Skip to content

Add W1 transaction ownership and lazy initialization foundations - #150

Merged
bazer merged 1 commit into
v0.10from
codex/0.10-w1-transaction-ownership
Sep 17, 2026
Merged

bazer merged 1 commit into
v0.10from
codex/0.10-w1-transaction-ownership

Conversation

@bazer

@bazer bazer commented Sep 17, 2026 •

Copy link
Copy Markdown
Owner

Why

The W1.1 contracts need explicit transaction ownership that survives suspension and can express first-use initialization without publishing half-initialized resources. The existing integer busy flag and thread-ID hydration allowance are not an async ownership model.

This is the W1.2 foundation, following merged #147 and the accepted limited W1 exception. It does not claim the complete W1.2 or W1 exit gate.

Changes

  • Replace the existing synchronous mutation/commit/rollback/disposal busy flag with a per-transaction operation lease. Conflicting calls still fail immediately; diagnostics now name the attempted and active operations.
  • Add explicit private steps, stale/foreign owner rejection and ownership transfer for reader lifetimes. No ambient AsyncLocal privilege, operation queue, database-wide lock or lock held during provider work/awaits.
  • Add internal resource initialization with separate direct sync/async paths. Publish only after full success; pre-cancellation leaves unused state reusable; started failures are terminal and never replayed.
  • Retain ownership during independent cleanup, preserve initialization and cleanup failure identities, and allow explicit final disposal of a partial resource when initialization cleanup failed.
  • Add 26 deterministic cases, including existing managed-transaction fixtures, cross-thread ownership, staged initialization failure/cancellation and cleanup suspension.

Deliberate limits

Production provider initialization is not wired to these helpers and its behavior is unchanged. Public async APIs, native dispatch, package dependencies and SQLite pooling are unchanged.

Existing read checks consult the shared gate, but full read/enumerator lifetime admission is not introduced here. The existing synchronous thread-ID hydration allowance remains on its old path; it must be replaced with a private owned source before async integration. Command/reader wrappers, callback drain/recovery, public failure composition, invocation capture and native bindings remain later work.

The gate adds allocation and short transition-lock costs versus the old integer flag. Performance comparison with W0 remains required; this PR makes no performance acceptance claim. W0-F1/native SQLite acceptance/release gates remain open.

Validation

All local executions used Release / .NET 10 and retained Testing CLI summaries/raw reports:

  • Transaction-focused unit tests: 101/101 passed.
  • Full unit suite: 1,890/1,890 passed.
  • SQLite-file anchor shard, max parallelism 8: 516/516 passed.
  • SQLite-memory anchor shard, max parallelism 8: 516/516 passed.
  • Core Release builds: .NET 8/9/10, zero warnings/errors.
  • Unit and compliance Release builds: zero warnings/errors.
  • Diff whitespace and local planning-document links checked. These pages are excluded from DocFX.

The implementation record names the local artifacts/w1-ownership-* reports. These were modified-checkout development checks, not frozen release evidence. Latest CI run 35242670355 passed all 12 jobs, including the required gate, on commit 52c3e3d69c047817d2ba827f06324be504207cdd. This PR is left open for review. No packages published.

Share explicit operation leases with existing synchronous mutation and completion guards. Protect private dispatch and reader handoff across awaits without ambient privileges, queuing or provider work under locks.

Add internal lazy resource publication with direct sync and async initialization, cancellation boundaries, terminal first-use failures and independent cleanup. Record 26 new controlled tests, 1,890 passing unit tests, both SQLite compliance shards and the remaining source/provider integration and performance gates.
@bazer
bazer merged commit 6dc4682 into v0.10 Sep 17, 2026
12 checks passed
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