feat: bootstrap portable engineering protocol CLI

Implement milestones 0 and 1 with project and repository configuration, Work persistence, discussions, draft decisions, evidence integrity, and deterministic context exports.

Add Java 25, Spring Boot and Modulith, native distributions, CI workflows, protocol documentation, and the pinned SDKMAN GraalVM CE toolchain.

Validated with 20 passing tests and the macOS ARM64 native multi-repository continuity smoke.
This commit is contained in:
Nilton Constantino
2026-11-11 16:14:22 +00:00
commit f0e0dd061a
49 changed files with 2367 additions and 0 deletions
@@ -0,0 +1,92 @@
package net.intrepid.aiengineering;
import net.intrepid.aiengineering.cli.EngineeringCli;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.nio.file.*;
import java.io.*;
import static org.assertj.core.api.Assertions.*;
class ProtocolIntegrationTest {
@TempDir Path root;
record Result(int code, String out, String err) {}
Result run(Path cwd, String... args) {
var out = new StringWriter(); var err = new StringWriter();
int code = new EngineeringCli(cwd).execute(new PrintWriter(out), new PrintWriter(err), args);
return new Result(code, out.toString(), err.toString());
}
Result ok(String... args) {
var r = run(root, args);
assertThat(r.code()).as(r.err()).isZero(); return r;
}
void init() { ok("init", "--name", "Test Project"); }
void repository(String name) throws Exception {
Path path = Files.createDirectory(root.resolve(name));
var process = new ProcessBuilder("git", "init", path.toString()).redirectErrorStream(true).start();
process.getInputStream().readAllBytes(); assertThat(process.waitFor()).isZero();
ok("repo", "add", name, "--path", name);
}
@Test void portableMultiRepositoryContinuity() throws Exception {
init(); repository("runtime"); repository("studio");
ok("work", "create", "Improve scene editor", "--goal", "Portable rendering", "--repo", "runtime", "--repo", "studio",
"--constraint", "No web server", "--acceptance", "Context reloads");
ok("discussion", "add", "WRK-0001", "--kind", "QUESTION", "--text", "Evaluate Canvas rendering?");
ok("discussion", "add", "WRK-0001", "--kind", "CONCLUSION", "--text", "Evaluate layered Canvas first");
ok("decision", "draft", "WRK-0001", "--title", "Use layered Canvas");
Path evidence = Files.writeString(root.resolve("evidence.txt"), "Rendering experiment: 60 fps\n");
ok("artifact", "add", "WRK-0001", "--file", evidence.toString(), "--purpose", "Rendering evidence");
String before = ok("work", "context", "WRK-0001").out();
Path nested = Files.createDirectories(root.resolve("studio/src/editor"));
var fresh = run(nested, "work", "context", "WRK-0001");
assertThat(fresh.code()).as(fresh.err()).isZero();
assertThat(fresh.out()).isEqualTo(before).contains("Portable rendering", "No web server", "Context reloads",
"Evaluate Canvas rendering?", "Use layered Canvas", "DRAFT", "Rendering evidence", "runtime", "studio", "OPEN");
assertThat(ok("work", "context", "WRK-0001", "--format", "json").out()).contains("\"schemaVersion\"", "sha256");
ok("project", "validate"); ok("work", "validate", "WRK-0001");
assertThat(Files.exists(root.resolve(".git"))).isFalse();
}
@Test void independentWorksAndDeterministicExports() {
init(); ok("work", "create", "One"); ok("work", "create", "Two");
ok("discussion", "add", "WRK-0001", "--text", "Only one");
assertThat(ok("work", "list", "--format", "json").out()).contains("WRK-0001", "WRK-0002");
assertThat(ok("work", "context", "WRK-0002").out()).doesNotContain("Only one");
assertThat(ok("work", "context", "WRK-0001").out()).isEqualTo(ok("work", "context", "WRK-0001").out());
}
@Test void invalidIdentifiersMissingResourcesAndNoOverwrite() throws Exception {
init();
assertThat(run(root, "init", "--name", "Again").code()).isEqualTo(2);
assertThat(run(root, "work", "show", "../../escape").code()).isEqualTo(2);
assertThat(run(root, "work", "show", "WRK-9999").code()).isEqualTo(3);
assertThat(run(root, "repo", "add", "missing", "--path", "missing").code()).isEqualTo(3);
assertThat(run(root, "repo", "add", "escape", "--path", "../escape").code()).isEqualTo(2);
org.junit.jupiter.api.Assumptions.assumeFalse(System.getProperty("os.name").startsWith("Windows"), "Symlink fixtures need OS support");
Path outside = Files.createTempDirectory("aie-outside-");
Files.createSymbolicLink(root.resolve("escape"), outside);
assertThat(run(root, "repo", "add", "escape", "--path", "escape").code()).isEqualTo(2);
}
@Test void validationDetectsMissingDecisionArtifactAndDuplicateWork() throws Exception {
init(); ok("work", "create", "One");
ok("decision", "draft", "WRK-0001", "--title", "Draft");
Path work = root.resolve(".ai-engineering/works/WRK-0001-one");
Files.delete(work.resolve("decisions/DEC-0001.md"));
assertThat(run(root, "work", "validate", "WRK-0001").code()).isEqualTo(4);
Files.createDirectory(root.resolve(".ai-engineering/works/WRK-0001-copy"));
Files.copy(work.resolve("work.md"), root.resolve(".ai-engineering/works/WRK-0001-copy/work.md"));
assertThat(run(root, "project", "validate").code()).isEqualTo(4);
}
@Test void invalidConfigurationIsDiagnosed() throws Exception {
init(); Files.writeString(root.resolve(".ai-engineering/ai-engineering.yaml"), "schemaVersion: 999\n");
assertThat(run(root, "project", "validate").code()).isEqualTo(4);
}
@Test void cliSmokeAndHelpForEveryCommand() {
assertThat(ok("--version").out()).isEqualTo("ai-engineering 0.1.0\n");
for (String command : new String[]{"", "init", "project", "project show", "project validate", "repo", "repo add", "repo list",
"work", "work create", "work list", "work show", "work validate", "work context", "discussion", "discussion add",
"decision", "decision draft", "artifact", "artifact add"}) {
var args = new java.util.ArrayList<String>();
if (!command.isEmpty()) args.addAll(java.util.List.of(command.split(" ")));
args.add("--help"); assertThat(ok(args.toArray(String[]::new)).out()).contains("Usage:");
}
assertThat(run(root, "--unknown").code()).isEqualTo(2);
}
}