# R13: empty/exited server, then reopen — extended reset capture

Evidence for [#24640](https://git.cafe/pingdotgg/t3code/pull/24640). Exactly R13 was recaptured in this round.

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

Environment: fs-31; Linux x86_64, kernel 6.1.102; Node v26.12.1; Python 3. Real apps/server CLI (`src/bin.ts`) from each installed, pinned checkout, driven through its shipped WebSocket RPC. Separate fresh home/database per run; T3CODE_DEV_SEED=0; same synthetic project/two threads/one idle terminal seed. No live user database was read or copied. Private `sudo unshare -m --propagation private` mount namespaces bind the shim over `/usr/bin/ps` (also reached through `/bin/ps`); the host ps is unchanged. Fallback forced with T3CODE_RESOURCE_MONITOR_PATH pointing to the same deliberately failing native helper. Ports 23130/23131; port 3773 untouched. No browser, viewport, theme, DPR or font scaling applies.

## Same scripted interaction, with timestamps above the query pair

Both sides run `driver.mjs <side> R13 0 1 3 valid`. Begin empty; wait 2.5s; open one idle terminal; await the initial fallback query completion; send `exit`; await its exited event and metadata; observe an additional 5s with no in-flight query; restart the same terminal ID; await three complete fallback queries and metadata; close and stop only recorded owned PIDs. The restart creates a new shell PID. The 5s exited interval exceeds the initial failure’s 2s backoff and lets the inactive polling branch run before reopening.

| Scripted step | Before UTC | After UTC |
|---|---|---|
| Empty server; zero fallback queries | 2026-10-27T15:16:46.620Z → 2026-10-27T15:16:49.121Z (2.501s) | 2026-10-27T15:16:48.972Z → 2026-10-27T15:16:51.474Z (2.502s) |
| Exited-only; zero new queries, zero in flight at start | 2026-10-27T15:16:50.325Z → 2026-10-27T15:16:55.327Z (5.002s) | 2026-10-27T15:16:52.648Z → 2026-10-27T15:16:57.652Z (5.004s) |
| Restart same terminal ID | 2026-10-27T15:16:55.429Z → 2026-10-27T15:16:55.445Z (0.016s) | 2026-10-27T15:16:57.754Z → 2026-10-27T15:16:57.768Z (0.014s) |
| Three post-reopen queries complete | 2026-10-27T15:17:02.406Z | 2026-10-27T15:17:04.718Z |

## Expected gaps from both pinned sources

Before: [delay calculation, line 653](https://git.cafe/pingdotgg/t3code/blob/e9236274a3a6e0c731a7df4092db1e686f039068/apps/server/src/terminal/Manager.ts#L653) is `min(1000 * 2**failureCount, 60000)`. The [inactive branch, line 2660](https://git.cafe/pingdotgg/t3code/blob/e9236274a3a6e0c731a7df4092db1e686f039068/apps/server/src/terminal/Manager.ts#L2660) resets the failure count to zero. The first reopened native-failed tick increments it to 1, so query 1→2 should idle **2s**; the next tick increments it to 2, so query 2→3 should idle **4s**. [Native failure plus successful fallback, line 1546](https://git.cafe/pingdotgg/t3code/blob/e9236274a3a6e0c731a7df4092db1e686f039068/apps/server/src/terminal/Manager.ts#L1546) still returns `snapshotSucceeded: false`.

After: [delay calculation, line 663](https://git.cafe/pingdotgg/t3code/blob/63e44670dd1d222cf63619d5e02415f2a9fd3bc2/apps/server/src/terminal/Manager.ts#L663) is `min(max(1000 * 2**failureCount, 4 * queryElapsedMs), 60000)`. The [inactive branch, line 2687](https://git.cafe/pingdotgg/t3code/blob/63e44670dd1d222cf63619d5e02415f2a9fd3bc2/apps/server/src/terminal/Manager.ts#L2687) also resets the count to zero, and [native failure plus successful fallback, line 1576](https://git.cafe/pingdotgg/t3code/blob/63e44670dd1d222cf63619d5e02415f2a9fd3bc2/apps/server/src/terminal/Manager.ts#L1576) still advances it. The first two post-reopen acquisitions take about 62–64ms, so their duration floors are about 250–256ms, below 2s/4s. Expected gaps are therefore also **2s, then 4s**.

A retained pre-exit failure count would instead give 4s, then 8s after the first reopened query. Observing the second and third reopened queries distinguishes that outcome from a reset. All reported gaps are completion→next-start, never start-to-start. Shim gaps include wrapper exit/drain plus the next Python startup; acquisition gaps use full application trace spans and are closest to the scheduled sleep.

## Paired query events

| Event | Before | After |
|---|---|---|
| Initial query before exit | R13, background; shim START 2026-10-27T15:16:49.930Z (mono 924799049667446); END 2026-10-27T15:16:49.946Z (mono 924799065069379); 15.4ms, exit 0; acquisition 2026-10-27T15:16:49.889Z→2026-10-27T15:16:49.953Z, 64.0ms | R13, background; shim START 2026-10-27T15:16:52.248Z (mono 924801367052681); END 2026-10-27T15:16:52.261Z (mono 924801380365525); 13.3ms, exit 0; acquisition 2026-10-27T15:16:52.205Z→2026-10-27T15:16:52.270Z, 64.5ms |
| Post-reopen query 1 | R13-post-reopen, background; shim START 2026-10-27T15:16:55.998Z (mono 924805117621670); END 2026-10-27T15:16:56.012Z (mono 924805131336768); 13.7ms, exit 0; acquisition 2026-10-27T15:16:55.958Z→2026-10-27T15:16:56.019Z, 61.4ms | R13-post-reopen, background; shim START 2026-10-27T15:16:58.316Z (mono 924807435309893); END 2026-10-27T15:16:58.328Z (mono 924807447951347); 12.6ms, exit 0; acquisition 2026-10-27T15:16:58.272Z→2026-10-27T15:16:58.335Z, 62.4ms |
| Post-reopen query 2 | R13-post-reopen, background; shim START 2026-10-27T15:16:58.065Z (mono 924807184189883); END 2026-10-27T15:16:58.078Z (mono 924807197201261); 13.0ms, exit 0; acquisition 2026-10-27T15:16:58.021Z→2026-10-27T15:16:58.085Z, 63.7ms | R13-post-reopen, background; shim START 2026-10-27T15:17:00.380Z (mono 924809499225730); END 2026-10-27T15:17:00.393Z (mono 924809512376590); 13.2ms, exit 0; acquisition 2026-10-27T15:17:00.337Z→2026-10-27T15:17:00.401Z, 63.9ms |
| Post-reopen query 3 | R13-post-reopen, background; shim START 2026-10-27T15:17:02.128Z (mono 924811247239741); END 2026-10-27T15:17:02.141Z (mono 924811260779802); 13.5ms, exit 0; acquisition 2026-10-27T15:17:02.086Z→2026-10-27T15:17:02.149Z, 62.5ms | R13-post-reopen, background; shim START 2026-10-27T15:17:04.446Z (mono 924813565376627); END 2026-10-27T15:17:04.459Z (mono 924813578594342); 13.2ms, exit 0; acquisition 2026-10-27T15:17:04.403Z→2026-10-27T15:17:04.467Z, 63.5ms |
| Post-reopen 1 END → 2 START | Expected 2.000s; acquisition gap **2.001484s**; shim gap **2.052853s**; matches reset | Expected 2.000s; acquisition gap **2.002251s**; shim gap **2.051274s**; matches reset; duration floor 249.5ms |
| Post-reopen 2 END → 3 START | Expected 4.000s; acquisition gap **4.001775s**; shim gap **4.050038s**; matches reset | Expected 4.000s; acquisition gap **4.002051s**; shim gap **4.053000s**; matches reset; duration floor 255.5ms |

## Result and what else changed

**Both observed pairs match the expected reset:** no fallback while empty/exited; reopening resumes fallback polling; the first post-reopen gap is about 2s and the next about 4s. Peak fallback concurrency is one on both sides. All four queries per side exit 0. Three reopened queries finish before cleanup; neither run ends after only the first one.

PR table Δ: **Same empty/exited suppression; reopen resets backoff to ~2s, then ~4s on both sides (three post-reopen queries captured).**

What else changed for R13: **no additional product behavior differences observed; no additions to the previous list.** This recapture extends the observation window and adds explicit exited-window/reopen milestones, PID capture for the restarted shell, and namespace/hash proof. Before and after use identical driver/shim/launcher bytes. Natural run differences are UTC/monotonic origins, PID values, ports, fresh database paths, startup time, full-machine process-table byte counts, and scheduler/launch overhead.

## Reproducibility and cleanup

The supplied archive was downloaded and inspected in a new empty scratch subdirectory. Script paths were relocated from `capture` to `capture-r13`; no product source was edited. `vp install` completed in the new before worktree; the supplied after worktree was already installed. The transcript embeds exact capture scripts and hashes, raw timestamped RPC records, shim interception START/END lines (argv `/bin/ps -eo pid=,ppid=,comm=`), native-helper failure records, namespace proof, relevant full acquisition trace spans, metadata, and cleanup results. Driver SHA256: `11ce0be6bba6331dcd9f0030bb62e1806061ef2cc32af0dbcae4b89918917b55`; shim SHA256: `2adfa9f0fbe37ad192240fdb144c7fc9b1cf45acb6345174f812d650c33852ac`.

- before: driver PID 3435573; owned server/wrapper/restarted-shell PIDs [3435651, 3435652, 3436769]; recorded shell PIDs [3436758, 3436769]; namespace `mnt:[4026532154]` vs host `mnt:[4026531841]`. Cleanup at 2026-10-27T15:17:04.633Z: no survivors before final kill; no remaining owned processes.
- after: driver PID 3435572; owned server/wrapper/restarted-shell PIDs [3435640, 3435641, 3436785]; recorded shell PIDs [3436764, 3436785]; namespace `mnt:[4026532153]` vs host `mnt:[4026531841]`. Cleanup at 2026-10-27T15:17:06.941Z: no survivors before final kill; no remaining owned processes.

Unverified items: none within R13 on this Linux server surface. No other fixture rows, clients, OSes, bundled executable, or native-success paths were recaptured or claimed.

## Before metadata snapshots

```json
[
  {
    "kind": "state",
    "utc": "2026-10-27T15:16:49.222Z",
    "mono_ns": "924798341931853",
    "ms": 11902.175748,
    "terminals": []
  },
  {
    "kind": "state",
    "utc": "2026-10-27T15:16:50.198Z",
    "mono_ns": "924799317714311",
    "ms": 12877.958327,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture-r13/2026-10-27T15-16-37.317Z-before-R13",
        "worktreePath": null,
        "status": "running",
        "pid": 3436758,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": false,
        "label": "Terminal 0",
        "updatedAt": "2026-10-27T15:16:49.260Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T15:16:50.325Z",
    "mono_ns": "924799444215536",
    "ms": 13004.459252,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture-r13/2026-10-27T15-16-37.317Z-before-R13",
        "worktreePath": null,
        "status": "exited",
        "pid": null,
        "exitCode": 0,
        "exitSignal": 0,
        "hasRunningSubprocess": false,
        "label": "Terminal 0",
        "updatedAt": "2026-10-27T15:16:50.205Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T15:16:55.428Z",
    "mono_ns": "924804548059888",
    "ms": 18108.303794,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture-r13/2026-10-27T15-16-37.317Z-before-R13",
        "worktreePath": null,
        "status": "exited",
        "pid": null,
        "exitCode": 0,
        "exitSignal": 0,
        "hasRunningSubprocess": false,
        "label": "Terminal 0",
        "updatedAt": "2026-10-27T15:16:50.205Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T15:16:55.545Z",
    "mono_ns": "924804664922413",
    "ms": 18225.166018,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture-r13/2026-10-27T15-16-37.317Z-before-R13",
        "worktreePath": null,
        "status": "running",
        "pid": 3436769,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": false,
        "label": "Terminal 0",
        "updatedAt": "2026-10-27T15:16:55.440Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T15:17:02.406Z",
    "mono_ns": "924811525111787",
    "ms": 25085.354861,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture-r13/2026-10-27T15-16-37.317Z-before-R13",
        "worktreePath": null,
        "status": "running",
        "pid": 3436769,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": false,
        "label": "Terminal 0",
        "updatedAt": "2026-10-27T15:16:55.470Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T15:17:02.515Z",
    "mono_ns": "924811634102865",
    "ms": 25194.347713,
    "terminals": []
  }
]
```

## After metadata snapshots

```json
[
  {
    "kind": "state",
    "utc": "2026-10-27T15:16:51.574Z",
    "mono_ns": "924800693491566",
    "ms": 14253.734661,
    "terminals": []
  },
  {
    "kind": "state",
    "utc": "2026-10-27T15:16:52.521Z",
    "mono_ns": "924801640495458",
    "ms": 15200.739414,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture-r13/2026-10-27T15-16-37.317Z-after-R13",
        "worktreePath": null,
        "status": "running",
        "pid": 3436764,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": false,
        "label": "Terminal 0",
        "updatedAt": "2026-10-27T15:16:51.603Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T15:16:52.648Z",
    "mono_ns": "924801767398177",
    "ms": 15327.642033,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture-r13/2026-10-27T15-16-37.317Z-after-R13",
        "worktreePath": null,
        "status": "exited",
        "pid": null,
        "exitCode": 0,
        "exitSignal": 0,
        "hasRunningSubprocess": false,
        "label": "Terminal 0",
        "updatedAt": "2026-10-27T15:16:52.528Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T15:16:57.753Z",
    "mono_ns": "924806872696777",
    "ms": 20432.940142,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture-r13/2026-10-27T15-16-37.317Z-after-R13",
        "worktreePath": null,
        "status": "exited",
        "pid": null,
        "exitCode": 0,
        "exitSignal": 0,
        "hasRunningSubprocess": false,
        "label": "Terminal 0",
        "updatedAt": "2026-10-27T15:16:52.528Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T15:16:57.868Z",
    "mono_ns": "924806987722095",
    "ms": 20547.964839,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture-r13/2026-10-27T15-16-37.317Z-after-R13",
        "worktreePath": null,
        "status": "running",
        "pid": 3436785,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": false,
        "label": "Terminal 0",
        "updatedAt": "2026-10-27T15:16:57.763Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T15:17:04.717Z",
    "mono_ns": "924813836812458",
    "ms": 27397.056193,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture-r13/2026-10-27T15-16-37.317Z-after-R13",
        "worktreePath": null,
        "status": "running",
        "pid": 3436785,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": false,
        "label": "Terminal 0",
        "updatedAt": "2026-10-27T15:16:57.792Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T15:17:04.828Z",
    "mono_ns": "924813947296297",
    "ms": 27507.539852,
    "terminals": []
  }
]
```
