Skip to content

fix(crash-reporting): stop post-mortem process metrics crowning a survivor as the crasher - #14662

Merged
brennanb2025 merged 11 commits into
mainfrom
brennanb2025/crash-renderer-metrics-postmortem
Aug 16, 2026
Merged

brennanb2025 merged 11 commits into
mainfrom
brennanb2025/crash-renderer-metrics-postmortem

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​684 $\color{#cf222e}{\Huge{\mathbf{−}}}$​32 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​652
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​315 $\color{#cf222e}{\Huge{\mathbf{−}}}$​55 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​260

ELI5

When an Orca process crashes, Electron reports the event after that process has already left its process list. The existing crash record therefore describes surviving processes only, which can make a survivor look like the process relevant to the crash.

This PR keeps a recent, whole-app process snapshot and writes it beside the post-gone snapshot. It deliberately does not guess which cached row was the crasher: Electron's gone events do not include a PID, so every cached snapshot carries an explicit attribution-ambiguity flag.

What Changed

  • Starts one unref'd 60-second main-process sampler, with an immediate first sample.
  • Emits the cached whole-app snapshot under processMetricsPreGone*, plus processMetricsPreGoneSampleAgeMs.
  • Emits processMetricsPreGoneCrashedProcessAttributionAmbiguous: true whenever a cached snapshot is present.
  • Keeps existing plain processMetrics* fields as the post-gone, survivors-only snapshot.
  • Uses Electron's documented (pid, creationTime) process identity when checking whether a sampled process from the crashed bucket disappeared, including same-PID/same-bucket reuse.
  • Adds renderer-wide peak working-set and private-byte maxima when Electron supplies them.
  • Adds system-memory fields sampled while building the gone record.

Exact Telemetry Semantics

  • processMetricsLargest* is the largest process in the post-gone snapshot and may be a survivor.
  • processMetricsPreGoneLargest* is the largest process in the entire cached snapshot and may also be a survivor.
  • processMetricsPreGoneRendererWorkingSetMB is the sum across all cached renderer/Tab processes.
  • processMetricsPreGoneRendererPeakWorkingSetMB and ...PrivateMB are maxima across all cached renderer/Tab processes.
  • No PreGone* field identifies the crashed process. processMetricsPreGoneCrashedProcessAttributionAmbiguous: true is the machine-readable boundary.
  • processMetricsCrashedProcessAbsent is a stateless absence signal: the gone-time bucket is empty, or a sampled same-bucket (pid, creationTime) identity is no longer present. Missing creation time degrades conservatively rather than claiming same-bucket PID replacement.
  • systemMemory* is sampled after Electron reports the process gone. Released memory can make free/swap-free look healthier than it was when the process exited; these fields are not crash-instant measurements.

Why

Field reports consistently showed renderer-gone records with the dead renderer missing from app.getAppMetrics(). A periodic snapshot restores useful before/after context, but a multi-renderer counterexample sets the contract boundary: a 300 MB renderer can die while a surviving 4.38 GB Tab owns cached Largest, peak, and private fields, and the renderer total is their 4.68 GB sum.

There is no more precise stateless implementation available from Electron's event payload. Per-crasher attribution would require new correlation/state machinery and would still be ambiguous across unrelated closes, crash loops, and processes born between samples, so this PR keeps the snapshot honest instead.

Trade-offs

  • With successful sweeps, the cached snapshot is normally up to 60 seconds old. Failed sweeps retain the last good sample, so it can be older; SampleAgeMs reports the actual staleness.
  • A process born and gone inside one interval may never appear in the cache.
  • A sweep during the blind period after death can replace the cache with a survivor-only snapshot; that zero/empty shape is preserved rather than attributed to a later crash.
  • Crash-loop records can reuse one cached era, but the ambiguity marker prevents interpreting it as a later crasher's metrics.
  • On macOS, Electron exposes total/free/file-backed/purgeable memory but no swap fields, and post-release free memory cannot confirm memory pressure. Windows/Linux swap fields are emitted when supplied.

Performance Review

The sampler adds one app.getAppMetrics() call at startup and once per 60 seconds. Work and retention are O(current Electron process count), the cache replaces one bounded snapshot rather than accumulating history, failed sweeps retain the last good sample, and the timer is unref'd. The existing real-Electron measurement for this branch was roughly 100 microseconds per process (about 3-6 ms for a heavy process tree), or approximately 0.005-0.01% duty at this interval.

Safety and Compatibility Review

  • Security: numeric process/system metrics only; creationTime is used internally and is not emitted. No new input, IPC, filesystem, or network surface.
  • macOS / Windows / Linux: creationTime is part of Electron's cross-platform ProcessMetric contract; optional platform memory fields are omitted rather than zero-filled.
  • SSH / folder workspaces / mobile: unaffected; collection belongs to the local Electron main process and assumes neither a git worktree nor a remote host.
  • Wire / provider compatibility: no RPC, stream, Git, or provider contract changes.
  • Backwards compatibility: additive fields only; existing plain-prefix field meanings are unchanged.
  • Startup: sampling begins after app.whenReady() and before process-gone listeners are installed; duplicate starts are guarded and the interval cannot keep shutdown alive.

Testing

  • process-gone-diagnostics.test.ts: 28 passed, including the larger-surviving-Tab counterexample, ambiguity field, same-PID/same-bucket creationTime reuse, blind-era/crash-loop behavior, platform-shaped system memory, startup sampling, failed sweeps, and unref cleanup.
  • process-gone-recorder.test.ts: 21 passed.
  • suppressed-process-gone-breadcrumb.test.ts: 2 passed.
  • pnpm run typecheck:node: passed.
  • Targeted oxlint, oxfmt --check, git diff --check, and the max-lines ratchet: passed.

Live Electron QA

Grok QA launched the exact review head c05398e77647e2bae215721fe33f8cf7e53dfcef from this worktree, verified window.api.app.getIdentity(), and triggered a real renderer crash via CDP Page.crash. The recovered crash dialog and persisted crash-reports.json showed processMetricsCrashedProcessAbsent: true, processMetricsPreGoneCrashedProcessAttributionAmbiguous: true, a surviving Browser as post-gone Largest, and macOS total/free/file-backed/purgeable fields with swap omitted. A final validation after rebasing onto current main ran the exact head 9bd2d59e584a0d5685675905aebd039836c963f8: all focused tests and node typecheck passed, and a fresh-profile real renderer crash after the sampling tick persisted the renderer in the pre-gone snapshot while the post-gone Largest remained the surviving Browser. A crash before the first post-startup tick also reproduced the documented born-and-gone interval blind spot.

Healthy PR worktree

Recovered crash dialog

Post-gone survivor metrics

Pre-gone ambiguity and snapshot metrics

Windows/Linux swap fields were not live-tested; source guards and shaped platform tests cover field availability, with the final CI matrix still running.

Linked Issue

No tracked GitHub issue; this came from the 2026-08-13/14 #orca-crashes field sweep.

AI Disclosure

AI assisted with implementation, adversarial review, and focused test construction.

Checklist

  • Focused change with exact telemetry semantics documented
  • Automated regression tests added
  • Security, performance, cross-platform, SSH/folder, mobile, and compatibility impact reviewed
  • Live Electron crash telemetry proof attached
  • Full suite/build not run locally; focused tests and node typecheck passed, with remaining coverage left to CI

Author

  • X / Twitter: @BrennanKB5

@coderabbitai

coderabbitai Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds normalized gone-time system-memory crash fields with injectable readers. Process-gone diagnostics now sample process metrics before termination, retain process identities, aggregate renderer memory peaks, detect absent crashed processes, and merge pre-gone and live details. The recorder passes the crashed process type. Suppressed process-gone breadcrumb construction moves to a dedicated module. Main-process startup starts periodic metric sampling. Tests cover sampling, identity, absence detection, memory normalization, precedence, and breadcrumb fields.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description is detailed and covers the change, rationale, testing, visual proof, compatibility, and AI disclosure, but it lacks the required linked issue. Add a valid tracked issue reference under Linked Issue, such as "Fixes #123".
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the primary change: preventing survivor metrics from being attributed to the crashed process.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/crash-renderer-metrics-postmortem branch from 0ef56a1 to c05398e Compare August 15, 2026 05:41
@brennanb2025
brennanb2025 force-pushed the brennanb2025/crash-renderer-metrics-postmortem branch 3 times, most recently from 6993617 to f76780b Compare August 16, 2026 07:54

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 19c9a156-26aa-47a8-a561-689b0464fdff

📥 Commits

Reviewing files that changed from the base of the PR and between c066a55 and f76780b.

📒 Files selected for processing (8)
  • src/main/crash-reporting/gone-time-system-memory.ts
  • src/main/crash-reporting/process-gone-diagnostics.test.ts
  • src/main/crash-reporting/process-gone-diagnostics.ts
  • src/main/crash-reporting/process-gone-recorder.test.ts
  • src/main/crash-reporting/process-gone-recorder.ts
  • src/main/crash-reporting/suppressed-process-gone-breadcrumb.test.ts
  • src/main/crash-reporting/suppressed-process-gone-breadcrumb.ts
  • src/main/index.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 8 remain after this review.

Comment on lines +282 to +292
const sampledSameBucketProcessVanished = Boolean(
liveIdentitiesByPid &&
preGoneSample?.processes.some(
(process) =>
process.identity.bucket === crashedBucket &&
sampledProcessIsGone(process, liveIdentitiesByPid)
)
)
if (liveMetricDetails[crashedBucketCountKey] === 0 || sampledSameBucketProcessVanished) {
crashDetails.processMetricsCrashedProcessAbsent = true
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

processMetricsCrashedProcessAbsent can be true when the crashed process still survives.

sampledSameBucketProcessVanished is true if any sampled process in the crashed bucket is gone. With several renderers, a normal window or tab close between the last sample and the crash also makes a sampled renderer disappear. The flag then claims absence even when the crashed renderer is still enumerated in the live metrics. Electron's gone event carries no pid, so this cannot be resolved exactly.

Consider recording the weaker claim explicitly, for example processMetricsSampledSameBucketProcessVanished, and reserve processMetricsCrashedProcessAbsent for the count === 0 case. That keeps the two evidence strengths separable during triage.

…rashed process's working set survives its crash report
…ampler coverage

Adversarial review found these mutations survived the suite:
- dropping the immediate sample at startPreGoneProcessMetricsSampling()
- removing the double-start idempotence guard
- widening renderer peak/private aggregation to all buckets
- a failed sweep erasing the previous good sample
- the recorder hardcoding 'renderer' instead of event.processType

Each now has a binding assertion; also documents that the
crashed-process-absent flag is bucket-level only.
…et count alone

The absent flag was bucket-level, so any surviving same-type process (a
webview guest, the dashboard popout, another utility) silently cleared it
— and webviewTag guests make multi-renderer sessions the norm. The pre-gone
sample now keeps per-process pid/bucket/workingSet identities; a sampled
same-bucket pid missing from the live set proves absence and reports the
vanished process's own working set (processMetricsVanished*), so the
crasher's size is no longer summed with surviving guests.

Also: split gone-time system memory into its own module (max-lines), pin
peak/private aggregation as a true max, clamp garbage negative working
sets and backwards clocks, pin live-metrics precedence over incoming
detail keys, and verify the sampler timer is unref'd by behavior.
…ce attribution

Loop-3 hardening of the vanished-pid logic:
- Live pids now carry their bucket: a recycled pid living on as a different
  process type still reads as a vanished sampled process (the bare pid set
  misread the crasher as alive).
- Vanished pids are attributed once. In a crash loop with no sweep between
  deaths, record #2 confidently inherited the FIRST crasher's pid and
  working set (dedupe window is only 2s, so both records ship); it now
  degrades to the honest bucket-count arm instead.
- An ambiguous multi-process VanishedWorkingSetMB sum is bounded by
  VanishedLargestWorkingSetMB so no single-process reading of the sum
  survives triage.
- Killer tests for the remaining mutation survivors: unreadable gone-time
  metrics prove nothing (flag/vanished stay off), pid-less sampled metrics
  never vanish, fractional-MB rounding, negative system-memory clamp, and
  full per-family precedence over colliding incoming detail keys.
…n instead of going silent

Loop-4 hardening of the consume-once attribution:
- processMetricsVanishedAlreadyReportedCount: a record whose vanished pids
  were consumed by a prior report now says so, instead of being
  indistinguishable from "nothing vanished" while its PreGone mirrors still
  show the prior crasher's era.
- processMetricsVanishedAmbiguousWithEarlierCrash: consume-once only consumed
  when the gone-time read succeeded; a crash recorded blind (getAppMetrics
  threw) left its pid unconsumed, so the next record in the same era
  confidently emitted THAT crash's pid and working set as its own. Blind
  buckets now taint the era until a fresh sweep.
- Pin two behaviors that were correct but unpinned: a failed sweep must not
  clear attribution state, and an ambiguous vanished pair is consumed too.
- Document gone-time system memory reading healthier than at kill time, and
  the bound on the attribution set.
- Split the suppressed-breadcrumb builder into its own module (max-lines).
…pin two unpinned behaviors

Loop-5 findings:
- processMetricsVanishedAmbiguousWithEarlierCrash fired only for the
  blind era; a partially-consumed era has the same shape (an earlier
  crash's unsampled respawn is as plausible a crasher as the newly
  vanished pid), yet emitted a confident VanishedPid with no flag.
- Pin the > largest tie-break (first-enumerated wins) instead of
  re-accepting it as an equivalent mutant every loop.
- The suppressed-breadcrumb type field had zero coverage after the
  module split — removing the whole block passed the suite.
… stateless absence proof

Five review loops found defects in the same subsystem: the per-pid
vanished attribution outputs (consume-once set, blind-era taint,
consumed-era ambiguity). The absence proof they fed does not need any
of it — a sampled same-bucket pid missing from the live enumeration
(including cross-bucket pid recycle) is stateless and idempotent, so
it stays true for every record of a crash loop with zero module-level
attribution state.

Dropped: processMetricsVanished{Count,WorkingSetMB,Pid,
LargestWorkingSetMB,AlreadyReportedCount,AmbiguousWithEarlierCrash},
attributedVanishedPids, metricsBlindCrashBuckets, and the tests that
existed only to defend them.

Kept and still pinned: the 60s pre-gone sampler and its lifecycle,
PreGone* mirrors + SampleAgeMs, renderer peak/private, gone-time
system memory, the recorder processType binding, the live/PreGone era
invariant, and the browser-pane case (webview guests keep the renderer
bucket alive) that motivated the PR — now asserted via the absence
flag plus PreGone mirrors alone. Documented the two honest limits:
PreGone values are sample-time (up-to-60s understatement, bounded by
AgeMs and lifetime peaks), and same-bucket pid recycle inside the
sweep window is a false negative for the absence proof.
…not the bucket's running sum

Loop-6 mutation battery found one survivor in the cut's re-anchored
suite: mutating Largest to carry the bucket's running sum survived every
test, because no fixture put a same-bucket sibling BEFORE the largest
process. That is the summing-bug family loop 2 found live. The
webview-guest test now enumerates the guest first and asserts
PreGoneLargest{Pid,Type,WorkingSetMB} carry the crasher's individual
4380, alongside the 4680 bucket total.

Also restores the false-positive caveat the cut's comment dropped: a
legitimately closed sampled process can trip the absence flag if the
crasher's row somehow survives the live enumeration (pre-existing,
unchanged by the cut).
PreGone mirrors are whole-app snapshots, so a larger surviving Tab can own Largest and renderer-wide peak/private fields. Emit an explicit ambiguity boundary, prove the counterexample, and use Electron's pid plus creationTime identity to catch same-bucket PID reuse without adding stateful attribution.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/crash-renderer-metrics-postmortem branch from f76780b to 9bd2d59 Compare August 16, 2026 18:41
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Final-head validation after rebase onto current main (9bd2d59e584a0d5685675905aebd039836c963f8):

  • Focused suites passed: diagnostics 28/28, recorder 21/21, suppressed breadcrumb 2/2; typecheck:node passed.
  • Launched this exact head in an isolated fresh-profile Electron instance and triggered a real renderer crash through CDP.
  • After a sampling tick, the persisted record showed post-gone processMetricsRendererCount: 0, surviving Browser as processMetricsLargestType, and a 7.1-second-old pre-gone snapshot with processMetricsPreGoneRendererCount: 1 / processMetricsPreGoneRendererWorkingSetMB: 127.
  • processMetricsCrashedProcessAbsent and processMetricsPreGoneCrashedProcessAttributionAmbiguous were both true. macOS total/free/file-backed/purgeable fields were emitted and swap fields were omitted.
  • Recovery dialog rendered correctly.

The fresh-profile run also reproduced the documented interval blind spot: a first renderer crash 54 seconds after the startup sample had PreGoneRendererCount: 0 because the renderer was born after that sample. The repeat after the next tick captured it correctly.

Final-head recovered renderer crash

@brennanb2025
brennanb2025 merged commit d5ef633 into main Aug 16, 2026
45 checks passed
AmethystLiang pushed a commit that referenced this pull request Aug 17, 2026
…vivor as the crasher (#14662)

* fix(crash-reporting): keep a pre-gone process-metrics sample so the crashed process's working set survives its crash report

* feat(crash-reporting): renderer peak/private bytes and gone-time system memory in crash details

* fix(crash-reporting): macOS system-memory fields and an era-invariant pin for peak/private metrics

* test(crash-reporting): kill five mutation survivors in the pre-gone sampler coverage

Adversarial review found these mutations survived the suite:
- dropping the immediate sample at startPreGoneProcessMetricsSampling()
- removing the double-start idempotence guard
- widening renderer peak/private aggregation to all buckets
- a failed sweep erasing the previous good sample
- the recorder hardcoding 'renderer' instead of event.processType

Each now has a binding assertion; also documents that the
crashed-process-absent flag is bucket-level only.

* fix(crash-reporting): prove crasher absence by vanished pid, not bucket count alone

The absent flag was bucket-level, so any surviving same-type process (a
webview guest, the dashboard popout, another utility) silently cleared it
— and webviewTag guests make multi-renderer sessions the norm. The pre-gone
sample now keeps per-process pid/bucket/workingSet identities; a sampled
same-bucket pid missing from the live set proves absence and reports the
vanished process's own working set (processMetricsVanished*), so the
crasher's size is no longer summed with surviving guests.

Also: split gone-time system memory into its own module (max-lines), pin
peak/private aggregation as a true max, clamp garbage negative working
sets and backwards clocks, pin live-metrics precedence over incoming
detail keys, and verify the sampler timer is unref'd by behavior.

* fix(crash-reporting): bucket-aware vanished-pid check with consume-once attribution

Loop-3 hardening of the vanished-pid logic:
- Live pids now carry their bucket: a recycled pid living on as a different
  process type still reads as a vanished sampled process (the bare pid set
  misread the crasher as alive).
- Vanished pids are attributed once. In a crash loop with no sweep between
  deaths, record #2 confidently inherited the FIRST crasher's pid and
  working set (dedupe window is only 2s, so both records ship); it now
  degrades to the honest bucket-count arm instead.
- An ambiguous multi-process VanishedWorkingSetMB sum is bounded by
  VanishedLargestWorkingSetMB so no single-process reading of the sum
  survives triage.
- Killer tests for the remaining mutation survivors: unreadable gone-time
  metrics prove nothing (flag/vanished stay off), pid-less sampled metrics
  never vanish, fractional-MB rounding, negative system-memory clamp, and
  full per-family precedence over colliding incoming detail keys.

* fix(crash-reporting): flag consumed and blind-era vanished attribution instead of going silent

Loop-4 hardening of the consume-once attribution:
- processMetricsVanishedAlreadyReportedCount: a record whose vanished pids
  were consumed by a prior report now says so, instead of being
  indistinguishable from "nothing vanished" while its PreGone mirrors still
  show the prior crasher's era.
- processMetricsVanishedAmbiguousWithEarlierCrash: consume-once only consumed
  when the gone-time read succeeded; a crash recorded blind (getAppMetrics
  threw) left its pid unconsumed, so the next record in the same era
  confidently emitted THAT crash's pid and working set as its own. Blind
  buckets now taint the era until a fresh sweep.
- Pin two behaviors that were correct but unpinned: a failed sweep must not
  clear attribution state, and an ambiguous vanished pair is consumed too.
- Document gone-time system memory reading healthier than at kill time, and
  the bound on the attribution set.
- Split the suppressed-breadcrumb builder into its own module (max-lines).

* fix(crash-reporting): extend vanished ambiguity to consumed eras and pin two unpinned behaviors

Loop-5 findings:
- processMetricsVanishedAmbiguousWithEarlierCrash fired only for the
  blind era; a partially-consumed era has the same shape (an earlier
  crash's unsampled respawn is as plausible a crasher as the newly
  vanished pid), yet emitted a confident VanishedPid with no flag.
- Pin the > largest tie-break (first-enumerated wins) instead of
  re-accepting it as an equivalent mutant every loop.
- The suppressed-breadcrumb type field had zero coverage after the
  module split — removing the whole block passed the suite.

* refactor(crash-reporting): cut per-pid vanished attribution, keep the stateless absence proof

Five review loops found defects in the same subsystem: the per-pid
vanished attribution outputs (consume-once set, blind-era taint,
consumed-era ambiguity). The absence proof they fed does not need any
of it — a sampled same-bucket pid missing from the live enumeration
(including cross-bucket pid recycle) is stateless and idempotent, so
it stays true for every record of a crash loop with zero module-level
attribution state.

Dropped: processMetricsVanished{Count,WorkingSetMB,Pid,
LargestWorkingSetMB,AlreadyReportedCount,AmbiguousWithEarlierCrash},
attributedVanishedPids, metricsBlindCrashBuckets, and the tests that
existed only to defend them.

Kept and still pinned: the 60s pre-gone sampler and its lifecycle,
PreGone* mirrors + SampleAgeMs, renderer peak/private, gone-time
system memory, the recorder processType binding, the live/PreGone era
invariant, and the browser-pane case (webview guests keep the renderer
bucket alive) that motivated the PR — now asserted via the absence
flag plus PreGone mirrors alone. Documented the two honest limits:
PreGone values are sample-time (up-to-60s understatement, bounded by
AgeMs and lifetime peaks), and same-bucket pid recycle inside the
sweep window is a false negative for the absence proof.

* test(crash-reporting): pin PreGoneLargest to the crasher's own size, not the bucket's running sum

Loop-6 mutation battery found one survivor in the cut's re-anchored
suite: mutating Largest to carry the bucket's running sum survived every
test, because no fixture put a same-bucket sibling BEFORE the largest
process. That is the summing-bug family loop 2 found live. The
webview-guest test now enumerates the guest first and asserts
PreGoneLargest{Pid,Type,WorkingSetMB} carry the crasher's individual
4380, alongside the 4680 bucket total.

Also restores the false-positive caveat the cut's comment dropped: a
legitimately closed sampled process can trip the absence flag if the
crasher's row somehow survives the live enumeration (pre-existing,
unchanged by the cut).

* fix(crash-reporting): mark pre-gone attribution ambiguous

PreGone mirrors are whole-app snapshots, so a larger surviving Tab can own Largest and renderer-wide peak/private fields. Emit an explicit ambiguity boundary, prove the counterexample, and use Electron's pid plus creationTime identity to catch same-bucket PID reuse without adding stateful attribution.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…vivor as the crasher (stablyai#14662)

* fix(crash-reporting): keep a pre-gone process-metrics sample so the crashed process's working set survives its crash report

* feat(crash-reporting): renderer peak/private bytes and gone-time system memory in crash details

* fix(crash-reporting): macOS system-memory fields and an era-invariant pin for peak/private metrics

* test(crash-reporting): kill five mutation survivors in the pre-gone sampler coverage

Adversarial review found these mutations survived the suite:
- dropping the immediate sample at startPreGoneProcessMetricsSampling()
- removing the double-start idempotence guard
- widening renderer peak/private aggregation to all buckets
- a failed sweep erasing the previous good sample
- the recorder hardcoding 'renderer' instead of event.processType

Each now has a binding assertion; also documents that the
crashed-process-absent flag is bucket-level only.

* fix(crash-reporting): prove crasher absence by vanished pid, not bucket count alone

The absent flag was bucket-level, so any surviving same-type process (a
webview guest, the dashboard popout, another utility) silently cleared it
— and webviewTag guests make multi-renderer sessions the norm. The pre-gone
sample now keeps per-process pid/bucket/workingSet identities; a sampled
same-bucket pid missing from the live set proves absence and reports the
vanished process's own working set (processMetricsVanished*), so the
crasher's size is no longer summed with surviving guests.

Also: split gone-time system memory into its own module (max-lines), pin
peak/private aggregation as a true max, clamp garbage negative working
sets and backwards clocks, pin live-metrics precedence over incoming
detail keys, and verify the sampler timer is unref'd by behavior.

* fix(crash-reporting): bucket-aware vanished-pid check with consume-once attribution

Loop-3 hardening of the vanished-pid logic:
- Live pids now carry their bucket: a recycled pid living on as a different
  process type still reads as a vanished sampled process (the bare pid set
  misread the crasher as alive).
- Vanished pids are attributed once. In a crash loop with no sweep between
  deaths, record stablyai#2 confidently inherited the FIRST crasher's pid and
  working set (dedupe window is only 2s, so both records ship); it now
  degrades to the honest bucket-count arm instead.
- An ambiguous multi-process VanishedWorkingSetMB sum is bounded by
  VanishedLargestWorkingSetMB so no single-process reading of the sum
  survives triage.
- Killer tests for the remaining mutation survivors: unreadable gone-time
  metrics prove nothing (flag/vanished stay off), pid-less sampled metrics
  never vanish, fractional-MB rounding, negative system-memory clamp, and
  full per-family precedence over colliding incoming detail keys.

* fix(crash-reporting): flag consumed and blind-era vanished attribution instead of going silent

Loop-4 hardening of the consume-once attribution:
- processMetricsVanishedAlreadyReportedCount: a record whose vanished pids
  were consumed by a prior report now says so, instead of being
  indistinguishable from "nothing vanished" while its PreGone mirrors still
  show the prior crasher's era.
- processMetricsVanishedAmbiguousWithEarlierCrash: consume-once only consumed
  when the gone-time read succeeded; a crash recorded blind (getAppMetrics
  threw) left its pid unconsumed, so the next record in the same era
  confidently emitted THAT crash's pid and working set as its own. Blind
  buckets now taint the era until a fresh sweep.
- Pin two behaviors that were correct but unpinned: a failed sweep must not
  clear attribution state, and an ambiguous vanished pair is consumed too.
- Document gone-time system memory reading healthier than at kill time, and
  the bound on the attribution set.
- Split the suppressed-breadcrumb builder into its own module (max-lines).

* fix(crash-reporting): extend vanished ambiguity to consumed eras and pin two unpinned behaviors

Loop-5 findings:
- processMetricsVanishedAmbiguousWithEarlierCrash fired only for the
  blind era; a partially-consumed era has the same shape (an earlier
  crash's unsampled respawn is as plausible a crasher as the newly
  vanished pid), yet emitted a confident VanishedPid with no flag.
- Pin the > largest tie-break (first-enumerated wins) instead of
  re-accepting it as an equivalent mutant every loop.
- The suppressed-breadcrumb type field had zero coverage after the
  module split — removing the whole block passed the suite.

* refactor(crash-reporting): cut per-pid vanished attribution, keep the stateless absence proof

Five review loops found defects in the same subsystem: the per-pid
vanished attribution outputs (consume-once set, blind-era taint,
consumed-era ambiguity). The absence proof they fed does not need any
of it — a sampled same-bucket pid missing from the live enumeration
(including cross-bucket pid recycle) is stateless and idempotent, so
it stays true for every record of a crash loop with zero module-level
attribution state.

Dropped: processMetricsVanished{Count,WorkingSetMB,Pid,
LargestWorkingSetMB,AlreadyReportedCount,AmbiguousWithEarlierCrash},
attributedVanishedPids, metricsBlindCrashBuckets, and the tests that
existed only to defend them.

Kept and still pinned: the 60s pre-gone sampler and its lifecycle,
PreGone* mirrors + SampleAgeMs, renderer peak/private, gone-time
system memory, the recorder processType binding, the live/PreGone era
invariant, and the browser-pane case (webview guests keep the renderer
bucket alive) that motivated the PR — now asserted via the absence
flag plus PreGone mirrors alone. Documented the two honest limits:
PreGone values are sample-time (up-to-60s understatement, bounded by
AgeMs and lifetime peaks), and same-bucket pid recycle inside the
sweep window is a false negative for the absence proof.

* test(crash-reporting): pin PreGoneLargest to the crasher's own size, not the bucket's running sum

Loop-6 mutation battery found one survivor in the cut's re-anchored
suite: mutating Largest to carry the bucket's running sum survived every
test, because no fixture put a same-bucket sibling BEFORE the largest
process. That is the summing-bug family loop 2 found live. The
webview-guest test now enumerates the guest first and asserts
PreGoneLargest{Pid,Type,WorkingSetMB} carry the crasher's individual
4380, alongside the 4680 bucket total.

Also restores the false-positive caveat the cut's comment dropped: a
legitimately closed sampled process can trip the absence flag if the
crasher's row somehow survives the live enumeration (pre-existing,
unchanged by the cut).

* fix(crash-reporting): mark pre-gone attribution ambiguous

PreGone mirrors are whole-app snapshots, so a larger surviving Tab can own Largest and renderer-wide peak/private fields. Emit an explicit ambiguity boundary, prove the counterexample, and use Electron's pid plus creationTime identity to catch same-bucket PID reuse without adding stateful attribution.
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