Skip to content

Make the session-commands scenario pass under the hostile tmpdir axis - #726

Merged
omkhar merged 1 commit into
mainfrom
fixup/session-commands-tmpdir-green
Sep 9, 2026
Merged

Make the session-commands scenario pass under the hostile tmpdir axis#726
omkhar merged 1 commit into
mainfrom
fixup/session-commands-tmpdir-green

Conversation

@omkhar

@omkhar omkhar commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Problem

shared/session-commands failed only on the tmpdir hostile-env axis (passed=16 failed=1). That axis points TMPDIR at a directory whose name carries a space, a literal $HOME, and a backtick `id` command substitution (scripts/ci/run-validate-in-validator.sh:~83-91), and the scenario roots its entire workspace tree under TMPDIR (TMP_DIR=$(mktemp -d "${TMPDIR:-/tmp}/...")). Two earlier piecemeal fixes (#724 clean filter, #725 diff textconv) did not reach the remaining breaks because the full scenario only executes inside the Linux validator container (macOS takes a different launch path), so they were never reproduced.

Method — reproduced in-container

Built the validator image and ran only this scenario inside it under the real hostile TMPDIR (uid 501, HOME/GOCACHE/GOMODCACHE mirroring the harness), iterating with bash -x until it ran to completion. Under set -e, running to completion is proof there is no remaining break.

Hostile-path sites found and fixed (both test-side defects)

  1. Monitor env-file assertions (3 lines). The product writes the monitor env file with printf '%s=%q\n' (scripts/workcell write_session_monitor_env_file). The assertions grepped the raw workspace path, which mismatched once %q escaped the hostile characters. Now match the %q-quoted form with grep -qxF.
  2. docker-desktop monitor fixture state file. The fixture hand-wrote session-monitor.env with a raw-interpolated heredoc and then had the product source it — the unquoted hostile path broke sourcing. Now emitted with printf "%q", mirroring the product's own format, so it is safe to source. (The intermediate single-quoted printf '…\n' was additionally nested inside a single-quoted bash -lc body, which collapsed the newlines into literal n; double-quoted formats — the existing pattern in these blocks — avoid that.)

Why spot-quoting, not re-rooting

Sibling scenarios and this one deliberately root TMP_DIR under ${TMPDIR} and pass under the axis — exercising real code under hostile paths is the axis's purpose. Re-rooting would defeat it. Both breaks were genuine test bugs that now match the product's real contract, and %q is a no-op on benign paths, so the normal axes are unchanged.

Verification (in-container)

  • Hostile TMPDIR: scenario runs to completion, exit 0 (was the sole failure before).
  • Normal TMPDIR: scenario exit 0 — no regression.
  • bash -n clean; shellcheck (validator image) clean.
  • The axis composition in run-validate-in-validator.sh is unchanged (space + $ + backtick preserved).

Why this is comprehensive

The fix was driven by an actual in-container run to completion rather than fixing the first error and guessing, so every hostile-path break the scenario can hit on this axis is covered in one pass.

…container hostile+normal runs pass, shellcheck clean; test-only path-quoting defect)

The shared/session-commands scenario roots its whole workspace tree under
TMPDIR, so the tmpdir hostile-env axis (space, literal $HOME, backtick
`id`) exposed two test-side path-quoting defects that only surface when
the full scenario runs in the Linux validator container:

- The monitor env-file assertions compared the raw workspace path against
  output the product writes with printf '%s=%q\n' (write_session_monitor_env_file),
  so they mismatched once %q escaped the hostile characters. Match the
  %q-quoted form with grep -qxF.

- The docker-desktop monitor fixture hand-wrote its session-monitor.env
  with a raw-interpolated heredoc, then had the product source it. Emit the
  file with printf %q, mirroring the product's own format, so it is safe to
  source. The prior single-quoted printf was also nested inside a
  single-quoted bash -lc body, which collapsed the newlines.

Verified in the validator container under the real hostile TMPDIR: the
scenario now runs to completion (set -e, so completion proves no remaining
break) and still passes under a normal TMPDIR. %q is a no-op on benign
paths, so the normal axes are unchanged.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-09T03:33:41.487080Z 8e9db5b Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@omkhar

omkhar commented Sep 9, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 8e9db5b2d9

ℹ️ 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".

@omkhar
omkhar merged commit eb22b78 into main Sep 9, 2026
18 checks passed
@omkhar
omkhar deleted the fixup/session-commands-tmpdir-green branch September 9, 2026 03:49
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