Repository navigation
relalg (D-RA-1): relational IR rewritten before it runs, lowered through R2IL — a D-CMR prototype - #1546
Conversation
…R2IL (D-RA-1) A query is described as a selection over one table's row space (All, Empty, Plane, comparison atoms, And/Or/Not) plus a measure. normalize() rewrites the description before anything runs: negation to the leaves, flattening and unit/zero absorption, complement, interval fusion per I32 lane in conjunctions, interval union in disjunctions, U32 equality agreement, absorption. A description that normalizes to Empty (or All, for a count) is answered without a program. Everything else lowers into R2IL calls over FoldDialect, which builds and runs one mask-risc program per fold. tests/rewrites.rs checks rewritten == as written == a row oracle over 400 generated descriptions and five measures, plus the cost effects (fewer passes, no program for contradictions and tautologies, a ten-way conjunction that only fits the scratch arena after fusion). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011BMJnDBAfzcuQh5HeT39Rh
relalg-v1 maps the crate onto D-CMR: the rules are D-CMR-6 constraint propagation over residual comparisons, the R2IL lowering is D-CMR-2's job by NAL's route, and D-RA-2 moves the rules into the contract set IR. Measured in the plan: 8 -> 2 mask-risc ops for four comparisons on one lane, contradictions and tautologies with no program, and 70 of 2,000 small descriptions that fit one fold only after the rewrite. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011BMJnDBAfzcuQh5HeT39Rh
Atom, Cmp and Measure must be Copy (compile-time guard), so no String can enter a description. D-RA-3 is re-scoped: a rule is a Rel built from coordinates; names are labels resolved once through the label codebook, never stored in a rule or used as an address, and text is a label view, never a query path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011BMJnDBAfzcuQh5HeT39Rh
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Warning Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c7e4732adc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
x = t ∨ x ≠ t stayed unrewritten because equalities went to the interval map and inequalities to the rest (codex review on #1546). A union now treats x ≠ a like the U32 case: a second inequality or an interval holding a covers the lane; otherwise the intervals are inside x ≠ a and absorbed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011BMJnDBAfzcuQh5HeT39Rh
What
New crate
crates/lance-graph-relalg. It has its own workspace root and is excluded from the default build, likelance-graph-nal, because it path-depslance-graph-r2iland through it OGAR. It is a prototype for D-CMR (.claude/plans/d-cmr-concept-chain-normalization-v1.md): rearrange a query's description with proven identities before anything runs, and lower only what is left.Reldescribes a set of rows of one table:All,Empty, a resident plane, one comparison on anI32orU32lane, andAnd/Or/Not. AQueryis aRelplus a measure (Count,Sum,Min,Max,Keep).Atom,CmpandMeasuremust beCopy(checked at compile time). Names are labels resolved through the label codebook and never become part of a description.normalizerewrites to a fixpoint:p ∧ ¬p = ∅,p ∨ ¬p = U;I32lane, a conjunction becomes one value interval plus the excluded values inside it;U32equalities either agree or contradict;symbolicanswers∅, andUfor a count, without running a program.runlowers to R2IL calls overFoldDialect(LOAD,IntSLess,IntEqual,IntAnd/Or/Not,RANGE, thenPopCount/SUM/MIN/MAX/KEEP). mask-risc executes them; the crate has no row loop.Measured
Run with
cargo test --manifest-path crates/lance-graph-relalg/Cargo.toml: 10 tests pass, clippy-D warningsand fmt are clean.x=3 ∨ x=4 ∨ x=5ScratchBufferTooSmall); runs after the rewriteFinding: the rewrite decides whether a query fits into one fold at all, not just how fast it runs. A fold has 8 scratch slots, and every negation in the as-written form takes one. 70 of 2,000 small runs therefore do not lower as written, and all of them run after the rewrite.
Disable runs: each guard was removed in turn, and each removal turned at least one test red:
≤negated to≥;<off by one;Stringin a measure (compile error).Relation to D-CMR
D-CMR puts the set algebra in
lance-graph-contract. It is explicitly not meant to be a third query syntax beside Quack'sFilterand NAL's R2IL programs. This crate is evidence for that plan, not a competitor:Not built: joins (a hop is a preimage over coordinates, D-CMR-5, never a foreign key), recursion (D-RA-4), row intervals, and Datalog rules (D-RA-3). Datalog rules will be algebra values, with names only as codebook labels.
Board
.claude/plans/relalg-v1.mdCargo.tomlexclude entry🤖 Generated with Claude Code
https://claude.ai/code/session_011BMJnDBAfzcuQh5HeT39Rh
Generated by Claude Code