fix: confirm_scars must not green-light a failed retrieval (GIT-93 step 2) - #27
Merged
Merged
Conversation
…ep 2) An empty scar set had two causes and one answer. recall() ran, reached the store and matched nothing — proceeding is correct. Or recall() never reached the store — nothing was checked and any warning that applies is still unseen. Both produced: ok No recall-surfaced scars to confirm. Proceed freely. This is why step 1 could hide for as long as it did. The *_scar_search RPC 404'd on every call from the day it was written, and the protocol reported success for that failure, so nothing accumulated into a signal anyone could notice. Fixing the RPC name without fixing the signal would leave the next such break equally well hidden — which is the actual defect worth removing. recall now records a failure marker on the session when the store cannot be reached, and clears it when a search succeeds. Cleared on success rather than on attempt, and independent of how many scars came back: a search that ran and matched nothing is a real answer; a failed one is not an answer at all. confirm_scars reads that marker before answering an empty set. On a failure it returns valid: false, names the underlying error, and says plainly that this is not the same as no relevant scars. The marker persists to session.json and is restored on recovery, following recall_called. A restart is exactly the event this state exists to survive, so it must not be the thing that launders a broken store into a clean slate. Verified end to end: with a prefix whose match_<table> function does not exist, recall 404s and confirm_scars returns REJECTED quoting PGRST202, where it previously returned "Proceed freely". +6 tests (1185 -> 1191), including the restart case, and confirmed to fail against the pre-fix behaviour (2 of 6). provenance-citation.test.ts mocks session-state and needed the two new exports added to its mock. Co-Authored-By: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GIT-93 step 2. Step 1 (#26) fixed the RPC names; this fixes the reason nobody noticed they were wrong.
The problem
An empty scar set had two causes and one answer:
recall()reached the store and matched nothing — proceeding is correctrecall()never reached the store — nothing was checkedBoth produced:
The
*_scar_searchRPC 404'd on every call since it was written, and the protocol reported success for that failure. Nothing ever accumulated into a signal. Fixing the name without fixing the signal leaves the next such break just as well hidden — that's the defect actually worth removing.The change
recallrecords a failure marker on the session when the store can't be reached, and clears it when a search succeeds. Cleared on success, not on attempt, and independent of result count: a search that ran and matched nothing is a real answer; a failed one is not an answer at all.confirm_scarsreads that marker before answering an empty set:The marker persists to
session.jsonand is restored on recovery, followingrecall_called. A restart is exactly the event this state exists to survive — it must not be what launders a broken store into a clean slate.Verification
End to end, with a prefix whose
match_<table>function does not exist:confirm_scarsProceed freelyREJECTED, quoting PGRST202+6 tests (1185 → 1191), including the restart case. Confirmed to fail against the pre-fix behaviour (2 of 6 fail when the check is removed).
provenance-citation.test.tsmockssession-stateand needed the two new exports added to its mock — no behavioural change to that suite.Still open on GIT-93
Step 3: reconcile the prefix rule with GIT-84 — one documented statement of which object classes
GITMEM_TABLE_PREFIXapplies to.🤖 Generated with Claude Code