Status: accepted
Context. ADR 0011 closed the Phase 2 scaffold: lcc semantic-retrieval can report a
disabled or blocked boundary state and can validate local manifest metadata, but retrieval
execution is still not implemented. The next useful decision is the smallest execution
contract that can later turn the scaffold into real retrieval without weakening the
deterministic core, inspection, preparation, or benchmark boundaries.
Decision. The first future retrieval execution adapter is a separate, explicit,
local-index adapter named local_index_v1. It may execute only when the user opts in to
semantic retrieval and explicitly requests execution. It selects evidence from a prebuilt
local semantic index and returns provenance-rich literal source spans. It does not build an
index, refresh an index, generate corpus embeddings, summarize, rewrite, paraphrase, call a
local or remote LLM, access the network, download assets, or build a prompt.
This ADR defines the future implementation contract only. The current repository still has no retrieval execution adapter.
The first adapter may do only this:
top_k, a semantic-index-1.0 manifest path, and an
embedding assets directory from an explicit semantic retrieval execution path;top_k selected evidence records with ranks, scores, chunk IDs, source
offsets, line spans, text hashes, and literal source text copied from the original source
spans.The adapter must not mutate source files, manifests, vector files, embedding assets, config files, or existing reports.
The retrieval execution code must remain inside lcc.semantic_retrieval and outside the
deterministic core.
Allowed import direction:
lcc.cli may import lcc.semantic_retrieval for the separate semantic retrieval command.lcc.semantic_retrieval.execution may import lcc.semantic_retrieval.boundary and the
concrete adapter module.lcc.semantic_retrieval.adapters.local_index may import boundary data structures and
optional semantic dependencies lazily, after explicit execution is requested.cleaning, token_budget, prompt_builder, reporting, pipeline, inspection,
lexical_selection, and benchmarking must not import lcc.semantic_retrieval.lcc.pipeline, lcc.prompt_builder, lcc.benchmarking, or
lcc.inspection to perform retrieval. It receives source text and manifest paths as
arguments.The existing status and manifest-validation path remains standard-library-only. Optional dependency imports are allowed only in the execution adapter.
Default installs remain dependency-light. No semantic dependency is required for optimize,
inspect, prepare, bench, or disabled semantic status reporting.
If the adapter needs a non-stdlib package, it must be exposed through a separate optional
extra, for example local-context-compiler[semantic]. The dependency must be imported lazily
only after explicit execution is requested. Missing or incompatible optional dependencies fail
closed with a dependency-specific reason; they must not silently produce empty results or fall
back to a different backend.
No dependency may download model, tokenizer, vector, or index assets at runtime. A dependency that tries to fetch assets during import or execution is incompatible with this boundary unless the adapter blocks the fetch and fails closed.
The first adapter consumes a prebuilt local index. Index creation remains out of scope.
Execution requires:
semantic-index-1.0 manifest that passes ADR 0011 validation;sha256:<hex> fingerprint exactly matches the manifest;embedding_assets;Status reporting and manifest validation must continue to avoid reading vector contents. Only the explicit execution path may open vector files.
The adapter must fail before returning selected evidence when any required condition is not met. Required fail-closed cases include:
top_k less than 1;Failures must report a deterministic reason_code and message. They must not return partial
rankings as success.
Selected evidence must remain literal source evidence. Every selected item must carry:
Prompt integration, if added later, must assemble selected context from these literal source spans. Generated summaries, paraphrases, model-written evidence, or rewritten chunks are not valid retrieval output for this adapter.
Existing report schemas are unchanged:
schema_version: "1.0";schema_version: "1.0";schema_version: "1.0";prepare-1.0;semantic-retrieval-0.1.The first execution adapter must write a separate report schema, starting at
semantic-retrieval-execution-1.0. That report may include retrieval status, adapter name,
manifest summary, source fingerprint, question fingerprint, top_k, selected evidence, and
fail-closed reason codes.
Adding semantic retrieval metadata to prepare, optimization, inspection, or benchmark
reports remains out of scope and requires a later accepted ADR or an explicit revision of this
ADR. Any future report integration must keep semantic fields separate from token-count fields
and must preserve ADR 0005 / ADR 0008 exact-vs-approximate token-count honesty.
The current no-execution status behavior remains valid:
lcc semantic-retrieval [--config lcc.yaml] [--report semantic-status.json]
A future implementation may extend only the separate semantic retrieval command with an explicit execution path. The accepted execution shape is:
lcc semantic-retrieval \
--enable-semantic-retrieval \
--execute \
--source INPUT \
--question TEXT \
--adapter local_index_v1 \
--index-manifest PATH \
--embedding-assets PATH \
[--top-k N] \
[--config lcc.yaml] \
[--report semantic-execution.json]
Config may supply only execution defaults:
semantic_retrieval:
enabled: true
adapter: local_index_v1
index_manifest: path/to/semantic.index.json
embedding_assets: path/to/local-assets
top_k: 8
--execute must be a CLI opt-in, not a config-only behavior. Existing deterministic commands
continue to ignore semantic_retrieval config keys unless a later ADR explicitly integrates
retrieval with those commands.
The eventual implementation must add tests that prove:
optimize, inspect, prepare, and bench paths do not import or invoke retrieval
execution;No implementation tests are required by this ADR until the adapter is actually implemented.
This ADR does not authorize:
prepare or optimize;Why. The right next step is one narrow execution contract, not more scaffold code and not a full RAG system. Keeping execution separate lets future work prove local semantic selection without touching the deterministic commands that already work offline and without presenting retrieval as implemented before it exists.
Forecloses. Retrieval execution may not enter the deterministic core, inspection, preparation, lexical selection, or benchmarking by accident. The first implementation must be explicit, local, fail-closed, provenance-preserving, and report-only until a later ADR accepts prompt or prepare integration.