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
@@ -0,0 +1,85 @@
package p.studio.utilities.json;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.*;
/** One bounded public view for compiler/LSP and Studio adapters. Does not interpret source language rules. */
public final class DiagnosticPayloads {
public static final int MAX_ISSUES = 1024;
public static final int MAX_BYTES = 1024 * 1024;
private static final ObjectMapper JSON = new ObjectMapper();
private DiagnosticPayloads() { }
public record View(List<Map<String, Object>> issues, Map<String, Object> summary) {
public View { issues = issues.stream().map(ImmutableJson::object).toList(); summary = ImmutableJson.object(summary); }
}
public static Map<String, Object> unavailableExplanation() {
return ImmutableJson.fields("id", null, "summary", null, "rule", null, "availability", "unavailable");
}
public static Map<String, Object> unavailableSemantics() {
return ImmutableJson.fields("availability", "unavailable", "facts", Map.of());
}
public static Map<String, Object> fact(Object value) {
return ImmutableJson.fields("value", value, "availability", "available", "reason", null);
}
public static Map<String, Object> missingFact(String reason) {
return ImmutableJson.fields("value", null, "availability", "not-recorded", "reason", reason);
}
public static Map<String, Object> limitation(String code, String message) {
return ImmutableJson.fields("code", code, "message", message);
}
public static Map<String, Object> issue(String code, String severity, String message) {
return ImmutableJson.fields("issueId", UUID.randomUUID().toString(),
"producer", ImmutableJson.fields("component", "unknown", "owner", null, "languageId", null),
"code", code, "codeOrigin", "studio-adapter", "templateId", null, "templateParameters", Map.of(),
"checkId", null, "severity", severity, "phase", null, "stageId", null, "failureKind", "unknown",
"message", message, "facts", Map.of(), "explanation", unavailableExplanation(),
"semanticContext", unavailableSemantics(), "origin", null, "related", List.of(),
"suggestedChecks", List.of(), "limitations", List.of());
}
public static View view(List<Map<String, Object>> input, String scope, String evaluation,
List<Map<String, Object>> stages, String revisionCoverage) {
long errors = input.stream().filter(i -> "ERROR".equals(i.get("severity"))).count();
long warnings = input.stream().filter(i -> "WARNING".equals(i.get("severity"))).count();
long infos = input.stream().filter(i -> "INFO".equals(i.get("severity"))).count();
var issues = new ArrayList<Map<String, Object>>();
int bytes = 2;
for (var issue : input) {
final int size;
try { size = JSON.writeValueAsBytes(issue).length + (issues.isEmpty() ? 0 : 1); }
catch (JsonProcessingException failure) { throw new IllegalArgumentException("Non-JSON diagnostic", failure); }
if (issues.size() == MAX_ISSUES || bytes + size > MAX_BYTES) break;
issues.add(issue); bytes += size;
}
boolean complete = issues.size() == input.size();
var limitations = complete ? List.of() : List.of(ImmutableJson.fields("code", "LIMIT_EXCEEDED",
"message", "Diagnostic details exceed the public payload budget", "maxIssues", MAX_ISSUES,
"maxBytes", MAX_BYTES, "totalIssues", input.size()));
var summary = ImmutableJson.fields("scope", scope, "validationStatus", evaluation,
"counts", ImmutableJson.fields("errors", errors, "warnings", warnings, "infos", infos),
"stages", stages, "coverage", ImmutableJson.fields("details", complete ? "complete" : "partial",
"revisions", revisionCoverage, "limitations", limitations));
return new View(issues, summary);
}
public static String evaluate(List<Map<String, Object>> issues) {
if (issues.stream().anyMatch(i -> "ERROR".equals(i.get("severity"))
&& Set.of("internal-failure", "infrastructure-failure", "verification-limit").contains(Objects.toString(i.get("failureKind"), "unknown")))) return "failed";
return issues.stream().anyMatch(i -> "ERROR".equals(i.get("severity"))) ? "rejected" : "passed";
}
public static Map<String, Object> stage(String id, String status) {
return ImmutableJson.fields("stageId", id, "status", status);
}
public static Map<String, Object> legacySummary(String scope) {
return ImmutableJson.fields("scope", scope, "validationStatus", "not-evaluated",
"counts", ImmutableJson.fields("errors", null, "warnings", null, "infos", null), "stages", List.of(),
"coverage", ImmutableJson.fields("details", "unavailable", "revisions", "unavailable",
"limitations", List.of(limitation("LEGACY_DIAGNOSTICS", "Producer supplied only legacy diagnostics"))));
}
}
@@ -0,0 +1,31 @@
package p.studio.utilities.json;
import java.util.*;
/** Immutable JSON-shaped values, including explicit null observations. */
public final class ImmutableJson {
private ImmutableJson() { }
public static Map<String, Object> object(Map<String, ?> source) {
var result = new LinkedHashMap<String, Object>();
if (source != null) source.forEach((key, value) -> result.put(Objects.requireNonNull(key), value(value)));
return Collections.unmodifiableMap(result);
}
public static Object value(Object source) {
if (source == null || source instanceof String || source instanceof Boolean || source instanceof Byte
|| source instanceof Short || source instanceof Integer || source instanceof Long || source instanceof Float
|| source instanceof Double || source instanceof java.math.BigInteger || source instanceof java.math.BigDecimal) return source;
if (source instanceof Map<?, ?> values) {
var result = new LinkedHashMap<String, Object>();
values.forEach((key, value) -> result.put((String) key, value(value)));
return Collections.unmodifiableMap(result);
}
if (source instanceof Collection<?> values) return values.stream().map(ImmutableJson::value).toList();
throw new IllegalArgumentException("Expected JSON scalar, map or collection, got " + source.getClass().getName());
}
public static Map<String, Object> fields(Object... pairs) {
if (pairs.length % 2 != 0) throw new IllegalArgumentException("Expected key/value pairs");
var result = new LinkedHashMap<String, Object>();
for (int i = 0; i < pairs.length; i += 2) result.put((String) pairs[i], pairs[i + 1]);
return object(result);
}
}