Repository navigation
test(conversation-store): 20 tests for sourceFromRole() + kindFromRole() + add --experimental-sqlite to test runner - #1214
Closed
bassilkhilo-ag2 wants to merge 1 commit into
Conversation
…e() pure routing helpers Guards the two exported pure functions that determine which SQLite surface (voice / phone / discord-voice) and canonical kind (user / agent / peer) a conversation record maps to: sourceFromRole() (8 tests): - phone-* prefix → 'phone' - discord-* prefix → 'discord-voice' - all other roles → 'voice' - empty string and unknown events → 'voice' kindFromRole() (12 tests): - 'user', *-user, *-caller → 'user' - 'assistant', 'sutando', *-agent, *-assistant → 'agent' - 'discord-peer' → 'peer' - SESSION_END, health.degraded and other events → verbatim passthrough Also adds --experimental-sqlite to tsx test command (node:sqlite is available in Node 22 but requires the flag; without it, the conversation-store module fails to import at test-suite load time). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
VasiliyRad
approved these changes
May 26, 2026
VasiliyRad
left a comment
Contributor
There was a problem hiding this comment.
20 tests for sourceFromRole / kindFromRole; package.json adds --experimental-sqlite to the tsx test runner so DatabaseSync-using code can import cleanly. The test wisely only imports the two pure helpers to avoid module-init I/O.
Heads-up: this PR's package.json change to the test script line conflicts with #1207 (which extends test:py glob + adds test:sh). Whichever lands second will need a small rebase. Easy 3-way merge — both touch the same script entries with different intents.
LGTM 👍
This was referenced May 27, 2026
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.
Summary
Adds 20 unit tests for the two pure routing helpers in
src/conversation-store.ts, and updates thenpm testrunner to pass--experimental-sqliteso the test can import the module.Why the flag is needed
conversation-store.tsimportsDatabaseSync from 'node:sqlite'at the top level. In Node 22,node:sqliteis available but requires--experimental-sqlite; without the flag, the entire test suite fails at module load time withERR_UNKNOWN_BUILTIN_MODULE. The flag does not affect any currently-passing tests.Tests added (
tests/conversation-store.test.ts, 20 tests)sourceFromRole()(8 tests) — determines which SQLite surface a conversation record writes to:phone-*prefix →'phone'discord-*prefix →'discord-voice'SESSION_END) →'voice'kindFromRole()(12 tests) — normalizes legacy role strings to the per-surface kind taxonomy:'user',*-user,*-caller→'user''assistant','sutando',*-agent,*-assistant→'agent''discord-peer'→'peer'SESSION_END,health.degraded) → verbatim passthroughAll 20/20 pass. The SQLite DB is never opened — only pure functions are exercised.