Repository navigation
LastLight v0.2.0
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
HIGHmatches atHIGH, while allowing near-tied strong candidates to be downgraded toMEDIUMinstead of overstating certainty. - Refuses weakly covered
MEDIUMmatches when another acceptable candidate is nearly tied, reportinginsufficient_confidencethrough the existing public refusal contract. - Adds public
DecisionMetadatawith the decision reason, winner score, runner-up score, margin, ratio, query coverage, query terms, and matched terms. - Adds
LastLight.explain()and the publicQueryExplanationcontract 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 asquery(), 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:
- no retrieved source remains
no_matching_knowledge; - a top result with retrieval confidence
LOWremains a refusal; - a clear
HIGHresult remainsHIGH; - two nearly tied
HIGHresults with limited query coverage may return the winner asMEDIUM; - a
MEDIUMwinner with both poor query coverage and a nearly tied acceptable runner-up is refused asinsufficient_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