# Semantic layer v3 — queryability, identity and governance

## What this experiment is for
A usable semantic layer is a versioned, queryable model, not a picture of extracted phrases. The graph must answer competency questions using typed, directed relationships and must be able to say that evidence is missing. A useful system exposes both the answer and its evidence chain.

## Identity model
- Document revision: pinned repository commit and manuscript directory. Source segment: exact file, line/character extent, content hash.
- Scoped referent / clause: local identity keyed by manuscript and statement or passage; mathematical variables and conditions remain local. The strings F, k, and V are not global IDs.
- Canonical concept: stable ID for reusable mathematical vocabulary; local referents may instantiate or concern a concept. A concept link does NOT mean two referents are equal. The finite field k in two different statements is not thereby the same field.
- Statement: use the manuscript's stable LaTeX label in its document namespace, independent of title spelling. Keep source revision and evidence separate.
- Assertion: stable directed edge identity, evidence, origin, scope or qualifier, and review status. Distinguish textual cross-reference, reviewed proof-use, concept classification, and logical clause role. Do not equate graph reachability with logical entailment.

## Views and queries
1. Curated source assertions: this working set is assistant-reviewed, not expert-approved truth. Exact raw source spans or pinned normalized excerpts support every edge.
2. Structural index: source labels and explicit references. Keep separate from the curated proof-use layer; a reference is not necessarily a logical dependency.
3. Proposal layer: extracted candidates, possible aliases and proposed ontology changes. No candidate enters query projection without review and validation.
4. Typed projection: direct adjacency triples derived from the curated assertion set for efficient traversal. RDF named graph has its own provenance, not unconditional domain truth. Every projected triple can be joined back to an assertion.
5. Query engine: explicit typed step sequences, forward and reverse, maximum 5 steps; bounded results; no generic undirected traversal in the default query UI. Return full path and qualifiers. Empty results mean not found within the current graph, not false. Execute reproducible RDF/SPARQL queries as a separate implementation check.

## Consolidation and ontology management
Stable concepts are separate from local nodes. Consolidation means mapping reviewed references to a canonical concept, preserving each local source, role, and scope. Do not merge clauses solely because their formulas match. Class definitions and predicate constraints are versioned. Proposed aliases, mapping changes and new predicates are reviewable and must have explicit impact reports; local UI drafts are not server mutations. Never silently rewrite source graph or backfill unsupported edges. Test changed TBox on current ABox, report affected edges and block incompatible change. Do not infer owl:sameAs from a label match.

## Acceptance
- Query actual paths with source evidence per hop; test negative paths, direction, branch qualifiers, scope, and multiple proofs.
- RDF round-trip, SHACL validation and independent SPARQL checks.
- Cross-document consolidation demonstrated with explicit citation to companion definition.
- Ontology change preview reports affected assertions and rejects invalid domain/range changes. Adding an unused relation does not assert any facts.
- Browser interaction test on live playground. Scope limitations must be visible: curated sample, incomplete coverage, no automated theorem proving, no external/user data, no production service changes.

## Corpus and revision sanity checks
The earlier source inventory was incomplete because the LaTeX include tree was not recursively traversed. The revised manifest pins 54 files (two manuscripts, their nested inputs, style, locators, bibliography). The documentary index contains 48 labeled statements in the exponent paper and 46 in the companion. 673/676 literal reference occurrences resolve; three cite a third manuscript outside this corpus. Two proof blocks have only proposed owners because explanatory prose intervenes. A layout-only anchor in the probing appendix is distinguished from semantic prose.

The integrated RDF dataset has seven named graphs. The source-index and source-evidence graphs expose documentary structure; a separate identity-links graph joins 10 curated identities to exact, document-scoped LaTeX labels. The semantic projection remains separate, and no documentary edge becomes a proof-use assertion. The unlabeled prose definition of ports is a curated local identity, not a fabricated source label.

A revision-impact simulator builds an index of in-memory synthetic source copies. It distinguishes unchanged relocated text, changed content, missing/renamed labels and changed references. Changed evidence segments quarantine affected semantic records for review; potential dependent proof claims are identified separately. It does not automatically promote a revised graph or declare a theorem false.

Production caveats: the current corpus-wide index is structural, not a full semantic extraction. The curated graph covers 9/48 labeled statements in the exponent paper. The workbench is static and client-side; ontology edits produce local scenarios and proposals, not approved persistent changes. RDF/SPARQL validation is executed offline in the test suite. Scaling, concurrent review, access control, persistent revision transactions, and expert-validated semantic coverage require further work.
