mirror of
https://github.com/nearai/ironclaw.git
synced 2026-09-03 08:06:01 +08:00
Flips capabilities { query: true, index.exact: true, index.prefix: true }
on both SQL backends so consumer stores can filter records by their
declared indexed projection. With the foundation + port PRs landed,
this completes the record/index/CAS triad — what each migrating store
needs to drop its own backend matrix.
What's in:
- IndexValue serde changed to #[serde(untagged)] so SQL backends can run
native predicates against the stored JSON (`indexed->>'scope' = ?` in
postgres, `json_extract(indexed, '$.scope') = ?` in libsql) without
unwrapping a tagged shape.
- ensure_index materializes expression indexes on json_extract /
->>'key' for the declared keys. Spec metadata stored in a new
root_filesystem_index_specs table so re-declaration is conflict-aware
and idempotent across processes. Conflicting specs (same name,
different keys/kind) fail with FilesystemError::IndexConflict.
IndexKind::Fts / Vector return Unsupported (separate port).
- query translates Filter::{Eq, PrefixOn, Range, And, Or} into SQL
WHERE-clause fragments with parameterized values. IndexValue::Text /
I64 / Bool supported; IndexValue::Bytes returns Unsupported (JSON
representation makes byte comparison fragile). Pagination via
Page::offset/limit on ORDER BY path.
- Capabilities: query=true, index.exact=true, index.prefix=true. Stays
events=false until the append/tail port.
Tests: 5 new libsql contract tests cover ensure_index idempotence +
conflict + unsupported-kind, query with multi-key Eq filter, prefix
filter on text, and pagination across multiple pages. 19 db-backed
tests total now pass.
Migrations:
- V29__root_filesystem_index_specs.sql (postgres, refinery-locked).
- libsql gets an idempotent CREATE TABLE IF NOT EXISTS via
LIBSQL_INDEX_SPECS_SCHEMA in run_migrations.
15 lines
592 B
SQL
15 lines
592 B
SQL
-- Track index declarations for root_filesystem_entries. Records the
|
|
-- (prefix, name, keys, kind) of every `ensure_index` call so re-declaration
|
|
-- is conflict-aware and idempotent across processes. The actual JSONB
|
|
-- expression indexes are created out-of-band by `ensure_index` and named
|
|
-- deterministically (`idx_rfs_<sanitized_prefix>_<name>`) so re-running
|
|
-- migrations doesn't recreate them.
|
|
|
|
CREATE TABLE IF NOT EXISTS root_filesystem_index_specs (
|
|
prefix TEXT NOT NULL,
|
|
name TEXT NOT NULL,
|
|
keys JSONB NOT NULL,
|
|
kind TEXT NOT NULL,
|
|
PRIMARY KEY (prefix, name)
|
|
);
|