codex-workflow-v2 2.0.0-beta.1 → 2.0.0-beta.11

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 (187) hide show
  1. package/README.md +94 -12
  2. package/dist/src/alpha6/adoption.js +13 -3
  3. package/dist/src/alpha6/adoption.js.map +1 -1
  4. package/dist/src/alpha6/handoff.d.ts +26 -2
  5. package/dist/src/alpha6/handoff.js +277 -29
  6. package/dist/src/alpha6/handoff.js.map +1 -1
  7. package/dist/src/alpha6/mechanical-feasibility.d.ts +7 -0
  8. package/dist/src/alpha6/mechanical-feasibility.js +303 -0
  9. package/dist/src/alpha6/mechanical-feasibility.js.map +1 -0
  10. package/dist/src/alpha6/milestone.d.ts +37 -2
  11. package/dist/src/alpha6/milestone.js +472 -33
  12. package/dist/src/alpha6/milestone.js.map +1 -1
  13. package/dist/src/alpha6/plan-integrity.d.ts +14 -0
  14. package/dist/src/alpha6/plan-integrity.js +127 -0
  15. package/dist/src/alpha6/plan-integrity.js.map +1 -0
  16. package/dist/src/alpha6/plan-risk.d.ts +1 -0
  17. package/dist/src/alpha6/plan-risk.js +15 -7
  18. package/dist/src/alpha6/plan-risk.js.map +1 -1
  19. package/dist/src/alpha6/remediation.d.ts +2 -1
  20. package/dist/src/alpha6/remediation.js +186 -9
  21. package/dist/src/alpha6/remediation.js.map +1 -1
  22. package/dist/src/alpha6/review.d.ts +3 -0
  23. package/dist/src/alpha6/review.js +24 -0
  24. package/dist/src/alpha6/review.js.map +1 -1
  25. package/dist/src/cli.js +486 -46
  26. package/dist/src/cli.js.map +1 -1
  27. package/dist/src/contracts.d.ts +238 -6
  28. package/dist/src/contracts.js +1 -1
  29. package/dist/src/credential-output.d.ts +10 -0
  30. package/dist/src/credential-output.js +73 -0
  31. package/dist/src/credential-output.js.map +1 -0
  32. package/dist/src/dependency-provenance.d.ts +19 -0
  33. package/dist/src/dependency-provenance.js +185 -0
  34. package/dist/src/dependency-provenance.js.map +1 -0
  35. package/dist/src/errors.d.ts +1 -1
  36. package/dist/src/errors.js.map +1 -1
  37. package/dist/src/git.d.ts +1 -1
  38. package/dist/src/git.js +13 -5
  39. package/dist/src/git.js.map +1 -1
  40. package/dist/src/index.d.ts +2 -1
  41. package/dist/src/index.js +2 -1
  42. package/dist/src/index.js.map +1 -1
  43. package/dist/src/lifecycle/canonical-hash.d.ts +6 -0
  44. package/dist/src/lifecycle/canonical-hash.js +24 -0
  45. package/dist/src/lifecycle/canonical-hash.js.map +1 -0
  46. package/dist/src/lifecycle/catalog.d.ts +26 -0
  47. package/dist/src/lifecycle/catalog.js +208 -0
  48. package/dist/src/lifecycle/catalog.js.map +1 -0
  49. package/dist/src/lifecycle/compiler-inspection.d.ts +48 -0
  50. package/dist/src/lifecycle/compiler-inspection.js +29 -0
  51. package/dist/src/lifecycle/compiler-inspection.js.map +1 -0
  52. package/dist/src/lifecycle/core-static-readiness.d.ts +6 -0
  53. package/dist/src/lifecycle/core-static-readiness.js +130 -0
  54. package/dist/src/lifecycle/core-static-readiness.js.map +1 -0
  55. package/dist/src/lifecycle/corrective-replan-authority.d.ts +53 -0
  56. package/dist/src/lifecycle/corrective-replan-authority.js +139 -0
  57. package/dist/src/lifecycle/corrective-replan-authority.js.map +1 -0
  58. package/dist/src/lifecycle/corrective-replan-binding-manifest.d.ts +21 -0
  59. package/dist/src/lifecycle/corrective-replan-binding-manifest.js +35 -0
  60. package/dist/src/lifecycle/corrective-replan-binding-manifest.js.map +1 -0
  61. package/dist/src/lifecycle/corrective-replan-credential-core.d.ts +86 -0
  62. package/dist/src/lifecycle/corrective-replan-credential-core.js +563 -0
  63. package/dist/src/lifecycle/corrective-replan-credential-core.js.map +1 -0
  64. package/dist/src/lifecycle/corrective-replan-credential-schema.d.ts +17 -0
  65. package/dist/src/lifecycle/corrective-replan-credential-schema.js +44 -0
  66. package/dist/src/lifecycle/corrective-replan-credential-schema.js.map +1 -0
  67. package/dist/src/lifecycle/corrective-replan-credentials.d.ts +47 -0
  68. package/dist/src/lifecycle/corrective-replan-credentials.js +103 -0
  69. package/dist/src/lifecycle/corrective-replan-credentials.js.map +1 -0
  70. package/dist/src/lifecycle/corrective-replan.d.ts +64 -0
  71. package/dist/src/lifecycle/corrective-replan.js +553 -0
  72. package/dist/src/lifecycle/corrective-replan.js.map +1 -0
  73. package/dist/src/lifecycle/evaluator.d.ts +2 -0
  74. package/dist/src/lifecycle/evaluator.js +35 -0
  75. package/dist/src/lifecycle/evaluator.js.map +1 -0
  76. package/dist/src/lifecycle/fingerprint.d.ts +31 -0
  77. package/dist/src/lifecycle/fingerprint.js +388 -0
  78. package/dist/src/lifecycle/fingerprint.js.map +1 -0
  79. package/dist/src/lifecycle/immutable.d.ts +1 -0
  80. package/dist/src/lifecycle/immutable.js +10 -0
  81. package/dist/src/lifecycle/immutable.js.map +1 -0
  82. package/dist/src/lifecycle/implementation-table.d.ts +29 -0
  83. package/dist/src/lifecycle/implementation-table.js +87 -0
  84. package/dist/src/lifecycle/implementation-table.js.map +1 -0
  85. package/dist/src/lifecycle/index.d.ts +4 -0
  86. package/dist/src/lifecycle/index.js +5 -0
  87. package/dist/src/lifecycle/index.js.map +1 -0
  88. package/dist/src/lifecycle/schema-artifact.d.ts +12 -0
  89. package/dist/src/lifecycle/schema-artifact.js +214 -0
  90. package/dist/src/lifecycle/schema-artifact.js.map +1 -0
  91. package/dist/src/lifecycle/semantic-registry.d.ts +6 -0
  92. package/dist/src/lifecycle/semantic-registry.js +489 -0
  93. package/dist/src/lifecycle/semantic-registry.js.map +1 -0
  94. package/dist/src/lifecycle/types.d.ts +718 -0
  95. package/dist/src/lifecycle/types.js +4 -0
  96. package/dist/src/lifecycle/types.js.map +1 -0
  97. package/dist/src/observation.d.ts +20 -0
  98. package/dist/src/observation.js +171 -0
  99. package/dist/src/observation.js.map +1 -0
  100. package/dist/src/reviewer.d.ts +43 -1
  101. package/dist/src/reviewer.js +203 -50
  102. package/dist/src/reviewer.js.map +1 -1
  103. package/dist/src/state/corrective-replan-executor.d.ts +64 -0
  104. package/dist/src/state/corrective-replan-executor.js +608 -0
  105. package/dist/src/state/corrective-replan-executor.js.map +1 -0
  106. package/dist/src/state/corrective-replan-public-schema.d.ts +3 -0
  107. package/dist/src/state/corrective-replan-public-schema.js +43 -0
  108. package/dist/src/state/corrective-replan-public-schema.js.map +1 -0
  109. package/dist/src/state/corrective-replan-public.d.ts +95 -0
  110. package/dist/src/state/corrective-replan-public.js +665 -0
  111. package/dist/src/state/corrective-replan-public.js.map +1 -0
  112. package/dist/src/state/corrective-replan-transaction.d.ts +160 -0
  113. package/dist/src/state/corrective-replan-transaction.js +730 -0
  114. package/dist/src/state/corrective-replan-transaction.js.map +1 -0
  115. package/dist/src/state/corrective-yield-executor.d.ts +31 -0
  116. package/dist/src/state/corrective-yield-executor.js +236 -0
  117. package/dist/src/state/corrective-yield-executor.js.map +1 -0
  118. package/dist/src/state/corrective-yield-transaction.d.ts +97 -0
  119. package/dist/src/state/corrective-yield-transaction.js +591 -0
  120. package/dist/src/state/corrective-yield-transaction.js.map +1 -0
  121. package/dist/src/state/lock.d.ts +76 -3
  122. package/dist/src/state/lock.js +611 -30
  123. package/dist/src/state/lock.js.map +1 -1
  124. package/dist/src/state/store.d.ts +3 -0
  125. package/dist/src/state/store.js +65 -12
  126. package/dist/src/state/store.js.map +1 -1
  127. package/dist/src/transition-core.d.ts +67 -0
  128. package/dist/src/transition-core.js +318 -0
  129. package/dist/src/transition-core.js.map +1 -0
  130. package/dist/src/version.d.ts +1 -1
  131. package/dist/src/version.js +1 -1
  132. package/dist/src/version.js.map +1 -1
  133. package/dist/src/workflow.d.ts +88 -24
  134. package/dist/src/workflow.js +1647 -270
  135. package/dist/src/workflow.js.map +1 -1
  136. package/docs/autonomy-guardrails.md +61 -1
  137. package/docs/beta11-plan-integrity-recovery-brief.md +38 -0
  138. package/docs/beta2-initial-assembly-navigation-brief.md +616 -0
  139. package/docs/delegated-approval.md +26 -1
  140. package/docs/development-flow.md +63 -8
  141. package/docs/lifecycle/state-machine-stabilization.md +641 -0
  142. package/docs/pdf/README.md +24 -0
  143. package/docs/pdf/codex-workflow-v2-architecture-ru.pdf +0 -0
  144. package/docs/pdf/codex-workflow-v2-chat-only-guide-ru.pdf +0 -0
  145. package/docs/pdf/codex-workflow-v2-technical-reference-ru.pdf +0 -0
  146. package/docs/pdf/requirements.txt +1 -0
  147. package/docs/pdf/sources/codex-workflow-v2-architecture-ru.md +234 -0
  148. package/docs/pdf/sources/codex-workflow-v2-chat-only-guide-ru.md +334 -0
  149. package/docs/pdf/sources/codex-workflow-v2-technical-reference-ru.md +413 -0
  150. package/docs/problem-briefs/01-pre-implementation-integrity.md +478 -0
  151. package/docs/problem-briefs/02-minimal-step-integrity.md +411 -0
  152. package/docs/problem-briefs/03-minimal-agent-context-integrity.md +358 -0
  153. package/docs/problem-briefs/04-task-dependency-and-structural-replacement-integrity.md +566 -0
  154. package/docs/problem-briefs/BRIEF-TEMPLATE.md +56 -0
  155. package/docs/problem-briefs/README.md +120 -0
  156. package/docs/problem-briefs/evidence/p01-mechanical-feasibility-corpus.md +90 -0
  157. package/docs/problem-briefs/evidence/signal-v4-pre-m3-replay.md +246 -0
  158. package/docs/release.md +30 -6
  159. package/docs/split-required-recovery.md +19 -25
  160. package/docs/stable-release-defect-register.md +465 -3
  161. package/docs/updating-existing-project.md +59 -4
  162. package/docs/validation-report.md +124 -56
  163. package/package.json +9 -1
  164. package/plugins/codex-workflow-gateway/.codex-plugin/plugin.json +10 -3
  165. package/plugins/codex-workflow-gateway/references/protocol.md +92 -4
  166. package/plugins/codex-workflow-gateway/scripts/chat-registry.mjs +376 -0
  167. package/plugins/codex-workflow-gateway/skills/codex-workflow-gateway/SKILL.md +263 -4
  168. package/references/state-machine.md +13 -6
  169. package/roles/delivery-coordinator.md +39 -0
  170. package/schemas/adoption-posture-event.schema.json +1 -1
  171. package/schemas/authorization-event.schema.json +64 -1
  172. package/schemas/context-envelope.schema.json +1 -1
  173. package/schemas/corrective-decision-event.schema.json +48 -3
  174. package/schemas/corrective-replan-credentials.private.schema.json +98 -0
  175. package/schemas/corrective-replan-execution-event.private.schema.json +53 -0
  176. package/schemas/corrective-replan-public.schema.json +142 -0
  177. package/schemas/corrective-replan-task-transaction.private.schema.json +151 -0
  178. package/schemas/corrective-yield-task-transaction.private.schema.json +98 -0
  179. package/schemas/milestone-scope-change-event.schema.json +6 -1
  180. package/schemas/milestone.schema.json +6 -1
  181. package/schemas/remediation-event.schema.json +11 -1
  182. package/schemas/task-handoff-event.schema.json +19 -3
  183. package/schemas/task.schema.json +24 -1
  184. package/schemas/transition-definition.schema.json +2609 -0
  185. package/schemas/transition-payloads.schema.json +140 -0
  186. package/scripts/generate-pdf-docs.py +512 -0
  187. package/scripts/run-pdf-docs.mjs +62 -0
@@ -0,0 +1,566 @@
1
+ ---
2
+ brief_id: WF2-P04
3
+ problem: "Milestone Task execution is not guarded by explicit canonical dependencies"
4
+ status: approved
5
+ owner: null
6
+ created_at: 2026-08-23
7
+ approved_at: 2026-08-24
8
+ implemented_at: null
9
+ revision: 5
10
+ ---
11
+
12
+ # Brief — P04-A Task Dependency Integrity
13
+
14
+ ## 0. Evidence and scope
15
+
16
+ The normal Task dependency gap is **confirmed**.
17
+
18
+ Current Milestone membership represents:
19
+
20
+ ```text
21
+ taskId
22
+ disposition
23
+ reason
24
+ ```
25
+
26
+ It has no canonical Task dependency edges. `startTask` checks that the Milestone is active and the
27
+ Task membership is required, but it does not check predecessor completion. Consequently, user or
28
+ Coordinator intent such as “Required Tasks execute sequentially” is not enforced by Core.
29
+
30
+ Current beta replacement already atomically updates Discovery, old Task, one replacement Task,
31
+ Milestone plan/state, Knowledge Map when eligible, and writer-lock state. It is a 1→1 operation and
32
+ does not preserve completed Steps or rewire downstream Tasks.
33
+
34
+ This brief implements **P04-A only**:
35
+
36
+ ```text
37
+ canonical Task dependencies
38
+ -> graph validation
39
+ -> runnable computation
40
+ -> guarded routing, claim, lease acquisition, and direct start
41
+ ```
42
+
43
+ It does not implement structural replacement. Until separate replacement authority exists, the
44
+ current 1→1 route always fails closed; even an empty historical edge set cannot authorize the new
45
+ Task boundary or topology.
46
+
47
+ Old active-M3 recovery, historical replacement IDs, and old T07/T08/T09/T10 topology are excluded
48
+ from mandatory materialization evidence. The implementation is validated from a clean pre-Milestone
49
+ repository and fresh Discovery.
50
+
51
+ ## 1. Problem
52
+
53
+ Milestone execution permission is currently derived from Task-local status and required membership.
54
+ Membership order or Coordinator convention may influence which Task is selected, but neither is
55
+ canonical dependency authority.
56
+
57
+ Required rule:
58
+
59
+ > A Task may start only when all explicit canonical predecessor Tasks are satisfied.
60
+
61
+ Ordinal and membership position remain display, history, and deterministic tie-break information.
62
+ They cannot create or satisfy a dependency.
63
+
64
+ ## 2. Required invariants
65
+
66
+ ### INV-1 — Dependencies are explicit
67
+
68
+ A Task dependency exists only as a canonical Task-to-Task edge supplied by current
69
+ Discovery/Milestone decomposition authority and committed in the Milestone Plan.
70
+
71
+ ### INV-2 — Runnable depends on predecessors
72
+
73
+ ```text
74
+ TASK_RUNNABLE =
75
+ task_execution_eligible
76
+ AND all_required_predecessors_satisfied
77
+ ```
78
+
79
+ ### INV-3 — Every execution entry point uses the same predicate
80
+
81
+ Core applies the predecessor predicate to repository navigation, scheduling, Task routing, handoff
82
+ preparation, `task claim`, writer-lease acquisition, and direct `task start`. Authorization does not
83
+ make a dependency-blocked Task runnable. A caller cannot bypass the graph by invoking a mutation
84
+ directly.
85
+
86
+ ### INV-4 — Ordinal is not dependency semantics
87
+
88
+ Membership position, display number, Task ID age, title, filename, and Coordinator prose cannot
89
+ create, remove, or satisfy an edge.
90
+
91
+ ### INV-5 — Independent Tasks remain independent
92
+
93
+ Workflow does not add edges merely to preserve a previous sequential scheduler policy. Scheduler
94
+ policy chooses only after the complete runnable set is computed.
95
+
96
+ ### INV-6 — Decomposition owns topology; Core validates it
97
+
98
+ Existing Discovery/Milestone planning supplies explicit provider/consumer Task mappings. P04 binds
99
+ those mappings to concrete Task IDs and validates their structure. It does not require P01 to be
100
+ implemented first.
101
+
102
+ If deferred P01-B is later approved and implemented, it strengthens semantic admission by
103
+ validating prerequisite, provider, output, and ownership facts before P04 receives the concrete
104
+ edge. P01-A does not provide those facts. P04 does not duplicate that semantic model, and Core
105
+ never infers a provider from prose, ordinals, titles, or paths.
106
+
107
+ ### INV-7 — Existing Milestone authority binds the graph
108
+
109
+ Task dependencies are part of the Milestone Plan and membership authority. Existing
110
+ `milestone.revision`, `membershipRevision`, and `planHash` invalidate stale authorization and role
111
+ context when the relevant dependency view changes.
112
+
113
+ ### INV-8 — Task and Step dependencies are separate
114
+
115
+ P02 Step dependencies do not automatically create Task edges. Task edges do not modify Step Plans.
116
+
117
+ ### INV-9 — Unknown dependency state is not permission
118
+
119
+ New Milestone Plans explicitly declare an array for every membership, including `[]`. Missing
120
+ dependency data in legacy active state cannot be interpreted as proof that the Task is independent.
121
+
122
+ ### INV-10 — Dependency mutation is atomic
123
+
124
+ Memberships, dependency arrays, Milestone revisions, Plan hash, and authorization supersession are
125
+ committed through the required Milestone Plan/scope-change transaction. P04-A must add this boundary
126
+ to initial Plan commit where it is currently absent. No partial graph is observable after rejection
127
+ or recovery.
128
+
129
+ ## 3. P04-A solution
130
+
131
+ ### A. Canonical dependency representation
132
+
133
+ Extend Milestone membership or use an equivalent normalized representation:
134
+
135
+ ```text
136
+ MilestoneMembership {
137
+ taskId
138
+ disposition
139
+ reason
140
+ dependsOnTaskIds[]
141
+ }
142
+ ```
143
+
144
+ The direction is exact:
145
+
146
+ ```text
147
+ consumer.dependsOnTaskIds = [provider]
148
+ ```
149
+
150
+ Every new canonical membership contains the field. An empty array means known independent under the
151
+ approved Milestone Plan; absence does not mean the same thing.
152
+
153
+ No separate dependency registry, Contract Registry, graph credential, or per-edge lifecycle is
154
+ introduced.
155
+
156
+ ### B. Graph validation
157
+
158
+ Before Milestone Plan commit or authorization:
159
+
160
+ - every membership declares `dependsOnTaskIds`, including an explicit empty array;
161
+ - every dependency target exists;
162
+ - every target belongs to the same Milestone;
163
+ - duplicate edges are rejected before hashing;
164
+ - each valid dependency array is sorted by exact Task ID before Plan hashing and persistence;
165
+ - self-edges and cycles are rejected;
166
+ - a required consumer cannot depend on a waived or cancelled provider;
167
+ - independent Tasks receive no inferred edges;
168
+ - the canonical arrays are included in the Milestone Plan hash;
169
+ - ambiguous semantic provider selection returns to decomposition authority; Scheduler does not
170
+ guess.
171
+
172
+ P04 validates the supplied graph. Before P01-B or equivalent semantic authority exists, semantic
173
+ correctness remains the responsibility of the existing decomposition/Plan review boundary rather
174
+ than a claim made mechanically by Core.
175
+
176
+ ### C. Runnable predicate
177
+
178
+ For each active required Task:
179
+
180
+ ```text
181
+ predecessor satisfied =
182
+ predecessor membership is required
183
+ AND predecessor Task status is merged
184
+ ```
185
+
186
+ The initial implementation uses `merged` because current Milestone validation already treats merged
187
+ required Tasks as completed. No alternative terminal status is invented.
188
+
189
+ Routing computes the complete runnable set first. Existing sequential scheduling may choose one
190
+ Task from that set, using ordinal only as a deterministic tie-break. If two independent Tasks are
191
+ runnable, sequential execution remains permitted but no artificial edge is recorded.
192
+
193
+ ### D. Guards on navigation, handoff, claim, and start
194
+
195
+ The same predicate governs:
196
+
197
+ - repository `next` and Task-specific `next` routing;
198
+ - scheduler selection;
199
+ - C1 handoff preparation;
200
+ - C1 `task claim` and writer-lease acquisition;
201
+ - direct `task start`;
202
+ - any equivalent direct mutation that begins execution.
203
+
204
+ A prepared or approved Task becomes non-runnable if its relevant Milestone dependency authority
205
+ changes. A prepared handoff is bound to the current Milestone revision, membership revision, and
206
+ Plan hash; a change makes it unclaimable. Both `task claim` and `task start` re-read current
207
+ Milestone state and cannot rely only on an older routing result or credential. A dependency-blocked
208
+ claim must not acquire or retain a writer lease.
209
+
210
+ For a Milestone-linked Task, the canonical handoff event and its credential projection add exactly:
211
+
212
+ ```text
213
+ dependencyBinding {
214
+ milestoneRevision
215
+ membershipRevision
216
+ milestonePlanHash
217
+ }
218
+ ```
219
+
220
+ The existing top-level `milestoneId` identifies the Milestone and is not duplicated inside the
221
+ binding. The claim token remains bound to the handoff event as today. Claim validates the stored
222
+ binding against current Milestone authority before writer-lease acquisition. Standalone Tasks use
223
+ `dependencyBinding: null`. No dependency data or credential is copied into chat evidence.
224
+
225
+ Execution authorization may exist before predecessors merge, but it does not bypass dependencies.
226
+ Existing base-HEAD and authorization freshness rules remain independently applicable.
227
+
228
+ ### E. Freshness and atomic Milestone binding
229
+
230
+ Reuse existing authority:
231
+
232
+ ```text
233
+ milestone revision
234
+ membership revision
235
+ Milestone plan hash
236
+ Task revision where already required
237
+ ```
238
+
239
+ Do not add `dependencyGraphRevision` unless implementation proves that these bindings cannot safely
240
+ identify dependency changes.
241
+
242
+ Initial assembly, Plan amendment, membership evolution, and any other operation that changes
243
+ dependencies must validate the complete candidate graph before writes.
244
+
245
+ Current scope-change apply already has a Milestone transaction/recovery boundary. Current initial
246
+ `setMilestonePlan` does not: it stages the Plan artifact, writes Milestone state, and publishes the
247
+ artifact as separate operations. P04-A must move that initial transition onto the existing
248
+ transaction/journal mechanism, or an equivalent atomic store primitive, before dependency data can
249
+ become execution authority.
250
+
251
+ Both initial Plan commit and later scope change commit, as one recoverable logical change:
252
+
253
+ ```text
254
+ memberships and dependency arrays
255
+ membershipRevision and Milestone revision
256
+ Milestone Plan artifact and planHash
257
+ execution-authorization supersession
258
+ ```
259
+
260
+ A validation failure, injected write failure, process interruption, or recovery cannot leave
261
+ membership state, dependency authority, Plan artifact, and Plan hash at different revisions. The
262
+ initial empty Milestone posture must remain intact when initial Plan commit fails.
263
+
264
+ ### F. Legacy-state policy
265
+
266
+ Historical stored memberships may lack `dependsOnTaskIds`.
267
+
268
+ Compatibility rules:
269
+
270
+ - accepted or cancelled terminal Milestones remain readable; their missing dependency data is
271
+ projected as legacy/unknown and is never reconstructed from ordinal;
272
+ - terminal historical state does not become execution authority;
273
+ - a nonterminal legacy Milestone with unstarted required Tasks cannot authorize, hand off, claim,
274
+ or start those Tasks until an explicit Milestone Plan amendment declares the complete dependency
275
+ arrays;
276
+ - the amendment uses the existing scope-change, Plan-hash, revision, and reauthorization rules;
277
+ - fresh Milestones and every newly written Plan require explicit arrays;
278
+ - absence is never silently persisted again as canonical `[]`.
279
+
280
+ The exact compatibility decoder may represent the legacy distinction internally without adding a
281
+ new durable authority object.
282
+
283
+ ### G. Read-only diagnostics and context projection
284
+
285
+ Dependency blocking must be observable. Repository `next`, Task-specific `next`, and `milestone
286
+ progress` expose a read-only projection sufficient to report:
287
+
288
+ ```text
289
+ taskId
290
+ dependsOnTaskIds
291
+ unsatisfiedPredecessorTaskIds
292
+ predecessor Task status
293
+ dependency-blocked reason
294
+ ```
295
+
296
+ When no Task is runnable because of dependencies, navigation returns the exact blocking
297
+ predecessors rather than an unexplained absence of work or an unrelated Task.
298
+
299
+ P04 owns the canonical edges and status projection. P03, if later approved, may include only the
300
+ relevant projection in role context; it cannot recompute or edit the graph.
301
+
302
+ ### H. Temporary fail-closed replacement boundary
303
+
304
+ P04-A does not implement structural replacement, but it must define how the existing 1→1
305
+ `replacement-materialize` transition behaves after dependencies become canonical.
306
+
307
+ Before any replacement writes, Core may compute incident edges for diagnostics:
308
+
309
+ ```text
310
+ incoming prerequisites = oldTask.dependsOnTaskIds
311
+ downstream consumers = memberships whose dependsOnTaskIds contain oldTaskId
312
+ ```
313
+
314
+ Temporary rule:
315
+
316
+ - every `replacement-materialize` attempt is rejected before mutation with an explicit
317
+ `structural-replacement-required` diagnostic, including legacy/unknown dependency state and a
318
+ canonical empty edge set;
319
+ - no dependency is copied, removed, or rewired automatically;
320
+ - no new lifecycle stage or replacement credential is introduced;
321
+ - rejection leaves Discovery, old Task, replacement Task, Milestone, Knowledge Map, lock state,
322
+ revisions, Plan artifact, and authorization unchanged.
323
+
324
+ An isolated historical Task is not an exception. `split-required` proves that its boundary changes;
325
+ an empty historical edge set does not prove that the replacement has no prerequisites or consumers.
326
+ Allowing the new membership to inherit `[]` would silently make a new semantic claim. This is
327
+ intentionally a safe stop until a later structural-replacement brief supplies a complete
328
+ decomposition-authorized candidate membership and topology.
329
+
330
+ ### I. Validation
331
+
332
+ #### I.1 Contract tests
333
+
334
+ - missing dependency array on a new Plan is rejected;
335
+ - explicit empty array is accepted as known independent;
336
+ - missing target and dependency outside the Milestone are rejected;
337
+ - duplicate, self, and cyclic edges cannot commit;
338
+ - dependency-array input order is normalized deterministically after duplicate rejection;
339
+ - ordinal without an edge creates no dependency;
340
+ - required consumer depending on waived/cancelled provider fails closed;
341
+ - Step dependencies remain unchanged.
342
+
343
+ #### I.2 Guard tests
344
+
345
+ - unsatisfied predecessor blocks repository navigation and direct start;
346
+ - Task-specific navigation cannot select a dependency-blocked Task;
347
+ - handoff preparation is blocked until predecessors merge;
348
+ - all predecessors merged permits routing and start;
349
+ - authorization alone does not bypass the predicate;
350
+ - dependency change invalidates stale routing/context and supersedes authorization as applicable;
351
+ - dependency change makes an older prepared handoff unclaimable;
352
+ - direct claim of a dependency-blocked Task is rejected without acquiring a writer lease;
353
+ - two independent Tasks are both runnable before scheduler tie-break.
354
+
355
+ #### I.3 Legacy tests
356
+
357
+ - terminal legacy Milestone without arrays remains readable and non-executable;
358
+ - ordinal is not used to reconstruct legacy edges;
359
+ - active legacy Milestone with unstarted Tasks fails closed;
360
+ - explicit Plan amendment produces canonical arrays and requires fresh authorization;
361
+ - newly written state never omits the field.
362
+
363
+ #### I.4 Replacement-boundary tests
364
+
365
+ - an isolated historical Task still blocks replacement before writes;
366
+ - an incoming predecessor reports the incident edge and blocks replacement before writes;
367
+ - a downstream consumer reports the incident edge and blocks replacement before writes;
368
+ - combined incoming and downstream edges remain unchanged after rejection;
369
+ - no Task, Discovery, Milestone, Knowledge, lock, artifact, sidecar, or authorization partial write
370
+ survives rejection or injected failure.
371
+
372
+ #### I.5 Fresh synthetic E2E
373
+
374
+ Use a new Milestone assembled from a clean repository and fresh Discovery:
375
+
376
+ ```text
377
+ Contracts
378
+ -> Exact root
379
+ -> Deterministic formalization
380
+ -> Extraction adapter
381
+ -> Evidence ledger
382
+ -> Delivery runtime
383
+ -> Acceptance host
384
+ ```
385
+
386
+ Expected:
387
+
388
+ - only Tasks with satisfied explicit predecessors are initially runnable;
389
+ - completion exposes exactly the next semantically declared consumer;
390
+ - a direct start of a blocked Task is rejected;
391
+ - no edge or result depends on Task IDs from a historical Milestone;
392
+ - repeated replay produces the same graph, diagnostics, and runnable set.
393
+
394
+ This graph is synthetic validation evidence, not a claim that production Signal semantics or
395
+ deployment topology are decided.
396
+
397
+ #### I.6 Independent and fan-in controls
398
+
399
+ For:
400
+
401
+ ```text
402
+ A -> C
403
+ B -> C
404
+ ```
405
+
406
+ A and B are independently runnable; C waits for both. Sequential scheduling remains permitted but
407
+ does not add A→B or B→A.
408
+
409
+ #### I.7 Property and transaction tests
410
+
411
+ For generated Milestone graphs verify:
412
+
413
+ - no cycle or dangling edge can commit;
414
+ - every runnable Task has only satisfied predecessors;
415
+ - adding an unrelated completed Task does not change another branch's runnable state;
416
+ - ordinal permutations do not change dependency permission;
417
+ - the same normalized Plan with different dependency-array input order yields the same Plan hash
418
+ and runnable set;
419
+ - rejected and fault-injected scope-change transactions preserve the complete previous graph and
420
+ authority;
421
+ - rejected, interrupted, and recovered initial Plan commits preserve either the complete initial
422
+ empty posture or the complete new Plan, never a state/artifact split.
423
+
424
+ #### I.8 Successful-Milestone controls
425
+
426
+ Replay completed non-replacement Milestones:
427
+
428
+ - Tasks with explicit empty arrays remain runnable under existing policy;
429
+ - valid sequential dependencies can be represented explicitly;
430
+ - no new user-visible lifecycle stage is introduced;
431
+ - ambiguous historical order is reported as unknown rather than reconstructed.
432
+
433
+ ### J. Deferred structural replacement integrity
434
+
435
+ Not part of P04-A:
436
+
437
+ - 1→N split materialization;
438
+ - requirement and acceptance redistribution;
439
+ - dependency rewiring from a superseded Task to replacements;
440
+ - downstream provider rebinding and fan-in evolution;
441
+ - transfer or adoption of completed Step commits;
442
+ - replacement topology inference;
443
+ - crash testing of a multi-Task graph rewrite.
444
+
445
+ Confirmed residual facts:
446
+
447
+ - current 1→1 replacement is already atomic and should be extended rather than replaced;
448
+ - automatic transfer of completed Step commits is not currently defined;
449
+ - safe future adoption requires exact commit, Step-definition, postcondition, base, and verification
450
+ evidence rather than silently copying completed state;
451
+ - replacement topology must come from decomposition authority;
452
+ - after P04-A, every replacement safely stops until this authority exists.
453
+
454
+ A separate P05 is preferred because structural replacement also owns scope redistribution and
455
+ completed-work adoption, not only graph mutation. If kept under P04, it must be a separately
456
+ materialized P04-B with independent acceptance criteria and replay.
457
+
458
+ ## 4. Dependencies and conflicts
459
+
460
+ - P04-A can be implemented before P01 using explicit mappings from existing Discovery/Milestone
461
+ planning authority.
462
+ - Deferred P01-B, if approved, owns semantic prerequisite, output, ownership, and
463
+ ambiguous-provider admission. P01-A does not. Neither owns concrete graph storage or runnable
464
+ computation.
465
+ - P02 owns Step dependencies independently.
466
+ - P03 may project P04 facts only after P04 authority exists.
467
+ - Current 1→1 replacement is blocked under the temporary rule in section H, including when the
468
+ historical Task has no incident edges.
469
+ - P05 or P04-B owns dependency-bearing replacement, 1→N topology, residual scope, and completed-work
470
+ adoption.
471
+ - Existing `membershipRevision`, Milestone revision, and Plan hash are preferred over a new graph
472
+ revision.
473
+
474
+ ## 5. Design approval gate
475
+
476
+ P04-A is the recommended first implementation brief. It may move from `hypothesis` to `approved`
477
+ only when a design review confirms that:
478
+
479
+ 1. `dependsOnTaskIds[]` has one canonical direction and duplicate edges are rejected.
480
+ 2. The predecessor predicate is shared by navigation, handoff preparation, claim, writer-lease
481
+ acquisition, and start.
482
+ 3. Handoff freshness binds to existing Milestone revision, membership revision, and Plan hash.
483
+ 4. Initial `setMilestonePlan` and later scope changes have one explicit atomic/recovery strategy.
484
+ 5. All replacement attempts fail before writes until P05/P04-B supplies complete topology
485
+ authority.
486
+ 6. Legacy absence remains distinguishable from canonical `[]`.
487
+ 7. The declared tests cover failure, recovery, independent Tasks, fan-in, and successful controls.
488
+
489
+ No implementation result is required for this design approval; the tests below are the
490
+ `approved -> implemented` gate.
491
+
492
+ ## 6. Implementation acceptance
493
+
494
+ P04-A may move from `approved` to `implemented` only when:
495
+
496
+ 1. Every new canonical Milestone membership stores an explicit dependency array.
497
+ 2. Missing, external, duplicate, self, and cyclic edges cannot commit.
498
+ 3. Runnable computation uses dependencies rather than ordinal.
499
+ 4. Navigation, handoff preparation, `task claim`, writer-lease acquisition, and direct `task start`
500
+ enforce the same predicate.
501
+ 5. Independent Tasks receive no artificial edges.
502
+ 6. Existing decomposition authority can supply edges without requiring P01 implementation.
503
+ 7. Ambiguous provider selection returns to decomposition authority rather than Scheduler inference.
504
+ 8. Existing Milestone revisions and hashes invalidate stale dependency views and authorization.
505
+ 9. Initial Plan commit and later scope changes commit graph and Milestone authority atomically and
506
+ recover without state/artifact divergence.
507
+ 10. Legacy terminal state remains readable but cannot become execution authority.
508
+ 11. Active legacy state fails closed until an explicit dependency Plan is approved.
509
+ 12. `next` and `milestone progress` identify exact unsatisfied predecessors.
510
+ 13. Every replacement attempt fails before writes, including for an isolated historical Task.
511
+ 14. P01 semantic facts are not duplicated by a Contract Registry.
512
+ 15. P02 Step dependencies remain unchanged.
513
+ 16. Fresh synthetic replay is deterministic.
514
+ 17. Successful non-replacement Milestones receive no systematic false blockers.
515
+ 18. No new user-visible lifecycle stage, dependency credential, parallel scheduler, or parent/child
516
+ Task lifecycle is introduced.
517
+ 19. Multi-Task replacement, rewiring, scope redistribution, and completed-Step adoption remain out
518
+ of P04-A.
519
+
520
+ ## 7. Non-goals
521
+
522
+ - structural replacement or completed-Step adoption;
523
+ - automatic dependency inference from text, filenames, titles, or ordinal;
524
+ - semantic prerequisite/output registry;
525
+ - Step reslicing;
526
+ - parallel execution;
527
+ - parent/child Tasks;
528
+ - Context Graph;
529
+ - replacement-specific lifecycle or credential;
530
+ - reconstruction of historical dependencies.
531
+
532
+ ## 8. Decision log
533
+
534
+ - 2026-08-23 — Revision 1 created as `hypothesis` combining Task dependency and structural
535
+ replacement concerns.
536
+ - 2026-08-24 — Source inspection confirmed missing normal Task dependency authority.
537
+ - 2026-08-24 — Existing atomic 1→1 replacement recognized; the original claim that replacement is
538
+ generally non-atomic was rejected.
539
+ - 2026-08-24 — Revision 2 limited implementation to normal Task dependency and runnable semantics;
540
+ 1→N replacement, completed-Step adoption, and downstream rewiring were deferred.
541
+ - 2026-08-24 — Mandatory old-M3 topology removed; fresh synthetic Task graph made the approval
542
+ replay.
543
+ - 2026-08-24 — Existing Milestone revision, membership revision, and Plan hash preferred over a new
544
+ dependency graph authority.
545
+ - 2026-08-24 — Revision 3 structured P04 as independently materializable P04-A, removed the hard
546
+ dependency on P01, added legacy-state policy, atomic binding, read-only diagnostics, and a
547
+ fail-closed boundary for dependency-bearing 1→1 replacement.
548
+ - 2026-08-24 — Revision 4 rejected duplicate edges, added an exact claim/lease freshness guard,
549
+ required initial Plan commit to join the transaction/recovery boundary, and blocked even isolated
550
+ replacement because an old empty edge set cannot authorize new topology.
551
+ - 2026-08-24 — P04-A designated the recommended first implementation brief; design approval and
552
+ implementation acceptance were separated.
553
+ - 2026-08-24 — Design review accepted: existing Milestone transaction machinery is the required
554
+ initial-Plan strategy, and the temporary fail-closed replacement boundary is accepted.
555
+ - 2026-08-24 — Status moved from `hypothesis` to `approved`; implementation has not started at this
556
+ decision boundary.
557
+ - 2026-08-24 — Revision 5 implementation candidate completed on
558
+ `codex/p04-task-dependencies`: canonical dependency arrays and DAG validation, shared runnable
559
+ guards, dependency-bound C1 handoff/claim/start, two-target initial Plan transaction/recovery,
560
+ legacy read/fail-closed policy, diagnostics, and unconditional pre-write structural-replacement
561
+ shutdown are present. Typecheck, plugin/schema validation, focused fault/replay tests, and the
562
+ full 306/306 regression suite passed. Status remains `approved` until the candidate is
563
+ merged/installed and accepted under the registry's implementation gate.
564
+ - 2026-08-24 — The exact final combined P04-A/P01-A suite passed 319/319. The packaged handshake now
565
+ advertises dependency DAG, atomic initial Plan, and structural-replacement-disabled capabilities
566
+ instead of the unavailable legacy replacement capability. Status remains `approved`.
@@ -0,0 +1,56 @@
1
+ ---
2
+ brief_id: WF2-PXX
3
+ problem: "TBD"
4
+ status: hypothesis
5
+ owner: null
6
+ created_at: 2026-08-23
7
+ approved_at: null
8
+ implemented_at: null
9
+ revision: 1
10
+ ---
11
+
12
+ # Brief — TBD
13
+
14
+ ## 1. What we solve
15
+
16
+ TBD
17
+
18
+ ## 2. How we solve it
19
+
20
+ TBD
21
+
22
+ ## 3. Why this approach
23
+
24
+ TBD
25
+
26
+ ## 4. Validation plan
27
+
28
+ TBD
29
+
30
+ ## Design approval gate
31
+
32
+ Define the problem/root-cause evidence, closed design decisions, dependency/conflict resolution, and
33
+ pre-implementation replay required to move this brief from `hypothesis` to `approved`. Do not make
34
+ tests that require the proposed code a circular prerequisite for design approval.
35
+
36
+ ## Implementation acceptance
37
+
38
+ Define the contract, E2E, regression, compatibility, and fault-injection evidence required to move
39
+ the approved brief to `implemented` after the code is merged/installed.
40
+
41
+ ## Dependencies and conflicts
42
+
43
+ TBD
44
+
45
+ ## Recommended go/no-go
46
+
47
+ Record `GO`, conditional `GO`, or `NO-GO`, the exact unresolved gate, and the required implementation
48
+ order. This recommendation does not change frontmatter status.
49
+
50
+ ## Non-goals
51
+
52
+ TBD
53
+
54
+ ## Decision log
55
+
56
+ - 2026-08-23 — Brief created with status `hypothesis`.