Skip to content

feat: get_knowledge language filter#267

Merged
cmeans-claude-dev[bot] merged 3 commits into
mainfrom
feat/get-knowledge-language-filter
Apr 12, 2026
Merged

feat: get_knowledge language filter#267
cmeans-claude-dev[bot] merged 3 commits into
mainfrom
feat/get-knowledge-language-filter

Conversation

@cmeans-claude-dev
Copy link
Copy Markdown
Contributor

@cmeans-claude-dev cmeans-claude-dev Bot commented Apr 12, 2026

Summary

  • get_knowledge gains optional language parameter (ISO 639-1 code)
  • Maps to WHERE e.language = %s::regconfig filter in PostgresStore
  • Store protocol updated with language parameter
  • 1 new test: filter entries by language

Closes #262. Refs #238.

QA

Prerequisites

  • pip install -e ".[dev]"
  • Deploy to test instance on alternate port (AWARENESS_PORT=8421)

Manual tests (via MCP tools)

    • Filter by language
    remember(source="qa", tags=["test"], description="Un texte français", language="fr")
    remember(source="qa", tags=["test"], description="An English text", language="en")
    get_knowledge(language="fr")
    

    Expected: only the French entry returned

    • No filter returns all
    get_knowledge(tags=["test"])
    

    Expected: both entries returned

🤖 Generated with Claude Code

@cmeans-claude-dev cmeans-claude-dev Bot added the Dev Active Developer is actively working on this PR; QA should not start label Apr 12, 2026
@github-actions github-actions Bot added the Awaiting CI Dev complete, waiting for CI/Codecov to pass before QA label Apr 12, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cmeans-claude-dev cmeans-claude-dev Bot added Ready for QA Dev work complete — QA can begin review and removed Dev Active Developer is actively working on this PR; QA should not start labels Apr 12, 2026
@github-actions github-actions Bot removed the Awaiting CI Dev complete, waiting for CI/Codecov to pass before QA label Apr 12, 2026
@cmeans cmeans added the QA Active QA is actively reviewing; Dev should not push changes label Apr 12, 2026
@github-actions github-actions Bot removed the Ready for QA Dev work complete — QA can begin review label Apr 12, 2026
Copy link
Copy Markdown
Owner

@cmeans cmeans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[QA] Round 1 on PR #267 — QA Failed

Verdict: one substantive observation on semantic mismatch. Code is otherwise clean, test is good, 827/827 pass, CI green, CHANGELOG accurate.

What is working well

  • SQL clause language = %s::regconfig is parameterized and safe ✓
  • Store Protocol updated with language parameter ✓
  • Test test_get_knowledge_filtered_by_language creates entries with explicit languages and verifies filter returns only the matching one ✓
  • Docstring is clear about the purpose: "show me all entries in language X" ✓
  • CHANGELOG under ### Added, accurate ✓

Substantive observation — unknown ISO codes silently map to simple, returning unexpected results

The filter path is:

lang_regconfig = iso_to_regconfig(language) if language else None

iso_to_regconfig("xx") returns "simple" (unknown codes fall back to simple per the mapping design). So get_knowledge(language="xx") filters for language = 'simple'::regconfig — which returns all entries with the default language, not zero entries.

From the user's perspective: "show me entries in language xx" → gets entries in simple (the majority of entries). This is a semantic mismatch.

The issue is that iso_to_regconfig() was designed for WRITE paths where "unknown → simple" is the correct fallback (you want the entry stored with a valid regconfig). For READ/FILTER paths, the semantics are different — an unknown code should match nothing, not match "simple."

Suggested fix options:

  • (a) Check for the fallback case explicitly:

    raw = iso_to_regconfig(language)
    lang_regconfig = raw if (raw != "simple" or language.strip().lower() == "simple") else None

    This filters for simple only when the user explicitly passes language="simple". Unknown codes become None (no filter applied) — or alternatively, return an empty result set.

  • (b) Return an error for unknown codes: _error_response("invalid_parameter", f"Unknown language code: {language!r}", ...). Strict but unambiguous.

  • (c) Accept the current behavior and document it: "Unknown ISO codes are treated as 'simple' for filtering purposes." Honest but potentially surprising.

The choice between (a) and (b) depends on whether you want "unknown code = no filter" or "unknown code = error." Either is better than the current "unknown code = filter for simple."

Verification

  • 827/827 tests pass (+1 new)
  • CI: all green
  • ruff/mypy: clean
  • CHANGELOG: ### Added, accurate, refs #262 + #238

Applying QA Failed as the final act.

@cmeans
Copy link
Copy Markdown
Owner

cmeans commented Apr 12, 2026

[QA] Round 1 — QA Failed. Substantive: unknown ISO codes (e.g. language="xx") map to "simple" via iso_to_regconfig(), causing the filter to return all entries with the default language instead of zero entries. Semantic mismatch — user asks for "entries in language xx" and gets "entries in simple". The write-path fallback ("unknown → simple") is correct for writes but wrong for filters. Fix: detect the fallback case and either skip the filter or return an error. Code otherwise clean, 827/827 tests, CI green.

@cmeans cmeans added QA Failed QA found issues — needs dev attention and removed QA Active QA is actively reviewing; Dev should not push changes labels Apr 12, 2026
@github-actions github-actions Bot added Awaiting CI Dev complete, waiting for CI/Codecov to pass before QA and removed QA Failed QA found issues — needs dev attention labels Apr 12, 2026
@cmeans-claude-dev
Copy link
Copy Markdown
Contributor Author

[Dev] QA round 1 fix: unknown ISO codes now return an error instead of silently matching simple entries. Added language='simple' as explicit filter option. New test for error case.

@github-actions github-actions Bot added Ready for QA Dev work complete — QA can begin review and removed Awaiting CI Dev complete, waiting for CI/Codecov to pass before QA labels Apr 12, 2026
@cmeans cmeans force-pushed the feat/get-knowledge-language-filter branch from 25c866e to 79ee624 Compare April 12, 2026 18:29
@github-actions github-actions Bot added Awaiting CI Dev complete, waiting for CI/Codecov to pass before QA Ready for QA Dev work complete — QA can begin review and removed Ready for QA Dev work complete — QA can begin review Awaiting CI Dev complete, waiting for CI/Codecov to pass before QA labels Apr 12, 2026
cmeans-claude-dev[bot] and others added 3 commits April 12, 2026 13:34
Add optional `language` parameter (ISO 639-1) to get_knowledge tool,
store protocol, and PostgresStore. Maps to WHERE e.language = %s::regconfig
filter. Enables queries like "show me all French entries".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Unknown ISO codes (e.g., 'xx') now return an error instead of silently
matching all 'simple' entries. Supports language='simple' explicitly
for filtering entries with no detected language.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… round 1)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cmeans cmeans force-pushed the feat/get-knowledge-language-filter branch from 79ee624 to d3aa98a Compare April 12, 2026 18:35
@github-actions github-actions Bot added Awaiting CI Dev complete, waiting for CI/Codecov to pass before QA and removed Ready for QA Dev work complete — QA can begin review labels Apr 12, 2026
@cmeans cmeans added the QA Active QA is actively reviewing; Dev should not push changes label Apr 12, 2026
Copy link
Copy Markdown
Owner

@cmeans cmeans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[QA] Round 2 — Signoff

Round-1 finding resolved. Dev chose option (b) — unknown ISO codes return an error with a helpful message listing valid formats. The implementation is clean:

  • normalized == SIMPLE → filter for simple entries (explicit language="simple" works as a valid filter) ✓
  • normalized not in ISO_639_1_TO_REGCONFIG_error_response with invalid_parameter code ✓
  • Valid ISO code → iso_to_regconfig() → regconfig filter ✓

No more semantic mismatch — "language=xx" now gives the user a clear error instead of silently returning all simple-language entries.

838/838 pass (+11 from round 1). ruff clean. 2 PR checkboxes checked off. Zero new observations.

Ready for QA Signoff.

@cmeans
Copy link
Copy Markdown
Owner

cmeans commented Apr 12, 2026

[QA] Round 2 — Ready for QA Signoff. Unknown ISO codes now return error (option b). Explicit language="simple" filter works. 838/838 pass, 2 checkboxes checked, ruff clean. Applying label as final act.

@cmeans cmeans added Ready for QA Signoff QA passed — ready for maintainer final review and merge and removed QA Active QA is actively reviewing; Dev should not push changes labels Apr 12, 2026
Copy link
Copy Markdown
Owner

@cmeans cmeans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions Bot added Ready for QA Dev work complete — QA can begin review and removed Awaiting CI Dev complete, waiting for CI/Codecov to pass before QA labels Apr 12, 2026
@cmeans cmeans added QA Approved Manual QA testing completed and passed and removed Ready for QA Dev work complete — QA can begin review Ready for QA Signoff QA passed — ready for maintainer final review and merge labels Apr 12, 2026
@cmeans-claude-dev cmeans-claude-dev Bot merged commit d5f2388 into main Apr 12, 2026
35 checks passed
@cmeans-claude-dev cmeans-claude-dev Bot deleted the feat/get-knowledge-language-filter branch April 12, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

QA Approved Manual QA testing completed and passed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: get_knowledge language filter

1 participant