feat(compiler): port runtime catalogs and enforce target ABI (AGD77)
Import both runtime catalogs and provenance, port all intrinsic metadata and exact constants, and validate target signatures and carriers through the common pipeline. Package matching compiler/SDK resources and add active parity plus production runtime conformance checks. Validation: 420 compiler/PBS tests passed, with 12 existing skips; provider export, runtime execution and installed catalog checks passed. The pre-existing Gfx.clear typed-metadata failure remains active and assigned to AGD78 under the explicitly accepted scope revision recorded in LSN-0080.
This commit is contained in:
@@ -19,6 +19,8 @@ public final class InstalledKnowledgeProbe {
|
||||
check(provider.getClass().getProtectionDomain().getCodeSource().getLocation().getPath().endsWith(".jar"), "Frontend must come from installed JAR");
|
||||
check(CompilerProjectKnowledge.class.getProtectionDomain().getCodeSource().getLocation().getPath().endsWith(".jar"), "App must come from installed JAR");
|
||||
check(!Files.exists(Path.of("settings.gradle.kts")) && !Files.exists(Path.of("docs")), "No repository in working directory");
|
||||
verifyRuntimeCatalogs(provider.getClass().getClassLoader());
|
||||
if (arguments.length == 1 && arguments[0].equals("--catalog-only")) return;
|
||||
Path root = Files.createDirectory(Path.of("example")).toRealPath();
|
||||
var docs = provider.documentation().orElseThrow().references(1, p.studio.AppMode.Game);
|
||||
for (var reference : docs) {
|
||||
@@ -49,7 +51,7 @@ public final class InstalledKnowledgeProbe {
|
||||
check(actual.toString().equals(reference.text()), "Incorrect installed reference: " + reference.id());
|
||||
}
|
||||
var result = BuilderPipelineService.INSTANCE.compile(
|
||||
BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, root.toString())), LogAggregator.empty());
|
||||
BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, root.toString())), LogAggregator.stdout());
|
||||
check(result.diagnostics().stream().noneMatch(issue -> issue.isError()), "Example must compile without errors");
|
||||
check(result.bytecodeBytes().length > 0, "Example must produce bytecode");
|
||||
verifyExternalSources(provider.getClass().getClassLoader());
|
||||
@@ -61,6 +63,30 @@ public final class InstalledKnowledgeProbe {
|
||||
if (!condition) throw new AssertionError(message);
|
||||
}
|
||||
|
||||
private static void verifyRuntimeCatalogs(ClassLoader loader) throws Exception {
|
||||
var names = java.util.List.of("INTRINSICS.csv", "BUILTIN_CONSTANTS.csv", "runtime-catalog.properties");
|
||||
var compiler = new java.util.HashMap<String, byte[]>();
|
||||
for (var name : names) {
|
||||
for (var owner : java.util.List.of("compiler", "pbs-sdk")) {
|
||||
var resource = loader.getResource("runtime-catalog/" + owner + "/" + name);
|
||||
check(resource != null && resource.getProtocol().equals("jar"), "Missing installed catalog: " + owner + "/" + name);
|
||||
try (var stream = resource.openStream()) {
|
||||
var bytes = stream.readAllBytes();
|
||||
if (owner.equals("compiler")) compiler.put(name, bytes);
|
||||
else check(java.util.Arrays.equals(compiler.get(name), bytes), "Compiler/SDK contract mismatch: " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
var properties = new java.util.Properties();
|
||||
properties.load(new java.io.ByteArrayInputStream(compiler.get("runtime-catalog.properties")));
|
||||
check(properties.getProperty("runtime.revision").matches("[0-9a-f]{40}"), "Missing target revision");
|
||||
for (var name : names.subList(0, 2)) {
|
||||
var digest = java.util.HexFormat.of().formatHex(java.security.MessageDigest.getInstance("SHA-256").digest(compiler.get(name)));
|
||||
check(digest.equals(properties.getProperty(name + ".sha256")), "Packaged catalog hash mismatch: " + name);
|
||||
}
|
||||
System.out.println("Installed compiler/SDK catalog identity verified: " + properties.getProperty("runtime.revision"));
|
||||
}
|
||||
|
||||
private static void verifyExternalSources(ClassLoader loader) throws Exception {
|
||||
var resource = loader.getResource("game/stdlib/1/sdk/gfx/main.pbs");
|
||||
check(resource != null && resource.getProtocol().equals("jar"), "SDK must be read from a JAR URL");
|
||||
|
||||
@@ -12,6 +12,17 @@ class InstalledKnowledgeTest {
|
||||
@TempDir Path outsideRepository;
|
||||
|
||||
@Test void installedJarsProvideAllReferencesAndCompileTheExampleOutsideTheCheckout() throws Exception {
|
||||
String log = runProbe();
|
||||
assertTrue(log.contains("references; example compiled"), log);
|
||||
assertTrue(log.contains("Packaged external sources verified"), log);
|
||||
}
|
||||
|
||||
@Test void installedCompilerAndSdkCarryTheSameVerifiedCatalog() throws Exception {
|
||||
String log = runProbe("--catalog-only");
|
||||
assertTrue(log.contains("Installed compiler/SDK catalog identity verified"), log);
|
||||
}
|
||||
|
||||
private String runProbe(String... arguments) throws Exception {
|
||||
Path distribution = Path.of(System.getProperty("studio.test.distribution"));
|
||||
String jars;
|
||||
try (var files = Files.list(distribution.resolve("lib"))) {
|
||||
@@ -20,15 +31,16 @@ class InstalledKnowledgeTest {
|
||||
}
|
||||
String probeClasses = Path.of(InstalledKnowledgeProbe.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
|
||||
Path output = outsideRepository.resolve("probe.log");
|
||||
var process = new ProcessBuilder(distribution.resolve("runtime/bin/java").toString(),
|
||||
"-cp", jars + java.io.File.pathSeparator + probeClasses, InstalledKnowledgeProbe.class.getName())
|
||||
var command = new java.util.ArrayList<>(java.util.List.of(distribution.resolve("runtime/bin/java").toString(),
|
||||
"-cp", jars + java.io.File.pathSeparator + probeClasses, InstalledKnowledgeProbe.class.getName()));
|
||||
command.addAll(java.util.List.of(arguments));
|
||||
var process = new ProcessBuilder(command)
|
||||
.directory(outsideRepository.toFile()).redirectErrorStream(true).redirectOutput(output.toFile()).start();
|
||||
try {
|
||||
assertTrue(process.waitFor(45, TimeUnit.SECONDS), "Installed knowledge probe timed out");
|
||||
String log = Files.readString(output);
|
||||
assertEquals(0, process.exitValue(), log);
|
||||
assertTrue(log.contains("references; example compiled"), log);
|
||||
assertTrue(log.contains("Packaged external sources verified"), log);
|
||||
return log;
|
||||
} finally { if (process.isAlive()) process.destroyForcibly().waitFor(); }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user