lcc

ADR 0012 - Semantic retrieval execution boundary

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.

Exact Scope

The first adapter may do only this:

The adapter must not mutate source files, manifests, vector files, embedding assets, config files, or existing reports.

Module Boundary

The retrieval execution code must remain inside lcc.semantic_retrieval and outside the deterministic core.

Allowed import direction:

The existing status and manifest-validation path remains standard-library-only. Optional dependency imports are allowed only in the execution adapter.

Dependency Strategy

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.

Local Assets and Index

The first adapter consumes a prebuilt local index. Index creation remains out of scope.

Execution requires:

Status reporting and manifest validation must continue to avoid reading vector contents. Only the explicit execution path may open vector files.

Fail-Closed Behavior

The adapter must fail before returning selected evidence when any required condition is not met. Required fail-closed cases include:

Failures must report a deterministic reason_code and message. They must not return partial rankings as success.

Provenance and Literal Output

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.

Report Schema Impact

Existing report schemas are unchanged:

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.

CLI and Config Impact

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.

Test Boundary

The eventual implementation must add tests that prove:

No implementation tests are required by this ADR until the adapter is actually implemented.

Out of Scope

This ADR does not authorize:

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.