# R08: Known-busy terminal, hung fallback and retry

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-31-16.836Z-before-R08`. After run: `/tmp/lead-24640-r1/capture/2026-10-27T14-31-16.837Z-after-R08`.

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.

Both start from a busy publication. Hung fallback timeout changes from about 1s to about 15s. After waits the capped 60s before retry; failures preserve busy/label. Signals and teardown are captured.

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 | R08-seed, background; shim START 2026-10-27T14:31:24.519Z (mono 922073641675244); END 2026-10-27T14:31:24.533Z (mono 922073655765395); 14.1ms, exit 0; acquisition 2026-10-27T14:31:24.478Z→2026-10-27T14:31:24.540Z, 62.2ms | R08-seed, background; shim START 2026-10-27T14:31:24.479Z (mono 922073601359475); END 2026-10-27T14:31:24.494Z (mono 922073616739907); 15.4ms, exit 0; acquisition 2026-10-27T14:31:24.437Z→2026-10-27T14:31:24.502Z, 64.6ms | 1s timeout → 15s timeout, 60s retry |
| Fallback query 2 | R08-failure, background; shim START 2026-10-27T14:31:26.591Z (mono 922075713336250); END 2026-10-27T14:31:27.560Z (mono 922076682269901); 968.9ms, signal 15; acquisition 2026-10-27T14:31:26.543Z→2026-10-27T14:31:27.567Z, 1024.0ms | R08-failure, background; shim START 2026-10-27T14:31:26.559Z (mono 922075681775004); END 2026-10-27T14:31:41.526Z (mono 922090648388306); 14966.6ms, signal 15; acquisition 2026-10-27T14:31:26.505Z→2026-10-27T14:31:41.534Z, 15029.3ms | Measured duration/result above |
| Fallback query 3 | R08-failure, background; shim START 2026-10-27T14:31:31.622Z (mono 922080744614527); END 2026-10-27T14:31:32.589Z (mono 922081712157719); 967.5ms, signal 15; acquisition 2026-10-27T14:31:31.571Z→2026-10-27T14:31:32.601Z, 1030.5ms | R08-failure, background; shim START 2026-10-27T14:32:41.587Z (mono 922150709308764); END 2026-10-27T14:32:56.547Z (mono 922165670028812); 14960.7ms, signal 15; acquisition 2026-10-27T14:32:41.536Z→2026-10-27T14:32:56.556Z, 15020.0ms | Measured duration/result above |
| Background completion→next-query gaps | R08-seed→R08-failure: shim gap 2.058s, acquisition gap 2.003s<br>R08-failure→R08-failure: shim gap 4.062s, acquisition gap 4.003s | R08-seed→R08-failure: shim gap 2.065s, acquisition gap 2.003s<br>R08-failure→R08-failure: shim gap 60.061s, acquisition gap 60.002s | 1s timeout → 15s timeout, 60s retry |
| Terminal event 1 | 2026-10-27T14:31:24.544Z `fixture-thread-a/term-0` activity, seq=5, busy=True, label=`fixture-child` | 2026-10-27T14:31:24.506Z `fixture-thread-a/term-0` activity, seq=5, busy=True, label=`fixture-child` | Compare identity/sequence; subscriptions deduplicated |
| Terminal event 2 | 2026-10-27T14:31:32.861Z `fixture-thread-a/term-0` closed, seq=6 | 2026-10-27T14:32:56.817Z `fixture-thread-a/term-0` closed, seq=6 | 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:31:17.050Z",
    "mono_ns": "922066172631819",
    "ms": 210.669539,
    "phase": "R08",
    "mode": "hang",
    "delay": 0
  },
  {
    "kind": "server-ready",
    "utc": "2026-10-27T14:31:23.373Z",
    "mono_ns": "922072496136216",
    "ms": 6534.176381
  },
  {
    "kind": "rpc-connected",
    "utc": "2026-10-27T14:31:23.508Z",
    "mono_ns": "922072630955426",
    "ms": 6668.994829
  },
  {
    "kind": "control",
    "utc": "2026-10-27T14:31:23.600Z",
    "mono_ns": "922072722401221",
    "ms": 6760.435534,
    "phase": "R08-seed",
    "mode": "valid",
    "delay": 0
  },
  {
    "kind": "child-ready",
    "utc": "2026-10-27T14:31:23.669Z",
    "mono_ns": "922072791712944",
    "ms": 6829.747718,
    "threadId": "fixture-thread-a",
    "terminalId": "term-0",
    "childPid": 3419137,
    "marker": "READY_R08_0"
  },
  {
    "kind": "control",
    "utc": "2026-10-27T14:31:24.658Z",
    "mono_ns": "922073780331151",
    "ms": 7818.365564,
    "phase": "R08-failure",
    "mode": "hang",
    "delay": 0
  },
  {
    "kind": "scenario-complete",
    "utc": "2026-10-27T14:31:32.852Z",
    "mono_ns": "922081974984640",
    "ms": 16013.019013
  },
  {
    "kind": "cleanup-start",
    "utc": "2026-10-27T14:31:32.993Z",
    "mono_ns": "922082115953145",
    "ms": 16153.994172,
    "pids": [
      3418195,
      3418196,
      3419135,
      3419137
    ],
    "ptyPids": [
      3419135,
      3419137
    ]
  },
  {
    "kind": "cleanup-end",
    "utc": "2026-10-27T14:31:35.125Z",
    "mono_ns": "922084248051147",
    "ms": 18286.088506,
    "survivorsBeforeFinalKill": [],
    "remaining": []
  }
]
```
Metadata snapshots taken before and after driver cleanup:
```json
[
  {
    "kind": "state",
    "utc": "2026-10-27T14:31:24.657Z",
    "mono_ns": "922073779980252",
    "ms": 7818.016669,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-31-16.836Z-before-R08",
        "worktreePath": null,
        "status": "running",
        "pid": 3419135,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": true,
        "label": "fixture-child",
        "updatedAt": "2026-10-27T14:31:24.542Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:31:32.852Z",
    "mono_ns": "922081974807688",
    "ms": 16012.844937,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-31-16.836Z-before-R08",
        "worktreePath": null,
        "status": "running",
        "pid": 3419135,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": true,
        "label": "fixture-child",
        "updatedAt": "2026-10-27T14:31:24.542Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:31:32.963Z",
    "mono_ns": "922082085964840",
    "ms": 16124.000506,
    "terminals": []
  }
]
```

## After scripted milestones and final observation states
```json
[
  {
    "kind": "control",
    "utc": "2026-10-27T14:31:17.063Z",
    "mono_ns": "922066185415350",
    "ms": 223.447939,
    "phase": "R08",
    "mode": "hang",
    "delay": 0
  },
  {
    "kind": "server-ready",
    "utc": "2026-10-27T14:31:23.203Z",
    "mono_ns": "922072326167338",
    "ms": 6364.211029
  },
  {
    "kind": "rpc-connected",
    "utc": "2026-10-27T14:31:23.332Z",
    "mono_ns": "922072455142976",
    "ms": 6493.179032
  },
  {
    "kind": "control",
    "utc": "2026-10-27T14:31:23.437Z",
    "mono_ns": "922072559924858",
    "ms": 6597.955674,
    "phase": "R08-seed",
    "mode": "valid",
    "delay": 0
  },
  {
    "kind": "child-ready",
    "utc": "2026-10-27T14:31:23.538Z",
    "mono_ns": "922072660380836",
    "ms": 6698.411561,
    "threadId": "fixture-thread-a",
    "terminalId": "term-0",
    "childPid": 3419121,
    "marker": "READY_R08_0"
  },
  {
    "kind": "control",
    "utc": "2026-10-27T14:31:24.628Z",
    "mono_ns": "922073750271351",
    "ms": 7788.302608,
    "phase": "R08-failure",
    "mode": "hang",
    "delay": 0
  },
  {
    "kind": "scenario-complete",
    "utc": "2026-10-27T14:32:56.808Z",
    "mono_ns": "922165931103727",
    "ms": 99969.134824
  },
  {
    "kind": "cleanup-start",
    "utc": "2026-10-27T14:32:56.937Z",
    "mono_ns": "922166060110583",
    "ms": 100098.144576,
    "pids": [
      3418197,
      3418200,
      3419119,
      3419121
    ],
    "ptyPids": [
      3419119,
      3419121
    ]
  },
  {
    "kind": "cleanup-end",
    "utc": "2026-10-27T14:32:59.057Z",
    "mono_ns": "922168179466972",
    "ms": 102217.515031,
    "survivorsBeforeFinalKill": [],
    "remaining": []
  }
]
```
Metadata snapshots taken before and after driver cleanup:
```json
[
  {
    "kind": "state",
    "utc": "2026-10-27T14:31:24.627Z",
    "mono_ns": "922073749938747",
    "ms": 7787.98957,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-31-16.837Z-after-R08",
        "worktreePath": null,
        "status": "running",
        "pid": 3419119,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": true,
        "label": "fixture-child",
        "updatedAt": "2026-10-27T14:31:24.504Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:32:56.808Z",
    "mono_ns": "922165930929881",
    "ms": 99968.963612,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-31-16.837Z-after-R08",
        "worktreePath": null,
        "status": "running",
        "pid": 3419119,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": true,
        "label": "fixture-child",
        "updatedAt": "2026-10-27T14:31:24.504Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:32:56.919Z",
    "mono_ns": "922166041306008",
    "ms": 100079.339388,
    "terminals": []
  }
]
```

## Behaviour difference
1s timeout → 15s timeout, 60s retry
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.