fix: call the retrieval RPCs by their deployed names (GIT-93) - #26
Merged
Conversation
recall has two paths: a local vector index, and a Supabase RPC fallback used
whenever that index is not ready. The fallback returned PGRST202 on every call.
scarSearch and semanticSearch built the RPC name by taking the TABLE prefix and
appending a verb:
const rpcName = `${getTableName("").replace(/_$/, "")}_scar_search`;
which is "orchestra_scar_search" under GITMEM_TABLE_PREFIX=orchestra_ and
"gitmem_scar_search" by default. Enumerating the functions PostgREST actually
exposes turned up neither, under any prefix — nor any *_scar_search at all. The
deployed names are match_<table> and match_<table>_weighted, so the RPC is named
after the table it searches, not after the prefix with a verb glued on. The
docstrings claiming gitmem_scar_search / gitmem_semantic_search described a
function that does not exist; they are corrected too.
So this was never a prefix mismatch that a non-default deployment tripped over.
The fallback had not worked on any deployment since it was written. It stayed
invisible because it is only reached while the local index is cold — a window
that happens to include the first recall of every session, the one the
SessionStart hook triggers, which is the recall that gates the work about to
be done.
_weighted is the correct one of the pair for scarSearch: that function is
documented as scar search with severity weighting, and it is the variant
returning decay_multiplier, which recall consumes. It takes match_threshold
rather than similarity_threshold, so the body changes with the name.
project_filter is deliberately not sent. This stands in for the unified
cross-project vector cache; filtering here would make the cold path return a
narrower set than the warm path it substitutes for — a silent behaviour change
on precisely the calls that are hardest to notice.
Verified end to end against the real store: a recall issued before
"[startup] GitMem initialized" now returns 3 scars with no PGRST202, where it
previously returned none. +5 tests (1180 -> 1185), hermetic (fetch stubbed,
asserting the URL), and confirmed to fail against the pre-fix names.
Not fixed here: with nothing surfaced, confirm_scars still reports "No
recall-surfaced scars to confirm. Proceed freely." — a green result for a
failed retrieval. Tracked on GIT-93 as step 2, and it is the reason this bug
could persist unnoticed.
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.
Fixes GIT-93.
What was broken
recallhas two retrieval paths — a local vector index, and a Supabase RPC fallback used whenever that index is not ready. The fallback returned PGRST202 on every call.Root cause
scarSearchandsemanticSearchbuilt the RPC name from the table prefix plus a verb:Enumerating the functions PostgREST actually exposes turned up no
*_scar_searchunder any prefix. The deployed names arematch_<table>andmatch_<table>_weighted— the RPC is named after the table it searches. The docstrings referencinggitmem_scar_searchdescribed a function that does not exist.So this was never a non-default-prefix problem. The fallback had not worked on any deployment since it was written. It stayed invisible because it is only reached while the local index is cold — a window that includes the first
recallof every session, the one theSessionStarthook triggers.Why
_weightedscarSearchis documented as scar search with severity weighting, and_weightedis the variant returningdecay_multiplier, whichrecallconsumes. It takesmatch_thresholdrather thansimilarity_threshold, so the request body changes with the name.project_filteris deliberately not sent: this stands in for the unified cross-project cache, so filtering would make the cold path return a narrower set than the warm path it substitutes for.Verification
Against the real store, a
recallissued before[startup] GitMem initialized:recall+5 tests (1180 → 1185), hermetic —
fetchstubbed, asserting the URL, so they hold for deployments this developer cannot reach. Confirmed to fail against the pre-fix names (3 of 5 fail when the old construction is restored).Not fixed here
With nothing surfaced,
confirm_scarsstill reports "No recall-surfaced scars to confirm. Proceed freely." — a green result for a failed retrieval, and the reason this could persist unnoticed. Tracked as step 2 on GIT-93.🤖 Generated with Claude Code