@dzhechkov/p-replicator 1.10.4 → 1.13.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 (136) hide show
  1. package/.dz-manifest.json +312 -76
  2. package/CHANGELOG.md +232 -0
  3. package/MULTIPLATFORM_ROADMAP.md +1 -1
  4. package/README/eng/01_quickstart.md +3 -3
  5. package/README/eng/02_user_guide.md +1 -1
  6. package/README/eng/03_admin_guide.md +2 -2
  7. package/README/eng/04_api_reference.md +11 -5
  8. package/README/eng/05_architecture.md +1 -1
  9. package/README/eng/README.md +2 -1
  10. package/README/ru/01_quickstart.md +3 -3
  11. package/README/ru/02_user_guide.md +1 -1
  12. package/README/ru/03_admin_guide.md +2 -2
  13. package/README/ru/04_api_reference.md +11 -5
  14. package/README/ru/05_architecture.md +1 -1
  15. package/README/ru/README.md +2 -1
  16. package/README/ru/html/index.html +9 -9
  17. package/README.md +278 -39
  18. package/package.json +5 -4
  19. package/sbom.json +665 -75
  20. package/scripts/check-pipeline-gaps.sh +413 -0
  21. package/src/commands/doctor.js +94 -4
  22. package/src/commands/init.js +1 -1
  23. package/src/rule-components.json +15 -0
  24. package/src/utils.js +35 -11
  25. package/templates/.claude/agents/harvest-coordinator.md +10 -1
  26. package/templates/.claude/agents/product-discoverer.md +38 -0
  27. package/templates/.claude/agents/replicate-coordinator.md +11 -1
  28. package/templates/.claude/commands/feature.md +81 -9
  29. package/templates/.claude/commands/go.md +9 -0
  30. package/templates/.claude/commands/harvest.md +39 -3
  31. package/templates/.claude/commands/myinsights.md +21 -26
  32. package/templates/.claude/commands/replicate.md +171 -37
  33. package/templates/.claude/commands/start.md +29 -0
  34. package/templates/.claude/hooks/capture-source-path.cjs +795 -0
  35. package/templates/.claude/hooks/check-canon.cjs +493 -0
  36. package/templates/.claude/hooks/check-embed-contract.cjs +374 -0
  37. package/templates/.claude/hooks/check-external-deps.cjs +288 -0
  38. package/templates/.claude/hooks/check-file-ownership.cjs +424 -0
  39. package/templates/.claude/hooks/check-handoff-manifest.cjs +367 -0
  40. package/templates/.claude/hooks/check-job-contract.cjs +501 -0
  41. package/templates/.claude/hooks/check-look-origin.cjs +240 -0
  42. package/templates/.claude/hooks/check-look-trace.cjs +385 -0
  43. package/templates/.claude/hooks/check-metric-source.cjs +296 -0
  44. package/templates/.claude/hooks/check-model-cost.cjs +470 -0
  45. package/templates/.claude/hooks/check-ports.cjs +434 -24
  46. package/templates/.claude/hooks/check-source-version.cjs +312 -0
  47. package/templates/.claude/hooks/check-swarm-receipts.cjs +197 -0
  48. package/templates/.claude/hooks/check-webhook-contract.cjs +535 -0
  49. package/templates/.claude/hooks/session-insights.cjs +158 -25
  50. package/templates/.claude/hooks/statusline.cjs +2 -2
  51. package/templates/.claude/hooks/write-insight.cjs +253 -0
  52. package/templates/.claude/rules/cost-of-detection-ladder.md +96 -0
  53. package/templates/.claude/rules/docker-ports.md +41 -19
  54. package/templates/.claude/rules/embeddable-widget.md +73 -0
  55. package/templates/.claude/rules/feature-lifecycle.md +13 -3
  56. package/templates/.claude/rules/honest-configuration.md +54 -0
  57. package/templates/.claude/rules/incoming-webhooks.md +99 -0
  58. package/templates/.claude/rules/insights-capture.md +10 -5
  59. package/templates/.claude/rules/long-running-job.md +73 -0
  60. package/templates/.claude/rules/model-call-cost.md +85 -0
  61. package/templates/.claude/rules/replicate-pipeline.md +123 -52
  62. package/templates/.claude/rules/skill-interface-protocol.md +1 -0
  63. package/templates/.claude/rules/swarm-file-evidence.md +46 -0
  64. package/templates/.claude/settings.json +13 -1
  65. package/templates/.claude/skills/brutal-honesty-review/SKILL.md +9 -0
  66. package/templates/.claude/skills/cc-toolkit-generator-enhanced/SKILL.md +4 -0
  67. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/03-generate-p0.md +46 -1
  68. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/04-generate-p1.md +7 -1
  69. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/06-package-deliver.md +20 -2
  70. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/claude-md-strategy.md +7 -0
  71. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/automation-commands.md +17 -0
  72. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/feature-lifecycle-ent.md +43 -5
  73. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/feature-lifecycle.md +43 -7
  74. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/start-command.md +19 -1
  75. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/swarm-file-evidence.md +151 -0
  76. package/templates/.claude/skills/goap-research-ed25519/SKILL.md +37 -22
  77. package/templates/.claude/skills/goap-research-ed25519/references/negative-results.md +94 -0
  78. package/templates/.claude/skills/goap-research-ed25519/scripts/check_report_evidence.py +368 -4
  79. package/templates/.claude/skills/goap-research-ed25519/scripts/ed25519_verifier.py +122 -5
  80. package/templates/.claude/skills/goap-research-ed25519/scripts/evidence_fetch.py +33 -16
  81. package/templates/.claude/skills/goap-research-ed25519/scripts/quote_provenance.py +342 -0
  82. package/templates/.claude/skills/goap-research-ed25519/scripts/test_ed25519_verifier.py +60 -0
  83. package/templates/.claude/skills/goap-research-ed25519/scripts/test_evidence_provenance.py +139 -6
  84. package/templates/.claude/skills/goap-research-ed25519/scripts/test_quote_provenance.py +274 -0
  85. package/templates/.claude/skills/goap-research-ed25519/scripts/test_suite_completeness.py +2 -1
  86. package/templates/.claude/skills/knowledge-extractor/SKILL.md +4 -0
  87. package/templates/.claude/skills/knowledge-extractor/modules/01-agent-review.md +16 -5
  88. package/templates/.claude/skills/pipeline-forge/SKILL.md +18 -23
  89. package/templates/.claude/skills/pipeline-forge/examples/replicate-analysis.md +7 -2
  90. package/templates/.claude/skills/pipeline-forge/references/patterns-catalog.md +19 -1
  91. package/templates/.claude/skills/pipeline-forge/references/self-extracted-patterns.md +17 -6
  92. package/templates/.claude/skills/pipeline-forge/references/skill-anatomy.md +0 -1
  93. package/templates/.claude/skills/reverse-engineering-unicorn/modules/025-cjm-prototype.md +21 -1
  94. package/templates/.claude/skills/sparc-prd-mini/SKILL.md +234 -716
  95. package/tests/e2e/lifecycle.test.js +55 -9
  96. package/tests/e2e/packed-insights-writer.test.js +308 -0
  97. package/tests/fixtures/prep-traceability-fixture/docs/features/order-refund/01_specification.md +29 -0
  98. package/tests/fixtures/prep-traceability-fixture/docs/features/order-refund/02_pseudocode.md +57 -0
  99. package/tests/snapshot/baseline.json +72 -46
  100. package/tests/snapshot/templates.test.js +47 -0
  101. package/tests/unit/absence-is-not-emptiness.test.js +15 -1
  102. package/tests/unit/capture-source-path.test.js +492 -0
  103. package/tests/unit/check-canon.test.js +403 -0
  104. package/tests/unit/check-embed-contract.test.js +422 -0
  105. package/tests/unit/check-external-deps.test.js +363 -0
  106. package/tests/unit/check-file-ownership.test.js +388 -0
  107. package/tests/unit/check-handoff-manifest.test.js +410 -0
  108. package/tests/unit/check-job-contract.test.js +514 -0
  109. package/tests/unit/check-look-origin.test.js +180 -0
  110. package/tests/unit/check-look-trace.test.js +420 -0
  111. package/tests/unit/check-metric-source.test.js +325 -0
  112. package/tests/unit/check-model-cost.test.js +425 -0
  113. package/tests/unit/check-pipeline-gaps.test.js +94 -0
  114. package/tests/unit/check-ports.test.js +773 -2
  115. package/tests/unit/check-source-version.test.js +344 -0
  116. package/tests/unit/check-swarm-receipts.test.js +231 -0
  117. package/tests/unit/check-webhook-contract.test.js +536 -0
  118. package/tests/unit/db-port-rule.test.js +43 -6
  119. package/tests/unit/detection-ladder-contract.test.js +302 -0
  120. package/tests/unit/detection-ladder-registry.test.js +52 -0
  121. package/tests/unit/doctor-insight-flow.test.js +315 -0
  122. package/tests/unit/external-dependency-check.test.js +19 -19
  123. package/tests/unit/generator-swarm-contract.test.js +287 -0
  124. package/tests/unit/guard-honest-input-meta.test.js +64 -0
  125. package/tests/unit/honest-failure-rules.test.js +574 -0
  126. package/tests/unit/hooks-project-anchored.test.js +67 -3
  127. package/tests/unit/insights-docs-tell-the-truth.test.js +52 -31
  128. package/tests/unit/insights-dz-delegation.test.js +197 -0
  129. package/tests/unit/insights-writer.test.js +285 -0
  130. package/tests/unit/look-phase-contract.test.js +231 -0
  131. package/tests/unit/negative-conclusion-gate.test.js +300 -0
  132. package/tests/unit/quote-provenance.test.js +122 -0
  133. package/tests/unit/shipped-suite-context.test.js +3 -1
  134. package/tests/unit/traceability-machine-ids.test.js +413 -0
  135. package/tests/unit/traceability-negative-fixture.test.js +322 -0
  136. package/tests/unit/utils.test.js +40 -2
@@ -149,8 +149,8 @@ Use swarm of agents to validate:
149
149
  | validator-coherence | All docs cross-ref | PRD↔DDD↔ADR↔C4 consistency |
150
150
 
151
151
  **Iterative loop (max 3 iterations):**
152
- 1. Run all validators in parallel (Task tool)
153
- 2. Aggregate gaps and blocked items
152
+ 1. Run all validators in parallel (Task tool), under the positive file receipt contract below
153
+ 2. Aggregate gaps and blocked items — only from validators whose receipt is terminal-completed
154
154
  3. Fix gaps in documents
155
155
  4. Re-validate
156
156
  5. Repeat until: no BLOCKED items, average score ≥70
@@ -175,9 +175,24 @@ When documentation is ready for implementation:
175
175
  4. Generate tests from Gherkin .feature files
176
176
  5. Validate Fitness Functions during implementation
177
177
  6. Save frequent commits to GitHub
178
+ 7. Validate every trace before merge or integration
179
+
180
+ #### Positive file receipt (required)
181
+
182
+ Before dispatch, allocate one `RUN_ID` and, for every unit, a unique `WORK_UNIT_ID` plus an
183
+ absolute `TRACE_PATH` unique to `(RUN_ID, WORK_UNIT_ID)`; record the launch instant and pass both
184
+ fields to the worker. Each worker must write a substantive body ending in `Status: completed` or
185
+ `Status: failed` to `TRACE_PATH` before it returns its one-line pointer. Before merge, verify every
186
+ path is a regular non-symlink file, non-whitespace, post-launch, and terminal. Narrative output or
187
+ silence is never a receipt. Name missing, stale, partial, unreadable, duplicate, failed, dead-PID,
188
+ or probe-error units and refuse merge, aggregation, or completion until every required receipt is
189
+ valid and completed. Run `node .claude/hooks/check-swarm-receipts.cjs <manifest>` — exit 0 all
190
+ completed, exit 1 undelivered or failed, exit 2 the check did not run. See
191
+ `.claude/rules/swarm-file-evidence.md` for mechanics and the bounded non-atomic-write exception.
178
192
 
179
193
  **Implementation rules:**
180
- - Each Bounded Context gets its own Task for parallel execution
194
+ - Each Bounded Context gets its own Task for parallel execution, with its own `WORK_UNIT_ID` and
195
+ `TRACE_PATH`
181
196
  - Reference docs (pseudocode, DDD tactical, ADR), don't hallucinate code
182
197
  - Commit after each logical unit: `feat(<feature-name>): <what>`
183
198
  - Run tests from .feature files in parallel with implementation
@@ -207,8 +222,9 @@ Use swarm of agents for review:
207
222
  Process:
208
223
  1. Run brutal-honesty-review on implementation
209
224
  2. Verify ADR compliance — each decision reflected in code
210
- 3. Verify Fitness Functions pass
211
- 4. Fix identified issues (use Task tool for parallel fixes)
225
+ 3. Verify Fitness Functions pass — every review agent delivers under the same positive file
226
+ receipt contract as Phase 3; a reviewer that returned nothing did not review
227
+ 4. Fix identified issues (use Task tool for parallel fixes, same contract)
212
228
  5. Save frequent commits: `fix(<feature-name>): <what>`
213
229
  6. Benchmark performance after implementation
214
230
  7. Re-review critical findings until clean
@@ -302,6 +318,24 @@ Enterprise features with complex domains follow the 4-phase lifecycle:
302
318
 
303
319
  ### Implementation (Phase 3)
304
320
  - One parallel Task per Bounded Context
321
+
322
+ #### Positive file receipt (required)
323
+
324
+ Before dispatch, allocate one `RUN_ID` and, for every unit, a unique `WORK_UNIT_ID` plus an
325
+ absolute `TRACE_PATH` unique to `(RUN_ID, WORK_UNIT_ID)`; record the launch instant and pass both
326
+ fields to the worker. Each worker must write a substantive body ending in `Status: completed` or
327
+ `Status: failed` to `TRACE_PATH` before it returns its one-line pointer. Before merge, verify every
328
+ path is a regular non-symlink file, non-whitespace, post-launch, and terminal. Narrative output or
329
+ silence is never a receipt. Name missing, stale, partial, unreadable, duplicate, failed, dead-PID,
330
+ or probe-error units and refuse merge, aggregation, or completion until every required receipt is
331
+ valid and completed. Run `node .claude/hooks/check-swarm-receipts.cjs <manifest>` — exit 0 all
332
+ completed, exit 1 undelivered or failed, exit 2 the check did not run. See
333
+ `.claude/rules/swarm-file-evidence.md` for mechanics and the bounded non-atomic-write exception.
334
+
335
+ Why the file and not the reply: a worker that died looks exactly like a worker still running —
336
+ both are silent — so a coordinator can report in good faith that a Bounded Context is under way
337
+ when nothing is running. A named file turns that into a fact a machine can check.
338
+
305
339
  - Read pseudocode .pseudo files — don't hallucinate code
306
340
  - Enforce aggregate invariants from DDD tactical docs
307
341
  - Generate test stubs from Gherkin .feature files
@@ -388,6 +422,10 @@ Complex domain features use the enterprise lifecycle: `/feature-ent [name]`
388
422
  3. **IMPLEMENT** — parallel agents per Bounded Context from validated docs
389
423
  4. **REVIEW** — brutal-honesty-review swarm (6 agents) → ADR + fitness verified
390
424
 
425
+ Every swarm phase delivers under `.claude/rules/swarm-file-evidence.md`: each parallel unit writes
426
+ a file at a named `TRACE_PATH`, and an agent's reply is a pointer, never the result. Verify with
427
+ `node .claude/hooks/check-swarm-receipts.cjs <manifest>` before merging anything.
428
+
391
429
  Use `/feature` for simple features, `/feature-ent` for complex domain features.
392
430
 
393
431
  Available enterprise lifecycle skills in `.claude/skills/`:
@@ -133,8 +133,8 @@ Use swarm of agents to validate:
133
133
  | validator-coherence | All SPARC files | Cross-reference consistency |
134
134
 
135
135
  **Iterative loop (max 3 iterations):**
136
- 1. Run all validators in parallel (Task tool)
137
- 2. Aggregate gaps and blocked items
136
+ 1. Run all validators in parallel (Task tool), under the positive file receipt contract below
137
+ 2. Aggregate gaps and blocked items — only from validators whose receipt is terminal-completed
138
138
  3. Fix gaps in SPARC documents
139
139
  4. Re-validate
140
140
  5. Repeat until: no BLOCKED items, average score ≥70
@@ -156,10 +156,24 @@ When SPARC plan is ready for implementation:
156
156
  - Implementation agents — parallel Task tool for independent modules
157
157
  3. **Make implementation modular** for reuse in other cases and applications
158
158
  4. Save frequent commits to GitHub
159
- 5. Spawn concurrent tasks to speed up development
159
+ 5. Spawn concurrent tasks to speed up development, under the contract below
160
+ 6. Validate every trace before merge or integration
161
+
162
+ #### Positive file receipt (required)
163
+
164
+ Before dispatch, allocate one `RUN_ID` and, for every unit, a unique `WORK_UNIT_ID` plus an
165
+ absolute `TRACE_PATH` unique to `(RUN_ID, WORK_UNIT_ID)`; record the launch instant and pass both
166
+ fields to the worker. Each worker must write a substantive body ending in `Status: completed` or
167
+ `Status: failed` to `TRACE_PATH` before it returns its one-line pointer. Before merge, verify every
168
+ path is a regular non-symlink file, non-whitespace, post-launch, and terminal. Narrative output or
169
+ silence is never a receipt. Name missing, stale, partial, unreadable, duplicate, failed, dead-PID,
170
+ or probe-error units and refuse merge, aggregation, or completion until every required receipt is
171
+ valid and completed. Run `node .claude/hooks/check-swarm-receipts.cjs <manifest>` — exit 0 all
172
+ completed, exit 1 undelivered or failed, exit 2 the check did not run. See
173
+ `.claude/rules/swarm-file-evidence.md` for mechanics and the bounded non-atomic-write exception.
160
174
 
161
175
  **Implementation rules:**
162
- - Each module gets its own Task for parallel execution
176
+ - Each module gets its own Task for parallel execution, with its own `WORK_UNIT_ID` and `TRACE_PATH`
163
177
  - Reference SPARC docs, don't hallucinate code
164
178
  - Commit after each logical unit: `feat(<feature-name>): <what>`
165
179
  - Run tests in parallel with implementation
@@ -185,8 +199,9 @@ Use swarm of agents for review:
185
199
  | testing | Test coverage | Edge cases, missing tests |
186
200
 
187
201
  Process:
188
- 1. Run brutal-honesty-review on implementation
189
- 2. Fix identified issues (use Task tool for parallel fixes)
202
+ 1. Run brutal-honesty-review on implementation — every review agent delivers under the same
203
+ positive file receipt contract as Phase 3; a reviewer that returned nothing did not review
204
+ 2. Fix identified issues (use Task tool for parallel fixes, same contract)
190
205
  3. Save frequent commits: `fix(<feature-name>): <what>`
191
206
  4. Benchmark after implementation
192
207
  5. Re-review critical findings until clean
@@ -265,8 +280,25 @@ Every new feature MUST follow the 4-phase lifecycle:
265
280
  - Run tests in parallel with development
266
281
  - Format: `feat(<feature-name>): <description>`
267
282
 
283
+ #### Positive file receipt (required)
284
+
285
+ Before dispatch, allocate one `RUN_ID` and, for every unit, a unique `WORK_UNIT_ID` plus an
286
+ absolute `TRACE_PATH` unique to `(RUN_ID, WORK_UNIT_ID)`; record the launch instant and pass both
287
+ fields to the worker. Each worker must write a substantive body ending in `Status: completed` or
288
+ `Status: failed` to `TRACE_PATH` before it returns its one-line pointer. Before merge, verify every
289
+ path is a regular non-symlink file, non-whitespace, post-launch, and terminal. Narrative output or
290
+ silence is never a receipt. Name missing, stale, partial, unreadable, duplicate, failed, dead-PID,
291
+ or probe-error units and refuse merge, aggregation, or completion until every required receipt is
292
+ valid and completed. Run `node .claude/hooks/check-swarm-receipts.cjs <manifest>` — exit 0 all
293
+ completed, exit 1 undelivered or failed, exit 2 the check did not run. See
294
+ `.claude/rules/swarm-file-evidence.md` for mechanics and the bounded non-atomic-write exception.
295
+
296
+ Why the file and not the reply: a worker that died looks exactly like a worker still running —
297
+ both are silent — so a coordinator can report in good faith that work is under way when none is.
298
+ A named file turns that into a fact a machine can check.
299
+
268
300
  ### Review (Phase 4)
269
- - Use brutal-honesty-review with swarm of agents
301
+ - Use brutal-honesty-review with swarm of agents, under the same positive file receipt contract
270
302
  - No sugar-coating — find real problems
271
303
  - Fix all critical and major issues before marking complete
272
304
  - Benchmark performance after implementation
@@ -323,6 +355,10 @@ New features use the 4-phase lifecycle: `/feature [name]`
323
355
  3. **IMPLEMENT** — parallel agents from validated docs
324
356
  4. **REVIEW** — brutal-honesty-review swarm → fix all criticals
325
357
 
358
+ Every swarm phase delivers under `.claude/rules/swarm-file-evidence.md`: each parallel unit writes
359
+ a file at a named `TRACE_PATH`, and an agent's reply is a pointer, never the result. Verify with
360
+ `node .claude/hooks/check-swarm-receipts.cjs <manifest>` before merging anything.
361
+
326
362
  Available lifecycle skills in `.claude/skills/`:
327
363
  - `sparc-prd-mini` (orchestrator, delegates to explore, goap-research, problem-solver-enhanced)
328
364
  - `explore` (Socratic questioning → Product Brief)
@@ -54,8 +54,25 @@ Generate:
54
54
  {{PACKAGE_FILE_LIST}}
55
55
 
56
56
  **Commits:** {{PACKAGE_COMMITS}}
57
+ **Receipt:** write the substantive summary to `TRACE_PATH`, terminal line last, then reply one line.
57
58
  {{/FOR_EACH_PACKAGE}}
58
59
 
60
+ #### Positive file receipt (required)
61
+
62
+ Before dispatch, allocate one `RUN_ID` and, for every unit, a unique `WORK_UNIT_ID` plus an
63
+ absolute `TRACE_PATH` unique to `(RUN_ID, WORK_UNIT_ID)`; record the launch instant and pass both
64
+ fields to the worker. Each worker must write a substantive body ending in `Status: completed` or
65
+ `Status: failed` to `TRACE_PATH` before it returns its one-line pointer. Before merge, verify every
66
+ path is a regular non-symlink file, non-whitespace, post-launch, and terminal. Narrative output or
67
+ silence is never a receipt. Name missing, stale, partial, unreadable, duplicate, failed, dead-PID,
68
+ or probe-error units and refuse merge, aggregation, or completion until every required receipt is
69
+ valid and completed. Run `node .claude/hooks/check-swarm-receipts.cjs <manifest>` — exit 0 all
70
+ completed, exit 1 undelivered or failed, exit 2 the check did not run. See
71
+ `.claude/rules/swarm-file-evidence.md` for mechanics and the bounded non-atomic-write exception.
72
+
73
+ Phase 3 may not begin until that check exits 0. A package Task that produced no trace produced no
74
+ package, however confidently it reported.
75
+
59
76
  ### Phase 3: Integration (sequential)
60
77
 
61
78
  1. **Verify cross-package imports** (shared modules used correctly)
@@ -177,7 +194,8 @@ Check Architecture.md for database presence:
177
194
  ### Key Principles
178
195
 
179
196
  1. **Docs as source of truth** — every Task must reference specific docs, never generate from memory
180
- 2. **Maximize parallelism** — independent packages run as parallel Tasks
197
+ 2. **Maximize parallelism** — independent packages run as parallel Tasks, each delivering its own
198
+ file receipt; a Task's reply is a pointer, never the result
181
199
  3. **Atomic commits** — one commit per logical change, not one giant commit
182
200
  4. **Full integration** — Phase 3 MUST include Docker build + start + health check (+ DB if applicable)
183
201
  5. **Error recovery** — git commits after each phase ensure progress is saved
@@ -0,0 +1,151 @@
1
+ # Swarm File Evidence Templates
2
+
3
+ > The swarm contract, in the form the GENERATOR emits it. Everything below is written INTO the
4
+ > target project — it is not guidance for this skill.
5
+ >
6
+ > WHY THIS FILE EXISTS. A worker that died looks exactly like a worker that is still running: both
7
+ > are silent. Silence therefore reads as `in progress`, and a coordinator reports in good faith
8
+ > that the review is running when no review exists. The absence of a receipt is indistinguishable
9
+ > from unfinished work, and so it reads as progress. The cure is to declare the RESULT of every
10
+ > parallel unit to be a FILE at a named path: no file, no work — and that is a fact a machine can
11
+ > establish, not a feeling a reader has to trust.
12
+ >
13
+ > MEASURED 2026-09-01 (the defect this closes): the generated feature lifecycle told the toolkit to
14
+ > launch parallel agents 22 times and required a file result zero times, while the package that
15
+ > emits it had already carried the cure in nine of its own files. The generator reproduced in every
16
+ > consumer project a defect its author had already fixed at home.
17
+
18
+ ---
19
+
20
+ ## 1. Rule Template: `swarm-file-evidence.md`
21
+
22
+ **Output path:** `.claude/rules/swarm-file-evidence.md`
23
+
24
+ **Do NOT overwrite** an existing file at that path — `npx @dzhechkov/p-replicator init` pre-ships
25
+ this rule, and a project initialised that way already has it. Generate it only when the path is
26
+ absent, which is the case for every toolkit produced into a project this package never initialised.
27
+
28
+ Emit the body below VERBATIM. It is byte-identical to the pre-shipped rule, and
29
+ `tests/unit/generator-swarm-contract.test.js` asserts that identity, so the two cannot drift.
30
+
31
+ ```markdown
32
+ # Swarm File Evidence
33
+
34
+ ## Rule
35
+
36
+ Every parallel work unit has a named file result. A narrative reply is only a pointer; silence is
37
+ neither progress nor completion. The coordinator may aggregate only positive, attributable terminal
38
+ receipts from the assigned files.
39
+
40
+ ## Mechanics
41
+
42
+ 1. Before dispatch, allocate a run-unique `RUN_ID` and a unique `WORK_UNIT_ID`. Resolve one absolute
43
+ `TRACE_PATH` per `(RUN_ID, WORK_UNIT_ID)`, record its pre-launch state, and pass both fields to the
44
+ worker. Two workers never share a path.
45
+ 2. The worker writes a substantive Markdown body to a temporary regular file in the same directory,
46
+ appends exactly `Status: completed` or `Status: failed` as the final line, renames it to
47
+ `TRACE_PATH`, then returns a one-line pointer. The terminal marker is written last.
48
+ 3. Before merge, synthesis, or completion, the coordinator checks each assigned path: absolute and
49
+ unique; regular and non-symlink; readable and non-whitespace; absent before launch or observably
50
+ changed after launch; final line terminal. It reads the file as the payload and reports
51
+ `valid receipts / required receipts` with every failed `WORK_UNIT_ID` and path.
52
+ 4. `Status: completed` permits consumption. `Status: failed` is a delivered failure and blocks a
53
+ successful aggregate. Missing, empty, stale, partial, unreadable, duplicate, or probe-error
54
+ evidence is undelivered or inconclusive. A dead PID stops waiting as failure; a live PID may only
55
+ extend waiting. Neither PID state proves delivery.
56
+
57
+ ## Bounded exception
58
+
59
+ If atomic rename is unavailable, write directly to `TRACE_PATH` and append the terminal marker last;
60
+ until that line exists the file is partial. Host-authoritative liveness may extend a deadline, but it
61
+ cannot replace the file result or turn missing evidence into success.
62
+
63
+ ## Observable violation → replacement
64
+
65
+ | Observable violation | Required replacement |
66
+ |---|---|
67
+ | Task report exists but `TRACE_PATH` does not | Name the unit/path, mark undelivered, and refuse aggregation. |
68
+ | File is empty, stale, symlinked, unreadable, or non-terminal | Keep the evidence out of the aggregate and rerun or diagnose that unit. |
69
+ | Status says `running` but its recorded PID is dead | Close the unit as failed; do not report continued work from silence. |
70
+ | Fewer than all required receipts are terminal-completed | Report the partial ratio and refuse completion. |
71
+
72
+ ## Self-check
73
+
74
+ For every parallel unit, point to its assignment containing `WORK_UNIT_ID` and absolute `TRACE_PATH`,
75
+ then point to the coordinator check performed before aggregation. Exercise missing, empty, stale,
76
+ partial, failed, dead-PID, and probe-error traces; only a fresh substantive file ending in
77
+ `Status: completed` may satisfy delivery.
78
+ ```
79
+
80
+ ---
81
+
82
+ ## 2. Seam Template: the positive file receipt
83
+
84
+ **Paste this block VERBATIM into every generated instruction that dispatches parallel agents** —
85
+ the `/feature` and `/feature-ent` commands, the `feature-lifecycle` rules, `/start` Phase 2, the
86
+ autonomous `/run` and `/go` loops, and any pipeline a project builds with `pipeline-forge`.
87
+ It is short on purpose: a contract nobody can afford to repeat is a contract that gets dropped.
88
+
89
+ ```markdown
90
+ #### Positive file receipt (required)
91
+
92
+ Before dispatch, allocate one `RUN_ID` and, for every unit, a unique `WORK_UNIT_ID` plus an
93
+ absolute `TRACE_PATH` unique to `(RUN_ID, WORK_UNIT_ID)`; record the launch instant and pass both
94
+ fields to the worker. Each worker must write a substantive body ending in `Status: completed` or
95
+ `Status: failed` to `TRACE_PATH` before it returns its one-line pointer. Before merge, verify every
96
+ path is a regular non-symlink file, non-whitespace, post-launch, and terminal. Narrative output or
97
+ silence is never a receipt. Name missing, stale, partial, unreadable, duplicate, failed, dead-PID,
98
+ or probe-error units and refuse merge, aggregation, or completion until every required receipt is
99
+ valid and completed. See `.claude/rules/swarm-file-evidence.md` for mechanics and the bounded
100
+ non-atomic-write exception.
101
+ ```
102
+
103
+ ## 3. The deterministic half: `check-swarm-receipts.cjs`
104
+
105
+ Section 2 is layer-2 text — it is read every run and violated in silence. The layer-1 half is a
106
+ utility that answers the same question without a model in the loop:
107
+
108
+ ```bash
109
+ node .claude/hooks/check-swarm-receipts.cjs .claude/traces/<RUN_ID>/receipts.json
110
+ ```
111
+
112
+ Three exit codes, and the third is the point:
113
+
114
+ | Exit | Meaning | Coordinator's obligation |
115
+ |------|---------|--------------------------|
116
+ | `0` | every receipt is fresh, substantive and `Status: completed` | may aggregate |
117
+ | `1` | at least one unit is undelivered or delivered `Status: failed` | refuse merge; name the units |
118
+ | `2` | THE CHECK DID NOT RUN — no manifest, malformed assignment, unreadable trace, or a still-live worker | refuse merge; this is an unknown, never a pass |
119
+
120
+ The coordinator writes the manifest BEFORE dispatch, which is what makes freshness checkable at all
121
+ — `launchMs` cannot be recovered afterwards:
122
+
123
+ ```json
124
+ {
125
+ "runId": "feature-auth-2026-09-01T12-00-00Z",
126
+ "launchMs": 1756728000000,
127
+ "units": [
128
+ { "workUnitId": "api", "tracePath": "/abs/project/.claude/traces/<RUN_ID>/api.md", "pid": 12345 },
129
+ { "workUnitId": "docs", "tracePath": "/abs/project/.claude/traces/<RUN_ID>/docs.md" }
130
+ ]
131
+ }
132
+ ```
133
+
134
+ `pid` is optional and can only move an ABSENT trace between "undelivered" and "still waiting". A
135
+ live worker may extend waiting; liveness has never been delivery.
136
+
137
+ ## 4. Where the generator must place all of this
138
+
139
+ | Generated artifact | What must appear |
140
+ |---|---|
141
+ | `.claude/rules/swarm-file-evidence.md` | Section 1 verbatim, unless the path already exists |
142
+ | `.claude/commands/feature.md` — Phase 3 | Section 2 block |
143
+ | `.claude/rules/feature-lifecycle.md` — Implementation | Section 2 block |
144
+ | `.claude/commands/feature-ent.md` + `feature-lifecycle-ent.md` | Section 2 block |
145
+ | `.claude/commands/start.md` — Phase 2 | Section 2 block |
146
+ | Autonomous loop commands (`/run`, `/go`) | Section 2 block |
147
+ | Any `pipeline-forge` pipeline with a swarm stage | Section 2 block |
148
+ | `CLAUDE.md` lifecycle section | one line naming the rule, so the contract is discoverable |
149
+
150
+ A generated toolkit that dispatches parallel agents anywhere and carries none of this is INCOMPLETE
151
+ — `06-package-deliver.md` fails delivery on it.
@@ -42,6 +42,17 @@ record of something recited from memory. That combination is legal, expressible,
42
42
  | `ASSERTED` | Stated from model memory, source never opened | Nothing about the source | `0.0` |
43
43
  | *(absent)* | Fact predates this axis | Evidence is **unknown** — neither asserted nor verified | no ceiling of its own |
44
44
 
45
+ For quoted text, the acquisition method is a separate closed vocabulary. The author-facing names
46
+ map exactly to the stored values; only the verifier can emit the verdict after comparing captured bytes.
47
+
48
+ | Stored method | Author-facing name | Verbatim ceiling |
49
+ |---|---|---|
50
+ | `raw-fetch` | `сырая-загрузка` | eligible only after a matching captured excerpt |
51
+ | `tool-summary` | `пересказ-инструментом` | never verbatim, even when the words happen to match |
52
+ | `search-listing` | `из-поисковой-выдачи` | eligible only after reconciliation against a captured excerpt |
53
+ | `manual` | `вручную` | eligible only after reconciliation against a captured excerpt |
54
+ | *(absent/other)* | `method-unknown` | never verbatim |
55
+
45
56
  **`FETCH_VERIFIED` cannot be self-declared.** It is minted only by `create_fetched_fact()`, which
46
57
  requires a `FetchRecord` — the byte hash, HTTP status and date of a request that actually happened.
47
58
  The manual constructors (`create_listing_fact`, `create_asserted_fact`) have no way to produce it.
@@ -54,7 +65,7 @@ Provenance, not truth.
54
65
  ### The report gate
55
66
 
56
67
  ```bash
57
- python3 scripts/check_report_evidence.py --report report.md --facts facts.json [--profile patient.json]
68
+ python3 scripts/check_report_evidence.py --report report.md --facts facts.json [--profile patient.json] [--excerpts evidence_excerpts]
58
69
  ```
59
70
 
60
71
  `ASSERTED` claims must not appear in a report at all. `LISTING_ONLY` claims may appear only with a
@@ -197,12 +208,10 @@ mkdir ~/health-research && cd ~/health-research # medical work lives here
197
208
  Do not run medical investigations inside a shared code repository. If you already have,
198
209
  the prompt log is `.dz/recall-usage.jsonl` and the lessons are in `.health-brain/`.
199
210
 
200
- Choosing the shared store anyway is not blocked it is ADVISED against. `dz teach
201
- --domain health-research` into a shared store prints what follows from the choice and
202
- the command that does it the other way; `dz recall --all --json --include-domain
203
- health-research` hands the data over and says how much of it is medical. Both end with
204
- "Nothing was blocked — this is your call." The data is yours; our job is that the choice
205
- is knowing rather than accidental.
211
+ Choosing the shared store anyway is ADVISED against, never blocked: both `dz teach --domain
212
+ health-research` and `dz recall --all --json --include-domain health-research` print what follows
213
+ from the choice and end with "Nothing was blocked this is your call" — the choice must be
214
+ knowing, not accidental.
206
215
  Step 1 is what makes a lesson safe to keep: a rule about a method has nowhere to put a
207
216
  person. But note what that is and is not — it is a discipline, performed by you and
208
217
  asserted with `--confirm-method`, which nothing verifies. The property that holds
@@ -501,38 +510,44 @@ Invalid signatures are rejected with confidence `0.0`; they are never a recovera
501
510
  4. Extract claims and source URLs.
502
511
  5. **Fetch each source through the tool, not by hand:**
503
512
  ```python
504
- from evidence_fetch import fetch_source, FetchRecord
505
- record = fetch_source(url) # real HTTP, stdlib only
513
+ from evidence_fetch import fetch_source_returning_body, FetchRecord
514
+ from quote_provenance import QuoteRecord, capture_excerpt, write_excerpt
515
+ record, body = fetch_source_returning_body(url) # real HTTP, captured bytes
506
516
  if isinstance(record, FetchRecord):
507
- fact = verifier.create_fetched_fact(claim, record, issuer, source_date="2024-03-01")
517
+ captured = capture_excerpt(body, quoted_text, record)
518
+ write_excerpt("evidence_excerpts", captured)
519
+ quoted = QuoteRecord(quoted_text, "raw-fetch", record.final_url,
520
+ record.sha256_body, locator, captured["excerpt_id"])
521
+ fact = verifier.create_fetched_fact(claim, record, issuer, quote=quoted)
508
522
  else: # offline, 404, oversize, refused scheme…
509
523
  fact = verifier.create_listing_fact(claim, url, reason=record.reason)
510
524
  ```
511
525
  A claim you never opened a source for is `verifier.create_asserted_fact(claim)` — record it
512
526
  honestly and let the gate refuse it. Never hand-label a class you did not earn.
527
+ 5a. **When quoting verbatim, capture at fetch time as shown above.** No captured source bytes means
528
+ no verbatim verdict; `tool-summary` can never earn one even when its words happen to match.
513
529
  6. Add facts to the research ledger; issuer-signed facts only when a pinned issuer key actually
514
530
  signed the message.
515
531
  7. Verify facts and citation chains.
516
532
  8. Cross-check claims through ordinary source evaluation.
517
533
  9. **Run the report gate before delivering:**
518
534
  `python3 scripts/check_report_evidence.py --report <report.md> --facts <facts.json>` — exit 0 required.
535
+ 9a. **A NEGATIVE conclusion ("no competitor has this") MUST carry its own basis:** КОРПУС · ПОЛНОТА ·
536
+ СПОСОБ ПОИСКА · ГРАНИЦА КОРПУСА · СЛЕДСТВИЕ. "We did not find it" is a property of the SEARCH;
537
+ "it is not there" is a property of the WORLD, and only an exhaustive corpus licenses the second.
538
+ Form, closed values and the measured reason: `references/negative-results.md`.
519
539
  10. Report confidence, evidence-class mix, unsigned claims, rejected signatures, and limitations
520
540
  explicitly.
521
541
 
522
542
  ## Output Expectations
523
543
 
524
- Reports should include:
525
-
526
- - Research objective and GOAP plan executed.
527
- - Findings with source URLs.
528
- - Verification status per claim on BOTH axes: trust (`ISSUER_SIGNED` / `SELF_ATTESTED` /
529
- `UNVERIFIED`) and evidence (`FETCH_VERIFIED` / `LISTING_ONLY` / `ASSERTED` / unknown-legacy).
530
- - The evidence-class mix as a count — the share of `ASSERTED` should be zero.
531
- - A visible marker next to every `LISTING_ONLY` claim ("source not opened directly — verify").
532
- - Chain integrity result when citation chains are used.
533
- - Unsigned and rejected claims.
534
- - Explicit caveat that cryptographic provenance is not truth verification, and that
535
- `FETCH_VERIFIED` means the bytes arrived — not that the source is right.
544
+ Reports include: the objective + executed GOAP plan; findings with source URLs; per-claim status on
545
+ BOTH axes — trust (`ISSUER_SIGNED`/`SELF_ATTESTED`/`UNVERIFIED`) and evidence
546
+ (`FETCH_VERIFIED`/`LISTING_ONLY`/`ASSERTED`/unknown-legacy); the evidence-class mix as a count
547
+ (the `ASSERTED` share should be zero); a visible marker on every `LISTING_ONLY` claim ("source not
548
+ opened directly verify"); chain integrity when chains are used; unsigned and rejected claims; the
549
+ explicit caveat that cryptographic provenance is not truth verification — `FETCH_VERIFIED` means
550
+ the bytes arrived, not that the source is right.
536
551
 
537
552
  ## Implementation
538
553
 
@@ -0,0 +1,94 @@
1
+ # Отрицательный вывод: «не нашли» и «доказали, что нет» — разные утверждения
2
+
3
+ Читается по требованию. В `SKILL.md` из этого файла живёт одна строка-указатель; всё остальное здесь,
4
+ потому что всегда-загружаемый корпус пакета исчерпан, а объём этой темы в него не помещается.
5
+
6
+ ## Отказ, ради которого это написано
7
+
8
+ Отчёт исследования умеет делать очень сильное утверждение: **«такой функции нет ни у одного из
9
+ конкурентов; ниша свободна»**. На нём основывают продукт. И ровно оно было НЕВИДИМО для аппарата
10
+ доверия.
11
+
12
+ **ИЗМЕРЕНО 2026-09-01, ТВИН-ТЕСТОМ, а не грепом** (грепу здесь верить нельзя: он находит словарь, а
13
+ не слепоту). `scripts/check_report_evidence.py` шёл ОТ ЛЕДЖЕРА К ОТЧЁТУ — для каждого записанного
14
+ факта искал его употребление в тексте. Два прогона на ОДНОМ леджере, отчёты различаются РОВНО одной
15
+ строкой отрицательного вывода:
16
+
17
+ ```bash
18
+ python3 check_report_evidence.py --report a.md --facts f.json --json > oa.json
19
+ python3 check_report_evidence.py --report b.md --facts f.json --json > ob.json # b.md = a.md + одна строка
20
+ diff oa.json ob.json # ДО починки: пусто, оба exit 0
21
+ ```
22
+
23
+ Вывод гейта был БАЙТ В БАЙТ одинаков. То есть ничем не подкреплённое отрицание не могло ни
24
+ увеличить, ни уменьшить число находок: оно было вне области зрения ПО ПОСТРОЕНИЮ, а не по недосмотру.
25
+ Причина простая и структурная: аппарат оценивал только утверждения, у которых ЕСТЬ источник, а у
26
+ отрицания источника нет — в этом и состоит отрицание.
27
+
28
+ **МЕХАНИЗМ:** «не встретилось» и «доказано, что нет» приходят в отчёте В ОДИНАКОВОЙ ФОРМЕ, и решения
29
+ по ним принимают одинаково. Первое — свойство ПОИСКА. Второе — свойство МИРА. Только второе
30
+ оправдывает продукт, построенный на пустой нише.
31
+
32
+ ## Форма, которую отрицательный вывод обязан нести
33
+
34
+ Пять полей рядом с утверждением (в пределах 900 знаков — блок, а не приложение):
35
+
36
+ | Поле | Что отвечает | Закрытые значения |
37
+ |---|---|---|
38
+ | `КОРПУС` | что именно прочитано, ПЕРЕЧНЕМ | свободный текст, но перечислимый |
39
+ | `ПОЛНОТА` | чем является этот перечень | `перечислимо и объявлено исчерпывающим` · `выборка` · `неизвестна` |
40
+ | `СПОСОБ ПОИСКА` | как искали и какими запросами | свободный текст |
41
+ | `ГРАНИЦА КОРПУСА` | по состоянию на когда | свободный текст |
42
+ | `СЛЕДСТВИЕ` | что из этого следует | `не встретилось` · `намеренно отсутствует` |
43
+
44
+ **Потолок, и он несущий.** `СЛЕДСТВИЕ: намеренно отсутствует` допустимо ТОЛЬКО при
45
+ `ПОЛНОТА: перечислимо и объявлено исчерпывающим`. Выборка и неизвестная полнота поддерживают
46
+ «не встретилось» и ничего сильнее: отсутствие в ЧАСТИ корпуса — отсутствие в ПОИСКЕ, а не в мире.
47
+
48
+ **Почему пяти полей, а не двух.** Первая редакция требовала только `КОРПУС` и `ПОЛНОТА`. Проверяющая
49
+ модель назвала это самым слабым местом заявки и была ПРАВА: **исчерпывающий ПЕРЕЧЕНЬ не доказывает
50
+ исчерпывающего ПОИСКА**. Двенадцать страниц, прочитанных от корки до корки, всё равно пропустят
51
+ функцию, если это были не те двенадцать — или если в запросе ни разу не прозвучало слово, которым
52
+ её называет сам поставщик. Поэтому в потолок входят также способ поиска, покрытие запросов, отказы
53
+ выборки и временная граница корпуса. Без них сильное «нет» выписывает себе разрешение само.
54
+
55
+ ## Пример
56
+
57
+ ```markdown
58
+ Вывод: массового экспорта нет ни у одного из трёх конкурентов.
59
+
60
+ КОРПУС: справочные центры A (14 стр.), B (9 стр.), C (11 стр.) — перечень в приложении A
61
+ ПОЛНОТА: выборка — 34 из ~120 страниц; отказ выборки: раздел для партнёров под входом
62
+ СПОСОБ ПОИСКА: полнотекстовый поиск по 6 запросам: «bulk export», «экспорт», «CSV», «API export», «выгрузка», «download all»
63
+ ГРАНИЦА КОРПУСА: по состоянию на 2026-08-30
64
+ СЛЕДСТВИЕ: не встретилось
65
+ ```
66
+
67
+ `СЛЕДСТВИЕ: намеренно отсутствует` в этом примере было бы отвергнуто гейтом: полнота — выборка.
68
+
69
+ ## Чего проверка НЕ решает, и это граница, а не недоделка
70
+
71
+ **Подходит ли названный корпус ВОПРОСУ.** Второй случай из полевого каталога ровно об этом: вопрос
72
+ «есть ли у продукта X функция Y», функция описана ТОЛЬКО в справочном центре, а корпусом взята карта
73
+ сайта. Карта сайта — идеально перечислимый, идеально исчерпывающий и НЕ ТОТ корпус. Проверка
74
+ заставляет корпус НАЗВАТЬ, чтобы человек мог судить о его пригодности; судить — не её работа, и
75
+ делать вид, что её, значило бы то самое ложное закрытие класса, которое весь гейт и отвергает.
76
+
77
+ ## Ворота
78
+
79
+ Отдельного вызова не нужно: проверка живёт внутри уже существующего гейта и ходит во ВТОРУЮ сторону —
80
+ от отрицательных выводов отчёта к их обоснованию.
81
+
82
+ ```bash
83
+ python3 .claude/skills/goap-research-ed25519/scripts/check_report_evidence.py \
84
+ --report report.md --facts facts.json --json
85
+ ```
86
+
87
+ Виды находок: `NEGATIVE_CONCLUSION_WITHOUT_BASIS` (нет одного из пяти полей — перечисляются, каких) ·
88
+ `NEGATIVE_COMPLETENESS_UNRECOGNISED` · `NEGATIVE_IMPLICATION_UNRECOGNISED` ·
89
+ `NEGATIVE_CLAIM_EXCEEDS_ITS_CEILING` (сильное следствие на выборке).
90
+
91
+ **Область срабатывания сужена намеренно.** Ловятся УНИВЕРСАЛЬНЫЕ отрицания («ни у одного», «none of
92
+ the», «ниша свободна»), а не любое «нет» в тексте: жадный сторож — не более строгий сторож, а
93
+ сторож, который удалят. Новая формулировка отрицания будет пропущена, и здесь это сказано вслух,
94
+ ровно как соседний пояс по относительному риску говорит о себе то же самое.