@kontourai/flow-agents 2.3.0 → 3.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 (301) hide show
  1. package/.github/CODEOWNERS +16 -0
  2. package/.github/workflows/ci.yml +44 -0
  3. package/.github/workflows/trust-reconcile.yml +62 -4
  4. package/AGENTS.md +4 -4
  5. package/CHANGELOG.md +62 -0
  6. package/CONTEXT.md +35 -0
  7. package/README.md +9 -3
  8. package/agents/dev.json +1 -1
  9. package/agents/tool-code-reviewer.json +1 -1
  10. package/agents/tool-planner.json +3 -3
  11. package/agents/tool-verifier.json +3 -3
  12. package/build/src/cli/assignment-provider.d.ts +1 -0
  13. package/build/src/cli/assignment-provider.js +748 -0
  14. package/build/src/cli/console-learning-projection.js +3 -2
  15. package/build/src/cli/effective-assignment-provider-settings.d.ts +1 -0
  16. package/build/src/cli/effective-assignment-provider-settings.js +125 -0
  17. package/build/src/cli/init.js +104 -21
  18. package/build/src/cli/kit.js +37 -6
  19. package/build/src/cli/pull-work-provider.js +1 -1
  20. package/build/src/cli/usage-feedback.js +3 -3
  21. package/build/src/cli/validate-hook-influence.js +1 -0
  22. package/build/src/cli/validate-workflow-artifacts.js +27 -7
  23. package/build/src/cli/workflow-artifact-cleanup-audit.js +36 -2
  24. package/build/src/cli/workflow-sidecar.d.ts +14 -7
  25. package/build/src/cli/workflow-sidecar.js +938 -168
  26. package/build/src/cli.js +6 -0
  27. package/build/src/flow-kit/validate.d.ts +23 -0
  28. package/build/src/flow-kit/validate.js +67 -1
  29. package/build/src/index.d.ts +1 -1
  30. package/build/src/index.js +1 -1
  31. package/build/src/lib/flow-resolver.d.ts +6 -4
  32. package/build/src/lib/flow-resolver.js +125 -58
  33. package/build/src/lib/local-artifact-root.d.ts +14 -2
  34. package/build/src/lib/local-artifact-root.js +22 -5
  35. package/build/src/lib/workflow-learning-projection.js +2 -2
  36. package/build/src/runtime-adapters.d.ts +12 -0
  37. package/build/src/runtime-adapters.js +56 -16
  38. package/build/src/tools/build-universal-bundles.js +49 -16
  39. package/build/src/tools/generate-context-map.js +10 -8
  40. package/build/src/tools/validate-source-tree.js +24 -1
  41. package/console.telemetry.json +22 -0
  42. package/context/contracts/artifact-contract.md +40 -7
  43. package/context/contracts/assignment-provider-contract.md +239 -0
  44. package/context/contracts/builder-kit-workflow-state-contract.md +5 -2
  45. package/context/contracts/decision-registry-contract.md +265 -0
  46. package/context/contracts/delivery-contract.md +3 -1
  47. package/context/contracts/execution-contract.md +25 -0
  48. package/context/contracts/governance-adapter-contract.md +2 -0
  49. package/context/contracts/knowledge-store-contract.md +197 -0
  50. package/context/contracts/planning-contract.md +4 -1
  51. package/context/contracts/review-contract.md +7 -3
  52. package/context/contracts/sandbox-policy.md +2 -0
  53. package/context/contracts/standing-directives.md +13 -0
  54. package/context/contracts/verification-contract.md +11 -1
  55. package/context/contracts/work-item-contract.md +3 -1
  56. package/context/deferred/parallelization.md +1 -1
  57. package/context/gate-awareness.md +4 -4
  58. package/context/scripts/git-status.sh +2 -2
  59. package/context/scripts/hooks/config-protection.js +502 -2
  60. package/context/scripts/hooks/lib/config-protection-remedies.js +69 -0
  61. package/context/scripts/hooks/run-hook.js +14 -1
  62. package/context/scripts/hooks/stop-goal-fit.js +1140 -99
  63. package/context/scripts/hooks/workflow-steering.js +212 -6
  64. package/context/settings/assignment-provider-settings.json +33 -0
  65. package/docs/adr/0007-flow-skill-kit-tool-boundary.md +2 -0
  66. package/docs/adr/0015-flow-flow-agents-boundary-reconciliation.md +35 -0
  67. package/docs/adr/0019-kit-dependency-ownership.md +62 -0
  68. package/docs/adr/0020-trust-reconcile-manifest-and-claim-classification.md +290 -0
  69. package/docs/adr/0021-assignment-leases-and-stale-claim-takeover.md +221 -0
  70. package/docs/adr/0022-fail-closed-delivery-reconciliation-with-governed-exemptions.md +463 -0
  71. package/docs/agent-system-guidebook.md +3 -3
  72. package/docs/agent-usage-feedback-loop.md +6 -6
  73. package/docs/context-map.md +10 -7
  74. package/docs/decisions/decision-records.md +57 -0
  75. package/docs/decisions/index.md +17 -0
  76. package/docs/decisions/knowledge-store-provider.md +51 -0
  77. package/docs/decisions/model-routing.md +63 -0
  78. package/docs/decisions/promotion-gate.md +52 -0
  79. package/docs/decisions/standing-directives.md +66 -0
  80. package/docs/developer-architecture.md +1 -1
  81. package/docs/fixture-ownership.md +4 -0
  82. package/docs/flow-kit-repository-contract.md +5 -5
  83. package/docs/getting-started.md +12 -2
  84. package/docs/integrations/harness-install.md +2 -1
  85. package/docs/kit-authoring-guide.md +64 -5
  86. package/docs/knowledge-kit.md +5 -1
  87. package/docs/learnings/2026-07-improvement-program.md +203 -0
  88. package/docs/migrations.md +6 -5
  89. package/docs/north-star.md +2 -2
  90. package/docs/operating-layers.md +4 -3
  91. package/docs/repository-structure.md +5 -5
  92. package/docs/skills-map.md +8 -8
  93. package/docs/spec/runtime-hook-surface.md +19 -15
  94. package/docs/spikes/graph-provider-2026-07.md +155 -0
  95. package/docs/standards-register.md +7 -7
  96. package/docs/trust-anchor-adoption.md +105 -4
  97. package/docs/work-item-adapters.md +1 -1
  98. package/docs/workflow-artifact-lifecycle.md +72 -9
  99. package/docs/workflow-eval-strategy.md +3 -3
  100. package/docs/workflow-shared-contracts.md +3 -2
  101. package/docs/workflow-usage-guide.md +260 -21
  102. package/evals/acceptance/DEMO-false-completion.md +20 -11
  103. package/evals/acceptance/prove-capture-teeth-declared.sh +15 -15
  104. package/evals/acceptance/prove-capture-teeth.sh +11 -11
  105. package/evals/acceptance/test_kiro_harness.sh +1 -1
  106. package/evals/ci/antigaming-suite.sh +5 -0
  107. package/evals/ci/run-baseline.sh +71 -1
  108. package/evals/fixtures/assignment-provider/actor-a.json +6 -0
  109. package/evals/fixtures/assignment-provider/actor-b.json +6 -0
  110. package/evals/fixtures/assignment-provider/github-issue-claimed.json +27 -0
  111. package/evals/fixtures/assignment-provider/github-issue-unassigned.json +7 -0
  112. package/evals/fixtures/assignment-provider/liveness-fresh.json +9 -0
  113. package/evals/fixtures/assignment-provider/liveness-stale.json +9 -0
  114. package/evals/fixtures/flow-kit-repository/invalid-bad-dependency/flows/review.flow.json +26 -0
  115. package/evals/fixtures/flow-kit-repository/invalid-bad-dependency/kit.json +13 -0
  116. package/evals/fixtures/flow-kit-repository/valid-with-dependency/flows/review.flow.json +26 -0
  117. package/evals/fixtures/flow-kit-repository/valid-with-dependency/kit.json +13 -0
  118. package/evals/fixtures/hook-influence/cases.json +32 -0
  119. package/evals/fixtures/pull-work-provider/github-issues.json +6 -6
  120. package/evals/fixtures/trust-reconcile-exploits/fabricated-attestation.json +59 -0
  121. package/evals/fixtures/trust-reconcile-exploits/no-label-bypass.json +36 -0
  122. package/evals/fixtures/trust-reconcile-exploits/skip-assumed-bypass.json +59 -0
  123. package/evals/fixtures/trust-reconcile-exploits/status-misassertion.json +48 -0
  124. package/evals/fixtures/trust-reconcile-exploits/waived-command-check.json +44 -0
  125. package/evals/fixtures/trust-reconcile-mixed-bundle/mixed-bundle.json +159 -0
  126. package/evals/fixtures/trust-reconcile-ws3/ws3-bundle.json +920 -0
  127. package/evals/integration/test_actor_identity.sh +254 -0
  128. package/evals/integration/test_assignment_provider_github.sh +318 -0
  129. package/evals/integration/test_assignment_provider_local_file.sh +222 -0
  130. package/evals/integration/test_builder_step_producers.sh +33 -23
  131. package/evals/integration/test_bundle_install.sh +22 -16
  132. package/evals/integration/test_bundle_lifecycle.sh +11 -11
  133. package/evals/integration/test_captured_fail_reconciliation.sh +50 -50
  134. package/evals/integration/test_checkpoint_signing.sh +43 -0
  135. package/evals/integration/test_claim_lookup.sh +4 -4
  136. package/evals/integration/test_codex_hook_resolution.sh +114 -0
  137. package/evals/integration/test_command_log_concurrency.sh +8 -8
  138. package/evals/integration/test_command_log_fork_classification.sh +3 -3
  139. package/evals/integration/test_command_log_integrity.sh +16 -16
  140. package/evals/integration/test_console_learning_projection.sh +1 -1
  141. package/evals/integration/test_critique_supersession_roundtrip.sh +182 -0
  142. package/evals/integration/test_dual_emit_flow_step.sh +145 -0
  143. package/evals/integration/test_enforcer_expects_driven.sh +12 -12
  144. package/evals/integration/test_evidence_capture_hook.sh +14 -13
  145. package/evals/integration/test_fixture_retirement_audit.sh +2 -2
  146. package/evals/integration/test_flow_agents_statusline.sh +2 -2
  147. package/evals/integration/test_flow_kit_install_git.sh +52 -0
  148. package/evals/integration/test_flow_kit_repository.sh +2 -0
  149. package/evals/integration/test_flowdef_session_activation.sh +6 -6
  150. package/evals/integration/test_flowdef_union_floor_regression.sh +429 -0
  151. package/evals/integration/test_gate_bypass_chain.sh +52 -40
  152. package/evals/integration/test_gate_lockdown.sh +97 -73
  153. package/evals/integration/test_gate_review_inquiry_records.sh +3 -3
  154. package/evals/integration/test_goal_fit_escape_hatch.sh +10 -10
  155. package/evals/integration/test_goal_fit_ghost_session.sh +104 -0
  156. package/evals/integration/test_goal_fit_hook.sh +32 -32
  157. package/evals/integration/test_goal_fit_rederive.sh +9 -9
  158. package/evals/integration/test_hook_category_behaviors.sh +103 -0
  159. package/evals/integration/test_hook_influence_cases.sh +1 -0
  160. package/evals/integration/test_install_merge.sh +262 -1
  161. package/evals/integration/test_kit_identity_trust.sh +6 -6
  162. package/evals/integration/test_liveness_conflict_injection.sh +587 -0
  163. package/evals/integration/test_liveness_heartbeat.sh +677 -0
  164. package/evals/integration/test_liveness_verdict.sh +394 -0
  165. package/evals/integration/test_local_flow_kit_install.sh +15 -0
  166. package/evals/integration/test_phase_map_and_gate_claim.sh +63 -11
  167. package/evals/integration/test_promote_gate.sh +178 -0
  168. package/evals/integration/test_publish_delivery.sh +23 -6
  169. package/evals/integration/test_pull_work_assignment_join.sh +132 -0
  170. package/evals/integration/test_pull_work_liveness_preflight.sh +394 -0
  171. package/evals/integration/test_pull_work_provider.sh +2 -2
  172. package/evals/integration/test_reconcile_soundness.sh +37 -13
  173. package/evals/integration/test_resolvefirststep_security.sh +22 -0
  174. package/evals/integration/test_runtime_adapter_activation.sh +87 -18
  175. package/evals/integration/test_session_resume_roundtrip.sh +147 -0
  176. package/evals/integration/test_sidecar_field_preservation.sh +249 -0
  177. package/evals/integration/test_trust_reconcile.sh +11 -10
  178. package/evals/integration/test_trust_reconcile_manifest.sh +79 -0
  179. package/evals/integration/test_trust_reconcile_mixed_bundle.sh +96 -0
  180. package/evals/integration/test_trust_reconcile_negatives.sh +759 -0
  181. package/evals/integration/test_usage_feedback_global.sh +5 -5
  182. package/evals/integration/test_validate_artifacts_portability.sh +60 -0
  183. package/evals/integration/test_verify_cli.sh +2 -2
  184. package/evals/integration/test_veritas_governance_kit.sh +117 -0
  185. package/evals/integration/test_workflow_artifact_cleanup_audit.sh +26 -1
  186. package/evals/integration/test_workflow_artifacts.sh +33 -0
  187. package/evals/integration/test_workflow_sidecar_writer.sh +802 -74
  188. package/evals/integration/test_workflow_steering_hook.sh +175 -5
  189. package/evals/lib/codex-provider.sh +1 -1
  190. package/evals/lib/node.sh +19 -1
  191. package/evals/run.sh +32 -0
  192. package/evals/static/test_decisions.sh +150 -0
  193. package/evals/static/test_flowdef_codeowners_coverage.sh +62 -0
  194. package/evals/static/test_knowledge_providers.sh +23 -0
  195. package/evals/static/test_package.sh +19 -10
  196. package/evals/static/test_universal_bundles.sh +48 -3
  197. package/evals/static/test_workflow_skills.sh +41 -8
  198. package/kits/builder/flows/build.flow.json +3 -74
  199. package/kits/builder/flows/publish-learn.flow.json +90 -0
  200. package/kits/builder/kit.json +11 -0
  201. package/kits/builder/skills/builder-shape/SKILL.md +1 -1
  202. package/kits/builder/skills/deliver/SKILL.md +32 -11
  203. package/kits/builder/skills/design-probe/SKILL.md +4 -4
  204. package/kits/builder/skills/evidence-gate/SKILL.md +26 -1
  205. package/kits/builder/skills/execute-plan/SKILL.md +2 -2
  206. package/kits/builder/skills/fix-bug/SKILL.md +2 -0
  207. package/kits/builder/skills/gate-review/SKILL.md +6 -6
  208. package/kits/builder/skills/idea-to-backlog/SKILL.md +1 -1
  209. package/kits/builder/skills/learning-review/SKILL.md +7 -7
  210. package/kits/builder/skills/pickup-probe/SKILL.md +5 -4
  211. package/kits/builder/skills/plan-work/SKILL.md +27 -5
  212. package/kits/builder/skills/pull-work/SKILL.md +148 -5
  213. package/kits/builder/skills/release-readiness/SKILL.md +4 -4
  214. package/kits/builder/skills/review-work/SKILL.md +24 -1
  215. package/kits/builder/skills/tdd-workflow/SKILL.md +2 -0
  216. package/kits/builder/skills/verify-work/SKILL.md +8 -1
  217. package/kits/catalog.json +6 -0
  218. package/kits/knowledge/kit.json +35 -0
  219. package/kits/knowledge/providers/conformance/fixtures/git-repo/CONTEXT.md +12 -0
  220. package/kits/knowledge/providers/conformance/fixtures/git-repo/docs/decisions/old-sprocket-shape.md +13 -0
  221. package/kits/knowledge/providers/conformance/fixtures/git-repo/docs/decisions/sprocket-shape.md +14 -0
  222. package/kits/knowledge/providers/conformance/fixtures/git-repo/docs/decisions/widget-format.md +14 -0
  223. package/kits/knowledge/providers/conformance/fixtures/git-repo/docs/learnings/fixture-learning.md +7 -0
  224. package/kits/knowledge/providers/conformance/fixtures/work-item/issues.json +30 -0
  225. package/kits/knowledge/providers/conformance/suite.test.js +125 -0
  226. package/kits/knowledge/providers/git-repo/index.js +236 -0
  227. package/kits/knowledge/providers/health/health-pass.test.js +99 -0
  228. package/kits/knowledge/providers/health/index.js +153 -0
  229. package/kits/knowledge/providers/index.js +24 -0
  230. package/kits/knowledge/providers/lib/model.js +91 -0
  231. package/kits/knowledge/providers/lib/schema-validate.js +119 -0
  232. package/kits/knowledge/providers/markdown-vault/index.js +169 -0
  233. package/kits/knowledge/providers/work-item/index.js +204 -0
  234. package/kits/veritas-governance/adapter/readiness-to-trust-bundle.mjs +178 -0
  235. package/kits/veritas-governance/docs/README.md +75 -0
  236. package/kits/veritas-governance/fixtures/readiness/not-ready.readiness-report.json +4645 -0
  237. package/kits/veritas-governance/fixtures/readiness/ready.readiness-report.json +4403 -0
  238. package/kits/veritas-governance/flows/readiness-check.flow.json +35 -0
  239. package/kits/veritas-governance/kit.json +16 -0
  240. package/package.json +11 -5
  241. package/packaging/README.md +2 -2
  242. package/packaging/conformance/fixtures/config-protection--allow-read-state-json.json +20 -0
  243. package/packaging/conformance/fixtures/config-protection--block-write-state-json.json +20 -0
  244. package/packaging/conformance/fixtures/stop-goal-fit--block-bundle-disputed-claim.json +1 -1
  245. package/packaging/conformance/fixtures/stop-goal-fit--block-capture-contradicts-claimed-pass.json +1 -1
  246. package/packaging/manifest.json +9 -10
  247. package/schemas/assignment-provider-settings.schema.json +125 -0
  248. package/schemas/decision-record.schema.json +109 -0
  249. package/schemas/knowledge/edge.schema.json +54 -0
  250. package/schemas/knowledge/health-report.schema.json +45 -0
  251. package/schemas/knowledge/node.schema.json +49 -0
  252. package/schemas/knowledge/proposal.schema.json +53 -0
  253. package/schemas/workflow-evidence.schema.json +1 -1
  254. package/schemas/workflow-state.schema.json +5 -0
  255. package/scripts/README.md +8 -3
  256. package/scripts/check-content-boundary.cjs +1 -1
  257. package/scripts/check-decisions.cjs +356 -0
  258. package/scripts/ci/derive-claim-status.mjs +74 -0
  259. package/scripts/ci/trust-reconcile.js +957 -103
  260. package/scripts/git-status.sh +2 -2
  261. package/scripts/hooks/claude-telemetry-hook.js +37 -3
  262. package/scripts/hooks/codex-telemetry-hook.js +36 -2
  263. package/scripts/hooks/config-protection.js +102 -30
  264. package/scripts/hooks/evidence-capture.js +3 -3
  265. package/scripts/hooks/lib/actor-identity.js +368 -0
  266. package/scripts/hooks/lib/config-protection-remedies.js +69 -0
  267. package/scripts/hooks/lib/liveness-heartbeat.js +361 -0
  268. package/scripts/hooks/lib/liveness-policy.js +127 -0
  269. package/scripts/hooks/lib/liveness-read.js +105 -12
  270. package/scripts/hooks/lib/liveness-write.js +46 -0
  271. package/scripts/hooks/lib/local-artifact-paths.js +12 -6
  272. package/scripts/hooks/opencode-telemetry-hook.js +27 -1
  273. package/scripts/hooks/pi-telemetry-hook.js +27 -1
  274. package/scripts/hooks/stop-goal-fit.js +157 -26
  275. package/scripts/hooks/workflow-steering.js +77 -3
  276. package/scripts/install-codex-home.sh +138 -38
  277. package/scripts/statusline/flow-agents-statusline.js +2 -2
  278. package/src/cli/assignment-provider.ts +845 -0
  279. package/src/cli/console-learning-projection.ts +3 -2
  280. package/src/cli/effective-assignment-provider-settings.ts +112 -0
  281. package/src/cli/init.ts +101 -21
  282. package/src/cli/kit.ts +37 -6
  283. package/src/cli/public-api.test.mjs +58 -6
  284. package/src/cli/pull-work-provider.ts +1 -1
  285. package/src/cli/trust-bundle-policy-order.test.mjs +87 -0
  286. package/src/cli/usage-feedback.ts +3 -3
  287. package/src/cli/validate-hook-influence.ts +1 -0
  288. package/src/cli/validate-workflow-artifacts.ts +27 -7
  289. package/src/cli/veritas-readiness-adapter.test.mjs +267 -0
  290. package/src/cli/workflow-artifact-cleanup-audit.ts +35 -2
  291. package/src/cli/workflow-sidecar.ts +933 -168
  292. package/src/cli.ts +6 -0
  293. package/src/flow-kit/validate.ts +74 -1
  294. package/src/index.ts +6 -2
  295. package/src/lib/flow-resolver.ts +123 -55
  296. package/src/lib/local-artifact-root.ts +24 -5
  297. package/src/lib/workflow-learning-projection.ts +2 -2
  298. package/src/runtime-adapters.ts +61 -15
  299. package/src/tools/build-universal-bundles.ts +49 -16
  300. package/src/tools/generate-context-map.ts +10 -8
  301. package/src/tools/validate-source-tree.ts +24 -1
@@ -0,0 +1,463 @@
1
+ ---
2
+ title: "ADR 0022: Fail-Closed Delivery Reconciliation with Governed Exemptions"
3
+ ---
4
+
5
+ # ADR 0022: Fail-Closed Delivery Reconciliation with Governed Exemptions
6
+
7
+ **Date:** 2026-07-02
8
+ **Status:** Proposed (shaped with Brian Anderson, 2026-07-02). Refines the Layer-2 CI
9
+ anchor established in [ADR 0017](./0017-anti-gaming-trust-security-model.md) and hardened in
10
+ [ADR 0020](./0020-trust-reconcile-manifest-and-claim-classification.md); does not change
11
+ their layered-defense posture.
12
+
13
+ ---
14
+
15
+ ## Context
16
+
17
+ `scripts/ci/trust-reconcile.js` — the external CI trust anchor ADR 0017 designed as the
18
+ un-forgeable Layer-2 boundary — has run **fail-open on bundle absence** since it existed. Its
19
+ own header states the behavior plainly:
20
+
21
+ > "Fail-open on bundle absence: if no bundle is provided (and none auto-discovered at
22
+ > `delivery/trust.bundle` or `delivery/trust.checkpoint.json`), only the fresh verify is
23
+ > enforced."
24
+
25
+ `discoverBundle()` (trust-reconcile.js:461-470) returns `null` when neither file exists, and
26
+ `runTrustReconcile()` (trust-reconcile.js:529-533) treats `null` as "Step 2 does not apply" —
27
+ Step 1 (fresh `npm run build && npm run eval:static`) still runs, but the actual anti-gaming
28
+ machinery ADR 0017/0020 built — reconciling claimed-pass commands, catching laundering,
29
+ catching never-captured claims, catching status-misassertion — never engages. The bundle is
30
+ also **fail-soft to produce**: `publishDelivery()` (`src/cli/workflow-sidecar.ts`, documented
31
+ in `delivery/README.md`) "does nothing if `trust.bundle` is absent (no crash, no error)." So
32
+ the single condition that turns Layer 2 on or off — whether a bundle exists in the diff — is
33
+ entirely under the delivering agent's control, and skipping it costs nothing and raises no
34
+ alarm.
35
+
36
+ That is a **kill switch by omission**: the agent, not an external anchor, decides whether the
37
+ anchor applies. This directly contradicts ADR 0017's own threat model ("no purely-local
38
+ control is airtight; the authoritative anchor must live somewhere the agent cannot
39
+ pre-disable or post-forge") — except here the "pre-disable" move is not a local hack at all,
40
+ it is simply *not delivering the artifact CI depends on to reconcile*, and CI accepts that
41
+ silently.
42
+
43
+ The historical record makes the exposure concrete, not theoretical: every PR before #265
44
+ passed the Trust Reconcile lane trivially via bundle absence (`git log --follow --
45
+ delivery/trust.bundle` shows the file's first appearance at #269, "veritas-governance kit —
46
+ readiness→trust-bundle adapter with settled gate semantics" — the first live,
47
+ capture-backed publish this repository ever produced). For roughly the entire history of the
48
+ anchor, Layer 2 has been running Step 1 only.
49
+
50
+ ## Decision
51
+
52
+ ### 1. The predicate: every change is agent-delivered by default; identification signals inform, never gate
53
+
54
+ Research into how agent-delivered changes are identifiable today turned up three candidate
55
+ signals, and all three share the same flaw: **they are agent-writable, agent-omittable, or
56
+ both.**
57
+
58
+ | Signal | Where it lives | What it proves when present | Why it cannot gate alone |
59
+ |---|---|---|---|
60
+ | Runtime-session commit trailer (`Claude-Session: https://claude.ai/code/session_...`, and the analogous `Codex-Session:` / `Opencode-Session:` / `Pi-Session:` forms implied by the same runtime set the actor-identity resolver already enumerates, `scripts/hooks/lib/actor-identity.js:58-65` `RUNTIME_SESSION_ID_VARS`) | Free text the agent appends to its own commit message | Positive proof of agent delivery, attributable to a runtime/session | Purely self-asserted; an agent that wants to hide simply omits the trailer. No repo code enforces its presence today — it is observed convention (present on essentially every recent merged PR per `git log`), not a contract. |
61
+ | `delivery/trust.bundle` / `trust.checkpoint.json` present in the diff | Committed transport path (`delivery/README.md`) | Positive proof of agent delivery (only `publishDelivery()` writes these) | This is the exact signal already in play — its **absence** is today's loophole. Trusting presence-only leaves absence exactly as exploitable as it is now. |
62
+ | A "required marker" naming the delivering agent | Does not exist today | Would prove delivery mechanism | Nothing in the codebase currently stamps a required, non-omittable, non-agent-writable marker of agent origin. |
63
+
64
+ No positive-detection signal can be the enforcement gate, because closing a gap that an agent
65
+ controls by omission with *another* agent-controlled, omittable signal reproduces the same
66
+ bug one layer up. The predicate therefore **inverts**: reconciliation applies to every change
67
+ by default. The three signals above are retained as **diagnostic and audit inputs only** —
68
+ they explain and attribute what the anchor already treats as agent-delivered; they do not
69
+ decide whether it treats it that way. Concretely, per signal:
70
+
71
+ 1. **Commit trailer present** — logged by the reconciler (new `[trust-reconcile] identified:
72
+ runtime-session trailer '<trailer>' on <ref>` line) for audit; does not change the exit
73
+ path. Reconciliation already applies (default).
74
+ 2. **`delivery/trust.bundle` present** — unchanged from today: Step 2's existing
75
+ reconcile-against-manifest logic (ADR 0020) runs exactly as it does now.
76
+ 3. **Neither present (today's common "nothing shipped" case, indistinguishable from a
77
+ legitimate human-only PR)** — this is the ambiguous case, and it is the one the fail-open
78
+ bug lived in. It now resolves to **agent-delivered, fail closed**: `trust-reconcile.js`'s
79
+ bundle-absence branch gains a new check — is there a well-formed DECLARED marker (§2) in
80
+ scope for this ref? No → **new divergence type**, `bundle-required-no-declared-marker`,
81
+ job exits 1. Yes → exempted, see below.
82
+ 4. **Malformed DECLARED marker** (missing any of the four required fields, §2) — treated as
83
+ absent; falls through to case 3's fail-closed default, with a diagnostic naming the
84
+ missing field(s) so a human fixing it does not have to guess the schema.
85
+
86
+ ### 2. The DECLARED no-agent-delivery marker
87
+
88
+ Humans and other legitimate non-agent changes (release-automation bots, direct maintainer
89
+ pushes) opt out via a committed `delivery/DECLARED` JSON file — the same `delivery/`
90
+ transport path `trust.bundle` already uses, so the anchor gains exactly one new
91
+ auto-discovery target, not a new mechanism:
92
+
93
+ ```json
94
+ {
95
+ "scope": "ref:release-please--branches--main",
96
+ "reason": "release-please automation PR; no agent delivery involved",
97
+ "approved_by": "briananderson1222",
98
+ "declared_at": "2026-07-02T00:00:00Z"
99
+ }
100
+ ```
101
+
102
+ All four fields are required for "well-formed." `scope` matches either a single ref/commit
103
+ range or a durable pattern (author or branch-prefix match — see Consequences for why this
104
+ matters for bot PRs). Presence and content are printed **loudly**, mirroring ADR 0020's
105
+ `WAIVED:` convention exactly:
106
+
107
+ ```
108
+ [trust-reconcile] DECLARED (no-agent-delivery): <scope> — <reason> (approved by <approved_by>, declared <declared_at>)
109
+ ```
110
+
111
+ A DECLARED marker exempts **Step 2 only** (bundle-required enforcement). Step 1 (fresh
112
+ verify) is never exempted by anything in this ADR — a human PR still has to build and pass
113
+ static evals; only the anti-gaming reconcile step, which presumes an agent-produced bundle
114
+ to reconcile against, is skippable, and only with attribution.
115
+
116
+ `delivery/DECLARED` is added to `.github/CODEOWNERS` alongside the other verify-config and
117
+ anchor paths (`/scripts/ci/`, `/package.json`, `/evals/run.sh`) it already lists — the same
118
+ mitigation ADR 0017 Layer 4 uses for every other self-asserted, unauthenticated field
119
+ (`approved_by` on a waiver has the identical shape and the identical residual; carried over
120
+ here rather than re-solved).
121
+
122
+ ### 3. Layering: the governance kit issues and audits; the anchor enforces
123
+
124
+ Per ADR 0017's own framing ("kits declare process; the anchor enforces"), exemption
125
+ *issuance* and *audit* — the human-approval workflow, not the enforcement decision — belong
126
+ in `kits/veritas-governance`, the kit this repository already stood up (#269, migrated #285)
127
+ for exactly this class of "turn a governance verdict into gate evidence" concern. It ships
128
+ today as a single flow/single gate (`flows/readiness-check.flow.json`: step `readiness` →
129
+ gate `gate-check-gate`, requiring a verified `software-readiness-verdict` trust.bundle
130
+ claim). This ADR specifies a second flow of the identical shape:
131
+
132
+ - **`flows/exemption-issuance.flow.json`** — agentless, K0, mirroring
133
+ `readiness-check.flow.json`'s structure: step `request` → gate `human-approval-gate`
134
+ (`expects` a trust.bundle claim of `claimType: "no-agent-delivery-exemption-approval"`,
135
+ `subjectType: "delivery-scope"`, `accepted_statuses: ["verified"]` — satisfiable only by
136
+ human-attached evidence, the same pattern `gate-check-gate` uses for the readiness verdict)
137
+ → step `issue`, which writes the resulting `delivery/DECLARED` file once the gate passes.
138
+ - **`exemption-usage-review`** — a periodic audit skill/flow that walks
139
+ `delivery/DECLARED` history (`git log --follow -- delivery/DECLARED`) merged in a review
140
+ window and surfaces every standing exemption (scope, reason, approver, age) for owner
141
+ re-confirmation — process visibility, not enforcement.
142
+
143
+ The load-bearing property: **uninstalling `veritas-governance` must never weaken
144
+ enforcement.** `trust-reconcile.js`'s marker-reading logic — auto-discover
145
+ `delivery/DECLARED`, require all four fields, print the DECLARED line, exempt Step 2 only —
146
+ lives in `scripts/ci/` (already CODEOWNERS-protected, already anchor-owned) and has zero
147
+ runtime dependency on the kit. A human can hand-author a compliant `delivery/DECLARED`
148
+ without the kit installed; they simply lose the guided issuance flow and the periodic-review
149
+ tooling. This is the concrete test of the layering claim, not just its statement.
150
+
151
+ ### 4. Breaking change — no legacy fallback
152
+
153
+ This changes the exit code of every future agent-delivered change (which, under the inverted
154
+ default, is every change unless explicitly DECLARED otherwise) that does not ship a
155
+ `delivery/trust.bundle`. There is no flag, no grace window, no opt-in period — matching the
156
+ owner's explicit direction to document this as a breaking change rather than carry a legacy
157
+ fail-open path indefinitely. Concretely:
158
+
159
+ - Any PR that today merges by passing Trust Reconcile "trivially via absence" starts failing
160
+ the moment this ships, until it either (a) publishes a bundle via the existing
161
+ `publishDelivery()` path, or (b) carries a DECLARED marker in scope.
162
+ - **Repos consuming `.github/workflows/trust-reconcile.yml` as a template** (ADR 0017 §
163
+ Consequences names this the intended reuse path) must pin to the pre-ADR-0022 commit until
164
+ ready, then adopt in one migration PR that either wires bundle publication into their
165
+ delivery flow or authors an initial `delivery/DECLARED` covering their known non-agent
166
+ actors (see Consequences below for the concrete bot case).
167
+
168
+ ## Scope boundaries
169
+
170
+ **`hasBuild` fail-open in `stop-goal-fit.js` (line 185; `loadActiveFlowStep`,
171
+ lines 305-316) is the same absence-controls-enforcement asymmetry in miniature — it is
172
+ explicitly out of scope for this ADR.** One-line rationale: it is a Layer-1, local,
173
+ **non-authoritative** fallback (its own comment: "Fail-open: returns null when build/ is
174
+ absent... the caller treats null as 'no active FlowDefinition' and falls back to the
175
+ `workflow.*` path") — Layer-1 heuristics were explicitly frozen by
176
+ [ADR 0018](./0018-freeze-local-shell-heuristics.md), which routes *all* new enforcement
177
+ concerns to the external anchor rather than adding local surface. This ADR *is* that
178
+ external-anchor hardening; extending the local `hasBuild` check would both violate the
179
+ freeze and buy nothing, since a determined agent controls its own local `build/` presence
180
+ regardless of what the local heuristic does. Cross-ref: ADR 0017 §Layer 1 vs Layer 2;
181
+ ADR 0018 §Decision.
182
+
183
+ ## Residuals (honest — ADR 0017 §Residuals / ADR 0020 §Residuals style; a bar-raiser, not a wall)
184
+
185
+ - **Forged human attribution.** `approved_by` on `delivery/DECLARED` is free text, not bound
186
+ to an authenticated identity — the identical residual ADR 0020 already carries for
187
+ `WAIVED`'s `approved_by`, and the identical mitigation: the loud, un-suppressible DECLARED
188
+ line plus CODEOWNERS review, not identity attestation. Not solved here; explicitly
189
+ inherited.
190
+ - **Shared credentials collapse the human/agent distinction.** An agent operating under
191
+ commit/push rights indistinguishable from a human collaborator (a shared PAT, a service
192
+ account with CODEOWNERS review rights) can author and approve its own DECLARED marker. This
193
+ is ADR 0017's already-named "trust-the-humans boundary... documented, not closed" —
194
+ unchanged by this ADR.
195
+ - **Identification signals undercount, they do not overcount.** Because the enforcement
196
+ default no longer depends on the commit-trailer or delivery-artifact signals (§1), an agent
197
+ can still freely omit both. Any future audit tooling built on those signals ("which PRs
198
+ were agent-delivered") will therefore undercount attribution — this ADR fixes the
199
+ enforcement default, not attribution completeness.
200
+ - **CI checkout depth limits trailer detection today.** `trust-reconcile.yml`'s
201
+ `actions/checkout` step does not currently widen fetch depth to cover a PR's full commit
202
+ range, so the commit-trailer diagnostic in §1's table is aspirational for CI-side logging
203
+ until checkout is widened. This does not block the ADR: the trailer is diagnostic-only,
204
+ never gating, per §1.
205
+ - **Bot/automation PRs need a durable, not per-PR, DECLARED scope**, or every dependabot /
206
+ release-please PR starts failing the moment this ships (see Consequences). `scope`
207
+ supports author/branch-pattern matching for exactly this reason, but the pattern-matching
208
+ logic itself is new surface this ADR specifies and a future implementation must get right;
209
+ a narrow pattern match is itself a residual surface (a scope pattern that is too broad
210
+ re-opens a blanket exemption).
211
+
212
+ ## Consequences
213
+
214
+ - Trust Reconcile stops being satisfiable by doing nothing. The anti-gaming machinery ADR
215
+ 0017/0020 built (reconcile, laundering screen, status re-derivation, `ATTESTED`/`WAIVED`
216
+ disclosure) now actually runs on every agent-delivered change by default, closing the gap
217
+ the historical record (`delivery/trust.bundle`'s first appearance at #269) shows has been
218
+ open for the anchor's entire prior history.
219
+ - **`dependabot.yml` and `release-please.yml`-authored PRs** (both present in this repo's
220
+ `.github/`) will start failing Trust Reconcile the moment this ships unless a durable,
221
+ author/branch-scoped `delivery/DECLARED` marker is authored for each before rollout — a
222
+ concrete, non-hypothetical migration item, not a theoretical edge case.
223
+ - `veritas-governance` gains a second flow and a periodic-review surface; its "unverified,
224
+ not first-party-allowlisted" trust status (per its own README) is unaffected by this ADR —
225
+ the anchor-side enforcement this ADR specifies works whether or not the kit is installed.
226
+ - `.github/CODEOWNERS` gains one new protected path (`/delivery/DECLARED` or a `/delivery/`
227
+ pattern narrow enough to exclude `trust.bundle`/`trust.checkpoint*`, which remain
228
+ agent-written).
229
+ - Downstream repos treating `trust-reconcile.yml` as a template inherit a breaking change on
230
+ adoption, not a gradual one — flagged explicitly per the owner's direction (§ Decision 4).
231
+
232
+ ## Alternatives Considered
233
+
234
+ - **Positive-detection predicate (trust the commit trailer or bundle presence as the sole
235
+ signal).** Rejected in §1: any agent-writable/omittable positive signal reproduces the
236
+ fail-open bug at one remove — an agent that wants to evade omits the signal being checked,
237
+ exactly as it omits the bundle today.
238
+ - **Extend `hasBuild` / Layer-1 heuristics to close the analogous gap locally.** Rejected —
239
+ violates the ADR 0018 freeze and cannot be authoritative regardless (Scope boundaries,
240
+ above); the correct fix lives in Layer 2, which is what this ADR does.
241
+ - **Grace period / opt-in flag before flipping the default.** Rejected per the owner's
242
+ explicit direction: document as a breaking change, do not carry a legacy fail-open path.
243
+ - **Require cryptographic (Sigstore-signed) attribution for the DECLARED marker instead of
244
+ free-text `approved_by`.** Deferred, not rejected — this is exactly the Assurance-profile
245
+ remedy ADR 0020's Residuals names for the identical `WAIVED` gap ("extending Layer 3's
246
+ keyless-Sigstore minting... to individual human-attestation events"). It does not exist yet
247
+ for waivers; inventing it first for DECLARED markers alone would be inconsistent scope.
248
+ When/if that Assurance profile lands, both `WAIVED` and `DECLARED` should adopt it together.
249
+ - **Put exemption enforcement inside `veritas-governance` itself (kit owns both issuance and
250
+ enforcement).** Rejected — this is precisely the layering ADR 0017 already establishes
251
+ ("kits declare process; the anchor enforces") and the explicit requirement that uninstalling
252
+ a kit must never weaken enforcement; enforcement logic must live anchor-side regardless of
253
+ which kit (if any) is installed.
254
+
255
+ ## References
256
+
257
+ - [ADR 0017: The Anti-Gaming Trust Security Model](./0017-anti-gaming-trust-security-model.md)
258
+ — the layered defense this ADR refines Layer 2 of; the threat-model framing ("no purely-local
259
+ control is airtight") this ADR's problem statement is a direct instance of.
260
+ - [ADR 0018: Freeze the Local Shell-Parsing Heuristics](./0018-freeze-local-shell-heuristics.md)
261
+ — the freeze that puts the `hasBuild` miniature explicitly out of scope and routes this
262
+ ADR's fix to the external anchor instead.
263
+ - [ADR 0020: Trust-Reconcile Manifest, Claim Classification, and Waivers](./0020-trust-reconcile-manifest-and-claim-classification.md)
264
+ — the `WAIVED`/`ATTESTED` disclosure conventions this ADR's `DECLARED` marker mirrors; its
265
+ Residuals section (`approved_by` unauthenticated, mitigated by CODEOWNERS + the loud log
266
+ line) is inherited verbatim for `DECLARED`.
267
+ - `scripts/ci/trust-reconcile.js` (`discoverBundle`, lines 461-470; `runTrustReconcile`
268
+ bundle-absence branch, lines 529-533) — the code this ADR changes.
269
+ - `src/cli/workflow-sidecar.ts` `publishDelivery()` / `delivery/README.md` — confirms the
270
+ bundle is fail-soft to produce today, the root of the omission loophole.
271
+ - `scripts/hooks/lib/actor-identity.js` (`RUNTIME_SESSION_ID_VARS`, lines 58-65) — the
272
+ runtime enumeration the commit-trailer signal's naming is grounded in.
273
+ - `scripts/hooks/stop-goal-fit.js` (`hasBuild`, line 185; `loadActiveFlowStep`, lines
274
+ 305-316) — the Layer-1 miniature explicitly scoped out.
275
+ - `kits/veritas-governance/` (`kit.json`, `flows/readiness-check.flow.json`,
276
+ `docs/README.md`) — the existing kit shape §3's `exemption-issuance.flow.json` mirrors.
277
+ - `.github/CODEOWNERS` — the existing self-asserted-field mitigation pattern extended to
278
+ `delivery/DECLARED`.
279
+ - `.github/dependabot.yml`, `.github/workflows/release-please.yml` — the concrete bot-PR
280
+ migration case named in Consequences.
281
+ - #274 — the issue this ADR resolves; #269 — the first live capture-backed bundle publish
282
+ cited in Context; #265 — the last PR to merge before that (i.e. the boundary of "every PR
283
+ before #265 passed Trust Reconcile trivially via absence").
284
+
285
+ ## Addendum (2026-07-03): compound `scope` (space-separated AND) — security-review hardening
286
+
287
+ A security review of the #300 implementation found that `ref:`/`branch-prefix:` scope
288
+ conditions match against `GITHUB_HEAD_REF` (or the `TRUST_RECONCILE_REF` override), and on a
289
+ **fork PR `GITHUB_HEAD_REF` is pusher-controlled** — any contributor who can open a PR can
290
+ name their branch to satisfy a `ref:`- or `branch-prefix:`-only scope. A `delivery/DECLARED`
291
+ entry written to exempt one specific bot (e.g. `ref:release-please--branches--main`) is
292
+ therefore satisfiable by anyone who pushes a branch with that exact name, not only by the
293
+ automation it names. `author:` (bound to the platform-set `GITHUB_ACTOR`, not attacker-chosen
294
+ in the same way) does not have this weakness alone, but a single `author:` condition cannot
295
+ express "and also narrow the blast radius to this branch pattern" — the two properties needed
296
+ combining, not substituting for each other.
297
+
298
+ **Decision:** `scope` may contain multiple space-separated conditions, each one of the four
299
+ forms specified in §2 (`ref:`, `commit:`/`commit:a..b`, `author:`, `branch-prefix:`); a
300
+ compound scope matches only if **every** condition matches (AND, not OR). A single-condition
301
+ scope is unchanged and remains valid (backward compatible — it is the N=1 case of the same
302
+ rule). Matching is still string equality/prefix only, per condition — no `RegExp` is
303
+ constructed from marker content in either the single- or compound-condition path. An
304
+ unrecognized-prefix condition anywhere in a compound scope makes the **whole** scope never
305
+ match, the same fail-closed behavior a malformed single-condition scope already had.
306
+
307
+ **`ref:`/`branch-prefix:` alone are insufficient for identity exemptions and MUST be combined
308
+ with `author:`.** Per the finding above, a scope meant to identify a specific bot/automation
309
+ actor (as opposed to a specific commit range or branch, where the identity question does not
310
+ arise) should not rely on `ref:`/`branch-prefix:` in isolation — combine it with `author:` so
311
+ the platform-set actor identity, not just a self-chosen branch name, has to match too. The
312
+ migration marker this ADR's Consequences named for release-please is updated accordingly:
313
+
314
+ ```json
315
+ {
316
+ "scope": "author:github-actions[bot] branch-prefix:release-please--",
317
+ "reason": "release-please automation PR; no agent delivery involved",
318
+ "approved_by": "briananderson1222",
319
+ "declared_at": "<ISO timestamp>"
320
+ }
321
+ ```
322
+
323
+ (`dependabot[bot]`'s entry, `author:dependabot[bot]`, was already a single `author:` condition
324
+ — security-review-confirmed sound as-is and left unchanged.)
325
+
326
+ **`/delivery/DECLARED` CODEOWNERS landed with #300/#301.** `.github/CODEOWNERS` now lists
327
+ `/delivery/DECLARED` under the same owner as `/scripts/ci/`, `/package.json`, and
328
+ `/evals/run.sh` (§2's original intent, made concrete); `evals/static/test_flowdef_codeowners_coverage.sh`
329
+ carries a regression-lock assertion for the entry. This closes the file-level half of #301;
330
+ server-side enforcement of CODEOWNERS review on `main` remains tracked separately (#225).
331
+
332
+ ## Addendum (2026-07-03, part 2): bundle-ownership staleness check — "for THIS change"
333
+
334
+ Owner-approved follow-up to the compound-scope addendum above, closing a second gap the same
335
+ security review surfaced, this time against a **live incident**: PR #278 (the same open
336
+ dependabot PR cited in Baseline/Consequences) carries a `delivery/trust.checkpoint.json`
337
+ inherited byte-for-byte from `main` (dependabot never runs the deliver skill on its own
338
+ branch — the file only exists there because `main`'s tree already had it). Prior to this
339
+ addendum, `discoverBundle()` finding *any* file at `delivery/trust.bundle` or
340
+ `delivery/trust.checkpoint.json` — regardless of whether it says anything about the change
341
+ actually being reconciled — was sufficient to route into Step 2. A stale, inherited
342
+ checkpoint from a completely unrelated prior PR would therefore either (a) reconcile
343
+ against claims/evidence that have nothing to do with the current diff (if it were a full
344
+ `trust.bundle`), or (b), as in the checkpoint-only case, hit the existing
345
+ `checkpoint-bypass` divergence — **coincidentally fail-closed today only because a bare
346
+ checkpoint has no `evidence[]`/`claims[]` to reconcile**, not because the reconciler
347
+ recognized the file as stale. A future stale *full* `trust.bundle` (not just a checkpoint)
348
+ inherited the same way would not have that accidental protection.
349
+
350
+ **Decision:** "bundle-required" (ADR 0022 §1) means a bundle **for this change**, not any
351
+ bundle merely reachable at the checkout. `discoverBundle()`'s result is now checked against
352
+ a commit-identity binding before Step 2 is allowed to run against it:
353
+
354
+ - **Binding chosen:** `trust.checkpoint.json`'s `commit_sha` field (stamped by
355
+ `sealTrustCheckpoint()` in `src/cli/workflow-sidecar.ts` from `git rev-parse HEAD` at seal
356
+ time) — the strongest identity signal available today. `trust.bundle` itself carries no
357
+ commit/branch metadata (schema: `{schemaVersion, source, claims, evidence, policies,
358
+ events}` — confirmed by inspection), so when the auto-discovered file is `trust.bundle`,
359
+ the check falls through to its sibling `delivery/trust.checkpoint.json` (same
360
+ `resolveDeliveryCandidates()` seam; `publishDelivery()` always writes both together).
361
+ - **Match rule:** the bundle's `commit_sha` equals this change's own sha
362
+ (`TRUST_RECONCILE_SHA`/`GITHUB_SHA`), OR is a git-ancestor of it, via the same `git
363
+ merge-base --is-ancestor` primitive `commit:` scopes already use. Exact equality alone was
364
+ considered and rejected: `sealTrustCheckpoint()` necessarily stamps a commit that precedes
365
+ its own delivery commit (a checkpoint cannot contain its own future commit's sha), so
366
+ requiring exact equality would reject every legitimately fresh delivery, not just stale
367
+ ones. Ancestor-or-equal correctly accepts "sealed earlier in this same open PR's own
368
+ linear history" while — because this repo squash-merges PRs into `main` — correctly
369
+ rejecting a checkpoint inherited from `main`: a squash-merged commit's checkpoint records
370
+ the pre-squash feature-branch tip as `commit_sha`, which is provably **not** an ancestor of
371
+ any later branch (squash discards the original commit graph), so any checkpoint that ever
372
+ lands on `main` becomes permanently unmatchable by a later, unrelated branch — exactly the
373
+ PR #278 shape.
374
+ - **Fail closed on ambiguity:** no extractable `commit_sha` (missing from both the bundle and
375
+ its sibling checkpoint), or this change's own sha unresolvable — never treated as owned. A
376
+ stale/unowned bundle prints a loud, grep-stable line (`stale bundle ignored — attests
377
+ <theirs>, this change is <ours>`) and is then treated exactly as if `discoverBundle()` had
378
+ returned nothing: it falls through to `delivery/DECLARED` resolution.
379
+ - **Scope:** this check applies ONLY to **auto-discovered** bundles. An explicit
380
+ `--bundle`/`TRUST_RECONCILE_BUNDLE` remains untouched — it is a deliberate caller choice
381
+ (test fixtures, a programmatic caller passing a specific bundle), not something silently
382
+ picked up from committed git tree state, and the real `.github/workflows/trust-reconcile.yml`
383
+ never passes `--bundle`; it always relies on auto-discovery, which is exactly the path the
384
+ incident went through.
385
+
386
+ **Residual, honestly named:** this binding is still self-reported (the checkpoint's own
387
+ `commit_sha`, not a cryptographic commit signature) and still only as strong as
388
+ `sealTrustCheckpoint()`'s local `git rev-parse HEAD` call — an adversarial agent that
389
+ controls its own local git state before delivery could, in principle, stamp an arbitrary
390
+ sha. This does not reopen the PR #278 gap (a human/bot PR that never runs the deliver skill
391
+ at all still cannot forge a checkpoint it never writes), but it is not a full defense against
392
+ a fully agent-controlled delivery pipeline; that class of residual is the same
393
+ "trust-the-humans boundary" ADR 0017/0020 already name, not newly introduced here.
394
+
395
+ ## Addendum (2026-07-03, part 3): CI-context contract for the staleness check
396
+
397
+ A re-review found a launch-blocking gap in the staleness check (Addendum part 2, above):
398
+ `isAncestorCommit()`'s `git merge-base --is-ancestor` call is only meaningful if the CI
399
+ checkout actually has the parent commit objects, and if the sha compared against is a
400
+ commit a checkpoint could plausibly have been sealed at. Neither held under
401
+ `.github/workflows/trust-reconcile.yml`'s prior configuration: the default
402
+ `actions/checkout` fetch depth is a **shallow clone (`fetch-depth: 1`)**, which has no
403
+ parent objects — `git merge-base` against a missing object exits 128, so the ancestor
404
+ check would be unresolvable for every real PR, not just stale ones, falsely staling
405
+ **every legitimately fresh delivery** on a required, admin-enforced check. Separately, on
406
+ a `pull_request` trigger `GITHUB_SHA` resolves to GitHub's synthetic merge commit
407
+ (`refs/pull/N/merge`), a commit that never existed at the time any real `seal-checkpoint`
408
+ run stamped `commit_sha` — so even a correctly-resolving ancestor check would compare
409
+ against the wrong target. Both are now fixed at the workflow layer, not by loosening the
410
+ reconciler's own fail-closed contract: the checkout step sets `fetch-depth: 0` (full
411
+ history), and the trust-reconcile step sets `TRUST_RECONCILE_SHA:
412
+ ${{ github.event.pull_request.head.sha || github.sha }}` so the ownership comparison
413
+ always uses the PR's own head commit on a `pull_request` trigger (falling back to
414
+ `github.sha`, which is already correct, on `push`/`workflow_dispatch`). The checkout ref
415
+ itself is unchanged — Step 1 (fresh verify) runs against the same tree it always has;
416
+ only the identity used for the Step-2 ownership comparison changes. This is a narrow,
417
+ deliberate, owner-recorded functional amendment to the "workflow YAML: comments only"
418
+ scoping the original Wave 1 plan set for this file — an unavoidable consequence of
419
+ closing the HIGH finding, not scope creep. `scripts/ci/trust-reconcile.js`'s own contract
420
+ is unchanged and stays fail-closed either way: a shallow/missing-object condition still
421
+ resolves to "not an ancestor" (never silently accepted), so a misconfigured downstream
422
+ adopter that keeps the shallow default degrades safely (falsely stales real bundles,
423
+ loudly, with a diagnosable line) rather than unsafely (accepting a bundle it cannot
424
+ actually verify).
425
+
426
+ ## Addendum (2026-07-03, part 4): event-scoped enforcement — gates gate PRs, not `main`
427
+
428
+ Final review found a second, more severe HIGH launch-blocker in the staleness check
429
+ (Addendum part 3, above): even with full-history checkout and correct sha binding, a
430
+ `push` run on `main` immediately after a squash-merge would still falsely stale the
431
+ just-merged, genuinely legitimate bundle — because `git merge --squash` (this repo's
432
+ merge strategy) discards the original commit graph, the resulting squash commit on `main`
433
+ has **no** git ancestry back to the feature-branch commit its checkpoint was sealed
434
+ against, by design, not by defect. Empirically reproduced with a synthetic squash pair.
435
+ Left unfixed, every delivery would fail the required Trust Reconcile check on `main`
436
+ immediately post-merge, and Phase 2 attestation minting (which runs only after Step 2
437
+ passes) would stop entirely — a regression far worse than the bug this whole ADR closes.
438
+
439
+ **Decision (reviewer option (a) — enforcement is event-scoped):** bundle-required
440
+ enforcement (§1's `bundle-required-no-declared-marker` fail-closed branch, and the
441
+ staleness-gate consequence of it, Addendum part 2) applies only when a run is **gating a
442
+ proposed change** — detected via `TRUST_RECONCILE_EVENT` (set from `github.event_name` by
443
+ the workflow), with a conservative default: an absent/unrecognized event value is treated
444
+ as gating (enforce), so every existing local/test caller and any misconfigured CI event
445
+ keeps today's stricter behavior. Only the literal value `push` is treated as a post-merge
446
+ run. On `push`, an absent or stale auto-discovered bundle is a loud, exit-0 no-op
447
+ (`push event: ... — skipping Step 2 (gating happened on the PR run)`) rather than a
448
+ failure or a `delivery/DECLARED` requirement — there is no "change" being gated on a push
449
+ to a protected branch (direct pushes are already excluded by branch protection; a push
450
+ run's own job is Step 1 fresh-verify, which is unaffected by this scoping and always
451
+ runs, plus Step 2 reconcile IF the bundle happens to still attest that exact commit,
452
+ forming the Phase 2 attestation basis). `pull_request` gating is completely unaffected —
453
+ the exact same squash-shape fixture used to prove the push no-op also proves the
454
+ identical shape still fails closed when `TRUST_RECONCILE_EVENT=pull_request`, confirming
455
+ this scoping narrows *when* enforcement applies, not *how strictly* it applies when it
456
+ does. Residual (HIGH, documented not solved): `TRUST_RECONCILE_EVENT`'s
457
+ source value (`github.event_name`) is authoritative GitHub Actions context, but the
458
+ workflow FILE that assigns it to the env var is itself PR-editable content on a
459
+ `pull_request` run — a PR could hardcode `TRUST_RECONCILE_EVENT: push` in its own copy of
460
+ the workflow to fake the post-merge no-op path; this is closed by required code-owner
461
+ review on `.github/workflows/trust-reconcile.yml` (#225, not yet server-side enforced),
462
+ the same residual class as every other self-asserted CI input this ADR already carries.
463
+ Step 1 (fresh verify) is unaffected by event scoping either way and always runs.
@@ -73,7 +73,7 @@ The hidden supports are:
73
73
  | “Keep going until nothing is left.” | Use hooks and workflow state to avoid stopping early, then continue through verification and docs. |
74
74
  | “Use subagents to critique.” | Delegate critique as report-only work, record findings, fix failures, and re-run verification. |
75
75
  | “Can we validate this on Flow Agents itself?” | Use Flow Agents artifacts, hooks, evals, and learning loops on Flow Agents itself. |
76
- | “What slug are we on?” | Resolve `.flow-agents/current.json`; do not depend on memory from chat. |
76
+ | “What slug are we on?” | Resolve `.kontourai/flow-agents/current.json`; do not depend on memory from chat. |
77
77
 
78
78
  ## Mental Model
79
79
 
@@ -192,7 +192,7 @@ npm run workflow:sidecar -- current --format path
192
192
  npm run workflow:sidecar -- record-agent-event ...
193
193
  ```
194
194
 
195
- `ensure-session` creates or selects the workflow and writes `.flow-agents/current.json`. `current` resolves the active workflow path. `record-agent-event` lets parallel workers append progress to `agents/<agent-id>/events.jsonl` without guessing the slug.
195
+ `ensure-session` creates or selects the workflow and writes `.kontourai/flow-agents/current.json`. `current` resolves the active workflow path. `record-agent-event` lets parallel workers append progress to `agents/<agent-id>/events.jsonl` without guessing the slug.
196
196
 
197
197
  This is the key answer to multi-agent coordination: agents should not rely on conversational memory for the current slug. The orchestrator resolves the active workflow and passes the path to delegates. Delegates append events. The orchestrator consolidates those events into root state, evidence, critique, and handoff.
198
198
 
@@ -320,7 +320,7 @@ flowchart LR
320
320
  Prompt --> Current --> State --> Handoff --> Evidence --> Action
321
321
  ```
322
322
 
323
- The agent should not reconstruct the session from memory. It should resolve the active workflow from `.flow-agents/current.json`, read the sidecars, and continue from the recorded next action. If evidence is missing, it should say `NOT_VERIFIED` or keep working. If critique is open, it should fix or route the finding. If everything is clean, it can deliver.
323
+ The agent should not reconstruct the session from memory. It should resolve the active workflow from `.kontourai/flow-agents/current.json`, read the sidecars, and continue from the recorded next action. If evidence is missing, it should say `NOT_VERIFIED` or keep working. If critique is open, it should fix or route the finding. If everything is clean, it can deliver.
324
324
 
325
325
  ## One-Page Cheat Sheet
326
326
 
@@ -12,7 +12,7 @@ The loop has three parts:
12
12
  2. Sync quality outcomes from task artifacts, evals, release gates, or humans.
13
13
  3. Report usage and outcome metrics by repo, runtime, profile, prompt, skill, or task type.
14
14
 
15
- Quality outcomes are not inferred from raw telemetry alone. The CLI can automatically derive coarse outcomes from task artifacts such as `.flow-agents/<slug>/*.md`: `delivered` and `complete` become `success`, `failed` becomes `failure`, and optionally open artifacts can be recorded as `not_verified`. It does not invent `quality_score` or `human_minutes_saved`; those remain human/eval/release-gate facts.
15
+ Quality outcomes are not inferred from raw telemetry alone. The CLI can automatically derive coarse outcomes from task artifacts such as `.kontourai/flow-agents/<slug>/*.md`: `delivered` and `complete` become `success`, `failed` becomes `failure`, and optionally open artifacts can be recorded as `not_verified`. It does not invent `quality_score` or `human_minutes_saved`; those remain human/eval/release-gate facts.
16
16
 
17
17
  ## Storage Defaults
18
18
 
@@ -158,7 +158,7 @@ Usage-only metrics can be computed from telemetry. Quality and value metrics req
158
158
 
159
159
  ### Project Dashboard
160
160
 
161
- Generate the local HTML dashboard. This syncs terminal task artifacts from `.flow-agents` into `.telemetry/outcomes.jsonl` before rendering:
161
+ Generate the local HTML dashboard. This syncs terminal task artifacts from `.kontourai/flow-agents` into `.telemetry/outcomes.jsonl` before rendering:
162
162
 
163
163
  ```bash
164
164
  npm run usage-feedback -- dashboard --force
@@ -170,7 +170,7 @@ Sync artifacts without rendering the dashboard:
170
170
 
171
171
  ```bash
172
172
  npm run usage-feedback -- sync-artifacts \
173
- --artifact-dir .flow-agents \
173
+ --artifact-dir .kontourai/flow-agents \
174
174
  --repo flow-agents \
175
175
  --profile-id codex-default \
176
176
  --prompt-id deliver-v1 \
@@ -185,7 +185,7 @@ npm run usage-feedback -- import-codex \
185
185
  --telemetry-dir .telemetry/repo-a \
186
186
  --source-id repo-a \
187
187
  --repo repo-a \
188
- --profile-id codex-kdev \
188
+ --profile-id codex-builder \
189
189
  --prompt-id deliver-v1 \
190
190
  --skill-id deliver
191
191
  ```
@@ -213,7 +213,7 @@ npm run usage-feedback -- record-outcome \
213
213
  --runtime codex \
214
214
  --repo repo-a \
215
215
  --agent dev \
216
- --profile-id codex-kdev \
216
+ --profile-id codex-builder \
217
217
  --prompt-id deliver-v1 \
218
218
  --skill-id deliver \
219
219
  --task-type delivery \
@@ -221,7 +221,7 @@ npm run usage-feedback -- record-outcome \
221
221
  --result success \
222
222
  --quality-score 5 \
223
223
  --human-minutes-saved 35 \
224
- --evidence .flow-agents/agent-usage-feedback-loop/agent-usage-feedback-loop--deliver.md
224
+ --evidence .kontourai/flow-agents/agent-usage-feedback-loop/agent-usage-feedback-loop--deliver.md
225
225
  ```
226
226
 
227
227
  Generate a report:
@@ -10,7 +10,7 @@ Generated by `npm run context-map`. Regenerate after changing agents, skills, sc
10
10
 
11
11
  - Start here when a session is long, resumed, or context-constrained.
12
12
  - Load only the specific skill, contract, schema, or doc that matches the task.
13
- - Treat `.flow-agents` as runtime state and `dist/` as generated output.
13
+ - Treat `.kontourai/flow-agents` as runtime state and `dist/` as generated output.
14
14
 
15
15
  ## Repository Shape
16
16
 
@@ -29,7 +29,8 @@ Generated by `npm run context-map`. Regenerate after changing agents, skills, sc
29
29
  | scripts | canonical copy | Build, validation, hook, telemetry, workflow, and import/export utilities. |
30
30
  | skills | canonical copy | On-demand capability instructions and workflow primitives. |
31
31
  | dist | generated | Generated bundle exports. Do not edit by hand. |
32
- | .flow-agents | runtime | Cross-session workflow artifacts and sidecars. Not committed by default. |
32
+ | .kontourai/flow-agents | runtime | Non-durable workflow artifacts, sidecars, and generated projections. Not committed by default. |
33
+ | .flow-agents | durable local state | Explicit Flow Agents config/install state. Not a runtime artifact fallback. |
33
34
 
34
35
  ## Core Commands
35
36
 
@@ -38,7 +39,7 @@ Generated by `npm run context-map`. Regenerate after changing agents, skills, sc
38
39
  | Source tree | npm run validate:source |
39
40
  | Static suite | bash evals/run.sh static |
40
41
  | Integration suite | bash evals/run.sh integration |
41
- | Workflow artifacts | npm run workflow:validate-artifacts -- --require-sidecars --require-critique .flow-agents/<slug> |
42
+ | Workflow artifacts | npm run workflow:validate-artifacts -- --require-sidecars --require-critique .kontourai/flow-agents/<slug> |
42
43
  | Workflow sidecars | npm run workflow:sidecar -- --help |
43
44
  | Claim lookup | npm run workflow:sidecar -- claim <id> <dir> |
44
45
  | Context map drift | npm run context-map:check |
@@ -46,11 +47,13 @@ Generated by `npm run context-map`. Regenerate after changing agents, skills, sc
46
47
 
47
48
  ## Workflow Sidecars
48
49
 
49
- Machine-readable workflow state lives beside Markdown artifacts in `.flow-agents/<slug>/`.
50
+ Machine-readable workflow state lives beside Markdown artifacts in `.kontourai/flow-agents/<slug>/`.
50
51
 
51
52
  | Schema | Title | ID |
52
53
  | --- | --- | --- |
54
+ | assignment-provider-settings.schema.json | Flow Agents Assignment Provider Settings | https://flow-agents.dev/schemas/assignment-provider-settings.schema.json |
53
55
  | backlog-provider-settings.schema.json | Flow Agents Backlog Provider Settings | https://flow-agents.dev/schemas/backlog-provider-settings.schema.json |
56
+ | decision-record.schema.json | Flow Agents Decision Record | https://flow-agents.dev/schemas/decision-record.schema.json |
54
57
  | flow-agents-settings.schema.json | Flow Agents Settings | https://flow-agents.dev/schemas/flow-agents-settings.schema.json |
55
58
  | workflow-acceptance.schema.json | Flow Agents Workflow Acceptance | https://flow-agents.dev/schemas/workflow-acceptance.schema.json |
56
59
  | workflow-critique.schema.json | Flow Agents Workflow Critique | https://flow-agents.dev/schemas/workflow-critique.schema.json |
@@ -109,10 +112,10 @@ Primary tools: `npm run workflow:sidecar`, `npm run workflow:validate-artifacts`
109
112
  | tool-explore-patterns | kimi-k2.5 | 6 | Delegate to me for Pattern detection - identifies architectural patterns, frameworks, and coding conventions |
110
113
  | tool-explore-structure | kimi-k2.5 | 6 | Delegate to me to scout out the project structure - maps directory layout and identifies key folders in a codebase |
111
114
  | tool-explore-tests | kimi-k2.5 | 6 | Delegate to me to find and understand testing strategies - locates test files and understands testing strategy |
112
- | tool-planner | claude-sonnet-4.6-1m | 7 | Delegate to me for codebase analysis and execution planning. Explores code, identifies patterns and dependencies, and writes plan/sidecar artifacts under .flow-agents. No production file modifications. |
115
+ | tool-planner | claude-sonnet-4.6-1m | 7 | Delegate to me for codebase analysis and execution planning. Explores code, identifies patterns and dependencies, and writes plan/sidecar artifacts under .kontourai/flow-agents. No production file modifications. |
113
116
  | tool-playwright | claude-sonnet-4.6-1m | 25 | Delegate to me for browser automation, testing, and debugging - loading real pages, testing navigation, checking accessibility via structured snapshots, evaluating scripts, and visual verification. Anything that would otherwise require a... |
114
117
  | tool-security-reviewer | claude-sonnet-4.6-1m | 7 | Delegate to me for security analysis. Checks OWASP Top 10, secrets detection, input validation, injection vulnerabilities, auth/authz, and rate limiting. Read-only analysis with shell for scanning tools. |
115
- | tool-verifier | claude-sonnet-4.6-1m | 8 | Delegate to me for implementation verification. Read-only + shell for source code; writes review/evidence artifacts under .flow-agents. Verifies acceptance criteria and produces PASS/FAIL/NOT_VERIFIED verdicts with evidence. No productio... |
118
+ | tool-verifier | claude-sonnet-4.6-1m | 8 | Delegate to me for implementation verification. Read-only + shell for source code; writes review/evidence artifacts under .kontourai/flow-agents. Verifies acceptance criteria and produces PASS/FAIL/NOT_VERIFIED verdicts with evidence. No... |
116
119
  | tool-worker | claude-sonnet-4.6-1m | 1 | Delegate to me for writing and developing source code for a project. Works best when a detailed plan can be provided. NO access to web tools. Can be used in parallel for any coding tasks that require trusted access to the write and shell... |
117
120
 
118
121
  ## Optional Powers
@@ -125,7 +128,7 @@ Primary tools: `npm run workflow:sidecar`, `npm run workflow:validate-artifacts`
125
128
  ## Current Workflow State
126
129
 
127
130
  Runtime workflow state is excluded from the committed map.
128
- Regenerate locally with `npm run context-map -- --include-runtime` to include recent `.flow-agents` state.
131
+ Regenerate locally with `npm run context-map -- --include-runtime` to include recent `.kontourai/flow-agents` state.
129
132
 
130
133
  ## Context Loading Rules
131
134