feat: LLM-grounded semantic layer (kb describe) + semantic grounding gate#14
Merged
Conversation
…gate First slice of the LLM-grounded layer (Roadmap). A separate, key-gated `kb describe` pass has an LLM write a short NL summary + structured claims for each api_route/entity in a snapshot; every claim is validated against the artifact's own grounding spans by a DETERMINISTIC sub-property gate, unvalidated claims are dropped, and a `description` artifact is stored only if something survives — grounded on the same spans (extraction_method=llm_grounded, model_id + prompt_version in the key). Never on the offline `kb index` path. - kb/extract/semantic: grounding.validate_claims (deterministic, no LLM) + describe.describe_snapshot (orchestration, reuses kb.llm + write_grounded_artifact). - queries.spans_for_artifact (span_id + fq_symbol_path + raw_text). - CLI `kb describe` (lazy LLM import, key-gated via has_llm_key). - MCP summarize + embed_text gain a `description` branch. - HARD gate eval/semantic_grounding_test (stub LLM, no key): an adversarial fabricated claim is dropped, the grounded one stored, description served as llm_grounded. Headline gates eight -> nine. - docs: README (Status, Quickstart, architecture, nine gates), DESIGN §11/§9 (un-defer kb.extract.semantic, semantic floor implemented), CHANGELOG. ruff + mypy --strict clean; 54 eval tests pass (+1 skipped). Stub end-to-end: descriptions inherit cross-file grounding; an all-ungrounded route's description is not stored at all.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First slice of the LLM-grounded semantic layer (next Roadmap item). A separate, key-gated
kb describepass has an LLM write a short NL summary + structured claims for eachapi_route/entityin a snapshot; every claim is validated against the artifact's own grounding spans by a deterministic sub-property gate, unvalidated claims are dropped, and adescriptionartifact is stored only if something survives — grounded on the same spans (extraction_method="llm_grounded",model_id+prompt_versionin the key). Never on the offlinekb indexpath.What
kb.extract.semantic—grounding.validate_claims(deterministic, no model) +describe.describe_snapshot(orchestration; reuseskb.llm+write_grounded_artifact, which already enforces ≥1 span /is_deterministic/model_id).queries.spans_for_artifact— span_id + fq_symbol_path + source text (validator input).kb describeCLI (lazy LLM import, key-gated viahas_llm_key).summarize+embed_textgain adescriptionbranch.semantic_grounding_teston a stub LLM (no API key): an adversarial fabricated claim is dropped, the grounded one stored, the description served asllm_grounded. Headline gates eight → nine — the DESIGN §9 semantic floor, enforced deterministically in CI.Verification
mypy --strictclean; 54 eval tests pass (+1 skipped)./internal) gets no description stored at all (anti-hallucination).kb describewith a key (manual / nightly later); not required for CI.Notes
kb indexstays offline/deterministic (no API key). Out of scope: business-process/call-graph extraction, other description kinds, real-LLM in the CI gate. No release this cycle (accumulates in[Unreleased]).