feat(pbs): add Beacon Workshop composition example
Test / Tests and coverage
Intrepid/Prometeu/Studio/pipeline/head This commit looks good

Add an original-asset minigame with modern controls, independent movement
and tool animations, randomized safe beacon layouts and 2D drone patrols.
Distribute the canonical project through installed knowledge and exercise
compiled cartridges and animation boundaries.

Fix lowering of admitted sibling constants and add a regression test.
Focused compiler, installed knowledge and direct native checks passed;
user tested and approved. Full make verify remains blocked by sandbox
sysctl restrictions in ACP tests. WRK-0022 remains open.
This commit is contained in:
2026-11-26 18:37:09 +00:00
parent 533c4110f4
commit fccfeca39d
54 changed files with 3880 additions and 7 deletions
@@ -21,6 +21,7 @@ public final class InstalledKnowledgeProbe {
check(!Files.exists(Path.of("settings.gradle.kts")) && !Files.exists(Path.of("docs")), "No repository in working directory");
verifyRuntimeCatalogs(provider.getClass().getClassLoader());
if (arguments.length == 1 && arguments[0].equals("--catalog-only")) return;
verifyBeaconWorkshop(provider.getClass().getClassLoader());
var guideType = Class.forName("p.studio.app.mcp.McpConnectionGuide");
check(guideType.getProtectionDomain().getCodeSource().getLocation().getPath().endsWith(".jar"), "Lifecycle guide must come from installed JAR");
var guide = (String)guideType.getField("INSTRUCTIONS").get(null);
@@ -283,6 +284,48 @@ public final class InstalledKnowledgeProbe {
System.out.println("Packaged external sources verified: JAR bytes, SDK/host/core navigation, hover, tokens, read-only, reconnect, no extraction");
}
private static void verifyBeaconWorkshop(ClassLoader loader) throws Exception {
String resource = "pbs-knowledge/examples/game/1/beacon-workshop/distribution.json";
var location = loader.getResource(resource);
check(location != null && location.getProtocol().equals("jar"), "Beacon Workshop must come from installed JAR");
var mapper = new ObjectMapper();
Path root = Files.createDirectory(Path.of("beacon-workshop")).toRealPath();
try (var input = location.openStream()) {
for (var file : mapper.readTree(input).path("files")) {
Path target = root.resolve(file.path("path").asText()).normalize();
check(target.startsWith(root), "Packaged game path must stay inside project");
var url = loader.getResource(file.path("resource").asText());
check(url != null && url.getProtocol().equals("jar"), "Every game resource must come from installed JAR");
try (var bytes = url.openStream()) {
byte[] data = bytes.readAllBytes();
check(java.util.HexFormat.of().formatHex(java.security.MessageDigest.getInstance("SHA-256").digest(data))
.equals(file.path("sha256").asText()), "Installed game resource hash mismatch");
Files.createDirectories(target.getParent()); Files.write(target, data);
}
}
}
var setup = new ProjectLocalStudioSetupStore(mapper);
var project = new ProjectCatalogService(root.getParent(), mapper, setup).openProject(root);
try (var workers = java.util.concurrent.Executors.newSingleThreadExecutor(); var packer = p.packer.Packer.bootstrap(mapper, ignored -> {})) {
var layouts = new p.studio.app.assets.PackerGlyphBankLayouts(packer.workspaceService(), mapper);
var build = new p.studio.core.shipper.StudioShipperService(new p.studio.app.compiler.CompilerBuildGatewayAdapter(layouts),
packer.workspaceService(), mapper, new p.studio.app.operation.ExecutorOperationExecutor(workers))
.prepare(project, ignored -> {}).completion().toCompletableFuture().get(60, java.util.concurrent.TimeUnit.SECONDS);
check(build.success(), "Installed Beacon Workshop must compile and pack: " + build.diagnostics());
Path output = Path.of(System.getProperty("pbs.registryConformanceDirectory")).resolve("beacon-workshop/installed-cartridge");
try (var files = Files.walk(build.manifestPath().getParent())) {
for (Path source : files.filter(Files::isRegularFile).toList()) {
Path target = output.resolve(build.manifestPath().getParent().relativize(source).toString());
Files.createDirectories(target.getParent()); Files.copy(source, target, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
}
}
mapper.writeValue(output.resolve("installed-source.json").toFile(), java.util.Map.of("resource", location.toString(),
"programSha256", java.util.HexFormat.of().formatHex(java.security.MessageDigest.getInstance("SHA-256")
.digest(Files.readAllBytes(output.resolve("program.pbx"))))));
}
System.out.println("Installed Beacon Workshop verified: original resources, hashes, generated factories, compile and pack");
}
private static int[] position(String text, String needle, int offset) {
int index = text.indexOf(needle);
check(index >= 0, "Missing source fragment: " + needle);