@kontourai/flow-agents 3.6.0 → 3.8.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 (96) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/build/src/builder-flow-run-adapter.d.ts +22 -2
  3. package/build/src/builder-flow-run-adapter.js +93 -28
  4. package/build/src/builder-flow-runtime.d.ts +8 -3
  5. package/build/src/builder-flow-runtime.js +407 -51
  6. package/build/src/cli/assignment-provider.d.ts +4 -7
  7. package/build/src/cli/assignment-provider.js +80 -14
  8. package/build/src/cli/builder-run.js +14 -18
  9. package/build/src/cli/workflow-sidecar.d.ts +28 -4
  10. package/build/src/cli/workflow-sidecar.js +825 -103
  11. package/build/src/cli/workflow.js +301 -43
  12. package/build/src/flow-kit/validate.d.ts +17 -0
  13. package/build/src/flow-kit/validate.js +340 -2
  14. package/build/src/index.js +5 -5
  15. package/build/src/lib/observed-command.d.ts +7 -0
  16. package/build/src/lib/observed-command.js +100 -0
  17. package/build/src/tools/build-universal-bundles.js +53 -3
  18. package/build/src/tools/generate-context-map.js +5 -3
  19. package/context/scripts/hooks/lib/kit-catalog.js +1 -1
  20. package/context/scripts/hooks/stop-goal-fit.js +78 -9
  21. package/docs/context-map.md +22 -20
  22. package/docs/developer-architecture.md +1 -1
  23. package/docs/getting-started.md +9 -1
  24. package/docs/public-workflow-cli.md +76 -7
  25. package/docs/skills-map.md +51 -27
  26. package/docs/spec/builder-flow-runtime.md +75 -40
  27. package/docs/workflow-usage-guide.md +109 -42
  28. package/evals/fixtures/hook-influence/cases.json +2 -2
  29. package/evals/integration/test_builder_entry_enforcement.sh +52 -41
  30. package/evals/integration/test_builder_step_producers.sh +330 -6
  31. package/evals/integration/test_bundle_install.sh +318 -65
  32. package/evals/integration/test_bundle_lifecycle.sh +4 -6
  33. package/evals/integration/test_critique_supersession_roundtrip.sh +21 -8
  34. package/evals/integration/test_current_json_per_actor.sh +12 -0
  35. package/evals/integration/test_dual_emit_flow_step.sh +62 -43
  36. package/evals/integration/test_flowdef_session_activation.sh +145 -25
  37. package/evals/integration/test_flowdef_session_history_preservation.sh +23 -21
  38. package/evals/integration/test_gate_lockdown.sh +3 -5
  39. package/evals/integration/test_goal_fit_hook.sh +60 -2
  40. package/evals/integration/test_install_merge.sh +18 -8
  41. package/evals/integration/test_liveness_verdict.sh +14 -17
  42. package/evals/integration/test_phase_map_and_gate_claim.sh +63 -38
  43. package/evals/integration/test_public_workflow_cli.sh +334 -14
  44. package/evals/integration/test_pull_work_liveness_preflight.sh +22 -66
  45. package/evals/integration/test_sidecar_field_preservation.sh +36 -11
  46. package/evals/integration/test_workflow_sidecar_writer.sh +277 -44
  47. package/evals/integration/test_workflow_steering_hook.sh +15 -38
  48. package/evals/run.sh +2 -0
  49. package/evals/static/test_builder_skill_coherence.sh +247 -0
  50. package/evals/static/test_library_exports.sh +5 -2
  51. package/evals/static/test_universal_bundles.sh +44 -1
  52. package/evals/static/test_workflow_skills.sh +13 -325
  53. package/kits/builder/flows/build.flow.json +22 -0
  54. package/kits/builder/flows/shape.flow.json +9 -9
  55. package/kits/builder/kit.json +70 -16
  56. package/kits/builder/skills/builder-shape/SKILL.md +75 -75
  57. package/kits/builder/skills/continue-work/SKILL.md +45 -106
  58. package/kits/builder/skills/deliver/SKILL.md +96 -442
  59. package/kits/builder/skills/design-probe/SKILL.md +40 -139
  60. package/kits/builder/skills/evidence-gate/SKILL.md +59 -201
  61. package/kits/builder/skills/execute-plan/SKILL.md +54 -125
  62. package/kits/builder/skills/fix-bug/SKILL.md +42 -132
  63. package/kits/builder/skills/gate-review/SKILL.md +60 -211
  64. package/kits/builder/skills/idea-to-backlog/SKILL.md +63 -244
  65. package/kits/builder/skills/learning-review/SKILL.md +63 -170
  66. package/kits/builder/skills/pickup-probe/SKILL.md +54 -111
  67. package/kits/builder/skills/plan-work/SKILL.md +51 -185
  68. package/kits/builder/skills/pull-work/SKILL.md +136 -485
  69. package/kits/builder/skills/release-readiness/SKILL.md +66 -107
  70. package/kits/builder/skills/review-work/SKILL.md +89 -176
  71. package/kits/builder/skills/tdd-workflow/SKILL.md +53 -147
  72. package/kits/builder/skills/verify-work/SKILL.md +101 -113
  73. package/package.json +2 -2
  74. package/packaging/README.md +1 -1
  75. package/scripts/README.md +1 -1
  76. package/scripts/hooks/lib/kit-catalog.js +1 -1
  77. package/scripts/hooks/stop-goal-fit.js +78 -9
  78. package/scripts/install-codex-home.sh +63 -23
  79. package/scripts/install-owned-files.js +18 -2
  80. package/src/builder-flow-run-adapter.ts +118 -32
  81. package/src/builder-flow-runtime.ts +426 -64
  82. package/src/cli/assignment-provider-lock.test.mjs +83 -0
  83. package/src/cli/assignment-provider.ts +75 -14
  84. package/src/cli/builder-flow-run-adapter.test.mjs +4 -2
  85. package/src/cli/builder-flow-runtime.test.mjs +436 -18
  86. package/src/cli/builder-run.ts +3 -9
  87. package/src/cli/kit-metadata-security.test.mjs +232 -6
  88. package/src/cli/public-api.test.mjs +15 -0
  89. package/src/cli/workflow-sidecar-execution-proof.test.mjs +90 -0
  90. package/src/cli/workflow-sidecar.ts +746 -103
  91. package/src/cli/workflow.ts +288 -41
  92. package/src/flow-kit/validate.ts +320 -2
  93. package/src/index.ts +6 -5
  94. package/src/lib/observed-command.ts +96 -0
  95. package/src/tools/build-universal-bundles.ts +51 -3
  96. package/src/tools/generate-context-map.ts +5 -3
@@ -28,26 +28,29 @@ expectations, and Builder Kit's structured action map.
28
28
 
29
29
  ## Entry And Synchronization
30
30
 
31
- A Builder session is created at the Flow Definition's entry step by the workflow
32
- sidecar. If automatic startup reports a failure, retry the canonical operation with:
31
+ A Builder session is created at the Flow Definition's entry step by the public
32
+ workflow command. Start the selected Work Item with its stable, human-readable
33
+ provider reference:
33
34
 
34
35
  ```bash
35
- flow-agents builder-run start --session-dir .kontourai/flow-agents/<slug>
36
+ flow-agents workflow start --flow builder.build --work-item <provider-ref> \
37
+ --assignment-provider <configured-kind> \
38
+ [--effective-state-json <provider-status.json>]
36
39
  ```
37
40
 
38
- `ensure-session --flow-id builder.build` starts or loads this canonical run before
39
- returning. When the local assignment provider durably assigns the exact Work Item
40
- to the resolved workflow actor, `ensure-session` rereads that record and produces
41
- the declared `builder.pull-work.selected` claim through the normal Surface trust
42
- bundle path. Flow evaluates that subject-bound evidence and advances to
43
- `design-probe`; Flow Agents does not write a transition or gate outcome directly.
44
- Skipped ownership, unresolved actors, precomputed state, and non-local providers do
45
- not produce selection evidence and remain at `pull-work`.
41
+ The configured provider resolves and durably assigns the exact Work Item to the
42
+ workflow actor. Non-local adapters pass their standard status result to start;
43
+ Flow Agents retains it as provenance and creates a local runtime lease mirror.
44
+ The start path then produces the declared
45
+ `builder.pull-work.selected` claim through the normal Surface trust bundle path.
46
+ Flow evaluates that subject-bound evidence and advances to `design-probe`; Flow
47
+ Agents does not write a transition or gate outcome directly. Skipped ownership,
48
+ unresolved actors, precomputed state, and unavailable provider resolution do not
49
+ produce selection evidence and remain at `pull-work`.
46
50
 
47
- The command remains the explicit recovery path if Flow startup fails after sidecar
48
- creation; the failure is returned to the caller and no substitute run state is
49
- invented. Runtime hooks keep projected actions advisory while the agent performs
50
- their declared skills and operations.
51
+ If start fails, the failure is returned to the caller and no substitute run state
52
+ is invented. Runtime hooks keep projected actions advisory while the agent
53
+ performs their declared skills and operations.
51
54
 
52
55
  Sidecars written by 3.4.2 may still contain `next_action.enforcement`. The 1.0
53
56
  schema accepts that deprecated field for artifact compatibility, but current
@@ -58,38 +61,64 @@ Item reference as the Flow run subject. It is idempotent for an existing canonic
58
61
  run. A direct primitive session without a Builder Flow stamp remains independent and
59
62
  does not create a Flow run.
60
63
 
61
- After a gate producer writes `trust.bundle`, the sidecar writer synchronizes an
62
- existing run automatically. Interrupted clients can replay the projected command:
64
+ After a gate producer writes `trust.bundle`, the public evidence path
65
+ synchronizes the existing run while holding the assignment subject lock.
66
+ Synchronization selects only live claims: producer-superseded claims and claims
67
+ carrying `metadata.superseded_by` remain auditable history but never determine
68
+ the current outcome. Passing evidence is published atomically only when every
69
+ required expectation for the gate is present; this prevents sequential critique
70
+ writes from attaching an intermediate partial snapshot and consuming a
71
+ route-back attempt. Failed evidence may still synchronize immediately when it
72
+ carries a route reason declared by the gate; a disputed report-only critique is
73
+ not itself a routed gate decision and remains pending.
74
+
75
+ Attachments carry the exact expectation ids selected from the current bundle.
76
+ Digest idempotence applies only while an unsuperseded attachment for that gate
77
+ and expectation set remains live. After route-back, claims must be current for
78
+ the new gate visit before synchronization, and claim/evidence identities used
79
+ by any earlier attachment to that gate can never satisfy the later visit.
80
+ Gate claims, verified criteria, and critiques carry producer-recorded version
81
+ timestamps plus `identity_version: 2` in their identity derivation so legitimate
82
+ re-verification creates new identities. Unmarked pre-upgrade records retain the
83
+ legacy identity formula during rebuild; installing new code alone can never
84
+ manufacture a fresh identity. Because those identities are embedded in TrustBundle bytes, a
85
+ genuinely new identity necessarily changes the bundle SHA-256; byte-identical
86
+ replay remains pending rather than consuming another attempt.
87
+
88
+ Every gate visit has a canonical boundary: the latest Flow transition into the
89
+ step, or the run's initial timestamp for its entry step. Claim creation and
90
+ observation timestamps must fall within that visit and may not be more than 30
91
+ seconds ahead of synchronization. The sole pre-boundary allowance is the
92
+ 30-second acquisition window for the assignment-backed `selected-work` claim,
93
+ which is intentionally produced immediately before the canonical run starts.
94
+ Previously attached claim and evidence identities are excluded from every later
95
+ visit to the same gate regardless of timestamp skew.
96
+
97
+ ## Public Status And Recovery
98
+
99
+ Inspect an interrupted canonical Builder session with:
63
100
 
64
101
  ```bash
65
- flow-agents builder-run sync --session-dir .kontourai/flow-agents/<slug>
102
+ flow-agents workflow status --session-dir .kontourai/flow-agents/<slug> --json
66
103
  ```
67
104
 
68
- Synchronization is digest-idempotent. The same trust bundle is not attached twice.
69
- Inspection loads the run without evaluating it, so invalid evidence is rejected
70
- before Flow mutation.
105
+ `workflow status` is read-only. It loads the canonical run and reports its run
106
+ identity, definition, status, current step, projected `next_action`, and bound
107
+ session directory. Callers cannot select a different run or force a step.
71
108
 
72
- ## Recovery
73
-
74
- Recover an interrupted canonical Builder session with:
109
+ For an active interrupted run, continue from the reported `next_action` and use
110
+ its exact idempotent command to recheck the canonical state. The current step's
111
+ producer records gate evidence through `flow-agents workflow evidence`; that
112
+ public operation validates assignment and observations before attaching the new
113
+ trust-bundle digest and evaluating the gate. For a paused run, the current
114
+ assignment actor resumes it with an explicit reason:
75
115
 
76
116
  ```bash
77
- flow-agents builder-run recover --session-dir .kontourai/flow-agents/<slug>
117
+ flow-agents workflow resume --session-dir .kontourai/flow-agents/<slug> --reason <text>
78
118
  ```
79
119
 
80
- `recover` derives the Flow run id from the session directory slug; callers cannot
81
- select a run id or step. It requires exactly one non-empty
82
- `state.work_item_refs` entry, loads the existing run through Flow's canonical load
83
- API, and verifies that the ref matches persisted `state.subject` and, when present,
84
- `state.params.subject`. A missing, foreign, or corrupt run fails closed and is not
85
- created or repaired.
86
-
87
- Recovery is load/validate/project only. It computes the complete projection before
88
- updating `state.json`, the matching global `current.json`, and matching per-actor
89
- current pointers. It does not inspect or attach `trust.bundle`, evaluate gates, or
90
- write any file in `.kontourai/flow/runs/<slug>/`; the complete Flow run tree remains
91
- byte-identical. Use `sync`, not `recover`, to attach recorded evidence and evaluate
92
- the current gate.
120
+ Do not use a private synchronization or recovery command, manually project run
121
+ state, or create a replacement run for a missing, foreign, or corrupt binding.
93
122
 
94
123
  ## Trust Binding
95
124
 
@@ -99,7 +128,7 @@ claims are ignored for that gate. A relevant claim with a missing or different
99
128
  subject reference is rejected; Flow is not mutated.
100
129
 
101
130
  A failed gate claim may include a Flow classifier through
102
- `record-gate-claim --status fail --route-reason <reason>`. Flow validates the reason
131
+ `flow-agents workflow evidence --status fail --route-reason <reason>`. Flow validates the reason
103
132
  against the gate's `on_route_back` map and owns both the destination and attempt
104
133
  budget. Flow Agents only projects the resulting attempt and maximum into `state.json`.
105
134
 
@@ -112,12 +141,18 @@ While a run is active, `state.json` contains:
112
141
  - `next_action.skills`: ordered Builder skills for the current step.
113
142
  - `next_action.operations`: ordered non-skill product operations when present.
114
143
  - `next_action.summary`: required gate claims derived from the Flow Definition.
115
- - `next_action.command`: the exact idempotent synchronization command.
144
+ - `next_action.command`: the exact idempotent public status command for reorientation.
116
145
 
117
146
  Workflow steering surfaces these fields on session start and prompt submission. The
118
147
  Stop hook treats an unfinished canonical Flow run as active even during pickup or
119
148
  planning, blocks a premature stop in block mode, and does not release its liveness
120
149
  claim. A run is complete only when Flow reaches its terminal step.
150
+
151
+ Projection is always derived from the canonical run's `current_step`, including
152
+ composed steps that have no legacy sidecar phase (`merge-ready-ci` and `learn`).
153
+ Both the legacy `current.json` pointer and every matching per-actor pointer are
154
+ updated from that canonical step; `phase_map` is presentation metadata, not the
155
+ authority for pointer navigation.
121
156
  # Builder Lifecycle Authority
122
157
 
123
158
  The canonical Flow run owns pause, resume, and cancellation. The current assignment actor may
@@ -4,10 +4,10 @@ title: Workflow Usage Guide
4
4
 
5
5
  # Workflow Usage Guide
6
6
 
7
- > Consumer repositories should use the supported public workflow surface and isolated exact-package
8
- > launcher documented in [Public Workflow CLI](public-workflow-cli.md). The lower-level writer
9
- > commands retained later in this guide describe internal/package migration mechanics and are not a
10
- > consumer prerequisite.
7
+ > Consumer repositories and Builder skills use the supported public workflow
8
+ > surface and isolated exact-package launcher documented in
9
+ > [Public Workflow CLI](public-workflow-cli.md). Lower-level writer commands are
10
+ > package internals, not a supported agent or consumer interface.
11
11
 
12
12
  This guide shows how to use the Builder Kit workflow skills in normal chats.
13
13
 
@@ -26,7 +26,7 @@ Workflow artifacts follow a closeout lifecycle. Local runtime artifacts live und
26
26
  For local artifact queue hygiene, run the read-only cleanup audit:
27
27
 
28
28
  ```bash
29
- npm run workflow-artifact-cleanup-audit -- --artifact-root .flow-agents
29
+ npm run workflow-artifact-cleanup-audit -- --artifact-root .kontourai/flow-agents
30
30
  ```
31
31
 
32
32
  The audit is linked to the lifecycle policy in `docs/workflow-artifact-lifecycle.md`. It classifies active WIP, cleanup candidates, terminal done records, active learning follow-ups, and invalid sidecars without deleting or archiving anything.
@@ -43,20 +43,21 @@ Use Builder Kit shape. I have several ideas:
43
43
  - billing alert improvements
44
44
  - AI dashboard summary
45
45
 
46
- Separate these into distinct ideas, use Probe/alignment questions if the outcome or bundle is unclear, find the thinnest meaningful slice for each, push back if I bundle unrelated work, and stop at the backlog gate unless I explicitly ask you to sync GitHub issues.
46
+ Separate these into distinct ideas, use Probe/alignment questions if the outcome or bundle is unclear, find the thinnest meaningful slice for each, push back if I bundle unrelated work, and stop at the backlog gate unless I explicitly ask you to sync configured provider work items (for example, GitHub issues).
47
47
  ```
48
48
 
49
49
  Expected behavior:
50
50
 
51
51
  - delegate shaping to `kits/builder/skills/idea-to-backlog/SKILL.md`
52
52
  - link the artifact to the Builder Kit Flow Definition at `kits/builder/flows/shape.flow.json`
53
+ - start the public `builder.shape` Flow with a safe explicit slug, then inspect its public status before the step producer records evidence
53
54
  - inventory each distinct idea separately
54
55
  - classify each idea
55
56
  - identify the thinnest meaningful slice
56
57
  - shape executable work items with a readable story/outcome, scope, non-goals, stable `R*` requirement ids, stable `AC*` acceptance ids, verification expectation, milestone/delivery outcome, dependencies, and source artifact
57
58
  - require bundle justification before grouping ideas
58
59
  - map dependencies as blocking, blocked-by, or related-only
59
- - stop at the backlog gate unless you explicitly ask to continue or explicitly request GitHub issue sync
60
+ - stop at the backlog gate unless you explicitly ask to continue or explicitly request configured provider work-item sync; GitHub issue sync is an optional adapter example
60
61
 
61
62
  Expected artifact:
62
63
 
@@ -94,7 +95,7 @@ If the relationship is only thematic, split the work. If there is a real depende
94
95
 
95
96
  ## 3. Pull Ready Work From The Backlog
96
97
 
97
- Use `pull-work` when provider-backed work items already exist and you want to choose what to work on next. GitHub issues are the first concrete adapter example, not the core workflow vocabulary.
98
+ Use `pull-work` when provider-backed work items already exist and you want to choose what to work on next. The public `builder.build` interface accepts exactly two Work Item reference forms: `provider:id` and `owner/repo#numeric-id`. The latter is a GitHub-compatible adapter form; do not invent arbitrary reference formats. GitHub issues remain an optional adapter example, not the core workflow vocabulary.
98
99
 
99
100
  Example prompt:
100
101
 
@@ -117,11 +118,11 @@ Expected artifact:
117
118
  .kontourai/flow-agents/<slug>/<slug>--pull-work.md
118
119
  ```
119
120
 
120
- When a repository has backlog provider settings, `pull-work` should use those settings without requiring the user to name the board. In Flow Agents, `npm run effective-backlog-settings -- --repo-path . --json` resolves `kontourai/flow-agents` to GitHub Project `kontourai/1`, so a prompt like `use pull-work` is enough for the configured provider path.
121
+ When a repository has backlog provider settings, `pull-work` should use those settings without requiring the user to name the board. In this repository, the optional GitHub adapter resolves `kontourai/flow-agents` to GitHub Project `kontourai/1`, so a prompt like `use pull-work` is enough for that configured provider path.
121
122
 
122
123
  ### Assignment ownership: the third provider leg
123
124
 
124
- Beside the `WorkItemProvider` (what work exists) and `BoardProvider` (how it is grouped/ranked) settings above, `pull-work` also reads `AssignmentProvider` settings to decide who currently owns a candidate work item before offering it. This is durable, human-visible ownership a GitHub issue assignee, an `agent:claimed` label, and a versioned machine-readable claim comment (or, for tracker-less repos and evals, an equivalent local JSON record) joined against the ephemeral liveness presence layer so a crashed session's stale claim never blocks a second session from picking up the same work.
125
+ Beside the `WorkItemProvider` (what work exists) and `BoardProvider` (how it is grouped/ranked) settings above, `pull-work` also reads `AssignmentProvider` settings to decide who currently owns a candidate work item before offering it. This is durable, human-visible ownership represented by the configured provider. For example, the optional GitHub adapter can use an issue assignee, an `agent:claimed` label, and a versioned machine-readable claim comment; tracker-less repos and evals can use an equivalent local JSON record. Join it against the ephemeral liveness presence layer so a crashed session's stale claim never blocks a second session from picking up the same work.
125
126
 
126
127
  Settings live at `context/settings/assignment-provider-settings.json` (validated by `schemas/assignment-provider-settings.schema.json`), mirroring the same `defaults`/`projects[]` shape as the backlog provider settings above; resolve them with `npm run effective-assignment-provider-settings -- --repo-path . --json`. See `context/contracts/assignment-provider-contract.md` for the full `claim`/`release`/`supersede`/`status`/`list` vocabulary, the assignment ⋈ liveness join table, and the human-assignee ask-first policy.
127
128
 
@@ -129,7 +130,7 @@ Direct `pull-work` remains a normal workflow primitive. The Builder Kit build pa
129
130
 
130
131
  Builder Kit build is the product-level entry point for implementation pickup. In that mode, `pull-work` may guide the next step automatically as `pull-work -> design-probe / pickup-probe`; direct `pull-work` still stops with a `plan-work` handoff unless you ask to continue.
131
132
 
132
- If the board is empty or every issue is vague/stale, route back to Builder Kit shape / `idea-to-backlog`. Do not invent implementation work from an empty queue.
133
+ If the board is empty or every work item is vague/stale, route back to Builder Kit shape / `idea-to-backlog`. Do not invent implementation work from an empty queue.
133
134
 
134
135
  Before selecting new work, `pull-work` must separate your WIP from global conflict context:
135
136
 
@@ -220,17 +221,17 @@ Use execute-plan for .kontourai/flow-agents/<slug>/<slug>--plan.md. Prefer isola
220
221
 
221
222
  Use `review-work` after implementation and before verification. Review is critique: it asks whether the code should change before you trust it.
222
223
 
223
- Review checks quality, security triggers, architecture fit, project standards, risky assumptions, and maintainability. It writes `critique.json`. A clean review does not prove the feature works; it only says the implementation has no open reviewer findings that block the next gate.
224
+ Review checks quality, security triggers, architecture fit, project standards, risky assumptions, and maintainability. In the active `verify` step, `review-work` owns `clean-critique` through public `workflow critique` in `trust.bundle`. A clean review does not prove the feature works; it only says the implementation has no open reviewer findings that block the next gate.
224
225
 
225
226
  Example prompt:
226
227
 
227
228
  ```text
228
- Use review-work for .kontourai/flow-agents/<slug>/<slug>--deliver.md. Run code review, security review if triggered, and standards/architecture critique. Record findings in critique.json. Do not fix code.
229
+ Use review-work for the current Builder session. Run code review, security review if triggered, and standards/architecture critique. Record findings through public workflow critique. Do not fix code.
229
230
  ```
230
231
 
231
232
  Then use `verify-work` for implementation verification. Verification is evidence: it asks what proves the accepted behavior works.
232
233
 
233
- Verification runs build/type/lint/test/security/browser/runtime checks as relevant, maps results to acceptance criteria and Goal Fit, and writes `evidence.json`.
234
+ Verification runs build/type/lint/test/security/browser/runtime checks as relevant, maps results to acceptance criteria and Goal Fit, and records command-backed evidence in `trust.bundle`. In the active `verify` step, `verify-work` owns `acceptance-criteria`, `tests-evidence`, and applicable `policy-compliance`.
234
235
 
235
236
  Example prompt:
236
237
 
@@ -277,7 +278,61 @@ Goal Fit is the local stop condition before a final answer. The working artifact
277
278
 
278
279
  The `stop-goal-fit` hook also checks the latest workflow artifact and warns when the session is about to stop with missing `Definition Of Done`, incomplete Goal Fit, invalid sidecars, or open final acceptance work. Set `FLOW_AGENTS_GOAL_FIT_STRICT=true` to block incomplete local delivery. Set `FLOW_AGENTS_REQUIRE_SIDECARS=true` when structured workflow state should be mandatory. Set `FLOW_AGENTS_REQUIRE_CRITIQUE=true` when critique records should also be mandatory.
279
280
 
280
- Use `npm run workflow:sidecar --` to create routine sidecars instead of hand-writing JSON:
281
+ For an active Builder run, inspect and record evidence through the public CLI:
282
+
283
+ ```bash
284
+ flow-agents workflow status --session-dir .kontourai/flow-agents/<slug> --json
285
+ flow-agents workflow evidence \
286
+ --session-dir .kontourai/flow-agents/<slug> \
287
+ --expectation <declared-expectation> \
288
+ --status <pass|fail|not_verified> \
289
+ --command "npm test" \
290
+ --summary "The recorded command supports the declared expectation." \
291
+ --evidence-ref-json '{"kind":"artifact","file":".kontourai/flow-agents/<slug>/<slug>--plan-work.md","summary":"Reviewable artifact for the declared expectation."}'
292
+
293
+ # For tests-evidence, repeat --criterion-json for every accepted criterion.
294
+ # Repeat --command and its matching top-level command ref when criteria use
295
+ # different checks.
296
+ flow-agents workflow evidence \
297
+ --session-dir .kontourai/flow-agents/<slug> \
298
+ --expectation tests-evidence \
299
+ --status pass \
300
+ --command "npm test" \
301
+ --summary "Each accepted criterion has command-backed verification evidence." \
302
+ --evidence-ref-json '{"kind":"command","excerpt":"npm test","summary":"Exact substantive project test command recorded for this verification result."}' \
303
+ --criterion-json '{"id":"<criterion-id>","status":"pass","evidence_refs":[{"kind":"command","excerpt":"npm test","summary":"Exact substantive project test command run for this criterion."}]}' \
304
+ --evidence-ref-json '{"kind":"artifact","file":".kontourai/flow-agents/<slug>/<slug>--plan-work.md","summary":"Criterion mapping and expected verification evidence."}'
305
+
306
+ flow-agents workflow critique \
307
+ --session-dir .kontourai/flow-agents/<slug> \
308
+ --verdict <pass|fail|not_verified> \
309
+ --summary "Report-only critique findings and gaps are recorded." \
310
+ --artifact-ref ".kontourai/flow-agents/<slug>/<slug>--deliver.md" \
311
+ --artifact-ref "<reviewed-changed-file>" \
312
+ --lane-json '{"id":"code-review","status":"pass","summary":"Code quality, correctness, architecture, and standards were reviewed.","evidence_refs":[{"kind":"artifact","file":".kontourai/flow-agents/<slug>/<slug>--deliver.md","summary":"Reviewed delivery artifact and changed-scope context."}]}'
313
+ ```
314
+
315
+ Only the step skill declared for that Flow expectation should publish it.
316
+ Run authenticated critique before `tests-evidence`; the delegated reviewer
317
+ invokes the public critique command under a runtime identity distinct from the
318
+ active implementation actor. The command does not accept a caller-selected
319
+ reviewer identity.
320
+ Every critique must include at least one substantive lane. A passing critique
321
+ must also cite the delivery report and reviewed changed files. Stored file
322
+ hashes and the workspace snapshot prevent later implementation changes from
323
+ inheriting a stale clean review.
324
+ Entrypoints, profiles, shared primitives, and extensions do not claim step-gate
325
+ completion. `review-work` owns only `clean-critique`; `verify-work` owns
326
+ `acceptance-criteria`, `tests-evidence`, and applicable `policy-compliance`.
327
+
328
+ ### Package Maintainer Internals
329
+
330
+ The following writer details explain existing package implementation and
331
+ maintenance tests. They are not Builder skill or consumer commands. Skills use
332
+ the public CLI shown above and treat an unavailable public operation as a
333
+ blocker or `NOT_VERIFIED` gap.
334
+
335
+ The package's internal writer can create and validate projected artifacts:
281
336
 
282
337
  ```bash
283
338
  npm run workflow:sidecar -- ensure-session \
@@ -293,15 +348,19 @@ npm run workflow:sidecar -- init-plan .kontourai/flow-agents/<slug>/<slug>--deli
293
348
 
294
349
  #### Deterministic slug from a work-item ref
295
350
 
296
- For issue-backed sessions, pass `--work-item <owner/repo#id>` instead of `--task-slug`. The
297
- derived slug has the format `<owner>-<repo>-<id>` for example:
351
+ For work-item-backed sessions, use one of the two supported reference forms:
352
+ `provider:id` or `owner/repo#numeric-id`. The latter is the GitHub-compatible
353
+ adapter form; do not use other formats. `--task-slug` is reserved for an
354
+ existing local Work Item retry. The internal writer derives a deterministic slug
355
+ from either supported form; the GitHub-compatible example has the format
356
+ `<owner>-<repo>-<id>`:
298
357
 
299
358
  ```bash
300
359
  npm run workflow:sidecar -- ensure-session \
301
360
  --work-item "kontourai/flow-agents#161" \
302
361
  --source-request "Implement #161" \
303
362
  --summary "Deterministic slug demo."
304
- # Creates .flow-agents/kontourai-flow-agents-161/
363
+ # Creates .kontourai/flow-agents/kontourai-flow-agents-161/
305
364
  ```
306
365
 
307
366
  The slug is deterministic and idempotent: any agent or worktree that runs `ensure-session
@@ -314,9 +373,10 @@ detectable via `liveness status --subject kontourai-flow-agents-161` (see
314
373
  Rules:
315
374
  - `--task-slug` always wins when both flags are supplied (back-compat).
316
375
  - Omitting both flags still dies with `--task-slug is required`.
317
- - The `id` part after `#` must be a plain integer (GitHub issue number). Non-integer ids are
318
- rejected.
319
- - Issue-backed sessions should prefer `--work-item` over hand-supplied `--task-slug` so that
376
+ - In `owner/repo#numeric-id`, the id after `#` must be a plain integer. In
377
+ `provider:id`, the provider and id must use the provider-neutral reference
378
+ grammar; nonconforming or arbitrary formats are rejected.
379
+ - Work-item-backed sessions should prefer `--work-item` over hand-supplied `--task-slug` so that
320
380
  liveness subjectId alignment is automatic.
321
381
 
322
382
  #### Branch convention
@@ -422,24 +482,28 @@ version's rule set) — but it is not a partial/best-effort pass either.
422
482
  when a `state.json` has no `branch` field, naming the gap without breaking legacy
423
483
  sessions/fixtures.
424
484
 
425
- Reviewer Markdown artifacts can be imported into `critique.json`:
426
-
427
- ```bash
428
- npm run workflow:sidecar -- import-critique .kontourai/flow-agents/<slug> .kontourai/flow-agents/<slug>/<slug>--review.md
429
- ```
485
+ Reviewer Markdown can be retained as a linked reference, but the public
486
+ `workflow critique` operation is the only Builder review-recording interface.
430
487
 
431
- Core workflow skills should use these writer commands when available. If a writer command or validation is unavailable or blocked, the artifact should record the exact sidecar gap as `NOT_VERIFIED` rather than silently falling back to an unstructured pass.
488
+ Package integration tests use these writer commands to exercise projection
489
+ internals. Core workflow skills must use `flow-agents workflow`; if its required
490
+ operation is unavailable or blocked, record the exact gap as `NOT_VERIFIED`
491
+ rather than silently falling back to an internal command or unstructured pass.
432
492
 
433
493
  Manual sidecar writing is an exceptional recovery path only. If `npm run workflow:sidecar --` cannot acquire `.workflow-sidecar.lockdir` with `EPERM` or `EACCES`, first fix the artifact directory permissions or ownership, or rerun the workflow in an approved writable workspace. If the writer is still blocked by local permissions or sandboxing, manually write only schema-valid sidecars, record the exact writer failure as `NOT_VERIFIED`, and run `npm run workflow:validate-artifacts -- --require-sidecars <artifact-dir>` before treating recovery as complete.
434
494
 
435
- For substantial Flow Agents repo changes, maintainers can use the combined local evidence command after checks and critique are ready:
495
+ The combined internal writer fixture below is documented only for maintainers
496
+ of its integration tests. It is not a Builder workflow operation:
436
497
 
437
498
  ```bash
438
499
  npm run workflow:sidecar -- dogfood-pass \
439
500
  --check-json '{"id":"focused-check","kind":"test","status":"pass","summary":"Focused check passed."}' \
440
501
  --require-critique \
441
502
  --critique-id "dogfood-review" \
442
- --critique-summary "Critique passed."
503
+ --critique-verdict pass \
504
+ --critique-summary "Critique passed." \
505
+ --artifact-ref ".kontourai/flow-agents/<slug>/<slug>--deliver.md" \
506
+ --lane-json '{"id":"code-review","status":"pass","summary":"Focused review completed.","evidence_refs":[{"kind":"artifact","file":".kontourai/flow-agents/<slug>/<slug>--deliver.md","summary":"Reviewed dogfood delivery artifact."}]}'
443
507
  ```
444
508
 
445
509
  `dogfood-pass` is fail-closed: it refuses a clean pass without evidence and refuses required critique gaps before writing partial evidence. When the same clean pass is also merge-ready, add `--release-decision merge` and one or more `--release-doc-ref` values to write `release.json` in the same validated pass. Release decisions require passing critique.
@@ -517,7 +581,7 @@ Completion gate:
517
581
  - `state.status` may be `delivered`, `accepted`, or `archived` with `phase: done` only when evidence is passing and either a promoted doc exists or the no-docs decision is explicit.
518
582
  - `NOT_VERIFIED` evidence cannot be promoted as a clean delivery doc. Promote it as a blocked or partial record only if the doc names the gap and next owner.
519
583
  - For adapter or provider work, the promoted doc should distinguish local/dry-run capability from live external mutation.
520
- - Final delivery must reconcile sidecars before stopping: `acceptance.json`, `evidence.json`, and `release.json` are authoritative gate inputs. Temporary verifier-local mismatch notes are superseded only when the final orchestrator evidence or release validation names the reconciled sidecars. If Markdown and sidecars still disagree, hold the terminal delivery.
584
+ - Final delivery must reconcile `trust.bundle` before stopping. Temporary verifier-local notes are superseded only when the final public evidence or release validation names the reconciled trust slices. If linked reports and the bundle disagree, hold the terminal delivery.
521
585
  - Final acceptance should also close the active local state: after merge or accepted no-provider-change work, do not leave `state.status: verified` unless release, docs promotion, or learning still has an unresolved blocker.
522
586
 
523
587
  The validator and stop hook enforce this shape for terminal workflows. If a delivery is terminal and neither the Markdown artifact nor `state.json.artifact_paths` points at durable docs, validation should fail unless the artifact records an explicit no-docs decision.
@@ -589,24 +653,27 @@ Use learning-review. Capture facts, decisions, gaps, follow-ups, and durable kno
589
653
  ## Resumable sessions
590
654
 
591
655
  Builder build sessions also project their canonical Flow run into the resume block.
592
- Start a newly selected session with `flow-agents builder-run start --session-dir
593
- .kontourai/flow-agents/<slug>`. Thereafter, follow `next_action.skills` or
594
- `next_action.operations`, record the current gate evidence, and use the exact
595
- `next_action.command` if automatic synchronization was interrupted. See
656
+ Start a newly selected session with `flow-agents workflow start --flow builder.build
657
+ --work-item <provider-ref> --assignment-provider <configured-kind>` and add
658
+ `--effective-state-json <provider-status.json>` for a non-local provider, where `<provider-ref>` is exactly `provider:id` or
659
+ `owner/repo#numeric-id`; the latter is the GitHub-compatible adapter form. The
660
+ adapter supplies the stable, human-readable Work Item reference. Thereafter, follow `next_action.skills` or `next_action.operations` and record the
661
+ current gate through the public `workflow evidence` command. After interruption, inspect
662
+ the read-only `workflow status` projection without attaching evidence or advancing the run. See
596
663
  [`docs/spec/builder-flow-runtime.md`](spec/builder-flow-runtime.md) for the ownership,
597
664
  trust-binding, route-back, and artifact-root contract.
598
665
 
599
- If the same Builder slice is interrupted and its sidecar/current pointers may be
600
- stale, restore the projection from the existing canonical Flow run with:
666
+ If the same Builder slice is interrupted, inspect its canonical status. Resume
667
+ only when the public status reports a paused run:
601
668
 
602
669
  ```bash
603
- flow-agents builder-run recover --session-dir .kontourai/flow-agents/<slug>
670
+ flow-agents workflow status --session-dir .kontourai/flow-agents/<slug> --json
671
+ flow-agents workflow resume --session-dir .kontourai/flow-agents/<slug> --reason "Continue the bound work item"
604
672
  ```
605
673
 
606
- The session slug is the run identity; recovery accepts no caller-selected run or
607
- step. It validates the sole Work Item binding and updates only the sidecar/current
608
- projection, leaving the entire Flow run byte-identical. Recovery never attaches or
609
- evaluates `trust.bundle`; use `builder-run sync` for that separate operation.
674
+ The session slug is the run identity. Do not select a different run, force a
675
+ step, or use an internal synchronization command to bypass the canonical next
676
+ action.
610
677
 
611
678
  When a session resumes (after context compaction, an agent restart, or a cross-session
612
679
  handoff), the workflow-steering hook emits a `RESUME:` block on `SessionStart` that
@@ -619,7 +686,7 @@ The `RESUME:` block supplements the existing `STATE:` line and contains:
619
686
  - **Plan** — path to the plan artifact (`<slug>--plan-work.md` from `state.json artifact_paths` or conventional fallback).
620
687
  - **Next step** — the first `handoff.json next_steps` entry.
621
688
  - **Blockers** — any recorded blockers from `handoff.json`, or "none".
622
- - **Trust** — `Trust: N verified / M disputed / T total` from reading `trust.bundle`. Each disputed or unknown claim is listed with its id and a copy-pasteable remedy command: `npm run workflow:sidecar -- claim <id> <dir>`.
689
+ - **Trust** — `Trust: N verified / M disputed / T total` from reading `trust.bundle`. Each disputed or unknown claim names the owning expectation so its step producer can attach resolving evidence through `flow-agents workflow evidence`.
623
690
  - **Liveness advisory** (when applicable) — `[LIVENESS WARNING: another agent appears live on this work: actor <X>, last seen <T>]` when the shared liveness stream (`.kontourai/flow-agents/liveness/events.jsonl`, ADR 0012) contains a fresh claim or heartbeat from a different actor for the same slug. This is advisory only — the hook exits 0 regardless. The block also always includes an `ACTOR: <actor> (<source>)` line — the same runtime-agnostic actor identity this session resolves for itself (see "Actor identity and liveness writes" below), so a resuming agent can see at a glance which identity its own liveness claims/heartbeats will be filed under.
624
691
  - **Route hint** — `To continue: resume this work. Or run pull-work to assess WIP and start new/parallel work.` — always routes the resume-vs-parallel decision through `pull-work` rather than auto-taking it.
625
692
 
@@ -131,7 +131,7 @@
131
131
  ],
132
132
  "agent_must_do": [
133
133
  "delegate to review-work for report-only critique before verify-work",
134
- "not count critique.json as verification evidence or evidence.json as critique",
134
+ "not count report-only critique as verification evidence",
135
135
  "route open critique findings back through execute-plan, then re-review and re-verify"
136
136
  ],
137
137
  "evidence": {
@@ -156,7 +156,7 @@
156
156
  "guidance_must_include": [
157
157
  "KIT WORKFLOW ROUTE",
158
158
  "activate `deliver`",
159
- "--flow-id builder.build",
159
+ "public `flow-agents workflow` interface",
160
160
  "plan-work -> execute-plan -> review-work -> verify-work",
161
161
  "release-readiness and learning-review"
162
162
  ],