Skip to content

D-SRAM-2 spike: crepe_plan! as a cold rule optimizer in front of relalg - #1631

Merged
AdaWorldAPI merged 6 commits into
mainfrom
ccr-d3ce1263-ied9yh
Oct 20, 2026
Merged

AdaWorldAPI merged 6 commits into
mainfrom
ccr-d3ce1263-ied9yh

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Lab research spike for D-SRAM-2. It does not authorize D-SRAM-2 and does not own D-RA-2. The plan is .claude/plans/crepe-rule-optimizer-spike-v1.md.

What changes

  • crates/crepe-plan-probe (new, excluded from the workspace, with its own [workspace]). It takes a query through these stages in order:
    1. crepe's compiler front end produces a plan.
    2. Labels are resolved to ids.
    3. Cold rewrites run: binding propagation, then elimination of duplicate atoms and duplicate rules. Elimination only runs for existence and set answers.
    4. The query is mapped to MORK's query_multi shape; shapes outside the D-MPS-9 subset are refused.
    5. A star over the D-MPS-8 table becomes one relalg And, which lowers to one mask-risc program per rule.
  • Semijoin reduction before preparation (Options::semijoin, native::prepare_semijoin). When a side is restricted by a constant, every side is laid out only for the centers that all restricted sides have.
  • lance-graph-relalg: an additive run_with_program, which also returns the lowered program so a caller can inspect it.
  • Crepe dependency: AdaWorldAPI/crepe branch ccr-d3ce1263-ied9yh (9fd5785). It adds crepe_plan!, which reuses Context::new and the binding analysis that crepe! already uses. No HashSet/HashMap runtime is emitted.
  • thought-git-probe review fixes from D-TGB-0/1: thought-git fixtures, oracle, signal checks and the slot pool #1630 / D-SRAM-2 spike: crepe_plan! as a cold rule optimizer in front of relalg #1631:
    • A squash no longer removes the branch parent.
    • Pressure::Squashed now carries from_is_older, so the caller merges in the right order.

Evidence

  • 20 differential tests (A–N) against crepe!, datafrog, the MORK shape and a nested-loop bag reference.
  • 12 disable runs; each one turns its named tests red (plan §5 and §2b).
  • Measurements at n = 50,000 Parent rows, release build:
rows laid out prepare terminal
all rewrites 36 0.28 ms 2.4 µs
without semijoin 56,286 3.47 ms 3.3 µs
no rewrites 118,802 8.17 ms 14.8 ms
  • With the semijoin on, the laid-out row count is 36 at every size.
  • All answers match the oracles at 100, 1k, 10k and 50k rows. Reproduce with cargo run --release --example measure.
  • Board: entries/2026-10-20-crepe-rule-optimizer-spike.md; the D-SRAM-2 row is annotated.

Open

  • crepe is a proc-macro crate, so dynamic MeTTa rules need a crepe-core library split.
  • Preparation still scans every row once, so it stays O(n). Removing the scan needs a key-column index on the stored relations.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VncKoyG6JkpsoqhqTGTv3f

New excluded lab crate crates/crepe-plan-probe:
- crepe_plan! (AdaWorldAPI/crepe 9fd5785) reports crepe's own checks,
  strata and left-to-right bound/free analysis as data; no HashMap index,
  HashSet store or fixpoint loop is generated.
- logic: labels to ids; flat positive non-recursive rules over @input
  relations, everything else refused by name.
- optimize: binding propagation (head unification with the demand, the
  adornment step of Souffle's magic sets), duplicate-atom and
  duplicate-rule elimination gated on duplicate-insensitive answers.
- mork_api: each rule as a typed query_multi pattern; nested, repeated
  variable and cyclic shapes refused (D-MPS-9).
- native: a star on one shared variable laid out by the D-MPS-8 table,
  joint mask = relalg And of presence planes, one mask-risc program;
  coordinate witness, domain fingerprint and generation checks.
- reference: nested-loop evaluator over the unoptimized rules.

relalg: run_with_program() returns the program the fold ran (additive;
run and run_as_written unchanged, 13/13 relalg tests).

16 tests (A-M of the brief): answers equal crepe!, datafrog, MORK and the
reference; set and bag kept apart; refusals by name; no foreign hop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VncKoyG6JkpsoqhqTGTv3f
Stage costs per size with and without the rewrites, parity against
datafrog and the nested-loop reference; Soufflé harvest table and
follow-ups in the plan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VncKoyG6JkpsoqhqTGTv3f
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VncKoyG6JkpsoqhqTGTv3f
@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: aa6b32b6-5188-4438-9257-3afa09b62368
  • 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.

Under pressure with a full pool, a root candidate was squashed with its
oldest child as the source. When that child was the new thought's parent,
the branch succeeded but the caller's parent handle went stale. The root
is now squashed into that child instead, and the child takes the root's
place in the tree. Found by review on #1630.

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

chatgpt-codex-connector Bot commented Oct 20, 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-20T18:14:29.261302Z 8b6b585 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: 8b6b585f6d

ℹ️ 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/thought-git-probe/src/slots.rs
Comment thread crates/crepe-plan-probe/src/pipeline.rs Outdated
Comment thread crates/crepe-plan-probe/src/native.rs
@coderabbitai

coderabbitai Bot commented Oct 20, 2026

Copy link
Copy Markdown

Add Carrot credits or activate Agent usage billing to use Autofix

…merge order

- crepe-plan-probe: the bindings path ran a Count pass and then a Keep
  pass, and counted only the first. It now runs the Keep program once and
  counts that run.
- crepe-plan-probe: joint refuses a generation vector whose length differs
  from the table's side count; JoinTable::check zips and would skip sides.
- thought-git-probe: a root squashed into its child (the branch-parent
  case) is the older thought, so Pressure::Squashed now carries
  from_is_older and the caller merges the younger writes on top.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VncKoyG6JkpsoqhqTGTv3f
@AdaWorldAPI
AdaWorldAPI merged commit 7c22f28 into main Oct 20, 2026
12 checks passed
AdaWorldAPI pushed a commit that referenced this pull request Oct 20, 2026
The full thought git API (thought-git-api-v1.md) is still a proposal.
crates/thought-git-probe implements the slot pool, the oracle and the
tests. It does not implement the production land, rebase or persistence
pipeline; D-TGB-2..5 stay Queued.

D-TGB-0 and D-TGB-1 merged with #1630/#1631, so their board rows now read
Shipped (lab) instead of In PR. The module doc no longer says that no
thought-git code exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VncKoyG6JkpsoqhqTGTv3f
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