feat(#306): OwnerRefs + finalizers + cascade GC (D5)#480
Open
windoliver wants to merge 17 commits into
Open
Conversation
…age; doc the orphan idempotency contract
…p (Sqlite) Extends AgentTaskStore interface with setAgentTaskDeletion, removeAgentTaskFinalizer, removeAgentTaskOwnerRef, reapAgentTask; implements them on SqliteAgentTaskStore via a shared mutateSpec CAS helper; widens AgentTaskSpecRecord/EntityMetadata finalizers to accept KindFinalizer|PropagationFinalizer; stubs four methods on TestAgentTaskStore and fakeTaskStore.
…on; CAS test + cast fixes
…real-loop test timeout under coverage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Kubernetes-style garbage collector for Grove's entity hierarchy (Epic D / #285, D5). Closes #306.
controller?: booleanflag +taskGroup/agentTaskkinds; newgrove.dev/*finalizer constants (KindFinalizer.PendingReview/PendingMerge,PropagationFinalizer.Foreground/Orphan) and aCascadePolicytype.owner-graph.ts— pure, I/O-free cascade/reap decision core (policyOf,planOwnerDeletion,planDanglingChild). Idempotent: returns[]at convergence.garbage-collector.ts—GarbageCollectorreconcile loop (same skeleton astask-controller/claim-controller) over a segregatedGcStoreinterface; CAS viawithIfMatch, cross-level re-drive so multi-level cascades converge without waiting for resync.SqliteAgentTaskStoregainssetAgentTaskDeletion/removeAgentTaskFinalizer/removeAgentTaskOwnerRef/reapAgentTask(finalizer-guarded hard delete; status row drops via the existing FK cascade). No schema migration (columns already existed).AgentTaskGcStore+CompositeGcStorebridge the loop to real AgentTask rows and span an (in-memory) TaskGroup owner + real AgentTask children.garbage-collector-wiring.ts(gated byGROVE_GC); liveserve.tsactivation deliberately deferred with TaskGroup persistence.Cascade policy is encoded as a propagation finalizer on the owner at delete time (mirrors k8s
foregroundDeletion/orphan), so policy survives restarts.Acceptance criteria (#306)
pending-review(in-memory + real SQLite). MergeTask/pending-mergedeferred (mechanism ready)Deferred follow-ups (documented in spec/plan/code, not dropped)
MergeTaskentity +grove.dev/pending-merge(one constant + one assignment away).TaskGrouppersistence (SQLite/Nexus) + live server-side GC activation.Terminatingcondition emission (needs status writes).listAll) —resync()only enumerates pending-deletion owners + their children; documented inline.Notable review fixes (adversarial review during development)
owner_ref_json"null"-string corruption + RV churn in the no-op write path.Test plan
bunx tsc --noEmitclean (theerasableSyntaxOnly/isolatedDeclarationsgate).owner-graph,garbage-collector(incl. real-worker-loop convergence),in-memory-gc-store,agent-task-gc-store(real SQLite Foreground/Background cascade +pending-reviewreap-block),sqlite-storelifecycle mutators (CAS + no-op + FK-cascade),garbage-collector-wiring.Note: the full
bun testsuite is green on this code when not resource-contended; an over-parallel coverage run produced timeouts in unrelated subprocess-heavy CLI-init/Nexus tests + one pre-existing Docker-probe test (resolveBackend), none in the changed code — verified by isolated re-runs.