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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) 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 +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 +95 -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/version.js.map +1 -1
  44. package/dist/src/workflow.d.ts +123 -9
  45. package/dist/src/workflow.js +1497 -76
  46. package/dist/src/workflow.js.map +1 -1
  47. package/docs/autonomy-guardrails.md +143 -0
  48. package/docs/decisions.md +27 -0
  49. package/docs/delegated-approval.md +30 -5
  50. package/docs/development-flow.md +40 -1
  51. package/docs/pdf/codex-workflow-v2-architecture-ru.pdf +155 -136
  52. package/docs/pdf/codex-workflow-v2-chat-only-guide-ru.pdf +236 -223
  53. package/docs/pdf/codex-workflow-v2-technical-reference-ru.pdf +225 -206
  54. package/docs/project-memory.md +7 -0
  55. package/docs/release.md +7 -0
  56. package/docs/updating-existing-project.md +75 -5
  57. package/docs/validation-report.md +56 -34
  58. package/package.json +2 -2
  59. package/plugins/codex-workflow-gateway/references/protocol.md +155 -6
  60. package/plugins/codex-workflow-gateway/skills/codex-workflow-gateway/SKILL.md +23 -1
  61. package/references/git-policy.md +5 -2
  62. package/references/state-machine.md +36 -0
  63. package/references/validation-and-review.md +28 -1
  64. package/roles/delivery-coordinator.md +11 -0
  65. package/roles/independent-reviewer.md +3 -0
  66. package/roles/technical-planner.md +7 -0
  67. package/roles/worker.md +4 -0
  68. package/schemas/adoption-posture-event.schema.json +129 -0
  69. package/schemas/corrective-decision-event.schema.json +55 -0
  70. package/schemas/corrective-plan-audit.schema.json +20 -0
  71. package/schemas/milestone-scope-change-event.schema.json +68 -0
  72. package/schemas/milestone-transaction-journal.schema.json +95 -0
  73. package/schemas/plan-risk-audit-event.schema.json +90 -0
  74. package/schemas/remediation-event.schema.json +53 -0
  75. package/schemas/reviewer-attestation-event.schema.json +49 -0
  76. package/schemas/step-review-event.schema.json +74 -0
  77. package/schemas/task-handoff-event.schema.json +116 -0
package/README.md CHANGED
@@ -13,9 +13,14 @@ 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
+ - read-only update preflight for clean checkout, running-Step, and writer-lease blockers;
23
+ - narrow alpha.6 C1 strict-review rescue without deleting or rotating the bound writer lease;
19
24
  - optional time-bound delegated approval with project/Milestone/Task scope and an explicit audit trail;
20
25
  - Milestones aggregate already merged Tasks on the base branch, without an integration branch;
21
26
  - V1 transition is snapshot-only and never performs semantic import.
@@ -28,8 +33,8 @@ cross-machine synchronization are not part of its contract.
28
33
  Node.js 22 or newer is required. Consumers pin the exact package version:
29
34
 
30
35
  ```bash
31
- npm install --save-dev --save-exact codex-workflow-v2@2.0.0-alpha.4
32
- npx codex-workflow gateway handshake
36
+ npm install --save-dev --save-exact codex-workflow-v2@2.0.0-alpha.6.1
37
+ npx codex-workflow gateway handshake --repo .
33
38
  npx codex-workflow doctor --repo .
34
39
  ```
35
40
 
@@ -44,10 +49,48 @@ npm run plugin:check
44
49
  npm run release:check
45
50
  ```
46
51
 
47
- ## Typical Task flow
52
+ ## Alpha.6 Task flow
48
53
 
49
54
  The CLI emits JSON. Every update after creation requires the current state revision.
50
55
 
56
+ For a fresh alpha.6 project, registration writes the adoption posture automatically. For an
57
+ existing schema 2 project, apply adoption before execution:
58
+
59
+ ```bash
60
+ codex-workflow update preflight --repo .
61
+ codex-workflow state adoption-prepare --repo .
62
+ codex-workflow state adoption-apply --repo . --actor user:owner --confirmation-code ADA-...
63
+ ```
64
+
65
+ Do not use `state migrate` for alpha.6 adoption.
66
+
67
+ ### Alpha.6 claimed-C1 strict-review rescue
68
+
69
+ `2.0.0-alpha.6.1` is a narrow external rescue runner for an exact deadlock: the project still
70
+ declares `2.0.0-alpha.6`, one guarded Step has a pending review at the clean completion HEAD,
71
+ the Project Knowledge Map advanced after that commit, and the Task retains its claimed C1
72
+ lease and original bound writer token. It does not update the project dependency or migrate
73
+ state.
74
+
75
+ Run the read-only preflight from the exact `2.0.0-alpha.6.1` package. Continue only when it
76
+ returns `eligible=true` and one `update rescue-review` action. The rescue command requires the
77
+ exact Task, Step, revision, claimant actor, and original writer token returned by the C1 lease.
78
+ It preserves and heartbeats that lease; never run `locks repair` first.
79
+
80
+ ```bash
81
+ npx --yes --package codex-workflow-v2@2.0.0-alpha.6.1 -- \
82
+ codex-workflow update rescue-preflight --repo .
83
+ npx --yes --package codex-workflow-v2@2.0.0-alpha.6.1 -- \
84
+ codex-workflow update rescue-review --repo . --id TASK-... --step STEP-... \
85
+ --expected-revision ... --actor agent:task-worker --writer-token <BOUND-TOKEN>
86
+ ```
87
+
88
+ The preflight and CLI output never expose the plaintext token. A missing lease, wrong actor or
89
+ token, dirty checkout, advanced HEAD, unrelated writer lease, or ambiguous
90
+ pending review fails closed without repairing state. After a successful review, follow `next`
91
+ through ordinary Knowledge reconcile/rebind and reach a safe update boundary before changing
92
+ the installed package.
93
+
51
94
  ```bash
52
95
  codex-workflow project-memory scan --repo .
53
96
  codex-workflow project-memory approve --repo . --expected-revision 1 --file selections.json
@@ -56,22 +99,60 @@ codex-workflow discovery start --repo . --goal "..." --outcome "..." \
56
99
  codex-workflow discovery materialize --repo . --id DISC-... \
57
100
  --expected-revision 1 --kind task --title "..."
58
101
  codex-workflow task plan-set --repo . --id TASK-... \
59
- --expected-revision 1 --file plan.json
102
+ --expected-revision 1 --file plan.json --risk-audit-file plan-risk-audit.json
60
103
  codex-workflow task authorize --repo . --id TASK-... \
61
104
  --expected-revision 2 --actor user
62
105
  codex-workflow task start --repo . --id TASK-... \
63
106
  --expected-revision 3 --workspace-owner local
64
107
  codex-workflow task run --repo . --id TASK-... --step STEP-001 \
65
108
  --expected-revision 4 --owner worker
109
+ # Worker changes only allowed files and leaves them uncommitted.
110
+ codex-workflow task step-complete --repo . --id TASK-... --step STEP-001 \
111
+ --expected-revision 5 --writer-token <TOKEN-FROM-TASK-RUN>
66
112
  ```
67
113
 
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
114
+ `task run` returns the writer token and Worker context. The Worker must not stage or commit.
115
+ `task step-complete` runs configured checks, creates the workflow-owned atomic commit, and
116
+ either records completion immediately or leaves the Step non-terminal for `task step-review`
117
+ when the current Plan Risk Audit marks it for strict review.
118
+
119
+ The Plan Risk Audit is mandatory for every new alpha.6 Task before execution authorization,
120
+ including a positive `approved` decision for a Plan with no guarded Steps. The audit sidecar
121
+ must identify a Plan author and an independent auditor, classify every current Step exactly
122
+ once, describe guarded failure modes, and bind required evidence to exact executable Step
123
+ checks. `split-required` and `stop-escalate` block authorization.
124
+
125
+ `task review-launch` starts the strict read-only reviewer after submission. If a completed Step changes approved project
70
126
  knowledge, reconcile and approve the map, then run `task knowledge-rebind --repo . --id
71
127
  TASK-... --expected-revision ...`. The rebind changes no Step definition, preserves runtime
72
128
  status and evidence, supersedes execution authorization, and requires `task authorize`
73
129
  before another Step or submission. Use `next` after transitions.
74
130
 
131
+ When `next.contextRefresh` offers a delegated content-only option, the coordinator may use:
132
+
133
+ ```bash
134
+ codex-workflow task context-refresh --repo . --id TASK-... \
135
+ --expected-task-revision ... --expected-map-revision ... \
136
+ --actor agent:deputy --delegation-grant DGR-...
137
+ ```
138
+
139
+ New/removed sources, category/authority changes, gaps, or conflicts are never auto-approved.
140
+
141
+ ## Alpha.6 sidecars
142
+
143
+ Alpha.6 keeps canonical entity JSON unchanged and stores guardrail evidence in append-only
144
+ sidecars:
145
+
146
+ - project: `adoption-posture.jsonl`
147
+ - task: `plan-risk-audits.jsonl`, `step-review-events.jsonl`,
148
+ `reviewer-attestations.jsonl`, `remediation-events.jsonl`,
149
+ `corrective-decisions.jsonl`, `handoffs.jsonl`
150
+ - milestone: `scope-change-events.jsonl`
151
+
152
+ Milestone scope-change recovery also uses Milestone-local `.transactions/` journal files.
153
+ Broken JSONL, duplicate event ids, broken hash chains, stale revision/hash/commit bindings,
154
+ or mismatched authority fail closed with structured diagnostics.
155
+
75
156
  ## Delegated approval
76
157
 
77
158
  Delegation never makes an agent a human actor. A user first approves an exact grant policy;
@@ -89,10 +170,33 @@ codex-workflow task authorize --repo . --id TASK-... --expected-revision 2 \
89
170
 
90
171
  Policies may allow only `project_memory.approve`, `task.execution_authorize`, `task.final_accept`,
91
172
  `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),
173
+ Milestone, or Task; Project Knowledge Map approval requires project scope. Alpha.6 does not
174
+ extend this allow-list to adoption apply, Milestone scope change, or other new human-only
175
+ actions. Revocation is immediate for future uses. The original human path remains available
176
+ and unchanged.
177
+
178
+ ## C1 handoff and legacy adoption
179
+
180
+ `C1` coordination uses `task handoff-prepare` (with `task handoff` retained as an alias),
181
+ `task claim --claim-token ...`, and `task handback-create` (with `task handback` retained as
182
+ an alias). `task handoff-show` returns the persisted safe bindings but never the plaintext
183
+ claim token. 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.6 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;