@kontourai/flow-agents 2.2.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 +46 -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
@@ -32,11 +32,11 @@ trap cleanup EXIT
32
32
  # ── helper: seed a minimal delivered workflow artifact ────────────────────────
33
33
  seed_repo() { # $1=dir $2=slug
34
34
  local p="$1" slug="$2"
35
- mkdir -p "$p/.flow-agents/$slug"
35
+ mkdir -p "$p/.kontourai/flow-agents/$slug"
36
36
  printf '# Repo\n' > "$p/AGENTS.md"
37
37
  printf '%s' "{\"schema_version\":\"1.0\",\"task_slug\":\"$slug\",\"status\":\"delivered\",\"phase\":\"done\",\"updated_at\":\"2026-06-23T00:00:00Z\",\"next_action\":{\"status\":\"done\",\"summary\":\"done\"}}" \
38
- > "$p/.flow-agents/$slug/state.json"
39
- cat > "$p/.flow-agents/$slug/$slug--deliver.md" << MD
38
+ > "$p/.kontourai/flow-agents/$slug/state.json"
39
+ cat > "$p/.kontourai/flow-agents/$slug/$slug--deliver.md" << MD
40
40
  # $slug
41
41
 
42
42
  branch: main
@@ -71,12 +71,12 @@ echo "Test 1: altered entry (flip fail→pass without fixing hash) → broken
71
71
  T1="$TMP/t1"; seed_repo "$T1" t1
72
72
  write_chained_log "$T1" t1
73
73
 
74
- LOG="$T1/.flow-agents/t1/command-log.jsonl"
74
+ LOG="$T1/.kontourai/flow-agents/t1/command-log.jsonl"
75
75
 
76
76
  if [[ -f "$LOG" ]]; then _pass "T1: command-log.jsonl written"; else _fail "T1: command-log.jsonl missing"; fi
77
77
 
78
78
  # Verify clean chain (before tamper)
79
- chain_status=$(node -e "const g = require('$GATE'); const r = g.verifyCommandLogChain('$T1/.flow-agents/t1'); console.log(r.status);")
79
+ chain_status=$(node -e "const g = require('$GATE'); const r = g.verifyCommandLogChain('$T1/.kontourai/flow-agents/t1'); console.log(r.status);")
80
80
  if [[ "$chain_status" == "ok" ]]; then
81
81
  _pass "T1: untampered chain verifies as ok"
82
82
  else
@@ -97,7 +97,7 @@ open(sys.argv[1], 'w').write('\n'.join(lines) + '\n')
97
97
  PY
98
98
 
99
99
  # Verify broken chain
100
- chain_after=$(node -e "const g = require('$GATE'); const r = g.verifyCommandLogChain('$T1/.flow-agents/t1'); console.log(r.status + ':' + r.brokenAt);")
100
+ chain_after=$(node -e "const g = require('$GATE'); const r = g.verifyCommandLogChain('$T1/.kontourai/flow-agents/t1'); console.log(r.status + ':' + r.brokenAt);")
101
101
  if [[ "$chain_after" == "broken:1" ]]; then
102
102
  _pass "T1: tampered entry detected → broken at entry 1"
103
103
  else
@@ -108,7 +108,7 @@ fi
108
108
  # The tampered entry (lint) was a FAIL flipped to PASS — so the log now shows a false pass.
109
109
  # Since chain is broken, gate should block with integrity warning and NOT trust log passes.
110
110
  printf '%s' '{"schema_version":"1.0","task_slug":"t1","verdict":"pass","checks":[{"id":"npm-test","kind":"command","status":"pass","command":"npm test","summary":"passed"}]}' \
111
- > "$T1/.flow-agents/t1/evidence.json"
111
+ > "$T1/.kontourai/flow-agents/t1/evidence.json"
112
112
 
113
113
  set +e
114
114
  gate_out=$(FLOW_AGENTS_GOAL_FIT_MODE=block FLOW_AGENTS_GOAL_FIT_BACKSTOP=skip \
@@ -141,7 +141,7 @@ echo "Test 2: removed/reordered entry → linkage breaks → broken → gate fla
141
141
  T2="$TMP/t2"; seed_repo "$T2" t2
142
142
  write_chained_log "$T2" t2
143
143
 
144
- LOG2="$T2/.flow-agents/t2/command-log.jsonl"
144
+ LOG2="$T2/.kontourai/flow-agents/t2/command-log.jsonl"
145
145
  lines_before=$(wc -l < "$LOG2" | tr -d ' ')
146
146
 
147
147
  # Reorder: swap entry 0 and entry 1
@@ -153,7 +153,7 @@ lines[0], lines[1] = lines[1], lines[0]
153
153
  open(sys.argv[1], 'w').write('\n'.join(lines) + '\n')
154
154
  PY
155
155
 
156
- chain_reorder=$(node -e "const g = require('$GATE'); const r = g.verifyCommandLogChain('$T2/.flow-agents/t2'); console.log(r.status);")
156
+ chain_reorder=$(node -e "const g = require('$GATE'); const r = g.verifyCommandLogChain('$T2/.kontourai/flow-agents/t2'); console.log(r.status);")
157
157
  if [[ "$chain_reorder" == "broken" ]]; then
158
158
  _pass "T2: reordered entries detected → broken"
159
159
  else
@@ -163,7 +163,7 @@ fi
163
163
  # Test: delete middle entry (restore then delete entry 0 so entry 1's prevHash is wrong)
164
164
  write_chained_log "$T2" t2 # re-append fresh entries (now 4 total — but that's fine for test)
165
165
  # Write a fresh log with just 2 entries and then delete the first
166
- LOG2_FRESH="$T2/.flow-agents/t2/command-log.jsonl"
166
+ LOG2_FRESH="$T2/.kontourai/flow-agents/t2/command-log.jsonl"
167
167
  python3 - "$LOG2_FRESH" << 'PY'
168
168
  import sys
169
169
  lines = [l for l in open(sys.argv[1]).read().strip().split('\n') if l.strip()]
@@ -173,7 +173,7 @@ last2 = lines[-2:]
173
173
  open(sys.argv[1], 'w').write(last2[1] + '\n')
174
174
  PY
175
175
 
176
- chain_delete=$(node -e "const g = require('$GATE'); const r = g.verifyCommandLogChain('$T2/.flow-agents/t2'); console.log(r.status);")
176
+ chain_delete=$(node -e "const g = require('$GATE'); const r = g.verifyCommandLogChain('$T2/.kontourai/flow-agents/t2'); console.log(r.status);")
177
177
  if [[ "$chain_delete" == "broken" ]]; then
178
178
  _pass "T2: removed predecessor entry detected → broken (prevHash mismatch)"
179
179
  else
@@ -191,7 +191,7 @@ printf '{"hook_event_name":"PostToolUse","tool_name":"Bash","cwd":"%s","tool_inp
191
191
  printf '{"hook_event_name":"PostToolUse","tool_name":"Bash","cwd":"%s","tool_input":{"command":"npm run build"},"tool_response":{"exitCode":1}}' "$T3" \
192
192
  | node "$CAPTURE" >/dev/null 2>&1
193
193
 
194
- chain_legit=$(node -e "const g = require('$GATE'); const r = g.verifyCommandLogChain('$T3/.flow-agents/t3'); console.log(r.status);")
194
+ chain_legit=$(node -e "const g = require('$GATE'); const r = g.verifyCommandLogChain('$T3/.kontourai/flow-agents/t3'); console.log(r.status);")
195
195
  if [[ "$chain_legit" == "ok" ]]; then
196
196
  _pass "T3: untampered chained log verifies ok"
197
197
  else
@@ -200,7 +200,7 @@ fi
200
200
 
201
201
  # Evidence claims npm run build passed (it actually failed → capture log shows fail → block)
202
202
  printf '%s' '{"schema_version":"1.0","task_slug":"t3","verdict":"pass","checks":[{"id":"build","kind":"command","status":"pass","command":"npm run build","summary":"build passed"}]}' \
203
- > "$T3/.flow-agents/t3/evidence.json"
203
+ > "$T3/.kontourai/flow-agents/t3/evidence.json"
204
204
 
205
205
  set +e
206
206
  gate3_out=$(FLOW_AGENTS_GOAL_FIT_MODE=block FLOW_AGENTS_GOAL_FIT_BACKSTOP=skip \
@@ -234,9 +234,9 @@ T4="$TMP/t4"; seed_repo "$T4" t4
234
234
 
235
235
  # Write a legacy-style log (no _chain field) — exactly like pre-B2 fixtures
236
236
  printf '%s\n' '{"command":"npm test","observedResult":"fail","exitCode":1,"capturedAt":"2026-06-23T00:00:00Z","source":"postToolUse-capture"}' \
237
- > "$T4/.flow-agents/t4/command-log.jsonl"
237
+ > "$T4/.kontourai/flow-agents/t4/command-log.jsonl"
238
238
 
239
- chain_legacy=$(node -e "const g = require('$GATE'); const r = g.verifyCommandLogChain('$T4/.flow-agents/t4'); console.log(r.status);")
239
+ chain_legacy=$(node -e "const g = require('$GATE'); const r = g.verifyCommandLogChain('$T4/.kontourai/flow-agents/t4'); console.log(r.status);")
240
240
  if [[ "$chain_legacy" == "legacy" ]]; then
241
241
  _pass "T4: unchained (legacy) log returns legacy status"
242
242
  else
@@ -245,7 +245,7 @@ fi
245
245
 
246
246
  # Evidence claims npm test passed, but legacy log shows it failed → still blocks
247
247
  printf '%s' '{"schema_version":"1.0","task_slug":"t4","verdict":"pass","checks":[{"id":"unit-tests","kind":"command","status":"pass","command":"npm test","summary":"passed"}]}' \
248
- > "$T4/.flow-agents/t4/evidence.json"
248
+ > "$T4/.kontourai/flow-agents/t4/evidence.json"
249
249
 
250
250
  set +e
251
251
  gate4_out=$(FLOW_AGENTS_GOAL_FIT_MODE=block FLOW_AGENTS_GOAL_FIT_BACKSTOP=skip \
@@ -102,7 +102,7 @@ if jq -e --arg generated "$GENERATED_AT" '
102
102
  .derivedFrom.eventHistory == "unavailable" and
103
103
  .derivedFrom.directSnapshot.emittedAt == $generated and
104
104
  .derivedFrom.directSnapshot.producer == {"id":"flow-agents-learning","product":"flow-agents"} and
105
- .derivedFrom.directSnapshot.sourceRef == {"product":"flow-agents","kind":"workflow-learning","id":".flow-agents/*/learning.json","label":"Local workflow learning sidecars"} and
105
+ .derivedFrom.directSnapshot.sourceRef == {"product":"flow-agents","kind":"workflow-learning","id":".kontourai/flow-agents/*/learning.json","label":"Local workflow learning sidecars"} and
106
106
  (.learnings | length) == 2
107
107
  ' "$PROJECTION" >/dev/null 2>&1; then
108
108
  _pass "projection envelope includes Console schema, scope, producer, and direct snapshot provenance"
@@ -103,6 +103,151 @@ else
103
103
  _fail "resolver: CJS require failed"
104
104
  fi
105
105
 
106
+ # Test 6: composed Builder closeout step resolves through builder.publish-learn
107
+ if node --input-type=module << NODEEOF
108
+ import { resolveFlowStep } from '${_RESOLVER_MOD}';
109
+ const r = resolveFlowStep('builder.build', 'pr-open', '${ROOT}');
110
+ if (!r) throw new Error('expected non-null result for builder.build/pr-open');
111
+ if (r.flowId !== 'builder.build') throw new Error('expected active flowId builder.build, got ' + r.flowId);
112
+ if (r.sourceFlowId !== 'builder.publish-learn') throw new Error('expected sourceFlowId builder.publish-learn, got ' + r.sourceFlowId);
113
+ if (r.gateId !== 'builder.publish-learn:pr-open-gate') throw new Error('expected composed gate id, got ' + r.gateId);
114
+ const claim = r.gateExpects.find(e => e.bundle_claim.claimType === 'builder.pr-open.pull-request');
115
+ if (!claim) throw new Error('expected builder.pr-open.pull-request in composed expects');
116
+ NODEEOF
117
+ then
118
+ _pass "resolver: builder.build/pr-open resolves composed builder.publish-learn gate"
119
+ else
120
+ _fail "resolver: builder.build/pr-open composed gate failed"
121
+ fi
122
+
123
+ # Test 7: composed child gates must export every imported expectation
124
+ COMPOSE_DEFS="$TMP/compose-defs"
125
+ mkdir -p "$COMPOSE_DEFS"
126
+ cat > "$COMPOSE_DEFS/test.parent.flow.json" <<'JSON'
127
+ {
128
+ "id": "test.parent",
129
+ "version": "1.0.0",
130
+ "steps": [{ "id": "compose", "next": null, "uses_flow": "test.child" }],
131
+ "gates": {}
132
+ }
133
+ JSON
134
+ cat > "$COMPOSE_DEFS/test.child.flow.json" <<'JSON'
135
+ {
136
+ "id": "test.child",
137
+ "version": "1.0.0",
138
+ "steps": [{ "id": "compose", "next": null }],
139
+ "exports": ["test.child.allowed"],
140
+ "gates": {
141
+ "compose-gate": {
142
+ "step": "compose",
143
+ "expects": [
144
+ {
145
+ "id": "allowed",
146
+ "kind": "trust.bundle",
147
+ "required": true,
148
+ "bundle_claim": {
149
+ "claimType": "test.child.allowed",
150
+ "subjectType": "flow-step",
151
+ "accepted_statuses": ["trusted", "accepted"]
152
+ }
153
+ }
154
+ ]
155
+ }
156
+ }
157
+ }
158
+ JSON
159
+
160
+ if FLOW_AGENTS_FLOW_DEFS_DIR="$COMPOSE_DEFS" node --input-type=module << NODEEOF
161
+ import { resolveFlowStep } from '${_RESOLVER_MOD}';
162
+ const r = resolveFlowStep('test.parent', 'compose', '${ROOT}');
163
+ if (!r) throw new Error('expected exported composition to resolve');
164
+ if (r.sourceFlowId !== 'test.child') throw new Error('expected sourceFlowId test.child, got ' + r.sourceFlowId);
165
+ if (!r.gateExpects.some(e => e.bundle_claim.claimType === 'test.child.allowed')) throw new Error('missing exported claim');
166
+ NODEEOF
167
+ then
168
+ _pass "resolver: composed child exports allow imported gate expectations"
169
+ else
170
+ _fail "resolver: exported composed child claim failed"
171
+ fi
172
+
173
+ cat > "$COMPOSE_DEFS/test.child.flow.json" <<'JSON'
174
+ {
175
+ "id": "test.child",
176
+ "version": "1.0.0",
177
+ "steps": [{ "id": "compose", "next": null }],
178
+ "exports": ["test.child.other"],
179
+ "gates": {
180
+ "compose-gate": {
181
+ "step": "compose",
182
+ "expects": [
183
+ {
184
+ "id": "allowed",
185
+ "kind": "trust.bundle",
186
+ "required": true,
187
+ "bundle_claim": {
188
+ "claimType": "test.child.allowed",
189
+ "subjectType": "flow-step",
190
+ "accepted_statuses": ["trusted", "accepted"]
191
+ }
192
+ }
193
+ ]
194
+ }
195
+ }
196
+ }
197
+ JSON
198
+
199
+ if FLOW_AGENTS_FLOW_DEFS_DIR="$COMPOSE_DEFS" node --input-type=module << NODEEOF
200
+ import { resolveFlowStep } from '${_RESOLVER_MOD}';
201
+ const r = resolveFlowStep('test.parent', 'compose', '${ROOT}');
202
+ if (r !== null) throw new Error('expected non-exported composition to fail closed');
203
+ NODEEOF
204
+ then
205
+ _pass "resolver: non-exported composed child claims fail closed"
206
+ else
207
+ _fail "resolver: non-exported composed child claim was imported"
208
+ fi
209
+
210
+ cat > "$COMPOSE_DEFS/test.child.flow.json" <<'JSON'
211
+ {
212
+ "id": "test.child",
213
+ "version": "1.0.0",
214
+ "steps": [{ "id": "compose", "next": null, "uses_flow": "test.child" }],
215
+ "exports": ["test.child.allowed"],
216
+ "gates": {}
217
+ }
218
+ JSON
219
+
220
+ if FLOW_AGENTS_FLOW_DEFS_DIR="$COMPOSE_DEFS" node --input-type=module << NODEEOF
221
+ import { resolveFlowStep } from '${_RESOLVER_MOD}';
222
+ const r = resolveFlowStep('test.parent', 'compose', '${ROOT}');
223
+ if (r !== null) throw new Error('expected self-cycle composition to return null');
224
+ NODEEOF
225
+ then
226
+ _pass "resolver: composed flow self-cycle returns null"
227
+ else
228
+ _fail "resolver: composed flow self-cycle did not fail closed"
229
+ fi
230
+
231
+ cat > "$COMPOSE_DEFS/test.parent.flow.json" <<'JSON'
232
+ {
233
+ "id": "test.parent",
234
+ "version": "1.0.0",
235
+ "steps": [{ "id": "compose", "next": null, "uses_flow": "../outside" }],
236
+ "gates": {}
237
+ }
238
+ JSON
239
+
240
+ if FLOW_AGENTS_FLOW_DEFS_DIR="$COMPOSE_DEFS" node --input-type=module << NODEEOF
241
+ import { resolveFlowStep } from '${_RESOLVER_MOD}';
242
+ const r = resolveFlowStep('test.parent', 'compose', '${ROOT}');
243
+ if (r !== null) throw new Error('expected invalid uses_flow id to return null');
244
+ NODEEOF
245
+ then
246
+ _pass "resolver: invalid composed uses_flow id returns null"
247
+ else
248
+ _fail "resolver: invalid composed uses_flow id did not fail closed"
249
+ fi
250
+
106
251
  echo ""
107
252
  echo "── P-d declared-only: session WITH active_flow_id=builder.build / active_step_id=verify ──"
108
253
 
@@ -34,11 +34,11 @@ trap cleanup EXIT
34
34
  # ─── helper: seed a minimal delivered workflow artifact ───────────────────────
35
35
  seed_repo() { # $1=dir $2=slug
36
36
  local p="$1" slug="$2"
37
- mkdir -p "$p/.flow-agents/$slug"
37
+ mkdir -p "$p/.kontourai/flow-agents/$slug"
38
38
  printf '# Repo\n' > "$p/AGENTS.md"
39
39
  printf '%s' "{\"schema_version\":\"1.0\",\"task_slug\":\"$slug\",\"status\":\"delivered\",\"phase\":\"done\",\"updated_at\":\"2026-06-26T00:00:00Z\",\"next_action\":{\"status\":\"done\",\"summary\":\"done\"}}" \
40
- > "$p/.flow-agents/$slug/state.json"
41
- cat > "$p/.flow-agents/$slug/$slug--deliver.md" << MD
40
+ > "$p/.kontourai/flow-agents/$slug/state.json"
41
+ cat > "$p/.kontourai/flow-agents/$slug/$slug--deliver.md" << MD
42
42
  # $slug
43
43
 
44
44
  branch: main
@@ -67,12 +67,12 @@ seed_repo "$T1_DIR" "declares-tampered"
67
67
 
68
68
  # current.json: active flow
69
69
  printf '%s' '{"artifact_dir":"declares-tampered","active_flow_id":"builder.build","active_step_id":"verify"}' \
70
- > "$T1_DIR/.flow-agents/current.json"
70
+ > "$T1_DIR/.kontourai/flow-agents/current.json"
71
71
 
72
- python3 - "$T1_DIR/.flow-agents/declares-tampered/trust.bundle" << 'PY'
72
+ python3 - "$T1_DIR/.kontourai/flow-agents/declares-tampered/trust.bundle" << 'PY'
73
73
  import json, sys
74
74
  bundle = {
75
- "schemaVersion": 3,
75
+ "schemaVersion": 5,
76
76
  "source": "flow-agents/workflow-sidecar",
77
77
  "claims": [{
78
78
  "id": "c1",
@@ -152,12 +152,12 @@ T2_DIR="$TMP/t2"
152
152
  seed_repo "$T2_DIR" "declares-clean"
153
153
 
154
154
  printf '%s' '{"artifact_dir":"declares-clean","active_flow_id":"builder.build","active_step_id":"verify"}' \
155
- > "$T2_DIR/.flow-agents/current.json"
155
+ > "$T2_DIR/.kontourai/flow-agents/current.json"
156
156
 
157
- python3 - "$T2_DIR/.flow-agents/declares-clean/trust.bundle" << 'PY'
157
+ python3 - "$T2_DIR/.kontourai/flow-agents/declares-clean/trust.bundle" << 'PY'
158
158
  import json, sys
159
159
  bundle = {
160
- "schemaVersion": 3,
160
+ "schemaVersion": 5,
161
161
  "source": "flow-agents/workflow-sidecar",
162
162
  "claims": [{
163
163
  "id": "c2",
@@ -227,12 +227,12 @@ seed_repo "$T3_DIR" "no-flow"
227
227
 
228
228
  # No current.json flow keys (empty current.json that is still valid)
229
229
  printf '%s' '{"artifact_dir":"no-flow"}' \
230
- > "$T3_DIR/.flow-agents/current.json"
230
+ > "$T3_DIR/.kontourai/flow-agents/current.json"
231
231
 
232
- python3 - "$T3_DIR/.flow-agents/no-flow/trust.bundle" << 'PY'
232
+ python3 - "$T3_DIR/.kontourai/flow-agents/no-flow/trust.bundle" << 'PY'
233
233
  import json, sys
234
234
  bundle = {
235
- "schemaVersion": 3,
235
+ "schemaVersion": 5,
236
236
  "source": "flow-agents/workflow-sidecar",
237
237
  "claims": [{
238
238
  "id": "c3",
@@ -2,7 +2,7 @@
2
2
  # test_evidence_capture_hook.sh — Capture-first evidence determinism contracts.
3
3
  #
4
4
  # Part A: evidence-capture.js deterministically records command executions to
5
- # .flow-agents/<slug>/command-log.jsonl (machine-recorded, not model-claimed).
5
+ # .kontourai/flow-agents/<slug>/command-log.jsonl (machine-recorded, not model-claimed).
6
6
  # Part B: stop-goal-fit.js cross-references evidence.json claimed-pass command
7
7
  # checks against the capture log, and re-runs a TRUSTED backstop command
8
8
  # only when the log has no execution for a claimed-pass command.
@@ -23,10 +23,10 @@ _fail() { echo " ✗ $1"; errors=$((errors + 1)); }
23
23
  # ---- helpers -------------------------------------------------------------
24
24
  seed_repo() { # $1 dir, $2 slug
25
25
  local p="$1" slug="$2"
26
- mkdir -p "$p/.flow-agents/$slug"
26
+ mkdir -p "$p/.kontourai/flow-agents/$slug"
27
27
  printf '# Repo\n' > "$p/AGENTS.md"
28
- printf '%s' "{\"schema_version\":\"1.0\",\"task_slug\":\"$slug\",\"status\":\"delivered\",\"phase\":\"done\",\"updated_at\":\"2026-06-23T00:00:00Z\",\"next_action\":{\"status\":\"done\",\"summary\":\"done\"}}" > "$p/.flow-agents/$slug/state.json"
29
- cat > "$p/.flow-agents/$slug/$slug--deliver.md" <<MD
28
+ printf '%s' "{\"schema_version\":\"1.0\",\"task_slug\":\"$slug\",\"status\":\"delivered\",\"phase\":\"done\",\"updated_at\":\"2026-06-23T00:00:00Z\",\"next_action\":{\"status\":\"done\",\"summary\":\"done\"}}" > "$p/.kontourai/flow-agents/$slug/state.json"
29
+ cat > "$p/.kontourai/flow-agents/$slug/$slug--deliver.md" <<MD
30
30
  # $slug
31
31
 
32
32
  branch: main
@@ -59,7 +59,7 @@ printf '{"hook_event_name":"PostToolUse","tool_name":"Bash","cwd":"%s","tool_inp
59
59
  # A non-command tool (Write) must NOT be captured.
60
60
  printf '{"hook_event_name":"PostToolUse","tool_name":"Write","cwd":"%s","tool_input":{"file_path":"/tmp/x"}}' "$A" | capture
61
61
 
62
- LOG="$A/.flow-agents/t1/command-log.jsonl"
62
+ LOG="$A/.kontourai/flow-agents/t1/command-log.jsonl"
63
63
  if [[ -f "$LOG" ]]; then _pass "capture writes command-log.jsonl"; else _fail "capture did not write command-log.jsonl"; fi
64
64
 
65
65
  lines=$(wc -l < "$LOG" | tr -d ' ')
@@ -90,8 +90,8 @@ else _fail "capture should be non-blocking and echo stdin"; fi
90
90
  # ============================================================================
91
91
  echo "Part B1: log contradicts claimed pass → block"
92
92
  B="$TMP/contradict"; seed_repo "$B" t1
93
- printf '%s' '{"schema_version":"1.0","task_slug":"t1","verdict":"pass","checks":[{"id":"unit-tests","kind":"command","status":"pass","command":"npm test","summary":"tests passed"}]}' > "$B/.flow-agents/t1/evidence.json"
94
- printf '%s\n' '{"command":"npm test","observedResult":"fail","exitCode":1,"capturedAt":"2026-06-23T00:00:00Z","source":"postToolUse-capture"}' > "$B/.flow-agents/t1/command-log.jsonl"
93
+ printf '%s' '{"schema_version":"1.0","task_slug":"t1","verdict":"pass","checks":[{"id":"unit-tests","kind":"command","status":"pass","command":"npm test","summary":"tests passed"}]}' > "$B/.kontourai/flow-agents/t1/evidence.json"
94
+ printf '%s\n' '{"command":"npm test","observedResult":"fail","exitCode":1,"capturedAt":"2026-06-23T00:00:00Z","source":"postToolUse-capture"}' > "$B/.kontourai/flow-agents/t1/command-log.jsonl"
95
95
 
96
96
  if FLOW_AGENTS_GOAL_FIT_MODE=block FLOW_AGENTS_GOAL_FIT_BACKSTOP=skip node "$GATE" >/dev/null 2>"$TMP/b1.err" <<JSON
97
97
  {"hook_event_name":"Stop","cwd":"$B"}
@@ -109,8 +109,8 @@ fi
109
109
  # ============================================================================
110
110
  echo "Part B2: log confirms claimed pass → satisfied, no re-run"
111
111
  C="$TMP/confirm"; seed_repo "$C" t1
112
- printf '%s' '{"schema_version":"1.0","task_slug":"t1","verdict":"pass","checks":[{"id":"unit-tests","kind":"command","status":"pass","command":"npm test","summary":"tests passed"}]}' > "$C/.flow-agents/t1/evidence.json"
113
- printf '%s\n' '{"command":"npm test","observedResult":"pass","exitCode":0,"capturedAt":"2026-06-23T00:00:00Z","source":"postToolUse-capture"}' > "$C/.flow-agents/t1/command-log.jsonl"
112
+ printf '%s' '{"schema_version":"1.0","task_slug":"t1","verdict":"pass","checks":[{"id":"unit-tests","kind":"command","status":"pass","command":"npm test","summary":"tests passed"}]}' > "$C/.kontourai/flow-agents/t1/evidence.json"
113
+ printf '%s\n' '{"command":"npm test","observedResult":"pass","exitCode":0,"capturedAt":"2026-06-23T00:00:00Z","source":"postToolUse-capture"}' > "$C/.kontourai/flow-agents/t1/command-log.jsonl"
114
114
  # A poisoned npm on PATH proves the gate does NOT re-run when the log confirms.
115
115
  POISON="$TMP/poison"; mkdir -p "$POISON"
116
116
  printf '#!/usr/bin/env bash\necho "npm should not run" >&2\nexit 99\n' > "$POISON/npm"; chmod +x "$POISON/npm"
@@ -127,7 +127,7 @@ else _pass "gate trusts the log on a confirmed pass and does not re-run the back
127
127
  echo "Part B3: never-captured claim → trusted manifest backstop catches a fail"
128
128
  D="$TMP/backstop"; seed_repo "$D" t1
129
129
  printf '%s' '{"name":"x","scripts":{"test":"exit 7"}}' > "$D/package.json"
130
- printf '%s' '{"schema_version":"1.0","task_slug":"t1","verdict":"pass","checks":[{"id":"unit-tests","kind":"command","status":"pass","command":"npm test","summary":"tests passed"}]}' > "$D/.flow-agents/t1/evidence.json"
130
+ printf '%s' '{"schema_version":"1.0","task_slug":"t1","verdict":"pass","checks":[{"id":"unit-tests","kind":"command","status":"pass","command":"npm test","summary":"tests passed"}]}' > "$D/.kontourai/flow-agents/t1/evidence.json"
131
131
  # command-log.jsonl intentionally absent — the command was never actually run.
132
132
 
133
133
  if FLOW_AGENTS_GOAL_FIT_MODE=block node "$GATE" >/dev/null 2>"$TMP/b3.err" <<JSON
@@ -146,9 +146,10 @@ fi
146
146
  # ============================================================================
147
147
  echo "Part B4: never-captured claim, nothing trusted resolves → NOT_VERIFIED"
148
148
  E="$TMP/notverified"; seed_repo "$E" t1
149
- printf '%s' '{"schema_version":"1.0","task_slug":"t1","verdict":"pass","checks":[{"id":"custom","kind":"command","status":"pass","command":"./my-thing.sh","summary":"ran custom"}]}' > "$E/.flow-agents/t1/evidence.json"
149
+ printf '%s' '{"schema_version":"1.0","task_slug":"t1","status":"in_progress","phase":"verification","updated_at":"2026-06-23T00:00:00Z","next_action":{"status":"continue","summary":"verify command evidence"}}' > "$E/.kontourai/flow-agents/t1/state.json"
150
+ printf '%s' '{"schema_version":"1.0","task_slug":"t1","verdict":"pass","checks":[{"id":"custom","kind":"command","status":"pass","command":"./my-thing.sh","summary":"ran custom"}]}' > "$E/.kontourai/flow-agents/t1/evidence.json"
150
151
 
151
- if FLOW_AGENTS_GOAL_FIT_MODE=block node "$GATE" >/dev/null 2>"$TMP/b4.err" <<JSON
152
+ if FLOW_AGENTS_GOAL_FIT_MODE=block FLOW_AGENTS_GOAL_FIT_RECHECK=false node "$GATE" >/dev/null 2>"$TMP/b4.err" <<JSON
152
153
  {"hook_event_name":"Stop","cwd":"$E"}
153
154
  JSON
154
155
  then _fail "gate should not silently pass an un-captured, un-verifiable claimed-pass command"
@@ -164,7 +165,7 @@ fi
164
165
  # ============================================================================
165
166
  echo "Part B5: free-form model command re-run is opt-in only"
166
167
  F="$TMP/recheck"; seed_repo "$F" t1
167
- printf '%s' '{"schema_version":"1.0","task_slug":"t1","verdict":"pass","checks":[{"id":"custom","kind":"command","status":"pass","command":"exit 5","summary":"ran custom"}]}' > "$F/.flow-agents/t1/evidence.json"
168
+ printf '%s' '{"schema_version":"1.0","task_slug":"t1","verdict":"pass","checks":[{"id":"custom","kind":"command","status":"pass","command":"exit 5","summary":"ran custom"}]}' > "$F/.kontourai/flow-agents/t1/evidence.json"
168
169
  # Opt-in ON: the model's free-form "exit 5" is re-run and fails → block.
169
170
  if FLOW_AGENTS_GOAL_FIT_MODE=block FLOW_AGENTS_GOAL_FIT_RECHECK=true node "$GATE" >/dev/null 2>"$TMP/b5.err" <<JSON
170
171
  {"hook_event_name":"Stop","cwd":"$F"}
@@ -21,9 +21,9 @@ json_query() {
21
21
  node -e 'const fs=require("fs"); let cur=JSON.parse(fs.readFileSync(process.argv[1],"utf8")); for (const part of process.argv[2].split(".")) cur=Array.isArray(cur) ? cur[Number(part)] : cur[part]; console.log(cur);' "$1" "$2"
22
22
  }
23
23
 
24
- [[ "$(json_query "$TMPDIR_EVAL/audit.json" "totals.scanned")" == "11" ]] && pass "audit scans all fixture groups" || fail "audit scans all fixture groups"
24
+ [[ "$(json_query "$TMPDIR_EVAL/audit.json" "totals.scanned")" == "14" ]] && pass "audit scans all fixture groups" || fail "audit scans all fixture groups"
25
25
  [[ "$(json_query "$TMPDIR_EVAL/audit.json" "totals.retire_candidates")" == "0" ]] && pass "audit finds no unowned retire candidates" || fail "audit finds no unowned retire candidates"
26
- [[ "$(json_query "$TMPDIR_EVAL/audit.json" "totals.kept")" == "11" ]] && pass "audit keeps all owned fixture groups" || fail "audit keeps all owned fixture groups"
26
+ [[ "$(json_query "$TMPDIR_EVAL/audit.json" "totals.kept")" == "14" ]] && pass "audit keeps all owned fixture groups" || fail "audit keeps all owned fixture groups"
27
27
 
28
28
  node - "$TMPDIR_EVAL/audit.json" <<'NODE'
29
29
  const fs = require("node:fs");
@@ -18,10 +18,10 @@ echo "=== Layer 2: Flow Agents Statusline ==="
18
18
  echo ""
19
19
 
20
20
  WORKSPACE="$TMPDIR_EVAL/workspace"
21
- TASK_DIR="$WORKSPACE/.flow-agents/status-demo"
21
+ TASK_DIR="$WORKSPACE/.kontourai/flow-agents/status-demo"
22
22
  mkdir -p "$TASK_DIR"
23
23
 
24
- cat >"$WORKSPACE/.flow-agents/current.json" <<'JSON'
24
+ cat >"$WORKSPACE/.kontourai/flow-agents/current.json" <<'JSON'
25
25
  {
26
26
  "schema_version": "1.0",
27
27
  "active_slug": "status-demo",
@@ -31,6 +31,58 @@ FILE_URL="file://$FIXTURE_REPO"
31
31
 
32
32
  echo " (fixture repo: $FILE_URL)"
33
33
 
34
+ # --- Test 0: default destination honors CODEX_HOME and --dest overrides it ---
35
+ DEFAULT_CODEX_HOME="$TMP_DIR/default-codex-home"
36
+ OVERRIDE_DEST="$TMP_DIR/override-dest"
37
+ mkdir -p "$DEFAULT_CODEX_HOME" "$OVERRIDE_DEST"
38
+
39
+ default_out="$TMP_DIR/default-dest.out"
40
+ if CODEX_HOME="$DEFAULT_CODEX_HOME" flow_agents_node "$CLI" install "$VALID_SRC" >"$default_out" 2>&1 \
41
+ && [[ -f "$DEFAULT_CODEX_HOME/kits/local/installed-kits.json" ]] \
42
+ && [[ -d "$DEFAULT_CODEX_HOME/kits/local/repositories/example-kit" ]]; then
43
+ pass "kit install without --dest defaults to CODEX_HOME"
44
+ else
45
+ fail "kit install without --dest did not default to CODEX_HOME"
46
+ sed -n '1,80p' "$default_out"
47
+ fi
48
+
49
+ list_out="$TMP_DIR/default-list.out"
50
+ if CODEX_HOME="$DEFAULT_CODEX_HOME" flow_agents_node "$CLI" list >"$list_out" 2>&1 \
51
+ && grep -q "example-kit" "$list_out"; then
52
+ pass "kit list without --dest reads CODEX_HOME"
53
+ else
54
+ fail "kit list without --dest did not read CODEX_HOME"
55
+ sed -n '1,80p' "$list_out"
56
+ fi
57
+
58
+ status_out="$TMP_DIR/default-status.out"
59
+ if CODEX_HOME="$DEFAULT_CODEX_HOME" flow_agents_node "$CLI" status example-kit >"$status_out" 2>&1 \
60
+ && grep -q '"id": "example-kit"' "$status_out"; then
61
+ pass "kit status without --dest reads CODEX_HOME"
62
+ else
63
+ fail "kit status without --dest did not read CODEX_HOME"
64
+ sed -n '1,80p' "$status_out"
65
+ fi
66
+
67
+ activate_out="$TMP_DIR/default-activate.out"
68
+ if CODEX_HOME="$DEFAULT_CODEX_HOME" flow_agents_node "$CLI" activate --source-root "$ROOT" >"$activate_out" 2>&1 \
69
+ && [[ -f "$DEFAULT_CODEX_HOME/.kontourai/flow-agents/projections/codex/activation.json" ]]; then
70
+ pass "kit activate without --dest writes CODEX_HOME"
71
+ else
72
+ fail "kit activate without --dest did not write CODEX_HOME"
73
+ sed -n '1,80p' "$activate_out"
74
+ fi
75
+
76
+ override_out="$TMP_DIR/override-dest.out"
77
+ if CODEX_HOME="$DEFAULT_CODEX_HOME" flow_agents_node "$CLI" install "$VALID_SRC" --dest "$OVERRIDE_DEST" >"$override_out" 2>&1 \
78
+ && [[ -f "$OVERRIDE_DEST/kits/local/installed-kits.json" ]] \
79
+ && [[ -d "$OVERRIDE_DEST/kits/local/repositories/example-kit" ]]; then
80
+ pass "kit install --dest overrides CODEX_HOME"
81
+ else
82
+ fail "kit install --dest did not override CODEX_HOME"
83
+ sed -n '1,80p' "$override_out"
84
+ fi
85
+
34
86
  # --- Test 1: basic install-git from file:// URL ---
35
87
  install_out="$TMP_DIR/install-git.out"
36
88
  if flow_agents_node "$CLI" install "$FILE_URL" --dest "$DEST" >"$install_out" 2>&1; then
@@ -54,6 +54,7 @@ expect_fail() {
54
54
  echo "=== Flow Kit Repository Fixture Checks ==="
55
55
  expect_pass "valid-local-kit"
56
56
  expect_pass "valid-unknown-extension"
57
+ expect_pass "valid-with-dependency"
57
58
  expect_fail "invalid-schema-version" '\.schema_version must be "1\.0"'
58
59
  expect_fail "invalid-missing-schema-version" '\.schema_version must be "1\.0"'
59
60
  expect_fail "invalid-id" '\.id must be a kebab-case string'
@@ -66,6 +67,7 @@ expect_fail "invalid-malformed-json" 'invalid JSON'
66
67
  expect_fail "invalid-asset-section" '\.docs must be a list'
67
68
  expect_fail "invalid-missing-extension-asset" 'docs\[0\]\.path points at missing asset'
68
69
  expect_fail "invalid-duplicate-flow" "flows\\[1\\]\\.path duplicates"
70
+ expect_fail "invalid-bad-dependency" 'dependencies\[0\]\.kit_id must be a kebab-case'
69
71
 
70
72
  echo ""
71
73
  echo "=== Builder Kit Shared Validation Check ==="
@@ -135,10 +135,10 @@ TAMPER_DIR="$TMP/tamper-verify"
135
135
  TAMPER_SLUG="tamper-verify-test"
136
136
  mkdir -p "$TAMPER_DIR"
137
137
  printf '# Test repo\n' > "$TAMPER_DIR/AGENTS.md"
138
- mkdir -p "$TAMPER_DIR/.flow-agents/$TAMPER_SLUG"
138
+ mkdir -p "$TAMPER_DIR/.kontourai/flow-agents/$TAMPER_SLUG"
139
139
 
140
140
  flow_agents_node "$WRITER" ensure-session \
141
- --artifact-root "$TAMPER_DIR/.flow-agents" \
141
+ --artifact-root "$TAMPER_DIR/.kontourai/flow-agents" \
142
142
  --task-slug "$TAMPER_SLUG" \
143
143
  --title "Tamper verify test" \
144
144
  --summary "Testing tamper detection at verify step." \
@@ -146,21 +146,21 @@ flow_agents_node "$WRITER" ensure-session \
146
146
  --step-id verify \
147
147
  --timestamp "2026-06-01T02:00:00Z" >/dev/null 2>&1
148
148
 
149
- flow_agents_node "$WRITER" init-plan "$TAMPER_DIR/.flow-agents/$TAMPER_SLUG/$TAMPER_SLUG--deliver.md" \
149
+ flow_agents_node "$WRITER" init-plan "$TAMPER_DIR/.kontourai/flow-agents/$TAMPER_SLUG/$TAMPER_SLUG--deliver.md" \
150
150
  --source-request "Test" --summary "Tamper test" \
151
151
  --timestamp "2026-06-01T02:00:00Z" >/dev/null 2>&1
152
152
 
153
- flow_agents_node "$WRITER" advance-state "$TAMPER_DIR/.flow-agents/$TAMPER_SLUG" \
153
+ flow_agents_node "$WRITER" advance-state "$TAMPER_DIR/.kontourai/flow-agents/$TAMPER_SLUG" \
154
154
  --status in_progress --phase verification \
155
155
  --summary "At verify." --next-action "Continue." \
156
156
  --flow-definition builder.build \
157
157
  --timestamp "2026-06-01T02:00:30Z" >/dev/null 2>&1
158
158
 
159
159
  # Write TAMPERED trust.bundle: stored verified, evidence passing=false
160
- python3 - "$TAMPER_DIR/.flow-agents/$TAMPER_SLUG/trust.bundle" << 'PY'
160
+ python3 - "$TAMPER_DIR/.kontourai/flow-agents/$TAMPER_SLUG/trust.bundle" << 'PY'
161
161
  import json, sys
162
162
  bundle = {
163
- "schemaVersion": 3,
163
+ "schemaVersion": 5,
164
164
  "source": "flow-agents/workflow-sidecar",
165
165
  "claims": [{
166
166
  "id": "c1",