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:
@@ -0,0 +1,30 @@
|
||||
package net.intrepid.aiengineering.discussion;
|
||||
|
||||
import net.intrepid.aiengineering.filesystem.*;
|
||||
import net.intrepid.aiengineering.work.*;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
public final class DiscussionService {
|
||||
private final WorkService works = new WorkService();
|
||||
public List<DiscussionEntry> list(Path root, String id) {
|
||||
Work work = works.load(root, id); Path folder = works.folder(root, id);
|
||||
return work.discussions().stream().map(ref -> {
|
||||
var entry = Documents.readDocument(Filespace.resolve(folder, "discussions/" + ref + ".md"), DiscussionEntry.class);
|
||||
if (!entry.id().equals(ref) || !entry.workId().equals(id)) throw ProtocolException.validation("Discussion identity mismatch: " + ref);
|
||||
return entry;
|
||||
}).toList();
|
||||
}
|
||||
public DiscussionEntry add(Path root, String workId, String text, DiscussionEntry.Kind kind, String author, String discussionId, String respondsTo) {
|
||||
return Filespace.locked(root, () -> {
|
||||
var work = works.load(root, workId);
|
||||
if (respondsTo != null && list(root, workId).stream().noneMatch(e -> e.id().equals(respondsTo)))
|
||||
throw ProtocolException.invalid("Response target not found in Work: " + respondsTo);
|
||||
String id = works.nextReference(work.discussions(), "DSC");
|
||||
var entry = new DiscussionEntry(1, id, workId, discussionId, kind, author, Instant.now().toString(), respondsTo, text);
|
||||
Documents.writeDocument(Filespace.resolve(works.folder(root, workId), "discussions/" + id + ".md"), entry, false);
|
||||
works.addReference(root, workId, "discussions", id); return entry;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user