Repository navigation
devcontainer.test/test-claude-tmux-statusline.sh: make the fake tmux/claude sandbox authoritative over the caller's real tmux identity - #53
Conversation
…claude sandbox authoritative over the caller's real tmux identity (#52) The test builds a fake claude/tmux sandbox and drives base-image/files/claude-profile and claude-statusline-command.sh against it, but its launcher-invoking assertions (the interactive tmux-session-creation check and the non-interactive `mcp list` check) never touched TMUX, TMUX_PANE, WORKBENCHES_CLAUDE_TMUX, WORKBENCHES_CLAUDE_TMUX_CHILD, WORKBENCHES_TMUX_SESSION, or WORKBENCHES_TMUX_PANE — every one of them a variable claude-profile or claude-statusline-command.sh reads straight from the environment. Run this test from inside any real tmux session (a live claude-profile-launched Claude Code pane included) and the caller's own values for those variables leak straight through. That is more than a mismatched assertion: with TMUX inherited but only the fake tmux binary on PATH, the launcher's claude_run_is_interactive() sees TMUX set and treats the launch as non-interactive, while export_tmux_identity() also sees TMUX set and unconditionally shells out to tmux to resolve #S/#{pane_id}. The fake tmux only logs its argv and prints nothing, so both come back empty, and export_tmux_identity()'s last statement — `[[ -n "$pane" ]] && export WORKBENCHES_TMUX_PANE=...` — evaluates false. Under the launcher's own `set -euo pipefail` that kills the launcher before it ever execs the fake claude binary; `script -e` propagates the failure, and the test's own `set -e` aborts the whole file right there, silently, before any `grep ... || fail` line runs. Reproduced by running the test as-is from inside this lane's own live tmux-backed session: exit 1, zero output, not even a FAIL message; `bash -x` shows it dying at the `script -qefc "$tty_command" /dev/null` line. Clear TMUX, TMUX_PANE, WORKBENCHES_CLAUDE_TMUX, WORKBENCHES_CLAUDE_TMUX_CHILD, WORKBENCHES_TMUX_SESSION, and WORKBENCHES_TMUX_PANE near the top of the test, before the sandbox is built — mirrors the guard devcontainer.test/test-claude-profile-lane-start.sh already carries for the same hazard (added alongside that file in #44, never retrofitted here), extended to also cover WORKBENCHES_CLAUDE_TMUX. The test's existing per-call `env -u TMUX -u TMUX_PANE -u WORKBENCHES_TMUX_SESSION -u WORKBENCHES_TMUX_PANE` around the non-tmux statusline panel assertion is untouched (now redundant, still harmless, keeps that one assertion self-documenting). Verified: `bash devcontainer.test/test-claude-tmux-statusline.sh` now passes both from inside this session's live tmux (`claude tmux statusline tests passed`, exit 0) and with `env -u TMUX -u TMUX_PANE -u WORKBENCHES_CLAUDE_TMUX_CHILD -u WORKBENCHES_TMUX_SESSION -u WORKBENCHES_TMUX_PANE` (same result), including three repeats and the explicit-path invocation form devcontainer.test/test.sh uses. Also re-ran devcontainer.test/test-claude-profile-lane-start.sh, devcontainer.test/test-claude-profile-preserves-model.sh, and devcontainer.test/test-claude-statusline-snapshots.sh both ways — all still pass; none of them are exercised by .github/workflows (speckit-git-bash.yml and speckit-git-powershell.yml only run the speckit/git-bootstrap suites), so CI's own invocation is unaffected. Lane: openreposhape-2 (openRepoShape-2) Closes #52. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
@codex review |
There was a problem hiding this comment.
Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 3 days and 3 hours by commenting @sourcery-ai review. Upgrade to get a review now.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideMakes the tmux/statusline integration test deterministic when invoked from a real tmux session by clearing inherited tmux identity and Claude launcher state, preventing false non-interactive detection, failed fake-tmux lookups, and premature launcher termination. File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
🔵 Needs a closer look
CLAUDE_LANE can still leak into the launcher and alter or abort test execution.
Pull request overview
This PR isolates the Claude tmux statusline test from inherited tmux environment state.
Changes:
- Clears launcher/statusline tmux variables before sandbox setup.
- Preserves existing assertions and per-call isolation.
File summaries
| File | Summary |
|---|---|
devcontainer.test/test-claude-tmux-statusline.sh |
Adds environment isolation for reliable execution inside or outside tmux. |
Review details
Suppressed comments (1)
devcontainer.test/test-claude-tmux-statusline.sh:30
- This guard still allows the caller's
CLAUDE_LANEto leak into the launcher.claude-profilereads that variable before the interactive check and then requires/invokeslane-start, so a caller that exports a lane can make this test exit before its assertions (or change the fake launch behavior). ClearCLAUDE_LANEas well, or explicitly override it incommon_env, so the baseline scenarios are independent of the invoking shell.
unset TMUX TMUX_PANE WORKBENCHES_CLAUDE_TMUX WORKBENCHES_CLAUDE_TMUX_CHILD \
WORKBENCHES_TMUX_SESSION WORKBENCHES_TMUX_PANE 2>/dev/null || true
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…t's launcher off to a real lane-start Copilot's review on #53 (commit 4647cab, 2026-09-11T13:19:55Z) caught a real gap in the first commit: the new unset block cleared every tmux-related variable claude-profile reads, but not CLAUDE_LANE — a separate input the launcher reads at its own top level (`lane="${CLAUDE_LANE:-}"`, base-image/files/claude-profile:260) before any tmux/interactive check runs at all. If a caller's shell has CLAUDE_LANE set (exactly the shape of the lane sessions this test is likeliest to run from — this lane's own session included), the launcher's `run` action checks `command -v lane-start` before `claude_run_is_interactive`/`start_profile_tmux` ever execute, and: - if `lane-start` is NOT on PATH: refuses immediately with exit 2 and a stderr message the test's own `script -qefc ... /dev/null >/dev/null` wrapper swallows — same silent-abort shape as the original tmux bug, just a different trigger and a different exit code. - if `lane-start` IS on PATH — which it genuinely is in this lane's own session (confirmed: `command -v lane-start` resolves to `/home/brett/.local/bin/lane-start`) — the launcher hands the *entire* launch to it (`exec lane-start "$lane" -- ...`, base-image/files/claude-profile:379-384) instead of the fake claude. A test run could invoke real lane tooling. Reproduced both safely, without ever letting a real lane-start run: checked out the pre-this-commit test content (4647cab) and ran it with CLAUDE_LANE=openRepoShape-2 exported and PATH constrained to exclude the real lane-start (`env -i PATH=/usr/bin:/bin:/usr/local/bin CLAUDE_LANE=openRepoShape-2 bash <old-test> <launcher> <statusline>`) — exit 2, zero output, confirming the silent-abort-before-any-assertion shape. Did not attempt the lane-start-reachable case for real, since that is precisely the unsafe behavior being fixed; the code path (base-image/files/claude-profile:379-384) is unconditional and not in dispute. Add CLAUDE_LANE to the same unset block, and use the opportunity to record, in the block's comment, why the launcher's other lane/launch-shaping variables don't need the same treatment: CLAUDE_BIN, CLAUDE_PROFILES_HOME, CLAUDE_PROFILES_MANIFEST, and WORKBENCHES_SHARED_MCP_FAMILIES are already owned via common_env's explicit assignments on every launcher invocation (an `env VAR=value command` assignment always overrides an inherited value of the same name, it cannot leak); CLAUDE_CONFIG_DIR is only ever written by the launcher for its children, never read as one of its own inputs, so there is nothing to clear there either. (XDG_CONFIG_HOME and WORKBENCHES_MCP_SYNC_BIN were also checked: both are only consulted on a fallback path already short-circuited by an owned variable — CLAUDE_PROFILES_MANIFEST and WORKBENCHES_SHARED_MCP_FAMILIES=disabled respectively — so neither can affect this test's scenarios either.) Verified: test-claude-tmux-statusline.sh now passes with CLAUDE_LANE=openRepoShape-2 exported, both from inside this lane's own live tmux session and with the tmux variables also unset (three combinations checked, all green, all exit 0). Re-ran test-claude-profile-lane-start.sh, test-claude-profile-preserves-model.sh, and test-claude-statusline-snapshots.sh both inside this tmux session and with the tmux variables unset — all still pass, no regressions. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
@copilot-pull-request-reviewer thanks — this was a real gap, not a false positive.
Reproduced the first case safely (constrained Fixed in 35a804a: added |
There was a problem hiding this comment.
🔵 Needs a closer look
Add an automated regression invocation with representative tmux and lane variables set.
Review details
Suppressed comments (1)
devcontainer.test/test-claude-tmux-statusline.sh:42
- This guard is not exercised by the standard
devcontainer.test/test.shrun: that entry point invokes this script in a clean container, and the script immediately unsets the variables before any assertion. A future removal or omission from this list would therefore still pass that test run; please add a wrapper/subprocess regression that invokes the test with representative tmux/lane variables set and fails on the pre-fix behavior, in addition to the manual live-tmux run.
unset TMUX TMUX_PANE WORKBENCHES_CLAUDE_TMUX WORKBENCHES_CLAUDE_TMUX_CHILD \
WORKBENCHES_TMUX_SESSION WORKBENCHES_TMUX_PANE CLAUDE_LANE 2>/dev/null || true
- Files reviewed: 1/1 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
LANDING — lane openreposhape-2 (openRepoShape-2), session 8706b0f5, 2026-09-11T13:31:26Z, PR #53 into opensoft/workBenches main (test-claude-tmux-statusline.sh isolates the launcher from the caller's tmux identity; closes workBenches#52) |
…n D2 Ratified design D2 of openxFactory's prefer-triad-project-shape (a2dc658d, lines 76-80) says: "Answering no ends the run before it writes anything; that is the person choosing to stop, not the advisory refusing, and the realization owner picks the exit status for it with the rule that nothing reads that status as a verdict about the repository." #139 shipped "no" as an unrecognised answer that continues. The lane coordinator, acting as realization owner, ruled the correction. What changes: - New TRIAD_STOP_ANSWERS = ("n", "no"), matched after strip().lower(), at both questions. Such an answer takes Ctrl-C's path, stop_at_the_triad_question(): nothing has been written, the stop is said, and the run ends by SIGINT, the platform's own status for an interrupted process. - Enter, y, yes, any other answer, and end of file still continue. s shows the steps and asks once more. - Both questions now read "n or Ctrl-C stops before anything is written". The D002 fallback takes brettheap/new-workstation#53's corrected Script Status sentence ("is realized in the script under #138."). It now renders byte-identical to project-agent-bootstrap.md at #53's head 35623857: 14821 bytes, md5 692f68037aa27d17eeb6f460b194597d. D001 and the entrypoint bullet are unchanged and still match. Pseudo-terminal tests: - stop on n, no, NO, " No ", s then n, and steps then No: SIGINT, the stop is said, nothing is written; - continue on Enter, y, yes, an unrecognised word, SHOW then a word, and end of file. Suite: 979 PASS before (e2cfc09), 1042 PASS / 0 FAIL after. update-upstream.py check: 23 copies match. Refs #138 Lane: codeXfactory-5 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rkstation#53 - tasks.md gains D004, ticked by #140. It quotes design D2 verbatim and records the realization and its tests. - D002 now notes that it tracks the corrected Script Status sentence of brettheap/new-workstation#53, and that #140 merges after #53. - spec.md decision 2 and User Story 3 are amended to the stop-on-no behaviour. The superseded "typing no continues" bullet is kept as the record of what #139 shipped. Refs #138 Lane: codeXfactory-5 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n or no stops per design D2 (D004) (#140) Follows brettheap/new-workstation#52 and #53, and completes task 5.4, "the bootstrap", of openxFactory's ratified change prefer-triad-project-shape (Speckit feature 021-triad-shape-advisory). D001-D003: setup-openspeckit's embedded fallbacks of openspec-speckit-workflow.md, project-agent-bootstrap.md and the global entrypoint's shape bullet now render byte-identical to the live protocol (26017 bytes, md5 5b36047e02421ab4e295285122a103fc; 14821 bytes, md5 692f68037aa27d17eeb6f460b194597d). D004: per the ratified design D2, "Answering no ends the run before it writes anything", so n or no at either Triad question now takes the same stop as Ctrl-C: nothing is written and the run ends by SIGINT. Enter, y, yes, end-of-file and any unrecognised answer still continue. The bootstrap suite rose from 966 to 1042 PASS with 0 FAIL. Merged on Brett Heap's word "merge 53 and 140" (2026-10-06). Lane: codeXfactory-5 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Lane: openreposhape-2 (openRepoShape-2)
Closes #52.
Problem
devcontainer.test/test-claude-tmux-statusline.shbuilds a fakeclaude/tmuxsandbox and drivesbase-image/files/claude-profileandclaude-statusline-command.shagainst it, but its launcher-invokingassertions (the interactive tmux-session-creation check and the
non-interactive
mcp listcheck) never touchedTMUX,TMUX_PANE,WORKBENCHES_CLAUDE_TMUX,WORKBENCHES_CLAUDE_TMUX_CHILD,WORKBENCHES_TMUX_SESSION, orWORKBENCHES_TMUX_PANE— every one of them avariable
claude-profileorclaude-statusline-command.shreads straightfrom the environment. Run the test from inside any real tmux session (a
live
claude-profile-launched Claude Code pane included) and the caller'sown values for those variables leak straight through.
That's more than a mismatched assertion: with
TMUXinherited but only thefake
tmuxbinary onPATH, the launcher'sclaude_run_is_interactive()sees
TMUXset and treats the launch as non-interactive, whileexport_tmux_identity()also seesTMUXset and unconditionally shellsout to
tmuxto resolve#S/#{pane_id}. The faketmuxonly logs itsargv and prints nothing, so both come back empty, and
export_tmux_identity()'s last statement —[[ -n "$pane" ]] && export WORKBENCHES_TMUX_PANE=...— evaluates false.Under the launcher's own
set -euo pipefailthat kills the launcher beforeit ever execs the fake
claudebinary;script -epropagates the failure,and the test's own
set -eaborts the whole file right there, silently,before any
grep ... || failline runs.Reproduced from inside this lane's own live tmux-backed session:
bash devcontainer.test/test-claude-tmux-statusline.sh→ exit1, zero output, not even a
FAIL: ...message.bash -xshows it dyingat the
script -qefc "$tty_command" /dev/nullline — the launcher itselfaborts before the test ever reaches an assertion.
env -u TMUX -u TMUX_PANE -u WORKBENCHES_CLAUDE_TMUX_CHILD -u WORKBENCHES_TMUX_SESSION -u WORKBENCHES_TMUX_PANE bash devcontainer.test/test-claude-tmux-statusline.sh→ passes:claude tmux statusline tests passed, exit 0.This is a different bug from the one #48 fixed: #48 stopped the test's
statusline invocations from leaking
$HOME-scoped snapshot artifacts intothe caller's real home directory. This is about the launcher invocations
earlier in the same file leaking the caller's tmux identity inward. PR #44
(which added the sibling
test-claude-profile-lane-start.sh) alreadyengineered exactly this guard for that new file, with a comment calling out
the same hazard, but never retrofitted the older
test-claude-tmux-statusline.sh— noted in passing, left unfixed. See #52for the full trace.
Fix
Clear
TMUX,TMUX_PANE,WORKBENCHES_CLAUDE_TMUX,WORKBENCHES_CLAUDE_TMUX_CHILD,WORKBENCHES_TMUX_SESSION, andWORKBENCHES_TMUX_PANEnear the top of the test, before the sandbox isbuilt — mirroring the guard
test-claude-profile-lane-start.shalreadycarries, extended to also cover
WORKBENCHES_CLAUDE_TMUX(the opt-outswitch
claude_run_is_interactivealso reads). The test's existingper-call
env -u TMUX -u TMUX_PANE -u WORKBENCHES_TMUX_SESSION -u WORKBENCHES_TMUX_PANEaround the non-tmux statusline panel assertion isuntouched (now redundant, still harmless, keeps that one assertion
self-documenting). Purely additive: 19 lines added, 0 removed, 0 changed.
Test plan
bash devcontainer.test/test-claude-tmux-statusline.shfrom insidethis lane's own live tmux-backed Claude Code session — passes
(
claude tmux statusline tests passed, exit 0); repeated 3x, noflakiness.
env -u TMUX -u TMUX_PANE -u WORKBENCHES_CLAUDE_TMUX_CHILD -u WORKBENCHES_TMUX_SESSION -u WORKBENCHES_TMUX_PANE bash devcontainer.test/test-claude-tmux-statusline.sh— passes, sameresult.
devcontainer.test/test.shuses inside the built image) — passes.devcontainer.test/test-claude-profile-lane-start.sh— passes bothinside this live tmux session and with the variables unset.
devcontainer.test/test-claude-profile-preserves-model.sh— passesboth ways (unaffected either way: it only exercises the launcher's
statusaction, which never reaches the tmux-sensitive code paths).devcontainer.test/test-claude-statusline-snapshots.sh— passes bothways.
.github/workflows/speckit-git-bash.ymlandspeckit-git-powershell.ymldon't invoke anytest-claude-*.shsuite(they only run the speckit/git-bootstrap tests), so CI's own
invocation of these tests is unaffected by this change.
🤖 Generated with Claude Code
Summary by Sourcery
Isolate the Claude tmux statusline test from the caller's tmux and lane environment so it consistently exercises only the fake sandbox.
Bug Fixes:
Tests: