activator: page suspect holders after 10 minutes of refusals (T3a)
docs/region-ha-runbook.md+6 −0docs/superpowers/notes/census-proposal-region-ha-g2-t3.md+23 −0internal/activator/backend_exec.go+3 −2internal/activator/hasamebox.go+6 −1internal/activator/hasuspectholder.go+135 −0internal/activator/hasuspectholder_test.go+362 −0internal/activator/hatakeover.go+4 −0internal/host/agent.go+1 −0internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/provision/testdata/plan14-root-reads-region-ha-g2-t3.tsv+9 −0
Intent
<task-notification> <task-id>bx7zun8yp</task-id> <tool-use-id>toolu_015mWgVEViVi4Uaop3xWAgf9</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/dc71bafb-7376-4e4b-a855-4d32f1eed771/tasks/bx7zun8yp.output</output-file> <status>completed</status> <summary>Background command "Wait for addendum CI on new main" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 20.4 g CO₂e (2,520,858 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on region-ha-g2-prep, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/docs/region-ha-runbook.md b/docs/region-ha-runbook.md| index b31c49cff..aa4b889b9 100644 |
| --- a/docs/region-ha-runbook.md |
| +++ b/docs/region-ha-runbook.md |
| @@ -71,3 +71,9 @@ A region-host role with SSM parameter scoping (`scope_ssm_parameter_reads`) can |
| Copy the value with an operator credential instead of the box role. This needs no change to the role. |
| If the box role itself must read it, widen `ssm_parameter_arn` to include that one parameter, or turn `scope_ssm_parameter_reads` off, through the deployment's infrastructure root and with scoped approval. Copy the value, then put the setting back, and check with an IAM policy simulation that the read is denied again. |
| + |
| +## A box is holding hosts it does not serve (ha_suspect_holder) |
| + |
| +1. Confirm in EC2 that the instance is terminated or is still running. |
| +2. If it is a group member, terminate it in its group with `--no-should-decrement-desired-capacity`. |
| +3. Never terminate a fixed box without a separate decision. Check its storage access and its agent first. |
diff --git a/docs/superpowers/notes/census-proposal-region-ha-g2-t3.md b/docs/superpowers/notes/census-proposal-region-ha-g2-t3.md| new file mode 100644 |
| index 000000000..b62a2780b |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-region-ha-g2-t3.md |
| @@ -0,0 +1,23 @@ |
| +# Census approval: region-ha-g2-t3 |
| + |
| +Ruling `census-ruling-region-ha-g2-t3`. 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 (9) | 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. | |
| +| `internal/activator/hasamebox.go` `ExecBackend.sameBoxEmpty` | sites | +registry:Host | T3a: record refused same-box recovery using the existing route Host and lease.CurrentSelf instance id; no new external read; +registry:Host for the tracker call; the emptiness proof and S3-free refusal stay unchanged; pages through the existing sink. | |
| +| `internal/activator/hatakeover.go` `ExecBackend.reportTakeover` | sites | +registry:Host ×2 | T3a: track visitor refusals and clear a host after confirmed termination; no new external read; reads only the existing route Host (+registry:Host x2) and the classified owner instance id; pages through the existing sink; departure-finalize keeps its existing immediate hourly page. | |
| + |
| +Envelopes re-pinned: `internal/activator`, `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. |
| +- `internal/activator/hasamebox.go` `ExecBackend.sameBoxEmpty`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: the closure lease.AcquireHA calls as the same-box proof for taking this box's own expired HA lock: true only when sameBoxProven holds, else logs an ALERT at most once a minute and answers false; +registry:Host x2, +whole:Route |
| +- `internal/activator/hatakeover.go` `ExecBackend.reportTakeover`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=Final fix P2-1: report all refused proof results through the per-host alarm and distinguish visitor from departure-finalize. No reads or authority.;rev3=census-ruling-region-ha-followups;basis=Page only departure-finalize proof refusals through the injected host sink, at warning level and once per host per hour. Send on a detached five-second context and log send failures. Read the existing route Host for page throttling, body and failure logging; no new storage read or takeover authority. |
| + |
| +Seal: `05f08edeb46837a18f1abca302ad21d8c7782edef8af00cc4082f5ed4ea35ad6` → `bb0a59db3aea6ee626a04e4165b128125c34a979fd5372b82c8849d2d3f63d6c`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-region-ha-g2-t3.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/activator/backend_exec.go b/internal/activator/backend_exec.go| index a43a2ec6e..0cdd3873e 100644 |
| --- a/internal/activator/backend_exec.go |
| +++ b/internal/activator/backend_exec.go |
| @@ -393,13 +393,14 @@ type ExecBackend struct { |
| // TerminationProofs replaces live-only takeover when the departure controller |
| // installs its verified identity resolver and shared durable proof cache. |
| TerminationProofs *lease.TerminationProofAdapter |
| - // Page sends finalizer proof refusals through the host paging sinks. Nil disables paging. |
| + // Page sends proof refusals through the host paging sinks. Nil disables paging. |
| Page func(ctx context.Context, level, subject, body string) error |
| // takeover is the takeover proof's log throttle (hatakeover.go). |
| takeover takeoverState |
| // sameBox is the same-box recovery's state (hasamebox.go): the hosts |
| // this process has acquired (acquiredHere). |
| - sameBox sameBoxState |
| + sameBox sameBoxState |
| + suspectHolders suspectHolderState |
| // haWakes is each host's last Acquire classification (hawake.go). |
| haWakes haWakes |
| // entryFiles is the Service's lookup of an awake entry's files |
diff --git a/internal/activator/hasamebox.go b/internal/activator/hasamebox.go| index fbb69bb99..2fa1050ec 100644 |
| --- a/internal/activator/hasamebox.go |
| +++ b/internal/activator/hasamebox.go |
| @@ -10,6 +10,7 @@ import ( |
| "time" |
| "github.com/carlosframework/platform/internal/cgroup" |
| + "github.com/carlosframework/platform/internal/lease" |
| "github.com/carlosframework/platform/internal/registry" |
| ) |
| @@ -69,6 +70,7 @@ func (b *ExecBackend) sameBoxEmpty(ctx context.Context, rt registry.Route) func( |
| return func() (bool, error) { |
| if err := b.sameBoxProven(rt); err != nil { |
| b.sameBox.alarm(rt.Host, err) |
| + b.note(rt.Host, lease.CurrentSelf().IID, true, b.suspectHolders.clock()) |
| return false, err |
| } |
| log.Printf("activator: %s: same-box recovery: the startup sweep proved every unit stopped and the host's slice reads empty", rt.Host) |
| @@ -167,4 +169,7 @@ func (s *sameBoxState) alarm(host string, why error) { |
| // markAcquiredHere records that this process acquired host (any acquire, |
| // HA or legacy). Nothing removes it: see sameBoxEmpty, 3. |
| -func markAcquiredHere(b *ExecBackend, host string) { b.sameBox.markAcquired(host) } |
| +func markAcquiredHere(b *ExecBackend, host string) { |
| + b.sameBox.markAcquired(host) |
| + b.suspectHolders.clear(host) |
| +} |
diff --git a/internal/activator/hasuspectholder.go b/internal/activator/hasuspectholder.go| new file mode 100644 |
| index 000000000..162d18b40 |
| --- /dev/null |
| +++ b/internal/activator/hasuspectholder.go |
| @@ -0,0 +1,135 @@ |
| +package activator |
| + |
| +import ( |
| + "context" |
| + "fmt" |
| + "log" |
| + "sort" |
| + "strings" |
| + "sync" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/alerting" |
| + "github.com/carlosframework/platform/internal/lease" |
| +) |
| + |
| +const suspectHolderAfter = 10 * time.Minute |
| +const suspectHolderFresh = 5 * time.Minute |
| + |
| +type suspectHolder struct { |
| + first, last time.Time |
| + ownerIID string |
| + crossed bool |
| +} |
| + |
| +type suspectHolderState struct { |
| + mu sync.Mutex |
| + hosts map[string]suspectHolder |
| + paged map[string]time.Time |
| + now func() time.Time |
| +} |
| + |
| +func (s *suspectHolderState) clock() time.Time { |
| + if s.now != nil { |
| + return s.now() |
| + } |
| + return time.Now() |
| +} |
| + |
| +func (s *suspectHolderState) clear(host string) { |
| + s.mu.Lock() |
| + defer s.mu.Unlock() |
| + delete(s.hosts, host) |
| +} |
| + |
| +func (b *ExecBackend) note(host, ownerIID string, sameBox bool, now time.Time) { |
| + if ownerIID == "" { |
| + return |
| + } |
| + s := &b.suspectHolders |
| + s.mu.Lock() |
| + if s.hosts == nil { |
| + s.hosts = make(map[string]suspectHolder) |
| + } |
| + // Expire idle entries while using only observations already made by wakes. |
| + for h, entry := range s.hosts { |
| + if now.Sub(entry.last) >= 2*lease.LeaseTTL { |
| + delete(s.hosts, h) |
| + } |
| + } |
| + for iid, last := range s.paged { |
| + if now.Sub(last) >= time.Hour { |
| + delete(s.paged, iid) |
| + } |
| + } |
| + entry, seen := s.hosts[host] |
| + if !seen || entry.ownerIID != ownerIID { |
| + entry = suspectHolder{first: now, ownerIID: ownerIID} |
| + } |
| + entry.last = now |
| + eligible := now.Sub(entry.first) >= suspectHolderAfter |
| + crossing := eligible && !entry.crossed |
| + entry.crossed = entry.crossed || crossing |
| + s.hosts[host] = entry |
| + var hosts []string |
| + if eligible && b.Page != nil { |
| + if _, already := s.paged[ownerIID]; !already { |
| + if s.paged == nil { |
| + s.paged = make(map[string]time.Time) |
| + } |
| + s.paged[ownerIID] = now |
| + for h, candidate := range s.hosts { |
| + if candidate.ownerIID == ownerIID && now.Sub(candidate.first) >= suspectHolderAfter && now.Sub(candidate.last) < suspectHolderFresh { |
| + hosts = append(hosts, h) |
| + } |
| + } |
| + } |
| + } |
| + s.mu.Unlock() |
| + |
| + if crossing { |
| + if sameBox { |
| + log.Printf(suspectHolderSameBoxLog, host) |
| + } else { |
| + log.Printf(suspectHolderLog, host, ownerIID) |
| + } |
| + } |
| + if len(hosts) == 0 { |
| + return |
| + } |
| + sort.Strings(hosts) |
| + listed := strings.Join(hosts[:min(10, len(hosts))], ", ") |
| + if len(hosts) > 10 { |
| + listed += fmt.Sprintf(" and %d more", len(hosts)-10) |
| + } |
| + subject, body := fmt.Sprintf(suspectHolderSubject, ownerIID), fmt.Sprintf(suspectHolderBody, ownerIID, listed) |
| + if sameBox { |
| + subject, body = fmt.Sprintf(suspectHolderSameBoxSubject, ownerIID), fmt.Sprintf(suspectHolderSameBoxBody, listed) |
| + } |
| + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) |
| + defer cancel() |
| + if err := b.Page(ctx, alerting.LevelWarning, subject, body); err != nil { |
| + log.Printf("ha_suspect_holder iid=%s page failed: %v", ownerIID, err) |
| + } |
| +} |
| + |
| +// SuspectHolderHosts counts sustained refusals observed in the last five minutes. |
| +func (b *ExecBackend) SuspectHolderHosts(now time.Time) int { |
| + s := &b.suspectHolders |
| + s.mu.Lock() |
| + defer s.mu.Unlock() |
| + n := 0 |
| + for _, entry := range s.hosts { |
| + if now.Sub(entry.first) >= suspectHolderAfter && now.Sub(entry.last) < suspectHolderFresh { |
| + n++ |
| + } |
| + } |
| + return n |
| +} |
| + |
| +const suspectHolderLog = "activator: ALERT %s: the host has been refused for over 10 minutes. Its lease belongs to instance %s, which is not confirmed terminated. (ha_suspect_holder)" |
| +const suspectHolderSameBoxLog = "activator: ALERT %s: the host has been refused for over 10 minutes. This box could not prove its earlier processes for it have stopped. (ha_suspect_holder_same_box)" |
| +const suspectHolderSubject = "Instance %s is holding hosts it does not serve." |
| +const suspectHolderBody = "Instance %s let its leases expire and is not confirmed terminated. These hosts have been down for over 10 minutes: %s. If the instance is in an Auto Scaling group, terminate it in its group. The hosts then move to a surviving box. If it is a fixed box, check its storage access and its agent first. This page repeats every hour while the hosts stay down. (ha_suspect_holder)" |
| +const suspectHolderSameBoxSubject = "Box %s cannot recover hosts after a restart." |
| +const suspectHolderSameBoxBody = "This box could not prove that its earlier processes for these hosts have stopped: %s. No other box may take them, so they have been down for over 10 minutes. If the box is in an Auto Scaling group, terminate it in its group. If it is a fixed box, check the agent's startup sweep and cgroup delegation. This page repeats every hour while the hosts stay down. (ha_suspect_holder_same_box)" |
diff --git a/internal/activator/hasuspectholder_test.go b/internal/activator/hasuspectholder_test.go| new file mode 100644 |
| index 000000000..1d871f68b |
| --- /dev/null |
| +++ b/internal/activator/hasuspectholder_test.go |
| @@ -0,0 +1,362 @@ |
| +package activator |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "fmt" |
| + "strings" |
| + "sync" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/alerting" |
| + "github.com/carlosframework/platform/internal/hafresh" |
| + "github.com/carlosframework/platform/internal/lease" |
| + "github.com/carlosframework/platform/internal/registry" |
| +) |
| + |
| +type suspectTestPage struct{ subject, body string } |
| +type suspectTestPages struct { |
| + mu sync.Mutex |
| + pages []suspectTestPage |
| +} |
| + |
| +func (p *suspectTestPages) wire(t *testing.T, b *ExecBackend) { |
| + t.Helper() |
| + b.Page = func(ctx context.Context, level, subject, body string) error { |
| + if ctx.Err() != nil { |
| + t.Errorf("spent page context: %v", ctx.Err()) |
| + } |
| + deadline, ok := ctx.Deadline() |
| + if !ok || time.Until(deadline) <= 0 || time.Until(deadline) > 5*time.Second { |
| + t.Errorf("page deadline: %v, %v", deadline, ok) |
| + } |
| + if level != alerting.LevelWarning { |
| + t.Errorf("page level: %s", level) |
| + } |
| + // A page sink may read the metric; the tracker must release its lock first. |
| + b.SuspectHolderHosts(time.Now()) |
| + p.mu.Lock() |
| + defer p.mu.Unlock() |
| + p.pages = append(p.pages, suspectTestPage{subject, body}) |
| + return nil |
| + } |
| +} |
| +func (p *suspectTestPages) snapshot() []suspectTestPage { |
| + p.mu.Lock() |
| + defer p.mu.Unlock() |
| + return append([]suspectTestPage(nil), p.pages...) |
| +} |
| +func suspectRefuse(t *testing.T, b *ExecBackend, rt registry.Route) { |
| + t.Helper() |
| + _, err := b.Acquire(context.Background(), rt) |
| + var refused *errLeaseRefused |
| + if !errors.As(err, &refused) { |
| + t.Fatalf("expected refused acquire, got %v", err) |
| + } |
| + if lockWrites(t, b, rt) != 0 { |
| + t.Fatal("refused acquire wrote a lock") |
| + } |
| +} |
| + |
| +func TestSuspectHolderThresholdAndHourly(t *testing.T) { |
| + logs := captureLog(t) |
| + b, rt, _ := takeoverBackend(t, time.Now().Add(-time.Minute), &terminatedOracle{}) |
| + now := time.Now() |
| + start := now |
| + b.suspectHolders.now = func() time.Time { return now } |
| + var pages suspectTestPages |
| + pages.wire(t, b) |
| + suspectRefuse(t, b, rt) |
| + now = start.Add(9*time.Minute + 59*time.Second) |
| + suspectRefuse(t, b, rt) |
| + if got := len(pages.snapshot()); got != 0 { |
| + t.Fatalf("pages before 10 minutes=%d", got) |
| + } |
| + if n := b.SuspectHolderHosts(now); n != 0 { |
| + t.Fatalf("early count=%d", n) |
| + } |
| + now = start.Add(10 * time.Minute) |
| + suspectRefuse(t, b, rt) |
| + if got := pages.snapshot(); len(got) != 1 || got[0].subject != "Instance i-b is holding hosts it does not serve." { |
| + t.Fatalf("crossing pages=%+v", got) |
| + } |
| + if n := b.SuspectHolderHosts(now); n != 1 { |
| + t.Fatalf("crossing count=%d", n) |
| + } |
| + if n := b.SuspectHolderHosts(now.Add(5*time.Minute - time.Nanosecond)); n != 1 { |
| + t.Fatalf("fresh count=%d", n) |
| + } |
| + if n := b.SuspectHolderHosts(now.Add(5 * time.Minute)); n != 0 { |
| + t.Fatalf("stale count=%d", n) |
| + } |
| + for _, d := range []time.Duration{20 * time.Minute, 40 * time.Minute, 60 * time.Minute, 70*time.Minute - time.Nanosecond} { |
| + now = start.Add(d) |
| + suspectRefuse(t, b, rt) |
| + } |
| + if got := len(pages.snapshot()); got != 1 { |
| + t.Fatalf("pages within hour=%d", got) |
| + } |
| + now = start.Add(70 * time.Minute) |
| + suspectRefuse(t, b, rt) |
| + if got := len(pages.snapshot()); got != 2 { |
| + t.Fatalf("hourly pages=%d", got) |
| + } |
| + if n := strings.Count(logs.String(), "(ha_suspect_holder)"); n != 1 { |
| + t.Fatalf("crossing logs=%d", n) |
| + } |
| +} |
| + |
| +func TestSuspectHolderGroupingAndLimit(t *testing.T) { |
| + b := &ExecBackend{} |
| + now := time.Now() |
| + start := now |
| + b.suspectHolders.now = func() time.Time { return now } |
| + var pages suspectTestPages |
| + pages.wire(t, b) |
| + report := func(host, owner string) { |
| + b.reportTakeover(context.Background(), registry.Route{Host: host}, owner, false, nil) |
| + } |
| + for i := 11; i >= 0; i-- { |
| + report(fmt.Sprintf("host-%02d.example.com", i), "i-b") |
| + } |
| + now = start.Add(9 * time.Minute) |
| + for i := 0; i < 12; i++ { |
| + report(fmt.Sprintf("host-%02d.example.com", i), "i-b") |
| + } |
| + now = start.Add(10 * time.Minute) |
| + report("host-00.example.com", "i-b") |
| + got := pages.snapshot() |
| + want := []string{} |
| + for i := 0; i < 10; i++ { |
| + want = append(want, fmt.Sprintf("host-%02d.example.com", i)) |
| + } |
| + if len(got) != 1 || !strings.Contains(got[0].body, strings.Join(want, ", ")+" and 2 more") || strings.Contains(got[0].body, "host-10") { |
| + t.Fatalf("group page=%+v", got) |
| + } |
| + report("other.example.com", "i-c") |
| + now = now.Add(10 * time.Minute) |
| + report("other.example.com", "i-c") |
| + if got := pages.snapshot(); len(got) != 2 || !strings.Contains(got[1].subject, "i-c") { |
| + t.Fatalf("owner pages=%+v", got) |
| + } |
| +} |
| + |
| +func TestSuspectHolderRecoveryClears(t *testing.T) { |
| + for _, mode := range []string{"terminated", "same-box"} { |
| + t.Run(mode, func(t *testing.T) { |
| + oracle := &terminatedOracle{yes: map[string]bool{}} |
| + b, rt, _ := takeoverBackend(t, time.Now().Add(-time.Minute), oracle) |
| + now := time.Now() |
| + b.suspectHolders.now = func() time.Time { return now } |
| + var pages suspectTestPages |
| + pages.wire(t, b) |
| + suspectRefuse(t, b, rt) |
| + now = now.Add(10 * time.Minute) |
| + suspectRefuse(t, b, rt) |
| + switch mode { |
| + case "terminated": |
| + oracle.yes["i-b"] = true |
| + case "same-box": |
| + putLockFor(t, b, rt, leaseBody(t, hafresh.OwnerFor(lease.CurrentSelf(), 7, true), time.Now().Add(-time.Minute))) |
| + sameBoxReady(b) |
| + } |
| + l, err := b.Acquire(context.Background(), rt) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + releaseHALease(t, l) |
| + if n := b.SuspectHolderHosts(now); n != 0 { |
| + t.Fatalf("successful acquire retained %d suspects", n) |
| + } |
| + b.reportTakeover(context.Background(), rt, "i-c", false, nil) |
| + now = now.Add(9*time.Minute + 59*time.Second) |
| + b.reportTakeover(context.Background(), rt, "i-c", false, nil) |
| + if got := len(pages.snapshot()); got != 1 { |
| + t.Fatalf("new owner paged early: %d", got) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestSuspectHolderResetOwnerAndGap(t *testing.T) { |
| + for _, changeOwner := range []bool{false, true} { |
| + t.Run(fmt.Sprint(changeOwner), func(t *testing.T) { |
| + b := &ExecBackend{} |
| + now := time.Now() |
| + start := now |
| + b.suspectHolders.now = func() time.Time { return now } |
| + var pages suspectTestPages |
| + pages.wire(t, b) |
| + rt := registry.Route{Host: "host.example.com"} |
| + b.reportTakeover(context.Background(), rt, "i-b", false, nil) |
| + owner := "i-b" |
| + now = start.Add(30 * time.Minute) |
| + if changeOwner { |
| + owner = "i-c" |
| + now = start.Add(9 * time.Minute) |
| + } |
| + b.reportTakeover(context.Background(), rt, owner, false, nil) |
| + now = now.Add(9*time.Minute + 59*time.Second) |
| + b.reportTakeover(context.Background(), rt, owner, false, nil) |
| + if len(pages.snapshot()) != 0 { |
| + t.Fatal("reset clock paged early") |
| + } |
| + now = now.Add(time.Second) |
| + b.reportTakeover(context.Background(), rt, owner, false, nil) |
| + if len(pages.snapshot()) != 1 { |
| + t.Fatal("reset clock failed to page") |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestSuspectHolderFinalizerExcludedAndConfirmedClear(t *testing.T) { |
| + b := &ExecBackend{} |
| + now := time.Now() |
| + b.suspectHolders.now = func() time.Time { return now } |
| + var pages suspectTestPages |
| + pages.wire(t, b) |
| + rt := registry.Route{Host: "host.example.com"} |
| + ctx := context.WithValue(context.Background(), adoptionCauseKey{}, "b") |
| + b.reportTakeover(ctx, rt, "i-b", false, nil) |
| + now = now.Add(10 * time.Minute) |
| + b.reportTakeover(ctx, rt, "i-b", false, nil) |
| + if got := pages.snapshot(); len(got) != 1 || strings.Contains(got[0].body, "ha_suspect_holder") { |
| + t.Fatalf("finalizer pages=%+v", got) |
| + } |
| + if b.SuspectHolderHosts(now) != 0 { |
| + t.Fatal("finalizer tracked as suspect") |
| + } |
| + b.reportTakeover(context.Background(), rt, "i-b", false, nil) |
| + now = now.Add(10 * time.Minute) |
| + b.reportTakeover(context.Background(), rt, "i-b", false, nil) |
| + if b.SuspectHolderHosts(now) != 1 { |
| + t.Fatal("visitor not tracked") |
| + } |
| + b.reportTakeover(ctx, rt, "i-b", true, nil) |
| + if b.SuspectHolderHosts(now) != 0 { |
| + t.Fatal("confirmed termination not cleared") |
| + } |
| +} |
| + |
| +func TestSuspectHolderSameBox(t *testing.T) { |
| + logs := captureLog(t) |
| + b, rt := haBackend(t, "host.example.com") |
| + b.StartupSwept = func() bool { return false } |
| + now := time.Now() |
| + b.suspectHolders.now = func() time.Time { return now } |
| + var pages suspectTestPages |
| + pages.wire(t, b) |
| + before := len(haFixOf(b).fx.Requests()) |
| + for _, d := range []time.Duration{0, 10 * time.Minute} { |
| + now = now.Add(d) |
| + if ok, err := b.sameBoxEmpty(context.Background(), rt)(); ok || err == nil { |
| + t.Fatal("same-box refusal changed") |
| + } |
| + } |
| + if got := pages.snapshot(); len(got) != 1 || got[0].subject != "Box i-a cannot recover hosts after a restart." || !strings.Contains(got[0].body, "ha_suspect_holder_same_box") { |
| + t.Fatalf("same-box pages=%+v", got) |
| + } |
| + if len(haFixOf(b).fx.Requests()) != before || lockWrites(t, b, rt) != 0 { |
| + t.Fatal("same-box tracking added storage requests") |
| + } |
| + if strings.Count(logs.String(), "(ha_suspect_holder_same_box)") != 1 { |
| + t.Fatalf("same-box log: %s", logs) |
| + } |
| +} |
| + |
| +func TestSuspectHolderConcurrentSpentContext(t *testing.T) { |
| + b := &ExecBackend{} |
| + now := time.Now() |
| + b.suspectHolders.now = func() time.Time { return now } |
| + var pages suspectTestPages |
| + pages.wire(t, b) |
| + rt := registry.Route{Host: "host.example.com"} |
| + ctx, cancel := context.WithCancel(context.Background()) |
| + cancel() |
| + b.reportTakeover(ctx, rt, "i-b", false, context.Canceled) |
| + now = now.Add(10 * time.Minute) |
| + var wg sync.WaitGroup |
| + for range 20 { |
| + wg.Go(func() { b.reportTakeover(ctx, rt, "i-b", false, context.Canceled); b.SuspectHolderHosts(now) }) |
| + } |
| + wg.Wait() |
| + if got := len(pages.snapshot()); got != 1 { |
| + t.Fatalf("concurrent pages=%d", got) |
| + } |
| +} |
| + |
| +func TestSuspectHolderNilPageStillCounts(t *testing.T) { |
| + b := &ExecBackend{} |
| + now := time.Now() |
| + b.suspectHolders.now = func() time.Time { return now } |
| + rt := registry.Route{Host: "host.example.com"} |
| + b.reportTakeover(context.Background(), rt, "i-b", false, nil) |
| + now = now.Add(10 * time.Minute) |
| + b.reportTakeover(context.Background(), rt, "i-b", false, nil) |
| + if b.SuspectHolderHosts(now) != 1 { |
| + t.Fatal("nil page lost suspect") |
| + } |
| +} |
| + |
| +func TestSuspectHolderAcquireBetweenRefusals(t *testing.T) { |
| + b, rt, _ := takeoverBackend(t, time.Now().Add(-time.Minute), &terminatedOracle{}) |
| + now := time.Now() |
| + start := now |
| + b.suspectHolders.now = func() time.Time { return now } |
| + var pages suspectTestPages |
| + pages.wire(t, b) |
| + suspectRefuse(t, b, rt) |
| + now = start.Add(5 * time.Minute) |
| + putLockFor(t, b, rt, leaseBody(t, hafresh.OwnerFor(lease.CurrentSelf(), 7, true), time.Now().Add(-time.Minute))) |
| + sameBoxReady(b) |
| + l, err := b.Acquire(context.Background(), rt) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + releaseHALease(t, l) |
| + putLockFor(t, b, rt, leaseBody(t, heldByB, time.Now().Add(-time.Minute))) |
| + writes := lockWrites(t, b, rt) |
| + for _, d := range []time.Duration{5 * time.Minute, 10 * time.Minute} { |
| + now = start.Add(d) |
| + if _, err := b.Acquire(context.Background(), rt); err == nil { |
| + t.Fatal("foreign owner was acquired") |
| + } |
| + } |
| + if len(pages.snapshot()) != 0 { |
| + t.Fatal("acquire between refusals did not reset clock") |
| + } |
| + now = start.Add(15 * time.Minute) |
| + if _, err := b.Acquire(context.Background(), rt); err == nil { |
| + t.Fatal("foreign owner was acquired") |
| + } |
| + if len(pages.snapshot()) != 1 { |
| + t.Fatal("new refusal period did not page") |
| + } |
| + if lockWrites(t, b, rt) != writes { |
| + t.Fatal("later refusals wrote a lock") |
| + } |
| +} |
| + |
| +func TestSuspectHolderPageListsOnlySustainedRecentRefusals(t *testing.T) { |
| + b := &ExecBackend{} |
| + now := time.Now() |
| + start := now |
| + b.suspectHolders.now = func() time.Time { return now } |
| + var pages suspectTestPages |
| + pages.wire(t, b) |
| + report := func(host string) { |
| + b.reportTakeover(context.Background(), registry.Route{Host: host}, "i-b", false, nil) |
| + } |
| + report("stale.example.com") |
| + report("active.example.com") |
| + now = start.Add(9 * time.Minute) |
| + report("young.example.com") |
| + now = start.Add(10 * time.Minute) |
| + report("active.example.com") |
| + got := pages.snapshot() |
| + if len(got) != 1 || !strings.Contains(got[0].body, "active.example.com") || strings.Contains(got[0].body, "stale.example.com") || strings.Contains(got[0].body, "young.example.com") { |
| + t.Fatalf("page hosts=%+v", got) |
| + } |
| +} |
diff --git a/internal/activator/hatakeover.go b/internal/activator/hatakeover.go| index 9659d1403..2077e3197 100644 |
| --- a/internal/activator/hatakeover.go |
| +++ b/internal/activator/hatakeover.go |
| @@ -49,6 +49,9 @@ func (b *ExecBackend) reportTakeover(ctx context.Context, rt registry.Route, iid |
| err = termfence.ErrTerminationProof |
| } |
| b.takeover.alarm(rt.Host, iid, cause, err) |
| + if cause == "visitor" { |
| + b.note(rt.Host, iid, false, b.suspectHolders.clock()) |
| + } |
| if finalizer && b.Page != nil && b.takeover.claimPage(rt.Host, time.Now()) { |
| if ref == "" { |
| ref = iid |
| @@ -64,6 +67,7 @@ func (b *ExecBackend) reportTakeover(ctx context.Context, rt registry.Route, iid |
| } |
| return |
| } |
| + b.suspectHolders.clear(rt.Host) |
| if cause == "departure-finalize" { |
| log.Printf("ha_takeover host=%s iid=%s cause=departure-finalize confirmed=%t error=%t", rt.Host, iid, gone, err != nil) |
| return |
diff --git a/internal/host/agent.go b/internal/host/agent.go| index d0f3d3ecf..d8fc32169 100644 |
| --- a/internal/host/agent.go |
| +++ b/internal/host/agent.go |
| @@ -548,6 +548,7 @@ func runAgent(args []string, buildClaims ClaimFactory) { |
| // terminated and whose lease expired asks EC2 through one oracle. |
| confirmer := haOwnerConfirmer() |
| eb.OwnerTerminated = confirmer.Terminated |
| + eb.Page = PageOperator |
| if fs, err := newProductionFilesStore(agentCtx, cfg.Bucket, cfg.Region); err != nil { |
| log.Printf("agent: region HA: files store: %v (every HA restore that needs it fails)", err) |
| } else { |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index c60237de8..63252130f 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -97,3 +97,4 @@ plan14-root-reads-hosts-floor-release.tsv 1daafee8030f9d370adf5541b5e87313523073 |
| plan14-root-reads-region-ha-p3b2.tsv 1b5ef39b210f3c7db69e589da8a467ac4d4a4f218e1d97fb4706cd277a27eae1 |
| plan14-root-reads-region-ha-p1b3b-s.tsv 05f08edeb46837a18f1abca302ad21d8c7782edef8af00cc4082f5ed4ea35ad6 |
| plan14-root-reads-region-ha-g2-t8.tsv 05f08edeb46837a18f1abca302ad21d8c7782edef8af00cc4082f5ed4ea35ad6 |
| +plan14-root-reads-region-ha-g2-t3.tsv bb0a59db3aea6ee626a04e4165b128125c34a979fd5372b82c8849d2d3f63d6c |
diff --git a/internal/provision/testdata/plan14-root-reads-region-ha-g2-t3.tsv b/internal/provision/testdata/plan14-root-reads-region-ha-g2-t3.tsv| new file mode 100644 |
| index 000000000..ef634a2c2 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-region-ha-g2-t3.tsv |
| @@ -0,0 +1,9 @@ |
| +# Census overlay region-ha-g2-t3, written by census-propose (#369). census-ruling-region-ha-g2-t3, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-region-ha-g2-t3.md. |
| +# 1 body, 2 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +@legacy 6adb58ef9090a3b20be51f76c5cd396b38b9bb0d8d29f49c5fb23866c3b5cd26 internal/activator/hasamebox.go ExecBackend.sameBoxEmpty legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: the closure lease.AcquireHA calls as the same-box proof for taking this box's own expired HA lock: true only when sameBoxProven holds, else logs an ALERT at most once a minute and answers false; +registry:Host x2, +whole:Route;rev3=census-ruling-region-ha-g2-t3;basis=T3a: record refused same-box recovery using the existing route Host and lease.CurrentSelf instance id; no new external read; +registry:Host for the tracker call; the emptiness proof and S3-free refusal stay unchanged; pages through the existing sink. registry:Host@194,registry:Host@218,registry:Host@436,whole:Route@157 8bbf73ab3184df6255726461112f7cac215f586dccb63d44fca3b4a124889844 |
| +@legacy dd2a33ff52dc6e169bffab22d1936900551eac1602986f51016c36bbf99a6364 internal/activator/hatakeover.go ExecBackend.reportTakeover legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=Final fix P2-1: report all refused proof results through the per-host alarm and distinguish visitor from departure-finalize. No reads or authority.;rev3=census-ruling-region-ha-followups;basis=Page only departure-finalize proof refusals through the injected host sink, at warning level and once per host per hour. Send on a detached five-second context and log send failures. Read the existing route Host for page throttling, body and failure logging; no new storage read or takeover authority.;rev3=census-ruling-region-ha-g2-t3;basis=T3a: track visitor refusals and clear a host after confirmed termination; no new external read; reads only the existing route Host (+registry:Host x2) and the classified owner instance id; pages through the existing sink; departure-finalize keeps its existing immediate hourly page. registry:Host@1060,registry:Host@1132,registry:Host@1267,registry:Host@1419,registry:Host@347,registry:Host@409,registry:Host@516,registry:Host@957 5fa4f65f910711b5e84a5c56a9c580d470be2139285dac2357271379b3e951ff |
| +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. file:Exec@19044,file:Open@1707,file:Statfs@49791,registry:App@12731,registry:Host@45873,whole:Route@12723,whole:Route@45075,whole:Route@45996,whole:Route@46058 40ba63413f1bb04807e0faff0eda913f4f10bda5cbd0a96512d130540b2b0352 |
| +internal/activator/hasamebox.go ExecBackend.sameBoxEmpty legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: the closure lease.AcquireHA calls as the same-box proof for taking this box's own expired HA lock: true only when sameBoxProven holds, else logs an ALERT at most once a minute and answers false; +registry:Host x2, +whole:Route;rev3=census-ruling-region-ha-g2-t3;basis=T3a: record refused same-box recovery using the existing route Host and lease.CurrentSelf instance id; no new external read; +registry:Host for the tracker call; the emptiness proof and S3-free refusal stay unchanged; pages through the existing sink. registry:Host@194,registry:Host@218,registry:Host@436,whole:Route@157 8bbf73ab3184df6255726461112f7cac215f586dccb63d44fca3b4a124889844 |
| +internal/activator/hatakeover.go ExecBackend.reportTakeover legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=Final fix P2-1: report all refused proof results through the per-host alarm and distinguish visitor from departure-finalize. No reads or authority.;rev3=census-ruling-region-ha-followups;basis=Page only departure-finalize proof refusals through the injected host sink, at warning level and once per host per hour. Send on a detached five-second context and log send failures. Read the existing route Host for page throttling, body and failure logging; no new storage read or takeover authority.;rev3=census-ruling-region-ha-g2-t3;basis=T3a: track visitor refusals and clear a host after confirmed termination; no new external read; reads only the existing route Host (+registry:Host x2) and the classified owner instance id; pages through the existing sink; departure-finalize keeps its existing immediate hourly page. registry:Host@1060,registry:Host@1132,registry:Host@1267,registry:Host@1419,registry:Host@347,registry:Host@409,registry:Host@516,registry:Host@957 5fa4f65f910711b5e84a5c56a9c580d470be2139285dac2357271379b3e951ff |
| +@coverage internal/activator 021afc30fe767e12688922f73153b146f6a5d16a1cd1e99a09a3f1ac68ddb880 |
| +@coverage internal/host 492558782ed5dc2d7ea3b9078a4e3e83ed27269c2b4013b0cec1ae89ab77de72 |