Conversation
… model Research on the Bend 2 language (released 2026-09-17): what it is, how it is used, and where it could fit around Arrow, Flight and Flight SQL. dev/bend2/README.md holds the notes. dev/bend2/prepared_statement/ is a Bend 2 model of the Flight SQL prepared-statement lifecycle with five laws (closed handles never execute, created handles do execute, stale handles after a bind are rejected, and a freshness invariant that holds at start and is kept by every request). `bend PROOF.bend` checks it in 0.2 s and rejects three injected bugs; the model also compiles to JS and to a native binary. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015wBzfARVa1g7nkB1muT5Sj
Turn the prepared-statement model into a test oracle for the Java
servers. The model gains the bind policy the spec allows ("may return
an updated handle"): rotate or keep, with a sixth law that a kept
handle still executes. traces.bend enumerates 1085 request sequences,
runs them through the proven model under both policies and prints the
expected response to each request; the output is committed as a test
resource so the Java build needs no Bend toolchain.
TestFlightSqlBendConformance replays every trace against
FlightSqlExample (keep column) and FlightSqlStatelessExample (rotate
column) through the raw Flight client and compares success or error
per request. The stateful example matches on all 4221 steps. The
stateless example deviates in three documented categories, kept as a
known-deviation set so the test fails on a fix or a regression:
executing or binding stale and closed handles succeeds, and binding a
rotated handle again fails.
dev/bend2/DIFFERENTIAL_TESTING.md explains the chain of trust, the
pieces, the results and the limits; the research notes are updated.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015wBzfARVa1g7nkB1muT5Sj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's Changed
Research on the Bend 2 programming language (released 2026-09-17) and where it could be applied around Arrow, Arrow Flight and Flight SQL; a proven Bend 2 model of the Flight SQL prepared-statement lifecycle; and a JUnit test that uses that model as an oracle to validate the two example Flight SQL servers. No production Java code or build changes.
dev/bend2/README.mdResearch notes covering what Bend 2 is (dependently typed, affine,
LAWS.bend/PROOF.bendchecked on every build, C/CUDA/Metal/JS targets), its type theory and trust model, tooling, stated limitations, how to run it, what proving costs in practice, and an assessment of where it fits with Arrow:dev/bend2/prepared_statement/A Bend 2 model of the Flight SQL prepared-statement lifecycle (
main.bend) with six laws (LAWS.bend) and their proofs (PROOF.bend). The spec says a server "may return an updated handle" on bind, so the model takes a policy flag: rotate the handle (stateless style) or keep it.closed_never_executes: afterClosePreparedStatement, executing the handle is an error, under either policy.created_handle_executes: the handle returned by create executes (anti-vacuity).stale_handle_rejected: under rotation, after aDoPutbind rotates the handle, the old handle is rejected, per the spec's "the server is responsible for detecting the case where the client does not use the updated handle and should return an error".kept_handle_executes: under the keeping policy, a bound handle still executes.fresh_start,fresh_kept: all live handles stay below the issue counter at start and after every request, so the stale-handle law covers every reachable state.bend PROOF.bendprintsAll terms check.in about 0.2 s. Three injected bugs (bind keeps the old handle live, close is a no-op, counter not advanced on create) each make the check fail. The model compiles to JavaScript and to a native binary.Differential conformance test (
dev/bend2/DIFFERENTIAL_TESTING.md)The laws only constrain the Bend model, so a bridge to Java was built:
traces.bendenumerates 1085 request sequences (all of length 1 to 3 over create, bind, execute and close on two handle ids, plus longer ones starting with create), runs them through the proven model under both policies, and prints the expected response per request. The output is committed atflight/flight-sql/src/test/resources/bend2/prepared_statement_traces.txt, so the Java build needs no Bend toolchain.TestFlightSqlBendConformancereplays every trace againstFlightSqlExample(keep column) andFlightSqlStatelessExample(rotate column) through the rawFlightClient, mapping the model's handle ids to the bytes each server issues, and compares success or error per request. Deviations are bucketed by category and each server carries a documented known-deviation set; the test fails if a category appears or disappears.Results:
FlightSqlExample(stateful)FlightSqlStatelessExampleThe stateless example encodes the query into the handle and validates nothing server-side, so it executes and binds stale and closed handles (the spec says the server "should return an error"), and it fails to bind a rotated handle a second time because it parses the rotated bytes as SQL (the spec allows chaining
DoPuthandles). These are recorded in the test as known deviations with the reason for each.The document explains the chain of trust (spec sentence to law, law to proof, proof to generated expectations, expectations to replay), what the test does and does not establish, and how to extend it to other servers and to the other models.
Follow-up proofs of concept for transactions and savepoints, IPC stream ordering, buffer reference counting and PollFlightInfo are being prepared as separate PRs.
🤖 Generated with Claude Code
https://claude.ai/code/session_015wBzfARVa1g7nkB1muT5Sj