fleet: drain past trashed apps, move detached box records (#1008)
Fixes the three #1008 T9 drill findings. - A trashed app's unlabelled record no longer blocks a fleet drain when it is movable and another box can carry it (same trash and production reads the box uses; restore keeps working). - Records tied to a detached box move to the survivor even on a one-box fleet; both detach doors relabel at once. R2 and the stateless floor hold. Relabel writes bump the serial so boxes converge in seconds. - A restarted unindexed (fleet) box runs its boot full pass on the first fast tick instead of a minute later. Astra reviewed each task and the branch; census approved on #280. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Squashed from fleet-drain-followups into main.
14 files changed,
+1,337
−16
docs/superpowers/notes/census-proposal-fleet-drain-followups.md+19 −0docs/superpowers/plans/2026-11-15-fleet-drain-followups.md+360 −0internal/console/fleetbox.go+4 −1internal/console/fleetbox_test.go+7 −2internal/console/fleetrelabel.go+173 −11internal/console/fleetrelabel_test.go+695 −0internal/console/fleets.go+2 −0internal/console/replicaplacement_fix_test.go+6 −2internal/host/agent.go+3 −0internal/host/agent_test.go+35 −0internal/host/changeindex.go+14 −0internal/provision/sr_followups_census_test.go+14 −0internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/provision/testdata/plan14-root-reads-fleet-drain-followups.tsv+4 −0
CI passed — run details
diff --git a/docs/superpowers/notes/census-proposal-fleet-drain-followups.md b/docs/superpowers/notes/census-proposal-fleet-drain-followups.md| new file mode 100644 |
| index 000000000..f1cc25cd9 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-fleet-drain-followups.md |
| @@ -0,0 +1,19 @@ |
| +# Census approval: fleet-drain-followups |
| + |
| +Ruling `census-ruling-fleet-drain-followups`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +| unit | change | read sites | what changed | |
| +|---|---|---|---| |
| +| `internal/host/agent.go` `runAgent` | body | unchanged (8) | 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. | |
| + |
| +Envelopes re-pinned: `internal/host`. |
| + |
| +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/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. |
| + |
| +Seal: `c6655e82e81ccd2a7547655eb393ec3fd10bba396255a1edb30d59b7ad1e682e` → `c6655e82e81ccd2a7547655eb393ec3fd10bba396255a1edb30d59b7ad1e682e`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-fleet-drain-followups.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/plans/2026-11-15-fleet-drain-followups.md b/docs/superpowers/plans/2026-11-15-fleet-drain-followups.md| new file mode 100644 |
| index 000000000..57e72c6fd |
| --- /dev/null |
| +++ b/docs/superpowers/plans/2026-11-15-fleet-drain-followups.md |
| @@ -0,0 +1,360 @@ |
| +# Fleet Drain Follow-ups Implementation Plan (#1008 T9 findings) |
| + |
| +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. |
| + |
| +**Goal:** Fix the two P2s the T9 dev drill found (`.superpowers/sdd/2026-11-15-fleet-drain-followups/t9-drill-report.md`, "Product findings" 1 and 2): an app in the Trash blocks every drain of its fleet, and a box detached from a two-box fleet strands its labelled records. File the P3 (a restarted fleet agent cannot read records for 35 to 60 s) as a precise finding, because its cause cannot be settled from code alone. |
| + |
| +**Architecture:** Console-only. Task 1 teaches `drainBox` that an unlabelled record of an app the boxes have already retired (trash marker read, production flag positively clear) is not something the drain has to move. Task 2 lets the relabel worker read a one-box fleet whole when a box that is no longer active was ever named on a record, gates `relabelFleet` on `v.Complete` instead of `v.Active`, and has both detach doors run that fleet's relabel at once. No record field, wire shape, CLI string or root-binary file changes. |
| + |
| +**Tech Stack:** Go. `internal/console` only (plus its tests). |
| + |
| +**Spec:** `docs/superpowers/specs/2026-11-14-fleet-record-labels-design.md` (rev 3, final): R2 (restore-required, no empty start), R3 (stateless eligibility via `movableVerified`), D2 (no worker first labelling). Managed fleets 1b rules 4 and 5 (moves off lost, draining and detached boxes; detach only with `--terminated`). |
| + |
| +**Round history:** none yet. This plan is round 0. Stopping rule 1 applies from the first review. |
| + |
| +## Global Constraints |
| + |
| +- **R2 holds.** Every move goes through `provision.SetRecordFleetBox`, which sets `FleetBoxMoved = true` whenever the label changes from one box to another (`internal/provision/fleetbox.go:72-74`). The destination then refuses an empty start (`internal/activator/startrule.go:333-376`). Nothing in this plan writes a record any other way. |
| +- **R3 holds.** Every move decision still calls `s.movableVerified(ctx, rec)` and `v.chooseMoveDestination(rootfs, stateless, exclude)`, so an always-on stateless record moves only to a box at `release.StatelessRuntimeFloor`. |
| +- **D2 holds.** The worker never writes a first label. An unlabelled record stays unlabelled in both tasks. |
| +- **`v.Active` keeps its meaning** (`whole && len(v.Boxes) >= 2`, `internal/console/fleetbox.go:429`). The create door (`apiinstances.go:2214`), replica placement and the label door are untouched. Only the relabel worker's gate and its view load change. |
| +- **The trash judgement mirrors the box.** A box retires a trashed app's routes only when the marker is positively read and the production flag is positively clear (`internal/provision/reconcile.go:1766-1775`, `productionClear` at `:327-341`, `retiredWhy` at `:2472-2490`). The console excuses a record from the drain only under the same two reads. An unreadable marker or flag is "still served", which keeps today's refusal. |
| +- **No new user-facing strings.** Console log lines only (they are operator logs, as every existing `console: fleet relabel` / `console: fleet drain` line is, and are not copy-reviewed). If an implementer finds they need a new answer string, stop and add it to the Copy section for Paul's review first. |
| +- **No census card.** Every changed file is under `internal/console`, which is outside the root-binary census scope (AGENTS.md, "What is in scope"). Confirm with `make census-card` at the end of each task: it must report no changed unit. |
| +- **Tests:** targeted `-run` only, never the full suite (CI runs it). On docs-t1: |
| + ``` |
| + mkdir -p "$HOME/.cache/fleet-drain-followups/tmp" |
| + TMPDIR="$HOME/.cache/fleet-drain-followups/tmp" go test ./internal/console/ -run '<pattern>' -count=1 |
| + ``` |
| + Leave `GOCACHE` at its default. Remove `$HOME/.cache/fleet-drain-followups/` by that exact path when done. Run Bash with the sandbox disabled (the bwrap error on another worktree's metadata). |
| +- **Every witness is deterministic:** explicit `now` values and direct calls (`fx.srv.fleetRelabelPass(ctx, now)`, `fx.srv.drainBox`), never sleeps. |
| +- Never run `git worktree`, `git stash`, `git config` or glob deletes. Commit subjects under 80 characters. |
| + |
| +## Decisions (with reasons) |
| + |
| +### D-A. Trashed apps: excuse their unlabelled records from the drain (option 1) |
| + |
| +Rejected **"trash retires the fleet instance records"**: restore depends on the records. Trash keeps them, restore leaves them alone, and the box's reconcile mints the instance routes again from them once the marker is gone (`internal/console/restore.go:28-41`, `restoredTemporaryNote`; `apicli.go` restore door comment "removing the trash marker re-enables instance minting"). Retiring them would make a restored fleet app come back with no instances, and they could not be recreated with their data identity. |
| + |
| +Rejected **"an owner verb clears them"**: a new CLI verb, route, parity row, docs and copy, for a state the owner did nothing wrong to reach. The person draining may not be the app's owner, and the label door answers 404 for a trashed app (`instancelabel.go`, `HasAppIn`), so the verb would have to be a second door into trashed apps. |
| + |
| +Chosen: in `drainBox`, an **unlabelled** record whose app's trash marker is positively read and whose production flag is positively clear does not strand the drain. Why this is safe and keeps restore working: |
| + |
| +- **It is not live.** Every box retires that app's routes on its next pass (`reconcile.go:2472-2490`, "app in the trash"), and the hub's forward phase drops them too (`trashFor` in `forwardView`, `reconcile.go:1805-1820`). |
| +- **It is not stranded.** An unlabelled record is carried by every box of the fleet (`ownsRecord`, spec §1). After the drained box is detached, the remaining boxes still carry it. A restore makes them mint it again, exactly as for any other app. |
| +- **Nothing is written to it.** It stays unlabelled (D2). Its data is in the fleet bucket from the stop's final checkpoint (R2's proven checkpoint), so a remaining box restores it on its first wake. |
| +- **Labelled records of a trashed app are not excused.** They follow the normal rules: moved like any other (so a later restore finds them on a live box), or stranding the drain if they cannot move. Excusing a labelled record would leave it tied to the box being removed, and after detach the restore would answer 503. |
| + |
| +Accepted race: the app is restored between the drain's marker read and its draining write. The restored unlabelled record is then carried by every box including the draining one, which is the pre-1b multi-box state the label door exists for. Nothing is stranded: the other boxes carry it. The drain does not take the app lock (it holds the fleet lock, and no current code orders app-then-fleet, so adding fleet-then-app is a lock-order risk for no safety gain). |
| + |
| +### D-B. Detached box on a one-box fleet: a "move off gone boxes" view, not a looser `Active` |
| + |
| +The relabel worker skips any fleet with fewer than two active boxes twice over: `loadFleetViewAt` returns early without the inventory (`fleetbox.go:358`), and `relabelFleet` returns on `!v.Active` (`fleetrelabel.go:153`). |
| + |
| +Chosen: |
| + |
| +- **A view load for the worker** (`relabelView`) that asks `loadFleetViewRequiredAt(..., requireComplete)` with `requireComplete` true exactly when the fleet has one active registry box and some non-active box (status `detached`, the only other status, `registry/fleets.go:120-122`) has `LabelledAt != 0`. Only then is the one-box inventory read, so a one-box fleet that never lost a labelled box costs nothing new. |
| +- **`relabelFleet` gates on `v.Complete`.** For two or more active boxes `Complete == Active`, so nothing changes there. Below two it is true only for a view read whole: the new case, and the existing one-box fleet with replica apps (whose view is already read whole, `fleetbox.go:358`). In both, moving records off a draining, lost or detached box to a valid survivor is the behaviour the worker already has on larger fleets. |
| +- **Destination rules are unchanged.** `chooseMoveDestination` still needs a fresh, non-draining box at the label floor (rootfs-ready for rootfs, at the stateless runtime floor for stateless). With no valid survivor the record stays and is logged, as today. |
| +- **"Lost" is already covered.** A box still active in the registry but silent past `fleetBoxLostAfter` keeps the fleet at two active boxes, so the existing path moves its records (`TestLostBoxMovesToTheSurvivor`). Only "detached" drops the active count, so only detached needs the new view. |
| +- **Both detach doors run the fleet's relabel at once** after a successful detach, under the fleet lock they already hold, bounded, best effort, answer unchanged. That makes `detach-box --terminated` itself the command that moves the records, instead of up to five minutes of 503s. |
| + |
| +The `instances label` answer "already tied to box-2. nothing to do" (C07) and the `fleets drain` answer "is detached. there is nothing to drain" need **no change**: with the detach-time relabel they describe the state truthfully in the normal case. The residual case (no valid survivor, or an unmovable record) is a follow-up in Deferred. |
| + |
| +### D-C. P3 is deferred with a precise finding |
| + |
| +See Deferred. The reconcile path on a fleet box carries no deadline of its own, so "context deadline exceeded" comes from a caller whose log line the drill report does not quote. The cheapest next step is reading that line, not a code change. |
| + |
| +## Landing |
| + |
| +- One branch, `fleet-drain-followups`, two commits (Task 1, Task 2). They both touch `fleetrelabel.go` but different functions. |
| +- **Review:** both tasks write instance records (production storage), so each gets Astra's verdict. One Astra run over the branch with a verdict per task is enough (stopping rule 3), at most three rounds. Brief from `docs/superpowers/reviews/REVIEW-BRIEF-TEMPLATE.md`. |
| +- No copy review, no census card, no parity or docs change. |
| +- Merge with `amadan branch merge carlos/platform fleet-drain-followups -expect <full sha> -squash -message "<subject under 80 chars>\n\n<body>"` (real newlines), after CI is green. Send the SHA to the release manager (8a3d302) and post on #1008. It rides v0.36.1. |
| + |
| +## File Structure |
| + |
| +| File | Change | Task | |
| +|---|---|---| |
| +| `internal/console/fleetrelabel.go` | `drainBox` excuses trashed apps' unlabelled records; `trashRetired` helper | T1 | |
| +| `internal/console/fleetrelabel.go` | `relabelView`, `goneLabelledBox`; `fleetRelabelPass` uses `relabelView`; `relabelFleet` gates on `v.Complete`; `relabelAfterDetach` | T2 | |
| +| `internal/console/fleets.go` | both detach doors call `relabelAfterDetach` | T2 | |
| +| `internal/console/fleetbox.go` | doc comment of `fleetView.Complete` / `Active` only | T2 | |
| +| `internal/console/fleetrelabel_test.go` | witnesses | T1, T2 | |
| +| `internal/console/fleetbox_test.go` | `countStore.listsOf` helper | T2 | |
| + |
| +--- |
| + |
| +### Task 1: A trashed app's unlabelled record no longer blocks a drain |
| + |
| +**Files:** |
| +- Modify: `internal/console/fleetrelabel.go`, `drainBox` (`:384-509`; the `rec.FleetBox == ""` case at `:457-460`) and its doc comment (`:372-383`); the file header comment (`:20-56`) gets one sentence. |
| +- Test: `internal/console/fleetrelabel_test.go` |
| + |
| +**Interfaces:** |
| +- Produces (unexported): |
| + ```go |
| + // 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". |
| + func (s *Server) trashRetired(ctx context.Context, sqid, app string) (bool, error) |
| + ``` |
| +- Consumes: `release.ReadAppTombstone`, `release.GetProduction`, `s.cfg.Releases`, `s.cfg.ReleasePub`. |
| + |
| +**Behaviour:** In `drainBox`'s record loop, replace |
| + |
| +```go |
| +if rec.FleetBox == "" { |
| + strand[rec.App] = true |
| + continue |
| +} |
| +``` |
| + |
| +with: look the app up in a per-call memo `retired map[AppRef]bool` (one marker read and at most one flag read per app per drain, and only for apps with an unlabelled record on this fleet). If `trashRetired` answers true, log once per app |
| + |
| +``` |
| +console: fleet drain %s/%s: %s/%s is in the trash and its routes are retired; its unlabelled records stay as they are and do not hold the drain |
| +``` |
| + |
| +and `continue` without stranding. On false, or on an error (log `console: fleet drain %s/%s: %s/%s: trash state unreadable: %v; treated as served`), strand as today. Labelled records of a trashed app go through the existing `movableVerified` / `chooseMoveDestination` path unchanged. `msgDrainStrandsApps` is unchanged. The one-box branch (`len(v.Boxes) < 2`, reading `fleetInventoryFor`) gets the same treatment because it shares the loop. |
| + |
| +Doc comment of `drainBox`: "A record cannot move when it is unlabelled (every box runs it), unless its app is in the Trash and the boxes have retired its routes (trashRetired): such a record is not served, every remaining box still carries it, and a restore mints it again from the record, so it does not hold the drain and is left unlabelled." |
| + |
| +- [ ] **Step 1: Write the failing witness** in `fleetrelabel_test.go`: |
| + |
| + ```go |
| + // #1008 T9 finding 1: an app in the Trash blocked every drain of its |
| + // fleet until it purged. An unlabelled record of an app whose marker is |
| + // read and whose production flag is clear is not served by any box, is |
| + // still carried by every other box, and comes back on restore, so it no |
| + // longer holds the drain. Its record is not written. |
| + func TestDrainSkipsATrashedAppsUnlabelledRecord(t *testing.T) { |
| + ctx := context.Background() |
| + fx, _, reg := fleetBoxWorld(t, "code-rl-drain-trash", "pi-1", "pi-2") |
| + placeBlog(t, fx) |
| + putFleetRecord(t, fx, "shop", "a.example.com", func(r *provision.Record) { r.FleetBox = "pi-1" }) |
| + putFleetRecord(t, fx, "blog", "x.example.com", nil) // unlabelled: every box carries it |
| + before := blogRecBytes(t, fx, "x.example.com") // raw object bytes, for "not written" |
| + |
| + // Baseline: live, it strands the drain (as TestDrainRefusesAnUnmanagedRecord/unlabelled). |
| + if stuck, err := fx.srv.drainBox(ctx, "pi", "pi-1"); err != nil || !slices.Equal(stuck, []string{"blog"}) { |
| + t.Fatalf("live: drainBox = %v, %v; want blog stranded", stuck, err) |
| + } |
| + if err := release.TrashApp(ctx, fx.rel, fx.sqid, "blog", "paul@keymail.dev", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + stuck, err := fx.srv.drainBox(ctx, "pi", "pi-1") |
| + if err != nil || len(stuck) != 0 { |
| + t.Fatalf("trashed: drainBox = %v, %v; want nothing stranded", stuck, err) |
| + } |
| + if r := shopRec(t, fx, "a.example.com"); r.FleetBox != "pi-2" || !r.FleetBoxMoved { |
| + t.Fatalf("shop's record after the drain: %+v; want moved to pi-2", r) |
| + } |
| + if b := boxRow(t, reg, "pi-1"); b.DrainingSince == 0 { |
| + t.Fatal("the drain did not mark pi-1 draining") |
| + } |
| + if got := blogRecBytes(t, fx, "x.example.com"); !bytes.Equal(got, before) { |
| + t.Fatalf("the trashed app's record was written:\n%s\nwant\n%s", got, before) |
| + } |
| + // Restore keeps working: the marker goes and the record is there, |
| + // unlabelled, on the fleet, for the remaining boxes to mint. |
| + if err := release.RestoreApp(ctx, fx.rel, fx.sqid, "blog"); err != nil { |
| + t.Fatal(err) |
| + } |
| + r, err := provision.GetRecord(ctx, fx.rel, fx.sqid, "blog", "x.example.com") |
| + if err != nil || r.Retired || r.Region != "fleet/pi" { |
| + t.Fatalf("after restore: %+v, %v; want the record kept on fleet/pi", r, err) |
| + } |
| + wantNoLabel(t, r) |
| + } |
| + ``` |
| + |
| + `blogRecBytes` is a small helper: `fx.rel.Get(ctx, provision.RecordKey(fx.sqid, "blog", h))`. |
| + |
| +- [ ] **Step 2: Write the refusals that must keep holding**, as subtests of `TestDrainStillRefusesATrashedAppTheBoxesServe`, each in its own `fleetBoxWorld` with `placeBlog`, shop's `a` labelled `pi-1` and blog trashed with `release.TrashApp`, asserting `stuck == []string{"blog"}`, no record written (`newCountStore` installed before the drain, `recordPuts() == 0`) and `pi-1` not draining: |
| + - `"production"`: `release.SetProduction(ctx, fx.rel, fx.priv, fx.sqid, "blog", true, "paul@keymail.dev")` before the drain. The box keeps serving a production app's routes despite the marker (`productionClear`). (Confirm the fixture's `fx.srv.cfg.ReleasePub` is `fx.priv`'s public key; if it is nil, set it in the subtest.) |
| + - `"unreadable marker"`: overwrite `release.AppTombstoneKey(fx.sqid, "blog")` with `{"schema":2}` (`ReadAppTombstone` refuses an unknown schema). |
| + - `"unreadable flag"`: a production object that does not verify (write any non-JSON bytes at `release.ProductionKey(fx.sqid, "blog")`). |
| + - `"labelled and unmovable"`: blog's record is `r.FleetBox, r.Addr = "pi-1", "127.0.0.1:9000"`. Only unlabelled records are excused. |
| +- [ ] **Step 3: Write the cost pin** `TestDrainReadsTrashStateOnlyForUnlabelledApps`: shop has a labelled record on `pi-1` and an unlabelled record; blog (placed) has only a labelled record on `pi-1`. Install `newCountStore`, drain, and assert `cs.getsOf(release.AppTombstoneKey(fx.sqid, "blog")) == 0` and `cs.getsOf(release.AppTombstoneKey(fx.sqid, "shop")) == 1` (one read per app per drain, however many unlabelled records it has; give shop two unlabelled records to prove the memo). |
| +- [ ] **Step 4: Run and confirm the witness fails** (blog stranded after the trash): |
| + `go test ./internal/console/ -run 'TestDrainSkipsATrashedAppsUnlabelledRecord|TestDrainStillRefusesATrashedAppTheBoxesServe|TestDrainReadsTrashStateOnlyForUnlabelledApps' -count=1`. Expected: the first and third FAIL, the refusal subtests PASS. |
| +- [ ] **Step 5: Implement** `trashRetired` and the loop change. |
| +- [ ] **Step 6: Run the new tests and the existing drain, trash and restore tests:** |
| + `go test ./internal/console/ -run 'TestDrain|TestAPITrash|TestAPIRestore|TestRestore|TestLostBoxAndDrain|TestStatelessMove|TestLabelDoor' -count=1`. Expected: PASS. `TestDrainRefusesAnUnmanagedRecord/unlabelled` must still pass (blog is live there). |
| +- [ ] **Step 7:** `gofmt -l internal/console`, `go vet ./internal/console/`, `make census-card` (expect no changed unit). |
| +- [ ] **Step 8: Commit.** `console: a trashed app's unlabelled record no longer holds a drain` (body: #1008 T9 finding 1, the rule, why restore keeps working). |
| + |
| +**Review focus for Astra:** the trash judgement matches the box's `removable` exactly (marker and flag both positively read); no write to an excused record; labelled records of trashed apps are not excused; the restore race is benign. |
| + |
| +--- |
| + |
| +### Task 2: Records on a detached box move to the sole survivor |
| + |
| +**Files:** |
| +- Modify: `internal/console/fleetrelabel.go`: `fleetRelabelPass` (`:104-132`, the `loadFleetViewAt` call at `:115`), `relabelFleet` (`:147-188`, the gate at `:153`), the header comment (`:20-56`); add `relabelView`, `goneLabelledBox`, `relabelAfterDetach`, `fleetDetachRelabelTimeout`. |
| +- Modify: `internal/console/fleets.go`: `handleAPIFleetDetachBox` (after the audit at `:635`) and `handleFleetDetachBoxPage` (after the audit at `:1724`). |
| +- Modify: `internal/console/fleetbox.go`: the `fleetView` doc comment (`:37-48`) gains one sentence on `Complete` for one-box views read whole by the relabel worker. No code change there. |
| +- Modify: `internal/console/fleetbox_test.go`: add `func (c *countStore) listsOf(prefixes ...string) int` beside `getsOf`. |
| +- Test: `internal/console/fleetrelabel_test.go` |
| + |
| +**Interfaces (unexported):** |
| + |
| +```go |
| +// goneLabelledBox reports whether a relabel pass must read a one-box fleet |
| +// whole: exactly one of boxes is active, and some box that is not active |
| +// (detached) was named on a record (LabelledAt != 0), so records may still |
| +// name it (#1008 T9 finding 2). Lost and draining boxes stay active, so a |
| +// fleet that still has two active boxes is read whole anyway. |
| +func goneLabelledBox(boxes []registry.FleetBox) bool |
| + |
| +// relabelView is the view a relabel pass acts on, as of now: |
| +// loadFleetViewRequiredAt, read whole also when goneLabelledBox holds. |
| +func (s *Server) relabelView(ctx context.Context, fleet string, now time.Time) (fleetView, error) |
| + |
| +// fleetDetachRelabelTimeout bounds the relabel a detach door runs. |
| +const fleetDetachRelabelTimeout = 20 * time.Second |
| + |
| +// relabelAfterDetach runs fleet's relabel at once after a detach door |
| +// detached a box, under the fleet lock the door holds, so the detached |
| +// box's records move to a survivor now rather than at the next worker |
| +// pass. Best effort: an error is logged and the worker repeats it within |
| +// fleetRelabelInterval. Off on a host-claim console, as the worker is. |
| +func (s *Server) relabelAfterDetach(ctx context.Context, fleet string) |
| +``` |
| + |
| +**Behaviour:** |
| + |
| +- `goneLabelledBox`: count `Status == "active"`; set `gone` for any other status with `LabelledAt != 0`; answer `active == 1 && gone`. |
| +- `relabelView`: open the pass registry, `ListFleetBoxes(fleet)`, then `s.loadFleetViewRequiredAt(ctx, fleet, now, goneLabelledBox(boxes))`. A registry error is the view error, as today. |
| +- `fleetRelabelPass`: `v, err := s.relabelView(ctx, f.Name, now)` in place of `loadFleetViewAt`. `reconcileReplicaFleet` keeps receiving the same `v`; it returns early on `len(v.ReplicaApps) == 0`, so a newly whole one-box view changes nothing for it. |
| +- `relabelFleet`: after the pause check, `if !v.Complete { return 0, nil }` replacing `!v.Active`, with the comment: "Moving off a gone box needs the whole view and nothing more: on two or more active boxes Complete is Active, and a one-box view is whole only when relabelView or replica placement asked for it. chooseMoveDestination still refuses a stale, draining or below-floor survivor." |
| +- `relabelAfterDetach`: return at once on `s.cfg.HostClaim`, `s.cfg.Releases == nil` or `s.cfg.Registry == ""`. Otherwise `ctx, cancel := context.WithTimeout(ctx, fleetDetachRelabelTimeout)`, `now := time.Now()`, `v, err := s.relabelView(ctx, fleet, now)`; on error log `console: fleet detach %s: relabel: view: %v; the relabel worker moves its records` and return; else `moved, _ := s.relabelFleet(ctx, fleet, v, now)` and, when `moved > 0`, log `console: fleet detach %s: moved %d records off the detached box`. |
| +- Both detach doors: call `s.relabelAfterDetach(r.Context(), fleet.Name)` after the audit line and before writing the answer. The lock is already held (`defer unlock()`). The answer body and status are unchanged. The managed-fleet refusal (`msgManagedBYO`) comes earlier, so managed fleets are unaffected; their boxes are covered by the worker. |
| + |
| +- [ ] **Step 1: Write the failing witness** (the drill's teardown, deterministic): |
| + |
| + ```go |
| + // #1008 T9 finding 2: a two-box fleet loses a box. After detach-box |
| + // --terminated the records labelled to it stayed tied to it and answered |
| + // 503: the worker skipped fleets with fewer than two active boxes. The |
| + // worker now reads a one-box fleet whole when a detached box was ever |
| + // labelled, and moves those records to the survivor, restore-required |
| + // (R2). A record already on the survivor is not written. |
| + func TestDetachedBoxRecordsMoveToTheSoleSurvivor(t *testing.T) { |
| + ctx := context.Background() |
| + fx, _, reg := fleetBoxWorld(t, "code-rl-sole", "pi-1", "pi-2") |
| + for _, h := range []string{"a.example.com", "b.example.com", "c.example.com"} { |
| + putFleetRecord(t, fx, "shop", h, nil) |
| + } |
| + labelOn(t, fx, reg, "a.example.com", "pi-1") |
| + labelOn(t, fx, reg, "b.example.com", "pi-2") |
| + labelOn(t, fx, reg, "c.example.com", "pi-2") |
| + if err := reg.SetFleetBoxStatus("pi", "pi-2", "detached"); err != nil { // the machine is gone |
| + t.Fatal(err) |
| + } |
| + now := time.Now() |
| + // The old gate: one active box is never Active. |
| + if v, err := fx.srv.loadFleetViewAt(ctx, "pi", now); err != nil || v.Active || v.Complete { |
| + t.Fatalf("plain view %+v, %v; want neither Active nor Complete", v, err) |
| + } |
| + cs := newCountStore(fx.rel) |
| + fx.srv.cfg.Releases = cs |
| + if err := fx.srv.fleetRelabelPass(ctx, now); err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, h := range []string{"b.example.com", "c.example.com"} { |
| + r := shopRec(t, fx, h) |
| + wantLabel(t, r, "pi-1") |
| + if !r.FleetBoxMoved { |
| + t.Fatalf("%s moved without FleetBoxMoved: it could start empty (R2)", h) |
| + } |
| + } |
| + if r := shopRec(t, fx, "a.example.com"); r.FleetBox != "pi-1" || r.FleetBoxMoved { |
| + t.Fatalf("a was already on the survivor and was rewritten: %+v", r) |
| + } |
| + if n := cs.recordPuts(); n != 2 { |
| + t.Fatalf("the pass wrote %d records; want 2", n) |
| + } |
| + // A second pass finds nothing to move. |
| + cs.reset() |
| + if err := fx.srv.fleetRelabelPass(ctx, now.Add(time.Minute)); err != nil { |
| + t.Fatal(err) |
| + } |
| + if n := cs.recordPuts(); n != 0 { |
| + t.Fatalf("a second pass wrote %d records", n) |
| + } |
| + } |
| + ``` |
| + |
| +- [ ] **Step 2: Write the edges**: |
| + - `TestDetachDoorMovesTheDetachedBoxesRecords`: as above but detach through the door, `detachAPI(t, fx, token, "pi-2", true)` must answer 200, and **with no worker pass** `b` and `c` are on `pi-1` with `FleetBoxMoved`. Same through `detachPage(t, fx, "pi-2", true)` as a subtest (`"page"`). |
| + - `TestSoleSurvivorMustBeAValidDestination`, subtests, each asserting `b` stays on `pi-2` and `recordPuts() == 0`: |
| + - `"stale"`: `piBeat(t, fx, "pi-1", true, now.Add(-21*time.Minute), release.FleetRecordLabelFloor)` before the pass; |
| + - `"draining"`: `if _, err := reg.SetFleetBoxDraining("pi", "pi-1", now.UnixNano()); err != nil { t.Fatal(err) }`; |
| + - `"rootfs not ready"`: `b` is `Runtime: provision.RuntimeRootfsV1` and `piBeat(..., "pi-1", false, now, ...)`; |
| + - `"below the label floor"`: survivor beats `v0.32.0`; the fleet is labelled, so the pass logs the pause and moves nothing (`labelsPausedBy`). |
| + - `TestDetachedStatelessRecordNeedsTheRuntimeFloor`: `statelessShopWorldOn(t, ..., map[string]string{"pi-1": release.StatelessRuntimeFloor, "pi-2": X})` puts the always-on stateless record on `pi-1`; mark `pi-1` labelled (`reg.MarkFleetBoxLabelled`) and detach it. Subtest `X = release.FleetBoxLabelFloor`: stays on `pi-1` (R3). Subtest `X = release.StatelessRuntimeFloor`: moves to `pi-2` with `FleetBoxMoved`. |
| + - `TestOneBoxFleetReadsNoInventoryWithoutAGoneLabelledBox`: `fleetBoxWorld(t, ..., "pi-1")` with a labelled record on `pi-1`; subtests `"never had a second box"` and `"detached box never labelled"` (`registerFleetBox(t, reg, "pi", "pi-2")` then detach it with `LabelledAt == 0`). Install `newCountStore`, run a pass, assert `cs.listsOf(provision.RecordsPrefix(fx.sqid, "shop")) == 0` and `recordPuts() == 0`. This pins the request budget. |
| + - `TestGoneLabelledBox`: table test over `[]registry.FleetBox`: one active plus one detached labelled is true; one active plus one detached unlabelled is false; two active plus one detached labelled is false (the ordinary view is already whole); zero active is false. |
| +- [ ] **Step 3: Run and confirm the failures:** |
| + `go test ./internal/console/ -run 'TestDetachedBoxRecordsMoveToTheSoleSurvivor|TestDetachDoorMovesTheDetachedBoxesRecords|TestSoleSurvivorMustBeAValidDestination|TestDetachedStatelessRecordNeedsTheRuntimeFloor|TestOneBoxFleetReadsNoInventoryWithoutAGoneLabelledBox|TestGoneLabelledBox' -count=1`. Expected: the first two and the moving stateless subtest FAIL (records stay on the detached box); `TestGoneLabelledBox` fails to compile until the helper exists (write the helper's signature with `return false` first so the rest compiles); the refusals PASS. |
| +- [ ] **Step 4: Implement** `goneLabelledBox`, `relabelView`, the pass and gate changes, `relabelAfterDetach` and the two door calls. |
| +- [ ] **Step 5: Run the new tests and the existing relabel, drain, detach and replica tests:** |
| + `go test ./internal/console/ -run 'TestDetached|TestDetachDoor|TestSoleSurvivor|TestOneBoxFleet|TestGoneLabelledBox|TestFirstLabellingIsOff|TestRelabel|TestLostBox|TestStatelessMove|TestDrain|TestBothDetachDoors|TestDetachRefusal|TestSilentBox|TestDetachSees|TestFleetDetachBox|TestLabelDoorDetachedBox|TestReplica|TestCopies|TestCreateSkipsStaleDrainingAndDetachedBoxes' -count=1`. Expected: PASS. If `TestDetachSeesARelabelThatLandsBeforeTheLock` or a replica test counts record writes across a detach, read why before changing it: the door now moves records, which is the intended change, and the test's assertion should be updated only if it pinned the old "nothing moves at detach" behaviour. |
| +- [ ] **Step 6:** `gofmt -l internal/console`, `go vet ./internal/console/`, `make census-card` (expect no changed unit). |
| +- [ ] **Step 7: Commit.** `console: move a detached box's records to the sole survivor` (body: #1008 T9 finding 2, the view rule, the detach-time relabel, R2/R3 unchanged). |
| + |
| +**Review focus for Astra:** `Complete` as the gate cannot admit a partial view; the one-box view is read only under `goneLabelledBox`; R2 (`FleetBoxMoved`) on every move; R3 on the survivor; the detach-time relabel runs under the lock the door holds and never changes the door's answer; host-claim consoles stay off. |
| + |
| +--- |
| + |
| +### Task 3: A restarted unindexed box reconciles on its first fast tick (P3) |
| + |
| +Findings: `.superpowers/sdd/2026-11-15-fleet-drain-followups/p3-findings.md` (read it; it carries the evidence and line numbers). |
| + |
| +**Cause.** After a restart a box with no record view (every fleet box; any box with the change index off) runs no reconcile until `instancesLoop`'s first pass, one minute after start (`internal/host/agent.go:4589`). The fast loop seeds the serial on its first read and does not run a pass for it (`agent.go:3380-3389`). Armed boxes get a boot full pass from `recordViewBackstop` setting `backstopFullDue` (`internal/host/changeindex.go:158-159`); unindexed boxes never do. |
| + |
| +**Files:** |
| +- Modify: `internal/host/agent.go` (or `changeindex.go`, beside the backstop): add `requestBootFullPass(v *provision.RecordView, due *atomic.Bool)` which stores true when `v == nil`; call it in `RunAgent` right after `v := armChangeIndex(...)` (`agent.go:~1076`), before `runHAIngressStartup` starts, with `&backstopFullDue`. Use the real types of `armChangeIndex`'s result and `backstopFullDue`; if they differ from the sketch, keep the behaviour. |
| +- Test: `internal/host` test file beside `TestFastTickActsOnSerialChangeNotBoot` (`agent_test.go:~1226`). |
| + |
| +**Behaviour.** `fastTick` takes the request on its first tick and `runFull` clears it (`agent.go:3460`, `:3587`). The serial seed rule is unchanged: this is a convergence pass, not a replay of the serial's restart/wake/schedule legs. Armed boxes are unchanged (the backstop owns the request). |
| + |
| +**Test `TestUnindexedBootRunsOneFullPass`** (deterministic, modelled on `TestDepartureInventoryNudgeWithoutIndex` in `hadepartures_inventory_test.go:~440`): |
| +1. `env := newFastFixture(t)`; bump the serial once (the label written while the agent was down). |
| +2. `var due atomic.Bool`; `passes := 0`; `d := env.deps(func(){ passes++ })`; `d.fullDue = &due` (use the fixture's actual field names). |
| +3. `requestBootFullPass(nil, &due)`; `fastTick(ctx, d, now)`: assert `passes == 1` and `!due.Load()`. |
| +4. `fastTick(ctx, d, now.Add(10*time.Second))`: assert `passes == 1`. |
| +5. Control: `requestBootFullPass(<non-nil view>, &due2)`: assert `!due2.Load()`. |
| +RED first: before the helper exists the test fails to compile; to show behavioural RED, temporarily assert step 3 without calling the helper and record that it fails with `passes == 0`. |
| + |
| +**Run:** `go test ./internal/host -run 'TestUnindexedBootRunsOneFullPass|TestFastTick|TestDepartureInventoryNudgeWithoutIndex|TestRecordViewBackstop' -count=1`. |
| + |
| +**Out of scope:** skipping `runHAIngressStartup` on fleet boxes (it times out in 5 s on a fleet box and logs "context deadline exceeded"); that needs the region HA owner's view and is filed on #1008. |
| + |
| +**Census:** this changes the root binary (`internal/host`): the controller runs `make census-card` / `census-propose` after the task. |
| + |
| +## Copy |
| + |
| +None. No CLI, console or email string is added or changed. `C07` ("%s is already tied to %s. nothing to do"), `C20`, `msgDrainStrandsApps` and `msgDrainBoxNotActive` stay as approved. New lines are console operator logs, in the style of the existing `console: fleet relabel` / `console: fleet drain` lines. |
| + |
| +## Census |
| + |
| +Tasks 1-2: none (`internal/console`, outside the root binary's scope; confirm with `make census-card`). Task 3 changes `internal/host`: census card needed (controller). |
| + |
| +## Deferred |
| + |
| +1. **P3** is now Task 3 (controller ruling 2026-11-15 after a read-only log investigation, p3-findings.md). Still deferred: skipping the startup HA ingress pass on fleet boxes (noise and wasted door GETs; needs the region HA owner), filed on #1008. |
| +2. **Label door answer for a record tied to a gone box** (P3 follow-up). When the detach-time relabel cannot move a record (no valid survivor, unmovable record, unverifiable manifest), `instances label` still says "already tied to box-2. nothing to do" for an instance that answers 503. A better answer names the gone box and the reason it has not moved. That is new copy for Paul's review, so it is not in this branch. |
| +3. **Replica assignments naming a detached box.** `relabelFleet` skips records with a `ReplicaAssignment`. Replica placement and `replicaDetachWarnings` own them; not re-checked here. |
| +4. **Drill note 4** (box-2's startup pass rewrote a binding with no lease). Spec §2 already treats bindings as evidence, not proof. No action. |
| +5. **Runbook.** `docs/fleet-runbook.md` could gain "Losing a box" (detach `--terminated` now moves the box's records to the survivors, restore-required) and "Trashed apps and drains". That is docs prose for Paul's copy review; propose it with the next copy batch. |
| + |
| +## Open questions |
| + |
| +None that need Paul. The rulings above (D-A option 1, D-B detach-time relabel, D-C defer) are the planner's. |
diff --git a/internal/console/fleetbox.go b/internal/console/fleetbox.go| index a3cf2ef96..a3e5b1d64 100644 |
| --- a/internal/console/fleetbox.go |
| +++ b/internal/console/fleetbox.go |
| @@ -45,7 +45,10 @@ import ( |
| // records count toward neither (fleetLabelsRecord). Records is the |
| // inventory the view was built from (every record placed on the fleet, |
| // static ones included), read only when the fleet has two or more active |
| -// boxes; the relabel worker and the drain act on it. |
| +// boxes; the relabel worker and the drain act on it. Complete: every read |
| +// above was whole; on a one-box view it is set only when the caller asked |
| +// for the whole view, as the relabel worker does for a fleet whose other |
| +// box was detached after being named on a record (relabelView). |
| type fleetView struct { |
| Boxes []fleetBoxView |
| Active, HasSidecars, DeploymentCurrent bool |
diff --git a/internal/console/fleetbox_test.go b/internal/console/fleetbox_test.go| index 8e37993db..70352aa3b 100644 |
| --- a/internal/console/fleetbox_test.go |
| +++ b/internal/console/fleetbox_test.go |
| @@ -418,10 +418,15 @@ func (c *countStore) getsOf(keys ...string) int { |
| return n |
| } |
| -func (c *countStore) listsOf(prefix string) int { |
| +// listsOf is how many listings of prefixes were made. |
| +func (c *countStore) listsOf(prefixes ...string) int { |
| c.mu.Lock() |
| defer c.mu.Unlock() |
| - return c.lists[prefix] |
| + n := 0 |
| + for _, p := range prefixes { |
| + n += c.lists[p] |
| + } |
| + return n |
| } |
| func TestInventoryRereadsOnlyChangedRecords(t *testing.T) { |
diff --git a/internal/console/fleetrelabel.go b/internal/console/fleetrelabel.go| index 626ab67b3..9abb17189 100644 |
| --- a/internal/console/fleetrelabel.go |
| +++ b/internal/console/fleetrelabel.go |
| @@ -20,7 +20,9 @@ import ( |
| // Managed fleets 1b, Task 6 (spec "1b addendum", rules 2, 4, 5, 8, 11). |
| // |
| // The relabel worker, FleetRelabel, runs one pass every five minutes. Per |
| -// fleet, under the fleet's lock and from one loadFleetView: |
| +// fleet, under the fleet's lock and from one relabelView (loadFleetView, |
| +// read whole also for a fleet left with one active box after a box named |
| +// on a record was detached, #1008 T9 finding 2): |
| // |
| // - When the fleet has labels and one of its boxes reports a release |
| // below release.FleetBoxLabelFloor, the pass logs an ERROR naming the |
| @@ -49,11 +51,16 @@ import ( |
| // |
| // The drain (`carlos fleets drain`, drainBox) moves every record the box |
| // runs or refuses up front, naming the apps, and marks the box draining in |
| -// the registry (draining_since). A draining box stays active, so it keeps |
| -// its fleet access and can see its records leave. The worker finishes any |
| -// move the drain could not make at once. The detach doors refuse a box the |
| -// console ever named on a record unless the request confirms its machine |
| -// is terminated (rule 5, detachHeld). |
| +// the registry (draining_since). An unlabelled record of an app in the |
| +// Trash whose routes the boxes have retired (trashRetired) does not hold |
| +// the drain, when another box could carry it, and is left as it is. A |
| +// draining box stays active, so it keeps its fleet access and can see its |
| +// records leave. The worker finishes any move the drain could not make at |
| +// once. The detach doors refuse a box the console ever named on a record |
| +// unless the request confirms its machine is terminated (rule 5, |
| +// detachHeld). A detach door then runs the fleet's relabel at once under |
| +// the lock it holds (relabelAfterDetach), so the detached box's records |
| +// move to a survivor without waiting for the worker. |
| // fleetRelabelInterval is the worker's period. |
| const fleetRelabelInterval = 5 * time.Minute |
| @@ -112,7 +119,7 @@ func (s *Server) fleetRelabelPass(ctx context.Context, now time.Time) error { |
| ctx = withWriteMemo(ctx) |
| for _, f := range fleets { |
| unlock := s.lockFleet(f.Name) |
| - v, err := s.loadFleetViewAt(ctx, f.Name, now) |
| + v, err := s.relabelView(ctx, f.Name, now) |
| if err != nil { |
| log.Printf("console: fleet relabel %s: view: %v", f.Name, err) |
| jobFailed(ctx, err) |
| @@ -132,6 +139,63 @@ func (s *Server) fleetRelabelPass(ctx context.Context, now time.Time) error { |
| return nil |
| } |
| +// goneLabelledBox reports whether a relabel pass must read a one-box fleet |
| +// whole: exactly one of boxes is active, and some box that is not active |
| +// (detached) was named on a record (LabelledAt != 0), so records may still |
| +// name it (#1008 T9 finding 2). Lost and draining boxes stay active, so a |
| +// fleet that still has two active boxes is read whole anyway. |
| +func goneLabelledBox(boxes []registry.FleetBox) bool { |
| + active, gone := 0, false |
| + for _, b := range boxes { |
| + if b.Status == "active" { |
| + active++ |
| + } else if b.LabelledAt != 0 { |
| + gone = true |
| + } |
| + } |
| + return active == 1 && gone |
| +} |
| + |
| +// relabelView is the view a relabel pass acts on, as of now: |
| +// loadFleetViewRequiredAt, read whole also when goneLabelledBox holds. |
| +func (s *Server) relabelView(ctx context.Context, fleet string, now time.Time) (fleetView, error) { |
| + reg, err := s.openPassRegistry() |
| + if err != nil { |
| + return fleetView{Load: map[string]int{}}, err |
| + } |
| + boxes, err := reg.ListFleetBoxes(fleet) |
| + if err != nil { |
| + return fleetView{Load: map[string]int{}}, err |
| + } |
| + return s.loadFleetViewRequiredAt(ctx, fleet, now, goneLabelledBox(boxes)) |
| +} |
| + |
| +// fleetDetachRelabelTimeout bounds the relabel a detach door runs. |
| +const fleetDetachRelabelTimeout = 20 * time.Second |
| + |
| +// relabelAfterDetach runs fleet's relabel at once after a detach door |
| +// detached a box, under the fleet lock the door holds, so the detached |
| +// box's records move to a survivor now rather than at the next worker |
| +// pass. Best effort: an error is logged and the worker repeats it within |
| +// fleetRelabelInterval. Off on a host-claim console, as the worker is. |
| +func (s *Server) relabelAfterDetach(ctx context.Context, fleet string) { |
| + if s.cfg.HostClaim || s.cfg.Releases == nil || s.cfg.Registry == "" { |
| + return |
| + } |
| + ctx, cancel := context.WithTimeout(ctx, fleetDetachRelabelTimeout) |
| + defer cancel() |
| + now := time.Now() |
| + v, err := s.relabelView(ctx, fleet, now) |
| + if err != nil { |
| + log.Printf("console: fleet detach %s: relabel: view: %v; the relabel worker moves its records", fleet, err) |
| + return |
| + } |
| + moved, _ := s.relabelFleet(ctx, fleet, v, now) |
| + if moved > 0 { |
| + log.Printf("console: fleet detach %s: moved %d records off the detached box", fleet, moved) |
| + } |
| +} |
| + |
| // relabel is one planned label write: rec to box to, and why. |
| type relabel struct { |
| rec provision.Record |
| @@ -150,7 +214,12 @@ func (s *Server) relabelFleet(ctx context.Context, fleet string, v fleetView, no |
| fleet, box, releaseOrUnknown(rel), release.FleetBoxLabelFloor) |
| return 0, nil |
| } |
| - if !v.Active { |
| + // Moving off a gone box needs the whole view and nothing more: on two |
| + // or more active boxes Complete is Active, and a one-box view is whole |
| + // only when relabelView or replica placement asked for it. |
| + // chooseMoveDestination still refuses a stale, draining or below-floor |
| + // survivor. |
| + if !v.Complete { |
| return 0, nil |
| } |
| // No first labelling here (D2): only records that already carry a |
| @@ -187,7 +256,8 @@ func (s *Server) relabelFleet(ctx context.Context, fleet string, v fleetView, no |
| } |
| // writeRelabels makes plan's writes, each marking its box labelled first, |
| -// and answers how many records were written. |
| +// announces them with one serial bump when any landed, and answers how |
| +// many records were written. |
| func (s *Server) writeRelabels(ctx context.Context, fleet string, plan []relabel, now time.Time) int { |
| if len(plan) == 0 { |
| return 0 |
| @@ -225,6 +295,14 @@ func (s *Server) writeRelabels(ctx context.Context, fleet string, plan []relabel |
| log.Printf("console: fleet relabel %s: %s from %s to %s (%s)", fleet, p.rec.Host, boxOrNone(p.rec.FleetBox), p.to, p.reason) |
| } |
| } |
| + if moved > 0 { |
| + // A box-consumed write, announced once for the pass as the label |
| + // door announces its own: a running box drops or takes the routes |
| + // now rather than at its next instance pass. bumpSerial is |
| + // detached from ctx, so moves that landed before a caller's |
| + // timeout (a detach door's) are still announced. |
| + s.bumpSerial(ctx) |
| + } |
| return moved |
| } |
| @@ -374,7 +452,15 @@ func (e *fleetPausedError) Error() string { return msgLabelsPaused(e.fleet, e.bo |
| // fleet's lock, it moves every record the box runs to another box, or |
| // refuses, answering the apps whose records cannot move, sorted, with |
| // nothing written. A record cannot move when it is unlabelled (every box |
| -// runs it), when the platform cannot move it (movable), or when no other |
| +// runs it), unless its app is in the Trash and the boxes have retired its |
| +// routes (trashRetired) and another box of the fleet could carry it |
| +// (chooseMoveDestination, excluding this one, with the stateless answer of |
| +// movableVerified, whose error strands the drain): such a record is not |
| +// served, every remaining box still carries it, and a restore mints it |
| +// again from the record, so it does not hold the drain and is left |
| +// unlabelled. On the fleet's last box it still holds the drain: a restore |
| +// racing the drain would leave the instance with no box. A record also |
| +// cannot move when the platform cannot move it (movable), or when no other |
| // box can take it. Otherwise the box is marked draining (it keeps its |
| // fleet access and gets no new assignment) and each record is relabelled |
| // to chooseDestination's choice. A record that changed since it was read, |
| @@ -446,6 +532,11 @@ func (s *Server) drainBox(ctx context.Context, fleet, label string) (stuck []str |
| return nil, errFleetDrainIncomplete |
| } |
| strand := map[string]bool{} |
| + // retired memoises trashRetired per app: one marker read and at most |
| + // one flag read per app per drain, only for apps with an unlabelled |
| + // record here. |
| + retired := map[AppRef]bool{} |
| + excused := map[AppRef]bool{} // apps whose excuse was logged |
| var plan []relabel |
| for _, rec := range recs { |
| if rec.ReplicaAssignment != nil { |
| @@ -455,7 +546,56 @@ func (s *Server) drainBox(ctx context.Context, fleet, label string) (stuck []str |
| continue |
| } |
| if rec.FleetBox == "" { |
| - strand[rec.App] = true |
| + // The excuse needs a box that stays: some other active box of |
| + // the fleet that could carry the record (chooseMoveDestination, |
| + // excluding this one). On the fleet's last box a restore racing |
| + // the drain would leave the instance with no box at all, so |
| + // there the record strands the drain as before. This first |
| + // test reads nothing; the stateless one below needs the |
| + // manifest and is asked only of a trashed app's record. |
| + rootfs := rec.Runtime == provision.RuntimeRootfsV1 |
| + if v.chooseMoveDestination(rootfs, false, label) == "" { |
| + strand[rec.App] = true |
| + continue |
| + } |
| + ref := AppRef{Sqid: rec.Account, App: rec.App} |
| + gone, seen := retired[ref] |
| + if !seen { |
| + var err error |
| + gone, err = s.trashRetired(ctx, rec.Account, rec.App) |
| + if err != nil { |
| + log.Printf("console: fleet drain %s/%s: %s/%s: trash state unreadable: %v; treated as served", fleet, label, rec.Account, rec.App, err) |
| + gone = false |
| + } |
| + retired[ref] = gone |
| + } |
| + if !gone { |
| + strand[rec.App] = true |
| + continue |
| + } |
| + // The survivor must also be able to run what a restore would |
| + // bring back, the same test the labelled path asks below. The |
| + // record must be movable (movableVerified's ok): one that never |
| + // is (a system unit, which belongs to this machine; an |
| + // unmanaged address) would come back unlabelled to a survivor |
| + // that lacks it, and no pass labels it. An always-on stateless |
| + // one needs a box at the stateless runtime floor. A manifest |
| + // that cannot be verified strands the drain. |
| + ok, stateless, err := s.movableVerified(ctx, rec) |
| + if err != nil { |
| + log.Printf("console: fleet drain %s/%s: %s: its manifest cannot be verified: %v; left", fleet, label, rec.Host, err) |
| + jobFailed(ctx, err) |
| + strand[rec.App] = true |
| + continue |
| + } |
| + if !ok || v.chooseMoveDestination(rootfs, stateless, label) == "" { |
| + strand[rec.App] = true |
| + continue |
| + } |
| + if !excused[ref] { |
| + excused[ref] = true |
| + log.Printf("console: fleet drain %s/%s: %s/%s is in the trash and its routes are retired; its unlabelled records stay as they are and do not hold the drain", fleet, label, rec.Account, rec.App) |
| + } |
| continue |
| } |
| ok, stateless, err := s.movableVerified(ctx, rec) |
| @@ -509,6 +649,28 @@ func (s *Server) drainBox(ctx context.Context, fleet, label string) (stuck []str |
| return nil, nil |
| } |
| +// 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". |
| +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 |
| +} |
| + |
| // The values of `carlos fleets ls`'s labels_paused: absent when the fleet |
| // is not paused, fleetLabelsPaused when a box of a fleet with labels |
| // reports a release below the floor, fleetLabelsUnknown when some box's |
diff --git a/internal/console/fleetrelabel_test.go b/internal/console/fleetrelabel_test.go| index 84267bd9d..a63a67e46 100644 |
| --- a/internal/console/fleetrelabel_test.go |
| +++ b/internal/console/fleetrelabel_test.go |
| @@ -506,6 +506,294 @@ func TestDrainRefusesAnUnmanagedRecord(t *testing.T) { |
| } |
| } |
| +// blogRecBytes is the raw object of blog's record of h. |
| +func blogRecBytes(t *testing.T, fx *consoleFixture, h string) []byte { |
| + t.Helper() |
| + b, _, err := fx.rel.Get(context.Background(), provision.RecordKey(fx.sqid, "blog", h)) |
| + if err != nil { |
| + t.Fatalf("read blog's record of %s: %v", h, err) |
| + } |
| + return b |
| +} |
| + |
| +// #1008 T9 finding 1: an app in the Trash blocked every drain of its |
| +// fleet until it purged. An unlabelled record of an app whose marker is |
| +// read and whose production flag is clear is not served by any box, is |
| +// still carried by every other box, and comes back on restore, so it no |
| +// longer holds the drain. Its record is not written. |
| +func TestDrainSkipsATrashedAppsUnlabelledRecord(t *testing.T) { |
| + ctx := context.Background() |
| + fx, _, reg := fleetBoxWorld(t, "code-rl-drain-trash", "pi-1", "pi-2") |
| + placeBlog(t, fx) |
| + putFleetRecord(t, fx, "shop", "a.example.com", func(r *provision.Record) { r.FleetBox = "pi-1" }) |
| + putFleetRecord(t, fx, "blog", "x.example.com", nil) // unlabelled: every box carries it |
| + before := blogRecBytes(t, fx, "x.example.com") // raw object bytes, for "not written" |
| + |
| + // Baseline: live, it strands the drain (as TestDrainRefusesAnUnmanagedRecord/unlabelled). |
| + if stuck, err := fx.srv.drainBox(ctx, "pi", "pi-1"); err != nil || !slices.Equal(stuck, []string{"blog"}) { |
| + t.Fatalf("live: drainBox = %v, %v; want blog stranded", stuck, err) |
| + } |
| + if err := release.TrashApp(ctx, fx.rel, fx.sqid, "blog", "paul@keymail.dev", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + stuck, err := fx.srv.drainBox(ctx, "pi", "pi-1") |
| + if err != nil || len(stuck) != 0 { |
| + t.Fatalf("trashed: drainBox = %v, %v; want nothing stranded", stuck, err) |
| + } |
| + if r := shopRec(t, fx, "a.example.com"); r.FleetBox != "pi-2" || !r.FleetBoxMoved { |
| + t.Fatalf("shop's record after the drain: %+v; want moved to pi-2", r) |
| + } |
| + if b := boxRow(t, reg, "pi-1"); b.DrainingSince == 0 { |
| + t.Fatal("the drain did not mark pi-1 draining") |
| + } |
| + if got := blogRecBytes(t, fx, "x.example.com"); !bytes.Equal(got, before) { |
| + t.Fatalf("the trashed app's record was written:\n%s\nwant\n%s", got, before) |
| + } |
| + // Restore keeps working: the marker goes and the record is there, |
| + // unlabelled, on the fleet, for the remaining boxes to mint. |
| + if err := release.RestoreApp(ctx, fx.rel, fx.sqid, "blog"); err != nil { |
| + t.Fatal(err) |
| + } |
| + r, err := provision.GetRecord(ctx, fx.rel, fx.sqid, "blog", "x.example.com") |
| + if err != nil || r.Retired || r.Region != "fleet/pi" { |
| + t.Fatalf("after restore: %+v, %v; want the record kept on fleet/pi", r, err) |
| + } |
| + wantNoLabel(t, r) |
| +} |
| + |
| +// Fix round 1 (review P1): the excuse needs a box that stays. On a |
| +// one-box fleet a trashed app's unlabelled record still strands the drain, |
| +// since a restore racing the drain would leave the instance on no box. The |
| +// trash state is not even read there. |
| +func TestDrainOfTheLastBoxStillRefusesATrashedApp(t *testing.T) { |
| + ctx := context.Background() |
| + fx, _, reg := fleetBoxWorld(t, "code-rl-trash-last", "pi-1") |
| + placeBlog(t, fx) |
| + putFleetRecord(t, fx, "blog", "x.example.com", nil) |
| + if err := release.TrashApp(ctx, fx.rel, fx.sqid, "blog", "paul@keymail.dev", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + cs := newCountStore(fx.rel) |
| + fx.srv.cfg.Releases = cs |
| + stuck, err := fx.srv.drainBox(ctx, "pi", "pi-1") |
| + if err != nil || !slices.Equal(stuck, []string{"blog"}) { |
| + t.Fatalf("drainBox = %v, %v; want blog stranded", stuck, err) |
| + } |
| + if n := cs.recordPuts(); n != 0 { |
| + t.Fatalf("a refused drain wrote %d records", n) |
| + } |
| + if n := cs.getsOf(release.AppTombstoneKey(fx.sqid, "blog")); n != 0 { |
| + t.Fatalf("the trash marker was read %d times with no box to stay", n) |
| + } |
| + if b := boxRow(t, reg, "pi-1"); b.DrainingSince != 0 { |
| + t.Fatal("a refused drain marked the box draining") |
| + } |
| +} |
| + |
| +// restoreOnGet restores app blog (deletes its trash marker) once, just |
| +// after the first read of key: a restore landing between the drain's trash |
| +// read and the drain's end. |
| +type restoreOnGet struct { |
| + release.Store |
| + key string |
| + fx *consoleFixture |
| + done bool |
| +} |
| + |
| +func (r *restoreOnGet) Get(ctx context.Context, key string) ([]byte, string, error) { |
| + body, etag, err := r.Store.Get(ctx, key) |
| + if key == r.key && !r.done { |
| + r.done = true |
| + if rerr := release.RestoreApp(ctx, r.fx.rel, r.fx.sqid, "blog"); rerr != nil { |
| + return nil, "", rerr |
| + } |
| + } |
| + return body, etag, err |
| +} |
| + |
| +// Fix round 1 (review P1), the race: blog is restored after the drain read |
| +// its trash marker and before the drain ends. The drain still succeeds, |
| +// excusing the record, and that is safe: the record was not written, so it |
| +// is still unlabelled on the fleet, and the surviving box pi-2 is one a |
| +// record can be on, so the restored instance is carried by pi-2. |
| +func TestDrainRacingARestoreLeavesTheInstanceOnTheSurvivor(t *testing.T) { |
| + ctx := context.Background() |
| + fx, _, reg := fleetBoxWorld(t, "code-rl-trash-race", "pi-1", "pi-2") |
| + placeBlog(t, fx) |
| + putFleetRecord(t, fx, "blog", "x.example.com", nil) |
| + before := blogRecBytes(t, fx, "x.example.com") |
| + if err := release.TrashApp(ctx, fx.rel, fx.sqid, "blog", "paul@keymail.dev", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + race := &restoreOnGet{Store: fx.rel, key: release.AppTombstoneKey(fx.sqid, "blog"), fx: fx} |
| + fx.srv.cfg.Releases = race |
| + stuck, err := fx.srv.drainBox(ctx, "pi", "pi-1") |
| + if err != nil || len(stuck) != 0 { |
| + t.Fatalf("drainBox = %v, %v; want nothing stranded", stuck, err) |
| + } |
| + if !race.done { |
| + t.Fatal("the drain never read the trash marker, so the witness proves nothing") |
| + } |
| + if tomb, err := release.ReadAppTombstone(ctx, fx.rel, fx.sqid, "blog"); err != nil || tomb != nil { |
| + t.Fatalf("blog is still in the trash (%v, %v); the restore did not land", tomb, err) |
| + } |
| + if b := boxRow(t, reg, "pi-1"); b.DrainingSince == 0 { |
| + t.Fatal("the drain did not mark pi-1 draining") |
| + } |
| + if got := blogRecBytes(t, fx, "x.example.com"); !bytes.Equal(got, before) { |
| + t.Fatalf("the excused record was written:\n%s\nwant\n%s", got, before) |
| + } |
| + r, err := provision.GetRecord(ctx, fx.rel, fx.sqid, "blog", "x.example.com") |
| + if err != nil || r.Retired || r.Region != "fleet/pi" { |
| + t.Fatalf("after the race: %+v, %v; want the record kept on fleet/pi", r, err) |
| + } |
| + wantNoLabel(t, r) // unlabelled: every box of the fleet carries it |
| + v, err := fx.srv.loadFleetView(ctx, "pi") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + _, stateless, err := fx.srv.movableVerified(ctx, *r) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if to := v.chooseMoveDestination(r.Runtime == provision.RuntimeRootfsV1, stateless, "pi-1"); to != "pi-2" { |
| + t.Fatalf("the restored instance's survivor = %q; want pi-2, able to run it (stateless %v): %+v", to, stateless, v.Boxes) |
| + } |
| +} |
| + |
| +// Fix round 2 (review P1): the survivor must be able to run the release a |
| +// restore brings back. shop's trashed always-on stateless record is |
| +// unlabelled; pi-1 is at the stateless runtime floor, pi-2 only at the |
| +// label floor. Draining pi-1 would leave a restored shop on a box that |
| +// cannot run it, so the drain refuses, naming shop, and writes nothing. |
| +func TestDrainRefusesATrashedStatelessRecordWithNoCapableSurvivor(t *testing.T) { |
| + ctx := context.Background() |
| + now := time.Now() |
| + fx, _, reg := fleetBoxWorld(t, "code-rl-trash-stateless", "pi-1", "pi-2") |
| + shipStatelessFloorRelease(t, fx, "shop", "v1") |
| + if err := release.Promote(ctx, fx.rel, fx.priv, fx.sqid, "shop", "edge", "v1"); err != nil { |
| + t.Fatal(err) |
| + } |
| + piBeat(t, fx, "pi-1", true, now, release.StatelessRuntimeFloor) |
| + piBeat(t, fx, "pi-2", true, now, release.FleetBoxLabelFloor) |
| + putFleetRecord(t, fx, "shop", "a.example.com", func(r *provision.Record) { |
| + r.Channel, r.Hibernate = "edge", new(bool) // always-on, unlabelled |
| + }) |
| + if err := release.TrashApp(ctx, fx.rel, fx.sqid, "shop", "paul@keymail.dev", now); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, stateless, err := fx.srv.movableVerified(ctx, *shopRec(t, fx, "a.example.com")); err != nil || !stateless { |
| + t.Fatalf("movableVerified: stateless %v, %v; the witness needs a stateless release", stateless, err) |
| + } |
| + cs := newCountStore(fx.rel) |
| + fx.srv.cfg.Releases = cs |
| + stuck, err := fx.srv.drainBox(ctx, "pi", "pi-1") |
| + if err != nil || !slices.Equal(stuck, []string{"shop"}) { |
| + t.Fatalf("drainBox = %v, %v; want shop stranded", stuck, err) |
| + } |
| + if n := cs.recordPuts(); n != 0 { |
| + t.Fatalf("a refused drain wrote %d records", n) |
| + } |
| + if b := boxRow(t, reg, "pi-1"); b.DrainingSince != 0 { |
| + t.Fatal("a refused drain marked the box draining") |
| + } |
| +} |
| + |
| +// The excuse is the box's own removable test (marker and production flag |
| +// both positively read, the flag clear) and covers unlabelled records |
| +// only. A trashed app the boxes still serve, or whose state cannot be |
| +// read, or whose record is labelled and cannot move, still strands the |
| +// drain with nothing written. |
| +func TestDrainStillRefusesATrashedAppTheBoxesServe(t *testing.T) { |
| + // overwrite replaces the object at key with body. |
| + overwrite := func(t *testing.T, fx *consoleFixture, key string, body []byte) { |
| + t.Helper() |
| + _, etag, err := fx.rel.Get(context.Background(), key) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := fx.rel.Put(context.Background(), key, body, etag); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + for _, tc := range []struct { |
| + name string |
| + recMut func(*provision.Record) |
| + // before runs before blog is trashed (the production flag cannot be |
| + // set on a trashed app), after once it is. |
| + before, after func(t *testing.T, fx *consoleFixture) |
| + }{ |
| + {"production", nil, func(t *testing.T, fx *consoleFixture) { |
| + if err := release.SetProduction(context.Background(), fx.rel, fx.priv, fx.sqid, "blog", true, "paul@keymail.dev"); err != nil { |
| + t.Fatal(err) |
| + } |
| + }, nil}, |
| + {"unreadable marker", nil, nil, func(t *testing.T, fx *consoleFixture) { |
| + overwrite(t, fx, release.AppTombstoneKey(fx.sqid, "blog"), []byte(`{"schema":2}`)) |
| + }}, |
| + {"unreadable flag", nil, nil, func(t *testing.T, fx *consoleFixture) { |
| + if _, err := fx.rel.Put(context.Background(), release.ProductionKey(fx.sqid, "blog"), []byte("not a flag"), ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + }}, |
| + {"labelled and unmovable", func(r *provision.Record) { r.FleetBox, r.Addr = "pi-1", "127.0.0.1:9000" }, nil, nil}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + ctx := context.Background() |
| + fx, _, reg := fleetBoxWorld(t, "code-rl-trash-served-"+strings.ReplaceAll(tc.name, " ", "-"), "pi-1", "pi-2") |
| + if !fx.srv.cfg.ReleasePub.Equal(fx.pub) { |
| + t.Fatal("the fixture's console does not hold the release root's public key") |
| + } |
| + placeBlog(t, fx) |
| + putFleetRecord(t, fx, "shop", "a.example.com", func(r *provision.Record) { r.FleetBox = "pi-1" }) |
| + putFleetRecord(t, fx, "blog", "x.example.com", tc.recMut) |
| + if tc.before != nil { |
| + tc.before(t, fx) |
| + } |
| + if err := release.TrashApp(ctx, fx.rel, fx.sqid, "blog", "paul@keymail.dev", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + if tc.after != nil { |
| + tc.after(t, fx) |
| + } |
| + cs := newCountStore(fx.rel) |
| + fx.srv.cfg.Releases = cs |
| + stuck, err := fx.srv.drainBox(ctx, "pi", "pi-1") |
| + if err != nil || !slices.Equal(stuck, []string{"blog"}) { |
| + t.Fatalf("drainBox = %v, %v; want blog stranded", stuck, err) |
| + } |
| + if n := cs.recordPuts(); n != 0 { |
| + t.Fatalf("a refused drain wrote %d records", n) |
| + } |
| + if b := boxRow(t, reg, "pi-1"); b.DrainingSince != 0 { |
| + t.Fatal("a refused drain marked the box draining") |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// The trash state is read only for an app with an unlabelled record on the |
| +// fleet, and once per app per drain however many such records it has. |
| +func TestDrainReadsTrashStateOnlyForUnlabelledApps(t *testing.T) { |
| + fx, _, _ := fleetBoxWorld(t, "code-rl-trash-reads", "pi-1", "pi-2") |
| + placeBlog(t, fx) |
| + putFleetRecord(t, fx, "shop", "a.example.com", func(r *provision.Record) { r.FleetBox = "pi-1" }) |
| + putFleetRecord(t, fx, "shop", "b.example.com", nil) |
| + putFleetRecord(t, fx, "shop", "c.example.com", nil) |
| + putFleetRecord(t, fx, "blog", "x.example.com", func(r *provision.Record) { r.FleetBox = "pi-1" }) |
| + cs := newCountStore(fx.rel) |
| + fx.srv.cfg.Releases = cs |
| + if _, err := fx.srv.drainBox(context.Background(), "pi", "pi-1"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if n := cs.getsOf(release.AppTombstoneKey(fx.sqid, "blog")); n != 0 { |
| + t.Fatalf("blog, with no unlabelled record, had its trash marker read %d times", n) |
| + } |
| + if n := cs.getsOf(release.AppTombstoneKey(fx.sqid, "shop")); n != 1 { |
| + t.Fatalf("shop's trash marker was read %d times; want once for its two unlabelled records", n) |
| + } |
| +} |
| + |
| // drainedPi1 is a world where pi-1 held a.example.com and was drained: its |
| // record is on pi-2 and pi-1 is draining. |
| func drainedPi1(t *testing.T, code string) (*consoleFixture, string, *registry.Registry) { |
| @@ -1020,3 +1308,410 @@ func TestLostBoxAndDrainLeaveAUnitInPlace(t *testing.T) { |
| } |
| }) |
| } |
| + |
| +// #1008 T9 finding 2: a two-box fleet loses a box. After detach-box |
| +// --terminated the records labelled to it stayed tied to it and answered |
| +// 503: the worker skipped fleets with fewer than two active boxes. The |
| +// worker now reads a one-box fleet whole when a detached box was ever |
| +// labelled, and moves those records to the survivor, restore-required |
| +// (R2). A record already on the survivor is not written. |
| +func TestDetachedBoxRecordsMoveToTheSoleSurvivor(t *testing.T) { |
| + ctx := context.Background() |
| + fx, _, reg := fleetBoxWorld(t, "code-rl-sole", "pi-1", "pi-2") |
| + for _, h := range []string{"a.example.com", "b.example.com", "c.example.com"} { |
| + putFleetRecord(t, fx, "shop", h, nil) |
| + } |
| + labelOn(t, fx, reg, "a.example.com", "pi-1") |
| + labelOn(t, fx, reg, "b.example.com", "pi-2") |
| + labelOn(t, fx, reg, "c.example.com", "pi-2") |
| + if err := reg.SetFleetBoxStatus("pi", "pi-2", "detached"); err != nil { // the machine is gone |
| + t.Fatal(err) |
| + } |
| + now := time.Now() |
| + // The old gate: one active box is never Active. |
| + if v, err := fx.srv.loadFleetViewAt(ctx, "pi", now); err != nil || v.Active || v.Complete { |
| + t.Fatalf("plain view %+v, %v; want neither Active nor Complete", v, err) |
| + } |
| + cs := newCountStore(fx.rel) |
| + fx.srv.cfg.Releases = cs |
| + if err := fx.srv.fleetRelabelPass(ctx, now); err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, h := range []string{"b.example.com", "c.example.com"} { |
| + wantMovedTo(t, shopRec(t, fx, h), "pi-1") |
| + } |
| + if r := shopRec(t, fx, "a.example.com"); r.FleetBox != "pi-1" || r.FleetBoxMoved { |
| + t.Fatalf("a was already on the survivor and was rewritten: %+v", r) |
| + } |
| + if n := cs.recordPuts(); n != 2 { |
| + t.Fatalf("the pass wrote %d records; want 2", n) |
| + } |
| + // A second pass finds nothing to move. |
| + cs.reset() |
| + if err := fx.srv.fleetRelabelPass(ctx, now.Add(time.Minute)); err != nil { |
| + t.Fatal(err) |
| + } |
| + if n := cs.recordPuts(); n != 0 { |
| + t.Fatalf("a second pass wrote %d records", n) |
| + } |
| +} |
| + |
| +// wantMovedTo fails unless rec is labelled box, assigned now, and marked |
| +// moved, so it never starts empty there (R2). |
| +func wantMovedTo(t *testing.T, rec *provision.Record, box string) { |
| + t.Helper() |
| + if rec.FleetBox != box { |
| + t.Fatalf("record %s labelled %q; want %q", rec.Host, rec.FleetBox, box) |
| + } |
| + at, err := time.Parse(time.RFC3339Nano, rec.FleetBoxAt) |
| + if err != nil || time.Since(at) > time.Minute { |
| + t.Fatalf("record %s assigned at %q (%v); want now", rec.Host, rec.FleetBoxAt, err) |
| + } |
| + if !rec.FleetBoxMoved { |
| + t.Fatalf("%s moved without FleetBoxMoved: it could start empty (R2)", rec.Host) |
| + } |
| +} |
| + |
| +// soleSurvivorWorld is pi-1 holding a and pi-2 holding b and c, both boxes |
| +// marked labelled, each record labelled at its creation with mut applied |
| +// (a rootfs record's runtime is fixed when it is created). |
| +func soleSurvivorWorld(t *testing.T, code string, mut func(*provision.Record)) (*consoleFixture, string, *registry.Registry) { |
| + t.Helper() |
| + fx, token, reg := fleetBoxWorld(t, code, "pi-1", "pi-2") |
| + for _, b := range []string{"pi-1", "pi-2"} { |
| + if err := reg.MarkFleetBoxLabelled("pi", b, time.Now().UnixNano()); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + for h, box := range map[string]string{"a.example.com": "pi-1", "b.example.com": "pi-2", "c.example.com": "pi-2"} { |
| + putFleetRecord(t, fx, "shop", h, func(r *provision.Record) { |
| + r.FleetBox, r.FleetBoxAt = box, time.Now().UTC().Format(time.RFC3339Nano) |
| + if mut != nil { |
| + mut(r) |
| + } |
| + }) |
| + } |
| + return fx, token, reg |
| +} |
| + |
| +// The detach doors move the detached box's records at once, under the |
| +// lock they hold, with no worker pass, and answer as before. |
| +func TestDetachDoorMovesTheDetachedBoxesRecords(t *testing.T) { |
| + for _, door := range []string{"api", "page"} { |
| + t.Run(door, func(t *testing.T) { |
| + fx, token, reg := soleSurvivorWorld(t, "code-rl-door-sole-"+door, nil) |
| + if door == "api" { |
| + if code, raw := detachAPI(t, fx, token, "pi-2", true); code != http.StatusOK || strings.TrimSpace(raw) != "{}" { |
| + t.Fatalf("API detach = %d %s; want 200 {}", code, raw) |
| + } |
| + } else if body := detachPage(t, fx, "pi-2", true); !strings.Contains(body, "Detached pi/pi-2.") { |
| + t.Fatalf("page detach shows no confirmation:\n%s", body) |
| + } |
| + if b := boxRow(t, reg, "pi-2"); b.Status != "detached" { |
| + t.Fatalf("box %+v; want detached", b) |
| + } |
| + for _, h := range []string{"b.example.com", "c.example.com"} { |
| + wantMovedTo(t, shopRec(t, fx, h), "pi-1") |
| + } |
| + if r := shopRec(t, fx, "a.example.com"); r.FleetBox != "pi-1" || r.FleetBoxMoved { |
| + t.Fatalf("a was rewritten: %+v", r) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// The sole survivor is a destination only as chooseMoveDestination allows: |
| +// a stale, draining, not-ready (for a rootfs record) or below-floor |
| +// survivor takes nothing. |
| +func TestSoleSurvivorMustBeAValidDestination(t *testing.T) { |
| + cases := []struct { |
| + name string |
| + mut func(*provision.Record) |
| + setup func(t *testing.T, fx *consoleFixture, reg *registry.Registry, now time.Time) |
| + log string |
| + }{ |
| + {name: "stale", setup: func(t *testing.T, fx *consoleFixture, reg *registry.Registry, now time.Time) { |
| + piBeat(t, fx, "pi-1", true, now.Add(-21*time.Minute), release.FleetRecordLabelFloor) |
| + }}, |
| + {name: "draining", setup: func(t *testing.T, fx *consoleFixture, reg *registry.Registry, now time.Time) { |
| + if _, err := reg.SetFleetBoxDraining("pi", "pi-1", now.UnixNano()); err != nil { |
| + t.Fatal(err) |
| + } |
| + }}, |
| + {name: "rootfs not ready", mut: func(r *provision.Record) { |
| + alwaysOn := false |
| + r.Runtime, r.Hibernate = provision.RuntimeRootfsV1, &alwaysOn |
| + }, |
| + setup: func(t *testing.T, fx *consoleFixture, reg *registry.Registry, now time.Time) { |
| + piBeat(t, fx, "pi-1", false, now, release.FleetRecordLabelFloor) |
| + }}, |
| + {name: "below the label floor", log: "relabelling is paused", |
| + setup: func(t *testing.T, fx *consoleFixture, reg *registry.Registry, now time.Time) { |
| + piBeat(t, fx, "pi-1", true, now, "v0.32.0") |
| + }}, |
| + } |
| + for i, tc := range cases { |
| + t.Run(tc.name, func(t *testing.T) { |
| + ctx := context.Background() |
| + now := time.Now() |
| + fx, _, reg := soleSurvivorWorld(t, "code-rl-sole-bad-"+string(rune('a'+i)), tc.mut) |
| + if err := reg.SetFleetBoxStatus("pi", "pi-2", "detached"); err != nil { |
| + t.Fatal(err) |
| + } |
| + tc.setup(t, fx, reg, now) |
| + cs := newCountStore(fx.rel) |
| + fx.srv.cfg.Releases = cs |
| + var logs bytes.Buffer |
| + restore := captureLogTo(&logs) |
| + err := fx.srv.fleetRelabelPass(ctx, now) |
| + restore() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if r := shopRec(t, fx, "b.example.com"); r.FleetBox != "pi-2" || r.FleetBoxMoved { |
| + t.Fatalf("b moved to an invalid survivor: %+v", r) |
| + } |
| + if n := cs.recordPuts(); n != 0 { |
| + t.Fatalf("the pass wrote %d records; want none", n) |
| + } |
| + if tc.log != "" && !strings.Contains(logs.String(), tc.log) { |
| + t.Fatalf("no %q line in the log:\n%s", tc.log, logs.String()) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// R3 across a detach: an always-on stateless record on a detached box moves |
| +// to the sole survivor only when it runs the stateless runtime floor. |
| +func TestDetachedStatelessRecordNeedsTheRuntimeFloor(t *testing.T) { |
| + for _, tc := range []struct { |
| + name, survivor string |
| + moves bool |
| + }{ |
| + {"survivor at the label floor", release.FleetBoxLabelFloor, false}, |
| + {"survivor at the runtime floor", release.StatelessRuntimeFloor, true}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + now := time.Now() |
| + code := "code-r3-detached-stay" |
| + if tc.moves { |
| + code = "code-r3-detached-move" |
| + } |
| + fx, reg := statelessShopWorldOn(t, code, "edge", now, |
| + map[string]string{"pi-1": release.StatelessRuntimeFloor, "pi-2": tc.survivor}) |
| + if err := reg.MarkFleetBoxLabelled("pi", "pi-1", now.UnixNano()); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := reg.SetFleetBoxStatus("pi", "pi-1", "detached"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := fx.srv.fleetRelabelPass(context.Background(), now); err != nil { |
| + t.Fatal(err) |
| + } |
| + r := shopRec(t, fx, "a.example.com") |
| + if tc.moves { |
| + wantMovedTo(t, r, "pi-2") |
| + } else if r.FleetBox != "pi-1" || r.FleetBoxMoved { |
| + t.Fatalf("a stateless record moved below the runtime floor: %+v", r) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// Request budget: a one-box fleet is read whole only when a detached box |
| +// was labelled. Without one, a pass lists no records and writes none. |
| +func TestOneBoxFleetReadsNoInventoryWithoutAGoneLabelledBox(t *testing.T) { |
| + for _, tc := range []struct { |
| + name string |
| + second bool |
| + }{ |
| + {"never had a second box", false}, |
| + {"detached box never labelled", true}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + code := "code-rl-onebox-lone" |
| + if tc.second { |
| + code = "code-rl-onebox-unlabelled" |
| + } |
| + fx, _, reg := fleetBoxWorld(t, code, "pi-1") |
| + putFleetRecord(t, fx, "shop", "a.example.com", nil) |
| + labelOn(t, fx, reg, "a.example.com", "pi-1") |
| + if tc.second { |
| + registerFleetBox(t, reg, "pi", "pi-2") |
| + if err := reg.SetFleetBoxStatus("pi", "pi-2", "detached"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if b := boxRow(t, reg, "pi-2"); b.LabelledAt != 0 { |
| + t.Fatalf("pi-2 is labelled: %+v", b) |
| + } |
| + } |
| + cs := newCountStore(fx.rel) |
| + fx.srv.cfg.Releases = cs |
| + if err := fx.srv.fleetRelabelPass(context.Background(), time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + if n := cs.listsOf(provision.RecordsPrefix(fx.sqid, "shop"), provision.SidecarsPrefix(fx.sqid, "shop")); n != 0 { |
| + t.Fatalf("the pass listed shop's records %d times; want none", n) |
| + } |
| + if n := cs.recordPuts(); n != 0 { |
| + t.Fatalf("the pass wrote %d records; want none", n) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestGoneLabelledBox(t *testing.T) { |
| + box := func(label, status string, labelledAt int64) registry.FleetBox { |
| + return registry.FleetBox{Fleet: "pi", Label: label, Status: status, LabelledAt: labelledAt} |
| + } |
| + for _, tc := range []struct { |
| + name string |
| + boxes []registry.FleetBox |
| + want bool |
| + }{ |
| + {"one active, one detached labelled", []registry.FleetBox{box("pi-1", "active", 1), box("pi-2", "detached", 1)}, true}, |
| + {"one active, one detached unlabelled", []registry.FleetBox{box("pi-1", "active", 1), box("pi-2", "detached", 0)}, false}, |
| + {"two active, one detached labelled", []registry.FleetBox{box("pi-1", "active", 0), box("pi-2", "active", 0), box("pi-3", "detached", 1)}, false}, |
| + {"none active", []registry.FleetBox{box("pi-1", "detached", 1), box("pi-2", "detached", 1)}, false}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + if got := goneLabelledBox(tc.boxes); got != tc.want { |
| + t.Fatalf("goneLabelledBox = %v; want %v", got, tc.want) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// Final review F1: a trashed app's unlabelled record is excused only when |
| +// it could move (movableVerified ok) and another box could carry it. One |
| +// that can never move (a system unit, which belongs to the machine; an |
| +// unmanaged upstream address) would be lost with the drained machine: a |
| +// restore brings it back unlabelled to a survivor that lacks it, and no |
| +// pass labels it. It strands the drain, with nothing written. |
| +func TestDrainRefusesATrashedAppsUnmovableUnlabelledRecord(t *testing.T) { |
| + cases := map[string]func(*provision.Record){ |
| + "unit": func(r *provision.Record) { r.Unit = "blog.service" }, |
| + "addr": func(r *provision.Record) { r.Addr = "127.0.0.1:9000" }, |
| + } |
| + for name, mut := range cases { |
| + t.Run(name, func(t *testing.T) { |
| + ctx := context.Background() |
| + fx, _, reg := fleetBoxWorld(t, "code-rl-trash-unmovable-"+name, "pi-1", "pi-2") |
| + placeBlog(t, fx) |
| + putFleetRecord(t, fx, "shop", "a.example.com", func(r *provision.Record) { r.FleetBox = "pi-1" }) |
| + putFleetRecord(t, fx, "blog", "x.example.com", mut) // unlabelled, never movable |
| + if err := release.TrashApp(ctx, fx.rel, fx.sqid, "blog", "paul@keymail.dev", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + if ok, _, err := fx.srv.movableVerified(ctx, *mustRecord(t, fx, "blog", "x.example.com")); ok || err != nil { |
| + t.Fatalf("movableVerified = %v, %v; the witness needs a record that cannot move", ok, err) |
| + } |
| + cs := newCountStore(fx.rel) |
| + fx.srv.cfg.Releases = cs |
| + stuck, err := fx.srv.drainBox(ctx, "pi", "pi-1") |
| + if err != nil || !slices.Equal(stuck, []string{"blog"}) { |
| + t.Fatalf("drainBox = %v, %v; want blog stranded", stuck, err) |
| + } |
| + if n := cs.recordPuts(); n != 0 { |
| + t.Fatalf("a refused drain wrote %d records", n) |
| + } |
| + if b := boxRow(t, reg, "pi-1"); b.DrainingSince != 0 { |
| + t.Fatal("a refused drain marked the box draining") |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// mustRecord reads app's record of h. |
| +func mustRecord(t *testing.T, fx *consoleFixture, app, h string) *provision.Record { |
| + t.Helper() |
| + rec, err := provision.GetRecord(context.Background(), fx.rel, fx.sqid, app, h) |
| + if err != nil { |
| + t.Fatalf("read %s/%s: %v", app, h, err) |
| + } |
| + return rec |
| +} |
| + |
| +// serialOf reads the bucket's serial. |
| +func serialOf(t *testing.T, fx *consoleFixture) int64 { |
| + t.Helper() |
| + doc, _, err := release.ReadSerial(context.Background(), fx.rel) |
| + if err != nil { |
| + t.Fatalf("read serial: %v", err) |
| + } |
| + return doc.Serial |
| +} |
| + |
| +// Final review F2: a label move is a write the boxes consume, so it is |
| +// announced (the serial is bumped) once the writes land, as the label |
| +// door does; a survivor that is already running then drops or takes the |
| +// routes at once rather than at its next instance pass. A pass that moves |
| +// nothing does not bump. Each door that moves records: the worker, the |
| +// drain and the detach doors. |
| +func TestRelabelMovesBumpTheSerial(t *testing.T) { |
| + t.Run("worker", func(t *testing.T) { |
| + ctx := context.Background() |
| + now := time.Now() |
| + fx, _, _ := fleetBoxWorld(t, "code-rl-serial-worker", "pi-1", "pi-2") |
| + putFleetRecord(t, fx, "shop", "a.example.com", func(r *provision.Record) { r.FleetBox = "pi-1" }) |
| + piBeat(t, fx, "pi-1", true, now.Add(-21*time.Minute), release.FleetBoxLabelFloor) |
| + before := serialOf(t, fx) |
| + if err := fx.srv.fleetRelabelPass(ctx, now); err != nil { |
| + t.Fatal(err) |
| + } |
| + wantMovedTo(t, shopRec(t, fx, "a.example.com"), "pi-2") |
| + moved := serialOf(t, fx) |
| + if moved <= before { |
| + t.Fatalf("a pass that moved a record left the serial at %d (before %d)", moved, before) |
| + } |
| + // The next pass has nothing to move: no announcement. |
| + if err := fx.srv.fleetRelabelPass(ctx, now.Add(time.Minute)); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got := serialOf(t, fx); got != moved { |
| + t.Fatalf("an idle pass bumped the serial: %d, was %d", got, moved) |
| + } |
| + }) |
| + t.Run("drain", func(t *testing.T) { |
| + fx, _, _ := fleetBoxWorld(t, "code-rl-serial-drain", "pi-1", "pi-2") |
| + putFleetRecord(t, fx, "shop", "a.example.com", func(r *provision.Record) { r.FleetBox = "pi-1" }) |
| + before := serialOf(t, fx) |
| + if stuck, err := fx.srv.drainBox(context.Background(), "pi", "pi-1"); err != nil || len(stuck) != 0 { |
| + t.Fatalf("drainBox = %v, %v", stuck, err) |
| + } |
| + wantMovedTo(t, shopRec(t, fx, "a.example.com"), "pi-2") |
| + if got := serialOf(t, fx); got <= before { |
| + t.Fatalf("a drain that moved a record left the serial at %d (before %d)", got, before) |
| + } |
| + }) |
| + t.Run("detach", func(t *testing.T) { |
| + fx, token, _ := soleSurvivorWorld(t, "code-rl-serial-detach", nil) |
| + before := serialOf(t, fx) |
| + if code, raw := detachAPI(t, fx, token, "pi-2", true); code != http.StatusOK { |
| + t.Fatalf("API detach = %d %s", code, raw) |
| + } |
| + wantMovedTo(t, shopRec(t, fx, "b.example.com"), "pi-1") |
| + if got := serialOf(t, fx); got <= before { |
| + t.Fatalf("a detach that moved records left the serial at %d (before %d)", got, before) |
| + } |
| + }) |
| + t.Run("cancelled context", func(t *testing.T) { |
| + // The writes landed before the caller's context ended (a detach |
| + // that timed out mid-plan): they are still announced. |
| + fx, _, reg := fleetBoxWorld(t, "code-rl-serial-cancel", "pi-1", "pi-2") |
| + putFleetRecord(t, fx, "shop", "a.example.com", func(r *provision.Record) { r.FleetBox = "pi-1" }) |
| + if err := reg.MarkFleetBoxLabelled("pi", "pi-2", time.Now().UnixNano()); err != nil { |
| + t.Fatal(err) |
| + } |
| + before := serialOf(t, fx) |
| + ctx, cancel := context.WithCancel(context.Background()) |
| + plan := []relabel{{rec: *shopRec(t, fx, "a.example.com"), to: "pi-2", reason: "test"}} |
| + cancel() |
| + if moved := fx.srv.writeRelabels(ctx, "pi", plan, time.Now()); moved != 1 { |
| + t.Fatalf("writeRelabels moved %d; want 1", moved) |
| + } |
| + if got := serialOf(t, fx); got <= before { |
| + t.Fatalf("a move under a cancelled context left the serial at %d (before %d)", got, before) |
| + } |
| + }) |
| +} |
diff --git a/internal/console/fleets.go b/internal/console/fleets.go| index e337429ff..bad2b9c16 100644 |
| --- a/internal/console/fleets.go |
| +++ b/internal/console/fleets.go |
| @@ -633,6 +633,7 @@ func (s *Server) handleAPIFleetDetachBox(w http.ResponseWriter, r *http.Request) |
| return |
| } |
| s.audit(acct, fleet.Name, addr, "fleet-detach-box", "detached "+fleet.Name+"/"+label+" (cli)") |
| + s.relabelAfterDetach(r.Context(), fleet.Name) |
| reply := map[string]any{} |
| if len(warnings) > 0 { |
| reply["warnings"] = warnings |
| @@ -1722,6 +1723,7 @@ func (s *Server) handleFleetDetachBoxPage(w http.ResponseWriter, r *http.Request |
| return |
| } |
| s.audit(acct, fleet.Name, addr, "fleet-detach-box", "detached "+fleet.Name+"/"+label+" (console)") |
| + s.relabelAfterDetach(r.Context(), fleet.Name) |
| confirmation := "Detached " + fleet.Name + "/" + label + "." |
| back("ok", strings.Join(append([]string{confirmation}, warnings...), "\n")) |
| } |
diff --git a/internal/console/replicaplacement_fix_test.go b/internal/console/replicaplacement_fix_test.go| index d208d20b2..5a12ab395 100644 |
| --- a/internal/console/replicaplacement_fix_test.go |
| +++ b/internal/console/replicaplacement_fix_test.go |
| @@ -85,18 +85,22 @@ func TestReplicaLegacyRelabelSurvivesEarlyReturn(t *testing.T) { |
| if err != nil { |
| t.Fatal(err) |
| } |
| + // rv is the view replica placement returns early on. The relabel |
| + // acts on v: an incomplete view writes nothing (its gate is |
| + // Complete), so "incomplete" withholds it from placement alone. |
| + rv := v |
| switch reason { |
| case "busy": |
| unlock := fx.srv.lockApp(fx.sqid, "blog") |
| defer unlock() |
| case "incomplete": |
| - v.Complete = false |
| + rv.Complete = false |
| case "floor": |
| fx.srv.consoleBuild = release.StatelessRuntimeFloor |
| } |
| unlock := fx.srv.lockFleet("pi") |
| defer unlock() |
| - if err := fx.srv.reconcileReplicaFleet(context.Background(), "pi", v, time.Now()); err != nil { |
| + if err := fx.srv.reconcileReplicaFleet(context.Background(), "pi", rv, time.Now()); err != nil { |
| t.Fatal(err) |
| } |
| if _, err := fx.srv.relabelFleet(context.Background(), "pi", v, time.Now()); err != nil { |
diff --git a/internal/host/agent.go b/internal/host/agent.go| index 183c52aa9..7d4920c78 100644 |
| --- a/internal/host/agent.go |
| +++ b/internal/host/agent.go |
| @@ -1074,6 +1074,9 @@ func runAgent(args []string, buildClaims ClaimFactory) { |
| // loops that read through it, with its backstop running from here. |
| // Without an index the backstop loop handles early full-pass requests. |
| v := armChangeIndex(agentCtx, os.Getenv, openDeployStore) |
| + // Requested here, not in the backstop loop: that loop starts only |
| + // once the HA ingress startup pass returns, tens of seconds later. |
| + requestBootFullPass(v, &backstopFullDue) |
| go func() { |
| runHAIngressStartup(agentCtx, openDeployStore, boxJudge, reg) |
| if agentCtx.Err() == nil { |
diff --git a/internal/host/agent_test.go b/internal/host/agent_test.go| index bb956e1b8..8860e504f 100644 |
| --- a/internal/host/agent_test.go |
| +++ b/internal/host/agent_test.go |
| @@ -1262,6 +1262,41 @@ func TestFastTickActsOnSerialChangeNotBoot(t *testing.T) { |
| } |
| } |
| +// TestUnindexedBootRunsOneFullPass pins P3 (#1008 T9): a restarted box with |
| +// no record view (every fleet box) has no backstop rebuild to request the |
| +// boot full pass, so RunAgent requests it. The fast loop's first tick, which |
| +// only SEEDS the present serial (no replay of its legs), runs that one full |
| +// pass instead of leaving the box unreconciled until instancesLoop, a minute |
| +// away. An armed box's request stays the backstop's. |
| +func TestUnindexedBootRunsOneFullPass(t *testing.T) { |
| + env := newFastFixture(t) |
| + now := time.Unix(1754640000, 0) |
| + // The label written while the agent was down: a present serial. |
| + if err := release.BumpSerial(context.Background(), env.store, now); err != nil { |
| + t.Fatalf("BumpSerial: %v", err) |
| + } |
| + var due atomic.Bool |
| + var passes int |
| + d := env.deps(func() { passes++ }) |
| + d.fullDue = &due |
| + requestBootFullPass(nil, &due) |
| + fastTick(context.Background(), d, now) // seeds the serial and runs the boot pass |
| + if passes != 1 || due.Load() { |
| + t.Fatalf("unindexed boot: passes=%d due=%v, want one pass and the request taken", passes, due.Load()) |
| + } |
| + fastTick(context.Background(), d, now.Add(10*time.Second)) // unchanged serial, nothing due |
| + if passes != 1 { |
| + t.Fatalf("boot pass must run once, got %d", passes) |
| + } |
| + |
| + var due2 atomic.Bool |
| + live := release.NewDirStore(t.TempDir()) |
| + requestBootFullPass(provision.NewRecordView(live, release.NewChangeWatch(live)), &due2) |
| + if due2.Load() { |
| + t.Fatal("an armed box's boot pass is the backstop's to request") |
| + } |
| +} |
| + |
| // TestFastTickClampsFullPasses pins the 5s clamp: a bump landing inside the |
| // window is DEFERRED (the acted serial is not recorded), and the next tick |
| // past the window fires it — a burst of console writes costs one pass set |
diff --git a/internal/host/changeindex.go b/internal/host/changeindex.go| index 120d66033..5cce83ff3 100644 |
| --- a/internal/host/changeindex.go |
| +++ b/internal/host/changeindex.go |
| @@ -145,6 +145,20 @@ func viewStore(ctx context.Context, live release.Store) (s release.Store, epoch |
| return sn.Store(live), sn.Epoch, true |
| } |
| +// requestBootFullPass asks the fast converge loop for one full pass at boot |
| +// when no record view is armed (every fleet box; any box with the index |
| +// off). An armed box gets that request from recordViewBackstop's first |
| +// rebuild; an unarmed one has no rebuild, and the fast loop's first tick only |
| +// seeds a present serial, so without this the first reconcile after a restart |
| +// was instancesLoop's, a minute away (#1008 T9, P3). It is a convergence |
| +// pass, not a replay: the serial's restart, wake and schedule legs still |
| +// treat the bumps behind the seed as history. |
| +func requestBootFullPass(v *provision.RecordView, due *atomic.Bool) { |
| + if v == nil { |
| + due.Store(true) |
| + } |
| +} |
| + |
| // recordViewBackstopLoop is the backstop (spec §4.4): Rebuild at start and |
| // every release.ChangeIndexBackstop, jittered by +-10%, each followed by the |
| // unrestricted full pass, so every leg is re-run over everything at least |
diff --git a/internal/provision/sr_followups_census_test.go b/internal/provision/sr_followups_census_test.go| index 9907c2a62..5f70ea139 100644 |
| --- a/internal/provision/sr_followups_census_test.go |
| +++ b/internal/provision/sr_followups_census_test.go |
| @@ -27,6 +27,18 @@ package provision |
| // a door box, through configAckStore's fleets/<fleet>/ prefix store. A |
| // config ack is not a host record and names no record key: nonrecord, |
| // sel:Put, as WriteConfigAck. |
| +// |
| +// Fleet drain follow-ups (#1008 T9 follow-ups), one re-digest: |
| +// - internal/console/fleetrelabel.go Server.writeRelabels (record-writer): |
| +// after the loop, when any relabel landed (moved > 0), it calls |
| +// s.bumpSerial(ctx) once, announcing the pass's record writes so boxes |
| +// converge now rather than at their next instance pass, as the label |
| +// door announces its own. The detach doors reach this writer through |
| +// relabelAfterDetach, which runs the fleet's relabel under the door's |
| +// lock so a detached box's records move to a survivor at once. The |
| +// record writes are unchanged: MarkFleetBoxLabelled, then |
| +// provision.SetRecordFleetBox only; bumpSerial writes no record. Still |
| +// record-writer, key:SetRecordFleetBox. |
| func srFollowupsWriteCensusInventory() []censusEntry { |
| entries := append([]censusEntry(nil), flatPlansWriteCensusInventory()...) |
| for _, r := range []censusEntry{ |
| @@ -34,6 +46,8 @@ func srFollowupsWriteCensusInventory() []censusEntry { |
| {"internal/appconfig/configack.go", "WriteConfigAck", "nonrecord", "sel:Put", "8dba7cab65ff994109d3edc75058101c90c2998f52afdce4734d29bb8259913c"}, |
| {"internal/host/movesfinal.go", "sourceFinal.configAck", "nonrecord", "sel:Put", "29eb4a6dd1944a8ba33b8cdb3b794d45336557b988976fbbcd6ff77dd1e054b3"}, |
| {"internal/appconfig/configack.go", "ReplaceConfigAckBlind", "nonrecord", "sel:Put", "4abea553f02c2bd0a520e6d1d39ccb79f4563a36d5575a49c2d29513f701edea"}, |
| + // Fleet drain follow-ups (#1008 T9): one bumpSerial after the loop when a relabel landed, and the detach doors' relabel reaches it; same typed SetRecordFleetBox write, no new record key. |
| + {"internal/console/fleetrelabel.go", "Server.writeRelabels", "record-writer", "key:SetRecordFleetBox", "2c69e710573d6da5de7622b825e822140d51b8f6c94621d5697dcbca1cfe3bb2"}, |
| } { |
| replaced := false |
| for i, e := range entries { |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 9d511301e..c30c10e7f 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -224,3 +224,4 @@ plan14-root-reads-drain-quiesce-1062.tsv 66404a2fb26ea541e99d9c3d3bd87cb3f2a346e |
| plan14-root-reads-flat-plans.tsv 66404a2fb26ea541e99d9c3d3bd87cb3f2a346eda95cdb7d7838cab2fcd844f5 |
| plan14-root-reads-sr-followups.tsv da718fcd010b3c1db861196e0bbb9121723a9857ad16c2a15a329983688b8981 |
| plan14-root-reads-close-direct-s3-fleet-writes.tsv c6655e82e81ccd2a7547655eb393ec3fd10bba396255a1edb30d59b7ad1e682e |
| +plan14-root-reads-fleet-drain-followups.tsv c6655e82e81ccd2a7547655eb393ec3fd10bba396255a1edb30d59b7ad1e682e |
diff --git a/internal/provision/testdata/plan14-root-reads-fleet-drain-followups.tsv b/internal/provision/testdata/plan14-root-reads-fleet-drain-followups.tsv| new file mode 100644 |
| index 000000000..b7416db26 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-fleet-drain-followups.tsv |
| @@ -0,0 +1,4 @@ |
| +# Census overlay fleet-drain-followups, written by census-propose (#369). census-ruling-fleet-drain-followups, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-fleet-drain-followups.md. |
| +# 1 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +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. file:Exec@21625,file:Open@2191,file:Statfs@57331,registry:App@13287,registry:App@13665,whole:Route@13279,whole:Route@13657,whole:Route@50809 eaf6f3075d035d9736a67ec68758ffcca780d595855456fecc3662ce2c637b4f |
| +@coverage internal/host 7721c7076a9ecb2fbd9a6a5edfd089b6af3ddab84e2a45493383a81cf461dbce |