Repository navigation
fix(review): say why a backend was skipped, and flag a round that fell back - #682
Conversation
…l back On #681 the whole round went to Bob, and the script said only "glm (not set up)". The real cause: the session started before the user added GLM_KEY_FILE to the shell profile, so it never saw the variable. The reviewer took "not set up" as a fact about the machine. - backend_ready may print a reason. glm's names the exact cause: no claude on PATH, GLM_KEY_FILE unset, set in the profile but not in this session, a file that is missing, or no gateway URL in it. - The "Tried first" line shows that reason. - When a reviewer did not use the first backend, the script ends with a Note line that says to tell the user before accepting the round. - SKILL.md: check GLM_KEY_FILE in this session before the run, and report the skip reason; do not read "not set up" as a fact about the machine. Assisted-By: Claude Signed-off-by: DAVID AMID <[email protected]>
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.309 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | aea32cb131ae |
blocking |
Verdict: blocking
Findings
-
scripts/offload-review.sh:348 — the new
Note:fires on a normal round-2 resume, where no backend fell back, and points at "Tried first" lines that were never printed.- What fails: round 2 after any round-1 fallback — the exact situation this PR was written for.
chain_for(lines 197–204) puts each reviewer's round-1 backend first, so it can resume its session. Reviewer 1 posts withbob, reviewer 2 withglm. No backend was skipped and no backend failed. The Note loop still fires, because"reviewer 1: bob"does not end in": glm". It says "not every reviewer used glm, the first backend" — false for reviewer 1, whose first backend wasbob. It also says "The reason is in the 'Tried first' lines above" — no such line exists, becauserun_reviewerprints "Tried first" only when a backend was actually skipped (line 292,triedempty here). - Proof:
chain_forline 201 putsprevfirst whenround > 1;usedentries are built as"reviewer $r: $b"(line 341); the loop at lines 347–349 tests only the suffix": $backend". I ran the loop withused=("reviewer 1: bob" "reviewer 2: glm")andbackend=glm: it prints the Note. A resumed session is a documented, intended flow (SKILL.md: "In round 2, each reviewer starts with the backend that wrote its round-1 review"), so the user gets a false alarm on a clean round. - Fix: flag the round from what actually happened, not from the backend names. Set a
fell_back=1flag where a backend is skipped (rc=4) or fails (thetriedpaths inrun_reviewer), and print the Note from that flag. Keep the "Tried first" promise only when at least one such line was printed.
- What fails: round 2 after any round-1 fallback — the exact situation this PR was written for.
-
scripts/offload-review/backends/glm.sh:68 — the login-shell probe can report the wrong reason for the skip, including in the exact case it was written to detect.
- What fails:
[ "$login" = set ]requires the whole stdout of the interactive shell to be exactlyset. Any line the profile writes to stdout is captured with it, so the probe then reports "GLM_KEY_FILE is not set (see the GLM setup guide)" even when the profile does set it. Also,${SHELL:-/bin/sh} -icstarts an interactive non-login shell: on macOS a variable in.zprofile(or.bash_profilefor bash users) is not sourced, so the probe misses it and again says "not set", while a new session would see the variable. - Proof: I ran a profile that both
exportsGLM_KEY_FILEandechoes one line; the captured value wasWelcome! Tools loaded.\nset, and the check answered "not set". zsh sources.zprofileonly for login shells, which-icis not. - Fix: make the probe print a unique marker and match it anywhere in the captured text, for example
printf 'CGPROBE:%s' "${GLM_KEY_FILE:+set}"and[[ $login == *CGPROBE:set* ]]. Use-lic(or check both the login and the interactive rc) so a variable in a login-only profile file counts.
- What fails:
Non-blocking
for u in "${used[@]}"(line 347) runs even whenusedis empty, which happens when both reviewers fail to post. On bash older than 4.4, an empty-array expansion underset -uis a fatal "unbound variable" error. The script guards other arrays with${arr[*]-}(line 202). This machine has bash 5.2, so it does not fail here.- SKILL.md's "Add a backend" section still does not list
backend_ready, and does not state its new contract: print the skip reason to stdout. A new backend that prints the reason to stderr loses it, and the script says only "not set up". - Two reviewers can attempt the same backend at the same time and both write
$skipdir/<backend>. The content is the same, so the worst case is one garbled reason line. - The
EXITtrap does not run on an untrapped SIGINT or SIGTERM, soskipdircan leak. It lives inTMPDIR, so the leak is small.
What I checked
- The full diff of the one commit (SKILL.md, scripts/offload-review.sh, backends/glm.sh) and the code around every change: the whole of
offload-review.shand all three backend files. - The
skipdirEXITtrap against the two subshell kinds that touch it: theattemptsubshell and the backgroundrun_reviewer. Tested in bash 5.2: neither inherits the trap, so neither deletesskipdirearly. - The new
backend_readycontract for all three backends:bobandclaudeprint nothing and keep exit-only semantics, so the stdout capture changes nothing for them. - The login-shell probe, with a simulated profile (proof in finding 2), and the Note loop, with a simulated round-2 resume (proof in finding 1).
- No builds or tests were run; live tests are not approved. The findings above are proven by code traces and local shell tests only.
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.309 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | aea32cb131ae |
blocking |
Verdict: blocking
Findings
-
scripts/offload-review/backends/glm.sh:68 — a profile that prints to stdout makes the probe report the wrong reason
- What fails:
GLM_KEY_FILEis unset in the session, and the shell profile sets it and prints any line to stdout. The probe captureshello-from-profile\nset, notset. The[ "$login" = set ]test at line 69 fails. The user then readsglm (not set up: GLM_KEY_FILE is not set (see the GLM setup guide))— the opposite of the truth. The profile has the variable; a new session would see it. The commit exists to say the right reason, and this case says the wrong one. - Proof: I ran the exact expression from line 68 with a fake
HOME, under both shells:- Profile:
echo hello-from-profile+export GLM_KEY_FILE=/tmp/key.json. SHELL=/bin/bash: capturedhello-from-profile\nset.SHELL=/bin/zsh(withZDOTDIRunset): capturedhello-from-profile\nset.- Both fail the
= setcomparison, so line 72 prints the "not set" message. On this machine today the probe works, because the profile's Homebrew lines go to stderr and2>/dev/nulldrops them. Any future stdout line in the profile breaks it.
- Profile:
- Fix: print a sentinel and match it with a glob, so extra profile output cannot break the match. For example, the child prints
printf 'CGPROBE:%s' "${GLM_KEY_FILE:+set}", and the test becomes[[ $login == *"CGPROBE:set"* ]].
- What fails:
-
scripts/offload-review.sh:347 — the
Note:line fires in round 2 for a resumed backend, and points at "Tried first" lines that do not exist- What fails: a reviewer fell back to bob in round 1. In round 2,
chain_for(line 201) puts bob first for that reviewer, so it resumes bob and posts on the first try.triedstays empty, sorun_reviewerprints no "Tried first" line (line 292 suppresses it). Theusedentry isreviewer 1: bob, which fails the*": $backend"match, so the Note fires: "The reason is in the 'Tried first' lines above." No such lines exist in this round's output. Nothing fell back in this round; the reviewer resumed its own round-1 backend by design. The user hunts for lines that were never printed. - Proof: trace — round 1: glm not ready, exit 4, bob posts for reviewer 1. Round 2:
chain_for 1returnsbob glm claude;backend_has_sessionis true; bob posts;tried=(); line 292 prints nothing. Main loop:used=("reviewer 1: bob" ...),backend=glm, line 348's[[ $u == *": glm" ]]fails, Note prints. This repeats on every round 2 after any round-1 fallback. - Fix: print the Note only when a fallback happened in this round. Let
run_reviewerwrite a marker into$skipdirwhen it posts with a backend that was not first in its own chain, and have the final loop read that marker. Or keep the Note but change its text for the resume case, and only cite "Tried first" when such a line was printed.
- What fails: a reviewer fell back to bob in round 1. In round 2,
Non-blocking
- The probe at glm.sh:68 spawns a full interactive login shell, twice per round (once per reviewer) while
GLM_KEY_FILEis unset. It runs the whole user profile, with side effects and no timeout. A profile that blocks would hang the round. A sentinel fix (finding 1) could also cache the answer. - glm.sh:77: if
python3is missing,glm_fieldyields empty and the message says "no gateway URL in the key file". The real reason is the missingpython3.backend_runrequirespython3anyway, so this is an edge case. - offload-review.sh:296: a multi-line reason is embedded in one "Tried first" entry. It reads fine; just noting it is intended.
What I checked
- Read the full diff (SKILL.md, offload-review.sh, glm.sh) and both scripts end to end, plus
backends/bob.shandbackends/claude.sh, to check the newbackend_readycontract against every backend. bob and claude print nothing on failure, so the${why:-not set up}default covers them. - Read CLAUDE.md and docs/design.md first. This PR touches only review tooling, not the pipeline, so the fail-open and data-dependence rules do not apply.
- Checked the new
skipdir+ EXIT trap against the two background reviewers: I ran a bash test with a counter file. The EXIT trap fires once, in the main shell. Background subshells and command substitutions do not fire it, so the sharedskipdiris not removed early while a reviewer still writes its reason. - Checked concurrent writes to
$skipdir/<backend>: both reviewers can attempt the same backend at the same time, butbackend_readyis deterministic, so both write the same bytes. Benign. - Checked the
set -einteractions: the||-guardedwhy=$(backend_ready ...)and the[[ ... ]] || { ... }Note loop do not trip the shell's ERR/EXIT paths. - Ran the login-shell probe under bash and zsh with fake profiles (findings 1's proof). No Go code changed in this PR; I ran no builds or tests.
… probe robust From both GLM reviewers of #682, round 1 (the same 2 findings each). - The Note fired on a normal round-2 resume of an earlier fallback backend, and pointed at "Tried first" lines that were never printed. run_reviewer now leaves a marker only when it fell back in this round, and the Note reads that marker. - The profile probe needed the shell's whole stdout to be "set", so a profile that prints a line read as "not set". It also used -ic, which skips .zprofile and .bash_profile. It now prints a CGPROBE: marker, matches it anywhere, and runs -lic. Assisted-By: Claude Signed-off-by: DAVID AMID <[email protected]>
|
Author reply to both reviewers, round 1 (head
|
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.309 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 2 of 2 | 494fae44d91a |
approve |
Verdict: approve
Findings
None. Both round-1 findings — mine and reviewer 2's, which were the same two — are fixed in 494fae44d91a, and I verified each fix with a local test.
- Round-1 finding 1 (Note fired on a clean round-2 resume): fixed.
run_reviewernow writes$skipdir/fellback-$ronly inside the sameifthat prints the "Tried first" line (scripts/offload-review.sh:292-297), so the marker exists only when a fallback happened in this round and the line the Note points at was printed. The final loop reads the marker, not the backend names (scripts/offload-review.sh:352-356).- Proof: I ran the new logic. Case A, a round-2 resume that posts on its first try (
triedempty): no marker, no Note. Case B, a real fallback (triednon-empty): the "Tried first" line and the Note are both printed. A resume of an earlier fallback backend no longer fires the Note.
- Round-1 finding 2 (profile probe reported the wrong reason): fixed.
- The probe prints a
CGPROBE:marker and the test matches*CGPROBE:set*anywhere in the captured output, so profile chatter cannot break it. It runs-lic, so.zprofileand.bash_profilecount (scripts/offload-review/backends/glm.sh:68-72). - Proof: I ran the probe with
GLM_KEY_FILEunset in the session and a.zprofilethat both exports the variable and echoes a line: it reports "set in your shell profile". With a.zprofilethat only echoes a line, it reports "not set". Both answers are right.
- The probe prints a
Non-blocking
- SKILL.md's "Add a backend" section still does not list
backend_readyor its contract: print the skip reason to stdout. From round 1, not addressed. - The probe still starts a full login shell once per attempt while
GLM_KEY_FILEis unset, with side effects and no timeout. Reviewer 2 noted this in round 1; unchanged. - My round-1 note about the empty
usedarray underset -uon old bash is resolved by side effect: the new loop iteratestodo, which is never empty.
What I checked
- Last review: round 1, aea32cb, 2026-10-23T11:40:08Z.
- New commits read: 1 (
494fae4fix(review): flag only a fallback in this round, and make the profile probe robust). - Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files).
- New items since my last review:
- Reviewer 2's round-1 review (11:41:37Z): the same two findings as mine. Both are fixed; I verified each fix myself (above), so I do not repeat them.
- Author reply (11:43:43Z): says both findings are fixed in
494fae44d91a. I checked the claim against the code and by test; it holds. - New commit
494fae4: read the full diff and the code around both changes. The diff touches only the two hunks that fix the findings.
- I checked the new commit for fresh defects: the marker file is written only after the parent's
wait, soskipdirstill exists; the two reviewers writefellback-1andfellback-2, so they do not collide; the Note fires at most once; a reviewer that fails every backend sets no marker, and the round already reports that failure with exit 1. - No builds or tests were run; live tests are not approved. The proofs above are code traces and local shell tests only.
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.309 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 2 of 2 | 494fae44d91a |
approve |
Verdict: approve
Round-1 findings
- glm.sh probe reported the wrong reason (my finding 1, same as reviewer 1's finding 2): fixed.
- The child now prints
CGPROBE:<value>and the test matches*CGPROBE:set*anywhere, so profile output cannot break it. The shell runs-lic, so login-only files count too. - I verified myself, with a fake
HOMEandGLM_KEY_FILEunset: chatty.zshrc→ match;.zprofile-only → match;.zlogin-only → match;.profile-only under bash → match; chatty.bash_profileunder bash → match; no profile → no match. All six cases give the right answer.
- The child now prints
- The
Note:fired on a round-2 resume and pointed at lines that were not printed (my finding 2, same as reviewer 1's finding 1): fixed.run_reviewernow writes$skipdir/fellback-<r>only when it printed a "Tried first" line, that is, when a backend was skipped or failed in this round. The final loop reads the marker, not the backend names.- I traced the cases: round-1 fallback → marker → Note, and the reason is in the printed line. Round-2 resume of an earlier fallback backend → first try posts,
triedempty → no marker → no Note. A failed resume that then posts with the next backend → marker → Note, and the reason is printed. I also simulated the final loop with fresh markers per case: it fires once when any reviewer intodohas a marker, and not at all without one. - The author's reply describes the same tests. My runs agree.
Findings
None. The new commit introduces no defect I can show.
Non-blocking
- glm.sh:68: the probe still misses one bash shape. With
SHELL=/bin/bash, the variable only in.bashrc, and no.bash_profile/.profilethat sources it,-licanswers "not set". On a Linux desktop whose terminals start non-login shells, a new session would see the variable, so the hint steers wrong. I verified the miss with a fakeHOME. This machine runs zsh, where-licreads.zshrc, so it cannot happen here. Fix if wanted: also probe a plain-icshell and treat either match as "in your profile". - SKILL.md:29: "When a reviewer did not use the first backend, the script prints a
Note:line" is now wider than the code. The Note fires only when a reviewer fell back in this round; a round-2 resume of another backend prints none. The success line still lists each reviewer's backend, so the case stays visible. Update the sentence when you touch the file next. - Reviewer 1's round-1 non-blocking item on SKILL.md's "Add a backend" section (no
backend_readystdout contract documented) is still open. Non-blocking; I agree it stays that way. - My round-1 note on probe cost stands: the probe runs the full login profile, twice per round, with no timeout.
What I checked
- Last review: round 1, aea32cb, 2026-10-23T11:41:37Z.
- New commits read: 1 (
494fae44fix(review): flag only a fallback in this round, and make the profile probe robust). - Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files).
- New items since my last review: the fix commit
494fae44(full diff read, both hunks traced through the current files), and the author's reply comment at 2026-10-23T11:43:43Z (both fixes described; I verified each myself rather than trusting it). Reviewer 1's round-1 review predates my last review; I read it in full anyway. It found the same 2 defects, so there is nothing to cross-check that I did not already prove. - Checked the new marker write against the subshell model I tested in round 1: it happens in the background
run_reviewershell, before the main shell'swaitreturns, and the EXIT trap removesskipdironly at final exit. No ordering problem. - Checked the new code under
set -euo pipefail: the invertedtriedtest, the: >marker write, and thefor r in "${todo[@]}"loop (todo is never empty) are all safe. The rewrite also removes reviewer 1's empty-used-array concern, since thefor u in "${used[@]}"loop is gone. - No Go code changed in this PR; I ran no builds or tests. My proofs are code traces and local shell probes only.
Summary
Note:line, so a fallback cannot go unnoticed.SKILL.mdtells the session to checkGLM_KEY_FILEbefore the run, and to report the reason for a skip.What we found
On #681, both reviewers fell back to Bob, and the script printed only
glm (not set up).GLM_KEY_FILEto~/.zshrcon 2026-10-23. A running session never sees a new line in the shell profile.What changed
backends/glm.sh:backend_readyprints its reason. The reasons:claudeis not on PATH;GLM_KEY_FILEis not set;GLM_KEY_FILEis set in the shell profile but not in this session, which started before it. The fix is a new session, or a prefix on the command;scripts/offload-review.sh:Tried first:line shows the reason, for exampleglm (not set up: GLM_KEY_FILE is set in your shell profile but not in this session ...).Note:line at the end, when any reviewer did not use the first backend.SKILL.md: check the variable in this session before the run, and tell the user the reason before you accept a round that fell back.The profile check runs
$SHELL -icand prints onlysetor nothing. It never prints the path or the key.How it was tested
backend_readysaysGLM_KEY_FILEset to the real fileGLM_KEY_FILE=/nopeSHELL=/bin/sh)bash -npasses on the script and the backend.🤖 Generated with Claude Code