feat(store): canonicalize tags on the write path (#653 choke-point) - #684
Open
norrietaylor wants to merge 1 commit into
Open
feat(store): canonicalize tags on the write path (#653 choke-point)#684norrietaylor wants to merge 1 commit into
norrietaylor wants to merge 1 commit into
Conversation
Phase 1 backfilled existing tags once; this is the complementary guarantee that *new* writes stay canonical, so the graph cannot silently re-fragment as the feed poller ingests new items. - DuckDBStore gains a single write-path choke-point: store / store_batch / update run each entry's tags through _canonicalize_entry_tags (alias substitution + optional namespace normalization + order-preserving dedupe). update() re-fetches to build its return value, so the returned Entry reflects the canonical tags. - Configured via three new constructor params (tag_aliases, tag_reserved_prefixes, tag_normalize_namespaces), wired from config.tags.* at all eight config-bearing construction sites (server, webhooks, cli). Empty alias map + normalization disabled is a true no-op, so an un-configured store writes byte-for-byte as before. Because every ingest path (feed poller, gh-sync, classify merge, direct distillery_store) persists through the store, this one choke-point also dedupes their assembled tags on the canonical form — no per-call-site change needed. Namespace-membership enforcement (known_namespaces + off/warn/strict) is split to a follow-up; this PR is pure canonicalization, inert by default. Stacked on the Phase 1 branch (needs canonicalize_tags + config.tags.aliases). Tests: store/store_batch/update canonicalize + dedupe, update return reflects canonical tags, namespace-normalization path, inert-by-default. Full suite 3235 passed; mypy --strict and ruff clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
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.
What
Follow-up to #680 (Phase 1). Phase 1 backfilled existing tags once; this is the complementary guarantee that new writes stay canonical — without it, the graph silently re-fragments as the feed poller ingests new items (it currently never applies the alias map).
Changes
DuckDBStore:store/store_batch/updaterun each entry's tags through_canonicalize_entry_tags(alias substitution + optional namespace normalization + order-preserving dedupe).update()re-fetches to build its return, so the returnedEntryreflects the canonical tags.tag_aliases,tag_reserved_prefixes,tag_normalize_namespaces), wired fromconfig.tags.*at all eight config-bearing construction sites (server ×2, webhooks, cli ×5). Empty alias map + normalization off is a true no-op → an un-configured store writes byte-for-byte as before.Why just the store (not the merge sites too)
The original design floated also canonicalizing at the poller / classify / gh-sync merge sites. That turns out to be redundant for correctness: every ingest path persists through the store, and the choke-point canonicalizes and dedupes on the canonical form at persist time. So one choke-point gives the full guarantee with far less surface than touching three call sites. (
Entrystays validate-only — no config in the model layer.)Deferred
Namespace-membership enforcement (
known_namespaces+ off/warn/strict gating of unknown namespaces) is split to a follow-up. This PR is pure canonicalization.Testing
store/store_batch/updatecanonicalize + dedupe;updatereturn reflects canonical tags; namespace-normalization path; inert-by-default (tags verbatim with no config).mypy --strict src/clean;ruff check src/ tests/clean.🤖 Generated with Claude Code