@kontourai/flow-agents 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/.github/CODEOWNERS +8 -0
  2. package/.github/workflows/ci.yml +32 -0
  3. package/AGENTS.md +4 -4
  4. package/CHANGELOG.md +39 -0
  5. package/CONTEXT.md +14 -0
  6. package/README.md +9 -3
  7. package/agents/dev.json +1 -1
  8. package/agents/tool-code-reviewer.json +1 -1
  9. package/agents/tool-planner.json +3 -3
  10. package/agents/tool-verifier.json +3 -3
  11. package/build/src/cli/console-learning-projection.js +3 -2
  12. package/build/src/cli/init.js +104 -21
  13. package/build/src/cli/kit.js +37 -6
  14. package/build/src/cli/pull-work-provider.js +1 -1
  15. package/build/src/cli/usage-feedback.js +3 -3
  16. package/build/src/cli/validate-hook-influence.js +1 -0
  17. package/build/src/cli/validate-workflow-artifacts.js +22 -6
  18. package/build/src/cli/workflow-artifact-cleanup-audit.js +36 -2
  19. package/build/src/cli/workflow-sidecar.d.ts +14 -7
  20. package/build/src/cli/workflow-sidecar.js +792 -69
  21. package/build/src/flow-kit/validate.d.ts +23 -0
  22. package/build/src/flow-kit/validate.js +67 -1
  23. package/build/src/index.d.ts +1 -1
  24. package/build/src/index.js +1 -1
  25. package/build/src/lib/flow-resolver.d.ts +6 -4
  26. package/build/src/lib/flow-resolver.js +125 -58
  27. package/build/src/lib/local-artifact-root.d.ts +14 -2
  28. package/build/src/lib/local-artifact-root.js +22 -5
  29. package/build/src/lib/workflow-learning-projection.js +2 -2
  30. package/build/src/runtime-adapters.d.ts +12 -0
  31. package/build/src/runtime-adapters.js +56 -16
  32. package/build/src/tools/build-universal-bundles.js +49 -16
  33. package/build/src/tools/generate-context-map.js +10 -8
  34. package/build/src/tools/validate-source-tree.js +23 -1
  35. package/console.telemetry.json +22 -0
  36. package/context/contracts/artifact-contract.md +38 -7
  37. package/context/contracts/builder-kit-workflow-state-contract.md +3 -2
  38. package/context/contracts/decision-registry-contract.md +263 -0
  39. package/context/contracts/delivery-contract.md +1 -1
  40. package/context/contracts/planning-contract.md +2 -1
  41. package/context/contracts/review-contract.md +5 -3
  42. package/context/contracts/verification-contract.md +9 -1
  43. package/context/contracts/work-item-contract.md +1 -1
  44. package/context/deferred/parallelization.md +1 -1
  45. package/context/gate-awareness.md +4 -4
  46. package/context/scripts/git-status.sh +2 -2
  47. package/context/scripts/hooks/config-protection.js +502 -2
  48. package/context/scripts/hooks/lib/config-protection-remedies.js +69 -0
  49. package/context/scripts/hooks/run-hook.js +14 -1
  50. package/context/scripts/hooks/stop-goal-fit.js +1140 -99
  51. package/context/scripts/hooks/workflow-steering.js +212 -6
  52. package/docs/adr/0007-flow-skill-kit-tool-boundary.md +2 -0
  53. package/docs/adr/0015-flow-flow-agents-boundary-reconciliation.md +35 -0
  54. package/docs/adr/0019-kit-dependency-ownership.md +62 -0
  55. package/docs/adr/0020-trust-reconcile-manifest-and-claim-classification.md +290 -0
  56. package/docs/adr/0021-assignment-leases-and-stale-claim-takeover.md +221 -0
  57. package/docs/adr/0022-fail-closed-delivery-reconciliation-with-governed-exemptions.md +283 -0
  58. package/docs/agent-system-guidebook.md +3 -3
  59. package/docs/agent-usage-feedback-loop.md +6 -6
  60. package/docs/context-map.md +9 -7
  61. package/docs/decisions/decision-records.md +57 -0
  62. package/docs/decisions/index.md +14 -0
  63. package/docs/decisions/promotion-gate.md +52 -0
  64. package/docs/developer-architecture.md +1 -1
  65. package/docs/fixture-ownership.md +3 -0
  66. package/docs/flow-kit-repository-contract.md +5 -5
  67. package/docs/getting-started.md +12 -2
  68. package/docs/integrations/harness-install.md +2 -1
  69. package/docs/kit-authoring-guide.md +64 -5
  70. package/docs/knowledge-kit.md +5 -1
  71. package/docs/learnings/2026-07-improvement-program.md +203 -0
  72. package/docs/migrations.md +6 -5
  73. package/docs/north-star.md +2 -2
  74. package/docs/operating-layers.md +4 -3
  75. package/docs/repository-structure.md +5 -5
  76. package/docs/skills-map.md +8 -8
  77. package/docs/spec/runtime-hook-surface.md +19 -15
  78. package/docs/spikes/graph-provider-2026-07.md +155 -0
  79. package/docs/standards-register.md +7 -7
  80. package/docs/trust-anchor-adoption.md +105 -4
  81. package/docs/work-item-adapters.md +1 -1
  82. package/docs/workflow-artifact-lifecycle.md +72 -9
  83. package/docs/workflow-eval-strategy.md +3 -3
  84. package/docs/workflow-shared-contracts.md +1 -1
  85. package/docs/workflow-usage-guide.md +254 -21
  86. package/evals/acceptance/DEMO-false-completion.md +20 -11
  87. package/evals/acceptance/prove-capture-teeth-declared.sh +15 -15
  88. package/evals/acceptance/prove-capture-teeth.sh +11 -11
  89. package/evals/acceptance/test_kiro_harness.sh +1 -1
  90. package/evals/ci/antigaming-suite.sh +5 -0
  91. package/evals/ci/run-baseline.sh +65 -1
  92. package/evals/fixtures/flow-kit-repository/invalid-bad-dependency/flows/review.flow.json +26 -0
  93. package/evals/fixtures/flow-kit-repository/invalid-bad-dependency/kit.json +13 -0
  94. package/evals/fixtures/flow-kit-repository/valid-with-dependency/flows/review.flow.json +26 -0
  95. package/evals/fixtures/flow-kit-repository/valid-with-dependency/kit.json +13 -0
  96. package/evals/fixtures/hook-influence/cases.json +32 -0
  97. package/evals/fixtures/pull-work-provider/github-issues.json +6 -6
  98. package/evals/fixtures/trust-reconcile-exploits/fabricated-attestation.json +59 -0
  99. package/evals/fixtures/trust-reconcile-exploits/no-label-bypass.json +36 -0
  100. package/evals/fixtures/trust-reconcile-exploits/skip-assumed-bypass.json +59 -0
  101. package/evals/fixtures/trust-reconcile-exploits/status-misassertion.json +48 -0
  102. package/evals/fixtures/trust-reconcile-exploits/waived-command-check.json +44 -0
  103. package/evals/fixtures/trust-reconcile-mixed-bundle/mixed-bundle.json +159 -0
  104. package/evals/fixtures/trust-reconcile-ws3/ws3-bundle.json +920 -0
  105. package/evals/integration/test_actor_identity.sh +254 -0
  106. package/evals/integration/test_builder_step_producers.sh +33 -23
  107. package/evals/integration/test_bundle_install.sh +22 -16
  108. package/evals/integration/test_bundle_lifecycle.sh +11 -11
  109. package/evals/integration/test_captured_fail_reconciliation.sh +50 -50
  110. package/evals/integration/test_checkpoint_signing.sh +43 -0
  111. package/evals/integration/test_claim_lookup.sh +4 -4
  112. package/evals/integration/test_codex_hook_resolution.sh +114 -0
  113. package/evals/integration/test_command_log_concurrency.sh +8 -8
  114. package/evals/integration/test_command_log_fork_classification.sh +3 -3
  115. package/evals/integration/test_command_log_integrity.sh +16 -16
  116. package/evals/integration/test_console_learning_projection.sh +1 -1
  117. package/evals/integration/test_dual_emit_flow_step.sh +145 -0
  118. package/evals/integration/test_enforcer_expects_driven.sh +12 -12
  119. package/evals/integration/test_evidence_capture_hook.sh +14 -13
  120. package/evals/integration/test_fixture_retirement_audit.sh +2 -2
  121. package/evals/integration/test_flow_agents_statusline.sh +2 -2
  122. package/evals/integration/test_flow_kit_install_git.sh +52 -0
  123. package/evals/integration/test_flow_kit_repository.sh +2 -0
  124. package/evals/integration/test_flowdef_session_activation.sh +6 -6
  125. package/evals/integration/test_flowdef_union_floor_regression.sh +429 -0
  126. package/evals/integration/test_gate_bypass_chain.sh +52 -40
  127. package/evals/integration/test_gate_lockdown.sh +97 -73
  128. package/evals/integration/test_gate_review_inquiry_records.sh +3 -3
  129. package/evals/integration/test_goal_fit_escape_hatch.sh +10 -10
  130. package/evals/integration/test_goal_fit_ghost_session.sh +104 -0
  131. package/evals/integration/test_goal_fit_hook.sh +32 -32
  132. package/evals/integration/test_goal_fit_rederive.sh +9 -9
  133. package/evals/integration/test_hook_category_behaviors.sh +103 -0
  134. package/evals/integration/test_hook_influence_cases.sh +1 -0
  135. package/evals/integration/test_install_merge.sh +262 -1
  136. package/evals/integration/test_kit_identity_trust.sh +6 -6
  137. package/evals/integration/test_liveness_conflict_injection.sh +587 -0
  138. package/evals/integration/test_liveness_heartbeat.sh +677 -0
  139. package/evals/integration/test_liveness_verdict.sh +394 -0
  140. package/evals/integration/test_local_flow_kit_install.sh +15 -0
  141. package/evals/integration/test_phase_map_and_gate_claim.sh +63 -11
  142. package/evals/integration/test_promote_gate.sh +178 -0
  143. package/evals/integration/test_publish_delivery.sh +2 -2
  144. package/evals/integration/test_pull_work_liveness_preflight.sh +386 -0
  145. package/evals/integration/test_pull_work_provider.sh +2 -2
  146. package/evals/integration/test_reconcile_soundness.sh +4 -4
  147. package/evals/integration/test_resolvefirststep_security.sh +22 -0
  148. package/evals/integration/test_runtime_adapter_activation.sh +87 -18
  149. package/evals/integration/test_session_resume_roundtrip.sh +147 -0
  150. package/evals/integration/test_sidecar_field_preservation.sh +249 -0
  151. package/evals/integration/test_trust_reconcile.sh +2 -2
  152. package/evals/integration/test_trust_reconcile_manifest.sh +79 -0
  153. package/evals/integration/test_trust_reconcile_mixed_bundle.sh +96 -0
  154. package/evals/integration/test_trust_reconcile_negatives.sh +151 -0
  155. package/evals/integration/test_usage_feedback_global.sh +5 -5
  156. package/evals/integration/test_validate_artifacts_portability.sh +60 -0
  157. package/evals/integration/test_verify_cli.sh +2 -2
  158. package/evals/integration/test_veritas_governance_kit.sh +117 -0
  159. package/evals/integration/test_workflow_artifact_cleanup_audit.sh +26 -1
  160. package/evals/integration/test_workflow_artifacts.sh +33 -0
  161. package/evals/integration/test_workflow_sidecar_writer.sh +723 -74
  162. package/evals/integration/test_workflow_steering_hook.sh +175 -5
  163. package/evals/lib/codex-provider.sh +1 -1
  164. package/evals/lib/node.sh +19 -1
  165. package/evals/run.sh +22 -0
  166. package/evals/static/test_decisions.sh +150 -0
  167. package/evals/static/test_flowdef_codeowners_coverage.sh +56 -0
  168. package/evals/static/test_package.sh +19 -10
  169. package/evals/static/test_universal_bundles.sh +48 -3
  170. package/evals/static/test_workflow_skills.sh +41 -8
  171. package/kits/builder/flows/build.flow.json +3 -74
  172. package/kits/builder/flows/publish-learn.flow.json +90 -0
  173. package/kits/builder/kit.json +11 -0
  174. package/kits/builder/skills/builder-shape/SKILL.md +1 -1
  175. package/kits/builder/skills/deliver/SKILL.md +13 -11
  176. package/kits/builder/skills/design-probe/SKILL.md +4 -4
  177. package/kits/builder/skills/evidence-gate/SKILL.md +26 -1
  178. package/kits/builder/skills/execute-plan/SKILL.md +2 -2
  179. package/kits/builder/skills/fix-bug/SKILL.md +2 -0
  180. package/kits/builder/skills/gate-review/SKILL.md +6 -6
  181. package/kits/builder/skills/idea-to-backlog/SKILL.md +1 -1
  182. package/kits/builder/skills/learning-review/SKILL.md +7 -7
  183. package/kits/builder/skills/pickup-probe/SKILL.md +5 -4
  184. package/kits/builder/skills/plan-work/SKILL.md +27 -5
  185. package/kits/builder/skills/pull-work/SKILL.md +80 -5
  186. package/kits/builder/skills/release-readiness/SKILL.md +4 -4
  187. package/kits/builder/skills/review-work/SKILL.md +24 -1
  188. package/kits/builder/skills/tdd-workflow/SKILL.md +2 -0
  189. package/kits/builder/skills/verify-work/SKILL.md +8 -1
  190. package/kits/catalog.json +6 -0
  191. package/kits/veritas-governance/adapter/readiness-to-trust-bundle.mjs +178 -0
  192. package/kits/veritas-governance/docs/README.md +75 -0
  193. package/kits/veritas-governance/fixtures/readiness/not-ready.readiness-report.json +4645 -0
  194. package/kits/veritas-governance/fixtures/readiness/ready.readiness-report.json +4403 -0
  195. package/kits/veritas-governance/flows/readiness-check.flow.json +35 -0
  196. package/kits/veritas-governance/kit.json +16 -0
  197. package/package.json +8 -4
  198. package/packaging/README.md +2 -2
  199. package/packaging/conformance/fixtures/config-protection--allow-read-state-json.json +20 -0
  200. package/packaging/conformance/fixtures/config-protection--block-write-state-json.json +20 -0
  201. package/packaging/conformance/fixtures/stop-goal-fit--block-bundle-disputed-claim.json +1 -1
  202. package/packaging/conformance/fixtures/stop-goal-fit--block-capture-contradicts-claimed-pass.json +1 -1
  203. package/packaging/manifest.json +9 -10
  204. package/schemas/decision-record.schema.json +109 -0
  205. package/schemas/workflow-evidence.schema.json +1 -1
  206. package/schemas/workflow-state.schema.json +5 -0
  207. package/scripts/README.md +8 -3
  208. package/scripts/check-content-boundary.cjs +1 -1
  209. package/scripts/check-decisions.cjs +356 -0
  210. package/scripts/ci/derive-claim-status.mjs +74 -0
  211. package/scripts/ci/trust-reconcile.js +436 -79
  212. package/scripts/git-status.sh +2 -2
  213. package/scripts/hooks/claude-telemetry-hook.js +37 -3
  214. package/scripts/hooks/codex-telemetry-hook.js +36 -2
  215. package/scripts/hooks/config-protection.js +102 -30
  216. package/scripts/hooks/evidence-capture.js +3 -3
  217. package/scripts/hooks/lib/actor-identity.js +368 -0
  218. package/scripts/hooks/lib/config-protection-remedies.js +69 -0
  219. package/scripts/hooks/lib/liveness-heartbeat.js +361 -0
  220. package/scripts/hooks/lib/liveness-policy.js +127 -0
  221. package/scripts/hooks/lib/liveness-read.js +105 -12
  222. package/scripts/hooks/lib/liveness-write.js +46 -0
  223. package/scripts/hooks/lib/local-artifact-paths.js +12 -6
  224. package/scripts/hooks/opencode-telemetry-hook.js +27 -1
  225. package/scripts/hooks/pi-telemetry-hook.js +27 -1
  226. package/scripts/hooks/stop-goal-fit.js +157 -26
  227. package/scripts/hooks/workflow-steering.js +77 -3
  228. package/scripts/install-codex-home.sh +138 -38
  229. package/scripts/statusline/flow-agents-statusline.js +2 -2
  230. package/src/cli/console-learning-projection.ts +3 -2
  231. package/src/cli/init.ts +101 -21
  232. package/src/cli/kit.ts +37 -6
  233. package/src/cli/public-api.test.mjs +58 -6
  234. package/src/cli/pull-work-provider.ts +1 -1
  235. package/src/cli/trust-bundle-policy-order.test.mjs +87 -0
  236. package/src/cli/usage-feedback.ts +3 -3
  237. package/src/cli/validate-hook-influence.ts +1 -0
  238. package/src/cli/validate-workflow-artifacts.ts +22 -6
  239. package/src/cli/veritas-readiness-adapter.test.mjs +267 -0
  240. package/src/cli/workflow-artifact-cleanup-audit.ts +35 -2
  241. package/src/cli/workflow-sidecar.ts +795 -71
  242. package/src/flow-kit/validate.ts +74 -1
  243. package/src/index.ts +6 -2
  244. package/src/lib/flow-resolver.ts +123 -55
  245. package/src/lib/local-artifact-root.ts +24 -5
  246. package/src/lib/workflow-learning-projection.ts +2 -2
  247. package/src/runtime-adapters.ts +61 -15
  248. package/src/tools/build-universal-bundles.ts +49 -16
  249. package/src/tools/generate-context-map.ts +10 -8
  250. package/src/tools/validate-source-tree.ts +23 -1
@@ -0,0 +1,263 @@
1
+ # Decision Registry Contract
2
+
3
+ Normative contract for the topic-keyed decision registry. This is the source of
4
+ truth for how NEW decisions are recorded in a Kontour repository. Numbered ADRs
5
+ under `docs/adr/` are frozen history and are never written for new decisions
6
+ (see [Relationship to ADRs](#relationship-to-adrs-and-grill-with-docs)).
7
+
8
+ Machine-checkable structure lives in `schemas/decision-record.schema.json`; the
9
+ validator/generator is `scripts/check-decisions.cjs`, exposed as
10
+ `npm run check:decisions` and `npm run gen:decisions-index` and wired into the
11
+ required `source-and-static` CI lane.
12
+
13
+ ## Why topic-keyed living records
14
+
15
+ Numbered ADRs accumulate three failure modes at multi-contributor, multi-repo
16
+ scale: contradictions (a new ADR appends a conflicting decision instead of
17
+ replacing the old one), bloat (derivation context is inlined alongside the
18
+ decision), and numbering collisions (two contributors both grab `0021-`). The
19
+ registry removes all three by construction:
20
+
21
+ - **One file per decision subject**, keyed by a vocabulary noun, not a number.
22
+ - **Supersession is an edit**, so the current answer is always the only answer.
23
+ - **Derivation context is linked, not inlined**, so files stay lean.
24
+
25
+ ## File location and shape
26
+
27
+ - Each decision lives at `docs/decisions/<topic-slug>.md`.
28
+ - Exactly **one file per decision SUBJECT**. If two questions have the same
29
+ subject, they share a file; if a file is answering two subjects, split it.
30
+ - A generated index lives at `docs/decisions/index.md` (see [Index](#index)).
31
+ - The file holds ONLY the current decision plus lean rationale. It does not
32
+ inline transcripts, exploration, meeting notes, or superseded prose.
33
+
34
+ A topic file is YAML frontmatter followed by a short Markdown body:
35
+
36
+ ```markdown
37
+ ---
38
+ status: current
39
+ subject: Decision records
40
+ decided: 2026-07-03
41
+ evidence:
42
+ - kind: issue
43
+ ref: https://github.com/kontourai/flow-agents/issues/310
44
+ - kind: session-archive
45
+ ref: .kontourai/flow-agents/decision-registry-shape/decision-registry-shape--idea-to-backlog.md
46
+ ---
47
+
48
+ # Decision records
49
+
50
+ The current answer, plus lean rationale. Derivation context is linked via
51
+ `evidence[]`, never pasted here.
52
+ ```
53
+
54
+ ## Slug rules: vocabulary is the namespace
55
+
56
+ - Slugs are **nouns from the repository's CONTEXT.md domain vocabulary**. The
57
+ ubiquitous language is the topic namespace; topic identity is downstream of it.
58
+ - Slugs are lowercase kebab-case: `^[a-z0-9]+(-[a-z0-9]+)*$`, matching a
59
+ glossary term (e.g. the glossary term "Decision Records" ->
60
+ `decision-records.md`).
61
+ - **If the subject term is absent from CONTEXT.md, add it to CONTEXT.md first**,
62
+ then create the topic file. This keeps slugs stable and collision-free: two
63
+ contributors deciding the same subject land on the same slug rather than
64
+ competing for the next number.
65
+
66
+ ## Frontmatter fields
67
+
68
+ Validated by `schemas/decision-record.schema.json`:
69
+
70
+ | Field | Required | Meaning |
71
+ | --- | --- | --- |
72
+ | `status` | yes | `current` \| `superseded` \| `merged` \| `needs-decision` (see [Status](#status-values)). |
73
+ | `subject` | yes | The decision subject, a CONTEXT.md vocabulary noun phrase. |
74
+ | `decided` | yes | ISO date `YYYY-MM-DD` the current decision was ratified. |
75
+ | `evidence[]` | yes | `{kind, ref}` links to durable provenance. Never a secret. |
76
+ | `supersedes[]` | no | Topic slugs whose subjects this file absorbed. |
77
+ | `superseded_by` | when superseded | The slug that now carries the answer. |
78
+ | `merged_into` | when merged | The slug this subject was folded into. |
79
+
80
+ ### Status values
81
+
82
+ - **`current`** — this file holds the live answer for its subject. Must not
83
+ carry `superseded_by` or `merged_into`.
84
+ - **`superseded`** — a tombstone: the subject moved to a different topic slug
85
+ (renamed or split). Requires `superseded_by`.
86
+ - **`merged`** — a tombstone: the subject was folded into another topic. Requires
87
+ `merged_into`.
88
+ - **`needs-decision`** — a stub that names an open subject with no ratified answer
89
+ yet. It carries provenance `evidence[]` (e.g. the frozen ADR whose subject is
90
+ still open) but no live decision body. This value exists so ADR freeze tooling
91
+ (issue #314) can record that a frozen ADR's subject still needs a living
92
+ decision without inventing an answer. A `needs-decision` stub is not a
93
+ tombstone and must not carry `superseded_by`/`merged_into`.
94
+
95
+ ### Evidence refs
96
+
97
+ Derivation context is LINKED, never inlined. Each `evidence[]` entry is
98
+ `{kind, ref}` where `kind` is one of `issue`, `pr`, `commit`, `session-archive`,
99
+ `adr`, `doc`, `url`:
100
+
101
+ - **`session-archive`** — a path to an archived session artifact (under
102
+ `.kontourai/`) promoted at retirement. Grilling/probe transcripts retire into
103
+ the session archive and are linked here as decision provenance.
104
+ - **`adr`** — a frozen numbered ADR under `docs/adr/` that is provenance for this
105
+ decision.
106
+ - **`issue`/`pr`/`commit`** — GitHub references (number, URL, or SHA).
107
+ - **`doc`/`url`** — a repository document path or external permalink.
108
+
109
+ `ref` values must never contain secret-shaped material (AWS access keys, GitHub
110
+ tokens, private-key blocks, JWTs, or `secret:`/`token:`-style literals). The
111
+ validator refuses them; link durable provenance, never a credential.
112
+
113
+ ## Supersession by edit
114
+
115
+ The normal way a decision changes is: **edit the topic file in place.** Update
116
+ the body to the new decision, bump `decided`, and add an `evidence[]` ref to the
117
+ PR/issue that changed it. There is no second file, no appendix, and no
118
+ contradiction — the file always states exactly one current answer.
119
+
120
+ Example — the pre-edit file:
121
+
122
+ ```markdown
123
+ ---
124
+ status: current
125
+ subject: Artifact retention window
126
+ decided: 2026-04-01
127
+ evidence:
128
+ - kind: pr
129
+ ref: https://github.com/kontourai/flow-agents/pull/120
130
+ ---
131
+
132
+ # Artifact retention window
133
+
134
+ Runtime artifacts are retained for 30 days, then archived.
135
+ ```
136
+
137
+ After a later decision to shorten the window, the SAME file becomes:
138
+
139
+ ```markdown
140
+ ---
141
+ status: current
142
+ subject: Artifact retention window
143
+ decided: 2026-07-01
144
+ evidence:
145
+ - kind: pr
146
+ ref: https://github.com/kontourai/flow-agents/pull/120
147
+ - kind: pr
148
+ ref: https://github.com/kontourai/flow-agents/pull/305
149
+ ---
150
+
151
+ # Artifact retention window
152
+
153
+ Runtime artifacts are retained for 14 days, then archived.
154
+ ```
155
+
156
+ The old answer is gone from the head; its provenance survives in the linked PRs.
157
+
158
+ ## Tombstones: when a topic moves or merges
159
+
160
+ Editing covers a decision changing. The rarer case is a SUBJECT moving to a
161
+ different slug. Then the old file becomes a tombstone so inbound links and
162
+ retrieval still resolve.
163
+
164
+ ### `superseded_by` — the subject moved to another slug
165
+
166
+ Use when a subject is renamed or split and its answer now lives under a different
167
+ slug. The old file:
168
+
169
+ ```markdown
170
+ ---
171
+ status: superseded
172
+ subject: Artifact retention window
173
+ decided: 2026-07-02
174
+ superseded_by: artifact-lifecycle
175
+ evidence:
176
+ - kind: pr
177
+ ref: https://github.com/kontourai/flow-agents/pull/330
178
+ ---
179
+
180
+ # Artifact retention window
181
+
182
+ Superseded. The current decision for this subject lives in
183
+ [artifact-lifecycle](./artifact-lifecycle.md).
184
+ ```
185
+
186
+ ### `merged_into` — the subject folded into an existing topic
187
+
188
+ Use when a subject is absorbed by another existing topic. The absorbed file:
189
+
190
+ ```markdown
191
+ ---
192
+ status: merged
193
+ subject: Artifact retention window
194
+ decided: 2026-07-02
195
+ merged_into: artifact-lifecycle
196
+ evidence:
197
+ - kind: pr
198
+ ref: https://github.com/kontourai/flow-agents/pull/330
199
+ ---
200
+
201
+ # Artifact retention window
202
+
203
+ Merged into [artifact-lifecycle](./artifact-lifecycle.md).
204
+ ```
205
+
206
+ The surviving file may record what it absorbed with `supersedes: [artifact-retention-window]`.
207
+
208
+ Both tombstone forms require the target slug to exist (a validator error
209
+ otherwise) and must not point at their own slug.
210
+
211
+ ## Retrieval-at-write
212
+
213
+ Before recording a decision, **consult `docs/decisions/index.md`** (the
214
+ always-loaded slug + one-liner index) and decide **revise-vs-create**:
215
+
216
+ 1. If an existing topic covers the subject, **revise that file** (edit in place,
217
+ or tombstone + move if the subject itself is changing identity).
218
+ 2. If no topic covers it, confirm the subject noun exists in CONTEXT.md (add it
219
+ if absent), then **create** `docs/decisions/<slug>.md`.
220
+
221
+ This retrieval-at-write step, plus a health check at rest (the validator + index
222
+ freshness in CI), is sufficient at this cardinality; no embeddings or semantic
223
+ topic matching are required.
224
+
225
+ ## Index
226
+
227
+ `docs/decisions/index.md` is generated by `npm run gen:decisions-index`
228
+ (`scripts/check-decisions.cjs gen-index`). It is deterministic and idempotent: a
229
+ second run with no topic change is diff-clean. It lists each topic slug, its
230
+ status, and a one-line summary (the `subject`, falling back to the first body
231
+ line). Do not edit it by hand. `npm run check:decisions` fails if the index is
232
+ missing or stale, so CI catches an out-of-date index.
233
+
234
+ The index is referenced from `CONTEXT.md` so retrieval-at-write always has a
235
+ cheap, loaded pointer into the registry.
236
+
237
+ ## Validation
238
+
239
+ `npm run check:decisions` (wired into the required `source-and-static` CI lane)
240
+ exits nonzero on any of:
241
+
242
+ - invalid frontmatter (missing `status`/`subject`/`decided`/`evidence`);
243
+ - unknown `status`;
244
+ - a secret-shaped `evidence[].ref`;
245
+ - a `superseded_by`/`merged_into`/`supersedes` slug that points at a missing
246
+ topic file;
247
+ - a status/relationship mismatch (e.g. `current` carrying a tombstone field, or
248
+ `superseded` without `superseded_by`);
249
+ - a stale or missing `docs/decisions/index.md`.
250
+
251
+ ## Relationship to ADRs and grill-with-docs
252
+
253
+ - **CONTEXT.md is the only external compatibility surface.** Grill-with-docs
254
+ interop reads the domain vocabulary from CONTEXT.md; the registry keys its
255
+ slugs off that same vocabulary. We inherit the grill-with-docs behavior, not
256
+ the numbered-ADR file format.
257
+ - **Numbered ADRs (`docs/adr/NNNN-*.md`) are frozen history.** They are never
258
+ written for new decisions and are never converted into topic files. Existing
259
+ ADRs are frozen-and-indexed by separate tooling (issue #314); a topic file may
260
+ cite a frozen ADR via an `adr` evidence ref as provenance.
261
+
262
+ The pilot record self-hosting this contract is
263
+ [docs/decisions/decision-records.md](../../docs/decisions/decision-records.md).
@@ -59,7 +59,7 @@ After CI passes and the work is merged, released, or otherwise accepted:
59
59
  - [ ] working artifacts archived or linked
60
60
  - [ ] long-lived docs updated with why and how the feature was built
61
61
  - [ ] durable docs link back to the provider record, archived plan, or session artifact when useful
62
- - [ ] local `.flow-agents/` runtime artifacts remain untracked, and durable outcomes are promoted before merge to `main`
62
+ - [ ] local `.kontourai/flow-agents/` runtime artifacts remain untracked, and durable outcomes are promoted before merge to `main`
63
63
  - [ ] follow-up issues or learning-review items created for deferred work
64
64
  - [ ] **workspace cleaned up after a confirmed merge**: the merge is verified from the provider's own merge record (a merge commit / `mergedAt`), not a green check or a command exit code; then the isolated worktree is removed and the now-merged branch is deleted locally and on the remote, honoring the `worktree_lifecycle` (`retain_until: pr_merged`) recorded at selection. Never delete a branch or worktree before the merge is confirmed. A delivery is not complete while it leaves a stale worktree or merged branch behind.
65
65
 
@@ -23,7 +23,7 @@ Also create or update structured sidecars beside the Markdown artifacts:
23
23
  Use the sidecar writer when available:
24
24
 
25
25
  ```bash
26
- npm run workflow:sidecar -- init-plan .flow-agents/<slug>/<slug>--deliver.md \
26
+ npm run workflow:sidecar -- init-plan .kontourai/flow-agents/<slug>/<slug>--deliver.md \
27
27
  --source-request "<original request>" \
28
28
  --summary "<planning summary>" \
29
29
  --next-action "<next execution step>"
@@ -79,6 +79,7 @@ The plan body must include:
79
79
  - Preserve stable requirement and acceptance ids from upstream backlog issues when they exist; otherwise create stable ids in the plan before execution.
80
80
  - Every implementation task must map back to the acceptance criteria it supports.
81
81
  - Acceptance criteria for implementation behavior must name expected command/test evidence and expected source evidence. Source evidence means structured refs with `kind`, `url`, `file`, `line_start`, `line_end`, and `excerpt` where applicable; use immutable GitHub blob permalinks pinned to a commit SHA when provider URLs are available, and local file/line refs only as pre-publish fallback.
82
+ - A `kind: "command"` evidence ref's `excerpt`/`command` field must be a **literally runnable shell command** (for example `npm test`, `bash evals/run.sh static`, `./scripts/check.sh`), not a prose description of a manual verification step. The goal-fit backstop and the CI reconciler treat this text as a command: a prose "excerpt" is classified `malformed-evidence` (it is never spawned as `bash -lc "<a sentence>"`, and it is not conflated with a caught false-completion — see `scripts/hooks/stop-goal-fit.js`). When a verification is not automatable — a manual review, a provider/CI observation, a document citation — use `kind: "artifact"`/`"external"` (or record the criterion as `not_verified`/`accepted_gap`) instead of fabricating a `kind: "command"` ref. This keeps the contract and the enforcing code in agreement (ADR 0020).
82
83
  - Plans should state that provider, PR, issue, closure, and final acceptance comments need an `Acceptance Evidence` table with columns `AC id`, `Status`, `Command/Test Evidence`, `Source Evidence / Permalinks`, and `Gaps`.
83
84
  - The Definition Of Done is the stop condition, not a decorative section.
84
85
  - If the goal is exploratory or uncertain, define what the user should be able to take away from the work.
@@ -78,10 +78,12 @@ If a perspective is required but cannot be reviewed, record it as `not_verified`
78
78
 
79
79
  When review runs as part of a workflow, write or update the configured critique artifact/sink. For the current local sidecar materialization, write or update `critique.json` beside the workflow artifacts using `schemas/workflow-critique.schema.json`.
80
80
 
81
+ Reviewers write critique **through** `record-critique` (or `import-critique` for a Markdown report), directly or via the orchestrating skill — never by hand-authoring `critique.json`, `evidence.json`, or `acceptance.json`. Those bespoke sidecars were retired as the source of truth by ADR 0010 Phase 4c; `trust.bundle` is the sole verification artifact and only the sidecar writer performs the evidence classification the CI trust anchor depends on (ADR 0020). `config-protection.js` blocks direct tool writes to these gate files by design.
82
+
81
83
  Prefer the sidecar writer when available:
82
84
 
83
85
  ```bash
84
- npm run workflow:sidecar -- record-critique .flow-agents/<slug> \
86
+ npm run workflow:sidecar -- record-critique .kontourai/flow-agents/<slug> \
85
87
  --id code-review \
86
88
  --reviewer tool-code-reviewer \
87
89
  --verdict pass \
@@ -91,8 +93,8 @@ npm run workflow:sidecar -- record-critique .flow-agents/<slug> \
91
93
  For Markdown reviewer reports, import them when possible:
92
94
 
93
95
  ```bash
94
- npm run workflow:sidecar -- import-critique .flow-agents/<slug> \
95
- .flow-agents/<slug>/<slug>--code-review.md \
96
+ npm run workflow:sidecar -- import-critique .kontourai/flow-agents/<slug> \
97
+ .kontourai/flow-agents/<slug>/<slug>--code-review.md \
96
98
  --reviewer tool-code-reviewer
97
99
  ```
98
100
 
@@ -14,6 +14,14 @@ Verification is report-only. It proves whether the implementation satisfies the
14
14
 
15
15
  Verifiers and reviewers do not modify source code. They may run commands, inspect files, take screenshots, and write verification artifacts. They must not apply fixes, formatting, lint autofixes, or patches.
16
16
 
17
+ ## Writing Evidence Through The Sidecar Writer
18
+
19
+ Verifiers write evidence and acceptance status **through** `record-evidence` (directly, or via the orchestrating skill), never by hand-authoring `evidence.json`, `acceptance.json`, or `trust.bundle`. Those bespoke sidecars were retired as the source of truth by ADR 0010 Phase 4c; the `trust.bundle` is the sole verification artifact, and only the sidecar writer performs the evidence classification (`evidenceType`/`method` derivation and manifest reconciliation) the CI trust anchor depends on (ADR 0020). `config-protection.js` blocks direct tool writes to these gate files by design. If the sidecar writer is unavailable, record the exact gap instead of writing the files by hand.
20
+
21
+ ## Mutation Testing Runs In A Scratch Copy
22
+
23
+ Mutation-testing tools (Stryker or equivalent) **must** run against a scratch/throwaway copy of the working tree, never the live working tree. They deliberately introduce defects to measure test-suite sensitivity; running them in place risks leaving mutated source, corrupting the checkout, or tripping the gate/anchor on injected failures. Copy the tree to a temporary directory (or a git worktree/clone) and run the mutation tool there; discard it afterward.
24
+
17
25
  ## Verification Phases
18
26
 
19
27
  Attempt relevant phases and record evidence:
@@ -77,7 +85,7 @@ When verification runs as part of a workflow, write or update `evidence.json` be
77
85
  Use the sidecar writer when available:
78
86
 
79
87
  ```bash
80
- npm run workflow:sidecar -- record-evidence .flow-agents/<slug> \
88
+ npm run workflow:sidecar -- record-evidence .kontourai/flow-agents/<slug> \
81
89
  --verdict pass \
82
90
  --check-json '{"id":"tests","kind":"test","status":"pass","summary":"Relevant checks passed."}'
83
91
  ```
@@ -176,7 +176,7 @@ GitHub is the first concrete mapping for this contract, not the generic vocabula
176
176
  | `related_links` | Issue links, closing references, discussions, docs, and cross-references. |
177
177
  | `source_provider` | `github`, repository owner/name, issue number, node id, and issue URL. |
178
178
  | `pr_links` | Linked pull requests, closing PRs, branches, or manually referenced PR URLs. |
179
- | `artifact_refs` | `.flow-agents/<slug>/` artifacts, plan/review/evidence links, and promoted docs referenced from the issue or workflow. |
179
+ | `artifact_refs` | `.kontourai/flow-agents/<slug>/` artifacts, plan/review/evidence links, and promoted docs referenced from the issue or workflow. |
180
180
 
181
181
  ### GitHub Projects as `BoardProvider`
182
182
 
@@ -26,7 +26,7 @@ Every worker delegation must target the exact `tool-worker` role. Omitting the r
26
26
  3. **Context** — relevant code patterns, conventions, types/interfaces it needs to follow
27
27
  4. **Working directory** — if different from current
28
28
 
29
- tool-worker manages its own TODO files in `.flow-agents/<slug>/` and tracks `modified_files` to detect conflicts with other parallel workers. It will end its turn immediately if instructions are insufficient rather than guessing.
29
+ tool-worker manages its own TODO files in `.kontourai/flow-agents/<slug>/` and tracks `modified_files` to detect conflicts with other parallel workers. It will end its turn immediately if instructions are insufficient rather than guessing.
30
30
 
31
31
  ## Conflict Avoidance
32
32
 
@@ -6,7 +6,7 @@ This repo runs three active gates implemented as Claude Code hook scripts. Every
6
6
 
7
7
  **goal-fit/Stop** (`scripts/hooks/stop-goal-fit.js`): fires on the agent Stop event (before the agent final-answers as complete). The gate reads `.flow-agents/` to find the most recent active workflow artifact and checks for: an incomplete Definition Of Done section, an incomplete or absent Goal Fit Gate section, open items in Final Acceptance when status is delivered, failing or NOT_VERIFIED checks in `evidence.json`, open sidecar issues (state.json showing non-done status, critique.json with open findings), and evidence cross-reference failures (the capture log in `command-log.jsonl` contradicting a claimed-pass command check in `evidence.json`). In `block` mode the gate exits 2, which prevents the Stop. The canonical engine default is `warn` (exit 0 with guidance on stderr); shipped runtime configs such as Claude Code at L2 set `block` so the installed product enforces. The gate releases automatically after a configurable number of consecutive identical blocks (default 3) to surface the situation to the human rather than looping forever.
8
8
 
9
- **evidence-capture** (`scripts/hooks/evidence-capture.js`): fires as a postToolUse hook on every shell or command tool execution. It deterministically records the actual command result — not the model's narration about it — to `.flow-agents/<slug>/command-log.jsonl` as an append-only JSONL log. Each record captures the command string, observed result (pass/fail), exit code when available, and a timestamp. Non-blocking; always exits 0. Fail-open: a capture failure never blocks the agent or corrupts the log.
9
+ **evidence-capture** (`scripts/hooks/evidence-capture.js`): fires as a postToolUse hook on every shell or command tool execution. It deterministically records the actual command result — not the model's narration about it — to `.kontourai/flow-agents/<slug>/command-log.jsonl` as an append-only JSONL log. Each record captures the command string, observed result (pass/fail), exit code when available, and a timestamp. Non-blocking; always exits 0. Fail-open: a capture failure never blocks the agent or corrupts the log.
10
10
 
11
11
  **reground** (`scripts/hooks/workflow-steering.js`): fires on `SessionStart` and `UserPromptSubmit` to re-inject the active workflow phase, goal, and next-step from `state.json` into the agent turn. This is what keeps an in-flight goal alive through context compaction and session resume without requiring the agent to voluntarily re-read sidecars. The hook also fires after subagent calls (use_subagent) to inject phase-transition reminders tailored to the completing subagent (planner, worker, reviewer, verifier). Non-blocking; always exits 0.
12
12
 
@@ -28,12 +28,12 @@ Do not conflate "inconvenient" with "false-block." If the gap named by the gate
28
28
 
29
29
  ## Missed-Block Diagnostic
30
30
 
31
- When a gate does not fire and you suspect it should have, the gate is almost never defective. The goal-fit/Stop gate only knows what the flow recorded in `.flow-agents/<slug>/`. It cross-references `evidence.json` command checks against `command-log.jsonl`. A suspected missed block nearly always means the flow did not record the evidence, not that the gate failed to evaluate it.
31
+ When a gate does not fire and you suspect it should have, the gate is almost never defective. The goal-fit/Stop gate only knows what the flow recorded in `.kontourai/flow-agents/<slug>/`. It cross-references `evidence.json` command checks against `command-log.jsonl`. A suspected missed block nearly always means the flow did not record the evidence, not that the gate failed to evaluate it.
32
32
 
33
33
  Start diagnosis here:
34
34
 
35
- 1. Check `.flow-agents/<slug>/command-log.jsonl` — was the relevant command captured? If the evidence-capture hook was not active when the command ran (for example, the session predated the hook or the artifact directory was not yet resolved), the log will have no entry for that command and the Stop gate will see no contradiction to raise.
36
- 2. Check `.flow-agents/<slug>/evidence.json` — does the relevant check exist with kind `command` and status `pass`? The gate only cross-references checks that are explicitly recorded in `evidence.json` as command-kind claimed passes. If the check was never written there, the gate has nothing to cross-reference.
35
+ 1. Check `.kontourai/flow-agents/<slug>/command-log.jsonl` — was the relevant command captured? If the evidence-capture hook was not active when the command ran (for example, the session predated the hook or the artifact directory was not yet resolved), the log will have no entry for that command and the Stop gate will see no contradiction to raise.
36
+ 2. Check `.kontourai/flow-agents/<slug>/evidence.json` — does the relevant check exist with kind `command` and status `pass`? The gate only cross-references checks that are explicitly recorded in `evidence.json` as command-kind claimed passes. If the check was never written there, the gate has nothing to cross-reference.
37
37
  3. If both files are present and consistent but the block still did not fire, verify that the artifact directory the gate found is the one you expect (`state.json` newest-mtime resolution) and that the workflow artifact has the correct type and status to be treated as active.
38
38
 
39
39
  A gate defect is a last resort diagnosis, not a first assumption.
@@ -32,11 +32,11 @@ if [ "$WORKTREE_COUNT" -gt 1 ]; then
32
32
  echo "=== Active Worktrees ($WORKTREE_COUNT) ==="
33
33
  git worktree list
34
34
  echo ""
35
- echo "⚠️ Multiple worktrees active — check .flow-agents/ for in-progress tasks before modifying shared files"
35
+ echo "⚠️ Multiple worktrees active — check .kontourai/flow-agents/ for in-progress tasks before modifying shared files"
36
36
  fi
37
37
 
38
38
  # List existing TODOs for awareness
39
- TODO_DIR=".flow-agents"
39
+ TODO_DIR=".kontourai/flow-agents"
40
40
  if [ -d "$TODO_DIR" ]; then
41
41
  TODO_COUNT=$(find "$TODO_DIR" -name "*.md" 2>/dev/null | wc -l | tr -d ' ')
42
42
  if [ "$TODO_COUNT" -gt 0 ]; then