Skip to content

RFC-027: Live semantic resolution (LSP-assisted incremental Phase B) - #795

Open
Abhishek5517 wants to merge 2 commits into
masterfrom
rfc/027-live-semantic-resolution
Open

RFC-027: Live semantic resolution (LSP-assisted incremental Phase B)#795
Abhishek5517 wants to merge 2 commits into
masterfrom
rfc/027-live-semantic-resolution

Conversation

@Abhishek5517

@Abhishek5517 Abhishek5517 commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Closes #794.

What this is

Draft RFC-027, proposing a live semantic resolution lane that closes the between-commits "mid-edit degradation" gap without regressing the commit-gated Phase B guarantee. Documentation only; no code changes.

File: docs/rfcs/RFC-027-live-semantic-resolution.md

Why

Phase B (SCIP) is commit-gated by deliberate decision, so between commits only Tree-sitter updates the graph. It sees that a reference exists but not which symbol it resolves to, so get_callers, get_blast_radius, and find_references degrade on the exact code being edited. This was hit repeatedly while dogfooding Travsr on itself.

The model

A strict separation of responsibilities:

Tree-sitter  ->  DETECTS      a reference exists            (live, cheap, always on)
SCIP graph   ->  OWNS         node identity (Kythe VName)   (durable ground truth)
LSP          ->  DISAMBIGUATES a specific position          (live, type-aware, optional)
Commit SCIP  ->  RATIFIES     the region, heals drift       (deterministic convergence)

LSP is used only as a disambiguation oracle over SCIP-identified candidates, never as a symbol or identity source. This is the key distinction from earlier LSP proposals that failed on identity: SCIP already gives every node a stable VName, so LSP is asked for a location, and SCIP owns location-to-node. When no server is present, behavior is exactly today's commit-gated path (zero regression).

What the RFC covers

  • Four-lane responsibility model and the resolution flow (local scope check -> candidate set -> unambiguous-lexical OR LSP-disambiguate -> map to node OR abstain).
  • Inline mermaid sequence diagram for both the live path and the commit ratification path.
  • Edit classification (body vs interface) and the reverse-dependency closure invalidation model, including the incoming/outgoing edge asymmetry.
  • The dirty-file span-mapping nuance for location_to_node (current Tree-sitter spans for dirty files, SCIP ranges for clean).
  • Correctness contract: precision-first / fail-closed, the ADR-009 Rule 4 fencing rule, the Invariant Build(deps): Update rusqlite requirement from 0.31 to 0.39 #4 convergence proof, and the determinism fence.
  • Schema deltas: new live provenance value (ADR-002 Rule 1) and a ref_resolution_state for pending references.
  • MCP surface impact (provenance labeling plus a live_overlay freshness note; no new tool).
  • LSP settle/consistency protocol, a continuous precision meter (diff live vs SCIP at commit, gate >= 0.99, SCIP wins ties), security/threat notes, a phased delivery plan, alternatives considered, and a risk register.

Correctness guarantees (the load-bearing ones)

  • Zero structural hallucination preserved. Fail-closed emission; abstention is surfaced honestly as pending, never as a fabricated edge.
  • Invariant Build(deps): Update rusqlite requirement from 0.31 to 0.39 #4 (incremental == full reindex) preserved. Every live edge is deleted and replaced by SCIP at commit, so the committed graph contains no live edges.
  • VName uniqueness (Invariant Bump actions/setup-node from 4 to 6 #1) and the corpus invariant (RFC-005) preserved. The live lane never mints identity and never enters the bridge registry.

Revisions since first push (commit f9d1d62)

Before sending this out for the sign-off reviews below, I fact-checked the draft's own citations against the codebase and the referenced ADRs/RFCs and tightened a few things. No external review yet; these are author corrections. All doc-only:

  • ADR-002 citation corrected. The provenance-tag requirement is Rule 1 (the provenance NOT NULL column), not Rule 5 (which is the SQL-upsert rule). Fixed in section 4 and section 9.1.
  • Provenance value list reconciled. Section 9.1 now notes the shipped store's de-facto enum (tree-sitter/lsif/scip) already diverged from ADR-002's originally written list (tree-sitter/lsif/merged); live extends the de-facto set and does not reinstate merged.
  • Schema field renamed. The proposed reference field resolution_state is renamed ref_resolution_state to avoid colliding with the daemon's existing record_dart_resolution_state bookkeeping (an unrelated Dart Phase B concept).
  • Phantom citation replaced. project_phase_b_commit_gated_decision was not a real artifact; section 2.2 now cites the real source, the commit-gated comments in travsr-daemon/src/lib.rs. (The commit-gated premise itself is confirmed in that code.)
  • Convergence hardened (pre-empts my own ask 1). Section 8.3 now ratifies by insert-SCIP-first (it wins by ADR-002 precedence), then delete leftover live edges, all in one WAL transaction, closing the transient-gap window. The sequence diagram is updated to match.
  • Graded-confidence path noted (pre-empts my own ask 3). Section 16.4 notes the edges table already carries a confidence column, so graded confidence can ride that field without touching the boolean provenance enum.

Status

Draft. Not for merge-to-ship of behavior; this PR lands the design doc for review. Sign-offs required before the RFC moves to Accepted: Principal Architect (schema + convergence proof), Principal Security Engineer (spawn path + IDE-piggyback trust), Solution Architect (MCP surface).

…se B)

Draft RFC proposing a live semantic resolution lane that closes the
between-commits "mid-edit degradation" gap without regressing the
commit-gated Phase B guarantee.

Core model is a strict separation of responsibilities:
  Tree-sitter  detects a reference exists
  SCIP graph   owns node identity (Kythe VName)
  LSP          disambiguates a specific position (surgical, optional)
  Commit SCIP  ratifies the region and heals drift

LSP is used only as a disambiguation oracle over SCIP-identified
candidates, never as a symbol/identity source. The lane is precision-first
and fail-closed: it emits an edge only when resolution is provably correct
and abstains (marks the reference pending) otherwise. When no language
server is present the system degrades to today's commit-gated behavior with
zero regression.

Includes an inline mermaid sequence diagram covering the live path and the
commit ratification path, the reverse-dependency closure invalidation model,
the ADR-009 Rule 4 fencing rule (live edges never enter the bridge registry),
the Invariant #4 convergence property, and a continuous precision meter that
diffs live edges against SCIP truth at each commit.
@Abhishek5517
Abhishek5517 requested a review from raj-rkv as a code owner August 24, 2026 14:22
@Abhishek5517 Abhishek5517 added documentation Improvements or additions to documentation enhancement New feature or request rfc Request for Comments architecture Architectural decision or contract labels Aug 24, 2026
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

Benchmark comparison (master → PR)

no benchmark comparisons to show

Threshold: p95 regression ≥ +10% fails this check.

…harden convergence

Applies the flagged PR-review fixes, all doc-only:

- Fix ADR-002 citation: the provenance-tag requirement is Rule 1
  (provenance NOT NULL column), not Rule 5 (SQL upsert logic). Corrected
  in section 4 and section 9.1.
- Note the de-facto provenance enum in the shipped store
  (tree-sitter/lsif/scip) already diverged from ADR-002's written
  value list (tree-sitter/lsif/merged); live extends the de-facto set.
- Rename the proposed reference field resolution_state to
  ref_resolution_state to avoid colliding with the daemon's existing
  record_dart_resolution_state bookkeeping (unrelated Dart concept).
- Replace the phantom project_phase_b_commit_gated_decision citation
  with the real source: the commit-gated comments in travsr-daemon.
- Harden the section 8.3 convergence flow against the delete-old /
  insert-new transient-gap hazard (review-ask 1): insert SCIP first
  (it wins by ADR-002 precedence), then delete leftover live edges,
  all in one WAL transaction. Sequence diagram updated to match.
- Answer review-ask 3 in section 16.4: the edges table already carries
  a confidence column, so graded confidence can ride that field
  without touching the boolean provenance enum.
@Abhishek5517 Abhishek5517 changed the title RFC-027: Live semantic resolution (LSP-assisted incremental Phase B) RFC-027: Live semantic resolution (LSP-assisted incremental Phase B) + implementation Aug 27, 2026
@Abhishek5517 Abhishek5517 changed the title RFC-027: Live semantic resolution (LSP-assisted incremental Phase B) + implementation RFC-027: Live semantic resolution (LSP-assisted incremental Phase B) Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

architecture Architectural decision or contract documentation Improvements or additions to documentation enhancement New feature or request rfc Request for Comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC-027: Live semantic resolution (LSP-assisted incremental Phase B)

1 participant