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