fix(test): isolate teamKnowledgeAwareness cache test from the machine cache#67
Merged
Merged
Conversation
… cache The "no path given" test passed undefined expecting [], but undefined does not bypass anything — it falls through to Branch B, the TTL cache at ~/.claude/tmp/knowledge-index.json. On any machine with a warm cache it returned the real note count, so the test was the lone red across the last several PRs. teamKnowledgeAwareness now takes an optional cache-reader (defaults to readKnowledgeIndex — zero production behaviour change) as a test seam. The test injects a null reader to isolate from the real cache. Adds a positive Branch-B test too: the cache-output format was previously untested.
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 this does
Fixes the one test that's been red on every PR for the last several runs —
teamKnowledgeAwareness › returns [] when no path is given. It only failed on our machines: the test passedundefinedexpecting[], butundefineddoesn't bypass anything — it falls through to the TTL cache at~/.claude/tmp/knowledge-index.json, and any machine with a warm cache returns the real note count. CI passed because its runners have a cold cache, which is exactly why it looked like a harmless flake. Now the test is deterministic everywhere.Summary
teamKnowledgeAwarenessgains an optional second argument — the cache reader, defaulting to the realreadKnowledgeIndex. Zero production behaviour change; it's a test seam so the cache (Branch B) can be stubbed.nullreader, isolating it from the real on-disk cache. Its comment now states whyundefineddoesn't bypass the cache, so this doesn't get reintroduced.undefined+ a stub cache with notes → "3 shared notes" output) — the cache-fallback output path was previously untested.The root cause: the test predates the TTL-cache feature (#62/#63). Before the cache existed,
undefinedgenuinely meant "no source → []". The cache added a second source the test never accounted for.Test Plan
bun test— 616 pass, 0 fail (previously 614 pass / 1 fail)bun run typecheckcleanbun run lintexit 0