Skip to content

refactor(global-db): run more registered writes as job transactions - #4321

Open
ScriptedAlchemy wants to merge 12 commits into
masterfrom
refactor/storage-global-db-jobs-2
Open

ScriptedAlchemy wants to merge 12 commits into
masterfrom
refactor/storage-global-db-jobs-2

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Part of #4099 (storage redesign, cutover step 5, slice 5i-4). Does not close it.

What changes

About twenty more global-db interactive write transactions now run as RegisteredGlobalDb::transact jobs, so each is one bounded writer job instead of a held transaction.

  • transact_or(wrap, body) maps a refused or failed job to the site's own error type. transact_or_rollback(wrap, body) with JobExit::{Rollback, Fail} lets a body end early with a value the caller wants as success (a replayed append). The job rolls back, so a replay leaves no commit. transact_config and transact_rollup now use transact_or.
  • Converted: accounting (2), workflow index (2), git topology anchor (1), GitHub stack delivery (4), delivery settlement (2), source rewrite presence, begin and complete (3), registry forget and retire (2) plus the shared delete helper, remote deletion (3), discovery queue (1), analytics append, outbox claim, delay and settle, retention prune, and append with cursor.
  • Helpers under these sites take &impl Executor or &impl QueryExecutor, so the same body serves the job and the sites still on interactive transactions.
  • WorkflowIngestWriteTxn (sessions trait) and its global-db impl are deleted; nothing used them after the workflow adapter moved.

Bodies are Fn; each site clones what it owns into the closure and none has an effect outside storage.

Left for a later slice

  • apply_registry_gc reads outside the transaction while holding it.
  • relink_orphan_store_instance has a manifest file effect between the SQL and the commit.
  • claim_and_settle_observability_emissions takes an FnMut that allocates producer sequences; a re-run would allocate twice.
  • append_analytics_event uses the writer connection, not an interactive transaction.
  • Unread groups: project_registry.rs, observation_projection, registered_lcm*, registered_provider_usage, registered_dashboard, registered_sessions, git_correlation_adapter, schema_stages and schema_contract invariants, git_index_transactions/database.rs, observation/retention.rs, observation/canonical_bodies.rs, observation/schema.rs.

Evidence

  • New tests in tests.rs next to the 5i-3 job tests: transact_or_rollback_keeps_an_early_value_but_never_a_commit, transact_or_wraps_a_scope_that_ended_mid_body_and_rolls_back, converted_write_is_refused_without_a_write_scope.
  • Existing tests that now exercise converted multi-write sites, including analytics_import_cursor_failure_rolls_back_events and analytics_import_cursor_conflict_rolls_back_events, plus the stack delivery, settlement, source rewrite and outbox suites.
  • Bazel: global-db unit_test and registered_schema_fail_closed, sessions unit_test, //crates/tracedecay:unit_test, :daemon_suite, :mcp_suite, :session_suite all pass; --config=clippy on global-db and sessions clean; rustfmt_check_2024 passes for both.
  • No mutation run on the new helpers: the rollback is the runtime's, and the tests assert its effect through the new entry points.

Devin Review

@changeset-bot

changeset-bot Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 19dd56d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant