fix(pbs): exclude transient state from packaged example knowledge
Test / Tests and coverage
Intrepid/Prometeu/Studio/pipeline/head This commit looks good

Keep canonical asset identities and verify cache-independent packaging and installed references.

Work: WRK-0027. Validation: make -C tooling verify, run 20261127T004152Z-e028bb55, PASSED.
This commit is contained in:
2026-11-27 00:51:37 +00:00
parent a2494e7d70
commit 219969b9e6
6 changed files with 71 additions and 1 deletions
@@ -17,7 +17,10 @@ val pbsResources = layout.projectDirectory.dir("src/main/resources")
val beaconWorkshop = rootProject.layout.projectDirectory.dir("test-projects/beacon-workshop")
val beaconFiles = fileTree(beaconWorkshop) {
include("src/**", "assets/**", "tools/*.py", "*.md", "prometeu.json", ".gitignore")
exclude("**/__pycache__/**")
// Local packer state and in-flight publications are not example source material.
// Keep assets/.prometeu/index.json: it owns the canonical asset identities.
exclude("assets/.prometeu/cache.json", "**/__pycache__/**",
"**/.asset-publish-*.tmp", "**/.record-*.tmp", "**/.animation-*.tmp")
}
val generatePbsKnowledge by tasks.registering(Sync::class) {
from(pbsSpecs) { include("*.md"); into("pbs-knowledge/specs") }
@@ -9,6 +9,35 @@ import java.util.*;
import static org.junit.jupiter.api.Assertions.*;
class PbsDocumentationTest {
@Test void beaconDistributionPreservesCanonicalAssetsAndExcludesTransientState() throws Exception {
String prefix = "pbs-knowledge/examples/game/1/beacon-workshop/";
var loader = getClass().getClassLoader();
var paths = new HashSet<String>();
var references = new PbsDocumentation().references(1, AppMode.Game).stream()
.map(FrontendReferenceProvider.Reference::id).collect(java.util.stream.Collectors.toSet());
try (var stream = loader.getResourceAsStream(prefix + "distribution.json")) {
assertNotNull(stream);
for (var file : new com.fasterxml.jackson.databind.ObjectMapper().readTree(stream).path("files")) {
String path = file.path("path").asText();
assertTrue(paths.add(path), path);
assertFalse(path.equals("assets/.prometeu/cache.json") || path.contains("__pycache__/")
|| path.matches("(?:.*/)?\\.(?:asset-publish|record|animation)-.*\\.tmp"), path);
assertEquals(prefix + path, file.path("resource").asText());
try (var content = loader.getResourceAsStream(prefix + path)) {
assertNotNull(content, path);
assertEquals(file.path("sha256").asText(), HexFormat.of().formatHex(
java.security.MessageDigest.getInstance("SHA-256").digest(content.readAllBytes())), path);
}
assertEquals(!path.endsWith(".png"), references.contains("pbs:example:game:1:beacon-workshop/" + path), path);
}
}
assertTrue(paths.containsAll(List.of("prometeu.json", "src/main.pbs", "assets/.prometeu/index.json",
"assets/workshop/asset.json", "assets/workshop/animations.studio.json",
"assets/workshop/beacon_on.png", "assets/room/scene-bank.pack-request.json")));
assertNull(loader.getResource(prefix + "assets/.prometeu/cache.json"));
assertFalse(references.contains("pbs:example:game:1:beacon-workshop/assets/.prometeu/cache.json"));
}
@Test void publishedFeatureIdsResolveToTheSameCanonicalChapterResourceAndHash() throws Exception {
// These IDs were published before the chapters were numbered.
var legacyIds = List.of("typed-arrays-and-optional-execution.md",