Repository navigation
oom(foundation): bound shared readers/limits + add BoundedMap primitive - #10299
Merged
Merged
Conversation
nwparker
force-pushed
the
oom/05-a5-shared-misc
branch
from
July 24, 2026 07:48
64ee51d to
f50920e
Compare
nwparker
force-pushed
the
oom/06-b-shared-wiring
branch
from
July 24, 2026 07:48
68c79b6 to
3cad51f
Compare
nwparker
force-pushed
the
oom/05-a5-shared-misc
branch
from
July 25, 2026 02:21
f50920e to
21bea06
Compare
nwparker
force-pushed
the
oom/06-b-shared-wiring
branch
from
July 25, 2026 02:21
3cad51f to
18835cd
Compare
nwparker
force-pushed
the
oom/05-a5-shared-misc
branch
from
July 25, 2026 02:39
21bea06 to
1085da2
Compare
nwparker
force-pushed
the
oom/06-b-shared-wiring
branch
from
July 25, 2026 02:39
18835cd to
7330bb7
Compare
nwparker
force-pushed
the
oom/05-a5-shared-misc
branch
from
July 25, 2026 03:10
1085da2 to
18ea52a
Compare
nwparker
force-pushed
the
oom/06-b-shared-wiring
branch
from
July 25, 2026 03:10
7330bb7 to
02ff993
Compare
Files: 18 applied, 0 deleted (from 6eb70d8) Co-authored-by: Orca <[email protected]>
Files: 7 applied, 0 deleted (from 6eb70d8) Co-authored-by: Orca <[email protected]>
Files: 21 applied, 0 deleted (from 6eb70d8) Co-authored-by: Orca <[email protected]>
Files: 8 applied, 0 deleted (from 6eb70d8) Co-authored-by: Orca <[email protected]>
Files: 28 applied, 0 deleted (from 6eb70d8) Co-authored-by: Orca <[email protected]>
Files: 81 applied, 0 deleted (from 6eb70d8) Co-authored-by: Orca <[email protected]>
nwparker
force-pushed
the
oom/05-a5-shared-misc
branch
from
July 25, 2026 03:34
18ea52a to
e73e980
Compare
nwparker
force-pushed
the
oom/06-b-shared-wiring
branch
from
July 25, 2026 03:34
02ff993 to
b4009ef
Compare
This was referenced Jul 25, 2026
brennanb2025
added a commit
that referenced
this pull request
Jul 25, 2026
…800MiB The filler colored per line, not per cell as its comment claimed, so the serialized seed only tracked plain-text size and needed 26k buffer rows to clear 16MiB. The xterm buffer costs rows x cols, which made this single file raise the whole src/main/daemon/ suite's peak RSS 5.2x (241MiB -> 1244MiB) — a real OOM risk on CI right after #10299 bounded readers for that reason. Carrying the bytes in SGR runs instead of rows reaches a larger seed from 5.5k rows: suite peak RSS 1244MiB -> 793MiB, and the margins improve too (seed 25.16MiB = 1.57x the threshold vs 1.19x before, checkpoint.json 46.1MiB = 2.88x vs 1.20x). Also makes the fixture match its own comment and be more representative of real colored agent output. Re-verified all three mutations still fail: cap at 16MiB -> "expected null not to be null"; endedAt gate deleted -> test 2 fails; writeSync unavailable -> both fail.
4 of 5 tasks
brennanb2025
added a commit
that referenced
this pull request
Jul 25, 2026
#10500) * test(terminal): pin checkpoint-only cold restore of a large checkpoint Triaging a report that checkpoint-only cold restore renders blank at every checkpoint size found no v1.4.156 regression: an A/B of v1.4.155 against origin/main returned byte-identical ColdRestoreInfo at 1.01, 5.56, 11.30 and 20.61 MiB, all 300 marker lines intact on both refs. Blankness tracks the meta.endedAt eligibility gate, not size — a cleanly ended session refuses to cold-restore at any size, which is by design and unchanged between the refs. What the triage did surface is a coverage gap. #10179's 16MiB checkpoint read cap sat under what the unbounded writer emits, so a large checkpoint threw, was swallowed to checkpoint=null, and the pane reopened empty; #10479 raised the cap but nothing pinned the round trip it had broken. history-reader-memory covers the bounded reader at its limit, not writer→reader recovery. Adds that round trip through the real HistoryManager writer and HistoryReader over a header-only log, and pins the endedAt gate that has now been mistaken for a size regression twice. Fails at the pre-#10479 cap with the exact production symptom (detectColdRestore returns null). * test(terminal): fail loudly when writeSync is unavailable writeLargeScrollback ignored writeSync's boolean, which is false when xterm's private _core.writeSync goes away. The size assertions catch that in the large-checkpoint test (416 bytes vs 16MiB), but the endedAt gate is size-independent, so that test silently passed on an empty snapshot — pinning the gate over no scrollback at all. * test(terminal): cut large-checkpoint fixture peak RSS from 1.2GiB to 800MiB The filler colored per line, not per cell as its comment claimed, so the serialized seed only tracked plain-text size and needed 26k buffer rows to clear 16MiB. The xterm buffer costs rows x cols, which made this single file raise the whole src/main/daemon/ suite's peak RSS 5.2x (241MiB -> 1244MiB) — a real OOM risk on CI right after #10299 bounded readers for that reason. Carrying the bytes in SGR runs instead of rows reaches a larger seed from 5.5k rows: suite peak RSS 1244MiB -> 793MiB, and the margins improve too (seed 25.16MiB = 1.57x the threshold vs 1.19x before, checkpoint.json 46.1MiB = 2.88x vs 1.20x). Also makes the fixture match its own comment and be more representative of real colored agent output. Re-verified all three mutations still fail: cap at 16MiB -> "expected null not to be null"; endedAt gate deleted -> test 2 fails; writeSync unavailable -> both fail. * test(terminal): tighten timeout, reuse prod dir-name helper, dispose first Review follow-ups, all test-only: - Import getHistorySessionDirName instead of hand-rolling encodeURIComponent. Equivalent today, but that helper exists to absorb encoding changes, so the hand-rolled copy would silently diverge from the writer it is checking. - Index FILLER_ROWS by its own length so growing the array cannot leave rows unused. - 300_000ms -> 60_000ms. The file runs in ~2.8s and vitest's own default is 30s; a 5-minute ceiling turns a hung regression into a stalled job rather than a failure. 60s keeps Windows headroom. - Take the snapshot, dispose, then checkpoint, so a throwing checkpoint() cannot leak the buffer. Note this is memory-neutral, not a saving: peak RSS is set at getSnapshot(), where the buffer and the serialized strings coexist, and measured ~800MiB either way. Mutations re-verified: cap at 16MiB -> "expected null not to be null"; endedAt gate deleted -> test 2 fails; writeSync unavailable -> both fail.
This was referenced Jul 25, 2026
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
…ve (stablyai#10299) * oom(01): A1-shared-readers — reintroduce stablyai#10179 subset Files: 18 applied, 0 deleted (from 925d4a7) Co-authored-by: Orca <[email protected]> * oom(02): A2-shared-image-media — reintroduce stablyai#10179 subset Files: 7 applied, 0 deleted (from 925d4a7) Co-authored-by: Orca <[email protected]> * oom(03): A3-shared-fs-listing — reintroduce stablyai#10179 subset Files: 21 applied, 0 deleted (from 925d4a7) Co-authored-by: Orca <[email protected]> * oom(04): A4-shared-remote-relay — reintroduce stablyai#10179 subset Files: 8 applied, 0 deleted (from 925d4a7) Co-authored-by: Orca <[email protected]> * oom(05): A5-shared-misc — reintroduce stablyai#10179 subset Files: 28 applied, 0 deleted (from 925d4a7) Co-authored-by: Orca <[email protected]> * oom(06): B-shared-wiring — reintroduce stablyai#10179 subset Files: 81 applied, 0 deleted (from 925d4a7) Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Orca <[email protected]>
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
stablyai#10500) * test(terminal): pin checkpoint-only cold restore of a large checkpoint Triaging a report that checkpoint-only cold restore renders blank at every checkpoint size found no v1.4.156 regression: an A/B of v1.4.155 against origin/main returned byte-identical ColdRestoreInfo at 1.01, 5.56, 11.30 and 20.61 MiB, all 300 marker lines intact on both refs. Blankness tracks the meta.endedAt eligibility gate, not size — a cleanly ended session refuses to cold-restore at any size, which is by design and unchanged between the refs. What the triage did surface is a coverage gap. stablyai#10179's 16MiB checkpoint read cap sat under what the unbounded writer emits, so a large checkpoint threw, was swallowed to checkpoint=null, and the pane reopened empty; stablyai#10479 raised the cap but nothing pinned the round trip it had broken. history-reader-memory covers the bounded reader at its limit, not writer→reader recovery. Adds that round trip through the real HistoryManager writer and HistoryReader over a header-only log, and pins the endedAt gate that has now been mistaken for a size regression twice. Fails at the pre-stablyai#10479 cap with the exact production symptom (detectColdRestore returns null). * test(terminal): fail loudly when writeSync is unavailable writeLargeScrollback ignored writeSync's boolean, which is false when xterm's private _core.writeSync goes away. The size assertions catch that in the large-checkpoint test (416 bytes vs 16MiB), but the endedAt gate is size-independent, so that test silently passed on an empty snapshot — pinning the gate over no scrollback at all. * test(terminal): cut large-checkpoint fixture peak RSS from 1.2GiB to 800MiB The filler colored per line, not per cell as its comment claimed, so the serialized seed only tracked plain-text size and needed 26k buffer rows to clear 16MiB. The xterm buffer costs rows x cols, which made this single file raise the whole src/main/daemon/ suite's peak RSS 5.2x (241MiB -> 1244MiB) — a real OOM risk on CI right after stablyai#10299 bounded readers for that reason. Carrying the bytes in SGR runs instead of rows reaches a larger seed from 5.5k rows: suite peak RSS 1244MiB -> 793MiB, and the margins improve too (seed 25.16MiB = 1.57x the threshold vs 1.19x before, checkpoint.json 46.1MiB = 2.88x vs 1.20x). Also makes the fixture match its own comment and be more representative of real colored agent output. Re-verified all three mutations still fail: cap at 16MiB -> "expected null not to be null"; endedAt gate deleted -> test 2 fails; writeSync unavailable -> both fail. * test(terminal): tighten timeout, reuse prod dir-name helper, dispose first Review follow-ups, all test-only: - Import getHistorySessionDirName instead of hand-rolling encodeURIComponent. Equivalent today, but that helper exists to absorb encoding changes, so the hand-rolled copy would silently diverge from the writer it is checking. - Index FILLER_ROWS by its own length so growing the array cannot leave rows unused. - 300_000ms -> 60_000ms. The file runs in ~2.8s and vitest's own default is 30s; a 5-minute ceiling turns a hung regression into a stalled job rather than a failure. 60s keeps Windows headroom. - Take the snapshot, dispose, then checkpoint, so a throwing checkpoint() cannot leak the buffer. Note this is memory-neutral, not a saving: peak RSS is set at getSnapshot(), where the buffer and the serialized strings coexist, and measured ~800MiB either way. Mutations re-verified: cap at 16MiB -> "expected null not to be null"; endedAt gate deleted -> test 2 fails; writeSync unavailable -> both fail.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Shared bounded-memory foundation (slices 03–06 of the #10179 re-land)
Re-lands the
src/sharedlayer of #10179 ("bound OOM-prone accumulators", reverted in #10255 for size) as one atomic PR, plus a new reusable primitive.Why one PR: these modules are mutually coupled — the new bounded readers depend on types/budgets that the wiring commit modifies, whose own tests depend on the readers. No slice ordering makes them individually CI-green, so splitting them further would only produce PRs that cannot pass CI. Slices 01–02 (pure additive primitives) already merged separately as #10294 / #10295.
What's in it
BoundedMap— a new count- and byte-bounded LRU primitive (src/shared/bounded-map.ts), replacing hand-rolled "Map + counter + byte ledger + evict-oldest" copies. Three call sites migrated onto it (secure-path-hardening-cache,github/conflict-summary-cache,runtime/orca-runtime); both duplicatesetBoundedMapEntryhelpers are deleted.BoundedMapcontract (documented in-file, each clause tested)set()never reports success for an entry it did not retain · weights must be non-negative safe integers · an unmeasurable or throwingsizeOffails closed (entry rejected, ledger intact — never crashes a relay on someone else's machine) ·maxEntryBytesis clamped tomaxBytes·keys()/values()/entries()return snapshots so a touching read during traversal terminates (peek()reads without reordering) ·onEvictfires only for capacity eviction, only after both bounds are restored, and one throwing hook cannot skip the others.Verification
BoundedMapunit tests (exact-limit + limit+1, LRU order, NaN-key protection, safe-integer boundary, non-destructive rejection, reentrant/throwing disposal).git/status.test.tsandImageViewer.test.tsxhad been split from the sources they cover.Review
Adversarially reviewed over three rounds (fable-xhigh + gpt-5.6-sol-xhigh, every claim verified by reproduction). Round 1 found 3 real defects, round 2 found 4 more, round 3 returned zero adopter-reachable findings — all fixed here.
Two further primitives (
AdmissionController,BoundedQueue) were deliberately dropped: they had no callers and review showed each was mis-shaped for the site it named (withAdmissionis lexical-only and would have released the watcher's cross-IPC claim too early;BoundedQueue'sshift()storage hits a V8 cliff at ~16k, right at the 16,384 PTY span cap). They return when a real adopter shapes them.OSS alternatives evaluated and rejected: installed
lru-cache@11requires node ≥20 while the relay bundles atnode18; it throws on a zerosizeCalculation(count-only is our most common mode), silently refusesundefinedvalues, and — verified by probe — produces a negativecalculatedSizeunder a config it accepts.🤖 Decomposed, reviewed & assembled by Claude Code from the reverted #10179.