carlos / platform Public

fix: show a refused fleet-size overlap on the instance's events (#892 S2)

Review round 1 of Task 4. The rollout scheduler emits PS-2-C05 as a
swap.no_room warn event on the instance's own stream when an overlap is
refused for want of memory, once per run of refusals (hostSlot
.noRoomShown), shown again only after another outcome clears it. The
activator exports ErrFleetOverlapRefused for that classification.

The reservation tests now wait on the reaped member's done channel, not
an empty set, before asserting the bytes were returned (leaveSet
releases after the delete and before done closes).

Census re-proposed: scheduler.done gains a whole:Route site.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 8090db11c357caf35c9094ef378e4b51f5b832d5 parent de78766
10 files changed, +176 −14
  • docs/superpowers/notes/census-proposal-stateless-scale-2-fleet-sizes.md +4 −2
  • internal/activator/fleetreserve.go +8 −0
  • internal/activator/fleetreserve_test.go +38 −6
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-stateless-scale-2-fleet-sizes.tsv +5 −2
  • internal/rollout/events.go +3 −0
  • internal/rollout/fake_test.go +4 −1
  • internal/rollout/noroom_test.go +89 −0
  • internal/rollout/queue.go +7 −2
  • internal/rollout/scheduler.go +17 −0

Intent

Human

<task-notification> <task-id>aa246ac98e0815e5f</task-id> <tool-use-id>toolu_01QYXnedsFJjuQfLtAYBFjSW</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/29a43d67-87d2-4557-8e9d-9b70d303a90b/tasks/aa246ac98e0815e5f.output</output-file> <status>completed</status> <summary>Agent "Implement S2 Task 4" 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 Commit: `de787661` feat: an overlap to a fleet size reserves its memory first (#892 S2). Not pushed. Tests: the 9 new tests went from RED to GREEN, the 4 mutation checks all failed the tests as they should, and `-race` on the new tests is clean. The `Swap|Sweep|Reap|OpSet` run passed except one timing test, below. Region HA (grouproll, grouprollaws, 12 TestRegionHA tests), the census tests and the darwin, windows and linux/arm64 builds all pass. Concerns: - **Census:** the `internal/activator` and `internal/host` checks were re-pinned, with one new unit, `memAvailable` (fixed `/proc/meminfo`, read by the agent, not root). Decision classes: reads 0, new 2 (`memAvailable` plus Task 1's `ReadMemTotal`), other 0. The Astra/Fable approval on #280 is still owed; I did not dispatch it. - **Box name in PS-2-C05:** I added `Service.BoxLabel`, set in `armRollout` from `rolloutBox(svc)`, the label the rollout's own events already use. - **Conservative refusals:** a new build's memory counts twice while the old build drains (once in its reservation, once in its actual use), so a second fleet-size overlap on the same box during that window may be refused early. This follows the brief's rule. - **Unrelated failure:** `TestSweepBurstOf252MeetsTheDeadline` (`escrow_test.go`), a wall-clock test, failed with the box's load average at 16.8. The rest of the run passed with it skipped. Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/stateless-scale-1/.superpowers/sdd/2026-11-22-892-s2-fleet-sizes/task-4-report.md</result> <usage><subagent_tokens>192336</subagent_tokens><tool_uses>63</tool_uses><duration_ms>1523509</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>buj8no9c9</task-id> <tool-use-id>toolu_01C7xBZ9q6c6GzVffoPTaHzh</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/29a43d67-87d2-4557-8e9d-9b70d303a90b/tasks/buj8no9c9.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/task4-review-brief.md $WS/task-4-review-astra.md &gt; $WS/astra-task4.log 2&gt;&amp;1" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>af43a305598457382</task-id> <tool-use-id>toolu_011tSgSBwhvSoB6J6SpP1MGJ</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/29a43d67-87d2-4557-8e9d-9b70d303a90b/tasks/af43a305598457382.output</output-file> <status>completed</status> <summary>Agent "Fable review S2 Task 4" 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>READY - Important (I1): a refused fleet-size overlap never tells the operator why. PS-2-C05 reaches only the agent's journal (`internal/rollout/scheduler.go:448-452`), while a bare "swapping" event is emitted before every retry (`scheduler.go:240`), every 15 s for as long as the box is short. This does not block the termination-path contract; it needs a controller ruling: either emit one deduplicated warn event carrying the reason, or waive it to S3/S4.</result> <usage><subagent_tokens>128269</subagent_tokens><tool_uses>23</tool_uses><duration_ms>289675</duration_ms></usage> </task-notification>

Attributed to this commit: 14.8 g CO₂e (1,854,108 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 403146fed..2e0d20858 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
@@ -13,8 +13,9 @@ Ruling `census-ruling-stateless-scale-2-fleet-sizes`. The independent reviewer a
| `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 |
+| `internal/rollout/scheduler.go` `scheduler.done` | sites | +whole:Route | the agent as carlos (#892 S2, review fix round 1): an attempt abandoned with activator.ErrFleetOverlapRefused emits its reason (PS-2-C05, the activator's own text naming only this box) once as a swap.no_room warn event on the instance's event stream, through the existing m.emit with the route s.route already read for the other events (+whole:Route); hostSlot.noRoomShown deduplicates it until an attempt ends another way. In-memory only; no read of a new input, no root call |
-Envelopes re-pinned: `internal/activator`, `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`, `internal/rollout`.
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.
@@ -29,12 +30,13 @@ Recorded dispositions, which each change must still satisfy:
- `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
- `internal/instancectl/size.go` `Server.handleSize`: legacy, task accepted-legacy. Basis: 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.
+- `internal/rollout/scheduler.go` `scheduler.done`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1,J4;basis=route-and-input;rev3=census-ruling-stateless-coordinator-route;basis=P25: classifies the preserved SwapResult.Err with errors.Is, including wrapped console-unreachable causes, to record the current scheduler revision and suppress duplicate abandoned logs. Diagnostic text no longer grants this classification. No new read sites or failure-book authority.
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` → `0377659fd972285e8d368f7b27764c6c82d796ca10996427bb014147086b87b5`.
+Seal: `47ebd73418bcbe1bdf9cf34a2b94e3393a1279aea58f9ee0aca3f0cfe42b9132` → `06dc311caae1f568db8bead1f516749cc71e5abad09753cfea6630bf5900ae60`.
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/fleetreserve.go b/internal/activator/fleetreserve.go
index bdcc3e4f3..4addab154 100644
--- a/internal/activator/fleetreserve.go
+++ b/internal/activator/fleetreserve.go
@@ -36,6 +36,11 @@ import (
// have reserved, is below the successor's limit.
var errFleetNoRoom = errors.New("not enough free memory")
+// ErrFleetOverlapRefused matches (errors.Is) every refused fleet-size
+// overlap reservation, whatever its cause: the rollout reports its reason,
+// PS-2-C05, on the instance's event stream.
+var ErrFleetOverlapRefused = errors.New("fleet-size overlap refused: no memory reserved")
+
// 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.
@@ -138,6 +143,9 @@ type fleetNoRoomError struct {
func (e fleetNoRoomError) Error() string { return fmt.Sprintf(fleetNoRoomMsg, e.box) }
func (e fleetNoRoomError) Unwrap() error { return e.cause }
+func (e fleetNoRoomError) Is(target error) bool {
+ return target == ErrFleetOverlapRefused
+}
// parseMemAvailable is /proc/meminfo's MemAvailable, in bytes.
func parseMemAvailable(meminfo []byte) (int64, error) {
diff --git a/internal/activator/fleetreserve_test.go b/internal/activator/fleetreserve_test.go
index 9b3eb4235..c5177f086 100644
--- a/internal/activator/fleetreserve_test.go
+++ b/internal/activator/fleetreserve_test.go
@@ -93,6 +93,35 @@ func setStuck(p *fakeProc, stuck bool) {
p.mu.Unlock()
}
+// memberDones is the done channel of every member of host's set, captured
+// before a reap: leaveSet releases the reservation before it closes done,
+// so a closed done means the release has happened (an empty set alone
+// does not).
+func (f *fleetFixture) memberDones(t *testing.T, host string) []chan struct{} {
+ t.Helper()
+ f.a.mu.Lock()
+ defer f.a.mu.Unlock()
+ var out []chan struct{}
+ for _, m := range f.a.entries[host].ops.members {
+ out = append(out, m.done)
+ }
+ if len(out) == 0 {
+ t.Fatalf("%s has no member to wait on", host)
+ }
+ return out
+}
+
+func waitDone(t *testing.T, what string, dones []chan struct{}) {
+ t.Helper()
+ for _, d := range dones {
+ select {
+ case <-d:
+ case <-time.After(5 * time.Second):
+ t.Fatalf("timed out waiting for %s", what)
+ }
+ }
+}
+
func (f *fleetFixture) members(host string) int {
_, m := f.a.genStateForTest(host)
return len(m)
@@ -136,7 +165,7 @@ func TestFleetLargeSwapReservesHeadroom(t *testing.T) {
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) {
+ if !errors.Is(refused.res.Err, errFleetNoRoom) || !errors.Is(refused.res.Err, ErrFleetOverlapRefused) {
t.Fatalf("the refusal's error %v does not wrap errFleetNoRoom", refused.res.Err)
}
if got := f.a.fleetReserve.held(); got != need {
@@ -200,8 +229,9 @@ func TestFleetReserveUnprovenCandidate(t *testing.T) {
}
_, p := f.b.lastGen()
p.exit()
+ dones := f.memberDones(t, f.host)
f.a.sweepOnce()
- waitFor(t, "the candidate reaped", func() bool { return f.members(f.host) == 0 })
+ waitDone(t, "the candidate reaped", dones)
if got := f.a.fleetReserve.held(); got != 0 {
t.Fatalf("reserved %d after the proof, want 0", got)
}
@@ -230,8 +260,9 @@ func TestFleetReserveUnprovenRetiring(t *testing.T) {
t.Fatalf("reserved %d after a sweep that proved nothing, want %d", got, need)
}
inc.exit()
+ dones := f.memberDones(t, f.host)
f.a.sweepOnce()
- waitFor(t, "the retiring generation reaped", func() bool { return f.members(f.host) == 0 })
+ waitDone(t, "the retiring generation reaped", dones)
if got := f.a.fleetReserve.held(); got != 0 {
t.Fatalf("reserved %d after the proof, want 0", got)
}
@@ -322,8 +353,9 @@ func TestFleetReserveSpawnErrorKeeps(t *testing.T) {
t.Fatalf("reserved %d after a failed proof, want %d", got, need)
}
f.kb.setErr(nil)
+ dones := f.memberDones(t, f.host)
f.a.sweepOnce()
- waitFor(t, "the generation proven empty", func() bool { return f.members(f.host) == 0 })
+ waitDone(t, "the generation proven empty", dones)
if got := f.a.fleetReserve.held(); got != 0 {
t.Fatalf("reserved %d after the proof, want 0", got)
}
@@ -360,8 +392,8 @@ func TestFleetReserveUnreadable(t *testing.T) {
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 res.Outcome != SwapAbandoned || res.Reason != want || !errors.Is(res.Err, ErrFleetOverlapRefused) {
+ t.Fatalf("Swap = %+v, want abandoned with %q, matching ErrFleetOverlapRefused", res, want)
}
if gens, raises, _ := f.b.calls(); gens != 0 || raises != 0 {
t.Fatalf("%d spawn(s), %d raise(s), want none", gens, raises)
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 7d39bcaf5..170722cf7 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 0377659fd972285e8d368f7b27764c6c82d796ca10996427bb014147086b87b5
+plan14-root-reads-stateless-scale-2-fleet-sizes.tsv 06dc311caae1f568db8bead1f516749cc71e5abad09753cfea6630bf5900ae60
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 472724876..5769889e0 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,5 +1,5 @@
# 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.
-# 9 body, 0 sites, 6 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 9 body, 1 sites, 7 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
@@ -10,6 +10,7 @@
@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
+@legacy 413658ed3c1d8df554d22b30c84585ae601d8b8a9aa9e63eec91a313880127d5 internal/rollout/scheduler.go scheduler.done legacy accepted-legacy accepted-legacy;rev3=J1,J4;basis=route-and-input;rev3=census-ruling-stateless-coordinator-route;basis=P25: classifies the preserved SwapResult.Err with errors.Is, including wrapped console-unreachable causes, to record the current scheduler revision and suppress duplicate abandoned logs. Diagnostic text no longer grants this classification. No new read sites or failure-book authority.;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=the agent as carlos (#892 S2, review fix round 1): an attempt abandoned with activator.ErrFleetOverlapRefused emits its reason (PS-2-C05, the activator's own text naming only this box) once as a swap.no_room warn event on the instance's event stream, through the existing m.emit with the route s.route already read for the other events (+whole:Route); hostSlot.noRoomShown deduplicates it until an attempt ends another way. In-memory only; no read of a new input, no root call file:Exec@5205,whole:Route@8821,whole:Route@9079,whole:Route@9237,whole:Route@9309,whole:Route@9428,whole:Route@9865 52d28e6fb3cf6aa8ca7f43278157108f239d037f322699e8af959bb903ae219e
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
@@ -21,9 +22,11 @@ internal/instancectl/server.go type Server legacy accepted-legacy accepted-legac
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
+internal/rollout/scheduler.go scheduler.done legacy accepted-legacy accepted-legacy;rev3=J1,J4;basis=route-and-input;rev3=census-ruling-stateless-coordinator-route;basis=P25: classifies the preserved SwapResult.Err with errors.Is, including wrapped console-unreachable causes, to record the current scheduler revision and suppress duplicate abandoned logs. Diagnostic text no longer grants this classification. No new read sites or failure-book authority.;rev3=census-ruling-stateless-scale-2-fleet-sizes;basis=the agent as carlos (#892 S2, review fix round 1): an attempt abandoned with activator.ErrFleetOverlapRefused emits its reason (PS-2-C05, the activator's own text naming only this box) once as a swap.no_room warn event on the instance's event stream, through the existing m.emit with the route s.route already read for the other events (+whole:Route); hostSlot.noRoomShown deduplicates it until an attempt ends another way. In-memory only; no read of a new input, no root call file:Exec@5205,whole:Route@8821,whole:Route@9079,whole:Route@9237,whole:Route@9309,whole:Route@9428,whole:Route@9865 52d28e6fb3cf6aa8ca7f43278157108f239d037f322699e8af959bb903ae219e
+@coverage internal/activator 409bac58f019b723377efe6427e4d5c72c0640ab45819c33b8f3cacebdc4af49
@coverage internal/apppolicy 0a758be8a30d847d27ff610736b668a526b8e5f47e6dcc042a8c143c25864295
@coverage internal/cgroup 18eb14bb51403da80ca35f8046278f79557a890d21527ec868a16b80d508e54f
@coverage internal/host cb2b0b3a72b55dc374f6c0d4d290b4d2917c344cde6b82a6a58b931d33515c7e
@coverage internal/instancectl 0dff99b0e92f914797c9c1004c9ad1af71e8704661a5dc14d0f6994c10f90f92
@coverage internal/release 97eb61c0652f9fe333f21f77359133ef4e0d9bbba777418ca67f8fab6799ad75
+@coverage internal/rollout 0ee5bb9c70bc1f941e265c513f4db2f2f1b54a1c0e95e56091b7c05b08ec5c7f
diff --git a/internal/rollout/events.go b/internal/rollout/events.go
index 1f755c0db..15dda570c 100644
--- a/internal/rollout/events.go
+++ b/internal/rollout/events.go
@@ -25,6 +25,9 @@ const (
EvFallbackServed EventCode = "fallback.served"
EvConfigPending EventCode = "config.pending"
EvStagingRefused EventCode = "staging.refused"
+ // EvSwapNoRoom: an overlap to a fleet size was refused for want of
+ // memory on the box (#892 S2); its text is PS-2-C05.
+ EvSwapNoRoom EventCode = "swap.no_room"
)
// reasonWord reads the platform's words, not the names between them: a
diff --git a/internal/rollout/fake_test.go b/internal/rollout/fake_test.go
index b6c1738c7..211cf0b33 100644
--- a/internal/rollout/fake_test.go
+++ b/internal/rollout/fake_test.go
@@ -381,14 +381,17 @@ func (f *fakeRoutes) get(host string) registry.Route {
type eventLog struct {
mu sync.Mutex
lines []string
+ // levels is each line's level, by index (lines keeps its old shape).
+ levels []string
}
func (e *eventLog) App(string, string, string, string) {}
-func (e *eventLog) Event(_, _, host, _, msg string) {
+func (e *eventLog) Event(_, _, host, level, msg string) {
e.mu.Lock()
defer e.mu.Unlock()
e.lines = append(e.lines, host+": "+msg)
+ e.levels = append(e.levels, level)
}
func (e *eventLog) has(substr string) bool {
diff --git a/internal/rollout/noroom_test.go b/internal/rollout/noroom_test.go
new file mode 100644
index 000000000..091ed843b
--- /dev/null
+++ b/internal/rollout/noroom_test.go
@@ -0,0 +1,89 @@
+package rollout
+
+import (
+ "fmt"
+ "slices"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/activator"
+)
+
+// noRoomErr is the activator's refused fleet-size overlap as the scheduler
+// meets it: PS-2-C05 as its text, matching ErrFleetOverlapRefused.
+type noRoomErr struct{}
+
+func (noRoomErr) Error() string {
+ return "not enough free memory on box-1 to start the new build beside the old one. the old build is still serving"
+}
+func (noRoomErr) Is(target error) bool { return target == activator.ErrFleetOverlapRefused }
+
+// A refused fleet-size overlap says why on the instance's own events, once:
+// a box that stays short does not repeat it on every retry. After an
+// attempt that ends any other way, a new refusal is shown again (#892 S2).
+func TestFleetNoRoomWarnsOncePerRun(t *testing.T) {
+ h := newHarness(t, "a")
+ h.stage("v2")
+ h.act.outcome = func(activator.Attempt) activator.SwapOutcome { return activator.SwapAbandoned }
+ setErr := func(err error) {
+ h.act.mu.Lock()
+ h.act.resultErr = err
+ h.act.mu.Unlock()
+ }
+ abandons := func() int {
+ h.logMu.Lock()
+ defer h.logMu.Unlock()
+ n := 0
+ for _, l := range h.logs {
+ if strings.Contains(l, "attempt onto v2 abandoned") {
+ n++
+ }
+ }
+ return n
+ }
+ retry := func(n int) {
+ t.Helper()
+ h.advance(abandonDeferral + time.Second)
+ h.pass()
+ waitFor(t, fmt.Sprintf("attempt %d done", n), func() bool { return abandons() == n })
+ }
+ want := noRoomErr{}.Error()
+ setErr(noRoomErr{})
+ h.install("v2", "a")
+ h.pass()
+ waitFor(t, "the first refusal", func() bool { return abandons() == 1 })
+ retry(2)
+ retry(3)
+ if n := h.events.count(want); n != 1 {
+ t.Fatalf("PS-2-C05 shown %d times over three refused attempts, want 1", n)
+ }
+ h.events.mu.Lock()
+ i := slices.Index(h.events.lines, "a: "+want)
+ level := ""
+ if i >= 0 {
+ level = h.events.levels[i]
+ }
+ h.events.mu.Unlock()
+ if i < 0 || level != "warn" {
+ t.Fatalf("no warn event carrying PS-2-C05 on a's stream (index %d, level %q): %q", i, level, h.eventLines())
+ }
+ if !h.logged(string(EvSwapNoRoom) + " a: " + want) {
+ t.Fatal("the event was not emitted as swap.no_room")
+ }
+ // An attempt abandoned for another reason clears it; the next refusal
+ // is shown again.
+ setErr(nil)
+ retry(4)
+ setErr(noRoomErr{})
+ retry(5)
+ if n := h.events.count(want); n != 2 {
+ t.Fatalf("PS-2-C05 shown %d times after it cleared and recurred, want 2", n)
+ }
+}
+
+func (h *harness) eventLines() []string {
+ h.events.mu.Lock()
+ defer h.events.mu.Unlock()
+ return slices.Clone(h.events.lines)
+}
diff --git a/internal/rollout/queue.go b/internal/rollout/queue.go
index 9fcddf909..9d2ff2bf4 100644
--- a/internal/rollout/queue.go
+++ b/internal/rollout/queue.go
@@ -93,8 +93,13 @@ type hostSlot struct {
notBefore time.Time // a staging refusal's wait (spec §4.2)
consoleUnreachableRev uint64
- running *dispatch
- buildRev uint64 // newest(host): moved only by a change of desired build
+ // noRoomShown is the fleet-size overlap refusal (PS-2-C05) last shown
+ // on the instance's events; "" once an attempt ends any other way. The
+ // event is emitted only when the reason is new, so a box that stays
+ // short does not repeat it on every retry (#892 S2).
+ noRoomShown string
+ running *dispatch
+ buildRev uint64 // newest(host): moved only by a change of desired build
// forceBuilds are `carlos instances retry`'s canary entitlements, one per
// retried build: each lets the adoption onto its build through a halt,
// as a canary. Each is its build's, whatever the slot wants when the
diff --git a/internal/rollout/scheduler.go b/internal/rollout/scheduler.go
index 2ccab1e9c..677942122 100644
--- a/internal/rollout/scheduler.go
+++ b/internal/rollout/scheduler.go
@@ -368,6 +368,18 @@ func (s *scheduler) done(d dispatch, res activator.SwapResult, mode activator.Sw
s.q.rearmRetry(d)
}
h := s.q.hosts[d.ID.Host]
+ // A refused fleet-size overlap (#892 S2): its reason, PS-2-C05, goes on
+ // the instance's events once per run of refusals (noRoomShown).
+ noRoom := res.Outcome == activator.SwapAbandoned && errors.Is(res.Err, activator.ErrFleetOverlapRefused)
+ showNoRoom := noRoom
+ if h != nil {
+ if noRoom {
+ showNoRoom = h.noRoomShown != res.Reason
+ h.noRoomShown = res.Reason
+ } else {
+ h.noRoomShown = ""
+ }
+ }
if h != nil && h.buildRev == d.SchedRev {
h.consoleUnreachableRev = 0
if res.Outcome == activator.SwapAbandoned && errors.Is(res.Err, replicas.ErrConsoleUnreachable) {
@@ -450,6 +462,11 @@ func (s *scheduler) done(d dispatch, res activator.SwapResult, mode activator.Sw
return
}
m.d.Logf("rollout: %s: %s attempt onto %s abandoned: %s", d.ID.Host, d.ID.Cause, d.ID.Build, res.Reason)
+ if showNoRoom {
+ // res.Reason is PS-2-C05 itself (the activator's
+ // fleetNoRoomError), approved copy naming only this box.
+ m.emit(rt, EvSwapNoRoom, "warn", res.Reason)
+ }
}
}