feat(studio): deliver asset authoring and automation workflows
Add shared human/task asset batches with reviewed atomic publication, explicit reference rebinds, ownership inspection and qualified glyph/scene budgets. Expose the same authoring and capacity results through Assets and MCP. Deliver isolated guest test targets, retained visual evidence and immutable runtime lifecycle/control observations. Preserve provider qualification and installed authoring examples alongside the completed discussion lessons. Close AGD-106 coordination and the delivered discussion workflows through housekeeping, updating lesson references and preserving qualification limits. Sound remains outside the asset delivery wave. Validation: 579 module tests and 31 additional desktop, process and installed checks passed; native glyph/scene 16/17 boundaries qualified. Discussion validation passed after housekeeping.
This commit is contained in:
+104
@@ -0,0 +1,104 @@
|
||||
package p.studio.api.assets;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class AssetAuthoringContractTest {
|
||||
private static final String DIGEST = "a".repeat(64);
|
||||
private static final AssetReference BANK = AssetReference.forAssetId(42);
|
||||
|
||||
@Test void previewCanRepresentRebindRejectionAndConflictWithoutPublishing() {
|
||||
var revision = revision();
|
||||
var oldGlyph = new AssetBatches.Artifact(BANK, "original-artifact");
|
||||
var animation = new AssetBatches.ReferenceUse(BANK, AssetBatches.ReferenceKind.animation, "walk.frames[0]", oldGlyph);
|
||||
var rebind = new AssetBatches.Rebind(oldGlyph, new AssetBatches.Artifact(BANK, "replacement-artifact"), List.of(animation));
|
||||
var ownership = new AssetBatches.Ownership(BANK, "assets/hero/atlas.png", "internal:glyph-pack", List.of(BANK), true);
|
||||
var request = new AssetBatches.Request(revision,
|
||||
List.of(new AssetBatches.ComposeBank("reorder", BANK, List.of("g1.png", "g0.png"))), List.of(), List.of(ownership));
|
||||
var nested = new ArrayList<>(List.of(0));
|
||||
var diagnostic = new AssetBatches.Diagnostic("packer", "EXPLICIT_REBIND_REQUIRED", "error", "Referenced glyph reordered", true,
|
||||
"assets/hero", "assets/hero/animation.json", AssetFamily.GLYPH_BANK,
|
||||
List.of(), List.of(), List.of(animation), null, null, null, Map.of("references", nested));
|
||||
nested.clear();
|
||||
var rejected = new AssetBatches.Preview("batch", "preview-request", revision, request,
|
||||
AssetBatches.PreviewState.rejected, List.of(), List.of(BANK), List.of(animation), List.of(ownership), List.of(), List.of(diagnostic));
|
||||
assertFalse(rejected.canCommit());
|
||||
assertEquals(List.of(0), rejected.diagnostics().getFirst().context().get("references"));
|
||||
assertEquals(List.of(animation), rebind.references());
|
||||
var conflict = new AssetBatches.Conflict("prometeu.json", DIGEST, "b".repeat(64), "Input changed externally");
|
||||
assertFalse(new AssetBatches.Preview("batch", "preview-request", revision, request, AssetBatches.PreviewState.conflict,
|
||||
List.of(), List.of(BANK), List.of(), List.of(), List.of(conflict), List.of()).canCommit());
|
||||
assertThrows(IllegalArgumentException.class, () -> new AssetBatches.Preview("batch", "preview-request", revision,
|
||||
request, AssetBatches.PreviewState.ready, List.of(), List.of(), List.of(), List.of(), List.of(), List.of(diagnostic)));
|
||||
assertThrows(IllegalArgumentException.class, () -> new AssetBatches.ImportPng("import",
|
||||
new AssetBatches.PngInput(null, "grant", DIGEST), BANK, "../outside.png"));
|
||||
assertEquals("inputs/hero.png", new AssetBatches.PngInput("inputs/hero.png", null, DIGEST).projectRelativePath());
|
||||
assertThrows(IllegalArgumentException.class, () -> new AssetBatches.PngInput("../outside.png", null, DIGEST));
|
||||
}
|
||||
|
||||
@Test void noOpAndRecoveredAppliedResultsRemainDistinctFromCancellationBeforeCommit() {
|
||||
var before = revision();
|
||||
var after = new AssetBatches.Revision(1, "b".repeat(64), Map.of("prometeu.json", DIGEST), Set.of());
|
||||
var file = new AssetBatches.FileChange("assets/hero/g0.png", AssetBatches.FileAction.create, null, DIGEST);
|
||||
var request = new AssetBatches.Request(before, List.of(), List.of(), List.of());
|
||||
assertTrue(new AssetBatches.Preview("batch", "preview", before, request, AssetBatches.PreviewState.no_op,
|
||||
List.of(), List.of(BANK), List.of(), List.of(), List.of(), List.of()).canCommit());
|
||||
for (var state : List.of(AssetBatches.CommitState.committed, AssetBatches.CommitState.recovered)) {
|
||||
var result = new AssetBatches.Result("batch", "commit", state, before, after, List.of(file), List.of(BANK), List.of(), List.of());
|
||||
assertTrue(result.applied()); assertEquals(after, result.after());
|
||||
}
|
||||
assertTrue(new AssetBatches.Result("batch", "commit", AssetBatches.CommitState.no_op,
|
||||
before, before, List.of(), List.of(BANK), List.of(), List.of()).applied());
|
||||
assertFalse(new AssetBatches.Result("batch", "commit", AssetBatches.CommitState.cancelled,
|
||||
before, before, List.of(), List.of(), List.of(), List.of()).applied());
|
||||
assertThrows(IllegalArgumentException.class, () -> new AssetBatches.Result("batch", "commit", AssetBatches.CommitState.cancelled,
|
||||
before, after, List.of(file), List.of(BANK), List.of(), List.of()));
|
||||
assertThrows(IllegalArgumentException.class, () -> new AssetBatches.Revision(1, DIGEST,
|
||||
Map.of("prometeu.json", DIGEST), Set.of("prometeu.json")));
|
||||
}
|
||||
|
||||
@Test void unknownCapacityAllowsUnqualifiedBuildButCannotStartManagedExecution() {
|
||||
var unknown = snapshot(AssetBudgets.ProfileSelection.unknown(null, "No selected runtime/profile"), 17, 0);
|
||||
assertTrue(unknown.buildAllowed()); assertFalse(unknown.managedExecutionAllowed());
|
||||
assertNull(unknown.pools().getFirst().limit());
|
||||
var selection = new AssetBudgets.ProfileSelection(AssetBudgets.QualificationState.known, DIGEST, profile(), "Exact executable qualified");
|
||||
var atLimit = snapshot(selection, 16, 1);
|
||||
assertTrue(atLimit.buildAllowed()); assertTrue(atLimit.managedExecutionAllowed());
|
||||
assertEquals(16, atLimit.pools().getFirst().requiredSlots());
|
||||
assertTrue(atLimit.pools().getFirst().potentialExceedsKnownLimit());
|
||||
var excess = snapshot(selection, 17, 0);
|
||||
assertFalse(excess.buildAllowed()); assertFalse(excess.managedExecutionAllowed());
|
||||
assertThrows(IllegalArgumentException.class, () -> new AssetBudgets.ProfileSelection(
|
||||
AssetBudgets.QualificationState.known, "b".repeat(64), profile(), "Changed executable"));
|
||||
var incompleteEvidence = profile().evidence().subList(0, 2);
|
||||
assertThrows(IllegalArgumentException.class, () -> new AssetBudgets.Profile(1, "fixture", "fixture", DIGEST, profile().limits(), incompleteEvidence));
|
||||
assertThrows(IllegalArgumentException.class, () -> new AssetBudgets.Snapshot(revision(), selection, List.of(), List.of(), List.of()));
|
||||
}
|
||||
|
||||
private AssetBatches.Revision revision() {
|
||||
return new AssetBatches.Revision(1, DIGEST, Map.of("prometeu.json", DIGEST,
|
||||
"assets/.prometeu/index.json", DIGEST), Set.of("assets/hero/new.png"));
|
||||
}
|
||||
private AssetBudgets.Profile profile() {
|
||||
var evidence = Arrays.stream(AssetBudgets.BankType.values()).map(type ->
|
||||
new AssetBudgets.BoundaryEvidence(type, 16, 17, "fixture/" + type + ".json", DIGEST)).toList();
|
||||
return new AssetBudgets.Profile(1, "fixture-only", "fixture-runtime", DIGEST,
|
||||
Map.of(AssetBudgets.BankType.glyph, 16, AssetBudgets.BankType.sound, 16, AssetBudgets.BankType.scene, 16), evidence);
|
||||
}
|
||||
private AssetBudgets.Snapshot snapshot(AssetBudgets.ProfileSelection selection, int preloads, int potential) {
|
||||
var pools = Arrays.stream(AssetBudgets.BankType.values()).map(type -> {
|
||||
var banks = java.util.stream.IntStream.range(0, preloads).mapToObj(index -> new AssetBudgets.Bank(
|
||||
AssetReference.forAssetId(index + 42), "assets/" + type + "/bank-" + index)).toList();
|
||||
var slots = java.util.stream.IntStream.range(0, preloads).mapToObj(index ->
|
||||
new AssetBudgets.Preload(banks.get(index), index, List.of())).toList();
|
||||
var dynamic = java.util.stream.IntStream.range(0, potential).mapToObj(index -> new AssetBudgets.Bank(
|
||||
AssetReference.forAssetId(1000 + index), "assets/" + type + "/dynamic-" + index)).toList();
|
||||
return new AssetBudgets.Pool(type, banks, banks, slots, dynamic,
|
||||
selection.profile() == null ? null : selection.profile().limits().get(type));
|
||||
}).toList();
|
||||
return new AssetBudgets.Snapshot(revision(), selection, List.of(), pools, List.of());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package p.studio.api.automation;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.math.BigInteger;
|
||||
import java.util.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class EvidenceTest {
|
||||
@Test void imageAndReadValuesNeverExposeMutableBackingArrays() {
|
||||
byte[] bytes={1,2,3,4};var image=new Evidence.Pixels(1,1,bytes);var read=new Evidence.Read("id",0,4,bytes);
|
||||
bytes[0]=99;image.rgba()[0]=98;read.bytes()[0]=97;
|
||||
assertEquals(1,image.channel(0,0,0));assertEquals(1,read.bytes()[0]);
|
||||
assertThrows(IllegalArgumentException.class,()->new Evidence.Pixels(2,1,bytes));
|
||||
assertThrows(IllegalArgumentException.class,()->image.channel(1,0,0));
|
||||
}
|
||||
@Test void historicalCountersRemainLosslessAndProvenanceIsDeeplyImmutable() {
|
||||
var max=new BigInteger("18446744073709551615");var mutable=new LinkedHashMap<String,Object>();
|
||||
mutable.put("frameId",max.toString());mutable.put("logicalFrameIndex",0);mutable.put("source",new ArrayList<>(List.of("original")));
|
||||
var artifact=new Evidence.Artifact(UUID.randomUUID().toString(),UUID.randomUUID().toString(),"a".repeat(64),32,"image/png",1,1,mutable);
|
||||
mutable.put("frameId",0);assertEquals(max,artifact.provenance().get("frameId"));assertEquals(BigInteger.ZERO,artifact.provenance().get("logicalFrameIndex"));
|
||||
assertThrows(UnsupportedOperationException.class,()->artifact.provenance().put("frameId",1));
|
||||
assertThrows(UnsupportedOperationException.class,()->((List<Object>)artifact.provenance().get("source")).add("changed"));
|
||||
}
|
||||
@Test void alphaBoundsAndZeroSizedOrOutOfBoundsRegionsCannotInventAValidComparison() {
|
||||
assertThrows(NullPointerException.class,()->Evidence.Parameters.exact(null));
|
||||
assertThrows(IllegalArgumentException.class,()->new Evidence.Parameters(null,List.of(),Evidence.Alpha.compare,-1,0));
|
||||
assertThrows(IllegalArgumentException.class,()->new Evidence.Rect(0,0,0,1));
|
||||
assertThrows(IllegalArgumentException.class,()->new Evidence.Rect(Integer.MAX_VALUE,0,Integer.MAX_VALUE,1).requireInside(100,100));
|
||||
assertEquals(512L*1024*1024,Evidence.DEFAULT_QUOTA);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package p.studio.api.automation;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.math.BigInteger;
|
||||
import java.util.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class GuestTestsTest {
|
||||
GuestTests.Target target(String id) {return new GuestTests.Target(id,"tests/"+id+"/main.pbs",List.of("src","tests/"+id),List.of("tests/support"),List.of("src/main.pbs"),List.of("first","second"),41000);}
|
||||
@Test void twoTargetsAndOmittedProductionSelectionDoNotChangeProjectMachineIdentity() {
|
||||
var catalog=new GuestTests.Catalog(1,List.of(target("life"),target("shop-save")));
|
||||
assertEquals(2,catalog.targets().size());assertTrue(new GuestTests.Selection(null).production());assertFalse(new GuestTests.Selection("life").production());
|
||||
assertThrows(IllegalArgumentException.class,()->new GuestTests.Catalog(1,List.of(target("life"),target("life"))));
|
||||
assertThrows(IllegalArgumentException.class,()->target("production"));assertThrows(IllegalArgumentException.class,()->new GuestTests.Catalog(2,List.of()));
|
||||
assertThrows(IllegalArgumentException.class,()->new GuestTests.Target("escape","../main.pbs",List.of("src"),List.of(),List.of(),List.of(),1));
|
||||
}
|
||||
@Test void provenanceAndSequenceZeroThroughUint64MaximumAreImmutableAndLossless() {
|
||||
var hashes=new HashMap<String,String>();hashes.put("src/main.pbs","a".repeat(64));
|
||||
var provenance=new GuestTests.BuildProvenance("life","build","tests/life/main.pbs",hashes,Map.of(),Map.of(),Map.of("target","Game"),"revision");
|
||||
hashes.clear();assertEquals(1,provenance.sourceSha256().size());
|
||||
var zero=new GuestTests.LogEvent(BigInteger.ZERO,BigInteger.ZERO,BigInteger.ZERO,"info","app",3L,41000,"{}");
|
||||
var max=new BigInteger("18446744073709551615");var last=new GuestTests.LogEvent(max,max,max,"info","app",3L,41000,"{}");
|
||||
var page=new GuestTests.LogPage("session",BigInteger.ZERO,List.of(zero),BigInteger.ZERO,BigInteger.ZERO,BigInteger.ZERO,false,false);
|
||||
var finalPage=new GuestTests.LogPage("session",BigInteger.ONE,List.of(last),max,max,max,true,true);
|
||||
assertEquals(BigInteger.ZERO,page.events().getFirst().sequence());assertEquals(max,finalPage.nextAfterSequence());
|
||||
assertThrows(IllegalArgumentException.class,()->new GuestTests.LogPage("session",BigInteger.ZERO,List.of(last,zero),BigInteger.ZERO,max,max,false,false));
|
||||
}
|
||||
@Test void everyCaseStateIsRepresentableButEmptyIncompleteOrFailedAssertionsCannotPass() {
|
||||
for(var state:GuestTests.CaseState.values())assertEquals(state,new GuestTests.CaseResult("case",state,List.of(),List.of()).state());
|
||||
assertThrows(IllegalArgumentException.class,()->result(GuestTests.Completion.completed,false,List.of()));
|
||||
var passed=new GuestTests.CaseResult("case",GuestTests.CaseState.passed,List.of(new GuestTests.Assertion("health","public API",10,10,true)),List.of());
|
||||
assertEquals(GuestTests.CaseState.passed,result(GuestTests.Completion.completed,true,List.of(passed)).verdict());
|
||||
assertThrows(IllegalArgumentException.class,()->result(GuestTests.Completion.timed_out,true,List.of(passed)));
|
||||
assertThrows(IllegalArgumentException.class,()->result(GuestTests.Completion.cancelled,true,List.of(passed)));
|
||||
var failed=new GuestTests.CaseResult("case",GuestTests.CaseState.failed,List.of(new GuestTests.Assertion("health","mismatch",10,9,false)),List.of());
|
||||
assertThrows(IllegalArgumentException.class,()->result(GuestTests.Completion.completed,true,List.of(failed)));
|
||||
}
|
||||
GuestTests.RunResult result(GuestTests.Completion completion,boolean complete,List<GuestTests.CaseResult> cases) {
|
||||
return new GuestTests.RunResult("run","life","build","session","operation","request",completion,GuestTests.CaseState.passed,complete,false,cases,List.of(),null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package p.studio.api.automation;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.util.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class RuntimeObservationTest {
|
||||
@Test void legacySnapshotsDoNotInventNativeAbsenceOrCleanupCompletion() {
|
||||
var snapshot = new AutomationSnapshot(java.nio.file.Path.of("."), ControlState.AGENT_WORKING, false,
|
||||
false, 0, null, null, null, false, List.of(), List.of());
|
||||
assertEquals(RuntimeObservation.Lifecycle.UNKNOWN, snapshot.runtimeObservation().lifecycle());
|
||||
assertNull(snapshot.controlObservation());
|
||||
}
|
||||
@Test void snapshotsAreDeeplyImmutableAndResetDoesNotRewritePriorProgressOrFrame() {
|
||||
var nativeState = new LinkedHashMap<String, Object>(); nativeState.put("status", "paused");
|
||||
var finished = RuntimeObservation.unknown("session", "build")
|
||||
.transition(RuntimeObservation.Lifecycle.BOOTED, "boot", Map.of("state", nativeState))
|
||||
.withProgress(new TrackedOperation.Progress(3L, 3L))
|
||||
.withCapture(new CanonicalCapture("session", "build", 3, 91, 1, 1, 1, new byte[]{1}));
|
||||
nativeState.put("status", "changed");
|
||||
var reset = finished.transition(RuntimeObservation.Lifecycle.UNBOOTED, "reset", Map.of());
|
||||
assertEquals(3L, finished.progress().completedFrames()); assertNotNull(finished.lastFrame());
|
||||
assertFalse(finished.captureStale()); assertTrue(reset.captureStale());
|
||||
assertNull(reset.lastFrame()); assertNull(reset.progress().completedFrames());
|
||||
assertEquals("paused", ((Map<?, ?>)finished.nativeDetails().get("state")).get("status"));
|
||||
assertThrows(UnsupportedOperationException.class, () -> finished.nativeDetails().clear());
|
||||
assertTrue(reset.recovery().stream().anyMatch(action -> action.action().equals("boot")));
|
||||
assertTrue(reset.recovery().stream().noneMatch(RuntimeObservation.RecoveryAction::automatic));
|
||||
}
|
||||
@Test void lostSessionRetainsOnlyKnownProgressAndLookupNeverSuggestsReplay() {
|
||||
var before = RuntimeObservation.unknown("session", "build").withProgress(new TrackedOperation.Progress(60L, null));
|
||||
var lost = before.transition(RuntimeObservation.Lifecycle.LOST, "process_supervisor", Map.of())
|
||||
.withContext(Map.of("clientRequestId", "original"));
|
||||
assertNull(lost.progress().completedFrames());
|
||||
assertEquals(Set.of("new_session", "lookup_operation"), lost.recovery().stream().map(RuntimeObservation.RecoveryAction::action).collect(java.util.stream.Collectors.toSet()));
|
||||
assertEquals(2, lost.withContext(Map.of("clientRequestId", "original")).recovery().size());
|
||||
assertThrows(IllegalArgumentException.class, () -> new RuntimeObservation.RecoveryAction("advance", List.of(), true));
|
||||
}
|
||||
}
|
||||
+5
-21
@@ -1,31 +1,15 @@
|
||||
package p.studio.api.diagnostic;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import p.studio.utilities.json.*;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import p.studio.api.values.ValueMaps;
|
||||
import java.util.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class DiagnosticPayloadTest {
|
||||
@Test void boundsWholeIssuesByCountAndUtf8BytesWithoutChangingEvaluation() throws Exception {
|
||||
var all = new ArrayList<Map<String, Object>>();
|
||||
for (int i = 0; i < 1030; i++) all.add(DiagnosticPayloads.issue("TEST", "ERROR", "failure " + i));
|
||||
var view = DiagnosticPayloads.view(all, "project", "rejected", List.of(), "partial");
|
||||
assertEquals(1024, view.issues().size());
|
||||
assertEquals(1030L, ((Map<?, ?>)view.summary().get("counts")).get("errors"));
|
||||
assertEquals("rejected", view.summary().get("validationStatus"));
|
||||
assertEquals("partial", ((Map<?, ?>)view.summary().get("coverage")).get("details"));
|
||||
assertTrue(view.summary().toString().contains("LIMIT_EXCEEDED"));
|
||||
var large = DiagnosticPayloads.issue("LARGE", "ERROR", "😀".repeat(300_000));
|
||||
var bytes = DiagnosticPayloads.view(List.of(all.getFirst(), large, all.getLast()), "build", "failed", List.of(), "partial");
|
||||
assertEquals(List.of(all.getFirst()), bytes.issues());
|
||||
assertTrue(new ObjectMapper().writeValueAsBytes(bytes.issues()).length <= DiagnosticPayloads.MAX_BYTES);
|
||||
assertEquals(3L, ((Map<?, ?>)bytes.summary().get("counts")).get("errors"));
|
||||
}
|
||||
@Test void issueIdentityAndKnownNullSurviveImmutableNeutralRoundTrip() {
|
||||
var input = new LinkedHashMap<>(DiagnosticPayloads.issue("ORIGINAL", "WARNING", "observed"));
|
||||
var facts = new LinkedHashMap<String, Object>(); facts.put("expectedType", DiagnosticPayloads.fact(null));
|
||||
input.put("semanticContext", ImmutableJson.fields("availability", "partial", "facts", facts));
|
||||
var input = new LinkedHashMap<>(DiagnosticValues.issue("ORIGINAL", "WARNING", "observed"));
|
||||
var facts = new LinkedHashMap<String, Object>(); facts.put("expectedType", ValueMaps.fields("value", null, "availability", "available", "reason", null));
|
||||
input.put("semanticContext", ValueMaps.fields("availability", "partial", "facts", facts));
|
||||
var issue = StudioDiagnostic.fromMap(input); input.clear(); facts.clear();
|
||||
assertEquals(issue.toMap(), StudioDiagnostic.fromMap(issue.toMap()).toMap());
|
||||
assertEquals(issue.toMap().get("issueId"), issue.toMap().get("issueId"));
|
||||
@@ -36,6 +20,6 @@ class DiagnosticPayloadTest {
|
||||
var additive = new StudioDiagnostic("PARTIAL", DiagnosticSeverity.INFO, "custom details", Map.of("facts", Map.of("observed", 1)));
|
||||
assertEquals(additive.toMap().get("issueId"), additive.toMap().get("issueId"));
|
||||
assertEquals(additive.toMap(), StudioDiagnostic.fromMap(additive.toMap()).toMap());
|
||||
assertNull(((Map<?, ?>)DiagnosticPayloads.legacySummary("build").get("counts")).get("errors"));
|
||||
assertNull(((Map<?, ?>)DiagnosticValues.legacySummary("build").get("counts")).get("errors"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user