@chllming/wave-orchestration 0.7.1 → 0.7.3

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 (32) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +8 -8
  3. package/docs/plans/component-cutover-matrix.json +50 -3
  4. package/docs/plans/current-state.md +1 -1
  5. package/docs/plans/end-state-architecture.md +927 -0
  6. package/docs/plans/examples/wave-example-live-proof.md +1 -1
  7. package/docs/plans/migration.md +2 -2
  8. package/docs/plans/waves/wave-1.md +376 -0
  9. package/docs/plans/waves/wave-2.md +292 -0
  10. package/docs/plans/waves/wave-3.md +342 -0
  11. package/docs/plans/waves/wave-4.md +391 -0
  12. package/docs/plans/waves/wave-5.md +382 -0
  13. package/docs/plans/waves/wave-6.md +321 -0
  14. package/docs/reference/npmjs-trusted-publishing.md +2 -2
  15. package/docs/reference/sample-waves.md +4 -4
  16. package/package.json +1 -1
  17. package/releases/manifest.json +36 -0
  18. package/scripts/wave-orchestrator/agent-state.mjs +462 -35
  19. package/scripts/wave-orchestrator/artifact-schemas.mjs +81 -0
  20. package/scripts/wave-orchestrator/control-cli.mjs +7 -1
  21. package/scripts/wave-orchestrator/coordination.mjs +11 -10
  22. package/scripts/wave-orchestrator/human-input-workflow.mjs +289 -0
  23. package/scripts/wave-orchestrator/install.mjs +22 -0
  24. package/scripts/wave-orchestrator/launcher-derived-state.mjs +915 -0
  25. package/scripts/wave-orchestrator/launcher-gates.mjs +1061 -0
  26. package/scripts/wave-orchestrator/launcher-retry.mjs +873 -0
  27. package/scripts/wave-orchestrator/launcher-supervisor.mjs +704 -0
  28. package/scripts/wave-orchestrator/launcher.mjs +153 -2922
  29. package/scripts/wave-orchestrator/task-entity.mjs +557 -0
  30. package/scripts/wave-orchestrator/wave-files.mjs +11 -2
  31. package/scripts/wave-orchestrator/wave-state-reducer.mjs +566 -0
  32. package/wave.config.json +1 -1
@@ -0,0 +1,391 @@
1
+ # Wave 4 - State Reducer, Contradiction Entities, and Evidence Lineage
2
+
3
+ **Commit message**: `Arch: add wave state reducer, contradiction entities, and stable fact ids`
4
+
5
+ ## Component promotions
6
+
7
+ - state-artifacts-and-feedback: pilot-live
8
+
9
+ ## Context7 defaults
10
+
11
+ - bundle: node-typescript
12
+ - query: "Event sourcing reducers, DAG traversal, content hashing, and deterministic replay in Node.js"
13
+
14
+ ## Agent A0: cont-QA
15
+
16
+ ### Role prompts
17
+
18
+ - docs/agents/wave-cont-qa-role.md
19
+
20
+ ### Executor
21
+
22
+ - id: codex
23
+ - model: gpt-5-codex
24
+ - codex.profile_name: review
25
+ - codex.search: true
26
+ - codex.json: true
27
+
28
+ ### Context7
29
+
30
+ - bundle: none
31
+
32
+ ### Prompt
33
+
34
+ ```text
35
+ Primary goal:
36
+ - Verify that the reducer is a pure function, contradiction entities are normalized, and fact identity is stable.
37
+
38
+ Required context before coding:
39
+ - Read docs/plans/end-state-architecture.md (sections: Wave State Reducer, Contradiction, Fact/Evidence).
40
+ - Read docs/reference/repository-guidance.md.
41
+
42
+ Specific expectations:
43
+ - confirm reducer takes the canonical authority set (control-plane events, coordination records, agent result envelopes) and returns complete wave state
44
+ - confirm reducer has no side effects
45
+ - confirm contradiction entities have a proper state machine: detected → acknowledged → repair_in_progress → resolved | waived
46
+ - confirm fact IDs use stable semantic identity with separate contentHash, NOT pure content-addressable hashing
47
+ - confirm gate engine blocks closure on unresolved contradictions
48
+ - confirm replay tests feed stored events through the reducer and assert on output
49
+ - do not PASS if the reducer reads from any derived cache
50
+
51
+ File ownership (only touch these paths):
52
+ - docs/plans/waves/reviews/wave-4-cont-qa.md
53
+ ```
54
+
55
+ ## Agent A8: Integration Steward
56
+
57
+ ### Role prompts
58
+
59
+ - docs/agents/wave-integration-role.md
60
+
61
+ ### Executor
62
+
63
+ - id: claude
64
+ - model: claude-sonnet-4-6
65
+
66
+ ### Context7
67
+
68
+ - bundle: none
69
+
70
+ ### Capabilities
71
+
72
+ - integration
73
+ - contradiction-recovery
74
+ - docs-shared-plan
75
+
76
+ ### Prompt
77
+
78
+ ```text
79
+ Synthesize the reducer, contradiction entities, and evidence lineage changes.
80
+
81
+ Required context before coding:
82
+ - Read docs/plans/end-state-architecture.md.
83
+ - Read docs/reference/repository-guidance.md.
84
+ - Read docs/research/agent-context-sources.md.
85
+
86
+ Verify:
87
+ - reducer output matches live state produced by the phase engines
88
+ - contradiction entities integrate cleanly with the integration summary
89
+ - fact lineage connects: introduction → citation → contradiction → supersession → closure decision
90
+ - replay tests cover at least: normal completion, gate failure, retry, contradiction repair, human input timeout
91
+ - no circular dependency between reducer and any phase engine
92
+
93
+ File ownership (only touch these paths):
94
+ - .tmp/main-wave-launcher/integration/wave-4.md
95
+ - .tmp/main-wave-launcher/integration/wave-4.json
96
+ ```
97
+
98
+ ## Agent A9: Documentation Steward
99
+
100
+ ### Role prompts
101
+
102
+ - docs/agents/wave-documentation-role.md
103
+
104
+ ### Executor
105
+
106
+ - id: opencode
107
+ - opencode.files: docs/plans/end-state-architecture.md,docs/plans/current-state.md
108
+
109
+ ### Context7
110
+
111
+ - bundle: none
112
+
113
+ ### Prompt
114
+
115
+ ```text
116
+ Update shared plan docs to reflect the reducer, contradiction entities, and evidence lineage.
117
+
118
+ Required context before coding:
119
+ - Read docs/reference/repository-guidance.md.
120
+ - Read docs/research/agent-context-sources.md.
121
+
122
+ File ownership (only touch these paths):
123
+ - docs/plans/current-state.md
124
+ - docs/plans/master-plan.md
125
+ - docs/plans/migration.md
126
+ - docs/plans/wave-orchestrator.md
127
+ - docs/plans/component-cutover-matrix.md
128
+ - docs/plans/component-cutover-matrix.json
129
+ - docs/reference/proof-metrics.md
130
+ ```
131
+
132
+ ## Agent A1: Wave State Reducer
133
+
134
+ ### Executor
135
+
136
+ - profile: implement-fast
137
+ - model: gpt-5-codex
138
+ - codex.add_dirs: scripts,test
139
+ - fallbacks: claude, opencode
140
+
141
+ ### Context7
142
+
143
+ - bundle: node-typescript
144
+ - query: "Pure function reducers, event sourcing projection, deterministic state rebuild"
145
+
146
+ ### Components
147
+
148
+ - state-artifacts-and-feedback
149
+
150
+ ### Exit contract
151
+
152
+ - completion: contract
153
+ - durability: none
154
+ - proof: unit
155
+ - doc-impact: owned
156
+
157
+ ### Deliverables
158
+
159
+ - scripts/wave-orchestrator/wave-state-reducer.mjs
160
+ - test/wave-orchestrator/wave-state-reducer.test.ts
161
+
162
+ ### Proof artifacts
163
+
164
+ - path: .tmp/wave-4-state-proof/reducer-replay-summary.json | kind: replay-summary | required-for: pilot-live
165
+
166
+ ### Prompt
167
+
168
+ ```text
169
+ Implement the wave state reducer as a pure function.
170
+
171
+ The reducer consumes the canonical authority set:
172
+ - control-plane events (lifecycle, proof, gates, tasks, contradictions, facts)
173
+ - coordination records (requests, blockers, handoffs, clarifications, human feedback)
174
+ - agent result envelopes (structured results per attempt)
175
+
176
+ And returns complete wave state:
177
+ reduce(controlPlaneEvents, coordinationRecords, agentResultEnvelopes) → {
178
+ waveState, attempt, tasks (Map), taskGraph (DAG),
179
+ proofAvailability (Map), contradictions (Map), facts (Map),
180
+ openBlockers, gateVerdicts (Map), retryTargetSet,
181
+ closureEligibility: { allSlicesProven, closureReady, blockedReasons },
182
+ humanInputs (Map), assignments (Map), dependencies (Map),
183
+ coordinationMetrics
184
+ }
185
+
186
+ Design rules:
187
+ 1. Pure function — no side effects, no file reads, no fs writes.
188
+ 2. All inputs are passed in, not read from disk.
189
+ 3. Deterministic — same inputs always produce same output.
190
+ 4. The launcher calls reduce() at each phase boundary.
191
+ 5. Replay tests feed stored events through reduce() and assert.
192
+
193
+ Write comprehensive replay tests:
194
+ - Normal wave completion
195
+ - Gate failure and retry
196
+ - Shared-component sibling wait
197
+ - Contradiction detection and repair
198
+ - Human input timeout and escalation
199
+ - Proof bundle supersession
200
+ - Multi-attempt with executor fallback
201
+
202
+ Required context before coding:
203
+ - Read docs/reference/repository-guidance.md.
204
+ - Read docs/research/agent-context-sources.md.
205
+ - Read docs/plans/end-state-architecture.md (section: Wave State Reducer).
206
+ - Read scripts/wave-orchestrator/control-plane.mjs (event shape).
207
+ - Read scripts/wave-orchestrator/coordination-store.mjs (record shape).
208
+ - Read scripts/wave-orchestrator/task-entity.mjs (task graph shape from Wave 2).
209
+
210
+ File ownership (only touch these paths):
211
+ - scripts/wave-orchestrator/wave-state-reducer.mjs
212
+ - test/wave-orchestrator/wave-state-reducer.test.ts
213
+ - .tmp/wave-4-state-proof/
214
+ ```
215
+
216
+ ## Agent A2: Contradiction Entity
217
+
218
+ ### Executor
219
+
220
+ - profile: implement-fast
221
+ - model: gpt-5-codex
222
+ - codex.add_dirs: scripts,test
223
+ - fallbacks: claude, opencode
224
+
225
+ ### Context7
226
+
227
+ - bundle: node-typescript
228
+
229
+ ### Components
230
+
231
+ - state-artifacts-and-feedback
232
+
233
+ ### Exit contract
234
+
235
+ - completion: contract
236
+ - durability: none
237
+ - proof: unit
238
+ - doc-impact: none
239
+
240
+ ### Deliverables
241
+
242
+ - scripts/wave-orchestrator/contradiction-entity.mjs
243
+ - test/wave-orchestrator/contradiction-entity.test.ts
244
+
245
+ ### Proof artifacts
246
+
247
+ - path: .tmp/wave-4-state-proof/contradiction-lifecycle.json | kind: contradiction-log | required-for: pilot-live
248
+
249
+ ### Prompt
250
+
251
+ ```text
252
+ Implement the contradiction entity as a first-class control-plane type.
253
+
254
+ Contradiction schema:
255
+ {
256
+ contradictionId: string, // stable id, not content-addressed
257
+ waveNumber: number,
258
+ lane: string,
259
+ kind: "proof_conflict" | "integration_conflict" | "claim_conflict" |
260
+ "evidence_conflict" | "component_conflict",
261
+ status: "detected" | "acknowledged" | "repair_in_progress" |
262
+ "resolved" | "waived",
263
+ reportedBy: string,
264
+ reportedAt: ISO8601,
265
+ resolvedBy: string | null,
266
+ resolvedAt: ISO8601 | null,
267
+ parties: [{ agentId, claim, evidence }],
268
+ affectedTasks: [taskId],
269
+ affectedFacts: [factId],
270
+ repairWork: [{ taskId, status }] | null,
271
+ resolution: { kind, detail, evidence } | null,
272
+ supersedes: contradictionId | null
273
+ }
274
+
275
+ Implementation:
276
+ 1. Add contradiction entity type to control-plane schema.
277
+ 2. Add appendContradictionEvent to control-plane.mjs.
278
+ 3. Add materializeContradictions to the reducer.
279
+ 4. Update gate engine to block closure on unresolved material contradictions.
280
+ 5. Update integration summary to reference active contradictions by id.
281
+ 6. Write tests for the full contradiction lifecycle.
282
+
283
+ Required context before coding:
284
+ - Read docs/reference/repository-guidance.md.
285
+ - Read docs/research/agent-context-sources.md.
286
+ - Read docs/plans/end-state-architecture.md (section: Entity Model — Contradiction).
287
+ - Read docs/reference/proof-metrics.md (section: Current Limits).
288
+ - Read scripts/wave-orchestrator/wave-control-schema.mjs.
289
+ - Read scripts/wave-orchestrator/control-plane.mjs.
290
+
291
+ File ownership (only touch these paths):
292
+ - scripts/wave-orchestrator/contradiction-entity.mjs
293
+ - scripts/wave-orchestrator/wave-control-schema.mjs
294
+ - scripts/wave-orchestrator/control-plane.mjs
295
+ - scripts/wave-orchestrator/launcher-gates.mjs
296
+ - test/wave-orchestrator/contradiction-entity.test.ts
297
+ - .tmp/wave-4-state-proof/
298
+ ```
299
+
300
+ ## Agent A3: Stable Fact and Evidence Lineage
301
+
302
+ ### Executor
303
+
304
+ - profile: implement-fast
305
+ - model: gpt-5-codex
306
+ - codex.add_dirs: scripts,test
307
+ - fallbacks: claude, opencode
308
+
309
+ ### Context7
310
+
311
+ - bundle: node-typescript
312
+
313
+ ### Components
314
+
315
+ - state-artifacts-and-feedback
316
+
317
+ ### Exit contract
318
+
319
+ - completion: contract
320
+ - durability: none
321
+ - proof: unit
322
+ - doc-impact: none
323
+
324
+ ### Deliverables
325
+
326
+ - scripts/wave-orchestrator/fact-entity.mjs
327
+ - test/wave-orchestrator/fact-entity.test.ts
328
+
329
+ ### Proof artifacts
330
+
331
+ - path: .tmp/wave-4-state-proof/fact-lineage-report.json | kind: lineage-report | required-for: pilot-live
332
+
333
+ ### Prompt
334
+
335
+ ```text
336
+ Implement stable fact identifiers and evidence lineage.
337
+
338
+ Fact identity is NOT purely content-addressable. Facts carry:
339
+ - factId: stable semantic identifier (survives refinement, normalization, supersession)
340
+ - contentHash: SHA256 of canonical statement (useful for dedup, but not the identity)
341
+ - version: increments when content is refined
342
+ - supersedes: factId of prior version
343
+ - status: "active" | "superseded" | "retracted"
344
+
345
+ Fact schema:
346
+ {
347
+ factId: string,
348
+ contentHash: string,
349
+ version: number,
350
+ waveNumber: number,
351
+ lane: string,
352
+ introducedBy: string,
353
+ introducedAt: ISO8601,
354
+ kind: "claim" | "proof" | "observation" | "decision" | "evidence",
355
+ content: string,
356
+ sourceArtifact: { path, kind, sha256 } | null,
357
+ citedBy: [{ entityType, entityId, context }],
358
+ contradictedBy: [contradictionId],
359
+ supersedes: factId | null,
360
+ supersededBy: factId | null,
361
+ status: "active" | "superseded" | "retracted"
362
+ }
363
+
364
+ The system should be able to answer:
365
+ - what fact was introduced
366
+ - where it was cited
367
+ - what contradicted it
368
+ - what superseded it
369
+ - which closure decision depended on it
370
+
371
+ Implementation:
372
+ 1. Add fact entity type to control-plane schema.
373
+ 2. Implement fact lifecycle in fact-entity.mjs.
374
+ 3. Link facts to contradictions via affectedFacts.
375
+ 4. Link facts to proof bundles and gate decisions via citedBy.
376
+ 5. Add fact materialization to the reducer.
377
+
378
+ Required context before coding:
379
+ - Read docs/reference/repository-guidance.md.
380
+ - Read docs/research/agent-context-sources.md.
381
+ - Read docs/plans/end-state-architecture.md (section: Entity Model — Fact/Evidence).
382
+ - Read docs/reference/proof-metrics.md (section: Current Limits re stable fact ids).
383
+ - Read scripts/wave-orchestrator/wave-control-schema.mjs.
384
+
385
+ File ownership (only touch these paths):
386
+ - scripts/wave-orchestrator/fact-entity.mjs
387
+ - scripts/wave-orchestrator/wave-control-schema.mjs
388
+ - scripts/wave-orchestrator/control-plane.mjs
389
+ - test/wave-orchestrator/fact-entity.test.ts
390
+ - .tmp/wave-4-state-proof/
391
+ ```