carlos / platform Public

Restore a deleted instance with its own parked data (same host) Feature Request open

Claimed by claude~paul@keymail.dev 3 weeks ago

Base (carlos/base, a front door that installs apps onto the account it runs on) needs to uninstall an app and later reinstall it with its data intact. Today it can't.

What happens: Base deletes the instance on uninstall (DELETE .../instances/{host}). Platform parks the database, as documented. On reinstall Base creates the instance again on the same host, and Platform refuses:

oficina-welcome.bds.oncarlos.com is in use or has held an app's data before, so it can't be created. Choose another address.

Seen live on account oficina (bds), 2026-11-07, from both the CLI and a service credential with the instance role.

I understand this is the never-reuse rule from docs/superpowers/specs/2026-10-26-nearest-region-without-claims-design.md: a recreated hostname must not surface stale data from another region, a move, or an earlier tenant. Base doesn't want the name reused for something new. It wants the same instance back, with its own parked data, in the same account and app.

Request: a supported way to restore a deleted instance, with its parked data, for the same app in the same account. Something like carlos instances restore --app <a> --host <h> and an instance-role door to match, refused when the host's data belongs to another app or account or can't be proven to be this instance's own. Alternatively, a way to stop an instance (no route, data kept) and start it again, so uninstalling doesn't delete it at all.

Until then, Base will give a reinstalled app a fresh address and tell the person it starts empty.

There may be a reason this isn't possible; if so, say, and Base will design around it for good.

Taken (Paul, 2026-11-07). Platform will add a supported restore; Base does not need to design around this for good.

Direction:

  • This is a restore, not a reuse. The hostname history's never-reuse rule stays as it is.
  • For a host first marked after the history went active, the mark names the only account and app that ever held it. That is the proof the data is the instance's own.
  • Restore brings the record back in the region where the last copy lived, never through nearest-region placement. A move leaves an older parked copy in its source region, so placement could surface stale data.
  • Delete will keep a durable note of where the last copy lived. Instances deleted before that change (like oficina-welcome) are restorable only if a check of that one host finds its data in exactly one place.
  • Refused: the mark predates activation, the account, app or kind differs, a live record exists, or a move is in flight.

Next: a spec on a design branch, then a plan. Until it ships, Base's interim (fresh address, starts empty) stands.

Spec status (branch design-instance-restore-658): stopping rule 2 triggered.

Round 1 (NOT READY): three P1s (provenance, staging, seeds), four P2s. Rev 3 fixed all of them. The staging leftover turned out to be a live bug outside restore, filed as #661. Round 2 (NOT READY): staging, seeds and all four P2s resolved. Two new P1s in the same family as round 1's provenance P1:

  1. Rev 3 proved "this mark was written under the current activation" by comparing timestamps. That fails: managed-fleet enrolment rewrites @mode.At, and a clock correction can order a pre-activation mark after activation.
  2. "Every allocation names the current app lifetime" passes vacuously for a host created with lifetimes off after activation. An app purged and recreated under the same name could then restore the old app's data. One new P2: ownership-first hides the owner's own detailed refusals. Fix: split ownership from eligibility.

Recommended cut, waiting on Paul: record provenance explicitly at the original create, from this release on, instead of reconstructing it. Each create whose mark is written fresh while the history has completed activation, with lifetimes on, flags its allocation row as a restore origin. Restore requires that flag on the original allocation and the same app lifetime on every allocation, checked in one function, with a randomized simulation guarding it. Anything without the flag is refused up front. That means only instances created after the release are restorable.

Spec review is over. Round 3 (Astra) came back READY AFTER FIXES with no P1. Its one P2 (a guard-simulation fixture with unmarked older data) is applied in rev 5, commit 20730f9d on design-instance-restore-658: docs/superpowers/specs/2026-11-07-instance-restore-658-design.md. Waiting on Paul's approval before the plan.

Spec rev 5 approved by Paul (2026-11-08). Plan next, on the same branch.

Plan status: stopping rule 2 triggered on the plan (the spec stays approved).

Plan round 1 (NOT READY): 3 P1, 5 P2. All fixed in plan rev 2. Plan round 2 (NOT READY): 5 resolved, 3 partly. Two P1s:

  1. Refusal precedence, the same family as round 1's duplicate P1. Rev 2's duplicate answer came before the pending check, so a delete pending before N1 answers "already exists" instead of R1.
  2. The simulation's new liveness assertion demands success after the history is invalidated, where R2 is correct. P2s: skipping the whole region block also drops the manifest allow-list and replica checks; CI doesn't run the simulation niced; NewestRetirement needs a rowid tie-break.

Recommended cut, waiting on Paul: state the admission rule once, as a precedence table in the plan, enforced in restoreProof alone. The order is: read error R1, then foreign S1, then pending R1, then duplicate, then mode R2, lineage R4/R8, retirement R8, shape R7, region R5, staging R6. A table test pins that order, and the simulation checks it against an independent oracle that encodes the same table, rather than calling restoreProof. Region becomes "choose the stored region, then run the ordinary region validation". CI niceness comes from a nice wrapper in the test itself, with a priority check.

Plan round 3 (last in budget): NOT READY. Rev 3's table and every round-2 finding are resolved except one partly. Two P1s, different causes:

  1. Precedence again, now at the code level. The deciding proof sits at the mark step, but the core's admit (lifetimes_create.go:99) and planCreateLocked (:103), and the leftover rail's duplicate check, can answer first. A host that turns pending between the two evaluations then gets 409 settling or "already exists" instead of R1.
  2. Test launcher. Linux syscall.Getpriority returns 20 - nice, so the planned ">= 10" check is inverted. P2: the niced child drops -test.short.

Copy deck approved by Paul (no edits), committed 769a26fa.

Recommendation to Paul: no fourth plan round. Apply the three fixes as stated: move the deciding proof before admit inside the lock hold, bypass the leftover rail entirely for a restore, normalise the priority, forward -test.short with a timeout. Then let Task 6's own Astra review check the placement in real code.

MERGED as 3933abe (2026-11-08): the instance create door accepts "restore": true. A service credential with the instance role can use it now: POST /api/cli/apps/{account}/{app}/instances with "restore": true brings back a deleted plain instance on the same host with whatever data it kept. The answer's "restore": true means the restore was accepted, not that the data is already back.

Limits: own region (the console's), plain instances, created and deleted after the release that carries this. Not released yet; it ships with the next platform release.

Still owed: the CLI's --restore flag (a small follow-up branch, in progress), the release, and the dev check from the spec (§8).

CLI side MERGED as 663b76b: carlos instances create --restore. Both halves are on main and ship with the next platform release. Owed after the release: the spec §8 dev check (create, write, delete, restore, read back; then the refusals), reported here.

Dev check after v0.34.31 (dev console): restore cannot pass yet. wakecheck (ops) instance restore658-a.dev.carlosframework.com: created 21:37Z, 4 rows written, deleted 21:38Z. A plain re-create was refused by the leftover rail, as expected. create --restore was refused with S1 ("is in use or has held an app's data before"). Cause, read-only: neither dev nor flagship has run carlos system lifetimes cutover. There is no control/lifetimes-cutover.json and control/host-incarnations/ is empty on both. With no slot, stage 1 fails, so the owner gets S1 rather than R2. That means restore is inert on both deployments until the cutover, which is one-way and needs every box on a lifetimes release first. Hosts created before the cutover stay non-restorable (no restore_origin). UX gap: on a lifetimes-off console the owner should see R2, not S1. The throwaway host keeps its mark and parked replica; nothing was purged.