edge: keep sweepStaticCache and setAside as the census units; re-propose
8 files changed,
+80
−110
docs/superpowers/notes/census-proposal-static-sweep-periodic.md+6 −14internal/edge/edge.go+1 −1internal/edge/static_periodic_sweep_test.go+3 −3internal/edge/static_sweep_other.go+3 −11internal/edge/static_sweep_test.go+4 −3internal/edge/static_sweep_unix.go+53 −61internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1internal/provision/testdata/plan14-root-reads-static-sweep-periodic.tsv+9 −16
CI passed — run details
diff --git a/docs/superpowers/notes/census-proposal-static-sweep-periodic.md b/docs/superpowers/notes/census-proposal-static-sweep-periodic.md| index aedade698..140dfd410 100644 |
| --- a/docs/superpowers/notes/census-proposal-static-sweep-periodic.md |
| +++ b/docs/superpowers/notes/census-proposal-static-sweep-periodic.md |
| @@ -1,38 +1,30 @@ |
| # Census approval: static-sweep-periodic |
| -Ruling `census-ruling-static-sweep-periodic`. The independent reviewer approves or rejects every change below, 6 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| +Ruling `census-ruling-static-sweep-periodic`. The independent reviewer approves or rejects every change below, 2 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| | unit | change | read sites | what changed | |
| |---|---|---|---| |
| | `internal/edge/edge.go` `Edge.staticHandlerFor` | body | unchanged (3) | hands each static handler the process staticTrees record (ss.trees) and registers it there (weak pointer); in-memory wiring only, no read added; read sites unchanged (3) | |
| +| `internal/edge/static_sweep_unix.go` `setAside` | body | unchanged (5) | same walk of <cacheDir>/<acct>/<app> with valid account and app names, same current-link read, lstat and recognised names (release trees, .extract-, .sweep- debris; never files, links, bare or unknown names); now under the process tracker mutex per app dir, skipping a dir a handler is choosing a tree in, and keeping the previous tree (newest other by mtime), trees live handlers serve and trees requests hold, besides current; run at startup (exclusive flock) and by a running sweep (exclusive record lock); the agent, not root | |
| +| `internal/edge/static_sweep_unix.go` `sweepStaticCache` | body | unchanged (2) | same startup flock protocol on <cacheDir>/.edge.lock (the same two OpenFile calls); now also takes a shared OFD record lock on byte 0 of that file before the startup check, returns the process staticTrees record (lock, periodic flag) and measures the kept trees after the startup removal; a running edge sweeps later through the same setAside under an exclusive record lock; the agent (carlos-edge.service, user carlos), not root; its own static cache only | |
| | `internal/host/agent.go` `runAgent` | body | unchanged (9) | 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) | |
| Envelopes re-pinned: `internal/edge`, `internal/host`. |
| -Removed units: the scan finds neither the declaration nor any of its sites. |
| - |
| -| unit | recorded disposition | basis | what changed | |
| -|---|---|---|---| |
| -| `internal/edge/static_sweep_unix.go` `setAside` | legacy, task accepted-legacy | accepted-legacy;rev3=census-ruling-static-sweep;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=root-input; once at startup, before any static handler exists, only under an exclusive flock (sweepStaticCache), reads its own static cache (<cacheDir>/<acct>/<app> with valid account and app names: entries, each current link, each entry lstat) and renames each release tree (<version>@<64-hex digest>) the current link does not name to a .sweep- name for removal, with its own debris (.extract-<n>, .sweep-<name>-<n>); never touches files, links, bare names, or names it does not recognise; every tree is a cache of a signed release that ensureExtracted re-verifies before extracting it again; no root decision | deleted | |
| - |
| 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. |
| -A removed unit's recorded disposition and basis are in its table above. For a removed unit or a retired envelope, confirm from the diff that the code is deleted and not moved: a read that moved shows on this card as a change to the unit that took it, and a unit moved whole shows as a new unit, a decision. Reject if a check, refusal or validation that root relies on goes with the deleted code and its callers' changes on this card do not account for that. |
| - |
| Recorded dispositions, which each change must still satisfy: |
| - `internal/edge/edge.go` `Edge.staticHandlerFor`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-devbox-mode;basis=devbox mode (#474): when WithLocalStatic set localStaticRoot (only edge.ServeDevbox sets it, run by carlos devbox serve as the unprivileged carlos-devbox user), a static route is handed to newLocalStaticHandler instead of the release store. Reads the same Route (its App) as before; with the root unset the store path is byte-for-byte unchanged. No new read |
| +- `internal/edge/static_sweep_unix.go` `setAside`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-static-sweep;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=root-input; once at startup, before any static handler exists, only under an exclusive flock (sweepStaticCache), reads its own static cache (<cacheDir>/<acct>/<app> with valid account and app names: entries, each current link, each entry lstat) and renames each release tree (<version>@<64-hex digest>) the current link does not name to a .sweep- name for removal, with its own debris (.extract-<n>, .sweep-<name>-<n>); never touches files, links, bare names, or names it does not recognise; every tree is a cache of a signed release that ensureExtracted re-verifies before extracting it again; no root decision |
| +- `internal/edge/static_sweep_unix.go` `sweepStaticCache`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-static-sweep;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=root-input; opens or creates <cacheDir>/.edge.lock and flocks it: a start that creates it sweeps nothing (an older edge may not lock; systemd stops an edge before it starts the next, Paul 2026-10-25), otherwise exclusive non-blocking to sweep, then shared for the process life; a lock it cannot hold is an ALERT and the edge still serves (Paul 2026-10-25); the lock decides only whether this start sweeps; no root decision |
| - `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. |
| New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff: |
| -- new `internal/edge/static_sweep_unix.go:openStaticTrees`: reads +file:OpenFile ×2; written legacy, accepted-legacy, frozen |
| -- new `internal/edge/static_sweep_unix.go:staticTrees.setAside`: reads +file:ReadDir ×2; written legacy, accepted-legacy, frozen |
| -- new `internal/edge/static_sweep_unix.go:staticTrees.setAsideAppLocked`: reads +file:Lstat, +file:ReadDir, +file:Readlink; written legacy, accepted-legacy, frozen |
| - new `internal/edge/static_trees.go:staticTrees.measure`: reads +file:ReadDir ×3; written legacy, accepted-legacy, frozen |
| - new `internal/edge/static_trees.go:treeBytes`: reads +file:WalkDir; written legacy, accepted-legacy, frozen |
| -- quiet `internal/edge/static_sweep_unix.go:sweepStaticCache`: reads nothing now; retired while it reads nothing (or its row keeps no sites) |
| -Seal: `9cdff432a5de2ffeaa147fdafd6a486c61c27a0c38f77466bddc86b149332c7d` → `7451abb5daf49fbb51041990de5cb66b51e521746a533a245d3e2cad12e40d14`. |
| +Seal: `9cdff432a5de2ffeaa147fdafd6a486c61c27a0c38f77466bddc86b149332c7d` → `8e1a93b3bf26af6f30d9d74298ac9d5fa7bb3e4ec8cba882bf0b8aafcb437ec7`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-static-sweep-periodic.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/edge/edge.go b/internal/edge/edge.go| index 218b7d576..c19a3bda5 100644 |
| --- a/internal/edge/edge.go |
| +++ b/internal/edge/edge.go |
| @@ -627,7 +627,7 @@ func (e *Edge) EnableStatic(store release.Store, pub ed25519.PublicKey, cacheDir |
| // the only edge using the cache (static_sweep_unix.go). The lock is |
| // held, shared, for the process's life. |
| if cacheDir != "" && e.staticTrees == nil { |
| - e.staticTrees, _ = openStaticTrees(cacheDir) |
| + e.staticTrees, _ = sweepStaticCache(cacheDir) |
| e.staticLock = e.staticTrees.lock |
| // Then again after every swap and every hour, for the process's life. |
| go e.staticTrees.run(staticSweepEvery, staticSweepSettle) |
diff --git a/internal/edge/static_periodic_sweep_test.go b/internal/edge/static_periodic_sweep_test.go| index 440942c22..76a573859 100644 |
| --- a/internal/edge/static_periodic_sweep_test.go |
| +++ b/internal/edge/static_periodic_sweep_test.go |
| @@ -26,7 +26,7 @@ import ( |
| func openTrees(t *testing.T, cache string) *staticTrees { |
| t.Helper() |
| seenLock(t, cache) |
| - tr, done := openStaticTrees(cache) |
| + tr, done := sweepStaticCache(cache) |
| <-done |
| if tr.lock == nil { |
| t.Fatal("no serving lock") |
| @@ -98,7 +98,7 @@ func TestStaticPeriodicSweepSkipsWhileAnotherEdgeServesAndKeepsItsLocks(t *testi |
| cacheTree(t, cache, "bab", "apt", tree(v)) |
| } |
| pointAt(t, cache, "bab", "apt", tree("v3")) |
| - other, done := openStaticTrees(cache) |
| + other, done := sweepStaticCache(cache) |
| <-done |
| if other.periodic { |
| t.Fatal("an edge that started beside another may sweep while running") |
| @@ -178,7 +178,7 @@ func TestStaticPeriodicSweepPreviousIsChosenFromEveryTree(t *testing.T) { |
| // lock, for the whole of its life: it never sweeps, at start or later. |
| func TestStaticPeriodicSweepNeverOnTheFirstLockAwareStart(t *testing.T) { |
| cache := t.TempDir() |
| - tr, done := openStaticTrees(cache) |
| + tr, done := sweepStaticCache(cache) |
| <-done |
| defer tr.lock.Close() |
| for _, v := range []string{"v1", "v2", "v3"} { |
diff --git a/internal/edge/static_sweep_other.go b/internal/edge/static_sweep_other.go| index 62860fb41..71c3fcc81 100644 |
| --- a/internal/edge/static_sweep_other.go |
| +++ b/internal/edge/static_sweep_other.go |
| @@ -2,18 +2,10 @@ |
| package edge |
| -import "os" |
| - |
| -// sweepStaticCache needs flock to know no other edge serves the cache; with |
| -// none here, nothing is swept (static_sweep_unix.go). |
| -func sweepStaticCache(cacheDir string) (*os.File, <-chan struct{}) { |
| - t, done := openStaticTrees(cacheDir) |
| - return t.lock, done |
| -} |
| - |
| -// openStaticTrees holds no lock and sweeps nothing here; it still measures |
| +// sweepStaticCache holds no lock and sweeps nothing here: it needs flock to |
| +// know no other edge serves the cache (static_sweep_unix.go); it still measures |
| // the trees for the disk alert. |
| -func openStaticTrees(cacheDir string) (*staticTrees, <-chan struct{}) { |
| +func sweepStaticCache(cacheDir string) (*staticTrees, <-chan struct{}) { |
| t := newStaticTrees(cacheDir) |
| done := make(chan struct{}) |
| go func() { defer close(done); t.measure() }() |
diff --git a/internal/edge/static_sweep_test.go b/internal/edge/static_sweep_test.go| index 7a98ac8bc..cf4a7230e 100644 |
| --- a/internal/edge/static_sweep_test.go |
| +++ b/internal/edge/static_sweep_test.go |
| @@ -70,7 +70,8 @@ func entries(t *testing.T, dir string) []string { |
| func sweep(t *testing.T, cache string) { |
| t.Helper() |
| - lock, done := sweepStaticCache(cache) |
| + tr, done := sweepStaticCache(cache) |
| + lock := tr.lock |
| if lock == nil { |
| t.Fatal("no serving lock") |
| } |
| @@ -136,8 +137,8 @@ func TestStaticStartupSweepNeverTakesAReleaseForDebris(t *testing.T) { |
| cacheTree(t, cache, "bab", "b", tree("v2")) |
| pointAt(t, cache, "bab", "b", tree("v2")) |
| - lock, done := sweepStaticCache(cache) |
| - defer lock.Close() |
| + tr, done := sweepStaticCache(cache) |
| + defer tr.lock.Close() |
| // Before the background removal ends, the non-current release is |
| // already gone from its own name: nothing can select it. |
| if _, err := os.Stat(filepath.Join(cache, "bab", "b", tree(".extract-9"))); !os.IsNotExist(err) { |
diff --git a/internal/edge/static_sweep_unix.go b/internal/edge/static_sweep_unix.go| index 9114ec71c..5a4f59e32 100644 |
| --- a/internal/edge/static_sweep_unix.go |
| +++ b/internal/edge/static_sweep_unix.go |
| @@ -84,20 +84,14 @@ func classifyStaticEntry(name string) staticEntry { |
| return entryUnknown |
| } |
| -// sweepStaticCache is openStaticTrees for callers that want only the lock. |
| -func sweepStaticCache(cacheDir string) (*os.File, <-chan struct{}) { |
| - t, done := openStaticTrees(cacheDir) |
| - return t.lock, done |
| -} |
| - |
| -// openStaticTrees takes this process's lock on cacheDir, sweeps it if no |
| +// sweepStaticCache takes this process's lock on cacheDir, sweeps it if no |
| // other edge can be using it, and returns the process's staticTrees (its |
| // lock held shared until the process exits, nil when none could be held) |
| // and a channel closed once the startup removal is done and the trees left |
| // are measured. A lock it cannot hold is an ALERT, not a refusal to serve: |
| // static sites stay up, and the only exposure is a second edge starting |
| // beside this one while it serves. |
| -func openStaticTrees(cacheDir string) (*staticTrees, <-chan struct{}) { |
| +func sweepStaticCache(cacheDir string) (*staticTrees, <-chan struct{}) { |
| t := newStaticTrees(cacheDir) |
| done := make(chan struct{}) |
| fail := func(f *os.File, err error) (*staticTrees, <-chan struct{}) { |
| @@ -146,7 +140,7 @@ func openStaticTrees(cacheDir string) (*staticTrees, <-chan struct{}) { |
| return measured() |
| } |
| t.periodic = recorded |
| - doomed := t.setAside() |
| + doomed := setAside(t) |
| if err := reshare(fd); err != nil { |
| return fail(lock, err) |
| } |
| @@ -196,7 +190,7 @@ func (t *staticTrees) sweepCache() int { |
| log.Printf("edge: static cache %s: another edge process serves from it; not swept (%v)", t.cacheDir, err) |
| return 0 |
| } |
| - doomed := t.setAside() |
| + doomed := setAside(t) |
| if err := recordLock(t.lock, true, false); err != nil { |
| log.Printf("ALERT: edge: static cache %s: record lock not made shared again (%v): no other edge can start a sweep check until this one exits", t.cacheDir, err) |
| } |
| @@ -205,79 +199,77 @@ func (t *staticTrees) sweepCache() int { |
| // setAside renames, in every <acct>/<app> directory, each release tree the |
| // sweep does not keep to a .sweep- name, and returns those paths and the |
| -// edge's debris for removal. It holds mu for each app directory, so no |
| +// edge's debris for removal. It holds t.mu for each app directory, so no |
| // handler can begin choosing a tree there meanwhile, and skips a directory |
| // a handler is already choosing in. It touches nothing it does not |
| // recognise. |
| -func (t *staticTrees) setAside() []string { |
| +func setAside(t *staticTrees) []string { |
| var doomed []string |
| accts, err := os.ReadDir(t.cacheDir) |
| if err != nil { |
| return nil |
| } |
| stamp := time.Now().UnixNano() |
| - for _, a := range accts { |
| - if !a.IsDir() || !release.ValidAccount(a.Name()) { |
| - continue |
| + app := func(appDir string) []string { |
| + t.mu.Lock() |
| + defer t.mu.Unlock() |
| + keep, busy := t.keepLocked(appDir) |
| + if busy { |
| + return nil |
| } |
| - apps, err := os.ReadDir(filepath.Join(t.cacheDir, a.Name())) |
| + cur, _ := os.Readlink(filepath.Join(appDir, "current")) |
| + names, err := os.ReadDir(appDir) |
| if err != nil { |
| - continue |
| + return nil |
| } |
| - for _, ap := range apps { |
| - if !ap.IsDir() || !release.ValidApp(ap.Name()) { |
| + var trees, doomed []string |
| + var prev string |
| + var prevAt time.Time |
| + for _, n := range names { |
| + name := n.Name() |
| + path := filepath.Join(appDir, name) |
| + fi, err := os.Lstat(path) |
| + if err != nil || !fi.IsDir() || name == cur { |
| continue |
| } |
| - appDir := filepath.Join(t.cacheDir, a.Name(), ap.Name()) |
| - t.mu.Lock() |
| - doomed = append(doomed, t.setAsideAppLocked(appDir, stamp)...) |
| - t.mu.Unlock() |
| - } |
| - } |
| - return doomed |
| -} |
| - |
| -func (t *staticTrees) setAsideAppLocked(appDir string, stamp int64) []string { |
| - keep, busy := t.keepLocked(appDir) |
| - if busy { |
| - return nil |
| - } |
| - cur, _ := os.Readlink(filepath.Join(appDir, "current")) |
| - names, err := os.ReadDir(appDir) |
| - if err != nil { |
| - return nil |
| - } |
| - var trees, doomed []string |
| - var prev string |
| - var prevAt time.Time |
| - for _, n := range names { |
| - name := n.Name() |
| - path := filepath.Join(appDir, name) |
| - fi, err := os.Lstat(path) |
| - if err != nil || !fi.IsDir() || name == cur { |
| - continue |
| + switch classifyStaticEntry(name) { |
| + case entryDebris: |
| + doomed = append(doomed, path) |
| + case entryTree: |
| + trees = append(trees, name) |
| + if prev == "" || fi.ModTime().After(prevAt) { |
| + prev, prevAt = name, fi.ModTime() |
| + } |
| + } |
| } |
| - switch classifyStaticEntry(name) { |
| - case entryDebris: |
| - doomed = append(doomed, path) |
| - case entryTree: |
| - trees = append(trees, name) |
| - if prev == "" || fi.ModTime().After(prevAt) { |
| - prev, prevAt = name, fi.ModTime() |
| + for _, name := range trees { |
| + if name == prev || keep[name] { |
| + continue |
| + } |
| + path := filepath.Join(appDir, name) |
| + to := filepath.Join(appDir, fmt.Sprintf(".sweep-%s-%d", name, stamp)) |
| + if err := os.Rename(path, to); err != nil { |
| + log.Printf("edge: static cache: set aside %s: %v", path, err) |
| + continue |
| } |
| + doomed = append(doomed, to) |
| } |
| + return doomed |
| } |
| - for _, name := range trees { |
| - if name == prev || keep[name] { |
| + for _, a := range accts { |
| + if !a.IsDir() || !release.ValidAccount(a.Name()) { |
| continue |
| } |
| - path := filepath.Join(appDir, name) |
| - to := filepath.Join(appDir, fmt.Sprintf(".sweep-%s-%d", name, stamp)) |
| - if err := os.Rename(path, to); err != nil { |
| - log.Printf("edge: static cache: set aside %s: %v", path, err) |
| + apps, err := os.ReadDir(filepath.Join(t.cacheDir, a.Name())) |
| + if err != nil { |
| continue |
| } |
| - doomed = append(doomed, to) |
| + for _, ap := range apps { |
| + if !ap.IsDir() || !release.ValidApp(ap.Name()) { |
| + continue |
| + } |
| + doomed = append(doomed, app(filepath.Join(t.cacheDir, a.Name(), ap.Name()))...) |
| + } |
| } |
| return doomed |
| } |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index a6b9b93d6..099d1eb06 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -120,4 +120,4 @@ plan14-root-reads-claim-countdown.tsv 5b31785441c6a48ddae93e9f3c0f8962f7983b55d8 |
| plan14-root-reads-region-ha-dr2.tsv 7247af7f4de84593d83c6f60c0147d0a04836146197dd60c2ed2bf78919cad22 |
| plan14-root-reads-dr1-left-link.tsv 160744b3062d0ab9a0cb3c7be3a391ae38cf89ffe410ddd5d179e0c3cb509b66 |
| plan14-root-reads-claim-source.tsv 9cdff432a5de2ffeaa147fdafd6a486c61c27a0c38f77466bddc86b149332c7d |
| -plan14-root-reads-static-sweep-periodic.tsv 7451abb5daf49fbb51041990de5cb66b51e521746a533a245d3e2cad12e40d14 |
| +plan14-root-reads-static-sweep-periodic.tsv 8e1a93b3bf26af6f30d9d74298ac9d5fa7bb3e4ec8cba882bf0b8aafcb437ec7 |
diff --git a/internal/provision/testdata/plan14-root-reads-static-sweep-periodic.tsv b/internal/provision/testdata/plan14-root-reads-static-sweep-periodic.tsv| index 2692a4a27..5d52a6bd0 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-static-sweep-periodic.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-static-sweep-periodic.tsv |
| @@ -1,23 +1,16 @@ |
| # Census overlay static-sweep-periodic, written by census-propose (#369). census-ruling-static-sweep-periodic, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-static-sweep-periodic.md. |
| -# 2 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| -# 1 removed: each unit's declaration, or each envelope's directory, is absent from the scanned tree, so its row goes, a frozen declaration is retired as absent, and an envelope is retired. |
| -# 6 new dispositions: 0 reads re-frozen at their disposition with the claim, 5 new units frozen accepted-legacy, 1 quiet units retired while they read nothing, 0 other. |
| +# 4 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 2 new dispositions: 0 reads re-frozen at their disposition with the claim, 2 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other. |
| @legacy 0d9c034567835848ee11da27eaa6b63532ceeb8a539c352aa210d434e255cade internal/edge/edge.go Edge.staticHandlerFor legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-devbox-mode;basis=devbox mode (#474): when WithLocalStatic set localStaticRoot (only edge.ServeDevbox sets it, run by carlos devbox serve as the unprivileged carlos-devbox user), a static route is handed to newLocalStaticHandler instead of the release store. Reads the same Route (its App) as before; with the root unset the store path is byte-for-byte unchanged. No new read;rev3=census-ruling-static-sweep-periodic;basis=hands each static handler the process staticTrees record (ss.trees) and registers it there (weak pointer); in-memory wiring only, no read added; read sites unchanged (3) registry:App@334,whole:Route@255,whole:Route@524 15d034f2a1a1b0d6c852dc2d95e236c6a1223da02b26e8a28aedac358ba880ad |
| -@legacy a3e86dc47f75a63ef79c88c210bcda6b3cc23bbacdd09a24ee2f6738e94cf192 internal/edge/static_sweep_unix.go openStaticTrees legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep-periodic;basis=was sweepStaticCache: same startup flock protocol on <cacheDir>/.edge.lock (OpenFile O_CREATE|O_EXCL then O_RDWR), plus a shared OFD record lock on byte 0 before the startup check; the agent (carlos-edge.service, user carlos), not root; its own static cache only file:OpenFile@627,file:OpenFile@772 4dbd82fa0b221468c56f3c1ef48b9f114c623b488c899b83783e0f4f89680a04 |
| -@legacy 35384549ddb058d8ea5801f19ebbea354f0fe3052a1fd9d15c96bbd8085c2d14 internal/edge/static_sweep_unix.go staticTrees.setAside legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep-periodic;basis=was setAside: same walk of <cacheDir>/<acct>/<app> with valid account and app names; now under the process tracker mutex per app dir; run at startup (exclusive flock) and by a running sweep (exclusive OFD record lock); the agent, not root file:ReadDir@279,file:ReadDir@80 2985e940319405f7679a10fe28d0feb2736775766203da6644577437f2a0ef29 |
| -@legacy e95f1aee9fa204ae4f810a8609e1cecdf9bf47307feba408032973fae5f19d56 internal/edge/static_sweep_unix.go staticTrees.setAsideAppLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep-periodic;basis=split out of setAside: per app dir reads current link, entries, lstat; keeps current, previous (newest other tree by mtime), trees live handlers serve and pinned trees; renames other <version>@<digest> trees to .sweep- names; same recognised names, never files, links or unknown names; the agent, not root file:Lstat@430,file:ReadDir@214,file:Readlink@153 b8d76a801b96db416626d8ffb96c071792b3509f212127ee0ac786f6f2a02a79 |
| +@legacy 6f88cc678942860fe509aa45f860e26c595fefbaa5c545ae5c288de714b447ab internal/edge/static_sweep_unix.go setAside legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=root-input; once at startup, before any static handler exists, only under an exclusive flock (sweepStaticCache), reads its own static cache (<cacheDir>/<acct>/<app> with valid account and app names: entries, each current link, each entry lstat) and renames each release tree (<version>@<64-hex digest>) the current link does not name to a .sweep- name for removal, with its own debris (.extract-<n>, .sweep-<name>-<n>); never touches files, links, bare names, or names it does not recognise; every tree is a cache of a signed release that ensureExtracted re-verifies before extracting it again; no root decision;rev3=census-ruling-static-sweep-periodic;basis=same walk of <cacheDir>/<acct>/<app> with valid account and app names, same current-link read, lstat and recognised names (release trees, .extract-, .sweep- debris; never files, links, bare or unknown names); now under the process tracker mutex per app dir, skipping a dir a handler is choosing a tree in, and keeping the previous tree (newest other by mtime), trees live handlers serve and trees requests hold, besides current; run at startup (exclusive flock) and by a running sweep (exclusive record lock); the agent, not root file:Lstat@607,file:ReadDir@1429,file:ReadDir@381,file:ReadDir@77,file:Readlink@319 d97bbd3bd80cecbbf742ba69e918dc86b9e8dc2e92ca449f3ed8fd3aa71d43ce |
| +@legacy 959347925e5800cc5da3bc49b372da9ebc437202ae8f3d7c7660f674ea2875f9 internal/edge/static_sweep_unix.go sweepStaticCache legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=root-input; opens or creates <cacheDir>/.edge.lock and flocks it: a start that creates it sweeps nothing (an older edge may not lock; systemd stops an edge before it starts the next, Paul 2026-10-25), otherwise exclusive non-blocking to sweep, then shared for the process life; a lock it cannot hold is an ALERT and the edge still serves (Paul 2026-10-25); the lock decides only whether this start sweeps; no root decision;rev3=census-ruling-static-sweep-periodic;basis=same startup flock protocol on <cacheDir>/.edge.lock (the same two OpenFile calls); now also takes a shared OFD record lock on byte 0 of that file before the startup check, returns the process staticTrees record (lock, periodic flag) and measures the kept trees after the startup removal; a running edge sweeps later through the same setAside under an exclusive record lock; the agent (carlos-edge.service, user carlos), not root; its own static cache only file:OpenFile@628,file:OpenFile@773 267bd955bcf877944008ee845e982639a5142e4ff68b8bc88ec551282b8cf46e |
| @legacy eefa3bd21175177cce68b954a56f77a2e246085086a9f3282a2a5902b49a1d98 internal/edge/static_trees.go staticTrees.measure legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep-periodic;basis=new: lists the agent own static cache (<cacheDir>/<acct>/<app>/<version>@<digest>) to size the kept trees for the disk alert; reads only, removes nothing; the agent, not root file:ReadDir@190,file:ReadDir@379,file:ReadDir@93 a2b1b3094abf48221682fd9f0200c64cc19788beca4c59c03e2fad9504f84175 |
| -@legacy 2d9642c1e6c88aa5ff5e6ca6952074679aaafb6943e1160fc0d27a322a9b05f8 internal/edge/static_trees.go treeBytes legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep-periodic;basis=new: WalkDir of one extracted static tree summing regular-file sizes (no symlink follow) for measure; reads only; the agent, not root file:WalkDir@53 1c1b3cbcc45822d6b0a60e82dcaa222b85cde71e7ad7ffe4b1cfb0e53685b800 |
| +@legacy 3f1fce4b3f378bed81741c94e47eecd3aac3e882a26fedec3d387e3247776caa internal/edge/static_trees.go treeBytes legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep-periodic;basis=new: WalkDir of one extracted static tree summing regular-file sizes (no symlink follow, no file contents) for measure; reads only; the agent, not root file:WalkDir@53 1c1b3cbcc45822d6b0a60e82dcaa222b85cde71e7ad7ffe4b1cfb0e53685b800 |
| internal/edge/edge.go Edge.staticHandlerFor legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-devbox-mode;basis=devbox mode (#474): when WithLocalStatic set localStaticRoot (only edge.ServeDevbox sets it, run by carlos devbox serve as the unprivileged carlos-devbox user), a static route is handed to newLocalStaticHandler instead of the release store. Reads the same Route (its App) as before; with the root unset the store path is byte-for-byte unchanged. No new read;rev3=census-ruling-static-sweep-periodic;basis=hands each static handler the process staticTrees record (ss.trees) and registers it there (weak pointer); in-memory wiring only, no read added; read sites unchanged (3) registry:App@334,whole:Route@255,whole:Route@524 15d034f2a1a1b0d6c852dc2d95e236c6a1223da02b26e8a28aedac358ba880ad |
| +internal/edge/static_sweep_unix.go setAside legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=root-input; once at startup, before any static handler exists, only under an exclusive flock (sweepStaticCache), reads its own static cache (<cacheDir>/<acct>/<app> with valid account and app names: entries, each current link, each entry lstat) and renames each release tree (<version>@<64-hex digest>) the current link does not name to a .sweep- name for removal, with its own debris (.extract-<n>, .sweep-<name>-<n>); never touches files, links, bare names, or names it does not recognise; every tree is a cache of a signed release that ensureExtracted re-verifies before extracting it again; no root decision;rev3=census-ruling-static-sweep-periodic;basis=same walk of <cacheDir>/<acct>/<app> with valid account and app names, same current-link read, lstat and recognised names (release trees, .extract-, .sweep- debris; never files, links, bare or unknown names); now under the process tracker mutex per app dir, skipping a dir a handler is choosing a tree in, and keeping the previous tree (newest other by mtime), trees live handlers serve and trees requests hold, besides current; run at startup (exclusive flock) and by a running sweep (exclusive record lock); the agent, not root file:Lstat@607,file:ReadDir@1429,file:ReadDir@381,file:ReadDir@77,file:Readlink@319 d97bbd3bd80cecbbf742ba69e918dc86b9e8dc2e92ca449f3ed8fd3aa71d43ce |
| +internal/edge/static_sweep_unix.go sweepStaticCache legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=root-input; opens or creates <cacheDir>/.edge.lock and flocks it: a start that creates it sweeps nothing (an older edge may not lock; systemd stops an edge before it starts the next, Paul 2026-10-25), otherwise exclusive non-blocking to sweep, then shared for the process life; a lock it cannot hold is an ALERT and the edge still serves (Paul 2026-10-25); the lock decides only whether this start sweeps; no root decision;rev3=census-ruling-static-sweep-periodic;basis=same startup flock protocol on <cacheDir>/.edge.lock (the same two OpenFile calls); now also takes a shared OFD record lock on byte 0 of that file before the startup check, returns the process staticTrees record (lock, periodic flag) and measures the kept trees after the startup removal; a running edge sweeps later through the same setAside under an exclusive record lock; the agent (carlos-edge.service, user carlos), not root; its own static cache only file:OpenFile@628,file:OpenFile@773 267bd955bcf877944008ee845e982639a5142e4ff68b8bc88ec551282b8cf46e |
| 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-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) file:Exec@19204,file:Open@1707,file:Statfs@50345,registry:App@12803,registry:Host@46381,whole:Route@12795,whole:Route@45539,whole:Route@46504,whole:Route@46566 54ae40577a09277ee38477906988887d2d13ab5a55ede0f33e9b79cc134a9263 |
| -internal/edge/static_sweep_unix.go openStaticTrees legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep-periodic;basis=was sweepStaticCache: same startup flock protocol on <cacheDir>/.edge.lock (OpenFile O_CREATE|O_EXCL then O_RDWR), plus a shared OFD record lock on byte 0 before the startup check; the agent (carlos-edge.service, user carlos), not root; its own static cache only file:OpenFile@627,file:OpenFile@772 4dbd82fa0b221468c56f3c1ef48b9f114c623b488c899b83783e0f4f89680a04 |
| -internal/edge/static_sweep_unix.go staticTrees.setAside legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep-periodic;basis=was setAside: same walk of <cacheDir>/<acct>/<app> with valid account and app names; now under the process tracker mutex per app dir; run at startup (exclusive flock) and by a running sweep (exclusive OFD record lock); the agent, not root file:ReadDir@279,file:ReadDir@80 2985e940319405f7679a10fe28d0feb2736775766203da6644577437f2a0ef29 |
| -internal/edge/static_sweep_unix.go staticTrees.setAsideAppLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep-periodic;basis=split out of setAside: per app dir reads current link, entries, lstat; keeps current, previous (newest other tree by mtime), trees live handlers serve and pinned trees; renames other <version>@<digest> trees to .sweep- names; same recognised names, never files, links or unknown names; the agent, not root file:Lstat@430,file:ReadDir@214,file:Readlink@153 b8d76a801b96db416626d8ffb96c071792b3509f212127ee0ac786f6f2a02a79 |
| internal/edge/static_trees.go staticTrees.measure legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep-periodic;basis=new: lists the agent own static cache (<cacheDir>/<acct>/<app>/<version>@<digest>) to size the kept trees for the disk alert; reads only, removes nothing; the agent, not root file:ReadDir@190,file:ReadDir@379,file:ReadDir@93 a2b1b3094abf48221682fd9f0200c64cc19788beca4c59c03e2fad9504f84175 |
| -internal/edge/static_trees.go treeBytes legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep-periodic;basis=new: WalkDir of one extracted static tree summing regular-file sizes (no symlink follow) for measure; reads only; the agent, not root file:WalkDir@53 1c1b3cbcc45822d6b0a60e82dcaa222b85cde71e7ad7ffe4b1cfb0e53685b800 |
| -@remove internal/edge/static_sweep_unix.go sweepStaticCache |
| -@removed internal/edge/static_sweep_unix.go sweepStaticCache H3 census-ruling-static-sweep-periodic;basis=now a thin wrapper over openStaticTrees returning its lock; reads nothing itself |
| -@remove internal/edge/static_sweep_unix.go setAside |
| -@removed internal/edge/static_sweep_unix.go setAside H3 census-ruling-static-sweep-periodic;absent;basis=deleted: declaration and sites absent from the tree |
| -@coverage internal/edge e148fde7135935d3884c9a1bbc4b83f314c336b9c731679934e08816b46c0671 |
| +internal/edge/static_trees.go treeBytes legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep-periodic;basis=new: WalkDir of one extracted static tree summing regular-file sizes (no symlink follow, no file contents) for measure; reads only; the agent, not root file:WalkDir@53 1c1b3cbcc45822d6b0a60e82dcaa222b85cde71e7ad7ffe4b1cfb0e53685b800 |
| +@coverage internal/edge ab551d932e21e4a46799825b3c6aee46a372c8fa7d69785dd9ed5487d9253e7e |
| @coverage internal/host 99eccc833ed045f41625804c43519a3c14c56adf7446ea91983514f9623742fb |