Skip to content

[Bug] Wire reviewer across harnesses: Kiro fs_write cap, trustedAgents, codex §12a step#405

Merged
apackeer merged 2 commits into
v2from
fix/reviewer-harness-wiring
Jul 3, 2026
Merged

[Bug] Wire reviewer across harnesses: Kiro fs_write cap, trustedAgents, codex §12a step#405
apackeer merged 2 commits into
v2from
fix/reviewer-harness-wiring

Conversation

@apackeer

@apackeer apackeer commented Jun 19, 2026

Copy link
Copy Markdown

What & why

The v2 reviewer mechanism — an optional reviewer: stage field that invokes a clean-room sub-agent which appends a READY/NOT-READY ## Review section to the artifact (stage-protocol §12a) — shipped in 2.0.0 but is inert or unsafe on some harnesses. This PR fixes three self-contained defects so the reviewer actually runs everywhere and can't write outside its lane. No change to per-unit / swarm reviewer behaviour (that depends on the unbuilt per-unit iteration engine and is deliberately left alone).

The three fixes

W1 — SECURITY: cap the Kiro reviewer's fs_write

The Kiro reviewer agent configs granted fs_write with no allowedPaths cap — broader than the builder agents they review, and broader than the conductor (which is path-capped). The reviewer only ever appends a ## Review section to the primary artifact under the aidlc/spaces/** workspace (the per-intent record dir - the flat aidlc-docs/ layout this PR originally capped to was retired on v2), so its write grant is now capped to match the conductor's own fs_write cap:

"fs_write": { "allowedPaths": ["aidlc/spaces/**"] }

Applied to all four reviewer JSONs: harness/{kiro,kiro-ide}/agents/aidlc-architecture-reviewer-agent.json and aidlc-product-lead-agent.json. tools / allowedTools / execute_bash are unchanged. (Kiro-specific: the Claude harness uses .md agents with no JSON tool-grant layer, and Codex .toml agents carry no write grant — verified.)

W2 — INVOCATION: trust the reviewer slugs

The reviewer personas were missing from the conductor's subagent.trustedAgents on Kiro / Kiro-IDE, so invoking the reviewer via the subagent tool would prompt or block. Added aidlc-architecture-reviewer-agent and aidlc-product-lead-agent to subagent.trustedAgents in harness/{kiro,kiro-ide}/agents/aidlc.json (the existing aidlc-developer-agent + aidlc-architect-agent are retained).

W3 — CODEX INERT: wire the §12a reviewer step into the Codex orchestrator

The Codex orchestrator SKILL.md had zero reviewer wiring while Claude and Kiro both have it, so on Codex a stage's reviewer: directive was silently ignored. The reviewer persona configs already ship to Codex (.codex/agents/aidlc-architecture-reviewer-agent.toml + aidlc-product-lead-agent.toml), so this is a prose fix:

  • (a) Inserted the §12a reviewer step as the first sub-step of the gate: true block in harness/codex/skills/aidlc/SKILL.md, using Codex's sub-agent idiom (spawn the agent role — the harness resolves .codex/agents/aidlc-<role>-agent.toml, which loads its own persona via developer_instructions); subsequent steps renumbered.
  • (b) The "STAGE RITUAL IS ATOMIC" line that Claude/Kiro carry has no equivalent in the Codex SKILL.md, so there was nothing to mirror — skipped.
  • (c) Corrected two stale 11 agent comments in harness/codex/emit.ts to 13 (the transpose emits 13 agent TOMLs = 11 domain + 2 reviewer personas).

Version

Per the Changelog Policy this bumps core/tools/aidlc-version.ts 2.1.7 → 2.1.8, the README badge, and adds a ## [2.1.8] CHANGELOG entry; the regenerated dist/ trees (claude / codex / kiro / kiro-ide) ride in the same commit. (Originally authored as 2.0.3 against the 2.0.2 base; rebased onto v2 at 2.1.7 on 2026-07-03 and re-bumped.)

Verification

  • bun run typecheck — 0 errors
  • bun scripts/package.ts --check — all four harness trees in sync (no dist drift)
  • bun test tests/unit/t68-version-changelog-sync.test.ts — green (version trio agrees at 2.0.3)
  • Default-tier suite (smoke + unit + integration, -P 8): smoke + unit 102 files / 2024 assertions / 0 failures. The two integration reds in the full parallel run (t72, t20) are live-SDK nondeterminism — both pass on isolated re-run and neither touches this diff.

Rebase notes (2026-07-03, onto v2 @ 2.1.7)

The branch was rebased across ~20 releases (2.0.2 -> 2.1.7). Each fix was re-verified against current v2 and three adjustments were made where the codebase had moved:

  • W1 cap repointed: aidlc-docs/ no longer exists on v2 (replaced by the per-intent aidlc/spaces/** workspace), so the reviewer fs_write cap now targets aidlc/spaces/** - identical to the conductor's own cap. Verified the ## Review section is appended to the primary artifact under the intent record dir (stage-protocol.md "Reviewer executes").
  • W2 extended to kiro-ide: the Kiro IDE harness (added after this PR was authored) shares the same trustedAgents gap; both reviewer slugs are added there too.
  • W3 parity completed: v2's per-unit iteration paragraph (added by the 2.1.2 for_each work) carries "Run the body + reviewer (§12a) for THIS unit only" and "The reviewer fires once PER UNIT" on Claude/Kiro/Kiro-IDE but not Codex; the Codex paragraph now matches. The §12a gate step itself was re-anchored on v2's current gate flow (learnings ritual now references aidlc/spaces/<space>/memory/org.md; the test-run carve-out is gone per 2.1.4). One of the two stale "11 agent" comments in emit.ts had drifted to a third spot; all now read 13.

Re-verified on the rebased head: bun run typecheck 0 errors; package.ts --check clean on all four trees; t68 + t04 green; smoke+unit tier 125 files / 2242 assertions / 0 failures (stamp 2026-07-03T10-14-20Z); deterministic e2e slice 31 files with the single red (t126, live Claude-SDK emitter-pairing) re-run green-alone (stamp 2026-07-03T10-30-37Z) - a known agent-latency flake, not a regression.

Out of scope

(deliberately not touched)

Per-unit / for_each reviewer behaviour and the swarm path (depend on the unbuilt per-unit iteration engine), the §12a loop determinism, and the ## Review builder-slug signature bug.

@leandrodamascena leandrodamascena left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

…er slugs, add codex §12a step

Brings the shipped v2 reviewer (verification-agent) mechanism up to scratch
so it actually runs everywhere and cannot write outside its lane. Three
self-contained defects fixed; no change to per-unit / swarm reviewer behaviour
(that depends on the unbuilt #368 per-unit iteration engine).

W1 — SECURITY: the Kiro reviewer agents granted unrestricted fs_write (no
allowedPaths cap), broader than the builders they review and the path-capped
conductor. Cap fs_write to aidlc/spaces/** — the only place the reviewer
legitimately writes (the `## Review` section appended to the primary artifact
under the per-intent record dir), matching the conductor's own cap. (The
original branch capped to aidlc-docs/**; that layout was retired on v2 in
favour of the per-intent aidlc/spaces workspace, so the cap was repointed
during the rebase.)
Files: harness/{kiro,kiro-ide}/agents/aidlc-architecture-reviewer-agent.json,
aidlc-product-lead-agent.json. (claude uses .md with no JSON tool-grant layer;
codex .toml carries no write grant — defect is Kiro-specific.)

W2 — INVOCATION: the reviewer personas were not in the conductor's
subagent.trustedAgents on Kiro/Kiro-IDE, so invoking them via the subagent tool
prompted/blocked. Added aidlc-architecture-reviewer-agent and
aidlc-product-lead-agent to trustedAgents in harness/{kiro,kiro-ide}/agents/aidlc.json.

W3 — CODEX INERT: the codex orchestrator SKILL.md had zero reviewer wiring, so a
stage's reviewer: directive was silently ignored. Wired the §12a reviewer step
into the gate:true flow as the first sub-step (before learnings), using codex's
sub-agent idiom (spawn the agent role; harness resolves the .toml persona);
renumbered subsequent steps. Codex has no STAGE-RITUAL-IS-ATOMIC line so W3(b)
was skipped. Also corrected the stale "11 agent" comments in harness/codex/emit.ts
to 13 (the transpose emits 13 agent TOMLs).

Per the Changelog Policy, this commit bumps core/tools/aidlc-version.ts 2.1.7 →
2.1.8, the README badge, adds the ## [2.1.8] CHANGELOG heading, and includes the
regenerated dist/ trees (claude/codex/kiro/kiro-ide). (Originally authored as
2.0.3 against the 2.0.2 base; re-bumped on the rebase onto v2 at 2.1.7.)
@apackeer apackeer force-pushed the fix/reviewer-harness-wiring branch from 687a3ff to 22a329b Compare July 3, 2026 11:13
t-acp-kiro-reviewer.serial.test.ts drives a reviewer-declaring stage
(requirements-analysis, poc, reviewer: aidlc-product-lead-agent) over a
live kiro-cli ACP session through the production aidlc conductor via
next --stage <slug> --single, and asserts the section-12a contract on
disk: the ## Review READY/NOT-READY verdict appended to requirements.md
under the per-intent record (aidlc/spaces/**, the tree the reviewer's
fs_write cap names), no resurrection of the retired flat aidlc-docs/
layout, and a sub-agent tool call carrying the reviewer slug.

Turn shape: disk-condition cancel (poll for ## Review then
session/cancel — the ACP forwarding loop never voluntarily ends), plus
one bounded follow-up turn if the model ends its turn on the stage's
prose-rendered questions. withState is load-bearing: without a seeded
aidlc-state.md the intent record does not resolve and the engine's
recordPrefix falls back to the bare intents root, so the stage writes
to a shard the poll never watches (live-observed on the first run).

Gated AIDLC_KIRO_ACP_LIVE=1; skips clean otherwise. Live GREEN 1/0
(5 expects, 328s). Test-only: no version bump.
@apackeer apackeer merged commit 89bcfa2 into v2 Jul 3, 2026
@apackeer apackeer deleted the fix/reviewer-harness-wiring branch July 3, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants