carlos / platform Public

edge: the startup sweep leaves bare names and invalid account or app directories alone; Paul's rulings recorded (Astra round 3)

Bare-version trees (pre-#253) are no longer swept: a bare name cannot be
told from an operator's directory. Only valid account and app directory
names are entered. Paul ruled the remaining two escalations: systemd's
stop-before-start is the guarantee no pre-lock edge lingers, and an edge
that cannot hold the lock serves with an ALERT. Census rows regenerated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 3ab02b6c01ba1c3312191daed806d5f7981d1fa9 parent 1ce2da7
6 files changed, +35 −30
  • docs/superpowers/notes/census-proposal-static-sweep.md +8 −11
  • internal/edge/static_sweep_test.go +6 −2
  • internal/edge/static_sweep_unix.go +14 −10
  • internal/provision/testdata/plan14-root-reads-chain.tsv +2 −2
  • internal/provision/testdata/plan14-root-reads-static-sweep-new.tsv +4 −4
  • internal/provision/testdata/plan14-root-reads-static-sweep.tsv +1 −1

CI passed — run details

diff --git a/docs/superpowers/notes/census-proposal-static-sweep.md b/docs/superpowers/notes/census-proposal-static-sweep.md
index 4da5648d4..df6465783 100644
--- a/docs/superpowers/notes/census-proposal-static-sweep.md
+++ b/docs/superpowers/notes/census-proposal-static-sweep.md
@@ -6,26 +6,23 @@ Envelopes re-pinned: `internal/edge`.
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. Escalate 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. An escalation goes to the census owner as a decision.
-Seal: `d3ad8fdaa8b4cac055ecfa0e7c5a16a830052cb7e7c1b38ab1136488e5ff915f` → `d3ad8fdaa8b4cac055ecfa0e7c5a16a830052cb7e7c1b38ab1136488e5ff915f`.
+Seal: `043c528ccb9d9576db9268256efd40f2f12bce9093fc41f762f0e07fa3f9cb9d` → `043c528ccb9d9576db9268256efd40f2f12bce9093fc41f762f0e07fa3f9cb9d`.
Overlay: `internal/provision/testdata/plan14-root-reads-static-sweep.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
## The decision: two new units, written by hand
-`internal/edge/static_sweep_unix.go` adds two units that read the disk, so census-propose leaves them to a decision. Their rows are in `internal/provision/testdata/plan14-root-reads-static-sweep-new.tsv`, chained before the overlay above. They are `@legacy` rows, so the seal moves to `d3ad8fda…915f`.
+`internal/edge/static_sweep_unix.go` adds two units that read the disk. Their rows are in `internal/provision/testdata/plan14-root-reads-static-sweep-new.tsv`, chained before the overlay above. They are `@legacy` rows, so the seal moves to `043c528c…cb9d`.
| unit | reads | proposed disposition |
|---|---|---|
| `sweepStaticCache` | `OpenFile` of `<cacheDir>/.edge.lock` (created if absent), then `flock` on it | `legacy`/`accepted-legacy`, J4 footing (`root-input`), as the edge's other static units are |
-| `setAside` | `ReadDir` of the cache, each account and each app; `Readlink` of each app's `current`; `Lstat` of each entry | the same |
+| `setAside` | `ReadDir` of the cache, each valid account and each valid app; `Readlink` of each app's `current`; `Lstat` of each entry | the same |
-Both run in the agent (`carlos-edge.service`, user carlos), not root. They run once, at startup, from `EnableStatic`, before any static handler exists. Every running edge holds the cache's lock shared for its life. A start sweeps only if it can take the lock exclusively. A start that creates the lock file sweeps nothing, because an edge from before this change may still be serving without taking the lock.
+Both run in the agent (`carlos-edge.service`, user carlos), not root. They run once, at startup, from `EnableStatic`, before any static handler exists. A start sweeps only when it takes the cache's lock exclusively, and a start that creates the lock file sweeps nothing.
-The sweep touches only entries the edge made, recognised by name:
-- release trees (`<version>@<64-hex digest>`), and pre-#253 trees named by a bare version;
-- temp extractions (`.extract-<n>`);
-- an earlier sweep's leftovers (`.sweep-<name>-<n>`).
+The sweep touches only release trees (`<version>@<64-hex digest>`) and the edge's own debris (`.extract-<n>`, `.sweep-<name>-<n>`), and only under valid account and app names. It never touches bare names, files, links, or anything it doesn't recognise. Each app keeps its `current` tree. Every other release tree is renamed before the sweep returns, then removed in the background. `ensureExtracted` verifies the signed release again before extracting a fresh copy.
-Each app keeps the tree its `current` link names. Every other release tree is renamed to `.sweep-<name>-<stamp>` before the sweep returns, then removed in the background with the debris. Files, links and anything it doesn't recognise are left alone. Nothing removed is lost: every tree is a cache of a signed release, and `ensureExtracted` verifies the release again before extracting a fresh copy.
-
-Astra's reviews shaped this design: round 1 dropped a sweep at each version swap, and round 2 brought in the first-start rule and the strict name rules.
+Paul's rulings, 2026-10-25, on Astra's round 3 escalations:
+- **The guarantee against an old edge:** systemd stops an edge before it starts the next. The edge only runs as `carlos-edge.service`.
+- **A lock this edge cannot hold:** it serves anyway and raises an ALERT, so a lock-file fault doesn't take static sites down.
diff --git a/internal/edge/static_sweep_test.go b/internal/edge/static_sweep_test.go
index 64065bd25..df7b1c712 100644
--- a/internal/edge/static_sweep_test.go
+++ b/internal/edge/static_sweep_test.go
@@ -80,8 +80,9 @@ func TestStaticStartupSweepKeepsOnlyEachAppsCurrentTree(t *testing.T) {
pointAt(t, cache, "bab", "apt", tree("v3"))
cacheTree(t, cache, "bab", "apt", ".extract-123")
cacheTree(t, cache, "bab", "apt", ".sweep-"+tree("v0")+"-17")
- cacheTree(t, cache, "bab", "apt", "v0.5.0-1") // a bare version: the key before #253
+ cacheTree(t, cache, "bab", "apt", "v0.5.0-1") // a bare version: left, as an operator's "backup" would be
cacheTree(t, cache, "bab", "apt", "backup 2026")
+ cacheTree(t, cache, "Not An Account", "apt", tree("v1")) // not a valid account: never entered
if err := os.WriteFile(filepath.Join(cache, "bab", "apt", "note.txt"), []byte("x"), 0o644); err != nil {
t.Fatal(err)
}
@@ -91,7 +92,7 @@ func TestStaticStartupSweepKeepsOnlyEachAppsCurrentTree(t *testing.T) {
sweep(t, cache)
- if got, want := entries(t, filepath.Join(cache, "bab", "apt")), []string{"backup 2026", "current", "note.txt", tree("v3")}; strings.Join(got, "|") != strings.Join(want, "|") {
+ if got, want := entries(t, filepath.Join(cache, "bab", "apt")), []string{"backup 2026", "current", "note.txt", "v0.5.0-1", tree("v3")}; strings.Join(got, "|") != strings.Join(want, "|") {
t.Errorf("bab/apt = %v, want %v", got, want)
}
if got, want := entries(t, filepath.Join(cache, "bac", "docs")), []string{"current", tree("v7")}; strings.Join(got, "|") != strings.Join(want, "|") {
@@ -100,6 +101,9 @@ func TestStaticStartupSweepKeepsOnlyEachAppsCurrentTree(t *testing.T) {
if got := entries(t, filepath.Join(cache, "bac", "nolink")); len(got) != 0 {
t.Errorf("bac/nolink = %v, want empty", got)
}
+ if got := entries(t, filepath.Join(cache, "Not An Account", "apt")); len(got) != 1 {
+ t.Errorf("an invalid account's directory was entered: %v", got)
+ }
}
// A release may be named like the edge's debris (.extract-x, .sweep-x-1
diff --git a/internal/edge/static_sweep_unix.go b/internal/edge/static_sweep_unix.go
index 6ea4d1ccd..fbf15e743 100644
--- a/internal/edge/static_sweep_unix.go
+++ b/internal/edge/static_sweep_unix.go
@@ -9,7 +9,6 @@ import (
"os"
"path/filepath"
"regexp"
- "strings"
"syscall"
"time"
@@ -26,12 +25,18 @@ import (
// life. A starting edge sweeps only if it can take it exclusively.
// - An edge from before this change takes no lock, so the first edge to
// create the lock file sweeps nothing: from its next start on, every
-// edge using the cache is known to take the lock.
+// edge using the cache is known to take the lock. That rests on the
+// edge only running as carlos-edge.service, which systemd stops before
+// it starts the next (Paul's ruling, 2026-10-25, on Astra round 3).
+// - An edge that cannot hold the lock serves anyway and raises an ALERT
+// (Paul's ruling, same day): a lock-file fault must not take static
+// sites down, and the exposure needs a second edge starting beside it.
//
// Only entries the edge itself made are touched, recognised by name:
-// release trees (<version>@<digest>, siteDirName), pre-#253 trees named by
-// a bare version, temp extractions (.extract-<n>, os.MkdirTemp's) and an
-// earlier sweep's leftovers (.sweep-<name>-<n>). Each app keeps the tree
+// release trees (<version>@<digest>, siteDirName), temp extractions
+// (.extract-<n>, os.MkdirTemp's) and an earlier sweep's leftovers
+// (.sweep-<name>-<n>), under account and app directories whose names are
+// valid ones. Each app keeps the tree
// its current link names. Every other release tree is renamed to a .sweep-
// name before the sweep returns, so no handler built after it can select
// it (ensureExtracted then extracts a fresh, verified copy if a pointer
@@ -60,9 +65,8 @@ func classifyStaticEntry(name string) staticEntry {
if extractTmpName.MatchString(name) || sweptName.MatchString(name) {
return entryDebris
}
- if !strings.HasPrefix(name, ".") && release.ValidVersion(name) {
- return entryTree // a pre-#253 tree, keyed by the bare version
- }
+ // A pre-#253 tree keyed by a bare version is not swept: a bare name
+ // cannot be told from an operator's directory (Astra round 3).
return entryUnknown
}
@@ -155,7 +159,7 @@ func setAside(cacheDir string) []string {
}
stamp := time.Now().UnixNano()
for _, a := range accts {
- if !a.IsDir() || strings.HasPrefix(a.Name(), ".") {
+ if !a.IsDir() || !release.ValidAccount(a.Name()) {
continue
}
apps, err := os.ReadDir(filepath.Join(cacheDir, a.Name()))
@@ -163,7 +167,7 @@ func setAside(cacheDir string) []string {
continue
}
for _, ap := range apps {
- if !ap.IsDir() || strings.HasPrefix(ap.Name(), ".") {
+ if !ap.IsDir() || !release.ValidApp(ap.Name()) {
continue
}
appDir := filepath.Join(cacheDir, a.Name(), ap.Name())
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 4002eada8..fa2e2fdeb 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -21,5 +21,5 @@ plan14-root-reads-edge-request-records.tsv 84cb1e17c2f9cabddcc1e6ed5b39b00ffa703
plan14-root-reads-data-lifecycle-336.tsv 539ae875b4a089bc6512ae2e047fa9e353e8b760c18312b81ec3400e5e1f6d48
plan14-root-reads-plans-4a-store.tsv 72dc835c04caf5b2b49cc6ecbfd865bb3123b997ee932e8ab7c0df239935a26b
plan14-root-reads-plans-4-notices-grace.tsv 43e430a3b3edf9333bfe2c64f24ca9e4c04475dc45ae4983d4e8bcab6a9c0bc4
-plan14-root-reads-static-sweep-new.tsv d3ad8fdaa8b4cac055ecfa0e7c5a16a830052cb7e7c1b38ab1136488e5ff915f
-plan14-root-reads-static-sweep.tsv d3ad8fdaa8b4cac055ecfa0e7c5a16a830052cb7e7c1b38ab1136488e5ff915f
+plan14-root-reads-static-sweep-new.tsv 043c528ccb9d9576db9268256efd40f2f12bce9093fc41f762f0e07fa3f9cb9d
+plan14-root-reads-static-sweep.tsv 043c528ccb9d9576db9268256efd40f2f12bce9093fc41f762f0e07fa3f9cb9d
diff --git a/internal/provision/testdata/plan14-root-reads-static-sweep-new.tsv b/internal/provision/testdata/plan14-root-reads-static-sweep-new.tsv
index e3b0b59ca..acc8062d7 100644
--- a/internal/provision/testdata/plan14-root-reads-static-sweep-new.tsv
+++ b/internal/provision/testdata/plan14-root-reads-static-sweep-new.tsv
@@ -1,5 +1,5 @@
# Census overlay static-sweep-new, hand-written: the two new units census-propose leaves to a decision (the static cache startup sweep). census-ruling-static-sweep, asked of the census owner with the approval card (docs/superpowers/notes/census-proposal-static-sweep.md).
-@legacy 14f932cd814fdd6e6120f38e59b7dc10897ad0bfc122528fd00c374c7ac81803 internal/edge/static_sweep_unix.go setAside legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=root-input; once at startup, before any static handler exists, only under an exclusive flock (sweepStaticCache), reads its own static cache (<cacheDir>/<acct>/<app>: entries, each current link, each entry lstat) and renames each release tree (<version>@<digest> or a pre-#253 bare version) the current link does not name to a .sweep- name for removal, with its own debris (.extract-<n>, .sweep-<name>-<n>); never touches files, links, or names it does not recognise; every tree is a cache of a signed release that ensureExtracted re-verifies before extracting it again; no root decision file:Lstat@795,file:ReadDir@276,file:ReadDir@593,file:ReadDir@78,file:Readlink@530 29fef16d6b05b3dc73148f45de083593704a381ba8e23b222148287edc8eebec
-@legacy bb227e2c3bf92531e7a1e6a04d17601eb6525a3ebe9f49cb55f6323066e07ebd internal/edge/static_sweep_unix.go sweepStaticCache legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=root-input; opens or creates <cacheDir>/.edge.lock and flocks it: a start that creates it sweeps nothing (an older edge may not lock), otherwise exclusive non-blocking to sweep, then shared for the process life; the lock decides only whether this start sweeps; no root decision file:OpenFile@556,file:OpenFile@701 0c2857704f81442d833c121e5f7f9b726324c52557d66a50a87d3b4c7c632fdf
-internal/edge/static_sweep_unix.go setAside legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=root-input; once at startup, before any static handler exists, only under an exclusive flock (sweepStaticCache), reads its own static cache (<cacheDir>/<acct>/<app>: entries, each current link, each entry lstat) and renames each release tree (<version>@<digest> or a pre-#253 bare version) the current link does not name to a .sweep- name for removal, with its own debris (.extract-<n>, .sweep-<name>-<n>); never touches files, links, or names it does not recognise; every tree is a cache of a signed release that ensureExtracted re-verifies before extracting it again; no root decision file:Lstat@795,file:ReadDir@276,file:ReadDir@593,file:ReadDir@78,file:Readlink@530 29fef16d6b05b3dc73148f45de083593704a381ba8e23b222148287edc8eebec
-internal/edge/static_sweep_unix.go sweepStaticCache legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=root-input; opens or creates <cacheDir>/.edge.lock and flocks it: a start that creates it sweeps nothing (an older edge may not lock), otherwise exclusive non-blocking to sweep, then shared for the process life; the lock decides only whether this start sweeps; no root decision file:OpenFile@556,file:OpenFile@701 0c2857704f81442d833c121e5f7f9b726324c52557d66a50a87d3b4c7c632fdf
+@legacy 01d453647fbf9841171111b2f665e8ec465f013d3d30ee89943d640e44d7e859 internal/edge/static_sweep_unix.go setAside legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=root-input; once at startup, before any static handler exists, only under an exclusive flock (sweepStaticCache), reads its own static cache (<cacheDir>/<acct>/<app> with valid account and app names: entries, each current link, each entry lstat) and renames each release tree (<version>@<64-hex digest>) the current link does not name to a .sweep- name for removal, with its own debris (.extract-<n>, .sweep-<name>-<n>); never touches files, links, bare names, or names it does not recognise; every tree is a cache of a signed release that ensureExtracted re-verifies before extracting it again; no root decision file:Lstat@789,file:ReadDir@275,file:ReadDir@587,file:ReadDir@78,file:Readlink@524 2606d2b61669d213755ecdc97f69c4ba14a476e3a63f06abff243a0a80204653
+@legacy f4b3cea3571093ff6035600d23a48a030829f97635ba72ce9fae343d3d3b54a9 internal/edge/static_sweep_unix.go sweepStaticCache legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=root-input; opens or creates <cacheDir>/.edge.lock and flocks it: a start that creates it sweeps nothing (an older edge may not lock; systemd stops an edge before it starts the next, Paul 2026-10-25), otherwise exclusive non-blocking to sweep, then shared for the process life; a lock it cannot hold is an ALERT and the edge still serves (Paul 2026-10-25); the lock decides only whether this start sweeps; no root decision file:OpenFile@556,file:OpenFile@701 0c2857704f81442d833c121e5f7f9b726324c52557d66a50a87d3b4c7c632fdf
+internal/edge/static_sweep_unix.go setAside legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=root-input; once at startup, before any static handler exists, only under an exclusive flock (sweepStaticCache), reads its own static cache (<cacheDir>/<acct>/<app> with valid account and app names: entries, each current link, each entry lstat) and renames each release tree (<version>@<64-hex digest>) the current link does not name to a .sweep- name for removal, with its own debris (.extract-<n>, .sweep-<name>-<n>); never touches files, links, bare names, or names it does not recognise; every tree is a cache of a signed release that ensureExtracted re-verifies before extracting it again; no root decision file:Lstat@789,file:ReadDir@275,file:ReadDir@587,file:ReadDir@78,file:Readlink@524 2606d2b61669d213755ecdc97f69c4ba14a476e3a63f06abff243a0a80204653
+internal/edge/static_sweep_unix.go sweepStaticCache legacy accepted-legacy accepted-legacy;rev3=census-ruling-static-sweep;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=root-input; opens or creates <cacheDir>/.edge.lock and flocks it: a start that creates it sweeps nothing (an older edge may not lock; systemd stops an edge before it starts the next, Paul 2026-10-25), otherwise exclusive non-blocking to sweep, then shared for the process life; a lock it cannot hold is an ALERT and the edge still serves (Paul 2026-10-25); the lock decides only whether this start sweeps; no root decision file:OpenFile@556,file:OpenFile@701 0c2857704f81442d833c121e5f7f9b726324c52557d66a50a87d3b4c7c632fdf
diff --git a/internal/provision/testdata/plan14-root-reads-static-sweep.tsv b/internal/provision/testdata/plan14-root-reads-static-sweep.tsv
index 361ccb6f9..524df8c5a 100644
--- a/internal/provision/testdata/plan14-root-reads-static-sweep.tsv
+++ b/internal/provision/testdata/plan14-root-reads-static-sweep.tsv
@@ -1,3 +1,3 @@
# Census overlay static-sweep, written by census-propose (#369). census-ruling-static-sweep, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-static-sweep.md.
# 0 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
-@coverage internal/edge 1af8976107f77e11dda358180292bc21bdd6898a2f090c5a25ffad8768775818
+@coverage internal/edge f9aea28dde318531d1fdfa59b23bcae0c5fdacdca6d3c7566d2163748a7ce3f8