Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
fix(ok): bound the crash prompt by teardown and staleness (PRD-8473 PRD-8266) (#4221)
Andrew Mikofalvy3305709233dc
diff --git a/.changeset/crash-prompt-handoff-shadow-and-staleness.md b/.changeset/crash-prompt-handoff-shadow-and-staleness.mdnew file mode 100644index 000000000..fec4b4d96--- /dev/null+++ b/.changeset/crash-prompt-handoff-shadow-and-staleness.md@@ -0,0 +1,15 @@+---+'@inkeep/open-knowledge': patch+---++Stop the crash prompt firing for deaths that were not crashes.++Three bounds on the crash reporter:++- A minidump written inside the 30-second teardown that follows a recorded update handoff no longer arms a report invitation. The process was already committed to quitting so the installer could replace it, and a fault on the way out is not something the user can act on. A dump past that window still prompts, because an install can be in flight for up to 30 minutes and a fault inside it is the app failing on its own. Only a dump this app can positively claim is shadowed; one it cannot parse still prompts, as it does elsewhere in the crash reporter.+- A death the app can date to more than a week ago no longer prompts. The death is dated by the latest evidence the app was alive — the newest crash dump or the previous session's last heartbeat, whichever is later, ignoring a heartbeat that postdates the launch reading it — so an old dump left on disk can neither make a recent death look stale nor become the subject of the report. Before this, a sentinel prompted the same at twelve seconds and twelve days old, and an un-acknowledged dump re-armed the same prompt on every launch indefinitely. A session that left no heartbeat and no dump cannot be dated, so it is exempt and still prompts: sentinels written before 0.35 carry no heartbeat, and their boot time answers when the session started rather than when it died.+- An armed invitation nobody answered within 24 hours is dropped undelivered instead of waiting for the lifetime of the process. The bound is per process, not per crash: a relaunch offers the same crash again, because a new launch is a new chance to ask and a session that never showed the prompt should not silently lose it.++The report note now carries when the crash happened and how long ago whenever the app can date the death itself — never by borrowing a crash dump the same report says was not the cause — so a stale report is legible without decoding the boot id.++The relative-time wording it uses is now shared with `ok ps`, which changes that command's `STARTED` column in two visible ways: an age under a minute reads `30s ago` rather than `30s`, so no cell reads as a bare duration, and a start time that postdates now reads `0s ago` rather than a negative duration. A stamp the command cannot parse still renders as the table's `—`.diff --git a/docs/content/reference/what-open-knowledge-writes.mdx b/docs/content/reference/what-open-knowledge-writes.mdxindex 2c5318f6f..e0b5ba192 100644--- a/docs/content/reference/what-open-knowledge-writes.mdx+++ b/docs/content/reference/what-open-knowledge-writes.mdx@@ -46,8 +46,8 @@ On every platform the app writes app-level state and logs on launch. The table b| `~/Library/Caches/com.inkeep.open-knowledge.ShipIt/` | Install log of the macOS update helper (Squirrel's ShipIt), which swaps the app bundle after the app has quit. The only record of why an update failed to install, so a bug report you send collects it — only this app's, never those of other applications that use the same update mechanism | Outside-project (home dir) || `~/Library/Logs/DiagnosticReports/` | Not written by OpenKnowledge at all — this is macOS's own crash-report directory, shared by every application on the machine. When the OS ends one of this app's processes it records why there, which is sometimes the only account of a session that stopped without a crash dump, so a bug report you send at the **Detailed diagnostics** level collects the reports macOS wrote for this app and its helper processes — only ours, never those of any other application, and never at the standard level. A report of ours still names the processes it was running alongside. A report also carries machine details macOS puts in every one of them — the account uid, the Mac model, and the name of the process that launched the app, which on a managed machine can be internal tooling — while the identifiers that would link your bundles to each other are replaced before bundling. `ok diagnose bundle` collects them too, on every run: that command produces the Detailed superset by design, and its summary tells you what the search found before it writes the zip | Outside-project (home dir) || `~/Library/Application Support/OpenKnowledge/Crashpad/` | Native crash minidumps, written by the OS crash handler (Electron's Crashpad) if the app ever crashes. Local-only: the crash reporter runs with `uploadToServer: false`, so no dump is ever uploaded automatically | Outside-project (home dir) |-| `~/Library/Application Support/OpenKnowledge/bug-report-dirty-shutdown.json` | Dirty-shutdown sentinel — written on **every** launch, refreshed as it runs, and removed on a clean quit. The next launch reads it to tell an app crash (prompts you) from the endings that are not a crash: a reboot, an OS shutdown, or dying asleep (all suppressed and logged instead), and an update install shutting the app down to replace its files (logged either way, and suppressed in almost every case: a shutdown the app had no chance to record, or one it cannot date because the previous session left no heartbeat, can still prompt so you are able to report it) | Outside-project (home dir) |-| `~/Library/Application Support/OpenKnowledge/bug-report-crash-acks.json` | Records which crash-report invitations you already answered or dismissed, so the same crash never re-prompts | Outside-project (home dir) |+| `~/Library/Application Support/OpenKnowledge/bug-report-dirty-shutdown.json` | Dirty-shutdown sentinel — written on **every** launch, refreshed as it runs, and removed on a clean quit. The next launch reads it to tell an app crash (prompts you) from the endings that are not a crash: a reboot, an OS shutdown, or dying asleep (all suppressed and logged instead), an update install shutting the app down to replace its files (logged either way, and suppressed in almost every case: a shutdown the app had no chance to record, or one it cannot date because the previous session left no heartbeat, can still prompt so you are able to report it), and a death the app can date to more than a week ago, which is too stale to report usefully — the diagnostics a report would gather describe the day you sent it rather than the day it happened. A fresh crash dump still overrides those, the same as it does for a reboot, a suspend or an OS shutdown — except in the first 30 seconds after the app committed to quitting for an update install, where a dump is part of that same shutdown rather than a crash you could act on. A session that left neither a heartbeat nor a crash dump cannot be dated, so it is never treated as stale | Outside-project (home dir) |+| `~/Library/Application Support/OpenKnowledge/bug-report-crash-acks.json` | Records which crash-report invitations you already answered or dismissed, so the same crash never re-prompts. Answering is what retires a crash: an invitation you simply never saw — because it went unanswered for a day, or the window it was waiting on never appeared — is dropped rather than answered, so that crash can be offered again the next time you open the app | Outside-project (home dir) |The app registers the `openknowledge://` URL scheme (for deep links) and checks for updates — on launch and periodically while it runs — against the OpenKnowledge update service at `openknowledge.ai/updates`, which redirects to the GitHub release asset and counts the update per version and channel (falling back to GitHub directly if it's unreachable). On macOS and Windows an update on your channel downloads in the background and installs on the next quit; on Linux — where there is no apt/rpm repository — the app downloads the new deb/rpm from the release feed and asks you to authorize the install (a `pkexec` password prompt) each time. You can also check on demand from **Check for updates…** in the app and Help menus. The channel (stable or beta) is fixed by the build you installed. Reinstall a stable build for any supported platform from `openknowledge.ai/download`. The `/download/beta` shortcut serves the latest Apple Silicon macOS beta; Windows and Linux beta installers are available from [GitHub Releases](https://github.com/inkeep/open-knowledge/releases). Override the feed with `OK_UPDATER_FEED_URL`.diff --git a/packages/app/src/components/ReportBugDialog.dom.test.tsx b/packages/app/src/components/ReportBugDialog.dom.test.tsxindex 1788c9a1d..8fa149dde 100644--- a/packages/app/src/components/ReportBugDialog.dom.test.tsx+++ b/packages/app/src/components/ReportBugDialog.dom.test.tsx@@ -707,6 +707,30 @@ describe('ReportBugDialog', () => {expect(log.createCalls[0]?.note).not.toContain('Crashed app version');});+ test('a crash invite that names when it crashed folds the time and its age in', async () => {+ const log = installBridge();+ await renderDialog({+ crashInvite: { ...BOOT_INVITE, crashedAt: '2026-08-31T03:15:17.929Z' },+ });++ await userEvent.click(screen.getByRole('button', { name: 'Create report' }));+ await screen.findByRole('heading', { name: 'Review your report' });++ const note = log.createCalls[0]?.note ?? '';+ expect(note).toContain('Crashed at: 2026-08-31T03:15:17.929Z (');+ expect(note).toMatch(/Crashed at: .+ \(\d+[smhd] ago\)/);+ });++ test('a crash invite with no crash time composes the note without that line', async () => {+ const log = installBridge();+ await renderDialog({ crashInvite: BOOT_INVITE });++ await userEvent.click(screen.getByRole('button', { name: 'Create report' }));+ await screen.findByRole('heading', { name: 'Review your report' });++ expect(log.createCalls[0]?.note).not.toContain('Crashed at');+ });+test('a plain compose with no dump on hand renders no crash-dump opt-in and sends no flag', async () => {const log = installBridge();await renderDialog();diff --git a/packages/app/src/components/ReportBugDialogBody.tsx b/packages/app/src/components/ReportBugDialogBody.tsxindex a5cac2aaa..91b9db273 100644--- a/packages/app/src/components/ReportBugDialogBody.tsx+++ b/packages/app/src/components/ReportBugDialogBody.tsx@@ -7,6 +7,7 @@ import type {} from '@inkeep/open-knowledge-core';import {BUG_REPORT_SCREENSHOT_ZIP_ENTRY,+ formatRelativeAge,isBugReportAttachmentEntry,} from '@inkeep/open-knowledge-core';import { Plural, Trans, useLingui } from '@lingui/react/macro';@@ -108,6 +109,9 @@ function crashInviteLines(invite: OkBugReportCrashDetectedEvent): string[] {if (invite.kind === 'boot' && invite.crashedAppVersion !== undefined) {lines.push(`Crashed app version: ${invite.crashedAppVersion}`);}+ if (invite.kind === 'boot' && invite.crashedAt !== undefined) {+ lines.push(`Crashed at: ${invite.crashedAt} (${formatRelativeAge(invite.crashedAt)})`);+ }return lines;}diff --git a/packages/cli/src/commands/ps.test.ts b/packages/cli/src/commands/ps.test.tsindex 8c6827f83..28156d703 100644--- a/packages/cli/src/commands/ps.test.ts+++ b/packages/cli/src/commands/ps.test.ts@@ -1,7 +1,7 @@import { describe, expect, test } from 'vitest';import { extractOkBinaryPath } from '../utils/process-scan.ts';import type { LockState } from './lock-state.ts';-import { isDesktopCommand, renderTable, runPs, timeAgo } from './ps.ts';+import { isDesktopCommand, renderTable, runPs, startedCell } from './ps.ts';const ELECTRON_UTILITY_COMMAND ='/path/to/Electron Helper.app/Contents/MacOS/Electron Helper --type=utility --utility-sub-type=node.mojom.NodeService --lang=en-US';@@ -76,29 +76,14 @@ const corruptLock: LockState = {lockPath: '/tmp/notes/.ok/server.lock',};-describe('timeAgo', () => {- test('returns seconds when diff < 60s', () => {- const now = new Date('2026-05-05T10:00:30.000Z').getTime();- expect(timeAgo('2026-05-05T10:00:00.000Z', now)).toBe('30s');- });-- test('returns minutes ago when diff < 1h', () => {+describe('startedCell', () => {+ test('renders the shared relative-time form', () => {const now = new Date('2026-05-05T10:05:00.000Z').getTime();- expect(timeAgo('2026-05-05T10:00:00.000Z', now)).toBe('5m ago');- });-- test('returns hours ago when diff < 24h', () => {- const now = new Date('2026-05-05T12:00:00.000Z').getTime();- expect(timeAgo('2026-05-05T10:00:00.000Z', now)).toBe('2h ago');- });-- test('returns days ago when diff >= 24h', () => {- const now = new Date('2026-05-08T10:00:00.000Z').getTime();- expect(timeAgo('2026-05-05T10:00:00.000Z', now)).toBe('3d ago');+ expect(startedCell('2026-05-05T10:00:00.000Z', now)).toBe('5m ago');});- test('returns — for invalid ISO string', () => {- expect(timeAgo('not-a-date')).toBe('—');+ test('renders the table empty-cell marker when the stamp cannot be read', () => {+ expect(startedCell('not-a-date')).toBe('—');});});diff --git a/packages/cli/src/commands/ps.ts b/packages/cli/src/commands/ps.tsindex b3c1514d8..20ec5a9d8 100644--- a/packages/cli/src/commands/ps.ts+++ b/packages/cli/src/commands/ps.ts@@ -1,3 +1,4 @@+import { formatRelativeAge, RELATIVE_TIME_UNKNOWN } from '@inkeep/open-knowledge-core';import { lockAdvertisesUi } from '@inkeep/open-knowledge-server';import { Command } from 'commander';import pc from 'picocolors';@@ -41,18 +42,9 @@ export function isDesktopCommand(command: string | null): boolean {);}-export function timeAgo(isoString: string, now = Date.now()): string {- const then = new Date(isoString).getTime();- if (Number.isNaN(then)) return '—';- const diffMs = now - then;- const diffSec = Math.floor(diffMs / 1000);- if (diffSec < 60) return `${diffSec}s`;- const diffMin = Math.floor(diffSec / 60);- if (diffMin < 60) return `${diffMin}m ago`;- const diffHr = Math.floor(diffMin / 60);- if (diffHr < 24) return `${diffHr}h ago`;- const diffDay = Math.floor(diffHr / 24);- return `${diffDay}d ago`;+export function startedCell(isoString: string, now = Date.now()): string {+ const age = formatRelativeAge(isoString, now);+ return age === RELATIVE_TIME_UNKNOWN ? '—' : age;}function buildEntry(@@ -158,7 +150,7 @@ export function renderTable(entries: PsEntry[]): string {formatCombinedUsage(e),displayStatus(e),String(e.server.pid),- timeAgo(e.server.startedAt),+ startedCell(e.server.startedAt),e.binary ?? '—',];});diff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex bdc6cf0d8..19ff94955 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -1956,6 +1956,7 @@ export {export { type BasenameIndex, createBasenameIndex } from './utils/path-resolve.ts';export { type PdfAnchorParts, parsePdfAnchor } from './utils/pdf-anchor.ts';export { randomUUID } from './utils/random-uuid.ts';+export { formatRelativeAge, RELATIVE_TIME_UNKNOWN } from './utils/relative-time.ts';export {decodeHrefPath,encodeHrefPath,diff --git a/packages/core/src/logger-types.ts b/packages/core/src/logger-types.tsindex 44d706b44..9bc15b5a6 100644--- a/packages/core/src/logger-types.ts+++ b/packages/core/src/logger-types.ts@@ -142,6 +142,7 @@ export type OkBugReportCrashDetectedEvent =context: { dirtyShutdown: boolean; newMinidumps: number };minidumpAvailable: boolean;crashedAppVersion?: string;+ crashedAt?: string;};export type OkBugReportCrashAckResult = { ok: true } | { ok: false; error: string };diff --git a/packages/core/src/utils/relative-time.test.ts b/packages/core/src/utils/relative-time.test.tsnew file mode 100644index 000000000..e2e7c0341--- /dev/null+++ b/packages/core/src/utils/relative-time.test.ts@@ -0,0 +1,40 @@+import { describe, expect, test } from 'vitest';+import { formatRelativeAge, RELATIVE_TIME_UNKNOWN } from './relative-time.ts';++const AT = '2026-08-31T03:15:17.929Z';+const atMs = Date.parse(AT);++const SECOND = 1000;+const MINUTE = 60 * SECOND;+const HOUR = 60 * MINUTE;+const DAY = 24 * HOUR;++describe('formatRelativeAge', () => {+ test.each([+ [0, '0s ago'],+ [30 * SECOND, '30s ago'],+ [59 * SECOND, '59s ago'],+ [MINUTE, '1m ago'],+ [59 * MINUTE, '59m ago'],+ [HOUR, '1h ago'],+ [23 * HOUR, '23h ago'],+ [DAY, '1d ago'],+ [28 * DAY, '28d ago'],+ ])('an age of %ims reads as %s', (offsetMs, expected) => {+ expect(formatRelativeAge(AT, atMs + offsetMs)).toBe(expected);+ });++ test('a clock that ran backwards clamps rather than rendering a negative age', () => {+ expect(formatRelativeAge(AT, atMs - 60 * SECOND)).toBe('0s ago');+ });++ test('an unparseable stamp reads as the unknown marker', () => {+ expect(formatRelativeAge('not-a-date', atMs)).toBe(RELATIVE_TIME_UNKNOWN);+ });++ test('every bucket carries the ago suffix, so no form reads as a bare duration', () => {+ for (const offsetMs of [0, 30 * SECOND, 5 * MINUTE, 3 * HOUR, 28 * DAY]) {+ expect(formatRelativeAge(AT, atMs + offsetMs)).toMatch(/ ago$/);+ }+ });+});diff --git a/packages/core/src/utils/relative-time.ts b/packages/core/src/utils/relative-time.tsnew file mode 100644index 000000000..793aa3316--- /dev/null+++ b/packages/core/src/utils/relative-time.ts@@ -0,0 +1,13 @@+export const RELATIVE_TIME_UNKNOWN = 'unknown';++export function formatRelativeAge(isoString: string, nowMs: number = Date.now()): string {+ const thenMs = Date.parse(isoString);+ if (!Number.isFinite(thenMs)) return RELATIVE_TIME_UNKNOWN;+ const diffSec = Math.floor(Math.max(0, nowMs - thenMs) / 1000);+ if (diffSec < 60) return `${diffSec}s ago`;+ const diffMin = Math.floor(diffSec / 60);+ if (diffMin < 60) return `${diffMin}m ago`;+ const diffHr = Math.floor(diffMin / 60);+ if (diffHr < 24) return `${diffHr}h ago`;+ return `${Math.floor(diffHr / 24)}d ago`;+}diff --git a/packages/desktop/src/main/crash-detection.test.ts b/packages/desktop/src/main/crash-detection.test.tsindex fbaed2d3b..955534926 100644--- a/packages/desktop/src/main/crash-detection.test.ts+++ b/packages/desktop/src/main/crash-detection.test.ts@@ -17,9 +17,12 @@ import {createCrashDetection,GPU_CRASH_INVITE_THRESHOLD,GPU_CRASH_WINDOW_MS,+ HANDOFF_TEARDOWN_WINDOW_MS,+ INVITE_EXPIRE_AFTER_MS,type InstallInFlight,MAX_DECLINED_DEATHS,SENTINEL_HEARTBEAT_INTERVAL_MS,+ STALE_CRASH_AFTER_MS,startLocalCrashReporter,} from './crash-detection.ts';import { buildMinidump } from './minidump.test-helper.ts';@@ -1744,36 +1747,42 @@ describe('auto-update install kill suppression', () => {});});+function committedInstallOf(version: string, handoffAt: number): AppState {+ return {+ ...emptyState(),+ versionPendingInstall: version,+ attemptedInstall: version,+ attemptedInstallHandoffAt: handoffAt,+ versionPendingInstallStagedAt: handoffAt - 60_000,+ attemptedInstallDeferredBoots: 0,+ };+}++function stagedButNeverCommittedOf(version: string, stagedAt: number): AppState {+ return {+ ...emptyState(),+ versionPendingInstall: version,+ attemptedInstall: version,+ attemptedInstallHandoffAt: null,+ versionPendingInstallStagedAt: stagedAt,+ attemptedInstallDeferredBoots: 0,+ };+}++function wireRealUpdater(rig: Rig, state: AppState): void {+ rig.deps.installInFlight = (span) =>+ installWasInFlightDuring(state, span, state.versionPendingInstallStagedAt);+}+describe('the instant the install-kill question is asked in', () => {const ATTEMPTED = '0.61.3';const TWO_HOURS_MS = 2 * 60 * 60 * 1000;- function committedInstall(handoffAt: number): AppState {- return {- ...emptyState(),- versionPendingInstall: ATTEMPTED,- attemptedInstall: ATTEMPTED,- attemptedInstallHandoffAt: handoffAt,- versionPendingInstallStagedAt: handoffAt - 60_000,- attemptedInstallDeferredBoots: 0,- };- }-- function stagedButNeverCommitted(stagedAt: number): AppState {- return {- ...emptyState(),- versionPendingInstall: ATTEMPTED,- attemptedInstall: ATTEMPTED,- attemptedInstallHandoffAt: null,- versionPendingInstallStagedAt: stagedAt,- attemptedInstallDeferredBoots: 0,- };- }+ const committedInstall = (handoffAt: number): AppState =>+ committedInstallOf(ATTEMPTED, handoffAt);- function wireRealUpdater(rig: Rig, state: AppState): void {- rig.deps.installInFlight = (span) =>- installWasInFlightDuring(state, span, state.versionPendingInstallStagedAt);- }+ const stagedButNeverCommitted = (stagedAt: number): AppState =>+ stagedButNeverCommittedOf(ATTEMPTED, stagedAt);test('an install in flight when the previous session died stays suppressed however late the reopen', () => {const rig = makeRig();@@ -2527,3 +2536,435 @@ describe('dumps of deaths the app declined to prompt for', () => {});});});++describe('dumps written during the teardown an update handoff started', () => {+ const SHADOW_ATTEMPTED = '0.66.2';++ function primeThenHandoff(rig: Rig): number {+ const prior = createCrashDetection(rig.deps);+ prior.detectBootCrash();+ prior.markCleanQuit();+ rig.advance(10 * 60_000);+ return rig.nowMs();+ }++ function seedFreshDump(rig: Rig, relPath: string, offsetFromHandoffMs: number): Date {+ const handoffAt = primeThenHandoff(rig);+ rig.setInstallInFlight({+ attemptedVersion: SHADOW_ATTEMPTED,+ handoffAt,+ recordedHandoff: true,+ });+ const dumpAt = new Date(handoffAt + offsetFromHandoffMs);+ seedMinidump(rig, relPath, dumpAt);+ return dumpAt;+ }++ test('a dump stamped inside the teardown window does not arm a prompt', () => {+ const rig = makeRig();+ const handoffAt = primeThenHandoff(rig);+ wireRealUpdater(rig, committedInstallOf(SHADOW_ATTEMPTED, handoffAt));+ const dumpAt = new Date(handoffAt + 1_671);+ seedMinidump(rig, 'completed/teardown.dmp', dumpAt);++ const detection = createCrashDetection(rig.deps);+ expect(detection.detectBootCrash()).toBeNull();+ expect(rig.infos).toContainEqual(+ expect.objectContaining({+ event: 'crash-detection.dump-handoff-shadowed',+ dumpMtimeAt: dumpAt.toISOString(),+ handoffAt: new Date(handoffAt).toISOString(),+ teardownWindowMs: HANDOFF_TEARDOWN_WINDOW_MS,+ attemptedInstall: SHADOW_ATTEMPTED,+ }),+ );+ detection.notifyRendererReady();+ expect(rig.emitted).toHaveLength(0);+ });++ test('an unreadable dump inside the window still arms — the shadow stays fail-open', () => {+ const rig = makeRig();+ const handoffAt = primeThenHandoff(rig);+ wireRealUpdater(rig, committedInstallOf(SHADOW_ATTEMPTED, handoffAt));+ seedMinidump(rig, 'completed/torn.dmp', new Date(handoffAt + 1_671), UNPARSEABLE_DUMP);++ const armed = createCrashDetection(rig.deps).detectBootCrash();+ expect(bootInvite(armed).context.newMinidumps).toBe(1);+ });++ test('a dump stamped past the teardown window still arms — the install was live, not quitting', () => {+ const rig = makeRig();+ seedFreshDump(rig, 'completed/later.dmp', HANDOFF_TEARDOWN_WINDOW_MS + 1_000);++ const armed = createCrashDetection(rig.deps).detectBootCrash();+ expect(bootInvite(armed).context.newMinidumps).toBe(1);+ });++ test('a dump stamped before the handoff still arms — the death preceded the quit', () => {+ const rig = makeRig();+ seedFreshDump(rig, 'completed/real.dmp', -60_000);++ const armed = createCrashDetection(rig.deps).detectBootCrash();+ expect(bootInvite(armed).context.newMinidumps).toBe(1);+ });++ test('a staging-fallback handoff shadows nothing — only a recorded commit bounds it', () => {+ const rig = makeRig();+ const stagedAt = primeThenHandoff(rig);+ wireRealUpdater(rig, stagedButNeverCommittedOf(SHADOW_ATTEMPTED, stagedAt));+ seedMinidump(rig, 'completed/after-staging.dmp', new Date(stagedAt + 1_671));++ const armed = createCrashDetection(rig.deps).detectBootCrash();+ expect(bootInvite(armed).context.newMinidumps).toBe(1);+ });++ test('with no install in flight a dump arms exactly as before', () => {+ const rig = makeRig();+ const prior = createCrashDetection(rig.deps);+ prior.detectBootCrash();+ prior.markCleanQuit();+ rig.advance(10 * 60_000);+ seedMinidump(rig, 'completed/plain.dmp', new Date(rig.nowMs()));++ const armed = createCrashDetection(rig.deps).detectBootCrash();+ expect(bootInvite(armed).context.newMinidumps).toBe(1);+ });+});++describe('staleness bounds on the crash reporter', () => {+ function seedSentinel(rig: Rig, lastAliveMs: number, bootSessionUuid?: string): void {+ mkdirSync(dirname(rig.deps.sentinelPath), { recursive: true });+ writeFileSync(+ rig.deps.sentinelPath,+ JSON.stringify({+ bootId: String(lastAliveMs),+ startedAt: new Date(lastAliveMs).toISOString(),+ lastAliveAt: new Date(lastAliveMs).toISOString(),+ appVersion: CRASHED_VERSION,+ ...(bootSessionUuid === undefined ? {} : { bootSessionUuid }),+ }),+ );+ }++ test('an invitation nobody answered past the bound is dropped undelivered', () => {+ const rig = makeRig();+ const prior = createCrashDetection(rig.deps);+ prior.detectBootCrash();+ prior.markCleanQuit();+ rig.advance(10 * 60_000);+ rig.setRendererAvailable(false);+ seedMinidump(rig, 'completed/fresh.dmp', new Date(rig.nowMs()));+ const detection = createCrashDetection(rig.deps);+ expect(detection.detectBootCrash()).not.toBeNull();++ rig.setRendererAvailable(true);+ rig.advance(INVITE_EXPIRE_AFTER_MS);+ detection.notifyRendererReady();++ expect(rig.emitted).toHaveLength(0);+ expect(rig.infos).toContainEqual(+ expect.objectContaining({ event: 'crash-detection.invitation-expired' }),+ );+ });++ test('an invitation answered inside the bound is still delivered', () => {+ const rig = makeRig();+ const prior = createCrashDetection(rig.deps);+ prior.detectBootCrash();+ prior.markCleanQuit();+ rig.advance(10 * 60_000);+ rig.setRendererAvailable(false);+ seedMinidump(rig, 'completed/fresh.dmp', new Date(rig.nowMs()));+ const detection = createCrashDetection(rig.deps);+ expect(detection.detectBootCrash()).not.toBeNull();++ rig.setRendererAvailable(true);+ rig.advance(INVITE_EXPIRE_AFTER_MS / 2);+ detection.notifyRendererReady();++ expect(rig.emitted).toHaveLength(1);+ });++ test('a sentinel older than the staleness bound suppresses the dirty-shutdown prompt', () => {+ const rig = makeRig();+ seedSentinel(rig, rig.nowMs());+ rig.advance(STALE_CRASH_AFTER_MS);++ expect(createCrashDetection(rig.deps).detectBootCrash()).toBeNull();+ expect(rig.infos).toContainEqual(+ expect.objectContaining({+ event: 'crash-detection.machine-level-death',+ reason: 'stale-crash',+ class: 'stale',+ machineCause: null,+ }),+ );+ });++ test('a reboot older than the bound suppresses as external, naming the machine cause', () => {+ const rig = makeRig();+ const bootedAt = rig.nowMs();+ seedSentinel(rig, bootedAt, 'boot-epoch-a');+ rig.advance(STALE_CRASH_AFTER_MS);+ rig.setBootSessionUuid('boot-epoch-b');++ expect(createCrashDetection(rig.deps).detectBootCrash()).toBeNull();+ expect(rig.infos).toContainEqual(+ expect.objectContaining({+ event: 'crash-detection.machine-level-death',+ reason: 'system-reboot',+ class: 'external',+ machineCause: 'system-reboot',+ }),+ );+ });++ test('a future-dated heartbeat cannot date a death, so it neither ages nor stamps it', () => {+ const rig = makeRig();+ const prior = createCrashDetection(rig.deps);+ prior.detectBootCrash();+ prior.markCleanQuit();+ rig.advance(10 * 60_000);+ seedSentinel(rig, rig.nowMs() + 3 * 60 * 60_000);++ const armed = createCrashDetection(rig.deps).detectBootCrash();+ expect(bootInvite(armed).context.dirtyShutdown).toBe(true);+ expect(bootInvite(armed).crashedAt).toBeUndefined();+ expect(rig.infos).not.toContainEqual(+ expect.objectContaining({ event: 'crash-detection.machine-level-death' }),+ );+ });++ test('a stale sentinel with a fresh dump still arms, as the dump-driven variant', () => {+ const rig = makeRig();+ createCrashDetection(rig.deps).detectBootCrash();+ seedSentinel(rig, rig.nowMs());+ rig.advance(STALE_CRASH_AFTER_MS);+ const dumpAt = new Date(rig.nowMs());+ seedMinidump(rig, 'completed/fresh.dmp', dumpAt);++ const armed = createCrashDetection(rig.deps).detectBootCrash();+ expect(bootInvite(armed).context.dirtyShutdown).toBe(false);+ expect(bootInvite(armed).crashedAt).toBe(dumpAt.toISOString());+ });++ test('a dump older than the staleness bound no longer arms on every launch', () => {+ const rig = makeRig();+ const prior = createCrashDetection(rig.deps);+ prior.detectBootCrash();+ prior.markCleanQuit();+ rig.advance(10 * 60_000);+ seedMinidump(rig, 'completed/ancient.dmp', new Date(rig.nowMs()));+ rig.advance(STALE_CRASH_AFTER_MS);++ expect(createCrashDetection(rig.deps).detectBootCrash()).toBeNull();+ expect(rig.infos).toContainEqual(+ expect.objectContaining({+ event: 'crash-detection.machine-level-death',+ reason: 'stale-crash',+ deathAtSource: 'dump-mtime',+ }),+ );+ });++ test('a dump inside the bound arms as before', () => {+ const rig = makeRig();+ const prior = createCrashDetection(rig.deps);+ prior.detectBootCrash();+ prior.markCleanQuit();+ rig.advance(10 * 60_000);+ seedMinidump(rig, 'completed/recent.dmp', new Date(rig.nowMs()));+ rig.advance(STALE_CRASH_AFTER_MS / 2);++ const armed = createCrashDetection(rig.deps).detectBootCrash();+ expect(bootInvite(armed).context.newMinidumps).toBe(1);+ });++ test('an aged-out dump never dates a death the heartbeat says was seconds ago', () => {+ const rig = makeRig();+ const prior = createCrashDetection(rig.deps);+ prior.detectBootCrash();+ prior.markCleanQuit();+ rig.advance(10 * 60_000);+ seedMinidump(rig, 'completed/ancient.dmp', new Date(rig.nowMs()));+ rig.advance(STALE_CRASH_AFTER_MS + 60 * 60_000);+ const lastAliveMs = rig.nowMs();+ seedSentinel(rig, lastAliveMs);+ rig.advance(60_000);++ const armed = createCrashDetection(rig.deps).detectBootCrash();+ expect(rig.infos).not.toContainEqual(+ expect.objectContaining({ event: 'crash-detection.machine-level-death' }),+ );+ expect(bootInvite(armed).crashedAt).toBe(new Date(lastAliveMs).toISOString());+ expect(bootInvite(armed).context.dirtyShutdown).toBe(true);+ });++ test('a reboot beside an aged-out dump reports the death the heartbeat dated, not the dump', () => {+ const rig = makeRig();+ const prior = createCrashDetection(rig.deps);+ prior.detectBootCrash();+ prior.markCleanQuit();+ rig.advance(10 * 60_000);+ seedMinidump(rig, 'completed/ancient.dmp', new Date(rig.nowMs()));+ rig.advance(STALE_CRASH_AFTER_MS + 60 * 60_000);+ const lastAliveMs = rig.nowMs();+ seedSentinel(rig, lastAliveMs, 'boot-epoch-a');+ rig.advance(60_000);+ rig.setBootSessionUuid('boot-epoch-b');++ const armed = createCrashDetection(rig.deps).detectBootCrash();+ expect(bootInvite(armed).crashedAt).toBe(new Date(lastAliveMs).toISOString());+ expect(bootInvite(armed).eventId).toBe(`boot:${String(lastAliveMs)}`);+ expect(bootInvite(armed).context.dirtyShutdown).toBe(true);+ });++ test('a future-dated heartbeat cannot outrank a fresh dump across a reboot', () => {+ const rig = makeRig();+ const prior = createCrashDetection(rig.deps);+ prior.detectBootCrash();+ prior.markCleanQuit();+ rig.advance(10 * 60_000);+ const dumpAt = new Date(rig.nowMs());+ seedMinidump(rig, 'completed/fresh.dmp', dumpAt);+ seedSentinel(rig, rig.nowMs() + 3 * 60 * 60_000, 'boot-epoch-a');+ rig.advance(60_000);+ rig.setBootSessionUuid('boot-epoch-b');++ const armed = createCrashDetection(rig.deps).detectBootCrash();+ expect(bootInvite(armed).context.dirtyShutdown).toBe(false);+ expect(bootInvite(armed).eventId).toBe(`boot:dump:${String(dumpAt.getTime())}`);+ expect(bootInvite(armed).crashedAt).toBe(dumpAt.toISOString());+ });++ test('a dirty shutdown is never dated by a dump it says did not explain the death', () => {+ const rig = makeRig();+ const prior = createCrashDetection(rig.deps);+ prior.detectBootCrash();+ prior.markCleanQuit();+ rig.advance(10 * 60_000);+ seedMinidump(rig, 'completed/older.dmp', new Date(rig.nowMs()));+ rig.advance(6 * 24 * 60 * 60_000);+ seedSentinel(rig, rig.nowMs() + 3 * 60 * 60_000);+ rig.advance(60_000);++ const armed = createCrashDetection(rig.deps).detectBootCrash();+ expect(bootInvite(armed).context.dirtyShutdown).toBe(true);+ expect(bootInvite(armed).crashedAt).toBeUndefined();+ });++ test('a reboot beside a future-dated heartbeat and no dump reports an undatable death', () => {+ const rig = makeRig();+ seedSentinel(rig, rig.nowMs() + 3 * 60 * 60_000, 'boot-epoch-a');+ rig.advance(60_000);+ rig.setBootSessionUuid('boot-epoch-b');++ expect(createCrashDetection(rig.deps).detectBootCrash()).toBeNull();+ const breadcrumb = rig.infos.find(+ (line) => line.event === 'crash-detection.machine-level-death',+ );+ expect(breadcrumb).toMatchObject({+ reason: 'system-reboot',+ class: 'external',+ machineCause: 'system-reboot',+ deathAt: null,+ deathAtSource: null,+ deathAgeMs: null,+ });+ expect(breadcrumb?.lastAliveAt).toEqual(expect.any(String));+ expect(breadcrumb?.sentinelAgeMs).toBeLessThan(0);+ });++ test('an install in flight is named on the prompt when the heartbeat outlived the dump', () => {+ const rig = makeRig();+ const prior = createCrashDetection(rig.deps);+ prior.detectBootCrash();+ prior.markCleanQuit();+ rig.advance(10 * 60_000);+ seedMinidump(rig, 'completed/earlier.dmp', new Date(rig.nowMs()));+ rig.advance(60 * 60_000);+ const lastAliveMs = rig.nowMs();+ seedSentinel(rig, lastAliveMs);+ wireRealUpdater(rig, committedInstallOf('0.66.2', lastAliveMs - 5 * 60_000));+ rig.advance(60_000);++ const armed = createCrashDetection(rig.deps).detectBootCrash();+ expect(bootInvite(armed).context.dirtyShutdown).toBe(true);+ expect(bootInvite(armed).context.newMinidumps).toBe(1);+ expect(rig.infos).toContainEqual(+ expect.objectContaining({+ event: 'crash-detection.boot',+ dirtyShutdown: true,+ attemptedInstall: '0.66.2',+ }),+ );+ });++ test('a sentinel with no last-alive stamp is never stale — pre-0.35 sentinels are exempt', () => {+ const rig = makeRig();+ mkdirSync(dirname(rig.deps.sentinelPath), { recursive: true });+ writeFileSync(+ rig.deps.sentinelPath,+ JSON.stringify({+ bootId: String(rig.nowMs()),+ startedAt: new Date(rig.nowMs()).toISOString(),+ }),+ );+ rig.advance(4 * STALE_CRASH_AFTER_MS);++ const armed = createCrashDetection(rig.deps).detectBootCrash();+ expect(bootInvite(armed).context.dirtyShutdown).toBe(true);+ expect(bootInvite(armed).crashedAt).toBeUndefined();+ });++ test('a sentinel inside the bound prompts as it always has, dated by its last heartbeat', () => {+ const rig = makeRig();+ const lastAliveMs = rig.nowMs();+ seedSentinel(rig, lastAliveMs);+ rig.advance(STALE_CRASH_AFTER_MS / 2);++ const armed = createCrashDetection(rig.deps).detectBootCrash();+ expect(bootInvite(armed).context.dirtyShutdown).toBe(true);+ expect(bootInvite(armed).crashedAt).toBe(new Date(lastAliveMs).toISOString());+ });++ test('an expired invitation is re-offered on the next launch, not retired for good', () => {+ const rig = makeRig();+ const prior = createCrashDetection(rig.deps);+ prior.detectBootCrash();+ prior.markCleanQuit();+ rig.advance(10 * 60_000);+ rig.setRendererAvailable(false);+ const dumpAt = new Date(rig.nowMs());+ seedMinidump(rig, 'completed/fresh.dmp', dumpAt);++ const expiring = createCrashDetection(rig.deps);+ const firstArmed = expiring.detectBootCrash();+ expect(firstArmed).not.toBeNull();+ rig.advance(INVITE_EXPIRE_AFTER_MS);+ rig.setRendererAvailable(true);+ expiring.notifyRendererReady();+ expect(rig.emitted).toHaveLength(0);+ expiring.markCleanQuit();++ const relaunched = createCrashDetection(rig.deps);+ const rearmed = relaunched.detectBootCrash();+ expect(bootInvite(rearmed).eventId).toBe(firstArmed?.eventId);+ relaunched.notifyRendererReady();+ expect(rig.emitted).toHaveLength(1);+ expect(bootInvite(rig.emitted[0] ?? null).crashedAt).toBe(dumpAt.toISOString());+ });++ test('the invitation carries when the crash happened, not only its boot id', () => {+ const rig = makeRig();+ const prior = createCrashDetection(rig.deps);+ prior.detectBootCrash();+ prior.markCleanQuit();+ rig.advance(10 * 60_000);+ const dumpAt = new Date(rig.nowMs());+ seedMinidump(rig, 'completed/fresh.dmp', dumpAt);++ const armed = createCrashDetection(rig.deps).detectBootCrash();+ expect(bootInvite(armed).crashedAt).toBe(dumpAt.toISOString());+ });+});diff --git a/packages/desktop/src/main/crash-detection.ts b/packages/desktop/src/main/crash-detection.tsindex 5ad01be2e..6e280e979 100644--- a/packages/desktop/src/main/crash-detection.ts+++ b/packages/desktop/src/main/crash-detection.ts@@ -32,6 +32,12 @@ export const GPU_CRASH_WINDOW_MS = 5 * 60_000;const INVITE_SUPERSEDE_AFTER_MS = 5 * 60_000;+export const HANDOFF_TEARDOWN_WINDOW_MS = 30_000;++export const INVITE_EXPIRE_AFTER_MS = 24 * 60 * 60_000;++export const STALE_CRASH_AFTER_MS = 7 * 24 * 60 * 60_000;+const MAX_ACKED_EVENT_IDS = 50;const DECLINED_DEATH_DUMP_MATCH_MS = 30_000;@@ -66,6 +72,7 @@ interface ClassifiedDump {ownership: MinidumpOwnership;crashKind: MinidumpCrashKind | null;declined: DeclinedDeathMatch;+ handoffShadowed: boolean;}interface CrashAckStore {@@ -316,6 +323,20 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {function tryDeliver(): void {if (active === null || active.delivered) return;+ const pendingAgeMs = deps.now().getTime() - active.armedAtMs;+ if (pendingAgeMs >= INVITE_EXPIRE_AFTER_MS) {+ deps.logger.info(+ {+ event: 'crash-detection.invitation-expired',+ eventId: active.event.eventId,+ pendingAgeMs,+ expireAfterMs: INVITE_EXPIRE_AFTER_MS,+ },+ 'crash invitation went unanswered past its staleness bound — dropping it undelivered',+ );+ active = null;+ return;+ }if (deps.emit(active.event)) {active.delivered = true;}@@ -464,6 +485,16 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {prevAppVersion = asReportableAppVersion(field('appVersion'));}+ const detectedAtMs = detectedAt.getTime();+ const lastAliveMs = epochMsOrNull(prevLastAliveAt);+ const deathFromMs = lastAliveMs ?? detectedAtMs;+ const deathFromSource = lastAliveMs !== null ? 'last-alive' : 'detected-at';+ const installInFlight =+ deps.installInFlight?.({ deathFromMs, deathToMs: detectedAtMs }) ?? null;+ const shadowingHandoffAt = installInFlight?.recordedHandoff+ ? installInFlight.handoffAt+ : null;+const freshDumps: ClassifiedDump[] = freshMinidumpEntries().map((entry) => {const ownership = classifyDump(entry.path);return {@@ -474,6 +505,11 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {ownership === 'ours'? declinedDeathForDump(entry): { matched: null, read: 'not-asked' },+ handoffShadowed:+ ownership === 'ours' &&+ shadowingHandoffAt !== null &&+ entry.mtimeMs >= shadowingHandoffAt &&+ entry.mtimeMs - shadowingHandoffAt <= HANDOFF_TEARDOWN_WINDOW_MS,};});const foreignDumpCount = freshDumps.filter((d) => d.ownership === 'foreign').length;@@ -520,8 +556,26 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {'ignored minidumps that this app could not claim',);}+ if (shadowingHandoffAt !== null) {+ const shadowingHandoffAtIso = new Date(shadowingHandoffAt).toISOString();+ for (const shadowed of freshDumps.filter((d) => d.handoffShadowed)) {+ deps.logger.info(+ {+ event: 'crash-detection.dump-handoff-shadowed',+ dumpMtimeAt: new Date(shadowed.entry.mtimeMs).toISOString(),+ handoffAt: shadowingHandoffAtIso,+ teardownWindowMs: HANDOFF_TEARDOWN_WINDOW_MS,+ attemptedInstall: installInFlight?.attemptedVersion ?? null,+ },+ 'ignored a minidump written after this app committed to quitting for an update install',+ );+ }+ }const arming = (d: ClassifiedDump): boolean =>- d.ownership !== 'foreign' && d.crashKind !== 'non-crash' && d.declined.matched === null;+ d.ownership !== 'foreign' &&+ d.crashKind !== 'non-crash' &&+ d.declined.matched === null &&+ !d.handoffShadowed;const newDumps = freshDumps.filter(arming).map((d) => d.entry.mtimeMs);const ownedDumpCount = freshDumps.filter((d) => d.ownership === 'ours' && d.crashKind !== 'non-crash',@@ -535,23 +589,37 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {sentinelPresent &&(rebootedBetweenSessions || prevPendingOsShutdownAt !== null || prevSuspendedAt !== null);- const detectedAtMs = detectedAt.getTime();- const lastAliveMs = epochMsOrNull(prevLastAliveAt);- const deathFromMs = lastAliveMs ?? detectedAtMs;- const deathFromSource = lastAliveMs !== null ? 'last-alive' : 'detected-at';- const installInFlight =- deps.installInFlight?.({ deathFromMs, deathToMs: detectedAtMs }) ?? null;const updateInstallDeath = sentinelPresent && installInFlight !== null;+ const suppressibleDeath = machineLevelDeath || updateInstallDeath;+ const sentinelAgeMs = lastAliveMs === null ? null : detectedAtMs - lastAliveMs;+ const sentinelOutdatedByDump =+ sentinelPresent && sentinelAgeMs !== null && sentinelAgeMs >= STALE_CRASH_AFTER_MS;+ const newestDumpMs = newDumps.length > 0 ? Math.max(...newDumps) : null;+ const datableLastAliveMs =+ lastAliveMs === null || lastAliveMs > detectedAtMs ? null : lastAliveMs;+ const deathAtMs =+ newestDumpMs === null || datableLastAliveMs === null+ ? (newestDumpMs ?? datableLastAliveMs)+ : Math.max(newestDumpMs, datableLastAliveMs);+ const deathAtSource =+ deathAtMs === null ? null : deathAtMs === newestDumpMs ? 'dump-mtime' : 'last-alive';+ const deathAgeMs = deathAtMs === null ? null : detectedAtMs - deathAtMs;+ const crashTooOld = deathAgeMs !== null && deathAgeMs >= STALE_CRASH_AFTER_MS;+ const somethingToReport = sentinelPresent || newDumps.length > 0;++ const machineSuppressed = suppressibleDeath && newDumps.length === 0;let armed: OkBugReportCrashDetectedEvent | null = null;- if ((machineLevelDeath || updateInstallDeath) && newDumps.length === 0) {- const reason = rebootedBetweenSessions- ? 'system-reboot'- : prevPendingOsShutdownAt !== null- ? 'os-shutdown'- : prevSuspendedAt !== null- ? 'suspended'- : 'update-install';+ if (machineSuppressed || crashTooOld) {+ const reason = !machineSuppressed+ ? 'stale-crash'+ : rebootedBetweenSessions+ ? 'system-reboot'+ : prevPendingOsShutdownAt !== null+ ? 'os-shutdown'+ : prevSuspendedAt !== null+ ? 'suspended'+ : 'update-install';const breadcrumb = {event: 'crash-detection.machine-level-death',reason,@@ -567,6 +635,19 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {prevBootSessionUuid,currentBootSessionUuid: bootSessionUuid,lastAliveAt: prevLastAliveAt,+ sentinelAgeMs,+ deathAgeMs,+ deathAt: deathAtMs === null ? null : new Date(deathAtMs).toISOString(),+ deathAtSource,+ staleAfterMs: STALE_CRASH_AFTER_MS,+ class: machineSuppressed ? 'external' : 'stale',+ machineCause: rebootedBetweenSessions+ ? 'system-reboot'+ : prevPendingOsShutdownAt !== null+ ? 'os-shutdown'+ : prevSuspendedAt !== null+ ? 'suspended'+ : null,suspendedAt: prevSuspendedAt,pendingOsShutdownAt: prevPendingOsShutdownAt,osShutdownReasons: prevOsShutdownReasons,@@ -583,11 +664,15 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {? 'previous session was killed by a system reboot — suppressing the report prompt': reason === 'suspended'? 'previous session died asleep without resuming — suppressing the report prompt'- : 'previous session was killed by an update install — suppressing the report prompt',+ : reason === 'stale-crash'+ ? 'previous session died too long ago to report usefully — suppressing the report prompt'+ : 'previous session was killed by an update install — suppressing the report prompt',);}- } else if (sentinelPresent || newDumps.length > 0) {- const dumpDriven = !sentinelPresent || machineLevelDeath || updateInstallDeath;+ } else if (somethingToReport) {+ const dumpDriven =+ (!sentinelPresent || suppressibleDeath || sentinelOutdatedByDump) &&+ deathAtSource === 'dump-mtime';const eventId = dumpDriven? `boot:dump:${Math.max(...newDumps)}`: `boot:${prevBootId ?? `unreadable:${detectedAt.getTime()}`}`;@@ -598,12 +683,14 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {const dumpAccessibilityMode =eventDump === undefined ? null : readMinidumpAccessibilityMode(eventDump.entry.path);const crashedAppVersion = dumpDriven ? (dumpVersion?.version ?? null) : prevAppVersion;+ const crashedAtMs = dumpDriven ? (eventDump?.entry.mtimeMs ?? null) : datableLastAliveMs;const event: OkBugReportCrashDetectedEvent = {eventId,kind: 'boot',context: { dirtyShutdown: !dumpDriven, newMinidumps: newDumps.length },minidumpAvailable: ownedDumpCount > 0,...(crashedAppVersion !== null ? { crashedAppVersion } : {}),+ ...(crashedAtMs !== null ? { crashedAt: new Date(crashedAtMs).toISOString() } : {}),};if (armInvite(event)) {armed = event;