Skip to content

test(cleanup): drain expired reads before the next cancellation control - #595

Merged
stamp-build[bot] merged 1 commit into
mainfrom
agent/otter/cancel-queue-control
Nov 1, 2026
Merged

stamp-build[bot] merged 1 commit into
mainfrom
agent/otter/cancel-queue-control

Conversation

@stamp-build

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

Copy link
Copy Markdown
Contributor

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


The cancellation queue regression waited for background preparation, then started its second turn while the first timed-out caller could still have a foreground query running. That second cancellation could also spend its one-second budget in the queue, leaving its tool unverified instead of exercising the intended successful fresh observation. The Windows failure in run 41314773914 reported two observation timeouts; it did not retain caller timestamps, so their exact queue durations are not known.

Keep the expired foreground read pending for two seconds in the negative control and await its completion before starting the next turn. Both queries still read the real process table. Assert each cancellation's actual observation result and include caller request/return times alongside query start/finish times in failures. The first turn must still leave its tool unverified, and the second must capture and reclaim its own tool. Product behavior and the one-second cancellation observation budget are unchanged.

Validation: the delayed read reproduces the original assertion failure with the old ordering, and both controls pass with the wait. Removing the wait again makes the regression fail; the mutation was restored. CI=1 pnpm run check passed: type checking, lint, 2,949 tests and 18 mock behavior cases. The amended fixture still requires Windows/macOS confirmation in PR CI.

@stamp-build
stamp-build Bot merged commit 8b8e985 into main Nov 1, 2026
36 checks passed
@stamp-build
stamp-build Bot deleted the agent/otter/cancel-queue-control branch November 1, 2026 14:45
stamp-build Bot added a commit that referenced this pull request Nov 1, 2026
<!-- stamp:review:v1 -->
<sup><img
src="https://cdn.slock.ai/avatars/6aabf32c-20bc-4cba-b55a-2aa72b60999b/8ba4452ceb890f1930886ef4286fdb99.webp"
width="16" height="16" align="absmiddle" alt=""> <b>Otter</b> from
open-agent-runtime opened this pull request through
Stamp</sup><br><sup><a
href="https://stamp.build/review?receipt=prc_6729fcef36ba34b6a3aa44fda20ef78b"><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 -->

A cancellation can spend its one-second observation budget waiting
behind Windows process-table preparation. Previously, its queued read
still started after the caller had timed out. A later cancellation then
waited behind that unwanted read and needed another fresh query, which
could consume its own budget too.

Pass each caller's existing deadline on the `performance.now()` clock
into the internal batcher. At query start, discard expired callers and
skip an empty batch. Choose foreground/background handles from the
remaining callers. Requests without a deadline remain live; an
already-started query continues under its existing limit. The caller
still rejects results delivered at or after its deadline, even when its
timer callback has not run. No public API, observation budget, retry,
PID identity check or signalling rule changes.

This also applies the existing five-second preparation budget before a
queued preparation begins. A background request without a deadline still
runs. Skipped batches are removed before their result settles, so a
later request receives a new observation rather than the skipped result.
The spec documents these boundaries. This removes avoidable queue work;
it does not promise success when an active query or the next OS read
itself is slow.

Validation:

- Fifteen deadline regressions cover all-expired and mixed callers, late
arrivals, unbounded background requests, foreground handle ownership,
skipped-batch settlement, real preparation's existing budget, exact
deadline boundaries, wall-clock changes and rejection of late identity
evidence. The original implementation failed the new expiry/ownership
controls.
- The real ACP/process-table regression no longer waits for the expired
read between turns. Its first observation still times out and leaves its
tool unverified; its second observation succeeds and disposal reclaims
that turn's tool. An unwanted read is deliberately delayed so a
regression cannot hide behind a fast local query.
- Removing expiry filtering, the post-read deadline guard or serial
ordering each caused the relevant tests to fail. Mutations were
restored.
- `CI=1 pnpm run check`: type checking, lint, 2,964 tests and 18 mock
behavior cases passed. Build and all fourteen behavior backends passed
locally, using explicit CI-version binary paths and required
availability. The new controls also passed on Windows and macOS in PR
CI.
- All 35 PR checks passed. Windows check required one rerun after the
installer smoke test's temporary-directory cleanup threw `ENOTEMPTY` and
hid the installation result; the unchanged retry installed CodeBuddy
2.179.1 successfully. Preserving the primary result during cleanup is
tracked as a separate follow-up.

Task #148; follows the fixture-only fix in
[#595](#595).

Co-authored-by: Otter <[email protected]>
@stamp-build stamp-build Bot mentioned this pull request Nov 2, 2026
stamp-build Bot added a commit that referenced this pull request Nov 2, 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_1fb2c3e99ea3c8907bcc12da1ca1dd98"><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 -->

Minor release: Cursor's optional peer moves to `@cursor/sdk` 1.2.0 and Cursor sessions now report native compaction. A cancellation no longer waits behind a queued process-table read nobody is waiting for (all platforms; most visible on Windows, where reads are slow).

## Behavior changes for hosts

### Cursor SDK 1.2.0 and native compaction (#509)
- The optional peer is now exactly `@cursor/sdk` 1.2.0 (was 1.1.0), and `@botiverse/oar-cli` depends on 1.2.0. A host that hands the SDK to `createCursorRuntime({ sdk: () => import("@cursor/sdk") })` must install 1.2.0. Hosts that do not use Cursor are unaffected.
- Cursor sessions emit the existing `compaction_started` and `compaction_ended` events from the SDK's `run.stream()` summary status: `running` starts, `completed` ends `completed`, `error` ends `failed`. Cursor reports no trigger or reason. A run aborted without a final summary records no compaction end, and a summary error does not change the turn's outcome. No new event type or manual compaction control.
- Every `run.stream()` message is also recorded verbatim as a `cursor/stream/<type>` frame. Only summary statuses add events, so text, tools and usage are still counted once.
- The exported `CursorSdk` type's run now has `stream()`. A host that passes its own SDK object or test double typed as `CursorSdk` must implement it.
- After `run.wait()` settles, the stream gets two seconds to drain. If it stays open, OAR records a `cursor/stream_unclosed` frame, stops reading it and ends the turn normally; late values cannot enter a later turn. A stream failure is recorded as `cursor/stream_failed` with the message redacted like Cursor login diagnostics.

### Process-table reads for expired callers (#596, #597)
- A queued process-table read whose callers have all reached their deadline is skipped instead of run. The batcher serves every platform: the one-second cancellation observation has a deadline everywhere, and on Windows so do the five-second capture, revalidation and background preparation reads. Before, an abandoned read could hold the queue, so a second cancellation shortly after the first could spend its one-second observation budget waiting and leave its tool cleanup unverified. A read already started still completes, and a late result still never counts as identity evidence for a caller that timed out. A request without a deadline always runs. Windows background preparation's existing five-second budget now also covers time spent queued: if it expires before the read starts, the read is skipped and preparation records a timeout.
- A failure while starting a queued read no longer leaves the read in the queue.

### Grok explicit shared placement (#585)
- The refusal message for an explicit `shared` request on `grokRuntime` changed; it is still `UnsupportedOptionError` with `option: "placement"` on every version and platform. Match on `option`, not on the text. The experimental Grok shared adapter added here is internal and unreachable from `grokRuntime` (`auto` stays isolated); only the composition under `experiments/sharing`, where its evidence lives, enables it.

## Docs
- Weekly maintenance pass (#598, #599, #600, #601): spec tables, the package README and runtime pages now cover Qwen, Qoder and CodeBuddy where they were missing, and statements that had drifted from the code are corrected (steer, `withdraw`, `resources()`, login and status coverage, Claude and Codex details, Kimi status and login floor). All pages state that no native runtime is admitted to shared placement.
- Qwen's runtime page documents how Qwen renames reused tool-call ids and suppresses identical replays (#590, #592).

## Tests and CI
- CodeBuddy CI pin 2.179.1 and Qwen 0.26.5 verification (#590); Qwen tool-call id regressions (#592); interrupt tests separated from forced-exit timing (#591); the cancellation-queue regression waits out its expired read before the next control (#595); CodeBuddy installation smoke keeps its result when temporary-directory cleanup fails (#597); pnpm `autoInstallPeers` set in `pnpm-workspace.yaml` and the stale `.npmrc` removed (#594); Grok shared-adapter tests respect the candidate's platforms (#602).

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

Co-authored-by: Cindy <[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.

0 participants