feat(database): atomically reconcile expired startup runs - #320
Draft
sandersonstabo wants to merge 3 commits into
Conversation
Adds fence-safe disposition for one expired E3 candidate: run->interrupted (retains binding, clears owner/lease/claim, stores bounded error pair, terminal_at NULL), dispatch->failed (clears lease, bounded reason), turn/item ->interrupted with consecutive lifecycle patches and counter advance. Full candidate-snapshot fences, SkippedMoved on zero-row, idempotent replay detection, and typed validation for patch/item agreement and counter/revision overflow. Single SeaORM transaction, no storage/provider/requeue. Includes in-memory tests for launching/no-item, running/with-item, unexpired boundary, stale snapshots, idempotent replay, mismatched input/duplicate patch/overflow, and terminal/queued isolation. Owned paths: modules/database/src/repository/startup_reconciliation_disposition.rs, tests/database/startup_reconciliation_disposition.rs VP must register module and re-export + Cargo/Bazel entries.
- production: remove stored-but-never-read LoadedState fields next_renderer_ordinal/updated_at_ms and LoadedTurn fields thread_id/ordinal/lifecycle/created_at_ms/updated_at_ms; retain validation before context construction; fences unchanged. - tests: remove unused OrdinalKind/RepositoryError, prefix unused claimed/receipt, combine identical bind arms, reduce commit_running_item to 4 args via RunningBatchFixtures, use sort_by_key, replace redundant closure with ItemId::as_str, replace len>=1 with !is_empty, add narrow allow for too_many_lines on two happy-path tests after helper extraction would obscure atomic assertions. rustfmt 1.98, cargo test 15 passed, cargo clippy (test+lib) clean, git diff --check clean. Owned paths only.
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.
Depends on #318.
Atomically fences one expired startup-reconciliation candidate and records the honest unknown outcome: run interrupted with provider binding retained, dispatch failed, and turn/optional assistant item sealed with ordered lifecycle patches. Stale snapshots roll back as a typed skip; identical replay is harmless.
Checks: focused database build; 15 atomic disposition tests; fresh production/test Clippy aspects; root format; locked/offline Cargo metadata; exact hash/status guards; Bazel shutdown 0.
Excluded: storage opening, cross-process custody, provider contact, prompt retry, startup/backend wiring, requeue, and remote merging.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Atomically fences one expired startup-reconciliation candidate in a single transaction, recording the honest unknown outcome: run interrupted with provider binding retained, dispatch failed, and turn/optional assistant item sealed with ordered lifecycle patches. Stale snapshots roll back as a typed skip; an identical replay is harmless.
Included
StartupReconciliationDispositionwith typed outcome, receipt, and error types, registered inmodules/database.Written for commit 1a5eff2. Summary will update on new commits.