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
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
+ - optional time-bound delegated approval with project/Milestone/Task scope and an explicit audit trail;
19
24
  - Milestones aggregate already merged Tasks on the base branch, without an integration branch;
20
25
  - V1 transition is snapshot-only and never performs semantic import.
21
26
 
@@ -27,8 +32,8 @@ cross-machine synchronization are not part of its contract.
27
32
  Node.js 22 or newer is required. Consumers pin the exact package version:
28
33
 
29
34
  ```bash
30
- npm install --save-dev --save-exact codex-workflow-v2@2.0.0-alpha.3
31
- npx codex-workflow gateway handshake
35
+ npm install --save-dev --save-exact codex-workflow-v2@2.0.0-alpha.6
36
+ npx codex-workflow gateway handshake --repo .
32
37
  npx codex-workflow doctor --repo .
33
38
  ```
34
39
 
@@ -43,10 +48,21 @@ npm run plugin:check
43
48
  npm run release:check
44
49
  ```
45
50
 
46
- ## Typical Task flow
51
+ ## Alpha.6 Task flow
47
52
 
48
53
  The CLI emits JSON. Every update after creation requires the current state revision.
49
54
 
55
+ For a fresh alpha.6 project, registration writes the adoption posture automatically. For an
56
+ existing schema 2 project, apply adoption before execution:
57
+
58
+ ```bash
59
+ codex-workflow update preflight --repo .
60
+ codex-workflow state adoption-prepare --repo .
61
+ codex-workflow state adoption-apply --repo . --actor user:owner --confirmation-code ADA-...
62
+ ```
63
+
64
+ Do not use `state migrate` for alpha.6 adoption.
65
+
50
66
  ```bash
51
67
  codex-workflow project-memory scan --repo .
52
68
  codex-workflow project-memory approve --repo . --expected-revision 1 --file selections.json
@@ -55,23 +71,104 @@ codex-workflow discovery start --repo . --goal "..." --outcome "..." \
55
71
  codex-workflow discovery materialize --repo . --id DISC-... \
56
72
  --expected-revision 1 --kind task --title "..."
57
73
  codex-workflow task plan-set --repo . --id TASK-... \
58
- --expected-revision 1 --file plan.json
74
+ --expected-revision 1 --file plan.json --risk-audit-file plan-risk-audit.json
59
75
  codex-workflow task authorize --repo . --id TASK-... \
60
76
  --expected-revision 2 --actor user
61
77
  codex-workflow task start --repo . --id TASK-... \
62
78
  --expected-revision 3 --workspace-owner local
63
79
  codex-workflow task run --repo . --id TASK-... --step STEP-001 \
64
80
  --expected-revision 4 --owner worker
81
+ # Worker changes only allowed files and leaves them uncommitted.
82
+ codex-workflow task step-complete --repo . --id TASK-... --step STEP-001 \
83
+ --expected-revision 5 --writer-token <TOKEN-FROM-TASK-RUN>
65
84
  ```
66
85
 
67
- `task run` returns the writer token and Worker context. `task review-launch` starts the
68
- strict read-only reviewer after submission. If a completed Step changes approved project
86
+ `task run` returns the writer token and Worker context. The Worker must not stage or commit.
87
+ `task step-complete` runs configured checks, creates the workflow-owned atomic commit, and
88
+ either records completion immediately or leaves the Step non-terminal for `task step-review`
89
+ when the current Plan Risk Audit marks it for strict review.
90
+
91
+ The Plan Risk Audit is mandatory for every new alpha.6 Task before execution authorization,
92
+ including a positive `approved` decision for a Plan with no guarded Steps. The audit sidecar
93
+ must identify a Plan author and an independent auditor, classify every current Step exactly
94
+ once, describe guarded failure modes, and bind required evidence to exact executable Step
95
+ checks. `split-required` and `stop-escalate` block authorization.
96
+
97
+ `task review-launch` starts the strict read-only reviewer after submission. If a completed Step changes approved project
69
98
  knowledge, reconcile and approve the map, then run `task knowledge-rebind --repo . --id
70
99
  TASK-... --expected-revision ...`. The rebind changes no Step definition, preserves runtime
71
100
  status and evidence, supersedes execution authorization, and requires `task authorize`
72
101
  before another Step or submission. Use `next` after transitions.
73
102
 
74
- See [development flow](docs/development-flow.md), [updating an existing project](docs/updating-existing-project.md), [project memory](docs/project-memory.md),
103
+ When `next.contextRefresh` offers a delegated content-only option, the coordinator may use:
104
+
105
+ ```bash
106
+ codex-workflow task context-refresh --repo . --id TASK-... \
107
+ --expected-task-revision ... --expected-map-revision ... \
108
+ --actor agent:deputy --delegation-grant DGR-...
109
+ ```
110
+
111
+ New/removed sources, category/authority changes, gaps, or conflicts are never auto-approved.
112
+
113
+ ## Alpha.6 sidecars
114
+
115
+ Alpha.6 keeps canonical entity JSON unchanged and stores guardrail evidence in append-only
116
+ sidecars:
117
+
118
+ - project: `adoption-posture.jsonl`
119
+ - task: `plan-risk-audits.jsonl`, `step-review-events.jsonl`,
120
+ `reviewer-attestations.jsonl`, `remediation-events.jsonl`,
121
+ `corrective-decisions.jsonl`, `handoffs.jsonl`
122
+ - milestone: `scope-change-events.jsonl`
123
+
124
+ Milestone scope-change recovery also uses Milestone-local `.transactions/` journal files.
125
+ Broken JSONL, duplicate event ids, broken hash chains, stale revision/hash/commit bindings,
126
+ or mismatched authority fail closed with structured diagnostics.
127
+
128
+ ## Delegated approval
129
+
130
+ Delegation never makes an agent a human actor. A user first approves an exact grant policy;
131
+ later authorization events record the agent as `delegate`, the user as `principal`, the grant
132
+ ID, policy hash, transition, scope, and expiry. Existing schema 2 projects need no migration.
133
+
134
+ ```bash
135
+ codex-workflow delegation prepare --repo . --file delegation-policy.json
136
+ # After the user confirms the returned DGA code in a later message:
137
+ codex-workflow delegation grant --repo . --file delegation-policy.json \
138
+ --confirmation-code DGA-...
139
+ codex-workflow task authorize --repo . --id TASK-... --expected-revision 2 \
140
+ --actor agent:deputy --delegation-grant DGR-...
141
+ ```
142
+
143
+ Policies may allow only `project_memory.approve`, `task.execution_authorize`, `task.final_accept`,
144
+ `milestone.execution_authorize`, and/or `milestone.final_accept`. Scope is one project,
145
+ Milestone, or Task; Project Knowledge Map approval requires project scope. Alpha.6 does not
146
+ extend this allow-list to adoption apply, Milestone scope change, or other new human-only
147
+ actions. Revocation is immediate for future uses. The original human path remains available
148
+ and unchanged.
149
+
150
+ ## C1 handoff and legacy adoption
151
+
152
+ `C1` coordination uses `task handoff-prepare` (with `task handoff` retained as an alias),
153
+ `task claim --claim-token ...`, and `task handback-create` (with `task handback` retained as
154
+ an alias). `task handoff-show` returns the persisted safe bindings but never the plaintext
155
+ claim token. Preparation returns a one-time claim token and a prompt bound to `handoffId`, Task
156
+ revision, Brief/Plan/Knowledge hashes, Milestone display positions, delegate/grant, expiry,
157
+ and exact expected next action. Only the token hash is persisted. Milestone-linked Tasks must
158
+ be claimed before start; terminal handback records result, evidence, review, knowledge,
159
+ limitations, and recommended-next bindings. This does not prove a physically separate Codex
160
+ thread.
161
+
162
+ For legacy schema 2 projects:
163
+
164
+ - accepted/cancelled Milestones stay terminal;
165
+ - merged/cancelled Tasks stay terminal;
166
+ - completed and skipped Steps in active Tasks keep their recorded status and evidence;
167
+ - remaining non-completed, non-skipped legacy Steps need a bootstrap Plan Risk Audit at a
168
+ safe boundary;
169
+ - newly created Milestones, Tasks, and Steps use the full alpha.6 contract.
170
+
171
+ 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),
75
172
  [accepted decisions](docs/decisions.md), [validation report](docs/validation-report.md), and
76
173
  [release policy](docs/release.md).
77
174
 
@@ -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;