codex-workflow-v2 2.0.0-alpha.4 → 2.0.0-alpha.6

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 (76) hide show
  1. package/README.md +86 -10
  2. package/dist/src/alpha6/adoption.d.ts +55 -0
  3. package/dist/src/alpha6/adoption.js +920 -0
  4. package/dist/src/alpha6/adoption.js.map +1 -0
  5. package/dist/src/alpha6/handoff.d.ts +39 -0
  6. package/dist/src/alpha6/handoff.js +975 -0
  7. package/dist/src/alpha6/handoff.js.map +1 -0
  8. package/dist/src/alpha6/journal.d.ts +30 -0
  9. package/dist/src/alpha6/journal.js +369 -0
  10. package/dist/src/alpha6/journal.js.map +1 -0
  11. package/dist/src/alpha6/milestone.d.ts +49 -0
  12. package/dist/src/alpha6/milestone.js +1049 -0
  13. package/dist/src/alpha6/milestone.js.map +1 -0
  14. package/dist/src/alpha6/plan-risk.d.ts +32 -0
  15. package/dist/src/alpha6/plan-risk.js +847 -0
  16. package/dist/src/alpha6/plan-risk.js.map +1 -0
  17. package/dist/src/alpha6/remediation.d.ts +20 -0
  18. package/dist/src/alpha6/remediation.js +748 -0
  19. package/dist/src/alpha6/remediation.js.map +1 -0
  20. package/dist/src/alpha6/review.d.ts +46 -0
  21. package/dist/src/alpha6/review.js +785 -0
  22. package/dist/src/alpha6/review.js.map +1 -0
  23. package/dist/src/alpha6/store-sidecars.d.ts +35 -0
  24. package/dist/src/alpha6/store-sidecars.js +281 -0
  25. package/dist/src/alpha6/store-sidecars.js.map +1 -0
  26. package/dist/src/cli.js +88 -19
  27. package/dist/src/cli.js.map +1 -1
  28. package/dist/src/contracts.d.ts +259 -0
  29. package/dist/src/git.js +2 -1
  30. package/dist/src/git.js.map +1 -1
  31. package/dist/src/index.d.ts +2 -0
  32. package/dist/src/reviewer.d.ts +6 -1
  33. package/dist/src/reviewer.js +145 -32
  34. package/dist/src/reviewer.js.map +1 -1
  35. package/dist/src/state/lock.d.ts +1 -0
  36. package/dist/src/state/lock.js +7 -1
  37. package/dist/src/state/lock.js.map +1 -1
  38. package/dist/src/state/store.d.ts +39 -1
  39. package/dist/src/state/store.js +127 -1
  40. package/dist/src/state/store.js.map +1 -1
  41. package/dist/src/version.d.ts +1 -1
  42. package/dist/src/version.js +1 -1
  43. package/dist/src/workflow.d.ts +78 -8
  44. package/dist/src/workflow.js +1312 -74
  45. package/dist/src/workflow.js.map +1 -1
  46. package/docs/autonomy-guardrails.md +143 -0
  47. package/docs/decisions.md +23 -0
  48. package/docs/delegated-approval.md +30 -5
  49. package/docs/development-flow.md +40 -1
  50. package/docs/pdf/codex-workflow-v2-architecture-ru.pdf +155 -136
  51. package/docs/pdf/codex-workflow-v2-chat-only-guide-ru.pdf +236 -223
  52. package/docs/pdf/codex-workflow-v2-technical-reference-ru.pdf +225 -206
  53. package/docs/project-memory.md +7 -0
  54. package/docs/release.md +7 -0
  55. package/docs/updating-existing-project.md +53 -5
  56. package/docs/validation-report.md +47 -34
  57. package/package.json +1 -1
  58. package/plugins/codex-workflow-gateway/references/protocol.md +150 -6
  59. package/plugins/codex-workflow-gateway/skills/codex-workflow-gateway/SKILL.md +16 -1
  60. package/references/git-policy.md +5 -2
  61. package/references/state-machine.md +36 -0
  62. package/references/validation-and-review.md +28 -1
  63. package/roles/delivery-coordinator.md +11 -0
  64. package/roles/independent-reviewer.md +3 -0
  65. package/roles/technical-planner.md +7 -0
  66. package/roles/worker.md +4 -0
  67. package/schemas/adoption-posture-event.schema.json +129 -0
  68. package/schemas/corrective-decision-event.schema.json +55 -0
  69. package/schemas/corrective-plan-audit.schema.json +20 -0
  70. package/schemas/milestone-scope-change-event.schema.json +68 -0
  71. package/schemas/milestone-transaction-journal.schema.json +95 -0
  72. package/schemas/plan-risk-audit-event.schema.json +90 -0
  73. package/schemas/remediation-event.schema.json +53 -0
  74. package/schemas/reviewer-attestation-event.schema.json +49 -0
  75. package/schemas/step-review-event.schema.json +74 -0
  76. package/schemas/task-handoff-event.schema.json +116 -0
package/docs/decisions.md CHANGED
@@ -57,3 +57,26 @@ This document closes the requirement gaps identified during the V2 design review
57
57
  both actors and the policy hash; revocation blocks future uses. This is an additive schema
58
58
  2 entity and optional authorization metadata, so existing schema 2 projects require no
59
59
  migration. It is local policy evidence, not a cryptographic identity signature.
60
+ 11. **Core-owned Step commit.** `task run` dispatches a Worker that leaves changes
61
+ uncommitted. For an active Step, `next` returns the exact `task step-complete` transition
62
+ and Step ID. That transition validates history and allowed paths, runs checks, creates
63
+ the atomic commit, and records evidence. A manual Worker commit is unrecorded history and
64
+ fails closed without changing persisted Task state. This changes navigation and
65
+ diagnostics only; state schema 2 and protocol 1 remain unchanged.
66
+ 12. **Autonomous correction guardrail.** The initial Plan must make migration,
67
+ concurrency, restart/replay, crash-window, and provider risks visible. After two failed
68
+ independent reviews, another corrective Plan requires a distinct Auditor covering every
69
+ latest finding. The audit is append-only artifact evidence; no Task state field or schema
70
+ change is required.
71
+ 13. **Content-only context refresh.** A delegate may compose reconcile, approval, knowledge
72
+ rebind, and execution reauthorization only when the approved source classification is
73
+ identical and only content hashes changed. Core validates both delegated transitions
74
+ before writing. Source-set, category, scope, authority, gap, or conflict changes stay on
75
+ the ordinary visible approval path. State schema 2 and protocol 1 remain unchanged.
76
+ 14. **Autonomous chat and closure boundary.** A Milestone coordinator owns orchestration and
77
+ final acceptance while each required Task uses a dedicated user-visible Task chat.
78
+ `next` exposes the Milestone completion contract, and delegated acceptance retains the
79
+ delegate actor and exact state-bound MSA code.
80
+ 15. **Safe update preflight.** Dependency updates begin with a read-only preflight requiring
81
+ a clean checkout, no running Step, and no active writer lease. It does not install,
82
+ migrate, or mutate project state.
@@ -52,6 +52,13 @@ delegation.transition
52
52
  acceptance still requires the current `MSA-*` code, preserving the revision/hash/HEAD binding;
53
53
  the pre-issued grant replaces only the later human-message requirement.
54
54
 
55
+ Alpha.6 does not widen this allow-list. Delegated approval does not authorize:
56
+
57
+ - `state adoption-apply`
58
+ - `milestone scope-change-prepare`
59
+ - `milestone scope-change-apply`
60
+ - any replacement human gate for Milestone membership repair or scope decisions
61
+
55
62
  ## Starting a delegate chat
56
63
 
57
64
  A grant does not start an agent and is not attached to a Codex chat automatically. Open a new
@@ -74,6 +81,10 @@ scope changes are not approval transitions: the delegate stops and asks the user
74
81
  Independent Reviewer roles may implement or review work, but the coordinating delegate alone
75
82
  uses the grant and passes `--delegation-grant` to the Core transition.
76
83
 
84
+ This matters more in alpha.6 because Milestone scope changes are explicitly journaled,
85
+ human-only lifecycle actions. A delegate may continue ordinary Milestone execution only inside
86
+ the already approved scope.
87
+
77
88
  ### Milestone delegate prompt
78
89
 
79
90
  Use project scope when the Milestone does not exist yet. An existing Milestone and its linked
@@ -99,8 +110,9 @@ project, status active, delegate, scope, transitions и expiresAt. Не созд
99
110
  вернул exact delegatedApprovalOptions для этого DGR-ID и transition; actor
100
111
  всегда agent:deputy, никогда user.
101
112
 
102
- Required Tasks выполняй последовательно. Для каждой Task можешь создать
103
- отдельный Codex-чат, передав ему Task delegate prompt, тот же actor и DGR-ID;
113
+ Required Tasks выполняй последовательно. Для каждой Task обязательно создай
114
+ отдельный пользовательский Codex-чат, передав ему Task delegate prompt, тот же actor и DGR-ID.
115
+ Milestone-чат не реализует Steps и не накапливает fix-loop всех Tasks;
104
116
  не запускай два writer на одном checkout. Worker и Reviewer не используют
105
117
  grant: approval-команды выполняет только delegate-координатор после их evidence.
106
118
 
@@ -135,19 +147,32 @@ Authorization выполняй только когда текущий next со
135
147
  delegatedApprovalOptions для DGR-ID и task.execution_authorize; используй
136
148
  actor agent:deputy и --delegation-grant, не записывай actor user.
137
149
 
138
- Далее следуй штатному lifecycle: один Step - один writer lease - один commit,
139
- checks и evidence. Worker не использует grant. При изменении Knowledge Map
150
+ Далее следуй штатному lifecycle: один Step - один writer lease. Worker меняет
151
+ только разрешённые файлы и оставляет их uncommitted; затем координатор вызывает
152
+ exact `task step-complete` из `next`, а core выполняет checks, создаёт commit и
153
+ записывает evidence. Worker не использует grant. При изменении Knowledge Map
140
154
  выполни reconcile; approve разрешён только при exact project_memory.approve
141
155
  option этого project-scoped grant. Затем knowledge-rebind и новая authorization.
156
+ Если next содержит exact `contextRefresh` для того же grant, можешь вместо четырёх
157
+ команд выполнить `task context-refresh`; при любом изменении source set,
158
+ category/authority, gaps или conflicts используй обычный видимый процесс.
142
159
 
143
160
  После submit запусти отдельный Independent Reviewer; Reviewer не использует
144
- grant и не исправляет код. Выполни допустимый fix-loop. Final acceptance делай
161
+ grant и не исправляет код. После второго failed review не запускай очередной
162
+ патч: получи отдельный corrective Plan audit, охватывающий все последние findings,
163
+ и передай его через `--corrective-audit-file`. Продолжай только при
164
+ `decision=continue-fix`; остальные решения верни пользователю/координатору.
165
+ Final acceptance делай
145
166
  только при exact task.final_accept option для DGR-ID, затем штатный merge.
146
167
  Если option отсутствует, grant истёк, scope не совпал или требуется смысловое
147
168
  решение пользователя - остановись. В конце покажи Task status, commits, checks,
148
169
  review и delegated authorization event.
149
170
  ```
150
171
 
172
+ Milestone coordinator waits for the dedicated Task chat to return its terminal Task status
173
+ and merge evidence before starting the next required Task. Internal subagents inside one
174
+ oversized Milestone chat are not a substitute for this user-visible Task boundary.
175
+
151
176
  After autonomous work, inspect the recorded events and revoke a broad grant when it is no
152
177
  longer needed. Revocation does not erase completed approvals.
153
178
 
@@ -21,10 +21,25 @@ Materialization requires an observable outcome, scope, acceptance criteria, and
21
21
  blocking unknowns. No Task identifier or branch exists before this gate. Task authorization
22
22
  is hash-bound to Brief and Plan. Later Plan changes supersede it.
23
23
 
24
+ In alpha.6, execution authorization also requires a current Plan Risk Audit bound to the same
25
+ Brief, Plan, Knowledge Map, and exact Step set. For existing schema 2 projects upgraded into
26
+ alpha.6, execution additionally requires adoption posture first; remaining legacy scope then
27
+ uses a bootstrap audit over the preserved non-`completed`, non-`skipped` Steps only.
28
+ The audit names a Plan author and independent auditor, binds each guarded failure mode to
29
+ exact executable evidence, and blocks authorization on `split-required` or `stop-escalate`.
30
+
24
31
  Local execution creates `codex/task-<id>-<slug>` from a clean base only after authorization.
25
32
  An externally owned checkout must already use a dedicated non-base branch. The core never
26
33
  creates or removes external worktrees. Each Step declares allowed writes, dependencies, and
27
- checks; unexpected paths or failed checks block its atomic commit.
34
+ checks. `task run` dispatches exactly one Step and returns a writer lease. The Worker changes
35
+ only allowed files and leaves them uncommitted. Repository-level `next` then returns the exact
36
+ `task step-complete` transition for the active Step. That core transition runs checks, stages
37
+ the allowed changes, creates the atomic Step commit, and records evidence. Unexpected paths,
38
+ failed checks, or any manual/unrecorded Worker commit block completion.
39
+
40
+ If the current Plan Risk Audit marks the Step for strict review, the atomic commit is still
41
+ created by core, but the Step remains non-terminal and `next` routes to `task step-review`
42
+ until commit-bound strict review and reviewer attestation pass.
28
43
 
29
44
  After a Step changes approved project knowledge, the Delivery Coordinator reconciles and
30
45
  reapproves the Project Knowledge Map, then runs `task knowledge-rebind` between Steps. The
@@ -35,12 +50,27 @@ active Worker Step, a no-op binding, an invalid knowledge target, or a modified
35
50
  artifact. After the user authorizes the rebound Plan, execution resumes in the existing
36
51
  workspace; if all Steps are complete, the next action is submission.
37
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.
57
+
38
58
  Submission requires a clean, auditable Task history and records evidence for the exact
39
59
  Task head. `task review-launch` starts a separate read-only reviewer. A passing fresh review
40
60
  permits Result creation. Human final acceptance binds Brief, Plan, Result, evidence, and
41
61
  the accepted head. Base advancement forces synchronization, checks, review, and acceptance
42
62
  to be repeated before merge.
43
63
 
64
+ The Technical Planner performs a risk review before authorization. Migration work includes a
65
+ populated forward-upgrade check; concurrent state includes deterministic races; restart,
66
+ replay, and crash claims include restart/crash-window evidence; provider work includes
67
+ failure injection and hidden-default verification. After two failed independent reviews,
68
+ another Plan requires a distinct corrective Auditor and `--corrective-audit-file`. Only a
69
+ `continue-fix` audit may continue; replan, split, and stop decisions return to coordination.
70
+ For guarded alpha.6 remediation, a third ordinary retry is blocked until a current
71
+ `task corrective-decision` exists for the same Step and Plan binding. If that corrective
72
+ attempt fails review, the third failure is a hard stop and no fourth run is permitted.
73
+
44
74
  Execution authorization and final acceptance use the human path by default. If the user has
45
75
  previously issued an active delegation grant for the exact transition and scope, the named
46
76
  delegate may perform that transition with `--delegation-grant`. The event keeps the delegate
@@ -63,6 +93,11 @@ and prevents new linked Tasks from starting. A Task that has started cannot be r
63
93
  it can be retained as waived/cancelled with history and reason. Tasks already in progress
64
94
  may finish while an amendment awaits authorization.
65
95
 
96
+ After the initial empty planning posture, alpha.6 does not use ordinary `milestone plan-set`
97
+ for scope changes. It uses human-only `milestone scope-change-prepare` and
98
+ `milestone scope-change-apply`, with journaled recovery across `state.json`, `plan.json`, and
99
+ `scope-change-events.jsonl`.
100
+
66
101
  A Milestone has no integration branch. Validation requires all required Tasks to be
67
102
  `merged`, checks the current clean base branch, and writes evidence plus Result. Final
68
103
  acceptance binds those artifacts to the unchanged base HEAD. Cancellation records a reason
@@ -87,6 +122,10 @@ With an eligible `milestone.final_accept` grant, `next` additionally returns
87
122
  turn because the earlier grant-issuance turn is the controlling user decision. Without such
88
123
  an option, the ordinary later-message human gate remains mandatory.
89
124
 
125
+ The Milestone coordinator keeps implementation out of its long-lived context: every required
126
+ Task runs in a dedicated user-visible Task chat. The Milestone chat owns ordering, exact
127
+ delegated transitions, merge observation, cross-Task validation, and final acceptance.
128
+
90
129
  ## Responsibility boundaries
91
130
 
92
131
  | Participant | Responsible for | Cannot decide |