Repository navigation
D156 step 2: filter search and search_documents by document tags - #614
Merged
Merged
Conversation
Tags join the D134 documents filter in the shared compiler core/document_filters.py, tested on the lineage. Names resolve to tag ids before retrieval and an unregistered tag fails with unknown_tag. With a D140 time scope the filter and the scope hold on the same occurrence for claims and for a fact's supporting claims. A completed empty filtered claim/chunk search says whether any live document matched. MCP search_documents gains tags (tool_version 4), the CLI gains --tag, --any-tag and --not-tag; openapi.json and TypeScript contracts regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
…ule, empty explanations, surfaces Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
…filter; qualification strata in the D142 sweep The D142 sweep gains D156 tag strata (1% and 90% of lineages) for chunk search and, with --claims, for claim search over one reused claim per served chunk, plus EXPLAIN ANALYZE of the tag filter's eligible-set probe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
…r parity; plan step 2 status Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
…dence rule Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
…o feat/document-tags-search-filter # Conflicts: # packages/typescript-client/contracts/metadata.json # packages/typescript-client/src/metadata.generated.ts # packages/typescript-client/src/version.generated.ts
…cts exactly; TS tag-filter validator checks shapes first Review r1 (GPT 6.1 sol) on #614: - Claims now enumerate their eligible set from the matching lineages, as chunks do from the matching versions, and reuse the exact / pushdown tiers. Unscoped fact search under a document filter enumerates the facts supported from matching lineages and, up to the exact tier threshold, scores them through the keyed exact branch instead of the HNSW loop. Regression: tagged items ranked beyond the work budget are found on every grain, and the same read is a boundary with the tiers switched off. - The TypeScript DocumentTagFilter invariant runs only on well-shaped lists, so malformed tags are an InputValidationError; parity fixtures added. - Filter tag resolution in reads locks nothing (step 1's write-side FOR SHARE cannot run in a read-only snapshot). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
…te from the base evidence tables; facts qualification harness Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
1 task done
…arch-filter # Conflicts: # packages/typescript-client/contracts/metadata.json # packages/typescript-client/src/metadata.generated.ts # packages/typescript-client/src/version.generated.ts
…efuses invalid tag references locally Review r2 (GPT 6.1 sol) on #614: - _enumerate_supported_facts deduplicates fact keys before applying EXACT_TIER_THRESHOLD; the support-row read is bounded at FILTER_PUSHDOWN_LIMIT + 1. Regression: two facts with four matching supports each take the exact tier behind twelve better-ranked facts. - The TypeScript DocumentTagFilter invariant applies the TagRef rule (512 raw, 1-128 after NFC) through the shared isTagRef; parity fixtures for empty, 129- and 513-character references. - Regenerated the storage-capture live-profile fixture after the main merge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
…rces Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
…by claim index Review r3 (GPT 6.1 sol) on #614: the fact enumeration joined each matching lineage's claims to a whole partitioned evidence table, which the planner hash-joined once per lineage (24 s at 90% of 20k facts). Each claim now probes relation_evidence and observation_evidence through their claim indexes in an OFFSET 0 LATERAL: 39 ms at 1% and 1.7 s at 90% on the same store (EXPLAIN ANALYZE in the PR). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
…arch-filter # Conflicts: # src/tests/fixtures/storage_capture/live_corpus_profile.json # src/tests/surfaces/test_d143_defaults_unchanged.py
fazpu
marked this pull request as ready for review
November 14, 2026 20:55
fazpu
added a commit
that referenced
this pull request
Nov 14, 2026
Release coordinates from origin/main (after #614), raised to a minor: PostgreSQL 18 becomes the reference server (D157); corpus folders and document tags ship. Changelog records 0.21.0 and labels the 0.20.0 entry. RELEASING.md: the pypi environment no longer has a required reviewer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXAuJJ6Tswr9Q3Auc1VPKb
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
D156 delivery step 2 (plan): filter
search(claims, chunks) andsearch_documentsby caller tags. Base:main(step 1, #606, is merged).What this does
DocumentSearchFilters.tags: {all?, any?, none?}takes tag names (any case) or tag_ids. At least one list must be non-empty, no list may repeat a tag, each list holds at most 32, and every reference follows TagRef. Unregistered tags fail withunknown_tag, naming every one, before anything is searched.core/document_filters.pytests tags on the lineage (document_tags.doc_id, oneEXISTSperalltag, so the planner starts fromix_document_tags_tag). Claims, chunks,search_documentsand P1 fact eligibility all share it. Read-side tag resolution locks nothing.documentsfilter. With a time scope, a periodised claim needs one occurrence that is both selected and matching, and a fact needs one supporting occurrence that both passes the evidence gate and matches. Before, the filter and the time scope were tested independently.boundary.filters.tags/documents.tags; 422unknown_tagonPOST /search/claims,POST /search/chunksandPOST /documents/search.search_documentsgets a flattagsfield (tool_version4).remember documents search --tag/--any-tag/--not-tag.openapi.json, TS contracts, D143 fixtures and the docs (website/) are updated;not-built-yetnow says the context operations are not filtered yet.Deviation from the design, agreed with the supervisor
No deployment surface searches relations or observations with a
documentsfilter. So the §4.4 evidence rule (supporting evidence from matching documents, contradictions and co-members from everywhere markedin_documents_filter, two-sidedevidence_totals) moves to step 3, in thefacts_contextevidence path. Step 2 builds the shared fact eligibility that step 3 consumes: P1search_facts_scored(documents=…)with tags, the same-occurrence rule and the exact tier. The plan says so. Theentity_idscombination is proven at the P1 nomination level, because no public step-2 read takes both.Qualification
These are synthetic stores on a local PostgreSQL 19 container. What was qualified: chunk and claim search at 300k chunks (D142 sweep,
benchmarks/p1_ranked/sweep.py), and fact search at 20k facts (benchmarks/p1_ranked/tag_facts.py). The 1M and 3M chunk stores could not be seeded: the PostgreSQL backend was OOM-killed (signal 9) in the shared ~10 GB Docker VM during the seed's bulk statements. Nothing was qualified at that scale.Chunks and claims: 300k chunks
6,000 lineages × 5 versions × 10 chunks and 60k claims reused across versions. 40 BM25 queries, k = 20, public
search_chunks/search_claims.The eligible-set probe (EXPLAIN ANALYZE) takes 78 ms for the 1% tag (600 rows), starting from
ix_document_tags_tag. For the 90% tag it reads its 20,001-row cap in 2.8 s (4.05M buffer hits), then falls back to ordinary nomination. That bounded probe is the broad-filter cost.Facts: 20k relations
One relation per lineage, random 1,536-dimension vectors, live mentions and evidence. 40 random query vectors, k = 20, P1
search_facts_scored(kind="relation").Fact enumeration probe, EXPLAIN ANALYZE, claim-keyed (review r3). Before this commit the same probe took 1.26 s at 1% and 24 s at 90%. The 63 of 64 identical per-partition index scans are elided below:
Verification
test_document_tag_filters_pg.py(14), D134 filter, D140 scoped retrieval, D153 eligibility and storage-capture profile: 85 passed. The full workers, surfaces and adapters lanes run in CI.check:generated,check:parity,npm test(607 pass).Contributor agreement
Signing on behalf of a legal entity (leave blank if accepting individually):
🤖 Generated with Claude Code
https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq