You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/superpowers/plans/2026-08-06-runtime-correctness-remediation.md
+7-8Lines changed: 7 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@
17
17
-`scripts/lib/background-worker.mjs`: spawn the private worker with bounded protected stdio and verify/reap startup.
18
18
-`scripts/zcode-companion.mjs`: constant `invoke`/`invoke-choice` entrypoints, ordinary output, reconciliation entry, and orchestration.
19
19
-`hooks/user-prompt-hook.mjs`: record original prompt and authorization facts without emitting a secret.
20
-
-`.codex-plugin/plugin.json` and `skills/*/SKILL.md`: explicitly load hooks and use only constant direct commands.
20
+
-`hooks/hooks.json`, `.codex-plugin/plugin.json`, and `skills/*/SKILL.md`: use Codex's default hook discovery without a redundant manifest override and use only constant direct commands.
21
21
-`scripts/lib/prompts.mjs`: separate trusted Rescue objective from untrusted Git evidence.
22
22
-`scripts/lib/recovery.mjs`: reconcile owned nonterminal jobs from persisted ZCode turn boundaries.
23
23
-`scripts/lib/state.mjs` and `scripts/lib/job-control.mjs`: persist recovery fields and command-specific default selection.
Expected: failures show there is no active-turn lookup, public invocation still requires FD3/FD4, hooks are undeclared, and pending-choice storage is absent.
58
+
Expected: failures show there is no active-turn lookup, public invocation still requires FD3/FD4, default hooks are not discovered, and pending-choice storage is absent.
59
59
60
60
-[ ]**Step 3: Implement the exact active-turn and prompt parser boundary**
61
61
@@ -77,7 +77,7 @@ Make `invoke <command>` and `invoke-choice <command> <enum>` read `CODEX_THREAD_
77
77
78
78
-[ ]**Step 5: Update installed plugin contracts**
79
79
80
-
Declare `"hooks": "./hooks/hooks.json"`. Replace each public Skill's FD instructions with a constant command such as:
80
+
Place registrations at the default `hooks/hooks.json` path and omit the optional manifest hook-path override. Replace each public Skill's FD instructions with a constant command such as:
@@ -154,7 +154,7 @@ Assert that accepted sends persist `inputId`, `startRevision`, and `beforeMessag
154
154
155
155
-[ ]**Step 2: Write the failing real-worker-crash test**
156
156
157
-
Start a production background worker against the persistent fake ZCode peer, wait until the job is `running` with a persisted boundary, kill the worker process, change the peer to completed/stopped/missing variants, then invoke status/result/start in a new companion process. Assert completed becomes succeeded with only post-boundary output, stopped becomes cancelled, and missing/ambiguous becomes terminal failed; no case remains running.
157
+
Start a production background worker against the persistent fake ZCode peer, wait until the job is `running` with a persisted boundary, kill the worker process, change the peer to completed/stopped/missing/ambiguous variants, then invoke status/result/start in a new companion process. Assert completed becomes succeeded with only post-boundary output, stopped becomes cancelled, and missing becomes failed. Ambiguous or known-active work must retain its guard unless `session/stop` is acknowledged; a failed stop remains retryable.
158
158
159
159
-[ ]**Step 3: Verify RED**
160
160
@@ -166,11 +166,11 @@ Expected: recovery fields are rejected or absent, selection chooses the latest a
166
166
167
167
-[ ]**Step 4: Implement recovery under the cancellation lock**
168
168
169
-
`reconcileOwnedJobs({ store, dataRoot, workspace, ownerSessionId, createClient })` lists only owned nonterminal records. For each record, hold `withJobCancellationLock`, restore broker ownership, use `session/list` to establish existence and `session/read` for state/messages, compare the persisted input/revision/before-message boundary, and transition exactly once. Coordinate `cancelling` with the same lock. On unsafe ambiguity, persist a bounded recovery error and terminal `failed` status.
169
+
`reconcileOwnedJobs({ store, dataRoot, workspace, ownerSessionId, createClient })` lists only owned nonterminal records. For each record, hold `withJobCancellationLock`, prove the exact worker lease is orphaned, restore broker ownership, use `session/list` to establish existence and `session/read` for state/messages, compare the persisted input/revision/before-message boundary, and transition exactly once. Coordinate `cancelling` with the same lock. On unsafe ambiguity, attempt bounded `session/stop`; without acknowledgement, persist a bounded retry error and retain the nonterminal guard.
170
170
171
171
-[ ]**Step 5: Call reconciliation at every required entry**
172
172
173
-
Run it before starting new work and before status/result/cancel selection. Do not reconcile sibling-owned jobs. Ensure connection/release/close happens in `finally` and a recovery failure for one job cannot skip terminalizing that job or leak the broker client.
173
+
Run it before starting new work and before status/result/cancel selection. Do not reconcile sibling-owned jobs. Ensure connection/release/close happens in `finally`; a recovery failure for one job must not skip siblings, release an unsafe guard, or leak the broker client.
Assert package/check scripts include the installed bridge E2E contract, no Skill mentions FD3/FD4/caller secrets, hooks are declared, background launch is production-owned, real ZCode release E2E requires non-empty `ZCODE_REAL_E2E_MODEL`, and the complete companion invocation uses that model.
251
+
Assert package/check scripts include the installed bridge E2E contract, no Skill mentions FD3/FD4/caller secrets, default `hooks/hooks.json` is valid and auto-discovered without a manifest override, background launch is production-owned, real ZCode release E2E requires non-empty `ZCODE_REAL_E2E_MODEL`, and the complete companion invocation uses that model.
252
252
253
253
-[ ]**Step 2: Add the opt-in authenticated Codex Skill E2E**
254
254
@@ -280,4 +280,3 @@ Expected: all deterministic tests pass, only explicitly unqualified authenticate
Copy file name to clipboardExpand all lines: docs/superpowers/specs/2026-08-03-zcode-plugin-codex-design.md
+21-14Lines changed: 21 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,7 @@ Companion command interface
54
54
55
55
### Plugin package
56
56
57
-
The distributable contains `.codex-plugin/plugin.json`, eight skill directories, Codex hooks, prompts, schemas, a Node.js companion runtime, and local marketplace metadata. Skills are intentionally thin: they resolve the plugin root, validate user intent where interaction is necessary, invoke the companion, and faithfully present its output.
57
+
The distributable contains `.codex-plugin/plugin.json`, eight skill directories, Codex hooks, prompts, schemas, a Node.js companion runtime, and local marketplace metadata. Codex auto-discovers the default `hooks/hooks.json`; the optional manifest hook-path override is omitted. Skills are intentionally thin: they resolve the plugin root, validate user intent where interaction is necessary, invoke the companion, and faithfully present its output.
58
58
59
59
### Companion runtime
60
60
@@ -299,24 +299,31 @@ TrackedJob
299
299
300
300
State changes are atomic and validated. Terminal jobs never return to a running
301
301
state. `cancelling` is nonterminal; a failed stop may transition it back to
302
-
`running` while recording `lastCancelError`. Foreground work also receives a job
303
-
record so interruption does not erase its outcome. Multiple read-only reviews may
304
-
coexist in one workspace; only one writable rescue may run there by default to
305
-
prevent concurrent edits.
302
+
`running` while recording `lastCancelError`. Every foreground or background
303
+
Review, Adversarial Review, Rescue, and Transfer worker acquires and durably
304
+
claims an exact worker lease before discovery, history reads, Git inspection, or
305
+
ZCode session work. Foreground work therefore also receives a job record so
306
+
interruption does not erase its outcome. Multiple read-only reviews may coexist
307
+
in one workspace; only one writable rescue may run there by default to prevent
308
+
concurrent edits.
306
309
307
310
For every accepted ZCode turn, the job persists the minimum recovery boundary:
308
311
the `inputId`, accepted state revision, and the set of assistant message IDs
309
312
visible before send. On the next start, status, result, or cancel invocation,
310
313
the companion locks each owned nonterminal job, reconnects the broker, restores
311
314
ownership, and reconciles through `session/read` and, when needed,
312
-
`session/list`. A remotely completed turn extracts only assistant output beyond
313
-
the persisted boundary, writes the result artifact, and transitions to
314
-
`succeeded`. A stopped/cancelled turn becomes `cancelled`; a missing session,
315
-
ambiguous boundary, incompatible state, or other condition that cannot be
316
-
safely resumed becomes an explicit terminal `failed` recovery outcome. A
317
-
persisted `cancelling` job coordinates with the cancellation lock and either
318
-
finishes cancellation or records a terminal recovery failure. No crash may
319
-
leave an owned job permanently `running`.
315
+
`session/list`. A remotely completed turn with a complete boundary extracts only
316
+
assistant output beyond that boundary, writes the result artifact, and becomes
317
+
`succeeded` even if local status was `cancelling`. A remotely paused/stopped turn
318
+
becomes `cancelled`; a proven missing or terminal-error session becomes
319
+
`failed`. Known active or protocol-ambiguous sessions receive a best-effort
320
+
`session/stop`; only an acknowledged stop permits terminalization. If stop is
321
+
not acknowledged, recovery retains the nonterminal job and writable guard with
322
+
a bounded error so a later cancellation can retry. A live exact lease is never
323
+
reconciled away; an orphan claimed queued job fails safely, while a legacy
324
+
lease-less queued record receives a conservative bounded stale grace period.
325
+
Orphan Transfer jobs stop a known imported session before failing; without a
326
+
known session they may fail safely because no mutating turn was sent.
320
327
321
328
## Model and Thought-Level Selection
322
329
@@ -411,7 +418,7 @@ The CLI discovery order is:
411
418
412
419
The runtime requires ZCode CLI 0.16.1 or newer. Discovery results may be cached with their version and observation time, but every launch verifies that the resolved target still exists. A JavaScript entrypoint is launched through the current Node executable; a native executable is launched directly.
413
420
414
-
The broker starts lazily for the first active session and is reused while healthy. Codex lifecycle hooks release session ownership and stop an idle broker. Cleanup must not stop sessions or jobs owned by sibling Codex sessions. After an abnormal exit, the next start, status, result, or cancel invocation reconciles owned nonterminal jobs, including jobs left in `cancelling`, from persisted turn boundaries and ZCode session state while holding the job's recovery/cancellation lock.
421
+
The broker starts lazily for the first active session and is reused while healthy. Codex lifecycle hooks release session ownership and stop an idle broker. Cleanup must not stop sessions or jobs owned by sibling Codex sessions. After an abnormal exit, the next start, status, result, or cancel invocation reconciles owned nonterminal jobs, including jobs left in `cancelling`, from persisted worker leases, turn boundaries, and ZCode session state while holding the job's recovery/cancellation lock. Unsafe ambiguity retains the job guard until remote terminal/missing proof or acknowledged stop.
0 commit comments