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:
+11
-1
@@ -6,7 +6,15 @@ public record BuilderPipelineConfig(
|
||||
boolean explain,
|
||||
String rootProjectPath,
|
||||
String vmProfile,
|
||||
SourceProviderFactory sourceProviderFactory) {
|
||||
SourceProviderFactory sourceProviderFactory,
|
||||
String buildTargetId,
|
||||
java.nio.file.Path outputDirectory) {
|
||||
public BuilderPipelineConfig(boolean explain, String rootProjectPath, String vmProfile, SourceProviderFactory factory, String buildTargetId) {
|
||||
this(explain, rootProjectPath, vmProfile, factory, buildTargetId, null);
|
||||
}
|
||||
public BuilderPipelineConfig(boolean explain, String rootProjectPath, String vmProfile, SourceProviderFactory factory) {
|
||||
this(explain, rootProjectPath, vmProfile, factory, "production", null);
|
||||
}
|
||||
|
||||
public BuilderPipelineConfig(
|
||||
final boolean explain,
|
||||
@@ -22,6 +30,8 @@ public record BuilderPipelineConfig(
|
||||
}
|
||||
|
||||
public BuilderPipelineConfig {
|
||||
buildTargetId = buildTargetId == null ? "production" : buildTargetId;
|
||||
if (!buildTargetId.matches("[A-Za-z0-9][A-Za-z0-9_.-]{0,127}")) throw new IllegalArgumentException("Invalid build target ID");
|
||||
vmProfile = vmProfile == null || vmProfile.isBlank() ? "core-v1" : vmProfile;
|
||||
sourceProviderFactory = sourceProviderFactory == null ? SourceProviderFactory.filesystem() : sourceProviderFactory;
|
||||
}
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class FrontendPhasePipelineStage implements PipelineStage {
|
||||
ctx.resolvedWorkspace.stdlib(),
|
||||
ctx.resolvedWorkspace.target(),
|
||||
p.studio.compiler.messages.HostAdmissionContext.permissiveDefault(),
|
||||
surface);
|
||||
surface, ctx.resolvedWorkspace.buildTargetId(), ctx.resolvedWorkspace.mainProject().getEntrypoint());
|
||||
final var diagnostics = DiagnosticSink.empty();
|
||||
ctx.irBackend = provider.compiler().compile(frontendPhaseContext, diagnostics, logs, issues);
|
||||
adaptDiagnostics(diagnostics, issues);
|
||||
|
||||
+19
-1
@@ -37,6 +37,7 @@ public class LoadSourcesPipelineStage implements PipelineStage {
|
||||
logs.using(log).debug("Project [ " + pd.getName() + " ] source loading...");
|
||||
|
||||
final var allowedExtensions = normalize(ctx.resolvedWorkspace.frontendSpec().getAllowedExtensions());
|
||||
final var selectedFiles = new java.util.TreeSet<Path>();
|
||||
// Iterates source roots; crawls files; registers them
|
||||
for (final var sourceRootPath : pd.getSourceRoots()) {
|
||||
logs.using(log).debug("Walking source root [ " + sourceRootPath + " ]");
|
||||
@@ -54,8 +55,25 @@ public class LoadSourcesPipelineStage implements PipelineStage {
|
||||
.exception(e));
|
||||
}
|
||||
|
||||
registerFiles(pId, pd, paths, ctx, logs, issues);
|
||||
selectedFiles.addAll(paths);
|
||||
}
|
||||
if (pd.getTestTarget() != null) {
|
||||
for (var exclusion : pd.getTestTarget().exclusions()) {
|
||||
final Path declared = pd.getRootPath().resolve(exclusion);
|
||||
try {
|
||||
if (!selectedFiles.contains(declared.toRealPath()))
|
||||
issues.report(b -> b.error(true).code("TEST_TARGET_EXCLUSION_INVALID")
|
||||
.message("Exact test exclusion is not an eligible selected source: " + declared));
|
||||
} catch (IOException failure) {
|
||||
issues.report(b -> b.error(true).code("TEST_TARGET_EXCLUSION_INVALID").message("Missing exact test exclusion: " + declared));
|
||||
}
|
||||
}
|
||||
}
|
||||
selectedFiles.removeIf(path -> pd.getExcludedSources().asList().contains(path)
|
||||
|| pd.getExcludedSourceRoots().stream().anyMatch(path::startsWith));
|
||||
if (pd.getEntrypoint() != null && !selectedFiles.contains(pd.getEntrypoint()))
|
||||
issues.report(b -> b.error(true).code("TEST_TARGET_ENTRYPOINT_INVALID").message("Selected entrypoint was not admitted: " + pd.getEntrypoint()));
|
||||
registerFiles(pId, pd, new ArrayList<>(selectedFiles), ctx, logs, issues);
|
||||
}
|
||||
|
||||
private static void registerFiles(
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ public class ResolveDepsPipelineStage implements PipelineStage {
|
||||
.message("[BUILD]: root project directory no found: " + ctx.config.rootProjectPath())
|
||||
.exception(e));
|
||||
}
|
||||
final var dependencyConfig = new DependencyConfig(ctx.config.explain(), ctx.rootProjectPathCanon);
|
||||
final var dependencyConfig = new DependencyConfig(ctx.config.explain(), ctx.rootProjectPathCanon, ctx.config.buildTargetId());
|
||||
ctx.resolvedWorkspace = DependencyService.INSTANCE.run(dependencyConfig, logs);
|
||||
ctx.fileTable = new FileTable(ctx.resolvedWorkspace.graph().projectTable().size());
|
||||
return BuildingIssueSink.empty();
|
||||
|
||||
+11
-3
@@ -38,15 +38,23 @@ public class WriteBytecodeArtifactPipelineStage implements PipelineStage {
|
||||
.message("[BUILD]: bytecode bytes are missing before WriteBytecodeArtifact stage"));
|
||||
}
|
||||
|
||||
final var outputDir = ctx.rootProjectPathCanon.resolve(OUTPUT_DIR);
|
||||
if (!"production".equals(ctx.config.buildTargetId()) && ctx.config.outputDirectory() == null)
|
||||
return BuildingIssueSink.empty().report(b -> b.error(true).code("TEST_TARGET_OUTPUT_REQUIRED")
|
||||
.message("Test builds require an exclusive target/build output directory"));
|
||||
final var outputDir = ctx.config.outputDirectory() == null ? ctx.rootProjectPathCanon.resolve(OUTPUT_DIR)
|
||||
: ctx.config.outputDirectory().toAbsolutePath().normalize();
|
||||
final var outputPath = outputDir.resolve(OUTPUT_FILE);
|
||||
try {
|
||||
var existingParent = outputDir;
|
||||
while (existingParent != null && !Files.exists(existingParent, java.nio.file.LinkOption.NOFOLLOW_LINKS)) existingParent = existingParent.getParent();
|
||||
if (existingParent == null || !existingParent.toRealPath().startsWith(ctx.rootProjectPathCanon.toRealPath())) throw new IOException("Build output escapes the project");
|
||||
Files.createDirectories(outputDir);
|
||||
if (!outputDir.toRealPath().startsWith(ctx.rootProjectPathCanon.toRealPath())) throw new IOException("Build output escapes the project");
|
||||
Files.write(
|
||||
outputPath,
|
||||
bytes,
|
||||
StandardOpenOption.CREATE,
|
||||
StandardOpenOption.TRUNCATE_EXISTING,
|
||||
"production".equals(ctx.config.buildTargetId()) ? StandardOpenOption.CREATE : StandardOpenOption.CREATE_NEW,
|
||||
"production".equals(ctx.config.buildTargetId()) ? StandardOpenOption.TRUNCATE_EXISTING : StandardOpenOption.WRITE,
|
||||
StandardOpenOption.WRITE);
|
||||
ctx.bytecodeArtifactPath = outputPath;
|
||||
logs.using(log).info("[BUILD]: wrote bytecode artifact to " + outputPath);
|
||||
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package p.studio.compiler.workspaces;
|
||||
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import p.studio.compiler.messages.*;
|
||||
import p.studio.compiler.models.*;
|
||||
import p.studio.compiler.utilities.SourceProviderFactory;
|
||||
import p.studio.utilities.logs.LogAggregator;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class IsolatedBuildTargetsTest {
|
||||
@TempDir Path root;
|
||||
@BeforeEach void fixture()throws Exception {
|
||||
root=root.toRealPath();
|
||||
write("prometeu.json","""
|
||||
{"name":"fixture","version":"1.0.0","language":"pbs","stdlib":"1","target":"Game","app_id":123,"dependencies":[],
|
||||
"testTargets":{"schemaVersion":1,"targets":[
|
||||
{"id":"life","entrypoint":"tests/life/main.pbs","sourceRoots":["src","tests/life"],"supportRoots":["tests/support"],"exclusions":["src/main.pbs"],"cases":["health"],"logTag":41000},
|
||||
{"id":"shop-save","entrypoint":"tests/shop/main.pbs","sourceRoots":["src","tests/shop"],"supportRoots":["tests/support"],"exclusions":["src/main.pbs"],"cases":["save"],"logTag":41001}]}}
|
||||
""");
|
||||
write("src/main.pbs","[Frame] fn frame() -> void {}\n");
|
||||
write("src/mod.barrel","pub fn frame() -> void;\n");
|
||||
write("src/domain/main.pbs","fn alive() -> bool { return true; }\n");
|
||||
write("src/domain/mod.barrel","pub fn alive() -> bool;\n");
|
||||
write("tests/life/main.pbs","import { alive } from @fixture:domain; import { check } from @fixture:assert; [Frame] fn frame() -> void { let health: bool = check(alive()); }\n");
|
||||
write("tests/shop/main.pbs","import { alive } from @fixture:domain; import { check } from @fixture:assert; [Frame] fn frame() -> void { let saved: bool = check(alive()); }\n");
|
||||
write("tests/support/assert/main.pbs","fn check(value: bool) -> bool { return value; }\n");
|
||||
write("tests/support/assert/mod.barrel","pub fn check(value: bool) -> bool;\n");
|
||||
}
|
||||
BuilderPipelineContext context(String target) {
|
||||
return BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false,root.toString(),"core-v1",SourceProviderFactory.filesystem(),target));
|
||||
}
|
||||
@Test void twoTargetsAndDefaultProductionUseSameResolverWithoutChangingSourcesOrMachineIdentity()throws Exception {
|
||||
var before=hashes();
|
||||
for(var target:List.of("life","shop-save","production")) {
|
||||
var ctx=context(target);p.studio.compiler.models.CompileResult compiled;
|
||||
try {compiled=BuilderPipelineService.INSTANCE.compile(ctx,LogAggregator.empty());}
|
||||
catch(p.studio.compiler.exceptions.BuildException failure){throw new AssertionError(target+": "+failure.getDiagnostics().stream().map(i->i.getCode()+": "+i.getMessage()).toList(),failure);}
|
||||
assertTrue(compiled.diagnostics().stream().noneMatch(BuildingIssue::isError),compiled.diagnostics().toString());
|
||||
assertEquals(target,ctx.resolvedWorkspace.buildTargetId());assertEquals(p.studio.AppMode.Game,ctx.resolvedWorkspace.target());
|
||||
var paths=paths(ctx);assertTrue(paths.contains("src/domain/main.pbs"));assertTrue(paths.contains("src/mod.barrel"));
|
||||
if(target.equals("production")) {
|
||||
assertTrue(paths.contains("src/main.pbs"));assertTrue(paths.stream().noneMatch(p->p.startsWith("tests/")));assertNull(ctx.resolvedWorkspace.mainProject().getEntrypoint());
|
||||
}else {
|
||||
assertFalse(paths.contains("src/main.pbs"));assertTrue(paths.contains("tests/support/assert/main.pbs"));
|
||||
assertTrue(paths.contains(target.equals("life")?"tests/life/main.pbs":"tests/shop/main.pbs"));
|
||||
assertFalse(paths.contains(target.equals("life")?"tests/shop/main.pbs":"tests/life/main.pbs"));
|
||||
assertEquals(root.resolve(target.equals("life")?"tests/life/main.pbs":"tests/shop/main.pbs"),ctx.resolvedWorkspace.mainProject().getEntrypoint());
|
||||
}
|
||||
assertEquals(before,hashes());
|
||||
}
|
||||
var omitted=BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false,root.toString()));
|
||||
BuilderPipelineService.INSTANCE.compile(omitted,LogAggregator.empty());assertEquals("production",omitted.resolvedWorkspace.buildTargetId());
|
||||
assertFalse(Files.exists(root.resolve("build")),"Compile-only target validation must not publish output");
|
||||
}
|
||||
@Test void includedBadSourceIsDiagnosedAtItsOriginalPathAndDoesNotAffectSiblingOrProduction()throws Exception {
|
||||
write("tests/life/bad.pbs","fn broken( this is invalid\n");var before=hashes();var ctx=context("life");
|
||||
var analysis=BuilderPipelineService.INSTANCE.analyze(ctx,LogAggregator.empty());
|
||||
assertTrue(analysis.diagnostics().stream().anyMatch(BuildingIssue::isError));
|
||||
assertTrue(analysis.diagnostics().stream().filter(i->i.getFileId()!=null)
|
||||
.anyMatch(i->ctx.fileTable.get(new p.studio.compiler.source.identifiers.FileId(i.getFileId())).getCanonPath().equals(root.resolve("tests/life/bad.pbs"))));
|
||||
assertEquals(before,hashes());
|
||||
assertDoesNotThrow(()->BuilderPipelineService.INSTANCE.compile(context("shop-save"),LogAggregator.empty()));
|
||||
assertDoesNotThrow(()->BuilderPipelineService.INSTANCE.compile(context("production"),LogAggregator.empty()));
|
||||
}
|
||||
@Test void selectedEntrypointOwnsFrameAndOrdinaryModuleVisibilityStillApplies()throws Exception {
|
||||
write("tests/life/main.pbs","fn helper() -> void {}\n");write("tests/life/driver.pbs","[Frame] fn frame() -> void {}\n");
|
||||
var invalid=BuilderPipelineService.INSTANCE.analyze(context("life"),LogAggregator.empty());
|
||||
assertTrue(invalid.diagnostics().stream().anyMatch(i->i.getCode().equals("E_SEM_TEST_TARGET_ENTRYPOINT")));
|
||||
Files.delete(root.resolve("tests/life/driver.pbs"));
|
||||
write("src/private/main.pbs","fn secret() -> int { return 42; }\n");write("src/private/mod.barrel","");
|
||||
write("tests/life/main.pbs","import { secret } from @fixture:private; [Frame] fn frame() -> void { let value: int = secret(); }\n");
|
||||
assertTrue(BuilderPipelineService.INSTANCE.analyze(context("life"),LogAggregator.empty()).diagnostics().stream().anyMatch(BuildingIssue::isError));
|
||||
}
|
||||
@Test void exactExclusionsAndCanonicalSourceScopeAreValidatedBeforeCompiling()throws Exception {
|
||||
assertThrows(p.studio.compiler.exceptions.BuildException.class,()->BuilderPipelineService.INSTANCE.compile(context("missing"),LogAggregator.empty()));
|
||||
var manifest=Files.readString(root.resolve("prometeu.json"));
|
||||
write("prometeu.json",manifest.replace("\"exclusions\":[\"src/main.pbs\"]","\"exclusions\":[\"src/missing.pbs\"]"));
|
||||
assertThrows(p.studio.compiler.exceptions.BuildException.class,()->BuilderPipelineService.INSTANCE.compile(context("life"),LogAggregator.empty()));
|
||||
write("prometeu.json",manifest.replace("\"sourceRoots\":[\"src\",\"tests/life\"]","\"sourceRoots\":[\"src\",\"tests/escape\"]"));
|
||||
Path external=Files.createTempDirectory("outside-target-");
|
||||
try {Files.createSymbolicLink(root.resolve("tests/escape"),external);
|
||||
assertThrows(p.studio.compiler.exceptions.BuildException.class,()->BuilderPipelineService.INSTANCE.compile(context("life"),LogAggregator.empty()));
|
||||
}finally{Files.deleteIfExists(external);}
|
||||
}
|
||||
void write(String path,String text)throws Exception {var file=root.resolve(path);Files.createDirectories(file.getParent());Files.writeString(file,text);}
|
||||
Set<String> paths(BuilderPipelineContext ctx) {
|
||||
var result=new HashSet<String>();for(var file:ctx.fileTable.values())if(file.getCanonPath().startsWith(root))result.add(root.relativize(file.getCanonPath()).toString());return result;
|
||||
}
|
||||
Map<String,String> hashes()throws Exception {
|
||||
var result=new TreeMap<String,String>();try(var files=Files.walk(root)) {for(var f:files.filter(Files::isRegularFile).toList())result.put(root.relativize(f).toString(),HexFormat.of().formatHex(java.security.MessageDigest.getInstance("SHA-256").digest(Files.readAllBytes(f))));}return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user