package p.studio.app.runtime; import org.junit.jupiter.api.*; import org.junit.jupiter.api.io.TempDir; import p.studio.api.automation.*; import p.studio.app.assets.SmallAssetProject; import java.nio.file.*; import java.util.*; import java.util.concurrent.TimeUnit; import static org.junit.jupiter.api.Assertions.*; /** Provider qualification precedes publication of a consumer capacity profile. No managed-guard bypass in production. */ @org.junit.jupiter.api.Tag("integration") class AssetCapacityInstalledRuntimeTest { @TempDir Path root; @Test void actualInstalledPoolsAcceptSixteenAndRejectSeventeenGlyphAndScenePreloads()throws Exception { Path installation=Path.of(System.getProperty("studio.test.runtimeInstall","")).toRealPath(); assertTrue(Files.isExecutable(installation.resolve("prometeu-headless"))); var json=new com.fasterxml.jackson.databind.ObjectMapper();var observations=new ArrayList>(); for(String type:List.of("glyph","scene"))for(int count:List.of(16,17)) { try(var fixture=new SmallAssetProject(root.resolve(type+count))) { var source=type.equals("scene")?fixture.glyph("source",false):null; for(int i=0;ip.bankType().equals(type.toUpperCase(Locale.ROOT))).count()); var process=new ProcessBuilder(installation.resolve("prometeu").toString(),"headless","--stdio").directory(fixture.root.toFile()).start(); var session=new HeadlessProcessSession(process,json,HeadlessLimits.defaults(),"qualify-"+type+count); var record=new LinkedHashMap();record.put("bankType",type);record.put("preloads",count);record.put("plan",plan); try { session.initializeAndBoot(build.manifestPath().getParent(),fixture.root,false,Map.of()); var result=session.advance(1,progress->{});record.put("observation",result.observation());record.put("outcome",result.kind().name()); if(count==16){assertEquals(AutomationOutcome.Kind.SUCCEEDED,result.kind(),result.toString());assertEquals(1,result.completedFrames());} else assertNotEquals(AutomationOutcome.Kind.SUCCEEDED,result.kind(),"Seventeenth preload must be rejected by the native pool"); }catch(AutomationException failure) { record.put("failure",failure.failure());assertEquals(17,count,"Sixteen native preloads must boot and execute"); var nativeFacts=json.valueToTree(failure.failure().runtimeError()); assertEquals("boot_failed",nativeFacts.path("code").asText(),nativeFacts.toString()); assertEquals("vm_panic",nativeFacts.path("details").path("fault").path("kind").asText(),nativeFacts.toString()); assertEquals("Cartridge preload failed: BackendError",nativeFacts.path("details").path("fault").path("message").asText(),nativeFacts.toString()); }finally { record.put("nativeObservation",session.observation()); try{session.shutdown().toCompletableFuture().get(7,TimeUnit.SECONDS);}finally{if(session.alive())session.abort("Capacity qualification cleanup");} } record.put("expected",count==16?"accepted":"rejected");observations.add(record); } } Path output=Path.of("build/asset-authoring-qualification");Files.createDirectories(output); var executables=new TreeMap();for(String file:List.of("prometeu","prometeu-headless","prometeu-runtime"))executables.put(file,HexFormat.of().formatHex(java.security.MessageDigest.getInstance("SHA-256").digest(Files.readAllBytes(installation.resolve(file))))); var nativeObservation=(RuntimeObservation)observations.getFirst().get("nativeObservation"); json.writerWithDefaultPrettyPrinter().writeValue(output.resolve("native-capacity-boundaries.json").toFile(),Map.of("installation",installation.toString(),"runtimeVersion",nativeObservation.nativeDetails().get("runtimeVersion"),"executables",executables,"observations",observations,"scope","Actual packaged native 16/17 qualification, glyph/scene only; no runtime writes/builds or larger guest budgets. Native rejection reports the existing aggregate preload BackendError, not a fabricated slot detail.")); } }