carlos / platform Public

retire-window-415: Astra round 1 P2 fixes (READY AFTER FIXES)

Round 1 (gpt-6-astra, findings in
docs/superpowers/specs/CODEX-FINDINGS-RETIRE-WINDOW-415.md): no P1, two
P2s, the six record-write census units approved.

- P2 1: the hourly trash sweep with lifetimes off (sweepTrashedApp ->
  release.PurgeAppIfTrashedAt) purged an expired app's records without a
  note. It notes first now. TestTrashSweepNotesTheRecordsItPurges failed
  before the fix (the witness named sweepTrashedApp too).
- P2 2: the witness no longer exempts deleteRecordIfMatch. It reads the
  notes of every console a test builds over the fixture's bucket
  (witnessServer: the fixture's own and ltOn.restart's). Mutation checks:
  dropping the helper's note fails five recovery tests; noting the
  previous owner's delete under the wrong app fails the allocation tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 706696ca38b1600512fc540717435cb1611d7cbb parent 3a23d09
4 files changed, +117 −13
  • docs/superpowers/specs/CODEX-FINDINGS-RETIRE-WINDOW-415.md +38 −0
  • internal/console/deletion_evidence_test.go +77 −13
  • internal/console/lifetimes_create_test.go +1 −0
  • internal/console/lifetimes_purge.go +1 −0

CI passed — run details

diff --git a/docs/superpowers/specs/CODEX-FINDINGS-RETIRE-WINDOW-415.md b/docs/superpowers/specs/CODEX-FINDINGS-RETIRE-WINDOW-415.md
new file mode 100644
index 000000000..a87fffec3
--- /dev/null
+++ b/docs/superpowers/specs/CODEX-FINDINGS-RETIRE-WINDOW-415.md
@@ -0,0 +1,38 @@
+Reviewed `origin/main...3a23d0947e5793a9167cad5fb73f133466ee385a`, round 1.
+
+The six record-write census entries are **approved**. Their fingerprints match the source; no class changes or new storage writes were introduced.
+
+| Unit | Verdict and evidence |
+|---|---|
+| `allocCleanLocked` | **Approve — key-site.** Both deletes retain their keys and ETags. Previous-owner evidence uses `plan.ownerAccount/ownerApp`. [lifetimes_create.go:324](/home/paulca/.cache/tmp/claude-1001/fu/retire-window-all-deletes-415/internal/console/lifetimes_create.go:324) |
+| `allocPrevOwnerCleanLocked` | **Approve — key-site.** Account/app come from parsing `PrevOwnerKey`; deletion retains that key and `prev.ETag`. [lifetimes_create.go:353](/home/paulca/.cache/tmp/claude-1001/fu/retire-window-all-deletes-415/internal/console/lifetimes_create.go:353) |
+| `deleteUnderRetiredSlot` | **Approve — key-site.** Same retirement-owned key, slot checks and observed ETag. [lifetimes_create.go:533](/home/paulca/.cache/tmp/claude-1001/fu/retire-window-all-deletes-415/internal/console/lifetimes_create.go:533) |
+| `migrationStepsLocked` | **Approve — key-site.** Corrupt-body deletion retains the migration’s key and `obs.ETag`; quarantine ordering is unchanged. [lifetimes_migrate.go:224](/home/paulca/.cache/tmp/claude-1001/fu/retire-window-all-deletes-415/internal/console/lifetimes_migrate.go:224) |
+| `retireStaleLocked` | **Approve — key-site.** Same account/app-derived key and conditional delete. [lifetimes_retire.go:202](/home/paulca/.cache/tmp/claude-1001/fu/retire-window-all-deletes-415/internal/console/lifetimes_retire.go:202) |
+| `retirementStepsLocked` | **Approve — record-writer.** Adds an in-memory note before dispatch; the existing tombstone `WriteRecord` and conditional removal remain unchanged. [lifetimes_retire.go:233](/home/paulca/.cache/tmp/claude-1001/fu/retire-window-all-deletes-415/internal/console/lifetimes_retire.go:233), [lifetimes_retire.go:314](/home/paulca/.cache/tmp/claude-1001/fu/retire-window-all-deletes-415/internal/console/lifetimes_retire.go:314) |
+
+Detach and normal/cleanup recovery reach the noted retirement dispatcher. Orphan recovery, allocation recovery and migration cleanup reach the noted delete helper. Every helper call passes the deleted key’s own account/app. Existing instance, sidecar, seed-finish, owner-purge and early-expiry-purge paths already note deletion. Claims are treated as shelved and inert, as the brief specifies.
+
+Adding `domain-detach` only introduces another refusal condition; it removes no existing check. The witness’s mutex and `done` flag prevent background deletes from calling `t.Errorf` after cleanup.
+
+**P1: none found.**
+
+**P2 — Coverage: the lifetimes-off hourly trash sweep still deletes records without noting them.**
+At [lifetimes_purge.go:231](/home/paulca/.cache/tmp/claude-1001/fu/retire-window-all-deletes-415/internal/console/lifetimes_purge.go:231), `sweepTrashedApp` calls `release.PurgeAppIfTrashedAt` directly. Unlike `purgeOne`, this path has no preceding note. The release sweep deletes every app key, including instance and sidecar records, at [trash.go:376](/home/paulca/.cache/tmp/claude-1001/fu/retire-window-all-deletes-415/internal/release/trash.go:376).
+
+An expired app swept with lifetimes off therefore loses records without updating deletion evidence or invalidating cached ownership facts. This is an existing omission left unresolved by the promised complete coverage. Add `noteRecordDeletion(a.Account, a.App, time.Now())` before the purge dispatch and cover the lifetimes-off hourly sweep.
+
+Fault family: every console record deletion must record evidence for its owning app before storage changes.
+
+**P2 — Witness: helper deletes bypass verification entirely.**
+[deletion_evidence_test.go:100](/home/paulca/.cache/tmp/claude-1001/fu/retire-window-all-deletes-415/internal/console/deletion_evidence_test.go:100) identifies `deleteRecordIfMatch` as `helper`; [deletion_evidence_test.go:43](/home/paulca/.cache/tmp/claude-1001/fu/retire-window-all-deletes-415/internal/console/deletion_evidence_test.go:43) then returns before checking evidence.
+
+Consequently, removing the helper’s note—or passing the wrong account/app during previous-owner cleanup—would escape this witness. The restart accommodation exempts these deletes even on the original server. Associate observations with the server performing the delete, including restarted servers, and remove the exemption. Verify that missing-note and wrong-owner mutations fail.
+
+Fault family: the deletion witness must independently check evidence at the storage boundary.
+
+**P3: none found.**
+
+By code tracing, the two new tests exercise the intended regression: the first clears audit evidence, while the second uses a fresh server and disables its startup hold. Main lacks the respective memory and audit evidence. Execution remains unverified: the targeted test command failed before compilation because the sandbox cannot create Go’s work directory. No full suites ran; the root-read census pass was not independently reproduced. `git diff --check` passed. No files changed.
+
+READY AFTER FIXES
\ No newline at end of file
diff --git a/internal/console/deletion_evidence_test.go b/internal/console/deletion_evidence_test.go
index 3077249f4..a92ab097a 100644
--- a/internal/console/deletion_evidence_test.go
+++ b/internal/console/deletion_evidence_test.go
@@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"runtime"
+ "slices"
"strings"
"sync"
"testing"
@@ -39,11 +40,8 @@ func witnessDeletionEvidence(t *testing.T, srv *Server, rel release.Store) {
if !ok {
return
}
- caller, console, helper := deletingCaller()
- if !console || helper {
- return
- }
- if srv.recentlyDeleted(acct, app, time.Now()) {
+ caller, console := deletingCaller()
+ if !console || witnessNoted(ds, acct, app) {
return
}
mu.Lock()
@@ -52,6 +50,7 @@ func witnessDeletionEvidence(t *testing.T, srv *Server, rel release.Store) {
violations = append(violations, key+" deleted by "+caller+" with no deletion evidence for "+acct+"/"+app)
}
}
+ witnessServer(t, ds, srv)
ds.witness.Store(&w)
t.Cleanup(func() {
mu.Lock()
@@ -74,16 +73,57 @@ func recordOwnerOfKey(key string) (acct, app string, ok bool) {
return parts[1], parts[2], true
}
+// witnessServers is every console a test built over a fixture's bucket:
+// the fixture's own, and a second one (ltOn.restart) over the same bucket.
+// A delete counts as noted when any of them noted its account and app,
+// since the witness cannot tell which server made the delete.
+var witnessServers sync.Map // *deletableStore -> *[]*Server, under witnessServersMu
+
+var witnessServersMu sync.Mutex
+
+// witnessServer adds srv to the servers rel's witness reads, until the
+// test ends.
+func witnessServer(t *testing.T, rel release.Store, srv *Server) {
+ ds, ok := rel.(*deletableStore)
+ if !ok {
+ return
+ }
+ witnessServersMu.Lock()
+ defer witnessServersMu.Unlock()
+ v, _ := witnessServers.LoadOrStore(ds, &[]*Server{})
+ list := v.(*[]*Server)
+ *list = append(*list, srv)
+ t.Cleanup(func() {
+ witnessServersMu.Lock()
+ defer witnessServersMu.Unlock()
+ *list = slices.DeleteFunc(*list, func(x *Server) bool { return x == srv })
+ })
+}
+
+// witnessNoted reports whether any console over ds noted a deletion of
+// acct/app within the window.
+func witnessNoted(ds *deletableStore, acct, app string) bool {
+ witnessServersMu.Lock()
+ defer witnessServersMu.Unlock()
+ v, ok := witnessServers.Load(ds)
+ if !ok {
+ return false
+ }
+ for _, srv := range *v.(*[]*Server) {
+ if srv.recentlyDeleted(acct, app, time.Now()) {
+ return true
+ }
+ }
+ return false
+}
+
// deletingCaller walks the delete's stack, past the store doubles and any
// other package (release, provision, hostops), to the first frame in
// internal/console, and reports its function and whether it is console code.
// A _test.go frame reached first is the test deleting behind the console's
// back; a test wrapper's own Delete or DeleteIfMatch passes the console's
-// delete on and is walked past. helper is a delete made inside
-// deleteRecordIfMatch, which notes on its own server before it deletes: the
-// server may be a second console a test built (restart), whose notes this
-// fixture's witness cannot read.
-func deletingCaller() (caller string, console, helper bool) {
+// delete on and is walked past.
+func deletingCaller() (string, bool) {
pcs := make([]uintptr, 64)
n := runtime.Callers(3, pcs)
frames := runtime.CallersFrames(pcs[:n])
@@ -95,12 +135,12 @@ func deletingCaller() (caller string, console, helper bool) {
case strings.HasSuffix(f.File, "_test.go") && isStoreMethod(f.Function):
// A test's store wrapper passing the console's delete on.
case strings.HasSuffix(f.File, "_test.go"):
- return f.Function, false, false
+ return f.Function, false
case strings.Contains(f.File, "/internal/console/"):
- return f.Function, true, strings.HasSuffix(f.Function, ".(*Server).deleteRecordIfMatch")
+ return f.Function, true
}
if !more {
- return "", false, false
+ return "", false
}
}
}
@@ -198,3 +238,27 @@ func (s ltModStore) ListMod(ctx context.Context, prefix string) ([]release.KeyMo
}
return ml.ListMod(ctx, prefix)
}
+
+// #415 review (Astra round 1, P2 1): the hourly trash sweep with lifetimes
+// off purges an expired app's records through the release sweep; it notes
+// the deletion first, like every other path.
+func TestTrashSweepNotesTheRecordsItPurges(t *testing.T) {
+ fx := newConsoleFixture(t)
+ ctx := context.Background()
+ now := time.Now()
+ rec := provision.Record{Schema: 1, Host: "one.kass.example.com", Slug: "one", App: "kass",
+ Account: release.OpsAccount, Channel: "stable", CreatedAt: now.Add(-48 * time.Hour)}
+ if err := provision.CreateRecord(ctx, fx.rel, rec); err != nil {
+ t.Fatal(err)
+ }
+ if err := release.TrashApp(ctx, fx.rel, release.OpsAccount, "kass", "test", now.Add(-release.TrashCooloff-time.Hour)); err != nil {
+ t.Fatal(err)
+ }
+ fx.srv.trashSweep(ctx, now)
+ if _, _, err := fx.rel.Get(ctx, provision.RecordKey(release.OpsAccount, "kass", rec.Host)); !errors.Is(err, os.ErrNotExist) {
+ t.Fatalf("the record after the sweep = %v, want it purged", err)
+ }
+ if !fx.srv.recentlyDeleted(release.OpsAccount, "kass", time.Now()) {
+ t.Fatal("the sweep purged a record without noting the deletion")
+ }
+}
diff --git a/internal/console/lifetimes_create_test.go b/internal/console/lifetimes_create_test.go
index 954a6c277..d693cbcb5 100644
--- a/internal/console/lifetimes_create_test.go
+++ b/internal/console/lifetimes_create_test.go
@@ -235,6 +235,7 @@ func (l ltOn) restart(t *testing.T) *Server {
if err != nil {
t.Fatal(err)
}
+ witnessServer(t, l.fx.rel, srv) // its deletion notes count too (#415)
ctx := context.Background()
srv.lifetimesWatchOnce(ctx)
l.clock.Advance(lifetimeSettle)
diff --git a/internal/console/lifetimes_purge.go b/internal/console/lifetimes_purge.go
index 460e858b2..68eed0704 100644
--- a/internal/console/lifetimes_purge.go
+++ b/internal/console/lifetimes_purge.go
@@ -228,6 +228,7 @@ func (s *Server) sweepTrashedApp(ctx context.Context, a release.TrashedApp, now
if lifetimesUnit(ctx) {
err = s.purgeAppWithLifetimes(ctx, a.Account, a.App, tomb.DeletedAt, now)
} else {
+ s.noteRecordDeletion(a.Account, a.App, time.Now()) // the canary-retire guard's evidence, first (#415)
err = release.PurgeAppIfTrashedAt(ctx, s.cfg.Releases, s.cfg.ReleasePub, a.Account, a.App, tomb.DeletedAt, now)
}
if err != nil {