checkwright 0.20.0 → 0.22.0

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 (250) hide show
  1. package/README.md +385 -19
  2. package/lib/common/digest.sh +18 -0
  3. package/lib/common/lock.sh +11 -0
  4. package/lib/common/recipe.sh +8 -11
  5. package/lib/doctor.sh +49 -0
  6. package/lib/init.sh +152 -29
  7. package/package.json +2 -2
  8. package/payload/artifact/targets.list +30 -0
  9. package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates +0 -0
  10. package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates.sha256 +1 -0
  11. package/payload/canon-kit/README.md +1 -0
  12. package/payload/canon-kit/SPEC.md +281 -26
  13. package/payload/canon-kit/checks/check-comment-tier.sh +7 -2
  14. package/payload/canon-kit/checks/check-docs-link-convention.sh +11 -4
  15. package/payload/canon-kit/checks/check-md-refs.sh +22 -9
  16. package/payload/canon-kit/checks/check-payload-claim.sh +133 -0
  17. package/payload/canon-kit/checks/check-prose-enum.sh +1 -1
  18. package/payload/canon-kit/checks/check-spec-pointer.sh +15 -4
  19. package/payload/canon-kit/gate-tests/check-comment-tier/good/good.sh +3 -0
  20. package/payload/canon-kit/gate-tests/check-comment-tier.test.sh +26 -3
  21. package/payload/canon-kit/gate-tests/check-docs-link-convention/bad/OUTSIDE.md +4 -0
  22. package/payload/canon-kit/gate-tests/check-docs-link-convention/bad/docs/index.md +3 -0
  23. package/payload/canon-kit/gate-tests/check-docs-link-convention/good/OUTSIDE.md +4 -0
  24. package/payload/canon-kit/gate-tests/check-docs-link-convention/good/docs/methodology.md +8 -0
  25. package/payload/canon-kit/gate-tests/check-docs-link-convention.test.sh +94 -0
  26. package/payload/canon-kit/gate-tests/check-manifest-count.test.sh +5 -3
  27. package/payload/canon-kit/gate-tests/check-payload-claim/bad/README.md +15 -0
  28. package/payload/canon-kit/gate-tests/check-payload-claim/bad/expect.txt +2 -0
  29. package/payload/canon-kit/gate-tests/check-payload-claim/bad/install.md +19 -0
  30. package/payload/canon-kit/gate-tests/check-payload-claim/bad/posts/note.md +6 -0
  31. package/payload/canon-kit/gate-tests/check-payload-claim/bad/scripts/canon-config.sh +8 -0
  32. package/payload/canon-kit/gate-tests/check-payload-claim/bad/scripts/payload-claims.sh +7 -0
  33. package/payload/canon-kit/gate-tests/check-payload-claim/good/README.md +15 -0
  34. package/payload/canon-kit/gate-tests/check-payload-claim/good/expect.txt +2 -0
  35. package/payload/canon-kit/gate-tests/check-payload-claim/good/install.md +20 -0
  36. package/payload/canon-kit/gate-tests/check-payload-claim/good/posts/note.md +6 -0
  37. package/payload/canon-kit/gate-tests/check-payload-claim/good/scripts/canon-config.sh +8 -0
  38. package/payload/canon-kit/gate-tests/check-payload-claim/good/scripts/payload-claims.sh +7 -0
  39. package/payload/canon-kit/gate-tests/check-prose-enum.test.sh +24 -1
  40. package/payload/canon-kit/gate-tests/check-spec-pointer/bad/expect.txt +1 -0
  41. package/payload/canon-kit/gate-tests/check-spec-pointer/bad/widget.sh +1 -0
  42. package/payload/canon-kit/gate-tests/check-spec-pointer/good/widget.sh +1 -0
  43. package/payload/canon-kit/lib/spec.sh +22 -12
  44. package/payload/canon-kit/smoke/install.sh +20 -1
  45. package/payload/canon-kit/templates/SPEC-amendment.md +5 -1
  46. package/payload/context-kit/SPEC.md +38 -7
  47. package/payload/context-kit/lib/toolfloor.sh +1 -1
  48. package/payload/context-kit/smoke/install.sh +3 -1
  49. package/payload/delegation-kit/README.md +2 -1
  50. package/payload/delegation-kit/SPEC.md +590 -48
  51. package/payload/delegation-kit/bin/run-dispatch-guard-tests.sh +97 -0
  52. package/payload/delegation-kit/checks/check-agent-tier-explicit.sh +61 -0
  53. package/payload/delegation-kit/checks/check-gate-tamper.sh +1 -1
  54. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/bad/agents/silent.md +7 -0
  55. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/bad/args +1 -0
  56. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/bad/expect.txt +1 -0
  57. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/agents/explicit-cheap.md +7 -0
  58. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/agents/explicit-inherit.md +8 -0
  59. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/args +1 -0
  60. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/expect.txt +1 -0
  61. package/payload/delegation-kit/lib/delegation.sh +3 -0
  62. package/payload/delegation-kit/smoke/install.sh +3 -1
  63. package/payload/delegation-kit/templates/agent-dispatch-guard.sh +61 -0
  64. package/payload/delegation-kit/templates/agent-execution.md +171 -15
  65. package/payload/delegation-kit/templates/delegation-config.sh +4 -0
  66. package/payload/delegation-kit/templates/dispatch-checklists.md +1 -1
  67. package/payload/delegation-kit/usage-tests/dispatch-guard-cases.tsv +30 -0
  68. package/payload/doctrine-kit/DOCTRINE.md +27 -0
  69. package/payload/doctrine-kit/README.md +5 -0
  70. package/payload/doctrine-kit/SPEC.md +62 -3
  71. package/payload/doctrine-kit/bin/install-doctrine.sh +84 -4
  72. package/payload/doctrine-kit/smoke/install.sh +77 -1
  73. package/payload/drift-kit/README.md +3 -2
  74. package/payload/drift-kit/SPEC.md +253 -20
  75. package/payload/drift-kit/bin/stage-economics.sh +157 -3
  76. package/payload/drift-kit/kpis/kpi-incident-recurrence.sh +42 -0
  77. package/payload/drift-kit/smoke/install.sh +155 -1
  78. package/payload/drift-kit/templates/economics.md +9 -0
  79. package/payload/drift-kit/templates/kpis.list +6 -1
  80. package/payload/evidence-kit/README.md +20 -6
  81. package/payload/evidence-kit/SPEC.md +355 -17
  82. package/payload/evidence-kit/bin/run-validate.sh +51 -9
  83. package/payload/evidence-kit/checks/check-battery-roster.sh +86 -0
  84. package/payload/evidence-kit/checks/check-producer-liveness.sh +34 -0
  85. package/payload/evidence-kit/gate-tests/check-battery-roster/bad/args +1 -0
  86. package/payload/evidence-kit/gate-tests/check-battery-roster/bad/expect.txt +1 -0
  87. package/payload/evidence-kit/gate-tests/check-battery-roster/bad/runner.md +14 -0
  88. package/payload/evidence-kit/gate-tests/check-battery-roster/bad/scripts/evidence-config.sh +7 -0
  89. package/payload/evidence-kit/gate-tests/check-battery-roster/good/args +1 -0
  90. package/payload/evidence-kit/gate-tests/check-battery-roster/good/expect.txt +1 -0
  91. package/payload/evidence-kit/gate-tests/check-battery-roster/good/runner.md +14 -0
  92. package/payload/evidence-kit/gate-tests/check-battery-roster/good/scripts/evidence-config.sh +7 -0
  93. package/payload/evidence-kit/gate-tests/check-battery-roster.test.sh +68 -0
  94. package/payload/evidence-kit/gate-tests/check-producer-liveness/bad/args +1 -0
  95. package/payload/evidence-kit/gate-tests/check-producer-liveness/bad/expect.txt +1 -0
  96. package/payload/evidence-kit/gate-tests/check-producer-liveness/bad/run-validate.lock +1 -0
  97. package/payload/evidence-kit/gate-tests/check-producer-liveness/good/args +1 -0
  98. package/payload/evidence-kit/gate-tests/check-producer-liveness/good/expect.txt +2 -0
  99. package/payload/evidence-kit/gate-tests/check-producer-liveness/good/run-validate.lock +1 -0
  100. package/payload/evidence-kit/gate-tests/producer-lock.test.sh +109 -0
  101. package/payload/evidence-kit/lib/evidence.sh +18 -0
  102. package/payload/evidence-kit/smoke/install.sh +17 -3
  103. package/payload/gate-sdk/README.md +4 -1
  104. package/payload/gate-sdk/SPEC.md +1955 -79
  105. package/payload/gate-sdk/bin/gen-pre-commit.sh +13 -3
  106. package/payload/gate-sdk/bin/run-consumer-smoke.sh +121 -1
  107. package/payload/gate-sdk/bin/run-gate-tests.sh +40 -9
  108. package/payload/gate-sdk/bin/run-gates.sh +32 -3
  109. package/payload/gate-sdk/bin/upgrade-smoke.sh +3 -3
  110. package/payload/gate-sdk/checks/check-action-gh-repo.gate +2 -0
  111. package/payload/gate-sdk/checks/check-action-pinning.gate +2 -0
  112. package/payload/gate-sdk/checks/check-action-run-shell.sh +3 -1
  113. package/payload/gate-sdk/checks/check-core-files.sh +27 -4
  114. package/payload/gate-sdk/checks/check-exec-bit.sh +20 -1
  115. package/payload/gate-sdk/checks/check-gate-binary-fresh.sh +106 -0
  116. package/payload/gate-sdk/checks/check-gate-exemption-tasks.sh +6 -7
  117. package/payload/gate-sdk/checks/check-gate-output.sh +9 -1
  118. package/payload/gate-sdk/checks/check-gate-substrate-parity.sh +302 -0
  119. package/payload/gate-sdk/checks/check-graph.sh +7 -8
  120. package/payload/gate-sdk/checks/check-readme-roster.sh +5 -0
  121. package/payload/gate-sdk/checks/check-reads-couples.sh +73 -22
  122. package/payload/gate-sdk/checks/check-template-registry-parity.sh +81 -0
  123. package/payload/gate-sdk/checks/check-tree-terms.sh +11 -7
  124. package/payload/gate-sdk/gate-tests/check-action-run-shell.test.sh +16 -1
  125. package/payload/gate-sdk/gate-tests/check-core-files.test.sh +64 -0
  126. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/args +2 -0
  127. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/expect.txt +5 -0
  128. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/kitroot/checks/check-vendored.gate +2 -0
  129. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/scripts/check-ported.gate +2 -0
  130. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/scripts/gate-sdk-config.sh +2 -0
  131. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/scripts/gates.list +4 -0
  132. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/stamp.txt +1 -0
  133. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/stub-bin +6 -0
  134. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/args +2 -0
  135. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/expect.txt +5 -0
  136. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/kitroot/checks/check-vendored.gate +2 -0
  137. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/scripts/check-ported.gate +2 -0
  138. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/scripts/gate-sdk-config.sh +2 -0
  139. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/scripts/gates.list +4 -0
  140. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/stamp.txt +1 -0
  141. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/stub-bin +5 -0
  142. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh.test.sh +81 -0
  143. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/TASK-QUEUE.md +3 -1
  144. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/expect.txt +3 -1
  145. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/gates/check-sample.sh +3 -1
  146. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/good/expect.txt +1 -0
  147. package/payload/gate-sdk/gate-tests/check-gate-output/bad/check-sample.sh +1 -0
  148. package/payload/gate-sdk/gate-tests/check-gate-output/good/check-sample.sh +1 -0
  149. package/payload/gate-sdk/gate-tests/check-gate-output/good/expect.txt +1 -0
  150. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/args +2 -0
  151. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/conservation.md +7 -0
  152. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/expect.txt +12 -0
  153. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/impl/gate.rs +2 -0
  154. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/kitroot/check-orphan.rs +3 -0
  155. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/publish.yml +15 -0
  156. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-alpha.sh +3 -0
  157. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-dup.gate +1 -0
  158. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-dup.sh +3 -0
  159. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-orphan.gate +1 -0
  160. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/gate-sdk-config.sh +6 -0
  161. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/gates.list +3 -0
  162. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/stub-bin +3 -0
  163. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/targets.list +3 -0
  164. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/args +2 -0
  165. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/conservation.md +8 -0
  166. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/expect.txt +7 -0
  167. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/impl/gate.rs +2 -0
  168. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/kitroot/check-other.rs +3 -0
  169. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/publish.yml +15 -0
  170. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/check-alpha.sh +3 -0
  171. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/check-ported.gate +2 -0
  172. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/gate-sdk-config.sh +6 -0
  173. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/gates.list +2 -0
  174. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/stub-bin +3 -0
  175. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/targets.list +2 -0
  176. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity.test.sh +123 -0
  177. package/payload/gate-sdk/gate-tests/check-reads-couples.test.sh +139 -0
  178. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/alpha-kit/templates/widgets.list +4 -0
  179. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/alpha-kit/widgets/widget-one.sh +3 -0
  180. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/alpha-kit/widgets/widget-two.sh +3 -0
  181. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/args +4 -0
  182. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/expect.txt +1 -0
  183. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/scripts/gate-sdk-config.sh +5 -0
  184. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/alpha-kit/templates/widgets.list +4 -0
  185. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/alpha-kit/widgets/widget-one.sh +3 -0
  186. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/alpha-kit/widgets/widget-two.sh +3 -0
  187. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/args +8 -0
  188. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/beta-kit/templates/rules.list +5 -0
  189. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/beta-kit/templates/table.tsv +4 -0
  190. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/expect.txt +1 -0
  191. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/scripts/gate-sdk-config.sh +5 -0
  192. package/payload/gate-sdk/gate-tests/lib-declaration.test.sh +4 -4
  193. package/payload/gate-sdk/gate-tests/lib-gate.test.sh +41 -1
  194. package/payload/gate-sdk/gate-tests/run-gate-tests.test.sh +144 -0
  195. package/payload/gate-sdk/lib/consumer-smoke.sh +26 -1
  196. package/payload/gate-sdk/lib/gate.sh +104 -13
  197. package/payload/gate-sdk/lib/inject.sh +21 -1
  198. package/payload/gate-sdk/smoke/install.sh +19 -1
  199. package/payload/guard-kit/README.md +4 -3
  200. package/payload/guard-kit/SPEC.md +88 -10
  201. package/payload/guard-kit/bin/compare-settings-allow.sh +40 -7
  202. package/payload/guard-kit/gate-tests/compare-settings-allow.test.sh +64 -0
  203. package/payload/guard-kit/lib/guard.sh +1 -0
  204. package/payload/guard-kit/templates/close-triage.md +35 -7
  205. package/payload/guard-kit/templates/guard-config.sh +3 -0
  206. package/payload/lifecycle-kit/README.md +1 -0
  207. package/payload/lifecycle-kit/SPEC.md +589 -33
  208. package/payload/lifecycle-kit/bin/enter-stage.sh +13 -3
  209. package/payload/lifecycle-kit/bin/file-gap.sh +42 -1
  210. package/payload/lifecycle-kit/bin/file-survey.sh +50 -0
  211. package/payload/lifecycle-kit/checks/check-merge-attrs.sh +1 -1
  212. package/payload/lifecycle-kit/checks/check-skill-binding.sh +1 -1
  213. package/payload/lifecycle-kit/checks/check-survey-record.sh +102 -0
  214. package/payload/lifecycle-kit/gate-tests/check-merge-attrs/bad/.gitattributes +1 -0
  215. package/payload/lifecycle-kit/gate-tests/check-merge-attrs/good/.gitattributes +1 -0
  216. package/payload/lifecycle-kit/gate-tests/check-merge-attrs.test.sh +1 -0
  217. package/payload/lifecycle-kit/gate-tests/check-survey-record/bad/args +2 -0
  218. package/payload/lifecycle-kit/gate-tests/check-survey-record/bad/expect.txt +4 -0
  219. package/payload/lifecycle-kit/gate-tests/check-survey-record/bad/record.md +18 -0
  220. package/payload/lifecycle-kit/gate-tests/check-survey-record/good/args +2 -0
  221. package/payload/lifecycle-kit/gate-tests/check-survey-record/good/expect.txt +1 -0
  222. package/payload/lifecycle-kit/gate-tests/check-survey-record/good/record.md +13 -0
  223. package/payload/lifecycle-kit/gate-tests/check-survey-record.test.sh +84 -0
  224. package/payload/lifecycle-kit/gate-tests/file-gap-recurrence.test.sh +94 -0
  225. package/payload/lifecycle-kit/gate-tests/survey-record-entry.test.sh +102 -0
  226. package/payload/lifecycle-kit/lib/stages.sh +8 -2
  227. package/payload/lifecycle-kit/smoke/install.sh +17 -1
  228. package/payload/lifecycle-kit/templates/consult.md +73 -0
  229. package/payload/lifecycle-kit/templates/lead.md +141 -10
  230. package/payload/lifecycle-kit/templates/stages/align.md +12 -0
  231. package/payload/lifecycle-kit/templates/stages/build.md +8 -0
  232. package/payload/lifecycle-kit/templates/stages/close.md +25 -4
  233. package/payload/lifecycle-kit/templates/stages/scope.md +34 -0
  234. package/payload/lifecycle-kit/templates/stages/spec.md +8 -0
  235. package/payload/lifecycle-kit/templates/stages/validate.md +8 -0
  236. package/payload/queue-kit/README.md +4 -1
  237. package/payload/queue-kit/SPEC.md +230 -6
  238. package/payload/queue-kit/bin/queue-edges.sh +78 -0
  239. package/payload/queue-kit/checks/check-queue-entry-budget.sh +5 -3
  240. package/payload/queue-kit/gate-tests/check-queue-hygiene/good/TASK-QUEUE.md +5 -0
  241. package/payload/queue-kit/gate-tests/queue-edges.test.sh +130 -0
  242. package/payload/queue-kit/smoke/install.sh +4 -1
  243. package/payload/queue-kit/templates/TASK-QUEUE.md +3 -0
  244. package/payload/site-kit/SPEC.md +135 -29
  245. package/payload/site-kit/checks/check-docs-render-fidelity.sh +100 -27
  246. package/payload/site-kit/gate-tests/check-docs-render-fidelity-batch.test.sh +158 -0
  247. package/payload/site-kit/lib/site.sh +16 -2
  248. package/payload/site-kit/smoke/install.sh +9 -1
  249. package/payload/gate-sdk/checks/check-action-gh-repo.sh +0 -321
  250. package/payload/gate-sdk/checks/check-action-pinning.sh +0 -55
@@ -207,6 +207,20 @@ Lag:
207
207
  line count of the knowledge-friction log (§The knowledge-friction loop).
208
208
  Lag by construction: only what a session *noticed and logged* is counted,
209
209
  so the value lower-bounds the real rate.
210
+ - **kpi-incident-recurrence** — re-filings of the same finding, summed over the
211
+ queue's `recurrence:` declarations (queue-kit/SPEC.md §The tag algebra owns the
212
+ grammar), plus the highest-count slug. Like `kpi-deferred-age` it re-implements
213
+ the read rather than sourcing queue-kit's lib, under the same accepted residual
214
+ — one owner doc, two implementations, both carrying a `spec:` line citing the
215
+ owner. **The lag label is a measurement claim, not a priority one.** A
216
+ recurrence nobody files is uncounted, exactly `kpi-knowledge-friction`'s
217
+ structure, so lag is the honest fidelity tier even though the metric is highly
218
+ actionable. Actionability rides lifecycle-kit's pre-emption rule and its
219
+ `LIFECYCLE_KIT_RECURRENCE_THRESHOLD`, never this report's weighting — which is
220
+ why the counter and the rule are two pieces and not one. A report-only signal
221
+ would have reproduced the defect the pair exists to fix: a faithful record no
222
+ ranking reads. `--trend` emits `recur <N>`; with no declaration anywhere it
223
+ degrades to `n/a (no recurrence declaration in the queue)`.
210
224
 
211
225
  The lag section is expected to be sparse — most lag measurements (review
212
226
  finding rates, detection latency) are manual tallies, and the kit ships no
@@ -293,7 +307,10 @@ commit that is not a close. Each closed iteration N owns the commit range
293
307
  from the root up to its close commit); no range-scoped column reads HEAD, so an
294
308
  interstitial commit — filed or hotfixed after a close, before the next scope —
295
309
  falls into the *next* iteration's range and surfaces only when that iteration
296
- closes, leaving every published row byte-identical until a new close lands.
310
+ closes, leaving every published row byte-identical until a new close lands. That
311
+ sentence is range arithmetic: it is descriptive of a commit that happens, and
312
+ *when* one may legitimately be made is lifecycle-kit/SPEC.md §Deviation
313
+ transitions' interstitial-mitigation rule, which leaves this accounting unchanged.
297
314
  Totals conserve across rows: every commit up to the last close belongs to
298
315
  exactly one range. The extractor reads no now-relative field (no age-from-today)
299
316
  either, so re-emission over an unchanged closed history is byte-identical —
@@ -555,12 +572,21 @@ stamp**. A stage that continues in a new session (a credential swap mid-stage,
555
572
  any resume) leaves that session unstamped, so it matches no stamp and is never
556
573
  sought; its burn is invisible rather than wrong. The meter therefore counts the
557
574
  transcripts under `DRIFT_KIT_SESSIONS_DIR` that no row claimed and reports the
558
- count. It is an **upper bound, never an attribution**: a transcript carries no
559
- iteration and no stage, so nothing in the join could place it, and most
560
- unstamped transcripts are ordinary non-lifecycle sessions. Sizing the blind spot
561
- is the whole of what drift-kit can do alone — attributing a continuation would
562
- need the *stamp* side to record it, which is lifecycle-kit's contract and no
563
- part of this meter's read-only consumption of it.
575
+ count.
576
+
577
+ The bound is **tighter than the stamp side alone**, because a dispatched
578
+ transcript *can* now be placed — through its anchor, by the fan-out row below.
579
+ What remains in the count is the transcript that resolved **no anchor**, and for
580
+ that residue it is still an **upper bound, never an attribution**: an unanchored
581
+ transcript carries no iteration and no stage *and descends from no session that
582
+ does*, so nothing in the join could place it. The reading that most of the
583
+ residue is ordinary non-lifecycle sessions becomes **more** true rather than
584
+ less, since the fan-out pass drains the lifecycle subtrees out of it. The one
585
+ case the fan-out row cannot reach is the unstamped **continuation**: it is a
586
+ resumption rather than a dispatch, so it has no parent edge to walk. Sizing that
587
+ blind spot is the whole of what drift-kit can do alone — attributing a
588
+ continuation would need the *stamp* side to record it, which is lifecycle-kit's
589
+ contract and no part of this meter's read-only consumption of it.
564
590
 
565
591
  **The trend log.** One line is appended per `(iteration, stage, model)` triple to
566
592
  `DRIFT_KIT_STAGE_ECONOMICS_LOG`, grammar:
@@ -569,7 +595,10 @@ part of this meter's read-only consumption of it.
569
595
  <date> <iteration> <stage> <model> in=<tok> out=<tok> cr=<tok> cw=<tok> cost=<usd|n/a>
570
596
  ```
571
597
 
572
- `cr` is cache-read and `cw` is cache-creation. `cr` is the headline field: the
598
+ `<stage>` is the **stage-or-role** column — a lifecycle stage, a cost-bearing
599
+ role, or either of those with the fan-out suffix appended (the reserved
600
+ `supervision` value and the fan-out row, below). `cr` is cache-read and `cw` is
601
+ cache-creation. `cr` is the headline field: the
573
602
  motivating dig showed cache-read of accumulated context — not model choice — is
574
603
  the dominant burn (build ~73% of session cost, climbing 37M→86M cr-tokens per
575
604
  session), so the field exists to keep that lever visible close-over-close. The
@@ -609,7 +638,9 @@ skeleton); the same rule decides this.
609
638
  role**, not stage alone. A supervision row is a role that carries cost and no
610
639
  stamp — never a lifecycle stage that dropped out of the roster. The column's
611
640
  members were roster-closed until this value existed, and a reader who assumes
612
- they still are would misdiagnose the row as roster drift.
641
+ they still are would misdiagnose the row as roster drift. The column widens
642
+ once more for the fan-out row below, which admits *either* member with a
643
+ suffix appended.
613
644
  - **The producer — derivation from the transcript path, not from a stamp.** The
614
645
  two-tier scan above already resolves a dispatched stage session at
615
646
  `<sessions-dir>/<lead-session-id>/subagents/<agent>.jsonl` while a lead sits
@@ -623,9 +654,12 @@ skeleton); the same rule decides this.
623
654
  session is *derived*, which is what keeps this a read-only consumption of
624
655
  lifecycle-kit/SPEC.md §The state machine.
625
656
  - **The attribution invariant.** A transcript's usage is attributed to exactly
626
- one `(iteration, stage)` pair — the rule the session-keyed join above enforces
627
- for stage rows, and the reason a lead whose own transcript already carried a
628
- stage row yields no supervision row. In the ordinary case a lead supervises one
657
+ **one row key** — either an `(iteration, stage-or-role)` pair or that pair's
658
+ fan-out value. That is the rule the session-keyed join above enforces for stage
659
+ rows, the reason a lead whose own transcript already carried a stage row yields
660
+ no supervision row, and (below) the reason a dispatched transcript resolves
661
+ exactly one anchor. One guard serves all three: a transcript already claimed by
662
+ a row is never a candidate for another. In the ordinary case a lead supervises one
629
663
  iteration and its whole usage lands on that iteration's supervision row —
630
664
  exact, no key. A lead spanning two or more iterations **apportions in
631
665
  proportion to the number of stamped stage sessions it dispatched per
@@ -637,7 +671,11 @@ skeleton); the same rule decides this.
637
671
  label, the meter emits a visible notice naming `DRIFT_KIT_SUPERVISION_LABEL`
638
672
  and emits **no** supervision rows that run. It is checkable from data the meter
639
673
  already reads — its own stamps — so this adds no roster dependency and no
640
- second bound to drift.
674
+ second bound to drift. **A suppressed anchor suppresses its fan-out**: with no
675
+ supervision row emitted the lead is no anchor, so its direct fan-out finds none
676
+ and emits nothing. A fan-out row for a role that emitted no row of its own
677
+ would be an orphan the reader cannot place, and the suppression is structural
678
+ rather than a second rule — the anchor registers only where the row did.
641
679
  - **Degradation.** A run with no nested-tier match (a stage run without a live
642
680
  lead) emits no supervision row and no notice: zero supervision burn is the
643
681
  honest reading, not a missing measurement. A lead transcript aged out of the
@@ -659,7 +697,140 @@ skeleton); the same rule decides this.
659
697
  naming, since it is the surface a hardcoded stage roster once broke; it reads
660
698
  stamps and its own `DRIFT_KIT_STAGES` roster, never this log. So a non-stage
661
699
  value in the column cannot silently fall out of a roster the way the
662
- trajectory's stamps did.
700
+ trajectory's stamps did. The same three readers were re-verified when the
701
+ column widened again for the fan-out value, and the conclusion is unchanged.
702
+
703
+ **The fan-out row — a stage's dispatched subtree is its own line item.** A stage
704
+ session that dispatches agents pays for their whole subtree, yet every dispatched
705
+ transcript carries no stamp of its own, so its burn lands in no row and each
706
+ per-stage figure understates that stage by its entire fan-out. The meter bills the
707
+ subtree to a row whose `<stage>` value is the **anchor's stage-or-role with
708
+ `DRIFT_KIT_FANOUT_SUFFIX` appended** (§Layout and configuration) — `build+fanout`,
709
+ `close+fanout`, `supervision+fanout`.
710
+
711
+ - **A suffixed value rather than a bare reserved label.** A bare `fanout` label —
712
+ the shape `supervision` takes — would answer "what did fan-out cost this
713
+ iteration" and lose *which stage's* fan-out it was, the question the motivating
714
+ measurement asked. The suffix keeps the `(iteration, stage)` join intact and
715
+ sorts the subtree row adjacent to its own stage row.
716
+ - **A separate row rather than a fold into the stage row.** Separability *is* the
717
+ deliverable: a folded total answers the operator's question only through a
718
+ stdout caveat the trend log does not carry, so the close-over-close series — the
719
+ log's whole purpose — would be blind to the split it was extended to show. A
720
+ fold would also silently redefine a value already logged, a `close` row written
721
+ before this change and one written after meaning different things under one
722
+ name, which is the drift the dedup key exists to prevent rather than to hide.
723
+ - **What it is not: a dispatch-type breakdown.** The row carries **no
724
+ dispatch-type dimension** — a fork's spend and a typed dispatch's spend fold
725
+ into one anchor total. It is an aggregate proxy for "what this stage's
726
+ delegation cost", never an isolation of fork cost, and a reader who splits a
727
+ posture decision on fork-versus-dispatch cannot get that split from this row.
728
+ - **The anchor set.** An anchor is a transcript that already holds a row of its
729
+ own: every **stamped stage session whose transcript resolved**, anchoring its
730
+ subtree to that stamp's `(iteration, stage)`; and every **lead that emitted a
731
+ supervision row**, anchoring its own direct fan-out to
732
+ `(iteration, DRIFT_KIT_SUPERVISION_LABEL)` — a lead's audit sweeps are as
733
+ unbilled as a stage's, and omitting them would fix half the tier. The two
734
+ conditions differ deliberately: a stage anchors on its stamp **resolving**,
735
+ because a stamped stage whose transcript carries no usage is still a real,
736
+ placeable `(iteration, stage)` for its subtree, while a supervision role that
737
+ emitted no row is not a role at all. A lead that already carried a stage row
738
+ yields no supervision row (the invariant above) and its fan-out anchors to that
739
+ **stage** row instead — the anchor lookup finds it and needs no special case.
740
+ - **The producer — the parent walk, nearest anchor wins.** A dispatched
741
+ transcript's *path* names only the root session: a grandchild sits flat in the
742
+ same `<root>/subagents/` directory as a child, so the path cannot carry the
743
+ parent edge. The harness writes it one file over, as a `.meta.json` sibling of
744
+ each nested transcript, whose `parentAgentId` names the parent agent — a **bare**
745
+ id, resolved against `agent-<id>.jsonl` in the same directory (the bare spelling
746
+ `<id>.jsonl` is accepted as a fallback, so neither spelling is guessed). A record
747
+ with no `parentAgentId` is a direct child of the root session that names the
748
+ directory. For each `subagents/` transcript that is neither an anchor nor
749
+ already holding a row, the meter walks parents by that rule until an anchor is
750
+ reached and gives the **nearest** anchor the transcript's usage; intermediate
751
+ non-anchor agents are transparent, which is what puts a deep fork under the
752
+ stage session that ultimately caused it rather than under the sweep that
753
+ happened to spawn it. A walk reaching the root session without meeting an anchor
754
+ emits **no** row and the transcript stays in the under-count bound — the correct
755
+ reading, since an ordinary non-lifecycle session's fan-out belongs to no
756
+ iteration and no stage. The walk is **bounded by the transcript population and
757
+ by a visited set**, so a cycle or a dangling `parentAgentId` costs a counted
758
+ notice rather than a loop. The parent forest is read with one pass per
759
+ `subagents/` directory rather than one per hop; the usage itself is the same
760
+ last-usage-per-message-id reader the stage rows use, so the pass costs one
761
+ transcript parse per attributed subtree member and no second parser.
762
+ - **Reading a harness-private artifact — why the coupling is admissible.** The
763
+ meta sibling is under no contract, and the meter reads it anyway on one ground:
764
+ it is the **same coupling class the meter already runs on**, one file over from
765
+ the transcript JSONL usage schema and the `<root>/subagents/` layout it already
766
+ depends on, and the failure mode of the shape changing is bounded to a *visible
767
+ no-op* rather than a wrong figure. That is the difference between coupling to a
768
+ shape for an **enrichment** and coupling to it for the pricing arithmetic; the
769
+ ruling is yes here and would be no there. The rejected alternative — taking the
770
+ key from a dispatcher-minted path instead — fails on the axis that decides it: a
771
+ convention a dispatcher can forget produces a **silent** under-count in the exact
772
+ tier this row exists to stop under-counting, it relocates the harness coupling
773
+ rather than removing it (parsing a child's first user message for a string the
774
+ meter must then trust), and it cannot reach a **fork** at all, since a fork
775
+ inherits context rather than receiving an authored prompt.
776
+ - **Apportionment.** Where a lead spans several iterations, its fan-out
777
+ apportions by the **same dispatch-count key, with the same integer split**, that
778
+ apportions its supervision row. Reusing the key rather than minting a second one
779
+ is the point: two keys over one lead would let the supervision row and its
780
+ fan-out row disagree about which iteration the lead belonged to.
781
+ - **Several anchors, one row — the fold, not a race.** One `(iteration, stage)`
782
+ can hold **several** anchors: a stage run as several sessions in one iteration
783
+ (a batch split) stamps once per session, and each session anchors its own
784
+ subtree. Their subtrees **sum into the single fan-out row** for that pair. This
785
+ follows from the invariant above rather than adding to it — the attribution unit
786
+ is the *row key*, not the anchor — and the alternative is not a second row but a
787
+ **lost** one: two appends under one `<iteration> <stage> <model>` triple make
788
+ the dedup key replace the first with the second, stranding its transcripts
789
+ attributed to a row the replacement erased. Apportionment happens **first and the
790
+ fold second**, since the dispatch-count split is a property of the anchor while
791
+ the row is not. The stdout caveat names the contributing anchor count where it
792
+ exceeds one, so a folded row is never read as one session's.
793
+ - **Collision rule.** The default suffix is collision-proof by construction — the
794
+ stamp reader's stage-field alphabet is lowercase alphanumerics and hyphens, so a
795
+ `+` can never appear in a stamped stage name. A consumer overriding the knob can
796
+ break that, so the check mirrors the supervision label's: if any stamp the run
797
+ reads names a stage **ending in** the suffix, the meter emits a visible notice
798
+ naming `DRIFT_KIT_FANOUT_SUFFIX` and emits **no** fan-out rows that run. It is
799
+ checkable from the stamps the meter already reads, so it adds no roster
800
+ dependency and no second bound to drift.
801
+ - **Degradation — the contract that bounds the coupling.** Every arm degrades to a
802
+ visible absence, never to a wrong figure, and never to a non-zero exit:
803
+
804
+ | what is missing | behavior |
805
+ | --- | --- |
806
+ | the meta layer entirely | no fan-out rows; one notice; every existing row unchanged — the meter's behavior before this row existed |
807
+ | one transcript's meta record | that transcript takes no fan-out row and stays in the under-count bound; counted in the unresolved notice |
808
+ | `parentAgentId` naming an agent with no transcript | same — counted, never guessed |
809
+ | a cycle or an over-long chain | same — the walk is bounded and the transcript counted |
810
+ | `jq` absent | already fatal to the whole join upstream; the fan-out pass never runs |
811
+ | the price table absent or missing a model row | the row's `cost` degrades to `n/a` and raises the existing incomplete-pricing caveat, exactly as a stage row's does |
812
+
813
+ - **No new field.** The four token fields, `cost`, and `date` carry a fan-out row
814
+ exactly as they carry a supervision row; the dedup key stays the
815
+ `<iteration> <stage> <model>` triple and a re-measure replaces the row's line
816
+ like any other. The split, the transcript count, and every degradation stay
817
+ **stdout caveats at measurement time** — a log field with no reader is a field
818
+ removed, and none of these has one. The row's own named readers are the
819
+ `/economics` narrative's fan-out line item (§The `/economics` skill), the
820
+ operator reading the trend log close-over-close, and the deferred
821
+ `benchmark-ab-experiment` rung's measurement half, which consumes this log
822
+ rather than rebuilding it and inherits the row with no change.
823
+ **No dispatch-type dimension either, and that is the answer to a question the
824
+ row invites.** A fork is distinguishable at the meta layer — its record carries
825
+ `isFork` beside an `agentType` naming the fork type, and carries no `model` —
826
+ but the row folds a stage's whole subtree into one line, so "what did forking
827
+ cost" is not a query this log answers. It is re-derived by walking
828
+ `parentAgentId` and pricing the fork transcripts directly, which is the honest
829
+ cost of leaving the dimension out until a reader for it exists.
830
+ - **No lifecycle change.** No stamp is added, no cursor moves, no stage-skill
831
+ template changes. The fan-out edge is *derived*, exactly as the supervision edge
832
+ is, which is what keeps this a read-only consumption of lifecycle-kit/SPEC.md
833
+ §The state machine.
663
834
 
664
835
  ## The `/economics` skill
665
836
 
@@ -693,7 +864,7 @@ drift-kit/
693
864
  bin/stage-economics.sh # the stage × model × iteration spend pricer
694
865
  kpis/kpi-*.sh # the bundled generic set
695
866
  templates/drift-config.sh
696
- templates/kpis.list # example registry (consumer copies + prunes)
867
+ templates/kpis.list # the shipped registry: every bundled KPI (consumer copies + prunes)
697
868
  templates/kpi-deprecated-surface.sh # example toolchain-shaped KPI (§Out of scope)
698
869
  templates/close-knowledge.md
699
870
  templates/price-table.tsv # placeholder + schema for the stage-economics price table (consumer fills the roster)
@@ -705,6 +876,15 @@ drift-kit/
705
876
  Registers no gates (advisory; the guard-kit precedent), so no `checks/`,
706
877
  `gate-tests/`, or `smoke/violation.sh`.
707
878
 
879
+ `templates/kpis.list` names every plugin in `kpis/`, never a starter subset: it
880
+ is the kit's claim about what it bundles, which the roster above, this SPEC, and
881
+ the smoke's per-KPI row assertion are all stated over. Pruning is the
882
+ *consumer's* act on its own copy, and the template's header says so.
883
+ `gate-sdk/SPEC.md §check-template-registry-parity` holds the two in parity both
884
+ ways — the sibling-directory pairing is what puts this template in that gate's
885
+ population, and `templates/kpi-deprecated-surface.sh`, an example a consumer
886
+ adapts rather than a bundled plugin, out of it.
887
+
708
888
  Config follows the established kit pattern: copy `templates/drift-config.sh`
709
889
  into the gates dir (or point `DRIFT_KIT_CONFIG_FILE` elsewhere) and override
710
890
  any knob; defaults fill what the consumer left unset, and a set-but-missing
@@ -783,6 +963,17 @@ Knobs (this repo's layout as defaults):
783
963
  lifecycle roster already carries that word renames it here; a stamp naming the
784
964
  label collides and suppresses the rows for that run rather than blending two
785
965
  meanings into one column value.
966
+ - `DRIFT_KIT_FANOUT_SUFFIX` — the suffix the stage-economics meter appends to an
967
+ anchor's stage-or-role value to name its dispatched subtree's row
968
+ (§The stage-economics meter, the fan-out row); default `+fanout`. The default is
969
+ collision-proof by construction (`+` is outside the stamp's stage alphabet); an
970
+ override that a stamped stage name ends in collides and suppresses the fan-out
971
+ rows for that run. Deliberately the *only* new knob: a meta-filename or
972
+ field-name knob would imply a portability the mechanism does not have (a
973
+ consumer on a different harness has a different artifact, not a differently
974
+ named one), and an opt-out for reading the meta layer would either default on
975
+ and be set by nobody or default off and ship the feature as dead code — the
976
+ degradation contract already gives a consumer the only thing an opt-out buys.
786
977
  - `DRIFT_KIT_STATE_FILE` — the WORKFLOW-STATE path whose *committed history and
787
978
  live content* the stage-economics join reads for stamps (§The stage-economics
788
979
  meter, history ∪ live); default `${GATE_SDK_WORKFLOW_DIR:-.workflow}/WORKFLOW-STATE.txt` (the
@@ -801,9 +992,24 @@ The report and every bundled plugin are advisory plain text over live git
801
992
  state — not fixture-stable, so no expected-output corpus (the gate
802
993
  contracts do not fit; context-kit's reasoning). `smoke/install.sh` builds
803
994
  the throwaway consumer, registers the bundled set, and asserts: exit 0 with
804
- both section headers and one row per registered KPI; a registry naming a
805
- missing plugin yields its visible `n/a` row without failing; `--trend`
806
- emits exactly one line. The trajectory extractor needs committed history the
995
+ both section headers and **at least** one row per registered KPI; a registry
996
+ naming a missing plugin yields its visible `n/a` row without failing; `--trend`
997
+ emits exactly one line; and, per registered name resolving to a bundled plugin,
998
+ that **the plugin itself emits a row when invoked directly**.
999
+
1000
+ A floor, not equality, because a plugin owns one *or more* rows —
1001
+ `kpi-queue-net-delta` (§Bundled KPIs) emits two by design — so equality would red
1002
+ the moment the bundled set contains a multi-row plugin. The per-plugin probe
1003
+ beside it is what carries the bite the floor cannot: the report substitutes its
1004
+ own `n/a (plugin failed)` row for a plugin that exits non-zero or emits nothing,
1005
+ so the row count holds even where every plugin is silent, and a multi-row plugin
1006
+ would in any case offset a sibling contributing none. Contribution is the
1007
+ property, not health — an `n/a` row is a row — and a name resolving to no plugin
1008
+ is skipped, that row being the report's own and asserted separately. The probe
1009
+ asserts it probed something, so a resolution change cannot make it vacuous.
1010
+ Residual limit, stated because it is real: neither assertion pins *which* plugin
1011
+ emitted a given row, so a plugin emitting the wrong number of rows is not caught.
1012
+ The trajectory extractor needs committed history the
807
1013
  throwaway consumer lacks, so `smoke/install.sh` proves it against a hermetic
808
1014
  fake-history repo — one closed, range-bounded iteration — and asserts the
809
1015
  table parses, that iteration's row is emitted, and the in-flight iteration's
@@ -845,7 +1051,28 @@ asserts exactly one supervision row is emitted for the iteration carrying the
845
1051
  lead transcript's own usage, that the dispatched session keeps its own stage row,
846
1052
  that the row's label is `DRIFT_KIT_SUPERVISION_LABEL`'s value rather than a
847
1053
  literal, and that a stamp naming the label suppresses the row with the collision
848
- notice. `kpi-price-table-age` is fixture-stable in the same way — it reads two
1054
+ notice. (iii) A *fan-out* fixture — a synthetic three-level tree: a flat
1055
+ `<lead>.jsonl`, and under `<lead>/subagents/` a stamped stage transcript with a
1056
+ `spawnDepth` 1 meta record, a child at `spawnDepth` 2 naming it as
1057
+ `parentAgentId`, and a grandchild at `spawnDepth` 3 naming the child; plus a
1058
+ **second session stamped into the same `(iteration, stage)`** carrying no
1059
+ assistant usage, with a child of its own — the batch-split shape, which is also
1060
+ the one that proves a stage anchors on its stamp *resolving* rather than on
1061
+ emitting a row. It asserts exactly one fan-out row for the stamped stage whose
1062
+ tokens are the **sum over the whole subtree** (so both a walk that stopped at
1063
+ depth 2 and two anchors racing under the dedup key instead of folding red), that
1064
+ the contributing anchor count is named where it exceeds one, that the stage
1065
+ row still carries only the stage session's own usage (so a fold reds), that the
1066
+ suffix comes from `DRIFT_KIT_FANOUT_SUFFIX` rather than a literal, that a stamp
1067
+ whose stage ends in the suffix raises the collision notice and suppresses the row,
1068
+ and that the under-count bound excludes every transcript the pass attributed.
1069
+ Its two **degradation** assertions are what make the coupling's bounded failure
1070
+ testable rather than asserted, and neither may be dropped for brevity: deleting
1071
+ the grandchild's meta record moves it back into the under-count bound and raises
1072
+ the counted unresolved notice while every row the pass does not own stays
1073
+ byte-identical, and deleting the whole meta layer emits zero fan-out rows plus the
1074
+ single notice with — again — every other row byte-identical.
1075
+ `kpi-price-table-age` is fixture-stable in the same way — it reads two
849
1076
  dates out of a file the fixture writes — so `smoke/install.sh` drives it over
850
1077
  purpose-built tables and asserts the age row, the `price <N>d` trend fragment,
851
1078
  each header's absence degrading its own row independently, and — **the
@@ -855,7 +1082,13 @@ and whose `prices-valid-through:` has passed reads a fresh age row and an
855
1082
  has not tested the feature: the age row is reassuring in exactly that case,
856
1083
  which is the defect. The no-table degradation is asserted to emit its single
857
1084
  `n/a (no price table)` row, and the report-wide one-row-per-registered-KPI
858
- assertion covers that shape from the other side. Gate-sdk's `check-shellcheck`
1085
+ assertion covers that shape from the other side. `kpi-incident-recurrence` is
1086
+ fixture-stable on the same grounds — it reads declarations out of a queue file the
1087
+ fixture writes — so `smoke/install.sh` drives it over a purpose-built queue and
1088
+ asserts the single lag row, that the count **sums dates across declarations**
1089
+ rather than counting declarations, the highest-count slug, the `recur <N>` trend
1090
+ fragment, and both degradations (a queue with no declaration, and no queue file at
1091
+ all) including the trend's silence under the first. Gate-sdk's `check-shellcheck`
859
1092
  lints all kit sources as usual.
860
1093
 
861
1094
  ## Out of scope
@@ -30,6 +30,7 @@ unset _ds_cfg
30
30
  : "${DRIFT_KIT_PRICE_TABLE:=${GATE_SDK_GATES_DIR:-scripts}/price-table.tsv}"
31
31
  : "${DRIFT_KIT_STATE_FILE:=${GATE_SDK_WORKFLOW_DIR:-.workflow}/WORKFLOW-STATE.txt}"
32
32
  : "${DRIFT_KIT_SUPERVISION_LABEL:=supervision}"
33
+ : "${DRIFT_KIT_FANOUT_SUFFIX:=+fanout}"
33
34
 
34
35
  sessions_dir() {
35
36
  if [[ -n "${DRIFT_KIT_SESSIONS_DIR:-}" ]]; then
@@ -165,9 +166,15 @@ printf 'stage-economics: %s\n' "$today"
165
166
  # one (iteration, stage). The stamp pass keys on the session, not the stamp, so a session bearing
166
167
  # two stamps resolves to its last one and the yielded stamps take no row instead of a duplicate.
167
168
  declare -A STAMP_SEEN=() SESS_CHOICE=() SESS_YIELDED=() ATTRIBUTED=() DISPATCH=() LEAD_SEEN=()
169
+ # spec: drift-kit/SPEC.md §The stage-economics meter — the fan-out row: an anchor is a transcript that
170
+ # already holds a row, and it carries the apportionment its own row was split by, so a lead's fan-out
171
+ # and its supervision row can never disagree about which iteration the lead belonged to.
172
+ declare -A ANCHOR_LABEL=() ANCHOR_ITERS=() ANCHOR_COUNTS=() ANCHOR_WHO=()
168
173
  SESS_ORDER=()
169
174
  LEAD_ORDER=()
175
+ ANCHOR_ORDER=()
170
176
  label_collision=0
177
+ suffix_collision=0
171
178
  stamps=0
172
179
  while read -r iter stage session8 _date _rest; do
173
180
  [[ -z "$iter" || "$iter" == \#* || "$iter" == "---" ]] && continue
@@ -176,6 +183,7 @@ while read -r iter stage session8 _date _rest; do
176
183
  STAMP_SEEN["$iter/$stage/$session8"]=1
177
184
  stamps=$((stamps + 1))
178
185
  [[ "$stage" == "$DRIFT_KIT_SUPERVISION_LABEL" ]] && label_collision=1
186
+ [[ -n "$DRIFT_KIT_FANOUT_SUFFIX" && "$stage" == *"$DRIFT_KIT_FANOUT_SUFFIX" ]] && suffix_collision=1
179
187
  if [[ -n "${SESS_CHOICE[$session8]:-}" ]]; then
180
188
  SESS_YIELDED[$session8]="${SESS_YIELDED[$session8]:-}${SESS_CHOICE[$session8]}; "
181
189
  else
@@ -202,6 +210,16 @@ for session8 in ${SESS_ORDER[@]+"${SESS_ORDER[@]}"}; do
202
210
  continue
203
211
  fi
204
212
  ATTRIBUTED[$transcript]=1
213
+ # spec: drift-kit/SPEC.md §The stage-economics meter — a stage anchors on the stamp resolving, not on a
214
+ # row being emitted: a stamped stage whose transcript carries no usage is still a real, placeable
215
+ # (iteration, stage) for its subtree, where a supervision role that emitted nothing is not a role at all.
216
+ if [[ -z "${ANCHOR_LABEL[$transcript]:-}" ]]; then
217
+ ANCHOR_LABEL[$transcript]="$stage"
218
+ ANCHOR_ITERS[$transcript]="$iter"
219
+ ANCHOR_COUNTS[$transcript]="1"
220
+ ANCHOR_WHO[$transcript]="$session8"
221
+ ANCHOR_ORDER+=("$transcript")
222
+ fi
205
223
  # spec: drift-kit/SPEC.md §The stage-economics meter — a nested-tier transcript names its supervising lead in
206
224
  # its own path, which is what makes the supervision row derivable with no stamp and no lifecycle change.
207
225
  if [[ "$transcript" == */subagents/*.jsonl ]]; then
@@ -278,13 +296,147 @@ if [[ "$degraded" -eq 0 && ${#LEAD_ORDER[@]} -gt 0 ]]; then
278
296
  done
279
297
  done <<< "$usage"
280
298
  ATTRIBUTED[$lead_path]=1
299
+ ANCHOR_LABEL[$lead_path]="$DRIFT_KIT_SUPERVISION_LABEL"
300
+ ANCHOR_ITERS[$lead_path]="${iters[*]}"
301
+ ANCHOR_COUNTS[$lead_path]="${counts[*]}"
302
+ ANCHOR_WHO[$lead_path]="$(normalize8 "$lead")"
303
+ ANCHOR_ORDER+=("$lead_path")
281
304
  done
282
305
  fi
283
306
  fi
284
307
 
308
+ # spec: drift-kit/SPEC.md §The stage-economics meter — the fan-out row: the path cannot carry the parent
309
+ # edge, so it comes from the harness's sibling meta record and the walk stops at the nearest anchor.
310
+ fanout_unresolved=0
311
+ fanout_rows=0
312
+ fanout_no_meta=0
313
+ if [[ "$degraded" -eq 0 && "${#ANCHOR_ORDER[@]}" -gt 0 ]]; then
314
+ if [[ "$suffix_collision" -eq 1 ]]; then
315
+ printf ' a stamp names a stage ending in "%s", colliding with DRIFT_KIT_FANOUT_SUFFIX — no fan-out rows emitted this run\n' \
316
+ "$DRIFT_KIT_FANOUT_SUFFIX"
317
+ else
318
+ _fo_dir="$(sessions_dir)"
319
+ declare -A META_PARENT=() META_HAVE=() FANOUT=()
320
+ FANOUT_ORDER=()
321
+ nested=0
322
+ shopt -s nullglob
323
+ for _fo_sub in "$_fo_dir"/*/subagents; do
324
+ _fo_metas=("$_fo_sub"/*.meta.json)
325
+ _fo_scripts=("$_fo_sub"/*.jsonl)
326
+ nested=$((nested + ${#_fo_scripts[@]}))
327
+ [[ "${#_fo_metas[@]}" -gt 0 ]] || continue
328
+ while IFS=$'\t' read -r _fo_mf _fo_pid; do
329
+ [[ -n "$_fo_mf" ]] || continue
330
+ _fo_t="${_fo_mf%.meta.json}.jsonl"
331
+ META_HAVE[$_fo_t]=1
332
+ if [[ -z "$_fo_pid" ]]; then
333
+ META_PARENT[$_fo_t]="${_fo_sub%/subagents}.jsonl"
334
+ elif [[ -f "$_fo_sub/agent-$_fo_pid.jsonl" ]]; then
335
+ META_PARENT[$_fo_t]="$_fo_sub/agent-$_fo_pid.jsonl"
336
+ elif [[ -f "$_fo_sub/$_fo_pid.jsonl" ]]; then
337
+ META_PARENT[$_fo_t]="$_fo_sub/$_fo_pid.jsonl"
338
+ else
339
+ META_PARENT[$_fo_t]="" # named an agent with no transcript: counted, never guessed
340
+ fi
341
+ done < <(jq -r '[input_filename, (.parentAgentId // "")] | @tsv' "${_fo_metas[@]}" 2>/dev/null)
342
+ done
343
+ shopt -u nullglob
344
+
345
+ if [[ "$nested" -gt 0 && "${#META_HAVE[@]}" -eq 0 ]]; then
346
+ fanout_no_meta=1
347
+ else
348
+ walk_anchor() { # $1=transcript -> WALK_ANCHOR = nearest anchor path, empty if none
349
+ local cur="$1" hops=0
350
+ local -A seen=()
351
+ WALK_ANCHOR=""
352
+ while :; do
353
+ if [[ -n "${ANCHOR_LABEL[$cur]:-}" ]]; then WALK_ANCHOR="$cur"; return 0; fi
354
+ hops=$((hops + 1))
355
+ [[ "$hops" -le "$nested" ]] || return 1
356
+ [[ -z "${seen[$cur]:-}" ]] || return 1
357
+ seen[$cur]=1
358
+ [[ -n "${META_HAVE[$cur]:-}" ]] || return 1
359
+ [[ -n "${META_PARENT[$cur]}" ]] || return 1
360
+ cur="${META_PARENT[$cur]}"
361
+ done
362
+ }
363
+
364
+ shopt -s nullglob
365
+ for f in "$_fo_dir"/*/subagents/*.jsonl; do
366
+ [[ -z "${ANCHOR_LABEL[$f]:-}" && -z "${ATTRIBUTED[$f]:-}" ]] || continue
367
+ if ! walk_anchor "$f"; then
368
+ fanout_unresolved=$((fanout_unresolved + 1))
369
+ continue
370
+ fi
371
+ ATTRIBUTED[$f]=1
372
+ usage="$(usage_by_model "$f")"
373
+ [[ -n "$usage" ]] || continue
374
+ while IFS=$'\t' read -r model in out cr cw; do
375
+ [[ -n "$model" ]] || continue
376
+ _fo_key="$WALK_ANCHOR|$model"
377
+ if [[ -z "${FANOUT[$_fo_key]:-}" ]]; then
378
+ FANOUT[$_fo_key]="$in $out $cr $cw"
379
+ FANOUT_ORDER+=("$_fo_key")
380
+ else
381
+ read -r a_in a_out a_cr a_cw <<< "${FANOUT[$_fo_key]}"
382
+ FANOUT[$_fo_key]="$((a_in + in)) $((a_out + out)) $((a_cr + cr)) $((a_cw + cw))"
383
+ fi
384
+ done <<< "$usage"
385
+ done
386
+ shopt -u nullglob
387
+
388
+ # spec: drift-kit/SPEC.md §The stage-economics meter — several anchors, one row: apportion
389
+ # first and fold second, since the split is the anchor's property and the row is not.
390
+ declare -A FOROW=() FOWHO=() FOCNT=()
391
+ FOROW_ORDER=()
392
+ for _fo_key in ${FANOUT_ORDER[@]+"${FANOUT_ORDER[@]}"}; do
393
+ anchor="${_fo_key%|*}"; model="${_fo_key##*|}"
394
+ read -r in out cr cw <<< "${FANOUT[$_fo_key]}"
395
+ read -r -a iters <<< "${ANCHOR_ITERS[$anchor]}"
396
+ read -r -a counts <<< "${ANCHOR_COUNTS[$anchor]}"
397
+ p_in=(); p_out=(); p_cr=(); p_cw=()
398
+ while IFS= read -r v; do p_in+=("$v"); done < <(split_tokens "$in" "${counts[@]}")
399
+ while IFS= read -r v; do p_out+=("$v"); done < <(split_tokens "$out" "${counts[@]}")
400
+ while IFS= read -r v; do p_cr+=("$v"); done < <(split_tokens "$cr" "${counts[@]}")
401
+ while IFS= read -r v; do p_cw+=("$v"); done < <(split_tokens "$cw" "${counts[@]}")
402
+ for i in "${!iters[@]}"; do
403
+ _fo_rk="${iters[$i]}|${ANCHOR_LABEL[$anchor]}|$model"
404
+ if [[ -z "${FOROW[$_fo_rk]:-}" ]]; then
405
+ FOROW[$_fo_rk]="${p_in[$i]} ${p_out[$i]} ${p_cr[$i]} ${p_cw[$i]}"
406
+ FOWHO[$_fo_rk]="${ANCHOR_WHO[$anchor]}"
407
+ FOCNT[$_fo_rk]=1
408
+ FOROW_ORDER+=("$_fo_rk")
409
+ else
410
+ read -r a_in a_out a_cr a_cw <<< "${FOROW[$_fo_rk]}"
411
+ FOROW[$_fo_rk]="$((a_in + p_in[i])) $((a_out + p_out[i])) $((a_cr + p_cr[i])) $((a_cw + p_cw[i]))"
412
+ FOCNT[$_fo_rk]=$(( FOCNT[$_fo_rk] + 1 ))
413
+ fi
414
+ done
415
+ done
416
+
417
+ for _fo_rk in ${FOROW_ORDER[@]+"${FOROW_ORDER[@]}"}; do
418
+ _fo_iter="${_fo_rk%%|*}"; _fo_rest="${_fo_rk#*|}"
419
+ _fo_label="${_fo_rest%|*}"; model="${_fo_rest##*|}"
420
+ read -r in out cr cw <<< "${FOROW[$_fo_rk]}"
421
+ who="${FOWHO[$_fo_rk]}"
422
+ [[ "${FOCNT[$_fo_rk]}" -eq 1 ]] || who="${FOCNT[$_fo_rk]} anchors"
423
+ emit_row "$_fo_iter" "$_fo_label$DRIFT_KIT_FANOUT_SUFFIX" "$who" \
424
+ "$model" "$in" "$out" "$cr" "$cw"
425
+ fanout_rows=$((fanout_rows + 1))
426
+ done
427
+ fi
428
+ fi
429
+ fi
430
+
431
+ [[ "$fanout_no_meta" -eq 0 ]] || \
432
+ printf ' no dispatch-attribution records beside the transcripts — no fan-out rows this run; every other row is unchanged (degraded, not failed)\n'
433
+ [[ "$fanout_unresolved" -eq 0 ]] || \
434
+ printf ' %d dispatched transcript(s) resolved no anchor (absent or dangling attribution record, or an over-long chain) — each stays in the unstamped bound below, never guessed\n' \
435
+ "$fanout_unresolved"
436
+
285
437
  # spec: drift-kit/SPEC.md §The stage-economics meter — the under-count bound: the unmatched counter reports stamps
286
438
  # with no transcript and is structurally blind to the inverse, so the inverse is counted too. A bound,
287
- # never an attribution — a transcript carries no iteration and no stage, so nothing could place it.
439
+ # never an attribution — what remains is a transcript that resolved no anchor, so nothing could place it.
288
440
  unstamped=0
289
441
  if [[ "$degraded" -eq 0 ]]; then
290
442
  _se_dir="$(sessions_dir)"
@@ -301,11 +453,13 @@ fi
301
453
  [[ "$unmatched" -eq 0 ]] || \
302
454
  printf ' %d stamp(s) had no matching transcript (skipped — session transcripts age out of the sessions dir)\n' "$unmatched"
303
455
  [[ "$unstamped" -eq 0 ]] || \
304
- printf ' %d transcript(s) in the sessions dir match no stamp and bill to no row — an upper bound on the unstamped-continuation under-count, not an attribution\n' "$unstamped"
456
+ printf ' %d transcript(s) in the sessions dir match no stamp and resolved no anchor, so they bill to no row — an upper bound on the unstamped-continuation under-count, not an attribution\n' "$unstamped"
305
457
 
306
458
  if [[ "$incomplete" -eq 1 ]]; then
307
459
  printf ' total pricing incomplete — one or more model cost cells degraded to n/a (unpriced model or absent table)\n'
308
460
  fi
309
- printf ' (cr=cache-read is the headline burn lever; one transcript bills to exactly one (iteration, stage) — a session bearing several stamps is attributed to its last and the yielded stamps are named above, never billed twice)\n'
461
+ printf ' (cr=cache-read is the headline burn lever; one transcript bills to exactly one row key — an (iteration, stage-or-role) pair or that pair'"'"'s fan-out value — so a session bearing several stamps is attributed to its last and the yielded stamps are named above, never billed twice)\n'
462
+ [[ "$fanout_rows" -eq 0 ]] || \
463
+ printf ' a per-stage figure above excludes its own fan-out: the subtree is the adjacent "%s" row, an aggregate over every dispatch shape (a fork and a typed dispatch fold into one total)\n' "$DRIFT_KIT_FANOUT_SUFFIX"
310
464
  printf ' logged: %s (%d row(s))\n' "$DRIFT_KIT_STAGE_ECONOMICS_LOG" "$rows"
311
465
  exit 0
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env bash
2
+ # spec: drift-kit/SPEC.md §Bundled KPIs — kpi-incident-recurrence: re-filings recorded by the queue's `recurrence:` declarations, and the highest-count slug (queue-kit/SPEC.md §The tag algebra owns the grammar; the second implementation is accepted residual — drift-kit cannot source queue-kit's lib without a cross-kit cycle)
3
+ set -uo pipefail
4
+
5
+ QUEUE="${DRIFT_KIT_QUEUE_FILE:-TASK-QUEUE.md}"
6
+
7
+ if [[ ! -f "$QUEUE" ]]; then
8
+ [[ "${1:-}" == "--trend" ]] && exit 0
9
+ printf 'lag\tincident recurrence\tn/a (no queue file)\n'
10
+ exit 0
11
+ fi
12
+
13
+ # spec: drift-kit/SPEC.md §Bundled KPIs — the declaration is self-slug-bearing and lives on a line of its own, so one anchored scan reads it with no entry-boundary parsing
14
+ read -r total top_slug top_count <<<"$(
15
+ awk '
16
+ $1 == "recurrence:" && NF >= 3 {
17
+ n = 0
18
+ for (i = 3; i <= NF; i++)
19
+ if ($i ~ /^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/) n++
20
+ if (n == 0) next
21
+ total += n
22
+ if (n > top) { top = n; slug = $2 }
23
+ }
24
+ END { printf "%d %s %d\n", total + 0, (slug == "" ? "-" : slug), top + 0 }
25
+ ' "$QUEUE" 2>/dev/null
26
+ )"
27
+
28
+ [[ "$total" =~ ^[0-9]+$ ]] || total=0
29
+
30
+ if [[ "$total" -eq 0 ]]; then
31
+ [[ "${1:-}" == "--trend" ]] && exit 0
32
+ printf 'lag\tincident recurrence\tn/a (no recurrence declaration in the queue)\n'
33
+ exit 0
34
+ fi
35
+
36
+ if [[ "${1:-}" == "--trend" ]]; then
37
+ printf 'recur %d\n' "$total"
38
+ exit 0
39
+ fi
40
+ printf 'lag\tincident recurrence\t%d re-filing(s) recorded; highest %s at %d (captured filings only — a lower bound)\n' \
41
+ "$total" "$top_slug" "$top_count"
42
+ exit 0