Skip to content

feat(semantic): native SymbolView/RelationView + unified symbol-neighborhood query #265

Description

@2233admin

Problem

#264 supplies a snapshot-bound, dependency-keyed multi-view index, but the built-in understanding path still stops at artifact catalog + lexical content. The Agent-facing gaps remain:

The product needs Graft-level semantic capability built in, while Pipeline remains the authority, identity, cache, budget and Agent-query center.

Decision

Add one native Rust semantic producer after #264:

source snapshot
  -> NativeSemanticProducer
  -> SymbolView + RelationView Artifact Refs
  -> QueryIndex materialized views
  -> ProjectContext::query(SymbolNeighborhood intent)
  -> same CLI/MCP domain answer

Borrow these semantics from Graft pinned at d834ca227d765b2736cfeafb97b0e71e2ea21d50, not its product/runtime:

  • deterministic symbol records with path/span/kind/qualified name/signature/exported/body hash;
  • closed relations: contains|calls|references|imports|implements|extends;
  • confidence classes: lsp_resolved|lsp_dispatch|ast_extracted|name_inferred|heuristic;
  • ambiguous cross-file names are dropped, never guessed;
  • unknown receiver member calls never fall back to any same-named method;
  • contains is structural and never participates in dependency walks;
  • optional LSP enrichment is best-effort: missing/timeout/error preserves the AST view and records the unavailable enrichment.

Upstream evidence:

First vertical slice

  1. Define closed, versioned SymbolView and RelationView artifact contracts. Every record carries producer, producerVersion, consumedSnapshotIdentity, evidence location/hash, and a non-numeric confidence class.
  2. Implement the native extractor for Rust plus one second-language fixture that exercises owner-qualified member calls. Keep grammar/extractor registration behind a provider boundary; do not add Graft/Node/npm as a production dependency.
  3. Add ViewKind::SymbolCatalog and ViewKind::Relations to the feat(index): add snapshot-bound multi-view query index #264 index. Reuse its view keys, retained-byte budget, corruption rebuild and freshness separation.
  4. Add typed SymbolNeighborhood intent behind ProjectContext. CLI and MCP construct the same intent and decode to the same domain answer; existing evidence-query JSON remains unchanged.
  5. Query precedence is explicit: compiler/native exact facts > LSP resolved > AST extracted > unique-name inferred > existing heuristics. A weaker producer never overwrites stronger evidence.
  6. Emit an internal query receipt with chosen producer/view key, rejected/fallback reasons, snapshot/freshness, confidence basis, bytes/items/time and budget/truncation state. It is audit evidence, not authority.
  7. Add a fixed benchmark comparing symbol localization, relation precision/recall, context bytes and warm/cold latency against the current heuristic path.

Acceptance

  • Same admitted snapshot + config + producer version yields byte-identical Symbol/Relation views and view keys.
  • Editing one file invalidates only its extraction and dependent relation projection; freshness-only checkout changes do not mutate committed view keys.
  • Duplicate cross-file names are not resolved; unknown receiver member calls do not resolve to bare same-named methods.
  • contains never enters impact/dependency traversal.
  • Missing LSP is a recorded no-op, not a core failure; heuristic fallback remains available and labeled.
  • Staging, forged, non-completed or mismatched publications never enter committed semantic views; cache hits never bypass A07/A08/Artifact Ref verification.
  • code-intel query --kind symbol and the MCP projection decode to the same bounded domain answer with explicit snapshot, freshness, confidence, coverage and truncation.
  • Benchmark uses the same snapshot/query corpus for old and new paths, at least 3 repetitions, reports cold build separately from warm queries, and shows higher relation precision with no material symbol-recall regression. Enabling by default requires a measured Agent-context reduction or latency win, not architectural preference.
  • Existing A08, evidence query, artifact query, MCP six-tool compatibility, primary run, install topology, repin, hardcoded-path and Sentrux gates remain green.

Non-goals

  • vendoring/forking Graft or reading its local cache in production;
  • importing Graft's hooks, markdown cards, statusline, auto-sync or LLM --deep layer;
  • a general-purpose route planner or monolithic “tool fabric” in this issue;
  • numeric confidence aggregation across heterogeneous producers;
  • making semantic views gate/adoption authority;
  • supporting every language in the first slice;
  • public release promotion during the DR-0006 RC freeze.

Follow-up: tool fragmentation

After this slice proves two producers can answer one typed intent, open a separate issue for AgentIntent + QueryPolicy + CapabilityCatalog + RoutePlanner + QueryReceipt across at least two intents. Keep catalog declaration, route selection, execution, answer assembly and receipt recording in separate modules; do not combine them into one orchestration god object.

Depends on #264. Refs #58 #128 #188 #221 #223 #225 #263.

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimedIssue claimed by an active session (DR-0004): read the claim comment before touching itenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions