Fix pull attribute ordering#10
Merged
Merged
Conversation
- attrs-frame's non-DB branch (FilteredDB pulls) had its take-while outside the ->> — dead code under util/cond+ — so the scan was unbounded and unguarded by entity: pulling an attribute an entity lacks leaked the next entity's value into the result. The take-while now lives inside the pipeline. - The parser stopped normalizing string-spelled keyword attributes: ":name" (and ":db/id") in a pull pattern were silently dropped. parse-attr-name now normalizes ":foo" strings to keywords up front; bare strings still name genuine string attributes. - attr-compare ordered attributes by Java's UTF-16 string compare, but the store orders their serialized form by UTF-8 bytes (code points); the orders disagree for supplementary-plane characters. Comparison now runs in code-point order (compare-attr-keys) — including the parser's sort-by, which also used default string compare and made pulls combining such attributes return nil. - The attribute sort key is computed once at parse time and cached on PullAttr instead of pr-str-ing the pattern attr's name on every frame-loop iteration. With regression tests for the FilteredDB bound, string-spelled attrs, and supplementary-plane attribute pairs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Two commits: the pull-attribute-ordering fix, plus the fixes for everything a high-effort multi-agent review of that commit confirmed.
cd8becb— Fix pull attribute orderingdbval's indexes order attribute components by their serialized (
pr-str) form, but pull's merge-join between the sorted pattern attributes and the:eavtdatom stream compared attributes with keywordcompare. The two orders disagree as soon as a pattern mixes plain and namespaced keywords (e.g.:typevs:instagram.story.image.preview/blob), desyncing the walk and silently dropping attributes from pull results. The fix centralizes the ordering inattr-sort-key/attr-compareand uses it intuple-list, both pull comparison sites, and the parser's attribute sort (:db/iddeliberately last). With regression test.26dd323— review findings, all confirmed by adversarial verificationattrs-frame's non-DBbranch had itstake-whileoutside the->>— dead code underutil/cond+— leaving the scan unbounded and entity-unguarded. Pulling an attribute an entity lacks assoc'd the next entity's value into the result (pre-existing bug; the ordering commit edited the dead form without noticing). Thetake-whilenow lives inside the pipeline.\":name\"and\":db/id\"in a pattern — formsparse-attr-specexplicitly accepts — no longer matched keyword datoms.parse-attr-namenow normalizes\":foo\"strings to keywords up front; bare strings still name genuine string attributes.attr-compareused Java string compare (UTF-16 code units) while the store orders serialized attributes by UTF-8 bytes (code points) — the orders disagree for supplementary-plane characters (emoji). Comparison now runs in code-point order viacompare-attr-keys. Fixing this surfaced one more spot the review hadn't isolated: the parser'ssort-byalso used default string compare, invertingfirst-attr/last-attrfor such patterns and making the pull returnniloutright.PullAttrinstead ofpr-str-ing the pattern attr's name on every frame-loop iteration.Test plan
\":name\",\":db/id\"), supplementary-plane attribute pairs.🤖 Generated with Claude Code
https://claude.ai/code/session_014dX8tTR4yFh5SyBGw3atpo