Skip to content

LastLight v0.2.0

Choose a tag to compare

@github-actions github-actions released this 05 Oct 17:09
8979407

LastLight 0.2.0

LastLight 0.2.0 makes the answer boundary more explicit and auditable. Retrieval scores remain unchanged, but the runtime now uses additional deterministic evidence before deciding whether a retrieved passage should be returned as an answer.

Highlights

  • Adds a confidence/refusal v2 decision layer that combines the winning result's existing retrieval confidence with query-term coverage and the score margin to the runner-up from the same search.
  • Keeps clear HIGH matches at HIGH, while allowing near-tied strong candidates to be downgraded to MEDIUM instead of overstating certainty.
  • Refuses weakly covered MEDIUM matches when another acceptable candidate is nearly tied, reporting insufficient_confidence through the existing public refusal contract.
  • Adds public DecisionMetadata with the decision reason, winner score, runner-up score, margin, ratio, query coverage, query terms, and matched terms.
  • Adds LastLight.explain() and the public QueryExplanation contract for audit UIs, regression tests, and incident reproduction.
  • Includes the same decision metadata directly on QueryResult, so normal integrations can inspect why an answer was accepted or refused without making a second query.
  • Routes LastLight.answer() through the same calibrated decision boundary as query(), preventing human-readable and structured APIs from disagreeing.
  • Adds focused regressions for clear winners, ambiguous high-confidence matches, weak ambiguous medium-confidence matches, and no-match refusals.
  • Extends installed-wheel CI checks to cover the new public contracts and explain() behavior.

Decision semantics

The new layer does not mix lexical and BM25 numeric score scales. Margin and ratio are calculated only between results returned by one retrieval execution using one selected strategy.

The rules are intentionally conservative:

  1. no retrieved source remains no_matching_knowledge;
  2. a top result with retrieval confidence LOW remains a refusal;
  3. a clear HIGH result remains HIGH;
  4. two nearly tied HIGH results with limited query coverage may return the winner as MEDIUM;
  5. a MEDIUM winner with both poor query coverage and a nearly tied acceptable runner-up is refused as insufficient_confidence.

search() remains the raw retrieval boundary and preserves each strategy's existing score and confidence. The new calibration applies at the answer boundary used by query() and answer().

Explainability

from lastlight import LastLight

engine = LastLight("pack.zip", strategy="bm25")
explanation = engine.explain("How long will food stay cold during a power outage?")

print(explanation.decision.accepted)
print(explanation.decision.confidence)
print(explanation.decision.reason)
print(explanation.decision.query_coverage)
print(explanation.decision.score_margin)
print(explanation.decision.matched_terms)

The explanation is entirely local and deterministic. No telemetry, model call, persistent database, or network service is introduced.

Compatibility

Knowledge Pack Format v1 is unchanged. search(), query(), answer(), plan(), pack inspection, validation, and provenance APIs remain available. QueryResult gains an optional decision field at the end of the dataclass contract for source compatibility with existing keyword and positional construction patterns.

Python 3.10, 3.11, and 3.12 remain supported. The runtime remains dependency-free outside the Python standard library.

Upgrade

python -m pip install --upgrade lastlight