implements PR-19.9 conformance fixtures diagnostics and gate closure

This commit is contained in:
2026-03-26 19:47:00 +00:00
parent 58c5ab26d7
commit 459f5e3b87
10 changed files with 322 additions and 12 deletions
@@ -3,6 +3,10 @@ package p.studio.compiler.backend.irvm;
import org.junit.jupiter.api.Test;
import p.studio.compiler.models.IRBackend;
import p.studio.compiler.models.IRBackendExecutableFunction;
import p.studio.compiler.models.IRGlobal;
import p.studio.compiler.models.IRSyntheticCallableKind;
import p.studio.compiler.models.IRSyntheticFunction;
import p.studio.compiler.models.IRSyntheticOrigin;
import p.studio.compiler.source.Span;
import p.studio.compiler.source.identifiers.CallableId;
import p.studio.compiler.source.identifiers.FileId;
@@ -62,6 +66,17 @@ class LowerToIRVMServiceTest {
final var backend = IRBackend.builder()
.entryPointCallableName("__pbs.frame_wrapper$m0")
.entryPointModuleId(new ModuleId(0))
.globals(ReadOnlyList.from(new IRGlobal(
new FileId(0),
new ModuleId(0),
"__pbs.boot_guard$m0",
"bool",
Span.none())))
.syntheticFunctions(ReadOnlyList.from(new IRSyntheticFunction(
new ModuleId(0),
"__pbs.frame_wrapper$m0",
IRSyntheticCallableKind.PUBLISHED_FRAME_WRAPPER,
new IRSyntheticOrigin(new FileId(0), "frame", new Span(new FileId(0), 1, 10)))))
.executableFunctions(ReadOnlyList.from(
fn("__pbs.file_init$f1", "app", 30, ReadOnlyList.from(ret())),
fn("__pbs.module_init$m0", "app", 31, ReadOnlyList.from(
@@ -95,6 +110,105 @@ class LowerToIRVMServiceTest {
.op());
}
@Test
void lowerMustRejectWhenSyntheticWrapperEntrypointIsMissing() {
final var backend = IRBackend.builder()
.entryPointCallableName("__pbs.frame_wrapper$m0")
.entryPointModuleId(new ModuleId(0))
.globals(ReadOnlyList.from(new IRGlobal(
new FileId(0),
new ModuleId(0),
"__pbs.boot_guard$m0",
"bool",
Span.none())))
.syntheticFunctions(ReadOnlyList.from(new IRSyntheticFunction(
new ModuleId(0),
"__pbs.frame_wrapper$m0",
IRSyntheticCallableKind.PUBLISHED_FRAME_WRAPPER,
new IRSyntheticOrigin(new FileId(0), "frame", new Span(new FileId(0), 1, 10)))))
.executableFunctions(ReadOnlyList.from(
fn("frame", "app", 20, ReadOnlyList.from(ret()))))
.build();
final var thrown = assertThrows(IRVMLoweringException.class, () -> new LowerToIRVMService().lower(backend));
assertEquals(IRVMLoweringErrorCode.LOWER_IRVM_SYNTHETIC_WRAPPER_ENTRYPOINT_MISSING, thrown.code());
}
@Test
void lowerMustRejectWhenPublishedWrapperWouldNotOccupyFunctionZero() {
final var backend = IRBackend.builder()
.entryPointCallableName("frame")
.entryPointModuleId(new ModuleId(0))
.globals(ReadOnlyList.from(new IRGlobal(
new FileId(0),
new ModuleId(0),
"__pbs.boot_guard$m0",
"bool",
Span.none())))
.syntheticFunctions(ReadOnlyList.from(new IRSyntheticFunction(
new ModuleId(0),
"__pbs.frame_wrapper$m0",
IRSyntheticCallableKind.PUBLISHED_FRAME_WRAPPER,
new IRSyntheticOrigin(new FileId(0), "frame", new Span(new FileId(0), 1, 10)))))
.executableFunctions(ReadOnlyList.from(
fn("__pbs.frame_wrapper$m0", "app", 40, ReadOnlyList.from(
callFunc("app", "frame", 20),
ret())),
fn("frame", "app", 20, ReadOnlyList.from(ret()))))
.build();
final var thrown = assertThrows(IRVMLoweringException.class, () -> new LowerToIRVMService().lower(backend));
assertEquals(IRVMLoweringErrorCode.LOWER_IRVM_PUBLISHED_ENTRYPOINT_NOT_ZERO, thrown.code());
}
@Test
void lowerMustRejectWhenHiddenBootGuardIsMissing() {
final var backend = IRBackend.builder()
.entryPointCallableName("__pbs.frame_wrapper$m0")
.entryPointModuleId(new ModuleId(0))
.syntheticFunctions(ReadOnlyList.from(new IRSyntheticFunction(
new ModuleId(0),
"__pbs.frame_wrapper$m0",
IRSyntheticCallableKind.PUBLISHED_FRAME_WRAPPER,
new IRSyntheticOrigin(new FileId(0), "frame", new Span(new FileId(0), 1, 10)))))
.executableFunctions(ReadOnlyList.from(
fn("__pbs.frame_wrapper$m0", "app", 40, ReadOnlyList.from(
callFunc("app", "frame", 20),
ret())),
fn("frame", "app", 20, ReadOnlyList.from(ret()))))
.build();
final var thrown = assertThrows(IRVMLoweringException.class, () -> new LowerToIRVMService().lower(backend));
assertEquals(IRVMLoweringErrorCode.LOWER_IRVM_HIDDEN_BOOT_GUARD_MISSING, thrown.code());
}
@Test
void lowerMustRejectWhenSyntheticCallableOriginIsMissing() {
final var backend = IRBackend.builder()
.entryPointCallableName("__pbs.frame_wrapper$m0")
.entryPointModuleId(new ModuleId(0))
.globals(ReadOnlyList.from(new IRGlobal(
new FileId(0),
new ModuleId(0),
"__pbs.boot_guard$m0",
"bool",
Span.none())))
.syntheticFunctions(ReadOnlyList.from(new IRSyntheticFunction(
new ModuleId(0),
"__pbs.frame_wrapper$m0",
IRSyntheticCallableKind.PUBLISHED_FRAME_WRAPPER,
new IRSyntheticOrigin(new FileId(0), "", Span.none()))))
.executableFunctions(ReadOnlyList.from(
fn("__pbs.frame_wrapper$m0", "app", 40, ReadOnlyList.from(
callFunc("app", "frame", 20),
ret())),
fn("frame", "app", 20, ReadOnlyList.from(ret()))))
.build();
final var thrown = assertThrows(IRVMLoweringException.class, () -> new LowerToIRVMService().lower(backend));
assertEquals(IRVMLoweringErrorCode.LOWER_IRVM_SYNTHETIC_ORIGIN_MISSING, thrown.code());
}
@Test
void lowerMustMapHostAndIntrinsicCallsites() {
final var backend = IRBackend.builder()
@@ -13,9 +13,9 @@ import static org.junit.jupiter.api.Assertions.fail;
class BackendClaimScopeSpecTest {
private static final String LOWERING_SPEC_RELATIVE_PATH =
"docs/compiler/general/specs/20. IRBackend to IRVM Lowering Specification.md";
"docs/specs/compiler/20. IRBackend to IRVM Lowering Specification.md";
private static final String MATRIX_RELATIVE_PATH =
"docs/compiler/general/specs/22. Backend Spec-to-Test Conformance Matrix.md";
"docs/specs/compiler/22. Backend Spec-to-Test Conformance Matrix.md";
private static final String DECISION_RELATIVE_PATH =
"docs/compiler/pbs/decisions/SPAWN-YIELD v1 Claim Rescope Decision.md";
@@ -63,7 +63,7 @@ class BackendClaimScopeSpecTest {
private Path locateRepoRoot() {
var cursor = Path.of(System.getProperty("user.dir")).toAbsolutePath().normalize();
while (cursor != null) {
final var hasDocs = Files.isDirectory(cursor.resolve("docs/compiler/general/specs"));
final var hasDocs = Files.isDirectory(cursor.resolve("docs/specs/compiler"));
final var hasCompiler = Files.isDirectory(cursor.resolve("prometeu-compiler"));
if (hasDocs && hasCompiler) {
return cursor;
@@ -14,7 +14,7 @@ import static org.junit.jupiter.api.Assertions.*;
class BackendConformanceMatrixSpecTest {
private static final String MATRIX_RELATIVE_PATH =
"docs/compiler/general/specs/22. Backend Spec-to-Test Conformance Matrix.md";
"docs/specs/compiler/22. Backend Spec-to-Test Conformance Matrix.md";
private static final String MATRIX_HARD_GATE_ENV = "PROMETEU_MATRIX_HARD_GATE";
private static final String CHANGED_FILES_ENV = "PROMETEU_CHANGED_FILES";
private static final List<String> HARD_GATE_PATH_PREFIXES = List.of(
@@ -158,8 +158,9 @@ class BackendConformanceMatrixSpecTest {
var cursor = Path.of(System.getProperty("user.dir")).toAbsolutePath().normalize();
while (cursor != null) {
final var hasDocs = Files.isDirectory(cursor.resolve("docs/compiler/general/specs"));
final var hasCurrentDocs = Files.isDirectory(cursor.resolve("docs/specs/compiler"));
final var hasCompiler = Files.isDirectory(cursor.resolve("prometeu-compiler"));
if (hasDocs && hasCompiler) {
if ((hasDocs || hasCurrentDocs) && hasCompiler) {
return cursor;
}
cursor = cursor.getParent();
@@ -62,7 +62,7 @@ class NoModuleKeyRegressionSpecTest {
private Path locateRepoRoot() {
var cursor = Path.of(System.getProperty("user.dir")).toAbsolutePath().normalize();
while (cursor != null) {
final var hasDocs = Files.isDirectory(cursor.resolve("docs/compiler/general/specs"));
final var hasDocs = Files.isDirectory(cursor.resolve("docs/specs/compiler"));
final var hasCompiler = Files.isDirectory(cursor.resolve("prometeu-compiler"));
if (hasDocs && hasCompiler) {
return cursor;