Repository navigation
fix: metrics wait for their session row instead of racing it to a 409 (GIT-73) - #42
Merged
2 commits merged intoSep 22, 2026
Merged
2 commits merged into
2 commits merged into
Conversation
… (GIT-73) session_start created its session row fire-and-forget and recorded its metrics at the same moment. gitmem_query_metrics.session_id references gitmem_sessions(id), so whichever request reached the store first decided whether the metrics insert failed with 409 (FK). recall right after session_start raced the same way. - session_start registers the pending session insert; recordMetrics waits for it (bounded at 15 s) before writing a row that references that session. - If the session row did not land, the metrics row is written without the FK and keeps the id in metadata.session_id, where session_close already reads it (GIT-109), instead of being lost. - Sessions this process did not create (resumed, another process's) are written immediately, as before. +5 tests. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A 409 from gitmem_query_metrics now fails the run. 10 flow runs on the v1.8.0 schema with the fix: 0 409s. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Sep 22, 2026
neoneye
pushed a commit
to agent-memory-atlas-archive/gitmem-dev--gitmem
that referenced
this pull request
Sep 22, 2026
Conflicts (blank-supabase.mjs): - EXPECTED_FAILURES: gitmem-dev#42 removed GIT-73 and gitmem-dev#44 removed GIT-105; both removals kept, so the list is empty. - all result fields and all checks kept. tsc clean.
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.
What
Metrics writes wait for their session row instead of racing it to a 409 (GIT-73).
session_startregisters its fire-and-forget session insert withregisterPendingSessionRow().recordMetricswaits for that insert, bounded at 15 s, before writing any row that references the session. That coverssession_start's own metrics and anything recorded right after it, e.g.recall.session_id: nulland keeps the id inmetadata.session_id. That's wheresession_closealready looks for it (GIT-109), so the row is kept instead of lost to a 409.session_startitself still doesn't wait: the session insert stays fire-and-forget, and only the metrics write is sequenced after it.Why
gitmem_query_metrics.session_idreferencesgitmem_sessions(id).session_startsent the session insert and its metrics insert at the same moment, so whichever reached the store first decided whether the metrics insert failed with 409 (FK violation).How to test
Venue (v1.8.0
setup.sql,vujndhcumgroztfkkdus; production not touched). GIT-73 is removed from the driver'sEXPECTED_FAILURES, so any 409 now fails the run. Tenflowruns each:origin/main1.10.0gitmem_query_metricsUnit tests: 1279/1279 pass (+5,
metrics-session-fk.test.ts):session_id: null, id inmetadata.session_id;No existing test encoded the old behaviour.
Checklist
npm run test:unitpasses (1279)Breaking changes
None.
🤖 Generated with Claude Code