Repository navigation
loom namespaces-gc matches a prefix as a literal string - #197
Merged
Merged
Conversation
The candidate scan matched --prefix and --exclude-prefix with LIKE and escaped only %, so _ in a prefix was a wildcard: --prefix lme_run --erase also erased an idle namespace named lmeXrun..., and --exclude-prefix fenced off names outside its prefix. The scan now uses startsWith, which has no metacharacters. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…rts the clickhouse-local test covers are gone Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…d-namespace test passes no unused exclude Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…dant Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
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.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
loom namespaces-gc --prefixand--exclude-prefixnow match the prefix as a literal string. Before, an_in a prefix matched any character, so--prefix lme_run --erasecould also erase an idle namespace namedlmeXrun....Why
Failing case:
loom namespaces-gc --prefix lme_run --erasewith idle, unregistered namespaceslme_run1andlmeXrun1. Both were candidates, and both were erased.Pattern:
_gc_candidatesmatched each prefix withnamespace LIKE {p:String}and built the pattern asp.replace("%", r"\%") + "%". That escaped%but not_or\, and_is a LIKE wildcard. The exclude side had the same flaw, in the safe direction:--exclude-prefix lme_ralso fenced offlmeXr.... Loom should delete only what its writer asked to delete, so the include side broke that rule. The default bench prefixes all end in-, so the default scan was not affected.Fix: both predicates now use
startsWith(namespace, {p:String}), which has no metacharacters, and the prefix is bound as given._gc_memoryless_explicitandloom namespaces-adopt --prefixalready usedstr.startswith, and thenamespace_gcworker reads the registry rather than matching a prefix, so nothing else in the command matches with LIKE.Scope and risk
This changes
server/cli/hygiene.py::_gc_candidatesonly. A prefix now matches only names that start with that exact text. No op, setting or stored data changes.Compatibility, rollout and rollback
Tests
tests/unit/test_namespaces_gc_prefix_sql.py(new) runs the scan on clickhouse-local against the realloom.memoryandloom.namespacestables. Onmainit failed:--prefix lme_rreturned{lme_r1, lmeXr1, lme%r2}, and--exclude-prefix lme_rdroppedlmeXr1. With the fix both tests pass.tests/unit/test_erasure_namespace_list.pydrops its SQL-text asserts on the prefix predicates, which the new test now covers on real tables.make format-check lint typecheckpassed. The unit tests for the erasure, bench-namespace and namespace-gc areas, plustest_public_copy.py, passed (121 tests).AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. I checked the failing test against
mainand every other prefix match in the command.I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed. (format, lint, typecheck and the touched areas' unit tests ran locally; the full unit suite runs in CI.)main; no merged migration is edited (none).frontend/changed (unchanged).docs/describe the system as it now is.git commit -s).🤖 Generated with Claude Code