Skip to content

fix(native): finish a Ctrl-C stop lost with its VM through hack down --recover (HACK-2746) - #1290

Merged
roodboi merged 12 commits into
nextfrom
claude-lead/ctrl-c-loss-recover
Nov 27, 2026
Merged

roodboi merged 12 commits into
nextfrom
claude-lead/ctrl-c-loss-recover

Conversation

@roodboi

@roodboi roodboi commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes HACK-2746. When the VM is lost during a Ctrl-C stop, hack down --recover now finishes that stop with data kept, and hack up then starts the run.

The bug

On a real VM, a foreground hack up reached ready and was stopped with Ctrl-C. About 50 ms later, while the receipt read cleanup-intent, the provider was killed. This failed 3 of 3 times on #1279 and 1 of 1 on next:

  • The advice named hack down --recover, which answered runtime_not_running.
  • hack up refused with graph_foreground_owner_exited_unadmitted.
  • runtime recover changed nothing.

No command got the run back.

Cause

In the kept evidence home, the receipt is at cleanup-intent. The owner's enrolled relay cleanup marker is still pending for the run's boot, and its bridge selection (relay-cleanup-bridges.json, one route) is beside it. The run's slots were already released.

The runtime's cross-boot dead-owner recovery already admits exactly this receipt (interrupted_enrollment in prepare) once the pool boots again. But nothing in the host-file selection showed it, so hack down --recover never started the stopped pool.

Fix

  • graph foreground-owner reports a new field, cross_boot_stop (dead_owner_cleanup::interrupted_stop). It is true when the receipt is at cleanup-intent with all of the following:
    • a valid pending relay cleanup marker for one of the pool's recorded boots;
    • the persisted bridge selection;
    • a provable dead relay owner, by that selection's routes or by a settled relay startup.
  • nativeCrossBootRecoverable admits that receipt, so hack down --recover starts the stopped pool and the runtime finishes the stop.
  • The ready-stage advice (nativeReadyLossRetirable) names the down for cleanup-intent only with cross_boot_stop or a selected dead-owner recovery. Otherwise it names no command, and with fix(native): name only recoveries the runtime accepts after a lost VM (HACK-2731) #1279's cause-line fix, neither does the cause line.
  • The retained-start preflight reports such a run as graph_foreground_owner_exited, naming hack down --recover, then hack up. hack up then recovers it itself, as for a ready run (HACK-2456).

Model

ForegroundLossRecovery.tla gains a Stopping stage (Ctrl-C while serving) and two rules, StopRecovery and StopAdvice. positive holds across 752 states. The new no-cross-boot-stop negative control is the runtime and message before this fix, and it fails NoRefusedAdvice at Stopping, as the VM did. The README and state chart are updated:

Foreground loss recovery state chart

Real VM (at 35bc2f3e)

Apple Silicon, pinned SmolVM 1.35.4, fresh isolated homes. The scenario: on a web and database project, a foreground hack up reaches ready, Ctrl-C goes to the process group, and the provider is SIGKILLed about 50 ms later while the receipt reads cleanup-intent.

Row Observed Result
1. Ctrl-C stop lost at cleanup-intent, then hack down --recover (3 runs) The foreground exits 1 in 0.13 to 0.36 s, and the advice names hack down --recover. down --recover exits 0 in 2.9, 4.1 and 2.8 s: it starts the pool, stops the services with data retained, and ps shows stopped-data-retained. hack up is then ready in 1.6 to 2.5 s, with the web page served and the database row kept. 3 of 3 PASS
2. The same, then a plain hack up with no down Ready in 7.8 s, with the "runtime had stopped under this run … recovered with data retained" note. The page is served, the row is kept, and a clean down follows PASS
3. The home kept from #1279 at 93af4083, driven by this binary down --recover exits 0 in 4.5 s, then up -d works with the row kept, and the cleanup is clean. The old receipt shape recovers PASS
4a. #1279: a no-port run with an unsettled relay No command is named, and a plain down does not start the pool. Unchanged PASS
4b. #1279: brought-back containers from a pre-#1273 run down --recover starts the pool and removes them, then up works. Unchanged PASS
5. smoke PASS

The commits after 35bc2f3e change only message text (the lost-VM cause line, from #1279), add a test, or merge next. The VM rows therefore still apply to this head.

Validation

  • Tests that fail on the old behaviour:
    • Rust: a_stop_interrupted_inside_its_enrolled_relay_cleanup_is_a_cross_boot_stop and the HACK-2746 case in a_remaining_publication_names_its_owner_state_without_effects.
    • TS: the cleanup-intent row of down --recover starts a stopped pool for a start lost before ready, the interrupted-stop rows of nativeLostStartRetirable, and the ready-stage and restart-preflight cleanup-intent rows. Removing the TS fix fails 5 of them. a Ctrl-C stop lost with its VM names the down in advice and cause only when the runtime finishes it checks the advice and the cause line together.
  • git diff origin/next...HEAD is this change only. next holds fix(native): name only recoveries the runtime accepts after a lost VM (HACK-2731) #1279 as a squash, and the merge resolves to this branch's side.
  • Mac:
    • Focused bun tests pass, root typecheck passes, and check passes with 111 warnings, the same as next.
    • cargo +1.97.1 fmt --check passes, and clippy -D warnings passes with default features and with --all-features.
    • provider::graph tests under the native-bench lock pass.
    • test:models, privacy:check and gitleaks pass.
  • Linux (the repo's toolchain image, --init): fmt, both clippy runs, test-runtime-core.sh with default features and with --all-features, and test:models pass.

🤖 Generated with Claude Code


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

roodboi and others added 11 commits November 26, 2026 15:03
… (HACK-2731)

Low follow-ups from the #1273 and #1274 reviews:

- The storage barrier reports `graph_cleanup_uncertain` only for a flush
  that did not confirm (deadline, lost reply or a failed guest command).
  `guest_identity_mismatch`, `runtime_changed` and every other error keep
  their own code.
- `graph foreground-owner` reports `cross_boot_relay`: whether the
  cross-boot recovery can prove the dead relay owner (a bridge slot, or a
  settled relay startup). A live run with no published port and an
  unsettled relay is no longer advised `hack down --recover`, and the down
  no longer starts the pool for it; the ready-stage message (and a
  restart's preflight loss) asks the runtime first.
- A lost start's advice parses the reply with the down's own parser
  (`parseNativeForegroundOwner`), so version, owner and digest checks
  cannot drift apart.
- `hack down --recover` starts a stopped pool for a stopped run whose
  lost-removal repair is owed: the refused `hack up` leaves a marker beside
  the run mapping, and the runtime reports an unconfirmed repair
  (`lost_removal_pending`). A verified stop clears the marker. This ends
  the `hack up` / `down --recover` loop after the pool goes idle.

The ForegroundLossRecovery model gains relay settlement (`settled`,
`Unsettled`, `LiveRelayAdvice`) and the `live-relay` negative control,
which fails on #1273's message rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e relay (HACK-2731)

#1279 review:

- A ready-stage loss now withholds `hack down --recover` only when the
  receipt is live and its relay owner is unprovable
  (`nativeLiveRelayUnprovable`). A VM lost during the owner's own stop
  (`cleanup-intent`, `stopped-data-retained`) or with a pending same-boot
  recovery keeps the down advice it had before, for `hack up` and for a
  restart lost in its preflight.
- `cross_boot_relay` counts a bridge registry as holding the run's slot
  only when the current pool owner wrote it, as its doc says.
- Removing a run mapping removes its lost-removal marker and a temporary
  file an interrupted marker write left beside it.

The ForegroundLossRecovery README says the receipt phase at ready is out
of the model's scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…--recover (HACK-2746)

On a real VM, a Ctrl-C followed by the provider's death while the receipt
read `cleanup-intent` left the run stuck. The advice named
`hack down --recover`, which answered `runtime_not_running`, and `hack up`
refused with `graph_foreground_owner_exited_unadmitted`.

The owner's stop runs inside its enrolled relay cleanup, and the cross-boot
dead-owner recovery already admits that receipt once the pool boots again
(`interrupted_enrollment`). What was missing was a selection that showed it:

- `graph foreground-owner` reports `cross_boot_stop`: the receipt is at
  `cleanup-intent` with a pending relay cleanup marker of one of the
  pool's recorded boots, the persisted bridge selection is beside it, and
  the dead relay owner is provable (its routes, or a settled relay startup).
- `nativeCrossBootRecoverable` admits it, so `hack down --recover` starts a
  stopped pool and the runtime finishes the stop with data kept. The
  ready-stage advice (`nativeReadyLossRetirable`) names the down for
  `cleanup-intent` only with `cross_boot_stop` or a selected dead-owner
  recovery, and names no command otherwise.
- The retained-start preflight reports such a run as
  `graph_foreground_owner_exited`, naming `hack down --recover`, then
  `hack up`. `hack up` then recovers it itself, as for a ready run
  (HACK-2456).

ForegroundLossRecovery gains a `Stopping` stage (Ctrl-C while serving), the
`StopRecovery` and `StopAdvice` rules, and the `no-cross-boot-stop` negative
control, which fails `NoRefusedAdvice` as the VM did. The README and state
chart are updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…HACK-2731)

#1279 review (Codex P2): a ready-stage loss the runtime cannot retire (`retirable` false) names no command, but the start's own error (the final inspection's unconfirmed cleanup) kept its "Run hack down --recover" sentence in the `(cause: …)` line. The cause's recovery sentence is now dropped for that stage too, as it already was for a requested loss.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ad/ctrl-c-loss-recover

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and cause only when finished (HACK-2746)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ad/ctrl-c-loss-recover

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
next holds #1279 squashed (986b7e9); its tree equals this branch's #1279 base (2aba1fd) plus #1280, so each conflict resolves to this branch's side.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/diagrams/foreground-loss-recovery.png
#	docs/diagrams/foreground-loss-recovery.svg
#	docs/guides/native-candidate.md
#	packages/runtime-core/src/provider/graph/bridges/cleanup.rs
#	packages/runtime-core/src/provider/graph/dead_owner_cleanup.rs
#	packages/runtime-core/src/provider/graph/mod.rs
#	scripts/lib/tla-runtime-models.ts
#	src/backends/native-cross-boot-recovery.ts
#	src/backends/native-project-start.ts
#	tests/models/tla/README.md
#	tests/models/tla/foreground-loss-recovery/ForegroundLossRecovery.tla
#	tests/models/tla/foreground-loss-recovery/code-without-veto.cfg
#	tests/models/tla/foreground-loss-recovery/failed-only.cfg
#	tests/models/tla/foreground-loss-recovery/generic-error.cfg
#	tests/models/tla/foreground-loss-recovery/intent-message.cfg
#	tests/models/tla/foreground-loss-recovery/keep-intent.cfg
#	tests/models/tla/foreground-loss-recovery/keep-leftover.cfg
#	tests/models/tla/foreground-loss-recovery/leak-lock.cfg
#	tests/models/tla/foreground-loss-recovery/live-relay.cfg
#	tests/models/tla/foreground-loss-recovery/negative.cfg
#	tests/models/tla/foreground-loss-recovery/no-cross-boot.cfg
#	tests/models/tla/foreground-loss-recovery/pinned-relay.cfg
#	tests/models/tla/foreground-loss-recovery/positive.cfg
#	tests/models/tla/foreground-loss-recovery/restart-recovers.cfg
#	tests/models/tla/foreground-loss-recovery/transitional-veto.cfg
#	tests/models/tla/foreground-loss-recovery/withhold-preparing.cfg
#	tests/models/tla/foreground-loss-recovery/withhold-requested.cfg
#	tests/native-project-down.test.ts
#	tests/native-project-start.test.ts
@roodboi roodboi added the ci:mac Run macOS checks for this pull request label Nov 27, 2026
@vercel

vercel Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hack-docs Ready Ready Preview Nov 27, 2026 7:52pm UTC

Request Review

@roodboi

roodboi commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@linear-code

linear-code Bot commented Nov 27, 2026

Copy link
Copy Markdown

HACK-2746

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T18:14:45.660217Z 8f74c28 Manual request
🔒 Security Review ✅ Completed 2026-11-27T18:17:43.838857Z 8f74c28 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 8f74c285da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 8f74c285da

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Resolved to the tree tested in batch run m3:z498 (lead train sync).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@roodboi
roodboi merged commit cc27cbf into next Nov 27, 2026
6 of 7 checks passed
@roodboi
roodboi deleted the claude-lead/ctrl-c-loss-recover branch November 27, 2026 19:51
roodboi added a commit that referenced this pull request Nov 27, 2026
…top (HACK-2757)

#1291 review (High): a provider SIGKILLed with its VM leaves the pool record
`running` with the dead boot until `runtime recover` writes
`recovered-unclean`, and `runtime status` reads it `process-exited`. The
current-boot exclusion skipped that boot too, so the owner's lost-VM advice
and a plain `hack up` lost `hack down --recover`. That undid #1290's
real-VM rows 1 and 2.

Now the current boot is skipped only while it is live: the record says
`running` and the provider is not proven gone (`identity::provider_gone`,
the check `runtime status` makes). An unreadable provider counts as live,
so nothing is promised then. The tests cover a `running` record with a
dead provider (a cross-boot stop, and `hack up` names the down), and a live
provider (neither).

The case where the VM really keeps running still has no supported recovery.
It is filed as HACK-2763.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:mac Run macOS checks for this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant