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(() -> {
|
||||
|
||||
Reference in New Issue
Block a user