# R02: Fast fallback, one terminal

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-27-23.879Z-before-R02`. After run: `/tmp/lead-24640-r1/capture/2026-10-27T14-27-23.778Z-after-R02`.

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.

Native failure remains a failed snapshot for cadence even when real ps succeeds. Both first two idle gaps follow approximately 2s and 4s.

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 | R02, background; shim START 2026-10-27T14:27:31.863Z (mono 921840986564630); END 2026-10-27T14:27:31.877Z (mono 921841000641187); 14.1ms, exit 0; acquisition 2026-10-27T14:27:31.823Z→2026-10-27T14:27:31.885Z, 61.9ms | R02, background; shim START 2026-10-27T14:27:31.768Z (mono 921840891286927); END 2026-10-27T14:27:31.783Z (mono 921840905861939); 14.6ms, exit 0; acquisition 2026-10-27T14:27:31.723Z→2026-10-27T14:27:31.792Z, 68.2ms | Same fast results and 2s/4s backoff |
| Fallback query 2 | R02, background; shim START 2026-10-27T14:27:33.928Z (mono 921843051544263); END 2026-10-27T14:27:33.945Z (mono 921843068130668); 16.6ms, exit 0; acquisition 2026-10-27T14:27:33.888Z→2026-10-27T14:27:33.950Z, 61.8ms | R02, background; shim START 2026-10-27T14:27:33.843Z (mono 921842965987235); END 2026-10-27T14:27:33.858Z (mono 921842981396863); 15.4ms, exit 0; acquisition 2026-10-27T14:27:33.795Z→2026-10-27T14:27:33.866Z, 70.6ms | Measured duration/result above |
| Fallback query 3 | R02, background; shim START 2026-10-27T14:27:37.991Z (mono 921847114289882); END 2026-10-27T14:27:38.014Z (mono 921847136866153); 22.6ms, exit 0; acquisition 2026-10-27T14:27:37.952Z→2026-10-27T14:27:38.020Z, 68.4ms | R02, background; shim START 2026-10-27T14:27:37.909Z (mono 921847032087977); END 2026-10-27T14:27:37.925Z (mono 921847047972746); 15.9ms, exit 0; acquisition 2026-10-27T14:27:37.867Z→2026-10-27T14:27:37.933Z, 65.7ms | Measured duration/result above |
| Background completion→next-query gaps | R02→R02: shim gap 2.051s, acquisition gap 2.004s<br>R02→R02: shim gap 4.046s, acquisition gap 4.001s | R02→R02: shim gap 2.060s, acquisition gap 2.004s<br>R02→R02: shim gap 4.051s, acquisition gap 4.001s | Same fast results and 2s/4s backoff |
| Terminal event 1 | 2026-10-27T14:27:31.889Z `fixture-thread-a/term-0` activity, seq=5, busy=True, label=`fixture-child` | 2026-10-27T14:27:31.796Z `fixture-thread-a/term-0` activity, seq=4, busy=True, label=`fixture-child` | Compare identity/sequence; subscriptions deduplicated |
| Terminal event 2 | 2026-10-27T14:27:38.283Z `fixture-thread-a/term-0` closed, seq=6 | 2026-10-27T14:27:38.196Z `fixture-thread-a/term-0` closed, seq=5 | 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:27:24.135Z",
    "mono_ns": "921833258643686",
    "ms": 252.770617,
    "phase": "R02",
    "mode": "valid",
    "delay": 0
  },
  {
    "kind": "server-ready",
    "utc": "2026-10-27T14:27:30.573Z",
    "mono_ns": "921839696608418",
    "ms": 6690.742342
  },
  {
    "kind": "rpc-connected",
    "utc": "2026-10-27T14:27:30.755Z",
    "mono_ns": "921839877917980",
    "ms": 6872.048738
  },
  {
    "kind": "child-ready",
    "utc": "2026-10-27T14:27:30.948Z",
    "mono_ns": "921840071648172",
    "ms": 7065.773861,
    "threadId": "fixture-thread-a",
    "terminalId": "term-0",
    "childPid": 3409169,
    "marker": "READY_R02_0"
  },
  {
    "kind": "scenario-complete",
    "utc": "2026-10-27T14:27:38.275Z",
    "mono_ns": "921847397949714",
    "ms": 14392.074671
  },
  {
    "kind": "cleanup-start",
    "utc": "2026-10-27T14:27:38.399Z",
    "mono_ns": "921847522635695",
    "ms": 14516.765271,
    "pids": [
      3408168,
      3408169,
      3409167,
      3409169
    ],
    "ptyPids": [
      3409167,
      3409169
    ]
  },
  {
    "kind": "cleanup-end",
    "utc": "2026-10-27T14:27:40.568Z",
    "mono_ns": "921849691113101",
    "ms": 16685.24966,
    "survivorsBeforeFinalKill": [],
    "remaining": []
  }
]
```
Metadata snapshots taken before and after driver cleanup:
```json
[
  {
    "kind": "state",
    "utc": "2026-10-27T14:27:38.274Z",
    "mono_ns": "921847397827415",
    "ms": 14391.954756,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-27-23.879Z-before-R02",
        "worktreePath": null,
        "status": "running",
        "pid": 3409167,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": true,
        "label": "fixture-child",
        "updatedAt": "2026-10-27T14:27:31.887Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:27:38.384Z",
    "mono_ns": "921847507607283",
    "ms": 14501.733562,
    "terminals": []
  }
]
```

## After scripted milestones and final observation states
```json
[
  {
    "kind": "control",
    "utc": "2026-10-27T14:27:24.026Z",
    "mono_ns": "921833149618304",
    "ms": 245.841378,
    "phase": "R02",
    "mode": "valid",
    "delay": 0
  },
  {
    "kind": "server-ready",
    "utc": "2026-10-27T14:27:30.477Z",
    "mono_ns": "921839600438050",
    "ms": 6696.663399
  },
  {
    "kind": "rpc-connected",
    "utc": "2026-10-27T14:27:30.648Z",
    "mono_ns": "921839771422713",
    "ms": 6867.650056
  },
  {
    "kind": "child-ready",
    "utc": "2026-10-27T14:27:30.923Z",
    "mono_ns": "921840046696024",
    "ms": 7142.918978,
    "threadId": "fixture-thread-a",
    "terminalId": "term-0",
    "childPid": 3409160,
    "marker": "READY_R02_0"
  },
  {
    "kind": "scenario-complete",
    "utc": "2026-10-27T14:27:38.188Z",
    "mono_ns": "921847311808040",
    "ms": 14408.029481
  },
  {
    "kind": "cleanup-start",
    "utc": "2026-10-27T14:27:38.315Z",
    "mono_ns": "921847438072441",
    "ms": 14534.297379,
    "pids": [
      3408144,
      3408151,
      3409154,
      3409160
    ],
    "ptyPids": [
      3409154,
      3409160
    ]
  },
  {
    "kind": "cleanup-end",
    "utc": "2026-10-27T14:27:40.426Z",
    "mono_ns": "921849548952910",
    "ms": 16645.183759,
    "survivorsBeforeFinalKill": [],
    "remaining": []
  }
]
```
Metadata snapshots taken before and after driver cleanup:
```json
[
  {
    "kind": "state",
    "utc": "2026-10-27T14:27:38.188Z",
    "mono_ns": "921847311705467",
    "ms": 14407.928341,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-27-23.778Z-after-R02",
        "worktreePath": null,
        "status": "running",
        "pid": 3409154,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": true,
        "label": "fixture-child",
        "updatedAt": "2026-10-27T14:27:31.793Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:27:38.297Z",
    "mono_ns": "921847420678972",
    "ms": 14516.902277,
    "terminals": []
  }
]
```

## Behaviour difference
Same fast results and 2s/4s backoff
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.