activator: the install guard reads package-level declarations too; the queued-restart test releases its proof before its drain in cleanup (Task 8 round 3 P2s)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/activator/rootfs_install_guard_test.go+32 −7internal/activator/rootfs_resident_lease_test.go+6 −9internal/activator/testdata/rootfs_verb_guard/install_pkgfunc.go+11 −0internal/activator/testdata/rootfs_verb_guard/install_pkglit.go+10 −0
CI cancelled — superseded by a newer push — run details
Intent
<task-notification> <task-id>a0af3e3ad04af18d4</task-id> <tool-use-id>toolu_01SmiNMSZwVf9oYNPiUcEbbK</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/723ae101-0fd7-40c3-a758-6adf1597efb2/tasks/a0af3e3ad04af18d4.output</output-file> <status>completed</status> <summary>Agent "Plan 3 Task 7 implementer" 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. Round 2's one finding is fixed, so Task 7 is ready to close. Commit: 2fe34113. The row a held wake re-reads is now admitted again right after the re-read. Before, it was checked only just before the lease, after the planner had already run, and the production planner can materialize a build for a row with no version. Tests: - The full activator package passes. - The invariant-guard command from common.md passes, as does the copy gate. - vet is clean, and the darwin and windows builds succeed. - The test of the re-read now plugs in a planner and checks that the refused row is never planned, materialized, leased or restored. - Putting the check back in its old place makes that test fail with one materialization. Concerns: nothing new. Still open from before: - The test harness can only start a real rootfs image where the box platform is linux-arm64. - The placeholder's replication is proven on file storage, not S3; that box check belongs in Task 10. Report: `.superpowers/sdd/2026-10-24-rootfs-apps-3-lifecycle/task-7-report.md`, with a round-2 note appended.</result> <usage><subagent_tokens>578826</subagent_tokens><tool_uses>6</tool_uses><duration_ms>162213</duration_ms></usage> </task-notification>
diff --git a/internal/activator/rootfs_install_guard_test.go b/internal/activator/rootfs_install_guard_test.go| index 72e8427fb..66a45a27e 100644 |
| --- a/internal/activator/rootfs_install_guard_test.go |
| +++ b/internal/activator/rootfs_install_guard_test.go |
| @@ -82,17 +82,38 @@ func guardedField(info *types.Info, x ast.Expr) string { |
| // installGuardViolations is every guarded write in f outside |
| // installGuardOwner, as "<func>: <what>"; owned counts the writes inside it. |
| +// Every declaration is read: a function's or method's body, and every |
| +// package-level declaration whole (a var initialised with a function |
| +// literal or an actEntry literal), with no owner exemption for the latter. |
| func installGuardViolations(pkg *packages.Package, f *ast.File) (violations []string, owned int) { |
| info := pkg.TypesInfo |
| for _, decl := range f.Decls { |
| - fd, ok := decl.(*ast.FuncDecl) |
| - if !ok || fd.Body == nil { |
| + var name string |
| + var body ast.Node |
| + switch d := decl.(type) { |
| + case *ast.FuncDecl: |
| + if d.Body == nil { |
| + continue |
| + } |
| + name, body = d.Name.Name, d.Body |
| + if d.Recv != nil && len(d.Recv.List) == 1 { |
| + name = receiverTypeName(d.Recv.List[0].Type) + "." + name |
| + } |
| + case *ast.GenDecl: |
| + var names []string |
| + for _, spec := range d.Specs { |
| + if vs, ok := spec.(*ast.ValueSpec); ok { |
| + for _, id := range vs.Names { |
| + names = append(names, id.Name) |
| + } |
| + } |
| + } |
| + // A package-level name never owns: "package-level" keeps it |
| + // apart from any function of the same name. |
| + name, body = "package-level "+strings.Join(names, ","), d |
| + default: |
| continue |
| } |
| - name := fd.Name.Name |
| - if fd.Recv != nil && len(fd.Recv.List) == 1 { |
| - name = receiverTypeName(fd.Recv.List[0].Type) + "." + name |
| - } |
| report := func(what string, x ast.Expr) { |
| if name == "Service."+installGuardOwner { |
| owned++ |
| @@ -103,7 +124,7 @@ func installGuardViolations(pkg *packages.Package, f *ast.File) (violations []st |
| } |
| violations = append(violations, name+": "+what+" outside "+installGuardOwner) |
| } |
| - ast.Inspect(fd.Body, func(n ast.Node) bool { |
| + ast.Inspect(body, func(n ast.Node) bool { |
| switch v := n.(type) { |
| case *ast.AssignStmt: |
| if v.Tok == token.DEFINE { |
| @@ -153,6 +174,10 @@ var installGuardFixtures = map[string][]string{ |
| "install_tier.go": {"Service.installGuardTier: sets actEntry.gen outside", |
| "genMember.recordCurrentTierLocked: sets actEntry.gen outside", "genMember.recordCurrentTierLocked: sets actEntry.proc outside", |
| "shedChild.installProcLocked: sets actEntry.proc outside"}, |
| + "install_pkgfunc.go": {"package-level installResident: sets actEntry.proc outside", |
| + "package-level installResidentGen: sets actEntry.gen outside"}, |
| + "install_pkglit.go": {"package-level residentEntry: builds an actEntry with proc", |
| + "package-level residentEntries: builds an actEntry with gen"}, |
| } |
| func TestResidentProcessInstallsGoThroughOnePlace(t *testing.T) { |
diff --git a/internal/activator/rootfs_resident_lease_test.go b/internal/activator/rootfs_resident_lease_test.go| index 239cabfd7..2f4c82dac 100644 |
| --- a/internal/activator/rootfs_resident_lease_test.go |
| +++ b/internal/activator/rootfs_resident_lease_test.go |
| @@ -452,16 +452,13 @@ func TestResidentQueuedRestartDuringWakeIsWatched(t *testing.T) { |
| drain := make(chan struct{}) |
| proc.setStopGate(drain) // the bounce's SIGTERM drain hangs |
| proved := make(chan struct{}) |
| + var provedOnce sync.Once |
| + releaseProof := func() { provedOnce.Do(func() { close(proved) }) } |
| var killed sync.Once |
| endAll := func() { killed.Do(func() { proc.exit(); close(drain) }) } |
| - t.Cleanup(func() { |
| - endAll() |
| - select { |
| - case <-proved: |
| - default: |
| - close(proved) |
| - } |
| - }) |
| + // The proof first: the kill callback may be inside killed.Do waiting on |
| + // it, and endAll's Do would wait for that callback. Then the drain. |
| + t.Cleanup(func() { releaseProof(); endAll() }) |
| var heldAtKill, closedAtKill bool |
| kb.kmu.Lock() |
| kb.onKill = func(uint64) { |
| @@ -488,7 +485,7 @@ func TestResidentQueuedRestartDuringWakeIsWatched(t *testing.T) { |
| if !a.hasEntry(host) || rep.isClosed() { |
| t.Fatal("the entry or the lease was released while the kill's proof was outstanding") |
| } |
| - close(proved) |
| + releaseProof() |
| waitFor(t, "the stop to finish", func() bool { return !a.hasEntry(host) }) |
| if !heldAtKill || closedAtKill { |
| t.Fatalf("at the kill: entry held %v, lease closed %v; want held and not closed", heldAtKill, closedAtKill) |
diff --git a/internal/activator/testdata/rootfs_verb_guard/install_pkgfunc.go b/internal/activator/testdata/rootfs_verb_guard/install_pkgfunc.go| new file mode 100644 |
| index 000000000..0454cface |
| --- /dev/null |
| +++ b/internal/activator/testdata/rootfs_verb_guard/install_pkgfunc.go |
| @@ -0,0 +1,11 @@ |
| +// Installs through package-level function literals, no FuncDecl in sight: |
| +// a plain var, and one in a var block named like the owner's helper. |
| +package activator |
| + |
| +var installResident = func(e *actEntry, p Proc) { e.proc = p } |
| + |
| +var ( |
| + installResidentGen = func(e *actEntry, g Gen) { |
| + func() { e.gen = g }() |
| + } |
| +) |
diff --git a/internal/activator/testdata/rootfs_verb_guard/install_pkglit.go b/internal/activator/testdata/rootfs_verb_guard/install_pkglit.go| new file mode 100644 |
| index 000000000..0d3308b55 |
| --- /dev/null |
| +++ b/internal/activator/testdata/rootfs_verb_guard/install_pkglit.go |
| @@ -0,0 +1,10 @@ |
| +// Package-level actEntry literals with a process or generation already on |
| +// them. |
| +package activator |
| + |
| +var residentEntry = &actEntry{host: "shop.example.com", proc: (*fakeGuardProc)(nil)} |
| + |
| +var residentEntries = []actEntry{{host: "shop.example.com", gen: Gen{N: 1}}} |
| + |
| +// fakeGuardProc is a Proc for the literal above. |
| +type fakeGuardProc struct{ Proc } |