# R15: Close 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-26-35.067Z-before-R15`. After run: `/tmp/lead-24640-r1/capture/2026-10-27T14-26-35.073Z-after-R15`.

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.

Close is gated on the shim START, and a survivor remains. Closed/remove events precede the delayed result; only the survivor receives busy activity after the successful after query.

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 | R15, background; shim START 2026-10-27T14:26:43.433Z (mono 921792556613358); END 2026-10-27T14:26:44.407Z (mono 921793530253807); 973.6ms, signal 15; acquisition 2026-10-27T14:26:43.399Z→2026-10-27T14:26:44.414Z, 1015.3ms | R15, background; shim START 2026-10-27T14:26:43.251Z (mono 921792374322495); END 2026-10-27T14:26:48.266Z (mono 921797388891466); 5014.6ms, exit 0; acquisition 2026-10-27T14:26:43.158Z→2026-10-27T14:26:48.274Z, 5116.3ms | Same prompt close; after updates survivor |
| Fallback query 2 | R15, background; shim START 2026-10-27T14:26:46.457Z (mono 921795580218874); END 2026-10-27T14:26:47.426Z (mono 921796548987515); 968.8ms, signal 15; acquisition 2026-10-27T14:26:46.417Z→2026-10-27T14:26:47.432Z, 1015.4ms | R15, background; shim START 2026-10-27T14:27:08.782Z (mono 921817905409295); END 2026-10-27T14:27:13.795Z (mono 921822917885540); 5012.5ms, exit 0; acquisition 2026-10-27T14:27:08.744Z→2026-10-27T14:27:13.802Z, 5058.4ms | Measured duration/result above |
| Background completion→next-query gaps | R15→R15: shim gap 2.050s, acquisition gap 2.003s | R15→R15: shim gap 20.517s, acquisition gap 20.470s | Same prompt close; after updates survivor |
| Terminal event 1 | 2026-10-27T14:26:43.648Z `fixture-thread-a/term-0` closed, seq=4 | 2026-10-27T14:26:43.351Z `fixture-thread-a/term-0` closed, seq=5 | Compare identity/sequence; subscriptions deduplicated |
| Terminal event 2 | 2026-10-27T14:26:47.703Z `fixture-thread-a/term-1` closed, seq=5 | 2026-10-27T14:26:48.279Z `fixture-thread-a/term-1` activity, seq=6, busy=True, label=`fixture-child` | Compare identity/sequence; subscriptions deduplicated |
| Terminal event 3 | — | 2026-10-27T14:27:14.055Z `fixture-thread-a/term-1` 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:26:35.218Z",
    "mono_ns": "921784341473297",
    "ms": 149.012575,
    "phase": "R15",
    "mode": "valid",
    "delay": 5000
  },
  {
    "kind": "server-ready",
    "utc": "2026-10-27T14:26:42.460Z",
    "mono_ns": "921791583377206",
    "ms": 7390.920892
  },
  {
    "kind": "rpc-connected",
    "utc": "2026-10-27T14:26:42.687Z",
    "mono_ns": "921791810060446",
    "ms": 7617.602839
  },
  {
    "kind": "child-ready",
    "utc": "2026-10-27T14:26:42.936Z",
    "mono_ns": "921792059220970",
    "ms": 7866.758114,
    "threadId": "fixture-thread-a",
    "terminalId": "term-0",
    "childPid": 3405977,
    "marker": "READY_R15_0"
  },
  {
    "kind": "child-ready",
    "utc": "2026-10-27T14:26:43.010Z",
    "mono_ns": "921792133691721",
    "ms": 7941.229306,
    "threadId": "fixture-thread-a",
    "terminalId": "term-1",
    "childPid": 3405994,
    "marker": "READY_R15_1"
  },
  {
    "kind": "interaction",
    "utc": "2026-10-27T14:26:43.434Z",
    "mono_ns": "921792557390395",
    "ms": 8364.929363,
    "action": "close captured candidate",
    "query": {
      "kind": "start",
      "pid": 3406097,
      "ppid": 3404668,
      "utc": "2026-10-27T14:26:43",
      "mono_ns": 921792556613358,
      "wall_ns": 1793111203433795300,
      "phase": "R15",
      "argv": [
        "/bin/ps",
        "-eo",
        "pid=,ppid=,comm="
      ],
      "control": {
        "phase": "R15",
        "mode": "valid",
        "delay": 5000
      }
    }
  },
  {
    "kind": "scenario-complete",
    "utc": "2026-10-27T14:26:47.697Z",
    "mono_ns": "921796819873745",
    "ms": 12627.41116
  },
  {
    "kind": "cleanup-start",
    "utc": "2026-10-27T14:26:47.823Z",
    "mono_ns": "921796946244286",
    "ms": 12753.784165,
    "pids": [
      3404667,
      3404668,
      3405990,
      3405994
    ],
    "ptyPids": [
      3405975,
      3405977,
      3405990,
      3405994
    ]
  },
  {
    "kind": "cleanup-end",
    "utc": "2026-10-27T14:26:49.933Z",
    "mono_ns": "921799055852439",
    "ms": 14863.395002,
    "survivorsBeforeFinalKill": [],
    "remaining": []
  }
]
```
Metadata snapshots taken before and after driver cleanup:
```json
[
  {
    "kind": "state",
    "utc": "2026-10-27T14:26:47.696Z",
    "mono_ns": "921796819723043",
    "ms": 12627.262742,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-1",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-26-35.067Z-before-R15",
        "worktreePath": null,
        "status": "running",
        "pid": 3405990,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": false,
        "label": "Terminal 1",
        "updatedAt": "2026-10-27T14:26:43.006Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:26:47.805Z",
    "mono_ns": "921796928027724",
    "ms": 12735.56621,
    "terminals": []
  }
]
```

## After scripted milestones and final observation states
```json
[
  {
    "kind": "control",
    "utc": "2026-10-27T14:26:35.251Z",
    "mono_ns": "921784374286842",
    "ms": 175.155297,
    "phase": "R15",
    "mode": "valid",
    "delay": 5000
  },
  {
    "kind": "server-ready",
    "utc": "2026-10-27T14:26:42.329Z",
    "mono_ns": "921791452580442",
    "ms": 7253.45038
  },
  {
    "kind": "rpc-connected",
    "utc": "2026-10-27T14:26:42.524Z",
    "mono_ns": "921791647671938",
    "ms": 7448.54405
  },
  {
    "kind": "child-ready",
    "utc": "2026-10-27T14:26:42.944Z",
    "mono_ns": "921792066998200",
    "ms": 7867.865542,
    "threadId": "fixture-thread-a",
    "terminalId": "term-0",
    "childPid": 3405974,
    "marker": "READY_R15_0"
  },
  {
    "kind": "child-ready",
    "utc": "2026-10-27T14:26:43.024Z",
    "mono_ns": "921792147232242",
    "ms": 7948.100907,
    "threadId": "fixture-thread-a",
    "terminalId": "term-1",
    "childPid": 3405995,
    "marker": "READY_R15_1"
  },
  {
    "kind": "interaction",
    "utc": "2026-10-27T14:26:43.252Z",
    "mono_ns": "921792375306020",
    "ms": 8176.174054,
    "action": "close captured candidate",
    "query": {
      "kind": "start",
      "pid": 3406008,
      "ppid": 3404677,
      "utc": "2026-10-27T14:26:43",
      "mono_ns": 921792374322495,
      "wall_ns": 1793111203251505000,
      "phase": "R15",
      "argv": [
        "/bin/ps",
        "-eo",
        "pid=,ppid=,comm="
      ],
      "control": {
        "phase": "R15",
        "mode": "valid",
        "delay": 5000
      }
    }
  },
  {
    "kind": "scenario-complete",
    "utc": "2026-10-27T14:27:14.049Z",
    "mono_ns": "921823172238155",
    "ms": 38973.104666
  },
  {
    "kind": "cleanup-start",
    "utc": "2026-10-27T14:27:14.173Z",
    "mono_ns": "921823296096924",
    "ms": 39096.967293,
    "pids": [
      3404676,
      3404677,
      3405992,
      3405995
    ],
    "ptyPids": [
      3405971,
      3405974,
      3405992,
      3405995
    ]
  },
  {
    "kind": "cleanup-end",
    "utc": "2026-10-27T14:27:16.276Z",
    "mono_ns": "921825398866418",
    "ms": 41199.745111,
    "survivorsBeforeFinalKill": [],
    "remaining": []
  }
]
```
Metadata snapshots taken before and after driver cleanup:
```json
[
  {
    "kind": "state",
    "utc": "2026-10-27T14:27:14.049Z",
    "mono_ns": "921823172073727",
    "ms": 38972.943173,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-1",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-26-35.073Z-after-R15",
        "worktreePath": null,
        "status": "running",
        "pid": 3405992,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": true,
        "label": "fixture-child",
        "updatedAt": "2026-10-27T14:26:48.277Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:27:14.157Z",
    "mono_ns": "921823279921179",
    "ms": 39080.790446,
    "terminals": []
  }
]
```

## Behaviour difference
Same prompt close; after updates survivor
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.