Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .claude/board/LATEST_STATE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
## 2026-11-12 — ABI minor 14: a mask belongs to one resource (D-LGJ-MASK-PARENT-1, in a PR)
## 2026-11-12 — the toolchain mandate is a test (ToolchainMandateTest)

`ToolchainMandateTest` (new suite, needs no native library) checks at run time
what the compiler flags only imply: the JVM is 28 or later; `LaneId`, `MaskId`,
`Ordinal`, `FacetId`, `RowRange` and `WideFieldMask` are value classes
(`Class.isValue()`); the FFM linker is available; `java/src/main` has no JNI
entry point (`System.load*`, `native` method). CI already installs JDK 28 EA
through `actions/setup-java` and compiles with `--release 28 --enable-preview`.
Disable-verified: `LaneId` as a plain `record` turns the suite red.

## 2026-11-12 — ABI minor 14: a mask belongs to one resource (D-LGJ-MASK-PARENT-1, merged in #96)

Operator decision 2026-11-12: apply the same-parent rule to the nine mask
arguments that checked only the row count.
Expand Down
4 changes: 3 additions & 1 deletion java/src/test/java/com/adaworldapi/lancegraph/AllTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static void main(String[] args) {
Map<String, Consumer<Checks>> suites = new LinkedHashMap<>();
suites.put("ApiSurfaceTest", ApiSurfaceTest::run);
suites.put("DoctrineFenceTest", DoctrineFenceTest::run);
suites.put("ToolchainMandateTest", ToolchainMandateTest::run);
suites.put("AbiContractTest", AbiContractTest::run);
suites.put("SmokeTest", SmokeTest::run);
suites.put("FixtureParityTest", FixtureParityTest::run);
Expand All @@ -42,7 +43,8 @@ public static void main(String[] args) {
// before reporting the skip. They are exactly the checks most worth having before the
// artifact exists.
int shapeCode = 0;
for (String name : new String[] {"ApiSurfaceTest", "DoctrineFenceTest"}) {
for (String name : new String[] {
"ApiSurfaceTest", "DoctrineFenceTest", "ToolchainMandateTest"}) {
Consumer<Checks> suite = suites.get(name);
if (suite == null) {
// A renamed registry key must fail as a report, not as an NPE mid-loop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ private static void fenceBackendDiagnosticOnly(Checks c, List<Path> javaFiles) {
* Walk up from the working directory to the first ancestor that carries both trees the
* fences scan. Tests run from {@code java/} per the README, but the fence should not care.
*/
private static Path repoRoot() {
static Path repoRoot() {
Path p = Path.of("").toAbsolutePath();
for (int i = 0; i < 8 && p != null; i++, p = p.getParent()) {
if (Files.isDirectory(p.resolve("java/src/main/java"))
Expand All @@ -734,7 +734,7 @@ private static Path repoRoot() {
return null;
}

private static List<Path> sourcesUnder(Path root, String suffix) {
static List<Path> sourcesUnder(Path root, String suffix) {
try (Stream<Path> walk = Files.walk(root)) {
return walk.filter(p -> p.getFileName().toString().endsWith(suffix))
.filter(Files::isRegularFile)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package com.adaworldapi.lancegraph;

import java.io.IOException;
import java.lang.foreign.Linker;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

/**
* The toolchain this repository requires, checked at run time: JDK 28 or later, Valhalla value
* classes for the six vocabulary types, and Panama (FFM) as the only way across to native code.
*
* <p>The compiler already refuses an older JDK ({@code --release 28}) and refuses {@code value
* record} without {@code --enable-preview}. What it cannot refuse is a quiet retreat: a vocabulary
* type turned back into an identity record, or a JNI entry point added beside the FFM membrane.
* Both still compile. This suite is what fails then.
*
* <p>Needs no native library.
*/
public final class ToolchainMandateTest {

private ToolchainMandateTest() {}

private static final int MIN_FEATURE = 28;

/** The vocabulary types that must be value classes (root CLAUDE.md, "P0 — JDK 28"). */
private static final Class<?>[] VALUE_TYPES = {
LaneId.class, MaskId.class, Ordinal.class, FacetId.class, RowRange.class,
WideFieldMask.class,
};

/** JNI entry points: a library load outside FFM, or a {@code native} method declaration. */
private static final Pattern JNI =
Pattern.compile("System\\.load(Library)?\\s*\\(|\\bnative\\s+[\\w<>\\[\\].]+\\s+\\w+\\s*\\(");

public static void main(String[] args) {
System.out.println("ToolchainMandateTest");
Checks c = new Checks("ToolchainMandateTest");
run(c);
System.exit(c.report());
}

public static void run(Checks c) {
c.section("JDK");
int feature = Runtime.version().feature();
c.that("running on JDK " + feature + " >= " + MIN_FEATURE, feature >= MIN_FEATURE);

c.section("Valhalla");
for (Class<?> t : VALUE_TYPES) {
c.that(t.getSimpleName() + " is a value class", t.isValue());
}
// The check can fail: an identity class answers false.
c.that("an identity class is not reported as a value class", !Checks.class.isValue());

c.section("Panama");
c.that("the FFM native linker is available", Linker.nativeLinker() != null);
c.that("the JNI pattern matches a native method",
JNI.matcher(" private static native long open(long n);").find());
c.that("the JNI pattern matches a library load",
JNI.matcher("System.loadLibrary(\"lgj_abi\");").find());
c.that("the JNI pattern ignores prose", !JNI.matcher("one native crossing (bulk)").find());

Path repo = DoctrineFenceTest.repoRoot();
if (repo == null) {
c.that("the repository root was found, so the source scan ran", false);
return;
}
List<Path> files = DoctrineFenceTest.sourcesUnder(repo.resolve("java/src/main/java"), ".java");
c.that("the scan covers the production tree (" + files.size() + " files >= 20)",
files.size() >= 20);
List<String> hits = new ArrayList<>();
for (Path f : files) {
List<String> lines;
try {
lines = Files.readAllLines(f);
} catch (IOException e) {
hits.add(f + ": unreadable");
continue;
}
for (int i = 0; i < lines.size(); i++) {
String line = lines.get(i).strip();
if (line.startsWith("*") || line.startsWith("//") || line.startsWith("/*")) {
continue;
}
if (JNI.matcher(line).find()) {
hits.add(repo.relativize(f) + ":" + (i + 1));
}
}
}
c.that("no JNI entry point in java/src/main " + hits, hits.isEmpty());
}
}
Loading