Skip to main content

Module reference_resolution

Module reference_resolution 

Source
Expand description

resolve_reference: the Layer-0 deterministic reference resolver from the “unified-verb” draft ADR (Slice 1 — resolver + ring).

Turns a natural-language reference into an id through four ordered stages, never guessing among close candidates:

  1. Id-string passthrough. A ref that already looks like a UUID or an 8+ hex-char prefix resolves through the existing by-ID path (KhiveRuntime::resolve_by_id / resolve_prefix_unfiltered) instead of being treated as free text — it must not error just because it arrived through resolve_reference rather than get. Scoped to entity ids only, identically for the full-UUID and prefix forms (matching the ring’s entity-only contract); a note/edge/event id-string is NotFound here, not an error — a caller resolving those uses get.
  2. Recently-referenced ring. An exact (case-insensitive) or substring match against this actor’s ring (reference_ring::ReferenceRing).
  3. Exact-name storage lookup. A deterministic, case-sensitive match against entities.name or an alias the entity holds (ADR-221) in the caller’s namespace (deleted_at IS NULL) — covers any entity that already exists but was never created/get/updated/deleted/merged/linked by this actor in this session, so stage 2’s ring never saw it (#849).
  4. Hybrid-search fallback. KhiveRuntime::hybrid_search over the caller’s namespace, ranked by RRF score.

A single candidate clearing the stage’s confidence bar resolves; multiple viable candidates or none never silently pick — they return Ambiguous or NotFound for the caller to disambiguate.

Structs§

ReferenceCandidate
A candidate id surfaced when a reference did not resolve outright.

Enums§

ReferenceResolution
Outcome of resolve_reference. Never a silent pick among close candidates: Ambiguous always lists what it found instead of guessing.

Constants§

EXACT_NAME_CONFIDENCE
Confidence for a stage-3 exact-name storage match: a deterministic, case-sensitive equality on entities.name or a held alias — stronger evidence than the ring’s case-insensitive session cache (RING_EXACT_CONFIDENCE), so it sits above both ring bands, but still below the absolute certainty of an id-string passthrough (1.0), which the caller supplied directly rather than by name. No other stage reports this value, so a caller can tell a stage-3 hit by it; the kg resolve verb reads it to set matched_alias.

Functions§

resolve_reference
Resolve one natural-language reference for token’s actor.
resolve_reference_with_entity_type
Resolve with an optional canonical entity subtype in the exact-name and search stages. ID and ring matches retain their existing kind-agnostic behavior, so a subtype filter cannot turn an explicit ID into a fuzzy hit.