Skip to content

test(gateway): give the viewer harness its own runtime root - #156

Merged
InfiniteInsight merged 1 commit into
mainfrom
gateway/178-hermetic-viewer-harness
Oct 28, 2026
Merged

InfiniteInsight merged 1 commit into
mainfrom
gateway/178-hermetic-viewer-harness

Conversation

@InfiniteInsight

Copy link
Copy Markdown
Owner

What this is

A test-harness hermeticity bug, not a defect in shipped code. Nothing under src/ or public/ changes here: the gateway itself behaved as designed, the harness just never told it where to look for conversations.

scripts/lib/viewerHarness.mts boots 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/fs with no path defaults to $HOME, the folder browser renders that, and renderDirList asks 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_DIR at 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_DIR is respected rather than replaced.

Verification

Before and after, same probe, same boot:

runtimeBaseDir(): /home/evan/.qwen        ->  /tmp/rc-viewer-home-03wQQr
/rc/sessions?cwd=/home/evan -> 16 rows    ->  0 rows

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 eslint on both changed files: only the pre-existing prefer-const at 6119, unchanged by this work.
  • npx vitest run in the package: 263 files, 3341 tests passed, 1 skipped.
  • Full verifier: 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.
  • No rebuild or live restart: the change is confined to scripts/, outside the rebuild-and-restart carve-out.

Closes InfiniteInsight/Qwen-Code-Remote#178

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
InfiniteInsight merged commit 5eec260 into main Oct 28, 2026
@InfiniteInsight
InfiniteInsight deleted the gateway/178-hermetic-viewer-harness branch October 28, 2026 01:21
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)
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