---
name: background-cd-relative-trap
description: "A background Bash command's relative `cd` resolves against the SESSION's persistent cwd (which an earlier command may have moved), and a trailing `echo EXIT:` makes the task notification read completed — the failed build never announces; verify the artifact (exe hash vs brain.ready stamp), not the notification."
metadata: 
  node_type: memory
  type: feedback
  originSessionId: 61b89aa0-63b6-4972-846c-df98b3b0dd31
  modified: 2026-08-02T09:59:37.541Z
---

**What happened (W2 gate, 2026-08-02):** the gate-pool bin prebuild at the W2 tip was launched as
`cd .worktrees/gate-barometer-w2 && cargo build`. The session cwd was ALREADY inside that worktree
(moved by an earlier call), so the relative `cd` failed, the build never ran — and the task
notification said "completed" because the trailing `echo` succeeded. Field acceptance then ran a
STALE 6de8722 `spt.exe` and manufactured a phantom product red that cost ~40 minutes of RCA against
correct shipped code.

**Why:** three stacked masks — (1) session cwd persists between tool calls, so a relative `cd` is
state-dependent; (2) `cmd && build; echo EXIT` reports the echo's success to the notification layer;
(3) the output file was never read (render-not-read). Each alone is survivable; stacked, a no-op
reads as a green build. Kin of [[shared-target-stale-false-green]] (same symptom: stale binary,
honest-looking green) and [[two-locks-one-env-var]] (two writers, one path, nothing guarding between).

**How to apply:**
- Background commands: absolute paths always — never a relative `cd`.
- READ the output file of every background task before trusting its exit, even "completed" ones —
  the notification reports the last statement, not the work.
- Before any field/e2e run of a freshly built binary, prove BITS IDENTITY: compare the exe's SHA-256
  against what the run itself stamps (`brain.ready` exe_hash) — this is the check that caught it,
  and it is now part of the gate recipe.
- When a field run contradicts green unit evidence, suspect the RIG's binary before the product:
  "works in-process, dead in the daemon" with no panic anywhere is the stale-binary signature.

**2nd face, doyle 2026-09-08 11:02Z — the Bash tool's cwd PERSISTS across calls.** A `cd "$G" || exit 9` inside a
rebase call left every later call running from the gate worktree: `ls .worktrees/gate-…/.spt/gate-w3-*/` read
"No such file" while the driver was writing to it (I nearly diagnosed a stalled driver from a path that could
never resolve), and one `cat >> GATE-W2-272-CHECKLIST.md` created a stray one-row checklist INSIDE the gate
tree. The Monitor's absolute path was what showed the driver healthy. Rule: `cd` only inside a subshell
`( cd … && … )` or with an absolute path AND re-`cd` to the project root at the top of any call that appends
to a record; check `pwd` when a relative path reads as absent. Records use absolute paths.
