carlos / platform Public

Fix maintenance test isolation and process start bound

Restore the fixture participation and floor after production configuration.
Verify configured apply with production directories read-only.

Document the two-second start-time lower bound and pin both truncations
in a proc fixture test.
Paul Campbell pushed by claude agent, operated by paul@keymail.dev cd0d54cf73b0b7e43422758491f37db1333e16a5 parent 8877f0e
4 files changed, +39 −5
  • internal/host/group_maintenance_clock.go +3 −3
  • internal/host/group_maintenance_prepare_test.go +33 −0
  • internal/host/group_maintenance_round1_test.go +2 −1
  • internal/host/group_maintenance_verbs.go +1 −1

CI failed — run details

Intent

Human

<task-notification> <task-id>a3a360e4842a84ee4</task-id> <tool-use-id>toolu_01Qx2UZHtM1SPHCghk7b9b76</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/e47280e8-3e59-4dc1-95d2-11de7237d34c/tasks/a3a360e4842a84ee4.output</output-file> <status>completed</status> <summary>Agent "Re-review B2b fix round 1" 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>Verdict: open: the ConfiguredApply test hygiene, and the started_at error bound (needs a ruling). Five of the seven findings are fully addressed. The two open items: - **New breakage:** the new apply test reaches the real host's `/var/lib/carlos-claims`, and it fails in our sandbox. - **Finding 2:** the "up to one second early" wording R13 required is mathematically wrong now that the time is printed in whole seconds. The rest of the diff is clean. `group_maintenance.go` and `group_maintenance_linux.go` are unchanged since d48d82d1, so the guard is unchanged. `go test ./internal/host -run TestGroupMaintenance` passes except `TestGroupMaintenanceConfiguredApply` (more on that below). **Per finding** (files are in `internal/host/`) 1. **Important, `group-maintenance apply`: ADDRESSED.** - The verb is dispatched at `group_maintenance_verbs.go:142` after the existing root check, group-marker check (fixed boxes refuse at :101 before any lock or change), non-blocking lock and marker re-check. - The body is at `group_maintenance_prepare.go:125-138`. It calls `localConfiguration` (checked host.env), then `configure`, then `withSystemRelease(runLocked(ctx,false,nil))`. That matches bare `Run` (`systemapply.go:343`) minus re-taking the lock it already holds. - Production wires `configure: configureMaintenanceApplier` (verbs.go:71), so the caller's environment is cleared and replaced. - The permit refusal comes from `runLocked`'s `requireGroupMaintenance("check")` (`systemapply.go:349-352`). That runs before the floor hook, staging or repoint. - Help text is at verbs.go:30-32. The test (`group_maintenance_round1_test.go:39-135`) does call the real `configureMaintenanceApplier` and checks the channel, key, bucket and roots come from host.env and the lock is held. But see the new breakage below. 2. **Important, `started_at` lower bound: ADDRESSED as written, but the wording is wrong.** `group_maintenance_clock.go:80` uses `time.Unix(boot+ticks/hz, 0)`. That rounds down, so it stays a lower bound. The comment (:14-17) and help (verbs.go:39-40) use the R13 text. The problem: `btime` is already rounded down to a whole second, and now the tick fraction is rounded down too. The real start can be up to about 2 seconds (plus one tick) after the printed value. So a generation "at least one second later" can still come before the real process start. No whole-second lower bound can be tighter than this. I'd ask for a ruling to change the text to "up to two seconds early; compare with a generation at least two seconds later" (or three for margin). Separately, `scripts/region-group-roll.py:626` compares with a strict `&gt;` and no margin; that is the other implementer's file. 3. **Minors:** - **configure test: ADDRESSED.** round1_test.go:39-90 checks channel, pubkey, bucket, roots, guard, PATH/AWS settings and that the caller's environment is cleared. - **Five-minute prepare deadline: ADDRESSED.** prepare.go:98 and 141-142 set one timeout covering the store open and both GETs. - If the deadline hits mid-download, `fetch` writes only into the private `.prepare-*` directory, which a `defer` removes (:200). - `ctx.Err()` is checked again before publishing (:223). - The cache and request are published through `safefile.Write` (temp file then rename), so nothing is ever half-written. - After that check the remaining steps are local copies, and the cache is copied before the request. - **`previous_result`: ADDRESSED.** prepare.go:184-193 and 233-241. - A match needs the full (channel, version, promoted_at) tuple, with the channel from host.env. - applied, rolled back and rollback failed set `request_written:false` and leave the old result untouched. `refused` is reported but still writes a request. - A corrupt result.json refuses. - **`.prepare-*` sweep: ADDRESSED.** prepare.go:105-123, called at :143 under the command lock. - It only reads root's own apply directory. - It only removes `.prepare-` plus an exact uint32 decimal suffix. That is the same shape `MkdirTemp` makes. - `entry.IsDir()` comes from the directory entry type, so symlinks are skipped, and `RemoveAll` does not follow links inside. - The test covers a symlink, a descriptive name and staging. - **`edge.started_at_error`: ADDRESSED.** verbs.go:214 and 331-336. `edge.error` is now only about the process. **New breakage:** - **Important (test hygiene): `TestGroupMaintenanceConfiguredApply` reaches real host state.** `maintenanceProductionConfigure` (round1_test.go:85-86) puts back the fake's ops, store, floorHook, rootMoves and openRegistry. It does not put back `a.participation` or `a.floor`. So `withSystemRelease` → `hostfloor.Disk{}` → `rootparticipation.OpenForUpdate()` opens `/var/lib/carlos-claims/authority/exec`. - **In the sandbox:** `/var` shows as owned by `nobody`, so both subtests fail with `permission denied`. I reproduced this at 36bdeb0d. - **Outside it:** where the directory doesn't exist the test passes by luck. That is probably why the implementer saw it pass. - **As root on a box with a live census:** it would run launch exclusion against the real ledger. - **Fix:** also copy `a.participation, a.floor = fake.participation, fake.floor` (the fixture sets these at `systemapply_test.go:135`). - Nothing else new at Critical or Important. I made no changes. My scratch files (the test binary) are deleted, and I didn't touch `scripts/`.</result> <usage><subagent_tokens>84929</subagent_tokens><tool_uses>21</tool_uses><duration_ms>228249</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>b600lo1wc</task-id> <tool-use-id>toolu_01TQKus7ZetNPpe1NRyY2mr6</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/e47280e8-3e59-4dc1-95d2-11de7237d34c/tasks/b600lo1wc.output</output-file> <status>completed</status> <summary>Background command ".superpowers/sdd/2026-11-04-region-ha-p3b-group/run-astra.sh b3" completed (exit code 0)</summary> </task-notification>

diff --git a/internal/host/group_maintenance_clock.go b/internal/host/group_maintenance_clock.go
index ccf0147e8..edd49c163 100644
--- a/internal/host/group_maintenance_clock.go
+++ b/internal/host/group_maintenance_clock.go
@@ -12,9 +12,9 @@ import (
)
// The edges object's generation is written by this box's own agent using the
-// same clock. btime has whole-second precision. started_at is a lower bound,
-// up to one second early; compare with a generation at least one second later
-// and check the edge identity has not changed.
+// same clock. Both btime and the tick offset are truncated to whole seconds.
+// started_at is a lower bound, up to two seconds early; compare with a generation
+// at least two seconds later and check the edge identity has not changed.
func maintenanceProcessStartedAt(procRoot, start string) (string, error) {
ticks, err := strconv.ParseUint(start, 10, 64)
if err != nil || ticks == 0 {
diff --git a/internal/host/group_maintenance_prepare_test.go b/internal/host/group_maintenance_prepare_test.go
index 811aed593..c819f5bb2 100644
--- a/internal/host/group_maintenance_prepare_test.go
+++ b/internal/host/group_maintenance_prepare_test.go
@@ -14,6 +14,7 @@ import (
"path/filepath"
"strings"
"testing"
+ "time"
"github.com/carlosframework/platform/internal/hostenv"
"github.com/carlosframework/platform/internal/release"
@@ -304,6 +305,38 @@ func TestGroupMaintenanceStartedAt(t *testing.T) {
}
}
+func TestGroupMaintenanceStartedAtLowerBound(t *testing.T) {
+ root := t.TempDir()
+ if err := os.Mkdir(filepath.Join(root, "self"), 0700); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(filepath.Join(root, "stat"), []byte("btime 1700000000\n"), 0600); err != nil {
+ t.Fatal(err)
+ }
+ aux := make([]byte, 32)
+ binary.NativeEndian.PutUint64(aux, 17)
+ binary.NativeEndian.PutUint64(aux[8:], 1000)
+ if err := os.WriteFile(filepath.Join(root, "self", "auxv"), aux, 0600); err != nil {
+ t.Fatal(err)
+ }
+ got, err := maintenanceProcessStartedAt(root, "990")
+ if err != nil {
+ t.Fatal(err)
+ }
+ printed, err := time.Parse(time.RFC3339, got)
+ if err != nil {
+ t.Fatal(err)
+ }
+ trueBoot := time.Unix(1700000000, 990000000)
+ trueStart := trueBoot.Add(990 * time.Millisecond)
+ if printed.After(trueStart) || printed.Before(trueStart.Add(-2*time.Second)) {
+ t.Fatalf("started_at %s outside two-second lower bound of %s", got, trueStart)
+ }
+ if early := trueStart.Sub(printed); early != 1980*time.Millisecond {
+ t.Fatalf("combined truncation = %s, want 1.98s", early)
+ }
+}
+
func TestGroupMaintenancePrepareArguments(t *testing.T) {
for _, args := range [][]string{{"prepare"}, {"prepare", "--sha256", "bad"}, {"rollback", "extra"}} {
var out bytes.Buffer
diff --git a/internal/host/group_maintenance_round1_test.go b/internal/host/group_maintenance_round1_test.go
index 235238db8..b02f5651d 100644
--- a/internal/host/group_maintenance_round1_test.go
+++ b/internal/host/group_maintenance_round1_test.go
@@ -83,6 +83,7 @@ func maintenanceProductionConfigure(t *testing.T, f *applyFixture, cmd *groupMai
}
a.ops, a.platform, a.build, a.soak = fake.ops, fake.platform, fake.build, fake.soak
a.floorHook, a.rootMoves, a.openRegistry = fake.floorHook, fake.rootMoves, fake.openRegistry
+ a.participation, a.floor = fake.participation, fake.floor
return nil
}
return &configured
@@ -174,7 +175,7 @@ func TestGroupMaintenanceApplyEntry(t *testing.T) {
}
})
}
- for _, phrase := range []string{"group-maintenance apply", "never bare", "five minutes", "previous_result", "a lower bound, up to one second early; compare with a generation at least one second later and check the edge identity has not changed"} {
+ for _, phrase := range []string{"group-maintenance apply", "never bare", "five minutes", "previous_result", "a lower bound, up to two seconds early; compare with a generation at least two seconds later and check the edge identity has not changed"} {
if !strings.Contains(groupMaintenanceHelp, phrase) {
t.Errorf("help missing %q", phrase)
}
diff --git a/internal/host/group_maintenance_verbs.go b/internal/host/group_maintenance_verbs.go
index c3c2cbcf2..a11cc2bbe 100644
--- a/internal/host/group_maintenance_verbs.go
+++ b/internal/host/group_maintenance_verbs.go
@@ -37,7 +37,7 @@ Root only, on a group member. Use through the attended Session Manager operator.
revoke Remove the permit. Keep all consumed-action records.
status Print one v1 JSON object, at most 8192 bytes. Make one local health GET.
Status includes edge.started_at in UTC at second precision, derived from kernel boot time and clock ticks.
-It is a lower bound, up to one second early; compare with a generation at least one second later and check the edge identity has not changed.
+It is a lower bound, up to two seconds early; compare with a generation at least two seconds later and check the edge identity has not changed.
Clock errors are in edge.started_at_error; edge.error describes the process.
accepted means the guard's validators accept this permit now; it is not readiness: check the action and its consumed flag too.
Status is local evidence, not proof of fresh admission or role publication.