Skip to content

feat(reviewing-prs): dispatch-time worktree bootstrap (WORKTREE_BOOTSTRAP_CMD) - #49

Merged
SSFSKIM merged 2 commits into
mainfrom
fix/review-worktree-bootstrap
Aug 10, 2026
Merged

SSFSKIM merged 2 commits into
mainfrom
fix/review-worktree-bootstrap

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Aug 9, 2026

Copy link
Copy Markdown
Owner

문제

리뷰 디스패치가 만드는 detached 워크트리는 맨몸(의존성·env 파일 없음)으로 시작한다. ida env-tracker(obra#1107)의 지배 스레드(+1 15건 이상): 리뷰어의 검증이 거짓 red(tsc·vitest 동시 오작동)나 공허한 green으로 갈렸고, 실제로 잘못된 리뷰 판정을 낸 사례가 기록돼 있다.

수정

  • WORKTREE_BOOTSTRAP_CMD 설정 시, 워커 스폰 전에 새 워크트리 안에서 실행 (PR 경로·scale-review 경로 양쪽). 예: npm run setup:worktree
  • 실패는 $DAEMON_HOME/<name>.bootstrap.log에 기록하고 디스패치는 막지 않음 (환경 프로비저닝 문제로 리뷰 자체를 잃지 않기 위해)
  • 미설정 = 기존 동작 그대로
  • WORKTREE_BOOTSTRAP_TIMEOUT (기본 900초)
  • 리뷰 워커 헤더에 '어느 쪽이든 red/green을 믿기 전에 환경부터 확인' 한 줄 추가

검증

  • tests/reviewing-prs/test-review-dispatch.sh에 신규 블록 6 asserts: 워크트리 안 실행·로그 적재·정상 스폰·실패 보고·실패 시에도 스폰·미설정 시 무동작 — 전부 PASS
  • 기존 전체 스위트 PASS, shell-lint PASS

배포 시 VM sweep 유닛에 Environment=WORKTREE_BOOTSTRAP_CMD=npm run setup:worktree를 추가하면 ida에 적용된다.

…TRAP_CMD)

Detached review worktrees start bare — no deps, no env files — which made
reviewer verification runs fail red or pass vacuously (ida#1107's dominant
thread, 15+ occurrences). When WORKTREE_BOOTSTRAP_CMD is set, the dispatcher
now runs it inside the fresh worktree before the worker spawns, for both the
PR and scale-review paths. Failure logs to $DAEMON_HOME/<name>.bootstrap.log
and never blocks dispatch. Unset = prior behavior.

The review worker header gains a note to verify the environment before
trusting red/green either way.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 741f57ae41

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +34 to +36
Either way, before trusting any red/green verification result, confirm the
worktree actually supports it (dependencies installed, env files present) —
a bare worktree produces false reds and vacuous greens.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Run the required behavior evaluation for this prompt change

This new instruction changes how every review worker interprets verification results, but the commit provides only shell assertions rather than the required before/after behavior evaluation or pressure testing. Add eval evidence covering false-red and vacuous-green scenarios before relying on this worker guidance. CLAUDE.mdL32-L39

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Judged per the instruction: reply-only. The added worker-prompt line restates what the review protocol already demands (verify the environment supports a result before trusting it) — it nudges attention to the new pre-bootstrap state rather than shaping new judgment behavior, so under this fork's bar (fork-local tweaks ship with sanity tests, per CLAUDE.md Working conventions) it takes the sanity-test track, not a before/after behavior eval. The behavior that actually changed in this PR is dispatcher-side (bootstrap execution, trust choreography, lock, budget), and that is covered by hermetic shell assertions in test-review-dispatch.sh. If the prompt line grows into real instruction changes later, that revision should meet the eval bar.

Comment on lines +348 to +349
( cd "$wt" && timeout "${WORKTREE_BOOTSTRAP_TIMEOUT:-900}" \
bash -lc "$WORKTREE_BOOTSTRAP_CMD" ) >"$log" 2>&1 || rc=$?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Provide a portable timeout on the supported macOS runner

When WORKTREE_BOOTSTRAP_CMD is enabled on the documented runner, this invokes GNU coreutils timeout, but references/runner-setup.md:1-48 assumes macOS and its required CLI/PATH setup lists no coreutils dependency. On a stock macOS runner the command exits 127 before bash -lc starts; because that error is deliberately swallowed, dispatch continues with an unbootstrapped worktree every time. Use a portable timer or document/install and invoke the macOS coreutils binary.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in d20d5c1: _run_with_budget prefers timeout -k 10, then gtimeout -k 10, and on stock macOS (neither present) falls back to a portable watchdog — background the command, TERM at the budget, KILL 10s later. The watchdog path is the one actually exercised by the test suite on this machine (no coreutils timeout installed): budget enforcement is prompt (2s) passes.

git -C "$LOCAL_REPO" worktree prune
git -C "$LOCAL_REPO" worktree add -q --detach "$wt" "$HEAD_SHA" \
|| { echo "#$pr: worktree add failed" >&2; rm -rf "$tmp"; return 1; }
_bootstrap_worktree "$wt" "review-pr-$pr"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Serialize dispatch before running the bootstrap

If a PR event and the 30-minute sweep overlap during a nontrivial bootstrap, no reviewer metadata exists yet, so both dispatches pass _decide; the second then sees no occupant and removes/recreates the same worktree at lines 421-425 while the first bootstrap is still using it, after which both can spawn against that path. This invalidates the no-lock live-reviewer serialization described in references/operation-manual.md:184-187; acquire a per-worker dispatch lock or publish an in-progress identity before entering the potentially 900-second hook.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in d20d5c1 with a per-worker mkdir dispatch lock ($DAEMON_HOME/<name>.dispatch.lock), matching board-sweep.sh's portable-lock + 30-min stale-steal policy (DISPATCH_LOCK_STALE). Consistent with the operation manual's serialization argument: dedupe-on-dispatch remains the primary serializer; the lock only covers the metadata-free window between workspace preparation and spawn that the manual's argument doesn't reach. Both dispatch_one and dispatch_epic acquire it. Tests: fresh lock → skip, no spawn; stale lock → stolen, dispatch proceeds; lock released after.

[ -n "${WORKTREE_BOOTSTRAP_CMD:-}" ] || return 0
local wt="$1" wname="$2" log rc=0
log="$DAEMON_HOME/$wname.bootstrap.log"
( cd "$wt" && timeout "${WORKTREE_BOOTSTRAP_TIMEOUT:-900}" \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep the bootstrap budget below the workflow timeout

For PR-triggered dispatches, references/pr-review-dispatch.yml:34 caps the entire job at 10 minutes, while this default allows the bootstrap alone to run for 15 minutes. A configured bootstrap taking 10–15 minutes is therefore terminated by GitHub before this function can report its nonfatal failure or spawn the reviewer, contradicting the stated dispatch-anyway behavior. Reduce this default below the remaining workflow budget or increase the workflow timeout.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in d20d5c1: default lowered to 480s, documented in the script header as bounded above by pr-review-dispatch.yml timeout-minutes: 10, and a comment added at the yml's timeout line ("raise both together, never just one").

local wt="$1" wname="$2" log rc=0
log="$DAEMON_HOME/$wname.bootstrap.log"
( cd "$wt" && timeout "${WORKTREE_BOOTSTRAP_TIMEOUT:-900}" \
bash -lc "$WORKTREE_BOOTSTRAP_CMD" ) >"$log" 2>&1 || rc=$?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid executing PR-controlled package scripts before review

With the documented example WORKTREE_BOOTSTRAP_CMD='npm run setup:worktree', this executes the package.json script from the unreviewed PR head—npm run --help describes the command as running arbitrary package scripts. That contradicts the dispatcher's existing invariant at lines 127-129 that the workflow must never execute PR code, and the cron sweep processes every open non-draft PR without the workflow's owner-actor gate, so a collaborator PR can run arbitrary shell code with the dispatcher's local credentials before any reviewer inspects it. Resolve the bootstrap implementation from a trusted base/canonical checkout or run it in an isolated, credential-free environment.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed mechanically in d20d5c1. With a bootstrap configured, the worktree is now born at origin/$BASE_REF, the bootstrap runs there, and only afterwards does the worktree move to the PR head (git checkout --detach $HEAD_SHA — untracked artifacts like node_modules survive). Every input the command resolves (package.json, lockfiles, scripts) comes from reviewed code; a PR editing the bootstrap's own inputs is deliberately not honored at dispatch time. Same choreography on the scale-review path (base branch → integration ref). The invariant is stated in the script next to the existing never-execute-PR-code invariant, and a test proves the bootstrap cannot see a PR-head-only file (bootstrap never sees PR-head files) while the worktree still lands on the head SHA.

Comment on lines +348 to +349
( cd "$wt" && timeout "${WORKTREE_BOOTSTRAP_TIMEOUT:-900}" \
bash -lc "$WORKTREE_BOOTSTRAP_CMD" ) >"$log" 2>&1 || rc=$?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Force-kill bootstraps that ignore the timeout signal

On the cron sweep path there is no outer job timeout, and GNU timeout --help states that the default sends only TERM, which a command can catch or ignore, and that --kill-after may be necessary. A bootstrap that ignores TERM therefore remains inside this call beyond 900 seconds, preventing the dispatcher from recording its intended nonfatal failure, spawning the worker, or continuing the sweep. Add a finite --kill-after grace period so the configured budget is actually enforced.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Addressed in d20d5c1 together with the portability finding: both the timeout/gtimeout route (-k 10) and the watchdog fallback (TERM at budget, KILL 10s later) hard-kill. The prompt-kill test passes through the watchdog path on the macOS test machine.

…able hard-kill timeout, dispatch lock, budget/workflow consistency

Review findings on the bootstrap hook, designed as one unit:

- SECURITY: the bootstrap now runs with the worktree at the TRUSTED base
  ref, never the PR head — package.json/lockfiles/scripts it resolves come
  from reviewed code, and the worktree moves to the reviewed ref only
  afterwards (untracked artifacts survive the checkout). Invariant stated
  next to the existing never-execute-PR-code invariant. Same choreography
  on the scale-review path (bootstrap at base branch, then integration ref).
- Portability: GNU timeout is absent on the stock-macOS runner (exit 127
  silently skipped every bootstrap). _run_with_budget prefers
  timeout/gtimeout -k 10, else a watchdog that TERMs at the budget and
  KILLs 10s later — signal-ignoring bootstraps cannot overrun.
- Race: per-worker mkdir dispatch lock (stale-steal 30 min, board-sweep.sh
  policy) covers the metadata-free window between workspace preparation
  and spawn where a PR event and the sweep could both pass dedupe and
  recreate the worktree mid-bootstrap.
- Budget: default 480s, documented as bounded above by
  pr-review-dispatch.yml timeout-minutes: 10 (comment added there too).

Tests: +11 assertions (trusted-ref proof, PR-head landing, prompt budget
kill, fresh-lock skip, stale-lock steal, lock release); full suite green;
shellcheck clean.
@SSFSKIM
SSFSKIM merged commit beb5106 into main Aug 10, 2026
@SSFSKIM
SSFSKIM deleted the fix/review-worktree-bootstrap branch August 10, 2026 06:48
SSFSKIM added a commit that referenced this pull request Sep 14, 2026
issue-tracker: a worker records a dependency itself — blocked-by add, then the yield edge (arkho #49)
SSFSKIM added a commit that referenced this pull request Sep 15, 2026
Main's two intervening changes are orthogonal to Milestone 6 and were taken
whole:

- the dependency yield (arkho #49) — `in-progress` → `ready-for-implementer`,
  note-required, deliberately outside the convergence count, refused
  `not-blocked` without an unfinished blocker on record;
- the reviewer agents' frontmatter blocking `Skill` alongside `Agent`, which
  replaces the prose guard that used to carry that rule in their bodies.

Neither touches the seams this milestone draws. In `_board.py` the yield edits
the `in-progress` LEGAL row and the note/convergence sets; the branch edits the
`in-design` row's build-edge comment. In `board-transition.sh` the yield's
blocked-by guard sits after the legality check, ahead of the `--plan` block the
branch rewrote. The review-ownership flag addresses the session that owns the
review loop, not a reviewer agent, so the tool-level block neither weakens nor
duplicates it.

The two lines meet once, coherently: a pre-spec build that hits a dependency
yields into the executor lane carrying `plan: pre-spec` and the `--branch` this
branch now requires, which is exactly what a recovery Executor resumes from.

Conflicts were the four declared version manifests only. Resolved to main's
7.91.0, then re-bumped to 7.92.0 with scripts/bump-version.sh; the spec's
revision note for the fix wave now names the version it actually ships under.

Also reflows one sentence in issue-tracker/SKILL.md so "which no park state
does" is not split across a line break. The phrase is asserted by
tests/issue-tracker/test-protocol-content.sh, and main's rewrite of that
paragraph broke the assertion on main itself — this restores it without
changing the wording.

Suites on the merged tree: issue-tracker test-protocol-content, test-board-scripts,
test-execute-dispatch; qa-loops test-skill-entrypoint; board-api
test-register-transition; skill-links test-cross-doc-refs (207 refs / 17 skills);
version-bump test-bump-version. scripts/lint-shell.sh exit 0, shellcheck -x -S
warning clean on the edited shell files, git diff --check clean.
SSFSKIM added a commit that referenced this pull request Sep 15, 2026
… 7.93.0

This branch's base, `board-seams`, merged as #141, so the PR is re-pointed at
main. The branch already carried board-seams through its round-three head
(9b6a924), so only two commits from that line are new here, plus main's own
two.

What arrived, and why none of it disturbs the native-review port:

- `## Unresolved Review Findings` (#141's last fix) adds a self-contained
  paragraph to TRIAGE describing how the build's carried findings arrive in the
  PR body. It is about what TRIAGE reads, not about how the engine runs, so it
  sits beside the rewritten START ENGINE section without touching it.
- The dependency yield (arkho #49) edits the implement protocol's park
  paragraph; this branch edits that file's pre-PR self-review clause. Different
  paragraphs, no overlap.
- The reviewer agents now block `Skill` as well as `Agent` in frontmatter. That
  constrains a reviewer AGENT. START ENGINE calls the workflow from the Reviewer
  WORKER's own session, which is not a reviewer agent, so the port's mechanism
  is untouched — and the block reinforces the same no-recursion boundary the
  workflow already drew by running each reviewer in its own worktree.

Conflicts were the four declared version manifests and the 2026-09-12 spec's
Revision Notes, where both lines appended. Both sides' notes are kept; this
branch's supersession note (the verification entry is the review's LEVEL, not a
reason to fan out codex runs) stays last, since it is what amends Acceptance
16's fan-out clause.

Versions resolved to main's 7.92.0, then re-bumped to 7.93.0 with
scripts/bump-version.sh. The qa-loops design spec's own version references move
with it, and a revision note records this rebase.

Suites on the merged tree: qa-loops test-skill-entrypoint, test-bootstrap-parity;
issue-tracker test-protocol-content; review-bench test-review-engine (at its
moved path); skill-links test-cross-doc-refs (210 refs / 17 skills); version-bump
test-bump-version. scripts/lint-shell.sh exit 0, whitespace check clean. The
retired-binding sweep over skills/agents/scripts/tests/docs still returns only
the tests' own assert_not_contains lines.
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.

1 participant