feat: an overlap to a fleet size reserves its memory first (#892 S2)
An overlap swap whose successor runs at a fleet size reserves the successor's full memory limit against MemAvailable, under one lock per box, after admission and before the parent raise. With no room, or an unreadable /proc/meminfo, nothing is raised or spawned and the attempt is abandoned with PS-2-C05; the old build keeps serving. The token lives on the successor member, is released at once only when nothing was spawned (raise, publication or exec gate refused), moves to the retiring member at the switch, and is otherwise released in leaveSet after a termination proof. Existing sizes take no reservation. Census overlay re-proposed (new unit fleetreserve_linux.go:memAvailable).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/notes/census-proposal-stateless-scale-2-fleet-sizes.md+12 −3internal/activator/activator.go+9 −0internal/activator/fleetreserve.go+165 −0internal/activator/fleetreserve_linux.go+15 −0internal/activator/fleetreserve_other.go+11 −0internal/activator/fleetreserve_test.go+423 −0internal/activator/opset.go+10 −0internal/activator/swap.go+33 −1internal/host/rollout.go+3 −0internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1internal/provision/testdata/plan14-root-reads-stateless-scale-2-fleet-sizes.tsv+13 −3
Intent
<task-notification> <task-id>ae89d2e3af27ba70f</task-id> <tool-use-id>toolu_01Xy3Hoih3iomjb78jaTyAaE</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/29a43d67-87d2-4557-8e9d-9b70d303a90b/tasks/ae89d2e3af27ba70f.output</output-file> <status>completed</status> <summary>Agent "Implement S2 Task 3" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE. Both P1s from Astra's round 1 review are fixed. Not pushed. Commits: b7bc73a2 (Task 3), c6b2afcf (fix round 1). 1. **Create now checks the channel pointers.** For an app with a fleet size created on a fleet, create runs the v0.43.0 floor check on the channels that fleet's boxes follow. It holds the lock that publications also wait on, in the documented order, until the record is written. Applies to all three create paths. - Below-floor pointer: 409 PS-2-C04. Unreadable pointer: 503 `sizeUnreadMsg`. No record is written either way. - An app at xlarge creates as before. 2. **The downgrade check now reads policies strictly.** A bucket policy that is unreadable, fails verification, or has expired refuses the below-floor publication instead of counting as no fleet size. A recorded policy that does not open refuses too. The policy door keeps its operator-repair fallback. Tests: the new tests failed with both fixes reverted and pass with them. The covering runs all pass: the Task 3 and Task 2 fleet-size tests, the publication-floor and create/lifetime suites, and the race tests touched. Cross-compile builds, and `make census-card` is clean, so no re-propose was needed. Concerns: - The host-claim create's later re-take step is outside the lock, the same limit as host-claim placement. - Astra's approval of the `internal/release` census envelope is not yet posted on #280. Report (fix round 1 section appended): /home/paulca/amadan.net/carlos/platform/.claude/worktrees/stateless-scale-1/.superpowers/sdd/2026-11-22-892-s2-fleet-sizes/task-3-report.md</result> <usage><subagent_tokens>289083</subagent_tokens><tool_uses>27</tool_uses><duration_ms>1325938</duration_ms></usage> </task-notification>
<task-notification> <task-id>bgnk0i9o8</task-id> <tool-use-id>toolu_019RayjzrG7a4WGSLe43DTjg</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/29a43d67-87d2-4557-8e9d-9b70d303a90b/tasks/bgnk0i9o8.output</output-file> <status>completed</status> <summary>Background command "WS=/home/paulca/amadan.net/carlos/platform/.claude/worktrees/stateless-scale-1/.superpowers/sdd/2026-11-22-892-s2-fleet-sizes; $WS/astra.sh $WS/astra-task3-r2-brief.md $WS/task-3-rereview-1-astra.md > $WS/astra-task3-r2.log 2>&1" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 17.0 g CO₂e (2,109,272 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on stateless-scale-2-fleet-sizes, 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/superpowers/notes/census-proposal-stateless-scale-2-fleet-sizes.md b/docs/superpowers/notes/census-proposal-stateless-scale-2-fleet-sizes.md| index 8ea88e894..403146fed 100644 |
| --- a/docs/superpowers/notes/census-proposal-stateless-scale-2-fleet-sizes.md |
| +++ b/docs/superpowers/notes/census-proposal-stateless-scale-2-fleet-sizes.md |
| @@ -1,22 +1,30 @@ |
| # Census approval: stateless-scale-2-fleet-sizes |
| -Ruling `census-ruling-stateless-scale-2-fleet-sizes`. The independent reviewer approves or rejects every change below, 1 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| +Ruling `census-ruling-stateless-scale-2-fleet-sizes`. 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/activator/activator.go` `type Service` | body | unchanged (0) | the agent (carlos-edge.service, user carlos), not root: two fields (#892 S2): BoxLabel (string, the rollout's own box label, set by armRollout) and fleetReserve (*fleetReservations, made by New with memAvailable), the box's in-memory overlap reservation for fleet sizes. Declaration only; no read added | |
| +| `internal/activator/opset.go` `Service.leaveSet` | body | unchanged (2) | the agent as carlos (#892 S2): after a member's termination is proven and it leaves the set, the fleet-size overlap reservation it holds (genMember.reserve) is released, in memory, under a.mu. No read added; no root call added; the restore and the proof are unchanged | |
| +| `internal/activator/swap.go` `Service.swapOverlap` | body | unchanged (17) | the agent as carlos (#892 S2): after admission and before the raise, a successor whose tier is a fleet size reserves its full MemoryMax through reserveFleetOverlap (memAvailable reads /proc/meminfo). With no room or an unreadable read the attempt is abandoned with PS-2-C05 before any raise, publication or spawn; the incumbent keeps serving. The token is stored on the member, released at once on a refused raise, a failed publication or a refused exec gate (nothing spawned), and otherwise moves to the retiring member at the switch. Adds a refusal only; the raise still goes to root's /parent unchanged; no root decision here. Read sites unchanged (17) | |
| | `internal/cgroup/cgroup.go` `setup` | body | unchanged (1) | the agent (carlos-edge.service, user carlos), not root: setup now also records a fleet-size gate on the agent's own Manager when CARLOS_FLEET is set in its environment (os.Getenv, beside the existing CARLOS_IMDS_FLAT_FENCE read). The gate's MemTotal closure reads /proc/meminfo through ReadMemTotal when a strict prepare is asked for a fleet size (#892 S2). It only lets the strict validators (PrepareStrict, PrepareGen, SetParentLimit) accept the new fleet rows within FleetMemoryBudget; without CARLOS_FLEET they take small..xlarge and today's parents exactly as before. Reads added: env CARLOS_FLEET; /proc/meminfo (kernel, fixed path) via the closure | |
| +| `internal/host/rollout.go` `armRollout` | body | unchanged (5) | the agent as carlos (#892 S2): also sets svc.BoxLabel = rolloutBox(svc), the label the scheduler already uses, for the PS-2-C05 refusal text. No read added | |
| | `internal/instancectl/gen.go` `Server.handleParent` | body | unchanged (1) | root: after the unchanged ValidParentLimit check, a parent outside today's shared set (one or two of small..xlarge) must also pass Server.Fleet.ParentAllowed: CARLOS_FLEET in root's host.env, not a gVisor box, readable MemTotal, and the whole overlap within max(0, MemTotal - max(1 GiB, MemTotal/8)), else 400 before any write. Today's parent set is accepted unchanged on every box. Same one site (r.URL.Query of the agent's request); no read added in this body (MemTotal is read by hostMemTotal through the gate) | |
| | `internal/instancectl/server.go` `runWithClaim` | body | unchanged (6) | root: the production Server literal gains Fleet: productionFleetGate(os.Getenv), which is Fleet = CARLOS_FLEET set in carlos-instance-control.service's environment (EnvironmentFile /etc/carlos/host.env, root-owned, the same way EdgeFenceOff reads CARLOS_EDGE_FENCE) and MemTotal = hostMemTotal (/proc/meminfo through cgroup.ReadMemTotal, read only when a fleet size is asked for). Reads added: env CARLOS_FLEET; /proc/meminfo (kernel, fixed path, via the gate) | |
| | `internal/instancectl/server.go` `type Server` | body | unchanged (1) | root: new field Fleet cgroup.FleetGate (#892 S2), root's fleet-size gate; field declaration only; no read added | |
| | `internal/instancectl/size.go` `Server.handleSize` | body | unchanged (1) | root: after the unchanged SizeByName check, the named row must pass Server.Fleet.GenAllowed (a shared size always; a fleet size only on a CARLOS_FLEET box, not gVisor, within the MemTotal budget), else 400 before any systemctl call. Same one site; no read added in this body | |
| -Envelopes re-pinned: `internal/apppolicy`, `internal/cgroup`, `internal/host`, `internal/instancectl`, `internal/release`. |
| +Envelopes re-pinned: `internal/activator`, `internal/apppolicy`, `internal/cgroup`, `internal/host`, `internal/instancectl`, `internal/release`. |
| Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| Recorded dispositions, which each change must still satisfy: |
| +- `internal/activator/activator.go` `type Service`: authority, task B,C,D,F,J4. Basis: rev3=PROPOSED-seed; existing activator lifecycle and due-wake state plus owned seed exclusion and incarnation-keyed diagnostics; normal refusal and preparation ordering remain authoritative; PROPOSED-plans-2-box-limits adds the idleFor hook field, which only narrows idle windows;rev3=census-ruling-plans-4c-box-throttle;basis=gains the maxRunFor hook field beside idleFor (plans 4c). No read added.;rev3=census-ruling-plans-4d-lapse;basis=gains the disabledFor hook field beside maxRunFor (plans 4d). No read added.;rev3=census-ruling-remote-instance-metrics;basis=gains tenancySeq, hostTenants and hostMixed, in-memory fields for Tenancies; no read added;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: one more field, markers (markerRetry: an atomic running flag and the last log time) for retryOwedMarkers; no read added; merge of origin/main d7ae1d76: main's fields are kept as main has them (census-ruling-remote-instance-metrics: tenancySeq, hostTenants, hostMixed); this branch's change is the same as above;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 7 and 8: new fields for rootfs admission (rootfsArmed, rootfsSwept), the per-host gate ask and refusal memo, and residency state (lister, backoff, start ceiling, cursor, test seam); no read;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: one new field, releaseOps (host to the in-memory release record, under a.mu); no read;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W: one new field, leaseNow (a clock seam for a worker start's headroom against the lease deadline, nil is the real clock); no read;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2: gains the holder cache and its single-flight state; no read;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (controller ruling after branch review R1, and Paul's R2 ruling): one field, Fleet (activator.FleetWake: the box's fleet state, not on a fleet by default, on a fleet with a known label and a record reader, or on a fleet with an invalid identity), set by the agent before Start and read only by routeCurrentUnderLease. No read in the declaration. Agent, not root.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a fix round 1: one field, drainBudget (time.Duration), which New copies from residentDrainBudget and a rootfs entry's lease watch reads in its place, so a test's change of the package var never races a watch goroutine; declaration only, reads nothing; merge of origin/main 6f1f6ca6: main's one field, Fleet (activator.FleetWake), is kept as main has it (census-ruling-managed-fleets-1b); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b3a;basis=Add bounded placement peer and diagnostic state and the over-capacity callback; no read in this declaration and no new root authority.;rev3=census-ruling-stateless-replicas-1;basis=Add coordinator, existing-record observation callback and per-host preparation locks; no read in the declaration. Task 3a: Add optional canonical storage-selection and durable deploy-ID callbacks; declaration only, no read or authority in these fields.;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): adds the heldLegs map to actEntry (legs by id, under a.mu) and heldWakeHook (atomic pointer to a callback) and heldLegSeq (atomic counter) to Service. State only, in memory; no read of tenant, app or box-agent-writable input.;rev3=census-ruling-wake-storm-cap;basis=the agent as carlos: one field, wakeSlots (chan struct{}, the wake semaphore made by New from Config.WakeSlots, default 4); declaration only, no read.;rev3=census-ruling-region-ha-p1b3b-t;basis=Add the B2 DutyStore interface field and process-local duty view, suppression and invalidation state. No read added. B2 adds the verified-successor identity callback; no read in the declaration. B3b adds a nonblocking departure-suspicion callback, invoked only after an accepted holder-forward failure and after cache locks release; it cannot authorize a take.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: immutable callbacks installed before Start for tenant admission, local start permission, fixed route exemptions and shutdown closure; nil callbacks preserve switch-off behavior; no new reads. Fix R1: add an immutable startup-phase callback for response copy, set before service startup. No new read or execution authority.;rev3=census-ruling-region-ha-g2-fixes;basis=Add in-memory HA loss state and pool withdrawal jobs; no new read.;rev3=census-ruling-region-ha-held-build;basis=region HA held-requests Task 1: one new field, drain (drainSources: two atomic func pointers for this box's and peers' drain state); no read added. region HA held-requests Task 2: one new field, moves (moveTable: per-host move state, hold counts and admission tickets in memory, under mu); no read added;rev3=census-ruling-held-move-speed;basis=the agent as carlos: one new field, moveStreams (per-host in-memory set of edge.StreamEnd for requests in flight, own mutex), for the move's early stream cut; actEntry gains drainRelease (bool, under a.mu), set by DrainStop; declarations only, no read added;rev3=census-ruling-fix-silent-start-kill-861;basis=#861: two fields, wakeFailMu and wakeFailLogged (per-host in-memory note of the last journalled wake failure); declaration only, no read;rev3=census-ruling-w6-ingress-drain;basis=new field TenantStartsClosed func() bool; when it answers true tenantStartRefusal refuses every start, exempt routes included. Wired only by fixedAdmission.bind to the ingress drain's closed flag. Struct field only; no read added.;rev3=census-ruling-stateless-replicas-4-task2;basis=Task 2: one field, replicaPolicies (host to the newest observed replica deploy and this box label, under mu), set only by SetReplicaDeploy; declaration only, no read.;rev3=census-ruling-stateless-replicas-4-task2-fix1;basis=Task 2 fix round 1: one more in-memory field, replicaFailed (host to the permit whose successor failed here, under mu), so that step only proves what it kept; declaration only, no read.;rev3=census-ruling-stateless-replicas-4-task3f;basis=Task 3F fix round 3 (#511 F11): two hook fields, MarkReplicaRelease and ReplicaReleaseMark (the failure book's per-host release mark on this box's disk). No read site.;rev3=census-ruling-stateless-replicas-4-task5;basis=Task 5 first commit (#511 F11): one in-memory field, heldSeen (host to the last held release attempt, error class and when it was met), under the existing wakeFailMu. Declaration only, no read.;rev3=census-ruling-stateless-replicas-4-merge-main;basis=Merge of main 5fac2ff1: both sides changed it. Main (27d3f501) adds the background atomic.Int64 field that tests wait on; this branch keeps its replica fields. Both kept as-is; no read added.;rev3=census-ruling-stateless-replicas-4-final;basis=#511 final wave item 3: adds replicaSwitched, an in-memory map of the permit each set row switched under (host -> permit key, time, resident flag); no read added; #511 micro-fix P1b: adds replicaNoGen, an in-memory map (host -> permit key and when first seen) that is only the bound's clock for a restarted permit holder with no generation; no read added;rev3=census-ruling-stateless-replicas-4-drill1;basis=#511 drill 1 R20 bound (round 1: clock with start and last seen): one in-memory field, releaseConfigWaits (per host, a stateless release's config wait), under mu; no read;rev3=census-ruling-stateless-replicas-4-r28;basis=R28 review round 2 (#511): one field, retiringCopy, an atomic pointer to the edge's in-memory retired-copy check, handed over by edge.New (SetRetiringCopy); no read, no root decision;rev3=census-ruling-g6-fence;basis=G6 F-C Task 3, the agent as carlos: four fields, fenceWatchers (sync.WaitGroup of running write-fence watchers) and three test seams nil in production (fenceWatchStarted, retainDB, wakeReturned). Declaration only, no read.;rev3=census-ruling-fleet-record-labels-m1;basis=fleet record labels R1/R2: actEntry gains checkpoint state (busy while CloseProven runs, unproven, named-once flag for C45), in-memory under a.mu; the worker gains fence pacing apart from crash backoff; Service gains test seams nil in production; declarations only, no read;rev3=census-ruling-race-activator-1249;basis=adds two test-only fields: leaseWork (a WaitGroup counting lease watches and the one-shot stops a short lease starts) and leaseWatchStop (a channel, nil in production, that a test closes to end every lease watch); no read added and production never waits on or closes either;rev3=census-ruling-fleet-restart-wake;basis=Fleet restart wake Task 1: the per-host journal note maps (wakeFailLogged, heldSeen) move into the embedded wakeNotes struct in wakefaillog.go, which adds fenceSeen. In-memory only; no read added. |
| +- `internal/activator/opset.go` `Service.leaveSet`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route |
| +- `internal/activator/swap.go` `Service.swapOverlap`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-carlos-run;basis=Re-digested at the pre-land merge: the body includes main's own change under census ruling zddr4, with no further change from this branch. the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body; admission and the switch refuse while a run's unit is starting, and the switch interrupts runs on the retiring generation; read sites unchanged, offsets moved;rev3=census-ruling-instance-egress-sizes-328-329;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=#329 plan 3 Task 4 and the final review: the new kind is registry:Size, one site, rt.Size != "" in the successor's max rule (the successor starts at the larger of its own sized tier and the incumbent's captured tier when the route has a size now or the incumbent runs at a tier other than its build's), and two more whole:Route sites: the successor's route is now sizedRouteLocked(e) with the wake route kept beside it as wakeRt for the incumbent's tier, and a second GenTier(rt, incumbent.Build) in that rule. The column comes from the agent's registry row (reconcile, from the signed app policy). Admission also refuses while a live size change is in flight. The raise still goes to root's /parent, whose memory_max root checks against its size table; no root decision here;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 N1, Task 8 and Task D: the incumbent's tier is recorded through recordCurrentTierLocked; genHealthy takes rt (so a rootfs generation is checked within the rootfs bound); the successor is installed through installProcLocked; after step 8 a rootfs build's declared processes are logged, never started (rootfsProcessesHook); no new file read;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R, R2: two new parameters from releaseBeforeSwap (pass, the proven pass, and due, whether the build needed a release); the admission and the exec gate both also ask releaseAdmitsSwapLocked, which refuses while any release record of the host is open (INV-R4) and, when a release was due, unless pass is this attempt's for the successor's build (INV-R5); no release runs here; the same 18 read sites, no read added; adds refusals only;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W2: step 8 no longer calls rootfsProcessesHook(ctx, e, rt, m.gen); it calls handOverRootfsWorkers(e), which stops and proves the retiring generation's workers gone and then registers the switched generation's set as pending (starts nothing; the tick starts them, and the stray rule refuses a start while an old worker is a stray, so two sets never run at once); site -whole:Route (rt no longer handed to the hook); no read added;rev3=census-ruling-edge-page-cache-1;basis=noteCurrent(e) instead of noteCurrent(e.host, m.gen.N) at the switch, as Service.wake; read sites unchanged (17); no read added |
| - `internal/cgroup/cgroup.go` `setup`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-hunt-account-root-hardening;basis=setup records whether the flat IMDS fence is armed (CARLOS_IMDS_FLAT_FENCE); when armed, a flat start whose shim or placement is unavailable is refused instead of falling back to start-and-move; no read is added |
| +- `internal/host/rollout.go` `armRollout`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=fix1-merge-review;basis=Comment-only clarification of failure-book saves; existing agent rollout setup remains legacy.;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: after the overlap scheduler arms, calls svc.ArmRootfs() so rootfs rows start only where the scheduler armed this boot; never on the refuseManaged path; no read added;rev3=census-ruling-stateless-replicas-1;basis=Task 3a: Bind Service.ReplicaDeployID to the same FailureBook the scheduler owns and bind RuntimeSelection to one CanonicalStatelessDigest read through the existing store. Fix 3a round 1 R18: canonical selection receives route stateless projection to keep legacy DemandHold fallback only for stateful/unknown builds; staged digest mismatch still refuses.;rev3=census-ruling-stateless-replicas-4-task2-fix1;basis=Task 2 fix round 1: the scheduler box label is rolloutBox(svc): the fleet identity label already on svc.Fleet (set from identity.Label before the scheduler arms), else BoxLabel() as before. No read added.;rev3=census-ruling-stateless-replicas-4-task3f;basis=Task 3F fix round 3 (#511 F11): also hands the failure book's MarkReplicaRelease and ReplicaReleaseMark to the activator, beside ReplicaDeployID. The book is the same file the agent already opened; no new read. |
| - `internal/instancectl/gen.go` `Server.handleParent`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J2,J4;basis=root-input;rev3=census-ruling-instance-egress-sizes-328-329;basis=#329 plan 3 Task 5: holds the host's slice lock (lockSliceWrites) around its one set-property, so /parent and /size never interleave on one slice. Its one site is still r.URL.Query() of the agent's request (counted as file:Query). The checks in this body are unchanged, though cgroup.ValidParentLimit, which it calls, now accepts one size or the sum of any two from the four-row table (up to 4 GiB, was 2 GiB); no read added.;rev3=census-ruling-agent-start-demo-1;basis=Reads fixed DemoBox and clamps the existing parent memory writer to small.;rev3=census-ruling-gvisor-demos;basis=Validate logical parent input as before, require the demo route in gVisor mode and apply Physical once to the small demo parent. Existing request query read unchanged; shares stay logical. |
| - `internal/instancectl/server.go` `runWithClaim`: authority, task C,D,G. Basis: Claim instance controller adds held-release RPC dispatch within existing launch/participation execution boundary.;rev3=census-ruling-rootfs-apps-2;basis=takes a RegistryView (HostApp and HostRuntime) for the bare hostApp, and the production Server literal gains HostRuntime, ProbeImage: BuildProbeImage, ProbeImageFile: ProbeImagePath, RootfsProbeOut under /run/carlos-control and DenyEvery: 10s; this body reads nothing new itself; the readers it wires (instanceRegistryHostRuntime, BuildProbeImage, the rootfs probe's output) are decision rows;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 4 and #329 plan 3 Task 5: takes the egress asserter as a parameter, sets it on the production Server literal (Egress) and starts its 30 s Loop beside probeLoop and diskLoop; the literal also names the fixture check ProbeFixturesOK (renamed in plan 2 Task 14). It sets no control drop-in directory: plan 3's ControlDropInDir default (/run/systemd/system.control) was deleted with removeGenControlDropIn in ef38e13b (the P1 EROFS fix), so instance control names systemd's control directory only to read it (TrustedDropinReader). The same four sites (the two exec.CommandContext closures, statfsBytes, the data literal), offsets moved; no read added.;rev3=census-ruling-agent-start-demo-1;basis=Wires root-owned demo config and existing fixed paths into the service.;rev3=census-ruling-region-ha-p3b;basis=Resume root-owned hairpin state before probes/control service work; verify current systemd agent identity and kernel fence/addresses, restore pidfd watch or revoke stale state. Same direct exec/statfs/data sites; indirect inputs are protected root snapshot/state and kernel evidence, never receipt data.;rev3=census-ruling-agent-start-demo-3;basis=Construct the demo snapshot supervisor for configured demo boxes; startup cleanup gates builder readiness. Census read-site delta: unchanged (4).;rev3=census-ruling-gvisor-demos;basis=Retain sandbox modes and error; bind host-provided baseline and runtime callbacks without importing host templates. Existing reads unchanged. Task 6: Capture HostClaims once from ControlConfig/hostwrite.Enabled and set the fixed root-owned bundle discovery directory. Existing command and configuration reads unchanged. Task 7: enable gVisor worker construction through fixed unitFamily(roleBuild); readiness proof rechecks sandbox admission and current Ready without reaching the constructor fatal path for transient refusals. Existing command/config reads unchanged. Final R1 P2: wire the fixed /var/lib/carlos/oci-rootfs parent for native readiness evidence; no request-supplied path. Carry the root-only host.env validation callback into Ready; no agent read or caller-selected path.;rev3=census-ruling-same-box-edge-fence;basis=Root. Sets NFT: edgefence.Exec (runs /usr/sbin/nft from PATH with fixed arguments and root-derived stdin, see the envelope) and EdgeFenceOff from os.Getenv; wraps s.Systemctl with guardStarts and calls bindEgressFence; calls denyLocalAddrs once before Serve so a leftover runtime exemption is checked or replaced by the whole deny before any request is served. No new file read; the exec is nft's.;rev3=census-ruling-bounded-systemctl;basis=the production Systemctl closure runs through internal/systemd.Command (same args, combined output, caller ctx; mutations no deadline of their own, queries also QueryTimeout); the new Journal closure runs journalctl through internal/systemd.Command(Journalctl) for the gVisor probe diagnostic only, with the arguments that closure used to pass to Run; no new read, path or input |
| - `internal/instancectl/server.go` `type Server`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-carlos-run;basis=Re-digested at the pre-land merge: the body includes main's own change under census ruling 292, with no further change from this branch. Census ruling 292 reclassified this declaration accepted-legacy (J2,J4) for root's per-host ordering of legacy run starts against stops; this ruling kept the row as main classed it. Its own addition is the cmd start's poll and wait bounds and its per-host lock map: field declarations only;rev3=census-ruling-rootfs-apps-2;basis=new fields: HostRuntime, ProbeImage, ProbeImageFile, RootfsProbeOut, DenyEvery, the deny's lastDeny and denyMu, the rootfs probe's report and lock, the jit reload counters and imageDigests; genStarting counts binary generation starts per unit; rootfsLocksMu and rootfsLocks, one lock entry per rootfs unit name being started or removed right now, held by a start from its layout through systemctl start and its own cleanup and by a removal from its proof through the raw removal, a removal refusing while it is taken, a waiting start giving up when its request ends, an entry dropped with its last holder or waiter (fixes E6, L2, L3); rootfsProvenHook, a test hook run between the proof and the raw removal; field declarations only; no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 and #329 plan 3 Task 5: the declaration gains sliceLocks (one mutex per host slice, taken by /size and /parent) and Egress (the asserter every start path calls), and its comment names the egress allow (plan 3's ControlDropInDir field was deleted in ef38e13b, the P1 EROFS fix); the same one site, the Statfs field, offset moved; no read added.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 6: comments only: the one-shot pacing fields cover /cmd and /tty, and cmdLocks is now keyed by (role, host) (oneShotKey, PF-7) so a session's start never waits behind a command's; field declarations unchanged; the same one site, no read added;rev3=census-ruling-agent-start-demo-1;basis=Adds fixed demo configuration, registry views, derived runtime root, synchronization and purge guard.;rev3=census-ruling-region-ha-p3b;basis=Add hairpinActive boolean alongside lastDeny under existing deny synchronization. Field declaration only; existing Statfs selector unchanged, no new read or externally supplied authority.;rev3=census-ruling-region-ha-p3b2-rolls;basis=adds one field holding the current hairpin exit watcher, guarded by the root hairpin flock; no new read;rev3=census-ruling-agent-start-demo-3;basis=Retain the snapshot supervisor in instance-control state; no new request-selected path. Census read-site delta: unchanged (1).;rev3=census-ruling-gvisor-demos;basis=Retain Task 1 mode/error/readiness fields, baseline/runtime callbacks, Task 4 per-host validated staged descriptors and root-selected probe nonce. Fix round 1 adds a private writer-operation seam assigned only in package tests, after the unchanged GVisorID admission check; production defaults still call the same checked constructor, WriteRootfs, WriteBundle and verifier. No new direct read or request-controlled callback. Task 5: private injected removal seam for unprivileged tests; production default removes only root-derived bundle and skeleton after both-family proof inside existing start fence. No new request field or agent-selected unit. Task 6: Retain serialized probe nonce, runtime-set identity verifier/token, fixed claims flag, bundle discovery root, and private unprivileged identity seam. No request-controlled callback or path; existing declaration read-site classification unchanged. Task 6 fix round 1: private gvisorProbeTestOps is set only in package tests; production defaults retain all fixed paths and the checked root output opener. No externally supplied callback or new direct read. Final R1 P2: retain fixed skeleton parent and concurrent per-instance cleanup refusals; no direct read or external configuration field. Carry the root-only host.env validation callback into Ready; no agent read or caller-selected path.;rev3=census-ruling-same-box-edge-fence;basis=Field declarations only: NFT (the nft runner; nil never loads the fence), EdgeFenceOff (host.env CARLOS_EDGE_FENCE=off), and under the existing denyMu/mu: fenceAddrs, fenceReason, fenceRetry, denyApplied. No read added.;rev3=census-ruling-bounded-systemctl;basis=new field Journal, the journalctl seam for the gVisor probe's diagnostic; field declaration only; no read added |
| @@ -24,8 +32,9 @@ Recorded dispositions, which each change must still satisfy: |
| New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff: |
| +- new `internal/activator/fleetreserve_linux.go:memAvailable`: reads +file:ReadFile; written legacy, accepted-legacy, frozen |
| - new `internal/cgroup/fleetgate.go:ReadMemTotal`: reads +file:ReadFile; written legacy, accepted-legacy, frozen |
| -Seal: `47ebd73418bcbe1bdf9cf34a2b94e3393a1279aea58f9ee0aca3f0cfe42b9132` → `dcd00ad63015e1ca6be4cd6f653c92a92891fea266e88e831e237adb64a1c54c`. |
| +Seal: `47ebd73418bcbe1bdf9cf34a2b94e3393a1279aea58f9ee0aca3f0cfe42b9132` → `0377659fd972285e8d368f7b27764c6c82d796ca10996427bb014147086b87b5`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-stateless-scale-2-fleet-sizes.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/activator/activator.go b/internal/activator/activator.go| index 325f54a8d..d3d63853c 100644 |
| --- a/internal/activator/activator.go |
| +++ b/internal/activator/activator.go |
| @@ -1413,6 +1413,13 @@ type Service struct { |
| // box at the route's Assigned), or on a fleet whose identity is invalid |
| // (every labelled wake refused). Set before Start, like Routes. |
| Fleet FleetWake |
| + // BoxLabel is this box's label as the rollout's events name it |
| + // (host.rolloutBox): PS-2-C05, a refused fleet-size overlap, names it. |
| + // Set before the rollout manager starts. |
| + BoxLabel string |
| + // fleetReserve is the box's overlap memory reservation for fleet sizes |
| + // (#892 S2, fleetreserve.go): one per Service. |
| + fleetReserve *fleetReservations |
| // Logs, when non-nil, receives member-visible platform events (wake |
| // outcomes, restart bounces) for `carlos logs` — set before Start, like |
| @@ -1774,6 +1781,8 @@ func New(cfg Config, backend Backend, due DueStore) *Service { |
| now: time.Now, |
| entries: make(map[string]*actEntry), |
| gens: GenerationsEnabled(), |
| + // The fleet-size overlap reservation (#892 S2) reads MemAvailable. |
| + fleetReserve: newFleetReservations(memAvailable), |
| } |
| a.initHALosses() |
| a.wakeSlots = make(chan struct{}, wakeSlotCount(cfg.WakeSlots)) |
diff --git a/internal/activator/fleetreserve.go b/internal/activator/fleetreserve.go| new file mode 100644 |
| index 000000000..bdcc3e4f3 |
| --- /dev/null |
| +++ b/internal/activator/fleetreserve.go |
| @@ -0,0 +1,165 @@ |
| +// fleetreserve.go is the box's memory reservation for overlap swaps to a |
| +// fleet size (#892 S2, spec §4 S2 bullet 5, plan ruling P1). An overlap |
| +// runs the old and the new generation side by side; at a fleet size the new |
| +// one alone can be most of the box. So before the parent is raised, the |
| +// successor's full memory limit is reserved against the box's available |
| +// memory, under one lock shared by every app on the box. With no room the |
| +// attempt is refused before anything runs, and the old build keeps serving. |
| +// |
| +// The existing sizes (small..xlarge) take no reservation: their overlaps |
| +// are admitted exactly as before. |
| +// |
| +// Ownership (exactly once): the token is taken after admission and before |
| +// the raise, and stored on the successor's genMember. A failure proven to |
| +// have run nothing (the raise refused, the exec gate refused, a context |
| +// cancelled before the spawn is called) releases it at once. Every other |
| +// exit keeps it on the member, and it is released in leaveSet, after the |
| +// member's termination is proven (dropMember, or a later reapExited). At |
| +// promotion it moves to the retiring member, which then holds it until the |
| +// old generation is proven gone. |
| +package activator |
| + |
| +import ( |
| + "bufio" |
| + "bytes" |
| + "errors" |
| + "fmt" |
| + "log" |
| + "strconv" |
| + "strings" |
| + "sync" |
| + |
| + "github.com/carlosframework/platform/internal/cgroup" |
| +) |
| + |
| +// errFleetNoRoom: the box's available memory, less what other overlaps |
| +// have reserved, is below the successor's limit. |
| +var errFleetNoRoom = errors.New("not enough free memory") |
| + |
| +// fleetNoRoomMsg is PS-2-C05 (scale copy deck, S2): the refusal reason an |
| +// overlap to a fleet size reports when its memory cannot be reserved. %s is |
| +// the box's label, the one the rollout's own events name. |
| +const fleetNoRoomMsg = "not enough free memory on %s to start the new build beside the old one. the old build is still serving" |
| + |
| +// fleetReservations is the box's reserved overlap memory. One per Service. |
| +type fleetReservations struct { |
| + mu sync.Mutex |
| + reserved int64 |
| + // avail is the box's available memory in bytes: /proc/meminfo |
| + // MemAvailable in production (memAvailable). |
| + avail func() (int64, error) |
| +} |
| + |
| +func newFleetReservations(avail func() (int64, error)) *fleetReservations { |
| + return &fleetReservations{avail: avail} |
| +} |
| + |
| +// reserve admits need bytes when avail() - reserved >= need, else returns |
| +// errFleetNoRoom (or avail's error). The read, the comparison and the add |
| +// are one critical section, so two overlaps never both count the same |
| +// free memory. |
| +func (r *fleetReservations) reserve(need int64) (*fleetToken, error) { |
| + r.mu.Lock() |
| + defer r.mu.Unlock() |
| + held := r.reserved |
| + avail, err := r.avail() |
| + if err != nil { |
| + return nil, err |
| + } |
| + if avail-held < need { |
| + return nil, errFleetNoRoom |
| + } |
| + r.reserved += need |
| + return &fleetToken{r: r, n: need}, nil |
| +} |
| + |
| +// held is the bytes reserved now. |
| +func (r *fleetReservations) held() int64 { |
| + r.mu.Lock() |
| + defer r.mu.Unlock() |
| + return r.reserved |
| +} |
| + |
| +// fleetToken is one overlap's reservation. |
| +type fleetToken struct { |
| + once sync.Once |
| + r *fleetReservations |
| + n int64 |
| +} |
| + |
| +// release returns the token's bytes. Only the first call does; a nil token |
| +// is no reservation. |
| +func (t *fleetToken) release() { |
| + if t == nil { |
| + return |
| + } |
| + t.once.Do(func() { |
| + t.r.mu.Lock() |
| + t.r.reserved -= t.n |
| + t.r.mu.Unlock() |
| + }) |
| +} |
| + |
| +// fleetSizeNeed is the bytes an overlap to tier must reserve: the tier's |
| +// full memory limit when it is a fleet size (web and workers share it, S1), |
| +// and 0 (no reservation) for every other tier. |
| +func fleetSizeNeed(tier cgroup.Limit) int64 { |
| + s, ok := cgroup.SizeOf(tier) |
| + if !ok || !cgroup.FleetSize(s.Name) { |
| + return 0 |
| + } |
| + return tier.MemoryMax |
| +} |
| + |
| +// reserveFleetOverlap takes the overlap's reservation for a successor at |
| +// tier: nil with no error when tier is not a fleet size. A refusal is |
| +// PS-2-C05, naming this box; an unreadable available memory refuses too. |
| +func (a *Service) reserveFleetOverlap(host string, tier cgroup.Limit) (*fleetToken, error) { |
| + need := fleetSizeNeed(tier) |
| + if need == 0 { |
| + return nil, nil |
| + } |
| + tok, err := a.fleetReserve.reserve(need) |
| + if err != nil { |
| + if !errors.Is(err, errFleetNoRoom) { |
| + log.Printf("activator: %s: read the box's available memory for a fleet-size overlap: %v", host, err) |
| + } |
| + return nil, fleetNoRoomError{box: a.BoxLabel, cause: err} |
| + } |
| + return tok, nil |
| +} |
| + |
| +// fleetNoRoomError is a refused reservation: its text is PS-2-C05, and it |
| +// wraps the cause (errFleetNoRoom or the read's error). |
| +type fleetNoRoomError struct { |
| + box string |
| + cause error |
| +} |
| + |
| +func (e fleetNoRoomError) Error() string { return fmt.Sprintf(fleetNoRoomMsg, e.box) } |
| +func (e fleetNoRoomError) Unwrap() error { return e.cause } |
| + |
| +// parseMemAvailable is /proc/meminfo's MemAvailable, in bytes. |
| +func parseMemAvailable(meminfo []byte) (int64, error) { |
| + sc := bufio.NewScanner(bytes.NewReader(meminfo)) |
| + for sc.Scan() { |
| + line := sc.Text() |
| + rest, ok := strings.CutPrefix(line, "MemAvailable:") |
| + if !ok { |
| + continue |
| + } |
| + f := strings.Fields(rest) |
| + if len(f) != 2 || f[1] != "kB" { |
| + return 0, fmt.Errorf("meminfo: malformed MemAvailable line %q", line) |
| + } |
| + kb, err := strconv.ParseInt(f[0], 10, 64) |
| + if err != nil || kb < 0 { |
| + return 0, fmt.Errorf("meminfo: malformed MemAvailable line %q", line) |
| + } |
| + return kb << 10, nil |
| + } |
| + if err := sc.Err(); err != nil { |
| + return 0, err |
| + } |
| + return 0, errors.New("meminfo: no MemAvailable line") |
| +} |
diff --git a/internal/activator/fleetreserve_linux.go b/internal/activator/fleetreserve_linux.go| new file mode 100644 |
| index 000000000..21e62ff7c |
| --- /dev/null |
| +++ b/internal/activator/fleetreserve_linux.go |
| @@ -0,0 +1,15 @@ |
| +//go:build linux |
| + |
| +package activator |
| + |
| +import "os" |
| + |
| +// memAvailable is the box's available memory: /proc/meminfo MemAvailable, |
| +// in bytes (#892 S2, the fleet-size overlap reservation). |
| +func memAvailable() (int64, error) { |
| + b, err := os.ReadFile("/proc/meminfo") |
| + if err != nil { |
| + return 0, err |
| + } |
| + return parseMemAvailable(b) |
| +} |
diff --git a/internal/activator/fleetreserve_other.go b/internal/activator/fleetreserve_other.go| new file mode 100644 |
| index 000000000..197687362 |
| --- /dev/null |
| +++ b/internal/activator/fleetreserve_other.go |
| @@ -0,0 +1,11 @@ |
| +//go:build !linux |
| + |
| +package activator |
| + |
| +import "errors" |
| + |
| +// memAvailable has no /proc/meminfo off Linux: a fleet-size overlap is |
| +// refused, as an unreadable read is on Linux. |
| +func memAvailable() (int64, error) { |
| + return 0, errors.New("available memory is read from /proc/meminfo, which this platform has not") |
| +} |
diff --git a/internal/activator/fleetreserve_test.go b/internal/activator/fleetreserve_test.go| new file mode 100644 |
| index 000000000..9b3eb4235 |
| --- /dev/null |
| +++ b/internal/activator/fleetreserve_test.go |
| @@ -0,0 +1,423 @@ |
| +package activator |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "fmt" |
| + "path/filepath" |
| + "sync" |
| + "sync/atomic" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/cgroup" |
| + "github.com/carlosframework/platform/internal/registry" |
| +) |
| + |
| +// fleetKillBackend is the swap fake plus plan 2's KillGen, so a generation |
| +// child's emptiness can be refused (err) and later proven. |
| +type fleetKillBackend struct { |
| + *fakeSwapBackend |
| + kmu sync.Mutex |
| + err error |
| +} |
| + |
| +func (k *fleetKillBackend) KillGen(context.Context, registry.Route, uint64) error { |
| + k.kmu.Lock() |
| + defer k.kmu.Unlock() |
| + return k.err |
| +} |
| + |
| +func (k *fleetKillBackend) setErr(err error) { |
| + k.kmu.Lock() |
| + k.err = err |
| + k.kmu.Unlock() |
| +} |
| + |
| +// fleetFixture is a swap fixture whose build v2 runs at the fleet size 4g |
| +// on box-1, with avail as the box's available memory. reads counts avail |
| +// calls. |
| +type fleetFixture struct { |
| + *swapFixture |
| + kb *fleetKillBackend |
| + reads atomic.Int32 |
| +} |
| + |
| +func newFleetFixture(t *testing.T, avail func() (int64, error)) *fleetFixture { |
| + t.Helper() |
| + var kb *fleetKillBackend |
| + f := newSwapFixtureOn(t, func(b *fakeSwapBackend) Backend { |
| + b.tiers = map[string]cgroup.Limit{"v2": fleetLimit(t, "4g")} |
| + kb = &fleetKillBackend{fakeSwapBackend: b} |
| + return kb |
| + }) |
| + ff := &fleetFixture{swapFixture: f, kb: kb} |
| + f.a.BoxLabel = "box-1" |
| + f.a.fleetReserve = newFleetReservations(func() (int64, error) { |
| + ff.reads.Add(1) |
| + return avail() |
| + }) |
| + return ff |
| +} |
| + |
| +func fleetLimit(t *testing.T, name string) cgroup.Limit { |
| + t.Helper() |
| + s, ok := cgroup.SizeByName(name) |
| + if !ok { |
| + t.Fatalf("no size %q", name) |
| + } |
| + return s.Limit |
| +} |
| + |
| +func fixedAvail(n int64) func() (int64, error) { |
| + return func() (int64, error) { return n, nil } |
| +} |
| + |
| +// awakeHost wakes a second app's host on the fixture's Service, at its own |
| +// incumbent generation, and returns its incumbent process. |
| +func (f *fleetFixture) awakeHost(t *testing.T, host string, n uint64) (*fakeProc, Gen) { |
| + t.Helper() |
| + rt := testRoute(host) |
| + rdir := t.TempDir() |
| + rt.Socket, rt.DBPath = filepath.Join(rdir, "app.sock"), filepath.Join(rdir, "app.db") |
| + arrangeAwake(t, f.a, rt) |
| + g := Gen{N: n, Socket: fmt.Sprintf("/run/carlos/g/inc%d.sock", n), Control: fmt.Sprintf("/run/carlos/g/inc%d.sock.control", n), |
| + Build: "v1", StagedPath: "/opt/carlos/versions/v1/app"} |
| + setCurrentGen(t, f.a, host, g) |
| + return f.b.lastProc(), g |
| +} |
| + |
| +func setStuck(p *fakeProc, stuck bool) { |
| + p.mu.Lock() |
| + p.stuck = stuck |
| + p.mu.Unlock() |
| +} |
| + |
| +func (f *fleetFixture) members(host string) int { |
| + _, m := f.a.genStateForTest(host) |
| + return len(m) |
| +} |
| + |
| +// Two apps on one box start overlaps to fleet-size successors at once, with |
| +// room for one. Exactly one is admitted. The refused one never raises its |
| +// parent or spawns, its incumbent is not stopped and keeps serving, and its |
| +// refusal is PS-2-C05. The admitted one completes as any swap, and its |
| +// bytes return only when its retiring generation is proven empty. |
| +func TestFleetLargeSwapReservesHeadroom(t *testing.T) { |
| + f := newFleetFixture(t, fixedAvail(6*gib)) |
| + need := fleetLimit(t, "4g").MemoryMax |
| + inc1 := f.b.lastProc() |
| + inc2, gen2 := f.awakeHost(t, "shop.example.com", 1<<41) |
| + setStuck(inc1, true) |
| + setStuck(inc2, true) |
| + incs := map[string]*fakeProc{f.host: inc1, "shop.example.com": inc2} |
| + sockets := map[string]string{f.host: f.incumbent.Socket, "shop.example.com": gen2.Socket} |
| + |
| + gate := make(chan struct{}) |
| + f.b.onRaise = func() { <-gate } // the admitted one waits at its raise |
| + type outcome struct { |
| + host string |
| + res SwapResult |
| + } |
| + results := make(chan outcome, 2) |
| + for _, host := range []string{f.host, "shop.example.com"} { |
| + at := f.attempt(ModeOverlap) |
| + at.Host = host |
| + goTracked(func() { results <- outcome{host, f.a.Swap(context.Background(), at, f.newest)} }) |
| + } |
| + var refused outcome |
| + select { |
| + case refused = <-results: |
| + case <-time.After(10 * time.Second): |
| + close(gate) |
| + t.Fatal("neither overlap was refused: both reached the raise") |
| + } |
| + want := "not enough free memory on box-1 to start the new build beside the old one. the old build is still serving" |
| + if refused.res.Outcome != SwapAbandoned || refused.res.Reason != want || refused.res.Executed { |
| + t.Fatalf("the refused overlap = %+v, want abandoned with %q", refused.res, want) |
| + } |
| + if !errors.Is(refused.res.Err, errFleetNoRoom) { |
| + t.Fatalf("the refusal's error %v does not wrap errFleetNoRoom", refused.res.Err) |
| + } |
| + if got := f.a.fleetReserve.held(); got != need { |
| + t.Fatalf("reserved %d while one overlap is admitted, want %d", got, need) |
| + } |
| + close(gate) |
| + admitted := <-results |
| + if admitted.host == refused.host { |
| + t.Fatal("both results are the same host's") |
| + } |
| + |
| + gens, raises, _ := f.b.calls() |
| + admittedOverlaps := raises |
| + refusedIncumbentStops := incs[refused.host].stopCalls() |
| + if admittedOverlaps != 1 || gens != 1 || refusedIncumbentStops != 0 { |
| + t.Fatalf("admittedOverlaps=%d spawns=%d refusedIncumbentStops=%d, want 1, 1, 0", admittedOverlaps, gens, refusedIncumbentStops) |
| + } |
| + if sock, ok := f.a.AppSocket(refused.host); !ok || sock != sockets[refused.host] { |
| + t.Fatalf("the refused app serves from %q (%v), want its incumbent %q", sock, ok, sockets[refused.host]) |
| + } |
| + if n := f.members(refused.host); n != 0 { |
| + t.Fatalf("the refused overlap left %d member(s)", n) |
| + } |
| + |
| + // The admitted overlap switched; its incumbent is stopped as any swap's, |
| + // but its exit is not yet proven, so its bytes stay reserved. |
| + if admitted.res.Outcome != SwapDone { |
| + t.Fatalf("the admitted overlap = %+v, want done", admitted.res) |
| + } |
| + if !incs[admitted.host].isStopped() && incs[admitted.host].stopCalls() == 0 { |
| + t.Fatal("the admitted overlap never stopped its incumbent") |
| + } |
| + if got := f.a.fleetReserve.held(); got != need { |
| + t.Fatalf("reserved %d before the retiring generation is proven gone, want %d", got, need) |
| + } |
| + incs[admitted.host].exit() |
| + f.a.sweepOnce() |
| + waitFor(t, "the retiring generation's bytes returned", func() bool { return f.a.fleetReserve.held() == 0 }) |
| + if n := f.members(admitted.host); n != 0 { |
| + t.Fatalf("%d member(s) left after the proof", n) |
| + } |
| +} |
| + |
| +// A failed successor whose termination is not proven keeps its reservation; |
| +// the sweep's reapExited proof releases it, once. |
| +func TestFleetReserveUnprovenCandidate(t *testing.T) { |
| + f := newFleetFixture(t, fixedAvail(16*gib)) |
| + need := fleetLimit(t, "4g").MemoryMax |
| + f.b.genStuck = true |
| + f.a.genHealth = func(context.Context, Gen) error { return errors.New("unhealthy: HTTP 503") } |
| + res := f.a.Swap(context.Background(), f.attempt(ModeOverlap), f.newest) |
| + if res.Outcome != SwapFailed { |
| + t.Fatalf("Swap = %+v, want failed", res) |
| + } |
| + if got := f.a.fleetReserve.held(); got != need { |
| + t.Fatalf("reserved %d with the candidate unproven, want %d", got, need) |
| + } |
| + f.a.sweepOnce() // the leader still runs: a re-stop, no proof |
| + if got := f.a.fleetReserve.held(); got != need { |
| + t.Fatalf("reserved %d after a sweep that proved nothing, want %d", got, need) |
| + } |
| + _, p := f.b.lastGen() |
| + p.exit() |
| + f.a.sweepOnce() |
| + waitFor(t, "the candidate reaped", func() bool { return f.members(f.host) == 0 }) |
| + if got := f.a.fleetReserve.held(); got != 0 { |
| + t.Fatalf("reserved %d after the proof, want 0", got) |
| + } |
| + f.a.sweepOnce() |
| + if got := f.a.fleetReserve.held(); got != 0 { |
| + t.Fatalf("reserved %d after a second sweep, want 0 (released once)", got) |
| + } |
| +} |
| + |
| +// After promotion, an unproven retiring generation keeps the reservation |
| +// until the sweep proves it gone. |
| +func TestFleetReserveUnprovenRetiring(t *testing.T) { |
| + f := newFleetFixture(t, fixedAvail(16*gib)) |
| + need := fleetLimit(t, "4g").MemoryMax |
| + inc := f.b.lastProc() |
| + setStuck(inc, true) |
| + res := f.a.Swap(context.Background(), f.attempt(ModeOverlap), f.newest) |
| + if res.Outcome != SwapDone || res.Reason == "" { |
| + t.Fatalf("Swap = %+v, want done with the retiring generation unproven", res) |
| + } |
| + if got := f.a.fleetReserve.held(); got != need { |
| + t.Fatalf("reserved %d with the retiring generation unproven, want %d", got, need) |
| + } |
| + f.a.sweepOnce() |
| + if got := f.a.fleetReserve.held(); got != need { |
| + t.Fatalf("reserved %d after a sweep that proved nothing, want %d", got, need) |
| + } |
| + inc.exit() |
| + f.a.sweepOnce() |
| + waitFor(t, "the retiring generation reaped", func() bool { return f.members(f.host) == 0 }) |
| + if got := f.a.fleetReserve.held(); got != 0 { |
| + t.Fatalf("reserved %d after the proof, want 0", got) |
| + } |
| +} |
| + |
| +// A refused raise, and a context cancelled before the spawn, ran nothing: |
| +// the reservation is released at once, even while the member's own child |
| +// cannot be proven empty. A second release is a no-op. |
| +func TestFleetReserveFailBeforeSpawn(t *testing.T) { |
| + for _, tc := range []struct { |
| + name string |
| + arrange func(f *fleetFixture, cancel context.CancelFunc) |
| + }{ |
| + {"raise refused", func(f *fleetFixture, _ context.CancelFunc) { |
| + f.b.raiseErr = fmt.Errorf("parent: %w", errNoGenContainment) |
| + }}, |
| + {"raise failed after a write", func(f *fleetFixture, _ context.CancelFunc) { |
| + f.b.raiseErr = errors.New("cgroup: parent memory.high: device or resource busy") |
| + }}, |
| + {"cancelled before spawn", func(f *fleetFixture, cancel context.CancelFunc) { |
| + f.b.onRaise = cancel |
| + }}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + f := newFleetFixture(t, fixedAvail(16*gib)) |
| + f.kb.setErr(errors.New("the child cannot be proven empty")) |
| + ctx, cancel := context.WithCancel(context.Background()) |
| + defer cancel() |
| + tc.arrange(f, cancel) |
| + res := f.a.Swap(ctx, f.attempt(ModeOverlap), f.newest) |
| + if res.Outcome == SwapDone || res.Executed { |
| + t.Fatalf("Swap = %+v, want a refusal that ran nothing", res) |
| + } |
| + if gens, _, _ := f.b.calls(); gens != 0 { |
| + t.Fatalf("%d spawn(s), want none", gens) |
| + } |
| + if got := f.a.fleetReserve.held(); got != 0 { |
| + t.Fatalf("reserved %d after a failure that ran nothing, want 0", got) |
| + } |
| + }) |
| + } |
| + t.Run("release twice", func(t *testing.T) { |
| + r := newFleetReservations(fixedAvail(8 * gib)) |
| + tok, err := r.reserve(4 * gib) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := r.reserve(5 * gib); !errors.Is(err, errFleetNoRoom) { |
| + t.Fatalf("a reserve past the room = %v, want errFleetNoRoom", err) |
| + } |
| + tok.release() |
| + tok.release() |
| + if got := r.held(); got != 0 { |
| + t.Fatalf("reserved %d after two releases of one token, want 0", got) |
| + } |
| + var none *fleetToken |
| + none.release() |
| + }) |
| +} |
| + |
| +// A spawn error with no process handle is not proof that nothing ran. With |
| +// its termination proof failing the reservation stays; a later sweep that |
| +// proves the generation empty releases it, once. |
| +func TestFleetReserveSpawnErrorKeeps(t *testing.T) { |
| + f := newFleetFixture(t, fixedAvail(16*gib)) |
| + need := fleetLimit(t, "4g").MemoryMax |
| + f.b.genErr = errors.New("exec: control channel closed mid-start") |
| + f.kb.setErr(errors.New("the child still holds a process")) |
| + res := f.a.Swap(context.Background(), f.attempt(ModeOverlap), f.newest) |
| + if res.Outcome == SwapDone { |
| + t.Fatalf("Swap = %+v, want a failure", res) |
| + } |
| + if got := f.a.fleetReserve.held(); got != need { |
| + t.Fatalf("reserved %d after a spawn error with an unproven child, want %d", got, need) |
| + } |
| + f.a.sweepOnce() |
| + waitFor(t, "the reaper's failed proof", func() bool { |
| + f.a.mu.Lock() |
| + defer f.a.mu.Unlock() |
| + for _, m := range f.a.entries[f.host].ops.members { |
| + if m.reaping { |
| + return false |
| + } |
| + } |
| + return true |
| + }) |
| + if got := f.a.fleetReserve.held(); got != need { |
| + t.Fatalf("reserved %d after a failed proof, want %d", got, need) |
| + } |
| + f.kb.setErr(nil) |
| + f.a.sweepOnce() |
| + waitFor(t, "the generation proven empty", func() bool { return f.members(f.host) == 0 }) |
| + if got := f.a.fleetReserve.held(); got != 0 { |
| + t.Fatalf("reserved %d after the proof, want 0", got) |
| + } |
| + f.a.sweepOnce() |
| + if got := f.a.fleetReserve.held(); got != 0 { |
| + t.Fatalf("reserved %d after another sweep, want 0", got) |
| + } |
| +} |
| + |
| +// An xlarge-to-xlarge overlap takes no reservation and is admitted whatever |
| +// avail says: the existing sizes behave as before. |
| +func TestFleetReserveSkipsExistingSizes(t *testing.T) { |
| + f := newFleetFixture(t, func() (int64, error) { return 0, errors.New("meminfo unreadable") }) |
| + xl := fleetLimit(t, "xlarge") |
| + f.b.gmu.Lock() |
| + f.b.tiers = map[string]cgroup.Limit{"v1": xl, "v2": xl} |
| + f.b.gmu.Unlock() |
| + res := f.a.Swap(context.Background(), f.attempt(ModeOverlap), f.newest) |
| + if res.Outcome != SwapDone { |
| + t.Fatalf("Swap = %+v, want done", res) |
| + } |
| + if n := f.reads.Load(); n != 0 { |
| + t.Fatalf("available memory read %d time(s) for an xlarge overlap, want 0", n) |
| + } |
| + if got := f.a.fleetReserve.held(); got != 0 { |
| + t.Fatalf("reserved %d, want 0", got) |
| + } |
| +} |
| + |
| +// An unreadable available memory refuses a fleet-size overlap, leaving the |
| +// old build serving. |
| +func TestFleetReserveUnreadable(t *testing.T) { |
| + f := newFleetFixture(t, func() (int64, error) { return 0, errors.New("meminfo: no MemAvailable line") }) |
| + inc := f.b.lastProc() |
| + res := f.a.Swap(context.Background(), f.attempt(ModeOverlap), f.newest) |
| + want := "not enough free memory on box-1 to start the new build beside the old one. the old build is still serving" |
| + if res.Outcome != SwapAbandoned || res.Reason != want { |
| + t.Fatalf("Swap = %+v, want abandoned with %q", res, want) |
| + } |
| + if gens, raises, _ := f.b.calls(); gens != 0 || raises != 0 { |
| + t.Fatalf("%d spawn(s), %d raise(s), want none", gens, raises) |
| + } |
| + if inc.stopCalls() != 0 { |
| + t.Fatal("the incumbent was stopped") |
| + } |
| + if got := f.appSocket(t); got != f.incumbent.Socket { |
| + t.Fatalf("serving from %q, want the incumbent", got) |
| + } |
| +} |
| + |
| +func TestParseMemAvailable(t *testing.T) { |
| + got, err := parseMemAvailable([]byte("MemTotal: 32617072 kB\nMemFree: 1000 kB\nMemAvailable: 20000000 kB\n")) |
| + if err != nil || got != 20000000<<10 { |
| + t.Fatalf("parseMemAvailable = %d, %v", got, err) |
| + } |
| + for _, bad := range []string{"MemTotal: 1 kB\n", "MemAvailable: x kB\n", "MemAvailable: 12\n", "MemAvailable: -1 kB\n"} { |
| + if _, err := parseMemAvailable([]byte(bad)); err == nil { |
| + t.Errorf("parseMemAvailable(%q) accepted", bad) |
| + } |
| + } |
| +} |
| + |
| +// The read of available memory, the comparison and the add are one |
| +// critical section: two reserves racing over room for one admit exactly |
| +// one, even when the second reaches its read while the first is inside its |
| +// own. Without the lock both would read the same free memory. |
| +func TestFleetReserveOneLock(t *testing.T) { |
| + firstIn, secondIn := make(chan struct{}), make(chan struct{}) |
| + var calls atomic.Int32 |
| + r := newFleetReservations(func() (int64, error) { |
| + if calls.Add(1) == 1 { |
| + close(firstIn) |
| + select { |
| + case <-secondIn: // only possible without the lock |
| + case <-time.After(300 * time.Millisecond): |
| + } |
| + } else { |
| + close(secondIn) |
| + } |
| + return 6 * gib, nil |
| + }) |
| + errs := make(chan error, 2) |
| + goTracked(func() { _, err := r.reserve(4 * gib); errs <- err }) |
| + <-firstIn |
| + goTracked(func() { _, err := r.reserve(4 * gib); errs <- err }) |
| + admitted := 0 |
| + for range 2 { |
| + if err := <-errs; err == nil { |
| + admitted++ |
| + } else if !errors.Is(err, errFleetNoRoom) { |
| + t.Fatalf("reserve: %v", err) |
| + } |
| + } |
| + if admitted != 1 || r.held() != 4*gib { |
| + t.Fatalf("admitted %d, reserved %d; want 1 and %d", admitted, r.held(), 4*gib) |
| + } |
| +} |
diff --git a/internal/activator/opset.go b/internal/activator/opset.go| index 420c749c3..45304068b 100644 |
| --- a/internal/activator/opset.go |
| +++ b/internal/activator/opset.go |
| @@ -59,6 +59,11 @@ type genMember struct { |
| // since a retained child may still run those bytes; leaveSet publishes |
| // again once it has left. |
| build release.StagedIdentity |
| + // reserve is the fleet-size overlap reservation this generation holds |
| + // (#892 S2, fleetreserve.go): a successor's from its admission, moved to |
| + // the retiring member at promotion. leaveSet releases it once the |
| + // member's termination is proven; nil holds none. |
| + reserve *fleetToken |
| } |
| // straySidecar is a legacy sidecar whose termination is unproven, with the |
| @@ -548,7 +553,12 @@ func (a *Service) leaveSet(e *actEntry, m *genMember) { |
| if e.ops.members[m.gen.N] == m { |
| delete(e.ops.members, m.gen.N) |
| } |
| + // Its termination is proven: a fleet-size overlap's reservation it |
| + // holds goes back to the box (#892 S2). The only release after a spawn. |
| + tok := m.reserve |
| + m.reserve = nil |
| a.mu.Unlock() |
| + tok.release() |
| close(m.done) |
| if _, listed := a.genIdentity(m.gen); listed || m.build != (release.StagedIdentity{}) { |
| // Its child is proven gone: its build is no longer referenced. |
diff --git a/internal/activator/swap.go b/internal/activator/swap.go| index 9b99498e0..16fa3f201 100644 |
| --- a/internal/activator/swap.go |
| +++ b/internal/activator/swap.go |
| @@ -717,6 +717,31 @@ func (a *Service) swapOverlap(ctx context.Context, gb SwapBackend, at Attempt, n |
| m.gen.Tier = succTier |
| a.mu.Unlock() |
| + // Step 1b (#892 S2): a successor at a fleet size reserves its full |
| + // memory limit on the box first, under the box's one reservation lock. |
| + // With no room, or an unreadable MemAvailable, nothing is raised or |
| + // spawned and the old build keeps serving (PS-2-C05). The token is the |
| + // member's from here (fleetreserve.go): released at once only by a |
| + // failure below that ran nothing, otherwise in leaveSet once the |
| + // member, or the retiring member it moves to, is proven gone. |
| + tok, err := a.reserveFleetOverlap(at.Host, succTier) |
| + if err != nil { |
| + a.dropMember(e, m) |
| + return abandon(err) |
| + } |
| + a.mu.Lock() |
| + m.reserve = tok |
| + a.mu.Unlock() |
| + // releaseUnrun releases the reservation of an attempt that ran nothing: |
| + // only before the spawn is called. |
| + releaseUnrun := func() { |
| + a.mu.Lock() |
| + t := m.reserve |
| + m.reserve = nil |
| + a.mu.Unlock() |
| + t.release() |
| + } |
| + |
| // Step 2: the parent raise, before the successor spawns (spec §7.3). |
| // The parent is marked potentially changed BEFORE the raise is asked: a |
| // raise that wrote memory.max and then failed a later write has changed |
| @@ -732,6 +757,7 @@ func (a *Service) swapOverlap(ctx context.Context, gb SwapBackend, at Attempt, n |
| e.ops.raised = false |
| a.mu.Unlock() |
| } |
| + releaseUnrun() // nothing spawned |
| a.dropMember(e, m) // restores a possibly changed parent (leaveSet) |
| return abandon(fmt.Errorf("raise parent limit: %w", err)) |
| } |
| @@ -741,6 +767,7 @@ func (a *Service) swapOverlap(ctx context.Context, gb SwapBackend, at Attempt, n |
| // it. A failed write abandons the attempt; nothing of it ran, so it is |
| // never a failure of the build. |
| if err := a.publishBeforeExec(); err != nil { |
| + releaseUnrun() // nothing spawned |
| a.dropMember(e, m) // restores the raised parent (leaveSet) |
| return abandon(err) |
| } |
| @@ -759,6 +786,7 @@ func (a *Service) swapOverlap(ctx context.Context, gb SwapBackend, at Attempt, n |
| return a.releaseAdmitsSwapLocked(at, m.gen, pass, due) |
| } |
| if err := a.admit(ctx, work, gate); err != nil { |
| + releaseUnrun() // refused (a cancelled context included) before the spawn is called |
| a.dropMember(e, m) // restores the raised parent (leaveSet) |
| return abandon(err) |
| } |
| @@ -845,7 +873,11 @@ func (a *Service) swapOverlap(ctx context.Context, gb SwapBackend, at Attempt, n |
| if err := gb.GenSwitched(e.route, m.gen, m.proc); err != nil { |
| return err |
| } |
| - retiring = &genMember{gen: e.gen, role: roleRetiring, proc: e.proc, done: make(chan struct{})} |
| + // The successor's reservation moves to the retiring member: the |
| + // overlap lasts until the old generation is proven gone, and that |
| + // member's leaveSet releases it (#892 S2). |
| + retiring = &genMember{gen: e.gen, role: roleRetiring, proc: e.proc, done: make(chan struct{}), reserve: m.reserve} |
| + m.reserve = nil |
| fence.retire(retiring.gen.N) // its schedule writes are refused from here, for good |
| delete(e.ops.members, m.gen.N) |
| a.addMemberLocked(e, retiring) // swapsim:M2 |
diff --git a/internal/host/rollout.go b/internal/host/rollout.go| index 25f246ea9..ca7aeeb66 100644 |
| --- a/internal/host/rollout.go |
| +++ b/internal/host/rollout.go |
| @@ -386,6 +386,9 @@ func armRollout(ctx context.Context, getenv func(string) string, svc *activator. |
| return nil |
| } |
| svc.ReplicaDeployID = book.ReplicaDeployID |
| + // The label a refused fleet-size overlap names (PS-2-C05, #892 S2): |
| + // the same one the rollout's own events use. |
| + svc.BoxLabel = rolloutBox(svc) |
| svc.MarkReplicaRelease, svc.ReplicaReleaseMark = book.MarkReplicaRelease, book.ReplicaReleaseMark |
| m := rollout.NewManager(ctx, rollout.Deps{ |
| Act: svc, Routes: reg, Book: book, OptDir: release.OptDir(), DataDir: dd, Box: rolloutBox(svc), |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 8142012a1..7d39bcaf5 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -275,4 +275,4 @@ plan14-root-reads-media-spike-values.tsv 194e88ad9cd7413c93b1181c0ac1e962107039a |
| plan14-root-reads-path-routes-across-boxes.tsv f959a3626e83650aaad1880eecc3feddebdbd78474937f4c619df658eb46a1d6 |
| plan14-root-reads-headers-security-allowlist.tsv f959a3626e83650aaad1880eecc3feddebdbd78474937f4c619df658eb46a1d6 |
| plan14-root-reads-stateless-scale-1-memory-env.tsv 47ebd73418bcbe1bdf9cf34a2b94e3393a1279aea58f9ee0aca3f0cfe42b9132 |
| -plan14-root-reads-stateless-scale-2-fleet-sizes.tsv dcd00ad63015e1ca6be4cd6f653c92a92891fea266e88e831e237adb64a1c54c |
| +plan14-root-reads-stateless-scale-2-fleet-sizes.tsv 0377659fd972285e8d368f7b27764c6c82d796ca10996427bb014147086b87b5 |
diff --git a/internal/provision/testdata/plan14-root-reads-stateless-scale-2-fleet-sizes.tsv b/internal/provision/testdata/plan14-root-reads-stateless-scale-2-fleet-sizes.tsv| index cf411c27e..472724876 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-stateless-scale-2-fleet-sizes.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-stateless-scale-2-fleet-sizes.tsv |
| @@ -1,19 +1,29 @@ |
| # Census overlay stateless-scale-2-fleet-sizes, written by census-propose (#369). census-ruling-stateless-scale-2-fleet-sizes, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-stateless-scale-2-fleet-sizes.md. |
| -# 5 body, 0 sites, 5 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| -# 1 new dispositions: 0 reads re-frozen at their disposition with the claim, 1 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other. |
| +# 9 body, 0 sites, 6 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 e213deeb3081f3d42430e25aff0ae7c475279e486740b9fd5dd9f1d7fca790e2 internal/activator/opset.go Service.leaveSet legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=the agent as carlos (#892 S2): after a member's termination is proven and it leaves the set, the fleet-size overlap reservation it holds (genMember.reserve) is released, in memory, under a.mu. No read added; no root call added; the restore and the proof are unchanged whole:Route@167,whole:Route@262 d98d4d22859c0b0e0ce554518bd5f58a801746f0059195201eed1b481f9d2ecd |
| +@legacy 9df0b085abd5b622634c95c659d2af4f7267e9f1dbfd4857620f998eff310932 internal/activator/swap.go Service.swapOverlap legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=Re-digested at the pre-land merge: the body includes main's own change under census ruling zddr4, with no further change from this branch. the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body; admission and the switch refuse while a run's unit is starting, and the switch interrupts runs on the retiring generation; read sites unchanged, offsets moved;rev3=census-ruling-instance-egress-sizes-328-329;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=#329 plan 3 Task 4 and the final review: the new kind is registry:Size, one site, rt.Size != "" in the successor's max rule (the successor starts at the larger of its own sized tier and the incumbent's captured tier when the route has a size now or the incumbent runs at a tier other than its build's), and two more whole:Route sites: the successor's route is now sizedRouteLocked(e) with the wake route kept beside it as wakeRt for the incumbent's tier, and a second GenTier(rt, incumbent.Build) in that rule. The column comes from the agent's registry row (reconcile, from the signed app policy). Admission also refuses while a live size change is in flight. The raise still goes to root's /parent, whose memory_max root checks against its size table; no root decision here;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 N1, Task 8 and Task D: the incumbent's tier is recorded through recordCurrentTierLocked; genHealthy takes rt (so a rootfs generation is checked within the rootfs bound); the successor is installed through installProcLocked; after step 8 a rootfs build's declared processes are logged, never started (rootfsProcessesHook); no new file read;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R, R2: two new parameters from releaseBeforeSwap (pass, the proven pass, and due, whether the build needed a release); the admission and the exec gate both also ask releaseAdmitsSwapLocked, which refuses while any release record of the host is open (INV-R4) and, when a release was due, unless pass is this attempt's for the successor's build (INV-R5); no release runs here; the same 18 read sites, no read added; adds refusals only;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W2: step 8 no longer calls rootfsProcessesHook(ctx, e, rt, m.gen); it calls handOverRootfsWorkers(e), which stops and proves the retiring generation's workers gone and then registers the switched generation's set as pending (starts nothing; the tick starts them, and the stray rule refuses a start while an old worker is a stray, so two sets never run at once); site -whole:Route (rt no longer handed to the hook); no read added;rev3=census-ruling-edge-page-cache-1;basis=noteCurrent(e) instead of noteCurrent(e.host, m.gen.N) at the switch, as Service.wake; read sites unchanged (17); no read added;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=the agent as carlos (#892 S2): after admission and before the raise, a successor whose tier is a fleet size reserves its full MemoryMax through reserveFleetOverlap (memAvailable reads /proc/meminfo). With no room or an unreadable read the attempt is abandoned with PS-2-C05 before any raise, publication or spawn; the incumbent keeps serving. The token is stored on the member, released at once on a refused raise, a failed publication or a refused exec gate (nothing spawned), and otherwise moves to the retiring member at the switch. Adds a refusal only; the raise still goes to root's /parent unchanged; no root decision here. Read sites unchanged (17) registry:Kind@2060,registry:Size@5198,whole:Route@11149,whole:Route@13230,whole:Route@13237,whole:Route@13277,whole:Route@2062,whole:Route@2386,whole:Route@3729,whole:Route@3733,whole:Route@3778,whole:Route@4373,whole:Route@4425,whole:Route@5244,whole:Route@6688,whole:Route@8434,whole:Route@9153 9e25dc3b8ffb4f73453f61b70075da5466040ed25ad213906254e96a56916689 |
| @legacy 0fa85d969c48493b2c14c3600ab8508c25d2eb2267ee86b70c592c3c602adbb1 internal/cgroup/cgroup.go setup legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-hunt-account-root-hardening;basis=setup records whether the flat IMDS fence is armed (CARLOS_IMDS_FLAT_FENCE); when armed, a flat start whose shim or placement is unavailable is refused instead of falling back to start-and-move; no read is added;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=the agent (carlos-edge.service, user carlos), not root: setup now also records a fleet-size gate on the agent's own Manager when CARLOS_FLEET is set in its environment (os.Getenv, beside the existing CARLOS_IMDS_FLAT_FENCE read). The gate's MemTotal closure reads /proc/meminfo through ReadMemTotal when a strict prepare is asked for a fleet size (#892 S2). It only lets the strict validators (PrepareStrict, PrepareGen, SetParentLimit) accept the new fleet rows within FleetMemoryBudget; without CARLOS_FLEET they take small..xlarge and today's parents exactly as before. Reads added: env CARLOS_FLEET; /proc/meminfo (kernel, fixed path) via the closure file:ReadFile@73 1c2d963c219576573ba11b9b1ba07c3823902b850615a93406f6cfc3c78065cb |
| +@legacy 6963d5a2d0b0eecf76bc22eb714fa1a1679c0b75b9892ee9123d189c7a5f6f88 internal/host/rollout.go armRollout legacy accepted-legacy accepted-legacy;rev3=fix1-merge-review;basis=Comment-only clarification of failure-book saves; existing agent rollout setup remains legacy.;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: after the overlap scheduler arms, calls svc.ArmRootfs() so rootfs rows start only where the scheduler armed this boot; never on the refuseManaged path; no read added;rev3=census-ruling-stateless-replicas-1;basis=Task 3a: Bind Service.ReplicaDeployID to the same FailureBook the scheduler owns and bind RuntimeSelection to one CanonicalStatelessDigest read through the existing store. Fix 3a round 1 R18: canonical selection receives route stateless projection to keep legacy DemandHold fallback only for stateful/unknown builds; staged digest mismatch still refuses.;rev3=census-ruling-stateless-replicas-4-task2-fix1;basis=Task 2 fix round 1: the scheduler box label is rolloutBox(svc): the fleet identity label already on svc.Fleet (set from identity.Label before the scheduler arms), else BoxLabel() as before. No read added.;rev3=census-ruling-stateless-replicas-4-task3f;basis=Task 3F fix round 3 (#511 F11): also hands the failure book's MarkReplicaRelease and ReplicaReleaseMark to the activator, beside ReplicaDeployID. The book is the same file the agent already opened; no new read.;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=the agent as carlos (#892 S2): also sets svc.BoxLabel = rolloutBox(svc), the label the scheduler already uses, for the PS-2-C05 refusal text. No read added registry:App@3165,registry:Stateless@3184,whole:Route@3160,whole:Route@3852,whole:Route@3936 ae4f008b6f31852c7afd387add5eb2f31f9df4b520a079117397033491c0a44f |
| @legacy bce72a2f498322b60434183b6db1c4703d8b691246083a08052e29757c6ea259 internal/instancectl/gen.go Server.handleParent legacy accepted-legacy accepted-legacy;rev3=J2,J4;basis=root-input;rev3=census-ruling-instance-egress-sizes-328-329;basis=#329 plan 3 Task 5: holds the host's slice lock (lockSliceWrites) around its one set-property, so /parent and /size never interleave on one slice. Its one site is still r.URL.Query() of the agent's request (counted as file:Query). The checks in this body are unchanged, though cgroup.ValidParentLimit, which it calls, now accepts one size or the sum of any two from the four-row table (up to 4 GiB, was 2 GiB); no read added.;rev3=census-ruling-agent-start-demo-1;basis=Reads fixed DemoBox and clamps the existing parent memory writer to small.;rev3=census-ruling-gvisor-demos;basis=Validate logical parent input as before, require the demo route in gVisor mode and apply Physical once to the small demo parent. Existing request query read unchanged; shares stay logical.;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=root: after the unchanged ValidParentLimit check, a parent outside today's shared set (one or two of small..xlarge) must also pass Server.Fleet.ParentAllowed: CARLOS_FLEET in root's host.env, not a gVisor box, readable MemTotal, and the whole overlap within max(0, MemTotal - max(1 GiB, MemTotal/8)), else 400 before any write. Today's parent set is accepted unchanged on every box. Same one site (r.URL.Query of the agent's request); no read added in this body (MemTotal is read by hostMemTotal through the gate) file:Query@78 2825f7708356c107eb3960e76865ce24eac36e23529374f1a4e78fb4e46b45df |
| @legacy 47730ce40f37422d345356b7f605b7f430a0a1413abb018c519b3b098a17412b internal/instancectl/server.go type Server legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=Re-digested at the pre-land merge: the body includes main's own change under census ruling 292, with no further change from this branch. Census ruling 292 reclassified this declaration accepted-legacy (J2,J4) for root's per-host ordering of legacy run starts against stops; this ruling kept the row as main classed it. Its own addition is the cmd start's poll and wait bounds and its per-host lock map: field declarations only;rev3=census-ruling-rootfs-apps-2;basis=new fields: HostRuntime, ProbeImage, ProbeImageFile, RootfsProbeOut, DenyEvery, the deny's lastDeny and denyMu, the rootfs probe's report and lock, the jit reload counters and imageDigests; genStarting counts binary generation starts per unit; rootfsLocksMu and rootfsLocks, one lock entry per rootfs unit name being started or removed right now, held by a start from its layout through systemctl start and its own cleanup and by a removal from its proof through the raw removal, a removal refusing while it is taken, a waiting start giving up when its request ends, an entry dropped with its last holder or waiter (fixes E6, L2, L3); rootfsProvenHook, a test hook run between the proof and the raw removal; field declarations only; no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 and #329 plan 3 Task 5: the declaration gains sliceLocks (one mutex per host slice, taken by /size and /parent) and Egress (the asserter every start path calls), and its comment names the egress allow (plan 3's ControlDropInDir field was deleted in ef38e13b, the P1 EROFS fix); the same one site, the Statfs field, offset moved; no read added.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 6: comments only: the one-shot pacing fields cover /cmd and /tty, and cmdLocks is now keyed by (role, host) (oneShotKey, PF-7) so a session's start never waits behind a command's; field declarations unchanged; the same one site, no read added;rev3=census-ruling-agent-start-demo-1;basis=Adds fixed demo configuration, registry views, derived runtime root, synchronization and purge guard.;rev3=census-ruling-region-ha-p3b;basis=Add hairpinActive boolean alongside lastDeny under existing deny synchronization. Field declaration only; existing Statfs selector unchanged, no new read or externally supplied authority.;rev3=census-ruling-region-ha-p3b2-rolls;basis=adds one field holding the current hairpin exit watcher, guarded by the root hairpin flock; no new read;rev3=census-ruling-agent-start-demo-3;basis=Retain the snapshot supervisor in instance-control state; no new request-selected path. Census read-site delta: unchanged (1).;rev3=census-ruling-gvisor-demos;basis=Retain Task 1 mode/error/readiness fields, baseline/runtime callbacks, Task 4 per-host validated staged descriptors and root-selected probe nonce. Fix round 1 adds a private writer-operation seam assigned only in package tests, after the unchanged GVisorID admission check; production defaults still call the same checked constructor, WriteRootfs, WriteBundle and verifier. No new direct read or request-controlled callback. Task 5: private injected removal seam for unprivileged tests; production default removes only root-derived bundle and skeleton after both-family proof inside existing start fence. No new request field or agent-selected unit. Task 6: Retain serialized probe nonce, runtime-set identity verifier/token, fixed claims flag, bundle discovery root, and private unprivileged identity seam. No request-controlled callback or path; existing declaration read-site classification unchanged. Task 6 fix round 1: private gvisorProbeTestOps is set only in package tests; production defaults retain all fixed paths and the checked root output opener. No externally supplied callback or new direct read. Final R1 P2: retain fixed skeleton parent and concurrent per-instance cleanup refusals; no direct read or external configuration field. Carry the root-only host.env validation callback into Ready; no agent read or caller-selected path.;rev3=census-ruling-same-box-edge-fence;basis=Field declarations only: NFT (the nft runner; nil never loads the fence), EdgeFenceOff (host.env CARLOS_EDGE_FENCE=off), and under the existing denyMu/mu: fenceAddrs, fenceReason, fenceRetry, denyApplied. No read added.;rev3=census-ruling-bounded-systemctl;basis=new field Journal, the journalctl seam for the gVisor probe's diagnostic; field declaration only; no read added;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=root: new field Fleet cgroup.FleetGate (#892 S2), root's fleet-size gate; field declaration only; no read added file:Statfs@5536 6187fe6aaa37d3e4740b72153fa648038ef9e2a3a998654234811be8c159bc8d |
| @legacy 1e939943a684cdb32282f7b1c7da889ad11acff9f59da960d35a0299b3a49110 internal/instancectl/size.go Server.handleSize legacy accepted-legacy accepted-legacy;rev3=census-ruling-instance-egress-sizes-328-329;identity=instance control (/opt/carlos/carlos instance-control, carlos-instance-control.service, root);basis=root-input (J2,J4, as Server.handleParent): new (#329 plan 3 Task 5): POST /size from the agent (the peer check admits only the edge unit's main process; claimAwareLegacy answers 503 with host claims on). Its one site is r.URL.Query() of that request (counted as file:Query): host must pass ValidHostShape, memory_max and gen are refused, size must name a row of cgroup.Sizes. Under the slice lock it runs systemctl set-property --runtime on SliceName(host) with that row's CPUWeight, CPUQuota and IOWeight, then writeSizeReadBack runs systemctl show of the slice and answers it. Root sets the slice's CPU and IO shares from the agent's choice among four platform rows; nothing from the request reaches systemctl as a string.;rev3=census-ruling-agent-start-demo-1;basis=Reads fixed DemoBox and clamps the existing live CPU/IO writer to small.;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=root: after the unchanged SizeByName check, the named row must pass Server.Fleet.GenAllowed (a shared size always; a fleet size only on a CARLOS_FLEET box, not gVisor, within the MemTotal budget), else 400 before any systemctl call. Same one site; no read added in this body file:Query@96 ef6d9da8f61aacd18fcfb6c19fe2113dde5414c97fab67de8d2e1ce5782273bb |
| +@legacy 6f7a98c34688769cfcc2f83d118fccbc6687019f895a6e32e2c6134cfa33a75c internal/activator/fleetreserve_linux.go memAvailable legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=new (#892 S2), the agent as carlos, not root: os.ReadFile of the fixed /proc/meminfo (kernel-written; no tenant, app or agent can write or name it), then parseMemAvailable (the MemAvailable line in kB). Used only to admit or refuse a fleet-size overlap; an error refuses it and the old build keeps serving file:ReadFile@48 5d103dc06ce36dca4323999597c2ed1c15cbed2e63018549ca7b0581aee2c42f |
| @legacy cfc2cad27651e696bdb8b59a3f7caf137df9eae22cce0b3efd73b2509da19b82 internal/cgroup/fleetgate.go ReadMemTotal legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=new: os.ReadFile of the path its caller names, then ParseMemTotal (the MemTotal line in kB, positive, bounded). Its callers pass the fixed /proc/meminfo only (instancectl hostMemTotal for root, the agent's cgroup setup closure); kernel-written, not writable by a tenant, app or agent. Used only to bound fleet sizes; an error refuses every fleet size file:ReadFile@59 00e5b8e25b9e3dbc9ee3e449ceaa22d283d69969dfc6582b2cfcdc74c07ef69e |
| +internal/activator/activator.go type Service authority B,C,D,F,J4 rev3=PROPOSED-seed; existing activator lifecycle and due-wake state plus owned seed exclusion and incarnation-keyed diagnostics; normal refusal and preparation ordering remain authoritative; PROPOSED-plans-2-box-limits adds the idleFor hook field, which only narrows idle windows;rev3=census-ruling-plans-4c-box-throttle;basis=gains the maxRunFor hook field beside idleFor (plans 4c). No read added.;rev3=census-ruling-plans-4d-lapse;basis=gains the disabledFor hook field beside maxRunFor (plans 4d). No read added.;rev3=census-ruling-remote-instance-metrics;basis=gains tenancySeq, hostTenants and hostMixed, in-memory fields for Tenancies; no read added;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: one more field, markers (markerRetry: an atomic running flag and the last log time) for retryOwedMarkers; no read added; merge of origin/main d7ae1d76: main's fields are kept as main has them (census-ruling-remote-instance-metrics: tenancySeq, hostTenants, hostMixed); this branch's change is the same as above;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 7 and 8: new fields for rootfs admission (rootfsArmed, rootfsSwept), the per-host gate ask and refusal memo, and residency state (lister, backoff, start ceiling, cursor, test seam); no read;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: one new field, releaseOps (host to the in-memory release record, under a.mu); no read;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W: one new field, leaseNow (a clock seam for a worker start's headroom against the lease deadline, nil is the real clock); no read;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2: gains the holder cache and its single-flight state; no read;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (controller ruling after branch review R1, and Paul's R2 ruling): one field, Fleet (activator.FleetWake: the box's fleet state, not on a fleet by default, on a fleet with a known label and a record reader, or on a fleet with an invalid identity), set by the agent before Start and read only by routeCurrentUnderLease. No read in the declaration. Agent, not root.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a fix round 1: one field, drainBudget (time.Duration), which New copies from residentDrainBudget and a rootfs entry's lease watch reads in its place, so a test's change of the package var never races a watch goroutine; declaration only, reads nothing; merge of origin/main 6f1f6ca6: main's one field, Fleet (activator.FleetWake), is kept as main has it (census-ruling-managed-fleets-1b); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b3a;basis=Add bounded placement peer and diagnostic state and the over-capacity callback; no read in this declaration and no new root authority.;rev3=census-ruling-stateless-replicas-1;basis=Add coordinator, existing-record observation callback and per-host preparation locks; no read in the declaration. Task 3a: Add optional canonical storage-selection and durable deploy-ID callbacks; declaration only, no read or authority in these fields.;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): adds the heldLegs map to actEntry (legs by id, under a.mu) and heldWakeHook (atomic pointer to a callback) and heldLegSeq (atomic counter) to Service. State only, in memory; no read of tenant, app or box-agent-writable input.;rev3=census-ruling-wake-storm-cap;basis=the agent as carlos: one field, wakeSlots (chan struct{}, the wake semaphore made by New from Config.WakeSlots, default 4); declaration only, no read.;rev3=census-ruling-region-ha-p1b3b-t;basis=Add the B2 DutyStore interface field and process-local duty view, suppression and invalidation state. No read added. B2 adds the verified-successor identity callback; no read in the declaration. B3b adds a nonblocking departure-suspicion callback, invoked only after an accepted holder-forward failure and after cache locks release; it cannot authorize a take.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: immutable callbacks installed before Start for tenant admission, local start permission, fixed route exemptions and shutdown closure; nil callbacks preserve switch-off behavior; no new reads. Fix R1: add an immutable startup-phase callback for response copy, set before service startup. No new read or execution authority.;rev3=census-ruling-region-ha-g2-fixes;basis=Add in-memory HA loss state and pool withdrawal jobs; no new read.;rev3=census-ruling-region-ha-held-build;basis=region HA held-requests Task 1: one new field, drain (drainSources: two atomic func pointers for this box's and peers' drain state); no read added. region HA held-requests Task 2: one new field, moves (moveTable: per-host move state, hold counts and admission tickets in memory, under mu); no read added;rev3=census-ruling-held-move-speed;basis=the agent as carlos: one new field, moveStreams (per-host in-memory set of edge.StreamEnd for requests in flight, own mutex), for the move's early stream cut; actEntry gains drainRelease (bool, under a.mu), set by DrainStop; declarations only, no read added;rev3=census-ruling-fix-silent-start-kill-861;basis=#861: two fields, wakeFailMu and wakeFailLogged (per-host in-memory note of the last journalled wake failure); declaration only, no read;rev3=census-ruling-w6-ingress-drain;basis=new field TenantStartsClosed func() bool; when it answers true tenantStartRefusal refuses every start, exempt routes included. Wired only by fixedAdmission.bind to the ingress drain's closed flag. Struct field only; no read added.;rev3=census-ruling-stateless-replicas-4-task2;basis=Task 2: one field, replicaPolicies (host to the newest observed replica deploy and this box label, under mu), set only by SetReplicaDeploy; declaration only, no read.;rev3=census-ruling-stateless-replicas-4-task2-fix1;basis=Task 2 fix round 1: one more in-memory field, replicaFailed (host to the permit whose successor failed here, under mu), so that step only proves what it kept; declaration only, no read.;rev3=census-ruling-stateless-replicas-4-task3f;basis=Task 3F fix round 3 (#511 F11): two hook fields, MarkReplicaRelease and ReplicaReleaseMark (the failure book's per-host release mark on this box's disk). No read site.;rev3=census-ruling-stateless-replicas-4-task5;basis=Task 5 first commit (#511 F11): one in-memory field, heldSeen (host to the last held release attempt, error class and when it was met), under the existing wakeFailMu. Declaration only, no read.;rev3=census-ruling-stateless-replicas-4-merge-main;basis=Merge of main 5fac2ff1: both sides changed it. Main (27d3f501) adds the background atomic.Int64 field that tests wait on; this branch keeps its replica fields. Both kept as-is; no read added.;rev3=census-ruling-stateless-replicas-4-final;basis=#511 final wave item 3: adds replicaSwitched, an in-memory map of the permit each set row switched under (host -> permit key, time, resident flag); no read added; #511 micro-fix P1b: adds replicaNoGen, an in-memory map (host -> permit key and when first seen) that is only the bound's clock for a restarted permit holder with no generation; no read added;rev3=census-ruling-stateless-replicas-4-drill1;basis=#511 drill 1 R20 bound (round 1: clock with start and last seen): one in-memory field, releaseConfigWaits (per host, a stateless release's config wait), under mu; no read;rev3=census-ruling-stateless-replicas-4-r28;basis=R28 review round 2 (#511): one field, retiringCopy, an atomic pointer to the edge's in-memory retired-copy check, handed over by edge.New (SetRetiringCopy); no read, no root decision;rev3=census-ruling-g6-fence;basis=G6 F-C Task 3, the agent as carlos: four fields, fenceWatchers (sync.WaitGroup of running write-fence watchers) and three test seams nil in production (fenceWatchStarted, retainDB, wakeReturned). Declaration only, no read.;rev3=census-ruling-fleet-record-labels-m1;basis=fleet record labels R1/R2: actEntry gains checkpoint state (busy while CloseProven runs, unproven, named-once flag for C45), in-memory under a.mu; the worker gains fence pacing apart from crash backoff; Service gains test seams nil in production; declarations only, no read;rev3=census-ruling-race-activator-1249;basis=adds two test-only fields: leaseWork (a WaitGroup counting lease watches and the one-shot stops a short lease starts) and leaseWatchStop (a channel, nil in production, that a test closes to end every lease watch); no read added and production never waits on or closes either;rev3=census-ruling-fleet-restart-wake;basis=Fleet restart wake Task 1: the per-host journal note maps (wakeFailLogged, heldSeen) move into the embedded wakeNotes struct in wakefaillog.go, which adds fenceSeen. In-memory only; no read added.;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=the agent (carlos-edge.service, user carlos), not root: two fields (#892 S2): BoxLabel (string, the rollout's own box label, set by armRollout) and fleetReserve (*fleetReservations, made by New with memAvailable), the box's in-memory overlap reservation for fleet sizes. Declaration only; no read added 4ce9eb2bbad7a6583e2a1277d4b869dac5bc450c419dcf34c09cdfb4dd2bbef4 |
| +internal/activator/opset.go Service.leaveSet legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=the agent as carlos (#892 S2): after a member's termination is proven and it leaves the set, the fleet-size overlap reservation it holds (genMember.reserve) is released, in memory, under a.mu. No read added; no root call added; the restore and the proof are unchanged whole:Route@167,whole:Route@262 d98d4d22859c0b0e0ce554518bd5f58a801746f0059195201eed1b481f9d2ecd |
| +internal/activator/swap.go Service.swapOverlap legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=Re-digested at the pre-land merge: the body includes main's own change under census ruling zddr4, with no further change from this branch. the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body; admission and the switch refuse while a run's unit is starting, and the switch interrupts runs on the retiring generation; read sites unchanged, offsets moved;rev3=census-ruling-instance-egress-sizes-328-329;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=#329 plan 3 Task 4 and the final review: the new kind is registry:Size, one site, rt.Size != "" in the successor's max rule (the successor starts at the larger of its own sized tier and the incumbent's captured tier when the route has a size now or the incumbent runs at a tier other than its build's), and two more whole:Route sites: the successor's route is now sizedRouteLocked(e) with the wake route kept beside it as wakeRt for the incumbent's tier, and a second GenTier(rt, incumbent.Build) in that rule. The column comes from the agent's registry row (reconcile, from the signed app policy). Admission also refuses while a live size change is in flight. The raise still goes to root's /parent, whose memory_max root checks against its size table; no root decision here;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 N1, Task 8 and Task D: the incumbent's tier is recorded through recordCurrentTierLocked; genHealthy takes rt (so a rootfs generation is checked within the rootfs bound); the successor is installed through installProcLocked; after step 8 a rootfs build's declared processes are logged, never started (rootfsProcessesHook); no new file read;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R, R2: two new parameters from releaseBeforeSwap (pass, the proven pass, and due, whether the build needed a release); the admission and the exec gate both also ask releaseAdmitsSwapLocked, which refuses while any release record of the host is open (INV-R4) and, when a release was due, unless pass is this attempt's for the successor's build (INV-R5); no release runs here; the same 18 read sites, no read added; adds refusals only;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W2: step 8 no longer calls rootfsProcessesHook(ctx, e, rt, m.gen); it calls handOverRootfsWorkers(e), which stops and proves the retiring generation's workers gone and then registers the switched generation's set as pending (starts nothing; the tick starts them, and the stray rule refuses a start while an old worker is a stray, so two sets never run at once); site -whole:Route (rt no longer handed to the hook); no read added;rev3=census-ruling-edge-page-cache-1;basis=noteCurrent(e) instead of noteCurrent(e.host, m.gen.N) at the switch, as Service.wake; read sites unchanged (17); no read added;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=the agent as carlos (#892 S2): after admission and before the raise, a successor whose tier is a fleet size reserves its full MemoryMax through reserveFleetOverlap (memAvailable reads /proc/meminfo). With no room or an unreadable read the attempt is abandoned with PS-2-C05 before any raise, publication or spawn; the incumbent keeps serving. The token is stored on the member, released at once on a refused raise, a failed publication or a refused exec gate (nothing spawned), and otherwise moves to the retiring member at the switch. Adds a refusal only; the raise still goes to root's /parent unchanged; no root decision here. Read sites unchanged (17) registry:Kind@2060,registry:Size@5198,whole:Route@11149,whole:Route@13230,whole:Route@13237,whole:Route@13277,whole:Route@2062,whole:Route@2386,whole:Route@3729,whole:Route@3733,whole:Route@3778,whole:Route@4373,whole:Route@4425,whole:Route@5244,whole:Route@6688,whole:Route@8434,whole:Route@9153 9e25dc3b8ffb4f73453f61b70075da5466040ed25ad213906254e96a56916689 |
| internal/cgroup/cgroup.go setup legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-hunt-account-root-hardening;basis=setup records whether the flat IMDS fence is armed (CARLOS_IMDS_FLAT_FENCE); when armed, a flat start whose shim or placement is unavailable is refused instead of falling back to start-and-move; no read is added;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=the agent (carlos-edge.service, user carlos), not root: setup now also records a fleet-size gate on the agent's own Manager when CARLOS_FLEET is set in its environment (os.Getenv, beside the existing CARLOS_IMDS_FLAT_FENCE read). The gate's MemTotal closure reads /proc/meminfo through ReadMemTotal when a strict prepare is asked for a fleet size (#892 S2). It only lets the strict validators (PrepareStrict, PrepareGen, SetParentLimit) accept the new fleet rows within FleetMemoryBudget; without CARLOS_FLEET they take small..xlarge and today's parents exactly as before. Reads added: env CARLOS_FLEET; /proc/meminfo (kernel, fixed path) via the closure file:ReadFile@73 1c2d963c219576573ba11b9b1ba07c3823902b850615a93406f6cfc3c78065cb |
| +internal/host/rollout.go armRollout legacy accepted-legacy accepted-legacy;rev3=fix1-merge-review;basis=Comment-only clarification of failure-book saves; existing agent rollout setup remains legacy.;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: after the overlap scheduler arms, calls svc.ArmRootfs() so rootfs rows start only where the scheduler armed this boot; never on the refuseManaged path; no read added;rev3=census-ruling-stateless-replicas-1;basis=Task 3a: Bind Service.ReplicaDeployID to the same FailureBook the scheduler owns and bind RuntimeSelection to one CanonicalStatelessDigest read through the existing store. Fix 3a round 1 R18: canonical selection receives route stateless projection to keep legacy DemandHold fallback only for stateful/unknown builds; staged digest mismatch still refuses.;rev3=census-ruling-stateless-replicas-4-task2-fix1;basis=Task 2 fix round 1: the scheduler box label is rolloutBox(svc): the fleet identity label already on svc.Fleet (set from identity.Label before the scheduler arms), else BoxLabel() as before. No read added.;rev3=census-ruling-stateless-replicas-4-task3f;basis=Task 3F fix round 3 (#511 F11): also hands the failure book's MarkReplicaRelease and ReplicaReleaseMark to the activator, beside ReplicaDeployID. The book is the same file the agent already opened; no new read.;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=the agent as carlos (#892 S2): also sets svc.BoxLabel = rolloutBox(svc), the label the scheduler already uses, for the PS-2-C05 refusal text. No read added registry:App@3165,registry:Stateless@3184,whole:Route@3160,whole:Route@3852,whole:Route@3936 ae4f008b6f31852c7afd387add5eb2f31f9df4b520a079117397033491c0a44f |
| internal/instancectl/gen.go Server.handleParent legacy accepted-legacy accepted-legacy;rev3=J2,J4;basis=root-input;rev3=census-ruling-instance-egress-sizes-328-329;basis=#329 plan 3 Task 5: holds the host's slice lock (lockSliceWrites) around its one set-property, so /parent and /size never interleave on one slice. Its one site is still r.URL.Query() of the agent's request (counted as file:Query). The checks in this body are unchanged, though cgroup.ValidParentLimit, which it calls, now accepts one size or the sum of any two from the four-row table (up to 4 GiB, was 2 GiB); no read added.;rev3=census-ruling-agent-start-demo-1;basis=Reads fixed DemoBox and clamps the existing parent memory writer to small.;rev3=census-ruling-gvisor-demos;basis=Validate logical parent input as before, require the demo route in gVisor mode and apply Physical once to the small demo parent. Existing request query read unchanged; shares stay logical.;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=root: after the unchanged ValidParentLimit check, a parent outside today's shared set (one or two of small..xlarge) must also pass Server.Fleet.ParentAllowed: CARLOS_FLEET in root's host.env, not a gVisor box, readable MemTotal, and the whole overlap within max(0, MemTotal - max(1 GiB, MemTotal/8)), else 400 before any write. Today's parent set is accepted unchanged on every box. Same one site (r.URL.Query of the agent's request); no read added in this body (MemTotal is read by hostMemTotal through the gate) file:Query@78 2825f7708356c107eb3960e76865ce24eac36e23529374f1a4e78fb4e46b45df |
| internal/instancectl/server.go runWithClaim authority C,D,G Claim instance controller adds held-release RPC dispatch within existing launch/participation execution boundary.;rev3=census-ruling-rootfs-apps-2;basis=takes a RegistryView (HostApp and HostRuntime) for the bare hostApp, and the production Server literal gains HostRuntime, ProbeImage: BuildProbeImage, ProbeImageFile: ProbeImagePath, RootfsProbeOut under /run/carlos-control and DenyEvery: 10s; this body reads nothing new itself; the readers it wires (instanceRegistryHostRuntime, BuildProbeImage, the rootfs probe's output) are decision rows;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 4 and #329 plan 3 Task 5: takes the egress asserter as a parameter, sets it on the production Server literal (Egress) and starts its 30 s Loop beside probeLoop and diskLoop; the literal also names the fixture check ProbeFixturesOK (renamed in plan 2 Task 14). It sets no control drop-in directory: plan 3's ControlDropInDir default (/run/systemd/system.control) was deleted with removeGenControlDropIn in ef38e13b (the P1 EROFS fix), so instance control names systemd's control directory only to read it (TrustedDropinReader). The same four sites (the two exec.CommandContext closures, statfsBytes, the data literal), offsets moved; no read added.;rev3=census-ruling-agent-start-demo-1;basis=Wires root-owned demo config and existing fixed paths into the service.;rev3=census-ruling-region-ha-p3b;basis=Resume root-owned hairpin state before probes/control service work; verify current systemd agent identity and kernel fence/addresses, restore pidfd watch or revoke stale state. Same direct exec/statfs/data sites; indirect inputs are protected root snapshot/state and kernel evidence, never receipt data.;rev3=census-ruling-agent-start-demo-3;basis=Construct the demo snapshot supervisor for configured demo boxes; startup cleanup gates builder readiness. Census read-site delta: unchanged (4).;rev3=census-ruling-gvisor-demos;basis=Retain sandbox modes and error; bind host-provided baseline and runtime callbacks without importing host templates. Existing reads unchanged. Task 6: Capture HostClaims once from ControlConfig/hostwrite.Enabled and set the fixed root-owned bundle discovery directory. Existing command and configuration reads unchanged. Task 7: enable gVisor worker construction through fixed unitFamily(roleBuild); readiness proof rechecks sandbox admission and current Ready without reaching the constructor fatal path for transient refusals. Existing command/config reads unchanged. Final R1 P2: wire the fixed /var/lib/carlos/oci-rootfs parent for native readiness evidence; no request-supplied path. Carry the root-only host.env validation callback into Ready; no agent read or caller-selected path.;rev3=census-ruling-same-box-edge-fence;basis=Root. Sets NFT: edgefence.Exec (runs /usr/sbin/nft from PATH with fixed arguments and root-derived stdin, see the envelope) and EdgeFenceOff from os.Getenv; wraps s.Systemctl with guardStarts and calls bindEgressFence; calls denyLocalAddrs once before Serve so a leftover runtime exemption is checked or replaced by the whole deny before any request is served. No new file read; the exec is nft's.;rev3=census-ruling-bounded-systemctl;basis=the production Systemctl closure runs through internal/systemd.Command (same args, combined output, caller ctx; mutations no deadline of their own, queries also QueryTimeout); the new Journal closure runs journalctl through internal/systemd.Command(Journalctl) for the gVisor probe diagnostic only, with the arguments that closure used to pass to Run; no new read, path or input;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=root: the production Server literal gains Fleet: productionFleetGate(os.Getenv), which is Fleet = CARLOS_FLEET set in carlos-instance-control.service's environment (EnvironmentFile /etc/carlos/host.env, root-owned, the same way EdgeFenceOff reads CARLOS_EDGE_FENCE) and MemTotal = hostMemTotal (/proc/meminfo through cgroup.ReadMemTotal, read only when a fleet size is asked for). Reads added: env CARLOS_FLEET; /proc/meminfo (kernel, fixed path, via the gate) data-literal@2897,file:Command@1151,file:Command@1333,file:CommandContext@1512,file:Exec@2713,file:Statfs@2918 61686631222d6594e5d77e1864201ca08bf664d9f4827c852b620849e1556ff7 |
| internal/instancectl/server.go type Server legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=Re-digested at the pre-land merge: the body includes main's own change under census ruling 292, with no further change from this branch. Census ruling 292 reclassified this declaration accepted-legacy (J2,J4) for root's per-host ordering of legacy run starts against stops; this ruling kept the row as main classed it. Its own addition is the cmd start's poll and wait bounds and its per-host lock map: field declarations only;rev3=census-ruling-rootfs-apps-2;basis=new fields: HostRuntime, ProbeImage, ProbeImageFile, RootfsProbeOut, DenyEvery, the deny's lastDeny and denyMu, the rootfs probe's report and lock, the jit reload counters and imageDigests; genStarting counts binary generation starts per unit; rootfsLocksMu and rootfsLocks, one lock entry per rootfs unit name being started or removed right now, held by a start from its layout through systemctl start and its own cleanup and by a removal from its proof through the raw removal, a removal refusing while it is taken, a waiting start giving up when its request ends, an entry dropped with its last holder or waiter (fixes E6, L2, L3); rootfsProvenHook, a test hook run between the proof and the raw removal; field declarations only; no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 and #329 plan 3 Task 5: the declaration gains sliceLocks (one mutex per host slice, taken by /size and /parent) and Egress (the asserter every start path calls), and its comment names the egress allow (plan 3's ControlDropInDir field was deleted in ef38e13b, the P1 EROFS fix); the same one site, the Statfs field, offset moved; no read added.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 6: comments only: the one-shot pacing fields cover /cmd and /tty, and cmdLocks is now keyed by (role, host) (oneShotKey, PF-7) so a session's start never waits behind a command's; field declarations unchanged; the same one site, no read added;rev3=census-ruling-agent-start-demo-1;basis=Adds fixed demo configuration, registry views, derived runtime root, synchronization and purge guard.;rev3=census-ruling-region-ha-p3b;basis=Add hairpinActive boolean alongside lastDeny under existing deny synchronization. Field declaration only; existing Statfs selector unchanged, no new read or externally supplied authority.;rev3=census-ruling-region-ha-p3b2-rolls;basis=adds one field holding the current hairpin exit watcher, guarded by the root hairpin flock; no new read;rev3=census-ruling-agent-start-demo-3;basis=Retain the snapshot supervisor in instance-control state; no new request-selected path. Census read-site delta: unchanged (1).;rev3=census-ruling-gvisor-demos;basis=Retain Task 1 mode/error/readiness fields, baseline/runtime callbacks, Task 4 per-host validated staged descriptors and root-selected probe nonce. Fix round 1 adds a private writer-operation seam assigned only in package tests, after the unchanged GVisorID admission check; production defaults still call the same checked constructor, WriteRootfs, WriteBundle and verifier. No new direct read or request-controlled callback. Task 5: private injected removal seam for unprivileged tests; production default removes only root-derived bundle and skeleton after both-family proof inside existing start fence. No new request field or agent-selected unit. Task 6: Retain serialized probe nonce, runtime-set identity verifier/token, fixed claims flag, bundle discovery root, and private unprivileged identity seam. No request-controlled callback or path; existing declaration read-site classification unchanged. Task 6 fix round 1: private gvisorProbeTestOps is set only in package tests; production defaults retain all fixed paths and the checked root output opener. No externally supplied callback or new direct read. Final R1 P2: retain fixed skeleton parent and concurrent per-instance cleanup refusals; no direct read or external configuration field. Carry the root-only host.env validation callback into Ready; no agent read or caller-selected path.;rev3=census-ruling-same-box-edge-fence;basis=Field declarations only: NFT (the nft runner; nil never loads the fence), EdgeFenceOff (host.env CARLOS_EDGE_FENCE=off), and under the existing denyMu/mu: fenceAddrs, fenceReason, fenceRetry, denyApplied. No read added.;rev3=census-ruling-bounded-systemctl;basis=new field Journal, the journalctl seam for the gVisor probe's diagnostic; field declaration only; no read added;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=root: new field Fleet cgroup.FleetGate (#892 S2), root's fleet-size gate; field declaration only; no read added file:Statfs@5536 6187fe6aaa37d3e4740b72153fa648038ef9e2a3a998654234811be8c159bc8d |
| internal/instancectl/size.go Server.handleSize legacy accepted-legacy accepted-legacy;rev3=census-ruling-instance-egress-sizes-328-329;identity=instance control (/opt/carlos/carlos instance-control, carlos-instance-control.service, root);basis=root-input (J2,J4, as Server.handleParent): new (#329 plan 3 Task 5): POST /size from the agent (the peer check admits only the edge unit's main process; claimAwareLegacy answers 503 with host claims on). Its one site is r.URL.Query() of that request (counted as file:Query): host must pass ValidHostShape, memory_max and gen are refused, size must name a row of cgroup.Sizes. Under the slice lock it runs systemctl set-property --runtime on SliceName(host) with that row's CPUWeight, CPUQuota and IOWeight, then writeSizeReadBack runs systemctl show of the slice and answers it. Root sets the slice's CPU and IO shares from the agent's choice among four platform rows; nothing from the request reaches systemctl as a string.;rev3=census-ruling-agent-start-demo-1;basis=Reads fixed DemoBox and clamps the existing live CPU/IO writer to small.;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=root: after the unchanged SizeByName check, the named row must pass Server.Fleet.GenAllowed (a shared size always; a fleet size only on a CARLOS_FLEET box, not gVisor, within the MemTotal budget), else 400 before any systemctl call. Same one site; no read added in this body file:Query@96 ef6d9da8f61aacd18fcfb6c19fe2113dde5414c97fab67de8d2e1ce5782273bb |
| +internal/activator/fleetreserve_linux.go memAvailable legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=new (#892 S2), the agent as carlos, not root: os.ReadFile of the fixed /proc/meminfo (kernel-written; no tenant, app or agent can write or name it), then parseMemAvailable (the MemAvailable line in kB). Used only to admit or refuse a fleet-size overlap; an error refuses it and the old build keeps serving file:ReadFile@48 5d103dc06ce36dca4323999597c2ed1c15cbed2e63018549ca7b0581aee2c42f |
| internal/cgroup/fleetgate.go ReadMemTotal legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=new: os.ReadFile of the path its caller names, then ParseMemTotal (the MemTotal line in kB, positive, bounded). Its callers pass the fixed /proc/meminfo only (instancectl hostMemTotal for root, the agent's cgroup setup closure); kernel-written, not writable by a tenant, app or agent. Used only to bound fleet sizes; an error refuses every fleet size file:ReadFile@59 00e5b8e25b9e3dbc9ee3e449ceaa22d283d69969dfc6582b2cfcdc74c07ef69e |
| +@coverage internal/activator 0ab9cadf2bcf21005a739f9725e41de95b1205130d5c1e40c36d8f25620bf504 |
| @coverage internal/apppolicy 0a758be8a30d847d27ff610736b668a526b8e5f47e6dcc042a8c143c25864295 |
| @coverage internal/cgroup 18eb14bb51403da80ca35f8046278f79557a890d21527ec868a16b80d508e54f |
| -@coverage internal/host 3a3bc8cc219234ee5669caa1b041ef7596655cbd4ae6a2397ca9a55ecc15c353 |
| +@coverage internal/host cb2b0b3a72b55dc374f6c0d4d290b4d2917c344cde6b82a6a58b931d33515c7e |
| @coverage internal/instancectl 0dff99b0e92f914797c9c1004c9ad1af71e8704661a5dc14d0f6994c10f90f92 |
| @coverage internal/release 97eb61c0652f9fe333f21f77359133ef4e0d9bbba777418ca67f8fab6799ad75 |