Goal
Establish GRDB with system SQLite as the native database dependency for the indexing work in #93, with verified JSON, expression-index, and FTS5 support, without adding SQLite or GRDB to portable MarkdownUtilitiesCore.
Packaging decision
Selected: option 1 — upstream GRDB through Swift Package Manager, using the SQLite runtime supplied by the operating system or Linux distribution.
This supersedes the earlier preference for a controlled bundled SQLite build. md-utils will not vendor or bundle its own SQLite runtime in the selected approach. SQLite versions, compilation options, and SQLite security/correctness updates are supplied by the OS or distribution; md-utils maintains its GRDB dependency and documents supported environments. A particular SQLite version alone is not proof that all required capabilities are available.
Fallback: option 3 — a source-based SwiftPM adaptation of GRDB using a controlled bundled SQLite runtime. Revisit this only if the system-runtime approach cannot meet supported deployment requirements. The fallback would require a maintainable GRDB C-module/package adaptation, matching feature flags, and verified symbol isolation and macOS/Linux compatibility. It must preserve SwiftPM builds; it is not the current implementation plan.
Rejected: option 2 — GRDB's Xcode-based custom SQLite framework workflow. Do not introduce an Xcode-specific build or distribution requirement for this integration.
Scope
- Integrate upstream GRDB into the native indexing target through SwiftPM. Keep GRDB and SQLite out of Core and its WASM dependency graph.
- Replace the earlier bundled-runtime prototype as needed to implement this decision; do not retain a second bundled SQLite runtime for index operations.
- Demonstrate compilation and linkage on macOS and Linux, and document the support matrix for other package targets. Document any required Linux development/runtime packages.
- Measure release binary size and clean-build overhead for the selected GRDB/system-SQLite approach, and check linkage in library consumers. Measurements of the earlier amalgamation prototype do not establish the overhead of this approach.
- Before creating, opening for mutation, or migrating an index, run capability probes through an in-memory GRDB connection using the same linked SQLite runtime as index operations. Exercise JSON queries, JSON expression-index creation/use, and FTS5 creation/write/search; do not rely solely on version numbers or reported compile options.
- Missing required capabilities must produce actionable errors identifying the linked SQLite runtime and the failed capability, with guidance to use a supported OS/distribution/runtime package. Fail before touching the index; do not silently fall back to a different runtime or reduced functionality. Existing non-index commands remain usable.
- Keep the public index schema based on standard SQLite JSON text, expression indexes, and FTS5 facilities, without requiring GRDB-specific SQL functions or custom extensions.
- Document that external SQLite tools use their own runtime and need compatible capabilities; installing md-utils or GRDB does not upgrade those tools.
- Define GRDB dependency maintenance and OS/distribution SQLite support/update policy. Own macOS/Linux validation in this repository.
Acceptance criteria
Out of scope
Implementing the option 3 fallback, Xcode-based database integration, StructuredQueries adoption, DuckDB, JMESPath/SQLite integration, and sqlite-jsonschema. DuckDB analytics and sqlite-jsonschema are potential future options only. Incremental indexing and query/server integration remain in the later child issues of #93.
Goal
Establish GRDB with system SQLite as the native database dependency for the indexing work in #93, with verified JSON, expression-index, and FTS5 support, without adding SQLite or GRDB to portable MarkdownUtilitiesCore.
Packaging decision
Selected: option 1 — upstream GRDB through Swift Package Manager, using the SQLite runtime supplied by the operating system or Linux distribution.
This supersedes the earlier preference for a controlled bundled SQLite build. md-utils will not vendor or bundle its own SQLite runtime in the selected approach. SQLite versions, compilation options, and SQLite security/correctness updates are supplied by the OS or distribution; md-utils maintains its GRDB dependency and documents supported environments. A particular SQLite version alone is not proof that all required capabilities are available.
Fallback: option 3 — a source-based SwiftPM adaptation of GRDB using a controlled bundled SQLite runtime. Revisit this only if the system-runtime approach cannot meet supported deployment requirements. The fallback would require a maintainable GRDB C-module/package adaptation, matching feature flags, and verified symbol isolation and macOS/Linux compatibility. It must preserve SwiftPM builds; it is not the current implementation plan.
Rejected: option 2 — GRDB's Xcode-based custom SQLite framework workflow. Do not introduce an Xcode-specific build or distribution requirement for this integration.
Scope
Acceptance criteria
Out of scope
Implementing the option 3 fallback, Xcode-based database integration, StructuredQueries adoption, DuckDB, JMESPath/SQLite integration, and sqlite-jsonschema. DuckDB analytics and sqlite-jsonschema are potential future options only. Incremental indexing and query/server integration remain in the later child issues of #93.