Repository navigation
D156 document tags: registry, assignments and SQL views (steps 1 and 4) - #606
Merged
Merged
Conversation
Registry (tags) and per-lineage assignments (document_tags) with the p9_49_0070 migration; TagCatalog list/create/update/delete and update_document_tags with unknown_tag strictness and the D156 limits; ingest adds tags without deciding versions; tags returned by GET /documents and search_documents; hard forget deletes a lineage's assignments. HTTP routes, SDK, CLI and MCP tools. Tests and docs follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
…, surface tests 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
…ples.facts_by_tag (D156 step 4) The two views join the query-space manifest (surface_manifest_hash rolls), the D48 deletion matrix (document_tags_live is a lineage-target surface) and the D143 layer map; examples.facts_by_tag joins facts to tags through supporting claims and passes the four-class fixture proofs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
…fore ingest stores bytes The ingest pre-check now refuses the per-document tag limit, like an unknown tag, before raw bytes or rows are stored. Adds the Tag documents guide and updates the HTTP, CLI, MCP, Python and TypeScript SDK, errors, query-space and not-built-yet pages; marks steps 1 and 4 implemented in the delivery plan and lists examples.facts_by_tag in the open query space design. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
…clean Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
Renumbers the D156 migration to p9_50_0071 (main added p9_49_0070), advances the storage-capture schema-head checks, and regenerates the query-space manifest, deletion matrix, openapi.json, the D143 defaults fixture, the TypeScript contracts and parity fixtures and the docs llms files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
…us tags only where the tables exist Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
Renumbers the D156 migration to p9_52_0073 after main's p9_50_0071 and p9_51_0072 corpus migrations and regenerates the query-space manifest, deletion matrix, openapi.json, the D143 defaults fixture, the TypeScript contracts and parity fixtures and the docs llms files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
… D153 oracle to the relations it predates 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
Renumbers the D156 migration to p9_53_0074 after main's p9_52_0073 corpus reconcile, points the compose upgrade gate and head pins at it, and regenerates the query-space manifest, deletion matrix, openapi.json, the D143 and D155 catalogue fixtures, the TypeScript contracts and parity fixtures and the docs llms files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
1 task done
…s and name resolution - Ingest removes the raw object it wrote when recording fails after storage (a tag deleted or a tag limit reached since the pre-check), so refused uploads leave no unreferenced bytes; tested on both ingest paths. - update_tag and delete_tag address a UUID-shaped reference by id only, so a tag named like another tag's id is never hit once that id is gone. - Resolved tags are share-locked until the writing transaction commits, so a concurrent delete_tag either waits (and cascades) or makes the write an unknown_tag refusal instead of a foreign-key error. - The Python and TypeScript SDKs search the registry with the NFC spelling when resolving a tag name. - create_tag and update_tag drop their unneeded savepoints. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
- Merges origin/main (live corpus capture) and moves the storage-capture schema-head checks to p9_53_0074; the tag tables join the catalog contract (tables, indexes, constraint counts, D156 objects) and the storage-capture source closure, and the generated capture profile is refreshed. - Ingest no longer deletes raw bytes after a refusal inside the write transaction: an unreferenced original from a refused attempt is already a tolerated, classified storage state (raw.unregistered_original), and the purge could delete a concurrent successful ingest's object. A refused ingest records nothing and a retry registers the same object (tested on both ingest paths). - update_tag and delete_tag lock their tag FOR UPDATE in one statement (by id, or by NFC name ignoring case), so concurrent name-addressed mutations queue instead of deadlocking on a share-to-update upgrade. - GET /tags takes name=, an exact match by the registry's own rule; both SDKs resolve a tag name through it instead of comparing case locally. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
…(review round 3) A tag reference was length-checked on the raw string while a declared name is checked after NFC, so a valid name spelled with combining characters (65 x "e\u0301": 130 characters sent, 65 after NFC) could be registered but not referenced. References now use the same rule as names: 1-128 characters after NFC, with a 512-character cap on the string as sent. This covers the HTTP models and ingest/name query parameters, the SDK models, the MCP argument parsing and schemas, and the TypeScript client and catalogue. Regression through HTTP update_document_tags, the SDK update/delete by name and the in-process MCP tools. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
fazpu
marked this pull request as ready for review
November 14, 2026 05:16
This was referenced Nov 14, 2026
Merged
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
Implements delivery steps 1 and 4 of D156 (document tags):
plan/plans/document_tags.md, binding designplan/designs/document_tags_design.md. Read filters by tags (steps 2 and 3) are not in this PR.What ships
p9_53_0074addstagsanddocument_tagsexactly as design §5. It also adds thememory_v1.tags_currentandmemory_v1.document_tags_liveviews, with view-owner and query-role grants.TagCatalog(spine/tags.py) provideslist_tags(query?),create_tag,update_taganddelete_tag.conflict.update_document_tagsrefuse unregistered tags withunknown_tagand list every one. Ingest checks this, and the per-document limit, before any bytes or rows are stored; the write transaction checks both again.tagsis optional and only adds tags. Tags never decide whether a version is created: a no-op resubmission with tags still returnscreated=false.update_document_tags. It is atomic and takesadd/remove, orset, which excludes the other two. An emptysetclears the tags. Removing an absent tag is fine. A deleted document returnsnot_found.GET /documentsitems andsearch_documentsresults now includetags.GET /tagsis a read;POST /tags,PATCH /tags/{tag_id},DELETE /tags/{tag_id}andPOST /documents/{doc_id}/tagsneed write scope.POST /ingesttakes a repeatedtagsparameter. None of the tag routes takes a spend hold.UnknownTagerror. Methods that address one tag resolve a name to its id.remember tags …,remember ingest --tagandremember documents tag.ingestis nowtool_version3.delete_tagis marked destructive.surface_manifest_hashrolls, the D48 deletion matrix and the D143 layer map. The new saved queryexamples.facts_by_tagjoins facts to tags through their supporting claims; there are now 19 examples.guides/tag-documents. The HTTP, CLI, MCP, Python and TypeScript, errors, result-types and query-space reference pages are updated, andnot-built-yetsays filtering by tag is not built.D56 / Rule 4
test_reuse_lifecycle.pygains two tests:No reuse key, header fact, embedding input or extraction window reads tags. No reuse boundary moves.
Review fixes (GPT 6.1 sol, four rounds, approved on e434647)
raw.unregistered_original), and re-sending the same bytes reuses it.GET /tags?name=, which compares the way the registry does (NFC normalisation, then PostgreSQLlower()).Verification
uv run ruff format --check src/ benchmarks/,uv run ruff check src/ benchmarks/,uv run pyright src/ benchmarks/ --pythonversion 3.13: clean.The full
pytest src/testsagainst PostgreSQL 19 on the previous merge head (before the last two fixes) had 7 failures, all intest_d153_eligibility_pg.py(its oracle snapshot read the new views). That is now fixed; the file alone has 29 passing. On 8aa7884,pytest src/tests/spine src/tests/workers src/tests/profiles src/tests/adaptersagainst PostgreSQL 19: 2180 passed, 125 skipped, 2 xfailed, 0 failed.TypeScript client:
check:generated,check:parity,typecheck,npm test(596 pass) andcheck:packageall pass.Docs:
check_docs_truth.py(public and--cloud) passes,generate_docs_llms.pywas rerun, and the website build passed earlier.GitHub CI on 8aa7884: green except CLA.
After the review fixes (head e434647): ruff, pyright, TypeScript checks and the PostgreSQL tag/migration/storage-capture suites pass locally. GitHub CI is all green except CLA, which this PR's agreement box fixes.
Contributor agreement
Signing on behalf of a legal entity (leave blank if accepting individually):
🤖 Generated with Claude Code
https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq