Skip to content

fix(process): EPERM is not a failed cleanup; bound the wait for output pipes after exit - #963

Merged
stamp-build[bot] merged 1 commit into
mainfrom
agent/cindy/airwing-process-pipes
Nov 18, 2026
Merged

stamp-build[bot] merged 1 commit into
mainfrom
agent/cindy/airwing-process-pipes

Conversation

@stamp-build

@stamp-build stamp-build Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Cindy from open-agent-runtime opened this pull request through Stamp
View in Stamp →


Contributed by builder (airwing) as a patch; opened by Cindy because their fork lacks workflow permission. Commit authorship is preserved. Reviewed in three rounds in Raft (#airwing-oar); round-3 verdict: go.

Why

A host that runs a runtime as another OS user (installation.command is a sudo -n -u <worker> -- <runtime> "$@" wrapper) makes OAR's direct child sudo. sudo is setuid root, but its real uid is the host's, so the host may signal it. Everything below it belongs to the worker, and the host gets EPERM signalling those processes. Measured on Ubuntu 22.04 with sudo 1.9.9 and a stand-in runtime that leaves a background process on its stdout (sh -c 'sleep 900 & exec sleep 901'), on origin/main at 4015fb1:

  • A group signal reaches only sudo. sudo relays SIGTERM to its direct command and exits; the background process survives.
  • A per-process signal to a worker process gets EPERM. signalEntries counted it as failed with codes: ["EPERM"], so codex's turn cleanup reported a failed cleanup for processes that are not OAR's to stop.
  • The orphan keeps the root's stdout/stderr open:
    • A session process's exited resolved, but OAR's ends of the pipes stayed open for the orphan's whole life, which also kept the host's event loop alive.
    • A one-shot command (runExecutable) that timed out never returned. It waits for close, and the stop cannot reach the orphan.

The pipe part is not specific to sudo. Any background job that keeps the root's stdout does the same, for every runtime, and that same-user case is what the tests cover.

What

  1. EPERM is foreign, not a failure, and it is reported. signalEntries counts a per-process EPERM in a new SignalReport.foreign, not in failed/codes. The group EPERM was already ignored, and the SIGTERM still goes to the direct child (its group) first, unchanged. Codex's abort cleanup carries the count: SessionCleanup gains foreign?: number (present when nonzero, on completed and failed). Under sudo it now reads completed {signalled: 0, foreign: 2}, not completed {signalled: 0}.
  2. The wait for output pipes after the root's exit is bounded (POSIX). New shared/executable/pipe-close.ts, PIPE_CLOSE_MS = 2000.
    • Which pipes are closed. Past the limit OAR closes its end of each pipe it is still reading. A pipe read to its end that has not closed is held by some process, whether or not one can be named, so it is closed even with no holder seen. A pipe holding data its reader has not taken yet (readableFlowing === false with readableLength > 0: paused, or a for await reader still busy with a chunk) is left to the reader. Once the reader has taken that data, OAR closes the pipe like the others if it is still open, and adds it to heldPipes. readableFlowing alone is not the test: it is false for a for await or 'readable' reader that is reading normally.
    • What is reported. cleanup.heldPipes = { waitedMs, pipes, holders }, plus the exit reason: Output pipes (stdout, stderr) still open 2014 ms after the root exited (left in the root's process group: pids 15631); OAR closed its end, so output may be incomplete. holders are the processes still in the root's process group, which may hold the pipes. A holder outside the group is not seen, and holders is then [] ("no holder identified"). If that process-table read fails, cleanup is unverified and the failed read is kept in observations (phase pipe_holders).
    • Session processes (spawnLineProcess, which every runtime's session process uses): after native exit and the existing cleanup, exited waits at most 2 s for stdout, stderr and the private pipe.
    • One-shot commands (runExecutable):
      • With no deadline, the wait is 2 s after the exit.
      • Once stopped (deadline, abort, output limit), the wait is 2 s after stopProbe has sent its SIGKILL escalation.
      • The wait is only an upper bound. close (every pipe at EOF) completes the result whenever it comes, so a command that exits on the SIGTERM returns at once, not after the kill grace.
      • When OAR closed the pipes, the result is ok: false with error.code: "OUTPUT_INCOMPLETE" and cleanup.heldPipes, so assertRan throws and names the holders.
    • Host-exit hook. Once OAR closes the pipes, the ChildProcess leaves the ownership set, so the hook never signals the root's pid or group by number again. The group members seen at that moment are kept by identity (pid and start time). At host exit, each one, with its descendants, is SIGKILLed only if the table still shows the same process. If no table could be read, nothing is kept.
    • Windows is unchanged. Sessions resolve exited without waiting for the pipes, as before. One-shot commands wait for close.

Docs: docs/spec/record-stream.md (the rule "A process left holding the output pipes never holds up the exit", and foreign in the abort-cleanup rule), docs/runtimes/codex.md.

Changes in round 3

review point change
BLOCKING: a stopped command waited the whole kill grace; a lone probe exited with code 13 close completes the result at any time again (run.ts). The bounded wait now only races it: it still awaits stopping and then starts the 2 s, but it completes the result only when it has closed held pipes (or failed). While it waits, the pipes it would close are open handles, so the event loop stays up; once they close, close has already settled the result, so the result never waits on the unref'd grace timer. runExecutable("sleep", ["30"], { timeoutMs: 300 }): 331 ms on base, hung on round 2 (exit 13 with nothing else on the loop; ~10.3 s in the maintainer's run), 329 ms now. The same with an abort at 300 ms: 317 ms base, 315 ms now.
B5: "paused" was too broad, and judged once A pipe is left to its reader only while readableFlowing === false && readableLength > 0. Such a pipe is checked again every 100 ms (an unref'd interval; Node has no event for a read() that a 'data' listener could watch without changing how the stream flows). Once the reader has taken the data, the pipe is closed if still open, and that report is merged into the session's heldPipes (mergeHeldPipes). A pipe whose EOF has arrived is never closed: Node emits end itself when the buffer is empty, so it closes on its own.
MINOR: opencode skills-v1 Noted under "For the maintainer to weigh".

Changes after round 1

review point change
B1: exit hook SIGKILLs a group that may no longer be OAR's keepOwnedAfterClose is removed. The child is dropped from ownedChildren (so the ChildProcess and its listener closures, including runExecutable's output buffers, are no longer kept for the host's life). Group members are kept as ProcessEntry identities through trackPendingCleanup (ownLeftProcesses) and signalled only on a start-time match.
B2: a session left its end open when no holder was seen Every pipe OAR is still reading is closed after the limit, with holders: [] when none is seen.
B3: truncated output reported ok: true ok: false, OUTPUT_INCOMPLETE, and heldPipes in diagnostics. record-stream.md now says that writes after the limit are lost and that the writer gets EPIPE/SIGPIPE.
B4: foreign was never surfaced It is carried into SessionCleanup.foreign, and codex.md tells hosts to check it.
B5: close only the pipe that is held Pipes are judged one at a time (see the finding below). Round 3 narrows which ones are left to their reader.
B6: stop-path timer started at stop() stopProbe now returns a promise that settles after its SIGKILL step. runExecutable starts the 2 s from there.
B7: no try/finally around closePipesAfterExit Added in runExecutable. A throw fails the result with the error and destroys the pipes. spawnLineProcess catches as well. closePipesAfterExit itself turns a table-read throw into a failure observation.
B8: failed table read reported as observed Now unverified, with the failed read in observations (phase pipe_holders).
Docs "Neither counted" is corrected: a member of a group whose group signal reached counts as signalled. The Windows sentence is corrected. The codex.md line break is fixed. The experiment's "before" is 4015fb1, and its "after" is marked as v1.
Tests withinTenSeconds's timer is unref'd. Each review point has a regression test (below).

Finding: the v1 /proc descriptor matching never matched anything. Node's stdio "pipes" on Linux are socketpairs. Our end and the child's end are different sockets with different inodes (socket:[N] and socket:[N+1] in /proc/<pid>/fd), and v1 compared our end's inode against pipe:[…] links. On top of that, asRecord(_handle).fd always came back undefined, because fd is a prototype getter. So v1 named holders only by process-group membership, on Linux too. The reviewer's /proc scan items (same-uid only, bounded concurrency, non-dumpable processes, the private _handle.fd) therefore go away together with the scan. Matching the peer of a Unix socket would need sock_diag (what ss -xp uses), which Node does not expose. Per-pipe judgement (B5) uses the pipe's own state instead. The trade-off: holders outside the root's group are not named, though their pipes are still closed.

Tests

Per the maintainer's guidance, the tests focus on the same-user case. No sudo runs were made for this revision.

tests/process-held-pipes.test.ts (real processes; seams only where noted):

  • Session with a background sleep on its pipes: exited returns within the limit (≥ 1.9 s, < 5 s). It reports heldPipes {pipes: [stdout, stderr], holders: [sleep]} and the exact reason string. stdout is closed, and the sleep is left running. (guidance 1)
  • Session whose holder left the root's group (a detached child of a node root): it still closes, with holders: [] and status observed. (B2)
  • kill() with the holder answering EPERM and the group signal reaching only the root (sudo's behaviour, injected through process.kill): no hang, the holder is reported, and status is observed.
  • Private pipe with unread data under a 'readable' listener, holder on stderr only: only stderr is closed, and the extra pipe still yields its data. (B5)
  • The maintainer's repro sh -c "(sleep 2.5; echo LATE) & echo EARLY; exit 0" with timeoutMs: 0: {ok: false, stdout: "EARLY\n", exitCode: null, error: OUTPUT_INCOMPLETE}, and assertRan throws, naming the holders. (B3, guidance 2)
  • runExecutable with no deadline and a holder: ok: false with the holder.
  • runExecutable timing out with an EPERM holder: settles with timeoutMs and the holder.
  • Stop path with each cleanup table read delayed 2.5 s and a holder that ignores SIGTERM: the holder dies by the SIGKILL and is not reported, and the result has no heldPipes. (B6)
  • closePipesAfterExit made to throw: the result still settles, with that error. (B7)
  • Process-table read made to fail: unverified, the failed read kept with phase pipe_holders, and holders: []. (B8)

tests/process-held-pipes-readers.test.ts (round 3, B5; holder on the private pipe only):

  • A for await reader: the pipe is closed after the limit, heldPipes {pipes: [extra], holders: [sleep]}, and the reader got its data.
  • A 'readable' reader that reads in its handler: same.
  • Backpressure after the root's exit (the holder writes two chunks; the reader pauses after the first): at exited the pipe is open, its data unread, and there is no heldPipes. After resume(), the reader gets the second chunk, the pipe is closed, and heldPipes names it and the holder. (A pause before the root's exit does not test this: Node's flushStdio resumes such a pipe at the exit.)
  • A for await reader busy with its first chunk past the limit while the second chunk and EOF arrive, with no holder: nothing is cut, the reader gets both chunks, and there is no heldPipes.

tests/process-stop-settles.test.ts (round 3, blocking):

  • runExecutable("sleep", ["30"], { timeoutMs: 300 }) with OAR_KILL_GRACE_MS=10000 returns before 300 ms + PIPE_CLOSE_MS, {ok: false, timeoutMs: 300}, with no cleanup.
  • The same, stopped by an AbortSignal at 300 ms: ABORT_ERR.
  • A fresh node process that only awaits probes at top level (the maintainer's exit-13 repro): a timed-out one, an aborted one, and one that ignores SIGTERM so that only the unref'd SIGKILL escalation ends it (OAR_KILL_GRACE_MS=300). It exits 0 with the three results.

All six round-3 tests that cover behaviour round 2 got wrong fail on round 2's run.ts, pipe-close.ts and process.ts. The for await one hangs, and the lone-probe one gets exit 13. The busy-reader-with-EOF test passes on both: it guards the new rule against cutting a pipe nobody holds.

tests/process-held-pipes-ownership.test.ts:

  • signalEntries with EPERM → { failed: 0, foreign: 1, codes: [] }.
  • A real host process with two sessions whose roots left holders: one holder stays; the other is killed and its root's number is then made to reach an unrelated sleep (a stand-in for pid reuse, which cannot be forced). After process.exit, the kept holder is gone and the unrelated process is alive. (B1, guidance 3)

tests/codex/codex-turn-processes.test.ts: an EPERM for some processes gives completed {signalled: 1, foreign: 1}, and EPERM for all gives completed {signalled: 0, foreign: 2} (B4). The failure-path tests inject EINVAL.

Checked against v1: with v1's packages/oar/src and these tests, 8 of the 10 process-held-pipes tests fail. The two EPERM tests that also passed on v1 cover behaviour v1 already had. The host-exit test fails on v1 (the unrelated process is killed), and the B4 tests fail on v1 because foreign is absent.

Validation

Local, Ubuntu 22.04 / Node 24.21, on origin/main 14348bd (rebased for round 3), with ~/.local/bin off PATH so no real runtime can start (only node, pnpm and npm linked in): pnpm run typecheck and pnpm run lint pass. CI=1 vitest run --maxWorkers=2: 545 files passed, 2 failed, 138 skipped; 5050 tests passed, 2 failed, 652 skipped. Neither failure comes from this patch. ci-runtime-scripts failed because npm was missing from the trimmed PATH; it passes with npm linked. installation-cache "a replaced executable is probed again" is flaky under load: it failed 2 of 5 runs alone on this branch and 3 of 6 on a base checkout. sea-trial and the aimock/native backends were not run locally; CI runs them. The cross-user repro (experiments/cross-user-kill/) is supplementary evidence from v1 (real second user, before 4015fb1 / after f98e4dd) and was not rerun; its README notes what the revision changes in that output.

For the maintainer to weigh

  • Holders are named only by process-group membership (see the finding above). A holder that left the group (the sudo worker's setsid tree, a claude Bash tool in a session of its own) is not named, but its pipes are still closed. Naming it would need sock_diag/ss -xp; I did not add an external tool dependency for a report field.
  • Group members are reported as "holders" even if a given member does not hold a pipe (one that redirected its output). The reason text says "left in the root's process group".
  • A pipe whose reader never takes its unread data is never closed by OAR, even when held. The cost: that fd stays open, and so does the 100 ms recheck interval (unref'd) until the pipe closes. exited still resolves. When the reader does take the data, a pipe closed then appears in diagnostics().cleanup.heldPipes, but not in the exited reason, which was already given.
  • opencode skills-v1 (stdout to a file, timeoutMs: 0, stderr a pipe): if something debug skill left behind holds only stderr for more than 2 s after the exit, the result is now OUTPUT_INCOMPLETE, so a complete catalog.json is reported as query_failed. Before this patch, the same case waited for as long as the holder lived. Failing is better than hanging; judging by the file alone would need a skills-specific exception, which I did not add.
  • OUTPUT_INCOMPLETE sets exitCode: null, as other failures in runExecutable do. The native exit code is not kept in the result.
  • The host-exit hook no longer group-kills an exited root's group after OAR closed its pipes. It kills only the identities seen at that moment, plus their descendants at exit. A process that joins the group later is not covered. Before, it would have been caught by kill(-pgid), at the cost of the B1 reuse risk.
  • One pending-cleanup closure per affected root (a few ProcessEntry records) stays for the host's life. It replaces the retained ChildProcess.
  • Abort with timeoutMs: 0 after the root has already exited: the 2 s wait that began at the exit is not restarted from the SIGKILL.
  • Still not changed: ACP reverse terminals (shared/acp/terminal.ts) and login processes, as in v1.

🤖 Generated with Claude Code

Follow-ups (non-blocking, from review round 3)

  • A pipe closed late (reader drained after exit) joins cleanup.heldPipes after exited resolved; exited.reason does not include it. The spec should say so plainly.
  • closeHeld reads the table before destroying, so a pipe reaching EOF during that read can still be listed; recheck isClosed after the read.
  • process-stop-settles bound (300 + PIPE_CLOSE_MS) is loose; about 1 s would catch smaller regressions.
  • A reader that never drains keeps the 100 ms recheck timer and the root in the ownership set (documented).

🤖 Generated with Claude Code

… after exit

A host that runs a runtime as another OS user (a `sudo -u` wrapper as
installation.command) makes OAR's direct child sudo, which it may
signal; everything below sudo is the worker's and answers OAR's signals
with EPERM. Measured with a real worker user and sudo 1.9.9:
signalEntries counted those EPERMs as failed signals, so codex's abort
cleanup reported a failure for processes that are not OAR's to stop; a
background process the runtime left kept its stdout open, so a session's
pipes stayed open for that process's life and a timed-out one-shot
command never returned. The pipe part holds for any background job, for
every runtime, same user included.

Signalling still starts with the direct child's group (SIGTERM first,
unchanged). A per-process EPERM is counted in SignalReport.foreign, not
in failed/codes, and codex's abort cleanup carries it as
SessionCleanup.foreign, so a cleanup that could not reach another
user's processes is not read as "all gone".

After the root's exit, OAR waits at most 2 s (PIPE_CLOSE_MS) for its
output pipes to close (POSIX; every runtime's session process and
runExecutable; for a stopped command, from the SIGKILL escalation). Past
that it closes its end of each pipe it is still reading, which only a
holder can keep open, named or not; a pipe with data its reader has not
taken yet (paused, or a busy `for await`) is left to it until it has,
then closed if still open. The wait only bounds: `close` still completes
a stopped command whenever every pipe is at EOF, so one that exits on
the SIGTERM returns at once, never on the unref'd kill grace.
cleanup.heldPipes and the exit reason give the pipes closed and the
processes left in the root's group; a failed table read makes the
cleanup unverified. runExecutable then fails with OUTPUT_INCOMPLETE
instead of returning truncated output as ok. OAR does not signal the
holders; the host-exit hook keeps them by identity (pid and start) and
no longer signals the exited root's pid or group by number, which may
have been reused. Windows is unchanged.

experiments/cross-user-kill reproduces the cross-user case with a real
second user (CI cannot sudo); tests/process-held-pipes*.test.ts and
tests/process-stop-settles.test.ts cover the same-user paths, including
pid reuse at host exit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@stamp-build
stamp-build Bot merged commit 3ccce9a into main Nov 18, 2026
22 checks passed
@stamp-build
stamp-build Bot deleted the agent/cindy/airwing-process-pipes branch November 18, 2026 19:06
stamp-build Bot added a commit that referenced this pull request Nov 18, 2026
…ing the holder read (#964)

<!-- stamp:review:v1 -->
<sup><img src="https://api.raft.build/api/avatars/pixel/bXVn.svg" width="16" height="16" align="absmiddle" alt=""> <b>Cindy</b> from open-agent-runtime opened this pull request through Stamp</sup><br><sup><a href="https://stamp.build/review?receipt=prc_f9d2c546495ae9a3ead800095721301a"><picture><source media="(prefers-color-scheme: dark)" srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg" width="13" height="12" align="absmiddle" alt=""></picture> View in Stamp →</a></sup>

---
<!-- /stamp:review:v1 -->

Contributed by builder (airwing) as a patch; opened by Cindy, who reviewed and verified it. The commit keeps their authorship.

Follow-ups to #963. These are the four items the maintainer listed, and nothing else.

## Changes

1. **Spec: a late-closed pipe is not in `exited.reason`** (`docs/spec/record-stream.md`). Sometimes OAR closes a pipe only after its reader has taken the unread data. That happens after `exited` has been emitted, so the pipe joins `cleanup.heldPipes` only. `exited.reason` never names it. The `LineProcess.exited` doc comment says the same.
2. **`closeHeld` re-checks `isClosed` after the process-table read** (`pipe-close.ts`). If a pipe closed during that read, OAR neither closes it nor reports it. If every pipe closed, `closeHeld` returns `undefined`: nothing is reported, nothing is owned, and `onLater` is not called.
3. **Tighter bound in `tests/process-stop-settles.test.ts`.** The limit is now `elapsedMs < 1000` (it was `300 + PIPE_CLOSE_MS`). The tests measure about 315 to 340 ms. They passed 10 times out of 10 in a row.
4. **A reader that never drains no longer keeps the recheck running or the root owned** (`pipe-close.ts`). `closeOnceTaken` used to recheck every 100 ms with no end, and the root stayed in the ownership set until its pipes closed. Now the recheck stops in either of two cases:
   - No pipe is still waiting: the reader took its data, or closed the pipe itself. As before, the child's `close` then removes the root from the ownership set.
   - `UNREAD_LIMIT_MS` (60 s) has passed. OAR stops looking and leaves the pipe to the reader. It reads the root's group and calls `ownLeftProcesses`, which removes the root from the ownership set and keeps the group's members by identity (pid and start). This is what already happens when OAR closes a pipe, so the host-exit hook never signals the root's group by number.

   A session has no common dispose hook for a `LineProcess`. Wiring one through every runtime would not be minimal, so the limit lives in `pipe-close.ts`.

## Tests

New file `tests/process-held-pipes-limits.test.ts` stubs the process table and `ownLeftProcesses` and uses `PassThrough` pipes. It checks four cases:
- A pipe that closes during the table read is left out of the report.
- When every pipe closes during the read, nothing is reported and nothing is owned.
- A paused reader that has not taken its data by the limit: the root's group is handed to `ownLeftProcesses` exactly once. When the reader resumes after that, OAR neither closes the pipe nor reports it.
- A reader that closes the pipe itself ends the recheck, and nothing is owned.

The first three fail on the code before this change.

- `pnpm typecheck`: pass.
- `pnpm lint`: pass.
- Process, executable, probe and codex turn-process suites: 35 files, 277 passed.
- Full `vitest run tests --maxWorkers=2`: 5053 passed, 1 failed. The failure is `installation-cache.test.ts › a replaced executable is probed again`. It is a timing flake: run alone it passed in 2 of 3 runs. Its cache key is dev/ino/size/mtime/ctime, and a file deleted and recreated within one timestamp tick can reuse the inode. This change does not touch that code.

No real-runtime suites were run.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: TennyZhuang <[email protected]>
@stamp-build stamp-build Bot mentioned this pull request Nov 19, 2026
stamp-build Bot added a commit that referenced this pull request Nov 19, 2026
<!-- stamp:review:v1 -->
<sup><img src="https://api.raft.build/api/avatars/pixel/bXVn.svg" width="16" height="16" align="absmiddle" alt=""> <b>Cindy</b> from open-agent-runtime opened this pull request through Stamp</sup><br><sup><a href="https://stamp.build/review?receipt=prc_9ca5c5e14797297ac929e3d33fabeeec"><picture><source media="(prefers-color-scheme: dark)" srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg" width="13" height="12" align="absmiddle" alt=""></picture> View in Stamp →</a></sup>

---
<!-- /stamp:review:v1 -->

Forking a saved session, Gemini quota notices with reset times on Antigravity, and bounded native queries. **One breaking change for hosts that consume the session view:** content that arrives outside a turn no longer joins a running turn (#953, below).

## Breaking: content outside turns stays outside them (#953)
Root text or tool updates can arrive after a native turn has ended, with no new start (Antigravity 1.5.10 and 1.5.11, an OpenCode own-reply sample). OAR used to show such a session as running indefinitely while there was no active turn to abort. Now the status fold keeps it idle with `activity: { since, lastEventAt }`, and the view keeps that content in its own message, `ViewMessage` `kind: "activity"`. A later prompt or verified native start opens a new turn without moving earlier activity into it. Late tool updates still amend their original entry, and process exit closes unresolved tools.
Consumers of `reduceSessionView` need a branch for `kind: "activity"` (type `ViewActivity`), and must replay a preceding start or a full checkpoint when they rebuild a running session.

## `SessionOptions.fork` (#888), feature
With `resume`, `fork` opens a new native session that starts as a copy of a saved one, optionally cut after a given turn (`fork.through`), and leaves the source untouched. `Session.id` is the copy's id (new type `SessionFork`). The root `turn_ended` event carries `forkAnchor` when the runtime has a usable cut point, and `reduceSessionView` puts it on `ViewTurn.forkAnchor`, so a host can offer "branch from here" without reading native frames.
- Claude: `--resume <source> --fork-session --session-id <new id>`, so OAR assigns the copy's id, with `through` as `--resume-session-at`. There is no `forkAnchor` on an aborted turn, or when the turn's last root assistant message holds a tool call or is followed by a tool result. `--fork-session` and, with a fork, `--resume-session-at` stay refused in `launchArgs`.
- Codex: `thread/fork` with `lastTurnId`; the copy's id is the thread id Codex returns. `through` needs codex 0.143.0 or later and is `runtime_outdated` before anything is sent on older versions or when Codex does not report its version. A Codex fork reports no token totals, because its total includes the source's turns.
- Every other runtime declares `fork` in `refusedSessionOptions` (new `RefusableSessionOption`).

## Antigravity: Gemini quota notices, whole-turn usage and credits (#982), fix
agy 1.5.12 can end a refused turn with a normal `end_turn` whose whole output is its "Individual quota reached ... Resets in 4h12m." notice. OAR now reports that turn as `failure: "quota"` with `resetsAt`, but only when the entire native output is that exact notice and the reply carries no usage; quoting the notice inside an answer stays `completed`. A prompt RPC error carrying the same sentence also supplies `resetsAt`. The reset has the precision of the smallest unit agy prints, so a retry at that time can still be refused.
- Token totals now come from the prompt reply, which covers every model call in the turn (two calls of 108 tokens report 216). Input is `totalTokens - outputTokens`, including cache reads; thought tokens count inside output; a reported zero cache write stays zero.
- When every model group is used up, the account snapshot now includes `credits` from agy's own `/credits` answer: `{ available, balance }`, with `balance` a decimal string. Absent means OAR did not ask or could not read a number.
- The antigravity page records that `usage_update.used` is the current context size on 1.5.12 with a real Gemini account (#981).

## Codex: quota reset times (#962), fix
Codex quota failures now carry `resetsAt` from the current turn's exhausted window when it is attributable to this session's root turn, and from the provider body preserved in a remote-compaction HTTP 400. Conflicting resets, child-thread activity and streamed failures that lost the body stay without one.

## Native queries are bounded and clean up after themselves (#978), fix
The shared query deadline now covers startup, the native read and cleanup. An owned child process tree is stopped even when startup finishes late; at the deadline the caller returns while shutdown finishes; a completed read keeps its value if only cleanup is slow. This fixes droid and its tools staying alive after `authStatus()` returned `unknown` against a stalled Factory peer, and the same ownership gap in several model and skill readers, including Cursor while its SDK subprocess starts. OpenCode model listing applies the deadline to its version probe too and rejects an invalid budget before starting. Login subprocesses get the same process-tree shutdown, and Antigravity `logout()` keeps a successful native logout when the status check after it fails.

## Process cleanup when a runtime runs as another user (#963, #964), fix
Contributed by builder (airwing). With a `sudo -u <worker>` wrapper as the runtime command, signalling the worker's processes gets `EPERM`. That is no longer a failed cleanup: Codex's abort cleanup reports those processes as `SessionCleanup.foreign`. On POSIX, OAR no longer waits forever for output pipes that a leftover background process holds open after the root exits: it closes its ends after 2 s and names them in the `exited` reason, leaves unread data to a busy reader, and stops watching after a further 60 s.

## `dispose()` after a native exit (#979), fix
If the native process exits on its own before the host calls `dispose()` (seen on Pi RPC), `dispose()` now resolves at once instead of never answering. Concurrent callers share one disposal.

## Claude: `userInvocable` only from the skill's own command (#950), fix
`true` now needs the skill's own entry in Claude's command list. A duplicated name, or a project skill shadowed by a builtin command, stays unknown, and `false` is claimed only for user and project settings skills.

## Also
- Docs: runtime pages and specs now keep what the code cannot say, and refer to the code for the rest (#971, #973, #977). Fork and turn-control refusals are complete on every page (#970, #972). An `OAR_<RUNTIME>_BIN` override is the only candidate when it is non-empty (#980). OpenCode v1 automatic compaction over ACP is documented (#969). Kimi docs match current adapter behaviour (#957). November 18 runtime version check recorded (#967).
- harbor, the long-run test host: channel rules travel in the appended system prompt, so they survive compaction (#968).
- CI: the Antigravity ACP baseline moves to 1.5.11 (#956). Tests: clearer diagnostics and fewer flakes for Antigravity, Kimi, Grok, Pi, shell children and startup refusals (#949, #951, #952, #954, #959, #960, #961, #966).
- README: dsh-engine-switch added to projects using OAR (#974).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Cindy <[email protected]>
Co-authored-by: xxchan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant