Skip to content

lgj-abi minor 13: a plan folded to one scalar, plus provenance and convergence tests - #95

Merged
AdaWorldAPI merged 3 commits into
mainfrom
ccr-c83f9f2f-t0hyyt
Nov 12, 2026
Merged

AdaWorldAPI merged 3 commits into
mainfrom
ccr-c83f9f2f-t0hyyt

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Three commits on top of #94. The first adds one export; the second adds tests only; the third is a board status line.

1. lgj_plan_scalar (ABI minor 13, docs/abi.md §21)

lgj_plan_eval lands a mask and returns its count. A caller that wants only a number still pays for the mask, and a sum pays a second crossing to read it back. lgj_plan_scalar folds the plan straight into a count or an I32 sum.

  • plan_lower::lower_scalar reuses lower_plan's ops unchanged and ends in mask-RISC's existing Count / MaskedSumI32 terminals. No new evaluator.
  • lgj_plan_eval is unchanged. It still lands its mask and its count.
  • View.count() and View.sumOf() keep their signatures. They call the new symbol at minor 13 or later and keep the mask path against an older library.
  • No new status, no manifest growth.
mask path scalar fold
crossings, count() 1 1
crossings, sumOf() 2 1
mask bytes written per call 8 × ceil(rows / 64) 0
Rust allocation per call (3 ops) 240 B 240 B, independent of rows
native latency, count baseline unchanged within noise
native latency, sum baseline 3–25% lower

The gain is the removed mask write and the saved crossing for a sum. It is not a large speed-up; §21.5 has the numbers.

Verified against lance-graph 0683c74, ndarray 5fc71d7:

  • Parity with three independent oracles (the mask path, mask-RISC's row-at-a-time reference on the same program, a hand walk over the fixture) across the {AND, OR}^n sweep at 1,000 and 65,536 rows.
  • 6 of 6 disable runs red (§21.6). One was green at first and exposed a missing test, which is now plan_defects_are_reported_as_lgj_plan_eval_reports_them.
  • AllTests 617 checks; consumer mains 70 / 68 / 3 / 12 (JDK 28+23-ea).
  • Against a minor-12 library built from the lgj-abi: map lance-graph's two new selection ExecError variants #94 commit, OldAbiCompatTest returns the same answers (71, 6257, 111296) in 2 crossings where minor 13 takes 1.

Re-pinned: LazinessTest (sumOf 2 → 1 crossing) and GroupSumTest (the per-group path 32 → 16 crossings).

Not done: JMH numbers through the JVM. The latency figures are native calls only.

2. Tests only: provenance and Program convergence

provenance.rs pins, as an asserted table, what twelve mask-taking exports check about where a mask came from. No rule is changed.

  • Nine check only the row count (lgj_op_eq_u32, lgj_op_gt_i32, lgj_plan_eval, both lane reductions, lgj_op_eq_classid, lgj_op_ternary_match, lgj_hop source and destination). They accept a mask created over a different resource, including one of the other kind.
  • Three require the mask's parent to be the resource they read, as the mask algebra does.
  • a_selection_can_be_relabelled_onto_another_resource_today shows what the first rule permits: a predicate evaluated on B, stored in A's mask and summed over A's values, returns OK and a number that answers neither.

Experiment, not in this PR: with the same-parent rule in all nine paths, AllTests, the consumer mains and the TinkerPop harness still pass; natively only the two tests that pin the lenient rule fail. bench/ was not run. Whether to tighten the rule is a separate decision.

both_lowerings_emit_the_same_program compares lowered Program values, not answers: for 56 plans (arity 2–5, all nine opcodes) and four terminals, plan_lower(ops) == quack::lower(fold_to_tree(ops)), 224 of 224. Dropping the survivor gate or swapping an AND's operands turns only this test red. Scope: the Quack side receives this file's tree reading of the flat plan; plans with no AND and the fk-keyed grouped sum are outside the claim.

Totals

Native: 211 tests, fmt and clippy -D warnings clean.


Generated by Claude Code

lgj_plan_scalar folds the fused plan straight into a count or a sum
(LGJ_FOLD_COUNT, LGJ_FOLD_SUM_I32). plan_lower::lower_scalar reuses
lower_plan's ops unchanged and ends in mask-RISC's Count / MaskedSumI32
terminals. lgj_plan_eval is unchanged and still lands its mask and count.

View.count() and View.sumOf() call the new symbol at minor >= 13 and keep
the mask path against an older library.

Measured: native 205 tests (9 new), 6 of 6 disable runs red; Java core
617 checks; consumers 70 / 68 / 3 / 12. sumOf() goes from 2 crossings to
1; the per-call mask write is removed; native latency is unchanged for
count and 3-25% lower for sum. docs/abi.md section 21 has the tables.

Re-pinned: LazinessTest (sumOf 2 -> 1) and GroupSumTest (per-group path
32 -> 16 crossings).

Claude-Session: https://claude.ai/code/session_01XAqKMP36eRfzsppfaEWMVz
provenance.rs states, as an asserted table, which of twelve mask-taking
exports require a mask's parent to be the resource they read (three, plus
the mask algebra) and which check only its row count (nine). It also
shows what the row-count rule permits: a predicate evaluated on one
resource, stored in another's mask and summed over the other's values,
with status OK. No rule is changed.

lowering_convergence.rs gains both_lowerings_emit_the_same_program:
for 56 plans and four terminals, plan_lower and quack::lower emit
structurally identical Programs (224 of 224). Two disable runs (survivor
gate dropped, AND operands swapped) turn only this test red.

Claude-Session: https://claude.ai/code/session_01XAqKMP36eRfzsppfaEWMVz
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

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

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 83469371-ffc9-4ab7-b798-9c7dfba6b2f4
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review November 12, 2026 22:27
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T22:29:03.031590Z 9c79b17 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.

@AdaWorldAPI
AdaWorldAPI merged commit 74cda93 into main Nov 12, 2026
5 checks passed
AdaWorldAPI pushed a commit that referenced this pull request Nov 12, 2026
Nine mask arguments checked only the row count: lgj_op_eq_u32,
lgj_op_gt_i32, lgj_plan_eval, lgj_reduce_sum_i32, lgj_reduce_i32,
lgj_op_eq_classid, lgj_op_ternary_match, and the source and destination
of lgj_hop. They now compare the mask's parent with the resource by
registry identity (Arc::ptr_eq), as the register sweeps already did.
Status stays MASK_LENGTH_MISMATCH. No new symbol, no registry change.

docs/abi.md section 3.1 is new and normative. The change narrows accepted
input, so it is not additive. The major is not bumped; the minor is
(13 -> 14), and 3.1 records that as a deliberate exception to section 2
together with its reason.

provenance.rs is re-pinned: all twelve exports refuse a sibling mask and a
mask of the other resource kind, every refusal leaves the mask and all
other outputs unchanged, lgj_hop is checked per mask, and the earlier
relabelling hazard is now a refusal. Four disable runs, four red.

Measured: native 212 tests; AllTests 617 checks; consumers 70 / 68 / 3 /
12; TinkerPop 25 + 55. bench/ not run.

Board: the scalar-terminal entries now say merged in #95.

Claude-Session: https://claude.ai/code/session_01XAqKMP36eRfzsppfaEWMVz
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