Repository navigation
fix(crash-reporting): preserve coalesced repeat accounting - #14666
Conversation
📝 WalkthroughWalkthroughThe breadcrumb store now uses monotonic time and tracks carried, resolved, and unresolved suppression counts. Emissions claim only unresolved repeats. Snapshot resolution checks whether the breadcrumb remains visible. Cleanup materializes unresolved repeats when the breadcrumb becomes unavailable. Tests cover time jumps, data-less folding, re-emissions, snapshot folds, ring eviction, snapshot-budget limits, unrelated cleanup, LRU eviction, and timer isolation. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/crash-reporting/crash-breadcrumb-store.ts (1)
119-128: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy liftPreserve orphaned repeats before deleting the coalesced state.
Lines 184-187 leave repeats unresolved when the crumb is no longer in snapshot evidence. Lines 119-128 and 142-148 then delete that state during expiry or LRU cleanup.
A later event with the same
coalesceKeyhas nopreviousstate. It emits withsuppressedSinceLast: 0, so the unresolved repeats are lost.Keep orphaned repeat state until the next same-key emission, or emit a new visible fallback breadcrumb before cleanup deletes the state. Add coverage for both expiry cleanup and
MAX_COALESCE_KEYSeviction after ring or snapshot-budget eviction.Also applies to: 142-148, 184-187
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: bbf0b5e7-b3a7-4acf-a203-3073cfcbe550
📒 Files selected for processing (2)
src/main/crash-reporting/crash-breadcrumb-store.test.tssrc/main/crash-reporting/crash-breadcrumb-store.ts
2370cd2 to
4f6f0f5
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/crash-reporting/crash-breadcrumb-store.test.ts (1)
336-338: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueReduce repeated test narration.
The test names and assertions already define these scenarios. Replace necessary rationale with one concise line. Remove comments that only restate the test flow.
src/main/crash-reporting/crash-breadcrumb-store.test.ts#L336-L338: reduce to one line about avoiding double-counting snapshot-resolved repeats.src/main/crash-reporting/crash-breadcrumb-store.test.ts#L364-L365: remove or reduce to one line about counting only new repeats.src/main/crash-reporting/crash-breadcrumb-store.test.ts#L374-L375: reduce to one line about preserving carried counts.src/main/crash-reporting/crash-breadcrumb-store.test.ts#L402-L405: reduce to one line about ring-evicted breadcrumbs.src/main/crash-reporting/crash-breadcrumb-store.test.ts#L435-L437: reduce to one line about snapshot-budget exclusion.src/main/crash-reporting/crash-breadcrumb-store.test.ts#L459-L460: reduce to one line about the retained-slot budget.src/main/crash-reporting/crash-breadcrumb-store.test.ts#L471-L472: reduce to one line about immutable snapshots.src/main/crash-reporting/crash-breadcrumb-store.test.ts#L501-L502: reduce to one line about fresh-window repeat counts.As per coding guidelines, “Comments must be concise, non-obvious, and brief—prefer one line.”
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d958f645-daba-4f63-9fad-f8402c4a26b3
📥 Commits
Reviewing files that changed from the base of the PR and between dcbfbab and 4f6f0f5d31cc5c7843124f0dbe91912deceb7cc4.
📒 Files selected for processing (3)
src/main/crash-reporting/crash-breadcrumb-store-orphan-cleanup.test.tssrc/main/crash-reporting/crash-breadcrumb-store.test.tssrc/main/crash-reporting/crash-breadcrumb-store.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/crash-reporting/crash-breadcrumb-store.ts
Electron launch-smoke (exact head
|
4f6f0f5 to
03a3c73
Compare
Electron launch-smoke (exact head
|
b93da7e to
d760fec
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
d760fec to
5f14e7b
Compare
Electron launch-smoke (exact head
|
5f14e7b to
0a21167
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 91b59451-4f9c-4bb0-99b7-80138c44b2bf
📥 Commits
Reviewing files that changed from the base of the PR and between 516a269 and 0a21167592c79ec63f92ef90d97a88f03763659b.
📒 Files selected for processing (4)
src/main/crash-reporting/crash-breadcrumb-store-orphan-cleanup.test.tssrc/main/crash-reporting/crash-breadcrumb-store.test.tssrc/main/crash-reporting/crash-breadcrumb-store.tssrc/main/crash-reporting/process-gone-recorder.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/main/crash-reporting/process-gone-recorder.test.ts
- src/main/crash-reporting/crash-breadcrumb-store.ts
- src/main/crash-reporting/crash-breadcrumb-store.test.ts
Included review availability: Your plan includes up to 10 reviews per rolling hour; 1 remains after this review.
| for (let index = 0; index < 30; index += 1) { | ||
| recordCrashBreadcrumb(`renderer_error_${index}`, { index }) | ||
| } | ||
| getCrashBreadcrumbSnapshot() |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Do not resolve the orphan before cleanup.
getCrashBreadcrumbSnapshot() resolves pending coalesced breadcrumbs before it builds the snapshot. These calls can materialize the repeats before the expiry or LRU trigger runs. The tests can then pass if cleanup does not preserve orphaned repeats.
Remove these snapshot calls. Take the snapshot only in the expectation helper.
Proposed fix
function orphanFromRing(): void {
for (let index = 0; index < 30; index += 1) {
recordCrashBreadcrumb(`renderer_error_${index}`, { index })
}
- getCrashBreadcrumbSnapshot()
}
function orphanFromSnapshotBudget(): void {
// ...
- getCrashBreadcrumbSnapshot()
}Also applies to: 54-54
Electron launch-smoke (exact head
|
Two ways one burst's suppressed repeats were misattributed in forensics, found across two adversarial review loops on the sibling-correlation work but pre-dating it (the coalesce machinery shipped in #8800/#5818/#10729): - Double-claim: a crash report filed mid-window snapshots the ring, folding the suppressed repeats into the emitted crumb — but the next emit still re-claimed those repeats in its suppressedSinceLast, reporting one burst twice across two crumbs. - Mirror erasure: a fold resolving onto a re-emitted crumb overwrote the count that crumb was born carrying, deleting the previous window's repeats. Track what each crumb has claimed (carried at emit, resolved by folds) so every repeat is attributed exactly once. And never resolve into an evicted crumb: when a storm pushes the burst crumb out of the 30-entry ring — or past the retained-slot snapshot budget — mid-window, folding there would mark the repeats claimed by evidence no snapshot can see and the burst would vanish from the record entirely; drop the handle so the next emit claims them instead. Semantic note for trace-mirroring consumers: the returned suppressedSinceLast is now net of already-folded repeats, so exactly-once holds over the union of trace spans and report snapshots rather than within the trace stream alone.
0a21167 to
2693c19
Compare
Electron launch-smoke (exact head
|
* fix(crash-reporting): attribute coalesced repeats exactly once Two ways one burst's suppressed repeats were misattributed in forensics, found across two adversarial review loops on the sibling-correlation work but pre-dating it (the coalesce machinery shipped in #8800/#5818/#10729): - Double-claim: a crash report filed mid-window snapshots the ring, folding the suppressed repeats into the emitted crumb — but the next emit still re-claimed those repeats in its suppressedSinceLast, reporting one burst twice across two crumbs. - Mirror erasure: a fold resolving onto a re-emitted crumb overwrote the count that crumb was born carrying, deleting the previous window's repeats. Track what each crumb has claimed (carried at emit, resolved by folds) so every repeat is attributed exactly once. And never resolve into an evicted crumb: when a storm pushes the burst crumb out of the 30-entry ring — or past the retained-slot snapshot budget — mid-window, folding there would mark the repeats claimed by evidence no snapshot can see and the burst would vanish from the record entirely; drop the handle so the next emit claims them instead. Semantic note for trace-mirroring consumers: the returned suppressedSinceLast is now net of already-folded repeats, so exactly-once holds over the union of trace spans and report snapshots rather than within the trace stream alone. * fix(crash-reporting): preserve orphaned repeat debt on cleanup * fix(crash-reporting): preserve data-less repeat debt * fix(crash-reporting): make coalescing window monotonic
…14666) * fix(crash-reporting): attribute coalesced repeats exactly once Two ways one burst's suppressed repeats were misattributed in forensics, found across two adversarial review loops on the sibling-correlation work but pre-dating it (the coalesce machinery shipped in stablyai#8800/stablyai#5818/stablyai#10729): - Double-claim: a crash report filed mid-window snapshots the ring, folding the suppressed repeats into the emitted crumb — but the next emit still re-claimed those repeats in its suppressedSinceLast, reporting one burst twice across two crumbs. - Mirror erasure: a fold resolving onto a re-emitted crumb overwrote the count that crumb was born carrying, deleting the previous window's repeats. Track what each crumb has claimed (carried at emit, resolved by folds) so every repeat is attributed exactly once. And never resolve into an evicted crumb: when a storm pushes the burst crumb out of the 30-entry ring — or past the retained-slot snapshot budget — mid-window, folding there would mark the repeats claimed by evidence no snapshot can see and the burst would vanish from the record entirely; drop the handle so the next emit claims them instead. Semantic note for trace-mirroring consumers: the returned suppressedSinceLast is now net of already-folded repeats, so exactly-once holds over the union of trace spans and report snapshots rather than within the trace stream alone. * fix(crash-reporting): preserve orphaned repeat debt on cleanup * fix(crash-reporting): preserve data-less repeat debt * fix(crash-reporting): make coalescing window monotonic


ELI5
When the same crash-related event fires rapidly, Orca doesn't write every occurrence —
it writes one entry plus a "repeated N times" count. Those counts are evidence: crash
investigations lean on them to tell one burst from two.
The bookkeeping had two bugs. If a crash report happened to be filed in the middle of a
burst, the report took a snapshot that included the pending repeats — and then the
normal path counted the same repeats AGAIN into the next entry, so one burst read as
two. Separately, when repeats were folded onto an entry that had itself been re-emitted
with a count, the fold overwrote the count the entry was born carrying — deleting a
window's worth of repeats from the record.
The first fix introduced a third bug worse than either: during a crash storm busy enough
to push the target entry out of the ring, the fold landed on a dead object and marked the
repeats resolved, so the burst vanished from every artifact. The reachability guard
stopped that zero-count regression, but review found one more escape hatch: TTL or LRU
cleanup could delete the deliberately unresolved state before the key emitted again.
The cleanup repair materializes only that unclaimed debt into the bounded ring before
cleanup drops the state.
Loop 2 closed the same cleanup hole for data-less breadcrumbs, where "no payload"
had been mistaken for "no pending repeat."
A cross-lane review then found that the 30-second suppression window used the wall clock.
A backward correction could stretch suppression indefinitely, while a forward correction
could collapse it early. The window now measures monotonic elapsed time; forensic ISO
timestamps remain wall-clock metadata.
What Changed
Four commits, four files (+481/−21), all in the durable breadcrumb store and its focused
tests — the path every coalesced breadcrumb producer routes through:
so the emit path no longer re-counts them into the next crumb.
that crumb was born carrying instead of overwriting it.
snapshot budget before resolving. Unreachable repeats remain unclaimed for the next
emit; if unrelated TTL or LRU cleanup arrives first, it materializes only the unclaimed
repeats into a fresh bounded-ring crumb before deleting the state.
count, so cleanup cannot mistake missing data for missing debt.
forward or backward system-clock corrections cannot shorten or extend the 30-second window.
Why
The durable breadcrumb store's repeat counts are forensic evidence — the crash sweep's
analyses read them as ground truth for how often something fired. The original defects
either inflated a burst into two or erased a window's repeats. The initial orphan guard
still allowed the same erasure when unrelated cleanup deleted the unresolved state; the
new cleanup handoff closes that final path without retaining unbounded tombstones.
Trade-offs
All three stated plainly:
earlier snapshot, and orphan-cleanup materialization emits no span. Report snapshots
are cumulative immutable views, while emitted breadcrumbs are mirrored into spans;
spans plus snapshots, or multiple snapshots, overlap by design and must not be summed
as disjoint counts. Span-only rate analytics can miss snapshot-owned counts.
ipc/crash-reporting.ts:185: if the renderer-errorstore.recordrejects, the already-folded snapshot dies with it and those counts canno longer resurface via emit re-claim. This is disk-failure-only; a transactional
unwind would couple the store to report-persistence outcomes across modules, judged
disproportionate to the failure mode.
agent_state_changedinindex.ts, pr-refresh-validation-backoff, pr-refresh-coordinator, IPC renderer
breadcrumbs, durable-crash-breadcrumb). Three ignore the return value. Two mirror
real emits into trace spans; rare orphan-cleanup materialization remains breadcrumb
evidence and does not add a forced trace flush.
Linked Issue
No tracked GitHub issue exists for this work — it originates from the #orca-crashes
field sweep of 2026-08-13/14. The defects were found while reviewing the sibling
external-kill-correlation branch (whose durable audit breadcrumbs depend on these counts
being exact) and split out on that reviewer's recommendation.
PR #14667 intentionally remains store-free and depends on this PR landing first. It is
blocked on this monotonic-window guarantee because its durable defer-time breadcrumbs route
through this store.
Visual Proof
No rendered interaction change. Grok's Electron/CDP launch smoke is attached in
#14666 (comment); unit-level accounting
evidence is the acceptance signal for this main-process-only change.
Testing
Post-rebase branch HEAD, one single-file Vitest invocation at a time: 102/102 across
13 focused files: store 21, orphan cleanup 6, bounded-map leak 3, six upstream-split PR
refresh coordinator shards 35, PR validation backoff 3, IPC renderer breadcrumbs 18,
durable breadcrumbs 3, and process-gone recorder 13.
Clock mutation: replacing only the monotonic source with
Date.now()yields2 failed | 19 passed: backward correction suppresses the required emit and forwardcorrection emits early. Restoring
performance.now()yields21 passed.The cleanup blocker is pinned as a four-case matrix: TTL expiry and LRU eviction
after both full ring eviction and retained-slot snapshot-budget orphaning.
Partial claims are pinned: cleanup materializes only repeats not
already folded into an earlier snapshot, and a later key emit starts with zero debt.
tsc --noEmit -p config/tsconfig.node.json, targetedoxlint, targetedoxfmt --check,and
git diff --checkpass after rebasing onto currentorigin/main.The earlier 38-mutant battery predates the cleanup fix and is not claimed as validation
for the new path; the focused regressions above replace the previously documented LRU
survivor assumption that this review disproved.
I manually tested these changes locally — not applicable to a main-process-only
accounting fix; no live crash storm was induced.
Automated tests added/updated, or explained why not below
AI Disclosure
Adversarial Review
Earlier review loops on the sibling work found the original double-claim and the first
fix's zero-evidence orphan, which led to splitting this store change into its own PR.
Adversarial review loop 1 on this PR then reproduced the remaining TTL/LRU state-deletion
blocker, added the four cleanup/orphan regressions plus a partial-claim debt-transfer case,
and drove the bounded materialization fix that now ships.
Adversarial review loop 2 then caught the optional-data contract hole in that cleanup
path, added data-less fold/orphan regressions, and clarified that immutable report
snapshots and their mirrored trace spans overlap by design.
Adversarial review loop 3 was reopened by a cross-lane clock finding, drove the monotonic
window plus backward/forward regressions and producer test-seam correction, and returned
CLEAN on the final diff.
Review
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH,
Mobile, general backwards compatibility, performance
existing sanitizer before entering evidence.
performance.now()provides per-processmonotonic elapsed time on every target; no platform-conditional path is added.
accounting remains local main-process state with no path, Git, or wire-format change.
attribution changes. Span-only rate analytics retain trade-off (1).
map at 4. Each call replaces one wall-clock read with one monotonic-clock read; steady
suppression still allocates nothing new, and only rare orphan cleanup performs one
sanitized ring write before deleting the state.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover;local preferred) — focused lint/format, node typecheck, and tests pass locally;
full commands were not run and are left to CI.
Author