Skip to content

feat: NativeConcurrency package trait — NIO/AsyncKit-free SQLiteKit#2

Draft
scottmarchant wants to merge 3 commits into
feat/khasmPAL-2026from
feat/native-concurrency-trait
Draft

feat: NativeConcurrency package trait — NIO/AsyncKit-free SQLiteKit#2
scottmarchant wants to merge 3 commits into
feat/khasmPAL-2026from
feat/native-concurrency-trait

Conversation

@scottmarchant

Copy link
Copy Markdown
Collaborator

What

Adds a NativeConcurrency package trait to SQLiteKit: an opt-in, NIO/AsyncKit-free Swift-concurrency flavor.

  • Package@swift-6.1.swift (versioned traits manifest): declares NIO (member of the default trait set), NativeConcurrency, and Freestanding, and forwards the trait selection to the storage stack (sqlite-nio / sql-kit trait-conditional dependencies). Pre-6.1 toolchains never see this file and keep resolving the plain Package.swift, so nothing changes for them.
  • NIO stays the default trait: a consumer that specifies nothing gets the existing NIO/AsyncKit-based API (EventLoopGroup-driven SQLiteConnectionSource, EventLoopFuture surfaces), byte-identical to today.
  • --traits NativeConcurrency re-keys the sources (#if NativeConcurrency): SQLiteConnectionSource, the SQLKit bridging (SQLiteConnection+SQLKit), and the data encoder/decoder paths move onto plain async/await with no NIO or AsyncKit linkage.

Why

Staged fork-internally ahead of a possible upstream proposal: it lets Swift-concurrency-native (and Embedded/WASI-leaning) consumers run the SQLite storage stack with zero NIO/EventLoopFuture surface while keeping one source tree, selected purely through SwiftPM package traits.

Verification

  • Default flavor: swift build and swift test green — the default (NIO) trait build is unchanged behavior.
  • swift build --traits NativeConcurrency: green, with no EventLoopFuture/NIO/AsyncKit surface in the flavor's API.

Branch shape

Base is the fork's feat/khasmPAL-2026 at exactly the revision khasm pins. The head carries the one fork-internal Embedded-gating commit the trait conversion textually builds on (the embedded port rebased onto that base with Embedded-only gating), the trait conversion commit itself, and a follow-up build commit pointing the trait-forwarded sqlite-nio/sql-kit dependencies at the fork branches that actually declare the NativeConcurrency trait (PassiveLogic/sqlite-nio#2, PassiveLogic/sql-kit#2) — required for standalone --traits resolution, since the previously referenced revisions declare no traits.

🤖 Generated with Claude Code

scottmarchant and others added 3 commits July 6, 2026 12:33
…sm's pinned base), Embedded-only gating

Replays the feat/swift-wasm-embedded-poc work (embedded SQLiteData
encoder/decoder stubs, Codable row-decode gates, dynamic-cast-free
version comparison) on top of the exact sqlite-kit revision khasm's
Package.resolved pins (d6a7f12, feat/khasmPAL-2026) instead of the
upstream-main base. The NIO-flavored gates become
`#if hasFeature(Embedded)`; the khasmPAL NIOAsyncRuntime-based
SQLiteConnectionSource is restored for regular WASI and gated out only
on Embedded. NIO products + AsyncKit are dropped from the manifest only
with KHASM_EMBEDDED=1; swift-nio/async-kit stay on the PassiveLogic fork
URLs (NOT local path clones — transitive path deps override identities
in the khasm root graph and the local swift-nio clone is not
flavor-safe). sqlite-nio/sql-kit resolve to the local embedded clones.

Prior upstream-main-based branch preserved as
feat/swift-wasm-embedded-poc-upstream-base.

Verified: embedded SDK build (KHASM_EMBEDDED=1) green; native green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add SwiftPM traits via a versioned Package@swift-6.1.swift, folding the
former Package@swift-5.9.swift port manifest into it (two manifests total:
the 5.8 base for old toolchains + the 6.1 traits manifest):

- traits: `NIO` (default; SwiftNIO + AsyncKit exactly as today) and
  `NativeConcurrency` (NIO-free: no connection-pool source, async-only
  surface over sqlite-nio's NativeConcurrency driver). The NIO/AsyncKit
  products carry `.when(traits: ["NIO"])`; the KHASM_EMBEDDED env
  conditional is gone. The sqlite-nio and sql-kit edges forward
  `default`/`NativeConcurrency` conditionally on this package's own traits.
- Source: NIO-swap gates re-keyed from `#if hasFeature(Embedded)` to
  `#if NativeConcurrency` (AsyncKit re-export, SQLiteConnectionSource
  whole-file, the SQLDatabase wrapper's eventLoop/future-execute/withSession).
  New for the (Foundation ∧ NativeConcurrency) combination: the Codable
  SQLiteDataDecoder's JSON blob fallback reads [UInt8] blobs, and the
  Codable encoder/decoder no longer import NIOCore/NIOFoundationCompat.
  Genuine Embedded language-limit gates (Codable coders' embedded stubs,
  UUID, `as? Self`, decode) stay on `hasFeature(Embedded)`.
- Accepted loss under NativeConcurrency: no `ConnectionPoolSource`.

Note: this commit keeps the branch-base remote URLs for PR-cuttability;
the khasm-graph path wiring lands separately.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…om the fork's feat/native-concurrency-trait branches

The trait-conditional dependency declarations enable NativeConcurrency on
sqlite-nio and sql-kit, so the resolved revisions must declare that trait.
Point both at the PassiveLogic fork branches carrying the trait manifests
(sql-kit's upstream 3.33.1+ and the fork's feat/khasmPAL-2026 sqlite-nio
branch declare no traits, which fails resolution under --traits).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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