Skip to content

lance-graph-r2il: polyfill lens 0xFFFF::0xF000 binds by position; R2IL, SQL and Quack names are aliases - #1899

Merged
AdaWorldAPI merged 3 commits into
mainfrom
ccr-85acaff0-oszq40-poslens
Oct 31, 2026
Merged

AdaWorldAPI merged 3 commits into
mainfrom
ccr-85acaff0-oszq40-poslens

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Implements D-DT64-7 §1a/§1b (plan on #1898) for the relational polyfill.

The problem

binding::prepare turned an algebra word into an opcode by reading the view's label and searching R2ILVocabulary for that name. The module doc said it directly: "the position a lens gives a word is free and only the name binds".

What changed

  • New module polyfill. It defines POLYFILL_LENS = 0xFFFF_F000 (left side 0xFFFF = hardcoded, right side 0xF000 = the relational polyfill) and POLYFILL: 17 positions in EXECUTABLE order. Each position carries:
    • its opcode;
    • its arity;
    • its aliases: the R2IL name, a SQL name where one fits, and the Quack variant.
  • binding::prepare accepts this lens.
    • Under it, word p is POLYFILL[p], and the view's label at p must be one of p's aliases.
    • A name that belongs to another position is refused with the new ExecRefusal::NotAnAlias. It never selects that other word.
    • The R2IL fold reading (0xC401) keeps its label binding unchanged.
  • New dev-dependency on lance-graph-quack, used by the parity tests. Quack is OGAR-free and does not depend on this crate.

SQL via Quack

Quack has no SQL text parser. Its SQL surface is the typed Query { Filter, Agg }, so SQL registers through Quack's variant names. Methods registered by those names give exactly the same answers as Quack's own lower + mask-risc execute over the same lanes:

  • 21 cases: Cmp::LtI32 combined with each of Agg::{Count, Any, All, SumI32, MinI32, MaxI32, CountDistinctOrderedU32}, over a partial, a full and an empty selection.
  • One compound filter using Cmp::EqI32, Filter::negate and Filter::and.

The SQL keyword aliases (<, AND, COUNT, EXISTS, …) are recorded in the table, but no parser in the tree produces them yet.

Tests and disable runs

All tests are in tests/integration/polyfill.rs. Each guard was disabled once to confirm a test fails:

guard disabled tests failing
alias check 1
positional path, falling back to label binding 4
lens not accepted 5
SUM and MIN opcodes swapped 3
duplicate alias 1
table arity check 1

The table-arity disable was green at first, because registration already ties the argument count to the declared arity. A test with a wrong runtime declare_algebra now makes that check load-bearing.

Also checked: the table matches R2ILVocabulary (name, arity, one result); R2IL, SQL and Quack views bind the same steps and the same plan id.

Local gates: cargo test -p lance-graph-r2il (all suites), clippy --all-targets -D warnings and fmt are clean; entries_index, citation_decay and append_only_gate pass.

Not covered

  • Quack variants with no single executable word: Rows, BlendI32, ScatterOrU32, the Group* aggregates, Cmp::{Ne, Le, Gt, Ge}, the ternary matches, the strided compares and Range.
  • Empty selections: SUM, MIN and MAX return the fold identity where SQL returns NULL.
  • Still runtime-declared: the lens goes through declare_algebra and its opcodes are ogar-loco values. DT64 acting as the authority for 0xFFFF is a later item (D-DT64-7-4, O8).

Board entry: .claude/board/entries/2026-10-31-polyfill-positional-lens.md.


Generated by Claude Code

…ition

Hardcoded behaviour is addressed 0xFFFF::0xF### (D-DT64-7 §1a). The new
polyfill module fixes the relational polyfill as a positional lens: word
p is POLYFILL[p], and each position carries its aliases (the R2IL opcode
name, a SQL name where one fits, and the Quack variant).

binding::prepare accepts this lens beside the R2IL fold reading. Under it
the view's label at a position must be one of that position's aliases; a
name belonging to another position is refused (NotAnAlias), never
followed. The R2IL fold reading keeps its label binding unchanged.

Tests: the table matches R2ILVocabulary (names, arity, result) and the
EXECUTABLE order; every alias names one position; R2IL, SQL and Quack
views bind the same plan and plan id; methods registered by Quack names
answer exactly as Quack's own lowering does through mask-risc, over a
partial, a full and an empty selection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqKMNZqKXSaeb9g2ypywF
…ng runtime declaration

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

coderabbitai Bot commented Oct 31, 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: 8ee4d29c-5671-4885-b80c-f6e98c9d3533
  • 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 October 31, 2026 20:59
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 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-31T21:00:00.371176Z 7d58148 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 f7b0499 into main Oct 31, 2026
16 checks passed
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