feat(studio): improve compiler reliability and AI diagnostics
Preserve structured diagnostics, source attribution, phase outcomes and revision context through compiler, Studio, LSP, MCP and JavaFX. Add project service discovery and resilient VS Code reconnection. Correct all eight reproduced PBS production failures in expression context, sibling executable bindings and nominal owner identity. Consolidate specs, lessons, immutable baseline evidence and the maintained source-to-guest qualification runner. Validation: required Gradle gate recorded 724 tests, with 711 passed and 13 skipped. Full corpus passed 168 compilation observations and 108 guest runs (104 successes and four deliberate faults); supplemental controls passed 42 compilations and 16 guest runs. TypeScript compilation, two Node discovery tests and discussion validation passed.
This commit is contained in:
@@ -113,6 +113,47 @@ class DevDesktopTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test void explainedDiagnosticPaneExpandsFactsAndOpensCurrentReadOnlySource() throws Exception {
|
||||
var source = root.resolve("main.pbs"); Files.writeString(source, "fn x() {}\n");
|
||||
var digest = java.util.HexFormat.of().formatHex(java.security.MessageDigest.getInstance("SHA-256").digest(Files.readAllBytes(source)));
|
||||
var value = new java.util.LinkedHashMap<>(p.studio.utilities.json.DiagnosticPayloads.issue("TEST_EXPLAINED", "ERROR", "Recorded detector failure"));
|
||||
value.put("checkId", "compiler.verify.ret-stack-height");
|
||||
value.put("explanation", java.util.Map.of("availability", "available", "summary", "RET must match the declared result slot count."));
|
||||
value.put("facts", java.util.Map.of("expectedHeight", 0, "actualHeight", 1));
|
||||
value.put("origin", java.util.Map.of("uri", source.toUri().toString(), "revision", digest, "range", java.util.Map.of("start", java.util.Map.of("line", 0, "character", 3), "end", java.util.Map.of("line", 0, "character", 4))));
|
||||
var pane = new p.studio.ui.javafx.diagnostics.DiagnosticResultsPane[1]; var window = new Stage[1];
|
||||
try {
|
||||
fx(() -> {
|
||||
pane[0] = new p.studio.ui.javafx.diagnostics.DiagnosticResultsPane(root);
|
||||
var view = p.studio.utilities.json.DiagnosticPayloads.view(java.util.List.of(value), "build", "failed", java.util.List.of(), "partial");
|
||||
pane[0].show(java.util.Map.of("issues", view.issues(), "summary", view.summary(), "context", java.util.Map.of()));
|
||||
window[0] = new Stage(); window[0].setTitle("Explained diagnostics desktop qualification");
|
||||
var scroll = new ScrollPane(pane[0]); scroll.setFitToWidth(true);
|
||||
window[0].setScene(new Scene(scroll, 1050, 900)); window[0].show();
|
||||
pane[0].getChildren().stream().filter(n -> n instanceof TitledPane).map(n -> (TitledPane)n).findFirst().orElseThrow().setExpanded(true); pane[0].applyCss(); pane[0].layout();
|
||||
var body = (VBox)pane[0].getChildren().stream().filter(n -> n instanceof TitledPane).map(n -> (TitledPane)n).findFirst().orElseThrow().getContent();
|
||||
assertTrue(body.getChildren().stream().filter(n -> n instanceof Label).anyMatch(n -> ((Label)n).getText().contains("RET")));
|
||||
body.getChildren().stream().filter(n -> n instanceof TitledPane && ((TitledPane)n).getText().equals("facts")).map(n -> (TitledPane)n).forEach(n -> n.setExpanded(true));
|
||||
pane[0].applyCss(); pane[0].layout();
|
||||
var image = window[0].getScene().snapshot(null); var pixels = image.getPixelReader();
|
||||
var buffer = new java.awt.image.BufferedImage((int)image.getWidth(), (int)image.getHeight(), java.awt.image.BufferedImage.TYPE_INT_ARGB);
|
||||
for (int y=0; y<buffer.getHeight(); y++) for (int x=0; x<buffer.getWidth(); x++) buffer.setRGB(x,y,pixels.getArgb(x,y));
|
||||
try { var path = Path.of("build/diagnostic-qualification/diagnostic-desktop.png"); Files.createDirectories(path.getParent()); javax.imageio.ImageIO.write(buffer,"png",path.toFile()); }
|
||||
catch (Exception error) { throw new RuntimeException(error); }
|
||||
body.getChildren().stream().filter(n -> n instanceof Button && ((Button)n).getText().equals("Open source")).map(n -> (Button)n).findFirst().orElseThrow().fire();
|
||||
});
|
||||
long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(5); var opened = new java.util.concurrent.atomic.AtomicBoolean();
|
||||
while (!opened.get() && System.nanoTime() < deadline) {
|
||||
fx(() -> { for (var visible : javafx.stage.Window.getWindows()) if (visible instanceof Stage stage && stage.getTitle().startsWith("Current source")) {
|
||||
var viewer = (TextArea)((VBox)stage.getScene().getRoot()).getChildren().get(1);
|
||||
assertFalse(viewer.isEditable()); assertEquals("x", viewer.getSelectedText()); opened.set(true);
|
||||
} });
|
||||
if (!opened.get()) Thread.sleep(10);
|
||||
}
|
||||
assertTrue(opened.get(), "Source viewer opened with verified revision and selection");
|
||||
} finally { fx(() -> { for (var visible : java.util.List.copyOf(javafx.stage.Window.getWindows())) visible.hide(); }); }
|
||||
}
|
||||
|
||||
@Test void formsSaveFailurePreservesDraftAndReturnReadsExternalContent() throws Exception {
|
||||
var file = root.resolve("document.txt"); Files.writeString(file, "initial");
|
||||
fx(() -> {
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package p.studio.app.compiler.fixture;
|
||||
|
||||
import p.studio.compiler.models.FrontendSpec;
|
||||
import p.studio.compiler.services.FrontendPhaseService;
|
||||
import p.studio.compiler.services.FrontendProvider;
|
||||
import p.studio.utilities.structures.ReadOnlySet;
|
||||
|
||||
public final class ControlledIrFrontend implements FrontendProvider {
|
||||
public static final String LANGUAGE_ID = "controlled-ir";
|
||||
|
||||
private final FrontendSpec specification = FrontendSpec.builder()
|
||||
.languageId(LANGUAGE_ID)
|
||||
.allowedExtensions(ReadOnlySet.from("synth"))
|
||||
.sourceRoots(ReadOnlySet.from("src"))
|
||||
.build();
|
||||
private final ControlledIrPhase compiler;
|
||||
|
||||
public ControlledIrFrontend() { this(false); }
|
||||
|
||||
public ControlledIrFrontend(boolean invalidRet) { this(invalidRet, false); }
|
||||
public ControlledIrFrontend(boolean invalidRet, boolean noInstructionOrigin) { compiler = new ControlledIrPhase(invalidRet, noInstructionOrigin); }
|
||||
|
||||
@Override
|
||||
public FrontendSpec specification() {
|
||||
return specification;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FrontendPhaseService compiler() {
|
||||
return compiler;
|
||||
}
|
||||
|
||||
public ControlledIrPhase syntheticCompiler() {
|
||||
return compiler;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package p.studio.app.compiler.fixture;
|
||||
|
||||
import p.studio.compiler.messages.BuildingIssueSink;
|
||||
import p.studio.compiler.messages.FrontendPhaseContext;
|
||||
import p.studio.compiler.models.IRBackend;
|
||||
import p.studio.compiler.models.IRBackendExecutableFunction;
|
||||
import p.studio.compiler.models.IRLifecycleCallableReference;
|
||||
import p.studio.compiler.models.IRLifecycleCallableRole;
|
||||
import p.studio.compiler.models.IRLifecycleDeclaration;
|
||||
import p.studio.compiler.models.IRLifecycleModuleDeclaration;
|
||||
import p.studio.compiler.services.FrontendPhaseService;
|
||||
import p.studio.compiler.source.Span;
|
||||
import p.studio.compiler.source.diagnostics.DiagnosticSink;
|
||||
import p.studio.compiler.source.identifiers.CallableId;
|
||||
import p.studio.compiler.source.identifiers.FileId;
|
||||
import p.studio.compiler.source.identifiers.ModuleId;
|
||||
import p.studio.compiler.source.tables.CallableSignatureRef;
|
||||
import p.studio.compiler.source.tables.ModuleReference;
|
||||
import p.studio.utilities.logs.LogAggregator;
|
||||
import p.studio.utilities.structures.ReadOnlyList;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
final class ControlledIrPhase implements FrontendPhaseService {
|
||||
private final AtomicBoolean invoked = new AtomicBoolean();
|
||||
private final boolean invalidRet;
|
||||
private final boolean noInstructionOrigin;
|
||||
|
||||
public ControlledIrPhase() { this(false); }
|
||||
|
||||
public ControlledIrPhase(boolean invalidRet) { this(invalidRet, false); }
|
||||
public ControlledIrPhase(boolean invalidRet, boolean noInstructionOrigin) { this.invalidRet = invalidRet; this.noInstructionOrigin = noInstructionOrigin; }
|
||||
|
||||
public boolean invoked() {
|
||||
return invoked.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRBackend compile(
|
||||
final FrontendPhaseContext request,
|
||||
final DiagnosticSink diagnostics,
|
||||
final LogAggregator logs,
|
||||
final BuildingIssueSink issues) {
|
||||
invoked.set(true);
|
||||
for (var id : request.fileTable.identifiers()) request.fileTable.get(id).readBytes();
|
||||
|
||||
final var moduleId = new ModuleId(0);
|
||||
final var fileId = new FileId(0);
|
||||
final var callableId = new CallableId(0);
|
||||
final var span = new Span(fileId, 0, 1);
|
||||
final var operationSpan = noInstructionOrigin ? Span.none() : span;
|
||||
var instructions = new java.util.ArrayList<IRBackendExecutableFunction.Instruction>();
|
||||
if (!invalidRet) {
|
||||
instructions.add(new IRBackendExecutableFunction.Instruction(IRBackendExecutableFunction.InstructionKind.PUSH_I32, ModuleId.none(), "", null, null, null, "1", null, null, null, operationSpan));
|
||||
instructions.add(new IRBackendExecutableFunction.Instruction(IRBackendExecutableFunction.InstructionKind.JMP_IF_TRUE, ModuleId.none(), "", null, null, null, null, "join", null, null, operationSpan));
|
||||
}
|
||||
instructions.add(new IRBackendExecutableFunction.Instruction(
|
||||
IRBackendExecutableFunction.InstructionKind.PUSH_I32, ModuleId.none(), "", null, null, null, "1", null, null, null, operationSpan));
|
||||
if (!invalidRet) instructions.add(new IRBackendExecutableFunction.Instruction(IRBackendExecutableFunction.InstructionKind.LABEL, ModuleId.none(), "", null, null, null, "join", null, null, null, operationSpan));
|
||||
instructions.add(new IRBackendExecutableFunction.Instruction(IRBackendExecutableFunction.InstructionKind.RET,
|
||||
"", null, null, operationSpan));
|
||||
final var frame = new IRBackendExecutableFunction(
|
||||
fileId,
|
||||
moduleId,
|
||||
"frame",
|
||||
callableId,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
ReadOnlyList.wrap(instructions),
|
||||
span);
|
||||
final var frameRoot = new IRLifecycleCallableReference(
|
||||
moduleId,
|
||||
fileId,
|
||||
callableId,
|
||||
IRLifecycleCallableRole.FRAME_ROOT,
|
||||
span);
|
||||
|
||||
return IRBackend.builder()
|
||||
.entryPointCallableName("frame")
|
||||
.entryPointModuleId(moduleId)
|
||||
.modulePool(ReadOnlyList.from(new ModuleReference("synth", ReadOnlyList.from("main"))))
|
||||
.callableSignatures(ReadOnlyList.from(
|
||||
new CallableSignatureRef(moduleId, "frame", 0, "() -> unit")))
|
||||
.executableFunctions(ReadOnlyList.from(frame))
|
||||
.lifecycleDeclaration(new IRLifecycleDeclaration(
|
||||
ReadOnlyList.from(new IRLifecycleModuleDeclaration(moduleId, ReadOnlyList.empty())),
|
||||
null,
|
||||
frameRoot))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -98,6 +98,15 @@ class AutomationLspQueriesTest {
|
||||
assertTrue(symbols.toString().contains("renamed"), symbols.toString());
|
||||
assertFalse(symbols.toString().contains("helper"), symbols.toString());
|
||||
}
|
||||
@Test void validEmptyDocumentIsSuccessfulEvaluatedAnalysis() throws Exception {
|
||||
Files.writeString(source, "");
|
||||
Files.writeString(source.resolveSibling("mod.barrel"), "pub fn frame() -> void;\n");
|
||||
Files.writeString(source.resolveSibling("frame.pbs"), "[Frame] fn frame() -> void {}\n"); acquire();
|
||||
var reply = query("diagnostics", Map.of("uri", source.toUri().toString()));
|
||||
assertTrue(reply.path("result").isEmpty(), reply.toString()); assertTrue(reply.path("analysis").path("issues").isEmpty(), reply.toString());
|
||||
assertEquals("passed", reply.path("analysis").path("summary").path("validationStatus").asText());
|
||||
assertEquals(0, reply.path("analysis").path("summary").path("counts").path("errors").asInt());
|
||||
}
|
||||
@Test void proposalsDoNotWriteFilesAndQueriesCoverAdvertisedOperations() throws Exception {
|
||||
acquire();
|
||||
for (String operation : List.of("hover", "completion", "signatureHelp", "references", "prepareRename", "semanticTokens"))
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
package p.studio.app.lsp;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import p.studio.api.automation.*;
|
||||
import p.studio.app.operation.ExecutorOperationExecutor;
|
||||
import p.studio.core.language.*;
|
||||
import p.studio.core.project.*;
|
||||
import p.studio.core.session.DefaultAutomationSession;
|
||||
import p.studio.app.compiler.CompilerProjectKnowledge;
|
||||
import p.studio.lsp.api.LspServerLifecycle;
|
||||
import p.studio.lsp.messages.*;
|
||||
import p.studio.lsp.services.protocol.ExternalSourceLanguageServer;
|
||||
import org.eclipse.lsp4j.*;
|
||||
import org.eclipse.lsp4j.jsonrpc.*;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.ResponseError;
|
||||
import java.net.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.*;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/** Controlled protocol faults use real sockets; the stubborn child is an explicitly injected port. */
|
||||
class LanguageFailureContractTest {
|
||||
@TempDir Path root;
|
||||
@Test void protocolMechanismsBecomeNeutralFailuresAndLegacyFallbackStaysLimited() throws Exception {
|
||||
root = root.toRealPath(); var json = new ObjectMapper();
|
||||
Files.writeString(root.resolve("prometeu.json"), "{\"name\":\"fault\",\"version\":\"1\",\"language\":\"pbs\",\"stdlib\":\"1\",\"target\":\"Game\",\"dependencies\":[]}");
|
||||
var source = Files.createDirectories(root.resolve("src")).resolve("main.pbs"); Files.writeString(source, "fn x() -> int { return 1; }\n");
|
||||
var access = new ProjectAccessRegistry(); var catalog = new ProjectCatalogService(root.getParent(), json, new ProjectLocalStudioSetupStore(json));
|
||||
var knowledge = new CompilerProjectKnowledge(access, catalog, json);
|
||||
var faults = new LinkedHashMap<Integer, AutomationFailure.Code>();
|
||||
faults.put(-32020, AutomationFailure.Code.LANGUAGE_QUERY_REVISION_MISMATCH);
|
||||
faults.put(-32603, AutomationFailure.Code.LANGUAGE_QUERY_INTERNAL_FAILURE);
|
||||
faults.put(-32099, AutomationFailure.Code.LANGUAGE_QUERY_PROTOCOL_FAILURE);
|
||||
faults.put(0, AutomationFailure.Code.LANGUAGE_QUERY_TIMEOUT);
|
||||
faults.put(1, null); // controlled standard-only server
|
||||
try (var threads = Executors.newCachedThreadPool()) {
|
||||
var authority = new DefaultAutomationSession(root, new ExecutorOperationExecutor(threads));
|
||||
var registration = access.register(root, authority::enterManual, () -> true, authority);
|
||||
authority.grant(false).toCompletableFuture().join(); var task = authority.acquire().task();
|
||||
try {
|
||||
for (var fault : faults.entrySet()) try (var listener = new ServerSocket(0, 8, InetAddress.getLoopbackAddress())) {
|
||||
var served = threads.submit(() -> {
|
||||
try (var socket = listener.accept()) {
|
||||
var clientRef = new AtomicReference<org.eclipse.lsp4j.services.LanguageClient>();
|
||||
var text = (org.eclipse.lsp4j.services.TextDocumentService)java.lang.reflect.Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{org.eclipse.lsp4j.services.TextDocumentService.class}, (proxy, method, args) -> {
|
||||
if (method.getName().equals("didOpen")) {
|
||||
var open = (DidOpenTextDocumentParams)args[0]; clientRef.get().publishDiagnostics(new PublishDiagnosticsParams(open.getTextDocument().getUri(), List.of()));
|
||||
}
|
||||
return null;
|
||||
});
|
||||
var server = (ExternalSourceLanguageServer)java.lang.reflect.Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{ExternalSourceLanguageServer.class}, (proxy, method, args) -> switch (method.getName()) {
|
||||
case "initialize" -> fault.getKey() == 0 ? new CompletableFuture<InitializeResult>()
|
||||
: fault.getKey() == 1 ? CompletableFuture.completedFuture(new InitializeResult(legacyCapabilities()))
|
||||
: CompletableFuture.failedFuture(new ResponseErrorException(new ResponseError(fault.getKey(), "controlled protocol failure", null)));
|
||||
case "getTextDocumentService" -> text;
|
||||
case "getWorkspaceService" -> new p.studio.lsp.services.protocol.PrometeuWorkspaceService();
|
||||
default -> null;
|
||||
});
|
||||
var launcher = new Launcher.Builder<org.eclipse.lsp4j.services.LanguageClient>().setLocalService(server)
|
||||
.setRemoteInterface(org.eclipse.lsp4j.services.LanguageClient.class).setInput(socket.getInputStream()).setOutput(socket.getOutputStream()).setExecutorService(threads).create();
|
||||
clientRef.set(launcher.getRemoteProxy()); launcher.startListening().get(5, TimeUnit.SECONDS);
|
||||
} catch (Exception ended) { /* Closing the client ends this controlled server. */ }
|
||||
});
|
||||
var endpoint = new LspServerEndpoint(InetAddress.getLoopbackAddress().getHostAddress(), listener.getLocalPort());
|
||||
var lifecycle = lifecycle(endpoint);
|
||||
var queries = new TaskLanguageQueries(access, new AutomationLspQueries(lifecycle, catalog, knowledge, json), 700, 500);
|
||||
var params = Map.<String, Object>of("uri", source.toUri().toString());
|
||||
if (fault.getValue() == null) {
|
||||
var reply = queries.query(root, task.value(), "diagnostics", params);
|
||||
assertTrue(reply.get("limitations").toString().contains("ANALYSIS_DETAILS_UNAVAILABLE"));
|
||||
assertTrue(reply.get("analysis").toString().contains("not-evaluated"));
|
||||
} else {
|
||||
var failure = assertThrows(AutomationException.class, () -> queries.query(root, task.value(), "diagnostics", params)).failure();
|
||||
assertEquals(fault.getValue(), failure.code()); assertTrue(failure.runtimeError().isEmpty());
|
||||
assertEquals(true, failure.details().get("workerTerminated")); assertNotNull(failure.details().get("queryId"));
|
||||
}
|
||||
served.get(3, TimeUnit.SECONDS);
|
||||
}
|
||||
var missing = new TaskLanguageQueries(access, new AutomationLspQueries(lifecycle(null), catalog, knowledge, json));
|
||||
assertEquals(AutomationFailure.Code.LANGUAGE_SERVER_UNAVAILABLE,
|
||||
assertThrows(AutomationException.class, () -> missing.query(root, task.value(), "diagnostics", Map.of("uri", source.toUri().toString()))).failure().code());
|
||||
} finally { authority.closeAsync().toCompletableFuture().get(5, TimeUnit.SECONDS); registration.unsubscribe(); }
|
||||
}
|
||||
}
|
||||
@Test void cancellationAndCleanupFailuresHaveSeparateNeutralCodes() throws Exception {
|
||||
try (var workers = Executors.newCachedThreadPool()) {
|
||||
var authority = new DefaultAutomationSession(root, new ExecutorOperationExecutor(workers));
|
||||
var access = new ProjectAccessRegistry(); var registration = access.register(root, authority::enterManual, () -> true, authority);
|
||||
authority.grant(false).toCompletableFuture().join(); var task = authority.acquire().task();
|
||||
try {
|
||||
for (boolean cleanupFailure : List.of(false, true)) {
|
||||
var port = new LanguageQueryPort() {
|
||||
public void endTask(TaskIdentity identity) {}
|
||||
public Map<String, Object> query(TaskIdentity identity, String operation, Map<String, Object> parameters) { throw new AssertionError(); }
|
||||
public Map<String, Object> query(TaskIdentity identity, String operation, Map<String, Object> parameters, LanguageQueryExecution execution) {
|
||||
if (!cleanupFailure) throw new CancellationException("controlled cancellation");
|
||||
execution.own(() -> { throw new IllegalStateException("controlled cleanup failure"); });
|
||||
execution.cancel(); return Map.of();
|
||||
}
|
||||
};
|
||||
var queries = new TaskLanguageQueries(access, port);
|
||||
var error = assertThrows(AutomationException.class, () -> queries.query(root, task.value(), "diagnostics", Map.of())).failure();
|
||||
assertEquals(cleanupFailure ? AutomationFailure.Code.LANGUAGE_QUERY_CLEANUP_FAILED : AutomationFailure.Code.LANGUAGE_QUERY_CANCELLED, error.code());
|
||||
assertEquals(true, error.details().get("workerTerminated"));
|
||||
if (cleanupFailure) assertEquals("failed", error.details().get("cleanup"));
|
||||
assertEquals(ControlState.AGENT_WORKING, authority.snapshot().state());
|
||||
}
|
||||
} finally { authority.closeAsync().toCompletableFuture().get(5,TimeUnit.SECONDS); registration.unsubscribe(); }
|
||||
}
|
||||
}
|
||||
static ServerCapabilities legacyCapabilities() {
|
||||
var capabilities = new ServerCapabilities(); capabilities.setTextDocumentSync(TextDocumentSyncKind.Full); return capabilities;
|
||||
}
|
||||
static LspServerLifecycle lifecycle(LspServerEndpoint endpoint) {
|
||||
return new LspServerLifecycle() {
|
||||
public void bootServer(LspServerConfiguration config, LspProjectContext context) {}
|
||||
public void shutdownServer(LspProjectContext context) {}
|
||||
public Optional<LspServerEndpoint> endpoint(LspProjectContext context) { return Optional.ofNullable(endpoint); }
|
||||
};
|
||||
}
|
||||
@Test void delayedChildCleanupKeepsAdmissionAndPrimaryFailureUntilActualTermination() throws Exception {
|
||||
try (var threads = Executors.newCachedThreadPool()) {
|
||||
var authority = new DefaultAutomationSession(root, new ExecutorOperationExecutor(threads));
|
||||
var access = new ProjectAccessRegistry(); var registration = access.register(root, authority::enterManual, () -> true, authority);
|
||||
authority.grant(false).toCompletableFuture().join(); var task = authority.acquire().task();
|
||||
var childEntered = new CountDownLatch(1); var releaseChild = new CountDownLatch(1); var executionRef = new AtomicReference<LanguageQueryExecution>();
|
||||
var port = new LanguageQueryPort() {
|
||||
public Map<String, Object> query(TaskIdentity task, String operation, Map<String, Object> parameters) { throw new AssertionError(); }
|
||||
public void endTask(TaskIdentity task) {}
|
||||
public Map<String, Object> query(TaskIdentity task, String operation, Map<String, Object> parameters, LanguageQueryExecution execution) {
|
||||
executionRef.set(execution); var child = Executors.newSingleThreadExecutor();
|
||||
child.submit(() -> { childEntered.countDown(); boolean interrupted = false;
|
||||
while (true) try { releaseChild.await(); break; } catch (InterruptedException ignored) { interrupted = true; }
|
||||
if (interrupted) Thread.currentThread().interrupt();
|
||||
});
|
||||
try { assertTrue(childEntered.await(2, TimeUnit.SECONDS)); } catch (InterruptedException stopped) { Thread.currentThread().interrupt(); }
|
||||
execution.own(child::shutdownNow);
|
||||
execution.finishWorkers(child);
|
||||
execution.record(AutomationFailure.Code.LANGUAGE_QUERY_INTERNAL_FAILURE, "late failure", Map.of());
|
||||
return Map.of("late", true);
|
||||
}
|
||||
};
|
||||
try {
|
||||
var queries = new TaskLanguageQueries(access, port, 150, 150);
|
||||
var call = threads.submit(() -> queries.query(root, task.value(), "diagnostics", Map.of()));
|
||||
assertTrue(childEntered.await(2, TimeUnit.SECONDS));
|
||||
var error = assertInstanceOf(AutomationException.class, assertThrows(ExecutionException.class, () -> call.get(2, TimeUnit.SECONDS)).getCause()).failure();
|
||||
assertEquals(AutomationFailure.Code.LANGUAGE_QUERY_TIMEOUT, error.code()); assertEquals(false, error.details().get("workerTerminated"));
|
||||
assertEquals(ControlResult.Status.BUSY, assertThrows(ControlDeniedException.class, () -> authority.submit(task, "successor", () -> null)).status());
|
||||
assertEquals(ControlState.AGENT_WORKING, authority.snapshot().state());
|
||||
releaseChild.countDown();
|
||||
long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(2);
|
||||
while (authority.snapshot().operation().state() != p.studio.api.operation.OperationState.CANCELLED && System.nanoTime() < deadline) Thread.onSpinWait();
|
||||
assertEquals(AutomationFailure.Code.LANGUAGE_QUERY_TIMEOUT, executionRef.get().exception(AutomationFailure.Code.LANGUAGE_QUERY_INTERNAL_FAILURE, "later", true).failure().code());
|
||||
} finally { releaseChild.countDown(); authority.closeAsync().toCompletableFuture().get(5, TimeUnit.SECONDS); registration.unsubscribe(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package p.studio.app.lsp;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import p.studio.api.project.*;
|
||||
import p.studio.lsp.services.LspServerLifecycleImpl;
|
||||
import java.nio.file.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class LspDiscoveryTest {
|
||||
@TempDir Path root;
|
||||
final ObjectMapper mapper = new ObjectMapper();
|
||||
ProjectReference project() { return new ProjectReference("app", "1.0", "pbs", 1, ProjectTarget.Game, root); }
|
||||
|
||||
@Test void publishesActualProjectEndpointAndRemovesItOnClose() throws Exception {
|
||||
var lifecycle = new LspServerLifecycleImpl();
|
||||
var adapter = new LspLifecycleAdapter(lifecycle);
|
||||
var project = project();
|
||||
adapter.boot(project);
|
||||
try {
|
||||
var data = mapper.readTree(root.resolve(".studio/lsp.json").toFile());
|
||||
assertEquals(1, data.path("schemaVersion").asInt());
|
||||
assertEquals(root.toRealPath().toString(), data.path("projectRoot").asText());
|
||||
assertEquals(ProcessHandle.current().pid(), data.path("processId").asLong());
|
||||
var endpoint = lifecycle.endpoint(LspLifecycleAdapter.context(project)).orElseThrow();
|
||||
assertEquals(endpoint.port(), data.path("port").asInt());
|
||||
assertEquals("127.0.0.1", data.path("host").asText());
|
||||
assertFalse(data.path("sessionId").asText().isBlank());
|
||||
} finally { adapter.shutdown(project); }
|
||||
assertFalse(Files.exists(root.resolve(".studio/lsp.json")));
|
||||
assertTrue(lifecycle.endpoint(LspLifecycleAdapter.context(project)).isEmpty());
|
||||
}
|
||||
|
||||
@Test void newSessionGetsFreshIdentityAndPortCanBeRediscovered() throws Exception {
|
||||
var adapter = new LspLifecycleAdapter(new LspServerLifecycleImpl());
|
||||
var project = project();
|
||||
adapter.boot(project);
|
||||
String first;
|
||||
try { first = mapper.readTree(root.resolve(".studio/lsp.json").toFile()).path("sessionId").asText(); }
|
||||
finally { adapter.shutdown(project); }
|
||||
adapter.boot(project);
|
||||
try { assertNotEquals(first, mapper.readTree(root.resolve(".studio/lsp.json").toFile()).path("sessionId").asText()); }
|
||||
finally { adapter.shutdown(project); }
|
||||
}
|
||||
|
||||
@Test void shutdownPreservesMetadataOwnedByAnotherSession() throws Exception {
|
||||
var adapter = new LspLifecycleAdapter(new LspServerLifecycleImpl());
|
||||
var project = project();
|
||||
adapter.boot(project);
|
||||
Files.writeString(root.resolve(".studio/lsp.json"), "{\"sessionId\":\"replacement\"}");
|
||||
adapter.shutdown(project);
|
||||
assertTrue(Files.readString(root.resolve(".studio/lsp.json")).contains("replacement"));
|
||||
}
|
||||
|
||||
@Test void failedPublicationRollsBackListeningServer() throws Exception {
|
||||
Files.writeString(root.resolve(".studio"), "blocked");
|
||||
var lifecycle = new LspServerLifecycleImpl();
|
||||
var adapter = new LspLifecycleAdapter(lifecycle);
|
||||
assertThrows(IllegalStateException.class, () -> adapter.boot(project()));
|
||||
assertTrue(lifecycle.endpoint(LspLifecycleAdapter.context(project())).isEmpty());
|
||||
}
|
||||
}
|
||||
@@ -375,6 +375,61 @@ class McpTaskToolsTest {
|
||||
error("INVALID_TASK", httpCall(client, server, reconnected, "studio_build_start", args().put("clientRequestId", "late")));
|
||||
} finally { lsp.shutdown(project); }
|
||||
}
|
||||
@Test void cancelledBuildCannotPublishSuccessOrUsableArtifactIdentityAfterLateReturn() throws Exception {
|
||||
acquire(); holdBuild = true;
|
||||
var receipt = value(call("studio_build_start", args().put("clientRequestId", "cancel-build")));
|
||||
assertTrue(buildEntered.await(2, TimeUnit.SECONDS));
|
||||
value(call("studio_operation_cancel", args().put("operationId", receipt.path("operationId").asText())));
|
||||
assertFalse(poll("cancel-build").path("workerTerminated").asBoolean()); buildGate.countDown();
|
||||
var result = completed("cancel-build");
|
||||
assertEquals("CANCELLED", result.path("state").asText()); assertEquals("CANCELLED", result.path("result").path("status").asText());
|
||||
assertEquals("cancelled", result.path("result").path("summary").path("validationStatus").asText()); assertTrue(result.path("result").path("buildId").isNull());
|
||||
assertEquals(ControlState.AGENT_WORKING, session.snapshot().state());
|
||||
}
|
||||
|
||||
@Test void controlledInvalidCommonIrRetAndJoinSurviveTheRealBuildGatewayAndAuthenticatedMcp() throws Exception {
|
||||
Files.writeString(root.resolve("prometeu.json"), "{\"name\":\"controlled\",\"version\":\"1\",\"language\":\"controlled-ir\",\"stdlib\":\"1\",\"target\":\"Game\",\"dependencies\":[]}");
|
||||
Files.createDirectories(root.resolve("src")); Files.writeString(root.resolve("src/probe.synth"), "x");
|
||||
var reports = mapper.createArrayNode();
|
||||
try (var packer = p.packer.Packer.bootstrap(mapper, ignored -> {})) {
|
||||
compose(new p.studio.core.shipper.StudioShipperService(new p.studio.app.compiler.CompilerBuildGatewayAdapter(), packer.workspaceService(), mapper, new ExecutorOperationExecutor(workers), access));
|
||||
try (var server = new LocalMcpServer(mapper, tools); var client = java.net.http.HttpClient.newHttpClient()) {
|
||||
server.start(); var credential = server.credentials().prepare(root); credential.activate(); httpAuthorization = "Bearer " + credential.secret();
|
||||
String connection = connect(client, server); session.grant(false).toCompletableFuture().join();
|
||||
task = value(httpCall(client, server, connection, "studio_control_acquire", rootOnly())).path("taskId").asText();
|
||||
for (var variant : List.of("ret", "join", "ret-no-origin")) {
|
||||
boolean ret = !variant.equals("join"), noOrigin = variant.endsWith("no-origin");
|
||||
var frontend = new p.studio.app.compiler.fixture.ControlledIrFrontend(ret, noOrigin);
|
||||
p.studio.compiler.FrontendRegistryService.register(frontend);
|
||||
try {
|
||||
String request = variant + "-fixture";
|
||||
value(httpCall(client, server, connection, "studio_build_start", args().put("clientRequestId", request)));
|
||||
var result = httpCompleted(client, server, connection, request); var build = result.path("result");
|
||||
assertEquals("FAILED", build.path("status").asText(), build.toString());
|
||||
assertEquals("failed", build.path("summary").path("validationStatus").asText());
|
||||
var issue = build.path("issues").get(0);
|
||||
assertEquals(ret ? "compiler.verify.ret-stack-height" : "compiler.verify.join-stack-height", issue.path("checkId").asText(), issue.toString());
|
||||
assertEquals("available", issue.path("explanation").path("availability").asText());
|
||||
assertEquals("irvm-function", issue.path("origin").path("verification").path("pcSpace").asText());
|
||||
assertEquals("byte", issue.path("origin").path("verification").path("pcUnit").asText());
|
||||
assertEquals("lowering-output", issue.path("origin").path("verification").path("validationPoint").asText());
|
||||
if (noOrigin) {
|
||||
assertTrue(issue.path("origin").path("uri").isNull()); assertTrue(issue.path("origin").path("range").isNull());
|
||||
assertEquals("no-source-span", issue.path("origin").path("attribution").path("absenceReason").asText());
|
||||
assertFalse(issue.path("related").isEmpty());
|
||||
} else assertEquals(root.resolve("src/probe.synth").toUri().toString(), issue.path("origin").path("uri").asText());
|
||||
assertTrue(issue.path("facts").has(ret ? "expectedHeight" : "existingHeight"));
|
||||
assertTrue(issue.path("facts").has(ret ? "actualHeight" : "incomingHeight"));
|
||||
reports.add(result);
|
||||
} finally { p.studio.compiler.FrontendRegistryService.unregister(frontend.specification().getLanguageId()); }
|
||||
}
|
||||
value(httpCall(client, server, connection, "studio_control_release", args()));
|
||||
}
|
||||
}
|
||||
var report = Path.of("build/diagnostic-qualification/controlled-backend.json"); Files.createDirectories(report.getParent());
|
||||
mapper.writerWithDefaultPrettyPrinter().writeValue(report.toFile(), reports);
|
||||
}
|
||||
|
||||
String connect(java.net.http.HttpClient client, LocalMcpServer server) throws Exception {
|
||||
var initialize = mapper.createObjectNode().put("jsonrpc", "2.0").put("id", 1).put("method", "initialize");
|
||||
var params = initialize.putObject("params").put("protocolVersion", "2025-06-18");
|
||||
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
package p.studio.app.mcp;
|
||||
|
||||
import com.fasterxml.jackson.databind.*;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import p.studio.app.compiler.*;
|
||||
import p.studio.app.lsp.*;
|
||||
import p.studio.app.operation.ExecutorOperationExecutor;
|
||||
import p.studio.core.project.*;
|
||||
import p.studio.core.session.*;
|
||||
import p.studio.core.language.*;
|
||||
import p.studio.core.shipper.*;
|
||||
import p.studio.lsp.services.LspServerLifecycleImpl;
|
||||
import p.studio.ui.javafx.workspaces.dev.DevWorkspaceProjection;
|
||||
import java.net.http.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/** Frozen sources, production compiler/packer/LSP, authenticated loopback MCP. No runtime execution. */
|
||||
class StructuredDiagnosticsIntegrationTest {
|
||||
@TempDir Path temporary;
|
||||
final ObjectMapper json = new ObjectMapper();
|
||||
@Test void frozenCorrectedCorpusAndControlsKeepFactsRevisionsAndCanonicalViews() throws Exception {
|
||||
byte[] corpus = getClass().getResourceAsStream("/diagnostics/cases.json").readAllBytes();
|
||||
assertEquals("0ad291942af21e990f5cae3348a5be368dee865aa2843ba0d0effd1a9136cb87", sha(corpus));
|
||||
var required = Set.of("F1-direct", "F1-two-calls", "F1-service-this", "F3-function", "F3-global", "F3-service", "F4-same-dependency", "F4-same-direct");
|
||||
var reports = json.createArrayNode();
|
||||
for (var example : json.readTree(corpus).path("cases")) {
|
||||
String name = example.path("id").asText();
|
||||
if (!required.contains(name) && !name.equals("F1-local") && !name.equals("F3-file-private")) continue;
|
||||
Path root = Files.createDirectory(temporary.resolve(name)).toRealPath();
|
||||
var files = example.path("files").fields();
|
||||
while (files.hasNext()) {
|
||||
var file = files.next(); var path = root.resolve(file.getKey());
|
||||
Files.createDirectories(path.getParent()); Files.writeString(path, file.getValue().asText());
|
||||
}
|
||||
Path source = root.resolve("src/main.pbs");
|
||||
assertEquals(example.path("files").path("src/main.pbs").asText(), Files.readString(source));
|
||||
var access = new ProjectAccessRegistry();
|
||||
var catalog = new ProjectCatalogService(temporary, json, new ProjectLocalStudioSetupStore(json));
|
||||
var project = catalog.openProject(root);
|
||||
var lifecycle = new LspServerLifecycleImpl(); var lsp = new LspLifecycleAdapter(lifecycle);
|
||||
try (var workers = Executors.newCachedThreadPool(); var packer = p.packer.Packer.bootstrap(json, ignored -> {})) {
|
||||
var operations = new ExecutorOperationExecutor(workers);
|
||||
var session = new DefaultAutomationSession(root, operations);
|
||||
var registration = access.register(root, session::enterManual, () -> !session.snapshot().closed(), session);
|
||||
lsp.boot(project);
|
||||
try {
|
||||
var shipper = new StudioShipperService(new CompilerBuildGatewayAdapter(), packer.workspaceService(), json, operations, access);
|
||||
var tasks = new DefaultTaskTools(access, catalog, shipper, Optional.empty());
|
||||
var language = new TaskLanguageQueries(access, new AutomationLspQueries(lifecycle, catalog, new CompilerProjectKnowledge(access, catalog, json), json));
|
||||
var handlers = new LinkedHashMap<>(McpTaskTools.handlers(tasks, json, false)); handlers.putAll(McpLanguageTools.handlers(language, json));
|
||||
try (var server = new LocalMcpServer(json, new McpToolRegistry(new McpToolCatalog(json), json, handlers)); var client = HttpClient.newHttpClient()) {
|
||||
server.start(); var credential = server.credentials().prepare(root); credential.activate();
|
||||
String authorization = "Bearer " + credential.secret();
|
||||
var init = json.createObjectNode().put("jsonrpc", "2.0").put("id", "init").put("method", "initialize");
|
||||
var params = init.putObject("params").put("protocolVersion", "2025-06-18"); params.putObject("capabilities");
|
||||
params.putObject("clientInfo").put("name", "diagnostic-qualification").put("version", "1");
|
||||
String connection = post(client, server, authorization, null, init).headers().firstValue("Mcp-Session-Id").orElseThrow();
|
||||
post(client, server, authorization, connection, json.createObjectNode().put("jsonrpc", "2.0").put("method", "notifications/initialized"));
|
||||
assertTrue(session.grant(false).toCompletableFuture().join().success());
|
||||
var args = json.createObjectNode().put("projectRoot", root.toString());
|
||||
String task = call(client, server, authorization, connection, "studio_control_acquire", args).path("taskId").asText(); args.put("taskId", task);
|
||||
var request = args.deepCopy().put("operation", "diagnostics"); request.putObject("parameters").put("uri", source.toUri().toString());
|
||||
var query = call(client, server, authorization, connection, "studio_language_query", request);
|
||||
var analysis = query.path("analysis"); assertFalse(analysis.path("analysisId").asText().isBlank(), query.toString());
|
||||
assertEquals(sha(Files.readAllBytes(source)), query.path("context").path("document").path("sha256").asText());
|
||||
assertEquals(analysis.path("analysisId"), query.path("context").path("analysisId"));
|
||||
assertTrue(analysis.path("inputs").size() > 0);
|
||||
for (var standard : query.path("result")) {
|
||||
var detail = standard.path("data").path("prometeu");
|
||||
assertEquals(analysis.path("analysisId"), detail.path("analysisId"));
|
||||
assertTrue(detail.path("issueId").asText().startsWith(analysis.path("analysisId").asText() + ":"));
|
||||
}
|
||||
var buildArgs = args.deepCopy().put("clientRequestId", name);
|
||||
var receipt = call(client, server, authorization, connection, "studio_build_start", buildArgs);
|
||||
JsonNode operation; long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(20);
|
||||
do {
|
||||
operation = call(client, server, authorization, connection, "studio_operation_get", buildArgs);
|
||||
if (operation.path("workerTerminated").asBoolean()) break;
|
||||
Thread.sleep(5);
|
||||
} while (System.nanoTime() < deadline);
|
||||
assertTrue(operation.path("workerTerminated").asBoolean(), operation.toString());
|
||||
assertEquals(receipt.path("operationId"), operation.path("operationId"));
|
||||
var build = operation.path("result");
|
||||
assertEquals(operation.path("operationId"), build.path("context").path("operationId"));
|
||||
assertEquals(task, build.path("context").path("taskId").asText());
|
||||
var ui = json.readTree(json.writeValueAsString(DevWorkspaceProjection.from(session.snapshot()).diagnosticResult()));
|
||||
for (var key : List.of("issues", "summary", "context")) assertEquals(build.path(key), ui.path(key), name + " UI/MCP " + key);
|
||||
if (name.equals("F3-file-private")) {
|
||||
assertEquals("FAILED", build.path("status").asText(), build.toString());
|
||||
assertTrue(build.path("buildId").isNull());
|
||||
assertExplained(name, build.path("issues")); assertExplained(name, analysis.path("issues"));
|
||||
assertNotEquals("passed", build.path("summary").path("validationStatus").asText());
|
||||
} else {
|
||||
assertEquals("SUCCESS", build.path("status").asText(), build.toString());
|
||||
assertEquals("passed", build.path("summary").path("validationStatus").asText());
|
||||
assertEquals("passed", analysis.path("summary").path("validationStatus").asText());
|
||||
}
|
||||
reports.addObject().put("case", name).put("primaryDocumentSha256", sha(Files.readAllBytes(source))).put("frozenProjectSourceSha256", example.path("sourceSha256").asText())
|
||||
.set("language", query);
|
||||
var reportCase = (ObjectNode)reports.get(reports.size()-1);
|
||||
reportCase.set("operation", operation);
|
||||
reportCase.put("harnessConfiguration", "Existing Studio cartridge app_id adoption; frozen PBS/barrel sources unchanged");
|
||||
var originalFiles = example.path("files").fields();
|
||||
while (originalFiles.hasNext()) {
|
||||
var original = originalFiles.next();
|
||||
if (original.getKey().endsWith(".pbs") || original.getKey().endsWith(".barrel"))
|
||||
assertEquals(original.getValue().asText(), Files.readString(root.resolve(original.getKey())), name + original.getKey());
|
||||
}
|
||||
var artifacts = reportCase.putArray("artifactProvenance");
|
||||
if (Files.isDirectory(root.resolve("build"))) try (var paths = Files.walk(root.resolve("build"))) {
|
||||
for (var artifact : paths.filter(Files::isRegularFile).sorted().toList())
|
||||
artifacts.addObject().put("path", root.relativize(artifact).toString()).put("sha256", sha(Files.readAllBytes(artifact)));
|
||||
}
|
||||
if (name.equals("F1-local")) {
|
||||
var empty = source.resolveSibling("empty.pbs"); Files.writeString(empty, "");
|
||||
var emptyRequest = args.deepCopy().put("operation", "diagnostics"); emptyRequest.putObject("parameters").put("uri", empty.toUri().toString());
|
||||
var emptyReply = call(client, server, authorization, connection, "studio_language_query", emptyRequest);
|
||||
assertTrue(emptyReply.path("analysis").path("issues").isEmpty(), emptyReply.toString());
|
||||
assertEquals("passed", emptyReply.path("analysis").path("summary").path("validationStatus").asText());
|
||||
assertEquals(sha(new byte[0]), emptyReply.path("context").path("document").path("sha256").asText());
|
||||
reportCase.set("validEmptyDocumentControl", emptyReply);
|
||||
}
|
||||
call(client, server, authorization, connection, "studio_control_release", args);
|
||||
}
|
||||
} finally { session.closeAsync().toCompletableFuture().get(5, TimeUnit.SECONDS); registration.unsubscribe(); lsp.shutdown(project); }
|
||||
}
|
||||
}
|
||||
assertEquals(10, reports.size());
|
||||
var report = Path.of("build/diagnostic-qualification/frozen-corpus.json"); Files.createDirectories(report.getParent());
|
||||
json.writerWithDefaultPrettyPrinter().writeValue(report.toFile(), reports);
|
||||
}
|
||||
void assertExplained(String name, JsonNode issues) {
|
||||
assertFalse(issues.isEmpty(), name);
|
||||
boolean found = false;
|
||||
for (var issue : issues) if (issue.path("checkId").asText().startsWith("pbs.")) {
|
||||
assertEquals("available", issue.path("explanation").path("availability").asText(), issue.toString());
|
||||
assertFalse(issue.path("semanticContext").path("facts").isEmpty(), issue.toString()); found = true;
|
||||
}
|
||||
assertTrue(found, name + issues);
|
||||
}
|
||||
JsonNode call(HttpClient client, LocalMcpServer server, String auth, String connection, String name, ObjectNode args) throws Exception {
|
||||
var body = json.createObjectNode().put("jsonrpc", "2.0").put("id", UUID.randomUUID().toString()).put("method", "tools/call");
|
||||
body.putObject("params").put("name", name).set("arguments", args);
|
||||
var result = json.readTree(post(client, server, auth, connection, body).body()).path("result");
|
||||
assertFalse(result.path("isError").asBoolean(), result.toString()); return result.path("structuredContent").path("value");
|
||||
}
|
||||
HttpResponse<String> post(HttpClient client, LocalMcpServer server, String auth, String connection, JsonNode body) throws Exception {
|
||||
var request = HttpRequest.newBuilder(server.connection().endpoint()).timeout(java.time.Duration.ofSeconds(15))
|
||||
.header("Authorization", auth).header("Content-Type", "application/json").header("Accept", "application/json, text/event-stream")
|
||||
.header("MCP-Protocol-Version", "2025-06-18");
|
||||
if (connection != null) request.header("Mcp-Session-Id", connection);
|
||||
var response = client.send(request.POST(HttpRequest.BodyPublishers.ofString(body.toString())).build(), HttpResponse.BodyHandlers.ofString());
|
||||
assertTrue(response.statusCode() == 200 || response.statusCode() == 202, response.body()); return response;
|
||||
}
|
||||
static String sha(byte[] bytes) throws Exception { return HexFormat.of().formatHex(java.security.MessageDigest.getInstance("SHA-256").digest(bytes)); }
|
||||
}
|
||||
@@ -0,0 +1,451 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"cases": [
|
||||
{
|
||||
"id": "F1-local",
|
||||
"family": "call-comparison-return",
|
||||
"description": "Control: method result materialized before comparison",
|
||||
"control": null,
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "declare struct Probe() { fn value() -> int { return 1; } }\ndeclare global data: Probe = new Probe();\nfn check() -> bool { let value=data.value(); return value!=0; }\n[Frame] fn frame() -> void { if !check() { let failure=1/0; } }\n"
|
||||
},
|
||||
"sourceSha256": "35df5a71b9d508b20e8b293a769ba1397a3209d99246c39240e8788cda932990"
|
||||
},
|
||||
{
|
||||
"id": "F1-direct",
|
||||
"family": "call-comparison-return",
|
||||
"description": "Method call compared directly in returned expression",
|
||||
"control": "F1-local",
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "declare struct Probe() { fn value() -> int { return 1; } }\ndeclare global data: Probe = new Probe();\nfn check() -> bool { return data.value()!=0; }\n[Frame] fn frame() -> void { if !check() { let failure=1/0; } }\n"
|
||||
},
|
||||
"sourceSha256": "382223b4c520762a93e3ee767255175adec8b24f69949b335c1a0030c9d75e61"
|
||||
},
|
||||
{
|
||||
"id": "F1-two-calls",
|
||||
"family": "call-comparison-return",
|
||||
"description": "Two method calls as comparison operands",
|
||||
"control": "F1-local",
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "declare struct Probe() { fn value() -> int { return 1; } }\ndeclare global data: Probe = new Probe();\nfn check() -> bool { return data.value()==data.value(); }\n[Frame] fn frame() -> void { if !check() { let failure=1/0; } }\n"
|
||||
},
|
||||
"sourceSha256": "2e3da1c805c18b5cdc34ca372fae737804a9274205ef377ac21d5b0034d60c4f"
|
||||
},
|
||||
{
|
||||
"id": "F1-service-this",
|
||||
"family": "call-comparison-return",
|
||||
"description": "Service receiver this inside a returned comparison",
|
||||
"control": "F1-service-local",
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "declare service Probe { fn value() -> int { return 1; } fn check() -> bool { return this.value()!=0; } }\n[Frame] fn frame() -> void { if !Probe.check() { let failure=1/0; } }\n"
|
||||
},
|
||||
"sourceSha256": "78a7ba39a880d9136b49f82ecbee7d409333c26861ff0a6b429ae6a55f08d089"
|
||||
},
|
||||
{
|
||||
"id": "F1-service-local",
|
||||
"family": "call-comparison-return",
|
||||
"description": "Control: identical service call materialized before returned comparison",
|
||||
"control": null,
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "declare service Probe { fn value() -> int { return 1; } fn check() -> bool { let value=this.value(); return value!=0; } }\n[Frame] fn frame() -> void { if !Probe.check() { let failure=1/0; } }\n"
|
||||
},
|
||||
"sourceSha256": "f07038dc6f42923a65b1df8c4d17aa61eb1714ae7907d82b87fcda9e6c4b73fb"
|
||||
},
|
||||
{
|
||||
"id": "F1-condition",
|
||||
"family": "call-comparison-return",
|
||||
"description": "Control: direct method comparison in an if condition",
|
||||
"control": null,
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "declare struct Probe() { fn value() -> int { return 1; } }\ndeclare global data: Probe = new Probe();\n[Frame] fn frame() -> void { if data.value()!=1 { let failure=1/0; } }\n"
|
||||
},
|
||||
"sourceSha256": "415d08d0155fc8e8b4e0df3c1eb47c0a6aa7bda6481fdc4f5024c14d0f70d014"
|
||||
},
|
||||
{
|
||||
"id": "F2-locals",
|
||||
"family": "nested-call-expression",
|
||||
"description": "Control: effectful call arguments stored in locals",
|
||||
"control": null,
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "declare global calls: int=0;\nfn next() -> int { calls+=1; return calls; }\nfn add(a: int,b: int) -> int { return a+b; }\n[Frame] fn frame() -> void { calls=0; let a=next(); let b=next(); let value=add(a,b); if value!=3 || calls!=2 { let failure=1/0; } }\n"
|
||||
},
|
||||
"sourceSha256": "1eb4dbd0bfa6fbc9e002793e6c23eefa80eb091d40ccf2253520b532b3420218"
|
||||
},
|
||||
{
|
||||
"id": "F2-arguments",
|
||||
"family": "nested-call-expression",
|
||||
"description": "Effectful call arguments evaluate once, left to right",
|
||||
"control": "F2-locals",
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "declare global calls: int=0;\nfn next() -> int { calls+=1; return calls; }\nfn add(a: int,b: int) -> int { return a+b; }\n[Frame] fn frame() -> void { calls=0; let value=add(next(),next()); if value!=3 || calls!=2 { let failure=1/0; } }\n"
|
||||
},
|
||||
"sourceSha256": "b8713121ffe7afacdd9d4ad6046768ff4ad681b44fcc153f84a432f6df75717c"
|
||||
},
|
||||
{
|
||||
"id": "F2-expression",
|
||||
"family": "nested-call-expression",
|
||||
"description": "Effectful calls nested inside arithmetic argument",
|
||||
"control": "F2-locals",
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "declare global calls: int=0;\nfn next() -> int { calls+=1; return calls; }\nfn add(a: int,b: int) -> int { return a+b; }\n[Frame] fn frame() -> void { calls=0; let value=add(next()+next(),next()); if value!=6 || calls!=3 { let failure=1/0; } }\n"
|
||||
},
|
||||
"sourceSha256": "c6ede06ecfad7bdd167b8f3afb849df362787484db1968f74b62c24909818073"
|
||||
},
|
||||
{
|
||||
"id": "F2-struct-method",
|
||||
"family": "nested-call-expression",
|
||||
"description": "Struct method used as another method argument",
|
||||
"control": "F2-locals",
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "declare struct Probe() { fn value() -> int { return 1; } }\ndeclare global data: Probe = new Probe();\nfn add(a: int,b: int) -> int { return a+b; }\n[Frame] fn frame() -> void { let value=add(data.value(),data.value()); if value!=2 { let failure=1/0; } }\n"
|
||||
},
|
||||
"sourceSha256": "8ed2b002ef5c20f01ae09949dc0ae75c574cce782dbe27bd304b25fa94045894"
|
||||
},
|
||||
{
|
||||
"id": "F3-single-file",
|
||||
"family": "same-module-files",
|
||||
"description": "Control: function and caller in the same file",
|
||||
"control": null,
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "fn increment(value: int) -> int { return value+1; }\n[Frame] fn frame() -> void { let value=increment(2); if value!=3 { let failure=1/0; } }\n"
|
||||
},
|
||||
"sourceSha256": "aff9dbc6f5e3b67b713da29e7e20eb97913464bedcc5f858964ec110ed7b8c4a"
|
||||
},
|
||||
{
|
||||
"id": "F3-function",
|
||||
"family": "same-module-files",
|
||||
"description": "mod function called from another file",
|
||||
"control": "F3-single-file",
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\nmod fn increment(value: int) -> int;\n",
|
||||
"src/helpers.pbs": "fn increment(value: int) -> int { return value+1; }\n",
|
||||
"src/main.pbs": "[Frame] fn frame() -> void { let value=increment(2); if value!=3 { let failure=1/0; } }\n"
|
||||
},
|
||||
"sourceSha256": "bcf9162dd44b7b7a50428e368789d10ab929301f382bae7c35cab06f1595c4b1"
|
||||
},
|
||||
{
|
||||
"id": "F3-global",
|
||||
"family": "same-module-files",
|
||||
"description": "mod global mutated from another file",
|
||||
"control": "F3-global-local",
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\nmod global count;\n",
|
||||
"src/state.pbs": "declare global count: int=0;\n",
|
||||
"src/main.pbs": "[Frame] fn frame() -> void { count=4; if count!=4 { let failure=1/0; } }\n"
|
||||
},
|
||||
"sourceSha256": "89c0749385172457659ca2e337ebc368e349065626a815198c314a089d95fc34"
|
||||
},
|
||||
{
|
||||
"id": "F3-service",
|
||||
"family": "same-module-files",
|
||||
"description": "mod service called from another file",
|
||||
"control": "F3-service-local",
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\nmod service Helper;\n",
|
||||
"src/helpers.pbs": "declare service Helper { fn value() -> int { return 3; } }\n",
|
||||
"src/main.pbs": "[Frame] fn frame() -> void { let value=Helper.value(); if value!=3 { let failure=1/0; } }\n"
|
||||
},
|
||||
"sourceSha256": "37b6c3b4c7d94d1f6f1cc258c84791fdd32c20ea38a88940b735fccf1c7f3b22"
|
||||
},
|
||||
{
|
||||
"id": "F3-global-local",
|
||||
"family": "same-module-files",
|
||||
"description": "Control: identical global and caller in the same file",
|
||||
"control": null,
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "declare global count: int=0;\n[Frame] fn frame() -> void { count=4; if count!=4 { let failure=1/0; } }\n"
|
||||
},
|
||||
"sourceSha256": "e175339cc069d0e14deb8e4e098b1310d877851f2415991ad65b446563aea924"
|
||||
},
|
||||
{
|
||||
"id": "F3-service-local",
|
||||
"family": "same-module-files",
|
||||
"description": "Control: identical service and caller in the same file",
|
||||
"control": null,
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "declare service Helper { fn value() -> int { return 3; } }\n[Frame] fn frame() -> void { let value=Helper.value(); if value!=3 { let failure=1/0; } }\n"
|
||||
},
|
||||
"sourceSha256": "387e15a0de25644a8862b6f88b74fc7839795e10c8736ebc5ada31670ffd79cb"
|
||||
},
|
||||
{
|
||||
"id": "F3-file-private",
|
||||
"family": "same-module-files",
|
||||
"description": "Negative control: function absent from barrel stays file-private",
|
||||
"control": "F3-function",
|
||||
"expectedCompile": "rejected",
|
||||
"expectedRuntime": "not_run",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/helpers.pbs": "fn increment(value: int) -> int { return value+1; }\n",
|
||||
"src/main.pbs": "[Frame] fn frame() -> void { let value=increment(2); }\n"
|
||||
},
|
||||
"sourceSha256": "b9359695e141c6fd14d5fbfcab68a8829ef4d87c3c7408dbc366465184ec2cfb"
|
||||
},
|
||||
{
|
||||
"id": "F4-distinct",
|
||||
"family": "homonymous-types",
|
||||
"description": "Types ARoomData/BRoomData; dependency=True; direct=False",
|
||||
"control": null,
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "import { A } from @caseapp:a;\nimport { B } from @caseapp:b;\n[Frame] fn frame() -> void { let value=A.value(); if value!=3 { let failure=1/0; } let other=B.value(); if other!=2 { let failure=1/0; } }\n",
|
||||
"src/a/mod.barrel": "pub service A;\nmod struct ARoomData;\n",
|
||||
"src/a/data.pbs": "declare struct ARoomData() { fn value() -> int { return 1; } }\n",
|
||||
"src/a/main.pbs": "import { B } from @caseapp:b;\ndeclare global room: ARoomData = new ARoomData();\ndeclare service A { fn value() -> int { let own=room.value(); let other=B.value(); return own+other; } }\n",
|
||||
"src/b/mod.barrel": "pub service B;\nmod struct BRoomData;\n",
|
||||
"src/b/data.pbs": "declare struct BRoomData() { fn value() -> int { return 2; } }\n",
|
||||
"src/b/main.pbs": "declare global room: BRoomData = new BRoomData();\ndeclare service B { fn value() -> int { return room.value(); } }\n"
|
||||
},
|
||||
"sourceSha256": "99c527e7749e4ea7c1cecce4063467e4f411b5481cdd641186975fee42299811"
|
||||
},
|
||||
{
|
||||
"id": "F4-same-no-dependency",
|
||||
"family": "homonymous-types",
|
||||
"description": "Types RoomData/RoomData; dependency=False; direct=False",
|
||||
"control": "F4-distinct",
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "import { A } from @caseapp:a;\nimport { B } from @caseapp:b;\n[Frame] fn frame() -> void { let value=A.value(); if value!=1 { let failure=1/0; } let other=B.value(); if other!=2 { let failure=1/0; } }\n",
|
||||
"src/a/mod.barrel": "pub service A;\nmod struct RoomData;\n",
|
||||
"src/a/data.pbs": "declare struct RoomData() { fn value() -> int { return 1; } }\n",
|
||||
"src/a/main.pbs": "declare global room: RoomData = new RoomData();\ndeclare service A { fn value() -> int { let own=room.value(); return own; } }\n",
|
||||
"src/b/mod.barrel": "pub service B;\nmod struct RoomData;\n",
|
||||
"src/b/data.pbs": "declare struct RoomData() { fn value() -> int { return 2; } }\n",
|
||||
"src/b/main.pbs": "declare global room: RoomData = new RoomData();\ndeclare service B { fn value() -> int { return room.value(); } }\n"
|
||||
},
|
||||
"sourceSha256": "db3c59d1f4f618856ed554310e5774f60d64f70e9ed0b122a5ab57d4e9870ce5"
|
||||
},
|
||||
{
|
||||
"id": "F4-same-dependency",
|
||||
"family": "homonymous-types",
|
||||
"description": "Types RoomData/RoomData; dependency=True; direct=False",
|
||||
"control": "F4-distinct",
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "import { A } from @caseapp:a;\nimport { B } from @caseapp:b;\n[Frame] fn frame() -> void { let value=A.value(); if value!=3 { let failure=1/0; } let other=B.value(); if other!=2 { let failure=1/0; } }\n",
|
||||
"src/a/mod.barrel": "pub service A;\nmod struct RoomData;\n",
|
||||
"src/a/data.pbs": "declare struct RoomData() { fn value() -> int { return 1; } }\n",
|
||||
"src/a/main.pbs": "import { B } from @caseapp:b;\ndeclare global room: RoomData = new RoomData();\ndeclare service A { fn value() -> int { let own=room.value(); let other=B.value(); return own+other; } }\n",
|
||||
"src/b/mod.barrel": "pub service B;\nmod struct RoomData;\n",
|
||||
"src/b/data.pbs": "declare struct RoomData() { fn value() -> int { return 2; } }\n",
|
||||
"src/b/main.pbs": "declare global room: RoomData = new RoomData();\ndeclare service B { fn value() -> int { return room.value(); } }\n"
|
||||
},
|
||||
"sourceSha256": "c4c624cb3556b8d05927ceda69e596482f4ec1d7b82f7f4ca7442483e2b8b831"
|
||||
},
|
||||
{
|
||||
"id": "F4-rename-a",
|
||||
"family": "homonymous-types",
|
||||
"description": "Types StartRoomData/RoomData; dependency=True; direct=False",
|
||||
"control": "F4-distinct",
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "import { A } from @caseapp:a;\nimport { B } from @caseapp:b;\n[Frame] fn frame() -> void { let value=A.value(); if value!=3 { let failure=1/0; } let other=B.value(); if other!=2 { let failure=1/0; } }\n",
|
||||
"src/a/mod.barrel": "pub service A;\nmod struct StartRoomData;\n",
|
||||
"src/a/data.pbs": "declare struct StartRoomData() { fn value() -> int { return 1; } }\n",
|
||||
"src/a/main.pbs": "import { B } from @caseapp:b;\ndeclare global room: StartRoomData = new StartRoomData();\ndeclare service A { fn value() -> int { let own=room.value(); let other=B.value(); return own+other; } }\n",
|
||||
"src/b/mod.barrel": "pub service B;\nmod struct RoomData;\n",
|
||||
"src/b/data.pbs": "declare struct RoomData() { fn value() -> int { return 2; } }\n",
|
||||
"src/b/main.pbs": "declare global room: RoomData = new RoomData();\ndeclare service B { fn value() -> int { return room.value(); } }\n"
|
||||
},
|
||||
"sourceSha256": "6cab04b1fbc3724cec1670a11ab46a792e5b83ea1fb12b4bf80f98d178c1290e"
|
||||
},
|
||||
{
|
||||
"id": "F4-same-direct",
|
||||
"family": "homonymous-types",
|
||||
"description": "Types RoomData/RoomData; dependency=True; direct=True",
|
||||
"control": "F4-distinct",
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "import { A } from @caseapp:a;\nimport { B } from @caseapp:b;\n[Frame] fn frame() -> void { let value=A.value(); if value!=3 { let failure=1/0; } let other=B.value(); if other!=2 { let failure=1/0; } }\n",
|
||||
"src/a/mod.barrel": "pub service A;\nmod struct RoomData;\n",
|
||||
"src/a/data.pbs": "declare struct RoomData() { fn value() -> int { return 1; } }\n",
|
||||
"src/a/main.pbs": "import { B } from @caseapp:b;\ndeclare global room: RoomData = new RoomData();\ndeclare service A { fn value() -> int { return room.value()+B.value(); } }\n",
|
||||
"src/b/mod.barrel": "pub service B;\nmod struct RoomData;\n",
|
||||
"src/b/data.pbs": "declare struct RoomData() { fn value() -> int { return 2; } }\n",
|
||||
"src/b/main.pbs": "declare global room: RoomData = new RoomData();\ndeclare service B { fn value() -> int { return room.value(); } }\n"
|
||||
},
|
||||
"sourceSha256": "79fc0901e3e60e7b50b83f5d10ba4e548bd57b0c83d281def25369cadb74633e"
|
||||
},
|
||||
{
|
||||
"id": "F4-public-aliases",
|
||||
"family": "homonymous-types",
|
||||
"description": "Two distinct nominal RoomData declarations imported with aliases",
|
||||
"control": "F4-distinct",
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "import { RoomData as LeftData } from @caseapp:a;\nimport { RoomData as RightData } from @caseapp:b;\ndeclare global left: LeftData = new LeftData(1);\ndeclare global right: RightData = new RightData(2);\n[Frame] fn frame() -> void { let a=left.value(); let b=right.value(); if a!=1 || b!=2 { let failure=1/0; } }\n",
|
||||
"src/a/mod.barrel": "pub struct RoomData;\n",
|
||||
"src/a/main.pbs": "declare struct RoomData(number: int) { fn value() -> int { return this.number; } }\n",
|
||||
"src/b/mod.barrel": "pub struct RoomData;\n",
|
||||
"src/b/main.pbs": "declare struct RoomData(number: int) { fn value() -> int { return this.number; } }\n"
|
||||
},
|
||||
"sourceSha256": "9379bc7c71cd6c1ff287f5771a78590a2e25b8dead05e78c563ff25ee8d1c207"
|
||||
},
|
||||
{
|
||||
"id": "F5-shopvisit",
|
||||
"family": "imported-struct-construction",
|
||||
"description": "Imported ShopVisit, alias=None, positional=False",
|
||||
"control": null,
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "import { ShopVisit } from @caseapp:scene;\nimport { Link } from @caseapp:link;\ndeclare global scene: ShopVisit = new ShopVisit.make(10);\n[Frame] fn frame() -> void { let value=Link.read(scene); if value!=10 { let failure=1/0; } }\n",
|
||||
"src/scene/mod.barrel": "pub struct ShopVisit;\n",
|
||||
"src/scene/main.pbs": "declare struct ShopVisit(value: int) { ctor make(value: int) { this.value=value; } fn read() -> int { return this.value; } }\n",
|
||||
"src/link/mod.barrel": "pub service Link;\n",
|
||||
"src/link/main.pbs": "import { ShopVisit } from @caseapp:scene;\ndeclare service Link { fn read(scene: ShopVisit) -> int { return scene.read(); } }\n"
|
||||
},
|
||||
"sourceSha256": "5373eaa6bece79658cb4cbd74fecc47d7d2a5954eee1812576243155fecb4c38"
|
||||
},
|
||||
{
|
||||
"id": "F5-scene",
|
||||
"family": "imported-struct-construction",
|
||||
"description": "Imported Scene, alias=None, positional=False",
|
||||
"control": "F5-shopvisit",
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "import { Scene } from @caseapp:scene;\nimport { Link } from @caseapp:link;\ndeclare global scene: Scene = new Scene.make(10);\n[Frame] fn frame() -> void { let value=Link.read(scene); if value!=10 { let failure=1/0; } }\n",
|
||||
"src/scene/mod.barrel": "pub struct Scene;\n",
|
||||
"src/scene/main.pbs": "declare struct Scene(value: int) { ctor make(value: int) { this.value=value; } fn read() -> int { return this.value; } }\n",
|
||||
"src/link/mod.barrel": "pub service Link;\n",
|
||||
"src/link/main.pbs": "import { Scene } from @caseapp:scene;\ndeclare service Link { fn read(scene: Scene) -> int { return scene.read(); } }\n"
|
||||
},
|
||||
"sourceSha256": "f84b4a4f6eb21100dfff74f26e4f453d4300d3e2dd79d70ee9b3992ed4c8d09f"
|
||||
},
|
||||
{
|
||||
"id": "F5-scene-alias",
|
||||
"family": "imported-struct-construction",
|
||||
"description": "Imported Scene, alias=WorldScene, positional=False",
|
||||
"control": "F5-shopvisit",
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "import { Scene as WorldScene } from @caseapp:scene;\nimport { Link } from @caseapp:link;\ndeclare global scene: WorldScene = new WorldScene.make(10);\n[Frame] fn frame() -> void { let value=Link.read(scene); if value!=10 { let failure=1/0; } }\n",
|
||||
"src/scene/mod.barrel": "pub struct Scene;\n",
|
||||
"src/scene/main.pbs": "declare struct Scene(value: int) { ctor make(value: int) { this.value=value; } fn read() -> int { return this.value; } }\n",
|
||||
"src/link/mod.barrel": "pub service Link;\n",
|
||||
"src/link/main.pbs": "import { Scene } from @caseapp:scene;\ndeclare service Link { fn read(scene: Scene) -> int { return scene.read(); } }\n"
|
||||
},
|
||||
"sourceSha256": "0f53a73f0f969919df0ad0df8a93e5b8e8db552310b69d37cae0f3ff9d625959"
|
||||
},
|
||||
{
|
||||
"id": "F5-scene-positional",
|
||||
"family": "imported-struct-construction",
|
||||
"description": "Imported Scene, alias=None, positional=True",
|
||||
"control": "F5-shopvisit",
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "passed",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "import { Scene } from @caseapp:scene;\nimport { Link } from @caseapp:link;\ndeclare global scene: Scene = new Scene(10);\n[Frame] fn frame() -> void { let value=Link.read(scene); if value!=10 { let failure=1/0; } }\n",
|
||||
"src/scene/mod.barrel": "pub struct Scene;\n",
|
||||
"src/scene/main.pbs": "declare struct Scene(value: int) { ctor make(value: int) { this.value=value; } fn read() -> int { return this.value; } }\n",
|
||||
"src/link/mod.barrel": "pub service Link;\n",
|
||||
"src/link/main.pbs": "import { Scene } from @caseapp:scene;\ndeclare service Link { fn read(scene: Scene) -> int { return scene.read(); } }\n"
|
||||
},
|
||||
"sourceSha256": "65b3452b0e30037b1e744de8e36dc629f2f5d11f5fb97068566d1a4b38baaeb7"
|
||||
},
|
||||
{
|
||||
"id": "runtime-trap-control",
|
||||
"family": "harness-control",
|
||||
"description": "Deliberate guest fault proves frame assertions are executed",
|
||||
"control": null,
|
||||
"expectedCompile": "compiled",
|
||||
"expectedRuntime": "fault",
|
||||
"files": {
|
||||
"prometeu.json": "{\n \"name\": \"caseapp\",\n \"version\": \"1.0.0\",\n \"language\": \"pbs\",\n \"stdlib\": \"1\",\n \"target\": \"Game\",\n \"dependencies\": []\n}\n",
|
||||
"src/mod.barrel": "pub fn frame() -> void;\n",
|
||||
"src/main.pbs": "[Frame] fn frame() -> void { let failure=1/0; }\n"
|
||||
},
|
||||
"sourceSha256": "60013483001b50eb3e7f8a9360142ec5ab49f8ca56edf1d6b0ca5b32251510d9"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user