Repository navigation
An entity name longer than 256 characters once normalised is no entity, and a point write refuses one - #366
Merged
Merged
Conversation
…ixed point at the cap The timing test fed 20 000 to 32 000 characters to canonical_entity_text, which returns '' for text over MAX_ENTITY_CHARS (256) before the normaliser runs, so it compared '' with '' and timed four len() checks. The test now asserts the cap itself and that a name of exactly 256 characters in each of the old shapes is non-empty and a fixed point. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…o canonicalising stays idempotent canonical_entity checked MAX_ENTITY_CHARS on the raw text only. NFKC can lengthen it: 256 U+FB01 ligatures normalise to 512 characters of 'fi', which were returned and stored, and a second pass returned ''. The normalised text is now checked against the cap too. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…sed text too names_only kept a name by its raw length, so a facet or an entity filter of 129 ligatures passed it, canonicalised to '' and fell back to the raw text, which was stored or bound unnormalised. A point write's fact part of 200 ligatures was refused as 'stored as ''' (articles, possessives and punctuation are dropped), which named the wrong cause. One predicate, fits_entity, now decides for canonical_entity, names_only and the validator, and the validator says the part is longer than 256 characters once normalised. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…rmalised Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…is named for what it refuses Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ds past the cap mints no node facet_triples and the co-occurrence projection stored a commit: or error: concept as concept.lower(), never normalised, so 'commit:' + 249 'İ' (256 characters, fitting the cap) became a 505-character node and a ligature stayed unfolded. code_facet_node folds it (fold_case), checks the cap on what it stores, and both write sides use it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…that folds past the cap mints no node" This reverts commit 5fbdcb8. 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):
An entity name longer than 256 characters once normalised (NFKC turns a
filigature intofi) is treated like one longer than 256 as written: it is no entity, and a point write's fact subject or object of that kind is refused with a message that says so.Why
canonical_entitycheckedMAX_ENTITY_CHARS(256) on the raw text only. NFKC can lengthen text: 256filigatures (U+FB01) normalise to 512 characters offi. That text was returned and stored, and a second pass (a query seed, or theexistingrow a triple repair canonicalises again) returned'', against the function's documented idempotence and the cap's comment that it is a wire bound.One predicate,
fits_entity, now applies the cap to the raw and the normalised text, and three places use it:canonical_entity: text past the cap once normalised is no entity.names_only(facet triples and a search'sentity_filter): it kept a name by its raw length, so 129 ligatures passed and were stored as a 258-character facet node, or bound as a filter, that a second pass turns into'', so no seed can reach it. Such a name is now left out, as a name past 256 as written already was, and the search falls back to the parsed entities.memory.set,memory.update,memory.update_by_idrelations): a subject or object of 200 ligatures was accepted and stored as a 400-character entity. It is now refused with'…' is longer than 256 characters once normalised, checked before the canonical-length check, whose "stored as ''" message would name the wrong cause.The test that guarded this area,
test_normalising_a_huge_entity_is_linear, fed 20 000 to 32 000 characters, all over the cap, so it compared''with''. It is replaced by tests that reach the normaliser. Input is capped at 256 characters and the lines-executed counter cannot see regex backtracking, so no timing bound remains.Scope and risk
server/memory/domain/graph_quality.py(canonical_entity,names_only, the newfits_entity), the fact validator inserver/memory/api/models_crud.py, anddocs/features/entity-graph.md. Only names that grow past 256 characters under NFKC are affected.Compatibility, rollout and rollback
relationssubject or object is at most 256 characters but longer once normalised is now refused (it was accepted and stored unnormalised). During a rolling upgrade build N-1 still accepts it; nothing stored is changed or deleted.Tests
tests/unit/test_memory_entities_canonical.py: 256 ligatures and 129 ligatures are no entity; 128 ligatures,İ× 200 and the other lengthening cases are non-empty fixed points; a 256-character name in each of the old timing shapes is a non-empty fixed point. The ligature cases fail onmain.tests/unit/test_code_facets.py: a facet of 129 ligatures mints no node (fails onmain: the node is 258 characters).tests/unit/test_entity_stopwords_and_embed_batch.py: anentity_filterof 129 ligatures falls back to the parsed entities (fails onmain).tests/unit/test_point_write_relation_names.py: a 200-ligature subject or object is refused as longer than 256 once normalised (accepted onmain).test_doc_links.py: pass.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 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.main; no merged migration is edited.frontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code