Memory: facts.source_turn_id stores FNV hash, not turns.id rowid — correlation permanently broken #15
Closed
opened 2026-05-12 19:03:51 +00:00 by KofTwentyTwo
·
1 comment
No Branch/Tag Specified
develop
ci/secrets-historical-baseline
feature/security-findings-2026-10
dependabot/npm_and_yarn/webview/npm_and_yarn-3ac77625be
dependabot/npm_and_yarn/webview/packages/bus/npm_and_yarn-c86b58a346
dependabot/npm_and_yarn/webview/vitejs/plugin-react-6.0.2
dependabot/npm_and_yarn/webview/vite-8.0.13
dependabot/npm_and_yarn/webview/zustand-5.0.13
dependabot/npm_and_yarn/webview/types/node-25.9.1
dependabot/npm_and_yarn/webview/vitest-4.1.6
dependabot/github_actions/actions/setup-node-6
dependabot/github_actions/github/codeql-action-4
dependabot/github_actions/actions/checkout-6
dependabot/github_actions/actions/cache-5
dependabot/github_actions/pnpm/action-setup-6
feat/local-first-llm-routing
docs/local-first-llm-routing-spec
fix/v0.2-wave-1-code-fixes
docs/v0.2-wave-1-doc-drift
docs/handoff-2026-05-14
docs/multi-runner-inventory
docs/ollama-baseline-58
fix/ci-env-harness-sqlite-voice-warmup
fix/ci-xcode-26-and-batcher-timing
chore/typecheck-blocking
fix/hud-typecheck-strict-undefined
wip/voice-log-menu-stash4
v0.1.0-dev.71
v0.1.0-dev.68
v0.1.0-dev.64
v0.1.0-dev.50
Labels
Clear labels
area:agent
area:build
area:bus
area:devtool
area:hud
area:logging
area:mcp
area:memory
area:vision
area:voice
audit-finding
bug
carry-forward
comment-cleanup
dependencies
documentation
duplicate
enhancement
epic
good first issue
help wanted
invalid
javascript
migration
question
severity:critical
severity:high
severity:low
severity:medium
wontfix
Something isn't working
Comment / docstring cleanup per .planning/code-commenting-guide.md
Dependency updates
Improvements or additions to documentation
This issue or pull request already exists
New feature or request
Good for newcomers
Extra attention is needed
This doesn't seem right
Pull requests that update javascript code
Further information is requested
This will not be worked on
Milestone
No items
No Milestone
v0.1 — It actually works (basic capabilities)
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: KofTwentyTwo/Jarvis#15
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
MemoryExtractionOrchestrator.processstill hashesTurnIDand stores the FNV hash infacts.source_turn_id. After today's FK fix, fact INSERTs succeed, butsource_turn_idholds the FNV-1a hash ofTurnID.rawValue(UUID string), not a realturns.idrowid. Fact-to-turn correlation is permanently broken.Evidence
packages/Memory/Sources/Memory/MemoryExtractionOrchestrator.swift:122-152(processbody +stableHash)SELECT source_turn_id FROM facts;→7747877241524896942(FNV hash)turnshasid=7747877241524896942MemorySchema.swift:35-50openly acknowledges the disjoint number systemsRoot cause / hypothesis
When the FK was dropped in
a5999e2, the writer-side change to use a realturns.idrowid wasn't made — the FNV hash is a Phase-7 artifact that survived the fix. The orchestrator hasjob.turnId: TurnID(UUID string) andturns.id INTEGER PRIMARY KEYautoincrement, but no lookup translates one to the other. The B-02 patch (commit48ad8d6) writes turn rows BEFORE memory extraction enqueues, but doesn't return the rowid, and there's no plumbing to feed it back.Recommended fix
Two surgical options:
Drop
source_turn_idfrom the schema entirely if no consumer reads it. Document that fact-to-turn correlation is viavalid_fromtimestamp proximity. Cleaner.Thread the real rowid: Make B-02's
appendTurnreturn the new rowid; thread it through theflushPaircallback (return triple(userText, assistantText, userTurnRowId)); haveMemoryExtractionCoordinator.start'sturnContentclosure return it; pass assourceTurnIdthrough toapplyOp. DropstableHashentirely.Option 1 is a one-day fix; option 2 is half a day and preserves correlation. The current state — silently storing nonsense — is the worst of both worlds.
Test
SELECT t.id FROM facts f JOIN turns t ON t.id = f.source_turn_idreturns a non-empty result after writing a fact, ORsource_turn_idcolumn does not exist after schema migrationfacts.source_turn_idSource
.planning/audit-2026-05-12/memory-audit.md(2026-05-12) — finding M-4 HIGHCross-references
48ad8d6) — provides the substrate for option 2Closed by v0.1 cluster merges on 2026-05-13. Develop now at
a8c7f1a0.