nl2sql

Schema & Metadata Layer

The schema layer provides authoritative, versioned snapshots and structured retrieval to ground planning. It is split into:

Schema contracts and metadata

Schema contracts are defined in nl2sql_adapter_sdk.schema:

Metadata complements contracts:

Snapshotting and fingerprinting

Each SchemaSnapshot (contract + metadata) is versioned using a deterministic fingerprint:

Schema store backends

build_schema_store() constructs a store based on settings:

Schema versions are timestamped and include a fingerprint prefix (e.g., YYYYMMDDhhmmss_<fp8>). Old versions are evicted beyond schema_store_max_versions.

Retrieval and authority

Schema retrieval resolves authoritative tables/columns from SchemaStore, not from the vector store. Vector store chunks are only used to identify candidates; final schema is resolved via snapshot. If retrieval yields no candidates, the retriever falls back to the full snapshot. schema_version_mismatch_policy governs mismatches between chunk versions and store versions.

See ../architecture/indexing.md for retrieval stages, chunk types, and vector store behavior.

Source references