Skip to content

fix: brand 'shared'/'global' sentinels + LLM synthesis in review_content - #11

Merged
delkc merged 4 commits into
mainfrom
claydelk/brand-filter-review-llm
Apr 23, 2026
Merged

fix: brand 'shared'/'global' sentinels + LLM synthesis in review_content#11
delkc merged 4 commits into
mainfrom
claydelk/brand-filter-review-llm

Conversation

@delkc

@delkc delkc commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator

Why

Two bugs found in real-world testing: knowledge units tagged brand: "shared" were silently excluded when filtering by a specific brand, and review_content returned a raw ~300K character prompt wall instead of synthesized findings.

What

  • Add isGlobal() helper treating null/undefined/"shared"/"global" as always-include; apply to semanticSearch(), applyFilters(), list_knowledge_units, and get_brand_rules
  • review_content now calls an Anthropic LLM internally (when ANTHROPIC_API_KEY is set), truncates bodies to 2000 chars each, and returns synthesized findings
  • ServeOptions gains anthropicApiKey and model fields; @anthropic-ai/sdk added as optional peer dep with graceful fallback to raw prompt
  • JSDoc on RuleFilter documents the shared/global sentinel convention
  • Two new tests cover sentinel inclusion in exactMatch and semanticSearch

Risk Assessment

Low — brand filter fix is additive (more results included, never fewer for valid queries); review_content LLM path only activates when an API key is present, existing raw-prompt behavior preserved as fallback.

References

Generated with Claude Code

delkc and others added 4 commits April 16, 2026 16:36
… support

Search:
- Add conservative English stemmer to BM25 tokenizer so plurals and
  common suffixes match (errors → error, messages → message, writing → write)

Loader:
- Generate brand-prefixed IDs (shared-voice-principles, cash-app-errors)
  so cross-brand files with the same filename no longer collide in the
  search index
- Detect duplicate IDs after loading and emit warnings rather than
  silently dropping the second unit

MCP server:
- search_knowledge: return compact listing (ID, title, enforcement,
  150-char excerpt) instead of full body for every result; instruct
  caller to use get_knowledge_unit(id) for full content
- get_brand_rules: return compact index instead of full compiled
  skill-md dump; fixes 212KB responses
- serveMcp: add bundlePaths option so aggregator repos can merge
  multiple knowledge bundles into one search index

Docs:
- Document serveMcp() API including multi-bundle usage
- Add Skills Convention section explaining skills/{name}/SKILL.md
  directory structure and local install pattern

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
'testing' now stems to 'test' — update expected output to match.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…esis to review_content

- isGlobal() helper treats null/undefined/'shared'/'global' as always-include
  in BM25SearchAdapter.semanticSearch(), applyFilters(), and all inline brand
  filters in mcp-server.ts (list_knowledge_units, get_brand_rules)
- review_content now calls an Anthropic LLM internally when ANTHROPIC_API_KEY
  is set; bodies truncated to 2000 chars each before passing to the model
- ServeOptions gains anthropicApiKey and model fields; @anthropic-ai/sdk added
  as optional peer dep
- JSDoc on RuleFilter documents the shared/global sentinel convention
- Two new tests cover brand sentinel inclusion in exactMatch and semanticSearch

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@delkc
delkc marked this pull request as ready for review April 23, 2026 14:51
@delkc
delkc requested a review from nahiyankhan as a code owner April 23, 2026 14:51
@delkc
delkc merged commit c55b36c into main Apr 23, 2026
6 checks passed
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.

2 participants