Repository navigation
Add schema-bound transactional runtime mutations (PR B) [skip ci] - #113
Merged
Merged
Conversation
added 8 commits
October 7, 2026 03:00
Dastari
changed the base branch from
feat/runtime-migration-targets-20260930
to
main
October 12, 2026 00:04
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.
Runtime-schema hosts can create, patch and delete one exact-key record inside an ORM state-machine transaction, with explicit host authority and atomic typed repository journal writes. Dropping a runtime mutation or guarded journal hook poisons the transaction: catching the timeout and returning
Okcannot commit staged work.Dependency and review checkpoint
c53a5de966ca5089a5e4aa2d727e144bae83e6bd.f2665ce68ed7fdbccb272cb8a783b6379ae5fd82. Digibase accepts R1–R3; this PR targets A's branch to keep the B diff separate.a3fc34c76e9e62f34f989d3bb9767493fc339035.01d4134da18028ec58e318e0ffd30ab244d0d8e1. Do not adopt this branch as a released combined source.B1 correction and exact-head verification
Digibase's fresh-database SQLite suffix-CAS reproduction failed before this correction: the four-bind budget invoked preimage authorization before the five-bind UPDATE was rejected. The regression reproduces that failure without schema drift or a host workaround.
RuntimePredicate::mutation_bind_countnow takes the selected backend and counts values emitted by the existing predicate renderer. Both CAS and authority preflight paths use it, including the key-plus-authority read budget. This adds no separate operator-count table and does not count repeated PostgreSQL SQL occurrences as distinct native binding slots. Public APIs, schema/hash/storage semantics and package versions remain unchanged.Verification at
04a1216aff86141ff6500b1dd0bf9adb4b0c6447:$nreferences consume one slot, not one per SQL occurrence.[skip ci]. No owner merge/publication.Focused commands (with
CARGO_BUILD_JOBS=2, disk scratch and sequential backends):The Clippy/Rustdoc, format, documentation, dependency, release-policy and compatibility commands below were rerun for B1. Prior broader migration/static/external-consumer evidence remains labelled with its earlier head. C's predecessor acceptance remains gated on B1 re-review. #112 does not resolve B1's accounting defect and is not copied into this branch.
Public contract
ValidatedRuntimeSchemabuildsruntime_key,runtime_create_request,runtime_update_requestandruntime_delete_request. Inputs are owned and schema-bound; omitted fields, SQL NULL and JSON null remain distinct. Required non-generated keys, composite ordering, immutable update keys, generated UUIDs, append-only restrictions and resource bounds are checked. Unsupported generation and modifying incoming delete actions reject explicitly.MutationContext::mutate_runtimerequiresRuntimeMutationEnvironment,RuntimeWriteAuthority<B>andTransactionMode::StateMachine. It reuses runtime handles, predicates, values, projections, row decoding and the existing pinned backend transaction. No raw SQL escape hatch or second canonical IR is added.The authority separately approves complete intent, authoritative preimage and actual staged result. Host policy-only revisions are checked in intent against the host's pinned policy generation; ORM fingerprints are separate. Internal projections union policy fields, keys, changed/CAS fields and requested outputs but never escape in the effect. SQL-renderable row restrictions apply to preimages and actual results. Missing/invisible/preimage-denied rows return
not_found; CAS conflicts are distinguished only after authorizing the preimage. Return grants must exactly match the requested projection, includingNone.The operation guard begins before the first await. Failure/drop poisons the context; unfinished/forgotten work separately blocks commit. The outer runner and
commit_and_emitcheck both invariants.run_runtime_before_commitseparately guards host hooks and their repository journal writes. Success remains pending until the outer runner commits; the engine emits no events.TransactionError::commit_outcomeconservatively retains unknown outcomes. Static-only inner-timeout behavior is unchanged.A's environment gains a private backend binding and a read-only accessor; its physical target, planner, hash/storage semantics and approved FK/DateTime corrections are preserved. Third-party backend traits gain no required methods;
RuntimeMutationBackendis additive. MSSQL reports unsupported capability.Executable consumer example
crates/graphql-orm/examples/runtime_mutation_journal.rsruns create, CAS update and delete with typed journal inserts on each backend. SQLite uses owned memory; PostgreSQL starts an identity-verified disposable Docker database. The same example runs throughtests/fixtures/repository-aggregate-consumerwith no direct async-graphql dependency.Prior B verification at
a3fc34c76e9e62f34f989d3bb9767493fc339035The first SQLite development run exposed a nullable record-state handling mistake in B, corrected before these successful runs. PostgreSQL string-prefix/suffix CAS inherits the pre-#112 renderer on this branch; combined string/CAS verification must follow the owner-controlled #112/A/B reconciliation before adoption. No fix is copied into B.
Commands use
CARGO_BUILD_JOBS=2, Rust 1.97.1, disk-backed scratch/targets and sequential backend lanes. No workspace--all-features, ambient application database, hosted workflow dispatch or release publication was used.Coverage includes staged-DML result-authorization cancellation, staged-journal hook cancellation, cancellation before DML, whole-runner cancellation, caught denial followed by successful work, forgotten guard state, connection reuse and suppressed events. Tests also cover current host policy revisions, field/row/output denial, bound-value limits, composite keys, nullable omission/NULL, generated UUIDs, JSON-null distinction, exact integer/date/byte values, defaults, CAS concurrency, cascade rejection/RESTRICT, PostgreSQL RLS and transaction-local auth. A's no-op, FK, RLS, legacy DateTime/Integer and rollback regressions remain selected.
Compatibility and limitations
No data migration, static API/SDL/cursor or timestamp-unit changes. Ordinary repository consumers remain framework-neutral. Bulk/nested writes and upserts are outside this slice. Runtime mutation support is SQLite/PostgreSQL; MSSQL evidence is compile-only, not live mutation execution. Driver decoding allocates complete selected values before applying record byte limits; limits are not streaming memory guarantees.
The host must pin the physical environment and complete policy revision under its external-DDL/schema fence. A certificate is not a lease protecting against arbitrary external DDL. Invoke hooks through the guarded wrapper; propagate errors from direct journal writes. Static-only transactions retain their prior cancellation limitation. Unknown commit outcomes require host reconciliation, not blind retries; no durable replay guarantee is claimed.
Downstream handoff
After owner merge/release of #112 and final A/B reconciliation/review, pin the exact reviewed immutable source with aligned ORM/macros and
default-features = false, selectingsqliteorpostgres. Compose runtime/system metadata, verify/apply A, retain its environment with the host schema generation, supply explicit runtime authority and current policy-revision checks, and execute through auth-aware state-machine transactions. Use guarded hooks or propagated typed journal inserts; publish success only after the runner returns. Run downstream SQLite/PostgreSQL contracts before adoption. No release identity is assigned by this PR.Documentation impact
New canonical runtime-mutation reference and index link, compiled/external host example, active A–D checkpoint, changelog/migration notes, aligned manifests/fixture locks and generated inventory. Future CI/release test selections include the new suite; Actions remain paused and all commits use
[skip ci].