writeCrashSnapshot
writeCrashSnapshot(
input):WriteCrashSnapshotResult
Defined in: _worktrees/docs-release/gaunt-sloth/packages/core/src/utils/debugDump.ts:468
GS2-48 — write a MINIMAL, ALWAYS-REDACTED crash snapshot to
~/.gsloth/debug-dumps/crash-<timestamp>/crash.json and return its paths.
This is the unattended sibling of writeDebugDump: it fires from the process-level crash
handler (file://./crashHandler.ts) with no human present, so — unlike /debug-dump — it
exposes NO redact opt-out. Redaction (GS2-47, hard-dep) is MANDATORY and applied to the whole
snapshot. It reuses this module’s location convention (ensureGlobalGslothDir() + debug-dumps/)
and rendering helpers, but deliberately stays minimal and crash-safe:
- a SINGLE
crash.json(not the multi-file interactive archive); - it does NOT shell out for git state (a subprocess is unsafe/slow while the process is dying);
- it keeps only the last CRASH_DEBUG_LOG_TAIL_LINES debugLog lines and the transcript TAIL.
Redaction shape (conscious choice): the entire normalized snapshot is passed through
redactValue in one pass. That is stricter than writeDebugDump, which uses
redactText (literal+pattern only) for its non-config artifacts to avoid field-masking a
legitimately token/secret-named field in tool output. For an unattended crash file the
over-masking is the SAFE direction and buys uniform circular-ref / depth / function handling in
one place, so it is intended, not an oversight. The config subtree is stripped of live instances
first (as writeDebugDump does) so a live LLM client’s internals never serialize.
Callers wrap this in their own try/catch (see file://./crashHandler.ts); it does its best
to be fail-safe internally (redactValue/safeStringify never throw), but the ONE unavoidably
throwing operation is the mkdirSync/writeFileSync to disk — an unwritable ~/.gsloth is what
the handler’s degraded path is for.