codex-workflow-v2 2.0.0-alpha.7.2.1 → 2.0.0-beta.2

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 (39) hide show
  1. package/README.md +24 -5
  2. package/dist/src/alpha6/milestone.d.ts +27 -0
  3. package/dist/src/alpha6/milestone.js +152 -1
  4. package/dist/src/alpha6/milestone.js.map +1 -1
  5. package/dist/src/beta1/project-transaction.d.ts +52 -0
  6. package/dist/src/beta1/project-transaction.js +297 -0
  7. package/dist/src/beta1/project-transaction.js.map +1 -0
  8. package/dist/src/cli.js +239 -4
  9. package/dist/src/cli.js.map +1 -1
  10. package/dist/src/contracts.d.ts +20 -0
  11. package/dist/src/diagnostics.d.ts +11 -0
  12. package/dist/src/diagnostics.js +54 -0
  13. package/dist/src/diagnostics.js.map +1 -1
  14. package/dist/src/git.js +2 -5
  15. package/dist/src/git.js.map +1 -1
  16. package/dist/src/reviewer.d.ts +4 -0
  17. package/dist/src/reviewer.js +24 -7
  18. package/dist/src/reviewer.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 +28 -1
  23. package/dist/src/workflow.js +658 -54
  24. package/dist/src/workflow.js.map +1 -1
  25. package/docs/autonomy-guardrails.md +11 -3
  26. package/docs/beta1-stabilization-brief.md +165 -0
  27. package/docs/beta2-initial-assembly-navigation-brief.md +616 -0
  28. package/docs/delegated-approval.md +4 -3
  29. package/docs/development-flow.md +23 -6
  30. package/docs/project-memory.md +7 -5
  31. package/docs/release.md +16 -2
  32. package/docs/split-required-recovery.md +54 -0
  33. package/docs/stable-release-defect-register.md +597 -0
  34. package/docs/updating-existing-project.md +2 -0
  35. package/package.json +2 -2
  36. package/plugins/codex-workflow-gateway/references/protocol.md +62 -3
  37. package/plugins/codex-workflow-gateway/skills/codex-workflow-gateway/SKILL.md +53 -2
  38. package/references/state-machine.md +4 -1
  39. package/schemas/task.schema.json +3 -1
@@ -25,6 +25,8 @@ Current capability set:
25
25
  - `delegated-approval-v1`
26
26
  - `task-knowledge-rebind-v1`
27
27
  - `task-context-refresh-v1`
28
+ - `terminal-task-replacement-transaction-v1`
29
+ - `project-composite-transaction-journal-v1`
28
30
  - `corrective-plan-audit-v1`
29
31
  - `safe-update-preflight-v1`
30
32
  - `strict-reviewer-v1`
@@ -42,6 +44,7 @@ Current capability set:
42
44
  - `alpha6-adoption-posture-v1`
43
45
  - `alpha6-strict-review-rescue-v1`
44
46
  - `milestone-initial-assembly-v1`
47
+ - `milestone-initial-assembly-navigation-v2`
45
48
  - `milestone-autonomy-contract-v1`
46
49
  - `milestone-autonomous-membership-evolution-v1`
47
50
  - `task-c1-derived-worker-actor-v1`
@@ -73,7 +76,9 @@ version, canonical entity summaries, and the current sidecar baseline hash. Adop
73
76
 
74
77
  ## Worker Step completion and strict Step Review
75
78
 
76
- `task run` dispatches one Step and returns its writer token and Worker envelope. The Worker
79
+ `task run` dispatches one Step and returns a first-field `writerLeaseReceipt`, followed by the
80
+ credential-free lease metadata, Task state, and Worker envelope. Consume the receipt before the
81
+ remaining payload and retain its token only in working memory. The Worker
77
82
  must leave all changes uncommitted and must not stage, commit, amend, reset, rebase, or
78
83
  modify Git history.
79
84
 
@@ -82,11 +87,36 @@ While that Step is `in_progress`, repository-level `next` normally returns
82
87
  `workflow-core` ownership. The coordinator invokes that transition with the current revision
83
88
  and writer token. Core then runs configured checks, validates `allowedWrites`, stages the
84
89
  changes, creates the atomic commit, and records evidence.
90
+ When `next` also includes `gitMutationPolicy`, obtain bounded permission for that exact
91
+ Git-writing transition before the first call; do not probe and retry after a
92
+ `.git/index.lock` failure. For `task start`, the policy applies only when the coordinator
93
+ chooses `--workspace-owner local`.
94
+
95
+ When `next` also includes `writerTokenContract`, the coordinator must retain the active writer
96
+ lease from `writerLeaseReceipt` and pass it with the advertised option on the first transition call.
97
+ The contract never contains the token value. Do not print, persist, reconstruct, or replace the
98
+ token with a redacted fingerprint; stop before mutation when the active lease is unavailable.
99
+ Satisfy this contract separately from any `gitMutationPolicy` on the same response.
100
+
101
+ `codex-workflow <noun> [action] --help` is a read-only command-discovery route. It exits without
102
+ constructing workflow state or validating lifecycle inputs. Use exact option lists only when the
103
+ response says `exactOptionContractAvailable=true`; otherwise consult this packaged protocol. After
104
+ help, obtain a fresh `next` before invoking the lifecycle transition.
85
105
 
86
106
  If the current Plan Risk Audit marks that Step for strict review, the commit is still
87
107
  workflow-owned, but `next` then returns `action: "task step-review"` with the same `stepId`
88
108
  and the exact `completionCommit`. Canonical Step completion remains blocked until the strict
89
109
  review and reviewer attestation sidecars verify against that exact commit.
110
+ Invoke `task step-review` with the same lifecycle actor advertised by `next`
111
+ (`c1Handoff.claimant` or `requiredActor` when present). The isolated reviewer is launched
112
+ inside Core; do not substitute the reviewer identity into `--actor`. In claimed C1 posture,
113
+ `next.writerTokenContract` is mandatory for both `task step-review` and the later
114
+ `task review-launch`; pass the retained active lease on the first call of each exact action.
115
+
116
+ After submission, a pending Task review is advertised as `action: "task review-launch"`, not
117
+ `task review-record`. That compound route launches the read-only reviewer and atomically
118
+ records the returned review. If claimant-bound mutation is active, pass the same lifecycle
119
+ actor through `--actor`; reviewer identity remains internal to the route.
90
120
 
91
121
  An unrecorded commit is Git history drift. Stop instead of adding another commit or editing
92
122
  workflow state manually; recovery remains coordinator-controlled.
@@ -127,8 +157,16 @@ classifications. A planned new scanner-visible Knowledge file must be declared w
127
157
  directories, and inferred authority are not declarations; only Core may decide whether the final
128
158
  diff is eligible for delegated refresh.
129
159
 
130
- Use `task context-refresh` only when the same `next` response exposes `contextRefresh` for the
131
- exact grant. Pass Task revision, map revision, delegate actor, and grant ID. The composite
160
+ For every `task plan-set` navigation, consume `next.taskPlanContract` before building the Plan.
161
+ Its `requiredRequirementIds` and `requiredAcceptanceIds` are exact-membership preconditions, not
162
+ descriptive hints. Preserve each ID verbatim in the corresponding Plan array and use the returned
163
+ Brief hash plus Knowledge Map revision/hash as the planning binding. Missing or stale contract data
164
+ is a stop condition.
165
+
166
+ Use `task context-refresh` only when the same `next` response returns it as the top-level action and
167
+ exposes `contextRefresh` for the exact grant. Pass Task revision, map revision, delegate actor, and
168
+ grant ID. Never run standalone `project-memory reconcile` first; Core blocks that non-atomic route
169
+ when the exact delegated composite is available. The composite
132
170
  operation accepts content-hash-only drift and, under a Milestone Autonomy Grant, an exact
133
171
  supporting-source addition predeclared by the current execution-authorized Task Plan. Core checks
134
172
  the full fail-closed predicate; do not reconstruct it in the gateway. When `next` instead returns
@@ -162,11 +200,28 @@ claimed, only the claimant may mutate the Task, and lease-bound mutations must p
162
200
  bound writer token. Milestone-linked Tasks must be claimed before start, and handback is
163
201
  terminal and evidence-bound. When target actor is omitted, Core derives
164
202
  `agent:worker:<task-id>`. No thread id is required or accepted as authority.
203
+ The successful prepare response begins with `credentialHandoff`. Consume that receipt before the
204
+ Task/event/bundle payload, retain its token only in working memory, and pass it exactly once to the
205
+ declared `task claim --claim-token` action for the declared target actor. The later bundle remains
206
+ contextual and intentionally contains no second copy of the claim token.
207
+ The successful claim response then begins with `writerLeaseReceipt`. Retain that token only in
208
+ working memory. In claimed C1 posture, fresh `next` exposes `writerTokenContract` on `task run`;
209
+ pass the receipt token through its declared `--writer-token` option on the first run call. The
210
+ successful run returns the refreshed writer receipt for later lease-bound transitions.
165
211
 
166
212
  ## Milestone assembly, autonomy, and human gate
167
213
 
168
214
  During initial planning, materialize every linked Task and then call `milestone plan-set` once
169
215
  with the complete membership. Execution is blocked while reverse membership is incomplete.
216
+ Before Task 1 and between linked Tasks, follow top-level `next.action = "milestone initial-assembly"`.
217
+ Its `linked-task-assembly.commands` permit `discovery start` and `discovery materialize`; after the
218
+ first linked Task exists, the separate closing option permits `milestone plan-set`. If `status` or `next` fails, stop: never label
219
+ the gap expected and invoke `milestone plan-set` directly.
220
+
221
+ Every required navigation checkpoint is strictly sequential: start `status`, wait until its
222
+ terminal result is recorded, then start `next` and wait for its terminal result. Never issue the
223
+ pair concurrently or through a parallel tool call. The trusted transcript validator treats a
224
+ second invocation before the first terminal result as indeterminate release evidence.
170
225
 
171
226
  After that Plan, one human may prepare and grant a maximum-72-hour Milestone Autonomy Contract:
172
227
 
@@ -223,6 +278,10 @@ transition matches the requested command, with the named delegate as actor and t
223
278
  as `--delegation-grant`. The resulting authorization event records the grant and both actors.
224
279
  For `milestone.final_accept`, also pass the current `MSA-*` code; the existing grant replaces
225
280
  the later-message requirement, not the state binding.
281
+ Do not pass `--delegation-grant` to ordinary C1 handoff, claim, run, step-complete,
282
+ step-review, merge, or sync-base calls. Those transitions are not authorized by a Milestone
283
+ approval grant unless the same `next` response explicitly advertises an eligible grant for the
284
+ exact transition.
226
285
 
227
286
  Delegated approval does not cover adoption apply or the ordinary semantic Milestone scope-change
228
287
  path. Membership-only evolution requires the separate Milestone Autonomy Contract.
@@ -51,12 +51,59 @@ scanner category. Do not replace the path with a wildcard or directory, do not i
51
51
  authority, and do not claim delegated-refresh eligibility; Core decides eligibility from the
52
52
  resulting repository diff and current authorization state.
53
53
 
54
- When `next` exposes an exact delegated `contextRefresh`, use `task context-refresh` only for
55
- the returned Task/map revisions, actor, and grant. A source-set change is eligible only when
54
+ When `next.action` is `task plan-set` (including the corrective-audit variant), treat
55
+ `next.taskPlanContract` as the exact transition precondition. Copy every
56
+ `requiredRequirementIds` entry into Plan `requirements` and every `requiredAcceptanceIds` entry
57
+ into Plan `acceptance` as exact array members; semantic prose may be added but cannot replace those
58
+ IDs. Bind the Plan to the returned `briefHash` and active `knowledgeMap` revision/hash. Stop if the
59
+ contract is absent or conflicts with the current Task/Knowledge state.
60
+
61
+ When `next` returns top-level `action: task context-refresh`, use only that atomic action for
62
+ the returned Task/map revisions, actor, and grant. Do not run standalone `project-memory reconcile`
63
+ first: Core rejects it because it would create a human-approval gap and strand the Task. A
64
+ source-set change is eligible only when
56
65
  Core identifies it as a Plan-bounded supporting-source addition under the same Milestone
57
66
  Autonomy Grant. Never infer eligibility from the Plan yourself; if Core returns
58
67
  `contextRefreshBlocked.unsafeDifferences`, use the ordinary visible Knowledge Map flow.
59
68
 
69
+ When `next` reports terminal `split-required`, follow `docs/split-required-recovery.md` from the
70
+ installed package. The only valid continuation is the exact `task replacement-materialize`
71
+ transition (or creation of its one ready Discovery when requested). Never rebind, refresh, replan,
72
+ authorize, or resume the historical Task, and never emulate the membership changes manually.
73
+
74
+ When `next` returns `milestone initial-assembly`, execution is unavailable. Follow only the
75
+ advertised `linked-task-assembly.commands` (`discovery start` and `discovery materialize`) until all
76
+ intended linked Tasks exist. The closing `milestone plan-set` option appears only after at least one
77
+ linked Task exists; use it once with the complete membership. After every boundary, run `status`,
78
+ wait for its terminal success, and only then run `next`; never launch the checkpoint pair in
79
+ parallel or in one parallel tool batch. If either fails, stop; do not
80
+ describe the reverse-membership gap as expected and invoke a direct closing command.
81
+
82
+ When `next` includes `gitMutationPolicy`, obtain bounded permission for that exact Git-writing
83
+ transition before the first call. Do not probe and retry after a `.git/index.lock` failure.
84
+ For `task start`, the policy applies only when choosing `--workspace-owner local`; for
85
+ `task step-complete`, `task merge`, and `task sync-base`, the advertised transition itself
86
+ writes Git metadata.
87
+
88
+ When `next` includes `writerTokenContract`, treat it as an exact first-call precondition. Retain
89
+ the active writer lease from the first-field `writerLeaseReceipt` returned by `task run` and pass it using the advertised `option` for that
90
+ transition. The token is sensitive: never print, summarize, persist, or substitute a redacted
91
+ fingerprint. Stop before mutation if the active lease is unavailable. This input contract is
92
+ independent from `gitMutationPolicy`; satisfy both when both are present.
93
+
94
+ On successful `task handoff-prepare`, consume the first-field `credentialHandoff` before reading
95
+ the Task/event/bundle payload. Retain its one-time token only in working memory and use it exactly
96
+ once with the declared `action` and `option` for the declared `targetActor`. Successful `task claim`
97
+ returns a first-field `writerLeaseReceipt`; retain that lease and pass it to claimed `task run` when
98
+ the fresh `next.writerTokenContract` requires it. Successful `task run` returns the refreshed
99
+ `writerLeaseReceipt`; retain it only until Core releases that lease.
100
+ Never search later payload fields for either credential and never copy credentials into evidence.
101
+
102
+ Command discovery with `codex-workflow <noun> [action] --help` is read-only. Use it only when the
103
+ exact invocation syntax is not already available from `next` and this protocol. Consume declared
104
+ `requiredOptions` and `optionalOptions`; when `exactOptionContractAvailable=false`, consult the
105
+ packaged protocol instead of guessing. Help never replaces a fresh `next` before mutation.
106
+
60
107
  ## Product Or Workflow Graph Refresh
61
108
 
62
109
  1. Run `graph refresh-request --kind product|workflow --mode moderate`.
@@ -111,6 +158,9 @@ Never create, broaden, renew, or replace a grant from an agent's own judgment. N
111
158
  the delegate as the user. When `next` exposes an eligible option, pass its grant ID through
112
159
  `--delegation-grant` and use the exact delegate string as `--actor`. The core remains the
113
160
  authority for status, expiry, scope, transition, and revocation checks.
161
+ If the same `next` response does not expose an eligible option for that exact transition, do
162
+ not pass `--delegation-grant`. Ordinary C1 handoff, claim, run, step-complete, step-review,
163
+ merge, and sync-base do not inherit a Milestone approval grant.
114
164
 
115
165
  For delegated Milestone final acceptance, the current `MSA-*` code is still required, but a
116
166
  new user turn is not: the previously issued grant is the controlling decision. If no eligible
@@ -149,5 +199,6 @@ returns `safe=true` with a clean checkout, no running Step, and no active writer
149
199
  - A request changes before evidence is bound.
150
200
  - An action would make MCP or the local map authoritative project memory.
151
201
  - A requested mutation is not authorized by the package CLI state.
202
+ - A lifecycle `status` or `next` failed; do not continue with a different lifecycle mutation.
152
203
  - A human gate was emitted but the user has not approved its exact confirmation code in a
153
204
  later message and no exact eligible delegated approval option exists.
@@ -63,7 +63,10 @@ human turn boundary.
63
63
 
64
64
  During initial planning, all linked Tasks may be materialized before one complete
65
65
  `milestone plan-set`; execution remains blocked until every reverse membership is classified.
66
- After that boundary, semantic updates use human-only `milestone scope-change-prepare` and
66
+ `next` returns `milestone initial-assembly` before Task 1 and after every safe linked-Task
67
+ materialization, with explicit `discovery start` and `discovery materialize` commands. After at
68
+ least one linked Task exists, it also exposes the closing `milestone plan-set` command. Failed navigation is fail-closed and cannot be treated as an
69
+ expected assembly signal. After that boundary, semantic updates use human-only `milestone scope-change-prepare` and
67
70
  `milestone scope-change-apply`. A human-confirmed, expiring Milestone Autonomy Contract may
68
71
  use `milestone autonomy-evolve` only for membership changes while outcome, success signal,
69
72
  acceptance, checks, discovery, and base branch remain fixed. It may also approve Project Memory
@@ -52,6 +52,8 @@
52
52
  },
53
53
  "additionalProperties": false
54
54
  }
55
- }
55
+ },
56
+ "replacementForTaskId": { "type": ["string", "null"], "pattern": "^TASK-[0-9A-HJKMNP-TV-Z]{26}$" },
57
+ "replacedByTaskId": { "type": ["string", "null"], "pattern": "^TASK-[0-9A-HJKMNP-TV-Z]{26}$" }
56
58
  }
57
59
  }