feat(pbs): add sprite animation and shared Studio authoring

Implement DEC-0084 with factory-only Sprite/Animator structs, complete result
lowering, validated animation sidecars, generated PBS factories and JavaFX/MCP
authoring through shared services.

Qualify native dev/release with ordinary and optimized producers, zero-allocation
playback, private-cycle reclamation, canonical Composer pixels, installed JARs
and JavaFX lifecycle. Preserve the runtime checkout and existing host ABI.
This commit is contained in:
2026-11-05 15:16:07 +00:00
parent 1d8b8c2101
commit bf31184d4d
151 changed files with 4823 additions and 98 deletions
@@ -0,0 +1,55 @@
package p.studio.app.animation;
import java.nio.file.*;
import p.animation.*;
import p.studio.api.assets.animation.AnimationService;
import p.studio.compiler.models.BuilderPipelineContext;
import p.studio.compiler.messages.BuilderPipelineConfig;
import p.studio.compiler.workspaces.BuilderPipelineService;
import p.studio.compiler.backend.bytecode.BytecodeEmitter;
import p.studio.utilities.logs.LogAggregator;
/** Runs only with installed product JARs, outside the checkout. No runtime checkout is read. */
public final class AnimationInstalledProbe {
public static void verify(Path root,Path corpus)throws Exception{
var f=new AnimationProjectFixture();f.root=root;f.setup();
try{
f.manual.execute(AnimationService.Request.save(f.project,f.uuid,null,f.document()));
Files.writeString(root.resolve("src/mod.barrel"),"pub fn frame()->void;pub fn animationProbe()->int;");
Files.writeString(root.resolve("src/main.pbs"),"import { create_hero } from @app:generated/animations/b_"+f.uuid.toString().replace("-","")+";\n"+"""
import { AnimationError } from @core:animation;
declare global trace:int=0;
fn run()->result<AnimationError> {
let value=create_hero(3)!;let other=create_hero(3)!;
value.play("idle")!;value.advance(2)!;
if value.sprite().glyph_id!=1 || other.sprite().glyph_id!=0 {let fail=1/0;}
trace=42;return ok(());
}
[Frame]fn frame()->void {run();}
fn animationProbe()->int {return trace;}
""");
var context=BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false,root.toString()));context.glyphBankLayoutSource=f.layouts;
var result=BuilderPipelineService.INSTANCE.compile(context,LogAggregator.stdout());
if(result.diagnostics().stream().anyMatch(d->d.isError()))throw new AssertionError(result.diagnostics());
Files.createDirectories(corpus);
for(boolean optimized:new boolean[]{false,true}){
var program=optimized?context.optimizedIrvm:context.irvm;
var module=new BytecodeEmitter().emit(program.coherentEmissionPlan());
String prefix="pbs-animation-installed"+(optimized?"-optimized":"");Files.write(corpus.resolve(prefix+".pbx"),module.serialize());
for(int i=0;i<program.module().functions().size();i++)if(program.module().functions().get(i).name().contains("animationProbe"))Files.writeString(corpus.resolve(prefix+".probe"),Integer.toString(i));
}
var bridge=new p.studio.lsp.services.compiler.CompilerLanguageServiceBridge(f.layouts);
var lsp=new p.studio.lsp.messages.LspProjectContext("app","pbs",root);
for(var id:context.fileTable.identifiers()){
var path=context.fileTable.get(id).getCanonPath();if(path.startsWith(Path.of("/virtual/generated/animations"))&&path.endsWith("main.pbs")){
var source=bridge.currentSource(lsp,path).orElseThrow();
if(!source.readOnly()||source.origins().isEmpty())throw new AssertionError("Installed generated origins");
}
}
var schema=AnimationInstalledProbe.class.getClassLoader().getResource("mcp/studio-tools-v1.json");
if(schema==null||!schema.getProtocol().equals("jar"))throw new AssertionError("Installed MCP schema missing");
try(var input=schema.openStream()){String text=new String(input.readAllBytes(),java.nio.charset.StandardCharsets.UTF_8);for(var name:new String[]{"studio_animation_query","studio_animation_update"})if(!text.contains(name))throw new AssertionError(name);}
System.out.println("Installed generated animation verified: shared save, factories, read-only origins, MCP schemas, ordinary/optimized corpus");
}finally{f.close();}
}
}