remote-instance-metrics: a setup that swept nothing knows no host clean (branch review round 1 P1)
sweepStale could not list the delegated root and returned quietly, so Leftover reported every host clean. Now a setup that cannot list the root, or a retaining one, makes every host a leftover for the agent's life. Also: the paging test's parse follows metricsLoop's new owners argument (CI). Census re-proposed; branch review brief round 2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 files changed,
+162
−21
docs/superpowers/notes/census-proposal-remote-instance-metrics.md+4 −2docs/superpowers/notes/remote-instance-metrics.md+19 −3docs/superpowers/reviews/CODEX-FINDINGS-remote-instance-metrics-branch-r1.md+56 −0docs/superpowers/reviews/CODEX-REVIEW-BRIEF-remote-instance-metrics-branch.md+20 −1internal/cgroup/cgroup.go+16 −8internal/cgroup/cgroup_test.go+38 −0internal/host/agentalerts_test.go+2 −2internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1internal/provision/testdata/plan14-root-reads-remote-instance-metrics.tsv+6 −4
CI passed — run details
diff --git a/docs/superpowers/notes/census-proposal-remote-instance-metrics.md b/docs/superpowers/notes/census-proposal-remote-instance-metrics.md| index 29b4c6a3c..ff3b5012f 100644 |
| --- a/docs/superpowers/notes/census-proposal-remote-instance-metrics.md |
| +++ b/docs/superpowers/notes/census-proposal-remote-instance-metrics.md |
| @@ -11,7 +11,8 @@ Ruling `census-ruling-remote-instance-metrics`. Every change below keeps the dis |
| | `internal/activator/probewake.go` `Service.ProbeWake` | body | unchanged (4) | the entries-map insertion goes through putEntryLocked; no read added | |
| | `internal/activator/recoveryprobe.go` `Service.RecoveryProbe` | body | unchanged (8) | the entries-map insertion goes through putEntryLocked (its nil-map make moves there); no read added | |
| | `internal/activator/swaphold.go` `Service.holdWakeLocked` | body | unchanged (2) | the entries-map insertion goes through putEntryLocked; no read added | |
| -| `internal/cgroup/cgroup.go` `Manager.sweepStale` | body | unchanged (2) | records the host of a per-host dir it could not remove in an in-memory leftover set (Manager.Leftover) for the metrics sampler; no read added, nothing removed differently | |
| +| `internal/cgroup/cgroup.go` `Manager.sweepStale` | body | unchanged (2) | records the host of a per-host dir it could not remove in an in-memory leftover set (Manager.Leftover) for the metrics sampler, and marks the whole sweep incomplete (every host a leftover) when it cannot list the root; logs that; no read added, nothing removed differently | |
| +| `internal/cgroup/cgroup.go` `setupAt` | body | unchanged (1) | a retaining setup also marks every host a leftover for the metrics sampler (an in-memory flag); no read added | |
| | `internal/console/apiinstances.go` `Server.healthByHost` | body | unchanged (12) | passes nil for ownerAppMetricsFrom's new tenant argument (local rows unchanged); no read added | |
| | `internal/console/apiinstances.go` `Server.instanceHealth` | body | unchanged (18) | a remote record with an accepted rollout entry also counts a metrics reading its box tagged with the record's own account and app as awake (one ownerAppMetricsFrom call over the shared in-memory sweep); registry reads unchanged; no read added | |
| | `internal/console/metricsview.go` `type UnitRow` | body | unchanged (1) | one more unexported field: the per-sample tenant tag index; schema only | |
| @@ -33,6 +34,7 @@ Recorded dispositions, which each change must still satisfy: |
| - `internal/activator/recoveryprobe.go` `Service.RecoveryProbe`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route |
| - `internal/activator/swaphold.go` `Service.holdWakeLocked`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route |
| - `internal/cgroup/cgroup.go` `Manager.sweepStale`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input |
| +- `internal/cgroup/cgroup.go` `setupAt`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 (final review F2): the supervise leaf's name now comes from the new exported constant SuperviseLeaf (the same value, supervise), which root's egress rail (internal/host/egress_rail_linux.go) also uses to tell the agent's own leaf from other cgroups in its delegated subtree. It is still the agent's own delegation dance, run by the agent (cgroup.Setup from runAgent, user carlos) in its own subtree; the same one site, the O_WRONLY OpenFile probe of cgroup.procs and cgroup.subtree_control; no read added. |
| - `internal/console/apiinstances.go` `Server.healthByHost`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Takes only the caller's ownership start per host (sinceByHost): readings only from samples at or after it, via ownerAppMetricsFrom. The awake set, the box pin and the until window are gone. Registry reads unchanged. |
| - `internal/console/apiinstances.go` `Server.instanceHealth`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Records with no local registry row get health only from remoteFacts (a box report whose rollout entry names the record's own account and app, generated after the record was created): awake is Running, held down is Failed, transient or unidentified is Can't tell right now. No metrics readings at all and no registry.Route literal for them. Local records unchanged. |
| - `internal/console/metricsview.go` `type UnitRow`: diagnostic, task H3. Basis: schema-only;rev3=census-ruling-console-remote-instances;basis=Two unexported fields carrying those raw per-sample readings; schema only. |
| @@ -40,6 +42,6 @@ Recorded dispositions, which each change must still satisfy: |
| - `internal/host/metrics_loop.go` `sampler.tick`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input |
| - `internal/metrics/sample.go` `type UnitSample`: diagnostic, task H3. Basis: schema-only |
| -Seal: `9adcf40e879f038fc9285ff85b419d7ce4f03559e31f9afcd40a0f3496af7d8e` → `d9d77f3901969e40169fdd689bc5ccae5f4684a519cd7448130ceb9091911bd6`. |
| +Seal: `9adcf40e879f038fc9285ff85b419d7ce4f03559e31f9afcd40a0f3496af7d8e` → `0c79dc166bf2a8707586b32eebb8ecc5e9155668b3b42168a139700ef889f506`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-remote-instance-metrics.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/notes/remote-instance-metrics.md b/docs/superpowers/notes/remote-instance-metrics.md| index e9bd0b6c4..e0e67f1c2 100644 |
| --- a/docs/superpowers/notes/remote-instance-metrics.md |
| +++ b/docs/superpowers/notes/remote-instance-metrics.md |
| @@ -99,10 +99,13 @@ Where the cgroup's contents come from, and how each is covered: |
| removes the per-host directories left behind (with their charges); one |
| it cannot remove may still hold a process or a child, so that host is |
| recorded as a leftover (`Manager.Leftover`) and never tagged in this |
| - agent's life. |
| + agent's life. A setup that could not list the root at all swept |
| + nothing, so every host is a leftover for this agent's life (branch |
| + review round 1). |
| 3. **Claim mode** retains processes and cgroups across restarts |
| - (`SetupRetaining`). `Tenancies` returns nothing in claim mode, so |
| - nothing is tagged there. |
| + (`SetupRetaining`). `Tenancies` returns nothing in claim mode, and a |
| + retaining setup reports every host as a leftover, so nothing is tagged |
| + there. |
| The tick: |
| @@ -264,3 +267,16 @@ Round 2 (Astra, 0a90c4c3): READY AFTER FIXES. Round 1's P1 resolved. |
| One P2 (request-budget accounting): remote-only views can now start the |
| existing sweep. Fixed above, with `TestRemoteMetricsRequestBudget`. The |
| note's review stops here (AGENTS.md stopping rule 1). |
| + |
| +## Branch review rounds |
| + |
| +Round 1 (Astra, e1233c74): NOT READY, one P1 in the fault family. |
| + |
| +- P1: `sweepStale` returned quietly when it could not list the delegated |
| + root, so `Leftover` reported every host clean and a reused host's |
| + retained charges could be tagged with its new tenant. Fixed as a gate |
| + up front: a setup that cannot list the root, or a retaining one, makes |
| + every host a leftover for the agent's life |
| + (`TestLeftoverAfterAnUnreadableSweep`; three mutants killed). |
| +- Census: Astra approved all fourteen changed units and five envelopes, |
| + and found the four decision rows' bases accurate. |
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-remote-instance-metrics-branch-r1.md b/docs/superpowers/reviews/CODEX-FINDINGS-remote-instance-metrics-branch-r1.md| new file mode 100644 |
| index 000000000..345d3c70d |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-remote-instance-metrics-branch-r1.md |
| @@ -0,0 +1,56 @@ |
| +Reviewed `e1233c74eaade1b0c8f0829ad1bf2c1be9d9c07b` against merge base `563453808bdd4ff0ac7f7c47f5a6e4a3293987f0`. Branch round **1 of 3**; the note’s two completed rounds remain recorded separately. |
| + |
| +1. **P1 — A failed startup sweep permits tagging cgroups whose previous tenant is unknown.** |
| + |
| + **Section:** Box ownership proof, `Manager.sweepStale` / `Leftover`. |
| + **Fault family:** **tenant identity of samples**. |
| + |
| + **Evidence:** [`sweepStale` returns immediately when the root directory listing fails](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/cgroup/cgroup.go:367), without recording that the sweep was incomplete. The new [`Leftover` method](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/cgroup/cgroup.go:403) consequently returns false for every host. [`Vouched`](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/metrics/owner.go:52) accepts that answer as sufficient to tag the reading. |
| + |
| + **Failure scenario:** Tenant A leaves a per-host cgroup containing charged memory across an agent restart. The startup `ReadDir` fails temporarily, so the cgroup is neither removed nor marked leftover. Once filesystem access recovers, tenant B acquires that hostname and wakes. [`startIn` uses `MkdirAll`, which accepts the existing directory](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/cgroup/cgroup.go:585); the new agent’s tenancy history contains only B. Both ownership probes therefore agree on B, and B receives a tagged memory reading that includes A’s retained charges. `CarryTags` cannot protect this case: it concerns previous sampler observations, and this sampler started after the restart. |
| + |
| + **Fix:** Preserve an explicit “startup sweep incomplete” state and refuse all ownership tags while it holds. Do not interpret an unreadable inventory as an empty inventory. Add a regression test that fails the initial directory listing, restores access, and verifies that a reused host remains untagged. |
| + |
| +No additional P2 or P3 findings. |
| + |
| +The targeted tests could not start because the read-only filesystem prevented Go from creating its build directory. Test coverage and mutation sensitivity were inspected in source; mutations and full suites were not run. No files were edited. |
| + |
| +**Census verdicts** |
| + |
| +These approvals concern root-read authority and the recorded dispositions; they do not clear the P1 above. |
| + |
| +| Changed unit | Verdict and evidence | |
| +|---|---| |
| +| `Service.WakeWorker` | **Approve.** Existing wake and shutdown gates remain; insertion adds only tenant bookkeeping. [activator.go:3282](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/activator/activator.go:3282) | |
| +| `Service.begin` | **Approve.** Fence, shutdown and single-entry ordering remain. [activator.go:1527](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/activator/activator.go:1527) | |
| +| `Service.sweepOnce` | **Approve.** Both insertions retain their existing eligibility checks. [activator.go:5042](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/activator/activator.go:5042), [activator.go:5103](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/activator/activator.go:5103) | |
| +| `type Service` | **Approve.** Additional fields hold in-memory tenancy history under the existing mutex. [activator.go:1214](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/activator/activator.go:1214) | |
| +| `Service.ProbeWake` | **Approve.** Claim, held-row, fence and existing-entry refusals remain. [probewake.go:185](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/activator/probewake.go:185) | |
| +| `Service.RecoveryProbe` | **Approve.** Readiness, policy, shutdown and fence checks remain. [recoveryprobe.go:55](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/activator/recoveryprobe.go:55) | |
| +| `Service.holdWakeLocked` | **Approve.** The pinned-wake check and deletion on refusal remain. [swaphold.go:323](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/activator/swaphold.go:323) | |
| +| `Manager.sweepStale` | **Approve for census.** Directory reads and removal targets are unchanged; added bookkeeping grants no root authority. Its incomplete-sweep handling causes the separate P1. [cgroup.go:366](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/cgroup/cgroup.go:366) | |
| +| `Server.healthByHost` | **Approve.** Passing a nil tenant filter preserves local-row behavior and existing registry reads. [apiinstances.go:457](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/console/apiinstances.go:457) | |
| +| `Server.instanceHealth` | **Approve.** Remote metrics use each record’s account, app and creation time after the existing report checks. No registry authority is widened. [apiinstances.go:373](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/console/apiinstances.go:373) | |
| +| `type UnitRow` | **Approve.** Additional diagnostic sample-index field only. [metricsview.go:54](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/console/metricsview.go:54) | |
| +| `runAgent` | **Approve.** Wires the existing registry, activator and cgroup manager into the sampler; no new root-selected path. [agent.go:909](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/host/agent.go:909) | |
| +| `sampler.tick` | **Approve.** Ownership probes and tag bookkeeping surround existing sampling; no new filesystem target or write authority. [metrics_loop.go:76](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/host/metrics_loop.go:76) | |
| +| `type UnitSample` | **Approve.** Additive, optional diagnostic wire field. [sample.go:21](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/metrics/sample.go:21) | |
| + |
| +| Re-pinned envelope | Verdict and evidence | |
| +|---|---| |
| +| `internal/activator` | **Approve.** Changed insertion sites and tenancy helpers add in-memory tracking; lifecycle authority remains unchanged. [tenancies.go:21](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/activator/tenancies.go:21) | |
| +| `internal/cgroup` | **Approve for census.** Existing reads/removals remain; `Leftover` reads only the new map. P1 remains outstanding. [cgroup.go:366](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/cgroup/cgroup.go:366) | |
| +| `internal/console` | **Approve.** Changes carry and filter diagnostic ownership data through the existing sweep and views. [metricsview.go:614](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/console/metricsview.go:614), [metricsview.go:916](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/console/metricsview.go:916), [server.go:3848](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/console/server.go:3848) | |
| +| `internal/host` | **Approve.** Additional registry listings use the agent’s existing handle; sampling and flush destinations remain unchanged. [metrics_owner.go:25](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/host/metrics_owner.go:25), [metrics_loop.go:824](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/host/metrics_loop.go:824) | |
| +| `internal/metrics` | **Approve.** Ownership helpers operate on supplied data; the additive field does not change raw-chunk or rollup storage authority. [owner.go:42](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/metrics/owner.go:42), [owner.go:65](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/metrics/owner.go:65), [owner.go:85](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/metrics/owner.go:85) | |
| + |
| +The four decision-row bases are accurate regarding their read sources and execution identity: |
| + |
| +- **`Service.Tenancies`: accurate.** Reads existing entry routes, excludes mixed hosts and claim mode, and updates only in-memory bookkeeping. [tenancies.go:60](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/activator/tenancies.go:60) |
| +- **`Service.putEntryLocked`: accurate.** Replaces the seven existing insertions and records route identity in memory. [tenancies.go:21](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/activator/tenancies.go:21) |
| +- **`metricsOwners`: accurate.** Reads activator tenancies and the agent’s existing registry; makes no store request or tenant-selected file open. [metrics_owner.go:25](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/host/metrics_owner.go:25) |
| +- **`Vouched`: accurate.** Joins supplied rows, tenancies and the leftover predicate without opening resources. Its safety still depends on fixing P1’s predicate behavior. [owner.go:42](/home/paulca/amadan.net/carlos/platform-remote-metrics/internal/metrics/owner.go:42) |
| + |
| +Acceptance of those four new dispositions remains the census owner’s decision. |
| + |
| +**NOT READY** |
| \ No newline at end of file |
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-remote-instance-metrics-branch.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-remote-instance-metrics-branch.md| index 34f752ce2..a5005b376 100644 |
| --- a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-remote-instance-metrics-branch.md |
| +++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-remote-instance-metrics-branch.md |
| @@ -1,4 +1,4 @@ |
| -# Review brief: branch remote-instance-metrics, round 1 of 3 |
| +# Review brief: branch remote-instance-metrics, round 2 of 3 |
| Repo carlos/platform, branch `remote-instance-metrics`, commit named in the |
| reviewer's prompt. |
| @@ -65,6 +65,25 @@ the wrong account). Name it beside every finding in that family. |
| are decisions for the census owner: say whether each row's basis is |
| accurate. |
| +## Round 2 |
| + |
| +Earlier rounds of the branch: round 1, |
| +`docs/superpowers/reviews/CODEX-FINDINGS-remote-instance-metrics-branch-r1.md` |
| +(one P1, fault family tenant identity of samples: an unlistable root at |
| +setup read as "no leftovers"). The note's own two rounds are recorded |
| +separately (see Authorities). |
| + |
| +First give one line per P1 and P2 from round 1: resolved, partly, or |
| +not. Carry every unresolved or partly resolved finding forward at its |
| +current severity, then add new findings. The verdict covers everything |
| +outstanding, earlier rounds included. Give census verdicts again only for |
| +units the fix changed (`Manager.sweepStale`, `setupAt` and the |
| +`internal/cgroup` envelope); round 1's other verdicts stand. |
| + |
| +AGENTS.md stopping rule 2 applies: a P1 in the same fault family this |
| +round stops the work and goes to Paul with options, so report one only |
| +with a concrete failure scenario and evidence. |
| + |
| ## Severity |
| - **P1**: unsafe, would not compile, a test fails, or it would not work. |
diff --git a/internal/cgroup/cgroup.go b/internal/cgroup/cgroup.go| index d4fe02e66..c924b28e9 100644 |
| --- a/internal/cgroup/cgroup.go |
| +++ b/internal/cgroup/cgroup.go |
| @@ -225,9 +225,12 @@ type Manager struct { |
| fencedSpawn bool |
| // leftover is the hosts whose per-host dir sweepStale could not remove |
| // at setup: something a previous agent started may still be alive in |
| - // it. Written once, during setup, before the manager is shared; read |
| - // only after (Leftover). |
| + // it. unswept says setup did not sweep at all (a retaining setup) or |
| + // could not list the root, so no host's dir is known clean. Both are |
| + // written once, during setup, before the manager is shared; read only |
| + // after (Leftover). |
| leftover map[string]bool |
| + unswept bool |
| // locks holds each host's start lock (hostLock), made on first use. |
| locksMu sync.Mutex |
| locks map[string]*sync.Mutex |
| @@ -356,6 +359,7 @@ func setupAt(root string, logf func(string, ...any), retain bool) (*Manager, err |
| m.sweepStale() |
| } else { |
| m.seedKilled() |
| + m.unswept = true // kept dirs may hold an earlier agent's processes |
| } |
| return m, nil |
| } |
| @@ -366,6 +370,9 @@ func setupAt(root string, logf func(string, ...any), retain bool) (*Manager, err |
| func (m *Manager) sweepStale() { |
| entries, err := os.ReadDir(m.root) |
| if err != nil { |
| + // Nothing was swept, so nothing is known clean (Leftover). |
| + m.logf("cgroup: stale exec dirs not swept: %v", err) |
| + m.unswept = true |
| return |
| } |
| for _, e := range entries { |
| @@ -395,13 +402,14 @@ func (m *Manager) sweepStale() { |
| } |
| } |
| -// Leftover reports whether host's dir was left populated by a previous |
| -// agent: setup's sweep could not remove it, so a process that agent started |
| -// may still run in it. The metrics sampler never vouches for such a host's |
| -// tenant in this agent's life (docs/superpowers/notes/remote-instance-metrics.md). |
| -// Nil-safe: no manager, no leftovers. |
| +// Leftover reports whether host's dir may hold what a previous agent left: |
| +// setup's sweep could not remove it, or setup swept nothing (a retaining |
| +// setup, or a root it could not list), so no dir is known clean. The |
| +// metrics sampler never vouches for such a host's tenant in this agent's |
| +// life (docs/superpowers/notes/remote-instance-metrics.md). Nil-safe: no |
| +// manager, no exec cgroups, no leftovers. |
| func (m *Manager) Leftover(host string) bool { |
| - return m != nil && m.leftover[host] |
| + return m != nil && (m.unswept || m.leftover[host]) |
| } |
| // ErrKilledCgroupKept is a start refused because the cgroup it would spawn |
diff --git a/internal/cgroup/cgroup_test.go b/internal/cgroup/cgroup_test.go| index bc70f698f..42d472356 100644 |
| --- a/internal/cgroup/cgroup_test.go |
| +++ b/internal/cgroup/cgroup_test.go |
| @@ -598,3 +598,41 @@ func TestLeftoverNamesHostsTheSweepCouldNotRemove(t *testing.T) { |
| t.Error("a nil manager reported a leftover") |
| } |
| } |
| + |
| +// TestLeftoverAfterAnUnreadableSweep (Astra, branch round 1, P1): when |
| +// setup cannot list the delegated root, it cannot know which per-host dirs |
| +// a previous agent left, so every host is a leftover for this agent's |
| +// life, even after the root reads again. A retaining setup removes |
| +// nothing, so the same holds there. |
| +func TestLeftoverAfterAnUnreadableSweep(t *testing.T) { |
| + root := newDelegatedRoot(t) |
| + if err := os.MkdirAll(filepath.Join(root, "carlos-exec@busy.example.com"), 0o755); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.Chmod(root, 0o300); err != nil { // writable, not listable |
| + t.Fatal(err) |
| + } |
| + if _, err := os.ReadDir(root); err == nil { |
| + t.Skip("the root is listable without read permission here (running as root?)") |
| + } |
| + m, err := SetupAt(root, t.Logf) |
| + if err := os.Chmod(root, 0o755); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, h := range []string{"busy.example.com", "new.example.com"} { |
| + if !m.Leftover(h) { |
| + t.Errorf("%s is not a leftover after a sweep that could not list the root", h) |
| + } |
| + } |
| + |
| + retained, err := SetupAtRetaining(newDelegatedRoot(t), t.Logf) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if !retained.Leftover("new.example.com") { |
| + t.Error("a retaining setup reported a host as known clean") |
| + } |
| +} |
diff --git a/internal/host/agentalerts_test.go b/internal/host/agentalerts_test.go| index fe006a6e1..d0debe5c2 100644 |
| --- a/internal/host/agentalerts_test.go |
| +++ b/internal/host/agentalerts_test.go |
| @@ -130,8 +130,8 @@ func TestAgentArmsPagingBeforeMovesConsumers(t *testing.T) { |
| if _, ok := at[name]; !ok { |
| at[name] = n.Pos() |
| } |
| - if name == "metricsLoop" && len(n.Args) == 3 { |
| - metricsArg = n.Args[2] |
| + if name == "metricsLoop" && len(n.Args) == 4 { |
| + metricsArg = n.Args[3] |
| } |
| } |
| return true |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 1a211517c..3eab3c066 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -60,4 +60,4 @@ plan14-root-reads-region-labels.tsv d1e00cfb29d88b7a8e4998b641164e539067a6e1e9e4 |
| plan14-root-reads-app-region-set.tsv 798a1ee3d8c8b775f963b9ae1dbc45e18628fa0c1e63404f46606601766ad66c |
| plan14-root-reads-nearest-region-a.tsv 798a1ee3d8c8b775f963b9ae1dbc45e18628fa0c1e63404f46606601766ad66c |
| plan14-root-reads-remote-instance-metrics-decisions.tsv 9adcf40e879f038fc9285ff85b419d7ce4f03559e31f9afcd40a0f3496af7d8e |
| -plan14-root-reads-remote-instance-metrics.tsv d9d77f3901969e40169fdd689bc5ccae5f4684a519cd7448130ceb9091911bd6 |
| +plan14-root-reads-remote-instance-metrics.tsv 0c79dc166bf2a8707586b32eebb8ecc5e9155668b3b42168a139700ef889f506 |
diff --git a/internal/provision/testdata/plan14-root-reads-remote-instance-metrics.tsv b/internal/provision/testdata/plan14-root-reads-remote-instance-metrics.tsv| index 996c7a96f..1d8d3b2bd 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-remote-instance-metrics.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-remote-instance-metrics.tsv |
| @@ -1,12 +1,13 @@ |
| # Census overlay remote-instance-metrics, written by census-propose (#369). census-ruling-remote-instance-metrics, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-remote-instance-metrics.md. |
| -# 14 body, 0 sites, 5 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 15 body, 0 sites, 5 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| @legacy a6eb3e02e5814f935d9388a84d59ab4b707ff4013a285b392c9490ac54eedbc9 internal/activator/activator.go Service.WakeWorker legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body; the stop now carries its reason for a run it interrupts (beginStopLocked's why argument); read sites unchanged, offsets moved;rev3=census-ruling-remote-instance-metrics;basis=the entries-map insertion goes through putEntryLocked (which also notes the route's tenant in memory for the metrics sampler); no read added registry:Host@1249,registry:Host@1658,registry:Host@834,registry:Host@864,whole:Route@1225 dab4506e9f7a8b802d2c930222b4775a4b1626c31c4e39ce2f39ca51c3ce37de |
| @legacy 0f486d4a3e0c57b860cf6a7966366d9baf83b7b69543f83def56eae800828258 internal/activator/activator.go Service.begin 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. the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body; the stop now carries its reason for a run it interrupts (beginStopLocked's why argument); read sites unchanged, offsets moved;rev3=census-ruling-edge-request-records;basis=gains a req *http.Request parameter and one edge.MarkWoke(req) call on the path that starts a wake, so the edge's request record can say which request woke the app; no read added;rev3=census-ruling-remote-instance-metrics;basis=the entries-map insertion goes through putEntryLocked (which also notes the route's tenant in memory for the metrics sampler); no read added registry:Host@1721,registry:Host@1807,registry:Host@345,registry:Host@929,whole:Route@1730,whole:Route@1737 2a6b1e1412a88632293b4bf767f6daf9376d2a00a87d1c27c91eaf02f82da468 |
| @legacy 59675b94e0210da250a611e302a33102209d5cb39ec40054b743ef9a795ad896 internal/activator/activator.go Service.sweepOnce legacy accepted-legacy accepted-legacy;rev3=PROPOSED-seed;basis=census-ruling-FS-R6; registry remains legacy; PROPOSED-plans-2-box-limits: the sweep also narrows an entry's idle window to its account's plan idle through the SetIdleFor hook (never lengthens it; always-on workers and held probe entries are untouched; the hibernate, inflight and held-for-tick guards are unchanged).;rev3=census-ruling-plans-4c-box-throttle;basis=after the worker max_run branch, stops a non-worker entry past the plans continuous-awake ceiling (maxRunFor, passed the row), busy or not, never mid-command (plans 4c). One more whole-row read: the row handed to the hook, as idleFor already is. This bypasses the inflight and held-for-tick protections the idle stop keeps, on purpose: escalated by Astra and ACCEPTED by Paul (census owner), 2026-10-25.;rev3=census-ruling-plans-4d-lapse;basis=stops a live entry the turned-off hook names (never mid-command, never a move's active probe), stands down an exited worker it names instead of restarting it (Astra finding 4), and skips such rows in the due loop and the always-on arm so they are not woken (plans 4d). Four more whole-row reads: the row handed to the hook (a.disabled), as idleFor and maxRunFor already are. Only stops or skips.;rev3=census-ruling-remote-instance-metrics;basis=its two entries-map insertions go through putEntryLocked (which also notes the route's tenant in memory for the metrics sampler); no read added registry:Hibernate@10051,registry:Hibernate@13703,registry:Hibernate@22874,registry:Hibernate@5522,registry:Hibernate@7526,registry:Host@22943,registry:Host@23001,registry:Host@23468,registry:Host@23561,registry:Host@24296,registry:Host@24385,registry:Host@25449,registry:Host@25736,registry:Host@25792,registry:NextDue@24251,registry:Status@22890,whole:Route@10053,whole:Route@10806,whole:Route@13705,whole:Route@15638,whole:Route@17348,whole:Route@17538,whole:Route@17831,whole:Route@18003,whole:Route@18150,whole:Route@22361,whole:Route@23050,whole:Route@23965,whole:Route@24305,whole:Route@24312,whole:Route@25264,whole:Route@25565,whole:Route@25769,whole:Route@5333,whole:Route@5524,whole:Route@7359,whole:Route@7528,whole:Route@7962 48ad35e412fd9bd7569fd3d8c8369c951caeff2a9ce153f8ed99038420b22b67 |
| @legacy 953938d6308026adf92bfd2e38d303c3a92a0d2e9b985153fbcf56510f135b44 internal/activator/probewake.go Service.ProbeWake legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-remote-instance-metrics;basis=the entries-map insertion goes through putEntryLocked; no read added whole:Route@673,whole:Route@698,whole:Route@817,whole:Route@825 2781783e5f445b0bb4d191a7598388da2a6d6f544ad42c6fe35c4b2117950e4c |
| @legacy d66d9f5d97e996bd8ab21e4456de1e5771d038ebcbe5e763bc4f0e0459000246 internal/activator/recoveryprobe.go Service.RecoveryProbe legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-remote-instance-metrics;basis=the entries-map insertion goes through putEntryLocked (its nil-map make moves there); no read added registry:Host@1103,registry:Host@1134,registry:Host@317,registry:Host@489,registry:Host@597,registry:Host@890,whole:Route@899,whole:Route@906 ddcaf70cc9a2701e9efb6dd042188febd3c48b586b78ca361341ecf32781ca6b |
| @legacy 8dc5d5765e58fd34d2ef176a9aac6cc4e68d7b209a970fa52ce3c403ed35cc83 internal/activator/swaphold.go Service.holdWakeLocked legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-remote-instance-metrics;basis=the entries-map insertion goes through putEntryLocked; no read added whole:Route@127,whole:Route@136 f670fc50a38c73000d04a59d2f4d5145c6bdbf08929a60f9257034dcf87e718e |
| -@legacy 6229b3f512ac8220942a71c00c05d57c8b6d5707eb817b0b9d814bc8e7887615 internal/cgroup/cgroup.go Manager.sweepStale legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-remote-instance-metrics;basis=records the host of a per-host dir it could not remove in an in-memory leftover set (Manager.Leftover) for the metrics sampler; no read added, nothing removed differently file:ReadDir@384,file:ReadDir@50 148cc59b7e6a047c782ab8904d544f7c1ccb1529e01848b4e7ba60a5f2b283f2 |
| +@legacy 255a2f8002c3dd5271f633ee70236aa83985ec9618d56b09a7d93ad4c29345e1 internal/cgroup/cgroup.go Manager.sweepStale legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-remote-instance-metrics;basis=records the host of a per-host dir it could not remove in an in-memory leftover set (Manager.Leftover) for the metrics sampler, and marks the whole sweep incomplete (every host a leftover) when it cannot list the root; logs that; no read added, nothing removed differently file:ReadDir@50,file:ReadDir@520 7f2c44b07bba53901fd727fb9c523074ec6591e19355f2e3b6d3a17352642ac3 |
| +@legacy 27dabc018aed7ce9bc1b99677ce678e9cbe194bc6747158c069fa6c297d543a5 internal/cgroup/cgroup.go setupAt legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 (final review F2): the supervise leaf's name now comes from the new exported constant SuperviseLeaf (the same value, supervise), which root's egress rail (internal/host/egress_rail_linux.go) also uses to tell the agent's own leaf from other cgroups in its delegated subtree. It is still the agent's own delegation dance, run by the agent (cgroup.Setup from runAgent, user carlos) in its own subtree; the same one site, the O_WRONLY OpenFile probe of cgroup.procs and cgroup.subtree_control; no read added.;rev3=census-ruling-remote-instance-metrics;basis=a retaining setup also marks every host a leftover for the metrics sampler (an in-memory flag); no read added file:OpenFile@423 65e910820bf75d058cc723b386549fe2bbb918d084535b22290a6464e0b698a8 |
| @legacy 6f5cc7c36ae2736f0055576e94f051e472ca8efea8ab7c6a0ffe9f23b6afa202 internal/console/apiinstances.go Server.healthByHost legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Takes only the caller's ownership start per host (sinceByHost): readings only from samples at or after it, via ownerAppMetricsFrom. The awake set, the box pin and the until window are gone. Registry reads unchanged.;rev3=census-ruling-remote-instance-metrics;basis=passes nil for ownerAppMetricsFrom's new tenant argument (local rows unchanged); no read added registry:Backing@1183,registry:Hibernate@1117,registry:Kind@1100,registry:Provisioned@1158,registry:Status@977,registry:Unit@1174,registry:Unit@329,registry:Unit@364,whole:Route@177,whole:Route@220,whole:Route@286,whole:Route@954 b6fb3262a2276c08f0186de50662e108d3c5ed556e7c523009456c99ba0a8694 |
| @legacy 88041d4f44760c23194da0498718a6d2b666ceafaacbbf853d0ac115ed9292bd internal/console/apiinstances.go Server.instanceHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Records with no local registry row get health only from remoteFacts (a box report whose rollout entry names the record's own account and app, generated after the record was created): awake is Running, held down is Failed, transient or unidentified is Can't tell right now. No metrics readings at all and no registry.Route literal for them. Local records unchanged.;rev3=census-ruling-remote-instance-metrics;basis=a remote record with an accepted rollout entry also counts a metrics reading its box tagged with the record's own account and app as awake (one ownerAppMetricsFrom call over the shared in-memory sweep); registry reads unchanged; no read added registry:Account@1987,registry:Account@2007,registry:App@1948,registry:App@1964,registry:Host@839,registry:Unit@2117,registry:Unit@2159,whole:Route@1151,whole:Route@2054,whole:Route@2075,whole:Route@3105,whole:Route@4929,whole:Route@4982,whole:Route@5097,whole:Route@792,whole:Route@821,whole:Route@832,whole:Route@850 8ae98bafde8d5a37ab36c5da3c29d10e396a45988d3f4fc30077c190f13034a8 |
| @legacy f0980583e1668d9bab93b81f49f6c80095da2d603e7ada5d5aadf641e45268a2 internal/host/metrics_loop.go sampler.tick legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-remote-instance-metrics;basis=calls the owners probe before and after the unit read and tags readings with metrics.TagUnits and metrics.CarryTags; no read added file:ReadBytes@963 74d913ac5a0b8a71822519a2a5e81235e4ec2d79793bbd4685e08d5e6e832533 |
| @@ -17,7 +18,8 @@ internal/activator/activator.go type Service authority B,C,D,F,J4 rev3=PROPOSED- |
| internal/activator/probewake.go Service.ProbeWake legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-remote-instance-metrics;basis=the entries-map insertion goes through putEntryLocked; no read added whole:Route@673,whole:Route@698,whole:Route@817,whole:Route@825 2781783e5f445b0bb4d191a7598388da2a6d6f544ad42c6fe35c4b2117950e4c |
| internal/activator/recoveryprobe.go Service.RecoveryProbe legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-remote-instance-metrics;basis=the entries-map insertion goes through putEntryLocked (its nil-map make moves there); no read added registry:Host@1103,registry:Host@1134,registry:Host@317,registry:Host@489,registry:Host@597,registry:Host@890,whole:Route@899,whole:Route@906 ddcaf70cc9a2701e9efb6dd042188febd3c48b586b78ca361341ecf32781ca6b |
| internal/activator/swaphold.go Service.holdWakeLocked legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-remote-instance-metrics;basis=the entries-map insertion goes through putEntryLocked; no read added whole:Route@127,whole:Route@136 f670fc50a38c73000d04a59d2f4d5145c6bdbf08929a60f9257034dcf87e718e |
| -internal/cgroup/cgroup.go Manager.sweepStale legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-remote-instance-metrics;basis=records the host of a per-host dir it could not remove in an in-memory leftover set (Manager.Leftover) for the metrics sampler; no read added, nothing removed differently file:ReadDir@384,file:ReadDir@50 148cc59b7e6a047c782ab8904d544f7c1ccb1529e01848b4e7ba60a5f2b283f2 |
| +internal/cgroup/cgroup.go Manager.sweepStale legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-remote-instance-metrics;basis=records the host of a per-host dir it could not remove in an in-memory leftover set (Manager.Leftover) for the metrics sampler, and marks the whole sweep incomplete (every host a leftover) when it cannot list the root; logs that; no read added, nothing removed differently file:ReadDir@50,file:ReadDir@520 7f2c44b07bba53901fd727fb9c523074ec6591e19355f2e3b6d3a17352642ac3 |
| +internal/cgroup/cgroup.go setupAt legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 (final review F2): the supervise leaf's name now comes from the new exported constant SuperviseLeaf (the same value, supervise), which root's egress rail (internal/host/egress_rail_linux.go) also uses to tell the agent's own leaf from other cgroups in its delegated subtree. It is still the agent's own delegation dance, run by the agent (cgroup.Setup from runAgent, user carlos) in its own subtree; the same one site, the O_WRONLY OpenFile probe of cgroup.procs and cgroup.subtree_control; no read added.;rev3=census-ruling-remote-instance-metrics;basis=a retaining setup also marks every host a leftover for the metrics sampler (an in-memory flag); no read added file:OpenFile@423 65e910820bf75d058cc723b386549fe2bbb918d084535b22290a6464e0b698a8 |
| internal/console/apiinstances.go Server.healthByHost legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Takes only the caller's ownership start per host (sinceByHost): readings only from samples at or after it, via ownerAppMetricsFrom. The awake set, the box pin and the until window are gone. Registry reads unchanged.;rev3=census-ruling-remote-instance-metrics;basis=passes nil for ownerAppMetricsFrom's new tenant argument (local rows unchanged); no read added registry:Backing@1183,registry:Hibernate@1117,registry:Kind@1100,registry:Provisioned@1158,registry:Status@977,registry:Unit@1174,registry:Unit@329,registry:Unit@364,whole:Route@177,whole:Route@220,whole:Route@286,whole:Route@954 b6fb3262a2276c08f0186de50662e108d3c5ed556e7c523009456c99ba0a8694 |
| internal/console/apiinstances.go Server.instanceHealth legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-remote-instances;basis=Records with no local registry row get health only from remoteFacts (a box report whose rollout entry names the record's own account and app, generated after the record was created): awake is Running, held down is Failed, transient or unidentified is Can't tell right now. No metrics readings at all and no registry.Route literal for them. Local records unchanged.;rev3=census-ruling-remote-instance-metrics;basis=a remote record with an accepted rollout entry also counts a metrics reading its box tagged with the record's own account and app as awake (one ownerAppMetricsFrom call over the shared in-memory sweep); registry reads unchanged; no read added registry:Account@1987,registry:Account@2007,registry:App@1948,registry:App@1964,registry:Host@839,registry:Unit@2117,registry:Unit@2159,whole:Route@1151,whole:Route@2054,whole:Route@2075,whole:Route@3105,whole:Route@4929,whole:Route@4982,whole:Route@5097,whole:Route@792,whole:Route@821,whole:Route@832,whole:Route@850 8ae98bafde8d5a37ab36c5da3c29d10e396a45988d3f4fc30077c190f13034a8 |
| internal/console/metricsview.go type UnitRow diagnostic H3 schema-only;rev3=census-ruling-console-remote-instances;basis=Two unexported fields carrying those raw per-sample readings; schema only.;rev3=census-ruling-remote-instance-metrics;basis=one more unexported field: the per-sample tenant tag index; schema only file:ReadBytes@133 0026b45b05959c902d4621e22af0c55d43ba6881fd3986638fff66985d500726 |
| @@ -25,7 +27,7 @@ internal/host/agent.go runAgent authority B,C,D,F rev3=census-ruling-self-serve- |
| internal/host/metrics_loop.go sampler.tick legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-remote-instance-metrics;basis=calls the owners probe before and after the unit read and tags readings with metrics.TagUnits and metrics.CarryTags; no read added file:ReadBytes@963 74d913ac5a0b8a71822519a2a5e81235e4ec2d79793bbd4685e08d5e6e832533 |
| internal/metrics/sample.go type UnitSample diagnostic H3 schema-only;rev3=census-ruling-remote-instance-metrics;basis=one more field, Owner (omitempty), the tenant tag; schema only file:ReadBytes@151 294c6d0be969498ccf499f72f9d0ba4f58544e3ae0038743954e2056a636adb7 |
| @coverage internal/activator 4ec80131ff1c00867e517914d59d579d57ca9c3f5b4d6090c5e59531bf8bc32d |
| -@coverage internal/cgroup 7b1a4c027236e1c79dc8e60e4bd8a134e6a9c1188cae3143a585cd7d35eefb3f |
| +@coverage internal/cgroup ddba8d2a795785c289462b63f52ee13afaab119a451a6086b098074e39c988fb |
| @coverage internal/console cae64d776ae0c568f7202040c38f5f0eb38c3fdae2c3a419cfd293ed666b2252 |
| @coverage internal/host 6807ca1d83f09adf0a247223c94bd6a7aae7987ef78deabde6d7ccbbdbe0f2bf |
| @coverage internal/metrics d7f3b57198083eb4e25ff6e3640e4f34b9f8235301182762c6883fa77ce12d76 |