feat: support simple projects and root Git repositories
Allow registering a single Git repository at the engineering project root with --path . while retaining path safety checks. Document Git-optional projects first and cover plain folders, root repositories, and multiple repositories in process tests and native smoke scenarios. Validated with 23 passing tests and macOS ARM64 native smoke checks for all three layouts.
This commit is contained in:
@@ -11,18 +11,41 @@ import static org.assertj.core.api.Assertions.*;
|
||||
class ProcessContinuityTest {
|
||||
@TempDir Path root;
|
||||
private String cli(String... args) throws Exception {
|
||||
return executeCli(false, args);
|
||||
}
|
||||
private String cliWithoutGit(String... args) throws Exception {
|
||||
return executeCli(true, args);
|
||||
}
|
||||
private String executeCli(boolean withoutGit, String... args) throws Exception {
|
||||
var command = new ArrayList<>(List.of(Path.of(System.getProperty("java.home"), "bin", "java").toString(),
|
||||
"-jar", System.getProperty("cli.jar")));
|
||||
command.addAll(List.of(args));
|
||||
Path log = Files.createTempFile("aie-process-", ".log");
|
||||
try {
|
||||
var process = new ProcessBuilder(command).directory(root.toFile()).redirectErrorStream(true).redirectOutput(log.toFile()).start();
|
||||
var builder = new ProcessBuilder(command).directory(root.toFile()).redirectErrorStream(true).redirectOutput(log.toFile());
|
||||
if (withoutGit) builder.environment().put("PATH", root.resolve("no-installed-tools").toString());
|
||||
var process = builder.start();
|
||||
boolean exited = process.waitFor(30, TimeUnit.SECONDS);
|
||||
if (!exited) process.destroyForcibly();
|
||||
assertThat(exited).as("CLI must terminate without a server").isTrue();
|
||||
String result = Files.readString(log); assertThat(process.exitValue()).as(result).isZero(); return result;
|
||||
} finally { Files.deleteIfExists(log); }
|
||||
}
|
||||
@Test void simpleProjectWorksAcrossProcessesWithoutGitOnPath() throws Exception {
|
||||
Path source = Files.writeString(root.resolve("main.txt"), "Existing project\n");
|
||||
cliWithoutGit("init", "--name", "Simple Project");
|
||||
assertThat(cliWithoutGit("repo", "list", "--format", "json").strip()).isEqualTo("[ ]");
|
||||
cliWithoutGit("work", "create", "Continue application", "--goal", "Preserve local context");
|
||||
cliWithoutGit("discussion", "add", "WRK-0001", "--text", "A simple folder is a complete engineering project");
|
||||
cliWithoutGit("artifact", "add", "WRK-0001", "--file", source.toString(), "--purpose", "Initial source evidence");
|
||||
cliWithoutGit("decision", "draft", "WRK-0001", "--title", "Pilot the protocol", "--evidence", "ART-0001");
|
||||
String context = cliWithoutGit("work", "context", "WRK-0001", "--format", "json");
|
||||
assertThat(cliWithoutGit("work", "context", "WRK-0001", "--format", "json")).isEqualTo(context)
|
||||
.contains("Preserve local context", "\"repositories\" : [ ]", "Initial source evidence", "Pilot the protocol");
|
||||
assertThat(cliWithoutGit("project", "validate", "--format", "json")).contains("\"valid\" : true");
|
||||
assertThat(Files.exists(root.resolve(".git"))).isFalse();
|
||||
assertThat(Files.readString(source)).isEqualTo("Existing project\n");
|
||||
}
|
||||
@Test void independentJvmProcessesReconstructMultiRepositoryWork() throws Exception {
|
||||
cli("init", "--name", "Continuity Experiment");
|
||||
for (String repo : List.of("runtime", "studio")) {
|
||||
|
||||
@@ -52,6 +52,28 @@ class ProtocolIntegrationTest {
|
||||
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 singleGitRepositoryCanShareTheEngineeringProjectRoot() throws Exception {
|
||||
var git = new ProcessBuilder("git", "init", root.toString()).redirectErrorStream(true).start();
|
||||
git.getInputStream().readAllBytes(); assertThat(git.waitFor()).isZero();
|
||||
Path source = Files.writeString(root.resolve("main.txt"), "Existing application source\n");
|
||||
byte[] gitConfig = Files.readAllBytes(root.resolve(".git/config"));
|
||||
init(); ok("repo", "add", "app", "--path", ".");
|
||||
assertThat(ok("repo", "list", "--format", "json").out()).contains("\"path\" : \".\"", "\"edit\" : false");
|
||||
ok("work", "create", "Improve application", "--repo", "app");
|
||||
String exported = ok("work", "context", "WRK-0001", "--format", "json").out();
|
||||
assertThat(exported).contains("\"repositoryId\" : \"app\"", "\"head\" : \"UNBORN\"");
|
||||
Path nested = Files.createDirectories(root.resolve("src/feature"));
|
||||
var fresh = run(nested, "work", "context", "WRK-0001", "--format", "json");
|
||||
assertThat(fresh.code()).as(fresh.err()).isZero(); assertThat(fresh.out()).isEqualTo(exported);
|
||||
ok("project", "validate");
|
||||
assertThat(Files.readString(source)).isEqualTo("Existing application source\n");
|
||||
assertThat(Files.readAllBytes(root.resolve(".git/config"))).isEqualTo(gitConfig);
|
||||
assertThat(run(root, "repo", "add", "duplicate", "--path", "./.").code()).isEqualTo(2);
|
||||
}
|
||||
@Test void protocolStorageCannotBeRegisteredAsASourceRepository() {
|
||||
init();
|
||||
assertThat(run(root, "repo", "add", "protocol", "--path", ".ai-engineering").code()).isEqualTo(2);
|
||||
}
|
||||
@Test void invalidIdentifiersMissingResourcesAndNoOverwrite() throws Exception {
|
||||
init();
|
||||
assertThat(run(root, "init", "--name", "Again").code()).isEqualTo(2);
|
||||
|
||||
Reference in New Issue
Block a user