@kontourai/flow-agents 3.12.0 → 4.0.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 (1029) hide show
  1. package/.github/workflows/ci.yml +76 -0
  2. package/CHANGELOG.md +48 -0
  3. package/build/generated/capability-declarations.json +177 -0
  4. package/build/src/builder-flow-runtime.d.ts +37 -0
  5. package/build/src/builder-flow-runtime.js +71 -1
  6. package/build/src/builder-gate-action-envelope.d.ts +59 -7
  7. package/build/src/builder-gate-action-envelope.js +163 -30
  8. package/build/src/builder-lifecycle-authority.d.ts +26 -0
  9. package/build/src/builder-lifecycle-authority.js +38 -0
  10. package/build/src/cli/builder-run.js +71 -2
  11. package/build/src/cli/narrative-render.d.ts +95 -0
  12. package/build/src/cli/narrative-render.js +466 -0
  13. package/build/src/cli/narrative-sources.d.ts +2 -0
  14. package/build/src/cli/narrative-sources.js +282 -0
  15. package/build/src/cli/public-contracts.d.ts +257 -0
  16. package/build/src/cli/public-contracts.js +87 -0
  17. package/build/src/cli/workflow-sidecar.d.ts +28 -12
  18. package/build/src/cli/workflow-sidecar.js +599 -180
  19. package/build/src/cli/workflow.js +11 -1
  20. package/build/src/cli.js +8 -0
  21. package/build/src/continuation-driver.d.ts +12 -0
  22. package/build/src/continuation-driver.js +16 -2
  23. package/build/src/continuation-validation.js +349 -3
  24. package/build/src/flow-kit/action-metadata.js +21 -1
  25. package/build/src/index.d.ts +33 -2
  26. package/build/src/index.js +24 -0
  27. package/build/src/lib/capability-declarations.d.ts +83 -0
  28. package/build/src/lib/capability-declarations.js +209 -0
  29. package/build/src/narrative/envelope.d.ts +111 -0
  30. package/build/src/narrative/envelope.js +590 -0
  31. package/build/src/narrative/eval-result.d.ts +60 -0
  32. package/build/src/narrative/eval-result.js +158 -0
  33. package/build/src/narrative/grounding-validator.d.ts +104 -0
  34. package/build/src/narrative/grounding-validator.js +472 -0
  35. package/build/src/narrative/integrity.d.ts +17 -0
  36. package/build/src/narrative/integrity.js +39 -0
  37. package/build/src/narrative/intent-economics.d.ts +42 -0
  38. package/build/src/narrative/intent-economics.js +82 -0
  39. package/build/src/narrative/intent.d.ts +94 -0
  40. package/build/src/narrative/intent.js +132 -0
  41. package/build/src/narrative/policy-filter.d.ts +15 -0
  42. package/build/src/narrative/policy-filter.js +58 -0
  43. package/build/src/narrative/projection.d.ts +58 -0
  44. package/build/src/narrative/projection.js +502 -0
  45. package/build/src/narrative/readers.d.ts +84 -0
  46. package/build/src/narrative/readers.js +406 -0
  47. package/build/src/narrative/render.d.ts +3 -0
  48. package/build/src/narrative/render.js +83 -0
  49. package/build/src/narrative/resolver.d.ts +52 -0
  50. package/build/src/narrative/resolver.js +190 -0
  51. package/build/src/narrative/snapshot.d.ts +90 -0
  52. package/build/src/narrative/snapshot.js +325 -0
  53. package/build/src/narrative/source-ids.d.ts +121 -0
  54. package/build/src/narrative/source-ids.js +201 -0
  55. package/build/src/narrative/statements.d.ts +84 -0
  56. package/build/src/narrative/statements.js +347 -0
  57. package/build/src/narrative/turn-spine.d.ts +19 -0
  58. package/build/src/narrative/turn-spine.js +73 -0
  59. package/build/src/tools/build-universal-bundles.js +8 -0
  60. package/build/src/tools/generate-capability-matrix.d.ts +7 -0
  61. package/build/src/tools/generate-capability-matrix.js +207 -0
  62. package/build/src/tools/validate-source-tree.js +5 -1
  63. package/context/scripts/hooks/stop-goal-fit.js +182 -9
  64. package/context/scripts/hooks/workflow-steering.js +160 -19
  65. package/context/scripts/telemetry/lib/session.sh +3 -0
  66. package/context/scripts/telemetry/lib/transport.sh +12 -3
  67. package/context/scripts/telemetry/telemetry.sh +480 -59
  68. package/dist/base/build/generated/capability-declarations.json +177 -0
  69. package/dist/base/build/package.json +1 -1
  70. package/dist/base/build/src/builder-flow-runtime.d.ts +37 -0
  71. package/dist/base/build/src/builder-flow-runtime.js +71 -1
  72. package/dist/base/build/src/builder-gate-action-envelope.d.ts +59 -7
  73. package/dist/base/build/src/builder-gate-action-envelope.js +163 -30
  74. package/dist/base/build/src/builder-lifecycle-authority.d.ts +26 -0
  75. package/dist/base/build/src/builder-lifecycle-authority.js +38 -0
  76. package/dist/base/build/src/cli/builder-run.js +71 -2
  77. package/dist/base/build/src/cli/narrative-render.d.ts +95 -0
  78. package/dist/base/build/src/cli/narrative-render.js +466 -0
  79. package/dist/base/build/src/cli/narrative-sources.d.ts +2 -0
  80. package/dist/base/build/src/cli/narrative-sources.js +282 -0
  81. package/dist/base/build/src/cli/public-contracts.d.ts +257 -0
  82. package/dist/base/build/src/cli/public-contracts.js +87 -0
  83. package/dist/base/build/src/cli/workflow-sidecar.d.ts +28 -12
  84. package/dist/base/build/src/cli/workflow-sidecar.js +599 -180
  85. package/dist/base/build/src/cli/workflow.js +11 -1
  86. package/dist/base/build/src/cli.js +8 -0
  87. package/dist/base/build/src/continuation-driver.d.ts +12 -0
  88. package/dist/base/build/src/continuation-driver.js +16 -2
  89. package/dist/base/build/src/continuation-validation.js +349 -3
  90. package/dist/base/build/src/flow-kit/action-metadata.js +21 -1
  91. package/dist/base/build/src/index.d.ts +33 -2
  92. package/dist/base/build/src/index.js +24 -0
  93. package/dist/base/build/src/lib/capability-declarations.d.ts +83 -0
  94. package/dist/base/build/src/lib/capability-declarations.js +209 -0
  95. package/dist/base/build/src/narrative/envelope.d.ts +111 -0
  96. package/dist/base/build/src/narrative/envelope.js +590 -0
  97. package/dist/base/build/src/narrative/eval-result.d.ts +60 -0
  98. package/dist/base/build/src/narrative/eval-result.js +158 -0
  99. package/dist/base/build/src/narrative/grounding-validator.d.ts +104 -0
  100. package/dist/base/build/src/narrative/grounding-validator.js +472 -0
  101. package/dist/base/build/src/narrative/integrity.d.ts +17 -0
  102. package/dist/base/build/src/narrative/integrity.js +39 -0
  103. package/dist/base/build/src/narrative/intent-economics.d.ts +42 -0
  104. package/dist/base/build/src/narrative/intent-economics.js +82 -0
  105. package/dist/base/build/src/narrative/intent.d.ts +94 -0
  106. package/dist/base/build/src/narrative/intent.js +132 -0
  107. package/dist/base/build/src/narrative/policy-filter.d.ts +15 -0
  108. package/dist/base/build/src/narrative/policy-filter.js +58 -0
  109. package/dist/base/build/src/narrative/projection.d.ts +58 -0
  110. package/dist/base/build/src/narrative/projection.js +502 -0
  111. package/dist/base/build/src/narrative/readers.d.ts +84 -0
  112. package/dist/base/build/src/narrative/readers.js +406 -0
  113. package/dist/base/build/src/narrative/render.d.ts +3 -0
  114. package/dist/base/build/src/narrative/render.js +83 -0
  115. package/dist/base/build/src/narrative/resolver.d.ts +52 -0
  116. package/dist/base/build/src/narrative/resolver.js +190 -0
  117. package/dist/base/build/src/narrative/snapshot.d.ts +90 -0
  118. package/dist/base/build/src/narrative/snapshot.js +325 -0
  119. package/dist/base/build/src/narrative/source-ids.d.ts +121 -0
  120. package/dist/base/build/src/narrative/source-ids.js +201 -0
  121. package/dist/base/build/src/narrative/statements.d.ts +84 -0
  122. package/dist/base/build/src/narrative/statements.js +347 -0
  123. package/dist/base/build/src/narrative/turn-spine.d.ts +19 -0
  124. package/dist/base/build/src/narrative/turn-spine.js +73 -0
  125. package/dist/base/build/src/tools/build-universal-bundles.js +8 -0
  126. package/dist/base/build/src/tools/generate-capability-matrix.d.ts +7 -0
  127. package/dist/base/build/src/tools/generate-capability-matrix.js +207 -0
  128. package/dist/base/build/src/tools/validate-source-tree.js +5 -1
  129. package/dist/base/context/scripts/hooks/stop-goal-fit.js +182 -9
  130. package/dist/base/context/scripts/hooks/workflow-steering.js +160 -19
  131. package/dist/base/context/scripts/telemetry/lib/session.sh +3 -0
  132. package/dist/base/context/scripts/telemetry/lib/transport.sh +12 -3
  133. package/dist/base/context/scripts/telemetry/telemetry.sh +480 -59
  134. package/dist/base/docs/context-map.md +4 -0
  135. package/dist/base/docs/decisions/index.md +1 -0
  136. package/dist/base/docs/decisions/writer-observed-execution.md +51 -0
  137. package/dist/base/docs/fixture-ownership.md +5 -1
  138. package/dist/base/docs/migrations.md +20 -0
  139. package/dist/base/docs/public-workflow-cli.md +9 -0
  140. package/dist/base/docs/spec/builder-flow-runtime.md +49 -8
  141. package/dist/base/docs/spec/runtime-hook-surface.md +29 -1
  142. package/dist/base/docs/specs/economics-record-contract.md +1 -1
  143. package/dist/base/docs/specs/harness-capability-matrix.md +63 -21
  144. package/dist/base/docs/workflow-usage-guide.md +4 -1
  145. package/dist/base/evals/ci/run-baseline.sh +38 -0
  146. package/dist/base/evals/fixtures/narrative-evals/README.md +62 -0
  147. package/dist/base/evals/fixtures/narrative-evals/corpus.json +129 -0
  148. package/dist/base/evals/fixtures/narrative-evals/scorer.mjs +522 -0
  149. package/dist/base/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
  150. package/dist/base/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
  151. package/dist/base/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
  152. package/dist/base/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
  153. package/dist/base/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
  154. package/dist/base/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
  155. package/dist/base/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
  156. package/dist/base/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
  157. package/dist/base/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
  158. package/dist/base/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
  159. package/dist/base/evals/fixtures/narrative-sources/repo/created.txt +1 -0
  160. package/dist/base/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
  161. package/dist/base/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
  162. package/dist/base/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
  163. package/dist/base/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
  164. package/dist/base/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
  165. package/dist/base/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
  166. package/dist/base/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
  167. package/dist/base/evals/integration/test_capability_declarations.sh +183 -0
  168. package/dist/base/evals/integration/test_economics_record.sh +42 -0
  169. package/dist/base/evals/integration/test_fixture_retirement_audit.sh +2 -2
  170. package/dist/base/evals/integration/test_gate_review_inquiry_records.sh +42 -35
  171. package/dist/base/evals/integration/test_goal_fit_hook.sh +13 -5
  172. package/dist/base/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
  173. package/dist/base/evals/integration/test_narrative_evals.sh +174 -0
  174. package/dist/base/evals/integration/test_narrative_grounded_envelope.sh +280 -0
  175. package/dist/base/evals/integration/test_narrative_grounding_validator.sh +166 -0
  176. package/dist/base/evals/integration/test_narrative_intent_annotation.sh +205 -0
  177. package/dist/base/evals/integration/test_narrative_prose_renderer.sh +239 -0
  178. package/dist/base/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
  179. package/dist/base/evals/integration/test_narrative_runtime_projection.sh +146 -0
  180. package/dist/base/evals/integration/test_narrative_source_contract.sh +228 -0
  181. package/dist/base/evals/integration/test_narrative_trust_isolation.sh +408 -0
  182. package/dist/base/evals/integration/test_plain_stop_messaging.sh +91 -0
  183. package/dist/base/evals/integration/test_session_resume_roundtrip.sh +228 -0
  184. package/dist/base/evals/integration/test_telemetry_action_class.sh +265 -0
  185. package/dist/base/evals/integration/test_telemetry_delegation.sh +291 -0
  186. package/dist/base/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
  187. package/dist/base/evals/integration/test_telemetry_task_slug.sh +158 -0
  188. package/dist/base/evals/integration/test_telemetry_tool_outcome.sh +279 -0
  189. package/dist/base/evals/integration/test_workflow_sidecar_writer.sh +111 -2
  190. package/dist/base/evals/run.sh +12 -0
  191. package/dist/base/evals/static/test_library_exports.sh +5 -0
  192. package/dist/base/install.sh +1 -1
  193. package/dist/base/schemas/grounded-execution-narrative.schema.json +292 -0
  194. package/dist/base/schemas/narrative-eval-result.schema.json +205 -0
  195. package/dist/base/schemas/narrative-runtime-projection.schema.json +134 -0
  196. package/dist/base/schemas/narrative-source-manifest.schema.json +294 -0
  197. package/dist/base/scripts/check-hachure-boundary.mjs +81 -0
  198. package/dist/base/scripts/hooks/stop-goal-fit.js +182 -9
  199. package/dist/base/scripts/hooks/workflow-steering.js +160 -19
  200. package/dist/base/scripts/telemetry/economics-record.schema.json +1 -1
  201. package/dist/base/scripts/telemetry/economics-record.sh +47 -3
  202. package/dist/base/scripts/telemetry/lib/session.sh +3 -0
  203. package/dist/base/scripts/telemetry/lib/transport.sh +12 -3
  204. package/dist/base/scripts/telemetry/telemetry.sh +480 -59
  205. package/dist/claude-code/build/generated/capability-declarations.json +177 -0
  206. package/dist/claude-code/build/package.json +1 -1
  207. package/dist/claude-code/build/src/builder-flow-runtime.d.ts +37 -0
  208. package/dist/claude-code/build/src/builder-flow-runtime.js +71 -1
  209. package/dist/claude-code/build/src/builder-gate-action-envelope.d.ts +59 -7
  210. package/dist/claude-code/build/src/builder-gate-action-envelope.js +163 -30
  211. package/dist/claude-code/build/src/builder-lifecycle-authority.d.ts +26 -0
  212. package/dist/claude-code/build/src/builder-lifecycle-authority.js +38 -0
  213. package/dist/claude-code/build/src/cli/builder-run.js +71 -2
  214. package/dist/claude-code/build/src/cli/narrative-render.d.ts +95 -0
  215. package/dist/claude-code/build/src/cli/narrative-render.js +466 -0
  216. package/dist/claude-code/build/src/cli/narrative-sources.d.ts +2 -0
  217. package/dist/claude-code/build/src/cli/narrative-sources.js +282 -0
  218. package/dist/claude-code/build/src/cli/public-contracts.d.ts +257 -0
  219. package/dist/claude-code/build/src/cli/public-contracts.js +87 -0
  220. package/dist/claude-code/build/src/cli/workflow-sidecar.d.ts +28 -12
  221. package/dist/claude-code/build/src/cli/workflow-sidecar.js +599 -180
  222. package/dist/claude-code/build/src/cli/workflow.js +11 -1
  223. package/dist/claude-code/build/src/cli.js +8 -0
  224. package/dist/claude-code/build/src/continuation-driver.d.ts +12 -0
  225. package/dist/claude-code/build/src/continuation-driver.js +16 -2
  226. package/dist/claude-code/build/src/continuation-validation.js +349 -3
  227. package/dist/claude-code/build/src/flow-kit/action-metadata.js +21 -1
  228. package/dist/claude-code/build/src/index.d.ts +33 -2
  229. package/dist/claude-code/build/src/index.js +24 -0
  230. package/dist/claude-code/build/src/lib/capability-declarations.d.ts +83 -0
  231. package/dist/claude-code/build/src/lib/capability-declarations.js +209 -0
  232. package/dist/claude-code/build/src/narrative/envelope.d.ts +111 -0
  233. package/dist/claude-code/build/src/narrative/envelope.js +590 -0
  234. package/dist/claude-code/build/src/narrative/eval-result.d.ts +60 -0
  235. package/dist/claude-code/build/src/narrative/eval-result.js +158 -0
  236. package/dist/claude-code/build/src/narrative/grounding-validator.d.ts +104 -0
  237. package/dist/claude-code/build/src/narrative/grounding-validator.js +472 -0
  238. package/dist/claude-code/build/src/narrative/integrity.d.ts +17 -0
  239. package/dist/claude-code/build/src/narrative/integrity.js +39 -0
  240. package/dist/claude-code/build/src/narrative/intent-economics.d.ts +42 -0
  241. package/dist/claude-code/build/src/narrative/intent-economics.js +82 -0
  242. package/dist/claude-code/build/src/narrative/intent.d.ts +94 -0
  243. package/dist/claude-code/build/src/narrative/intent.js +132 -0
  244. package/dist/claude-code/build/src/narrative/policy-filter.d.ts +15 -0
  245. package/dist/claude-code/build/src/narrative/policy-filter.js +58 -0
  246. package/dist/claude-code/build/src/narrative/projection.d.ts +58 -0
  247. package/dist/claude-code/build/src/narrative/projection.js +502 -0
  248. package/dist/claude-code/build/src/narrative/readers.d.ts +84 -0
  249. package/dist/claude-code/build/src/narrative/readers.js +406 -0
  250. package/dist/claude-code/build/src/narrative/render.d.ts +3 -0
  251. package/dist/claude-code/build/src/narrative/render.js +83 -0
  252. package/dist/claude-code/build/src/narrative/resolver.d.ts +52 -0
  253. package/dist/claude-code/build/src/narrative/resolver.js +190 -0
  254. package/dist/claude-code/build/src/narrative/snapshot.d.ts +90 -0
  255. package/dist/claude-code/build/src/narrative/snapshot.js +325 -0
  256. package/dist/claude-code/build/src/narrative/source-ids.d.ts +121 -0
  257. package/dist/claude-code/build/src/narrative/source-ids.js +201 -0
  258. package/dist/claude-code/build/src/narrative/statements.d.ts +84 -0
  259. package/dist/claude-code/build/src/narrative/statements.js +347 -0
  260. package/dist/claude-code/build/src/narrative/turn-spine.d.ts +19 -0
  261. package/dist/claude-code/build/src/narrative/turn-spine.js +73 -0
  262. package/dist/claude-code/build/src/tools/build-universal-bundles.js +8 -0
  263. package/dist/claude-code/build/src/tools/generate-capability-matrix.d.ts +7 -0
  264. package/dist/claude-code/build/src/tools/generate-capability-matrix.js +207 -0
  265. package/dist/claude-code/build/src/tools/validate-source-tree.js +5 -1
  266. package/dist/claude-code/context/scripts/hooks/stop-goal-fit.js +182 -9
  267. package/dist/claude-code/context/scripts/hooks/workflow-steering.js +160 -19
  268. package/dist/claude-code/context/scripts/telemetry/lib/session.sh +3 -0
  269. package/dist/claude-code/context/scripts/telemetry/lib/transport.sh +12 -3
  270. package/dist/claude-code/context/scripts/telemetry/telemetry.sh +480 -59
  271. package/dist/claude-code/docs/context-map.md +4 -0
  272. package/dist/claude-code/docs/decisions/index.md +1 -0
  273. package/dist/claude-code/docs/decisions/writer-observed-execution.md +51 -0
  274. package/dist/claude-code/docs/fixture-ownership.md +5 -1
  275. package/dist/claude-code/docs/migrations.md +20 -0
  276. package/dist/claude-code/docs/public-workflow-cli.md +9 -0
  277. package/dist/claude-code/docs/spec/builder-flow-runtime.md +49 -8
  278. package/dist/claude-code/docs/spec/runtime-hook-surface.md +29 -1
  279. package/dist/claude-code/docs/specs/economics-record-contract.md +1 -1
  280. package/dist/claude-code/docs/specs/harness-capability-matrix.md +63 -21
  281. package/dist/claude-code/docs/workflow-usage-guide.md +4 -1
  282. package/dist/claude-code/evals/ci/run-baseline.sh +38 -0
  283. package/dist/claude-code/evals/fixtures/narrative-evals/README.md +62 -0
  284. package/dist/claude-code/evals/fixtures/narrative-evals/corpus.json +129 -0
  285. package/dist/claude-code/evals/fixtures/narrative-evals/scorer.mjs +522 -0
  286. package/dist/claude-code/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
  287. package/dist/claude-code/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
  288. package/dist/claude-code/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
  289. package/dist/claude-code/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
  290. package/dist/claude-code/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
  291. package/dist/claude-code/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
  292. package/dist/claude-code/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
  293. package/dist/claude-code/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
  294. package/dist/claude-code/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
  295. package/dist/claude-code/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
  296. package/dist/claude-code/evals/fixtures/narrative-sources/repo/created.txt +1 -0
  297. package/dist/claude-code/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
  298. package/dist/claude-code/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
  299. package/dist/claude-code/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
  300. package/dist/claude-code/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
  301. package/dist/claude-code/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
  302. package/dist/claude-code/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
  303. package/dist/claude-code/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
  304. package/dist/claude-code/evals/integration/test_capability_declarations.sh +183 -0
  305. package/dist/claude-code/evals/integration/test_economics_record.sh +42 -0
  306. package/dist/claude-code/evals/integration/test_fixture_retirement_audit.sh +2 -2
  307. package/dist/claude-code/evals/integration/test_gate_review_inquiry_records.sh +42 -35
  308. package/dist/claude-code/evals/integration/test_goal_fit_hook.sh +13 -5
  309. package/dist/claude-code/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
  310. package/dist/claude-code/evals/integration/test_narrative_evals.sh +174 -0
  311. package/dist/claude-code/evals/integration/test_narrative_grounded_envelope.sh +280 -0
  312. package/dist/claude-code/evals/integration/test_narrative_grounding_validator.sh +166 -0
  313. package/dist/claude-code/evals/integration/test_narrative_intent_annotation.sh +205 -0
  314. package/dist/claude-code/evals/integration/test_narrative_prose_renderer.sh +239 -0
  315. package/dist/claude-code/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
  316. package/dist/claude-code/evals/integration/test_narrative_runtime_projection.sh +146 -0
  317. package/dist/claude-code/evals/integration/test_narrative_source_contract.sh +228 -0
  318. package/dist/claude-code/evals/integration/test_narrative_trust_isolation.sh +408 -0
  319. package/dist/claude-code/evals/integration/test_plain_stop_messaging.sh +91 -0
  320. package/dist/claude-code/evals/integration/test_session_resume_roundtrip.sh +228 -0
  321. package/dist/claude-code/evals/integration/test_telemetry_action_class.sh +265 -0
  322. package/dist/claude-code/evals/integration/test_telemetry_delegation.sh +291 -0
  323. package/dist/claude-code/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
  324. package/dist/claude-code/evals/integration/test_telemetry_task_slug.sh +158 -0
  325. package/dist/claude-code/evals/integration/test_telemetry_tool_outcome.sh +279 -0
  326. package/dist/claude-code/evals/integration/test_workflow_sidecar_writer.sh +111 -2
  327. package/dist/claude-code/evals/run.sh +12 -0
  328. package/dist/claude-code/evals/static/test_library_exports.sh +5 -0
  329. package/dist/claude-code/install.sh +1 -1
  330. package/dist/claude-code/schemas/grounded-execution-narrative.schema.json +292 -0
  331. package/dist/claude-code/schemas/narrative-eval-result.schema.json +205 -0
  332. package/dist/claude-code/schemas/narrative-runtime-projection.schema.json +134 -0
  333. package/dist/claude-code/schemas/narrative-source-manifest.schema.json +294 -0
  334. package/dist/claude-code/scripts/check-hachure-boundary.mjs +81 -0
  335. package/dist/claude-code/scripts/hooks/stop-goal-fit.js +182 -9
  336. package/dist/claude-code/scripts/hooks/workflow-steering.js +160 -19
  337. package/dist/claude-code/scripts/telemetry/economics-record.schema.json +1 -1
  338. package/dist/claude-code/scripts/telemetry/economics-record.sh +47 -3
  339. package/dist/claude-code/scripts/telemetry/lib/session.sh +3 -0
  340. package/dist/claude-code/scripts/telemetry/lib/transport.sh +12 -3
  341. package/dist/claude-code/scripts/telemetry/telemetry.sh +480 -59
  342. package/dist/codex/build/generated/capability-declarations.json +177 -0
  343. package/dist/codex/build/package.json +1 -1
  344. package/dist/codex/build/src/builder-flow-runtime.d.ts +37 -0
  345. package/dist/codex/build/src/builder-flow-runtime.js +71 -1
  346. package/dist/codex/build/src/builder-gate-action-envelope.d.ts +59 -7
  347. package/dist/codex/build/src/builder-gate-action-envelope.js +163 -30
  348. package/dist/codex/build/src/builder-lifecycle-authority.d.ts +26 -0
  349. package/dist/codex/build/src/builder-lifecycle-authority.js +38 -0
  350. package/dist/codex/build/src/cli/builder-run.js +71 -2
  351. package/dist/codex/build/src/cli/narrative-render.d.ts +95 -0
  352. package/dist/codex/build/src/cli/narrative-render.js +466 -0
  353. package/dist/codex/build/src/cli/narrative-sources.d.ts +2 -0
  354. package/dist/codex/build/src/cli/narrative-sources.js +282 -0
  355. package/dist/codex/build/src/cli/public-contracts.d.ts +257 -0
  356. package/dist/codex/build/src/cli/public-contracts.js +87 -0
  357. package/dist/codex/build/src/cli/workflow-sidecar.d.ts +28 -12
  358. package/dist/codex/build/src/cli/workflow-sidecar.js +599 -180
  359. package/dist/codex/build/src/cli/workflow.js +11 -1
  360. package/dist/codex/build/src/cli.js +8 -0
  361. package/dist/codex/build/src/continuation-driver.d.ts +12 -0
  362. package/dist/codex/build/src/continuation-driver.js +16 -2
  363. package/dist/codex/build/src/continuation-validation.js +349 -3
  364. package/dist/codex/build/src/flow-kit/action-metadata.js +21 -1
  365. package/dist/codex/build/src/index.d.ts +33 -2
  366. package/dist/codex/build/src/index.js +24 -0
  367. package/dist/codex/build/src/lib/capability-declarations.d.ts +83 -0
  368. package/dist/codex/build/src/lib/capability-declarations.js +209 -0
  369. package/dist/codex/build/src/narrative/envelope.d.ts +111 -0
  370. package/dist/codex/build/src/narrative/envelope.js +590 -0
  371. package/dist/codex/build/src/narrative/eval-result.d.ts +60 -0
  372. package/dist/codex/build/src/narrative/eval-result.js +158 -0
  373. package/dist/codex/build/src/narrative/grounding-validator.d.ts +104 -0
  374. package/dist/codex/build/src/narrative/grounding-validator.js +472 -0
  375. package/dist/codex/build/src/narrative/integrity.d.ts +17 -0
  376. package/dist/codex/build/src/narrative/integrity.js +39 -0
  377. package/dist/codex/build/src/narrative/intent-economics.d.ts +42 -0
  378. package/dist/codex/build/src/narrative/intent-economics.js +82 -0
  379. package/dist/codex/build/src/narrative/intent.d.ts +94 -0
  380. package/dist/codex/build/src/narrative/intent.js +132 -0
  381. package/dist/codex/build/src/narrative/policy-filter.d.ts +15 -0
  382. package/dist/codex/build/src/narrative/policy-filter.js +58 -0
  383. package/dist/codex/build/src/narrative/projection.d.ts +58 -0
  384. package/dist/codex/build/src/narrative/projection.js +502 -0
  385. package/dist/codex/build/src/narrative/readers.d.ts +84 -0
  386. package/dist/codex/build/src/narrative/readers.js +406 -0
  387. package/dist/codex/build/src/narrative/render.d.ts +3 -0
  388. package/dist/codex/build/src/narrative/render.js +83 -0
  389. package/dist/codex/build/src/narrative/resolver.d.ts +52 -0
  390. package/dist/codex/build/src/narrative/resolver.js +190 -0
  391. package/dist/codex/build/src/narrative/snapshot.d.ts +90 -0
  392. package/dist/codex/build/src/narrative/snapshot.js +325 -0
  393. package/dist/codex/build/src/narrative/source-ids.d.ts +121 -0
  394. package/dist/codex/build/src/narrative/source-ids.js +201 -0
  395. package/dist/codex/build/src/narrative/statements.d.ts +84 -0
  396. package/dist/codex/build/src/narrative/statements.js +347 -0
  397. package/dist/codex/build/src/narrative/turn-spine.d.ts +19 -0
  398. package/dist/codex/build/src/narrative/turn-spine.js +73 -0
  399. package/dist/codex/build/src/tools/build-universal-bundles.js +8 -0
  400. package/dist/codex/build/src/tools/generate-capability-matrix.d.ts +7 -0
  401. package/dist/codex/build/src/tools/generate-capability-matrix.js +207 -0
  402. package/dist/codex/build/src/tools/validate-source-tree.js +5 -1
  403. package/dist/codex/context/scripts/hooks/stop-goal-fit.js +182 -9
  404. package/dist/codex/context/scripts/hooks/workflow-steering.js +160 -19
  405. package/dist/codex/context/scripts/telemetry/lib/session.sh +3 -0
  406. package/dist/codex/context/scripts/telemetry/lib/transport.sh +12 -3
  407. package/dist/codex/context/scripts/telemetry/telemetry.sh +480 -59
  408. package/dist/codex/docs/context-map.md +4 -0
  409. package/dist/codex/docs/decisions/index.md +1 -0
  410. package/dist/codex/docs/decisions/writer-observed-execution.md +51 -0
  411. package/dist/codex/docs/fixture-ownership.md +5 -1
  412. package/dist/codex/docs/migrations.md +20 -0
  413. package/dist/codex/docs/public-workflow-cli.md +9 -0
  414. package/dist/codex/docs/spec/builder-flow-runtime.md +49 -8
  415. package/dist/codex/docs/spec/runtime-hook-surface.md +29 -1
  416. package/dist/codex/docs/specs/economics-record-contract.md +1 -1
  417. package/dist/codex/docs/specs/harness-capability-matrix.md +63 -21
  418. package/dist/codex/docs/workflow-usage-guide.md +4 -1
  419. package/dist/codex/evals/ci/run-baseline.sh +38 -0
  420. package/dist/codex/evals/fixtures/narrative-evals/README.md +62 -0
  421. package/dist/codex/evals/fixtures/narrative-evals/corpus.json +129 -0
  422. package/dist/codex/evals/fixtures/narrative-evals/scorer.mjs +522 -0
  423. package/dist/codex/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
  424. package/dist/codex/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
  425. package/dist/codex/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
  426. package/dist/codex/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
  427. package/dist/codex/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
  428. package/dist/codex/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
  429. package/dist/codex/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
  430. package/dist/codex/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
  431. package/dist/codex/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
  432. package/dist/codex/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
  433. package/dist/codex/evals/fixtures/narrative-sources/repo/created.txt +1 -0
  434. package/dist/codex/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
  435. package/dist/codex/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
  436. package/dist/codex/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
  437. package/dist/codex/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
  438. package/dist/codex/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
  439. package/dist/codex/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
  440. package/dist/codex/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
  441. package/dist/codex/evals/integration/test_capability_declarations.sh +183 -0
  442. package/dist/codex/evals/integration/test_economics_record.sh +42 -0
  443. package/dist/codex/evals/integration/test_fixture_retirement_audit.sh +2 -2
  444. package/dist/codex/evals/integration/test_gate_review_inquiry_records.sh +42 -35
  445. package/dist/codex/evals/integration/test_goal_fit_hook.sh +13 -5
  446. package/dist/codex/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
  447. package/dist/codex/evals/integration/test_narrative_evals.sh +174 -0
  448. package/dist/codex/evals/integration/test_narrative_grounded_envelope.sh +280 -0
  449. package/dist/codex/evals/integration/test_narrative_grounding_validator.sh +166 -0
  450. package/dist/codex/evals/integration/test_narrative_intent_annotation.sh +205 -0
  451. package/dist/codex/evals/integration/test_narrative_prose_renderer.sh +239 -0
  452. package/dist/codex/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
  453. package/dist/codex/evals/integration/test_narrative_runtime_projection.sh +146 -0
  454. package/dist/codex/evals/integration/test_narrative_source_contract.sh +228 -0
  455. package/dist/codex/evals/integration/test_narrative_trust_isolation.sh +408 -0
  456. package/dist/codex/evals/integration/test_plain_stop_messaging.sh +91 -0
  457. package/dist/codex/evals/integration/test_session_resume_roundtrip.sh +228 -0
  458. package/dist/codex/evals/integration/test_telemetry_action_class.sh +265 -0
  459. package/dist/codex/evals/integration/test_telemetry_delegation.sh +291 -0
  460. package/dist/codex/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
  461. package/dist/codex/evals/integration/test_telemetry_task_slug.sh +158 -0
  462. package/dist/codex/evals/integration/test_telemetry_tool_outcome.sh +279 -0
  463. package/dist/codex/evals/integration/test_workflow_sidecar_writer.sh +111 -2
  464. package/dist/codex/evals/run.sh +12 -0
  465. package/dist/codex/evals/static/test_library_exports.sh +5 -0
  466. package/dist/codex/install.sh +1 -1
  467. package/dist/codex/schemas/grounded-execution-narrative.schema.json +292 -0
  468. package/dist/codex/schemas/narrative-eval-result.schema.json +205 -0
  469. package/dist/codex/schemas/narrative-runtime-projection.schema.json +134 -0
  470. package/dist/codex/schemas/narrative-source-manifest.schema.json +294 -0
  471. package/dist/codex/scripts/check-hachure-boundary.mjs +81 -0
  472. package/dist/codex/scripts/hooks/stop-goal-fit.js +182 -9
  473. package/dist/codex/scripts/hooks/workflow-steering.js +160 -19
  474. package/dist/codex/scripts/telemetry/economics-record.schema.json +1 -1
  475. package/dist/codex/scripts/telemetry/economics-record.sh +47 -3
  476. package/dist/codex/scripts/telemetry/lib/session.sh +3 -0
  477. package/dist/codex/scripts/telemetry/lib/transport.sh +12 -3
  478. package/dist/codex/scripts/telemetry/telemetry.sh +480 -59
  479. package/dist/kiro/build/generated/capability-declarations.json +177 -0
  480. package/dist/kiro/build/package.json +1 -1
  481. package/dist/kiro/build/src/builder-flow-runtime.d.ts +37 -0
  482. package/dist/kiro/build/src/builder-flow-runtime.js +71 -1
  483. package/dist/kiro/build/src/builder-gate-action-envelope.d.ts +59 -7
  484. package/dist/kiro/build/src/builder-gate-action-envelope.js +163 -30
  485. package/dist/kiro/build/src/builder-lifecycle-authority.d.ts +26 -0
  486. package/dist/kiro/build/src/builder-lifecycle-authority.js +38 -0
  487. package/dist/kiro/build/src/cli/builder-run.js +71 -2
  488. package/dist/kiro/build/src/cli/narrative-render.d.ts +95 -0
  489. package/dist/kiro/build/src/cli/narrative-render.js +466 -0
  490. package/dist/kiro/build/src/cli/narrative-sources.d.ts +2 -0
  491. package/dist/kiro/build/src/cli/narrative-sources.js +282 -0
  492. package/dist/kiro/build/src/cli/public-contracts.d.ts +257 -0
  493. package/dist/kiro/build/src/cli/public-contracts.js +87 -0
  494. package/dist/kiro/build/src/cli/workflow-sidecar.d.ts +28 -12
  495. package/dist/kiro/build/src/cli/workflow-sidecar.js +599 -180
  496. package/dist/kiro/build/src/cli/workflow.js +11 -1
  497. package/dist/kiro/build/src/cli.js +8 -0
  498. package/dist/kiro/build/src/continuation-driver.d.ts +12 -0
  499. package/dist/kiro/build/src/continuation-driver.js +16 -2
  500. package/dist/kiro/build/src/continuation-validation.js +349 -3
  501. package/dist/kiro/build/src/flow-kit/action-metadata.js +21 -1
  502. package/dist/kiro/build/src/index.d.ts +33 -2
  503. package/dist/kiro/build/src/index.js +24 -0
  504. package/dist/kiro/build/src/lib/capability-declarations.d.ts +83 -0
  505. package/dist/kiro/build/src/lib/capability-declarations.js +209 -0
  506. package/dist/kiro/build/src/narrative/envelope.d.ts +111 -0
  507. package/dist/kiro/build/src/narrative/envelope.js +590 -0
  508. package/dist/kiro/build/src/narrative/eval-result.d.ts +60 -0
  509. package/dist/kiro/build/src/narrative/eval-result.js +158 -0
  510. package/dist/kiro/build/src/narrative/grounding-validator.d.ts +104 -0
  511. package/dist/kiro/build/src/narrative/grounding-validator.js +472 -0
  512. package/dist/kiro/build/src/narrative/integrity.d.ts +17 -0
  513. package/dist/kiro/build/src/narrative/integrity.js +39 -0
  514. package/dist/kiro/build/src/narrative/intent-economics.d.ts +42 -0
  515. package/dist/kiro/build/src/narrative/intent-economics.js +82 -0
  516. package/dist/kiro/build/src/narrative/intent.d.ts +94 -0
  517. package/dist/kiro/build/src/narrative/intent.js +132 -0
  518. package/dist/kiro/build/src/narrative/policy-filter.d.ts +15 -0
  519. package/dist/kiro/build/src/narrative/policy-filter.js +58 -0
  520. package/dist/kiro/build/src/narrative/projection.d.ts +58 -0
  521. package/dist/kiro/build/src/narrative/projection.js +502 -0
  522. package/dist/kiro/build/src/narrative/readers.d.ts +84 -0
  523. package/dist/kiro/build/src/narrative/readers.js +406 -0
  524. package/dist/kiro/build/src/narrative/render.d.ts +3 -0
  525. package/dist/kiro/build/src/narrative/render.js +83 -0
  526. package/dist/kiro/build/src/narrative/resolver.d.ts +52 -0
  527. package/dist/kiro/build/src/narrative/resolver.js +190 -0
  528. package/dist/kiro/build/src/narrative/snapshot.d.ts +90 -0
  529. package/dist/kiro/build/src/narrative/snapshot.js +325 -0
  530. package/dist/kiro/build/src/narrative/source-ids.d.ts +121 -0
  531. package/dist/kiro/build/src/narrative/source-ids.js +201 -0
  532. package/dist/kiro/build/src/narrative/statements.d.ts +84 -0
  533. package/dist/kiro/build/src/narrative/statements.js +347 -0
  534. package/dist/kiro/build/src/narrative/turn-spine.d.ts +19 -0
  535. package/dist/kiro/build/src/narrative/turn-spine.js +73 -0
  536. package/dist/kiro/build/src/tools/build-universal-bundles.js +8 -0
  537. package/dist/kiro/build/src/tools/generate-capability-matrix.d.ts +7 -0
  538. package/dist/kiro/build/src/tools/generate-capability-matrix.js +207 -0
  539. package/dist/kiro/build/src/tools/validate-source-tree.js +5 -1
  540. package/dist/kiro/context/scripts/hooks/stop-goal-fit.js +182 -9
  541. package/dist/kiro/context/scripts/hooks/workflow-steering.js +160 -19
  542. package/dist/kiro/context/scripts/telemetry/lib/session.sh +3 -0
  543. package/dist/kiro/context/scripts/telemetry/lib/transport.sh +12 -3
  544. package/dist/kiro/context/scripts/telemetry/telemetry.sh +480 -59
  545. package/dist/kiro/docs/context-map.md +4 -0
  546. package/dist/kiro/docs/decisions/index.md +1 -0
  547. package/dist/kiro/docs/decisions/writer-observed-execution.md +51 -0
  548. package/dist/kiro/docs/fixture-ownership.md +5 -1
  549. package/dist/kiro/docs/migrations.md +20 -0
  550. package/dist/kiro/docs/public-workflow-cli.md +9 -0
  551. package/dist/kiro/docs/spec/builder-flow-runtime.md +49 -8
  552. package/dist/kiro/docs/spec/runtime-hook-surface.md +29 -1
  553. package/dist/kiro/docs/specs/economics-record-contract.md +1 -1
  554. package/dist/kiro/docs/specs/harness-capability-matrix.md +63 -21
  555. package/dist/kiro/docs/workflow-usage-guide.md +4 -1
  556. package/dist/kiro/evals/ci/run-baseline.sh +38 -0
  557. package/dist/kiro/evals/fixtures/narrative-evals/README.md +62 -0
  558. package/dist/kiro/evals/fixtures/narrative-evals/corpus.json +129 -0
  559. package/dist/kiro/evals/fixtures/narrative-evals/scorer.mjs +522 -0
  560. package/dist/kiro/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
  561. package/dist/kiro/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
  562. package/dist/kiro/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
  563. package/dist/kiro/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
  564. package/dist/kiro/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
  565. package/dist/kiro/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
  566. package/dist/kiro/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
  567. package/dist/kiro/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
  568. package/dist/kiro/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
  569. package/dist/kiro/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
  570. package/dist/kiro/evals/fixtures/narrative-sources/repo/created.txt +1 -0
  571. package/dist/kiro/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
  572. package/dist/kiro/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
  573. package/dist/kiro/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
  574. package/dist/kiro/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
  575. package/dist/kiro/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
  576. package/dist/kiro/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
  577. package/dist/kiro/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
  578. package/dist/kiro/evals/integration/test_capability_declarations.sh +183 -0
  579. package/dist/kiro/evals/integration/test_economics_record.sh +42 -0
  580. package/dist/kiro/evals/integration/test_fixture_retirement_audit.sh +2 -2
  581. package/dist/kiro/evals/integration/test_gate_review_inquiry_records.sh +42 -35
  582. package/dist/kiro/evals/integration/test_goal_fit_hook.sh +13 -5
  583. package/dist/kiro/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
  584. package/dist/kiro/evals/integration/test_narrative_evals.sh +174 -0
  585. package/dist/kiro/evals/integration/test_narrative_grounded_envelope.sh +280 -0
  586. package/dist/kiro/evals/integration/test_narrative_grounding_validator.sh +166 -0
  587. package/dist/kiro/evals/integration/test_narrative_intent_annotation.sh +205 -0
  588. package/dist/kiro/evals/integration/test_narrative_prose_renderer.sh +239 -0
  589. package/dist/kiro/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
  590. package/dist/kiro/evals/integration/test_narrative_runtime_projection.sh +146 -0
  591. package/dist/kiro/evals/integration/test_narrative_source_contract.sh +228 -0
  592. package/dist/kiro/evals/integration/test_narrative_trust_isolation.sh +408 -0
  593. package/dist/kiro/evals/integration/test_plain_stop_messaging.sh +91 -0
  594. package/dist/kiro/evals/integration/test_session_resume_roundtrip.sh +228 -0
  595. package/dist/kiro/evals/integration/test_telemetry_action_class.sh +265 -0
  596. package/dist/kiro/evals/integration/test_telemetry_delegation.sh +291 -0
  597. package/dist/kiro/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
  598. package/dist/kiro/evals/integration/test_telemetry_task_slug.sh +158 -0
  599. package/dist/kiro/evals/integration/test_telemetry_tool_outcome.sh +279 -0
  600. package/dist/kiro/evals/integration/test_workflow_sidecar_writer.sh +111 -2
  601. package/dist/kiro/evals/run.sh +12 -0
  602. package/dist/kiro/evals/static/test_library_exports.sh +5 -0
  603. package/dist/kiro/install.sh +1 -1
  604. package/dist/kiro/schemas/grounded-execution-narrative.schema.json +292 -0
  605. package/dist/kiro/schemas/narrative-eval-result.schema.json +205 -0
  606. package/dist/kiro/schemas/narrative-runtime-projection.schema.json +134 -0
  607. package/dist/kiro/schemas/narrative-source-manifest.schema.json +294 -0
  608. package/dist/kiro/scripts/check-hachure-boundary.mjs +81 -0
  609. package/dist/kiro/scripts/hooks/stop-goal-fit.js +182 -9
  610. package/dist/kiro/scripts/hooks/workflow-steering.js +160 -19
  611. package/dist/kiro/scripts/telemetry/economics-record.schema.json +1 -1
  612. package/dist/kiro/scripts/telemetry/economics-record.sh +47 -3
  613. package/dist/kiro/scripts/telemetry/lib/session.sh +3 -0
  614. package/dist/kiro/scripts/telemetry/lib/transport.sh +12 -3
  615. package/dist/kiro/scripts/telemetry/telemetry.sh +480 -59
  616. package/dist/opencode/build/generated/capability-declarations.json +177 -0
  617. package/dist/opencode/build/package.json +1 -1
  618. package/dist/opencode/build/src/builder-flow-runtime.d.ts +37 -0
  619. package/dist/opencode/build/src/builder-flow-runtime.js +71 -1
  620. package/dist/opencode/build/src/builder-gate-action-envelope.d.ts +59 -7
  621. package/dist/opencode/build/src/builder-gate-action-envelope.js +163 -30
  622. package/dist/opencode/build/src/builder-lifecycle-authority.d.ts +26 -0
  623. package/dist/opencode/build/src/builder-lifecycle-authority.js +38 -0
  624. package/dist/opencode/build/src/cli/builder-run.js +71 -2
  625. package/dist/opencode/build/src/cli/narrative-render.d.ts +95 -0
  626. package/dist/opencode/build/src/cli/narrative-render.js +466 -0
  627. package/dist/opencode/build/src/cli/narrative-sources.d.ts +2 -0
  628. package/dist/opencode/build/src/cli/narrative-sources.js +282 -0
  629. package/dist/opencode/build/src/cli/public-contracts.d.ts +257 -0
  630. package/dist/opencode/build/src/cli/public-contracts.js +87 -0
  631. package/dist/opencode/build/src/cli/workflow-sidecar.d.ts +28 -12
  632. package/dist/opencode/build/src/cli/workflow-sidecar.js +599 -180
  633. package/dist/opencode/build/src/cli/workflow.js +11 -1
  634. package/dist/opencode/build/src/cli.js +8 -0
  635. package/dist/opencode/build/src/continuation-driver.d.ts +12 -0
  636. package/dist/opencode/build/src/continuation-driver.js +16 -2
  637. package/dist/opencode/build/src/continuation-validation.js +349 -3
  638. package/dist/opencode/build/src/flow-kit/action-metadata.js +21 -1
  639. package/dist/opencode/build/src/index.d.ts +33 -2
  640. package/dist/opencode/build/src/index.js +24 -0
  641. package/dist/opencode/build/src/lib/capability-declarations.d.ts +83 -0
  642. package/dist/opencode/build/src/lib/capability-declarations.js +209 -0
  643. package/dist/opencode/build/src/narrative/envelope.d.ts +111 -0
  644. package/dist/opencode/build/src/narrative/envelope.js +590 -0
  645. package/dist/opencode/build/src/narrative/eval-result.d.ts +60 -0
  646. package/dist/opencode/build/src/narrative/eval-result.js +158 -0
  647. package/dist/opencode/build/src/narrative/grounding-validator.d.ts +104 -0
  648. package/dist/opencode/build/src/narrative/grounding-validator.js +472 -0
  649. package/dist/opencode/build/src/narrative/integrity.d.ts +17 -0
  650. package/dist/opencode/build/src/narrative/integrity.js +39 -0
  651. package/dist/opencode/build/src/narrative/intent-economics.d.ts +42 -0
  652. package/dist/opencode/build/src/narrative/intent-economics.js +82 -0
  653. package/dist/opencode/build/src/narrative/intent.d.ts +94 -0
  654. package/dist/opencode/build/src/narrative/intent.js +132 -0
  655. package/dist/opencode/build/src/narrative/policy-filter.d.ts +15 -0
  656. package/dist/opencode/build/src/narrative/policy-filter.js +58 -0
  657. package/dist/opencode/build/src/narrative/projection.d.ts +58 -0
  658. package/dist/opencode/build/src/narrative/projection.js +502 -0
  659. package/dist/opencode/build/src/narrative/readers.d.ts +84 -0
  660. package/dist/opencode/build/src/narrative/readers.js +406 -0
  661. package/dist/opencode/build/src/narrative/render.d.ts +3 -0
  662. package/dist/opencode/build/src/narrative/render.js +83 -0
  663. package/dist/opencode/build/src/narrative/resolver.d.ts +52 -0
  664. package/dist/opencode/build/src/narrative/resolver.js +190 -0
  665. package/dist/opencode/build/src/narrative/snapshot.d.ts +90 -0
  666. package/dist/opencode/build/src/narrative/snapshot.js +325 -0
  667. package/dist/opencode/build/src/narrative/source-ids.d.ts +121 -0
  668. package/dist/opencode/build/src/narrative/source-ids.js +201 -0
  669. package/dist/opencode/build/src/narrative/statements.d.ts +84 -0
  670. package/dist/opencode/build/src/narrative/statements.js +347 -0
  671. package/dist/opencode/build/src/narrative/turn-spine.d.ts +19 -0
  672. package/dist/opencode/build/src/narrative/turn-spine.js +73 -0
  673. package/dist/opencode/build/src/tools/build-universal-bundles.js +8 -0
  674. package/dist/opencode/build/src/tools/generate-capability-matrix.d.ts +7 -0
  675. package/dist/opencode/build/src/tools/generate-capability-matrix.js +207 -0
  676. package/dist/opencode/build/src/tools/validate-source-tree.js +5 -1
  677. package/dist/opencode/context/scripts/hooks/stop-goal-fit.js +182 -9
  678. package/dist/opencode/context/scripts/hooks/workflow-steering.js +160 -19
  679. package/dist/opencode/context/scripts/telemetry/lib/session.sh +3 -0
  680. package/dist/opencode/context/scripts/telemetry/lib/transport.sh +12 -3
  681. package/dist/opencode/context/scripts/telemetry/telemetry.sh +480 -59
  682. package/dist/opencode/docs/context-map.md +4 -0
  683. package/dist/opencode/docs/decisions/index.md +1 -0
  684. package/dist/opencode/docs/decisions/writer-observed-execution.md +51 -0
  685. package/dist/opencode/docs/fixture-ownership.md +5 -1
  686. package/dist/opencode/docs/migrations.md +20 -0
  687. package/dist/opencode/docs/public-workflow-cli.md +9 -0
  688. package/dist/opencode/docs/spec/builder-flow-runtime.md +49 -8
  689. package/dist/opencode/docs/spec/runtime-hook-surface.md +29 -1
  690. package/dist/opencode/docs/specs/economics-record-contract.md +1 -1
  691. package/dist/opencode/docs/specs/harness-capability-matrix.md +63 -21
  692. package/dist/opencode/docs/workflow-usage-guide.md +4 -1
  693. package/dist/opencode/evals/ci/run-baseline.sh +38 -0
  694. package/dist/opencode/evals/fixtures/narrative-evals/README.md +62 -0
  695. package/dist/opencode/evals/fixtures/narrative-evals/corpus.json +129 -0
  696. package/dist/opencode/evals/fixtures/narrative-evals/scorer.mjs +522 -0
  697. package/dist/opencode/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
  698. package/dist/opencode/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
  699. package/dist/opencode/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
  700. package/dist/opencode/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
  701. package/dist/opencode/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
  702. package/dist/opencode/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
  703. package/dist/opencode/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
  704. package/dist/opencode/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
  705. package/dist/opencode/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
  706. package/dist/opencode/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
  707. package/dist/opencode/evals/fixtures/narrative-sources/repo/created.txt +1 -0
  708. package/dist/opencode/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
  709. package/dist/opencode/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
  710. package/dist/opencode/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
  711. package/dist/opencode/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
  712. package/dist/opencode/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
  713. package/dist/opencode/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
  714. package/dist/opencode/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
  715. package/dist/opencode/evals/integration/test_capability_declarations.sh +183 -0
  716. package/dist/opencode/evals/integration/test_economics_record.sh +42 -0
  717. package/dist/opencode/evals/integration/test_fixture_retirement_audit.sh +2 -2
  718. package/dist/opencode/evals/integration/test_gate_review_inquiry_records.sh +42 -35
  719. package/dist/opencode/evals/integration/test_goal_fit_hook.sh +13 -5
  720. package/dist/opencode/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
  721. package/dist/opencode/evals/integration/test_narrative_evals.sh +174 -0
  722. package/dist/opencode/evals/integration/test_narrative_grounded_envelope.sh +280 -0
  723. package/dist/opencode/evals/integration/test_narrative_grounding_validator.sh +166 -0
  724. package/dist/opencode/evals/integration/test_narrative_intent_annotation.sh +205 -0
  725. package/dist/opencode/evals/integration/test_narrative_prose_renderer.sh +239 -0
  726. package/dist/opencode/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
  727. package/dist/opencode/evals/integration/test_narrative_runtime_projection.sh +146 -0
  728. package/dist/opencode/evals/integration/test_narrative_source_contract.sh +228 -0
  729. package/dist/opencode/evals/integration/test_narrative_trust_isolation.sh +408 -0
  730. package/dist/opencode/evals/integration/test_plain_stop_messaging.sh +91 -0
  731. package/dist/opencode/evals/integration/test_session_resume_roundtrip.sh +228 -0
  732. package/dist/opencode/evals/integration/test_telemetry_action_class.sh +265 -0
  733. package/dist/opencode/evals/integration/test_telemetry_delegation.sh +291 -0
  734. package/dist/opencode/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
  735. package/dist/opencode/evals/integration/test_telemetry_task_slug.sh +158 -0
  736. package/dist/opencode/evals/integration/test_telemetry_tool_outcome.sh +279 -0
  737. package/dist/opencode/evals/integration/test_workflow_sidecar_writer.sh +111 -2
  738. package/dist/opencode/evals/run.sh +12 -0
  739. package/dist/opencode/evals/static/test_library_exports.sh +5 -0
  740. package/dist/opencode/install.sh +1 -1
  741. package/dist/opencode/schemas/grounded-execution-narrative.schema.json +292 -0
  742. package/dist/opencode/schemas/narrative-eval-result.schema.json +205 -0
  743. package/dist/opencode/schemas/narrative-runtime-projection.schema.json +134 -0
  744. package/dist/opencode/schemas/narrative-source-manifest.schema.json +294 -0
  745. package/dist/opencode/scripts/check-hachure-boundary.mjs +81 -0
  746. package/dist/opencode/scripts/hooks/stop-goal-fit.js +182 -9
  747. package/dist/opencode/scripts/hooks/workflow-steering.js +160 -19
  748. package/dist/opencode/scripts/telemetry/economics-record.schema.json +1 -1
  749. package/dist/opencode/scripts/telemetry/economics-record.sh +47 -3
  750. package/dist/opencode/scripts/telemetry/lib/session.sh +3 -0
  751. package/dist/opencode/scripts/telemetry/lib/transport.sh +12 -3
  752. package/dist/opencode/scripts/telemetry/telemetry.sh +480 -59
  753. package/dist/pi/build/generated/capability-declarations.json +177 -0
  754. package/dist/pi/build/package.json +1 -1
  755. package/dist/pi/build/src/builder-flow-runtime.d.ts +37 -0
  756. package/dist/pi/build/src/builder-flow-runtime.js +71 -1
  757. package/dist/pi/build/src/builder-gate-action-envelope.d.ts +59 -7
  758. package/dist/pi/build/src/builder-gate-action-envelope.js +163 -30
  759. package/dist/pi/build/src/builder-lifecycle-authority.d.ts +26 -0
  760. package/dist/pi/build/src/builder-lifecycle-authority.js +38 -0
  761. package/dist/pi/build/src/cli/builder-run.js +71 -2
  762. package/dist/pi/build/src/cli/narrative-render.d.ts +95 -0
  763. package/dist/pi/build/src/cli/narrative-render.js +466 -0
  764. package/dist/pi/build/src/cli/narrative-sources.d.ts +2 -0
  765. package/dist/pi/build/src/cli/narrative-sources.js +282 -0
  766. package/dist/pi/build/src/cli/public-contracts.d.ts +257 -0
  767. package/dist/pi/build/src/cli/public-contracts.js +87 -0
  768. package/dist/pi/build/src/cli/workflow-sidecar.d.ts +28 -12
  769. package/dist/pi/build/src/cli/workflow-sidecar.js +599 -180
  770. package/dist/pi/build/src/cli/workflow.js +11 -1
  771. package/dist/pi/build/src/cli.js +8 -0
  772. package/dist/pi/build/src/continuation-driver.d.ts +12 -0
  773. package/dist/pi/build/src/continuation-driver.js +16 -2
  774. package/dist/pi/build/src/continuation-validation.js +349 -3
  775. package/dist/pi/build/src/flow-kit/action-metadata.js +21 -1
  776. package/dist/pi/build/src/index.d.ts +33 -2
  777. package/dist/pi/build/src/index.js +24 -0
  778. package/dist/pi/build/src/lib/capability-declarations.d.ts +83 -0
  779. package/dist/pi/build/src/lib/capability-declarations.js +209 -0
  780. package/dist/pi/build/src/narrative/envelope.d.ts +111 -0
  781. package/dist/pi/build/src/narrative/envelope.js +590 -0
  782. package/dist/pi/build/src/narrative/eval-result.d.ts +60 -0
  783. package/dist/pi/build/src/narrative/eval-result.js +158 -0
  784. package/dist/pi/build/src/narrative/grounding-validator.d.ts +104 -0
  785. package/dist/pi/build/src/narrative/grounding-validator.js +472 -0
  786. package/dist/pi/build/src/narrative/integrity.d.ts +17 -0
  787. package/dist/pi/build/src/narrative/integrity.js +39 -0
  788. package/dist/pi/build/src/narrative/intent-economics.d.ts +42 -0
  789. package/dist/pi/build/src/narrative/intent-economics.js +82 -0
  790. package/dist/pi/build/src/narrative/intent.d.ts +94 -0
  791. package/dist/pi/build/src/narrative/intent.js +132 -0
  792. package/dist/pi/build/src/narrative/policy-filter.d.ts +15 -0
  793. package/dist/pi/build/src/narrative/policy-filter.js +58 -0
  794. package/dist/pi/build/src/narrative/projection.d.ts +58 -0
  795. package/dist/pi/build/src/narrative/projection.js +502 -0
  796. package/dist/pi/build/src/narrative/readers.d.ts +84 -0
  797. package/dist/pi/build/src/narrative/readers.js +406 -0
  798. package/dist/pi/build/src/narrative/render.d.ts +3 -0
  799. package/dist/pi/build/src/narrative/render.js +83 -0
  800. package/dist/pi/build/src/narrative/resolver.d.ts +52 -0
  801. package/dist/pi/build/src/narrative/resolver.js +190 -0
  802. package/dist/pi/build/src/narrative/snapshot.d.ts +90 -0
  803. package/dist/pi/build/src/narrative/snapshot.js +325 -0
  804. package/dist/pi/build/src/narrative/source-ids.d.ts +121 -0
  805. package/dist/pi/build/src/narrative/source-ids.js +201 -0
  806. package/dist/pi/build/src/narrative/statements.d.ts +84 -0
  807. package/dist/pi/build/src/narrative/statements.js +347 -0
  808. package/dist/pi/build/src/narrative/turn-spine.d.ts +19 -0
  809. package/dist/pi/build/src/narrative/turn-spine.js +73 -0
  810. package/dist/pi/build/src/tools/build-universal-bundles.js +8 -0
  811. package/dist/pi/build/src/tools/generate-capability-matrix.d.ts +7 -0
  812. package/dist/pi/build/src/tools/generate-capability-matrix.js +207 -0
  813. package/dist/pi/build/src/tools/validate-source-tree.js +5 -1
  814. package/dist/pi/context/scripts/hooks/stop-goal-fit.js +182 -9
  815. package/dist/pi/context/scripts/hooks/workflow-steering.js +160 -19
  816. package/dist/pi/context/scripts/telemetry/lib/session.sh +3 -0
  817. package/dist/pi/context/scripts/telemetry/lib/transport.sh +12 -3
  818. package/dist/pi/context/scripts/telemetry/telemetry.sh +480 -59
  819. package/dist/pi/docs/context-map.md +4 -0
  820. package/dist/pi/docs/decisions/index.md +1 -0
  821. package/dist/pi/docs/decisions/writer-observed-execution.md +51 -0
  822. package/dist/pi/docs/fixture-ownership.md +5 -1
  823. package/dist/pi/docs/migrations.md +20 -0
  824. package/dist/pi/docs/public-workflow-cli.md +9 -0
  825. package/dist/pi/docs/spec/builder-flow-runtime.md +49 -8
  826. package/dist/pi/docs/spec/runtime-hook-surface.md +29 -1
  827. package/dist/pi/docs/specs/economics-record-contract.md +1 -1
  828. package/dist/pi/docs/specs/harness-capability-matrix.md +63 -21
  829. package/dist/pi/docs/workflow-usage-guide.md +4 -1
  830. package/dist/pi/evals/ci/run-baseline.sh +38 -0
  831. package/dist/pi/evals/fixtures/narrative-evals/README.md +62 -0
  832. package/dist/pi/evals/fixtures/narrative-evals/corpus.json +129 -0
  833. package/dist/pi/evals/fixtures/narrative-evals/scorer.mjs +522 -0
  834. package/dist/pi/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
  835. package/dist/pi/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
  836. package/dist/pi/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
  837. package/dist/pi/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
  838. package/dist/pi/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
  839. package/dist/pi/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
  840. package/dist/pi/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
  841. package/dist/pi/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
  842. package/dist/pi/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
  843. package/dist/pi/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
  844. package/dist/pi/evals/fixtures/narrative-sources/repo/created.txt +1 -0
  845. package/dist/pi/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
  846. package/dist/pi/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
  847. package/dist/pi/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
  848. package/dist/pi/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
  849. package/dist/pi/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
  850. package/dist/pi/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
  851. package/dist/pi/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
  852. package/dist/pi/evals/integration/test_capability_declarations.sh +183 -0
  853. package/dist/pi/evals/integration/test_economics_record.sh +42 -0
  854. package/dist/pi/evals/integration/test_fixture_retirement_audit.sh +2 -2
  855. package/dist/pi/evals/integration/test_gate_review_inquiry_records.sh +42 -35
  856. package/dist/pi/evals/integration/test_goal_fit_hook.sh +13 -5
  857. package/dist/pi/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
  858. package/dist/pi/evals/integration/test_narrative_evals.sh +174 -0
  859. package/dist/pi/evals/integration/test_narrative_grounded_envelope.sh +280 -0
  860. package/dist/pi/evals/integration/test_narrative_grounding_validator.sh +166 -0
  861. package/dist/pi/evals/integration/test_narrative_intent_annotation.sh +205 -0
  862. package/dist/pi/evals/integration/test_narrative_prose_renderer.sh +239 -0
  863. package/dist/pi/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
  864. package/dist/pi/evals/integration/test_narrative_runtime_projection.sh +146 -0
  865. package/dist/pi/evals/integration/test_narrative_source_contract.sh +228 -0
  866. package/dist/pi/evals/integration/test_narrative_trust_isolation.sh +408 -0
  867. package/dist/pi/evals/integration/test_plain_stop_messaging.sh +91 -0
  868. package/dist/pi/evals/integration/test_session_resume_roundtrip.sh +228 -0
  869. package/dist/pi/evals/integration/test_telemetry_action_class.sh +265 -0
  870. package/dist/pi/evals/integration/test_telemetry_delegation.sh +291 -0
  871. package/dist/pi/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
  872. package/dist/pi/evals/integration/test_telemetry_task_slug.sh +158 -0
  873. package/dist/pi/evals/integration/test_telemetry_tool_outcome.sh +279 -0
  874. package/dist/pi/evals/integration/test_workflow_sidecar_writer.sh +111 -2
  875. package/dist/pi/evals/run.sh +12 -0
  876. package/dist/pi/evals/static/test_library_exports.sh +5 -0
  877. package/dist/pi/install.sh +1 -1
  878. package/dist/pi/schemas/grounded-execution-narrative.schema.json +292 -0
  879. package/dist/pi/schemas/narrative-eval-result.schema.json +205 -0
  880. package/dist/pi/schemas/narrative-runtime-projection.schema.json +134 -0
  881. package/dist/pi/schemas/narrative-source-manifest.schema.json +294 -0
  882. package/dist/pi/scripts/check-hachure-boundary.mjs +81 -0
  883. package/dist/pi/scripts/hooks/stop-goal-fit.js +182 -9
  884. package/dist/pi/scripts/hooks/workflow-steering.js +160 -19
  885. package/dist/pi/scripts/telemetry/economics-record.schema.json +1 -1
  886. package/dist/pi/scripts/telemetry/economics-record.sh +47 -3
  887. package/dist/pi/scripts/telemetry/lib/session.sh +3 -0
  888. package/dist/pi/scripts/telemetry/lib/transport.sh +12 -3
  889. package/dist/pi/scripts/telemetry/telemetry.sh +480 -59
  890. package/docs/context-map.md +4 -0
  891. package/docs/decisions/index.md +1 -0
  892. package/docs/decisions/writer-observed-execution.md +51 -0
  893. package/docs/fixture-ownership.md +5 -1
  894. package/docs/migrations.md +20 -0
  895. package/docs/public-workflow-cli.md +9 -0
  896. package/docs/spec/builder-flow-runtime.md +49 -8
  897. package/docs/spec/runtime-hook-surface.md +29 -1
  898. package/docs/specs/economics-record-contract.md +1 -1
  899. package/docs/specs/harness-capability-matrix.md +63 -21
  900. package/docs/workflow-usage-guide.md +4 -1
  901. package/evals/ci/run-baseline.sh +38 -0
  902. package/evals/fixtures/narrative-evals/README.md +62 -0
  903. package/evals/fixtures/narrative-evals/corpus.json +129 -0
  904. package/evals/fixtures/narrative-evals/scorer.mjs +522 -0
  905. package/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
  906. package/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
  907. package/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
  908. package/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
  909. package/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
  910. package/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
  911. package/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
  912. package/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
  913. package/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
  914. package/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
  915. package/evals/fixtures/narrative-sources/repo/created.txt +1 -0
  916. package/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
  917. package/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
  918. package/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
  919. package/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
  920. package/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
  921. package/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
  922. package/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
  923. package/evals/integration/test_capability_declarations.sh +183 -0
  924. package/evals/integration/test_economics_record.sh +42 -0
  925. package/evals/integration/test_fixture_retirement_audit.sh +2 -2
  926. package/evals/integration/test_gate_review_inquiry_records.sh +42 -35
  927. package/evals/integration/test_goal_fit_hook.sh +13 -5
  928. package/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
  929. package/evals/integration/test_narrative_evals.sh +174 -0
  930. package/evals/integration/test_narrative_grounded_envelope.sh +280 -0
  931. package/evals/integration/test_narrative_grounding_validator.sh +166 -0
  932. package/evals/integration/test_narrative_intent_annotation.sh +205 -0
  933. package/evals/integration/test_narrative_prose_renderer.sh +239 -0
  934. package/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
  935. package/evals/integration/test_narrative_runtime_projection.sh +146 -0
  936. package/evals/integration/test_narrative_source_contract.sh +228 -0
  937. package/evals/integration/test_narrative_trust_isolation.sh +408 -0
  938. package/evals/integration/test_plain_stop_messaging.sh +91 -0
  939. package/evals/integration/test_session_resume_roundtrip.sh +228 -0
  940. package/evals/integration/test_telemetry_action_class.sh +265 -0
  941. package/evals/integration/test_telemetry_delegation.sh +291 -0
  942. package/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
  943. package/evals/integration/test_telemetry_task_slug.sh +158 -0
  944. package/evals/integration/test_telemetry_tool_outcome.sh +279 -0
  945. package/evals/integration/test_workflow_sidecar_writer.sh +111 -2
  946. package/evals/run.sh +12 -0
  947. package/evals/static/test_library_exports.sh +5 -0
  948. package/package.json +9 -5
  949. package/schemas/grounded-execution-narrative.schema.json +292 -0
  950. package/schemas/narrative-eval-result.schema.json +205 -0
  951. package/schemas/narrative-runtime-projection.schema.json +134 -0
  952. package/schemas/narrative-source-manifest.schema.json +294 -0
  953. package/scripts/check-hachure-boundary.mjs +81 -0
  954. package/scripts/hooks/stop-goal-fit.js +182 -9
  955. package/scripts/hooks/workflow-steering.js +160 -19
  956. package/scripts/telemetry/economics-record.schema.json +1 -1
  957. package/scripts/telemetry/economics-record.sh +47 -3
  958. package/scripts/telemetry/lib/session.sh +3 -0
  959. package/scripts/telemetry/lib/transport.sh +12 -3
  960. package/scripts/telemetry/telemetry.sh +480 -59
  961. package/src/builder-flow-runtime.ts +102 -1
  962. package/src/builder-gate-action-envelope.ts +216 -37
  963. package/src/builder-lifecycle-authority.ts +48 -0
  964. package/src/cli/builder-flow-runtime.test.mjs +220 -7
  965. package/src/cli/builder-run.ts +71 -1
  966. package/src/cli/capability-declarations.test.mjs +117 -0
  967. package/src/cli/continuation-driver.test.mjs +332 -10
  968. package/src/cli/kit-metadata-security.test.mjs +90 -2
  969. package/src/cli/narrative-arch-isolation.test.mjs +198 -0
  970. package/src/cli/narrative-envelope.test.mjs +367 -0
  971. package/src/cli/narrative-grounding-validator.test.mjs +322 -0
  972. package/src/cli/narrative-intent.test.mjs +177 -0
  973. package/src/cli/narrative-policy-filter.test.mjs +66 -0
  974. package/src/cli/narrative-projection.test.mjs +236 -0
  975. package/src/cli/narrative-readers.test.mjs +196 -0
  976. package/src/cli/narrative-render.test.mjs +221 -0
  977. package/src/cli/narrative-render.ts +589 -0
  978. package/src/cli/narrative-resolver.test.mjs +114 -0
  979. package/src/cli/narrative-snapshot.test.mjs +149 -0
  980. package/src/cli/narrative-source-ids.test.mjs +84 -0
  981. package/src/cli/narrative-sources.ts +276 -0
  982. package/src/cli/narrative-statements.test.mjs +369 -0
  983. package/src/cli/narrative-turn-spine.test.mjs +74 -0
  984. package/src/cli/public-api.test.mjs +17 -0
  985. package/src/cli/public-contracts.ts +95 -0
  986. package/src/cli/sidecar-pure-helpers.test.mjs +216 -24
  987. package/src/cli/trust-bundle-policy-order.test.mjs +134 -1
  988. package/src/cli/workflow-sidecar.ts +563 -167
  989. package/src/cli/workflow.ts +15 -1
  990. package/src/cli/writer-observed-execution.test.mjs +102 -0
  991. package/src/cli.ts +8 -0
  992. package/src/continuation-driver.ts +32 -3
  993. package/src/continuation-validation.ts +362 -4
  994. package/src/flow-kit/action-metadata.ts +20 -1
  995. package/src/index.ts +241 -0
  996. package/src/lib/capability-declarations.ts +261 -0
  997. package/src/narrative/envelope.ts +624 -0
  998. package/src/narrative/eval-result.ts +175 -0
  999. package/src/narrative/grounding-validator.ts +610 -0
  1000. package/src/narrative/integrity.ts +53 -0
  1001. package/src/narrative/intent-economics.ts +119 -0
  1002. package/src/narrative/intent.ts +216 -0
  1003. package/src/narrative/policy-filter.ts +66 -0
  1004. package/src/narrative/projection.ts +530 -0
  1005. package/src/narrative/readers.ts +427 -0
  1006. package/src/narrative/render.ts +82 -0
  1007. package/src/narrative/resolver.ts +195 -0
  1008. package/src/narrative/snapshot.ts +365 -0
  1009. package/src/narrative/source-ids.ts +294 -0
  1010. package/src/narrative/statements.ts +423 -0
  1011. package/src/narrative/turn-spine.ts +99 -0
  1012. package/src/tools/build-universal-bundles.ts +8 -0
  1013. package/src/tools/generate-capability-matrix.ts +215 -0
  1014. package/src/tools/validate-source-tree.ts +5 -1
  1015. package/build/src/cli/sidecar-claim-explain.d.ts +0 -45
  1016. package/build/src/cli/sidecar-claim-explain.js +0 -87
  1017. package/dist/base/build/src/cli/sidecar-claim-explain.d.ts +0 -45
  1018. package/dist/base/build/src/cli/sidecar-claim-explain.js +0 -87
  1019. package/dist/claude-code/build/src/cli/sidecar-claim-explain.d.ts +0 -45
  1020. package/dist/claude-code/build/src/cli/sidecar-claim-explain.js +0 -87
  1021. package/dist/codex/build/src/cli/sidecar-claim-explain.d.ts +0 -45
  1022. package/dist/codex/build/src/cli/sidecar-claim-explain.js +0 -87
  1023. package/dist/kiro/build/src/cli/sidecar-claim-explain.d.ts +0 -45
  1024. package/dist/kiro/build/src/cli/sidecar-claim-explain.js +0 -87
  1025. package/dist/opencode/build/src/cli/sidecar-claim-explain.d.ts +0 -45
  1026. package/dist/opencode/build/src/cli/sidecar-claim-explain.js +0 -87
  1027. package/dist/pi/build/src/cli/sidecar-claim-explain.d.ts +0 -45
  1028. package/dist/pi/build/src/cli/sidecar-claim-explain.js +0 -87
  1029. package/src/cli/sidecar-claim-explain.ts +0 -130
@@ -0,0 +1,51 @@
1
+ ---
2
+ status: current
3
+ subject: Writer-observed execution
4
+ decided: 2026-07-14
5
+ evidence:
6
+ - kind: issue
7
+ ref: "634"
8
+ - kind: adr
9
+ ref: docs/adr/0017-anti-gaming-trust-security-model.md
10
+ - kind: adr
11
+ ref: docs/adr/0020-trust-reconcile-manifest-and-claim-classification.md
12
+ ---
13
+ # Writer-observed execution
14
+
15
+ **Decision.** When `record-gate-claim` executes a declared evidence command itself
16
+ (`runObservedCommand` — a real process it spawned, with a real exit code, output hash, and,
17
+ for tests, a `local-process-exit` execution proof), it appends that observation to the same
18
+ hash-chained `command-log.jsonl` the PostToolUse capture hook writes, under the same
19
+ lockfile protocol, visibly attributed via `source: "canonical-writer-execution"`. The
20
+ capture fold's precedence is **outcome-ranked, source-blind**: observed fail > observed
21
+ pass > ambiguous, with the exit code always traveling with the winning status. The
22
+ properties that matter follow: a writer pass can lift ambiguity but can never bury an
23
+ independently captured failure (fail is sticky from either source), and a writer-observed
24
+ failure likewise defeats any pass. Passes from the two sources rank equally — the
25
+ distinction between them lives in the permanent `source` attribution, not in the fold. The chain
26
+ fork classifier tolerates shared-parent siblings only when every sibling's source is
27
+ `postToolUse-capture` or `canonical-writer-execution`; any other source on a shared parent
28
+ remains tamper.
29
+
30
+ **Context.** ADR 0017/0020 make the independent capture log the truth source for command
31
+ outcomes, and #470 hardened capture to never record `pass` without positive evidence. On
32
+ hosts whose runtime hook payloads carry no exit code (Codex's PostToolUse
33
+ `tool_response` today), every captured entry is honestly `ambiguous` — and #634 showed the
34
+ consequence: `builder.verify.*` claims can never derive `verified`, while the sanctioned
35
+ accepted-gap waiver produces `assumed`, which no gate's `accepted_statuses` admits. The
36
+ verify gate was structurally unclosable on such hosts regardless of evidence quality.
37
+
38
+ **Why this preserves the anti-gaming posture.** A writer observation is not an inference or
39
+ a self-report of intent — it is the exit code of a process the canonical writer itself
40
+ spawned and waited on. It enters the record distinguishable forever (the `source` field),
41
+ tamper-evident (chain-hashed), serialized against the hook (shared lock), and subordinate
42
+ on conflict (an observed fail from either source wins). The waiver path is untouched:
43
+ accepted gaps remain disclosure that derives `assumed`, never gate satisfaction.
44
+
45
+ **Residual risk, accepted.** A compromised writer process could self-attest a pass the hook
46
+ never saw. Mitigations: the attribution is permanent and auditable; the chain makes
47
+ retroactive editing detectable; a hook-observed failure always prevails; and PR CI Trust
48
+ Reconcile re-executes manifest commands independently of any local observation. Follow-up
49
+ (#634 option c): when runtime harnesses surface exit codes in hook payloads, hook capture
50
+ naturally resumes confirming passes first-hand; writer observations then serve as
51
+ corroboration rather than the sole deterministic signal.
@@ -23,11 +23,15 @@ run `npm run validate:source --` and `npm run fixture:retirement-audit --`.
23
23
  | `evals/fixtures/kit-conformance-levels` | K-level conformance and consumer-target derivation fixtures | `evals/integration/test_kit_conformance_levels.sh` | Keep while K-level derivation, degradation invariant, and consumer-target badge rules are tested. |
24
24
  | `evals/fixtures/hook-influence` | hook influence behavioral cases | `evals/integration/test_hook_influence_cases.sh`, `evals/static/test_workflow_skills.sh`, `scripts/validate-hook-influence-cases.js` | Keep while hook influence cases define agent guidance behavior. |
25
25
  | `evals/fixtures/learning-review-proposals` | learning-review kit/gate tuning proposal fixtures (#352): pattern-present (engineered cost-inflation + gate false-block-rate pattern, with sessions/ trust.bundle + gate-review.inquiries.json joins and a hand-computed expected-aggregates.json), balanced (proportional cost/findings movement -> zero proposals), under-threshold (below LR_MIN_WINDOW_SAMPLE), repeat-window (idempotency), and effect-follow-up (later-window effect-fill pass for a ratified proposal) | `evals/integration/test_learning_review_proposals.sh` | Keep while `scripts/telemetry/learning-review-proposals.sh`/`learning-review-decide.sh` (docs/specs/learning-review-proposals-contract.md) are enforced: hand-computed aggregates, evidence-cited proposals, zero-mutation, idempotency, and the ratify -> effect-fill trail. |
26
+ | `evals/fixtures/narrative-sources` | narrative source snapshot, offline resolution, integrity, completeness, fail-closed redaction, grounded runtime projection, grounded execution narrative, and trust-isolation fixtures (#613, #617, #618, #619) | `evals/integration/test_narrative_source_contract.sh`, `evals/integration/test_narrative_runtime_projection.sh`, `evals/integration/test_narrative_grounded_envelope.sh`, `evals/integration/test_narrative_redaction_failclosed.sh`, `evals/integration/test_narrative_trust_isolation.sh` | Keep while the narrative source manifest, content-addressed offline resolver, integrity verification, grounded runtime projection, grounded execution narrative composition, capture-completeness disclosure, lifecycle locality, fail-closed redaction, and narrative trust-isolation contracts are supported. |
27
+ | `evals/fixtures/narrative-grounding-validator` | narrative grounding validator adversarial fixtures (#623) | `evals/integration/test_narrative_grounding_validator.sh` | Keep while deterministic citation integrity, material-event coverage, epistemic-label integrity, and fail-closed narrative publication are enforced. |
28
+ | `evals/fixtures/narrative-prose-renderer` | model-assisted prose renderer adversarial fixtures (#614): provenance-subset (unsupported-summary), no-op-loop lack-of-progress wording, and prompt-injection fixtures reused from evals/fixtures/narrative-grounding-validator | `evals/integration/test_narrative_prose_renderer.sh` | Keep while the fail-closed prose renderer (D3 provenance-subset citation check, provider gating, economics-always, zero-prose-artifact-on-failure) is enforced. |
29
+ | `evals/fixtures/narrative-evals` | grounded narrative faithfulness eval corpus + result-schema package (#612): ten R1 case-class fixtures with frozen-manifest answer keys plus five R3 corruption fixtures whose named eval-check anchors are the scorer-teeth mutation targets | `evals/integration/test_narrative_evals.sh` | Keep while the versioned adversarial corpus, its frozen-manifest answer keys, the schema-valid narrative-eval-result output, the declared cross-runtime capability parity, and the R3 scorer-teeth mutation battery are enforced. |
26
30
  | `evals/fixtures/pull-work-provider` | work item provider normalization fixtures | `evals/integration/test_pull_work_provider.sh` | Keep while provider normalization preserves blockers, artifact refs, board membership, and freshness metadata. |
27
31
  | `evals/fixtures/pull-work-wip-shepherding` | WIP shepherding state fixtures | `evals/static/test_workflow_skills.sh` | Keep while pull-work documents personal versus global WIP behavior. |
28
32
  | `evals/fixtures/reconcile-preflight` | #356 reconcile-preflight shape fixtures not already covered by trust-reconcile-exploits (un-superseded disputed critique, standalone disputed session-local claim) | `evals/integration/test_reconcile_preflight.sh` | Keep while the local `reconcile-preflight` subcommand (#356) is proven against the two shapes trust-reconcile-exploits does not already fixture (un-superseded disputed critique, standalone disputed session-local claim); the other four shapes reuse trust-reconcile-exploits/trust-reconcile-mixed-bundle directly rather than forking near-duplicates. |
29
33
  | `evals/fixtures/surface-trust` | Surface trust evidence fixtures | `evals/integration/test_workflow_sidecar_writer.sh` | Keep while sidecar writer maps Surface trust evidence into workflow records. |
30
- | `evals/fixtures/telemetry` | hermetic Stop-hook usage transcript fixture (#defect-2026-07 telemetry-usage-cost-extraction): a multi-model JSONL transcript with .message.model + .message.usage token blocks proving real token/cost/model extraction end-to-end; also reused by the #568 slice 1 per-tool-call usage-enrichment eval (test_telemetry_tool_usage.sh), which adds usage-transcript-oversized-prefix.jsonl to prove the bounded tail-read | `evals/integration/test_usage_cost.sh`, `evals/integration/test_telemetry_usage_pipeline.sh`, `evals/integration/test_telemetry_tool_usage.sh` | Keep while telemetry.sh's Stop-hook usage pipeline (usage_parse_transcript / usage_model_from_transcript_usage / usage_last_turn_usage) is proven against hermetic multi-model and oversized-prefix transcripts rather than relying on live runtime data. |
34
+ | `evals/fixtures/telemetry` | hermetic Stop-hook usage transcript fixture (#defect-2026-07 telemetry-usage-cost-extraction): a multi-model JSONL transcript with .message.model + .message.usage token blocks proving real token/cost/model extraction end-to-end; also reused by the #568 slice 1 per-tool-call usage-enrichment eval (test_telemetry_tool_usage.sh), which adds usage-transcript-oversized-prefix.jsonl to prove the bounded tail-read | `evals/integration/test_usage_cost.sh`, `evals/integration/test_telemetry_usage_pipeline.sh`, `evals/integration/test_telemetry_tool_usage.sh`, `evals/integration/test_telemetry_tool_outcome.sh` | Keep while telemetry.sh's Stop-hook usage pipeline (usage_parse_transcript / usage_model_from_transcript_usage / usage_last_turn_usage) is proven against hermetic multi-model and oversized-prefix transcripts rather than relying on live runtime data. |
31
35
  | `evals/fixtures/trust-reconcile-exploits` | WS8 trust-reconcile anti-gaming exploit fixtures (frozen negative regressions); also reused by the #356 local reconcile-preflight eval (same shapes, no forked copies) | `evals/integration/test_trust_reconcile_negatives.sh`, `evals/integration/test_reconcile_preflight.sh` | Keep while trust-reconcile.js enforces the WS8 iteration-2 soundness properties (no-label test_output, unwaived-assumed, status-misassertion, waiver-on-command); each fixture is a permanent negative regression. |
32
36
  | `evals/fixtures/trust-reconcile-mixed-bundle` | WS8 trust-reconcile mixed-evidence end-to-end proof fixture; also reused by the #356 reconcile-preflight eval as its CLEAN-BUNDLE (AC4) case | `evals/integration/test_trust_reconcile_mixed_bundle.sh`, `evals/integration/test_reconcile_preflight.sh` | Keep while the trust-reconcile manifest/classification/waiver contract (ADR 0020) is enforced; proves a mixed test_output + session-local + waived bundle passes the CI anchor. |
33
37
  | `evals/fixtures/trust-reconcile-ws3` | WS8 AC6 backward-compat fixture: real ws3-kit-dependencies-namespacing old-style bundle | `evals/integration/test_trust_reconcile_negatives.sh` | Keep while backward compatibility with pre-classification (all-test_output) bundles is asserted; proves an old-style bundle still FAILS the same way (no silent pass). |
@@ -6,6 +6,26 @@ title: Migrations
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ - Gate-action envelopes now use `schema_version: "3.0"`. `action.declared_artifacts`
10
+ and `stop_condition.required.artifact_refs` contain typed targets instead of
11
+ strings. A `file` target names its project-relative `path` and whether it is
12
+ directly writable or must be produced through a declared operation; a
13
+ `trust_slice` target is explicitly non-writable and names the public interface
14
+ that records it. `action.artifact_bindings` maps each typed target to the
15
+ gate expectation ids it satisfies, so consumers can derive the exact required
16
+ target set from unresolved required expectations without private kit metadata.
17
+ The bindings are product-owned gate semantics, not grader hints or
18
+ consumer-authored guidance. Empty expectation ownership on a file represents
19
+ a declared optional artifact that is never gate-required; trust slices must
20
+ own an expectation so their recording interface can be derived.
21
+ Structured evidence parameters reference the canonical
22
+ `public_interfaces.schemas.evidence_ref_json` JSON Schema. There is no legacy
23
+ envelope fallback; adapters must require version 3.0 and stop treating
24
+ `trust.bundle#<slice>` as a filesystem path.
25
+ - Gate-action envelope version 2.0 added the originating `gate_id` to each
26
+ `gate.requirements` entry, allowing consumers to
27
+ verify accepted exceptions without private Flow-definition knowledge. There
28
+ was no legacy version 1.0 fallback.
9
29
  - Workflow runtime artifacts now live under `.kontourai/flow-agents/` instead
10
30
  of earlier runtime roots such as `.flow-agents/` or `.agents/flow-agents/`.
11
31
  Move any local session directories, sidecars, or `current.json` pointers you
@@ -165,12 +165,21 @@ consume another turn when `workflow drive` is invoked again:
165
165
  flow_agents workflow drive \
166
166
  --session-dir .kontourai/flow-agents/example \
167
167
  --adapter-command-file .kontourai/flow-agents/runtime-adapter.json \
168
+ --context-policy fresh \
168
169
  --max-turns 6 \
169
170
  --turn-timeout-ms 900000 \
170
171
  --barrier-wait-ms 300000 \
171
172
  --json
172
173
  ```
173
174
 
175
+ `--context-policy warm` remains the default and requests one new adapter context for the mission,
176
+ then resumes it. `--context-policy fresh` requests a new context for every bounded Flow action. Both
177
+ policies pass the same canonical gate-action handoff and preserve the same Flow gates, evidence rules,
178
+ mission budget, and adapter authority. The selected policy is persisted with the mission and cannot be
179
+ changed on resume. Adapters must honor the request's `context_strategy.thread` value and must not infer
180
+ context routing from model names. This is a context-management capability, not permission to drop gates,
181
+ invent evidence, or replay a prior transcript into a nominally fresh context.
182
+
174
183
  Driver state and its append-only event stream live under
175
184
  `.kontourai/flow-agents/<slug>/continuation-driver/`. The mission turn count survives reinvocation;
176
185
  subsequent invocations must use the same `--max-turns` value. The request contains the
@@ -157,7 +157,7 @@ authority for pointer navigation.
157
157
  ### Gate-Action Envelope
158
158
 
159
159
  Every active Builder continuation request includes a bounded
160
- `gate_action_envelope` with schema version `1.0`. Flow Agents derives it from
160
+ `gate_action_envelope` with schema version `3.0`. Flow Agents derives it from
161
161
  the persisted canonical Flow run and effective Flow Definition, then joins it
162
162
  to the installed Builder Kit's validated `flow_step_actions` record. It is an
163
163
  execution context, not a second gate evaluator: Flow remains the only authority
@@ -179,12 +179,30 @@ Declared operations, artifacts, and evidence expectation ids come from product
179
179
  metadata. `implementation_allowed` is also product metadata; the shipped Builder
180
180
  Kit declares it true only for `builder.build/execute`.
181
181
 
182
- The read-only status interface is an exact version-pinned command. Mutation
182
+ Declared artifact targets are typed. A `file` target includes its resolved
183
+ project-relative path under the active session, its direct-write policy, and
184
+ the skill or external operation that produces it. Operation result files are
185
+ not model-writable. A `trust_slice` target names a
186
+ logical `trust.bundle#<slice>` projection, sets `direct_write_allowed` to false,
187
+ and identifies the public evidence or critique interface that records it. A
188
+ trust slice is never a filename and adapters must not edit `trust.bundle`
189
+ directly.
190
+
191
+ The read-only status interface identifies the exact package version, binary,
192
+ and argv without requiring an adapter to parse a shell command. Mutation
183
193
  interfaces are typed per expectation: `workflow.evidence`, `workflow.critique`,
184
194
  or a named product operation such as `publish-change`. Evidence and critique
185
195
  interfaces expose fixed argv plus typed required parameters and allowed values;
186
- they do not publish shell strings with substitution placeholders. Consumers add
187
- parameter values as distinct argv entries.
196
+ they do not publish shell strings with substitution placeholders. Structured
197
+ evidence parameters reference `public_interfaces.schemas.evidence_ref_json`, a
198
+ bounded JSON Schema with required fields for source, command, artifact,
199
+ provider, and external evidence. Consumers add parameter values as distinct
200
+ argv entries.
201
+
202
+ Adapters that perform an allowed direct file write remain responsible for
203
+ opening the target without following symlinks and for confirming that the final
204
+ path remains inside the active session. The envelope declares authority and
205
+ identity; it does not make an arbitrary adapter filesystem write atomic.
188
206
 
189
207
  `publish-change` is a provider-capability protocol, not a claim that the local
190
208
  `flow-agents publish-change` helper opens a pull request. Its envelope binds the
@@ -204,7 +222,14 @@ checks; it is not the provider action executor.
204
222
  empty lists for terminal actions. Expectation ids must exactly equal the resolved
205
223
  Flow expectation set. Artifact bindings map each artifact to its owning
206
224
  expectations, allowing optional artifacts to remain declared without appearing
207
- under `stop_condition.required`. Operation bindings must resolve through the
225
+ under `stop_condition.required`. The same ownership is projected publicly as
226
+ typed `action.artifact_bindings`; consumers derive required targets by selecting
227
+ bindings that own an unresolved required expectation. These bindings are
228
+ product-owned gate semantics, not grader hints or consumer-authored guidance.
229
+ For file artifacts, an empty `expectation_ids` list keeps the artifact declared
230
+ and observable but never gate-required. Trust slices must own at least one
231
+ expectation because ownership determines their recording interface.
232
+ Operation bindings must resolve through the
208
233
  canonical public operation catalog, not merely a self-declared string. Artifact
209
234
  refs are either lexically safe session-relative paths or validated
210
235
  `trust.bundle#<safe-id>` virtual refs; absolute paths, traversal, and arbitrary
@@ -265,11 +290,16 @@ exception applies, or every effective expectation is optional. This advances
265
290
  those gates without prematurely evaluating ordinary missing-required gates, and
266
291
  once the run advances no obsolete action skill remains required.
267
292
 
268
- The envelope and its prior-turn delta are additive fields of
293
+ The envelope, its prior-turn delta, and `context_strategy` are additive fields of
269
294
  `ContinuationTurnRequest` schema `1.0`; adapters that only consume the existing
270
- request fields remain compatible. When `workflow drive` produces its optional
295
+ request fields remain compatible. `context_strategy` tells a capable adapter to
296
+ start a `new` context or `resume` the mission context and identifies the handoff
297
+ as canonical. The mission-bound policy defaults to warm continuation; selecting
298
+ fresh context changes only transcript routing, never the Flow contract, gate
299
+ requirements, or evidence authority. When `workflow drive` produces its optional
271
300
  signed request/result attestation, the exact request object (including the
272
- envelope) is included in the signed payload without transformation.
301
+ envelope and context strategy) is included in the signed payload without
302
+ transformation.
273
303
  # Builder Lifecycle Authority
274
304
 
275
305
  The canonical Flow run owns pause, resume, and cancellation. The current assignment actor may
@@ -295,6 +325,7 @@ Flow issue #118.
295
325
  ```text
296
326
  flow-agents builder-run pause --session-dir <dir> --reason <text>
297
327
  flow-agents builder-run resume --session-dir <dir> --reason <text>
328
+ flow-agents builder-run cancel-request --session-dir <dir> [--out <file>] [--reason <text>] [--actor <name>] [--expires-in-hours <n>]
298
329
  flow-agents builder-run cancel --session-dir <dir> --authorization-file <record.json>
299
330
  flow-agents builder-run release-assignment --session-dir <dir> --reason <text>
300
331
  flow-agents builder-run archive --session-dir <dir> --authorization-file <record.json>
@@ -307,3 +338,13 @@ assignment while holding the same lock; a successfully consumed cancellation non
307
338
  replayed. Archive accepts only completed or canceled runs, moves the session under
308
339
  `.kontourai/flow-agents/archive/<slug>/`, and retains the canonical Flow run. None of these
309
340
  operations deletes a branch or worktree; cleanup requires a separate provider-aware action.
341
+
342
+ `cancel-request` is a **read-only convenience** that removes the friction of hand-assembling a
343
+ cancellation record: it mints the *unsigned* authorization for the run (correct `run_id`,
344
+ `subject`, active `assignment_actor`, a fresh `nonce` and expiry) and prints the exact
345
+ `signing_payload` bytes to sign. It does not sign, cancel, or mutate anything — the operator signs
346
+ the payload with their Ed25519 lifecycle-authority key, adds the `signature` block to the emitted
347
+ file, and runs `cancel --authorization-file` as above. The signing payload is produced through the
348
+ same actor/request normalization the verifier applies, so a signature over it verifies by
349
+ construction. Like `cancel`, it requires an active assignment holder; an active run whose
350
+ assignment has already been released cannot be authorized this way without re-claiming it first.
@@ -29,13 +29,20 @@ Every Flow Agents event has a canonical name that is runtime-neutral. Adapters m
29
29
  | `userPromptSubmit` | The user submits a new turn or message. Maps from `UserPromptSubmit`. | `hook_event_name` | `turn.prompt_text` (redacted by default), `cwd` |
30
30
  | `preToolUse` | Immediately before a tool call is executed. Maps from `PreToolUse`. | `hook_event_name`, `tool_name`, `tool_input` | `tool_id`, `cwd`, `usage.model`, `usage.input_tokens`, `usage.output_tokens`, `usage.cache_creation_input_tokens`, `usage.cache_read_input_tokens`, `usage.estimated_cost_usd`, `usage.pricing_version` |
31
31
  | `permissionRequest` | The runtime is asking for permission to run a tool or action. Maps from `PermissionRequest`. | `hook_event_name`, `tool_name` | `tool_input`, `cwd` |
32
- | `postToolUse` | After a tool call completes (success or failure). Maps from `PostToolUse` and `PostToolUseFailure`. | `hook_event_name`, `tool_name`, `tool_response` | `tool_input`, `tool_output`, `error`, `cwd`, `usage.model`, `usage.input_tokens`, `usage.output_tokens`, `usage.cache_creation_input_tokens`, `usage.cache_read_input_tokens`, `usage.estimated_cost_usd`, `usage.pricing_version` |
32
+ | `postToolUse` | After a tool call completes (success or failure). Maps from `PostToolUse` and `PostToolUseFailure`. | `hook_event_name`, `tool_name`, `tool_response` | `tool_input`, `tool_output`, `error`, `cwd`, `tool.duration_ms`, `tool.outcome`, `tool.status`, `usage.model`, `usage.input_tokens`, `usage.output_tokens`, `usage.cache_creation_input_tokens`, `usage.cache_read_input_tokens`, `usage.estimated_cost_usd`, `usage.pricing_version` |
33
33
  | `stop` | The agent is about to stop and return control to the user. Maps from `Stop` and `SessionEnd`. | `hook_event_name` | `stop_reason`, `cwd` |
34
34
  | `subagentStart` | A subagent or specialist delegate is spawning. Maps from `SubagentStart` (Codex). | `hook_event_name` | `agent_name`, `agent_type` |
35
35
  | `subagentStop` | A subagent or specialist delegate has stopped. Maps from `SubagentStop` (Codex). | `hook_event_name` | `agent_name`, `outcome` |
36
36
 
37
37
  **`usage.*` on `preToolUse`/`postToolUse` (#568 slice 1).** These two events carry an optional `.usage` object — `model`, `input_tokens`, `output_tokens`, `cache_creation_input_tokens`, `cache_read_input_tokens`, `estimated_cost_usd`, `pricing_version` — sourced from the runtime transcript's LAST assistant turn (the turn that produced this specific tool call), joined via a bounded tail-read of `hook.transcript_path`. This is **per-turn, not a per-tool-call cost fraction**: multiple tool calls inside the same assistant turn (parallel tool_use blocks) report the *same* whole-turn usage figures — do not sum `estimated_cost_usd` across `tool.invoke`/`tool.result` rows within one turn, or cost will be double-counted; `session.usage`'s cumulative totals remain the authoritative aggregate. When the transcript join is unavailable but the runtime's `.model` hook field is present, only `usage.model` is populated and every token/cost field is explicitly `null` (never a guessed number); `.model` itself is best-effort on these two events (see §8.2), not a contractually guaranteed field. `tool.permission_request` (`permissionRequest`) is explicitly excluded from this enrichment.
38
38
 
39
+ **`tool.duration_ms` / `tool.outcome` / `tool.status` on `tool.result` (#580).** Every `tool.result` record (from `postToolUse`/`PostToolUse`/`PostToolUseFailure`) carries three intrinsic tool-result fields on its `.tool` object (co-located with `.tool.name`/`.tool.output`):
40
+ - **`duration_ms`** — non-negative wall-clock milliseconds between this tool's invoke and its result, correlated per tool call (host call id when present, else a content hash of `tool_name` + compact `tool_input`). The invoke's start time is recorded on `preToolUse` and read+unlinked on the matching result. It is **`null`** — never a fabricated `0` or a stale value — when the matching start record is absent (a result with no prior recorded invoke). Best-effort and non-blocking; a missing/corrupt start record degrades to `null`. Resolution is millisecond on hosts with a sub-second clock (`$EPOCHREALTIME`/GNU `date +%s%3N`) and second-granular on the portable fallback.
41
+ - **`outcome`** — the deterministic tri-state `pass` | `fail` | `ambiguous` from the canonical observation contract (§2.5), computed in-process by a jq port of `scripts/hooks/evidence-capture.js observeResult` so the Claude hot path stays hermetic (no node subprocess). A `PostToolUseFailure` event folds to `fail`. Never derived from stdout text or model narration. On the Codex runtime only — where the exit code lives in the rollout banner rather than the payload — the code is resolved via `scripts/hooks/lib/codex-exit-code.js` and fed through the same tri-state; an unreadable rollout degrades to `ambiguous`.
42
+ - **`status`** — the host-surfaced integer exit code when one is cleanly present (the same fields §2.5 scans), else **`null`**.
43
+
44
+ `tool.invoke` and `tool.permission_request` records carry none of these three fields (an invoke has no result yet; a permission request is not a tool result). The three fields are derived scalars only (a timestamp delta, a verdict, an integer) — no args/output/secret material — and the start record stores a bare timestamp, so the console-relay sanitize backstop is unaffected.
45
+
39
46
  ### Redaction Defaults
40
47
 
41
48
  Telemetry channels redact sensitive payload fields before emission. Adapters must honor these defaults and must not log raw hook payloads without applying channel redaction.
@@ -87,6 +94,27 @@ way.
87
94
  supported, it resolves from step 3 onward. Adapters MUST document which manifests they honor so the
88
95
  attribution granularity difference is explicit, not surprising.
89
96
 
97
+ #### Work-item attribution (`task_slug`)
98
+
99
+ Where `context.project` groups events by *codebase*, `task_slug` groups them by the *active Builder
100
+ work item* — so the console can report cost and activity per unit of work (the "Cost by work-item"
101
+ breakdown), not just per project.
102
+
103
+ | Field | Semantics | Redacted? | Producer requirement |
104
+ | --- | --- | --- | --- |
105
+ | `task_slug` | Top-level slug of the Builder run active in `context.cwd` at emission time. | **No** (an opaque work-item slug; carries no path or content) | Adapters SHOULD stamp `task_slug` when a Builder run is active in the working dir. **Omit the field entirely when no run is active — never emit an empty string and never fabricate a slug.** |
106
+
107
+ Canonical resolution (harness adapter), first match wins, read from the *same* `current.json` the
108
+ economics relay reads so both surfaces attribute to one identifier:
109
+
110
+ 1. `<cwd>/.kontourai/flow-agents/current.json` → `.active_slug`, else `.artifact_dir`.
111
+ 2. `<cwd>/.flow-agents/current.json` (legacy location) → `.active_slug`, else `.artifact_dir`.
112
+ 3. No file, or both fields empty → **no `task_slug` key on the record.**
113
+
114
+ Only the slug string is stored; no prompt, args, or file content is ever read into it. A non-Builder
115
+ session (no `current.json`) therefore emits records with no `task_slug`, and the console buckets
116
+ those under "unknown" rather than inventing an attribution.
117
+
90
118
  ### Exit Code Protocol (Canonical Hook Scripts)
91
119
 
92
120
  Canonical hook scripts in `scripts/hooks/` use the following exit code contract — originally derived from Kiro conventions and shared across all harness adapters via the adapter translation layer:
@@ -156,7 +156,7 @@ from a harness-blind gap (full doctrine + per-runtime matrix in `harness-capabil
156
156
  | Field | Meaning |
157
157
  | --- | --- |
158
158
  | `runtime` | the runtime that produced the record (`claude-code`, `kiro-cli`, …), from `session.usage .agent.runtime` |
159
- | `per_delegation_tokens` | `true` iff the runtime isolates per-sub-agent tokens. `false` everywhere today → per-delegation cost unavailable |
159
+ | `per_delegation_tokens` | `true` iff the runtime isolates per-sub-agent tokens. **Derived (not a hardcoded literal, #620)** from the runtime's capability declaration — the emitter reads the build-only `build/generated/capability-declarations.json` (generated from `src/lib/capability-declarations.ts`), keys it on the normalized `.agent.runtime` (`kiro-cli`→`kiro`), and emits `true` iff the declared `per_delegation_tokens` status is `supported`. An unresolved runtime or a missing declaration JSON yields the explicit sentinel `false` — never a fabricated `true`. `false` everywhere today → per-delegation cost unavailable |
160
160
  | `per_delegation_outcome` | outcome-signal coverage this run: `full`\|`partial`\|`none`\|`n/a` |
161
161
 
162
162
  Consumers MUST read `signals` before rendering a delegation metric: if the needed signal is unavailable,
@@ -3,6 +3,10 @@
3
3
  **The signals a feature can rely on depend on which runtime/harness the kit is hooked into. State the
4
4
  coverage; never assume it, never fabricate the gap.**
5
5
 
6
+ > Generated by `npm run capability-matrix` from `src/lib/capability-declarations.ts` — the single
7
+ > source of truth. Do NOT edit this file by hand; change the declarations and regenerate. CI fails on
8
+ > drift (`npm run capability-matrix -- --check`).
9
+
6
10
  This is a cross-cutting contract: any feature whose data comes from telemetry (economics, delegation
7
11
  efficiency, liveness, learning) must declare which signals it needs, which *class* each falls in, and
8
12
  how it degrades when the current runtime does not expose one. A missing signal is rendered as
@@ -35,30 +39,67 @@ exposed:
35
39
  | Field | Class | Meaning |
36
40
  | --- | --- | --- |
37
41
  | `runtime` | — | the runtime that produced the record (`claude-code`, `kiro-cli`, `codex`, …) |
38
- | `per_delegation_tokens` | sub-agent-internal | `true` iff the runtime isolates per-sub-agent token usage. **`false` on every runtime today** → per-delegation cost is unavailable; the console attributes cost at `(role, model)` granularity via `cost.by_model` instead. |
42
+ | `per_delegation_tokens` | sub-agent-internal | `true` iff the runtime isolates per-sub-agent token usage. **`false` on every runtime today** → per-delegation cost is unavailable; the console attributes cost at `(role, model)` granularity via `cost.by_model` instead. Derived from this matrix's `per_delegation_tokens` capability declaration, not a hardcoded literal. |
39
43
  | `per_delegation_outcome` | orchestrator-observable | coverage of the outcome signal on this run: `full` (every delegation resolved to a real outcome), `partial` (some), `none` (delegations exist but none had a verdict/escalation/re-dispatch), `n/a` (no delegations observed). |
40
44
 
41
45
  Consumers (console panels, `learning-review`) MUST read `signals` before rendering a metric: if the
42
46
  signal a metric needs is unavailable, show "not measurable on this harness," not a misleading number.
43
47
 
44
- ## Per-runtime coverage (current, honest snapshot)
45
-
46
- `✓` exposed · `partial` best-effort/orchestrator-derived · `✗` not exposed. Update this table as
47
- runtimes add instrumentation — it is the single source of truth the `signals` values are stamped from.
48
-
49
- | Signal | Class | claude-code | kiro-cli | codex | raw-model runner |
50
- | --- | --- | --- | --- | --- | --- |
51
- | whole-run tokens/cost (`by_model`) | run-level | | | | partial |
52
- | delegation dispatch (role/model) | orchestrator-observable | | | partial | |
53
- | re-dispatch / re-prompt count | orchestrator-observable | ✓ | ✓ | partial | ✗ |
54
- | escalation (tier bump) | orchestrator-observable | ✓ | | partial | ✗ |
55
- | supersession / correction | orchestrator-observable | partial | partial | ✗ | ✗ |
56
- | per-sub-agent terminal verdict | mixed | partial | partial | ✗ | ✗ |
57
- | per-sub-agent tokens/cost | sub-agent-internal | ✗ | ✗ | ✗ | ✗ |
58
-
59
- "partial" for verdicts/supersession reflects that these depend on the workflow actually recording an
60
- `evidence`/`verdict`/`supersession` event for the agent — capturable, but not guaranteed every run.
61
- That is exactly why `outcome` degrades to `unavailable` rather than `accepted` when the event is absent.
48
+ ## Per-runtime capability coverage (generated, honest snapshot)
49
+
50
+ `✓` exposed · `partial` best-effort/orchestrator-derived · `✗` not exposed. This table is generated
51
+ from `src/lib/capability-declarations.ts`; update the declarations there as runtimes add
52
+ instrumentation — it is the single source of truth the `signals` values are stamped from. The
53
+ `kiro-cli` runtime value normalizes to the canonical `kiro` column before lookup.
54
+
55
+ | Capability | `claude-code` | `codex` | `kiro` | `opencode` | `pi` | `codex-local` | `strands-local` |
56
+ | --- | --- | --- | --- | --- | --- | --- | --- |
57
+ | `turn_id` | | | ✓ | partial | ✓ | | ✗ |
58
+ | `transcript_path` | | | ✓ | | | ✗ | ✗ |
59
+ | `intent_annotation` | | | | | ✗ | ✗ | ✗ |
60
+ | `per_delegation_trace_context` | | | | | ✗ | ✗ | ✗ |
61
+ | `per_delegation_tokens` | | | ✗ | ✗ | ✗ | ✗ | ✗ |
62
+ | `terminal_verdict` | partial | ✗ | partial | ✗ | ✗ | ✗ | ✗ |
63
+
64
+ ### Declared notes and reasons
65
+
66
+ Every `partial` / `✗` cell above, with its declared justification:
67
+
68
+ - `turn_id` · `opencode` (partial): session.start telemetry is unavailable in opencode run (non-interactive) mode; tool events still carry a turn context.
69
+ - `turn_id` · `codex-local` (unsupported): codex-local is a kit-activation adapter, not an agent-runtime telemetry source; it emits no per-turn agent-runtime telemetry.
70
+ - `turn_id` · `strands-local` (unsupported): strands-local is a kit-activation adapter, not an agent-runtime telemetry source; it emits no per-turn agent-runtime telemetry.
71
+ - `transcript_path` · `opencode` (unsupported): opencode does not expose a per-session transcript path to hooks.
72
+ - `transcript_path` · `pi` (unsupported): pi does not expose a per-session transcript path to hooks.
73
+ - `transcript_path` · `codex-local` (unsupported): codex-local is a kit-activation adapter and does not expose a per-session transcript path.
74
+ - `transcript_path` · `strands-local` (unsupported): strands-local is a kit-activation adapter and does not expose a per-session transcript path.
75
+ - `intent_annotation` · `claude-code` (unsupported): Intent-annotation capture is not implemented on any runtime yet (#622).
76
+ - `intent_annotation` · `codex` (unsupported): Intent-annotation capture is not implemented on any runtime yet (#622).
77
+ - `intent_annotation` · `kiro` (unsupported): Intent-annotation capture is not implemented on any runtime yet (#622).
78
+ - `intent_annotation` · `opencode` (unsupported): Intent-annotation capture is not implemented on any runtime yet (#622).
79
+ - `intent_annotation` · `pi` (unsupported): Intent-annotation capture is not implemented on any runtime yet (#622).
80
+ - `intent_annotation` · `codex-local` (unsupported): Intent-annotation capture is not implemented on any runtime yet (#622).
81
+ - `intent_annotation` · `strands-local` (unsupported): Intent-annotation capture is not implemented on any runtime yet (#622).
82
+ - `per_delegation_trace_context` · `claude-code` (unsupported): Per-delegation trace-context propagation is not implemented on any runtime yet (#425).
83
+ - `per_delegation_trace_context` · `codex` (unsupported): Per-delegation trace-context propagation is not implemented on any runtime yet (#425).
84
+ - `per_delegation_trace_context` · `kiro` (unsupported): Per-delegation trace-context propagation is not implemented on any runtime yet (#425).
85
+ - `per_delegation_trace_context` · `opencode` (unsupported): Per-delegation trace-context propagation is not implemented on any runtime yet (#425).
86
+ - `per_delegation_trace_context` · `pi` (unsupported): Per-delegation trace-context propagation is not implemented on any runtime yet (#425).
87
+ - `per_delegation_trace_context` · `codex-local` (unsupported): Per-delegation trace-context propagation is not implemented on any runtime yet (#425).
88
+ - `per_delegation_trace_context` · `strands-local` (unsupported): Per-delegation trace-context propagation is not implemented on any runtime yet (#425).
89
+ - `per_delegation_tokens` · `claude-code` (unsupported): No runtime isolates per-sub-agent token usage; per-delegation cost is attributed at (role, model) granularity instead.
90
+ - `per_delegation_tokens` · `codex` (unsupported): No runtime isolates per-sub-agent token usage; per-delegation cost is attributed at (role, model) granularity instead.
91
+ - `per_delegation_tokens` · `kiro` (unsupported): No runtime isolates per-sub-agent token usage; per-delegation cost is attributed at (role, model) granularity instead.
92
+ - `per_delegation_tokens` · `opencode` (unsupported): No runtime isolates per-sub-agent token usage; per-delegation cost is attributed at (role, model) granularity instead.
93
+ - `per_delegation_tokens` · `pi` (unsupported): No runtime isolates per-sub-agent token usage; per-delegation cost is attributed at (role, model) granularity instead.
94
+ - `per_delegation_tokens` · `codex-local` (unsupported): No runtime isolates per-sub-agent token usage; per-delegation cost is attributed at (role, model) granularity instead.
95
+ - `per_delegation_tokens` · `strands-local` (unsupported): No runtime isolates per-sub-agent token usage; per-delegation cost is attributed at (role, model) granularity instead.
96
+ - `terminal_verdict` · `claude-code` (partial): Captured only when the workflow records an evidence/verdict event for the sub-agent — not guaranteed every run.
97
+ - `terminal_verdict` · `codex` (unsupported): Codex does not surface a per-sub-agent terminal verdict to the orchestrator.
98
+ - `terminal_verdict` · `kiro` (partial): Captured only when the workflow records an evidence/verdict event for the sub-agent — not guaranteed every run.
99
+ - `terminal_verdict` · `opencode` (unsupported): opencode does not surface per-sub-agent terminal verdicts.
100
+ - `terminal_verdict` · `pi` (unsupported): pi has no named-subagent registry, so per-sub-agent verdicts are not observable.
101
+ - `terminal_verdict` · `codex-local` (unsupported): codex-local is a kit-activation adapter and does not surface per-sub-agent terminal verdicts.
102
+ - `terminal_verdict` · `strands-local` (unsupported): strands-local is a kit-activation adapter and does not surface per-sub-agent terminal verdicts.
62
103
 
63
104
  ## The doctrine (applies to any telemetry-dependent feature)
64
105
 
@@ -70,5 +111,6 @@ That is exactly why `outcome` degrades to `unavailable` rather than `accepted` w
70
111
  is not `$0`; an outcome you cannot observe is not `accepted`.
71
112
  4. **Fall back to the coarsest honest proxy** when the fine signal is missing (per-delegation cost →
72
113
  `(role, model)` via `by_model`), and label the proxy as such.
73
- 5. **Keep this matrix current.** When a harness starts exposing a signal, flip the cell and the
74
- `signals` stamp follows — the feature "lights up" without a schema change.
114
+ 5. **Keep these declarations current.** When a harness starts exposing a signal, flip the declaration in
115
+ `src/lib/capability-declarations.ts` and regenerate — the `signals` stamp follows and the feature
116
+ "lights up" without a schema change.
@@ -667,7 +667,10 @@ For unattended runtime re-entry, the active assignment actor may use `workflow d
667
667
  explicit runtime adapter argv file. The driver repeats the same public projection/evidence cycle,
668
668
  persists its mission turn budget, and parks on adapter-declared PID or deadline barriers instead of
669
669
  spending turns while external work is incomplete. Adapter completion never advances a gate by
670
- self-report; only trust evidence accepted by canonical Flow can change the current step. See
670
+ self-report; only trust evidence accepted by canonical Flow can change the current step. Use
671
+ `--context-policy fresh` when the selected adapter supports canonical fresh-context handoffs and
672
+ the runtime capability profile calls for bounded contexts. This preserves every gate while avoiding
673
+ prior-transcript replay between actions; `warm` remains the default. See
671
674
  [`docs/public-workflow-cli.md`](public-workflow-cli.md#bounded-continuation-driver) for the protocol.
672
675
 
673
676
  If the same Builder slice is interrupted, inspect its canonical status. Resume
@@ -11,9 +11,11 @@ mkdir -p "$LOG_DIR"
11
11
 
12
12
  CHECKS=(
13
13
  "Content boundary|npm run check:content-boundary --"
14
+ "Hachure boundary|npm run check:hachure-boundary --"
14
15
  "Decision registry|npm run check:decisions --"
15
16
  "Source tree validation|npm run validate:source --"
16
17
  "Context map drift|npm run context-map -- --check"
18
+ "Capability matrix drift|npm run capability-matrix -- --check"
17
19
  "Static eval suite|bash evals/run.sh static"
18
20
  "Workflow artifact integration|bash evals/integration/test_workflow_artifacts.sh"
19
21
  "Workflow artifact cleanup audit integration|bash evals/integration/test_workflow_artifact_cleanup_audit.sh"
@@ -22,6 +24,15 @@ CHECKS=(
22
24
  "Workflow sidecar writer integration|bash evals/integration/test_workflow_sidecar_writer.sh"
23
25
  "Sidecar field preservation integration|bash evals/integration/test_sidecar_field_preservation.sh"
24
26
  "Record-check integration|bash evals/integration/test_record_check.sh"
27
+ "Narrative source contract integration|bash evals/integration/test_narrative_source_contract.sh"
28
+ "Narrative runtime projection integration|bash evals/integration/test_narrative_runtime_projection.sh"
29
+ "Narrative grounded envelope integration|bash evals/integration/test_narrative_grounded_envelope.sh"
30
+ "Narrative redaction fail-closed integration|bash evals/integration/test_narrative_redaction_failclosed.sh"
31
+ "Narrative trust isolation integration|bash evals/integration/test_narrative_trust_isolation.sh"
32
+ "Narrative grounding validator integration|bash evals/integration/test_narrative_grounding_validator.sh"
33
+ "Narrative prose renderer integration|bash evals/integration/test_narrative_prose_renderer.sh"
34
+ "Narrative grounded evals integration|bash evals/integration/test_narrative_evals.sh"
35
+ "Narrative intent annotation integration|bash evals/integration/test_narrative_intent_annotation.sh"
25
36
  "Actor identity resolver integration|bash evals/integration/test_actor_identity.sh"
26
37
  "CI-runtime actor identity integration|bash evals/integration/test_ci_actor_identity.sh"
27
38
  "Assignment provider local-file integration|bash evals/integration/test_assignment_provider_local_file.sh"
@@ -35,6 +46,8 @@ CHECKS=(
35
46
  "Liveness console relay integration|bash evals/integration/test_liveness_console_relay.sh"
36
47
  "Console tenant isolation integration|bash evals/integration/test_console_tenant_isolation.sh"
37
48
  "Goal Fit hook integration|bash evals/integration/test_goal_fit_hook.sh"
49
+ "Plain stop messaging integration|bash evals/integration/test_plain_stop_messaging.sh"
50
+ "Goal Fit narrative exclusion integration|env -u FLOW_AGENTS_GOAL_FIT_MODE bash evals/integration/test_goal_fit_narrative_exclusion.sh"
38
51
  "Hook category behavior integration|bash evals/integration/test_hook_category_behaviors.sh"
39
52
  "Workflow steering hook integration|bash evals/integration/test_workflow_steering_hook.sh"
40
53
  "Hook influence contract integration|bash evals/integration/test_hook_influence_cases.sh"
@@ -61,7 +74,13 @@ CHECKS=(
61
74
  "Usage and cost integration|bash evals/integration/test_usage_cost.sh"
62
75
  "Telemetry usage pipeline integration|bash evals/integration/test_telemetry_usage_pipeline.sh"
63
76
  "Telemetry tool usage integration|bash evals/integration/test_telemetry_tool_usage.sh"
77
+ "Telemetry tool outcome integration|bash evals/integration/test_telemetry_tool_outcome.sh"
78
+ "Telemetry delegation integration|bash evals/integration/test_telemetry_delegation.sh"
79
+ "Telemetry action-class integration|bash evals/integration/test_telemetry_action_class.sh"
80
+ "Telemetry sanitize usage integration|bash evals/integration/test_telemetry_sanitize_usage.sh"
81
+ "Telemetry task slug integration|bash evals/integration/test_telemetry_task_slug.sh"
64
82
  "Economics record integration|bash evals/integration/test_economics_record.sh"
83
+ "Capability declarations integration|bash evals/integration/test_capability_declarations.sh"
65
84
  "Learning review proposals integration|bash evals/integration/test_learning_review_proposals.sh"
66
85
  "Utterance check integration|bash evals/integration/test_utterance_check.sh"
67
86
  "Pull work provider integration|bash evals/integration/test_pull_work_provider.sh"
@@ -100,9 +119,11 @@ CHECKS=(
100
119
 
101
120
  LANE_SOURCE_AND_STATIC=(
102
121
  "Content boundary"
122
+ "Hachure boundary"
103
123
  "Decision registry"
104
124
  "Source tree validation"
105
125
  "Context map drift"
126
+ "Capability matrix drift"
106
127
  "Static eval suite"
107
128
  )
108
129
 
@@ -110,6 +131,15 @@ LANE_WORKFLOW_CONTRACTS=(
110
131
  "Workflow artifact integration"
111
132
  "Workflow artifact cleanup audit integration"
112
133
  "Fixture retirement audit integration"
134
+ "Narrative source contract integration"
135
+ "Narrative runtime projection integration"
136
+ "Narrative grounded envelope integration"
137
+ "Narrative redaction fail-closed integration"
138
+ "Narrative trust isolation integration"
139
+ "Narrative grounding validator integration"
140
+ "Narrative prose renderer integration"
141
+ "Narrative grounded evals integration"
142
+ "Narrative intent annotation integration"
113
143
  "Publish-change helper integration"
114
144
  "Workflow sidecar writer integration"
115
145
  "Sidecar field preservation integration"
@@ -126,10 +156,15 @@ LANE_WORKFLOW_CONTRACTS=(
126
156
  "Current.json per-actor integration"
127
157
  "Liveness console relay integration"
128
158
  "Console tenant isolation integration"
159
+ "Telemetry tool outcome integration"
160
+ "Telemetry delegation integration"
161
+ "Telemetry action-class integration"
129
162
  )
130
163
 
131
164
  LANE_RUNTIME_AND_KIT=(
132
165
  "Goal Fit hook integration"
166
+ "Plain stop messaging integration"
167
+ "Goal Fit narrative exclusion integration"
133
168
  "Hook category behavior integration"
134
169
  "Workflow steering hook integration"
135
170
  "Hook influence contract integration"
@@ -156,7 +191,10 @@ LANE_RUNTIME_AND_KIT=(
156
191
  "Usage and cost integration"
157
192
  "Telemetry usage pipeline integration"
158
193
  "Telemetry tool usage integration"
194
+ "Telemetry sanitize usage integration"
195
+ "Telemetry task slug integration"
159
196
  "Economics record integration"
197
+ "Capability declarations integration"
160
198
  "Learning review proposals integration"
161
199
  "Utterance check integration"
162
200
  "Pull work provider integration"
@@ -0,0 +1,62 @@
1
+ # Grounded narrative evals corpus (#612)
2
+
3
+ A versioned, frozen-manifest-grounded adversarial fixture corpus and its scorer
4
+ for the narrative faithfulness program. This directory is the shared, externally
5
+ consumable package for the human-study and cross-presentation work in
6
+ kontourai/evals#95: the corpus + result schema are self-describing and can be
7
+ ingested unmodified.
8
+
9
+ ## Package contract
10
+
11
+ - `corpus.json` (`schema_version: "narrative-evals-corpus/v1"`) enumerates every
12
+ fixture: its `id`, its `case_class` (one of the ten R1 classes), a declarative
13
+ `build` recipe (seeded source records materialized through the public
14
+ `snapshotNarrative` API into a frozen manifest — never a hand-fabricated
15
+ manifest), and a typed `expected` answer key (`verdict` of `accept` / `reject`
16
+ / `known_gap`, plus `material_claims`, `epistemic_labels`, and citation
17
+ resolvability). Corruption fixtures additionally carry a `corruption` block and
18
+ the named `check` their defect must trip. The serialization references only
19
+ seeded records and fa1 source IDs, never internal flow-agents APIs.
20
+ - `schemas/narrative-eval-result.schema.json` (`schema_version:
21
+ "narrative-eval-result/v1"`, at the repo root) is the consolidated result
22
+ contract: per-fixture verdicts, aggregate faithfulness metrics
23
+ (unsupported-claim rate, citation precision/recall/resolvability, material-claim
24
+ coverage, per-class omission rate, epistemic-classification accuracy), an
25
+ `uncertainty` block (every metric carries a sample count + range), the DECLARED
26
+ cross-runtime `capability_parity` block, documented `known_gaps`, and per-fixture
27
+ `raw_source_links` for audit. `validateNarrativeEvalResult` (exported from the
28
+ package root) is the ajv-free validator.
29
+ - `scorer.mjs` is the hermetic scorer. `node scorer.mjs all` replays the whole
30
+ corpus and emits one schema-valid `narrative-eval-result/v1` object (write it to
31
+ a file with `NARRATIVE_EVAL_RESULT_OUT=<path>`); per-check modes
32
+ (`support` / `citation` / `coverage` / `epistemic` / `injection`) drive the
33
+ mutation battery. It imports only the BUILT modules under `build/`, so run
34
+ `npm run build` first.
35
+
36
+ ## Case classes and detection
37
+
38
+ The ten R1 case classes (`passing`, `failing`, `ambiguous`, `contradictory`,
39
+ `redacted`, `nested-agent`, `timeout`, `no-op`, `created-file`,
40
+ `prompt-injection`) are honest narratives scored `accept`, except the
41
+ `contradictory` case which is disclosed as a documented `known_gap`
42
+ (contradiction detection is an upstream gap, sequenced #568/#425 — it is never
43
+ faked as real detection). Five R3 corruption fixtures (hallucinated statement,
44
+ omitted failure, dangling citation, mislabeled inference, injection-followed
45
+ prose) each carry one deliberate defect the scorer must detect (`reject`). Every
46
+ corruption class is the teeth-proving mutation target for its `/* eval-check:<name> */`
47
+ anchor: `evals/integration/test_narrative_evals.sh` disables each detection in
48
+ turn and proves the matching fixture flips `expected=reject -> actual=accept`,
49
+ then restores the scorer byte-for-byte.
50
+
51
+ Results are per-corpus MEASUREMENTS, not proofs: no metric is asserted from a
52
+ single fixture, model, or runtime, and capability gaps are asserted from the
53
+ #620 declarations (`queryCapability`), never probed from behavior.
54
+
55
+ ## Running
56
+
57
+ ```sh
58
+ npm run build
59
+ node evals/fixtures/narrative-evals/scorer.mjs all
60
+ # or the full gate (corpus + schema validation + mutation battery):
61
+ bash evals/integration/test_narrative_evals.sh
62
+ ```