Skip to content

feat(bin): gate PR readiness on independent different-family review - #1470

Closed
JaredHuynhning wants to merge 4 commits into
kunchenguid:mainfrom
JaredHuynhning:fm/fm-independent-verifier
Closed

JaredHuynhning wants to merge 4 commits into
kunchenguid:mainfrom
JaredHuynhning:fm/fm-independent-verifier

Conversation

@JaredHuynhning

Copy link
Copy Markdown

Intent

Make independent verification a permanent structural part of Firstmate's delivery lifecycle so no finished open pull request can be presented as captain-ready until a cold reviewer from a model family different from the recorded builder has cleared the exact current head. Derive model families at runtime from recorded harness and model metadata; fail closed with the exact missing fact when the builder family or a verified different-family adapter cannot be established; give the reviewer only the original task acceptance criteria and exact diff; block only confirmed correctness, security, privacy, data-loss, and acceptance failures; allow one review plus one fix/re-review, with a second rejection opening the circuit; invalidate verdicts when the head moves; and make reviewer identity and finding the first captain-facing line. Scope the gate to finished, unmerged pull requests, keep forge access read-only, add no poller or wake-frequency increase, preserve all AGENTS.md section 7 safety boundaries through a concise named exception, and eliminate stale fixed-vendor reviewer guidance from private configuration outside the tracked pull request.

What Changed

  • Adds bin/fm-independent-review.sh, a standing gate that reads a finished open pull request's exact forge head read-only, resolves the builder's model family from recorded harness/model metadata, dispatches one cold reviewer from a verified different-family adapter with only the original acceptance criteria and the exact diff, and records a verdict bound to that head. It allows one review plus one fix re-review, opens the circuit on a second rejection, invalidates verdicts when the head moves, and fails closed naming the missing fact when a family or adapter cannot be established.
  • bin/fm-pr-check.sh now runs that gate before recording anything: it refuses to record pr=/pr_head= or arm the merge poll without a clear verdict matching the current head, takes pr_head from the reviewed-head binding instead of a separate gh read, and buffers migration and fm-guard output so the reviewer identity and finding are the first captain-facing line. bin/fm-teardown.sh retires the round files, verdict, and bounded bundles on completed parent-task teardown, and bin/fm-test-run.sh maps the new script and suite into the pr-forge family.
  • Documents the gate as a named exception in AGENTS.md section 7 (including its cooperative task-identity provenance and the honest-but-fallible threat model), plus README, docs/architecture.md, docs/scripts.md, and the GitLab merge-watch record. Adds tests/fm-independent-review.test.sh (19 behaviours) and updates the pr-check, pr-merge, secondmate-safety, teardown, and test-run suites for the new boundary.

Risk Assessment

⚠️ Medium: The authorized subtraction is clean with no dangling references or behavioural side effects and every earlier fix survives intact, but the overall change still places a new mandatory fail-closed gate on the critical path of every PR readiness call, with an acknowledged and now-documented operational follow-up (stale review rounds accumulate and need manual or teardown-time retirement).

Testing

Ran the repo runner on the new gate suite and every other changed suite, then drove the real fm-pr-check.sh and fm-independent-review.sh end to end against a real git remote with only the forge CLI and agent spawner stubbed, capturing a CLI transcript of the full reject to fix to clear lifecycle plus the circuit-breaker, head-invalidation, scope, and fail-closed paths; the gate behaves as intended and the only failures seen are a teardown case that fails identically at the base commit and a scheduler-timing assertion that passes in isolation.

Evidence: End-to-end CLI transcript of the independent-verification gate

================================================================
SCENARIO A - a Codex-built PR walks the full gate: review -> reject -> one fix round -> clear
================================================================

--- Builder metadata recorded for the finished ship task
harness=codex
model=gpt-5.6-sol
kind=ship
mode=no-mistakes
current forge head: eb667265c01b110a2907cc45e7bd2c2df0855143

--- A1. Captain readiness call on a finished, unreviewed PR

$ /Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1
independent review started: round 1 reviewer=ir-task-a-r1-eb667265c01b family=anthropic head=eb667265c01b110a2907cc45e7bd2c2df0855143
[exit 3]

recorded pr= / pr_head= in task meta: 0
merge poll armed (state/task-a.check.sh): no
task state written while the review is pending (no poll, no new wake source):
  ir-task-a-r1-eb667265c01b.meta
  task-a.independent-review.bundle-1
  task-a.independent-review.round-1
  task-a.meta
  task-a.status

--- A2. Reviewer selection was derived at runtime from the recorded builder family
builder:  harness=codex model=gpt-5.6-sol family=openai
reviewer: task=ir-task-a-r1-eb667265c01b harness=claude family=anthropic
fm-spawn dispatch log (id / harness / model): ir-task-a-r1-eb667265c01b	claude	default

--- A3. What the cold reviewer was actually given
--- reviewer brief ---
You are an independent cold reviewer managed by firstmate.
Work autonomously and do not wait for a human.

# Review boundary

Read only these two immutable artifacts:

- Original task acceptance criteria: /var/folders/_s/01tmj3vx0bn03t1t29k76npw0000gn/T/no-mistakes-evidence/01KYZ540F9BSG1FBNKY00JGX8P/work/scenario-a/home/state/task-a.independent-review.bundle-1/criteria.md
- Exact pull request diff for head eb667265c01b110a2907cc45e7bd2c2df0855143: /var/folders/_s/01tmj3vx0bn03t1t29k76npw0000gn/T/no-mistakes-evidence/01KYZ540F9BSG1FBNKY00JGX8P/work/scenario-a/home/state/task-a.independent-review.bundle-1/diff.patch

Do not inspect the repository, builder messages, status history, pipeline output, summaries, or any previous review.
Your job is to try to refute the change rather than approve it.
Keep the review short and bounded to the supplied criteria and diff.

Block only on confirmed correctness, security, privacy, data loss, or unmet acceptance criteria.
Record every other concern as a non-blocking follow-up.
Uncertainty is not a confirmed blocker: state the missing evidence as a follow-up unless the supplied diff itself proves an in-scope failure.

# Verdict

Submit exactly one verdict against head eb667265c01b110a2907cc45e7bd2c2df0855143.
For a clear result, run:

  FM_HOME='/var/folders/_s/01tmj3vx0bn03t1t29k76npw0000gn/T/no-mistakes-evidence/01KYZ540F9BSG1FBNKY00JGX8P/work/scenario-a/home' FM_STATE_OVERRIDE='/var/folders/_s/01tmj3vx0bn03t1t29k76npw0000gn/T/no-mistakes-evidence/01KYZ540F9BSG1FBNKY00JGX8P/work/scenario-a/home/state' FM_DATA_OVERRIDE='/var/folders/_s/01tmj3vx0bn03t1t29k76npw0000gn/T/no-mistakes-evidence/01KYZ540F9BSG1FBNKY00JGX8P/work/scenario-a/home/data' '/Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-independent-review.sh' submit 'task-a' 'ir-task-a-r1-eb667265c01b' 'eb667265c01b110a2907cc45e7bd2c2df0855143' clear '<one-line summary>' [--follow-up '<one-line note>']

For a rejection, run:

  FM_HOME='/var/folders/_s/01tmj3vx0bn03t1t29k76npw0000gn/T/no-mistakes-evidence/01KYZ540F9BSG1FBNKY00JGX8P/work/scenario-a/home' FM_STATE_OVERRIDE='/var/folders/_s/01tmj3vx0bn03t1t29k76npw0000gn/T/no-mistakes-evidence/01KYZ540F9BSG1FBNKY00JGX8P/work/scenario-a/home/state' FM_DATA_OVERRIDE='/var/folders/_s/01tmj3vx0bn03t1t29k76npw0000gn/T/no-mistakes-evidence/01KYZ540F9BSG1FBNKY00JGX8P/work/scenario-a/home/data' '/Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-independent-review.sh' submit 'task-a' 'ir-task-a-r1-eb667265c01b' 'eb667265c01b110a2907cc45e7bd2c2df0855143' reject '<one-line summary>' --block <correctness|security|privacy|data-loss|acceptance> '<one-line finding>' [additional --block or --follow-up arguments]

Never edit, comment on, approve, merge, close, or re-run anything on the pull request.
Never fix the finding yourself.
Write the same bounded result to /var/folders/_s/01tmj3vx0bn03t1t29k76npw0000gn/T/no-mistakes-evidence/01KYZ540F9BSG1FBNKY00JGX8P/work/scenario-a/home/data/ir-task-a-r1-eb667265c01b/report.md, run:

  FM_HOME='/var/folders/_s/01tmj3vx0bn03t1t29k76npw0000gn/T/no-mistakes-evidence/01KYZ540F9BSG1FBNKY00JGX8P/work/scenario-a/home' FM_STATE_OVERRIDE='/var/folders/_s/01tmj3vx0bn03t1t29k76npw0000gn/T/no-mistakes-evidence/01KYZ540F9BSG1FBNKY00JGX8P/work/scenario-a/home/state' FM_DATA_OVERRIDE='/var/folders/_s/01tmj3vx0bn03t1t29k76npw0000gn/T/no-mistakes-evidence/01KYZ540F9BSG1FBNKY00JGX8P/work/scenario-a/home/data' '/Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-decision-hold.sh' complete 'ir-task-a-r1-eb667265c01b' --none

Then append one line to /var/folders/_s/01tmj3vx0bn03t1t29k76npw0000gn/T/no-mistakes-evidence/01KYZ540F9BSG1FBNKY00JGX8P/work/scenario-a/home/state/ir-task-a-r1-eb667265c01b.status:

  done: independent review submitted for task-a at eb667265c01b110a2907cc45e7bd2c2df0855143

Stop after that line.
--- bundled acceptance criteria (immutable copy) ---
Reject every authorization request except the literal value `allowed`.

## Acceptance criteria

- `allowed` succeeds.
- Every other value fails.
- No caller can bypass the check.

--- bundled exact diff (first lines) ---
diff --git a/authorize.sh b/authorize.sh
new file mode 100644
index 0000000..3cfa828
--- /dev/null
+++ b/authorize.sh
@@ -0,0 +1 @@
+authorize() { return 0; } # DEFECT_ACCEPTS_EVERYTHING
--- leakage check: builder reasoning must not reach the cold bundle ---
no builder reasoning, status history, or pipeline output in the reviewer bundle

--- A4. The cold reviewer submits its bounded verdict

$ /Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-independent-review.sh submit task-a ir-task-a-r1-eb667265c01b eb667265c01b110a2907cc45e7bd2c2df0855143 reject authorization accepts every input --block correctness authorize.sh returns success for unauthorized values
recorded independent review: task=task-a round=1 verdict=reject head=eb667265c01b110a2907cc45e7bd2c2df0855143
[exit 0]

--- A5. Captain readiness call after the rejection

$ /Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1
error: independent review rejected head eb667265c01b110a2907cc45e7bd2c2df0855143: authorization accepts every input
blocker: correctness: authorize.sh returns success for unauthorized values
[exit 1]

merge poll armed: no

--- A6. Builder pushes the fix; the head moves
new forge head: 1527915c89cd4926d2a499eac17bb8e68efbc9d6

$ /Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1
independent review started: round 2 reviewer=ir-task-a-r2-1527915c89cd family=anthropic head=1527915c89cd4926d2a499eac17bb8e68efbc9d6
[exit 3]

--- A7. Round 2 is a fresh cold reviewer with no prior verdict in its brief
round-1 reviewer: ir-task-a-r1-eb667265c01b
round-2 reviewer: ir-task-a-r2-1527915c89cd
round-2 brief or bundle carries the round-1 reviewer id or its finding: 0 file(s)

$ /Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-independent-review.sh submit task-a ir-task-a-r2-1527915c89cd 1527915c89cd4926d2a499eac17bb8e68efbc9d6 clear no blocking findings --follow-up consider a regression test for the empty-string case
recorded independent review: task=task-a round=2 verdict=clear head=1527915c89cd4926d2a499eac17bb8e68efbc9d6
[exit 0]

--- A8. Captain readiness call after the clear verdict on the exact current head

$ /Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1
Independent review: ir-task-a-r2-1527915c89cd via claude (anthropic family) - no blocking findings
armed: state/task-a.check.sh
[exit 0]

recorded readiness metadata:
pr=https://github.com/example/repo/pull/1
pr_head=1527915c89cd4926d2a499eac17bb8e68efbc9d6
exact forge head:  1527915c89cd4926d2a499eac17bb8e68efbc9d6
merge poll armed: yes

--- A9. The head moves again after clearance: the verdict is invalidated and the circuit is open
new forge head: f647467e294b8335f372a2f32f54c041fa6241a6

$ /Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1
error: pull request head changed after two review rounds; the circuit is open and the work must be re-scoped
[exit 1]

================================================================
SCENARIO C - a second rejection opens the circuit instead of buying a third round
================================================================

--- C1. Round 1 dispatches and rejects

$ /Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1
independent review started: round 1 reviewer=ir-task-a-r1-588b1f8b0ef5 family=anthropic head=588b1f8b0ef5a1879d51c5d28831d06f8634da4f
[exit 3]

$ /Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-independent-review.sh submit task-a ir-task-a-r1-588b1f8b0ef5 588b1f8b0ef5a1879d51c5d28831d06f8634da4f reject authorization accepts every input --block correctness authorize.sh returns success for unauthorized values
recorded independent review: task=task-a round=1 verdict=reject head=588b1f8b0ef5a1879d51c5d28831d06f8634da4f
[exit 0]

--- C2. The builder pushes a fix that is still defective; round 2 dispatches

$ /Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1
independent review started: round 2 reviewer=ir-task-a-r2-0a9c8fe22e25 family=anthropic head=0a9c8fe22e250f622abba2254cec5ccbcbd7a669
[exit 3]

$ /Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-independent-review.sh submit task-a ir-task-a-r2-0a9c8fe22e25 0a9c8fe22e250f622abba2254cec5ccbcbd7a669 reject authorization accepts every input --block correctness authorize.sh returns success for unauthorized values
recorded independent review: task=task-a round=2 verdict=reject head=0a9c8fe22e250f622abba2254cec5ccbcbd7a669
[exit 0]

--- C3. Captain readiness call after the second rejection

$ /Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1
error: independent review rejected head 0a9c8fe22e250f622abba2254cec5ccbcbd7a669: authorization accepts every input
blocker: correctness: authorize.sh returns success for unauthorized values
error: second rejection opened the circuit; stop and re-scope the design instead of producing a third fix round
[exit 1]

================================================================
SCENARIO B - fail-closed refusals name the exact missing fact
================================================================

--- B1. No verified different-family adapter is available

$ /Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1
error: could not establish an available verified different-family reviewer for builder family 'openai'
[exit 1]

--- B2. Builder family cannot be established from a model-routing harness with no recorded model

$ /Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1
error: could not establish builder model family: harness=pi requires a recorded model with a verified provider family
[exit 1]

--- B3. The same model-routing harness with a recorded provider resolves and dispatches

$ /Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1
independent review started: round 1 reviewer=ir-task-a-r1-36012e9f47fe family=openai head=36012e9f47feefc7d2b33a6054b45c354bb5d6ba
[exit 3]
derived builder family: anthropic -> reviewer family: openai

--- B4. Scope: a draft PR is never read

$ /Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1
error: pull request is still a draft; independent review covers finished pull requests only
[exit 1]

--- B5. Scope: an already merged PR is never read

$ /Users/jared/.no-mistakes/worktrees/adf67e3dce98/01KYZ540F9BSG1FBNKY00JGX8P/bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1
error: pull request is already merged; independent review never runs on merged work
[exit 1]

--- B6. Forge access stayed read-only for the whole run
every gh invocation made by the gate across all scenarios:
  13 pr view --json state,isDraft,headRefOid
(the gh stub exits 1 on any call shape other than the read-only `pr view` field selection)

================================================================
END OF TRANSCRIPT
================================================================
Evidence: Reproducible harness that generates the transcript
#!/usr/bin/env bash
# End-to-end demonstration of the standing independent-verification gate.
#
# Drives the real captain-facing entry point `bin/fm-pr-check.sh` against a real
# git remote carrying refs/pull/1/head, with only the forge CLI (gh) and the
# agent spawner (fm-spawn.sh) stubbed. Every firstmate script under test is the
# real one from the branch.
set -u

ROOT=${1:?usage: independent-review-e2e.sh <repo-root> <workdir>}
WORK=${2:?usage: independent-review-e2e.sh <repo-root> <workdir>}
REVIEW="$ROOT/bin/fm-independent-review.sh"
PR_CHECK="$ROOT/bin/fm-pr-check.sh"
BASE_PATH=/usr/bin:/bin:/usr/sbin:/sbin

export GIT_AUTHOR_NAME=fmtest [email protected]
export GIT_COMMITTER_NAME=fmtest [email protected]
# Fixture commits must not run the host's global hooks (gitleaks etc.).
export GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null

rule() { printf '\n================================================================\n%s\n================================================================\n' "$*"; }
step() { printf '\n--- %s\n' "$*"; }

# show <label> -- <command...>: print the command, run it, print output + status.
show() {
  local dir=$1; shift
  printf '\n$ %s\n' "$*"
  FM_ROOT_OVERRIDE="$dir/root" FM_HOME="$dir/home" \
    FM_STATE_OVERRIDE="$dir/home/state" FM_DATA_OVERRIDE="$dir/home/data" \
    FM_CONFIG_OVERRIDE="$dir/home/config" FM_TEST_REMOTE="$dir/remote.git" \
    FM_TEST_GH_LOG="$WORK/gh-calls.log" \
    FM_TEST_SPAWN_LOG="$dir/spawn.log" PATH="$dir/fakebin:$BASE_PATH" \
    "$@" 2>&1
  local rc=$?
  printf '[exit %s]\n' "$rc"
  return "$rc"
}

make_case() {
  local name=$1 builder_harness=$2 builder_model=$3 implementation=$4
  local dir="$WORK/$name" source remote project wt home fake_root fakebin
  source="$dir/source"; remote="$dir/remote.git"; project="$dir/project"
  wt="$dir/wt"; home="$dir/home"; fake_root="$dir/root"; fakebin="$dir/fakebin"

  mkdir -p "$source" "$home/state" "$home/data/task-a" "$home/config" "$fake_root/bin" "$fakebin"
  git -C "$source" init -q -b main
  printf '%s\n' '# fixture' > "$source/README.md"
  git -C "$source" add README.md
  git -C "$source" commit -qm initial
  git clone --quiet --bare "$source" "$remote"
  git -C "$source" remote add origin "file://$remote"
  git -C "$source" push -q -u origin main
  git clone --quiet "$remote" "$project"
  git clone --quiet "$remote" "$wt"
  git -C "$wt" checkout -qb feature
  printf '%s\n' "$implementation" > "$wt/authorize.sh"
  git -C "$wt" add authorize.sh
  git -C "$wt" commit -qm feature
  git -C "$wt" push -q origin HEAD:refs/pull/1/head

  cat > "$home/data/task-a/brief.md" <<'EOF'
You are a builder.

# Task
Reject every authorization request except the literal value `allowed`.

## Acceptance criteria

- `allowed` succeeds.
- Every other value fails.
- No caller can bypass the check.

# Builder summary
BUILDER_REASONING_SENTINEL: trust me, the implementation is correct.

# Definition of done
Open a pull request.
EOF

  {
    printf 'window=fm-task-a\nendpoint_task_id=task-a\n'
    printf 'worktree=%s\nproject=%s\n' "$wt" "$project"
    printf 'harness=%s\nmodel=%s\n' "$builder_harness" "$builder_model"
    printf 'kind=ship\nmode=no-mistakes\nyolo=off\n'
  } > "$home/state/task-a.meta"
  chmod 0600 "$home/state/task-a.meta"
  printf '%s\n' 'done: PR https://github.com/example/repo/pull/1 checks green' > "$home/state/task-a.status"

  cat > "$fakebin/gh" <<'SH'
#!/usr/bin/env bash
[ "${1:-} ${2:-}" = 'pr view' ] || exit 1
shift 2
json=; query=
while [ "$#" -gt 0 ]; do
  case "$1" in
    --json) json=$2; shift 2 ;;
    -q|--jq) query=$2; shift 2 ;;
    --repo) shift 2 ;;
    *) shift ;;
  esac
done
[ "$json" = state,isDraft,headRefOid ] || exit 1
[ -n "$query" ] || exit 1
head=$(git --git-dir="$FM_TEST_REMOTE" rev-parse refs/pull/1/head)
[ -z "${FM_TEST_GH_LOG:-}" ] || printf 'pr view --json state,isDraft,headRefOid\n' >> "$FM_TEST_GH_LOG"
printf '%s\t%s\t%s\n' "${FM_TEST_PR_STATE:-OPEN}" "${FM_TEST_PR_DRAFT:-false}" "$head"
SH
  cat > "$fake_root/bin/fm-spawn.sh" <<'SH'
#!/usr/bin/env bash
id=$1; project=$2; shift 2
harness=; model=default
while [ "$#" -gt 0 ]; do
  case "$1" in
    --harness) harness=$2; shift 2 ;;
    --model) model=$2; shift 2 ;;
    --effort) shift 2 ;;
    --scout) shift ;;
    *) exit 2 ;;
  esac
done
printf '%s\t%s\t%s\n' "$id" "$harness" "$model" >> "$FM_TEST_SPAWN_LOG"
{
  printf 'window=fm-%s\nendpoint_task_id=%s\n' "$id" "$id"
  printf 'worktree=%s\nproject=%s\n' "$project" "$project"
  printf 'harness=%s\nmodel=%s\n' "$harness" "$model"
  printf 'kind=scout\nmode=scout\nyolo=off\n'
} > "$FM_STATE_OVERRIDE/$id.meta"
SH
  printf '#!/usr/bin/env bash\nexit 0\n' > "$fake_root/bin/fm-guard.sh"
  printf '#!/usr/bin/env bash\nexec "%s" "$@"\n' "$REVIEW" > "$fake_root/bin/fm-independent-review.sh"
  printf '#!/usr/bin/env bash\nexit 0\n' > "$fakebin/claude"
  printf '#!/usr/bin/env bash\nexit 0\n' > "$fakebin/codex"
  chmod +x "$fakebin/gh" "$fakebin/claude" "$fakebin/codex" "$fake_root/bin/fm-spawn.sh" \
    "$fake_root/bin/fm-guard.sh" "$fake_root/bin/fm-independent-review.sh"
  : > "$dir/spawn.log"
  printf '%s\n' "$dir"
}

round_value() { sed -n "s/^$3=//p" "$1/home/state/task-a.independent-review.round-$2" | tail -1; }

# The stand-in reviewer agent: reads ONLY the two bundled cold artifacts it was
# given, then submits one bounded verdict through the documented command.
reviewer_agent() {
  local dir=$1 round=$2 reviewer head diff
  reviewer=$(round_value "$dir" "$round" reviewer_task)
  head=$(round_value "$dir" "$round" head)
  diff=$(round_value "$dir" "$round" diff)
  if grep -F 'DEFECT_ACCEPTS_EVERYTHING' "$diff" >/dev/null; then
    show "$dir" "$REVIEW" submit task-a "$reviewer" "$head" reject \
      'authorization accepts every input' \
      --block correctness 'authorize.sh returns success for unauthorized values'
  else
    show "$dir" "$REVIEW" submit task-a "$reviewer" "$head" clear 'no blocking findings' \
      --follow-up 'consider a regression test for the empty-string case'
  fi
}

advance_head() {
  local dir=$1 implementation=$2 message=$3
  printf '%s\n' "$implementation" > "$dir/wt/authorize.sh"
  git -C "$dir/wt" add authorize.sh
  git -C "$dir/wt" commit -qm "$message"
  git -C "$dir/wt" push -q --force origin HEAD:refs/pull/1/head
}

################################################################
rule 'SCENARIO A - a Codex-built PR walks the full gate: review -> reject -> one fix round -> clear'
DIR=$(make_case scenario-a codex gpt-5.6-sol 'authorize() { return 0; } # DEFECT_ACCEPTS_EVERYTHING')

step 'Builder metadata recorded for the finished ship task'
grep -E '^(harness|model|kind|mode)=' "$DIR/home/state/task-a.meta"
printf 'current forge head: %s\n' "$(git --git-dir="$DIR/remote.git" rev-parse refs/pull/1/head)"

step 'A1. Captain readiness call on a finished, unreviewed PR'
show "$DIR" "$PR_CHECK" task-a https://github.com/example/repo/pull/1
printf '\nrecorded pr= / pr_head= in task meta: %s\n' \
  "$(grep -cE '^pr(_head)?=' "$DIR/home/state/task-a.meta")"
printf 'merge poll armed (state/task-a.check.sh): %s\n' \
  "$([ -e "$DIR/home/state/task-a.check.sh" ] && echo yes || echo no)"
printf 'task state written while the review is pending (no poll, no new wake source):\n'
ls -1 "$DIR/home/state" | sed 's/^/  /'

step 'A2. Reviewer selection was derived at runtime from the recorded builder family'
printf 'builder:  harness=%s model=%s family=%s\n' \
  "$(round_value "$DIR" 1 builder_harness)" "$(round_value "$DIR" 1 builder_model)" \
  "$(round_value "$DIR" 1 builder_family)"
printf 'reviewer: task=%s harness=%s family=%s\n' \
  "$(round_value "$DIR" 1 reviewer_task)" "$(round_value "$DIR" 1 reviewer_harness)" \
  "$(round_value "$DIR" 1 reviewer_family)"
printf 'fm-spawn dispatch log (id / harness / model): %s\n' "$(cat "$DIR/spawn.log")"

step 'A3. What the cold reviewer was actually given'
printf '%s\n' '--- reviewer brief ---'
cat "$(round_value "$DIR" 1 brief)"
printf '%s\n' '--- bundled acceptance criteria (immutable copy) ---'
cat "$(round_value "$DIR" 1 criteria)"
printf '%s\n' '--- bundled exact diff (first lines) ---'
head -12 "$(round_value "$DIR" 1 diff)"
printf '%s\n' '--- leakage check: builder reasoning must not reach the cold bundle ---'
if grep -rl 'BUILDER_REASONING_SENTINEL' "$DIR/home/state/task-a.independent-review.bundle-1" \
  "$(round_value "$DIR" 1 brief)" 2>/dev/null; then
  printf 'LEAK: builder reasoning reached the reviewer\n'
else
  printf 'no builder reasoning, status history, or pipeline output in the reviewer bundle\n'
fi

step 'A4. The cold reviewer submits its bounded verdict'
reviewer_agent "$DIR" 1

step 'A5. Captain readiness call after the rejection'
show "$DIR" "$PR_CHECK" task-a https://github.com/example/repo/pull/1
printf '\nmerge poll armed: %s\n' \
  "$([ -e "$DIR/home/state/task-a.check.sh" ] && echo yes || echo no)"

step 'A6. Builder pushes the fix; the head moves'
advance_head "$DIR" 'authorize() { [ "${1:-}" = allowed ]; }' 'fix: reject unauthorized values'
printf 'new forge head: %s\n' "$(git --git-dir="$DIR/remote.git" rev-parse refs/pull/1/head)"
show "$DIR" "$PR_CHECK" task-a https://github.com/example/repo/pull/1

step 'A7. Round 2 is a fresh cold reviewer with no prior verdict in its brief'
printf 'round-1 reviewer: %s\n' "$(round_value "$DIR" 1 reviewer_task)"
printf 'round-2 reviewer: %s\n' "$(round_value "$DIR" 2 reviewer_task)"
printf 'round-2 brief or bundle carries the round-1 reviewer id or its finding: %s\n' \
  "$(grep -rlF -e "$(round_value "$DIR" 1 reviewer_task)" \
      -e 'authorize.sh returns success for unauthorized values' \
      "$(round_value "$DIR" 2 brief)" "$DIR/home/state/task-a.independent-review.bundle-2" \
      2>/dev/null | wc -l | tr -d ' ') file(s)"
reviewer_agent "$DIR" 2

step 'A8. Captain readiness call after the clear verdict on the exact current head'
show "$DIR" "$PR_CHECK" task-a https://github.com/example/repo/pull/1
printf '\nrecorded readiness metadata:\n'
grep -E '^pr(_head)?=' "$DIR/home/state/task-a.meta"
printf 'exact forge head:  %s\n' "$(git --git-dir="$DIR/remote.git" rev-parse refs/pull/1/head)"
printf 'merge poll armed: %s\n' \
  "$([ -e "$DIR/home/state/task-a.check.sh" ] && echo yes || echo no)"

step 'A9. The head moves again after clearance: the verdict is invalidated and the circuit is open'
advance_head "$DIR" 'authorize() { [ "${1:-}" = allowed ] || [ "${1:-}" = admin ]; }' 'feat: also allow admin'
printf 'new forge head: %s\n' "$(git --git-dir="$DIR/remote.git" rev-parse refs/pull/1/head)"
show "$DIR" "$PR_CHECK" task-a https://github.com/example/repo/pull/1

################################################################
rule 'SCENARIO C - a second rejection opens the circuit instead of buying a third round'
DIR_C=$(make_case scenario-c codex gpt-5.6-sol 'authorize() { return 0; } # DEFECT_ACCEPTS_EVERYTHING')

step 'C1. Round 1 dispatches and rejects'
show "$DIR_C" "$PR_CHECK" task-a https://github.com/example/repo/pull/1
reviewer_agent "$DIR_C" 1

step 'C2. The builder pushes a fix that is still defective; round 2 dispatches'
advance_head "$DIR_C" 'authorize() { return 0; } # DEFECT_ACCEPTS_EVERYTHING (still)' 'fix: attempt two'
show "$DIR_C" "$PR_CHECK" task-a https://github.com/example/repo/pull/1
reviewer_agent "$DIR_C" 2

step 'C3. Captain readiness call after the second rejection'
show "$DIR_C" "$PR_CHECK" task-a https://github.com/example/repo/pull/1

################################################################
rule 'SCENARIO B - fail-closed refusals name the exact missing fact'

step 'B1. No verified different-family adapter is available'
DIR_B1=$(make_case scenario-b1 codex gpt-5.6-sol 'authorize() { [ "${1:-}" = allowed ]; }')
rm -f "$DIR_B1/fakebin/claude" "$DIR_B1/fakebin/codex"
export FM_INDEPENDENT_REVIEW_CANDIDATES='claude|default|high'
show "$DIR_B1" "$PR_CHECK" task-a https://github.com/example/repo/pull/1
unset FM_INDEPENDENT_REVIEW_CANDIDATES

step 'B2. Builder family cannot be established from a model-routing harness with no recorded model'
DIR_B2=$(make_case scenario-b2 pi default 'authorize() { [ "${1:-}" = allowed ]; }')
show "$DIR_B2" "$PR_CHECK" task-a https://github.com/example/repo/pull/1

step 'B3. The same model-routing harness with a recorded provider resolves and dispatches'
DIR_B3=$(make_case scenario-b3 pi openrouter/anthropic/claude-sonnet-4.6 'authorize() { [ "${1:-}" = allowed ]; }')
show "$DIR_B3" "$PR_CHECK" task-a https://github.com/example/repo/pull/1
printf 'derived builder family: %s -> reviewer family: %s\n' \
  "$(round_value "$DIR_B3" 1 builder_family)" "$(round_value "$DIR_B3" 1 reviewer_family)"

step 'B4. Scope: a draft PR is never read'
DIR_B4=$(make_case scenario-b4 codex gpt-5.6-sol 'authorize() { [ "${1:-}" = allowed ]; }')
export FM_TEST_PR_DRAFT=true
show "$DIR_B4" "$PR_CHECK" task-a https://github.com/example/repo/pull/1
unset FM_TEST_PR_DRAFT

step 'B5. Scope: an already merged PR is never read'
export FM_TEST_PR_STATE=MERGED
show "$DIR_B4" "$PR_CHECK" task-a https://github.com/example/repo/pull/1
unset FM_TEST_PR_STATE

step 'B6. Forge access stayed read-only for the whole run'
printf 'every gh invocation made by the gate across all scenarios:\n'
sort "$WORK/gh-calls.log" | uniq -c
printf '(the gh stub exits 1 on any call shape other than the read-only `pr view` field selection)\n'

rule 'END OF TRANSCRIPT'
Evidence: Captain-facing readiness output before and after independent clearance
--- A1. Captain readiness call on a finished, unreviewed PR

$ bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1
independent review started: round 1 reviewer=ir-task-a-r1-eb667265c01b family=anthropic head=eb667265c01b...
[exit 3]

recorded pr= / pr_head= in task meta: 0
merge poll armed (state/task-a.check.sh): no

--- A5. Captain readiness call after the rejection

$ bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1
error: independent review rejected head eb667265c01b...: authorization accepts every input
blocker: correctness: authorize.sh returns success for unauthorized values
[exit 1]

--- A8. Captain readiness call after the clear verdict on the exact current head

$ bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1
Independent review: ir-task-a-r2-1527915c89cd via claude (anthropic family) - no blocking findings
armed: state/task-a.check.sh
[exit 0]

recorded readiness metadata:
pr=https://github.com/example/repo/pull/1
pr_head=1527915c89cd4926d2a499eac17bb8e68efbc9d6
exact forge head: 1527915c89cd4926d2a499eac17bb8e68efbc9d6

--- A9. The head moves again after clearance

$ bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1
error: pull request head changed after two review rounds; the circuit is open and the work must be re-scoped
[exit 1]
Evidence: Second rejection opens the circuit, and fail-closed refusals name the missing fact
--- C3. Captain readiness call after the second rejection

$ bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1
error: independent review rejected head 0a9c8fe22e25...: authorization accepts every input
blocker: correctness: authorize.sh returns success for unauthorized values
error: second rejection opened the circuit; stop and re-scope the design instead of producing a third fix round
[exit 1]

--- B1. No verified different-family adapter is available
error: could not establish an available verified different-family reviewer for builder family 'openai'
[exit 1]

--- B2. Builder family unresolvable from a model-routing harness with no recorded model
error: could not establish builder model family: harness=pi requires a recorded model with a verified provider family
[exit 1]

--- B3. Same harness with a recorded provider resolves and dispatches
independent review started: round 1 reviewer=ir-task-a-r1-92497eff39b3 family=openai head=92497eff39b3...
derived builder family: anthropic -> reviewer family: openai

--- B4/B5. Scope
error: pull request is still a draft; independent review covers finished pull requests only
error: pull request is already merged; independent review never runs on merged work

--- B6. Forge access stayed read-only
10 pr view --json state,isDraft,headRefOid
Evidence: Reviewer coldness: only criteria and exact diff, no builder reasoning, no prior verdict
--- A3. What the cold reviewer was actually given
--- bundled acceptance criteria (immutable copy) ---
Reject every authorization request except the literal value `allowed`.

## Acceptance criteria

- `allowed` succeeds.
- Every other value fails.
- No caller can bypass the check.

--- bundled exact diff (first lines) ---
diff --git a/authorize.sh b/authorize.sh
new file mode 100644
+authorize() { return 0; } # DEFECT_ACCEPTS_EVERYTHING

--- leakage check ---
no builder reasoning, status history, or pipeline output in the reviewer bundle

--- A7. Round 2 is a fresh cold reviewer
round-1 reviewer: ir-task-a-r1-eb667265c01b
round-2 reviewer: ir-task-a-r2-1527915c89cd
round-2 brief or bundle carries the round-1 reviewer id or its finding: 0 file(s)

--- task state written while the review is pending (no poll, no new wake source)
ir-task-a-r1-eb667265c01b.meta
task-a.independent-review.bundle-1
task-a.independent-review.round-1
task-a.meta
task-a.status
- Outcome: ⚠️ 3 issues (1 warning, 2 infos) across 1 run (14m28s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 7 issues found → auto-fixed (2) ✅
  • 🚨 bin/fm-independent-review.sh:184 - inspect_pr reads the GitHub PR state and head with gh-axi pr view &lt;n&gt; --repo &lt;path&gt; --json state,isDraft,headRefOid --template ..., but gh-axi's pr view supports only --comments/--reviews/--full. Verified live against the real binary: it exits 0, silently ignores --json/--template, and prints its own compact block (pull_request: / number: ...) that contains no head SHA and no tab separators. IFS=$&#39;\t&#39; read therefore sets PR_STATE="pull_request:" and PR_HEAD="", fm_pr_head_valid &#34;&#34; fails, and inspect_pr refuses with 'could not establish the pull request exact head commit from the forge response'. Because fm-pr-check.sh now hard-gates on this, every GitHub PR readiness call is permanently blocked and no task can ever be reported captain-ready. The repo already uses plain gh for exactly this kind of field read (bin/fm-teardown.sh:456 gh pr view &#34;$target&#34; --json state,headRefOid -q ..., bin/fm-pr-poll.sh:65); switch this call to gh pr view &#34;$FM_PR_NUMBER&#34; --repo &#34;$FM_PR_PATH&#34; --json state,isDraft,headRefOid -q &#39;.state + &#34;\t&#34; + (.isDraft|tostring) + &#34;\t&#34; + .headRefOid&#39; (and adjust the command -v probe to gh). The new test suite mocks gh-axi with the tab-separated shape, so it cannot catch this.
  • ⚠️ bin/fm-independent-review.sh:654 - A round that can never produce a verdict wedges readiness permanently with no in-band recovery. If fm-spawn fails (worktree pool exhaustion, backend error, quota), start_review appends status=launch-failed to the round file but leaves it on disk; start_review refuses to recreate an existing round file (line 380), so the next ready at the same head hits the launch-failed branch and returns 1 forever, and if the head has since moved it takes the verdict_round != round branch and prints a false 'independent review pending for prior head ...' and returns 3 forever. The same wedge occurs when a reviewer launches but dies before submitting: ready reports pending indefinitely with no timeout or re-dispatch. Recovery requires an operator to hand-delete state/<id>.independent-review.round-N, which is documented nowhere. Make a round with status=launch-failed (no reviewer_task ever started) replaceable so the next ready re-dispatches, and give the dead-reviewer case either an explicit re-dispatch path or a refusal that names the exact file to retire.
  • ⚠️ bin/fm-independent-review.sh:294 - extract_task_criteria stops at the first line matching /^# / after # Task, so any line beginning with '# ' inside the task section truncates the criteria. Real briefs (bin/fm-brief.sh:254/363) place free-form firstmate-written task text and acceptance criteria between # Task and # Setup, and that text routinely contains fenced shell snippets whose comments start with '# '. The truncation is silent: the bundle still passes the [ -s ] and size checks, so the cold reviewer judges the diff against a partial acceptance-criteria set and can return clear for a PR that fails the omitted criteria. This fails open on the one input the gate exists to check. Stop only on a known brief heading (^# (Setup|Rules|Definition of done|Herdr...)) or track fenced code blocks while scanning.
  • ℹ️ bin/fm-independent-review.sh:749 - submit_command authenticates the verdict only by task identity: the reviewer id must appear as reviewer_task= in a round file and its meta must record kind=scout with a matching harness/model/family. Nothing binds the submission to the reviewer process itself, and the round file (mode 0600, same uid as every other firstmate agent) contains the reviewer_task id and head, so the builder task or any other local agent can run fm-independent-review.sh submit &lt;parent&gt; &lt;reviewer-id&gt; &lt;head&gt; clear &#39;...&#39; and record a clear verdict the cold reviewer never produced. That is the single fact the whole gate rests on. The repo already has a pattern for this (the per-task hook registry tokens, &lt;id&gt;.grok-turnend-token / &lt;id&gt;.kimi-turnend-token): write a per-round secret into the reviewer's private data dir, interpolate it into the reviewer brief's submit command, and require it on submit. Flagging rather than fixing because it changes the reviewer contract.
  • ℹ️ bin/fm-pr-check.sh:104 - fm-guard.sh moved from before the migration step to after the review gate, so its watcher-liveness and worktree-tangle banner no longer fires on the pending, rejected, or unresolvable paths - which are now the common outcomes of this command, and exactly the window in which the captain is waiting on a reviewer and a dead watcher matters most. The move was presumably needed to keep the verdict as the first stdout line (fm-guard writes 24 of its 26 messages to stdout). The same buffering pattern already applied to MIGRATION_OUTPUT solves both: run fm-guard before the review dispatch, capture its stdout, and print it after the verdict line.
  • ℹ️ bin/fm-independent-review.sh:631 - The clear-verdict branch duplicates a five-argument printf across an if/else whose only difference is whether the reviewer model is appended to the harness name. Compose the identity once (e.g. reviewer_id=$harness then [ &#34;$model&#34; = default ] || reviewer_id=$harness/$model) and emit a single printf, so the captain-facing line - the one output the intent makes load-bearing - has one definition instead of two that can drift.
  • ℹ️ docs/scripts.md:88 - AGENTS.md, docs/architecture.md, and docs/gitlab-merge-watch.md were updated for the gate, but the operator-current script index was not: bin/fm-independent-review.sh has no row, and the fm-pr-check.sh row still reads 'Record validated pr= and pr_head= values, then atomically arm a static merge poll' with no mention that it now refuses until a different-family clear verdict matches the exact head. Add the new row and amend the fm-pr-check.sh row.

🔧 Fix: fix(bin): repair forge read and review round recovery
1 info still open:

  • ℹ️ bin/fm-independent-review.sh:663 - The new retirement path treats a round as replaceable whenever its reviewer has no state/<reviewer>.meta and no .status, which includes a round still recorded as status=launching. fm-spawn writes the reviewer meta late (after worktree creation and backend readiness), so during that window a second overlapping ready/fm-pr-check for the same task would see round_never_launched=true and run retire_round, which rm -rfs the bundle and $DATA/<reviewer> - deleting brief.md out from under the fm-spawn call that is still launching (fm-spawn.sh:847 requires that file to exist). Preconditions are narrow: firstmate holds a per-home session lock and fm-pr-check is not called by the watcher, so single-captain operation never overlaps. Raising it rather than changing it because narrowing the check to status=launch-failed would trade this away for a mid-spawn crash that is no longer auto-retired (it would still get the explicit 'retire <file>' message), and that is the author's call. No change needed if single-caller operation is the accepted assumption.

🔧 Fix: refactor(bin): drop automatic stale review round retirement
✅ Re-checked - no issues remain.

⚠️ **Test** - 3 issues (1 warning, 2 infos)
  • ⚠️ /Users/jared/.claude/rules/how-i-work.md:73 - Intent requires eliminating stale fixed-vendor reviewer guidance from private configuration outside the tracked pull request, but /Users/jared/.claude/rules/how-i-work.md:73 still mandates "one independent adversarial cross-check from Codex, never Gemini", which contradicts the new runtime-derived different-family rule. It sits outside the worktree, so I could not verify it was handled elsewhere and did not change it. The user needs to decide whether to update that private rule file.
  • ℹ️ tests/fm-teardown.test.sh:1557 - tests/fm-teardown.test.sh fails on the herdr-preflight-missing-adapter case (stderr lacks the "nothing was changed" refusal explanation). The identical failure reproduces on a clean extraction of base commit 1e24757, so it is pre-existing and not a regression from this change.
  • ℹ️ tests/fm-test-run.test.sh - tests/fm-test-run.test.sh's "jobs=2 must refill the first completed slot" assertion failed once while running concurrently with the heavy pr-forge suites, and passed when the suite was re-run in isolation. It is a load-sensitive timing assertion, not a product failure.
  • bin/fm-test-run.sh tests/fm-independent-review.test.sh (19 behaviours, all pass)
  • bin/fm-test-run.sh tests/fm-pr-check-security.test.sh tests/fm-pr-merge.test.sh tests/fm-secondmate-safety.test.sh tests/fm-teardown.test.sh tests/fm-test-run.test.sh
  • bin/fm-test-run.sh tests/fm-test-run.test.sh re-run in isolation (passes, confirming the earlier failure was load-sensitive)
  • bin/fm-test-run.sh tests/fm-teardown.test.sh run against a clean extraction of base commit 1e24757 (same failure, confirming it is pre-existing)
  • Manual end-to-end: bash independent-review-e2e.sh &lt;repo-root&gt; &lt;workdir&gt; driving real bin/fm-pr-check.sh task-a https://github.com/example/repo/pull/1 through unreviewed dispatch, rejection, fix round, clear verdict, and post-clearance head move
  • Manual: bin/fm-independent-review.sh submit task-a &lt;reviewer-id&gt; &lt;head&gt; reject ... --block correctness ... and the matching clear submission from the reviewer bundle only
  • Manual: reviewer-bundle leakage check (grep -rl BUILDER_REASONING_SENTINEL over the round-1 bundle and brief) and round-2 coldness check for the round-1 reviewer id and finding
  • Manual fail-closed checks: no different-family adapter available, harness=pi with no recorded model, harness=pi model=openrouter/anthropic/claude-sonnet-4.6, draft PR, merged PR
  • Manual read-only forge check: tally of every gh invocation made by the gate across all scenarios
⚠️ **Document** - 1 info
  • ℹ️ .agents/skills/bootstrap-diagnostics/SKILL.md:42 - .agents/skills/bootstrap-diagnostics/SKILL.md:42 tells the operator to recover a quarantined PR poll by rearming "only through bin/fm-pr-check.sh with canonical inputs". That call now also runs the standing independent-review gate, so a rearm can be refused or can dispatch a new reviewer round when the forge head has moved since the recorded verdict. The sentence is not false, so I left it alone rather than copying the gate contract into a second agent-runtime surface; the gate's own refusal names the pending round and file. Worth a one-clause pointer to AGENTS.md section 7 if maintainers want the recovery path to state its new precondition.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@JaredHuynhning
JaredHuynhning force-pushed the fm/fm-independent-verifier branch 2 times, most recently from fe55571 to b378dc6 Compare August 3, 2026 17:31
@JaredHuynhning
JaredHuynhning force-pushed the fm/fm-independent-verifier branch from b378dc6 to 3e590c8 Compare August 4, 2026 09:00
@kunchenguid

kunchenguid commented Aug 5, 2026 •

Copy link
Copy Markdown
Owner

Automated reminder: thanks for the PR! This branch currently has a merge conflict with the base branch.

When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again.

Noted for firstmate#1470 at 3e590c87.

@kunchenguid kunchenguid added wheelhouse:pending-contributor-action Managed by Wheelhouse and removed wheelhouse:pending-contributor-action Managed by Wheelhouse labels Aug 5, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: closing this as stale. It has been waiting on a contributor update for 14+ days with no author push or comment. Reopen if you want to pick it back up.

@RooseveltAdvisors

Copy link
Copy Markdown
Contributor

Observation, not a change request - noting this for the record since the PR is currently closed as stale (closed-stale-14d), so it is informational for anyone who picks it back up.

In bin/fm-independent-review.sh, the verdict-accept path (round selection and reviewer binding, roughly :746-761 - referenced in our notes as :749) authenticates a submission by task identity plus the round/head binding: the round file must exist, its reviewer_task must match, the recorded head must equal the bundle head, and the reviewer must be kind=scout. What it does not have is a shared secret between the brief that hands the reviewer its submit command (the submit_command() helper, :694/:328) and the code that accepts it.

So any local process able to write to $STATE can record a clear the cold reviewer never produced. That matters more here than in most gates, because the verdict is the single fact the whole design rests on: a forged clear reads exactly like an earned one.

A direction that would close it without changing the interface: a per-round secret written into the reviewer's private data dir, interpolated into the submit command when the brief is built and required on submit - the same shape as the existing <id>.grok-turnend-token / <id>.kimi-turnend-token registry pattern.

Happy to be wrong if there is an authentication step I did not read; recording it as an observation rather than filing it as an issue.

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.

3 participants