Repository navigation
test(gateway): give the viewer harness its own runtime root - #156
Merged
Merged
Conversation
The harness booted the gateway without naming a runtime base, so runtimeBaseDir() fell back to the host's ~/.qwen and a harness page's rail listed this machine's own conversations: GET /rc/fs with no path defaults to $HOME, the folder browser renders that, and renderDirList then asks for that folder's conversations. Any rail assertion was therefore a statement about the host, and a full verifier run printed the user's session titles. The root is created once per process rather than once per boot because the variable is read at request time and the #152 pool boots up to four viewers inside one Node process, so a per-boot value would let one scenario's request resolve against another's directory. P127 guards it by planting a transcript inside the root and requiring the rail to list exactly that row, which fails in both directions: an empty-rail assertion alone would also pass on a host with nothing to list. Its refusal to write outside the root is a separate assertion, because an inherited QWEN_RUNTIME_DIR naming the real ~/.qwen satisfies the containment check and was found putting the plant into a live history.
InfiniteInsight
added a commit
that referenced
this pull request
Oct 29, 2026
…d-half fix(rc-gateway): policy and routing hot reload held to the boot rules, bounded, audited (#156 second half)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
A test-harness hermeticity bug, not a defect in shipped code. Nothing under
src/orpublic/changes here: the gateway itself behaved as designed, the harness just never told it where to look for conversations.scripts/lib/viewerHarness.mtsboots the real gateway against the stub daemon and gives it temp dirs for tokens, audit and ui-prefs, but never named a runtime base.sessions/chatsPath.ts#runtimeBaseDir()therefore fell back to the host's~/.qwen, and the page's own load chain walks right into it:GET /rc/fswith no path defaults to$HOME, the folder browser renders that, andrenderDirListasks for that folder's conversations.Measured on this box before the change, a harness page's rail listed 16 of the machine's real conversations, with their titles printed in the verifier output. So any rail assertion was a statement about the host rather than about the page, and a full run read the user's session titles.
The change
The harness creates a runtime root and points
QWEN_RUNTIME_DIRat it, cleaned up on process exit.One design point worth reviewing: the root is created once per process, not once per boot. The variable is read at request time rather than captured at construction, and the pool from #152 boots up to four viewers inside one Node process, so a per-boot value with a restore would let one scenario's request resolve against another scenario's directory. An inherited
QWEN_RUNTIME_DIRis respected rather than replaced.Verification
Before and after, same probe, same boot:
P28's own line now reads "(0 conversations found)" where it previously reported the host's 16.
The guard
P127 plants a transcript inside the harness root and requires the rail to list exactly that row. An empty-rail assertion alone would not be a guard, because it also passes on a host with nothing to list.
Mutation-tested by restoring the pre-fix condition through the environment (
QWEN_RUNTIME_DIR=/home/evan/.qwen, no code edit): P127 fails, and it fails at a refusal that runs before any write, with nothing left in the real home. That test also caught two defects in the first draft of the guard, both fixed: the empty-list check was reading the DOM before the chain's list had landed (so it measured an empty box rather than an empty scan and passed while the host was being read), and the root-containment check cannot carry the write-safety claim because an inherited value naming the real home satisfies it.Gates
npx tsc --noEmit: clean.npx eslinton both changed files: only the pre-existingprefer-constat 6119, unchanged by this work.npx vitest runin the package: 263 files, 3341 tests passed, 1 skipped.146 passed, 0 failed(baseline 145 plus P127). One earlier run failed P6, a frame-buffering scenario unrelated to the rail; it passed twice in isolation and clean in the re-run, which is the known load flake.scripts/, outside the rebuild-and-restart carve-out.Closes InfiniteInsight/Qwen-Code-Remote#178