Summary
The SQLite periodic cleanup loop calls the in-memory Store.CleanupRuns directly and never commits the resulting deletes. On source base 49078e7adce93c8ed61108c6f427782f475cfc2c, a real timer tick removes an expired run and its evidence from memory, but all six durable rows remain. Reopening without the final Close/Flush persist restores the run and checkpoint. This is a deterministic local SQLite reproduction, not a production load or process-kill claim.
The prior historical tracker #2154 mentioned cleanup-loop shutdown, but its text incorrectly treated s.store.CleanupRuns as a persistence call. This issue uses the current code and a real durable-reopen failure instead of reopening that catch-all tracker.
Scope / file ownership
One writer in an isolated task worktree. Allowed files:
edge-server/internal/store/sqlite_store.go: commit periodic deletions, retain pending persistence for retry after transient failure, and stop/join owned background loops before final shutdown persistence. Tests use testing/synctest to advance the actual constructor-owned loops at production cadence; no shortened interval seam is added.
edge-server/internal/store/sqlite_periodic_cleanup_test.go: real database, actual timer/constructor, fault-recovery and shutdown coverage.
docs/architecture/02-edge-server.md: align the stable persistence/lifecycle description if needed.
Interfaces / invariants / exclusions
Public APIs, 5-minute cadence, 24-hour terminal TTL, 50-per-thread cap, selected terminal states and cascade membership stay unchanged. Preserve the existing explicit-write failure policy: memory may change on a failed durable commit and LastPersistError reports that failure. No schema, connection-pool, PRAGMA, WAL policy, settings, runtime configuration or deployment changes. No new verifier or broad storage abstraction; no actual workspace files are deleted by run retention.
Acceptance
Initial failing regression: go test ./internal/store -run TestSQLitePeriodicCleanupIsDurableBeforeClose -count=1 -v from edge-server with CGO_ENABLED=0 on Windows. The test explicitly bypasses final persistence so shutdown cannot hide the missing periodic write.
Summary
The SQLite periodic cleanup loop calls the in-memory
Store.CleanupRunsdirectly and never commits the resulting deletes. On source base49078e7adce93c8ed61108c6f427782f475cfc2c, a real timer tick removes an expired run and its evidence from memory, but all six durable rows remain. Reopening without the finalClose/Flushpersist restores the run and checkpoint. This is a deterministic local SQLite reproduction, not a production load or process-kill claim.The prior historical tracker #2154 mentioned cleanup-loop shutdown, but its text incorrectly treated
s.store.CleanupRunsas a persistence call. This issue uses the current code and a real durable-reopen failure instead of reopening that catch-all tracker.Scope / file ownership
One writer in an isolated task worktree. Allowed files:
edge-server/internal/store/sqlite_store.go: commit periodic deletions, retain pending persistence for retry after transient failure, and stop/join owned background loops before final shutdown persistence. Tests usetesting/synctestto advance the actual constructor-owned loops at production cadence; no shortened interval seam is added.edge-server/internal/store/sqlite_periodic_cleanup_test.go: real database, actual timer/constructor, fault-recovery and shutdown coverage.docs/architecture/02-edge-server.md: align the stable persistence/lifecycle description if needed.Interfaces / invariants / exclusions
Public APIs, 5-minute cadence, 24-hour terminal TTL, 50-per-thread cap, selected terminal states and cascade membership stay unchanged. Preserve the existing explicit-write failure policy: memory may change on a failed durable commit and
LastPersistErrorreports that failure. No schema, connection-pool, PRAGMA, WAL policy, settings, runtime configuration or deployment changes. No new verifier or broad storage abstraction; no actual workspace files are deleted by run retention.Acceptance
Initial failing regression:
go test ./internal/store -run TestSQLitePeriodicCleanupIsDurableBeforeClose -count=1 -vfromedge-serverwithCGO_ENABLED=0on Windows. The test explicitly bypasses final persistence so shutdown cannot hide the missing periodic write.