fix(heartbeat): durably classify process_lost reaps for the BLO-12292 split (BLO-16181) - #675
Merged
Merged
Conversation
… split (BLO-16181) The reaper's process_lost mint discarded whether a backing k8s Job was ever created and what state it reached, erasing the single most useful discriminator for the fleet-wide process_lost instability (BLO-12292) and for reattach feasibility (BLO-12564): a run whose Job never got a name is unreattachable, while a run whose Job ran and vanished may be. Record a stable classification (plus the raw signals it derives from) on resultJson.processLoss at mint time, from state the reap loop already holds -- no extra kube round-trip. Pod exit codes are N/A here (runs reaching this mint have no inspectable pod), and a confirmed exact-name 404 finalizes upstream as job_missing, never process_lost, so it does not reach this mint either. - New pure module process-loss-classification.ts (classifyProcessLoss + buildProcessLossCapture), exhaustively unit-tested with no DB. - Reaper threads the pre-adapter Job liveness it already resolves into the mint and injects the capture into resultJson. - 4 DB-backed reaper tests assert the persisted processLoss block for pre-adapter-unstamped, started-job-absent (unstamped + stamped), and pre-adapter-stamped-dead (liveness threading). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Hey @kkroo! Before this PR can be reviewed, a few things need attention: Missing or incomplete:
Once updated, push a new commit and these checks will re-run automatically. — commitperclip |
This was referenced Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thinking Path
Linked Issues or Issue Description
Board issue: BLO-16181 (implements the durable-capture recommendation from the BLO-16181 diagnostic spike). Parent: BLO-12292. Consumers: BLO-16184 (monitor), BLO-12564 (reattach). No GitHub issue mirror exists, so the underlying problem is described inline below following the bug template.
What happened
The reaper's
process_lostmint discarded all backing-Job state, leaving no way to tell a Job-never-created loss from a Job-ran-then-vanished loss.Expected behavior
Every
process_lostmint durably records a stable classification + the signals it derives from, queryable atresult_json->'processLoss'->>'classification'.Steps to reproduce
process_lost(pre-adapter setup death, or a started run whose Job left the live snapshot while silent).heartbeat_runs.result_json— before this change there is no structured record of Job/name state.Paperclip version
master @ this PR
Deployment mode
k8s external-lifecycle adapters (
claude_k8s/opencode_k8s)What Changed
server/src/services/process-loss-classification.ts(classifyProcessLoss+buildProcessLossCapture), exhaustively unit-tested with no DB.process_lostmint and threads the pre-adapter Job liveness it already resolves; zero new kube calls — every signal is already in hand at the mint.{externalLifecycleRun:false, classification:"local"}marker so the monitor can exclude them without a join.terminated.{reason,exitCode}is intentionally not captured here: runs reaching this mint have no inspectable pod, and a confirmed exact-name 404 finalizes upstream asjob_missing, neverprocess_lost.Verification
cd server && npx vitest run src/__tests__/process-loss-classification.test.ts— pure unit tests (general shard, no DB), every classification branch. 10/10 green locally.heartbeat-process-recovery.test.ts— 4 DB-backed reaper tests (serialized shard, run in CI) assert the mint persists the correctprocessLossblock for pre-adapter-unstamped, started-job-absent (unstamped + stamped), and pre-adapter-stamped-dead (liveness threading).cd server && npx tsc --noEmit -p tsconfig.json— clean.Risks
Low risk. The change is additive: it only adds a
processLosskey toresultJsonat theprocess_lostmint and threads a new localletinto the reap loop; no control flow, errorCode, or existing field changes.mergeHeartbeatRunStopMetadatapreserves the injected key (spreadsresultJsonfirst). Existing reaper tests assertresultJsonviatoMatchObject(subset), so the added key does not break them.Model Used
Claude Opus 4.8 (model ID
claude-opus-4-8), 1M context window, extended thinking, with tool use / code execution.Checklist
🤖 Generated with Claude Code