Skip to content

Core interop round 4: read-eval, j.u.c construction, prefix lists, dotted protocol names - #703

Merged
yogthos merged 7 commits into
mainfrom
fix/grain-core-round4
Aug 22, 2026
Merged

yogthos merged 7 commits into
mainfrom
fix/grain-core-round4

Conversation

@yogthos

@yogthos yogthos commented Aug 22, 2026

Copy link
Copy Markdown
Member

Reopened against main — this was #701, which GitHub closed when its base branch was deleted on #697's merge. Same commits, same validation.

Round 4 of the Grain gap audit (epic jolt-o3sw). Four gaps, two of them general bugs that real libraries hit:

  • #= read-eval, gated by *read-eval* as on the JVM (EDN still rejects it). clj-uuid uses about twenty of them.
  • java.util.concurrent construction — ArrayBlockingQueue, FutureTask, ThreadPoolExecutor. The machinery existed; only the constructors were missing. getQueue returns a real depth view. One documented divergence: a full queue blocks rather than rejecting, since jolt models no rejection policy.
  • Vector-spelled require prefix lists. (:require [clj-uuid [bitmop :as bitmop]]) was read as a self-require and silently dropped every alias in the list — the list spelling worked, the vector spelling did not. Fixed in the one shared expander so the loader, the analyzer, and the corpus environment's alias-only path all agree.
  • A deftype/reify naming a protocol by its dotted class spelling ((deftype T [] my.ns.PThing (m [_] …))) resolves to the protocol like the JVM. The methods used to file as interface methods and dispatch answered "No method …". Found running μ/log's publishers.

Plus java.nio.charset.StandardCharsets.

Validation

  • 31 new corpus rows, each certified against JVM Clojure 1.12.5 by the certify gate
  • make test green, 0 new divergences
  • make gambitgen re-run for the records change; gambitseedcheck passes

Yogthos added 7 commits August 22, 2026 13:39
The clojure reader's EvalReader: #=form reads its form and evaluates it on the
spot (clj-uuid computes its bit masks with #= about twenty times), refusing
under (binding [*read-eval* false] ...) with the JVM's message. EDN still has
no = dispatch. The eval entry point and the var cell live in later-loaded
files and resolve at call time; a load interleaves read and eval per top-level
form, so earlier requires are visible to a #= in a later form. The known
divergence entry for '#= is inert data' is retired (jolt-o3sw.10).
The shapes Grain's SQLite write coordinator constructs directly.
ArrayBlockingQueue is a real bounded blocking queue (offer/put/take/poll with
the timed variants, fiber-aware through jolt-cv-wait; take answers (v . #t)
internally so a false element stays distinct from a timeout). FutureTask is a
run-once task with a blocking get; cancel wins only before run starts (the JVM
can interrupt a running task, jolt cannot). The ThreadPoolExecutor ctor builds
on make-executor, sized by maximumPoolSize, keepAlive/factory/handler accepted
and ignored; submit/execute route a FutureTask through its own run. .getQueue
answers a live VIEW of the executor's internal queue — real depth, capacity
from the ctor's queue argument — because tasks flow through the executor's own
unbounded queue: the JVM rejects a submit when the bounded queue fills, jolt
queues it, and that is the documented divergence. 12 corpus rows certified on
OpenJDK 20 (jolt-o3sw.9).
[clj-uuid [bitmop :as bitmop] [clock :as clock] ...] is a prefix list on the
JVM — a vector is a single libspec only when its second element is a keyword
or absent. The old single-libspec read required the PREFIX itself, which for
clj-uuid meant a silent self-require mid-load with every sub-spec and alias
dropped, and 'Unknown class bitmop' at the first qualified call. The expansion
now lives in ns.ss (expand-libspec) shared by the loader's expand-spec, the
build driver, and compile-eval's alias pre-scan — the pre-scan and the gates'
alias-only require missed prefix lists in both spellings before this.
The constants ARE the charset name strings, which every jolt charset seam
(.getBytes, String ctors, stream readers) takes — so the constant composes
with all of them. clj-uuid's v3/v5 digest path calls
(.getBytes s StandardCharsets/UTF_8).
A deftype/reify may name a protocol by its class — mulog's ConsolePublisher
implements com.brunobonacci.mulog.publisher.PPublisher — and the JVM resolves
that to the protocol. protocol-key-of only tried the symbol as a var
reference, so the dotted spelling filed the methods as interface methods and
protocol dispatch answered 'No method publish-delay'. On a miss it now reads
the last segment as the name and the demunged prefix as the namespace and
looks the protocol var up there. Found running mulog under jolt-o3sw.12.
@yogthos
yogthos merged commit 42c86bf into main Aug 22, 2026
9 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.

1 participant