region HA: trashed app hosts no longer hold departures (#1192)
On dev IE (2026-11-17) a trashed app's instance record and released lock named member g-03152630. Its departure deferred that host forever (a trashed app has no route), so the member's edges record stayed published and the next drain timed out waiting on the dead box. - release.TrashRetired: one trash rule shared by the fleet drain (#1008 T9), the reconcile and the departure scan. - Departure scan discharges a TrashRetired host once its lock is released or expired; the finalization gate rereads it, so a restore or a production flag keeps the departure. - Drain ack skips a group member whose departure the box has enrolled (termination proven); the report lists it under departed. - close-lost names a still-published edges record and never deletes it (spec V20). Witness: the 11-17 world finishes inside the DR-5 bound; without the rule it stalls; a drain listing the dead member succeeds. Astra R1 READY AFTER FIXES (P2 fixed); census ha-1192 approved on #280; copy by Luna under delegation. Inert until a release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Prompts: <paseo-system version="1" kind="agent-message" source-agent-id="8a3d302a-eac7-407c-b61c-f5ccc66b5544" message-id="18849fb0-bb08-4375-a9e2-eb3928ab8300"> Agent manager 8a3d302: agreed on all four, including the close-lost deviation (report and name the still-published record, no delete; the departure owns retirement). Note it's the same family as #1008 T9's "trashed app record blocks a drain": check that both trash checks now share one rule for "a trashed app's records never hold HA or fleet work". Carry on. </paseo-system> Squashed from ha-1192-close-lost-edges into main.
26 files changed,
+954
−62
docs/superpowers/notes/census-claims-ha-1192.tsv+7 −0docs/superpowers/notes/census-proposal-ha-1192.md+33 −0docs/superpowers/reviews/ASTRA-R1-ha-1192.md+42 −0docs/superpowers/reviews/CODEX-REVIEW-BRIEF-ha-1192.md+117 −0docs/superpowers/reviews/LUNA-COPY-BRIEF-ha-1192.md+47 −0docs/superpowers/reviews/LUNA-COPY-RESULT-ha-1192.md+5 −0docs/superpowers/specs/2026-11-09-group-roll-verb-design.md+1 −0internal/console/fleetrelabel.go+5 −18internal/grouproll/probe_test.go+3 −3internal/grouproll/roll.go+41 −2internal/grouproll/roll_test.go+62 −3internal/grouproll/text.go+1 −0internal/grouproll/text_test.go+4 −3internal/host/agent.go+4 −0internal/host/hadepartures.go+3 −0internal/host/hadepartures_metrics.go+6 −0internal/host/hadepartures_scan.go+77 −12internal/host/hadepartures_trash_test.go+187 −0internal/host/hadepartures_wiring.go+8 −0internal/host/hadrain.go+41 −16internal/host/hadrain_departed_test.go+134 −0internal/provision/reconcile.go+2 −5internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/provision/testdata/plan14-root-reads-ha-1192.tsv+20 −0internal/release/trash.go+32 −0internal/release/trashretired_test.go+71 −0
CI passed — run details
landed from ha-1192-close-lost-edges
diff --git a/docs/superpowers/notes/census-claims-ha-1192.tsv b/docs/superpowers/notes/census-claims-ha-1192.tsv| new file mode 100644 |
| index 000000000..ba2f0fb77 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-claims-ha-1192.tsv |
| @@ -0,0 +1,7 @@ |
| +internal/grouproll/roll.go:Engine.closeLost operator CLI only (refuses root): after its group and EC2 checks, lists control/edges/ once through the existing journaled edgesList and reads its own journal's validated row for box_ref; reports whether the lost member's record is listed; writes nothing to the bucket |
| +internal/host/agent.go:runAgent sets the group drain driver's departed hook to armedPeerDeparted (the armed departure controller's PeerDeparted: local registry identity + departure journal); no new read |
| +internal/host/hadepartures_scan.go:Controller.unservedRevoked also rechecks hosts recorded trashed through Controller.trashed (local route lookup, then release.TrashRetired on the deployment bucket: the app's deleted.json and production flag, keys built from the record's own account/app); a restored app revokes the discharge before the edges delete |
| +internal/host/hadepartures_wiring.go:armHADepartures wires DepartureConfig.TrashRetired: release.TrashRetired over a.OpenStore (the deployment bucket) with the box's CARLOS_RELEASE_PUBKEY via provisionTickConfig, the same marker and flag reads the reconcile already makes |
| +internal/host/hadepartures_scan.go:Controller.ScanPass records a matched host whose app is TrashRetired, with a released or expired lock, as result "trashed" (no import, lock untouched) instead of adopting it; only reads added are the trash marker and production flag, and only when the local registry has no route for the host |
| +internal/host/hadepartures_scan.go:Controller.complete excludes "trashed" hosts from the recovered count, as it does "unserved" |
| +internal/host/hadepartures_scan.go:Controller.trashed new: reads the local registry route for a departure host, then (only when there is none) DepartureConfig.TrashRetired: release.TrashRetired on the deployment bucket, the app's trash marker apps/<account>/<app>/deleted.json and its root-signed production flag, account/app taken from the host's instance record (validated by ReadAppTombstone: schema 1, path and body agree); memoized per app per pass; any error answers false (keeps the host) |
diff --git a/docs/superpowers/notes/census-proposal-ha-1192.md b/docs/superpowers/notes/census-proposal-ha-1192.md| new file mode 100644 |
| index 000000000..ae0500fb5 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-ha-1192.md |
| @@ -0,0 +1,33 @@ |
| +# Census approval: ha-1192 |
| + |
| +Ruling `census-ruling-ha-1192`. The independent reviewer approves or rejects every change below, 1 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +| unit | change | read sites | what changed | |
| +|---|---|---|---| |
| +| `internal/grouproll/roll.go` `Engine.closeLost` | body | unchanged (1) | operator CLI only (refuses root): after its group and EC2 checks, lists control/edges/ once through the existing journaled edgesList and reads its own journal's validated row for box_ref; reports whether the lost member's record is listed; writes nothing to the bucket | |
| +| `internal/host/agent.go` `runAgent` | body | unchanged (8) | sets the group drain driver's departed hook to armedPeerDeparted (the armed departure controller's PeerDeparted: local registry identity + departure journal); no new read | |
| +| `internal/host/hadepartures_scan.go` `Controller.unservedRevoked` | body | unchanged (5) | also rechecks hosts recorded trashed through Controller.trashed (local route lookup, then release.TrashRetired on the deployment bucket: the app's deleted.json and production flag, keys built from the record's own account/app); a restored app revokes the discharge before the edges delete | |
| +| `internal/host/hadepartures_wiring.go` `armHADepartures` | body | unchanged (17) | wires DepartureConfig.TrashRetired: release.TrashRetired over a.OpenStore (the deployment bucket) with the box's CARLOS_RELEASE_PUBKEY via provisionTickConfig, the same marker and flag reads the reconcile already makes | |
| +| `internal/host/hadepartures_scan.go` `Controller.ScanPass` | sites | +registry:Hosts, +registry:Result, +whole:HADepartureHostScan ×2 | records a matched host whose app is TrashRetired, with a released or expired lock, as result "trashed" (no import, lock untouched) instead of adopting it; only reads added are the trash marker and production flag, and only when the local registry has no route for the host | |
| +| `internal/host/hadepartures_scan.go` `Controller.complete` | sites | +registry:Result | excludes "trashed" hosts from the recovered count, as it does "unserved" | |
| + |
| +Envelopes re-pinned: `internal/grouproll`, `internal/host`, `internal/provision`, `internal/release`. |
| + |
| +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. Reject 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. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| + |
| +Recorded dispositions, which each change must still satisfy: |
| + |
| +- `internal/grouproll/roll.go` `Engine.closeLost`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-group-roll-verb;basis=lstats provider-divergence.json in the operator's own 0700 state directory to say it is kept |
| +- `internal/host/agent.go` `runAgent`: authority, task B,C,D,F. Basis: rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): builds the box's lifetime judge once (newBoxJudge, nil with host claims on) and hands it to the seed placement, the moves and runs workers and every loop it starts; read sites unchanged, offsets moved; B,C,D,F authority retained; self-serve moves 1 Task 8: derives the box's lifetimes switch from the judge once (lifetimes := boxJudge != nil) and hands it to the edges file loop; read sites unchanged, offsets moved;rev3=census-ruling-plans-4d-lapse;basis=arms two more plans hooks from the same snapshot: e.SetPlanDisabledFor(planDisabledFor) beside SetPlanGovernedFor, and svc.SetDisabledFor(planDisabledRoute) beside SetMaxRunFor (plans 4d); the reads live in those units (plans-4d-units decision); read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 9b81d97b (with main's plan rate ceiling, edge request records, regional box names, self-serve moves plan 1, plans 4d-1 lapse and its other later changes under main's own census rulings) plus the rootfs placement wiring in the activator start: an agentRootfs built from eb.NestedOK, CARLOS_DEPLOYMENT_SINGLE_TENANT, CARLOS_POOLS, the claim flag, swapArming's answer, the control client's /ready/rootfs and, on a fleet box whose identity resolved, fleetOwnerCheck over the deploy store main already opens for the fleet label (fleetStore), then arm and armedRootfs.Store; this body reads nothing new itself; the closures it wires read later, at a rootfs wake and each status tick: GET /ready/rootfs over the control socket, NestedOK's checks, and release.FleetOwnerKey for the judged row's own account and this box's fleet from the deploy store;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 7 and 11, #329 plan 3 Task 7 and plan 1 Task 7's policy cache: the control client is built once and handed to eb.Control, to the status tick (egressStatus) and to a new egressNudgeLoop goroutine; armSizeSource(svc, "/sys/fs/cgroup") after the activator Service; armPolicyCache() after armChangeIndex; statusLoop takes egressStatus. The reads are those units' own (decision rows); this body reads nothing new: the same five sites, offsets moved, in the agent; B,C,D,F authority retained.;rev3=census-ruling-remote-instance-metrics;basis=builds the metrics loop's owners closure (metricsOwners over the agent's registry, the activator and cgm.Leftover) when an activator exists and hands it to metricsLoop; reads nothing new itself;rev3=census-ruling-edge-asset-cache-3;basis=adds file:Statfs. runAgent keeps its authority (B,C,D,F). The new site is assetcache.Statfs, an exported assetcache.FS interface value (var Statfs FS = statfsFS{}), not a function value and not a call in runAgent: the ready hook passes it to armEdgeAssetCache as the store's filesystem, and armEdgeAssetCache calls its Space method on the configured data directory (dataDir(): $CARLOS_DATA_DIR, else /data), which calls unix.Statfs there (statfsFS.Space, accepted legacy at census-ruling-edge-asset-cache-2). No request-supplied pathname reaches it.;rev3=census-ruling-remote-metrics-nested;basis=main's body (merged origin/main acfa4f80, under main's own census rulings) plus: snapshots the nested layout (snapshotNestedUnits over /sys/fs/cgroup/carlos.slice/carlos-instances.slice) once at start, before the activator, and hands the metrics loop a unitSources struct (stamped units, routeHostNames, that root and the snapshot); reads nothing new itself;rev3=census-ruling-region-ha-p1a;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): wires region HA P1a into the activator: cfg.Record = haRecordFacts(openDeployStore, boxJudge) (the box's lifetime judge this body already builds with newBoxJudge, nil with host claims on; CI fix) and cfg.Self = lease.CurrentSelf; eb.Lifetimes (the process's lifetime index), eb.Registry, eb.StartupSwept (seedSweptAtStart.Load), eb.FilesStore from newProductionFilesStore (now lease.NewFilesStore, rootaws-loaded, a log line on failure) and lease.SetObligationDir(<data>/.ha-owed) (logged on failure; HA acquires then refuse); this body reads nothing new itself, the same five sites; the reads are those units' own (haRecordFacts and lease's SetObligationDir are new rows on this card); merge of origin/main d7ae1d76: main's own later changes to this body are kept as main has them, under main's rulings (census-ruling-remote-instance-metrics: the metricsOwners closure for metricsLoop; census-ruling-edge-asset-cache-3: the +file:Statfs site, assetcache.Statfs handed to the asset ready hook); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b1;basis=region HA P1b-1: builds one termfence.Confirmer (Self from lease.CurrentSelf at each call, EC2 DescribeInstances method only, client from rootaws.LoadDefaultConfig with retries off, built lazily on first use) and sets eb.OwnerTerminated; this body reads nothing new itself, the same six sites;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: the startup Sweep literal hands its answer to startupSwept, which logs as before and, only on a clean sweep, marks rootfs admission swept (MarkRootfsSwept); same Sweep call, no read added;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (controller ruling after branch review R1, and Paul's R2 ruling): sets svc.Fleet = fleetWakeFor(os.Getenv, identity, identErr, fleetStore) from the identity it already resolves once and the deployment store the fleet loops already opened, and logs an ERROR naming the identity error when the box is on a fleet with an invalid identity. fleetWakeFor reads CARLOS_REGION and CARLOS_FLEET from the same environment. Read sites unchanged (6). Agent, not root; a platform box is unchanged.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12: one call more beside armRunsPass, armInteractivePass(svc, reg, rolloutSink, boxJudge), in the same activator Configure hook, handing it the same box judge; fix round 1 (Astra P2, shutdown): after svc.Shutdown(ctx), shutdownInteractive(ctx) ends and joins every interactive session under the same shutdown budget; the worker's own reads are its units' (interactive.go); this body reads nothing new, the same six sites; merge of origin/main 6f1f6ca6: main's svc.Fleet = fleetWakeFor(...) and its invalid-identity ERROR line are kept as main has them (census-ruling-managed-fleets-1b); this branch's change is the same as above; read sites unchanged (6);rev3=census-ruling-fix-set-aside-exdev;basis=set-aside EXDEV fix: one field more on the agent ExecBackend literal, RawInstanceDir: layout.RawInstanceDir (a pure path join: <dataDir>/.instances/<InstanceID(host)>), so the start rule set-aside moves a copy out through the raw directory instead of through the nosymfollow bind; this body reads nothing new, the same six sites;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: one more assignment beside eb.FilesStore: eb.EscrowKey = haEscrowKey(os.Getenv("CARLOS_SECRETS_KEY")), the agent's own environment parsed by appconfig.ParsePrivateKey as the moves pass parses it (unset or unparseable: a log line and nil, and HA publication refuses on the box). No path is opened or read, no read site added; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 4: one more goroutine beside configSyncLoop: go escrowLoop(agentCtx, reg, svc), the escrow sweep every 30 s over the same registry and Service. This body reads nothing new itself; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 5: one more call beside eb.EscrowKey: wireRawSecretPages(eb, PageOperator, metricsBoxLabel(os.Getenv, readMachineID())), which sets eb.OnRawSecret to page an operator (alerting.Page through PageOperator, LevelIncident) on its own goroutine with a 20 s timeout; metricsBoxLabel and readMachineID are the reads this body already makes for the moves refusal log; no new read site; the same six sites, offsets moved; B,C,D,F authority retained. Merge of origin/main 90c4d3aa: main's own later changes to this body are kept as main has them, under main's rulings; this branch's change is the same as above. Merge of origin/main 00bf5b8c (fleet set-aside EXDEV fix): main's change to this body is kept as main has it, under its own census ruling; this branch's change is unchanged.;rev3=census-ruling-probe-burst-limit;basis=two more sink wirings beside setAnalyticsSink: setProtectionSink(e.SetProtectionRecordOnly) and setAssetOwnersSource(e.AssetOwners), function values the telemetry pass calls; this body reads nothing new, the same six sites; authority B,C,D,F retained; no new root read or write kind;rev3=census-ruling-region-ha-p1b3a;basis=Arm HA placement exactly once on the existing Service before activatorStart and edges publication, wiring AwakeApps and the PageOperator callback; existing six read sites unchanged, no new root authority.;rev3=census-ruling-stateless-replicas-1;basis=Final review I3: start the concrete coordinator's renewal worker with agent setup; existing closeReplicaCoordinator shutdown cancels and joins it before release. No new read sites or credentials. Merge origin/main c59715e7: retain main's armHAPlacement(svc, PageOperator) wiring beside the existing activator setup; stateless coordinator and shutdown wiring remain. Same read sites; no new root read or credential.;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): in the edge-ready callback, calls act.SetHeldWakeHook(e.HeldWake) when act is non-nil (installing the non-blocking wake callback) and stores e.HeldStreamsForStatus in heldStreamsSource. Wiring of in-memory callbacks only; no read added.;rev3=census-ruling-region-ha-p1b3b-t;basis=Wire Service.SetDutyView to the live edge DutySnapshot in the ready callback. No new read; no new loop or cloud operation. B2 wires the registry as the persistent DutyStore before service startup; no new cloud or filesystem path. B3b: arm one journal-backed termination consumer before service startup using agentCtx and the shared confirmer; expose edge tick and join at edge shutdown. No new direct read sites.;rev3=census-ruling-agent-start-demo-1;basis=Passes the existing registry, data store and hibernation prefix into the demo worker, and the existing instance-control client into the demo before-exec hook. No alternate data store or polling loop. Merge resolution against origin/main 9bd45488 retains main's HA departure controller, lifecycle and duty wiring alongside the demo data store and worker; no read site added by the resolution.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: install closed fixed admission before every launch source, bind activator/backend and edge, wire the real termination Started lifecycle and role reader after the change index; close before cancellation/child shutdown. No new external reads or cloud authority. Fix R1: move bind/lifecycle/edge-option wiring into wireAgentAdmission and worker listing into runWorkerBootPassAfterAdmission. Worker boot waits for admission before listing then uses unchanged bounded wakes and per-host serialization; whole Route read moves to the helper. No new storage, cloud, or root execution authority. Preserve merged main's agent wiring and census basis; the branch removes one whole Route use by moving worker iteration to the helper, with no added read kind.;rev3=census-ruling-stateless-replicas-2;basis=Slice 3b: arms a fleet-only worker using the existing registry, activator, backend and authenticated console transport. Owned worker stops and joins at shutdown. No new bucket reader. merge of origin/main 9b8b2c50: retain HA duty/departure lifecycle, wake-slot and existing agent wiring alongside the replica placement worker; no new read introduced by resolution. merge of origin/main 6be08467: Retain main demo configuration, admission, build and expiry wiring alongside the replica worker; merge-only body change, no additional read. merge of origin/main 7920cccf: Retain main box-role/group admission wiring and boot publication beside the owned replica worker and shutdown; main moves the boot registry List into runWorkerBootPassAfterAdmission, removing its inline whole Route site. No new read introduced by conflict resolution.;rev3=census-ruling-stateless-replicas-3;basis=Task 1 fix round 1 M3: retain the private snapshot source and cancel/join ownership, but use the replica-health-specific retry loop. It logs its first failure only and retains the existing exponential backoff capped at 30 seconds; unsupported builds return nil. Existing five direct read sites unchanged; no new credentials, bucket reader or app lifecycle action. Fix round 1 Q20: publish Edge.ReplicaSnapshots as a separate in-memory status source, leaving the tenant-visible Upstreams source unchanged. No new external reader or authority.;rev3=census-ruling-region-ha-p3b;basis=Load root-written group marker/configuration, configure signed boot binding and agent receipt completer, wire cancellable admission into departure work and expose cached GroupReaderSnapshot. New indirect boot reads use protected root files; agent-owned receipt controls duplicate initial completion only, never root restart permission. Same five direct sites. Merge 45cebde4 retains the replica health socket lifecycle and setReplicaSource beside GroupReaderSnapshot; no extra read beyond main.;rev3=census-ruling-agent-start-demo-2;basis=agent.go:309-329 opens demo-traffic.db beside the operator-configured registry when a demo domain exists, closes it at shutdown and wires drain-before-purge; :1010-1019 shares the worker and write gate; :1164-1177 installs the fleet identity and closed-until-worker serving callback. One added whole Route pass; the new indirect filesystem/SQL reads are claimed in openDemoTraffic and worker/store units. No request chooses the database pathname.;rev3=census-ruling-region-ha-p1b3b-s;basis=Wire the service duty view to authoritative cached sidecar manifest placement in LifetimeIndex and the edge sidecar projection; missing policy denies duty. Existing instance duty wiring remains.;rev3=census-ruling-region-ha-g2-t3;basis=T3a: wire eb.Page = PageOperator beside OwnerTerminated before departures arm, so suspect-holder pages work if departure setup fails; no new read; existing nine sites and authority unchanged; pages through the existing sink. T3b: publish the same backend through an atomic pointer for the metrics observer, and clear it on return; no new external read or authority.;rev3=census-ruling-agent-start-demo-3;basis=Wire the claim activator and root snapshot client into the demo worker; pass moved readiness to status reporting. Census read-site delta: unchanged (9).;rev3=census-ruling-region-ha-g2-fixes;basis=Wire local pool evidence, live withdrawal activator, startup ingress scan and alias publication, and edge lookup; no new direct sites; new indirect record/claim reads use existing store/judge paths described in ingress helpers.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: starts the existing record-view backstop loop with a departure-inventory listener (non-blocking, coalesced signal) even without an armed RecordView; it requests the existing full pass (backstopFullDue) there. Same nine read sites; no new read or authority.;rev3=census-ruling-region-ha-graceful-terminate-t2;basis=Derive one signal-time deadline with a 90-second budget; cap departure stop and startup/seed/service shutdown joins by it. No read added.;rev3=census-ruling-static-sweep-periodic;basis=in the edge-ready callback, publishes e.LargestStaticTree in staticTreeSource for the disk alert line (diskAlertFrac in the metrics loop); in-memory wiring only, no read added; read sites unchanged (9);rev3=census-ruling-edge-page-cache-1;basis=wires the exec backend's CurrentInputs into the edge cache (wireCurrentInputs) and, in the ready hook after armEdgeAssetCache (whose returned store it now keeps), calls armEdgePageCache, which does nothing unless CARLOS_PAGE_CACHE=1; read sites unchanged (9); no read added;rev3=census-ruling-gvisor-demos;basis=Capture sandbox resolution and refusal once; log errors once; gate route admission and BeforeExec before process launch. No new root read. Task 5: pass the once-captured sandbox effective mode/config error into ExecBackend, UnitBackend and the immutable Client expectation. Same startup environment/registry reads; swapArming declines gVisor before placement. Task 8: arm read-only status projection with the existing Client.SandboxStatus callback. Agent status now queries the existing root /ready endpoint; no new root authority or guest-file input. Merge2 e8a1ddde: retain main wireCurrentInputs and armEdgePageCache through the existing asset-store ready hook alongside branch once-captured sandbox mode, wake gates and root status wiring. No new direct read; main page-cache helpers retain their own census overlays.;rev3=census-ruling-region-ha-held-build;basis=wires the drain state: svc.SetDrainingSource(boxDrain.IsDraining), svc.SetPeerDrainView(e.PeerDraining), e.SetPeerDrainedHook(svc.DropHoldersNaming); in-memory only; no read added; region HA held-requests Task 5: on group members, starts the drain driver over the activator, the edge and boxDrain, and serves its root-only drain socket; no read added beyond the socket's own Branch review r1: the drain state follows the root start fence on group members (the fence reader is the existing fenceLocation.read, a root-owned fixed path); e.SetPeerUndrainedHook(svc.AllowHoldersNaming) beside the drained hook (memory only); the drain socket serves only the agent's own user. No read added.;rev3=census-ruling-security-review-mitigations;basis=Wire the cached operator flat-layout choice into the exec backend's new-resident refusal; no read source added, existing authority retained.;rev3=census-ruling-w6-ingress-drain;basis=agent (user carlos), not root. Builds the ingress drain (newIngressDrain) with arming read at ask time from os.Getenv (CARLOS_REGION_HA, CARLOS_INGRESS_TARGET_GROUPS, both from the root-owned host.env), the fixed admission and lease.CurrentSelf (existing IMDS identity); its reader is awstg.Load, the box role's credentials calling ELB DescribeTargetHealth/DescribeTargetGroupAttributes (new AWS reads, by the agent). Wires admission.closeStartsForIngressDrain, the lbhealth drain condition, ingress.setEdge, and ingress.shutdownStarted in WithShutdownStarted. The drain socket (/run/carlos/.ha-drain/drain.sock, agent-user only, existing) is now also served on a fixed box with the drain configured (was group members only), routing /v1/ingress/* to the ingress drain and the group drain verbs to 404 there. armHADepartures now takes fixtureDepartureGetenv() and MakeQueue fixtureDepartureQueue(), which in a production (non-rootrunner) build are os.Getenv and nil, as before. Read sites unchanged (9).;rev3=census-ruling-stateless-replicas-4-task1;basis=Arms the fleet-only replica swap worker next to the placement worker: same console URL and fleet token as the existing replicaCoordinatorAPI, the existing activator Service; stops and joins at shutdown. No new read site, credential or bucket reader.;rev3=census-ruling-stateless-replicas-4-task2;basis=Task 2: sets deployWorker.step to the rollout scheduler answer for the record permit (replicaStepOf over armedRollout), an in-memory callback; no read site, credential or bucket reader added.;rev3=census-ruling-stateless-replicas-4-task2-fix2;basis=Task 2 fix round 2: the swap worker step is armedReplicaStep, the same lazy scheduler lookup as before as a named function; no read site added.;rev3=census-ruling-stateless-replicas-4-merge-main;basis=Merge of main 5fac2ff1: both sides changed it. Main (01d6ca78, linked-deployments-slice1) starts linkLoop beside tunnelLoop; this branch keeps its replica coordinator wiring. Both kept as-is; no read added.;rev3=census-ruling-stateless-replicas-4-final;basis=#511 final wave item 2: wires the swap worker's drive (armedReplicaDrive, the armed rollout manager's DriveReplicaRelease); no read added;rev3=census-ruling-stateless-replicas-4-merge-main2;basis=Merge of main af871da0 (v0.34.49): both sides changed it. Main (178dcfe5, member-backups-2a) moves the inline duty-view closure into armDutyView/dutyView and starts verifyAssignLoop; its sites drop by registry:Host and whole:Route x2 as main recorded them. This branch keeps its replica coordinator, swap worker and drive wiring. Both kept as-is; no read added.;rev3=census-ruling-stateless-replicas-4-drill3;basis=drill 3 R24: makes one in-memory channel, closes it (once) inside the edge's existing shutdown-started callback after ingress.shutdownStarted, and passes it to tunnelLoop, which drains only a fleet channel name; no read added, same six sites; touches no admission, lease, ingress drain, listener or file; the agent process, no root decision;rev3=census-ruling-edge-ppv2;basis=Agent (uid carlos), not root. memwatchLoop now gets edgeProxyCounters(&demoEdge) (in-process counters, no read). The drain socket's driver is newAgentDrainSocket(ingress, e, os.Getenv), which attaches the edge trust handler only when CARLOS_INGRESS_PROXY_SOURCES in the agent's environment (from the root-owned host.env) parses to a non-empty list; the socket is served when drainSocketServed: a group member or a configured ingress drain (both as before), or a box armed for PROXY protocol (new). The socket's path and agent-user-only permissions are unchanged. Read sites unchanged (6).;rev3=census-ruling-same-box-edge-fence;basis=Agent (uid carlos), not root. One added line: armEdgeFenceStatus(ctl.EdgeFence), beside the existing armExecSandboxStatus, so the layout report can ask root's /ready for the edge fence state over the control socket client the agent already holds. No read added.;rev3=census-ruling-platform-mail-submission;basis=Task 4: sets eb.Mail = mailsubmit.SocketForwarder{} on every box, and eb.MailSwitch to a mailSwitchCache's On that opens the deploy store itself through openDeployStore, retried at most once a minute with an error line until it opens (review round 1, Task 4 P3), armed for the serial-move refresh (armedMailSwitch). Task 6: also sets the ExecBackend's ManifestOf, the same staged-manifest read as TierOf (rt.App and RouteAccount(rt), hence +registry:App and +whole:Route), for the spawn-time check of decision 10, which logs and emits an event and never refuses. Agent, not root. Fable final P2-2: eb.MailSwitch is the cache's State (three-valued: on, off, unknown) in place of On; an unreadable switch is unknown, never off. No read added.;rev3=census-ruling-fleet-drain-followups;basis=P3 (#1008 T9): one call after armChangeIndex, requestBootFullPass(v, &backstopFullDue), which stores true in the existing in-memory backstopFullDue flag only when no record view is armed, so the fast loop runs its existing full pass on its first tick instead of instancesLoop a minute later; armed boxes unchanged. No read added; read sites unchanged (8); agent, not root.;rev3=census-ruling-fleet-first-reconcile-speed;basis=Startup timing log lines only: runDuties builds a step logger (newStartupLog, which reads the in-memory agent start time) and logs one line after the wait on the activator startup latch and after each existing duty before go fastConvergeLoop. One newStartupLog().at line in the edge ready hook before go tunnelLoop. No read added; read sites unchanged (8). Agent, not root. |
| +- `internal/host/hadepartures_scan.go` `Controller.unservedRevoked`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-dr5;basis=DR-5 R2: rechecks unserved discharges before the edges delete; reads inventory records, scan Hosts, the in-memory view, policy and local journal rows via unserved(). No remote read. |
| +- `internal/host/hadepartures_wiring.go` `armHADepartures`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3 fix r1: Install proof adapter, adoption identity and suspicion callbacks before asynchronous startup. Lazily retry the same deployment/data clients; lifetime callback reads only the current host through ExecBackend.TerminationLifetime. Add bounded structured paging for unresolved per-iid records. No new bucket, tenant input path or acquire bypass. B4: Wire the shared lock reader and existing AdoptHost entry. Read local route, Pair and duty revision only after authoritative inventory eligibility; bind its record lifetime and refuse missing/mismatched local routes. No route synthesis or pool widening. B5: Publish the armed controller to the existing metrics sampler. No new loop, remote source or process authority.;rev3=census-ruling-region-ha-followups;basis=Inject the existing PageOperator function into the backend when HA departures are armed; no new read or paging transport.;rev3=census-ruling-region-ha-p3b;basis=Require group admission/BeginWork callbacks and pass them into the sole departure consumer, including the production adoption closure. Same store, identity and registry reads; consumer Started remains a lifecycle fact, not duty authority.;rev3=census-ruling-region-ha-p1b3b-s;basis=Carry the actual provisionTickConfig pools and inbound posture into CanAdopt; stamped sidecars use the existing production adopter. Legacy unresolved paging remains. No wider tenancy or new remote source.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: wires the controller's RequestInventory hook to the agent's early-backstop signal. No new store, read or loop. |
| +- `internal/host/hadepartures_scan.go` `Controller.ScanPass`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B4: Read authoritative pre-filter inventory, exact canonical lock revisions through one page reader, local scan checkpoints and adoption receipts. Persist source identity before the sole AdoptHost importer; validate later successor identity/lifetime/generation and require a fresh full zero-match rescan. Unknown state, unsupported hosts and missing previously matched locks refuse completion. No process launch or tenancy expansion. Preserve checkpoints across walks of identical record bytes; persist the current inventory generation separately and recheck source freshness/completeness before every page and deletion. Placement changes cannot filter the lock census. Fix r1/P15: classify legacy and unrelated locks as zero only before any D match; keep strict successor checks for previously matched hosts and hold malformed HA identities. Compare read start to expiry. Resume authority-complete deletion without rescanning unchanged inventory; persist evidence and scan errors with bounded retry. B4 fix r2: Inventory-only waits request the existing hourly page only after observed evidence is older than ChangeIndexBackstop plus 10 percent. Freshness and completion gates are unchanged; no new read. B5: Route the unchanged AdoptHost callback through measured telemetry; no new authority or lock read.;rev3=census-ruling-region-ha-p3b;basis=Gate and register the existing departure scan with admission before any work. Existing registry/object reads remain, closed members do not import, and shutdown cancels/joins registered work; no new root input.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: when a departure is blocked only on inventory freshness, signals the bounded early backstop round (global 60 s spacing, three per evidence) instead of waiting for the 30 min backstop. FreshAfter/I3 gates unchanged; no walk inside the step; no new read.;rev3=census-ruling-region-ha-g3-fixes;basis=Track current record revisions across inventory publications; separate lease waits from blockers and persist Cursor as zero for rollback. Drop removed records from coverage while retaining adoption or validated-successor gates for current hosts. Use the bounded lock-prefix listing only after validating every current host prefix; preserve per-host reads for known duties and fall back to the existing 32-host scan when listing evidence is unavailable. Cache listing evidence only in this process under scanMu, invalidate it on blocked work or inventory changes, and permit 128 reads with proven listing coverage. Added reads include departure LastError, host scan state and registry Hosts; the new remote read is a bounded LIST of the configured lock prefix in the existing data bucket.;rev3=census-ruling-region-ha-dr5;basis=BASIS AMENDED by spec 7.5 (DR-5, approved by agent manager 8a3d302 for the region HA standing approval): the B4 completion gate "adoption or validated successor" becomes "adoption, validated successor, or unserved discharge". A host may be discharged unserved only when (1) its lock is a valid release marker naming the departed box or a held lock whose expiry this box read as passed, (2) this box would adopt it but for the pool (placement, HA, lifetime, kind and sidecar rules, not denied), and (3) the complete in-memory departure view shows no in-scope box that serves or may serve the pool, other than group members with a departure enrolled in this box journal (fixed refs never count as gone; unknown served_pools blocks). Every unserved discharge is rechecked at one finalization gate immediately before the conditional edges delete. An unserved host is never imported and its lock is never written, so no lease authority moves; the full zero-match rescan still runs, with unserved hosts the only allowed matches. Inputs: served_pools comes from edges files that only box roles write (already trusted by this scan for identity and by placement); a box agent that lies can at most let a departure finish without import, which it can already cause by deleting edges files with its own role. No new remote read; reads Hosts/Rescan/Result from the local journal. The rescan is due at once. |
| +- `internal/host/hadepartures_scan.go` `Controller.complete`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B4: Read the durable departure/scan and current inventory, then conditionally delete only the retained exact edges key/revision. Reread uncertain results and refuse replacement identities. Persist deletion and acknowledged index phases before complete; queue receipts stay in memory and only complete rows acknowledge. Fresh process evidence is required before authority checkpoint reuse. Fix r1/P15: ignore the old scan-level ETag override and delete only the original departure ETag. Exact-key readback retries the same tag; a changed tag is never deleted and advances only with a different verified iid under the same ref/account/scope, otherwise holds and pages. Persist permission fault episodes; route completion faults through bounded retry. No new filesystem or executable input. B4 fix r4/P18 supersedes fixed-ref deletion: only the deterministic account/iid group reference may delete its retained exact ETag. Every other ref performs an exact-key GET and stays pending unless absent or the existing verified newer-incarnation check succeeds; the live replacement file is left intact. Group revision changes stay pending. No new key or authority read. B5: Increment completion counter only after the durable complete phase; C4 ordering stays after that commit.;rev3=census-ruling-region-ha-p3b;basis=Require registered admitted work before completing a departure or acknowledging it. Existing coverage, inventory, lease and successor reads remain; closed members defer rather than clear obligations.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: drops the per-departure nudge bookkeeping (moved to a fixed-size global limiter). Completion gates, exact-ETag deletion and reads unchanged.;rev3=census-ruling-region-ha-g3-fixes;basis=Require current inventory visit coverage and re-read group edges before conditional deletion. Verify identity and scope before rebinding a changed ETag; preserve fixed-ref retention and exact-ETag deletion. Reads scan EdgesETag and coverage state; no new object key or read source.;rev3=census-ruling-region-ha-dr2;basis=DR-2: after the edges phases, calls retireStatusSnapshot, which for a deterministic account/iid group reference only does one GET of status/boxes/<ref>.json in the deployment store and a conditional delete of that exact revision (ETag). Best-effort and time-bounded (at most 5 s, always leaving 2 s of the step for the completion save; Astra R1 P2): any failure or timeout is logged and never holds completion, paging or acknowledgement. Fixed refs untouched. No filesystem, executable or new authority read; no change to the edges deletion, completion gates or ordering.;rev3=census-ruling-region-ha-dr5;basis=DR-5: one finalization gate immediately before the conditional edges delete revalidates unserved discharges (unservedRevoked: local view, policy, journal only); on failure clears DeleteUncertain and resets to a fresh walk before any delete. The completion log counts imported hosts only. No new remote read. |
| + |
| +New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff: |
| + |
| +- new `internal/host/hadepartures_scan.go:Controller.trashed`: reads +registry:Account, +registry:App, +whole:Route; written legacy, accepted-legacy, frozen |
| + |
| +Seal: `7ca068c5c146a679b4726d74fe43cf9c47f97080f9c08b761a36a9a12a5a3c54` → `8df52839a0c961d3721f3a5c3247d06202dae4e00d011844b7117f8e918803d4`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-ha-1192.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/reviews/ASTRA-R1-ha-1192.md b/docs/superpowers/reviews/ASTRA-R1-ha-1192.md| new file mode 100644 |
| index 000000000..6181f5e3f |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/ASTRA-R1-ha-1192.md |
| @@ -0,0 +1,42 @@ |
| +Reviewed `03ff5d17..d3eb89cc99cbb2845a9f96868566856f9f8c7319`, round 1. No P1 findings. |
| + |
| +- **P2 — Task 2 / witnesses: the restore test does not exercise the finalization gate.** At [hadepartures_trash_test.go:140](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/ha-1192/internal/host/hadepartures_trash_test.go:140), restoration happens on the first `ha_departure_trashed` log. The subsequent rescan encounters the restored app and blocks before finalization. This test would therefore still pass if the new `departureTrashed` recheck at [hadepartures_scan.go:488](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/ha-1192/internal/host/hadepartures_scan.go:488) were removed. |
| + |
| + **Failure scenario:** restoration after the rescan, during finalization, has no regression witness. **Fix:** restore through the existing `dr5HookedStore` on the final edges GET, following [hadepartures_dr5_test.go:685](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/ha-1192/internal/host/hadepartures_dr5_test.go:685). Assert that the hook fires, the gate logs revocation, and the edges record remains. **Fault family:** discharge evidence must remain valid immediately before edges deletion. |
| + |
| +- **P3 — Task 2: the “normal departures read nothing” comment is too broad.** [hadepartures_scan.go:410](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/ha-1192/internal/host/hadepartures_scan.go:410) assumes every live app has a local route. Live hosts outside this box’s pool do not. `ScanPass` calls `trashed` before checking adoption eligibility, so these hosts now incur a marker GET, memoized per app per pass. |
| + |
| + **Scenario:** the existing DR-5 named-pool hosts on a shared-pool-only box take this path without being trashed. **Fix:** narrow the comment to hosts with a matching local route and document the additional reads for other hosts. **Fault family:** request-cost documentation must match the executed path. Keep this on the follow-up list. |
| + |
| +Task assessments: |
| + |
| +| Task | Assessment | |
| +|---|---| |
| +| 1 — Shared rule | Approve. Matches reconcile’s marker-present/production-clear decision, including nil keys. Fleet drain retains its capable-survivor and movability gates. | |
| +| 2 — Departure scan | Implementation approved; witness correction above required. Lock identity and expiry checks remain. Matching local routes retain the adoption path. The finalization gate rereads trash state and revokes restored discharges. | |
| +| 3 — Drain acknowledgement | Approve. A verified deterministic group reference and enrolled departure are required. Enrollment requires termination proof. Fixed, unknown and self references fail closed; atomic lookup handles late controller arming. | |
| +| 4 — Close-lost | Approve. Listing is journaled before closure; failure leaves the transaction open. Missing validated references retain the previous closure path. No edges deletion is introduced. | |
| + |
| +The incident witness uses production departure wiring and preserves the pre-fix stall case. Drain witnesses combine that controller with simulated peer acknowledgements. The restore witness needs the correction above. |
| + |
| +Census decisions for the specified tip: |
| + |
| +| Unit or envelope | Verdict and evidence | |
| +|---|---| |
| +| `Engine.closeLost` | **Approve** — [roll.go:1557](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/ha-1192/internal/grouproll/roll.go:1557), through line 1642: operator-side listing and journal reads; no bucket write. | |
| +| `runAgent` | **Approve** — [agent.go:1329](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/ha-1192/internal/host/agent.go:1329): callback wiring only; existing authority disposition retained. | |
| +| `Controller.unservedRevoked` | **Approve** — [hadepartures_scan.go:479](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/ha-1192/internal/host/hadepartures_scan.go:479): restores revoke discharge; failures retain work. | |
| +| `armHADepartures` | **Approve** — [hadepartures_wiring.go:113](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/ha-1192/internal/host/hadepartures_wiring.go:113): existing deployment store and reconcile release key. | |
| +| `Controller.ScanPass` | **Approve** — [hadepartures_scan.go:235](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/ha-1192/internal/host/hadepartures_scan.go:235), through line 395: identity, expiry and independent rescan preserved; no lock mutation for trashed hosts. | |
| +| `Controller.complete` | **Approve** — [hadepartures_scan.go:732](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/ha-1192/internal/host/hadepartures_scan.go:732), through line 869: conditional deletion remains behind revalidation; changed count excludes discharged hosts. | |
| +| New `Controller.trashed` | **Approve**, accepted-legacy — [hadepartures_scan.go:415](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/ha-1192/internal/host/hadepartures_scan.go:415): local route lookup and bounded existing app-state reads; errors return false. | |
| +| `internal/grouproll` envelope | **Approve** — [roll.go:1592](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/ha-1192/internal/grouproll/roll.go:1592), helper through 1642; [text.go:29](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/ha-1192/internal/grouproll/text.go:29). No new root authority. | |
| +| `internal/host` envelope | **Approve** — units above plus [PeerDeparted:528](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/ha-1192/internal/host/hadepartures_scan.go:528), [armedPeerDeparted:77](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/ha-1192/internal/host/hadepartures_metrics.go:77), and [publishAndAck:582](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/ha-1192/internal/host/hadrain.go:582). Termination proof remains required. | |
| +| `internal/provision` envelope | **Approve** — [reconcile.go:327](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/ha-1192/internal/provision/reconcile.go:327): equivalent shared-helper substitution. | |
| +| `internal/release` envelope | **Approve** — [trash.go:102](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/ha-1192/internal/release/trash.go:102), through line 127: existing marker and signed-flag readers; no new filesystem or executable input. | |
| + |
| +`git diff --check` passed. Targeted Go tests could not start: the read-only sandbox refused creation of Go’s build directory. Runtime and census-test results remain unverified. No files were changed. |
| + |
| +Apply the P2 correction without reopening review, under the brief’s stopping rule. |
| + |
| +**READY AFTER FIXES** |
| \ No newline at end of file |
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-ha-1192.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-ha-1192.md| new file mode 100644 |
| index 000000000..cd8c6c7c3 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-ha-1192.md |
| @@ -0,0 +1,117 @@ |
| +# Review brief: branch ha-1192-close-lost-edges (#1192), round 1 of 3 |
| + |
| +Repo carlos/platform, branch `ha-1192-close-lost-edges`, tip as named in |
| +your prompt. Under review: the diff `03ff5d17..<tip>` (base is |
| +origin/main 03ff5d17). Authorities on main: region HA DR-5 (merged |
| +3d71df18, `internal/host/hadepartures*.go`, spec §7.5 as cited in code), |
| +the group roll verb spec |
| +`docs/superpowers/specs/2026-11-09-group-roll-verb-design.md`, the drain |
| +driver `internal/host/hadrain.go` (§25.4), and the fleet drain trash rule |
| +from #1008 T9 (`internal/console/fleetrelabel.go` trashRetired). |
| + |
| +You are an independent reviewer. Read the diff, then the code it names, |
| +and check every claim against that code. This one round covers four |
| +tasks; give a verdict per task and one overall, plus the census verdicts. |
| + |
| +## The incident (dev IE, 2026-11-17) |
| + |
| +App bab/g6x was trashed on 11-14 (apps/bab/g6x/deleted.json), but its |
| +instance record and its lock, a clean release marker naming group member |
| +g-03152630, stayed. When g-03152630 was terminated by a group replace, |
| +every box's departure scan matched the host and adoption deferred it on |
| +every pass (no route: a trashed app is never minted), so the departure |
| +never reached authority_complete and the member's edges record stayed |
| +published (admitted, draining). The next drain listed the dead member |
| +and failed after 2 minutes waiting for its acknowledgement. Box journals |
| +showed `ha_departure_transfer host=g6x... result=deferred` 20 times on |
| +three boxes over 25 minutes. |
| + |
| +## Fixed: do not re-argue |
| + |
| +- Agent manager 8a3d302 (2026-11-17): close-lost reports and names a |
| + still-published edges record and never deletes it; the boxes' |
| + termination recovery owns retirement. Also: the fleet drain and the |
| + departure must share ONE trash rule ("a trashed app's records never |
| + hold HA or fleet work"). |
| +- DR-5's rules (unserved discharge, proven-departed group refs only, |
| + fixed refs never proven, the finalization gate) are merged and not |
| + under review except where this diff changes them. |
| + |
| +## What to check |
| + |
| +1. **Task 1, the shared rule** (`internal/release/trash.go` |
| + TrashRetired, ProductionClear; `internal/console/fleetrelabel.go`; |
| + `internal/provision/reconcile.go` productionClear). Is TrashRetired |
| + exactly the reconcile's `removable` (marker positively present AND |
| + production flag positively clear, nil key = clear)? The console's old |
| + trashRetired errored on a present flag with a nil key; it now answers |
| + clear like the reconcile. Is that safe for the fleet drain? |
| +2. **Task 2, departure scan** (`internal/host/hadepartures_scan.go` |
| + ScanPass, trashed, unservedRevoked, complete; wiring in |
| + `hadepartures_wiring.go`). Can a host be discharged while some box |
| + could still serve or wake it (production app, restore, route still |
| + minted somewhere, a marker that is not a clean release, a lock still |
| + held)? Rule 1 (release marker or passed expiry) must still apply. |
| + Does the gate on "no local route" let a host whose app is trashed but |
| + whose route this box still holds go the adopt path harmlessly? Is the |
| + finalization gate's recheck correct after a restore? Any new S3 |
| + request on the normal (non-trashed) path? |
| +3. **Task 3, drain ack** (`internal/host/hadrain.go` publishAndAck, |
| + `Controller.PeerDeparted`, `armedPeerDeparted`, `agent.go`). Is |
| + skipping a peer whose departure this box enrolled safe for §25.4's |
| + guarantee (every live box has seen the drain state before the move)? |
| + Can a live box be skipped: a fixed ref, a ref reused, an enrolled |
| + departure for an instance that is not terminated, a departure record |
| + left after completion while the ref publishes again? Races between |
| + the drain goroutine and the departure controller arming late. |
| +4. **Task 4, close-lost** (`internal/grouproll/roll.go` closeLost, |
| + lostEdgesPublished, text key `lost_edges_published`, spec row V20). |
| + The listing is journaled before `lost-member-closed`; a failed |
| + listing refuses and leaves the transaction open. Any path where |
| + close-lost now fails to close a transaction it closed before, beyond |
| + a failed listing? |
| +5. **Witnesses** (`internal/host/hadepartures_trash_test.go`, |
| + `hadrain_departed_test.go`, `internal/release/trashretired_test.go`, |
| + `internal/grouproll/roll_test.go` close-lost tests). Do they go |
| + through production wiring and prove the claim (the before-1192 test |
| + shows the stall)? Deterministic? |
| +6. **Census**: `docs/superpowers/notes/census-proposal-ha-1192.md` and |
| + the claims beside it. AGENTS.md "The census: the reviewer decides": |
| + give a verdict for every unit and every re-pinned envelope. Reject if |
| + root now opens, runs, queries or follows anything from a path or |
| + input a tenant, app or box agent can create, write or name, or a |
| + check is weakened. Note: the new trash reads take account/app from |
| + an instance record and read `apps/<account>/<app>/deleted.json` and |
| + the root-signed production flag in the deployment bucket, the same |
| + reads the reconcile already makes for the same records. |
| + |
| +## Severity |
| + |
| +- **P1**: unsafe, would not compile, a test fails, or it would not work. |
| + Blocks merge. |
| +- **P2**: wrong or missing. Fixed without reopening this review. (The |
| + census, and review of any newly changed security, root, termination |
| + or production-storage behaviour, still check the fix; see AGENTS.md, |
| + "Stopping rules".) |
| +- **P3**: clarity or polish. Goes on a follow-up list; never a reason for |
| + another round. |
| + |
| +A P1 states its failure scenario and the evidence (file:line). Do not |
| +raise a P2 to P1 to keep the review open. |
| + |
| +## Output |
| + |
| +Findings ranked P1, P2, P3. Each gives the task, the problem, the |
| +evidence (file:line, verified), the failure scenario, a concrete fix and |
| +the invariant or trust boundary it breaks (that is its fault family). |
| +Then the census verdict per unit and envelope (approve or reject, citing |
| +the lines read). End with exactly one verdict: |
| + |
| +- **READY**: no P1 and no P2. |
| +- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another |
| + round. |
| +- **NOT READY**: one or more P1s, listed. |
| + |
| +Do not edit files. Do not spawn Anthropic-model reviewers or subagents of |
| +your own. Do not run the full test suites; targeted `go test -run` on the |
| +changed packages is fine (socket tests may need TMPDIR=/home/paulca/t). |
diff --git a/docs/superpowers/reviews/LUNA-COPY-BRIEF-ha-1192.md b/docs/superpowers/reviews/LUNA-COPY-BRIEF-ha-1192.md| new file mode 100644 |
| index 000000000..d79f0350e |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/LUNA-COPY-BRIEF-ha-1192.md |
| @@ -0,0 +1,47 @@ |
| +# Luna copy brief: ha-1192, one close-lost line |
| + |
| +You are the copy-review gate itself for this set. Paul delegated copy review |
| +of platform CLI copy to you (2026-10-25); your verdict IS the review. Do NOT |
| +run the copy-review skill or start any server, and do not edit any file. |
| +Write your answer as your final message only. |
| + |
| +## The string |
| + |
| +Key `lost_edges_published` in `internal/grouproll/text.go`, printed by |
| +`carlos system group close-lost` (an operator CLI for region HA groups). |
| + |
| +Draft: |
| + |
| + The member's edges record {key} is still published. Termination recovery on the remaining boxes retires it; drains do not wait for the member once a box has recorded its departure. |
| + |
| +Where it appears: an operator closes a stuck group transaction whose member |
| +(an EC2 instance) is already terminated. The terminal first prints the |
| +existing line "Transaction closed with outcome failed-member-lost. This does |
| +not record recovery." This line follows only when the dead member's edges |
| +record (the file each box publishes in the deployment bucket to say it is |
| +serving) is still there. That leftover blocked a drain on 2026-11-17. The |
| +line must tell the operator: (1) which record is still there, (2) the |
| +remaining boxes remove it themselves (do not delete it by hand), and (3) |
| +until then, drains on the other members do not wait for the dead member, |
| +provided a box has recorded the member's departure. |
| + |
| +`{key}` is replaced with a path such as |
| +`control/edges/g-03152630d13dc3375e31.json` and must stay exactly |
| +`{key}`. No other placeholders may be added. |
| + |
| +## House rules (Paul) |
| + |
| +- No em dashes. Use a full stop and a new sentence. |
| +- Plain, direct, short. No jargon the operator would not know; "edges |
| + record", "termination recovery", "drain" and "departure" are terms the |
| + operator runbook uses and may stay. |
| +- Sentences start with a capital and end with a full stop, as the |
| + neighbouring lines in text.go do. Use the same straight apostrophe the |
| + neighbouring lines use (this is terminal text in Go source). |
| +- Do not change meaning: the boxes, never the operator, remove the record. |
| + |
| +## Answer |
| + |
| +A table with columns key | new text | why, one row. If the draft is fine, |
| +repeat it unchanged and say so. Then a FLAGS line: "FLAGS: none", or each |
| +fact you cannot verify from this brief or a wording Paul should see. |
diff --git a/docs/superpowers/reviews/LUNA-COPY-RESULT-ha-1192.md b/docs/superpowers/reviews/LUNA-COPY-RESULT-ha-1192.md| new file mode 100644 |
| index 000000000..7679cbffc |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/LUNA-COPY-RESULT-ha-1192.md |
| @@ -0,0 +1,5 @@ |
| +| key | new text | why | |
| +|---|---|---| |
| +| `lost_edges_published` | The member's edges record `{key}` is still published. Do not delete it by hand. Termination recovery on the remaining boxes retires it. Drains on the other members do not wait for the member once a box has recorded its departure. | Adds the required instruction that the boxes remove the record, not the operator. | |
| + |
| +FLAGS: none |
| \ No newline at end of file |
diff --git a/docs/superpowers/specs/2026-11-09-group-roll-verb-design.md b/docs/superpowers/specs/2026-11-09-group-roll-verb-design.md| index 78ea8b7fe..649057ab9 100644 |
| --- a/docs/superpowers/specs/2026-11-09-group-roll-verb-design.md |
| +++ b/docs/superpowers/specs/2026-11-09-group-roll-verb-design.md |
| @@ -380,6 +380,7 @@ build to it. |
| | V17 | Every provider call is made once (`--cli-read-timeout`, retries 1) | Reads (the describes, caller identity, HeadBucket, S3 GET and list) are retried while AWS throttles them: four calls at most, about 1, 2 and 4 s apart, jittered; any other failure and the last throttle fail closed as before. Writes and box sessions are never retried. Bare `carlos system group`, its -h and an unknown verb print the group's help | Step-3 dev W4 2026-11-10: the group describe refused under ASG throttling (8a3d302) | |
| | V18 | A request that gets no response is one failed call | A read whose request got no response at all (the SDK's RequestSendError: a reset or EOF on a reused connection, no call in CloudTrail) is retried as a throttle is (V17's budget); a timeout is not, and stays one bound. A failure to get credentials (AssumeRole, SSO), throttled or unanswered, is never retried, so no credential call repeats. Writes and sessions are never retried | G5 release 1, dev, 2026-11-11: the post-prepare group describe failed in 14 ms with no CloudTrail call; resume closed it (8a3d302) | |
| | V19 | The provider observation names one launch template version; any other pinned version refuses `observation` | The observation carries across a re-pin that changes only user data (§7.1). A launch template version other than the observation's, with the same template id and name, is accepted when the two versions' launch template data are identical once UserData is removed; anything else refuses `observation` as before | G5 release 1, 2026-11-11: every release's re-pin left the next roll needing a pin-back (Paul approved option b, 11-11) | |
| +| V20 | close-lost reads the group and EC2 only | After the group and EC2 checks, close-lost lists `control/edges/` once (journaled, like the floor's listing; a failure refuses and leaves the transaction open). If the member's edges record is still listed it records `edges_published: true` and says so, naming the record. It never deletes it: the boxes' termination recovery retires it once every host naming the member is settled, and a drain does not wait for a member whose departure the box has enrolled | #1192, dev IE 2026-11-17: a member closed with close-lost kept its edges record (its departure was held by a trashed app's host) and the next drain failed waiting on it (8a3d302: report, never delete) | |
| Not deviations, recorded so nobody "fixes" them in the port: the drain-rerun |
| backoff and the TakeHost `wake_timeout` follow-ups from the held build stay |
diff --git a/internal/console/fleetrelabel.go b/internal/console/fleetrelabel.go| index 9abb17189..b5176106b 100644 |
| --- a/internal/console/fleetrelabel.go |
| +++ b/internal/console/fleetrelabel.go |
| @@ -650,25 +650,12 @@ func (s *Server) drainBox(ctx context.Context, fleet, label string) (stuck []str |
| } |
| // trashRetired reports whether the boxes have retired app's routes because |
| -// it is in the Trash: its marker positively read (release.ReadAppTombstone) |
| -// and its production flag positively clear (release.GetProduction with |
| -// s.cfg.ReleasePub: absent, or present and not production). This is |
| -// reconcile's removable test (internal/provision/reconcile.go:1766-1775, |
| -// productionClear) asked of the same bucket. An unreadable marker or flag |
| -// is an error, which the caller treats as "still served". |
| +// it is in the Trash: release.TrashRetired, the one rule the departure scan |
| +// shares (#1192), asked of the same bucket with s.cfg.ReleasePub. An |
| +// unreadable marker or flag is an error, which the caller treats as "still |
| +// served". |
| func (s *Server) trashRetired(ctx context.Context, sqid, app string) (bool, error) { |
| - tomb, err := release.ReadAppTombstone(ctx, s.cfg.Releases, sqid, app) |
| - if err != nil { |
| - return false, err |
| - } |
| - if tomb == nil { |
| - return false, nil |
| - } |
| - flag, err := release.GetProduction(ctx, s.cfg.Releases, s.cfg.ReleasePub, sqid, app) |
| - if err != nil { |
| - return false, err |
| - } |
| - return flag == nil || !flag.Production, nil |
| + return release.TrashRetired(ctx, s.cfg.Releases, s.cfg.ReleasePub, sqid, app) |
| } |
| // The values of `carlos fleets ls`'s labels_paused: absent when the fleet |
diff --git a/internal/grouproll/probe_test.go b/internal/grouproll/probe_test.go| index 3ca950383..724dd691b 100644 |
| --- a/internal/grouproll/probe_test.go |
| +++ b/internal/grouproll/probe_test.go |
| @@ -441,16 +441,16 @@ func TestProbeCloseLost(t *testing.T) { |
| checkClosed := func(t *testing.T, h *harness, tx string) { |
| t.Helper() |
| must(t, closeLost(h, tx)) |
| - if h.activeTx() != "" || !reflect.DeepEqual(h.f.ops(), []string{"group", "ec2_instance"}) { |
| + if h.activeTx() != "" || !reflect.DeepEqual(h.f.ops(), []string{"group", "ec2_instance", "edges_list"}) { |
| t.Fatalf("calls %v", h.f.ops()) |
| } |
| j := h.txJournal(tx) |
| rows := j.Rows() |
| var kinds []string |
| - for _, r := range rows[len(rows)-6:] { |
| + for _, r := range rows[len(rows)-8:] { |
| kinds = append(kinds, r["kind"].(string)) |
| } |
| - if !reflect.DeepEqual(kinds, []string{"intent", "response", "intent", "response", "lost-member-closed", "done"}) { |
| + if !reflect.DeepEqual(kinds, []string{"intent", "response", "intent", "response", "intent", "response", "lost-member-closed", "done"}) { |
| t.Fatalf("rows %v", kinds) |
| } |
| closed, _ := j.Last("lost-member-closed", nil) |
diff --git a/internal/grouproll/roll.go b/internal/grouproll/roll.go| index edcf5afe0..388bef1b5 100644 |
| --- a/internal/grouproll/roll.go |
| +++ b/internal/grouproll/roll.go |
| @@ -1586,8 +1586,18 @@ func (e *Engine) closeLost(ctx context.Context) error { |
| if evidence.IID != iid || (evidence.State != "terminated" && evidence.State != "not-found") { |
| return refuse("close_lost_refused") |
| } |
| - if _, err := e.event("lost-member-closed", map[string]any{"iid": iid, "group": groupMap(g), |
| - "describe": instanceMap(evidence), "attended_by": e.attended}); err != nil { |
| + // #1192 (V20): the member's edges record is retired by the boxes' |
| + // termination recovery, never by this verb. Say whether it is still |
| + // published, so the operator knows that recovery still owes it. |
| + ref, published, err := e.lostEdgesPublished(ctx) |
| + if err != nil { |
| + return err |
| + } |
| + closed := map[string]any{"iid": iid, "group": groupMap(g), "describe": instanceMap(evidence), "attended_by": e.attended} |
| + if ref != "" { |
| + closed["edges_published"] = published |
| + } |
| + if _, err := e.event("lost-member-closed", closed); err != nil { |
| return err |
| } |
| if _, err := e.event("done", map[string]any{"outcome": "failed-member-lost"}); err != nil { |
| @@ -1597,8 +1607,37 @@ func (e *Engine) closeLost(ctx context.Context) error { |
| return err |
| } |
| e.say("close-lost", Text("lost_closed")) |
| + if published { |
| + e.say("close-lost", Text("lost_edges_published", "key", "control/edges/"+ref+".json")) |
| + } |
| if _, err := os.Lstat(e.s.DivergencePath()); err == nil { |
| e.say("close-lost", Text("divergence_retained", "path", e.s.DivergencePath())) |
| } |
| return nil |
| } |
| + |
| +// lostEdgesPublished is close-lost's one read of control/edges/ (#1192, |
| +// V20): ref is the member's box reference from the validated row ("" when |
| +// the transaction never validated one, and then nothing is read), and |
| +// published whether its edges record is still listed. |
| +func (e *Engine) lostEdgesPublished(ctx context.Context) (string, bool, error) { |
| + valid, ok := e.last("validated", nil) |
| + if !ok { |
| + return "", false, nil |
| + } |
| + identity, _ := valid["identity"].(map[string]any) |
| + ref, _ := identity["box_ref"].(string) |
| + if !EdgesKey.MatchString("control/edges/" + ref + ".json") { |
| + return "", false, nil |
| + } |
| + keys, err := e.edgesList(ctx) |
| + if err != nil { |
| + return "", false, err |
| + } |
| + for _, k := range keys { |
| + if m := EdgesKey.FindStringSubmatch(k); m != nil && m[1] == ref { |
| + return ref, true, nil |
| + } |
| + } |
| + return ref, false, nil |
| +} |
diff --git a/internal/grouproll/roll_test.go b/internal/grouproll/roll_test.go| index 4200caf89..1b2c05814 100644 |
| --- a/internal/grouproll/roll_test.go |
| +++ b/internal/grouproll/roll_test.go |
| @@ -1930,16 +1930,16 @@ func (h *harness) checkClosed(t *testing.T, tx string) { |
| if err := h.closeLost(tx); err != nil { |
| t.Fatal(err) |
| } |
| - if h.activeTx() != "" || !reflect.DeepEqual(h.f.ops(), []string{"group", "ec2_instance"}) { |
| + if h.activeTx() != "" || !reflect.DeepEqual(h.f.ops(), []string{"group", "ec2_instance", "edges_list"}) { |
| t.Fatalf("calls %v", h.f.ops()) |
| } |
| j := h.txJournal(tx) |
| rows := j.Rows() |
| var kinds []string |
| - for _, r := range rows[len(rows)-6:] { |
| + for _, r := range rows[len(rows)-8:] { |
| kinds = append(kinds, r["kind"].(string)) |
| } |
| - if !reflect.DeepEqual(kinds, []string{"intent", "response", "intent", "response", "lost-member-closed", "done"}) { |
| + if !reflect.DeepEqual(kinds, []string{"intent", "response", "intent", "response", "intent", "response", "lost-member-closed", "done"}) { |
| t.Fatalf("rows %v", kinds) |
| } |
| closed, _ := j.Last("lost-member-closed", nil) |
| @@ -1961,6 +1961,65 @@ func (h *harness) checkClosed(t *testing.T, tx string) { |
| if !strings.Contains(h.out.String(), Text("lost_closed")) { |
| t.Fatal("not said") |
| } |
| + // #1192 (V20): the lost member's edges record is still listed here, and |
| + // close-lost says so, naming it, without touching it. |
| + ref := h.f.boxes[fakeIID]["box_ref"].(string) |
| + if closed["edges_published"] != true || !strings.Contains(h.out.String(), Text("lost_edges_published", "key", "control/edges/"+ref+".json")) { |
| + t.Fatalf("edges_published %v; out %s", closed["edges_published"], h.out.String()) |
| + } |
| + if len(h.f.writes) != 0 { |
| + t.Fatalf("writes %v", h.f.writes) |
| + } |
| +} |
| + |
| +// #1192 (V20): a lost member whose edges record is already retired closes |
| +// with edges_published false and no line about it; a failed listing |
| +// refuses and leaves the transaction open, like a failed describe. |
| +func TestCloseLostEdgesRecord(t *testing.T) { |
| + t.Run("retired", func(t *testing.T) { |
| + h := newHarness(t, 2) |
| + tx := h.seedLost() |
| + ref := h.f.boxes[fakeIID]["box_ref"].(string) |
| + h.f.intercept = func(op string, _ map[string]any, _ bool, perform func() (any, error)) (any, error) { |
| + r, err := perform() |
| + if op != "edges_list" || err != nil { |
| + return r, err |
| + } |
| + var keep []string |
| + for _, k := range r.([]string) { |
| + if k != "control/edges/"+ref+".json" { |
| + keep = append(keep, k) |
| + } |
| + } |
| + return keep, nil |
| + } |
| + must(t, h.closeLost(tx)) |
| + closed, _ := h.txJournal(tx).Last("lost-member-closed", nil) |
| + if closed["edges_published"] != false || strings.Contains(h.out.String(), "edges record") { |
| + t.Fatalf("edges_published %v; out %s", closed["edges_published"], h.out.String()) |
| + } |
| + }) |
| + t.Run("listing fails", func(t *testing.T) { |
| + h := newHarness(t, 2) |
| + tx := h.seedLost() |
| + h.f.before = func(op string, _ map[string]any) error { |
| + if op == "edges_list" { |
| + return Uncertain{Key: "api"} |
| + } |
| + return nil |
| + } |
| + if err := h.closeLost(tx); err == nil { |
| + t.Fatal("close-lost closed with an unread edges listing") |
| + } |
| + if h.activeTx() != tx { |
| + t.Fatalf("active %q", h.activeTx()) |
| + } |
| + for _, k := range []string{"lost-member-closed", "done"} { |
| + if _, ok := h.txJournal(tx).Last(k, nil); ok { |
| + t.Fatalf("%s recorded", k) |
| + } |
| + } |
| + }) |
| } |
| // test_close_lost_terminated_preserves_flags_and_status. |
diff --git a/internal/grouproll/text.go b/internal/grouproll/text.go| index 0164a7842..6697fe1c2 100644 |
| --- a/internal/grouproll/text.go |
| +++ b/internal/grouproll/text.go |
| @@ -26,6 +26,7 @@ var text = map[string]string{ |
| "close-lost": "Close an active transaction after confirming that its member is gone. Record failure.", |
| "close_lost_refused": "The member must be absent from the exact group and either terminated or absent from EC2.", |
| "lost_closed": "Transaction closed with outcome failed-member-lost. This does not record recovery.", |
| + "lost_edges_published": "The member's edges record `{key}` is still published. Do not delete it by hand. Termination recovery on the remaining boxes retires it. Drains on the other members do not wait for the member once a box has recorded its departure.", |
| "divergence_retained": "Provider divergence flag retained: {path}", |
| "abandoned": "Transaction abandoned before any group write intent.", |
| "abandon_refused": "A write intent exists. Use resume, rollback or return.", |
diff --git a/internal/grouproll/text_test.go b/internal/grouproll/text_test.go| index cab9b7478..c608a4501 100644 |
| --- a/internal/grouproll/text_test.go |
| +++ b/internal/grouproll/text_test.go |
| @@ -18,9 +18,10 @@ func TestTextRendersEveryKey(t *testing.T) { |
| // another region than the group, 2026-11-10), and remote_said (the |
| // member's own refusal, 2026-11-11); bucket_region, remote_said and the |
| // fixed remove_minimum approved in copy review 2026-11-11 (Paul, |
| - // unchanged). |
| - if len(text) != 147 { |
| - t.Fatalf("text has %d keys, want the 139 approved plus 8", len(text)) |
| + // unchanged), and lost_edges_published (#1192, 2026-11-17; approved by |
| + // delegation: Luna pass, docs/superpowers/reviews/LUNA-COPY-*-ha-1192.md). |
| + if len(text) != 148 { |
| + t.Fatalf("text has %d keys, want the 139 approved plus 9", len(text)) |
| } |
| for key, raw := range text { |
| var args []string |
diff --git a/internal/host/agent.go b/internal/host/agent.go| index 838c77eab..3283fd277 100644 |
| --- a/internal/host/agent.go |
| +++ b/internal/host/agent.go |
| @@ -1330,6 +1330,10 @@ func runAgent(args []string, buildClaims ClaimFactory) { |
| // only: the drain verbs are theirs. |
| if admission != nil && admission.group { |
| driver.group = newDrainDriver(svc, e, boxDrain, groupStartFence.read) |
| + // #1192: a proven-departed member is not waited on. |
| + // The departure controller arms later, behind |
| + // admission; read it as armed at each ask. |
| + driver.group.departed = armedPeerDeparted |
| } |
| setDutyView = svc.SetDutyView |
| } |
diff --git a/internal/host/hadepartures.go b/internal/host/hadepartures.go| index 9bcce556f..4168c85a4 100644 |
| --- a/internal/host/hadepartures.go |
| +++ b/internal/host/hadepartures.go |
| @@ -88,6 +88,9 @@ type DepartureConfig struct { |
| Pending func(context.Context, registry.HADeparture, provision.InventorySnapshot) error |
| Page func(context.Context, registry.HADeparture, []provision.DepartureHost) error |
| PageIdentity func(context.Context, registry.HAPendingTermination, string) error |
| + // TrashRetired is release.TrashRetired over the deployment bucket with |
| + // this box's release key (#1192). Nil never discharges a host. |
| + TrashRetired func(ctx context.Context, account, app string) (bool, error) |
| } |
| type Controller struct { |
| telemetry departureTelemetry |
diff --git a/internal/host/hadepartures_metrics.go b/internal/host/hadepartures_metrics.go| index 40e123484..040229a50 100644 |
| --- a/internal/host/hadepartures_metrics.go |
| +++ b/internal/host/hadepartures_metrics.go |
| @@ -71,3 +71,9 @@ func sampleDepartures() *metrics.DepartureSample { |
| s, _ := c.Metrics(ctx) |
| return &s |
| } |
| + |
| +// armedPeerDeparted is the armed departure controller's PeerDeparted, false |
| +// while none is armed (the drain driver's departed, #1192). |
| +func armedPeerDeparted(ctx context.Context, ref string) bool { |
| + return metricsDepartures.Load().PeerDeparted(ctx, ref) |
| +} |
diff --git a/internal/host/hadepartures_scan.go b/internal/host/hadepartures_scan.go| index 47b3141a2..69edfbe72 100644 |
| --- a/internal/host/hadepartures_scan.go |
| +++ b/internal/host/hadepartures_scan.go |
| @@ -6,6 +6,7 @@ import ( |
| "encoding/json" |
| "errors" |
| "fmt" |
| + "github.com/carlosframework/platform/internal/boxid" |
| "os" |
| "path" |
| "strconv" |
| @@ -169,6 +170,7 @@ func (c *Controller) ScanPass(ctx context.Context) (bool, error) { |
| } |
| blockers := []provision.DepartureHost{} |
| departed := map[string]bool{} |
| + trash := map[string]bool{} |
| count := 0 |
| for _, h := range inv.Records { |
| digest := scanDigest(h) |
| @@ -292,8 +294,12 @@ func (c *Controller) ScanPass(ctx context.Context) (bool, error) { |
| old.Result = "pending" |
| old.NotBefore = time.Time{} |
| s.Hosts[h.Host] = old |
| + // #1192: a host of an app the boxes retired to the Trash is never |
| + // adopted (no box mints its route), so it does not hold the |
| + // departure either. Like unserved, it waits for rule 1 below. |
| + trashed := c.trashed(ctx, h, trash) |
| unserved := false |
| - if !CanAdopt(h, c.cfg.Policy()) || !h.HA { |
| + if !trashed && (!CanAdopt(h, c.cfg.Policy()) || !h.HA) { |
| // DR-5 (spec §7.5): a host no surviving box could adopt does not |
| // hold the departure. It is neither imported nor touched. |
| if unserved = c.unserved(ctx, d, h, departed); !unserved { |
| @@ -308,6 +314,12 @@ func (c *Controller) ScanPass(ctx context.Context) (bool, error) { |
| wait(old.NotBefore) |
| continue |
| } |
| + if trashed { |
| + old.Result = departureTrashed |
| + s.Hosts[h.Host] = old |
| + c.logf("ha_departure_trashed departure=%s box=%s host=%s app=%s/%s generation=%d", d.ID, d.Box.Ref, h.Host, h.Account, h.App, v.Lock.Generation) |
| + continue |
| + } |
| if unserved { |
| old.Result = departureUnserved |
| s.Hosts[h.Host] = old |
| @@ -389,6 +401,36 @@ func (c *Controller) ScanPass(ctx context.Context) (bool, error) { |
| // could adopt it remains, so the departure finishes without an import. |
| const departureUnserved = "unserved" |
| +// departureTrashed marks a host discharged because its app is in the Trash |
| +// and the boxes have retired its routes (release.TrashRetired, #1192): no |
| +// box will adopt it until a restore, so the departure finishes without an |
| +// import. Rule 1 (a release marker or a passed expiry) still applies. |
| +const departureTrashed = "trashed" |
| + |
| +// trashed reports whether h's app is TrashRetired. It asks only when this |
| +// box holds no route for the host: a host this box serves reads nothing. |
| +// A matched host outside this box's pools (one DR-5 may find unserved) has |
| +// no route here either, so it costs the marker read (and, when a marker is |
| +// present, the flag read), once per app per pass, memoized in memo. Any |
| +// read failure answers false: the host keeps the departure as before. |
| +func (c *Controller) trashed(ctx context.Context, h provision.DepartureHost, memo map[string]bool) bool { |
| + if c.cfg.TrashRetired == nil || h.Account == "" || h.App == "" { |
| + return false |
| + } |
| + if rt, err := c.cfg.Registry.Get(h.Host); err != nil || (rt != nil && rt.Account == h.Account && rt.App == h.App) { |
| + return false |
| + } |
| + key := h.Account + "/" + h.App |
| + if known, ok := memo[key]; ok { |
| + return known |
| + } |
| + call, cancel := context.WithTimeout(ctx, 5*time.Second) |
| + retired, err := c.cfg.TrashRetired(call, h.Account, h.App) |
| + cancel() |
| + memo[key] = err == nil && retired |
| + return memo[key] |
| +} |
| + |
| // unserved applies spec §7.5 rules 2 and 3 (rule 1, the release marker or |
| // the passed expiry, is the scan's own wait). It reads only this box's |
| // departure view and local journal: no S3 request. departed memoizes the |
| @@ -431,16 +473,28 @@ func (c *Controller) unserved(ctx context.Context, d registry.HADeparture, h pro |
| } |
| // unservedRevoked reports the first current host recorded unserved that no |
| -// longer meets spec §7.5: this box could now adopt it, or a possible server |
| -// is in view. It reads only the view, the policy and the local journal. |
| +// longer meets spec §7.5 (this box could now adopt it, or a possible server |
| +// is in view), or recorded trashed whose app is no longer TrashRetired (a |
| +// restore, #1192). Unserved reads only the view, the policy and the local |
| +// journal; trashed reads the marker and flag again, once per app. |
| func (c *Controller) unservedRevoked(ctx context.Context, d registry.HADeparture, s registry.HADepartureScan, inv provision.InventorySnapshot) (string, bool) { |
| departed := map[string]bool{} |
| + trash := map[string]bool{} |
| for _, h := range inv.Records { |
| - if hs, ok := s.Hosts[h.Host]; !ok || hs.Result != departureUnserved || hs.Lifetime != h.Lifetime { |
| + hs, ok := s.Hosts[h.Host] |
| + if !ok || hs.Lifetime != h.Lifetime { |
| continue |
| } |
| - if (CanAdopt(h, c.cfg.Policy()) && h.HA) || !c.unserved(ctx, d, h, departed) { |
| - return h.Host, true |
| + switch hs.Result { |
| + case departureTrashed: |
| + // #1192: a restore since the scan gives the host back to a box. |
| + if !c.trashed(ctx, h, trash) { |
| + return h.Host, true |
| + } |
| + case departureUnserved: |
| + if (CanAdopt(h, c.cfg.Policy()) && h.HA) || !c.unserved(ctx, d, h, departed) { |
| + return h.Host, true |
| + } |
| } |
| } |
| return "", false |
| @@ -462,15 +516,26 @@ func (c *Controller) provenDeparted(ctx context.Context, d registry.HADeparture, |
| memo[ref] = ref == groupReferenceOf(d.Box.Account, d.Box.InstanceID) |
| return memo[ref] |
| } |
| - o, ok, err := c.cfg.Identities.Resolve(ctx, ref, "") |
| - if err != nil || !ok || !o.Known || o.PlacementNull || o.Box.Ref != ref || ref != groupReferenceOf(o.Box.Account, o.Box.InstanceID) { |
| + memo[ref] = c.PeerDeparted(ctx, ref) |
| + return memo[ref] |
| +} |
| + |
| +// PeerDeparted is provenDeparted's rule for any other box, and the drain's |
| +// (#1192): ref is a group reference, bound to its one account and instance |
| +// by a verified identity, whose departure this box's journal holds (any |
| +// phase). Enrollment requires termination proof, so a true answer means |
| +// the instance is terminated and nothing will publish under ref again. |
| +// Any failure, an unknown ref, a fixed ref or this box answers false. |
| +func (c *Controller) PeerDeparted(ctx context.Context, ref string) bool { |
| + if c == nil || !boxid.ValidBox(ref) || ref == c.cfg.Self.Ref { |
| return false |
| } |
| - if _, err = c.cfg.Registry.Departure(ctx, departureID(c.cfg.DeploymentBucket, o.Box)); err != nil { |
| + o, ok, err := c.cfg.Identities.Resolve(ctx, ref, "") |
| + if err != nil || !ok || !o.Known || o.PlacementNull || o.Box.Ref != ref || ref != groupReferenceOf(o.Box.Account, o.Box.InstanceID) { |
| return false |
| } |
| - memo[ref] = true |
| - return true |
| + _, err = c.cfg.Registry.Departure(ctx, departureID(c.cfg.DeploymentBucket, o.Box)) |
| + return err == nil |
| } |
| type departureLockListing struct { |
| @@ -797,7 +862,7 @@ func (c *Controller) complete(ctx context.Context, id string) (result error) { |
| c.telemetry.mu.Unlock() |
| recovered := 0 |
| for _, h := range s.Hosts { |
| - if h.Result != departureUnserved { |
| + if h.Result != departureUnserved && h.Result != departureTrashed { |
| recovered++ |
| } |
| } |
diff --git a/internal/host/hadepartures_trash_test.go b/internal/host/hadepartures_trash_test.go| new file mode 100644 |
| index 000000000..843616d4d |
| --- /dev/null |
| +++ b/internal/host/hadepartures_trash_test.go |
| @@ -0,0 +1,187 @@ |
| +package host |
| + |
| +// #1192 (dev IE, 2026-11-17): app bab/g6x was trashed on 11-14, but its |
| +// instance record and its released lock, naming group member A, stayed. |
| +// When A was terminated its departure matched the host, and adoption |
| +// deferred it on every pass (a trashed app's route is never minted), so |
| +// A's edges record was never retired and every later drain waited on it. |
| +// |
| +// The witness is the DR-5 rig (production wiring of armHADepartures) with |
| +// one more host: an app in the Trash, in a pool this box serves, whose |
| +// clean release marker names A. |
| + |
| +import ( |
| + "context" |
| + "crypto/ed25519" |
| + "slices" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +const trashedHost = "g6x.bab.example.com" |
| + |
| +// withTrashedHost adds the 11-17 host to the rig: record, release marker by |
| +// A, then the app trashed, then an inventory round (which still lists it). |
| +func withTrashedHost(t *testing.T, x *dr5Rig) { |
| + t.Helper() |
| + ctx := t.Context() |
| + rec := provision.Record{Schema: 1, Account: "bab", App: "g6x", Host: trashedHost, Channel: "edge", HA: true, CreatedAt: x.start.Add(-time.Hour)} |
| + if err := provision.CreateRecord(ctx, x.store, rec); err != nil { |
| + t.Fatal(err) |
| + } |
| + x.records = append(x.records, rec) |
| + x.putMarker(t, trashedHost, x.dead, 9) |
| + if err := release.TrashApp(ctx, x.store, "bab", "g6x", "paul@keymail.dev", x.start.Add(-time.Hour)); err != nil { |
| + t.Fatal(err) |
| + } |
| + x.reconcile(t) |
| + inv := x.a.Inventory.Snapshot() |
| + if !slices.ContainsFunc(inv.Records, func(h provision.DepartureHost) bool { return h.Host == trashedHost }) { |
| + t.Fatal("the trashed app's record is not in the departure inventory: the rig does not reproduce 11-17") |
| + } |
| + if rt, err := x.a.Registry.Get(trashedHost); err != nil || rt != nil { |
| + t.Fatalf("the trashed app has a route here (%+v, %v): the rig does not reproduce 11-17", rt, err) |
| + } |
| + x.locks[trashedHost] = x.lockBody(t, trashedHost) |
| +} |
| + |
| +func (x *dr5Rig) trashedUntouched(t *testing.T) { |
| + t.Helper() |
| + if got := x.lockBody(t, trashedHost); string(got) != string(x.locks[trashedHost]) { |
| + t.Fatalf("the trashed host's lock changed:\n%s\n%s", x.locks[trashedHost], got) |
| + } |
| + entry, _ := provision.LifetimeEntryOf(x.record(t, trashedHost)) |
| + if _, adopted, err := x.a.Registry.HAAdoption(t.Context(), trashedHost, entry.ID, x.id); err != nil || adopted { |
| + t.Fatalf("the trashed host was imported: %v", err) |
| + } |
| +} |
| + |
| +func TestDepartureTrashedAppDoesNotHoldIt(t *testing.T) { |
| + x := newDR5Rig(t, dr5Options{}) |
| + withTrashedHost(t, x) |
| + doneA, doneB := x.run(t, 5*time.Minute, nil) |
| + if doneA == 0 || doneA > dr5Bound || doneB == 0 { |
| + t.Fatalf("departures not finished within %s: A=%s B=%s logs=%q", dr5Bound, doneA, doneB, x.logs) |
| + } |
| + for _, key := range []string{x.edgesKey, "status/boxes/" + x.dead.Ref + ".json"} { |
| + if !x.gone(t, key) { |
| + t.Fatalf("%s left behind", key) |
| + } |
| + } |
| + if !slices.ContainsFunc(x.logs, func(l string) bool { |
| + return strings.HasPrefix(l, "ha_departure_trashed ") && strings.Contains(l, "host="+trashedHost) |
| + }) { |
| + t.Fatalf("no ha_departure_trashed line: %q", x.logs) |
| + } |
| + if x.pages != 0 { |
| + t.Fatalf("paged %d times", x.pages) |
| + } |
| + x.trashedUntouched(t) |
| + x.assertUntouched(t) |
| +} |
| + |
| +// Without the rule (the pre-#1192 scan), the same world never finishes: |
| +// this is the 11-17 stall, kept so the witness above proves the fix. |
| +func TestDepartureTrashedAppHeldItBefore1192(t *testing.T) { |
| + x := newDR5Rig(t, dr5Options{}) |
| + withTrashedHost(t, x) |
| + x.c.cfg.TrashRetired = nil |
| + doneA, doneB := x.run(t, 5*time.Minute, nil) |
| + if doneA != 0 { |
| + t.Fatalf("A finished at T+%s with no trash rule", doneA) |
| + } |
| + if doneB == 0 { |
| + t.Fatal("B did not finish") |
| + } |
| + if x.gone(t, x.edgesKey) { |
| + t.Fatal("A's edges file retired") |
| + } |
| +} |
| + |
| +// A trashed production app keeps its routes on every box, so it keeps the |
| +// departure too: the shared rule (release.TrashRetired) says not retired. |
| +func TestDepartureTrashedProductionAppStillHoldsIt(t *testing.T) { |
| + x := newDR5Rig(t, dr5Options{}) |
| + pub, priv, err := ed25519.GenerateKey(nil) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + ctx := t.Context() |
| + if err = release.SetProduction(ctx, x.store, priv, "bab", "g6x", true, "paul@keymail.dev"); err != nil { |
| + t.Fatal(err) |
| + } |
| + withTrashedHost(t, x) |
| + x.c.cfg.TrashRetired = func(ctx context.Context, account, app string) (bool, error) { |
| + return release.TrashRetired(ctx, x.store, pub, account, app) |
| + } |
| + if doneA, _ := x.run(t, 5*time.Minute, nil); doneA != 0 { |
| + t.Fatalf("A finished at T+%s on a production app's host", doneA) |
| + } |
| + if x.gone(t, x.edgesKey) { |
| + t.Fatal("A's edges file retired") |
| + } |
| +} |
| + |
| +// A restore after the host was discharged, before the delete, keeps the |
| +// departure: the rescan and the finalization gate read the marker again, |
| +// and the host then waits like any other. The restore lands inside the |
| +// discharge's own log call, so nothing of the scan runs before it. |
| +func TestDepartureTrashedAppRestoredBeforeDelete(t *testing.T) { |
| + x := newDR5Rig(t, dr5Options{}) |
| + withTrashedHost(t, x) |
| + restored := false |
| + logf := x.c.cfg.Logf |
| + x.c.cfg.Logf = func(f string, args ...any) { |
| + logf(f, args...) |
| + if !restored && strings.HasPrefix(f, "ha_departure_trashed ") { |
| + restored = true |
| + if err := release.RestoreApp(t.Context(), x.store, "bab", "g6x"); err != nil { |
| + t.Error(err) |
| + } |
| + } |
| + } |
| + doneA, _ := x.run(t, 5*time.Minute, nil) |
| + if !restored { |
| + t.Fatal("the host was never discharged, so the restore proves nothing") |
| + } |
| + if doneA != 0 { |
| + t.Fatalf("A finished at T+%s after its trashed host was restored", doneA) |
| + } |
| + if x.gone(t, x.edgesKey) { |
| + t.Fatal("A's edges file retired after the restore") |
| + } |
| +} |
| + |
| +// A restore that lands during the finalize, after the rescan discharged the |
| +// host and while the edges read is in flight, is caught by the finalization |
| +// gate (Astra R1 P2): the departure goes back to a walk and A's edges record |
| +// stays. Removing the gate's trashed recheck fails this test. |
| +func TestDepartureTrashedAppRestoredAtTheGate(t *testing.T) { |
| + x := newDR5Rig(t, dr5Options{}) |
| + withTrashedHost(t, x) |
| + fired := false |
| + hooked := &dr5HookedStore{Store: x.store, key: x.edgesKey, hook: func() { |
| + if err := release.RestoreApp(t.Context(), x.store, "bab", "g6x"); err != nil { |
| + t.Error(err) |
| + } |
| + fired = true |
| + }} |
| + x.c.cfg.OpenStore = func(context.Context) (release.Store, error) { return hooked, nil } |
| + doneA, _ := x.run(t, 5*time.Minute, nil) |
| + if !fired { |
| + t.Fatal("the finalize never read A's edges file") |
| + } |
| + if doneA != 0 || x.gone(t, x.edgesKey) { |
| + t.Fatalf("A finished at T+%s although its trashed host was restored before the delete", doneA) |
| + } |
| + if !slices.ContainsFunc(x.logs, func(l string) bool { |
| + return strings.HasPrefix(l, "ha_departure_unserved_revoked ") && strings.Contains(l, "host="+trashedHost) |
| + }) { |
| + t.Fatalf("the gate did not revoke the trashed host: %q", x.logs) |
| + } |
| + x.trashedUntouched(t) |
| +} |
diff --git a/internal/host/hadepartures_wiring.go b/internal/host/hadepartures_wiring.go| index dbac38bb9..41587730e 100644 |
| --- a/internal/host/hadepartures_wiring.go |
| +++ b/internal/host/hadepartures_wiring.go |
| @@ -112,6 +112,14 @@ func armHADepartures(ctx context.Context, a departureArm) (*Controller, hadepart |
| } |
| c, err := NewController(DepartureConfig{Admitted: a.Admitted, BeginWork: a.BeginWork, Registry: a.Registry, OpenStore: a.OpenStore, NewReader: defaultDepartureReader, Prefix: func(host string) string { return activator.HibernatePrefix(a.Backend.Cfg.Prefix, host) }, Identities: repo, Confirmer: a.Confirmer, Cache: cache, ProofStore: a.ProofStore, Self: a.Self, DeploymentBucket: a.Getenv("CARLOS_DEPLOYMENT_BUCKET"), Inventory: func() provision.InventorySnapshot { return departureInventorySnapshot(a.Inventory) }, RequestInventory: requestDepartureInventory, Policy: func() LocalPolicy { |
| return LocalPolicy{Scope: a.Self.Scope, Pools: provisionTickConfig(a.Getenv).Pools, Inbound: provisionTickConfig(a.Getenv).Inbound} |
| + }, TrashRetired: func(ctx context.Context, account, app string) (bool, error) { |
| + // The box's own retirement decision: the same bucket and release |
| + // key its reconcile reads (provisionTickConfig, productionClear). |
| + store, err := a.OpenStore(ctx) |
| + if err != nil { |
| + return false, err |
| + } |
| + return release.TrashRetired(ctx, store, provisionTickConfig(a.Getenv).ReleasePub, account, app) |
| }, Invalidate: a.Service.InvalidateDutyHolder, PageIdentity: func(ctx context.Context, h registry.HAPendingTermination, code string) error { |
| return PageOperator(ctx, alerting.LevelWarning, "ha_departure_pending", fmt.Sprintf("code=%s account=%s region=%s iid=%s", code, h.Account, h.Region, h.IID)) |
| }, Page: func(ctx context.Context, d registry.HADeparture, hosts []provision.DepartureHost) error { |
diff --git a/internal/host/hadrain.go b/internal/host/hadrain.go| index 38247d378..2cb6b9e63 100644 |
| --- a/internal/host/hadrain.go |
| +++ b/internal/host/hadrain.go |
| @@ -144,17 +144,20 @@ type drainReport struct { |
| Reasons []string `json:"reasons"` |
| // Fence is the start fence's transaction as the move step read it, |
| // at its start and again at its end. |
| - Fence string `json:"fence"` |
| - StartedAt time.Time `json:"started_at"` |
| - FinishedAt *time.Time `json:"finished_at"` |
| - Acked []string `json:"acked"` |
| - Moved []drainMoved `json:"moved"` |
| - Released []drainLeft `json:"released"` |
| - Unclean []string `json:"unclean"` |
| - Left []drainLeft `json:"left"` |
| - Holds drainHolds `json:"holds"` |
| - Closed int `json:"connections_closed_at_bound"` |
| - Quiet drainQuietOut `json:"quiet"` |
| + Fence string `json:"fence"` |
| + StartedAt time.Time `json:"started_at"` |
| + FinishedAt *time.Time `json:"finished_at"` |
| + Acked []string `json:"acked"` |
| + // Departed is the listed peers not waited for: group members whose |
| + // departure this box has enrolled, termination proven (#1192). |
| + Departed []string `json:"departed,omitempty"` |
| + Moved []drainMoved `json:"moved"` |
| + Released []drainLeft `json:"released"` |
| + Unclean []string `json:"unclean"` |
| + Left []drainLeft `json:"left"` |
| + Holds drainHolds `json:"holds"` |
| + Closed int `json:"connections_closed_at_bound"` |
| + Quiet drainQuietOut `json:"quiet"` |
| } |
| // drainMoved is one host moved: its confirmed holder and lock generation. |
| @@ -201,6 +204,10 @@ type drainDriver struct { |
| // and logf their log: seams for tests. |
| quietTick func() (<-chan time.Time, func()) |
| logf func(format string, args ...any) |
| + // departed reports a peer that is a group member whose departure this |
| + // box has enrolled (Controller.PeerDeparted): terminated, proven, and |
| + // never coming back under that reference. Nil waits for every peer. |
| + departed func(ctx context.Context, ref string) bool |
| mu sync.Mutex |
| // txn is the drain transaction this agent is in, "" for none. |
| @@ -353,6 +360,7 @@ func (d *drainDriver) snapshot() *drainReport { |
| c := *d.report |
| c.Reasons = append([]string(nil), c.Reasons...) |
| c.Acked = append([]string(nil), c.Acked...) |
| + c.Departed = append([]string(nil), c.Departed...) |
| c.Moved = append([]drainMoved(nil), c.Moved...) |
| c.Released = append([]drainLeft(nil), c.Released...) |
| c.Unclean = append([]string(nil), c.Unclean...) |
| @@ -591,6 +599,10 @@ func (d *drainDriver) publishAndAck(ctx context.Context, txn, phase string, rep |
| // their answers back on a channel. |
| seen := map[string]bool{} |
| why := map[string]string{} |
| + // gone: peers proven departed (#1192). A dead member cannot answer, |
| + // and its edges record stays published until its departure finishes, |
| + // so waiting for it only fails the drain at the bound. |
| + gone := map[string]bool{} |
| type answer struct { |
| peer string |
| ok bool |
| @@ -605,13 +617,26 @@ func (d *drainDriver) publishAndAck(ctx context.Context, txn, phase string, rep |
| } |
| var pending []string |
| for _, p := range peers { |
| - if !seen[p] { |
| + if !seen[p] && !gone[p] && d.departed != nil && d.departed(actx, p) { |
| + gone[p] = true |
| + d.logf("ha-drain: %s is a departed group member (termination proven); its acknowledgement is not awaited", p) |
| + } |
| + if !seen[p] && !gone[p] { |
| pending = append(pending, p) |
| } |
| } |
| if len(pending) == 0 { |
| - sort.Strings(peers) |
| - d.note(func() { rep.Acked = append([]string(nil), peers...) }) |
| + var acked, departed []string |
| + for _, p := range peers { |
| + if gone[p] && !seen[p] { |
| + departed = append(departed, p) |
| + } else { |
| + acked = append(acked, p) |
| + } |
| + } |
| + sort.Strings(acked) |
| + sort.Strings(departed) |
| + d.note(func() { rep.Acked, rep.Departed = acked, departed }) |
| return nil |
| } |
| answers := make(chan answer, len(pending)) |
| @@ -634,11 +659,11 @@ func (d *drainDriver) publishAndAck(ctx context.Context, txn, phase string, rep |
| why[a.peer] = "not seen yet" |
| } |
| } |
| - if allSeen(peers, seen) { |
| + if allSeen(pending, seen) { |
| continue |
| } |
| var missing []string |
| - for _, p := range peers { |
| + for _, p := range pending { |
| if !seen[p] { |
| missing = append(missing, p+" ("+why[p]+")") |
| } |
diff --git a/internal/host/hadrain_departed_test.go b/internal/host/hadrain_departed_test.go| new file mode 100644 |
| index 000000000..f58ed2b15 |
| --- /dev/null |
| +++ b/internal/host/hadrain_departed_test.go |
| @@ -0,0 +1,134 @@ |
| +package host |
| + |
| +// #1192: a drain does not wait for a peer that is a proven-departed group |
| +// member. On dev IE (2026-11-17) the dead member g-03152630's edges record |
| +// stayed published, the verb listed it, and the drain of the next member |
| +// asked it for 2 minutes and failed ("the draining state was not |
| +// acknowledged by g-03152630...: context deadline exceeded"). |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "slices" |
| + "strings" |
| + "testing" |
| + "time" |
| +) |
| + |
| +func TestDrainSkipsProvenDepartedPeer(t *testing.T) { |
| + defer shorten(&drainAckBound, 200*time.Millisecond)() |
| + defer shorten(&drainAckEvery, 20*time.Millisecond)() |
| + act, ed, marks := healthyDrain() |
| + ed.peers = []string{"b", "c", "g-dead"} |
| + ed.ack = func(peer string) (bool, error) { |
| + if peer == "g-dead" { |
| + return false, context.DeadlineExceeded |
| + } |
| + return true, nil |
| + } |
| + d := newDrainDriver(act, ed, marks, fenceOf("t1")) |
| + d.departed = func(_ context.Context, ref string) bool { return ref == "g-dead" } |
| + rep := runDrainListed(t, d, "t1", []string{"b", "g-dead"}) |
| + if rep.Result != "ok" { |
| + t.Fatalf("report %+v", rep) |
| + } |
| + if !slices.Equal(rep.Departed, []string{"g-dead"}) || slices.Contains(rep.Acked, "g-dead") || !slices.Contains(rep.Acked, "b") || !slices.Contains(rep.Acked, "c") { |
| + t.Fatalf("acked %v departed %v", rep.Acked, rep.Departed) |
| + } |
| + if n := ed.askCount("g-dead draining") + ed.askCount("g-dead drained"); n != 0 { |
| + t.Fatalf("a proven-departed peer was asked %d times", n) |
| + } |
| +} |
| + |
| +// A peer proven departed only while the drain waits (its departure enrolls |
| +// late) stops being waited for at once; one never proven still fails the |
| +// drain at the bound, named, as before. |
| +func TestDrainDepartedPeerProvenLateAndNever(t *testing.T) { |
| + defer shorten(&drainAckBound, 300*time.Millisecond)() |
| + defer shorten(&drainAckEvery, 20*time.Millisecond)() |
| + act, ed, marks := healthyDrain() |
| + ed.ack = func(peer string) (bool, error) { |
| + if peer == "c" { |
| + return false, errors.New("dial refused") |
| + } |
| + return true, nil |
| + } |
| + d := newDrainDriver(act, ed, marks, fenceOf("t1")) |
| + d.departed = func(_ context.Context, ref string) bool { return ref == "c" && ed.askCount("c draining") >= 2 } |
| + if rep := runDrain(t, d, "t1"); rep.Result != "ok" || !slices.Equal(rep.Departed, []string{"c"}) { |
| + t.Fatalf("late proof: report %+v", rep) |
| + } |
| + |
| + act, ed, marks = healthyDrain() |
| + ed.ack = func(peer string) (bool, error) { |
| + if peer == "c" { |
| + return false, errors.New("dial refused") |
| + } |
| + return true, nil |
| + } |
| + d = newDrainDriver(act, ed, marks, fenceOf("t1")) |
| + d.departed = func(context.Context, string) bool { return false } |
| + if rep := runDrain(t, d, "t1"); rep.Result != "failed" || !strings.Contains(strings.Join(rep.Reasons, ";"), "c (dial refused)") || len(rep.Departed) != 0 { |
| + t.Fatalf("never proven: report %+v", rep) |
| + } |
| +} |
| + |
| +// The 11-17 sequence on the production departure wiring (the DR-5 rig with |
| +// the trashed g6x host): member A terminated, its departure enrolled; a |
| +// drain on this box that lists A does not wait for it; the departure then |
| +// finishes within the DR-5 bound and retires A's edges record. PeerDeparted |
| +// answers only for the proven group member: never for a live peer, an |
| +// unknown ref, this box, or a fixed ref (whose name a replacement reuses). |
| +func TestDrainAfterLostMember1192(t *testing.T) { |
| + defer shorten(&drainAckBound, 300*time.Millisecond)() |
| + defer shorten(&drainAckEvery, 20*time.Millisecond)() |
| + // The fixed-ref case on its own rig: its serving replacement blocks A. |
| + fx := newDR5Rig(t, dr5Options{fixedPeer: true}) |
| + if fx.c.PeerDeparted(t.Context(), "fixedha") { |
| + t.Fatal("PeerDeparted(fixed ref) = true") |
| + } |
| + |
| + x := newDR5Rig(t, dr5Options{}) |
| + withTrashedHost(t, x) |
| + ctx := t.Context() |
| + |
| + if !x.c.PeerDeparted(ctx, x.dead.Ref) || !x.c.PeerDeparted(ctx, x.b.Ref) { |
| + t.Fatal("the terminated members are not proven departed") |
| + } |
| + for _, ref := range []string{x.peer.Ref, x.a.Self.Ref, "g-00000000000000000000", "not a ref"} { |
| + if x.c.PeerDeparted(ctx, ref) { |
| + t.Fatalf("PeerDeparted(%q) = true", ref) |
| + } |
| + } |
| + |
| + drain := func(listed []string) *drainReport { |
| + act, ed, marks := healthyDrain() |
| + ed.peers = append([]string{x.peer.Ref}, listed...) |
| + ed.ack = func(peer string) (bool, error) { |
| + if peer == x.peer.Ref { |
| + return true, nil |
| + } |
| + return false, context.DeadlineExceeded |
| + } |
| + d := newDrainDriver(act, ed, marks, fenceOf("t1")) |
| + d.departed = x.c.PeerDeparted |
| + return runDrainListed(t, d, "t1", append([]string{x.peer.Ref}, listed...)) |
| + } |
| + // Before the departure finishes: A is still listed and does not answer. |
| + if x.gone(t, x.edgesKey) { |
| + t.Fatal("A's edges record is already gone; the witness proves nothing") |
| + } |
| + rep := drain([]string{x.dead.Ref}) |
| + if rep.Result != "ok" || !slices.Equal(rep.Departed, []string{x.dead.Ref}) { |
| + t.Fatalf("drain with A listed: %+v", rep) |
| + } |
| + |
| + doneA, _ := x.run(t, 5*time.Minute, nil) |
| + if doneA == 0 || doneA > dr5Bound || !x.gone(t, x.edgesKey) { |
| + t.Fatalf("A's departure: done at T+%s, edges gone %v; logs %q", doneA, x.gone(t, x.edgesKey), x.logs) |
| + } |
| + // After: the verb no longer lists A, and the drain acks the live peer. |
| + if rep = drain(nil); rep.Result != "ok" || len(rep.Departed) != 0 { |
| + t.Fatalf("drain after the departure: %+v", rep) |
| + } |
| +} |
diff --git a/internal/provision/reconcile.go b/internal/provision/reconcile.go| index 780da7732..2c153a565 100644 |
| --- a/internal/provision/reconcile.go |
| +++ b/internal/provision/reconcile.go |
| @@ -325,15 +325,12 @@ type trashState struct { |
| // marker on purpose has to be told why nothing happened, or they will assume |
| // deletion is broken. |
| func productionClear(ctx context.Context, s release.Store, pub ed25519.PublicKey, acct, app string) bool { |
| - if pub == nil { |
| - return true |
| - } |
| - flag, err := release.GetProduction(ctx, s, pub, acct, app) |
| + ok, err := release.ProductionClear(ctx, s, pub, acct, app) |
| switch { |
| case err != nil: |
| log.Printf("provision: cannot read the production flag for %s/%s — refusing to act on the trash marker: %v", acct, app, err) |
| return false |
| - case flag != nil && flag.Production: |
| + case !ok: |
| log.Printf("provision: trash marker on production app %s/%s — refusing to act on it; turn production off first", acct, app) |
| return false |
| } |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 542f75862..62225b972 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -241,3 +241,4 @@ plan14-root-reads-config-receipts-1.tsv 4abde13ec40d53a479684b7f1e2079fbedb6c40c |
| plan14-root-reads-audit-edge-test-sleeps.tsv 4abde13ec40d53a479684b7f1e2079fbedb6c40cb1a28819c97853cdab768b2f |
| plan14-root-reads-ha-generations-floor.tsv 7ca068c5c146a679b4726d74fe43cf9c47f97080f9c08b761a36a9a12a5a3c54 |
| plan14-root-reads-fix-1193-wal-close-test.tsv 7ca068c5c146a679b4726d74fe43cf9c47f97080f9c08b761a36a9a12a5a3c54 |
| +plan14-root-reads-ha-1192.tsv 8df52839a0c961d3721f3a5c3247d06202dae4e00d011844b7117f8e918803d4 |
diff --git a/internal/provision/testdata/plan14-root-reads-ha-1192.tsv b/internal/provision/testdata/plan14-root-reads-ha-1192.tsv| new file mode 100644 |
| index 000000000..63d8b2eb0 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-ha-1192.tsv |
| @@ -0,0 +1,20 @@ |
| +# Census overlay ha-1192, written by census-propose (#369). census-ruling-ha-1192, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-ha-1192.md. |
| +# 4 body, 2 sites, 4 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 1 new dispositions: 0 reads re-frozen at their disposition with the claim, 1 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other. |
| +@legacy 54abaed8aef438227c077c9953fd126eb0659601a6b0931cfc44b16b73e44008 internal/grouproll/roll.go Engine.closeLost legacy accepted-legacy accepted-legacy;rev3=census-ruling-group-roll-verb;basis=lstats provider-divergence.json in the operator's own 0700 state directory to say it is kept;rev3=census-ruling-ha-1192;basis=operator CLI only (refuses root): after its group and EC2 checks, lists control/edges/ once through the existing journaled edgesList and reads its own journal's validated row for box_ref; reports whether the lost member's record is listed; writes nothing to the bucket file:Lstat@1652 80623961d79ff087d2762245947ad8fd1580f01f0d17d61bb9e39408b3e3909b |
| +@legacy 3162289fa8c4b24a1288058cbd29564f400ac551ae2b6af7e615efd66f5deaf6 internal/host/hadepartures_scan.go Controller.unservedRevoked legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-dr5;basis=DR-5 R2: rechecks unserved discharges before the edges delete; reads inventory records, scan Hosts, the in-memory view, policy and local journal rows via unserved(). No remote read.;rev3=census-ruling-ha-1192;basis=also rechecks hosts recorded trashed through Controller.trashed (local route lookup, then release.TrashRetired on the deployment bucket: the app's deleted.json and production flag, keys built from the record's own account/app); a restored app revokes the discharge before the edges delete registry:Hosts@264,registry:Lifetime@292,registry:Result@345,whole:HADeparture@603,whole:HADepartureHostScan@266 128e67867ba015573eb135c054fff315ac9c85976995a56a1e02c9ec9fd7f210 |
| +@legacy 311889a4155f477a01fb0aa4a7f93cf710fc47c577147252fbc87068514f4e9c internal/host/hadepartures_wiring.go armHADepartures legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3 fix r1: Install proof adapter, adoption identity and suspicion callbacks before asynchronous startup. Lazily retry the same deployment/data clients; lifetime callback reads only the current host through ExecBackend.TerminationLifetime. Add bounded structured paging for unresolved per-iid records. No new bucket, tenant input path or acquire bypass. B4: Wire the shared lock reader and existing AdoptHost entry. Read local route, Pair and duty revision only after authoritative inventory eligibility; bind its record lifetime and refuse missing/mismatched local routes. No route synthesis or pool widening. B5: Publish the armed controller to the existing metrics sampler. No new loop, remote source or process authority.;rev3=census-ruling-region-ha-followups;basis=Inject the existing PageOperator function into the backend when HA departures are armed; no new read or paging transport.;rev3=census-ruling-region-ha-p3b;basis=Require group admission/BeginWork callbacks and pass them into the sole departure consumer, including the production adoption closure. Same store, identity and registry reads; consumer Started remains a lifecycle fact, not duty authority.;rev3=census-ruling-region-ha-p1b3b-s;basis=Carry the actual provisionTickConfig pools and inbound posture into CanAdopt; stamped sidecars use the existing production adopter. Legacy unresolved paging remains. No wider tenancy or new remote source.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: wires the controller's RequestInventory hook to the agent's early-backstop signal. No new store, read or loop.;rev3=census-ruling-ha-1192;basis=wires DepartureConfig.TrashRetired: release.TrashRetired over a.OpenStore (the deployment bucket) with the box's CARLOS_RELEASE_PUBKEY via provisionTickConfig, the same marker and flag reads the reconcile already makes registry:Account@4137,registry:Account@7899,registry:App@7926,registry:IID@4158,registry:Incarnation@8086,registry:Pool@7945,registry:Region@4148,registry:Region@7966,registry:Revision@8321,registry:Revision@8718,registry:ServingSeq@8114,whole:DutyState@8440,whole:Pair@8303,whole:Pair@8696,whole:Pair@8702,whole:Route@7886,whole:Route@8595 b8286e2eac2e77fa7159063f805c11ed871453196d6a7978f56745a636361133 |
| +@legacy 617584322b1bf03ab5f8efbb6c2e2778bee223160a3d73ea68a1d15c761b08cb internal/host/hadepartures_scan.go Controller.trashed legacy accepted-legacy accepted-legacy;rev3=census-ruling-ha-1192;basis=new: reads the local registry route for a departure host, then (only when there is none) DepartureConfig.TrashRetired: release.TrashRetired on the deployment bucket, the app's trash marker apps/<account>/<app>/deleted.json and its root-signed production flag, account/app taken from the host's instance record (validated by ReadAppTombstone: schema 1, path and body agree); memoized per app per pass; any error answers false (keeps the host) registry:Account@261,registry:App@288,whole:Route@248 01b7ecbbb43befacfa4799b382763320aaaefa42716d7a61c528c4d303416027 |
| +@legacy 9b57442e21f8d414f2b196d7980e059dc4c8616a092ba15ea6ad5609f0a64cfc internal/host/hadepartures_scan.go Controller.ScanPass legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B4: Read authoritative pre-filter inventory, exact canonical lock revisions through one page reader, local scan checkpoints and adoption receipts. Persist source identity before the sole AdoptHost importer; validate later successor identity/lifetime/generation and require a fresh full zero-match rescan. Unknown state, unsupported hosts and missing previously matched locks refuse completion. No process launch or tenancy expansion. Preserve checkpoints across walks of identical record bytes; persist the current inventory generation separately and recheck source freshness/completeness before every page and deletion. Placement changes cannot filter the lock census. Fix r1/P15: classify legacy and unrelated locks as zero only before any D match; keep strict successor checks for previously matched hosts and hold malformed HA identities. Compare read start to expiry. Resume authority-complete deletion without rescanning unchanged inventory; persist evidence and scan errors with bounded retry. B4 fix r2: Inventory-only waits request the existing hourly page only after observed evidence is older than ChangeIndexBackstop plus 10 percent. Freshness and completion gates are unchanged; no new read. B5: Route the unchanged AdoptHost callback through measured telemetry; no new authority or lock read.;rev3=census-ruling-region-ha-p3b;basis=Gate and register the existing departure scan with admission before any work. Existing registry/object reads remain, closed members do not import, and shutdown cancels/joins registered work; no new root input.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: when a departure is blocked only on inventory freshness, signals the bounded early backstop round (global 60 s spacing, three per evidence) instead of waiting for the 30 min backstop. FreshAfter/I3 gates unchanged; no walk inside the step; no new read.;rev3=census-ruling-region-ha-g3-fixes;basis=Track current record revisions across inventory publications; separate lease waits from blockers and persist Cursor as zero for rollback. Drop removed records from coverage while retaining adoption or validated-successor gates for current hosts. Use the bounded lock-prefix listing only after validating every current host prefix; preserve per-host reads for known duties and fall back to the existing 32-host scan when listing evidence is unavailable. Cache listing evidence only in this process under scanMu, invalidate it on blocked work or inventory changes, and permit 128 reads with proven listing coverage. Added reads include departure LastError, host scan state and registry Hosts; the new remote read is a bounded LIST of the configured lock prefix in the existing data bucket.;rev3=census-ruling-region-ha-dr5;basis=BASIS AMENDED by spec 7.5 (DR-5, approved by agent manager 8a3d302 for the region HA standing approval): the B4 completion gate "adoption or validated successor" becomes "adoption, validated successor, or unserved discharge". A host may be discharged unserved only when (1) its lock is a valid release marker naming the departed box or a held lock whose expiry this box read as passed, (2) this box would adopt it but for the pool (placement, HA, lifetime, kind and sidecar rules, not denied), and (3) the complete in-memory departure view shows no in-scope box that serves or may serve the pool, other than group members with a departure enrolled in this box journal (fixed refs never count as gone; unknown served_pools blocks). Every unserved discharge is rechecked at one finalization gate immediately before the conditional edges delete. An unserved host is never imported and its lock is never written, so no lease authority moves; the full zero-match rescan still runs, with unserved hosts the only allowed matches. Inputs: served_pools comes from edges files that only box roles write (already trusted by this scan for identity and by placement); a box agent that lies can at most let a departure finish without import, which it can already cause by deleting edges files with its own role. No new remote read; reads Hosts/Rescan/Result from the local journal. The rescan is due at once.;rev3=census-ruling-ha-1192;basis=records a matched host whose app is TrashRetired, with a released or expired lock, as result "trashed" (no import, lock untouched) instead of adopting it; only reads added are the trash marker and production flag, and only when the local registry has no route for the host registry:Cursor@2032,registry:Cursor@2122,registry:Cursor@9546,registry:Generation@2094,registry:Generation@8811,registry:Hosts@2306,registry:Hosts@2326,registry:Hosts@3357,registry:Hosts@3977,registry:Hosts@4045,registry:Hosts@6053,registry:Hosts@6440,registry:Hosts@7147,registry:Hosts@7259,registry:Hosts@7498,registry:Hosts@8256,registry:InventoryGeneration@1913,registry:LastError@2902,registry:Lifetime@4006,registry:NotBefore@2191,registry:NotBefore@3905,registry:NotBefore@4378,registry:NotBefore@4419,registry:NotBefore@4444,registry:NotBefore@6021,registry:NotBefore@6410,registry:NotBefore@7111,registry:NotBefore@7177,registry:NotBefore@9220,registry:NotBefore@9274,registry:NotBefore@9599,registry:Observed@5592,registry:Observed@5739,registry:Observed@6293,registry:Observed@6327,registry:Phase@1448,registry:Phase@2049,registry:Phase@2384,registry:Phase@5309,registry:Phase@634,registry:Phase@689,registry:Phase@729,registry:RecordDigest@3287,registry:RecordDigest@4340,registry:RecordDigest@6350,registry:Rescan@2137,registry:Rescan@4320,registry:Rescan@5478,registry:Rescan@7678,registry:Rescan@8997,registry:Rescan@9385,registry:Rescan@9438,registry:Result@5991,registry:Result@6385,registry:Result@7226,registry:Result@7464,registry:Result@8222,registry:Unresolved@2156,registry:Unresolved@3811,registry:Unresolved@8280,registry:Unresolved@8868,registry:Unresolved@9113,registry:Unresolved@9396,registry:Unresolved@9562,registry:Version@7954,registry:Visited@2073,registry:Visited@2219,registry:Visited@3262,registry:Visited@3762,registry:Visited@3838,registry:Visited@3932,registry:Visited@8307,registry:Visited@9628,registry:Waiting@2175,registry:Waiting@9128,registry:Waiting@9203,registry:Waiting@9417,registry:Waiting@9582,whole:HADeparture@10014,whole:HADeparture@1111,whole:HADeparture@1230,whole:HADeparture@1415,whole:HADeparture@1704,whole:HADeparture@2517,whole:HADeparture@2714,whole:HADeparture@2870,whole:HADeparture@3005,whole:HADeparture@350,whole:HADeparture@392,whole:HADeparture@5589,whole:HADeparture@6941,whole:HADeparture@7922,whole:HADeparture@8058,whole:HADeparture@8414,whole:HADeparture@914,whole:HADeparture@9845,whole:HADepartureHostScan@2308,whole:HADepartureHostScan@2328,whole:HADepartureHostScan@3359,whole:HADepartureHostScan@3979,whole:HADepartureHostScan@4047,whole:HADepartureHostScan@4081,whole:HADepartureHostScan@6055,whole:HADepartureHostScan@6071,whole:HADepartureHostScan@6112,whole:HADepartureHostScan@6442,whole:HADepartureHostScan@6458,whole:HADepartureHostScan@7149,whole:HADepartureHostScan@7165,whole:HADepartureHostScan@7261,whole:HADepartureHostScan@7277,whole:HADepartureHostScan@7500,whole:HADepartureHostScan@7516,whole:HADepartureHostScan@8258,whole:HADepartureHostScan@8274,whole:HADepartureScan@7859,whole:HADepartureScan@8802,whole:HADepartureScan@9779,whole:HADepartureVisit@2075,whole:HADepartureVisit@2221,whole:HADepartureVisit@3264,whole:HADepartureVisit@3764,whole:HADepartureVisit@3782,whole:HADepartureVisit@3840,whole:HADepartureVisit@3858,whole:HADepartureVisit@3934,whole:HADepartureVisit@3952,whole:HADepartureVisit@8309,whole:HADepartureVisit@8327,whole:HADepartureVisit@9630 d11e9de047f7f5dde6a4dbab412fea5c061b0d8c4fbb018685f1705ab5859693 |
| +@legacy 80ef75f0d83091001e50f0d3a4826d7054623d3f05c77b84b979caf65974d583 internal/host/hadepartures_scan.go Controller.complete legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B4: Read the durable departure/scan and current inventory, then conditionally delete only the retained exact edges key/revision. Reread uncertain results and refuse replacement identities. Persist deletion and acknowledged index phases before complete; queue receipts stay in memory and only complete rows acknowledge. Fresh process evidence is required before authority checkpoint reuse. Fix r1/P15: ignore the old scan-level ETag override and delete only the original departure ETag. Exact-key readback retries the same tag; a changed tag is never deleted and advances only with a different verified iid under the same ref/account/scope, otherwise holds and pages. Persist permission fault episodes; route completion faults through bounded retry. No new filesystem or executable input. B4 fix r4/P18 supersedes fixed-ref deletion: only the deterministic account/iid group reference may delete its retained exact ETag. Every other ref performs an exact-key GET and stays pending unless absent or the existing verified newer-incarnation check succeeds; the live replacement file is left intact. Group revision changes stay pending. No new key or authority read. B5: Increment completion counter only after the durable complete phase; C4 ordering stays after that commit.;rev3=census-ruling-region-ha-p3b;basis=Require registered admitted work before completing a departure or acknowledging it. Existing coverage, inventory, lease and successor reads remain; closed members defer rather than clear obligations.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: drops the per-departure nudge bookkeeping (moved to a fixed-size global limiter). Completion gates, exact-ETag deletion and reads unchanged.;rev3=census-ruling-region-ha-g3-fixes;basis=Require current inventory visit coverage and re-read group edges before conditional deletion. Verify identity and scope before rebinding a changed ETag; preserve fixed-ref retention and exact-ETag deletion. Reads scan EdgesETag and coverage state; no new object key or read source.;rev3=census-ruling-region-ha-dr2;basis=DR-2: after the edges phases, calls retireStatusSnapshot, which for a deterministic account/iid group reference only does one GET of status/boxes/<ref>.json in the deployment store and a conditional delete of that exact revision (ETag). Best-effort and time-bounded (at most 5 s, always leaving 2 s of the step for the completion save; Astra R1 P2): any failure or timeout is logged and never holds completion, paging or acknowledgement. Fixed refs untouched. No filesystem, executable or new authority read; no change to the edges deletion, completion gates or ordering.;rev3=census-ruling-region-ha-dr5;basis=DR-5: one finalization gate immediately before the conditional edges delete revalidates unserved discharges (unservedRevoked: local view, policy, journal only); on failure clears DeleteUncertain and resets to a fresh walk before any delete. The completion log counts imported hosts only. No new remote read.;rev3=census-ruling-ha-1192;basis=excludes "trashed" hosts from the recovered count, as it does "unserved" registry:DeleteUncertain@3813,registry:DeleteUncertain@4544,registry:DeleteUncertain@4997,registry:EdgesETag@1894,registry:EdgesETag@2906,registry:Hosts@5848,registry:InventoryGeneration@1846,registry:PermissionAlerted@2426,registry:PermissionAlerted@3559,registry:PermissionAlerted@5141,registry:PermissionAlerted@5545,registry:PermissionAlerted@841,registry:PermissionAlerted@883,registry:Phase@1002,registry:Phase@1042,registry:Phase@1538,registry:Phase@262,registry:Phase@3692,registry:Phase@5259,registry:Phase@680,registry:Phase@950,registry:Phase@967,registry:Rescan@4574,registry:Result@5863,registry:Result@5896,registry:Version@665,registry:Visited@4595,whole:HADeparture@2846,whole:HADeparture@315,whole:HADeparture@442,whole:HADeparture@4423,whole:HADeparture@5671,whole:HADeparture@6057,whole:HADepartureHostScan@5850,whole:HADepartureScan@1718,whole:HADepartureScan@4426,whole:HADepartureScan@643,whole:HADepartureVisit@4597 f33013ac30442297b3e54f41180c4216262080cbeb373f9d1617ab7c47b64a2a |
| +internal/grouproll/roll.go Engine.closeLost legacy accepted-legacy accepted-legacy;rev3=census-ruling-group-roll-verb;basis=lstats provider-divergence.json in the operator's own 0700 state directory to say it is kept;rev3=census-ruling-ha-1192;basis=operator CLI only (refuses root): after its group and EC2 checks, lists control/edges/ once through the existing journaled edgesList and reads its own journal's validated row for box_ref; reports whether the lost member's record is listed; writes nothing to the bucket file:Lstat@1652 80623961d79ff087d2762245947ad8fd1580f01f0d17d61bb9e39408b3e3909b |
| +internal/host/agent.go runAgent authority B,C,D,F rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): builds the box's lifetime judge once (newBoxJudge, nil with host claims on) and hands it to the seed placement, the moves and runs workers and every loop it starts; read sites unchanged, offsets moved; B,C,D,F authority retained; self-serve moves 1 Task 8: derives the box's lifetimes switch from the judge once (lifetimes := boxJudge != nil) and hands it to the edges file loop; read sites unchanged, offsets moved;rev3=census-ruling-plans-4d-lapse;basis=arms two more plans hooks from the same snapshot: e.SetPlanDisabledFor(planDisabledFor) beside SetPlanGovernedFor, and svc.SetDisabledFor(planDisabledRoute) beside SetMaxRunFor (plans 4d); the reads live in those units (plans-4d-units decision); read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 9b81d97b (with main's plan rate ceiling, edge request records, regional box names, self-serve moves plan 1, plans 4d-1 lapse and its other later changes under main's own census rulings) plus the rootfs placement wiring in the activator start: an agentRootfs built from eb.NestedOK, CARLOS_DEPLOYMENT_SINGLE_TENANT, CARLOS_POOLS, the claim flag, swapArming's answer, the control client's /ready/rootfs and, on a fleet box whose identity resolved, fleetOwnerCheck over the deploy store main already opens for the fleet label (fleetStore), then arm and armedRootfs.Store; this body reads nothing new itself; the closures it wires read later, at a rootfs wake and each status tick: GET /ready/rootfs over the control socket, NestedOK's checks, and release.FleetOwnerKey for the judged row's own account and this box's fleet from the deploy store;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 7 and 11, #329 plan 3 Task 7 and plan 1 Task 7's policy cache: the control client is built once and handed to eb.Control, to the status tick (egressStatus) and to a new egressNudgeLoop goroutine; armSizeSource(svc, "/sys/fs/cgroup") after the activator Service; armPolicyCache() after armChangeIndex; statusLoop takes egressStatus. The reads are those units' own (decision rows); this body reads nothing new: the same five sites, offsets moved, in the agent; B,C,D,F authority retained.;rev3=census-ruling-remote-instance-metrics;basis=builds the metrics loop's owners closure (metricsOwners over the agent's registry, the activator and cgm.Leftover) when an activator exists and hands it to metricsLoop; reads nothing new itself;rev3=census-ruling-edge-asset-cache-3;basis=adds file:Statfs. runAgent keeps its authority (B,C,D,F). The new site is assetcache.Statfs, an exported assetcache.FS interface value (var Statfs FS = statfsFS{}), not a function value and not a call in runAgent: the ready hook passes it to armEdgeAssetCache as the store's filesystem, and armEdgeAssetCache calls its Space method on the configured data directory (dataDir(): $CARLOS_DATA_DIR, else /data), which calls unix.Statfs there (statfsFS.Space, accepted legacy at census-ruling-edge-asset-cache-2). No request-supplied pathname reaches it.;rev3=census-ruling-remote-metrics-nested;basis=main's body (merged origin/main acfa4f80, under main's own census rulings) plus: snapshots the nested layout (snapshotNestedUnits over /sys/fs/cgroup/carlos.slice/carlos-instances.slice) once at start, before the activator, and hands the metrics loop a unitSources struct (stamped units, routeHostNames, that root and the snapshot); reads nothing new itself;rev3=census-ruling-region-ha-p1a;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): wires region HA P1a into the activator: cfg.Record = haRecordFacts(openDeployStore, boxJudge) (the box's lifetime judge this body already builds with newBoxJudge, nil with host claims on; CI fix) and cfg.Self = lease.CurrentSelf; eb.Lifetimes (the process's lifetime index), eb.Registry, eb.StartupSwept (seedSweptAtStart.Load), eb.FilesStore from newProductionFilesStore (now lease.NewFilesStore, rootaws-loaded, a log line on failure) and lease.SetObligationDir(<data>/.ha-owed) (logged on failure; HA acquires then refuse); this body reads nothing new itself, the same five sites; the reads are those units' own (haRecordFacts and lease's SetObligationDir are new rows on this card); merge of origin/main d7ae1d76: main's own later changes to this body are kept as main has them, under main's rulings (census-ruling-remote-instance-metrics: the metricsOwners closure for metricsLoop; census-ruling-edge-asset-cache-3: the +file:Statfs site, assetcache.Statfs handed to the asset ready hook); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b1;basis=region HA P1b-1: builds one termfence.Confirmer (Self from lease.CurrentSelf at each call, EC2 DescribeInstances method only, client from rootaws.LoadDefaultConfig with retries off, built lazily on first use) and sets eb.OwnerTerminated; this body reads nothing new itself, the same six sites;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: the startup Sweep literal hands its answer to startupSwept, which logs as before and, only on a clean sweep, marks rootfs admission swept (MarkRootfsSwept); same Sweep call, no read added;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (controller ruling after branch review R1, and Paul's R2 ruling): sets svc.Fleet = fleetWakeFor(os.Getenv, identity, identErr, fleetStore) from the identity it already resolves once and the deployment store the fleet loops already opened, and logs an ERROR naming the identity error when the box is on a fleet with an invalid identity. fleetWakeFor reads CARLOS_REGION and CARLOS_FLEET from the same environment. Read sites unchanged (6). Agent, not root; a platform box is unchanged.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12: one call more beside armRunsPass, armInteractivePass(svc, reg, rolloutSink, boxJudge), in the same activator Configure hook, handing it the same box judge; fix round 1 (Astra P2, shutdown): after svc.Shutdown(ctx), shutdownInteractive(ctx) ends and joins every interactive session under the same shutdown budget; the worker's own reads are its units' (interactive.go); this body reads nothing new, the same six sites; merge of origin/main 6f1f6ca6: main's svc.Fleet = fleetWakeFor(...) and its invalid-identity ERROR line are kept as main has them (census-ruling-managed-fleets-1b); this branch's change is the same as above; read sites unchanged (6);rev3=census-ruling-fix-set-aside-exdev;basis=set-aside EXDEV fix: one field more on the agent ExecBackend literal, RawInstanceDir: layout.RawInstanceDir (a pure path join: <dataDir>/.instances/<InstanceID(host)>), so the start rule set-aside moves a copy out through the raw directory instead of through the nosymfollow bind; this body reads nothing new, the same six sites;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: one more assignment beside eb.FilesStore: eb.EscrowKey = haEscrowKey(os.Getenv("CARLOS_SECRETS_KEY")), the agent's own environment parsed by appconfig.ParsePrivateKey as the moves pass parses it (unset or unparseable: a log line and nil, and HA publication refuses on the box). No path is opened or read, no read site added; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 4: one more goroutine beside configSyncLoop: go escrowLoop(agentCtx, reg, svc), the escrow sweep every 30 s over the same registry and Service. This body reads nothing new itself; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 5: one more call beside eb.EscrowKey: wireRawSecretPages(eb, PageOperator, metricsBoxLabel(os.Getenv, readMachineID())), which sets eb.OnRawSecret to page an operator (alerting.Page through PageOperator, LevelIncident) on its own goroutine with a 20 s timeout; metricsBoxLabel and readMachineID are the reads this body already makes for the moves refusal log; no new read site; the same six sites, offsets moved; B,C,D,F authority retained. Merge of origin/main 90c4d3aa: main's own later changes to this body are kept as main has them, under main's rulings; this branch's change is the same as above. Merge of origin/main 00bf5b8c (fleet set-aside EXDEV fix): main's change to this body is kept as main has it, under its own census ruling; this branch's change is unchanged.;rev3=census-ruling-probe-burst-limit;basis=two more sink wirings beside setAnalyticsSink: setProtectionSink(e.SetProtectionRecordOnly) and setAssetOwnersSource(e.AssetOwners), function values the telemetry pass calls; this body reads nothing new, the same six sites; authority B,C,D,F retained; no new root read or write kind;rev3=census-ruling-region-ha-p1b3a;basis=Arm HA placement exactly once on the existing Service before activatorStart and edges publication, wiring AwakeApps and the PageOperator callback; existing six read sites unchanged, no new root authority.;rev3=census-ruling-stateless-replicas-1;basis=Final review I3: start the concrete coordinator's renewal worker with agent setup; existing closeReplicaCoordinator shutdown cancels and joins it before release. No new read sites or credentials. Merge origin/main c59715e7: retain main's armHAPlacement(svc, PageOperator) wiring beside the existing activator setup; stateless coordinator and shutdown wiring remain. Same read sites; no new root read or credential.;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): in the edge-ready callback, calls act.SetHeldWakeHook(e.HeldWake) when act is non-nil (installing the non-blocking wake callback) and stores e.HeldStreamsForStatus in heldStreamsSource. Wiring of in-memory callbacks only; no read added.;rev3=census-ruling-region-ha-p1b3b-t;basis=Wire Service.SetDutyView to the live edge DutySnapshot in the ready callback. No new read; no new loop or cloud operation. B2 wires the registry as the persistent DutyStore before service startup; no new cloud or filesystem path. B3b: arm one journal-backed termination consumer before service startup using agentCtx and the shared confirmer; expose edge tick and join at edge shutdown. No new direct read sites.;rev3=census-ruling-agent-start-demo-1;basis=Passes the existing registry, data store and hibernation prefix into the demo worker, and the existing instance-control client into the demo before-exec hook. No alternate data store or polling loop. Merge resolution against origin/main 9bd45488 retains main's HA departure controller, lifecycle and duty wiring alongside the demo data store and worker; no read site added by the resolution.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: install closed fixed admission before every launch source, bind activator/backend and edge, wire the real termination Started lifecycle and role reader after the change index; close before cancellation/child shutdown. No new external reads or cloud authority. Fix R1: move bind/lifecycle/edge-option wiring into wireAgentAdmission and worker listing into runWorkerBootPassAfterAdmission. Worker boot waits for admission before listing then uses unchanged bounded wakes and per-host serialization; whole Route read moves to the helper. No new storage, cloud, or root execution authority. Preserve merged main's agent wiring and census basis; the branch removes one whole Route use by moving worker iteration to the helper, with no added read kind.;rev3=census-ruling-stateless-replicas-2;basis=Slice 3b: arms a fleet-only worker using the existing registry, activator, backend and authenticated console transport. Owned worker stops and joins at shutdown. No new bucket reader. merge of origin/main 9b8b2c50: retain HA duty/departure lifecycle, wake-slot and existing agent wiring alongside the replica placement worker; no new read introduced by resolution. merge of origin/main 6be08467: Retain main demo configuration, admission, build and expiry wiring alongside the replica worker; merge-only body change, no additional read. merge of origin/main 7920cccf: Retain main box-role/group admission wiring and boot publication beside the owned replica worker and shutdown; main moves the boot registry List into runWorkerBootPassAfterAdmission, removing its inline whole Route site. No new read introduced by conflict resolution.;rev3=census-ruling-stateless-replicas-3;basis=Task 1 fix round 1 M3: retain the private snapshot source and cancel/join ownership, but use the replica-health-specific retry loop. It logs its first failure only and retains the existing exponential backoff capped at 30 seconds; unsupported builds return nil. Existing five direct read sites unchanged; no new credentials, bucket reader or app lifecycle action. Fix round 1 Q20: publish Edge.ReplicaSnapshots as a separate in-memory status source, leaving the tenant-visible Upstreams source unchanged. No new external reader or authority.;rev3=census-ruling-region-ha-p3b;basis=Load root-written group marker/configuration, configure signed boot binding and agent receipt completer, wire cancellable admission into departure work and expose cached GroupReaderSnapshot. New indirect boot reads use protected root files; agent-owned receipt controls duplicate initial completion only, never root restart permission. Same five direct sites. Merge 45cebde4 retains the replica health socket lifecycle and setReplicaSource beside GroupReaderSnapshot; no extra read beyond main.;rev3=census-ruling-agent-start-demo-2;basis=agent.go:309-329 opens demo-traffic.db beside the operator-configured registry when a demo domain exists, closes it at shutdown and wires drain-before-purge; :1010-1019 shares the worker and write gate; :1164-1177 installs the fleet identity and closed-until-worker serving callback. One added whole Route pass; the new indirect filesystem/SQL reads are claimed in openDemoTraffic and worker/store units. No request chooses the database pathname.;rev3=census-ruling-region-ha-p1b3b-s;basis=Wire the service duty view to authoritative cached sidecar manifest placement in LifetimeIndex and the edge sidecar projection; missing policy denies duty. Existing instance duty wiring remains.;rev3=census-ruling-region-ha-g2-t3;basis=T3a: wire eb.Page = PageOperator beside OwnerTerminated before departures arm, so suspect-holder pages work if departure setup fails; no new read; existing nine sites and authority unchanged; pages through the existing sink. T3b: publish the same backend through an atomic pointer for the metrics observer, and clear it on return; no new external read or authority.;rev3=census-ruling-agent-start-demo-3;basis=Wire the claim activator and root snapshot client into the demo worker; pass moved readiness to status reporting. Census read-site delta: unchanged (9).;rev3=census-ruling-region-ha-g2-fixes;basis=Wire local pool evidence, live withdrawal activator, startup ingress scan and alias publication, and edge lookup; no new direct sites; new indirect record/claim reads use existing store/judge paths described in ingress helpers.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: starts the existing record-view backstop loop with a departure-inventory listener (non-blocking, coalesced signal) even without an armed RecordView; it requests the existing full pass (backstopFullDue) there. Same nine read sites; no new read or authority.;rev3=census-ruling-region-ha-graceful-terminate-t2;basis=Derive one signal-time deadline with a 90-second budget; cap departure stop and startup/seed/service shutdown joins by it. No read added.;rev3=census-ruling-static-sweep-periodic;basis=in the edge-ready callback, publishes e.LargestStaticTree in staticTreeSource for the disk alert line (diskAlertFrac in the metrics loop); in-memory wiring only, no read added; read sites unchanged (9);rev3=census-ruling-edge-page-cache-1;basis=wires the exec backend's CurrentInputs into the edge cache (wireCurrentInputs) and, in the ready hook after armEdgeAssetCache (whose returned store it now keeps), calls armEdgePageCache, which does nothing unless CARLOS_PAGE_CACHE=1; read sites unchanged (9); no read added;rev3=census-ruling-gvisor-demos;basis=Capture sandbox resolution and refusal once; log errors once; gate route admission and BeforeExec before process launch. No new root read. Task 5: pass the once-captured sandbox effective mode/config error into ExecBackend, UnitBackend and the immutable Client expectation. Same startup environment/registry reads; swapArming declines gVisor before placement. Task 8: arm read-only status projection with the existing Client.SandboxStatus callback. Agent status now queries the existing root /ready endpoint; no new root authority or guest-file input. Merge2 e8a1ddde: retain main wireCurrentInputs and armEdgePageCache through the existing asset-store ready hook alongside branch once-captured sandbox mode, wake gates and root status wiring. No new direct read; main page-cache helpers retain their own census overlays.;rev3=census-ruling-region-ha-held-build;basis=wires the drain state: svc.SetDrainingSource(boxDrain.IsDraining), svc.SetPeerDrainView(e.PeerDraining), e.SetPeerDrainedHook(svc.DropHoldersNaming); in-memory only; no read added; region HA held-requests Task 5: on group members, starts the drain driver over the activator, the edge and boxDrain, and serves its root-only drain socket; no read added beyond the socket's own Branch review r1: the drain state follows the root start fence on group members (the fence reader is the existing fenceLocation.read, a root-owned fixed path); e.SetPeerUndrainedHook(svc.AllowHoldersNaming) beside the drained hook (memory only); the drain socket serves only the agent's own user. No read added.;rev3=census-ruling-security-review-mitigations;basis=Wire the cached operator flat-layout choice into the exec backend's new-resident refusal; no read source added, existing authority retained.;rev3=census-ruling-w6-ingress-drain;basis=agent (user carlos), not root. Builds the ingress drain (newIngressDrain) with arming read at ask time from os.Getenv (CARLOS_REGION_HA, CARLOS_INGRESS_TARGET_GROUPS, both from the root-owned host.env), the fixed admission and lease.CurrentSelf (existing IMDS identity); its reader is awstg.Load, the box role's credentials calling ELB DescribeTargetHealth/DescribeTargetGroupAttributes (new AWS reads, by the agent). Wires admission.closeStartsForIngressDrain, the lbhealth drain condition, ingress.setEdge, and ingress.shutdownStarted in WithShutdownStarted. The drain socket (/run/carlos/.ha-drain/drain.sock, agent-user only, existing) is now also served on a fixed box with the drain configured (was group members only), routing /v1/ingress/* to the ingress drain and the group drain verbs to 404 there. armHADepartures now takes fixtureDepartureGetenv() and MakeQueue fixtureDepartureQueue(), which in a production (non-rootrunner) build are os.Getenv and nil, as before. Read sites unchanged (9).;rev3=census-ruling-stateless-replicas-4-task1;basis=Arms the fleet-only replica swap worker next to the placement worker: same console URL and fleet token as the existing replicaCoordinatorAPI, the existing activator Service; stops and joins at shutdown. No new read site, credential or bucket reader.;rev3=census-ruling-stateless-replicas-4-task2;basis=Task 2: sets deployWorker.step to the rollout scheduler answer for the record permit (replicaStepOf over armedRollout), an in-memory callback; no read site, credential or bucket reader added.;rev3=census-ruling-stateless-replicas-4-task2-fix2;basis=Task 2 fix round 2: the swap worker step is armedReplicaStep, the same lazy scheduler lookup as before as a named function; no read site added.;rev3=census-ruling-stateless-replicas-4-merge-main;basis=Merge of main 5fac2ff1: both sides changed it. Main (01d6ca78, linked-deployments-slice1) starts linkLoop beside tunnelLoop; this branch keeps its replica coordinator wiring. Both kept as-is; no read added.;rev3=census-ruling-stateless-replicas-4-final;basis=#511 final wave item 2: wires the swap worker's drive (armedReplicaDrive, the armed rollout manager's DriveReplicaRelease); no read added;rev3=census-ruling-stateless-replicas-4-merge-main2;basis=Merge of main af871da0 (v0.34.49): both sides changed it. Main (178dcfe5, member-backups-2a) moves the inline duty-view closure into armDutyView/dutyView and starts verifyAssignLoop; its sites drop by registry:Host and whole:Route x2 as main recorded them. This branch keeps its replica coordinator, swap worker and drive wiring. Both kept as-is; no read added.;rev3=census-ruling-stateless-replicas-4-drill3;basis=drill 3 R24: makes one in-memory channel, closes it (once) inside the edge's existing shutdown-started callback after ingress.shutdownStarted, and passes it to tunnelLoop, which drains only a fleet channel name; no read added, same six sites; touches no admission, lease, ingress drain, listener or file; the agent process, no root decision;rev3=census-ruling-edge-ppv2;basis=Agent (uid carlos), not root. memwatchLoop now gets edgeProxyCounters(&demoEdge) (in-process counters, no read). The drain socket's driver is newAgentDrainSocket(ingress, e, os.Getenv), which attaches the edge trust handler only when CARLOS_INGRESS_PROXY_SOURCES in the agent's environment (from the root-owned host.env) parses to a non-empty list; the socket is served when drainSocketServed: a group member or a configured ingress drain (both as before), or a box armed for PROXY protocol (new). The socket's path and agent-user-only permissions are unchanged. Read sites unchanged (6).;rev3=census-ruling-same-box-edge-fence;basis=Agent (uid carlos), not root. One added line: armEdgeFenceStatus(ctl.EdgeFence), beside the existing armExecSandboxStatus, so the layout report can ask root's /ready for the edge fence state over the control socket client the agent already holds. No read added.;rev3=census-ruling-platform-mail-submission;basis=Task 4: sets eb.Mail = mailsubmit.SocketForwarder{} on every box, and eb.MailSwitch to a mailSwitchCache's On that opens the deploy store itself through openDeployStore, retried at most once a minute with an error line until it opens (review round 1, Task 4 P3), armed for the serial-move refresh (armedMailSwitch). Task 6: also sets the ExecBackend's ManifestOf, the same staged-manifest read as TierOf (rt.App and RouteAccount(rt), hence +registry:App and +whole:Route), for the spawn-time check of decision 10, which logs and emits an event and never refuses. Agent, not root. Fable final P2-2: eb.MailSwitch is the cache's State (three-valued: on, off, unknown) in place of On; an unreadable switch is unknown, never off. No read added.;rev3=census-ruling-fleet-drain-followups;basis=P3 (#1008 T9): one call after armChangeIndex, requestBootFullPass(v, &backstopFullDue), which stores true in the existing in-memory backstopFullDue flag only when no record view is armed, so the fast loop runs its existing full pass on its first tick instead of instancesLoop a minute later; armed boxes unchanged. No read added; read sites unchanged (8); agent, not root.;rev3=census-ruling-fleet-first-reconcile-speed;basis=Startup timing log lines only: runDuties builds a step logger (newStartupLog, which reads the in-memory agent start time) and logs one line after the wait on the activator startup latch and after each existing duty before go fastConvergeLoop. One newStartupLog().at line in the edge ready hook before go tunnelLoop. No read added; read sites unchanged (8). Agent, not root.;rev3=census-ruling-ha-1192;basis=sets the group drain driver's departed hook to armedPeerDeparted (the armed departure controller's PeerDeparted: local registry identity + departure journal); no new read file:Exec@21625,file:Open@2191,file:Statfs@58031,registry:App@13287,registry:App@13665,whole:Route@13279,whole:Route@13657,whole:Route@51246 d7d631e7c13c6a48bec242a6c4ea9824eb8a81ebe83bc113cb3b1c7ee50314eb |
| +internal/host/hadepartures_scan.go Controller.unservedRevoked legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-dr5;basis=DR-5 R2: rechecks unserved discharges before the edges delete; reads inventory records, scan Hosts, the in-memory view, policy and local journal rows via unserved(). No remote read.;rev3=census-ruling-ha-1192;basis=also rechecks hosts recorded trashed through Controller.trashed (local route lookup, then release.TrashRetired on the deployment bucket: the app's deleted.json and production flag, keys built from the record's own account/app); a restored app revokes the discharge before the edges delete registry:Hosts@264,registry:Lifetime@292,registry:Result@345,whole:HADeparture@603,whole:HADepartureHostScan@266 128e67867ba015573eb135c054fff315ac9c85976995a56a1e02c9ec9fd7f210 |
| +internal/host/hadepartures_wiring.go armHADepartures legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3 fix r1: Install proof adapter, adoption identity and suspicion callbacks before asynchronous startup. Lazily retry the same deployment/data clients; lifetime callback reads only the current host through ExecBackend.TerminationLifetime. Add bounded structured paging for unresolved per-iid records. No new bucket, tenant input path or acquire bypass. B4: Wire the shared lock reader and existing AdoptHost entry. Read local route, Pair and duty revision only after authoritative inventory eligibility; bind its record lifetime and refuse missing/mismatched local routes. No route synthesis or pool widening. B5: Publish the armed controller to the existing metrics sampler. No new loop, remote source or process authority.;rev3=census-ruling-region-ha-followups;basis=Inject the existing PageOperator function into the backend when HA departures are armed; no new read or paging transport.;rev3=census-ruling-region-ha-p3b;basis=Require group admission/BeginWork callbacks and pass them into the sole departure consumer, including the production adoption closure. Same store, identity and registry reads; consumer Started remains a lifecycle fact, not duty authority.;rev3=census-ruling-region-ha-p1b3b-s;basis=Carry the actual provisionTickConfig pools and inbound posture into CanAdopt; stamped sidecars use the existing production adopter. Legacy unresolved paging remains. No wider tenancy or new remote source.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: wires the controller's RequestInventory hook to the agent's early-backstop signal. No new store, read or loop.;rev3=census-ruling-ha-1192;basis=wires DepartureConfig.TrashRetired: release.TrashRetired over a.OpenStore (the deployment bucket) with the box's CARLOS_RELEASE_PUBKEY via provisionTickConfig, the same marker and flag reads the reconcile already makes registry:Account@4137,registry:Account@7899,registry:App@7926,registry:IID@4158,registry:Incarnation@8086,registry:Pool@7945,registry:Region@4148,registry:Region@7966,registry:Revision@8321,registry:Revision@8718,registry:ServingSeq@8114,whole:DutyState@8440,whole:Pair@8303,whole:Pair@8696,whole:Pair@8702,whole:Route@7886,whole:Route@8595 b8286e2eac2e77fa7159063f805c11ed871453196d6a7978f56745a636361133 |
| +internal/host/hadepartures_scan.go Controller.trashed legacy accepted-legacy accepted-legacy;rev3=census-ruling-ha-1192;basis=new: reads the local registry route for a departure host, then (only when there is none) DepartureConfig.TrashRetired: release.TrashRetired on the deployment bucket, the app's trash marker apps/<account>/<app>/deleted.json and its root-signed production flag, account/app taken from the host's instance record (validated by ReadAppTombstone: schema 1, path and body agree); memoized per app per pass; any error answers false (keeps the host) registry:Account@261,registry:App@288,whole:Route@248 01b7ecbbb43befacfa4799b382763320aaaefa42716d7a61c528c4d303416027 |
| +internal/host/hadepartures_scan.go Controller.ScanPass legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B4: Read authoritative pre-filter inventory, exact canonical lock revisions through one page reader, local scan checkpoints and adoption receipts. Persist source identity before the sole AdoptHost importer; validate later successor identity/lifetime/generation and require a fresh full zero-match rescan. Unknown state, unsupported hosts and missing previously matched locks refuse completion. No process launch or tenancy expansion. Preserve checkpoints across walks of identical record bytes; persist the current inventory generation separately and recheck source freshness/completeness before every page and deletion. Placement changes cannot filter the lock census. Fix r1/P15: classify legacy and unrelated locks as zero only before any D match; keep strict successor checks for previously matched hosts and hold malformed HA identities. Compare read start to expiry. Resume authority-complete deletion without rescanning unchanged inventory; persist evidence and scan errors with bounded retry. B4 fix r2: Inventory-only waits request the existing hourly page only after observed evidence is older than ChangeIndexBackstop plus 10 percent. Freshness and completion gates are unchanged; no new read. B5: Route the unchanged AdoptHost callback through measured telemetry; no new authority or lock read.;rev3=census-ruling-region-ha-p3b;basis=Gate and register the existing departure scan with admission before any work. Existing registry/object reads remain, closed members do not import, and shutdown cancels/joins registered work; no new root input.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: when a departure is blocked only on inventory freshness, signals the bounded early backstop round (global 60 s spacing, three per evidence) instead of waiting for the 30 min backstop. FreshAfter/I3 gates unchanged; no walk inside the step; no new read.;rev3=census-ruling-region-ha-g3-fixes;basis=Track current record revisions across inventory publications; separate lease waits from blockers and persist Cursor as zero for rollback. Drop removed records from coverage while retaining adoption or validated-successor gates for current hosts. Use the bounded lock-prefix listing only after validating every current host prefix; preserve per-host reads for known duties and fall back to the existing 32-host scan when listing evidence is unavailable. Cache listing evidence only in this process under scanMu, invalidate it on blocked work or inventory changes, and permit 128 reads with proven listing coverage. Added reads include departure LastError, host scan state and registry Hosts; the new remote read is a bounded LIST of the configured lock prefix in the existing data bucket.;rev3=census-ruling-region-ha-dr5;basis=BASIS AMENDED by spec 7.5 (DR-5, approved by agent manager 8a3d302 for the region HA standing approval): the B4 completion gate "adoption or validated successor" becomes "adoption, validated successor, or unserved discharge". A host may be discharged unserved only when (1) its lock is a valid release marker naming the departed box or a held lock whose expiry this box read as passed, (2) this box would adopt it but for the pool (placement, HA, lifetime, kind and sidecar rules, not denied), and (3) the complete in-memory departure view shows no in-scope box that serves or may serve the pool, other than group members with a departure enrolled in this box journal (fixed refs never count as gone; unknown served_pools blocks). Every unserved discharge is rechecked at one finalization gate immediately before the conditional edges delete. An unserved host is never imported and its lock is never written, so no lease authority moves; the full zero-match rescan still runs, with unserved hosts the only allowed matches. Inputs: served_pools comes from edges files that only box roles write (already trusted by this scan for identity and by placement); a box agent that lies can at most let a departure finish without import, which it can already cause by deleting edges files with its own role. No new remote read; reads Hosts/Rescan/Result from the local journal. The rescan is due at once.;rev3=census-ruling-ha-1192;basis=records a matched host whose app is TrashRetired, with a released or expired lock, as result "trashed" (no import, lock untouched) instead of adopting it; only reads added are the trash marker and production flag, and only when the local registry has no route for the host registry:Cursor@2032,registry:Cursor@2122,registry:Cursor@9546,registry:Generation@2094,registry:Generation@8811,registry:Hosts@2306,registry:Hosts@2326,registry:Hosts@3357,registry:Hosts@3977,registry:Hosts@4045,registry:Hosts@6053,registry:Hosts@6440,registry:Hosts@7147,registry:Hosts@7259,registry:Hosts@7498,registry:Hosts@8256,registry:InventoryGeneration@1913,registry:LastError@2902,registry:Lifetime@4006,registry:NotBefore@2191,registry:NotBefore@3905,registry:NotBefore@4378,registry:NotBefore@4419,registry:NotBefore@4444,registry:NotBefore@6021,registry:NotBefore@6410,registry:NotBefore@7111,registry:NotBefore@7177,registry:NotBefore@9220,registry:NotBefore@9274,registry:NotBefore@9599,registry:Observed@5592,registry:Observed@5739,registry:Observed@6293,registry:Observed@6327,registry:Phase@1448,registry:Phase@2049,registry:Phase@2384,registry:Phase@5309,registry:Phase@634,registry:Phase@689,registry:Phase@729,registry:RecordDigest@3287,registry:RecordDigest@4340,registry:RecordDigest@6350,registry:Rescan@2137,registry:Rescan@4320,registry:Rescan@5478,registry:Rescan@7678,registry:Rescan@8997,registry:Rescan@9385,registry:Rescan@9438,registry:Result@5991,registry:Result@6385,registry:Result@7226,registry:Result@7464,registry:Result@8222,registry:Unresolved@2156,registry:Unresolved@3811,registry:Unresolved@8280,registry:Unresolved@8868,registry:Unresolved@9113,registry:Unresolved@9396,registry:Unresolved@9562,registry:Version@7954,registry:Visited@2073,registry:Visited@2219,registry:Visited@3262,registry:Visited@3762,registry:Visited@3838,registry:Visited@3932,registry:Visited@8307,registry:Visited@9628,registry:Waiting@2175,registry:Waiting@9128,registry:Waiting@9203,registry:Waiting@9417,registry:Waiting@9582,whole:HADeparture@10014,whole:HADeparture@1111,whole:HADeparture@1230,whole:HADeparture@1415,whole:HADeparture@1704,whole:HADeparture@2517,whole:HADeparture@2714,whole:HADeparture@2870,whole:HADeparture@3005,whole:HADeparture@350,whole:HADeparture@392,whole:HADeparture@5589,whole:HADeparture@6941,whole:HADeparture@7922,whole:HADeparture@8058,whole:HADeparture@8414,whole:HADeparture@914,whole:HADeparture@9845,whole:HADepartureHostScan@2308,whole:HADepartureHostScan@2328,whole:HADepartureHostScan@3359,whole:HADepartureHostScan@3979,whole:HADepartureHostScan@4047,whole:HADepartureHostScan@4081,whole:HADepartureHostScan@6055,whole:HADepartureHostScan@6071,whole:HADepartureHostScan@6112,whole:HADepartureHostScan@6442,whole:HADepartureHostScan@6458,whole:HADepartureHostScan@7149,whole:HADepartureHostScan@7165,whole:HADepartureHostScan@7261,whole:HADepartureHostScan@7277,whole:HADepartureHostScan@7500,whole:HADepartureHostScan@7516,whole:HADepartureHostScan@8258,whole:HADepartureHostScan@8274,whole:HADepartureScan@7859,whole:HADepartureScan@8802,whole:HADepartureScan@9779,whole:HADepartureVisit@2075,whole:HADepartureVisit@2221,whole:HADepartureVisit@3264,whole:HADepartureVisit@3764,whole:HADepartureVisit@3782,whole:HADepartureVisit@3840,whole:HADepartureVisit@3858,whole:HADepartureVisit@3934,whole:HADepartureVisit@3952,whole:HADepartureVisit@8309,whole:HADepartureVisit@8327,whole:HADepartureVisit@9630 d11e9de047f7f5dde6a4dbab412fea5c061b0d8c4fbb018685f1705ab5859693 |
| +internal/host/hadepartures_scan.go Controller.complete legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B4: Read the durable departure/scan and current inventory, then conditionally delete only the retained exact edges key/revision. Reread uncertain results and refuse replacement identities. Persist deletion and acknowledged index phases before complete; queue receipts stay in memory and only complete rows acknowledge. Fresh process evidence is required before authority checkpoint reuse. Fix r1/P15: ignore the old scan-level ETag override and delete only the original departure ETag. Exact-key readback retries the same tag; a changed tag is never deleted and advances only with a different verified iid under the same ref/account/scope, otherwise holds and pages. Persist permission fault episodes; route completion faults through bounded retry. No new filesystem or executable input. B4 fix r4/P18 supersedes fixed-ref deletion: only the deterministic account/iid group reference may delete its retained exact ETag. Every other ref performs an exact-key GET and stays pending unless absent or the existing verified newer-incarnation check succeeds; the live replacement file is left intact. Group revision changes stay pending. No new key or authority read. B5: Increment completion counter only after the durable complete phase; C4 ordering stays after that commit.;rev3=census-ruling-region-ha-p3b;basis=Require registered admitted work before completing a departure or acknowledging it. Existing coverage, inventory, lease and successor reads remain; closed members defer rather than clear obligations.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: drops the per-departure nudge bookkeeping (moved to a fixed-size global limiter). Completion gates, exact-ETag deletion and reads unchanged.;rev3=census-ruling-region-ha-g3-fixes;basis=Require current inventory visit coverage and re-read group edges before conditional deletion. Verify identity and scope before rebinding a changed ETag; preserve fixed-ref retention and exact-ETag deletion. Reads scan EdgesETag and coverage state; no new object key or read source.;rev3=census-ruling-region-ha-dr2;basis=DR-2: after the edges phases, calls retireStatusSnapshot, which for a deterministic account/iid group reference only does one GET of status/boxes/<ref>.json in the deployment store and a conditional delete of that exact revision (ETag). Best-effort and time-bounded (at most 5 s, always leaving 2 s of the step for the completion save; Astra R1 P2): any failure or timeout is logged and never holds completion, paging or acknowledgement. Fixed refs untouched. No filesystem, executable or new authority read; no change to the edges deletion, completion gates or ordering.;rev3=census-ruling-region-ha-dr5;basis=DR-5: one finalization gate immediately before the conditional edges delete revalidates unserved discharges (unservedRevoked: local view, policy, journal only); on failure clears DeleteUncertain and resets to a fresh walk before any delete. The completion log counts imported hosts only. No new remote read.;rev3=census-ruling-ha-1192;basis=excludes "trashed" hosts from the recovered count, as it does "unserved" registry:DeleteUncertain@3813,registry:DeleteUncertain@4544,registry:DeleteUncertain@4997,registry:EdgesETag@1894,registry:EdgesETag@2906,registry:Hosts@5848,registry:InventoryGeneration@1846,registry:PermissionAlerted@2426,registry:PermissionAlerted@3559,registry:PermissionAlerted@5141,registry:PermissionAlerted@5545,registry:PermissionAlerted@841,registry:PermissionAlerted@883,registry:Phase@1002,registry:Phase@1042,registry:Phase@1538,registry:Phase@262,registry:Phase@3692,registry:Phase@5259,registry:Phase@680,registry:Phase@950,registry:Phase@967,registry:Rescan@4574,registry:Result@5863,registry:Result@5896,registry:Version@665,registry:Visited@4595,whole:HADeparture@2846,whole:HADeparture@315,whole:HADeparture@442,whole:HADeparture@4423,whole:HADeparture@5671,whole:HADeparture@6057,whole:HADepartureHostScan@5850,whole:HADepartureScan@1718,whole:HADepartureScan@4426,whole:HADepartureScan@643,whole:HADepartureVisit@4597 f33013ac30442297b3e54f41180c4216262080cbeb373f9d1617ab7c47b64a2a |
| +@coverage internal/grouproll e70f2bf825d2c82b12d0fa20caf8188428bfee463663655e6e1f7b2fa1b031ce |
| +@coverage internal/host aefe5e496e8a72699a4d7b0219c27347a825ba1995bac33f21cc5fad9d4704a6 |
| +@coverage internal/provision 1e4a77fec6e7c6484abaf60c76e6b4729615e161b43fae792c9047b201ae87f0 |
| +@coverage internal/release 7d86684d77c3db85e2da19596bdd73110b21d4923c280786b6068141d3fa62d3 |
diff --git a/internal/release/trash.go b/internal/release/trash.go| index 33ae4f0c9..aaaccf214 100644 |
| --- a/internal/release/trash.go |
| +++ b/internal/release/trash.go |
| @@ -94,6 +94,38 @@ func ReadAppTombstone(ctx context.Context, s Store, acct, app string) (*AppTombs |
| return &t, nil |
| } |
| +// ProductionClear is the production half of the trash rule: whether app's |
| +// production flag is positively clear (absent, or present and not |
| +// production). A nil pub is a box with no release key, which retires |
| +// trashed apps without reading the flag (internal/host agent.go), so it |
| +// answers clear. An unreadable flag is an error, never "clear". |
| +func ProductionClear(ctx context.Context, s Store, pub ed25519.PublicKey, acct, app string) (bool, error) { |
| + if pub == nil { |
| + return true, nil |
| + } |
| + flag, err := GetProduction(ctx, s, pub, acct, app) |
| + if err != nil { |
| + return false, err |
| + } |
| + return flag == nil || !flag.Production, nil |
| +} |
| + |
| +// TrashRetired is the one rule for "a trashed app's records never hold HA |
| +// or fleet work" (#1192, #1008 T9): true only when app's trash marker is |
| +// positively read and present AND its production flag is positively clear |
| +// (ProductionClear). That is exactly when the boxes retire the app's routes |
| +// (provision reconcile's removable), so no box will ever wake, adopt or |
| +// serve its hosts until a restore deletes the marker. Any read failure is |
| +// an error, which every caller treats as "still served": a fleet drain |
| +// keeps waiting and a departure keeps its host. |
| +func TrashRetired(ctx context.Context, s Store, pub ed25519.PublicKey, acct, app string) (bool, error) { |
| + tomb, err := ReadAppTombstone(ctx, s, acct, app) |
| + if err != nil || tomb == nil { |
| + return false, err |
| + } |
| + return ProductionClear(ctx, s, pub, acct, app) |
| +} |
| + |
| // RestoreApp deletes the marker. Store.Delete is idempotent by contract, so |
| // restoring an app that is not in the trash is a no-op, not an error. |
| func RestoreApp(ctx context.Context, s Store, acct, app string) error { |
diff --git a/internal/release/trashretired_test.go b/internal/release/trashretired_test.go| new file mode 100644 |
| index 000000000..ee350d2ed |
| --- /dev/null |
| +++ b/internal/release/trashretired_test.go |
| @@ -0,0 +1,71 @@ |
| +package release |
| + |
| +// TrashRetired is the one rule the fleet drain (#1008 T9) and the region |
| +// HA departure scan (#1192) share: an app's records stop holding work only |
| +// when its trash marker is positively present and its production flag is |
| +// positively clear. Every other answer, including a read failure, keeps |
| +// the work. |
| + |
| +import ( |
| + "context" |
| + "testing" |
| + "time" |
| +) |
| + |
| +func TestTrashRetired(t *testing.T) { |
| + ctx := context.Background() |
| + priv, pub := testKeys(t) |
| + |
| + t.Run("live app", func(t *testing.T) { |
| + s := NewDirStore(t.TempDir()) |
| + if got, err := TrashRetired(ctx, s, pub, "bab", "g6x"); got || err != nil { |
| + t.Fatalf("TrashRetired(live) = %v, %v; want false, nil", got, err) |
| + } |
| + }) |
| + t.Run("trashed app", func(t *testing.T) { |
| + s := NewDirStore(t.TempDir()) |
| + if err := TrashApp(ctx, s, "bab", "g6x", "paul@keymail.dev", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got, err := TrashRetired(ctx, s, pub, "bab", "g6x"); !got || err != nil { |
| + t.Fatalf("TrashRetired(trashed) = %v, %v; want true, nil", got, err) |
| + } |
| + // A keyless box retires trashed apps without reading the flag. |
| + if got, err := TrashRetired(ctx, s, nil, "bab", "g6x"); !got || err != nil { |
| + t.Fatalf("TrashRetired(trashed, no key) = %v, %v; want true, nil", got, err) |
| + } |
| + }) |
| + t.Run("trashed production app keeps its work", func(t *testing.T) { |
| + s := NewDirStore(t.TempDir()) |
| + if err := SetProduction(ctx, s, priv, "bab", "g6x", true, "paul@keymail.dev"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := TrashApp(ctx, s, "bab", "g6x", "paul@keymail.dev", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got, err := TrashRetired(ctx, s, pub, "bab", "g6x"); got || err != nil { |
| + t.Fatalf("TrashRetired(trashed production) = %v, %v; want false, nil", got, err) |
| + } |
| + }) |
| + t.Run("unreadable marker is an error", func(t *testing.T) { |
| + s := NewDirStore(t.TempDir()) |
| + if _, err := s.Put(ctx, AppTombstoneKey("bab", "g6x"), []byte(`{"schema":2}`), ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got, err := TrashRetired(ctx, s, pub, "bab", "g6x"); got || err == nil { |
| + t.Fatalf("TrashRetired(bad marker) = %v, %v; want false and an error", got, err) |
| + } |
| + }) |
| + t.Run("unreadable flag is an error", func(t *testing.T) { |
| + s := NewDirStore(t.TempDir()) |
| + if err := TrashApp(ctx, s, "bab", "g6x", "paul@keymail.dev", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := s.Put(ctx, ProductionKey("bab", "g6x"), []byte(`not json`), ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got, err := TrashRetired(ctx, s, pub, "bab", "g6x"); got || err == nil { |
| + t.Fatalf("TrashRetired(bad flag) = %v, %v; want false and an error", got, err) |
| + } |
| + }) |
| +} |