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

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 (82) hide show
  1. package/README.md +114 -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 +40 -0
  6. package/dist/src/alpha6/handoff.js +981 -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 +52 -0
  12. package/dist/src/alpha6/milestone.js +1103 -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 +908 -0
  16. package/dist/src/alpha6/plan-risk.js.map +1 -0
  17. package/dist/src/alpha6/remediation.d.ts +21 -0
  18. package/dist/src/alpha6/remediation.js +754 -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/alpha7/autonomy.d.ts +61 -0
  27. package/dist/src/alpha7/autonomy.js +256 -0
  28. package/dist/src/alpha7/autonomy.js.map +1 -0
  29. package/dist/src/cli.js +109 -19
  30. package/dist/src/cli.js.map +1 -1
  31. package/dist/src/contracts.d.ts +268 -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 +5 -0
  35. package/dist/src/index.js +3 -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 +39 -1
  44. package/dist/src/state/store.js +127 -1
  45. package/dist/src/state/store.js.map +1 -1
  46. package/dist/src/version.d.ts +1 -1
  47. package/dist/src/version.js +1 -1
  48. package/dist/src/workflow.d.ts +113 -8
  49. package/dist/src/workflow.js +1635 -78
  50. package/dist/src/workflow.js.map +1 -1
  51. package/docs/autonomy-guardrails.md +164 -0
  52. package/docs/decisions.md +39 -0
  53. package/docs/delegated-approval.md +37 -5
  54. package/docs/development-flow.md +45 -1
  55. package/docs/pdf/codex-workflow-v2-architecture-ru.pdf +155 -136
  56. package/docs/pdf/codex-workflow-v2-chat-only-guide-ru.pdf +236 -223
  57. package/docs/pdf/codex-workflow-v2-technical-reference-ru.pdf +225 -206
  58. package/docs/project-memory.md +7 -0
  59. package/docs/release.md +9 -0
  60. package/docs/updating-existing-project.md +63 -5
  61. package/docs/validation-report.md +52 -34
  62. package/package.json +1 -1
  63. package/plugins/codex-workflow-gateway/references/protocol.md +182 -6
  64. package/plugins/codex-workflow-gateway/skills/codex-workflow-gateway/SKILL.md +35 -1
  65. package/references/git-policy.md +5 -2
  66. package/references/state-machine.md +43 -0
  67. package/references/validation-and-review.md +28 -1
  68. package/roles/delivery-coordinator.md +21 -1
  69. package/roles/independent-reviewer.md +3 -0
  70. package/roles/technical-planner.md +10 -0
  71. package/roles/worker.md +4 -0
  72. package/schemas/adoption-posture-event.schema.json +129 -0
  73. package/schemas/corrective-decision-event.schema.json +55 -0
  74. package/schemas/corrective-plan-audit.schema.json +20 -0
  75. package/schemas/milestone-autonomy-event.schema.json +45 -0
  76. package/schemas/milestone-scope-change-event.schema.json +70 -0
  77. package/schemas/milestone-transaction-journal.schema.json +95 -0
  78. package/schemas/plan-risk-audit-event.schema.json +107 -0
  79. package/schemas/remediation-event.schema.json +53 -0
  80. package/schemas/reviewer-attestation-event.schema.json +49 -0
  81. package/schemas/step-review-event.schema.json +74 -0
  82. package/schemas/task-handoff-event.schema.json +116 -0
package/README.md CHANGED
@@ -13,10 +13,18 @@ automation do not import anything from the parent V1 project.
13
13
  - Discovery precedes Task or Milestone identifiers and branches;
14
14
  - Project Knowledge Map approval binds Plans to current canonical files;
15
15
  - safe Task Plan knowledge rebind preserves Step evidence and requires fresh authorization;
16
+ - delegated content-only context refresh composes map refresh, rebind, and reauthorization
17
+ without hiding classification changes;
16
18
  - optional `codebase-memory-mcp` product and workflow graph bindings with explicit fallback;
17
19
  - one writer lease and one atomic Git commit per completed Step;
18
20
  - explicit execution authorization, independent review, and a state-bound human final-acceptance gate;
21
+ - high-risk Plan guidance and a mandatory separate corrective audit after two failed reviews;
22
+ - executable proof obligations with hostile counterexamples for every guarded failure mode;
23
+ - read-only update preflight for clean checkout, running-Step, and writer-lease blockers;
24
+ - narrow, read-only alpha.6 strict-review rescue preflight for the lifecycle deadlock fixed in alpha.7;
19
25
  - optional time-bound delegated approval with project/Milestone/Task scope and an explicit audit trail;
26
+ - one bounded Milestone Autonomy Contract for approvals, guarded content-only context refresh,
27
+ and membership-only Task-graph evolution;
20
28
  - Milestones aggregate already merged Tasks on the base branch, without an integration branch;
21
29
  - V1 transition is snapshot-only and never performs semantic import.
22
30
 
@@ -28,8 +36,8 @@ cross-machine synchronization are not part of its contract.
28
36
  Node.js 22 or newer is required. Consumers pin the exact package version:
29
37
 
30
38
  ```bash
31
- npm install --save-dev --save-exact codex-workflow-v2@2.0.0-alpha.4
32
- npx codex-workflow gateway handshake
39
+ npm install --save-dev --save-exact codex-workflow-v2@2.0.0-alpha.7
40
+ npx codex-workflow gateway handshake --repo .
33
41
  npx codex-workflow doctor --repo .
34
42
  ```
35
43
 
@@ -44,10 +52,21 @@ npm run plugin:check
44
52
  npm run release:check
45
53
  ```
46
54
 
47
- ## Typical Task flow
55
+ ## Alpha.7 Task flow
48
56
 
49
57
  The CLI emits JSON. Every update after creation requires the current state revision.
50
58
 
59
+ For a fresh alpha.7 project, registration writes the adoption posture automatically. For an
60
+ existing schema 2 project, apply adoption before execution:
61
+
62
+ ```bash
63
+ codex-workflow update preflight --repo .
64
+ codex-workflow state adoption-prepare --repo .
65
+ codex-workflow state adoption-apply --repo . --actor user:owner --confirmation-code ADA-...
66
+ ```
67
+
68
+ Do not use `state migrate` for schema-2 adoption.
69
+
51
70
  ```bash
52
71
  codex-workflow project-memory scan --repo .
53
72
  codex-workflow project-memory approve --repo . --expected-revision 1 --file selections.json
@@ -56,22 +75,63 @@ codex-workflow discovery start --repo . --goal "..." --outcome "..." \
56
75
  codex-workflow discovery materialize --repo . --id DISC-... \
57
76
  --expected-revision 1 --kind task --title "..."
58
77
  codex-workflow task plan-set --repo . --id TASK-... \
59
- --expected-revision 1 --file plan.json
78
+ --expected-revision 1 --file plan.json --risk-audit-file plan-risk-audit.json
60
79
  codex-workflow task authorize --repo . --id TASK-... \
61
80
  --expected-revision 2 --actor user
62
81
  codex-workflow task start --repo . --id TASK-... \
63
82
  --expected-revision 3 --workspace-owner local
64
83
  codex-workflow task run --repo . --id TASK-... --step STEP-001 \
65
84
  --expected-revision 4 --owner worker
85
+ # Worker changes only allowed files and leaves them uncommitted.
86
+ codex-workflow task step-complete --repo . --id TASK-... --step STEP-001 \
87
+ --expected-revision 5 --writer-token <TOKEN-FROM-TASK-RUN>
66
88
  ```
67
89
 
68
- `task run` returns the writer token and Worker context. `task review-launch` starts the
69
- strict read-only reviewer after submission. If a completed Step changes approved project
90
+ `task run` returns the writer token and Worker context. The Worker must not stage or commit.
91
+ `task step-complete` runs configured checks, creates the workflow-owned atomic commit, and
92
+ either records completion immediately or leaves the Step non-terminal for `task step-review`
93
+ when the current Plan Risk Audit marks it for strict review.
94
+
95
+ The Plan Risk Audit is mandatory for every new alpha.7 Task before execution authorization,
96
+ including a positive `approved` decision for a Plan with no guarded Steps. The audit sidecar
97
+ must identify a Plan author and an independent auditor, classify every current Step exactly
98
+ once, describe guarded failure modes, and bind required evidence to exact executable Step
99
+ checks. Every guarded failure mode additionally needs one `proofObligations` entry containing
100
+ the hostile `counterexample`, expected safe result, and an exact executable evidence command.
101
+ `split-required` and `stop-escalate` block authorization. Historical alpha.6 audit sidecars
102
+ remain readable for strict-review recovery, but newly recorded audits must use proof obligations.
103
+
104
+ `task review-launch` starts the strict read-only reviewer after submission. If a completed Step changes approved project
70
105
  knowledge, reconcile and approve the map, then run `task knowledge-rebind --repo . --id
71
106
  TASK-... --expected-revision ...`. The rebind changes no Step definition, preserves runtime
72
107
  status and evidence, supersedes execution authorization, and requires `task authorize`
73
108
  before another Step or submission. Use `next` after transitions.
74
109
 
110
+ When `next.contextRefresh` offers a delegated content-only option, the coordinator may use:
111
+
112
+ ```bash
113
+ codex-workflow task context-refresh --repo . --id TASK-... \
114
+ --expected-task-revision ... --expected-map-revision ... \
115
+ --actor agent:deputy --delegation-grant DGR-...
116
+ ```
117
+
118
+ New/removed sources, category/authority changes, gaps, or conflicts are never auto-approved.
119
+
120
+ ## Alpha.7 sidecars
121
+
122
+ Alpha.7 keeps canonical entity JSON unchanged and stores guardrail evidence in append-only
123
+ sidecars:
124
+
125
+ - project: `adoption-posture.jsonl`
126
+ - task: `plan-risk-audits.jsonl`, `step-review-events.jsonl`,
127
+ `reviewer-attestations.jsonl`, `remediation-events.jsonl`,
128
+ `corrective-decisions.jsonl`, `handoffs.jsonl`
129
+ - milestone: `scope-change-events.jsonl`, `autonomy-contract-events.jsonl`
130
+
131
+ Milestone scope-change recovery also uses Milestone-local `.transactions/` journal files.
132
+ Broken JSONL, duplicate event ids, broken hash chains, stale revision/hash/commit bindings,
133
+ or mismatched authority fail closed with structured diagnostics.
134
+
75
135
  ## Delegated approval
76
136
 
77
137
  Delegation never makes an agent a human actor. A user first approves an exact grant policy;
@@ -89,10 +149,54 @@ codex-workflow task authorize --repo . --id TASK-... --expected-revision 2 \
89
149
 
90
150
  Policies may allow only `project_memory.approve`, `task.execution_authorize`, `task.final_accept`,
91
151
  `milestone.execution_authorize`, and/or `milestone.final_accept`. Scope is one project,
92
- Milestone, or Task; Project Knowledge Map approval requires project scope. Revocation is immediate for future uses. The original human path remains
93
- available and unchanged.
94
-
95
- See [development flow](docs/development-flow.md), [delegated approval](docs/delegated-approval.md), [updating an existing project](docs/updating-existing-project.md), [project memory](docs/project-memory.md),
152
+ Milestone, or Task; ordinary Project Knowledge Map approval requires project scope. Alpha.7 does
153
+ not extend this allow-list. A separate Milestone Autonomy Contract may authorize membership-only
154
+ evolution and the `project_memory.approve` half of an atomic, content-only Task context refresh
155
+ for the same Milestone. It cannot approve Project Memory as a standalone operation. Outcome,
156
+ success signal, acceptance, checks, discovery, and base branch remain cryptographically fixed.
157
+ Adoption apply and semantic scope changes stay human-only. Revocation is immediate for future
158
+ uses. The original human path remains available and unchanged.
159
+
160
+ ## Milestone autonomy and alpha.6 rescue
161
+
162
+ Materialize all linked Task discoveries while the new Milestone remains in its initial planning
163
+ posture, then call `milestone plan-set` once with the complete classified membership. Execution
164
+ is unavailable until that full Plan exists. To approve a bounded autonomous run for up to 72
165
+ hours, use `milestone autonomy-prepare` and, after confirming its `MAC-*` binding,
166
+ `milestone autonomy-grant`. The resulting milestone-scoped grant covers Task/Milestone execution
167
+ and final-acceptance approvals plus Project Memory approval only inside an atomic content-only
168
+ Task context refresh for the same Milestone. `milestone autonomy-evolve` may change only
169
+ memberships and always supersedes the current execution authorization; semantic changes require
170
+ the ordinary human scope-change path.
171
+
172
+ `update rescue-preflight` is a read-only compatibility route for one exact deadlock shape:
173
+ the project is pinned to `2.0.0-alpha.6`, exactly one strict review is pending, the checkout and
174
+ completion HEAD are exact, and no active lease exists. It returns only stale-lock repair and
175
+ strict-review actions. It neither installs alpha.7 nor rewrites state.
176
+
177
+ ## C1 handoff and legacy adoption
178
+
179
+ `C1` coordination uses `task handoff-prepare` (with `task handoff` retained as an alias),
180
+ `task claim --claim-token ...`, and `task handback-create` (with `task handback` retained as
181
+ an alias). `task handoff-show` returns the persisted safe bindings but never the plaintext
182
+ claim token. If `--target-actor` is omitted, alpha.7 deterministically derives a distinct
183
+ `agent:worker:<task-id>` actor. Preparation returns a one-time claim token and a prompt bound to `handoffId`, Task
184
+ revision, Brief/Plan/Knowledge hashes, Milestone display positions, delegate/grant, expiry,
185
+ and exact expected next action. Only the token hash is persisted. Milestone-linked Tasks must
186
+ be claimed before start; terminal handback records result, evidence, review, knowledge,
187
+ limitations, and recommended-next bindings. This does not prove a physically separate Codex
188
+ thread.
189
+
190
+ For legacy schema 2 projects:
191
+
192
+ - accepted/cancelled Milestones stay terminal;
193
+ - merged/cancelled Tasks stay terminal;
194
+ - completed and skipped Steps in active Tasks keep their recorded status and evidence;
195
+ - remaining non-completed, non-skipped legacy Steps need a bootstrap Plan Risk Audit at a
196
+ safe boundary;
197
+ - newly created Milestones, Tasks, and Steps use the full alpha.7 contract.
198
+
199
+ See [development flow](docs/development-flow.md), [autonomy guardrails](docs/autonomy-guardrails.md), [delegated approval](docs/delegated-approval.md), [updating an existing project](docs/updating-existing-project.md), [project memory](docs/project-memory.md),
96
200
  [accepted decisions](docs/decisions.md), [validation report](docs/validation-report.md), and
97
201
  [release policy](docs/release.md).
98
202
 
@@ -0,0 +1,55 @@
1
+ import type { AdoptionPostureEvent, AdoptionRepositoryIdentity, MilestoneState, TaskState } from '../contracts.js';
2
+ import type { RepositoryIdentity } from '../repository.js';
3
+ import type { FileStateStore } from '../state/store.js';
4
+ export interface AdoptionSidecarInventoryEntry {
5
+ scope: 'project' | 'task' | 'milestone';
6
+ ownerId: string;
7
+ sidecarName: string;
8
+ contentHash: string;
9
+ }
10
+ export interface AdoptionPreparationInput {
11
+ projectId: string;
12
+ repositoryIdentity: AdoptionRepositoryIdentity | RepositoryIdentity;
13
+ packageVersion: string;
14
+ protocolVersion: number;
15
+ stateSchemaVersion: number;
16
+ tasks: TaskState[];
17
+ milestones: MilestoneState[];
18
+ sidecarInventory: AdoptionSidecarInventoryEntry[];
19
+ blockers: string[];
20
+ now: Date;
21
+ }
22
+ export interface AdoptionPreparation {
23
+ status: 'missing' | 'ready' | 'applied';
24
+ safe: boolean;
25
+ blockers: string[];
26
+ currentPosture: AdoptionPostureEvent | null;
27
+ baselineDigestHash: string;
28
+ sidecarBaselineHash: string;
29
+ confirmationCodeBindingHash: string | null;
30
+ confirmationCode: string | null;
31
+ candidateEvent: AdoptionPostureEvent | null;
32
+ }
33
+ export interface AdoptionStatus {
34
+ status: 'missing' | 'ready' | 'applied';
35
+ safe: boolean;
36
+ blockers: string[];
37
+ currentPosture: AdoptionPostureEvent | null;
38
+ baselineDigestHash: string;
39
+ sidecarBaselineHash: string;
40
+ }
41
+ export interface ProjectRegistrationAdoptionInput {
42
+ projectId: string;
43
+ repositoryIdentity: AdoptionRepositoryIdentity | RepositoryIdentity;
44
+ packageVersion: string;
45
+ protocolVersion: number;
46
+ stateSchemaVersion: number;
47
+ now: Date;
48
+ }
49
+ export declare function readCurrentAdoptionPosture(store: FileStateStore, projectId: string): AdoptionPostureEvent | null;
50
+ export declare function status(input: AdoptionPreparationInput, currentPosture?: AdoptionPostureEvent | null): AdoptionStatus;
51
+ export declare function buildAdoptionPreparation(input: AdoptionPreparationInput, currentPosture?: AdoptionPostureEvent | null): AdoptionPreparation;
52
+ export declare function initializeProjectRegistrationAdoption(store: FileStateStore, input: ProjectRegistrationAdoptionInput): AdoptionPostureEvent;
53
+ export declare function applyAdoptionPosture(store: FileStateStore, input: AdoptionPreparationInput, actor: string, confirmationCode: string): AdoptionPostureEvent;
54
+ export declare function buildProjectRegistrationAdoptionEvent(input: AdoptionPreparationInput): AdoptionPostureEvent;
55
+ export declare function assertAdoptionBaselinePreserved(posture: AdoptionPostureEvent, tasks: TaskState[], milestones: MilestoneState[]): void;