# R16: Restart same ID and open new ID during 5s query

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

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.

Restart and new-open are gated on START. Before/after snapshots expose old and new PIDs. No busy activity from the stale candidate set is published for the restarted/new terminal; the next fresh query supplies both correct identities after.

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 | R16, background; shim START 2026-10-27T14:27:24.798Z (mono 921833921129957); END 2026-10-27T14:27:25.754Z (mono 921834877787128); 956.7ms, signal 15; acquisition 2026-10-27T14:27:24.742Z→2026-10-27T14:27:25.761Z, 1018.9ms | R16, background; shim START 2026-10-27T14:27:24.812Z (mono 921833934875232); END 2026-10-27T14:27:29.847Z (mono 921838970679440); 5035.8ms, exit 0; acquisition 2026-10-27T14:27:24.748Z→2026-10-27T14:27:29.857Z, 5109.1ms | Same stale-identity suppression; after fresh result |
| Fallback query 2 | R16, background; shim START 2026-10-27T14:27:27.844Z (mono 921836967036793); END 2026-10-27T14:27:28.806Z (mono 921837929086852); 962.1ms, signal 15; acquisition 2026-10-27T14:27:27.764Z→2026-10-27T14:27:28.811Z, 1047.2ms | R16, background; shim START 2026-10-27T14:27:50.342Z (mono 921859465773985); END 2026-10-27T14:27:55.367Z (mono 921864489857024); 5024.1ms, exit 0; acquisition 2026-10-27T14:27:50.297Z→2026-10-27T14:27:55.374Z, 5077.0ms | Measured duration/result above |
| Background completion→next-query gaps | R16→R16: shim gap 2.089s, acquisition gap 2.003s | R16→R16: shim gap 20.495s, acquisition gap 20.440s | Same stale-identity suppression; after fresh result |
| Terminal event 1 | 2026-10-27T14:27:24.830Z `fixture-thread-a/term-0` restarted, seq=4, pid=3408191 | 2026-10-27T14:27:24.862Z `fixture-thread-a/term-0` restarted, seq=5, pid=3408200 | Compare identity/sequence; subscriptions deduplicated |
| Terminal event 2 | 2026-10-27T14:27:29.082Z `fixture-thread-a/term-0` closed, seq=9 | 2026-10-27T14:27:55.380Z `fixture-thread-a/term-0` activity, seq=10, busy=True, label=`fixture-child` | Compare identity/sequence; subscriptions deduplicated |
| Terminal event 3 | 2026-10-27T14:27:29.088Z `fixture-thread-a/term-1` closed, seq=9 | 2026-10-27T14:27:55.381Z `fixture-thread-a/term-1` activity, seq=7, busy=True, label=`fixture-child` | Compare identity/sequence; subscriptions deduplicated |
| Terminal event 4 | — | 2026-10-27T14:27:55.627Z `fixture-thread-a/term-0` closed, seq=11 | Compare identity/sequence; subscriptions deduplicated |
| Terminal event 5 | — | 2026-10-27T14:27:55.635Z `fixture-thread-a/term-1` closed, seq=8 | 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:17.290Z",
    "mono_ns": "921826413219050",
    "ms": 173.827666,
    "phase": "R16",
    "mode": "valid",
    "delay": 5000
  },
  {
    "kind": "server-ready",
    "utc": "2026-10-27T14:27:23.814Z",
    "mono_ns": "921832937150582",
    "ms": 6697.76545
  },
  {
    "kind": "rpc-connected",
    "utc": "2026-10-27T14:27:24.038Z",
    "mono_ns": "921833161248070",
    "ms": 6921.858651
  },
  {
    "kind": "child-ready",
    "utc": "2026-10-27T14:27:24.248Z",
    "mono_ns": "921833371175026",
    "ms": 7131.781008,
    "threadId": "fixture-thread-a",
    "terminalId": "term-0",
    "childPid": 3408179,
    "marker": "READY_R16_0"
  },
  {
    "kind": "interaction",
    "utc": "2026-10-27T14:27:24.817Z",
    "mono_ns": "921833939835146",
    "ms": 7700.440867,
    "action": "restart captured candidate, open new candidate",
    "query": {
      "kind": "start",
      "pid": 3408188,
      "ppid": 3407145,
      "utc": "2026-10-27T14:27:24",
      "mono_ns": 921833921129957,
      "wall_ns": 1793111244798312200,
      "phase": "R16",
      "argv": [
        "/bin/ps",
        "-eo",
        "pid=,ppid=,comm="
      ],
      "control": {
        "phase": "R16",
        "mode": "valid",
        "delay": 5000
      }
    }
  },
  {
    "kind": "child-ready",
    "utc": "2026-10-27T14:27:24.956Z",
    "mono_ns": "921834079377516",
    "ms": 7839.983328,
    "threadId": "fixture-thread-a",
    "terminalId": "term-1",
    "childPid": 3408203,
    "marker": "READY_R16_1"
  },
  {
    "kind": "scenario-complete",
    "utc": "2026-10-27T14:27:29.076Z",
    "mono_ns": "921838198907296",
    "ms": 11959.511534
  },
  {
    "kind": "cleanup-start",
    "utc": "2026-10-27T14:27:29.218Z",
    "mono_ns": "921838341170676",
    "ms": 12101.77769,
    "pids": [
      3407143,
      3407145,
      3408191,
      3408197,
      3408203,
      3408227
    ],
    "ptyPids": [
      3408177,
      3408179,
      3408191,
      3408197,
      3408203
    ]
  },
  {
    "kind": "cleanup-end",
    "utc": "2026-10-27T14:27:31.397Z",
    "mono_ns": "921840520287543",
    "ms": 14280.900888,
    "survivorsBeforeFinalKill": [],
    "remaining": []
  }
]
```
Metadata snapshots taken before and after driver cleanup:
```json
[
  {
    "kind": "state",
    "utc": "2026-10-27T14:27:29.075Z",
    "mono_ns": "921838198801146",
    "ms": 11959.406426,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-27-17.114Z-before-R16",
        "worktreePath": null,
        "status": "running",
        "pid": 3408191,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": false,
        "label": "Terminal 0",
        "updatedAt": "2026-10-27T14:27:24.975Z"
      },
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-1",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-27-17.114Z-before-R16",
        "worktreePath": null,
        "status": "running",
        "pid": 3408197,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": false,
        "label": "Terminal 1",
        "updatedAt": "2026-10-27T14:27:24.937Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:27:29.190Z",
    "mono_ns": "921838312901080",
    "ms": 12073.507321,
    "terminals": []
  }
]
```

## After scripted milestones and final observation states
```json
[
  {
    "kind": "control",
    "utc": "2026-10-27T14:27:17.298Z",
    "mono_ns": "921826421567651",
    "ms": 182.24132,
    "phase": "R16",
    "mode": "valid",
    "delay": 5000
  },
  {
    "kind": "server-ready",
    "utc": "2026-10-27T14:27:23.684Z",
    "mono_ns": "921832807437100",
    "ms": 6568.114706
  },
  {
    "kind": "rpc-connected",
    "utc": "2026-10-27T14:27:23.859Z",
    "mono_ns": "921832981982373",
    "ms": 6742.659087
  },
  {
    "kind": "child-ready",
    "utc": "2026-10-27T14:27:24.091Z",
    "mono_ns": "921833214295804",
    "ms": 6974.966897,
    "threadId": "fixture-thread-a",
    "terminalId": "term-0",
    "childPid": 3408145,
    "marker": "READY_R16_0"
  },
  {
    "kind": "interaction",
    "utc": "2026-10-27T14:27:24.825Z",
    "mono_ns": "921833948389042",
    "ms": 7709.060297,
    "action": "restart captured candidate, open new candidate",
    "query": {
      "kind": "start",
      "pid": 3408189,
      "ppid": 3407148,
      "utc": "2026-10-27T14:27:24",
      "mono_ns": 921833934875232,
      "wall_ns": 1793111244812057300,
      "phase": "R16",
      "argv": [
        "/bin/ps",
        "-eo",
        "pid=,ppid=,comm="
      ],
      "control": {
        "phase": "R16",
        "mode": "valid",
        "delay": 5000
      }
    }
  },
  {
    "kind": "child-ready",
    "utc": "2026-10-27T14:27:24.973Z",
    "mono_ns": "921834096813294",
    "ms": 7857.484067,
    "threadId": "fixture-thread-a",
    "terminalId": "term-1",
    "childPid": 3408215,
    "marker": "READY_R16_1"
  },
  {
    "kind": "scenario-complete",
    "utc": "2026-10-27T14:27:55.619Z",
    "mono_ns": "921864742754939",
    "ms": 38503.425042
  },
  {
    "kind": "cleanup-start",
    "utc": "2026-10-27T14:27:55.771Z",
    "mono_ns": "921864894309374",
    "ms": 38654.98159,
    "pids": [
      3407144,
      3407148,
      3408200,
      3408204,
      3408215,
      3408243
    ],
    "ptyPids": [
      3408142,
      3408145,
      3408200,
      3408204,
      3408215
    ]
  },
  {
    "kind": "cleanup-end",
    "utc": "2026-10-27T14:27:57.904Z",
    "mono_ns": "921867027344673",
    "ms": 40788.026598,
    "survivorsBeforeFinalKill": [],
    "remaining": []
  }
]
```
Metadata snapshots taken before and after driver cleanup:
```json
[
  {
    "kind": "state",
    "utc": "2026-10-27T14:27:55.619Z",
    "mono_ns": "921864742654862",
    "ms": 38503.327098,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-27-17.114Z-after-R16",
        "worktreePath": null,
        "status": "running",
        "pid": 3408200,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": true,
        "label": "fixture-child",
        "updatedAt": "2026-10-27T14:27:55.376Z"
      },
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-1",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-27-17.114Z-after-R16",
        "worktreePath": null,
        "status": "running",
        "pid": 3408204,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": true,
        "label": "fixture-child",
        "updatedAt": "2026-10-27T14:27:55.378Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:27:55.737Z",
    "mono_ns": "921864860075724",
    "ms": 38620.748711,
    "terminals": []
  }
]
```

## Behaviour difference
Same stale-identity suppression; after fresh result
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.