Skip to content

fix(test): isolate teamKnowledgeAwareness cache test from the machine cache#67

Merged
arzafran merged 1 commit into
mainfrom
fix/team-knowledge-test-isolation
Jun 22, 2026
Merged

fix(test): isolate teamKnowledgeAwareness cache test from the machine cache#67
arzafran merged 1 commit into
mainfrom
fix/team-knowledge-test-isolation

Conversation

@arzafran

Copy link
Copy Markdown
Member

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 passed undefined expecting [], but undefined doesn'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

  • teamKnowledgeAwareness gains an optional second argument — the cache reader, defaulting to the real readKnowledgeIndex. Zero production behaviour change; it's a test seam so the cache (Branch B) can be stubbed.
  • The failing test injects a null reader, isolating it from the real on-disk cache. Its comment now states why undefined doesn't bypass the cache, so this doesn't get reintroduced.
  • Adds a positive Branch-B test (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, undefined genuinely meant "no source → []". The cache added a second source the test never accounted for.

Test Plan

  • bun test616 pass, 0 fail (previously 614 pass / 1 fail)
  • bun run typecheck clean
  • bun run lint exit 0

… 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.
@arzafran arzafran merged commit 0ca7cbf into main Jun 22, 2026
15 checks passed
@arzafran arzafran deleted the fix/team-knowledge-test-isolation branch June 22, 2026 11:49
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