feat(studio): improve compiler reliability and AI diagnostics
Test / Tests and coverage occurred while executing withChecks step.
Intrepid/Prometeu/Studio/pipeline/pr-master There was a failure building this commit

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:
2026-11-10 12:36:25 +00:00
parent 38f201a9c9
commit ea1cc26fe3
1216 changed files with 168017 additions and 354 deletions
+1 -1
View File
@@ -2,4 +2,4 @@ plugins {
id("gradle.java-library-conventions")
}
dependencies { api(project(":prometeu-animation")) }
dependencies { api(project(":prometeu-animation")); api(project(":prometeu-infra")) }
@@ -7,20 +7,24 @@ import java.util.LinkedHashMap;
import java.util.Collections;
/** Stable domain failure codes, independent of HTTP status and JSON-RPC errors. */
public record AutomationFailure(Code code, String message, Map<String, Object> runtimeError) {
public record AutomationFailure(Code code, String message, Map<String, Object> runtimeError, Map<String, Object> details) {
public AutomationFailure(Code code, String message) { this(code, message, Map.of()); }
public AutomationFailure(Code code, String message, Map<String, Object> runtimeError) { this(code, message, runtimeError, Map.of()); }
public enum Code {
PROJECT_NOT_OPEN, NOT_GRANTED, INVALID_TASK, BUSY, CLOSED, CLEANUP_FAILED,
UNSUPPORTED_LANGUAGE, UNSUPPORTED_CAPABILITY, REFERENCE_NOT_FOUND, DOCUMENTATION_UNAVAILABLE,
OUTSIDE_PROJECT_SCOPE, READ_ONLY_SCOPE, OPERATION_NOT_FOUND, CLIENT_REQUEST_CONFLICT,
RUNTIME_UNAVAILABLE, RUNTIME_INCOMPATIBLE, SESSION_NOT_FOUND, BUILD_NOT_FOUND,
ANIMATION_INVALID, ANIMATION_CONFLICT, NO_FRAME_AVAILABLE, LIMIT_EXCEEDED, NOT_CANCELABLE, MEMCARD_ERROR, INFRASTRUCTURE_FAILURE
ANIMATION_INVALID, ANIMATION_CONFLICT, NO_FRAME_AVAILABLE, LIMIT_EXCEEDED, NOT_CANCELABLE, MEMCARD_ERROR, INFRASTRUCTURE_FAILURE,
LANGUAGE_QUERY_TIMEOUT, LANGUAGE_QUERY_CANCELLED, LANGUAGE_SERVER_UNAVAILABLE, LANGUAGE_QUERY_PROTOCOL_FAILURE,
LANGUAGE_QUERY_INTERNAL_FAILURE, LANGUAGE_QUERY_CLEANUP_FAILED, LANGUAGE_QUERY_REVISION_MISMATCH
}
public AutomationFailure {
Objects.requireNonNull(code); Objects.requireNonNull(message);
var copy = new LinkedHashMap<String, Object>();
if (runtimeError != null) runtimeError.forEach((key, value) -> copy.put(key, freeze(value)));
runtimeError = Collections.unmodifiableMap(copy);
details = p.studio.utilities.json.ImmutableJson.object(details);
}
private static Object freeze(Object value) {
if (value instanceof Map<?, ?> map) {
@@ -1,7 +1,10 @@
package p.studio.api.automation;
import java.util.List;
public record AutomationOutcome(Kind kind, long requestedFrames, long completedFrames,
List<String> diagnostics, CanonicalCapture capture) {
List<String> diagnostics, CanonicalCapture capture, java.util.Map<String, Object> diagnosticResult) {
public AutomationOutcome(Kind kind, long requestedFrames, long completedFrames, List<String> diagnostics, CanonicalCapture capture) {
this(kind, requestedFrames, completedFrames, diagnostics, capture, java.util.Map.of());
}
public enum Kind { SUCCEEDED, TERMINATED, GUEST_FAULT, INFRASTRUCTURE_FAILURE, CANCELLED, ACTION_REQUIRED }
public AutomationOutcome { diagnostics = List.copyOf(diagnostics); }
public AutomationOutcome { diagnostics = List.copyOf(diagnostics); diagnosticResult = p.studio.utilities.json.ImmutableJson.object(diagnosticResult); }
}
@@ -4,8 +4,11 @@ import java.util.List;
import p.studio.api.operation.OperationSnapshot;
public record AutomationSnapshot(Path projectRoot, ControlState state, boolean handoffPending,
boolean closed, int manualOperations, TaskIdentity task, OperationSnapshot operation,
CanonicalCapture capture, boolean stale, List<String> diagnostics, List<String> calls) {
public AutomationSnapshot { diagnostics = List.copyOf(diagnostics); calls = List.copyOf(calls); }
CanonicalCapture capture, boolean stale, List<String> diagnostics, List<String> calls, java.util.Map<String, Object> diagnosticResult) {
public AutomationSnapshot(Path root, ControlState state, boolean pending, boolean closed, int manualOperations, TaskIdentity task, OperationSnapshot operation, CanonicalCapture capture, boolean stale, List<String> diagnostics, List<String> calls) {
this(root, state, pending, closed, manualOperations, task, operation, capture, stale, diagnostics, calls, java.util.Map.of());
}
public AutomationSnapshot { diagnostics = List.copyOf(diagnostics); calls = List.copyOf(calls); diagnosticResult = p.studio.utilities.json.ImmutableJson.object(diagnosticResult); }
public boolean manualAllowed() { return !closed && !handoffPending && state == ControlState.MANUAL; }
public boolean canGrant() { return manualAllowed() && manualOperations == 0; }
public boolean canReclaim() { return !closed && state != ControlState.MANUAL; }
@@ -1,8 +1,13 @@
package p.studio.api.diagnostic;
import java.util.Objects;
import java.util.Map;
import java.util.LinkedHashMap;
import p.studio.utilities.json.ImmutableJson;
import p.studio.utilities.json.DiagnosticPayloads;
public record StudioDiagnostic(String code, DiagnosticSeverity severity, String message) {
public record StudioDiagnostic(String code, DiagnosticSeverity severity, String message, Map<String, Object> details) {
public StudioDiagnostic(String code, DiagnosticSeverity severity, String message) { this(code, severity, message, Map.of()); }
public StudioDiagnostic {
Objects.requireNonNull(code, "code");
Objects.requireNonNull(severity, "severity");
@@ -10,5 +15,21 @@ public record StudioDiagnostic(String code, DiagnosticSeverity severity, String
if (code.isBlank()) {
throw new IllegalArgumentException("code must not be blank");
}
var complete = new LinkedHashMap<>(DiagnosticPayloads.issue(code, severity.name(), message));
if (details != null) complete.putAll(details);
if (!(complete.get("issueId") instanceof String identity) || identity.isBlank())
complete.put("issueId", java.util.UUID.randomUUID().toString());
details = ImmutableJson.object(complete);
}
public static StudioDiagnostic fromMap(Map<String, Object> value) {
return new StudioDiagnostic((String) value.get("code"), DiagnosticSeverity.valueOf((String) value.get("severity")),
(String) value.get("message"), value);
}
public Map<String, Object> toMap() {
var value = new LinkedHashMap<>(details);
value.put("code", code); value.put("severity", severity.name()); value.put("message", message);
return ImmutableJson.object(value);
}
}
@@ -2,5 +2,6 @@ package p.studio.api.shipper;
public enum ShipperPreparationStatus {
SUCCESS,
FAILED
FAILED,
CANCELLED
}
@@ -3,19 +3,45 @@ package p.studio.api.shipper;
import java.nio.file.Path;
import java.util.List;
import java.util.Objects;
import java.util.Map;
import p.studio.api.diagnostic.StudioDiagnostic;
import p.studio.utilities.json.ImmutableJson;
import p.studio.utilities.json.DiagnosticPayloads;
public record ShipperPrepareResult(
ShipperPreparationStatus status,
List<ShipperLogEntry> logs,
Path manifestPath,
List<Path> emittedArtifacts,
List<String> diagnostics) {
List<String> diagnostics,
List<StudioDiagnostic> issues,
Map<String, Object> summary,
Map<String, Object> context) {
public ShipperPrepareResult(ShipperPreparationStatus status, List<ShipperLogEntry> logs, Path manifestPath,
List<Path> emittedArtifacts, List<String> diagnostics) {
this(status, logs, manifestPath, emittedArtifacts, diagnostics, List.of(), DiagnosticPayloads.legacySummary("build"), Map.of());
}
public ShipperPrepareResult {
Objects.requireNonNull(status, "status");
logs = List.copyOf(Objects.requireNonNull(logs, "logs"));
manifestPath = manifestPath == null ? null : manifestPath.toAbsolutePath().normalize();
emittedArtifacts = List.copyOf(Objects.requireNonNull(emittedArtifacts, "emittedArtifacts"));
diagnostics = List.copyOf(Objects.requireNonNull(diagnostics, "diagnostics"));
issues = List.copyOf(issues); summary = ImmutableJson.object(summary); context = ImmutableJson.object(context);
}
public Map<String, Object> diagnosticView() {
return ImmutableJson.fields("issues", issues.stream().map(StudioDiagnostic::toMap).toList(), "summary", summary, "context", context);
}
public ShipperPrepareResult withContext(Map<String, Object> additions) {
var merged = new java.util.LinkedHashMap<>(context); merged.putAll(additions);
return new ShipperPrepareResult(status, logs, manifestPath, emittedArtifacts, diagnostics, issues, summary, merged);
}
public ShipperPrepareResult asCancelled() {
var cancelled = new java.util.LinkedHashMap<>(summary); cancelled.put("validationStatus", "cancelled");
return new ShipperPrepareResult(ShipperPreparationStatus.CANCELLED, logs, null, List.of(), diagnostics, issues, cancelled, context);
}
public boolean success() {
@@ -0,0 +1,41 @@
package p.studio.api.diagnostic;
import org.junit.jupiter.api.Test;
import p.studio.utilities.json.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.*;
import static org.junit.jupiter.api.Assertions.*;
class DiagnosticPayloadTest {
@Test void boundsWholeIssuesByCountAndUtf8BytesWithoutChangingEvaluation() throws Exception {
var all = new ArrayList<Map<String, Object>>();
for (int i = 0; i < 1030; i++) all.add(DiagnosticPayloads.issue("TEST", "ERROR", "failure " + i));
var view = DiagnosticPayloads.view(all, "project", "rejected", List.of(), "partial");
assertEquals(1024, view.issues().size());
assertEquals(1030L, ((Map<?, ?>)view.summary().get("counts")).get("errors"));
assertEquals("rejected", view.summary().get("validationStatus"));
assertEquals("partial", ((Map<?, ?>)view.summary().get("coverage")).get("details"));
assertTrue(view.summary().toString().contains("LIMIT_EXCEEDED"));
var large = DiagnosticPayloads.issue("LARGE", "ERROR", "😀".repeat(300_000));
var bytes = DiagnosticPayloads.view(List.of(all.getFirst(), large, all.getLast()), "build", "failed", List.of(), "partial");
assertEquals(List.of(all.getFirst()), bytes.issues());
assertTrue(new ObjectMapper().writeValueAsBytes(bytes.issues()).length <= DiagnosticPayloads.MAX_BYTES);
assertEquals(3L, ((Map<?, ?>)bytes.summary().get("counts")).get("errors"));
}
@Test void issueIdentityAndKnownNullSurviveImmutableNeutralRoundTrip() {
var input = new LinkedHashMap<>(DiagnosticPayloads.issue("ORIGINAL", "WARNING", "observed"));
var facts = new LinkedHashMap<String, Object>(); facts.put("expectedType", DiagnosticPayloads.fact(null));
input.put("semanticContext", ImmutableJson.fields("availability", "partial", "facts", facts));
var issue = StudioDiagnostic.fromMap(input); input.clear(); facts.clear();
assertEquals(issue.toMap(), StudioDiagnostic.fromMap(issue.toMap()).toMap());
assertEquals(issue.toMap().get("issueId"), issue.toMap().get("issueId"));
assertTrue(issue.toMap().toString().contains("expectedType"));
assertThrows(UnsupportedOperationException.class, () -> issue.toMap().put("code", "other"));
var legacy = new StudioDiagnostic("OLD", DiagnosticSeverity.INFO, "legacy");
assertEquals(legacy.toMap().get("issueId"), legacy.toMap().get("issueId"));
var additive = new StudioDiagnostic("PARTIAL", DiagnosticSeverity.INFO, "custom details", Map.of("facts", Map.of("observed", 1)));
assertEquals(additive.toMap().get("issueId"), additive.toMap().get("issueId"));
assertEquals(additive.toMap(), StudioDiagnostic.fromMap(additive.toMap()).toMap());
assertNull(((Map<?, ?>)DiagnosticPayloads.legacySummary("build").get("counts")).get("errors"));
}
}