codex-workflow-v2 2.0.0-alpha.7.2 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +23 -5
  2. package/dist/src/alpha6/milestone.d.ts +17 -0
  3. package/dist/src/alpha6/milestone.js +54 -0
  4. package/dist/src/alpha6/milestone.js.map +1 -1
  5. package/dist/src/alpha6/remediation.d.ts +18 -1
  6. package/dist/src/alpha6/remediation.js +458 -9
  7. package/dist/src/alpha6/remediation.js.map +1 -1
  8. package/dist/src/beta1/project-transaction.d.ts +52 -0
  9. package/dist/src/beta1/project-transaction.js +297 -0
  10. package/dist/src/beta1/project-transaction.js.map +1 -0
  11. package/dist/src/cli.js +23 -1
  12. package/dist/src/cli.js.map +1 -1
  13. package/dist/src/contracts.d.ts +39 -0
  14. package/dist/src/diagnostics.d.ts +11 -0
  15. package/dist/src/diagnostics.js +54 -0
  16. package/dist/src/diagnostics.js.map +1 -1
  17. package/dist/src/git.js +2 -5
  18. package/dist/src/git.js.map +1 -1
  19. package/dist/src/version.d.ts +1 -1
  20. package/dist/src/version.js +1 -1
  21. package/dist/src/version.js.map +1 -1
  22. package/dist/src/workflow.d.ts +11 -1
  23. package/dist/src/workflow.js +519 -56
  24. package/dist/src/workflow.js.map +1 -1
  25. package/docs/alpha7.2.1-remediation-recovery-brief.md +86 -0
  26. package/docs/autonomy-guardrails.md +3 -2
  27. package/docs/beta1-stabilization-brief.md +165 -0
  28. package/docs/delegated-approval.md +4 -3
  29. package/docs/development-flow.md +6 -4
  30. package/docs/project-memory.md +7 -5
  31. package/docs/release.md +9 -2
  32. package/docs/split-required-recovery.md +53 -0
  33. package/docs/stable-release-defect-register.md +268 -0
  34. package/package.json +2 -2
  35. package/plugins/codex-workflow-gateway/references/protocol.md +6 -2
  36. package/plugins/codex-workflow-gateway/skills/codex-workflow-gateway/SKILL.md +9 -2
  37. package/schemas/remediation-mode-recovery-event.schema.json +42 -0
  38. package/schemas/task.schema.json +3 -1
@@ -0,0 +1,86 @@
1
+ # Codex Workflow V2 2.0.0-alpha.7.2.1 — remediation recovery brief
2
+
3
+ ## Source and scope
4
+
5
+ Source release: `v2.0.0-alpha.7.2` at
6
+ `1d5b09f0116ea241b9b5f71c0fa3320ac4318891`.
7
+
8
+ This is a narrow lifecycle patch. It does not change product scope, Milestone
9
+ semantics, the three-attempt guarded-review limit, or historical events in
10
+ place. `signal_v4` is read-only evidence and must be replayed only from a copy
11
+ of its workflow state.
12
+
13
+ ## Reproduced defects
14
+
15
+ ### D1 — recovered third attempt is recorded as ordinary
16
+
17
+ After two ordinary failures, an authorized `continue-fix`, a Knowledge-only
18
+ Plan rebind, and alpha.7.2 corrective recovery, `task run` correctly permits
19
+ attempt ordinal 3. If that run later fails checks or strict review, the failure
20
+ writer loses the recovery binding and appends remediation ordinal 3 with
21
+ `mode=ordinary`. The same Core then rejects its own event as `STATE_CORRUPT`.
22
+
23
+ Exact production evidence:
24
+
25
+ - Task `TASK-01M00W190K3V3HM68Q3QVSH1AY`;
26
+ - Step `STEP-002-FORMALIZATION-CONTRACTS`;
27
+ - corrective decision `CRD-01M011B4MM5R1FZG2DSDRHVXJ4`;
28
+ - recovery `CDR-01M01ST9ENGH4F3W5TRJ9EC53C`;
29
+ - malformed remediation `RME-01M01TBQ4P5KR24J51WTMT79DY`;
30
+ - ordinal `3`, stored mode `ordinary`, required effective mode `corrective`.
31
+
32
+ ### D2 — `next` advertises an impossible context refresh
33
+
34
+ With an active Step and Knowledge drift from its uncommitted allowed writes,
35
+ `next` may advertise delegated `task context-refresh`, while the transition
36
+ correctly rejects any refresh during `Step=in_progress`. The truthful action is
37
+ the active Step action (`task step-complete`, then strict review). Knowledge
38
+ refresh follows only after the Step becomes terminal.
39
+
40
+ ## Required behavior
41
+
42
+ 1. Every guarded failure writer (`checks-failed`, `review-failed`, and
43
+ `review-unverified`, including retry/idempotence paths) must preserve the
44
+ exact validated corrective-recovery binding and record ordinal 3 as
45
+ `corrective`.
46
+ 2. Alpha.7.2 legacy state with exactly the D1 shape must have one explicit,
47
+ append-only recovery transition. The original remediation event and its
48
+ hash chain remain byte-for-byte unchanged.
49
+ 3. The recovery event binds the exact Task, Step, Task revision, malformed
50
+ remediation ID/hash, corrective decision ID/hash, corrective recovery
51
+ ID/hash, ordinal, Plan hash, actor, and mode correction
52
+ `ordinary -> corrective`.
53
+ 4. Recovery validation and authority checks occur before the first write.
54
+ Failure is non-mutating; identical retry is idempotent; conflicting or
55
+ duplicate recovery fails closed.
56
+ 5. After recovery, `next` must expose the existing guarded hard stop with only
57
+ `split-required` and `stop-escalate`. A fourth remediation run remains
58
+ prohibited.
59
+ 6. Any other ordinal, mode, decision, Plan, event-chain, review evidence,
60
+ recovery evidence, actor/token, Task/Step status, or duplicate shape is not
61
+ recoverable.
62
+ 7. While a Step is active, `next` must return its executable Step action and
63
+ must not advertise `task context-refresh` or standalone Project Knowledge
64
+ work that the exact transition ordering rejects.
65
+
66
+ ## Deterministic evidence
67
+
68
+ - Future path: two failures → recovered continue-fix → run → failed checks and
69
+ failed/unverified strict-review variants → ordinal 3 is corrective. Failed
70
+ checks/review reach hard stop; unverified isolation permits only strict-review
71
+ retry for the same completion commit and never another run.
72
+ - Legacy path: copy exact malformed alpha.7.2 state → `next` advertises the
73
+ explicit recovery → recovery append → identical retry is idempotent →
74
+ original files unchanged except the new recovery sidecar → `next` advertises
75
+ hard stop, never `task run`.
76
+ - Negative cases cover mismatched IDs/hashes/revision/actor/token, missing or
77
+ ambiguous recovery, broken event chains, non-ordinal-3 events, and repeated
78
+ conflicting recovery.
79
+ - Navigation parity: active Step plus eligible Knowledge drift returns
80
+ `task step-complete`; after completion it returns strict review before any
81
+ context refresh.
82
+
83
+ ## Release boundary
84
+
85
+ Stop after full deterministic validation, exact disposable `signal_v4` replay,
86
+ and self-review. Do not tag, push, publish, or mutate `signal_v4`.
@@ -88,8 +88,9 @@ not a human approval, while auditor independence remains mandatory.
88
88
 
89
89
  ## Atomic context refresh
90
90
 
91
- When `next.contextRefresh` offers an exact option, a project-scoped delegate may run one
92
- composite transition:
91
+ When `next` returns top-level `action: task context-refresh` with an exact option, a
92
+ project-scoped delegate may run one composite transition and must not run standalone reconcile
93
+ first:
93
94
 
94
95
  ```text
95
96
  task context-refresh
@@ -0,0 +1,165 @@
1
+ # Codex Workflow V2 2.0.0-beta.1 Stabilization Brief
2
+
3
+ Status: implementation complete; release candidate awaiting user authorization for commit/tag/push/publish
4
+
5
+ Baseline: `v2.0.0-alpha.7.2.1` (`1214b4c`)
6
+
7
+ Primary evidence register: [stable-release-defect-register.md](stable-release-defect-register.md)
8
+
9
+ ## Objective
10
+
11
+ Produce one feature-frozen beta release that closes every confirmed workflow defect found during
12
+ the `signal_v4` Milestone 3 alpha.7 replay, resolves or evidence-closes the remaining validation
13
+ concurrency investigation, preserves every alpha.7 regression guard, and proves that a real agent can
14
+ recover a terminal `split-required` Task by creating a replacement Task without reviving or rewriting
15
+ the historical Task.
16
+
17
+ No intermediate npm version is published. `signal_v4` and its external workflow state are read-only
18
+ evidence. Workflow V2 is not used to organize this repository's implementation.
19
+
20
+ ## Release scope
21
+
22
+ ### B1 — Secret-safe lock recovery (`WF-STABLE-001`)
23
+
24
+ - `locks repair` must never expose a plaintext writer token in ordinary CLI JSON, logs, errors, or
25
+ snapshots.
26
+ - A repaired lease may expose only non-authorizing metadata and a token fingerprint.
27
+ - If ownership recovery needs a new credential, it must use an explicit one-time handoff boundary
28
+ rather than a reusable token in general diagnostics.
29
+
30
+ ### B2 — Terminal corrective routing and replacement (`WF-STABLE-002/003`)
31
+
32
+ - `split-required` and `stop-escalate` outrank Project Knowledge reconcile, approval, rebind, context
33
+ refresh, authorization, and Task run.
34
+ - `task knowledge-rebind` and `task context-refresh` reject these postures before their first write.
35
+ - A Project Knowledge change cannot detach a terminal corrective decision from its historical Plan.
36
+ - `next` must expose an explicit replacement route for `split-required`; `stop-escalate` remains a
37
+ hard stop.
38
+ - Replacement must be one journal-recoverable transition that:
39
+ - consumes one ready Task Discovery;
40
+ - materializes a new Task with a new ID and the same active Milestone;
41
+ - changes the old membership from `required` to `cancelled` with a reason;
42
+ - adds the replacement as `required` with an explicit relationship reason;
43
+ - marks the old Task `cancelled` without changing its Plan, Steps, review, remediation, corrective,
44
+ result, or evidence history;
45
+ - revokes the cancelled Task's writer lease in the same recoverable transaction;
46
+ - absorbs exact safe Plan-bound Knowledge drift through the active Milestone Autonomy Grant in
47
+ that transaction, so the replacement Task can be planned without a stranded standalone gate;
48
+ - supersedes Milestone execution authorization and increments membership revision;
49
+ - leaves no orphan Task or partial membership state after process interruption;
50
+ - is idempotently recoverable from its journal.
51
+ - Normal standalone Project Knowledge actions must identify a triggering Task only as diagnostic
52
+ provenance, never as implied Task authorization.
53
+ - When an exact delegated atomic context refresh is eligible, `next` must return it as the top-level
54
+ action and standalone reconcile must fail before writing; an agent cannot create an avoidable
55
+ human-approval gap by selecting the nested Project Knowledge sub-transition.
56
+
57
+ ### B3 — Update/base diagnostics and canonical recovery guidance (`WF-STABLE-004/005`)
58
+
59
+ - Update diagnostics must distinguish the current checkout from an active Milestone base branch and
60
+ report exact declared, locked, installed, current-branch, and base-branch workflow versions.
61
+ - Divergence must fail closed before lifecycle work continues and must recommend dependency-only
62
+ transport rather than merging product commits.
63
+ - Documentation must include one canonical `split-required` recovery prompt and exact ordering for
64
+ replacement, membership evolution, Milestone reauthorization, new Task planning, and execution.
65
+
66
+ ### B4 — Composite context-refresh durability (`WF-STABLE-006`)
67
+
68
+ - Project Knowledge reconcile/approval, Task Plan rebind, rebound risk-audit evidence, and execution
69
+ authorization must use a recoverable multi-file transaction.
70
+ - All semantic and authority checks happen before the first target write.
71
+ - Crash recovery is deterministic and idempotent at every write boundary.
72
+ - `doctor`, `status`, and `next` detect an incomplete transaction and return the exact recovery action;
73
+ no partial refresh is treated as authorized.
74
+
75
+ ### B5 — Deterministic maintainer validation (`WF-STABLE-007`)
76
+
77
+ - Reproduce or disprove shared-output contention between full validation commands.
78
+ - If confirmed, serialize destructive build/test output preparation or isolate per-run artifacts.
79
+ - Concurrent invocation must either complete independently or fail immediately with a clear,
80
+ non-secret diagnostic; it must not hang silently.
81
+ - Child processes and temporary resources are cleaned up after interruption.
82
+
83
+ ## Required deterministic evidence
84
+
85
+ 1. Exact `signal_v4` replay:
86
+ `split-required -> Knowledge Map 169 active -> next replacement -> replacement transaction -> old
87
+ Task immutable/terminal -> new required Task planning`.
88
+ 2. Negative rebind/context-refresh tests for `split-required` and `stop-escalate` proving zero writes.
89
+ 3. Replacement rejection tests for wrong Task, wrong Milestone, wrong decision, non-ready Discovery,
90
+ semantic Milestone changes, stale revisions, expired/wrong actor autonomy, corrupt sidecars, and
91
+ duplicate retries.
92
+ 4. Crash injection before and after every replacement and context-refresh transaction write.
93
+ 5. CLI/output scans proving writer tokens are absent.
94
+ 6. Base-version divergence tests for clean and dirty repositories and unrelated product commits.
95
+ 7. Concurrent validation reproduction with bounded completion.
96
+ 8. All existing unit, integration, milestone, alpha.6, alpha.7, packaging, plugin, downstream smoke,
97
+ release, and root regression checks.
98
+
99
+ ## Real-agent acceptance
100
+
101
+ Create a fresh disposable downstream project with isolated `CODEX_HOME`, workflow state, plugin root,
102
+ and a locally packed beta candidate. A real Delegate must complete:
103
+
104
+ 1. Discovery and initial Milestone assembly.
105
+ 2. A guarded Task with three failed strict reviews, `continue-fix`, and a terminal
106
+ `split-required` decision.
107
+ 3. A Project Knowledge change and human-style approval boundary.
108
+ 4. The exact replacement transition without rebind of the failed Task.
109
+ 5. Replacement Task implementation, review, merge, remaining required Task completion, Milestone
110
+ validation, and final acceptance.
111
+
112
+ The E2E is invalid if the harness injects lifecycle failures, edits external state, reuses a stale
113
+ plugin cache, bypasses `next`, or requires a fourth remediation attempt.
114
+
115
+ ## Final evidence
116
+
117
+ - Deterministic package suite: all beta.1 transaction, terminal-routing, Knowledge refresh,
118
+ diagnostics, concurrency, alpha.6, alpha.7, integration, Milestone, and workflow regressions pass.
119
+ - Crash replay covers rollback and dead-process roll-forward at every tested write boundary,
120
+ including deletion of the cancelled Task writer lease.
121
+ - Real-agent disposable run:
122
+ `test-runs/2.0.0-beta.1/replacement-e2e-final`.
123
+ - Historical Task `TASK-01M02N276D6AE83VBVRH17RDQY` ended `cancelled` at revision 18 and links to
124
+ replacement Task `TASK-01M02NMZZBVCA4TZKK6WG724RY`.
125
+ - Replacement Task passed its guarded Step review and independent final review, then merged as
126
+ `c8d45be7f3165731cf891a47e88a112f76d0119f`.
127
+ - Milestone `MS-01M02N1M9M1CT8RHYGSZH8ETHC` reached `accepted` revision 7; final `next` returned
128
+ repository `idle`.
129
+ - The run exposed one additional bounded UX defect: local replacement start initially required a
130
+ manual return from the cancelled Task branch to `main`. The final candidate makes local Task start
131
+ create its branch from the exact declared base ref even when another clean Task branch is checked
132
+ out, with a deterministic regression.
133
+
134
+ ## Non-goals
135
+
136
+ - Fixing the downstream `signal_v4` NUL validator in this repository.
137
+ - Deleting historical Milestones, Tasks, branches, chats, worktrees, or append-only evidence.
138
+ - Broadening delegated authority or removing human final acceptance.
139
+ - Publishing, tagging, pushing, or modifying `signal_v4` without separate user authorization.
140
+ - Declaring `2.0.0` stable before the new real `signal_v4` Milestone completes successfully.
141
+
142
+ ## Release gate
143
+
144
+ `2.0.0-beta.1` is recommended only when all confirmed findings are closed, every investigation is
145
+ resolved with evidence, deterministic and crash replay pass, the real-agent disposable Milestone
146
+ reaches final acceptance, an independent final audit has no unresolved material finding, and the
147
+ release diff contains no downstream product implementation.
148
+
149
+ ## Final audit and residual risks
150
+
151
+ No material requirement gap remains in the beta.1 scope. The final source audit confirmed that
152
+ authority checks precede replacement/context-refresh target writes, cancelled Task authority is
153
+ deleted inside the same recoverable transaction, terminal decisions outrank Knowledge navigation,
154
+ and ordinary CLI output contains no reusable writer credential.
155
+
156
+ Residual beta risks are bounded:
157
+
158
+ - the project journal is a local-process/local-filesystem recovery protocol, not a distributed
159
+ cross-host transaction service; cross-machine synchronization remains outside the package
160
+ contract;
161
+ - the final real-agent run encountered and safely recovered the clean-branch start precondition;
162
+ the final candidate fixes that behavior and covers it deterministically, but the entire long E2E
163
+ was not repeated solely for that Git convenience change;
164
+ - `2.0.0` stable remains gated on a successful new real `signal_v4` Milestone, as stated in the
165
+ non-goals.
@@ -160,9 +160,10 @@ exact `task step-complete` из `next`, а core выполняет checks, со
160
160
  записывает evidence. Worker не использует grant. При изменении Knowledge Map
161
161
  выполни reconcile; approve разрешён только при exact project_memory.approve
162
162
  option этого project-scoped grant. Затем knowledge-rebind и новая authorization.
163
- Если next содержит exact `contextRefresh` для того же grant, можешь вместо четырёх
164
- команд выполнить `task context-refresh`; при любом изменении source set,
165
- category/authority, gaps или conflicts используй обычный видимый процесс.
163
+ Если next возвращает top-level `action: task context-refresh` и exact `contextRefresh` для того же
164
+ grant, выполни только `task context-refresh`; не запускай перед ним standalone reconcile. Exact
165
+ Plan-declared supporting additions допустимы только когда их признал Core. При любом другом
166
+ изменении source set, category/authority, gaps или conflicts используй обычный видимый процесс.
166
167
 
167
168
  После submit запусти отдельный Independent Reviewer; Reviewer не использует
168
169
  grant и не исправляет код. После второго failed review не запускай очередной
@@ -50,10 +50,12 @@ active Worker Step, a no-op binding, an invalid knowledge target, or a modified
50
50
  artifact. After the user authorizes the rebound Plan, execution resumes in the existing
51
51
  workspace; if all Steps are complete, the next action is submission.
52
52
 
53
- When `next.contextRefresh` exposes an eligible project-scoped grant and content-only mode,
54
- `task context-refresh` may compose reconcile, delegated map approval, rebind, and delegated
55
- execution reauthorization. Core validates both approval transitions before writing and
56
- rejects any source-set, category, scope, authority, gap, or conflict change.
53
+ When `next` returns top-level `action: task context-refresh` with an eligible grant,
54
+ `task context-refresh` composes reconcile, delegated map approval, rebind, and delegated
55
+ execution reauthorization. Do not run standalone reconcile first. Core validates both approval
56
+ transitions before writing. It permits content-only drift and exact Plan-declared supporting-source
57
+ additions under Milestone autonomy; every unsafe source-set, category, scope, authority, gap, or
58
+ conflict change is rejected.
57
59
 
58
60
  Submission requires a clean, auditable Task history and records evidence for the exact
59
61
  Task head. `task review-launch` starts a separate read-only reviewer. A passing fresh review
@@ -30,12 +30,14 @@ definition, status, and evidence record, records the old/new binding, supersedes
30
30
  authorization, and cannot run while a Step is in progress. If local state is lost, the map
31
31
  is rebuilt from repository files.
32
32
 
33
- For delegated autonomy, repository `next` may expose `contextRefresh` when the stored map was
34
- active and inspection proves content-hash-only drift. `task context-refresh` then performs
33
+ For delegated autonomy, repository `next` returns top-level `action: task context-refresh` and an
34
+ exact `contextRefresh` option when the stored map was active and inspection proves eligible drift.
35
+ Do not run standalone reconcile first. `task context-refresh` then performs
35
36
  reconcile, delegated map approval, Task rebind, and delegated execution authorization while
36
- preserving the ordinary audit events. The command rejects new/removed sources, category,
37
- scope or authority changes, changed gaps, and conflicts. Those changes always remain visible
38
- for normal classification and approval.
37
+ preserving the ordinary audit events. In addition to content-only drift, a Milestone Autonomy Grant
38
+ may admit one or more exact Plan-declared supporting sources. The command rejects removed,
39
+ undeclared, canonical, category/scope/authority-changing, gap-changing, and conflicting sources.
40
+ Those changes remain visible for normal classification and approval.
39
41
 
40
42
  ## Codebase graph
41
43
 
package/docs/release.md CHANGED
@@ -20,14 +20,21 @@ The downstream smoke packs the actual tarball, installs it into an empty tempora
20
20
  runs the packaged CLI handshake, and proves installation created none of `.codex`, `.tasks`,
21
21
  `.increments`, or `.memory-bank` in that project.
22
22
 
23
- For alpha.7, the release gate also relies on `npm run release:check` to fail if:
23
+ For beta.1, the release gate also relies on `npm run release:check` to fail if:
24
24
 
25
25
  - canonical entity schema 2 shapes drift;
26
26
  - protocol 1 compatibility is no longer additive;
27
27
  - the delegated transition allow-list expands;
28
28
  - schema-2 adoption is presented as `state migrate` instead of posture sidecars;
29
29
  - alpha.7 rescue, Milestone autonomy (including guarded content refresh), derived actor, or
30
- proof-obligation capabilities and schemas are absent from the packaged surface.
30
+ proof-obligation capabilities and schemas are absent from the packaged surface;
31
+ - terminal Task replacement, project-level transaction recovery, secret-safe lock diagnostics,
32
+ version/base diagnostics, or serialized maintainer validation are missing.
33
+
34
+ Full `npm test` and `npm run validate` invocations share destructive build outputs and are therefore
35
+ single-owner operations. A concurrent invocation fails immediately with
36
+ `VALIDATION_ALREADY_RUNNING`; retry it after the owner exits. Stale process locks are recovered
37
+ automatically.
31
38
 
32
39
  Tag releases as `v<package-version>`. The tag workflow verifies the tag/package match and
33
40
  uses npm trusted publishing with public access. For a public GitHub repository and public
@@ -0,0 +1,53 @@
1
+ # Canonical `split-required` recovery
2
+
3
+ Use this procedure only when the exact package-local `next` response identifies a terminal
4
+ `split-required` decision. Never rebind, refresh, replan, authorize, or resume the historical Task.
5
+
6
+ ## Delegate prompt
7
+
8
+ ```text
9
+ Continue the active Milestone through the package-local codex-workflow-v2 Core only.
10
+
11
+ 1. Run `codex-workflow status --repo .` and `codex-workflow next --repo .`. Treat every returned
12
+ revision and action as authoritative. Stop on corruption, stop-escalate, version divergence, or
13
+ an unexpected action. Do not edit workflow state or sidecars.
14
+ 2. Confirm that `next` reports the historical Task as `split-required`. Do not run
15
+ `task knowledge-rebind`, `task context-refresh`, `task plan-set`, `task authorize`, or `task run`
16
+ for that Task.
17
+ 3. If `next` says `discovery start`, create one thin replacement Discovery containing only the
18
+ failed Step's remaining outcome, exact acceptance, constraints, and explicit out-of-scope. Make
19
+ it `ready_to_materialize`, then run `status` and `next` again.
20
+ 4. When `next` returns `task replacement-materialize`, run that exact command with its old Task,
21
+ Discovery, and Milestone revisions, a precise replacement title, and the current authorized
22
+ actor. This single transaction must consume the Discovery, cancel/link the historical Task,
23
+ create/link the replacement Task, change both memberships, supersede Milestone execution
24
+ authorization, and leave the Milestone awaiting reauthorization. Do not perform a separate
25
+ scope change for these effects.
26
+ 5. Run `status` and `next`. Verify: old Task `cancelled`; old membership `cancelled`; new Task
27
+ `planning` and `replacementForTaskId` points to the old Task; new membership `required`;
28
+ Milestone `awaiting_execution_authorization`. If any relation is missing, stop and run `doctor`.
29
+ 6. Follow the exact `next` transition to reauthorize the changed Milestone. Run `status` and `next`
30
+ again. Do not reuse the historical Task's Plan or authorization.
31
+ 7. Plan the replacement Task from its own Brief, record the required Plan Risk Audit, authorize it,
32
+ prepare and claim its C1 handoff, and execute only the exact Step returned by `next`. Run
33
+ `status` and `next` after every state boundary.
34
+ 8. Complete review, final acceptance, merge, remaining required Tasks, Milestone validation, and
35
+ Milestone final acceptance through exact Core transitions. Never create a fourth remediation
36
+ attempt for the historical Task.
37
+ ```
38
+
39
+ ## Exact replacement command shape
40
+
41
+ ```sh
42
+ codex-workflow task replacement-materialize --repo . \
43
+ --id TASK-OLD \
44
+ --expected-revision OLD_TASK_REVISION \
45
+ --discovery DISC-REPLACEMENT \
46
+ --expected-discovery-revision DISCOVERY_REVISION \
47
+ --expected-milestone-revision MILESTONE_REVISION \
48
+ --title "Thin replacement title" \
49
+ --actor agent:milestone-coordinator
50
+ ```
51
+
52
+ Copy revisions from the same `next` response. If multiple ready Discoveries exist, Core refuses to
53
+ guess; choose the intended Discovery explicitly after reviewing its raw content.