# R12: Spawn ENOENT then recovery

Before [e9236274a3](https://git.cafe/pingdotgg/t3code/commit/e9236274a3a6e0c731a7df4092db1e686f039068); after [63e44670dd](https://git.cafe/pingdotgg/t3code/commit/63e44670dd1d222cf63619d5e02415f2a9fd3bc2).

Before run: `/tmp/lead-24640-r1/capture/2026-10-27T14-25-07.576Z-before-R12`. After run: `/tmp/lead-24640-r1/capture/2026-10-27T14-25-07.579Z-after-R12`.

Environment: fs-31 Linux x86_64, Node v26.12.1; no viewport/theme/DPR/font scaling. Fresh per-run app databases. Same RPC fixture on each side. Native sidecars compiled with isolated Rust 1.99.1 where used.

Only exact ps spawn calls are redirected to a deliberately nonexistent executable, with ENOENT recorded at the native Node spawn boundary. Both retain busy state and later use a restored valid real-ps wrapper.

Wrapper timings exclude Python startup and stream drain. Acquisition timings use the real terminal.posixProcessTableSnapshot trace span. An idle gap is END→next START, never start-to-start. Before delay=min(1000×2^failureCount,60000)ms; after delay=min(max(1000×2^failureCount,4×measured fallback acquisition),60000)ms. Native-failed production ticks increment failureCount even when fallback succeeds; successful absent-supplier harness ticks reset it. Native requests and terminal processing can add overhead.

| Event | Before ([e9236274a3](https://git.cafe/pingdotgg/t3code/commit/e9236274a3a6e0c731a7df4092db1e686f039068)) | After ([63e44670dd](https://git.cafe/pingdotgg/t3code/commit/63e44670dd1d222cf63619d5e02415f2a9fd3bc2)) | Δ |
|---|---|---|---|
| Fallback query 1 | R12-seed, background; shim START 2026-10-27T14:25:15 (mono 921704402973214); END 2026-10-27T14:25:15 (mono 921704417806931); 14.8ms, exit 0; acquisition 2026-10-27T14:25:15.239Z→2026-10-27T14:25:15.303Z, 63.5ms | R12-seed, background; shim START 2026-10-27T14:25:15 (mono 921704413754519); END 2026-10-27T14:25:15 (mono 921704427383115); 13.6ms, exit 0; acquisition 2026-10-27T14:25:15.251Z→2026-10-27T14:25:15.312Z, 60.8ms | Same ENOENT retention/recovery |
| Fallback query 2 | R12-failure, background; shim START 2026-10-27T14:25:17.313Z (mono 921706436801059); END 2026-10-27T14:25:17.314Z (mono 921706437347484); 0.5ms, exit ENOENT; acquisition 2026-10-27T14:25:17.306Z→2026-10-27T14:25:17.316Z, 9.9ms | R12-failure, background; shim START 2026-10-27T14:25:17.322Z (mono 921706445822973); END 2026-10-27T14:25:17.323Z (mono 921706446393624); 0.6ms, exit ENOENT; acquisition 2026-10-27T14:25:17.316Z→2026-10-27T14:25:17.324Z, 8.9ms | Measured duration/result above |
| Fallback query 3 | R12-failure, background; shim START 2026-10-27T14:25:21.327Z (mono 921710449875408); END 2026-10-27T14:25:21.327Z (mono 921710450219614); 0.3ms, exit ENOENT; acquisition 2026-10-27T14:25:21.318Z→2026-10-27T14:25:21.328Z, 9.4ms | R12-failure, background; shim START 2026-10-27T14:25:21.334Z (mono 921710457310195); END 2026-10-27T14:25:21.334Z (mono 921710457736956); 0.4ms, exit ENOENT; acquisition 2026-10-27T14:25:21.327Z→2026-10-27T14:25:21.335Z, 8.2ms | Measured duration/result above |
| Fallback query 4 | R12-failure, background; shim START 2026-10-27T14:25:29.371Z (mono 921718493892749); END 2026-10-27T14:25:29.387Z (mono 921718510508227); 16.6ms, exit 0; acquisition 2026-10-27T14:25:29.330Z→2026-10-27T14:25:29.397Z, 67.2ms | R12-failure, background; shim START 2026-10-27T14:25:29.381Z (mono 921718504604707); END 2026-10-27T14:25:29.394Z (mono 921718517780246); 13.2ms, exit 0; acquisition 2026-10-27T14:25:29.337Z→2026-10-27T14:25:29.401Z, 64.3ms | Measured duration/result above |
| Background completion→next-query gaps | R12-seed→R12-failure: shim gap 2.019s, acquisition gap 2.003s<br>R12-failure→R12-failure: shim gap 4.013s, acquisition gap 4.002s<br>R12-failure→R12-failure: shim gap 8.044s, acquisition gap 8.002s | R12-seed→R12-failure: shim gap 2.018s, acquisition gap 2.004s<br>R12-failure→R12-failure: shim gap 4.011s, acquisition gap 4.002s<br>R12-failure→R12-failure: shim gap 8.047s, acquisition gap 8.002s | Same ENOENT retention/recovery |
| Terminal event 1 | 2026-10-27T14:25:15.306Z `fixture-thread-a/term-0` activity, seq=5, busy=True, label=`fixture-child` | 2026-10-27T14:25:15.316Z `fixture-thread-a/term-0` activity, seq=6, busy=True, label=`fixture-child` | Compare identity/sequence; subscriptions deduplicated |
| Terminal event 2 | 2026-10-27T14:25:29.651Z `fixture-thread-a/term-0` closed, seq=6 | 2026-10-27T14:25:29.672Z `fixture-thread-a/term-0` closed, seq=7 | Compare identity/sequence; subscriptions deduplicated |
| Peak all fallback queries | 1 | 1 | Independent closeIdle may overlap one background query |
| Peak background fallback queries | 1 | 1 | Independent closeIdle may overlap one background query |

## Before scripted milestones and final observation states
```json
[
  {
    "kind": "control",
    "utc": "2026-10-27T14:25:07.762Z",
    "ms": 183.757143,
    "phase": "R12",
    "mode": "spawnfail",
    "delay": 0
  },
  {
    "kind": "server-ready",
    "utc": "2026-10-27T14:25:14.224Z",
    "ms": 6644.944562
  },
  {
    "kind": "rpc-connected",
    "utc": "2026-10-27T14:25:14.325Z",
    "ms": 6746.003791
  },
  {
    "kind": "control",
    "utc": "2026-10-27T14:25:14.423Z",
    "ms": 6844.747907,
    "phase": "R12-seed",
    "mode": "valid",
    "delay": 0
  },
  {
    "kind": "child-ready",
    "utc": "2026-10-27T14:25:14.490Z",
    "ms": 6911.18658,
    "threadId": "fixture-thread-a",
    "terminalId": "term-0",
    "childPid": 3398962,
    "marker": "READY_R12_0"
  },
  {
    "kind": "control",
    "utc": "2026-10-27T14:25:15.416Z",
    "ms": 7837.395332,
    "phase": "R12-failure",
    "mode": "spawnfail",
    "delay": 0
  },
  {
    "kind": "control",
    "utc": "2026-10-27T14:25:21.598Z",
    "ms": 14018.843373,
    "phase": "R12-failure",
    "mode": "valid",
    "delay": 0
  },
  {
    "kind": "spawn-failure-recovery",
    "utc": "2026-10-27T14:25:29.643Z",
    "ms": 22063.992641
  },
  {
    "kind": "scenario-complete",
    "utc": "2026-10-27T14:25:29.643Z",
    "ms": 22064.023635
  },
  {
    "kind": "cleanup-start",
    "utc": "2026-10-27T14:25:29.769Z",
    "ms": 22189.834703,
    "pids": [
      3397959,
      3397961,
      3398960,
      3398962
    ],
    "ptyPids": [
      3398960,
      3398962
    ]
  },
  {
    "kind": "cleanup-end",
    "utc": "2026-10-27T14:25:31.870Z",
    "ms": 24291.546393,
    "survivorsBeforeFinalKill": [],
    "remaining": []
  }
]
```
Metadata snapshots taken before and after driver cleanup:
```json
[
  {
    "kind": "state",
    "utc": "2026-10-27T14:25:15.416Z",
    "ms": 7837.116198,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-25-07.576Z-before-R12",
        "worktreePath": null,
        "status": "running",
        "pid": 3398960,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": true,
        "label": "fixture-child",
        "updatedAt": "2026-10-27T14:25:15.304Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:25:21.597Z",
    "ms": 14018.567756,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-25-07.576Z-before-R12",
        "worktreePath": null,
        "status": "running",
        "pid": 3398960,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": true,
        "label": "fixture-child",
        "updatedAt": "2026-10-27T14:25:15.304Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:25:29.643Z",
    "ms": 22063.879643,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-25-07.576Z-before-R12",
        "worktreePath": null,
        "status": "running",
        "pid": 3398960,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": true,
        "label": "fixture-child",
        "updatedAt": "2026-10-27T14:25:15.304Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:25:29.751Z",
    "ms": 22172.604145,
    "terminals": []
  }
]
```

## After scripted milestones and final observation states
```json
[
  {
    "kind": "control",
    "utc": "2026-10-27T14:25:07.773Z",
    "ms": 191.695144,
    "phase": "R12",
    "mode": "spawnfail",
    "delay": 0
  },
  {
    "kind": "server-ready",
    "utc": "2026-10-27T14:25:14.114Z",
    "ms": 6532.600183
  },
  {
    "kind": "rpc-connected",
    "utc": "2026-10-27T14:25:14.250Z",
    "ms": 6668.528163
  },
  {
    "kind": "control",
    "utc": "2026-10-27T14:25:14.344Z",
    "ms": 6762.370814,
    "phase": "R12-seed",
    "mode": "valid",
    "delay": 0
  },
  {
    "kind": "child-ready",
    "utc": "2026-10-27T14:25:14.417Z",
    "ms": 6835.938481,
    "threadId": "fixture-thread-a",
    "terminalId": "term-0",
    "childPid": 3398952,
    "marker": "READY_R12_0"
  },
  {
    "kind": "control",
    "utc": "2026-10-27T14:25:15.424Z",
    "ms": 7842.103765,
    "phase": "R12-failure",
    "mode": "spawnfail",
    "delay": 0
  },
  {
    "kind": "control",
    "utc": "2026-10-27T14:25:21.606Z",
    "ms": 14024.32163,
    "phase": "R12-failure",
    "mode": "valid",
    "delay": 0
  },
  {
    "kind": "spawn-failure-recovery",
    "utc": "2026-10-27T14:25:29.664Z",
    "ms": 22082.460746
  },
  {
    "kind": "scenario-complete",
    "utc": "2026-10-27T14:25:29.664Z",
    "ms": 22082.490517
  },
  {
    "kind": "cleanup-start",
    "utc": "2026-10-27T14:25:29.789Z",
    "ms": 22207.378383,
    "pids": [
      3397960,
      3397964,
      3398950,
      3398952
    ],
    "ptyPids": [
      3398950,
      3398952
    ]
  },
  {
    "kind": "cleanup-end",
    "utc": "2026-10-27T14:25:31.887Z",
    "ms": 24305.935183,
    "survivorsBeforeFinalKill": [],
    "remaining": []
  }
]
```
Metadata snapshots taken before and after driver cleanup:
```json
[
  {
    "kind": "state",
    "utc": "2026-10-27T14:25:15.423Z",
    "ms": 7841.885054,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-25-07.579Z-after-R12",
        "worktreePath": null,
        "status": "running",
        "pid": 3398950,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": true,
        "label": "fixture-child",
        "updatedAt": "2026-10-27T14:25:15.314Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:25:21.606Z",
    "ms": 14024.121304,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-25-07.579Z-after-R12",
        "worktreePath": null,
        "status": "running",
        "pid": 3398950,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": true,
        "label": "fixture-child",
        "updatedAt": "2026-10-27T14:25:15.314Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:25:29.664Z",
    "ms": 22082.371625,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-25-07.579Z-after-R12",
        "worktreePath": null,
        "status": "running",
        "pid": 3398950,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": true,
        "label": "fixture-child",
        "updatedAt": "2026-10-27T14:25:15.314Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:25:29.773Z",
    "ms": 22191.09796,
    "terminals": []
  }
]
```

## Behaviour difference
Same ENOENT retention/recovery
Raw UTC/monotonic RPC, query, signal, metadata, warnings, and cleanup records are in the paired transcripts. PID, randomly generated script terminal suffix, database path, UTC, sequence batching, and scheduler jitter naturally vary between fresh runs. No visual comparison is applicable.