docs: consolidate canonical specs and preserve PBS reference IDs
This commit is contained in:
@@ -23,6 +23,7 @@ public final class InstalledKnowledgeProbe {
|
||||
if (arguments.length == 1 && arguments[0].equals("--catalog-only")) return;
|
||||
Path root = Files.createDirectory(Path.of("example")).toRealPath();
|
||||
var docs = provider.documentation().orElseThrow().references(1, p.studio.AppMode.Game);
|
||||
verifySpecificationAliases(provider.getClass().getClassLoader(), docs);
|
||||
check(docs.stream().anyMatch(r -> r.id().equals("pbs:spec:generic-contracts.md")), "Missing installed generic-contract specification");
|
||||
check(docs.stream().anyMatch(r -> r.id().equals("pbs:example:game:1:src/contracts.pbs")), "Missing installed generic-contract example");
|
||||
check(docs.stream().anyMatch(r -> r.id().equals("pbs:spec:generic-structs-and-free-functions.md")), "Missing installed generic struct/function specification");
|
||||
@@ -129,6 +130,28 @@ public final class InstalledKnowledgeProbe {
|
||||
if (!condition) throw new AssertionError(message);
|
||||
}
|
||||
|
||||
private static void verifySpecificationAliases(ClassLoader loader,
|
||||
java.util.List<p.studio.compiler.services.FrontendReferenceProvider.Reference> docs) throws Exception {
|
||||
var resource = loader.getResource("pbs-knowledge/index.json");
|
||||
check(resource != null && resource.getProtocol().equals("jar"), "Reference index must come from installed JAR");
|
||||
var entries = new java.util.HashMap<String, com.fasterxml.jackson.databind.JsonNode>();
|
||||
try (var stream = resource.openStream()) {
|
||||
new ObjectMapper().readTree(stream).get("references")
|
||||
.forEach(entry -> entries.put(entry.get("id").asText(), entry));
|
||||
}
|
||||
var aliases = docs.stream().filter(ref -> ref.id().startsWith("pbs:spec:") && ref.id().endsWith(".md")).toList();
|
||||
check(aliases.size() == 12, "All 12 published filename IDs must remain installed");
|
||||
for (var alias : aliases) {
|
||||
var old = entries.get(alias.id());
|
||||
var chapter = docs.stream().filter(ref -> ref.id().matches("pbs:spec:[0-9]+")
|
||||
&& entries.get(ref.id()).get("resource").equals(old.get("resource"))).findFirst().orElseThrow();
|
||||
check(chapter.text().equals(alias.text()), "Installed alias text mismatch: " + alias.id());
|
||||
check(entries.get(chapter.id()).get("sha256").equals(old.get("sha256")), "Installed alias hash mismatch: " + alias.id());
|
||||
check(loader.getResource(old.get("resource").asText()).getProtocol().equals("jar"), "Alias must use a canonical JAR resource");
|
||||
}
|
||||
System.out.println("Installed specification aliases verified: 12 canonical resources");
|
||||
}
|
||||
|
||||
private static void verifyRuntimeCatalogs(ClassLoader loader) throws Exception {
|
||||
var names = java.util.List.of("INTRINSICS.csv", "BUILTIN_CONSTANTS.csv", "runtime-catalog.properties");
|
||||
var compiler = new java.util.HashMap<String, byte[]>();
|
||||
|
||||
@@ -15,6 +15,7 @@ class InstalledKnowledgeTest {
|
||||
String log = runProbe();
|
||||
assertTrue(log.contains("references; example compiled"), log);
|
||||
assertTrue(log.contains("Packaged external sources verified"), log);
|
||||
assertTrue(log.contains("Installed specification aliases verified: 12 canonical resources"), log);
|
||||
assertTrue(log.contains("Installed List/Cursor execution fixture generated"), log);
|
||||
assertTrue(log.contains("Installed Linked execution fixture generated"), log);
|
||||
assertTrue(log.contains("Installed map execution fixture generated"), log);
|
||||
|
||||
Reference in New Issue
Block a user