Skip to content

D-CMR-1 / D-RA-2: the contract owns single-table set algebra; relalg delegates - #1644

Merged
AdaWorldAPI merged 6 commits into
mainfrom
claude/eager-albattani-iufugq
Oct 21, 2026
Merged

AdaWorldAPI merged 6 commits into
mainfrom
claude/eager-albattani-iufugq

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Implements the first architecture PR named by ADR-2026-10-20-SIX §2 (entries/2026-10-20-six-decisions.md, on main via #1640). The single-table rewrites move into the contract, independent of any physical layout. relalg becomes a consumer.

Dependency diagram

Before

lance-graph-relalg ── owns normalize (Rel rewrites) ──► lowers to r2il / mask-risc
lance-graph-contract   (no set algebra)

After

lance-graph-contract::set_algebra        (zero deps: SetExpr, Res, Runs, normalize)
        ▲  path dep, new
lance-graph-relalg ── Rel ⇄ SetExpr, then delegates ──► lowers to r2il / mask-risc (unchanged)
        (Quack, crepe / R2IL: later consumers via D-CMR-6; not touched here)

The contract's Cargo.toml is unchanged; it still has no dependencies.

What is in the contract

  • SetExpr: All | Empty | Sym(u32) | Res(Res) | And | Or | Not.
    • Sym is an opaque two-valued set. It does not name a plane or a bitset; relalg maps Plane(i) onto it.
    • Res is a residual predicate on one lane, with the same fields as relalg's Atom.
  • normalize: relalg's rules, ported unchanged except for absorption.
    • Rules: De Morgan, associative flattening, idempotence, complement pairs, per-lane interval fusion and merge.

    • Absorption is matched against flattened sibling sets, in two forms:

      1. A dual child And(ms) inside an Or is dropped when some member m is already covered by the siblings: m is a sibling, or an Or whose members are all siblings.
      2. It is also dropped when a sibling And(ks) has every k among ms. This is x ∨ (x ∧ y) with x itself a conjunction.

      Both have duals inside an And. Children are dropped one at a time, each checked only against the children still kept. This closes N17 (ISS-RELALG-ABSORPTION-AFTER-DE-MORGAN): ¬(x ∧ (x ∨ y)) now reduces to ¬x when x is a leaf, an And or an Or.

    • Flattening happens before relalg's slot admission.

    • No rule distributes, so normalization never grows an expression; a test checks this.

  • Runs: sorted, disjoint, half-open intervals.
    • ∩, ∪ and ∖ are each a single merge pass, O(n + m).
    • complement(universe) returns Err(OutOfUniverse) when the set reaches past the given universe.

relalg

normalize converts Rel to SetExpr, calls the contract and converts back. symbolic, run, lowering and the public API are unchanged.

Regression results (relalg, before vs after)

target before after
tests/rewrites.rs 14 passed 14 passed (identical names)
lib unit tests 2 passed 3 passed (+conversion_round_trips)
tests/absorption_n17.rs (new) — 2 passed
  • cargo test -p lance-graph-contract --lib set_algebra: 10 passed.
  • Consumers: cargo check --all-targets passes for holo-h14d-probe, lance-graph-metta and crepe-plan-probe.
  • Clippy -D warnings is clean on the contract and on relalg.

crepe-plan-probe: its test m_the_known_absorption_gap_is_untouched_and_not_produced pinned N17 as unfixed and asked to be updated when that changed. CI probe caught it. The test is renamed ..._is_closed_and_not_produced and now asserts that both compound cases reduce. Its Or case also exposed absorption form 2, which was added with a red-first test.

Algebra-law tests (contract)

  • Differential. normalize(e) is compared against e over materialized bitsets with an explicit universe (N = 97), for 3,000 random nested expressions. The test also checks idempotence and that the rewrites fired on most inputs (anti-vacuity).
  • Runs laws. ∩, ∪, ∖ and complement are compared with bitsets, together with canonical form, De Morgan, distributivity, identities and double complement. Universes tested: 0, 1, 2, 63, 64, 65 and 100.
  • Single cases. N17, its dual, the sub-conjunction case, a silence twin, flattening before depth, and complement pairs.

Disable probes (each restored afterwards)

probe effect
contract normalize returns its input relalg: 10 of 14 rewrites.rs tests and both N17 tests fail, so relalg really exercises the contract
absorption form 1 off only the N17 tests fail (1 in relalg, 2 in the contract)
absorption form 2 off only absorption_of_a_superset_conjunction fails
absorption on a partial cover (all → any) the silence twin fails, and so does the bitset differential (the rule becomes unsound)
max dropped in the union merge runs_obey_the_set_laws_against_bitsets fails

Scope held

No joins, positional gathers, relational AST ownership, recursion, D-MPS-8 or graph_hop. Measures on Runs (Count, Sum) are not in this PR.

Board updates:

  • LATEST_STATE: contract inventory.
  • STATUS_BOARD: D-CMR-1 and D-RA-2.
  • ISSUES: N17.
  • New entry 2026-10-20-d-cmr-1-set-algebra.md, plus the entries index.

main is merged in (#1641); its conflicts were in board files only.

🤖 Generated with Claude Code

https://claude.ai/code/session_013z2e1YXkm6o6HNrDn5BPWA

…gates

lance_graph_contract::set_algebra (zero dependencies):
- SetExpr {All, Empty, Sym, Res, And, Or, Not}, Res (one-lane residual),
  Cmp; normalize = the one implementation of the single-table rewrites
  (De Morgan, associative flattening, idempotence, complement pairs,
  per-lane interval fusion/merge, absorption).
- Absorption is matched against flattened sibling sets, one child at a
  time: closes ISS-RELALG-ABSORPTION-AFTER-DE-MORGAN (N17).
- Runs: sorted disjoint half-open intervals with intersect / union /
  difference / complement(universe); complement refuses a set past the
  declared universe.
- Tests: differential vs materialized bitsets (3,000 random nested
  expressions), no leaf growth, N17 + dual, partial-cover silence twin,
  flatten-before-depth, Runs laws vs bitsets incl. empty/full/boundary.

lance-graph-relalg: normalize converts Rel <-> SetExpr and delegates.
Public API unchanged; the 16 existing tests pass unchanged; N17
regression in tests/absorption_n17.rs. Disable runs recorded in
entries/2026-10-20-d-cmr-1-set-algebra.md.

Board: LATEST_STATE contract inventory, STATUS_BOARD D-CMR-1 / D-RA-2,
ISSUES N17, entry + index.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013z2e1YXkm6o6HNrDn5BPWA
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 54bb39ac-8911-439e-8c6d-f0937c19a389
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013z2e1YXkm6o6HNrDn5BPWA
@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review October 21, 2026 00:15
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T00:18:20.307462Z 705a505 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 705a505c60

ℹ️ 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".

Comment thread crates/lance-graph-contract/src/set_algebra.rs Outdated
…17 pin

CI (probe) showed crepe-plan-probe's pin m_the_known_absorption_gap
firing: the compound-x case is now fixed, as the pin asked to be told.
Its Or-x variant exposed a second absorption shape: after De Morgan,
(¬P0 ∧ ¬P2) ∨ (¬P0 ∧ ¬P2 ∧ ¬P1), i.e. one dual child a sub-conjunction
of another. normalize now also drops And(ms) in an Or when a sibling
And(ks) has every k in ms (dually in an And). Red first
(absorption_of_a_superset_conjunction), green after, disable-verified;
the bitset differential stays green.

crepe-plan-probe: the pin is flipped to assert both compound cases now
reduce, renamed ..._is_closed_and_not_produced.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013z2e1YXkm6o6HNrDn5BPWA
union re-sorted n+m intervals through from_intervals while the type
promises cost linear in intervals. Now a two-pointer merge of the two
canonical lists. Covered by runs_obey_the_set_laws_against_bitsets;
dropping the max in the merge turns it red.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013z2e1YXkm6o6HNrDn5BPWA
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013z2e1YXkm6o6HNrDn5BPWA
…entries index after #1643

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013z2e1YXkm6o6HNrDn5BPWA
@AdaWorldAPI
AdaWorldAPI merged commit c05a313 into main Oct 21, 2026
19 checks passed
AdaWorldAPI pushed a commit that referenced this pull request Oct 21, 2026
PR_ARC entry for #1644; LATEST_STATE main-after-#1644; STATUS D-CMR-1
Shipped, D-RA-2 updated; ISSUES N17 resolved by #1644; the D-CMR-1 entry
carries the post-merge measurement: holo-h14d-probe stage 1 now widens
0 of 2,000 programs by the rewrite (was 2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013z2e1YXkm6o6HNrDn5BPWA
AdaWorldAPI added a commit that referenced this pull request Oct 21, 2026
board: record #1644 (D-CMR-1) merged; N17 measured closed (0 of 2,000 widened)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants