Skip to content

fix: remote recall calls setup.sql's gitmem_scar_search (GIT-114) - #50

Merged
3 commits merged into
mainfrom
bugfix/GIT-114-remote-recall-rpc
Sep 23, 2026
Merged

3 commits merged into
mainfrom
bugfix/GIT-114-remote-recall-rpc

Conversation

@nTEG-dev

Copy link
Copy Markdown
Member

What

Recall's store fallback now calls the function setup.sql actually creates (GIT-114).

  • Default prefix (gitmem_): calls gitmem_scar_search with similarity_threshold. If the store answers PGRST202 (no such function), it falls back to match_gitmem_learnings_weighted with match_threshold. The first function that exists is remembered for the process; any other error is a real failure and isn't retried under another name.
  • Non-default prefix: only match_<table>_weighted. gitmem_scar_search reads gitmem_learnings by name, so under orchestra_ it would search the wrong table.
  • Missing columns: gitmem_scar_search returns only id, title, description, severity, scar_type, counter_arguments, decay_multiplier and similarity. The fields recall renders (learning_type, applies_when, why_this_matters, action_protocol, …) are fetched for the matched ids in one select. If that select fails, the matched scars are still returned without them.
  • Removed the dead semanticSearch (match_gitmem_learnings, no callers).
  • Drift analyzer extended to RPC names (scanRpcNames, parseFunctions). Every RPC src/ can call on the customer's store must be defined by v1.8.0's setup.sql or allowlisted by ticket: match_gitmem_learnings_weighted (GIT-114, fallback only) and match_transcript_chunks (GIT-106, dev only). The licensing RPC is a fixed URL to another project and is classified external.

Why

When the local vector index isn't ready, recall asks the store. That covers every server start until warm-up finishes, a new or empty store, a failed load, and GITMEM_SEARCH_MODE=remote. GIT-93 named the RPC after the function on nTEG's store; no setup.sql defines it. So every customer's cold recall got PGRST202 and returned nothing.

Decision to review

The fallback keeps nTEG's store working. The ticket says to use gitmem_scar_search. Per the GIT-93 survey, nTEG's store has match_*_weighted and no *_scar_search. So instead of switching outright, the code tries the setup.sql function first and falls back only on PGRST202. I didn't probe production to confirm which functions it has (rule: never touch production); the fallback makes that unnecessary.

How to test

Venue (vujndhcumgroztfkkdus, reset to v1.8.0:schema/setup.sql; production not touched). flow has two new probes, each on a fresh server: recall with GITMEM_SEARCH_MODE=remote, and recall called immediately on a cold server.

origin/main 1.11.0 This branch
POST /rpc/match_gitmem_learnings_weighted 404 (PGRST202) not called
Remote-mode recall no scar; exit 1 seeded scar via gitmem_scar_search
Cold-start recall no scar seeded scar; took the Local cache not ready fallback
Exit 1 0, no expected failures seen

Unit tests: 1365/1365 (+9). Four cover the fallback, no retry on a real error, the follow-up select and tolerating its failure; five cover RPC drift, including a planted-drift self-test.

Existing tests changed

scar-search-rpc-name.test.ts:

  • "tracks the prefix rather than hardcoding one deployment's table" asserted match_gitmem_learnings_weighted for the default prefix, which is the bug itself. It now asserts gitmem_scar_search with similarity_threshold.
  • "semanticSearch calls match_" was removed along with the dead function.
  • The three orchestra_ tests are unchanged: nTEG's prefix still calls match_orchestra_learnings_weighted.
  • Checklist

    • Unit tests pass (1365)
    • Venue: fails on main, passes on the branch (v1.8.0)
    • No schema change

    🤖 Generated with Claude Code

Claude and others added 3 commits September 22, 2026 20:12
When the local vector index isn't ready (every server start until warm-up,
a new or empty store, a failed load, GITMEM_SEARCH_MODE=remote), recall
called match_gitmem_learnings_weighted. No setup.sql defines it: GIT-93
took the name from nTEG's store. Every customer's cold recall got
PGRST202 and returned nothing.

- Default prefix: call gitmem_scar_search with similarity_threshold. If
  the store answers PGRST202 (no such function, e.g. nTEG's), fall back to
  match_gitmem_learnings_weighted with match_threshold. The first that
  exists is remembered for the process; any other error is not retried.
- Non-default prefix: only match_<table>_weighted. gitmem_scar_search reads
  gitmem_learnings by name and would search the wrong table.
- gitmem_scar_search doesn't return learning_type, applies_when,
  why_this_matters and the other fields recall renders. They are fetched
  for the matched ids in one select; if that fails, the rows are returned
  without them.
- Remove the dead semanticSearch (match_gitmem_learnings, no callers).

scar-search-rpc-name.test.ts: "tracks the prefix" asserted
match_gitmem_learnings_weighted for the default prefix, the bug itself;
it now asserts gitmem_scar_search. The semanticSearch test goes with the
function. +4 tests: PGRST202 fallback, no retry on a real error, the
follow-up select, and tolerating its failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-114)

scanRpcNames resolves "/rpc/<name>" in string and template literals
(getTableName expanded) and, where the URL is built from a variable, the
name properties of the candidate objects in the same file. Fixed https://
URLs (licensing) are classified external. Every store RPC must be defined
by setup.sql or allowlisted by ticket; stale entries and unresolved
dynamic names fail. Planted-drift self-test included. +5 tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ld server (GIT-114)

Both must return a seeded scar through the store's RPC. On 1.11.0 the RPC
404s (PGRST202) and both probes find nothing: exit 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nTEG-dev nTEG-dev closed this pull request by merging all changes into main in 60a990e Sep 23, 2026
@nTEG-dev
nTEG-dev deleted the bugfix/GIT-114-remote-recall-rpc branch September 23, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant