stdioBridge unit tests inherit the host env — 3 false reds on any machine that exports IDSS_PAYLOAD_DIR (i.e. every drive host) #755

Closed
opened 2026-08-24 19:41:09 +00:00 by matou-build-agent · 2 comments

Found while proving #750 offline on matou-dev-server-01 (session-runner host).

app/tests/unit/stdioBridge.test.ts spawns a REAL process and asserts what the
helper env carries. Three of its cases read the ambient environment instead of
only the launch options, so they fail on any machine that exports
IDSS_PAYLOAD_DIR — which every drive host does, because that is exactly how
scripts/smoke-private-path.sh and the rehearsal machinery resolve the payload
(#295).

Reproduce (at e6cfb52, before #750's commit — this is not a regression from it):

cd app
IDSS_PAYLOAD_DIR=/anything pnpm vitest run tests/unit/stdioBridge.test.ts   # 3 failed | 5 passed
env -u IDSS_PAYLOAD_DIR pnpm vitest run tests/unit/stdioBridge.test.ts      # 8 passed

The three:

  • injects the carried payload dir + state dir into the helper env
  • lets a shell IDSS_PAYLOAD_DIR win over the carried payloadDir
  • leaves the payload dir unset when the launch carries none

Why it matters: a unit test whose verdict depends on the operator's shell is a
false red on precisely the machines that also run the live drives — the hosts
where a real red most needs to be trusted. The third case is the sharpest: it
asserts an ABSENCE that the host env can never satisfy.

Suggested fix: make the test own the child's environment rather than inheriting
it — pass an explicit env to the spawn (or stub process.env for the case),
so the "a shell IDSS_PAYLOAD_DIR wins" case sets that variable deliberately
instead of borrowing whatever the host happens to export. Worth a scan for
sibling tests that spawn with an inherited env.

Filed as a follow-up under ADR 0174 rule 1 (work only the session's ticket, file
follow-ups) — #750 left this untouched.

Found while proving #750 offline on `matou-dev-server-01` (session-runner host). `app/tests/unit/stdioBridge.test.ts` spawns a REAL process and asserts what the helper env carries. Three of its cases read the ambient environment instead of only the launch options, so they fail on any machine that exports `IDSS_PAYLOAD_DIR` — which every drive host does, because that is exactly how `scripts/smoke-private-path.sh` and the rehearsal machinery resolve the payload (#295). Reproduce (at `e6cfb52`, before #750's commit — this is not a regression from it): ``` cd app IDSS_PAYLOAD_DIR=/anything pnpm vitest run tests/unit/stdioBridge.test.ts # 3 failed | 5 passed env -u IDSS_PAYLOAD_DIR pnpm vitest run tests/unit/stdioBridge.test.ts # 8 passed ``` The three: - injects the carried payload dir + state dir into the helper env - lets a shell IDSS_PAYLOAD_DIR win over the carried payloadDir - leaves the payload dir unset when the launch carries none Why it matters: a unit test whose verdict depends on the operator's shell is a false red on precisely the machines that also run the live drives — the hosts where a real red most needs to be trusted. The third case is the sharpest: it asserts an ABSENCE that the host env can never satisfy. Suggested fix: make the test own the child's environment rather than inheriting it — pass an explicit env to the spawn (or stub `process.env` for the case), so the "a shell IDSS_PAYLOAD_DIR wins" case sets that variable deliberately instead of borrowing whatever the host happens to export. Worth a scan for sibling tests that spawn with an inherited env. Filed as a follow-up under ADR 0174 rule 1 (work only the session's ticket, file follow-ups) — #750 left this untouched.
Author
Member

swarm-claim host=elitebook-distributed-server-03 run=9830
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=9830 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #755 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 755,
  "status": "success",
  "commits": [
    "8bb8d80"
  ],
  "changed_files": [
    "app/tests/unit/stdioBridge.test.ts"
  ],
  "tests": [
    {
      "command": "CI=true IDSS_PAYLOAD_DIR=/anything IDSS_STATE_DIR=/hoststate pnpm vitest run tests/unit/stdioBridge.test.ts",
      "exit_code": 0
    },
    {
      "command": "CI=true env -u IDSS_PAYLOAD_DIR -u IDSS_STATE_DIR pnpm vitest run tests/unit/stdioBridge.test.ts",
      "exit_code": 0
    }
  ],
  "criteria": {
    "The three env cases pass on a machine that exports IDSS_PAYLOAD_DIR": "Ran with IDSS_PAYLOAD_DIR=/anything IDSS_STATE_DIR=/hoststate -> 8 passed (was 3 failed | 5 passed at e6cfb52)",
    "The tests still pass on a clean env": "Ran with env -u IDSS_PAYLOAD_DIR -u IDSS_STATE_DIR -> 8 passed",
    "The 'unset when launch carries none' case asserts an absence the host cannot contradict": "beforeEach clears IDSS_PAYLOAD_DIR/IDSS_STATE_DIR so the test owns the var; commit 8bb8d80",
    "The 'shell wins' case sets the var deliberately, not borrowed from host": "Case now assigns process.env.IDSS_PAYLOAD_DIR on a cleared base; afterEach restores host value; commit 8bb8d80",
    "Scan siblings for inherited-env spawns": "Only stdioBridge.test.ts spawns with inherited env; payloadDir.test.ts is static-source analysis; noted in commit"
  },
  "summary": "stdioBridge env-precedence tests now own IDSS_PAYLOAD_DIR/IDSS_STATE_DIR via a beforeEach/afterEach so a host export no longer reds them on drive hosts.",
  "blockers": []
}
**close-report** for #755 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 755, "status": "success", "commits": [ "8bb8d80" ], "changed_files": [ "app/tests/unit/stdioBridge.test.ts" ], "tests": [ { "command": "CI=true IDSS_PAYLOAD_DIR=/anything IDSS_STATE_DIR=/hoststate pnpm vitest run tests/unit/stdioBridge.test.ts", "exit_code": 0 }, { "command": "CI=true env -u IDSS_PAYLOAD_DIR -u IDSS_STATE_DIR pnpm vitest run tests/unit/stdioBridge.test.ts", "exit_code": 0 } ], "criteria": { "The three env cases pass on a machine that exports IDSS_PAYLOAD_DIR": "Ran with IDSS_PAYLOAD_DIR=/anything IDSS_STATE_DIR=/hoststate -> 8 passed (was 3 failed | 5 passed at e6cfb52)", "The tests still pass on a clean env": "Ran with env -u IDSS_PAYLOAD_DIR -u IDSS_STATE_DIR -> 8 passed", "The 'unset when launch carries none' case asserts an absence the host cannot contradict": "beforeEach clears IDSS_PAYLOAD_DIR/IDSS_STATE_DIR so the test owns the var; commit 8bb8d80", "The 'shell wins' case sets the var deliberately, not borrowed from host": "Case now assigns process.env.IDSS_PAYLOAD_DIR on a cleared base; afterEach restores host value; commit 8bb8d80", "Scan siblings for inherited-env spawns": "Only stdioBridge.test.ts spawns with inherited env; payloadDir.test.ts is static-source analysis; noted in commit" }, "summary": "stdioBridge env-precedence tests now own IDSS_PAYLOAD_DIR/IDSS_STATE_DIR via a beforeEach/afterEach so a host export no longer reds them on drive hosts.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#755
No description provided.