codex-workflow-v2 2.0.0-alpha.3 → 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 (85) hide show
  1. package/README.md +104 -7
  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 +110 -23
  27. package/dist/src/cli.js.map +1 -1
  28. package/dist/src/contracts.d.ts +319 -1
  29. package/dist/src/delegation.d.ts +8 -0
  30. package/dist/src/delegation.js +155 -0
  31. package/dist/src/delegation.js.map +1 -0
  32. package/dist/src/git.js +2 -1
  33. package/dist/src/git.js.map +1 -1
  34. package/dist/src/index.d.ts +3 -0
  35. package/dist/src/index.js +1 -0
  36. package/dist/src/index.js.map +1 -1
  37. package/dist/src/reviewer.d.ts +6 -1
  38. package/dist/src/reviewer.js +145 -32
  39. package/dist/src/reviewer.js.map +1 -1
  40. package/dist/src/state/lock.d.ts +1 -0
  41. package/dist/src/state/lock.js +7 -1
  42. package/dist/src/state/lock.js.map +1 -1
  43. package/dist/src/state/store.d.ts +43 -1
  44. package/dist/src/state/store.js +140 -1
  45. package/dist/src/state/store.js.map +1 -1
  46. package/dist/src/ulid.d.ts +1 -1
  47. package/dist/src/ulid.js.map +1 -1
  48. package/dist/src/version.d.ts +1 -1
  49. package/dist/src/version.js +1 -1
  50. package/dist/src/workflow.d.ts +91 -13
  51. package/dist/src/workflow.js +1459 -76
  52. package/dist/src/workflow.js.map +1 -1
  53. package/docs/autonomy-guardrails.md +143 -0
  54. package/docs/decisions.md +30 -0
  55. package/docs/delegated-approval.md +189 -0
  56. package/docs/development-flow.md +53 -2
  57. package/docs/pdf/codex-workflow-v2-architecture-ru.pdf +426 -410
  58. package/docs/pdf/codex-workflow-v2-chat-only-guide-ru.pdf +778 -612
  59. package/docs/pdf/codex-workflow-v2-technical-reference-ru.pdf +526 -452
  60. package/docs/project-memory.md +7 -0
  61. package/docs/release.md +7 -0
  62. package/docs/updating-existing-project.md +141 -4
  63. package/docs/validation-report.md +47 -24
  64. package/package.json +1 -1
  65. package/plugins/codex-workflow-gateway/references/protocol.md +162 -5
  66. package/plugins/codex-workflow-gateway/skills/codex-workflow-gateway/SKILL.md +38 -3
  67. package/references/git-policy.md +5 -2
  68. package/references/state-machine.md +48 -0
  69. package/references/validation-and-review.md +28 -1
  70. package/roles/delivery-coordinator.md +11 -0
  71. package/roles/independent-reviewer.md +3 -0
  72. package/roles/technical-planner.md +7 -0
  73. package/roles/worker.md +4 -0
  74. package/schemas/adoption-posture-event.schema.json +129 -0
  75. package/schemas/authorization-event.schema.json +55 -0
  76. package/schemas/corrective-decision-event.schema.json +55 -0
  77. package/schemas/corrective-plan-audit.schema.json +20 -0
  78. package/schemas/delegation-grant.schema.json +69 -0
  79. package/schemas/milestone-scope-change-event.schema.json +68 -0
  80. package/schemas/milestone-transaction-journal.schema.json +95 -0
  81. package/schemas/plan-risk-audit-event.schema.json +90 -0
  82. package/schemas/remediation-event.schema.json +53 -0
  83. package/schemas/reviewer-attestation-event.schema.json +49 -0
  84. package/schemas/step-review-event.schema.json +74 -0
  85. package/schemas/task-handoff-event.schema.json +116 -0
@@ -30,6 +30,13 @@ 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
35
+ 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.
39
+
33
40
  ## Codebase graph
34
41
 
35
42
  The graph is an optional derived index, never the durable memory authority. The gateway asks
package/docs/release.md CHANGED
@@ -20,6 +20,13 @@ 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.6, the release gate also relies on `npm run release:check` to fail if:
24
+
25
+ - canonical entity schema 2 shapes drift;
26
+ - protocol 1 compatibility is no longer additive;
27
+ - the delegated transition allow-list expands;
28
+ - alpha.6 adoption is presented as `state migrate` instead of posture sidecars.
29
+
23
30
  Tag releases as `v<package-version>`. The tag workflow verifies the tag/package match and
24
31
  uses npm trusted publishing with public access. For a public GitHub repository and public
25
32
  package, npm trusted publishing generates provenance automatically. Publishing is never
@@ -19,7 +19,8 @@ gateway, но не удаляет и не пересоздаёт это сост
19
19
  Никогда не разрешайте агенту вручную редактировать, переносить или удалять внешний state.
20
20
  Команда миграции нужна только тогда, когда документация новой версии прямо сообщает о новой
21
21
  state schema. Совпадение `stateSchemaVersion` до и после обновления означает, что миграция не
22
- нужна.
22
+ нужна. Для alpha.6 при `stateSchemaVersion: 2` применяется не migration, а sidecar-only
23
+ adoption posture.
23
24
 
24
25
  ## 1. Подготовьте отдельный чат обновления
25
26
 
@@ -33,10 +34,12 @@ Codex и откройте в нужном проекте отдельный ча
33
34
  из npm: https://www.npmjs.com/package/codex-workflow-v2.
34
35
 
35
36
  Все команды выполняешь ты. Сначала прочитай AGENTS.md и определи Git root.
36
- До изменений запусти project-local gateway handshake, doctor, status и next;
37
+ До изменений запусти project-local gateway handshake, doctor, status, next и
38
+ read-only `update preflight`;
37
39
  зафиксируй текущую версию, protocolVersion, stateSchemaVersion, projectId,
38
- активные сущности и наличие writer lease. Если Worker сейчас выполняется,
39
- остановись без обновления.
40
+ активные сущности и наличие writer lease. Продолжай только если preflight
41
+ вернул safe=true: checkout чистый, running Step и active writer lease отсутствуют.
42
+ Иначе остановись без обновления и покажи blockers.
40
43
 
41
44
  Обнови только точную npm-зависимость и lock-файл, без диапазона версий.
42
45
  Не удаляй и не редактируй вручную $CODEX_HOME/workflow-state/v2.
@@ -62,6 +65,9 @@ plugin за пределами workspace. Это ожидаемая границ
62
65
  5. `projectId` совпадает со значением до обновления.
63
66
  6. Существующие Task/Milestone ID, revisions и terminal statuses сохранились.
64
67
  7. Персональный gateway обновлён из установленного пакета.
68
+ 8. `update preflight` до изменения подтвердил чистую lifecycle-границу.
69
+ 9. Для alpha.6 существующий schema 2 проект либо уже имеет `adoption-posture.jsonl`,
70
+ либо `next`/`status` требуют `state adoption-prepare` и затем `state adoption-apply`.
65
71
 
66
72
  Изменение `projectId`, исчезновение сущностей или ошибка unsupported state schema — причина
67
73
  остановиться. Не соглашайтесь на «починку» удалением state. Агент должен вернуть dependency к
@@ -92,6 +98,137 @@ handshake, doctor, status и next. Подтверди точную declared/inst
92
98
  нужно выполнить `scan/reconcile`, показать пользователю изменения классификации и получить
93
99
  approval, если он требуется.
94
100
 
101
+ ## 3.0. Alpha.6 adoption для существующего schema 2 проекта
102
+
103
+ Если проект уже вёлся на alpha.5 или другой schema 2 версии без alpha.6 posture, новый runtime
104
+ не разрешит execution-переходы, пока не будет записан adoption sidecar. Это нормальное
105
+ fail-closed поведение, а не повреждение state.
106
+
107
+ Порядок:
108
+
109
+ 1. `update preflight --repo .`
110
+ 2. `state adoption-prepare --repo .`
111
+ 3. Проверить returned baseline и `ADA-*` confirmation code
112
+ 4. `state adoption-apply --repo . --actor <human-actor> --confirmation-code <ADA-CODE>`
113
+
114
+ Граница должна быть безопасной:
115
+
116
+ - checkout чистый;
117
+ - нет `in_progress` Step;
118
+ - нет active writer lease;
119
+ - stale writer lease сначала чинится обычным repair-путём.
120
+
121
+ Alpha.6 adoption сохраняет:
122
+
123
+ - terminal Milestones со статусом `accepted` или `cancelled`;
124
+ - terminal Tasks со статусом `merged` или `cancelled`;
125
+ - completed и skipped Steps в активных Tasks вместе с их evidence.
126
+
127
+ Alpha.6 adoption не делает:
128
+
129
+ - не переписывает canonical entity JSON;
130
+ - не переоткрывает terminal-сущности;
131
+ - не прогоняет заново уже completed legacy Steps;
132
+ - не использует `state migrate`.
133
+
134
+ После adoption remaining legacy scope должен получить bootstrap Plan Risk Audit только для
135
+ оставшихся non-`completed` и non-`skipped` Step.
136
+
137
+ ## 3.1. При необходимости включите delegated approval
138
+
139
+ Delegated approval не включается автоматически после обновления. Существующие авторизации и
140
+ terminal-сущности не меняются, а `stateSchemaVersion` остаётся `2`. Пользователь один раз
141
+ подтверждает точную policy; после этого named delegate может выполнять только перечисленные
142
+ переходы до истечения срока или revocation.
143
+
144
+ Для заместителя, который должен планировать ещё не созданные Milestones и Tasks, нужен
145
+ ограниченный по времени project scope. Более узкий Milestone/Task scope безопаснее, когда ID
146
+ уже известен. Пример policy:
147
+
148
+ ```json
149
+ {
150
+ "principal": "user:owner",
151
+ "delegate": "agent:deputy",
152
+ "scope": { "kind": "project" },
153
+ "transitions": [
154
+ "project_memory.approve",
155
+ "milestone.execution_authorize",
156
+ "milestone.final_accept",
157
+ "task.execution_authorize",
158
+ "task.final_accept"
159
+ ],
160
+ "expiresAt": "<ISO-8601 UTC>"
161
+ }
162
+ ```
163
+
164
+ Промпт для выпуска grant:
165
+
166
+ ```text
167
+ Подготовь delegated approval policy для этого проекта: principal user:owner,
168
+ delegate agent:deputy, project scope, переходы project_memory.approve,
169
+ milestone.execution_authorize,
170
+ milestone.final_accept, task.execution_authorize и task.final_accept, срок до
171
+ <ДАТА_И_ВРЕМЯ_UTC>. Создай временный JSON вне репозитория и выполни только
172
+ delegation prepare. Покажи всю policy, projectId, policyHash и DGA-код, затем
173
+ остановись. Grant в этом же ответе не выпускай.
174
+ ```
175
+
176
+ После проверки ответьте отдельным сообщением:
177
+
178
+ ```text
179
+ Одобряю выпуск delegated approval grant для policy hash <POLICY_HASH>
180
+ с кодом <DGA-CODE>. Выпусти grant и покажи DGR-ID, scope, transitions,
181
+ expiresAt и revision.
182
+ ```
183
+
184
+ `delegation list` и `status` показывают grants. Для досрочной остановки автономности агент
185
+ выполняет `delegation revoke` от имени точного principal с текущей revision и причиной.
186
+ Revocation запрещает будущие использования, но не переписывает уже записанные события.
187
+
188
+ Важно: это локальная проверка policy и audit trail, а не криптографическая аутентификация
189
+ Codex-процесса. Любой процесс с доступом к локальному state и CLI может заявить строку
190
+ delegate. Поэтому project-wide grant должен быть короткоживущим, а секреты, платежи, реальные
191
+ торговые операции и иные необратимые действия требуют отдельных технических ограничений и не
192
+ должны полагаться только на delegated approval. Alpha.6 не расширяет allow-list transitions:
193
+ grant не даёт authority на adoption apply, Milestone scope change или другие новые
194
+ human-only guardrails.
195
+
196
+ ## 3.2. Запустите delegate в новом чате
197
+
198
+ Grant сам не запускает агента и не прикрепляется к существующему чату. После получения
199
+ `DGR-ID` откройте новый Local-чат в том же Codex Project. Новый чат нужен ещё и потому, что он
200
+ загрузит актуальную gateway-инструкцию. Передайте точные `delegate` и `DGR-ID`; `DGA-код`
201
+ больше не нужен.
202
+
203
+ Перед запуском проверьте выбор scope:
204
+
205
+ - новый Milestone или новая standalone Task с `AUTO` требуют project scope;
206
+ - существующий Milestone и его linked Tasks могут использовать Milestone scope;
207
+ - одна существующая Task может использовать Task scope;
208
+ - Knowledge Map approval доступен только project-scoped grant с
209
+ `project_memory.approve`.
210
+
211
+ Полные копируемые промпты для Milestone delegate и Task delegate находятся в
212
+ `docs/delegated-approval.md` и chat-only PDF. В обоих промптах delegate обязан сначала
213
+ выполнить `delegation show`, а каждый approval применять только при exact записи в текущем
214
+ `next.delegatedApprovalOptions`. Внутренние Worker и Independent Reviewer grant не используют:
215
+ его применяет координатор после получения их evidence.
216
+
217
+ Рекомендуемые названия чатов:
218
+
219
+ ```text
220
+ NN - M2 delegated coordinator
221
+ NN - M2/T1 delegated execution
222
+ NN - Standalone delegated task
223
+ ```
224
+
225
+ После завершения автономного окна попросите отдельный контрольный чат показать
226
+ `delegation list`, использованные authorization events и отозвать ненужный широкий grant.
227
+
228
+ Для Milestone delegate отдельный Task-чат обязателен для каждой required Task. Это сохраняет
229
+ пользовательский audit trail и не позволяет одному длинному Milestone-чату накапливать
230
+ реализацию, compaction и review всех Tasks.
231
+
95
232
  ## 4. Продолжите начатый Milestone или создайте следующий
96
233
 
97
234
  Terminal Milestone со статусом `accepted` остаётся закрытым. Для следующего результата нужно
@@ -1,28 +1,51 @@
1
1
  # V2 Alpha Validation Report
2
2
 
3
- Release candidate `2.0.0-alpha.3` was validated on 2026-08-12 with Node.js 24.17.0.
3
+ Release candidate `2.0.0-alpha.6` was validated through 2026-08-14 with Node.js 24.17.0.
4
4
 
5
- - TypeScript typecheck and build passed.
6
- - All 41 unit and integration tests passed. Coverage includes the complete Task lifecycle,
7
- a Project Knowledge Map change between Steps, preservation of completed Step evidence,
8
- mandatory reauthorization, the public `task knowledge-rebind` CLI route, no-op and active
9
- Worker rejection, current gateway capability negotiation, and rejection of deprecated
10
- state schema instead of migration.
11
- - Milestone scheduling now ignores unstarted Tasks with cancelled/waived or terminal
12
- membership paths. Final Milestone acceptance exposes a revision/hash/HEAD-bound human gate,
13
- rejects a wrong code, and regenerates its code after base advancement and revalidation.
14
- - Milestone amendments, graph binding, deterministic V1 snapshot, symlink rejection, writer
15
- leases, and strict reviewer fail-closed behavior also passed.
16
- - npm dry-run packaging produced `codex-workflow-v2-2.0.0-alpha.3.tgz` with runtime, schemas,
17
- roles, references, docs, and plugin source.
18
- - Downstream installation from that tarball and the packaged CLI handshake passed; the
19
- installation created none of the forbidden repository workflow directories.
20
- - Plugin validation and the repository release check passed for `2.0.0-alpha.3`.
21
- - The alpha.3 CLI read the existing Signal project state created by alpha.2 without migration:
22
- project ID and accepted Milestone 1 were preserved, while repository-level `next` returned
23
- `idle` instead of the historical cancelled Task.
5
+ - `npm run typecheck`, `npm run build`, `npm test`, `npm run validate`, `npm run plugin:check`,
6
+ `npm run smoke:downstream`, `npm run release:check`, and `npm run pack:check` passed in the
7
+ task evidence recorded for TASK-002.
8
+ - The final sequential full suite passed `81/81` on 2026-08-14.
9
+ - Plan Risk Audit coverage includes the combined `plan-set --risk-audit-file` path, atomic
10
+ rejection before Task/Plan acceptance, distinct planner/auditor identities, exact current
11
+ Step-set equality, concrete failure modes, executable evidence binding, coupled
12
+ migration/recovery rationale, blocking split/stop decisions, and adoption-aware
13
+ remaining-scope bootstrap handling.
14
+ - Strict high-risk Step Review coverage includes workflow-owned completion commits,
15
+ `task step-review` routing, commit-bound reviewer attestation, and fail-closed rejection of
16
+ stale, malformed, unverified, and wrong-commit review evidence.
17
+ - Guarded remediation coverage includes the per-Step circuit breaker: two ordinary retries
18
+ allowed, third gated by bounded `continue-fix`, a hard stop after a third failed corrective
19
+ review, and stop/redirection handling for `split-required` and `stop-escalate`.
20
+ - Milestone coverage includes human-only scope-change prepare/apply, journaled recovery of
21
+ `state.json`, `plan.json`, and `scope-change-events.jsonl`, plus membership-integrity
22
+ blocking for stale or contradictory Milestone/Task state, including reverse detection of a
23
+ live linked Task missing from required/waived/cancelled membership.
24
+ - `C1` coordination coverage includes the full prepared bundle, one-time and expiring claim
25
+ token, Task/Plan/Knowledge/Milestone bindings, exact expected-next prompt, optional grant,
26
+ target-only claim, claimant-only mutation, mandatory claim before Milestone Task start,
27
+ lease-token binding, and terminal evidence-bound handback.
28
+ - Adoption coverage includes sidecar-only `state adoption-prepare` and `state adoption-apply`,
29
+ automatic posture initialization for fresh alpha.6 projects, preservation of terminal
30
+ Milestones and Tasks, preservation of completed and skipped legacy Steps, and execution
31
+ blocking until posture is present.
32
+ - Compatibility checks passed for `protocolVersion: 1`, `STATE_SCHEMA_VERSION: 2`, unchanged
33
+ canonical Task and Milestone shapes, and unchanged delegated transition allow-list.
34
+ - Gateway handshake coverage includes the alpha.6 capabilities:
35
+ `plan-risk-audit-sidecar-v1`, `step-strict-review-sidecar-v1`,
36
+ `step-remediation-circuit-breaker-sidecar-v1`, `milestone-scope-change-sidecar-v1`,
37
+ `milestone-membership-integrity-v1`, `task-c1-handoff-sidecar-v1`, and
38
+ `alpha6-adoption-posture-v1`, plus strengthened contracts advertised as
39
+ `semantic-plan-risk-audit-v2`, `guarded-remediation-hard-stop-v1`,
40
+ `milestone-reverse-membership-integrity-v1`, and `task-c1-handoff-bundle-v2`.
41
+ - npm dry-run packaging produced `codex-workflow-v2-2.0.0-alpha.6.tgz` with runtime, schemas,
42
+ references, docs, and plugin source. Downstream installation and the packaged CLI handshake
43
+ passed, and the install created none of `.codex`, `.tasks`, `.increments`, or
44
+ `.memory-bank` in the temporary project.
24
45
 
25
- The strict reviewer implementation did not change in this release candidate. Its original
26
- 2026-07-16 real Codex CLI isolation probe denied a repository write and returned
27
- `isolationProbe: "denied"`. The reviewer remains fail-closed: inability to prove isolation
28
- records `unverified` and blocks acceptance.
46
+ Not claimed here:
47
+
48
+ - no final release publish;
49
+ - no final task audit beyond the recorded subtask evidence;
50
+ - no new real-Codex isolation probe beyond the existing fail-closed strict-reviewer
51
+ implementation and its automated coverage.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-workflow-v2",
3
- "version": "2.0.0-alpha.3",
3
+ "version": "2.0.0-alpha.6",
4
4
  "description": "Requirements-first Codex development workflow with local state and explicit Git ownership.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,12 +8,154 @@ Run:
8
8
  codex-workflow gateway handshake --repo <git-root>
9
9
  ```
10
10
 
11
- Require package name `codex-workflow-v2`, protocol version `1`, state
12
- schema version `2`, and the capabilities needed for the requested operation. Task execution
13
- that may cross a Project Knowledge Map revision requires `task-knowledge-rebind-v1`.
14
- Milestone final acceptance requires `milestone-human-final-gate-v1`.
11
+ Require:
12
+
13
+ - package name `codex-workflow-v2`
14
+ - protocol version `1`
15
+ - state schema version `2`
16
+ - the capabilities needed for the requested operation
17
+
18
+ Current capability set:
19
+
20
+ - `project-memory-v1`
21
+ - `graph-binding-v1`
22
+ - `local-state-v1`
23
+ - `milestone-lifecycle-v1`
24
+ - `milestone-human-final-gate-v1`
25
+ - `delegated-approval-v1`
26
+ - `task-knowledge-rebind-v1`
27
+ - `task-context-refresh-v1`
28
+ - `corrective-plan-audit-v1`
29
+ - `safe-update-preflight-v1`
30
+ - `strict-reviewer-v1`
31
+ - `legacy-snapshot-v1`
32
+ - `plan-risk-audit-sidecar-v1`
33
+ - `step-strict-review-sidecar-v1`
34
+ - `step-remediation-circuit-breaker-sidecar-v1`
35
+ - `milestone-scope-change-sidecar-v1`
36
+ - `milestone-membership-integrity-v1`
37
+ - `task-c1-handoff-sidecar-v1`
38
+ - `semantic-plan-risk-audit-v2`
39
+ - `guarded-remediation-hard-stop-v1`
40
+ - `milestone-reverse-membership-integrity-v1`
41
+ - `task-c1-handoff-bundle-v2`
42
+ - `alpha6-adoption-posture-v1`
43
+
44
+ Protocol `1` and schema `2` remain valid only because alpha.6 is additive. The gateway must
45
+ not claim compatibility if canonical entity shapes or non-additive command semantics change.
46
+
47
+ ## Alpha.6 adoption posture
48
+
49
+ For an existing schema 2 project without alpha.6 posture, repository-level `next` blocks
50
+ execution behind adoption:
51
+
52
+ - `action: "state adoption-apply"` when the repository is already at a safe boundary
53
+ - `action: "restore safe boundary, then state adoption-prepare"` otherwise
54
+
55
+ Use:
15
56
 
16
- ## Milestone Human Gate
57
+ ```text
58
+ codex-workflow state adoption-prepare --repo <git-root>
59
+ codex-workflow state adoption-apply --repo <git-root> \
60
+ --actor <HUMAN-ACTOR> --confirmation-code <ADA-CODE>
61
+ ```
62
+
63
+ The confirmation is bound to project identity, package version, protocol version, schema
64
+ version, canonical entity summaries, and the current sidecar baseline hash. Adoption is not
65
+ `state migrate`.
66
+
67
+ ## Worker Step completion and strict Step Review
68
+
69
+ `task run` dispatches one Step and returns its writer token and Worker envelope. The Worker
70
+ must leave all changes uncommitted and must not stage, commit, amend, reset, rebase, or
71
+ modify Git history.
72
+
73
+ While that Step is `in_progress`, repository-level `next` normally returns
74
+ `action: "task step-complete"`, the exact `stepId`, and a `commitPolicy` declaring
75
+ `workflow-core` ownership. The coordinator invokes that transition with the current revision
76
+ and writer token. Core then runs configured checks, validates `allowedWrites`, stages the
77
+ changes, creates the atomic commit, and records evidence.
78
+
79
+ If the current Plan Risk Audit marks that Step for strict review, the commit is still
80
+ workflow-owned, but `next` then returns `action: "task step-review"` with the same `stepId`
81
+ and the exact `completionCommit`. Canonical Step completion remains blocked until the strict
82
+ review and reviewer attestation sidecars verify against that exact commit.
83
+
84
+ An unrecorded commit is Git history drift. Stop instead of adding another commit or editing
85
+ workflow state manually; recovery remains coordinator-controlled.
86
+
87
+ ## Plan Risk Audit and remediation breaker
88
+
89
+ Before `task authorize`, every new alpha.6 Task requires:
90
+
91
+ ```text
92
+ codex-workflow task plan-risk-audit --repo <git-root> \
93
+ --id <TASK-ID> --expected-revision <REVISION> --file <audit.json>
94
+ ```
95
+
96
+ The audit must classify every current Step exactly once, name distinct planner/auditor
97
+ actors, and bind guarded failure modes to exact Step checks. Use `decision=approved` for an
98
+ unguarded Plan. Missing, stale, `split-required`, or `stop-escalate` evidence blocks
99
+ authorization.
100
+
101
+ For guarded remediation, `next.correctivePlanGate` or the runtime gate blocks a third
102
+ ordinary retry on the same guarded Step until a current corrective decision exists. Record it
103
+ with:
104
+
105
+ ```text
106
+ codex-workflow task corrective-decision --repo <git-root> \
107
+ --id <TASK-ID> --step <STEP-ID> --expected-revision <REVISION> --file <decision.json>
108
+ ```
109
+
110
+ Only `continue-fix` permits bounded continuation. `replan-required`, `split-required`, and
111
+ `stop-escalate` are stop or redirection decisions. If the third corrective review fails, a
112
+ fourth run is prohibited; only split or stop may be recorded.
113
+
114
+ ## Context refresh
115
+
116
+ Use `task context-refresh` only when the same `next` response exposes `contextRefresh` for the
117
+ exact grant. Pass Task revision, map revision, delegate actor, and grant ID. The composite
118
+ operation is restricted to content-hash-only drift and records the ordinary delegated map and
119
+ Task authorization evidence. Any semantic map change remains on the normal visible path.
120
+
121
+ Before updating the installed package, run `update preflight`. Continue only for `safe=true`.
122
+
123
+ ## C1 handoff
124
+
125
+ `C1` coordination is machine-bound and local. Use:
126
+
127
+ ```text
128
+ codex-workflow task handoff-prepare --repo <git-root> --id <TASK-ID> \
129
+ --expected-revision <REVISION> --actor <CURRENT-ACTOR> \
130
+ --target-actor <TARGET-ACTOR> --reason <TEXT> [--writer-token <TOKEN>] \
131
+ [--delegation-grant <GRANT>] [--expires-at <ISO-TIMESTAMP>]
132
+ codex-workflow task handoff-show --repo <git-root> --id <TASK-ID>
133
+ codex-workflow task claim --repo <git-root> --id <TASK-ID> \
134
+ --expected-revision <REVISION> --actor <TARGET-ACTOR> --claim-token <TOKEN> \
135
+ [--writer-token <WRITER-TOKEN>]
136
+ codex-workflow task handback-create --repo <git-root> --id <TASK-ID> \
137
+ --expected-revision <REVISION> --actor <CLAIMANT> --reason <TEXT> \
138
+ --recommended-next <TEXT> [--limitation <TEXT>] [--writer-token <TOKEN>]
139
+ ```
140
+
141
+ While a handoff is pending, `next` blocks the previous action behind `task claim`. While
142
+ claimed, only the claimant may mutate the Task, and lease-bound mutations must present the
143
+ bound writer token. Milestone-linked Tasks must be claimed before start, and handback is
144
+ terminal and evidence-bound. No thread id is required or accepted as authority.
145
+
146
+ ## Milestone scope change and human gate
147
+
148
+ After the initial empty planning posture, Milestone scope updates use:
149
+
150
+ ```text
151
+ codex-workflow milestone scope-change-prepare --repo <git-root> \
152
+ --id <MS-ID> --expected-revision <REVISION> --actor <HUMAN-ACTOR> --file <plan.json>
153
+ codex-workflow milestone scope-change-apply --repo <git-root> \
154
+ --id <MS-ID> --expected-revision <REVISION> --actor <HUMAN-ACTOR> \
155
+ --confirmation-code <MSC-CODE> --file <plan.json>
156
+ ```
157
+
158
+ This path is human-only. Delegated approval never authorizes it.
17
159
 
18
160
  At `awaiting_final_acceptance`, `next` returns `requiredHumanGate` with kind
19
161
  `milestone_final_acceptance`, Milestone ID, revision, Plan/Result/evidence hashes, validated
@@ -29,6 +171,21 @@ codex-workflow milestone accept --repo <git-root> --id <MS-ID> \
29
171
  Do not infer approval from the request that initiated validation. A changed revision, hash,
30
172
  or HEAD requires a new gate.
31
173
 
174
+ ## Delegated Approval
175
+
176
+ `delegation prepare --file <policy.json>` returns a `delegation_grant_issuance` gate with a
177
+ project-bound policy hash and `DGA-*` confirmation code. Display it and end the turn. A later
178
+ explicit user message containing the exact code permits `delegation grant`.
179
+
180
+ Active eligible grants appear in `next.delegatedApprovalOptions`. Use only the option whose
181
+ transition matches the requested command, with the named delegate as actor and the grant ID
182
+ as `--delegation-grant`. The resulting authorization event records the grant and both actors.
183
+ For `milestone.final_accept`, also pass the current `MSA-*` code; the existing grant replaces
184
+ the later-message requirement, not the state binding.
185
+
186
+ Delegated approval does not cover adoption apply, Milestone scope change, or any other new
187
+ human-only alpha.6 action.
188
+
32
189
  ## Graph Refresh Request
33
190
 
34
191
  The package returns:
@@ -38,6 +38,10 @@ classifications, hashes, gaps, conflicts, and approval evidence.
38
38
 
39
39
  Do not create a memory directory or write project files during scan.
40
40
 
41
+ When `next` exposes an exact delegated `contextRefresh`, use `task context-refresh` only for
42
+ the returned Task/map revisions, actor, and grant. Never use it when the source set,
43
+ classification, authority, gaps, or conflicts changed.
44
+
41
45
  ## Product Or Workflow Graph Refresh
42
46
 
43
47
  1. Run `graph refresh-request --kind product|workflow --mode moderate`.
@@ -57,14 +61,20 @@ independently blocks the workflow.
57
61
 
58
62
  - Scope Lead: architecture and broad search only.
59
63
  - Technical Planner: architecture, search, and trace evidence.
60
- - Worker: targeted search, trace, and snippets for its Step.
64
+ - Worker: targeted search, trace, and snippets for its Step. It leaves all file changes
65
+ uncommitted and never stages or mutates Git history; the coordinator invokes the exact
66
+ `task step-complete` returned by `next`, and core owns checks, commit creation, and evidence.
61
67
  - Delivery Coordinator: list, status, index, detect, and bind lifecycle.
68
+ - A Milestone Delivery Coordinator creates a dedicated user-visible Task chat for every
69
+ required Task and keeps implementation out of the Milestone chat.
62
70
  - Independent Reviewer: receives recorded evidence and confirms critical
63
71
  claims against files, Git, and tests.
64
72
 
65
73
  ## Human Gates
66
74
 
67
- Treat `requiredHumanGate` from the project-local package as a mandatory turn boundary.
75
+ Treat `requiredHumanGate` from the project-local package as a mandatory turn boundary unless
76
+ the same `next` response contains a currently eligible `delegatedApprovalOptions` entry for
77
+ the exact transition and the agent is the entry's named delegate.
68
78
  For `milestone_final_acceptance`, show the user the Milestone ID, revision, Plan hash,
69
79
  Result hash, evidence hash, validated HEAD, and confirmation code. Ask whether the user
70
80
  accepts that exact result, then stop without invoking `milestone accept`.
@@ -75,6 +85,31 @@ A generic instruction such as “continue”, “finish”, or “bring it to fi
75
85
  final acceptance. If `next` returns a different code or binding, discard the old response
76
86
  and ask again.
77
87
 
88
+ ## Delegated Approval
89
+
90
+ Delegation issuance is itself a mandatory human turn boundary. Run `delegation prepare` with
91
+ the proposed policy, show the complete principal, delegate, scope, transitions, expiry,
92
+ policy hash, and `DGA-*` confirmation code, then stop. Only after a later user message
93
+ explicitly approves that exact code may `delegation grant` be invoked.
94
+
95
+ Never create, broaden, renew, or replace a grant from an agent's own judgment. Never record
96
+ the delegate as the user. When `next` exposes an eligible option, pass its grant ID through
97
+ `--delegation-grant` and use the exact delegate string as `--actor`. The core remains the
98
+ authority for status, expiry, scope, transition, and revocation checks.
99
+
100
+ For delegated Milestone final acceptance, the current `MSA-*` code is still required, but a
101
+ new user turn is not: the previously issued grant is the controlling decision. If no eligible
102
+ option is returned, follow the ordinary human-gate rule above. Knowledge Map approval is
103
+ delegable only through an explicit project-scoped `project_memory.approve` permission. Scope
104
+ changes, grant issuance, and grant expansion are never delegated by `delegated-approval-v1`.
105
+
106
+ After two failed Task reviews, follow `next.correctivePlanGate`: obtain a distinct read-only
107
+ corrective Auditor result and pass it through `--corrective-audit-file`. Do not continue for
108
+ replan, split, or stop decisions.
109
+
110
+ Before an npm package update, run the project-local `update preflight` and stop unless it
111
+ returns `safe=true` with a clean checkout, no running Step, and no active writer lease.
112
+
78
113
  ## Stop Conditions
79
114
 
80
115
  - Dependency version is missing, ranged, or differs from the installed package.
@@ -84,4 +119,4 @@ and ask again.
84
119
  - An action would make MCP or the local map authoritative project memory.
85
120
  - A requested mutation is not authorized by the package CLI state.
86
121
  - A human gate was emitted but the user has not approved its exact confirmation code in a
87
- later message.
122
+ later message and no exact eligible delegated approval option exists.
@@ -3,5 +3,8 @@
3
3
  The default mode uses a dedicated task branch in the current clean checkout. The core
4
4
  does not create or remove worktrees. An externally supplied worktree or clone must already
5
5
  be on a dedicated non-base branch; its provider owns merge and cleanup. Every completed
6
- Step becomes one commit with Task and Step trailers. Unexpected changed paths block the
7
- commit. Base advancement invalidates validation and final acceptance before merge.
6
+ Step becomes one commit with Task and Step trailers. The Worker leaves its changes
7
+ uncommitted; `task step-complete` owns configured checks, staging, commit creation, and Step
8
+ evidence. A Worker must not run `git add`, `git commit`, amend, reset, rebase, or otherwise
9
+ change Git history. Unexpected changed paths or unrecorded commits block Step completion.
10
+ Base advancement invalidates validation and final acceptance before merge.
@@ -6,6 +6,29 @@ to the task commit and Brief, Plan, and evidence hashes. Final acceptance is a s
6
6
  human event bound to Result, evidence, and commit. Locks expire only diagnostically;
7
7
  removing a stale lock is always an explicit repair operation.
8
8
 
9
+ Alpha.6 keeps canonical entity JSON unchanged at `stateSchemaVersion: 2` and adds lifecycle
10
+ evidence through sidecars. `protocolVersion: 1` remains valid only because the alpha.6
11
+ surface is additive and capability-advertised.
12
+
13
+ Before execution authorization, every alpha.6 Task must have a current Plan Risk Audit bound
14
+ to the current Brief, Plan, Knowledge Map, and exact Step set. The audit is required even when
15
+ all Steps are unguarded, must name distinct planner/auditor actors, and must bind guarded
16
+ failure modes to exact Step checks. Missing, stale, inconsistent, `split-required`, or
17
+ `stop-escalate` evidence blocks authorization.
18
+
19
+ If the current Plan Risk Audit marks a Step for strict review, `task step-complete` still
20
+ creates the workflow-owned commit but keeps the Step non-terminal. Repository `next` routes to
21
+ `task step-review` until a valid strict review and reviewer attestation bind to that exact
22
+ commit.
23
+
24
+ Human approval remains the default. A user may instead issue a time-bound delegation grant
25
+ after confirming a deterministic `DGA-*` code bound to the project and exact policy hash.
26
+ The policy names a distinct principal and delegate, a project/Milestone/Task scope, and an
27
+ allow-list of approval transitions. Delegated transitions fail closed on actor, scope,
28
+ transition, expiry, revocation, or project mismatch. Their authorization events record
29
+ `authorizationMode: delegated` plus the grant ID, policy hash, principal, delegate, and exact
30
+ transition; the delegate is never recorded as the user.
31
+
9
32
  When an approved Project Knowledge Map changes between Task Steps, the coordinator first
10
33
  reconciles and obtains approval for the new map, then uses `task knowledge-rebind`. This
11
34
  mechanical transition preserves Step definitions, runtime status, and evidence, records both
@@ -13,6 +36,12 @@ bindings, supersedes execution authorization, and returns the Task to
13
36
  `awaiting_execution_authorization`. It cannot run while a Step is `in_progress` or while the
14
37
  Task is `blocked`; unrelated blocks must be resolved through their owning transition.
15
38
 
39
+ For alpha.6 guarded remediation, two ordinary remediation attempts are allowed. A third
40
+ ordinary retry is blocked until a current corrective decision exists for the same Step and
41
+ Plan binding. `continue-fix` allows bounded continuation; `replan-required`,
42
+ `split-required`, and `stop-escalate` stop ordinary execution. A failed third corrective
43
+ attempt is a hard stop: no fourth run or new continue/replan decision is accepted.
44
+
16
45
  Milestone authorization is bound to its Plan and membership revision. Plan amendments
17
46
  supersede authorization. Milestone validation and acceptance are bound to the current base
18
47
  HEAD. In `awaiting_final_acceptance`, `next` returns a state-bound human gate. The agent must
@@ -21,6 +50,25 @@ valid only after a later explicit user response repeats that code; the CLI requi
21
50
  explicit actor and the exact code. Cancellation records intent but performs no Git reversal.
22
51
  If the base HEAD or final artifacts change before acceptance, `next` withholds the gate and
23
52
  requires Milestone validation again; revalidation supersedes the previous candidate binding.
53
+ An already issued grant containing `milestone.final_accept` may cross that gate autonomously,
54
+ but the acceptance command still requires the current `MSA-*` code so the use remains bound
55
+ to the validated revision, hashes, and HEAD. Grant issuance itself always remains a prior
56
+ human turn boundary.
57
+
58
+ After the initial empty planning posture, Milestone scope updates no longer use ordinary
59
+ `milestone plan-set`. They must go through `milestone scope-change-prepare` and
60
+ `milestone scope-change-apply`, which journal `state.json`, `plan.json`, and
61
+ `scope-change-events.jsonl` together and remain human-only. Membership integrity is validated
62
+ before scheduling, Task start, Milestone validation, scope change, and repository `next`.
63
+ The same guard scans in reverse and blocks every live Task whose `milestoneId` is absent from
64
+ the Milestone's required/waived/cancelled classification.
65
+
66
+ `C1` coordination is machine-bound but local: `task handoff-prepare` returns a one-time claim
67
+ token and prompt bound to a stable handoff ID, revision, context hashes, Milestone positions,
68
+ delegate/grant, expected next action, and expiry. `task claim` validates those bindings and
69
+ activates claimant-only mutation; terminal `task handback-create` returns result, evidence,
70
+ review, knowledge, limitation, and recommended-next bindings. Milestone Tasks must be claimed
71
+ before start. No part of this contract requires or proves a physically separate Codex thread.
24
72
 
25
73
  Repository-level scheduling respects current Milestone membership. An unstarted linked Task
26
74
  is eligible only for an `active` Milestone with `required` disposition. Historical unstarted