---
name: two-background-jobs-one-output-path
description: Two background runs redirected to the SAME output file make every later grep unattributable — I read a FAILED summary that belonged to the other run and nearly diagnosed a second mechanism that did not exist.
metadata: 
  node_type: memory
  type: feedback
  originSessionId: 94b5d55b-90d1-4473-8623-929bda19d570
  modified: 2026-08-21T11:23:04.650Z
---

Chasing one red in #172 I launched a control run writing `> $S/172-spt.txt`,
then — before it finished — launched a second, corrected run writing to **the
same path**. Both completed. The second job's `grep` then read a file the first
job had written.

The result was incoherent and I nearly theorised my way into it: the run
reported `EXIT=0` on the same lines as a `test result: FAILED`, which is
impossible for one cargo invocation. The honest reading was not "a subtle
second mechanism" — it was "these two lines came from two different runs".

**Why it is dangerous rather than merely confusing:** each line looks
well-formed, they arrive adjacent in one tool result, and nothing marks the
seam. An exit code from run B beside a failure summary from run A is exactly the
shape of a real, interesting anomaly — so the instinct is to explain it, and any
explanation you invent is a fiction with evidence-shaped support.

**How to apply:**
1. One output path per invocation. Put the task id (or a `-clean`, `-v2`
   suffix) in the filename — never reuse a path while an earlier job could still
   be writing it.
2. When two readings CONTRADICT arithmetically (exit 0 beside a FAILED
   summary; counts that cannot both be true), suspect the *plumbing* before the
   product. Re-run once, alone, to a fresh path, and read that.
3. Redirect-and-echo-`$?` in the same command captures the right exit only if
   nothing else raced the file. State which run a number came from.

Kin: [[exit-code-after-a-pipe-is-the-tails]] (the exit belonged to the wrong
process), [[empty-tasklist-is-not-a-dead-background-task]] (a still-running job
you cannot see), [[dont-take-a-diagnosis-as-measured]].
