# R19: Observed project-script success/nonzero completion

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

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.

Real thread.settle runs a configured runOnSettle project script and consumes its observed completion. A new idle sibling is opened after script readiness. Exit 0 closes only the script terminal; exit 7 leaves the failed-script terminal and its new idle sibling. The initial all-thread settlement cleanup is separately visible.

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 | R19, background; shim START 2026-10-27T14:43:04.303Z (mono 922773425758396); END 2026-10-27T14:43:04.340Z (mono 922773462400614); 36.6ms, exit 0; acquisition 2026-10-27T14:43:04.228Z→2026-10-27T14:43:04.348Z, 119.6ms | R19, background; shim START 2026-10-27T14:43:06.263Z (mono 922775385025792); END 2026-10-27T14:43:06.277Z (mono 922775399550468); 14.5ms, exit 0; acquisition 2026-10-27T14:43:06.217Z→2026-10-27T14:43:06.285Z, 67.6ms | Same targeted success cleanup/nonzero retention |
| Fallback query 2 | R19, closeIdle; shim START 2026-10-27T14:43:04.472Z (mono 922773593885199); END 2026-10-27T14:43:04.516Z (mono 922773638761182); 44.9ms, exit 0; acquisition 2026-10-27T14:43:04.369Z→2026-10-27T14:43:04.524Z, 154.3ms | R19, closeIdle; shim START 2026-10-27T14:43:06.374Z (mono 922775496246673); END 2026-10-27T14:43:06.393Z (mono 922775515049535); 18.8ms, exit 0; acquisition 2026-10-27T14:43:06.314Z→2026-10-27T14:43:06.402Z, 87.3ms | Measured duration/result above |
| Fallback query 3 | R19, closeIdle; shim START 2026-10-27T14:43:04.868Z (mono 922773990109483); END 2026-10-27T14:43:04.915Z (mono 922774037645877); 47.5ms, exit 0; acquisition 2026-10-27T14:43:04.782Z→2026-10-27T14:43:04.923Z, 140.5ms | R19, closeIdle; shim START 2026-10-27T14:43:06.764Z (mono 922775886870612); END 2026-10-27T14:43:06.777Z (mono 922775899523878); 12.7ms, exit 0; acquisition 2026-10-27T14:43:06.725Z→2026-10-27T14:43:06.783Z, 58.4ms | Measured duration/result above |
| Fallback query 4 | R19, background; shim START 2026-10-27T14:43:06.388Z (mono 922775510425201); END 2026-10-27T14:43:06.407Z (mono 922775529035823); 18.6ms, exit 0; acquisition 2026-10-27T14:43:06.351Z→2026-10-27T14:43:06.415Z, 63.8ms | R19, background; shim START 2026-10-27T14:43:08.342Z (mono 922777464616483); END 2026-10-27T14:43:08.357Z (mono 922777479154847); 14.5ms, exit 0; acquisition 2026-10-27T14:43:08.288Z→2026-10-27T14:43:08.364Z, 75.8ms | Measured duration/result above |
| Fallback query 5 | R19, background; shim START 2026-10-27T14:43:10.467Z (mono 922779589804462); END 2026-10-27T14:43:10.481Z (mono 922779603744092); 13.9ms, exit 0; acquisition 2026-10-27T14:43:10.417Z→2026-10-27T14:43:10.488Z, 71.9ms | R19, background; shim START 2026-10-27T14:43:12.416Z (mono 922781538286265); END 2026-10-27T14:43:12.429Z (mono 922781551108258); 12.8ms, exit 0; acquisition 2026-10-27T14:43:12.366Z→2026-10-27T14:43:12.434Z, 67.5ms | Measured duration/result above |
| Background completion→next-query gaps | R19→R19: shim gap 2.048s, acquisition gap 2.003s<br>R19→R19: shim gap 4.061s, acquisition gap 4.002s | R19→R19: shim gap 2.065s, acquisition gap 2.003s<br>R19→R19: shim gap 4.059s, acquisition gap 4.003s | Same targeted success cleanup/nonzero retention |
| Terminal event 1 | 2026-10-27T14:43:04.351Z `fixture-thread-a/settle-fixture-settle-417b577d` activity, seq=7, busy=True, label=`fixture-script` | 2026-10-27T14:43:06.289Z `fixture-thread-a/settle-fixture-settle-408d0bf4` activity, seq=7, busy=True, label=`fixture-script` | Compare identity/sequence; subscriptions deduplicated |
| Terminal event 2 | 2026-10-27T14:43:04.619Z `fixture-thread-a/settle-fixture-settle-417b577d` closed, seq=11 | 2026-10-27T14:43:06.551Z `fixture-thread-a/settle-fixture-settle-408d0bf4` closed, seq=11 | Compare identity/sequence; subscriptions deduplicated |
| Terminal event 3 | 2026-10-27T14:43:04.984Z `fixture-thread-a/term-0` closed, seq=4 | 2026-10-27T14:43:06.938Z `fixture-thread-a/term-0` closed, seq=5 | Compare identity/sequence; subscriptions deduplicated |
| Terminal event 4 | 2026-10-27T14:43:06.417Z `fixture-thread-a/settle-fixture-fail-fa076505` activity, seq=8, busy=True, label=`fixture-script` | 2026-10-27T14:43:08.367Z `fixture-thread-a/settle-fixture-fail-25979cad` activity, seq=7, busy=True, label=`fixture-script` | Compare identity/sequence; subscriptions deduplicated |
| Terminal event 5 | 2026-10-27T14:43:10.491Z `fixture-thread-a/settle-fixture-fail-fa076505` activity, seq=12, busy=False, label=`settle-fixture-fail-fa076505` | 2026-10-27T14:43:12.437Z `fixture-thread-a/settle-fixture-fail-25979cad` activity, seq=11, busy=False, label=`settle-fixture-fail-25979cad` | Compare identity/sequence; subscriptions deduplicated |
| Terminal event 6 | 2026-10-27T14:43:10.612Z `fixture-thread-a/term-1` closed, seq=3 | 2026-10-27T14:43:12.567Z `fixture-thread-a/term-1` closed, seq=4 | 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:42:55.413Z",
    "mono_ns": "922764535254260",
    "ms": 214.579318,
    "phase": "R19",
    "mode": "valid",
    "delay": 0
  },
  {
    "kind": "server-ready",
    "utc": "2026-10-27T14:43:03.134Z",
    "mono_ns": "922772256311620",
    "ms": 7935.638792
  },
  {
    "kind": "rpc-connected",
    "utc": "2026-10-27T14:43:03.249Z",
    "mono_ns": "922772371680683",
    "ms": 8051.009588
  },
  {
    "kind": "script-success-phase",
    "utc": "2026-10-27T14:43:03.435Z",
    "mono_ns": "922772557214178",
    "ms": 8236.536862
  },
  {
    "kind": "settlement-cleanup-completed",
    "utc": "2026-10-27T14:43:03.585Z",
    "mono_ns": "922772707493891",
    "ms": 8386.818227,
    "threadId": "fixture-thread-a",
    "span": {
      "type": "effect-span",
      "name": "ThreadSettlementServiceV2.cleanUpSettledThread",
      "traceId": "d69c2e76585d81ae8e859b68325a0807",
      "spanId": "0d59330c2f8d2455",
      "parentSpanId": "635674eccb028410",
      "sampled": true,
      "kind": "internal",
      "startTimeUnixNano": "1793112183465626584",
      "endTimeUnixNano": "1793112183502614490",
      "durationMs": 36.987906,
      "attributes": {},
      "events": [],
      "links": [],
      "exit": {
        "_tag": "Success"
      }
    }
  },
  {
    "kind": "script-target",
    "utc": "2026-10-27T14:43:03.646Z",
    "mono_ns": "922772767912832",
    "ms": 8447.236057,
    "terminalId": "settle-fixture-settle-417b577d",
    "pid": 3424863
  },
  {
    "kind": "release-script",
    "utc": "2026-10-27T14:43:04.360Z",
    "mono_ns": "922773482650231",
    "ms": 9161.973555
  },
  {
    "kind": "settlement-cleanup-completed",
    "utc": "2026-10-27T14:43:05.571Z",
    "mono_ns": "922774692959522",
    "ms": 10372.28482,
    "threadId": "fixture-thread-a",
    "span": {
      "type": "effect-span",
      "name": "ThreadSettlementServiceV2.cleanUpSettledThread",
      "traceId": "d69c2e76585d81ae8e859b68325a0807",
      "spanId": "f73b300ac0626c2f",
      "parentSpanId": "635674eccb028410",
      "sampled": true,
      "kind": "internal",
      "startTimeUnixNano": "1793112184780045316",
      "endTimeUnixNano": "1793112185007560926",
      "durationMs": 227.51561,
      "attributes": {},
      "events": [],
      "links": [],
      "exit": {
        "_tag": "Success"
      }
    }
  },
  {
    "kind": "release-failed-script",
    "utc": "2026-10-27T14:43:06.425Z",
    "mono_ns": "922775547139434",
    "ms": 11226.462758,
    "terminalId": "settle-fixture-fail-fa076505"
  },
  {
    "kind": "scenario-complete",
    "utc": "2026-10-27T14:43:10.605Z",
    "mono_ns": "922779727109365",
    "ms": 15406.431828
  },
  {
    "kind": "cleanup-start",
    "utc": "2026-10-27T14:43:10.734Z",
    "mono_ns": "922779856414491",
    "ms": 15535.741753,
    "pids": [
      3423855,
      3423856,
      3425282,
      3425473
    ],
    "ptyPids": [
      3424863,
      3424936,
      3425282,
      3425473
    ]
  },
  {
    "kind": "cleanup-end",
    "utc": "2026-10-27T14:43:12.852Z",
    "mono_ns": "922781974134421",
    "ms": 17653.464097,
    "survivorsBeforeFinalKill": [],
    "remaining": []
  }
]
```
Metadata snapshots taken before and after driver cleanup:
```json
[
  {
    "kind": "state",
    "utc": "2026-10-27T14:43:04.726Z",
    "mono_ns": "922773848143546",
    "ms": 9527.467632,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-42-55.195Z-before-R19",
        "worktreePath": null,
        "status": "running",
        "pid": 3424936,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": false,
        "label": "Terminal 0",
        "updatedAt": "2026-10-27T14:43:03.689Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:43:10.605Z",
    "mono_ns": "922779726988288",
    "ms": 15406.312925,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "settle-fixture-fail-fa076505",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-42-55.195Z-before-R19",
        "worktreePath": "/tmp/lead-24640-r1/capture/2026-10-27T14-42-55.195Z-before-R19",
        "status": "running",
        "pid": 3425282,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": false,
        "label": "settle-fixture-fail-fa076505",
        "updatedAt": "2026-10-27T14:43:10.489Z"
      },
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-1",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-42-55.195Z-before-R19",
        "worktreePath": null,
        "status": "running",
        "pid": 3425473,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": false,
        "label": "Terminal 1",
        "updatedAt": "2026-10-27T14:43:05.620Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:43:10.713Z",
    "mono_ns": "922779835753853",
    "ms": 15515.078721,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "settle-fixture-fail-fa076505",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-42-55.195Z-before-R19",
        "worktreePath": "/tmp/lead-24640-r1/capture/2026-10-27T14-42-55.195Z-before-R19",
        "status": "running",
        "pid": 3425282,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": false,
        "label": "settle-fixture-fail-fa076505",
        "updatedAt": "2026-10-27T14:43:10.489Z"
      }
    ]
  }
]
```

## After scripted milestones and final observation states
```json
[
  {
    "kind": "control",
    "utc": "2026-10-27T14:42:56.599Z",
    "mono_ns": "922765720993691",
    "ms": 248.566569,
    "phase": "R19",
    "mode": "valid",
    "delay": 0
  },
  {
    "kind": "server-ready",
    "utc": "2026-10-27T14:43:05.223Z",
    "mono_ns": "922774345695923",
    "ms": 8873.258862
  },
  {
    "kind": "rpc-connected",
    "utc": "2026-10-27T14:43:05.441Z",
    "mono_ns": "922774563446356",
    "ms": 9091.011438
  },
  {
    "kind": "script-success-phase",
    "utc": "2026-10-27T14:43:05.638Z",
    "mono_ns": "922774760368947",
    "ms": 9287.928017
  },
  {
    "kind": "settlement-cleanup-completed",
    "utc": "2026-10-27T14:43:05.785Z",
    "mono_ns": "922774907701130",
    "ms": 9435.262855,
    "threadId": "fixture-thread-a",
    "span": {
      "type": "effect-span",
      "name": "ThreadSettlementServiceV2.cleanUpSettledThread",
      "traceId": "f6c1d049648a9ab877a2081319f2a3d2",
      "spanId": "d7afbe584a3a5f84",
      "parentSpanId": "d75fd3c99064aa0a",
      "sampled": true,
      "kind": "internal",
      "startTimeUnixNano": "1793112185685548385",
      "endTimeUnixNano": "1793112185746382956",
      "durationMs": 60.834571,
      "attributes": {},
      "events": [],
      "links": [],
      "exit": {
        "_tag": "Success"
      }
    }
  },
  {
    "kind": "script-target",
    "utc": "2026-10-27T14:43:05.866Z",
    "mono_ns": "922774988727088",
    "ms": 9516.286519,
    "terminalId": "settle-fixture-settle-408d0bf4",
    "pid": 3425522
  },
  {
    "kind": "release-script",
    "utc": "2026-10-27T14:43:06.307Z",
    "mono_ns": "922775429091936",
    "ms": 9956.651678
  },
  {
    "kind": "settlement-cleanup-completed",
    "utc": "2026-10-27T14:43:07.787Z",
    "mono_ns": "922776909159111",
    "ms": 11436.719745,
    "threadId": "fixture-thread-a",
    "span": {
      "type": "effect-span",
      "name": "ThreadSettlementServiceV2.cleanUpSettledThread",
      "traceId": "f6c1d049648a9ab877a2081319f2a3d2",
      "spanId": "20ab8205d7aa8e66",
      "parentSpanId": "d75fd3c99064aa0a",
      "sampled": true,
      "kind": "internal",
      "startTimeUnixNano": "1793112186723269005",
      "endTimeUnixNano": "1793112186937726499",
      "durationMs": 214.457494,
      "attributes": {},
      "events": [],
      "links": [],
      "exit": {
        "_tag": "Success"
      }
    }
  },
  {
    "kind": "release-failed-script",
    "utc": "2026-10-27T14:43:08.387Z",
    "mono_ns": "922777508952875",
    "ms": 12036.512998,
    "terminalId": "settle-fixture-fail-25979cad"
  },
  {
    "kind": "scenario-complete",
    "utc": "2026-10-27T14:43:12.559Z",
    "mono_ns": "922781680978513",
    "ms": 16208.538116
  },
  {
    "kind": "cleanup-start",
    "utc": "2026-10-27T14:43:12.685Z",
    "mono_ns": "922781807413065",
    "ms": 16334.975893,
    "pids": [
      3423899,
      3423900,
      3425836,
      3425898
    ],
    "ptyPids": [
      3425522,
      3425627,
      3425836,
      3425898
    ]
  },
  {
    "kind": "cleanup-end",
    "utc": "2026-10-27T14:43:14.822Z",
    "mono_ns": "922783944304969",
    "ms": 18471.868488,
    "survivorsBeforeFinalKill": [
      3423900,
      3423899
    ],
    "remaining": []
  }
]
```
Metadata snapshots taken before and after driver cleanup:
```json
[
  {
    "kind": "state",
    "utc": "2026-10-27T14:43:06.671Z",
    "mono_ns": "922775793308556",
    "ms": 10320.86898,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-0",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-42-56.347Z-after-R19",
        "worktreePath": null,
        "status": "running",
        "pid": 3425627,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": false,
        "label": "Terminal 0",
        "updatedAt": "2026-10-27T14:43:05.889Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:43:12.558Z",
    "mono_ns": "922781680818353",
    "ms": 16208.38025,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "settle-fixture-fail-25979cad",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-42-56.347Z-after-R19",
        "worktreePath": "/tmp/lead-24640-r1/capture/2026-10-27T14-42-56.347Z-after-R19",
        "status": "running",
        "pid": 3425836,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": false,
        "label": "settle-fixture-fail-25979cad",
        "updatedAt": "2026-10-27T14:43:12.435Z"
      },
      {
        "threadId": "fixture-thread-a",
        "terminalId": "term-1",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-42-56.347Z-after-R19",
        "worktreePath": null,
        "status": "running",
        "pid": 3425898,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": false,
        "label": "Terminal 1",
        "updatedAt": "2026-10-27T14:43:07.802Z"
      }
    ]
  },
  {
    "kind": "state",
    "utc": "2026-10-27T14:43:12.668Z",
    "mono_ns": "922781790810309",
    "ms": 16318.372937,
    "terminals": [
      {
        "threadId": "fixture-thread-a",
        "terminalId": "settle-fixture-fail-25979cad",
        "cwd": "/tmp/lead-24640-r1/capture/2026-10-27T14-42-56.347Z-after-R19",
        "worktreePath": "/tmp/lead-24640-r1/capture/2026-10-27T14-42-56.347Z-after-R19",
        "status": "running",
        "pid": 3425836,
        "exitCode": null,
        "exitSignal": null,
        "hasRunningSubprocess": false,
        "label": "settle-fixture-fail-25979cad",
        "updatedAt": "2026-10-27T14:43:12.435Z"
      }
    ]
  }
]
```

## Behaviour difference
Same targeted success cleanup/nonzero retention
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.