Offline door: a malformed claim object is a 502 again; census overlay
The claim object goes back to hostclaim.Read, so one that is present but does not decode and validate as a claim is a 502 exactly as on main; only the claim schema can tell. The admission and backfill checks stay console-local. TestOfflineDoorAbsenceChecksRefuseAndFail pins the 502. Census census-ruling-claims-cleanup-r1 (make census-propose): three body changes and nine envelope re-pins, all approvals, no decision.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 files changed,
+69
−41
docs/superpowers/notes/census-proposal-claims-cleanup-r1.md+23 −0docs/superpowers/plans/2026-10-25-claims-cleanup-r1.md+1 −1internal/console/apiinstancemove_offline.go+9 −8internal/console/apiinstancemove_offline_absence.go+6 −14internal/console/apiinstancemove_offline_absence_test.go+13 −18internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/provision/testdata/plan14-root-reads-claims-cleanup-r1.tsv+16 −0
CI passed — run details
diff --git a/docs/superpowers/notes/census-proposal-claims-cleanup-r1.md b/docs/superpowers/notes/census-proposal-claims-cleanup-r1.md| new file mode 100644 |
| index 000000000..d188f4665 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-claims-cleanup-r1.md |
| @@ -0,0 +1,23 @@ |
| +# Census approval: claims-cleanup-r1 |
| + |
| +Ruling `census-ruling-claims-cleanup-r1`. Every change below keeps the disposition it already has, so it needs an approval, not a decision. |
| + |
| +| unit | change | read sites | what changed | |
| +|---|---|---|---| |
| +| `internal/console/apiinstancemove_offline.go` `Server.offlineClaimEvidence` | body | unchanged (1) | claims cleanup R1: the admission and backfill reads use the console's own keys and a local copy of hostops.BackfillPlan (same store Gets, same refusals) instead of hostops.AdmissionKey and CheckCreateFreeze; the host claim is still read through hostclaim.Read; no read added, the one scanned read (hostclaim.Read) unchanged | |
| +| `internal/console/apiruns.go` `Server.handleAPIRunCreate` | body | unchanged (1) | claims cleanup R1: the request's incarnation comes from provision.Incarnation, hostclaim.Incarnation's body moved unchanged (golden vectors); no read added or changed | |
| +| `internal/host/agent.go` `runAdoptUnderRootRelease` | body | unchanged (4) | claims cleanup R1: the claims shutdown timeout is the host constant claimsShutdownLimit (120s) instead of hostbox.RequestLimit (120s); no read added or changed | |
| + |
| +Envelopes re-pinned: `internal/console`, `internal/dbreads`, `internal/host`, `internal/hostclaim`, `internal/instancectl`, `internal/park`, `internal/provision`, `internal/regionname`, `internal/runs`. |
| + |
| +Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Escalate if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. An escalation goes to the census owner as a decision. |
| + |
| +Recorded dispositions, which each change must still satisfy: |
| + |
| +- `internal/console/apiinstancemove_offline.go` `Server.offlineClaimEvidence`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-moves-offline;basis=root-input (J4, as main's moves units); the console (cmd/console serve under console.service, user carlos-console): new, reads the host claim, the record's acquisition, a domains claim and the app's admission only to refuse an offline start (MV-O29, MV-O20); a failed read refuses with a 502, never reads as absence; deny-only |
| +- `internal/console/apiruns.go` `Server.handleAPIRunCreate`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the console (cmd/console serve under console.service, user carlos-console): the run create door reads the record, and rereads it after an unknown admit, through readRecord, judged under a unit admitted on and unjudged before; read sites unchanged, offsets moved |
| +- `internal/host/agent.go` `runAdoptUnderRootRelease`: authority, task B3,E1,E2,E3. Basis: rev3=census-ruling-self-serve-moves-1;basis=root claim/adopt/update controller uid 0: builds root's lifetime judge once from the host-claim switch and hands it to both productionRestartRequestPass calls; read sites unchanged, offsets moved; the preceding B3,E1,E2,E3 classification retained |
| + |
| +Seal: `a864cf31b6bf2c30b5aa8c2647835efdc456f34f4945eea12751daab2457728e` → `9cef5e93a1e3520e02efe66455bf70c1170d380b6d6a72ede02036ce3dd41924`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-claims-cleanup-r1.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/plans/2026-10-25-claims-cleanup-r1.md b/docs/superpowers/plans/2026-10-25-claims-cleanup-r1.md| index 309d912e6..1606e30a4 100644 |
| --- a/docs/superpowers/plans/2026-10-25-claims-cleanup-r1.md |
| +++ b/docs/superpowers/plans/2026-10-25-claims-cleanup-r1.md |
| @@ -18,7 +18,7 @@ |
| ## Review Focus |
| -- A present-but-malformed `control/hosts/<host>.json`: today a 502 (decode/validate failure); console-local presence check answers 409. Pinned by a test; called out in the report. |
| +- A present-but-malformed `control/hosts/<host>.json` stays a 502: the claim object is still read through `hostclaim.Read`, because only the claim schema can tell a malformed object from a claim. Pinned by `TestOfflineDoorAbsenceChecksRefuseAndFail`. The admission and backfill checks are console-local. |
| - A backfill plan at phase `done` must still be allowed; the console-local verify must re-encode canonically, so the local plan type copies `hostops.BackfillPlan`'s shape exactly (pinned by a test that signs a `hostops.BackfillPlan` and reads it locally). |
| - An invalid host or account shape must still give 502 on the claim and admission checks. |
| - `hostclaim.Incarnation` must keep returning `hostclaim.ErrMalformed` for its claim callers. |
diff --git a/internal/console/apiinstancemove_offline.go b/internal/console/apiinstancemove_offline.go| index ac8b7ba3f..1739c1776 100644 |
| --- a/internal/console/apiinstancemove_offline.go |
| +++ b/internal/console/apiinstancemove_offline.go |
| @@ -17,6 +17,7 @@ import ( |
| "time" |
| "github.com/carlosframework/platform/internal/domains" |
| + "github.com/carlosframework/platform/internal/hostclaim" |
| "github.com/carlosframework/platform/internal/moves" |
| "github.com/carlosframework/platform/internal/provision" |
| "github.com/carlosframework/platform/internal/release" |
| @@ -436,17 +437,17 @@ func (s *Server) offlineClaimEvidence(ctx context.Context, d offlineDoor) *offli |
| if d.rec.Acquisition != "" { |
| return has |
| } |
| - // Any claim object at all refuses; a read that fails is never absence. |
| - claimKey, ok := offlineHostClaimKey(d.host) |
| - if !ok { |
| - log.Printf("console: offline move %s: claim read: invalid host", d.host) |
| + // The claim object is still read through hostclaim: an object that is |
| + // present but does not decode and validate as a claim is a 502, and |
| + // only the claim schema can say which it is (claims cleanup R1 keeps |
| + // this one read where it was). |
| + obs, err := hostclaim.Read(ctx, s.cfg.Releases, d.host) |
| + if err != nil { |
| + log.Printf("console: offline move %s: claim read: %v", d.host, err) |
| return unreadable |
| } |
| - if _, _, err := s.cfg.Releases.Get(ctx, claimKey); err == nil { |
| + if !obs.Absent { |
| return has |
| - } else if !errors.Is(err, os.ErrNotExist) { |
| - log.Printf("console: offline move %s: claim read: %v", d.host, err) |
| - return unreadable |
| } |
| if c, err := domains.GetClaim(ctx, s.cfg.Releases, d.host); err == nil && c.Acquisition != "" { |
| return has |
diff --git a/internal/console/apiinstancemove_offline_absence.go b/internal/console/apiinstancemove_offline_absence.go| index 05bd9128b..1338bf80a 100644 |
| --- a/internal/console/apiinstancemove_offline_absence.go |
| +++ b/internal/console/apiinstancemove_offline_absence.go |
| @@ -11,24 +11,16 @@ import ( |
| "github.com/carlosframework/platform/internal/release" |
| ) |
| -// The offline move door's absence checks (MV-O20, MV-O29), read here and |
| -// not through the host claim packages since claims cleanup R1: host claims |
| -// are off everywhere and their packages are going, but a deployment that |
| -// ever wrote one of these objects must still be refused. Each key is the |
| -// claim packages' own (TestOfflineAbsenceKeysAreTheClaimKeys). |
| +// The offline move door's admission and backfill checks (MV-O20, MV-O29), |
| +// read here and not through hostops since claims cleanup R1: host claims |
| +// are off everywhere and hostops is going, but a deployment that ever wrote |
| +// one of these objects must still be refused. Each key is hostops' own |
| +// (TestOfflineAbsenceKeysAreTheClaimKeys). The claim object itself is still |
| +// read through hostclaim (offlineClaimEvidence). |
| // offlineBackfillKey is the host-claim backfill plan (hostops.BackfillKey). |
| const offlineBackfillKey = "control/hosts-backfill.json" |
| -// offlineHostClaimKey is a host's claim object (hostclaim.Key); false for a |
| -// host that is not host-shaped. |
| -func offlineHostClaimKey(host string) (string, bool) { |
| - if !controlname.ValidHostShape(host) { |
| - return "", false |
| - } |
| - return "control/hosts/" + host + ".json", true |
| -} |
| - |
| // offlineAdmissionKey is an app's claim admission (hostops.AdmissionKey); |
| // false for an account or app that is not well formed. |
| func offlineAdmissionKey(account, app string) (string, bool) { |
diff --git a/internal/console/apiinstancemove_offline_absence_test.go b/internal/console/apiinstancemove_offline_absence_test.go| index eb7fe77b6..a45536537 100644 |
| --- a/internal/console/apiinstancemove_offline_absence_test.go |
| +++ b/internal/console/apiinstancemove_offline_absence_test.go |
| @@ -22,16 +22,6 @@ func TestOfflineAbsenceKeysAreTheClaimKeys(t *testing.T) { |
| t.Fatalf("backfill key = %q, want %q", offlineBackfillKey, want) |
| } |
| } |
| - for _, host := range []string{offlineHost, "a.b", "", "../x", "UPPER.example.com", "x/y.example.com"} { |
| - got, ok := offlineHostClaimKey(host) |
| - want, err := hostclaim.Key(host) |
| - if ok != (err == nil) || got != want { |
| - t.Errorf("claim key %q = %q %v; hostclaim.Key = %q %v", host, got, ok, want, err) |
| - } |
| - if ok && got != "control/hosts/"+host+".json" { |
| - t.Errorf("claim key %q = %q", host, got) |
| - } |
| - } |
| for _, c := range []struct{ acct, app string }{{"bab", "shop"}, {"BAB", "shop"}, {"bab", ""}, {"", "shop"}, {"bab", "../x"}} { |
| got, ok := offlineAdmissionKey(c.acct, c.app) |
| want, err := hostops.AdmissionKey(c.acct, c.app) |
| @@ -133,17 +123,22 @@ func (s offlineFaultStore) Get(ctx context.Context, key string) ([]byte, string, |
| return s.Store.Get(ctx, key) |
| } |
| -// Any object at the claim key refuses, a well-formed claim or not; any |
| -// failed read of the three objects is a 502 and never an absence. (Before |
| -// claims cleanup R1 a claim object that did not decode and validate as a |
| -// claim was a 502; it is now refused as present, a 409. Either way nothing |
| -// is written.) |
| +// A claim object that is present but does not decode and validate as a |
| +// claim is a 502, as it was before claims cleanup R1 (a valid one is a 409: |
| +// TestOfflineStartRefusals); any failed read of the three objects is a 502 |
| +// and never an absence. Nothing is written either way. |
| func TestOfflineDoorAbsenceChecksRefuseAndFail(t *testing.T) { |
| const body = `{"region":"uk"}` |
| - claimKey, _ := offlineHostClaimKey(offlineHost) |
| + claimKey, err := hostclaim.Key(offlineHost) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| w := newOfflineWorld(t, oneEach...) |
| - offlinePut(t, w.fx.rel, claimKey, []byte("not json")) |
| - w.refused(http.MethodPost, "", body, http.StatusConflict, msgO29) |
| + for _, raw := range []string{"not json", `{}`, `{"v":1,"host":"other.example.com"}`} { |
| + offlinePut(t, w.fx.rel, claimKey, []byte(raw)) |
| + w.refused(http.MethodPost, "", body, http.StatusBadGateway, "could not read the host claim") |
| + w.refused(http.MethodPost, "/stage", body, http.StatusBadGateway, "could not read the host claim") |
| + } |
| if err := w.fx.rel.Delete(context.Background(), claimKey); err != nil { |
| t.Fatal(err) |
| } |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index cd596e877..789a8850a 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -43,3 +43,4 @@ plan14-root-reads-rootfs-apps-2.tsv b1b17467ff148c3a0b1dd3312b7a80498db11cc4b455 |
| plan14-root-reads-edge-protection-2-decisions.tsv 7d90eff62dcb3d2d211b9f0fa37ba1967f1f418884a11c1476cdaa50b187efd5 |
| plan14-root-reads-edge-protection-2.tsv a864cf31b6bf2c30b5aa8c2647835efdc456f34f4945eea12751daab2457728e |
| plan14-root-reads-offline-move-trim-t1.tsv a864cf31b6bf2c30b5aa8c2647835efdc456f34f4945eea12751daab2457728e |
| +plan14-root-reads-claims-cleanup-r1.tsv 9cef5e93a1e3520e02efe66455bf70c1170d380b6d6a72ede02036ce3dd41924 |
diff --git a/internal/provision/testdata/plan14-root-reads-claims-cleanup-r1.tsv b/internal/provision/testdata/plan14-root-reads-claims-cleanup-r1.tsv| new file mode 100644 |
| index 000000000..1c82ae095 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-claims-cleanup-r1.tsv |
| @@ -0,0 +1,16 @@ |
| +# Census overlay claims-cleanup-r1, written by census-propose (#369). census-ruling-claims-cleanup-r1, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-claims-cleanup-r1.md. |
| +# 3 body, 0 sites, 9 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +@legacy 00d2e505f623cf6cebd25ed2c8d71bd5721ad7b7c7ade9d0be49b10f71c0470b internal/console/apiinstancemove_offline.go Server.offlineClaimEvidence legacy accepted-legacy accepted-legacy;rev3=census-ruling-moves-offline;basis=root-input (J4, as main's moves units); the console (cmd/console serve under console.service, user carlos-console): new, reads the host claim, the record's acquisition, a domains claim and the app's admission only to refuse an offline start (MV-O29, MV-O20); a failed read refuses with a 502, never reads as absence; deny-only;rev3=census-ruling-claims-cleanup-r1;basis=claims cleanup R1: the admission and backfill reads use the console's own keys and a local copy of hostops.BackfillPlan (same store Gets, same refusals) instead of hostops.AdmissionKey and CheckCreateFreeze; the host claim is still read through hostclaim.Read; no read added, the one scanned read (hostclaim.Read) unchanged file:Read@645 b9c29234b8db391f37db8b898901a0380b94ff0941e24b9d8ba240f530a79390 |
| +@legacy c7c644f83c1376f5dc136a13ba4009e8178325b5b2dac71c6ff6485d97385054 internal/console/apiruns.go Server.handleAPIRunCreate legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the console (cmd/console serve under console.service, user carlos-console): the run create door reads the record, and rereads it after an unknown admit, through readRecord, judged under a unit admitted on and unjudged before; read sites unchanged, offsets moved;rev3=census-ruling-claims-cleanup-r1;basis=claims cleanup R1: the request's incarnation comes from provision.Incarnation, hostclaim.Incarnation's body moved unchanged (golden vectors); no read added or changed file:Open@2086 a45e07833e363d6c7563bd3263f400b79873a839e51cda286c9d712053dde273 |
| +internal/console/apiinstancemove_offline.go Server.offlineClaimEvidence legacy accepted-legacy accepted-legacy;rev3=census-ruling-moves-offline;basis=root-input (J4, as main's moves units); the console (cmd/console serve under console.service, user carlos-console): new, reads the host claim, the record's acquisition, a domains claim and the app's admission only to refuse an offline start (MV-O29, MV-O20); a failed read refuses with a 502, never reads as absence; deny-only;rev3=census-ruling-claims-cleanup-r1;basis=claims cleanup R1: the admission and backfill reads use the console's own keys and a local copy of hostops.BackfillPlan (same store Gets, same refusals) instead of hostops.AdmissionKey and CheckCreateFreeze; the host claim is still read through hostclaim.Read; no read added, the one scanned read (hostclaim.Read) unchanged file:Read@645 b9c29234b8db391f37db8b898901a0380b94ff0941e24b9d8ba240f530a79390 |
| +internal/console/apiruns.go Server.handleAPIRunCreate legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the console (cmd/console serve under console.service, user carlos-console): the run create door reads the record, and rereads it after an unknown admit, through readRecord, judged under a unit admitted on and unjudged before; read sites unchanged, offsets moved;rev3=census-ruling-claims-cleanup-r1;basis=claims cleanup R1: the request's incarnation comes from provision.Incarnation, hostclaim.Incarnation's body moved unchanged (golden vectors); no read added or changed file:Open@2086 a45e07833e363d6c7563bd3263f400b79873a839e51cda286c9d712053dde273 |
| +internal/host/agent.go runAdoptUnderRootRelease authority B3,E1,E2,E3 rev3=census-ruling-self-serve-moves-1;basis=root claim/adopt/update controller uid 0: builds root's lifetime judge once from the host-claim switch and hands it to both productionRestartRequestPass calls; read sites unchanged, offsets moved; the preceding B3,E1,E2,E3 classification retained;rev3=census-ruling-claims-cleanup-r1;basis=claims cleanup R1: the claims shutdown timeout is the host constant claimsShutdownLimit (120s) instead of hostbox.RequestLimit (120s); no read added or changed whole:Route@11242,whole:Route@18538,whole:Route@18574,whole:Route@8533 1916559ef754fc27b761d2d489a4b34e1870ce050e6d00352788672209e67162 |
| +@coverage internal/console cce9d2eb49af5fcbcfde38c0c6f6d151cb9165bb846478fe5869f44acb8cfa64 |
| +@coverage internal/dbreads 3435a8265f4d16964920439675e1c2f982e5424c8d41248f009f643214d59ddc |
| +@coverage internal/host bb6ea03949a8e370305881229c70fc811c4ce6c6dd5710571e0ca4d396f1f7a1 |
| +@coverage internal/hostclaim 821d6bddd4d98009253602e5f2515b4ad077d6b694308fd7a718f688d227f21e |
| +@coverage internal/instancectl b73cb1ce1f6540bb232d737a6f429147c40bb62eda90b80b4930a0c1d0954cc1 |
| +@coverage internal/park 778a86513bc64068b93e257c09972fbc307ebe401a125a61003f3ad26a28f611 |
| +@coverage internal/provision f444c473b07f7497f3e294503c3d0f8f98e9d7377856d69ae2ecae7f71fc12d8 |
| +@coverage internal/regionname 5815be8b9d786cdf646ae30a3d23350096c3f0bd8200859067db2038affc68e6 |
| +@coverage internal/runs 0b7c525299df1f91b42dbcfb62f8a660ab4cb4256f849d7302dbe9d39b0925be |