feat: import open Discussion Framework agendas into Works
Add deterministic preview and fingerprint-bound application for independent DF sources under an AIE umbrella. Preserve complete agendas and original evidence with source-scoped identities, validated receipts and safe retries. Publish prepared Works atomically, require review for changed imports and retain existing refinement without source edits or model calls. Advertise protocol contract 2 while continuing to read contract-1 projects. Add JVM, concurrency, recovery and native coverage; document usage and complete WRK-0007 with verification evidence.
This commit is contained in:
@@ -9,6 +9,7 @@ import net.intrepid.aiengineering.artifact.*;
|
||||
import net.intrepid.aiengineering.planning.*;
|
||||
import net.intrepid.aiengineering.agent.*;
|
||||
import net.intrepid.aiengineering.verification.*;
|
||||
import net.intrepid.aiengineering.legacyimport.DiscussionImport;
|
||||
import org.springframework.aot.hint.*;
|
||||
|
||||
public final class NativeHints implements RuntimeHintsRegistrar {
|
||||
@@ -32,6 +33,9 @@ public final class NativeHints implements RuntimeHintsRegistrar {
|
||||
AgentRun.class, AgentRun.Applied.class, AgentService.Available.class, AgentService.View.class,
|
||||
AgentAdapter.Selection.class, AgentAdapter.Result.class, AgentAdapter.Invocation.class, AgentRun.Provenance.class,
|
||||
CliAgentAdapter.Doctor.class, CliAgentAdapter.Classification.class, CliAgentAdapter.WireProposal.class,
|
||||
DiscussionImport.Source.class, DiscussionImport.SourceView.class, DiscussionImport.AgendaView.class,
|
||||
DiscussionImport.Entry.class, DiscussionImport.Report.class, DiscussionImport.ImportedAgenda.class,
|
||||
DiscussionImport.Receipt.class, DiscussionImport.Action.class,
|
||||
Artifact.class, ValidationReport.class, VerificationService.Context.class, DiscussionService.MigrationReport.class}) {
|
||||
hints.reflection().registerType(type, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS);
|
||||
}
|
||||
|
||||
@@ -35,16 +35,22 @@ public final class ArtifactService {
|
||||
return Filespace.locked(root, () -> {
|
||||
var work = works.editable(root, workId); String id = works.nextReference(work.artifacts(), "ART");
|
||||
Path folder = works.folder(root, workId);
|
||||
Path parent = Filespace.resolve(folder, "artifacts/evidence");
|
||||
Path stage = Filespace.resolve(parent, "." + id + "-" + UUID.randomUUID() + ".tmp"); Filespace.directory(stage);
|
||||
var artifact = new Artifact(1, id, workId, origin, purpose,
|
||||
"artifacts/evidence/" + id + "/payload", hash(bytes), bytes.length, author, Instant.now().toString());
|
||||
Filespace.writeBytes(stage.resolve("payload"), bytes, false);
|
||||
Filespace.write(stage.resolve("artifact.yaml"), Documents.yaml(artifact), false);
|
||||
Filespace.moveDirectory(stage, Filespace.resolve(parent, id));
|
||||
var artifact = writePrepared(folder, workId, id, bytes, purpose, origin, author);
|
||||
works.addReference(root, workId, "artifacts", id); return artifact;
|
||||
});
|
||||
}
|
||||
/** Normal evidence format in an unpublished Work folder; caller publishes its Work references. */
|
||||
public Artifact writePrepared(Path folder, String workId, String id, byte[] content, String purpose, String origin, String author) {
|
||||
Work.identifier(workId, "WRK"); Work.identifier(id, "ART"); byte[] bytes = content.clone();
|
||||
if (bytes.length > MAX_BYTES) throw ProtocolException.invalid("Evidence exceeds 1 MiB");
|
||||
Path parent = Filespace.resolve(folder, "artifacts/evidence");
|
||||
Path stage = Filespace.resolve(parent, "." + id + "-" + UUID.randomUUID() + ".tmp"); Filespace.directory(stage);
|
||||
var artifact = new Artifact(1, id, workId, origin, purpose,
|
||||
"artifacts/evidence/" + id + "/payload", hash(bytes), bytes.length, author, Instant.now().toString());
|
||||
Filespace.writeBytes(stage.resolve("payload"), bytes, false);
|
||||
Filespace.write(stage.resolve("artifact.yaml"), Documents.yaml(artifact), false);
|
||||
Filespace.moveDirectory(stage, Filespace.resolve(parent, id)); return artifact;
|
||||
}
|
||||
public void validate(Path root, String id) {
|
||||
for (var artifact : list(root, id)) {
|
||||
Path path = Filespace.resolve(works.folder(root, id), artifact.path());
|
||||
|
||||
@@ -42,6 +42,7 @@ public final class EngineeringCli implements Runnable {
|
||||
.addSubcommand("plan", new CommandLine(new PlanCommands()).addSubcommand("step", new StepCommands()))
|
||||
.addSubcommand("topic", new TopicCommands()).addSubcommand("survey", new SurveyCommands()).addSubcommand("agent", new AgentCommands())
|
||||
.addSubcommand("epic", new EpicCommands());
|
||||
commandLine.addSubcommand("import", new CommandLine(new ImportCommands()).addSubcommand("discussion", new DiscussionImportCommand()));
|
||||
configure(commandLine, out, err);
|
||||
commandLine.setExecutionExceptionHandler((exception, command, parse) -> {
|
||||
if (exception instanceof ProtocolException problem) { err.println(problem.getMessage()); return problem.exitCode(); }
|
||||
@@ -61,6 +62,49 @@ public final class EngineeringCli implements Runnable {
|
||||
}
|
||||
private Path resolve(Path path) { return path.isAbsolute() ? path : cwd.resolve(path); }
|
||||
enum Format { markdown, json }
|
||||
@Command(name = "import", mixinStandardHelpOptions = true, description = "Import supported legacy context with explicit preview and application.")
|
||||
public class ImportCommands implements Runnable {
|
||||
@Override public void run() { commandLine.getSubcommands().get("import").usage(output); }
|
||||
}
|
||||
@Command(name = "discussion", mixinStandardHelpOptions = true, description = "Preview or import DF DSCs with open AGD agendas, without a model call.")
|
||||
public class DiscussionImportCommand implements java.util.concurrent.Callable<Integer> {
|
||||
@Option(names = "--source", required = true, description = "Stable source ID=PATH; repeat for independent DF projects. Paths are caller-relative.") List<String> sources;
|
||||
@Option(names = "--target", description = "SOURCE=TEXT target description; repeat for multiple targets.") List<String> targets;
|
||||
@Option(names = "--apply", description = "Publish the reviewed import; requires --expect.") boolean apply;
|
||||
@Option(names = "--expect", description = "Fingerprint returned by a valid preview.") String expected;
|
||||
@Option(names = "--author", defaultValue = "human") String author;
|
||||
@Option(names = "--format", defaultValue = "markdown") Format format;
|
||||
private String[] pair(String value, String option) {
|
||||
int at = value.indexOf('=');
|
||||
if (at < 1 || at == value.length() - 1) throw ProtocolException.invalid(option + " requires ID=VALUE");
|
||||
return new String[]{value.substring(0, at), value.substring(at + 1)};
|
||||
}
|
||||
@Override public Integer call() {
|
||||
if (apply && expected == null) throw ProtocolException.invalid("--apply requires --expect from a preview");
|
||||
if (!apply && expected != null) throw ProtocolException.invalid("--expect requires --apply");
|
||||
var roots = new java.util.LinkedHashMap<String, String>(); var targetMap = new java.util.HashMap<String, List<String>>();
|
||||
for (String raw : sources) {
|
||||
var pair = pair(raw, "--source");
|
||||
if (roots.putIfAbsent(pair[0], resolve(Path.of(pair[1])).normalize().toString()) != null)
|
||||
throw ProtocolException.invalid("Duplicate source ID: " + pair[0]);
|
||||
}
|
||||
for (String raw : safe(targets)) {
|
||||
var pair = pair(raw, "--target");
|
||||
if (!roots.containsKey(pair[0])) throw ProtocolException.invalid("Unknown target source: " + pair[0]);
|
||||
targetMap.computeIfAbsent(pair[0], k -> new java.util.ArrayList<>()).add(pair[1]);
|
||||
}
|
||||
var inputs = roots.entrySet().stream().map(e -> new net.intrepid.aiengineering.legacyimport.DiscussionImport.Source(e.getKey(), e.getValue(), targetMap.get(e.getKey()))).toList();
|
||||
var importer = new net.intrepid.aiengineering.legacyimport.DiscussionImportService(); Path destination = root();
|
||||
if (apply) {
|
||||
var validity = verification.project(destination);
|
||||
if (!validity.valid()) throw ProtocolException.validation(String.join("; ", validity.issues()));
|
||||
}
|
||||
var result = apply ? importer.apply(destination, inputs, expected, author) : importer.preview(destination, inputs);
|
||||
if (format == Format.json) output.print(Documents.json(result));
|
||||
else output.print(net.intrepid.aiengineering.legacyimport.DiscussionImportService.markdown(result));
|
||||
return result.valid() ? 0 : 4;
|
||||
}
|
||||
}
|
||||
private int emit(Object value, Format format) {
|
||||
output.print(format == Format.json ? Documents.json(value) : Documents.yaml(value)); return 0;
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@org.springframework.modulith.ApplicationModule(allowedDependencies = {"filesystem", "project", "work", "discussion", "decision", "artifact", "verification", "planning", "agent"})
|
||||
@org.springframework.modulith.ApplicationModule(allowedDependencies = {"filesystem", "project", "work", "discussion", "decision", "artifact", "verification", "planning", "agent", "legacyimport"})
|
||||
package net.intrepid.aiengineering.cli;
|
||||
|
||||
@@ -23,11 +23,16 @@ public final class DiscussionService {
|
||||
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.writeMarkdownDocument(Filespace.resolve(works.folder(root, workId), "discussions/" + id + ".md"), entry, "text", false);
|
||||
var entry = writePrepared(works.folder(root, workId), workId, id, text, kind, author, discussionId, respondsTo);
|
||||
works.addReference(root, workId, "discussions", id); return entry;
|
||||
});
|
||||
}
|
||||
/** Normal discussion format in an unpublished Work folder; caller publishes its Work references. */
|
||||
public DiscussionEntry writePrepared(Path folder, String workId, String id, String text, DiscussionEntry.Kind kind,
|
||||
String author, String discussionId, String respondsTo) {
|
||||
var entry = new DiscussionEntry(1, id, workId, discussionId, kind, author, Instant.now().toString(), respondsTo, text);
|
||||
Documents.writeMarkdownDocument(Filespace.resolve(folder, "discussions/" + id + ".md"), entry, "text", false); return entry;
|
||||
}
|
||||
public record MigrationReport(int schemaVersion, int converted, int unchanged, List<String> backups) {
|
||||
public MigrationReport { backups = List.copyOf(backups); }
|
||||
}
|
||||
|
||||
@@ -57,6 +57,8 @@ public final class Documents {
|
||||
public static int documentVersion(Path path) { return version(parts(path).metadata(), path); }
|
||||
/** Raw persisted metadata for read-only diagnostics, without materializing defaults. */
|
||||
public static ObjectNode metadata(Path path) { return parts(path).metadata(); }
|
||||
/** Parse an already captured legacy document without rereading a concurrently edited source. */
|
||||
public static ObjectNode metadataText(String text) { return parts(text, "captured Markdown").metadata(); }
|
||||
private static int version(ObjectNode metadata, Path path) {
|
||||
var value = metadata.get("documentVersion");
|
||||
if (value == null) return 1;
|
||||
@@ -65,14 +67,17 @@ public final class Documents {
|
||||
}
|
||||
private record Parts(ObjectNode metadata, String body) {}
|
||||
private static Parts parts(Path path) {
|
||||
String text = Filespace.read(path); var match = FRONT_MATTER.matcher(text);
|
||||
if (!match.find()) throw ProtocolException.validation("Missing or unclosed YAML front matter: " + path);
|
||||
return parts(Filespace.read(path), path.toString());
|
||||
}
|
||||
private static Parts parts(String text, String location) {
|
||||
var match = FRONT_MATTER.matcher(text);
|
||||
if (!match.find()) throw ProtocolException.validation("Missing or unclosed YAML front matter: " + location);
|
||||
try {
|
||||
if (!(YAML.readTree(match.group(1)) instanceof ObjectNode metadata))
|
||||
throw ProtocolException.validation("Front matter must be an object: " + path);
|
||||
throw ProtocolException.validation("Front matter must be an object: " + location);
|
||||
return new Parts(metadata, text.substring(match.end()));
|
||||
} catch (ProtocolException e) { throw e; }
|
||||
catch (RuntimeException e) { throw ProtocolException.validation("Invalid front matter at " + path + ": " + e.getMessage()); }
|
||||
catch (RuntimeException e) { throw ProtocolException.validation("Invalid front matter at " + location + ": " + e.getMessage()); }
|
||||
}
|
||||
public static String markdownDocument(Object value, String bodyField) {
|
||||
ObjectNode metadata = YAML.valueToTree(value);
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package net.intrepid.aiengineering.legacyimport;
|
||||
|
||||
import net.intrepid.aiengineering.filesystem.ProtocolException;
|
||||
import net.intrepid.aiengineering.project.ProjectConfig;
|
||||
import net.intrepid.aiengineering.work.Work;
|
||||
import java.util.*;
|
||||
|
||||
/** Public CLI reports and owned provenance; source content itself stays in normal evidence payloads. */
|
||||
public final class DiscussionImport {
|
||||
private DiscussionImport() {}
|
||||
public static final String RECEIPT_ORIGIN = "ai-engineering:discussion-import:";
|
||||
public enum Action { CREATE, UNCHANGED, REVIEW, SKIP, ERROR }
|
||||
public record Source(String id, String path, List<String> targets) {
|
||||
public Source {
|
||||
ProjectConfig.identifier(id); ProtocolException.text(path, "DF source path");
|
||||
targets = targets == null || targets.isEmpty() ? List.of(id) : targets.stream().distinct().sorted().toList();
|
||||
targets.forEach(t -> ProtocolException.text(t, "source target"));
|
||||
}
|
||||
}
|
||||
public record SourceView(String id, String path, List<String> targets, String indexSha256) {
|
||||
public SourceView { targets = List.copyOf(targets); }
|
||||
}
|
||||
public record AgendaView(String id, String file, String status, boolean selected, String sha256, String reason) {}
|
||||
public record Entry(String sourceId, String dscId, String title, List<AgendaView> agendas,
|
||||
Action action, String workId, String contentHash, String reason) {
|
||||
public Entry { agendas = List.copyOf(agendas); }
|
||||
}
|
||||
public record Report(int schemaVersion, boolean valid, boolean applied, String fingerprint,
|
||||
List<SourceView> sources, List<Entry> discussions, List<String> errors, Map<String, String> publishedWorks) {
|
||||
public Report {
|
||||
sources = List.copyOf(sources); discussions = List.copyOf(discussions); errors = List.copyOf(errors);
|
||||
publishedWorks = Collections.unmodifiableMap(new TreeMap<>(publishedWorks));
|
||||
}
|
||||
}
|
||||
public record ImportedAgenda(String id, String file, String sha256, String discussionId, String artifactId) {
|
||||
public ImportedAgenda {
|
||||
Work.identifier(id, "AGD"); ProtocolException.text(file, "original agenda path"); hash(sha256);
|
||||
Work.identifier(discussionId, "DSC"); Work.identifier(artifactId, "ART");
|
||||
}
|
||||
}
|
||||
public record Receipt(int schemaVersion, String workId, String sourceId, String sourceRoot, String dscId,
|
||||
List<String> targets, String contentHash, String dscSha256, String dscArtifactId, List<ImportedAgenda> agendas) {
|
||||
public Receipt {
|
||||
ProtocolException.schema(schemaVersion); Work.identifier(workId, "WRK"); ProjectConfig.identifier(sourceId);
|
||||
ProtocolException.text(sourceRoot, "DF source location"); Work.identifier(dscId, "DSC");
|
||||
targets = List.copyOf(targets); targets.forEach(t -> ProtocolException.text(t, "source target"));
|
||||
if (targets.isEmpty() || targets.stream().distinct().count() != targets.size()) throw ProtocolException.validation("Invalid import targets");
|
||||
hash(contentHash); hash(dscSha256); Work.identifier(dscArtifactId, "ART"); agendas = List.copyOf(agendas);
|
||||
if (agendas.isEmpty() || agendas.stream().map(ImportedAgenda::id).distinct().count() != agendas.size()
|
||||
|| agendas.stream().map(ImportedAgenda::discussionId).distinct().count() != agendas.size()
|
||||
|| agendas.stream().map(ImportedAgenda::artifactId).distinct().count() != agendas.size()
|
||||
|| agendas.stream().anyMatch(a -> a.artifactId().equals(dscArtifactId)))
|
||||
throw ProtocolException.validation("Invalid imported agenda identities");
|
||||
}
|
||||
}
|
||||
public static void hash(String value) {
|
||||
if (value == null || !value.matches("[a-f0-9]{64}")) throw ProtocolException.validation("Invalid import SHA-256");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
package net.intrepid.aiengineering.legacyimport;
|
||||
|
||||
import net.intrepid.aiengineering.artifact.*;
|
||||
import net.intrepid.aiengineering.discussion.*;
|
||||
import net.intrepid.aiengineering.filesystem.*;
|
||||
import net.intrepid.aiengineering.project.*;
|
||||
import net.intrepid.aiengineering.work.*;
|
||||
import tools.jackson.databind.JsonNode;
|
||||
import tools.jackson.databind.node.ObjectNode;
|
||||
import java.nio.*;
|
||||
import java.nio.charset.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import static net.intrepid.aiengineering.legacyimport.DiscussionImport.*;
|
||||
|
||||
/** Deterministic DF reader and publisher. No adapter, source command or source write is used. */
|
||||
public final class DiscussionImportService {
|
||||
public static final int MAX_INDEX_BYTES = 8 * 1024 * 1024;
|
||||
public static final int MAX_BATCH_BYTES = 32 * 1024 * 1024;
|
||||
private final WorkService works = new WorkService();
|
||||
private final ArtifactService artifacts = new ArtifactService();
|
||||
private final DiscussionService discussions = new DiscussionService();
|
||||
private final java.util.function.Consumer<Work> afterPublication;
|
||||
public DiscussionImportService() { this(work -> {}); }
|
||||
/** Fault injection at the batch publication boundary; not exposed by the CLI. */
|
||||
DiscussionImportService(java.util.function.Consumer<Work> afterPublication) { this.afterPublication = afterPublication; }
|
||||
private record Original(String id, String file, Path path, byte[] bytes) {}
|
||||
private record Candidate(Source source, String dscId, String title, byte[] record, List<Original> agendas, String hash) {}
|
||||
private record Existing(Receipt receipt, String workId, String fingerprint) {}
|
||||
private record Snapshot(Report report, List<Candidate> candidates, Map<Path, byte[]> watched) {}
|
||||
|
||||
public Report preview(Path root, List<Source> sources) { return capture(root, sources).report(); }
|
||||
|
||||
public Report apply(Path root, List<Source> sources, String expected, String author) {
|
||||
if (expected == null || !expected.matches("[a-f0-9]{64}")) throw ProtocolException.invalid("--apply requires --expect with a preview fingerprint");
|
||||
ProtocolException.text(author, "import author");
|
||||
return Filespace.locked(root, () -> {
|
||||
var snapshot = capture(root, sources); var report = snapshot.report();
|
||||
if (!report.valid()) return report;
|
||||
if (!report.fingerprint().equals(expected)) return error(report, "Preview changed; run preview again before applying");
|
||||
verify(snapshot.watched());
|
||||
var published = new TreeMap<String, String>();
|
||||
try {
|
||||
for (var candidate : snapshot.candidates()) {
|
||||
var entry = report.discussions().stream().filter(e -> key(e.sourceId(), e.dscId()).equals(key(candidate.source().id(), candidate.dscId()))).findFirst().orElseThrow();
|
||||
if (entry.action() != Action.CREATE) continue;
|
||||
var source = candidate.source();
|
||||
String description = "Imported Discussion Framework discussion " + candidate.dscId() + " from " + source.id()
|
||||
+ " (" + source.path() + ").\n\nTargets:\n" + String.join("\n", source.targets().stream().map(t -> "- " + t).toList());
|
||||
var work = works.createPrepared(root, source.id() + ": " + candidate.title(), description, candidate.title(),
|
||||
"Continue the open agendas of " + source.id() + "/" + candidate.dscId(), List.of(), List.of(), List.of(), author,
|
||||
(folder, seed) -> {
|
||||
var prepared = seed(folder, seed, candidate, author);
|
||||
// Source changes during staging cannot publish a stale Work.
|
||||
verify(snapshot.watched()); return prepared;
|
||||
});
|
||||
published.put(key(source.id(), candidate.dscId()), work.id());
|
||||
afterPublication.accept(work);
|
||||
}
|
||||
} catch (RuntimeException failure) {
|
||||
int code = failure instanceof ProtocolException p ? p.exitCode() : 1;
|
||||
throw new ProtocolException(code, "DF import failed: " + failure.getMessage() + "; published Works: " + published
|
||||
+ ". Run preview again to resume; unpublished staging may remain for inspection.");
|
||||
}
|
||||
return new Report(1, true, true, report.fingerprint(), report.sources(), report.discussions(), List.of(), published);
|
||||
});
|
||||
}
|
||||
|
||||
private Work seed(Path folder, Work work, Candidate candidate, String author) {
|
||||
var imported = new ArrayList<ImportedAgenda>();
|
||||
String source = candidate.source().id();
|
||||
for (var original : candidate.agendas()) {
|
||||
String discussionId = works.nextReference(work.discussions(), "DSC"), artifactId = works.nextReference(work.artifacts(), "ART");
|
||||
discussions.writePrepared(folder, work.id(), discussionId, utf8(original.bytes()), DiscussionEntry.Kind.NOTE,
|
||||
"discussion-import:" + source, "df:" + source + ":" + original.id(), null);
|
||||
artifacts.writePrepared(folder, work.id(), artifactId, original.bytes(), "Original DF agenda " + original.id(),
|
||||
"discussion-framework:" + source + ":" + original.id() + ":" + original.file(), author);
|
||||
imported.add(new ImportedAgenda(original.id(), original.file(), Revisions.hash(original.bytes()), discussionId, artifactId));
|
||||
work = work.reference("discussions", discussionId).reference("artifacts", artifactId);
|
||||
}
|
||||
String recordArtifact = works.nextReference(work.artifacts(), "ART");
|
||||
artifacts.writePrepared(folder, work.id(), recordArtifact, candidate.record(), "Original DF discussion index record " + candidate.dscId(),
|
||||
"discussion-framework:" + source + ":" + candidate.dscId() + ":index-record", author);
|
||||
work = work.reference("artifacts", recordArtifact);
|
||||
var receipt = new Receipt(1, work.id(), source, candidate.source().path(), candidate.dscId(), candidate.source().targets(),
|
||||
candidate.hash(), Revisions.hash(candidate.record()), recordArtifact, imported);
|
||||
String receiptId = works.nextReference(work.artifacts(), "ART");
|
||||
artifacts.writePrepared(folder, work.id(), receiptId, Documents.json(receipt).getBytes(StandardCharsets.UTF_8),
|
||||
"DF import identity and provenance", RECEIPT_ORIGIN + key(source, candidate.dscId()), author);
|
||||
return work.reference("artifacts", receiptId);
|
||||
}
|
||||
|
||||
private Snapshot capture(Path root, List<Source> requested) {
|
||||
var sources = normalize(requested); var config = new ProjectService().load(root);
|
||||
var errors = new ArrayList<String>(); var entries = new ArrayList<Entry>(); var candidates = new ArrayList<Candidate>();
|
||||
var views = new ArrayList<SourceView>(); var watched = new LinkedHashMap<Path, byte[]>();
|
||||
Map<String, Existing> existing;
|
||||
try { existing = existing(root); }
|
||||
catch (RuntimeException e) { errors.add("Destination: " + e.getMessage()); existing = Map.of(); }
|
||||
for (var source : sources) {
|
||||
Path sourceRoot = Path.of(source.path()); String indexHash = null;
|
||||
try {
|
||||
for (var repo : config.repositories()) if (!repo.access().read()
|
||||
&& new ProjectService().repositoryPath(root, repo).toAbsolutePath().normalize().equals(sourceRoot))
|
||||
throw ProtocolException.validation("Source repository is not readable by project policy: " + repo.id());
|
||||
Path index = Filespace.resolve(sourceRoot, "discussion/index.ndjson");
|
||||
byte[] bytes = read(index, MAX_INDEX_BYTES); watch(watched, index, bytes); indexHash = Revisions.hash(bytes);
|
||||
boolean meta = false; var seen = new HashSet<String>(); var seenAgendas = new HashSet<String>(); int lineNumber = 0;
|
||||
for (String line : utf8(bytes).split("\n", -1)) {
|
||||
lineNumber++; if (line.isBlank()) continue;
|
||||
try {
|
||||
var record = Documents.parseJson(line, ObjectNode.class);
|
||||
if (record == null) throw ProtocolException.validation("Expected a JSON object");
|
||||
if (!meta) {
|
||||
if (!text(record, "type").equals("meta") || record.get("next_id") == null || !record.get("next_id").isObject())
|
||||
throw ProtocolException.validation("First DF record must be meta with next_id");
|
||||
if (record.has("schemaVersion") && (!record.get("schemaVersion").isIntegralNumber() || record.get("schemaVersion").intValue() != 1))
|
||||
throw ProtocolException.validation("Unsupported DF schemaVersion");
|
||||
meta = true; continue;
|
||||
}
|
||||
if (!text(record, "type").equals("discussion")) throw ProtocolException.validation("Expected a discussion record after meta");
|
||||
readDiscussion(source, record, line.getBytes(StandardCharsets.UTF_8), seen, seenAgendas, existing, watched, entries, candidates, errors);
|
||||
} catch (RuntimeException e) { errors.add(source.id() + "/index.ndjson:" + lineNumber + ": " + e.getMessage()); }
|
||||
}
|
||||
if (!meta) errors.add(source.id() + ": missing DF meta record");
|
||||
} catch (RuntimeException e) { errors.add(source.id() + ": " + e.getMessage()); }
|
||||
views.add(new SourceView(source.id(), source.path(), source.targets(), indexHash));
|
||||
}
|
||||
entries.sort(Comparator.comparing(Entry::sourceId).thenComparing(Entry::dscId));
|
||||
var destination = new TreeMap<String, String>(); existing.forEach((key, value) -> destination.put(key, value.fingerprint()));
|
||||
String fingerprint = Revisions.hash(Documents.json(List.of(root.toAbsolutePath().normalize().toString(), views, entries, errors, destination)));
|
||||
boolean valid = errors.isEmpty() && entries.stream().noneMatch(e -> e.action() == Action.REVIEW || e.action() == Action.ERROR);
|
||||
return new Snapshot(new Report(1, valid, false, fingerprint, views, entries, errors, Map.of()), List.copyOf(candidates), watched);
|
||||
}
|
||||
|
||||
private void readDiscussion(Source source, ObjectNode record, byte[] raw, Set<String> seen, Set<String> seenAgendas,
|
||||
Map<String, Existing> existing, Map<Path, byte[]> watched, List<Entry> entries, List<Candidate> candidates, List<String> errors) {
|
||||
String id = text(record, "id"); Work.identifier(id, "DSC");
|
||||
if (!seen.add(id)) throw ProtocolException.validation("Duplicate DSC ID: " + id);
|
||||
String state = text(record, "status"), title = optional(record, "title", optional(record, "ticket", id));
|
||||
var agendaViews = new ArrayList<AgendaView>(); var originals = new ArrayList<Original>(); boolean invalid = false;
|
||||
JsonNode agendas = record.get("agendas");
|
||||
if (agendas != null && !agendas.isArray()) throw ProtocolException.validation("agendas must be an array: " + id);
|
||||
if (agendas != null) for (int n = 0; n < agendas.size(); n++) {
|
||||
JsonNode agenda = agendas.get(n); String agendaId = "entry-" + (n + 1), file = "", status = "";
|
||||
try {
|
||||
agendaId = text(agenda, "id"); Work.identifier(agendaId, "AGD");
|
||||
if (!seenAgendas.add(agendaId)) throw ProtocolException.validation("Duplicate AGD ID: " + agendaId);
|
||||
file = text(agenda, "file"); status = text(agenda, "status");
|
||||
Path directory = Filespace.resolve(Path.of(source.path()), "discussion/workflow/agendas");
|
||||
Path path = Filespace.resolve(directory, file);
|
||||
if (!status.equals("open")) {
|
||||
agendaViews.add(new AgendaView(agendaId, file, status, false, null, "Agenda status is " + status)); continue;
|
||||
}
|
||||
if (List.of("done", "completed", "abandoned").contains(state))
|
||||
throw ProtocolException.validation("Open agenda contradicts terminal DSC status " + state);
|
||||
byte[] bytes = read(path, (int) ArtifactService.MAX_BYTES); watch(watched, path, bytes);
|
||||
var metadata = Documents.metadataText(utf8(bytes));
|
||||
if (!agendaId.equals(text(metadata, "id")) || !status.equals(text(metadata, "status")))
|
||||
throw ProtocolException.validation("Agenda ID/status differs between index and Markdown");
|
||||
agendaViews.add(new AgendaView(agendaId, file, status, true, Revisions.hash(bytes), "Open agenda selected"));
|
||||
originals.add(new Original(agendaId, file, path, bytes));
|
||||
} catch (RuntimeException e) {
|
||||
invalid = true; errors.add(source.id() + "/" + id + "/" + agendaId + ": " + e.getMessage());
|
||||
agendaViews.add(new AgendaView(agendaId, file, status, false, null, e.getMessage()));
|
||||
}
|
||||
}
|
||||
var prior = existing.get(key(source.id(), id));
|
||||
if (originals.isEmpty() || invalid) {
|
||||
entries.add(new Entry(source.id(), id, title, agendaViews, invalid ? Action.ERROR : Action.SKIP,
|
||||
prior == null ? null : prior.workId(), null, invalid ? "Invalid agenda data" : "No open agendas; any existing Work is retained")); return;
|
||||
}
|
||||
if (raw.length > ArtifactService.MAX_BYTES) throw ProtocolException.validation("DF discussion record exceeds the 1 MiB evidence limit");
|
||||
String hash = contentHash(source.id(), source.targets(), Revisions.hash(raw), originals.stream()
|
||||
.map(a -> List.of(a.id(), a.file(), Revisions.hash(a.bytes()))).toList());
|
||||
Action action = prior == null ? Action.CREATE : prior.receipt().contentHash().equals(hash) ? Action.UNCHANGED : Action.REVIEW;
|
||||
entries.add(new Entry(source.id(), id, title, agendaViews, action, prior == null ? null : prior.workId(), hash,
|
||||
action == Action.CREATE ? "New source discussion" : action == Action.UNCHANGED ? "Identical import; destination refinements retained" : "Source content or targets changed; review without overwriting"));
|
||||
candidates.add(new Candidate(source, id, title, raw, List.copyOf(originals), hash));
|
||||
}
|
||||
|
||||
private static String contentHash(String source, List<String> targets, String recordHash, List<List<String>> agendas) {
|
||||
return Revisions.hash(Documents.json(List.of(source, targets, recordHash, agendas)));
|
||||
}
|
||||
private static String key(String source, String dsc) { return source + ":" + dsc; }
|
||||
private static String text(JsonNode node, String field) {
|
||||
var value = node == null ? null : node.get(field);
|
||||
if (value == null || !value.isString() || value.stringValue().isBlank()) throw ProtocolException.validation("Missing or invalid " + field);
|
||||
return value.stringValue();
|
||||
}
|
||||
private static String optional(JsonNode node, String field, String fallback) {
|
||||
var value = node.get(field); return value != null && value.isString() && !value.stringValue().isBlank() ? value.stringValue() : fallback;
|
||||
}
|
||||
private static List<Source> normalize(List<Source> requested) {
|
||||
if (requested == null || requested.isEmpty()) throw ProtocolException.invalid("Supply at least one --source ID=PATH");
|
||||
var ids = new HashSet<String>(); var roots = new HashSet<Path>(); var result = new ArrayList<Source>();
|
||||
for (var source : requested) {
|
||||
if (!ids.add(source.id())) throw ProtocolException.invalid("Duplicate source ID: " + source.id());
|
||||
Path path = Filespace.io(() -> Path.of(source.path()).toAbsolutePath().normalize().toRealPath());
|
||||
if (!Files.isDirectory(path, LinkOption.NOFOLLOW_LINKS)) throw ProtocolException.invalid("DF source root is not a directory: " + path);
|
||||
if (path.getFileName().toString().equals("discussion") && !Files.exists(Filespace.resolve(path, "discussion/index.ndjson"))
|
||||
&& Files.exists(Filespace.resolve(path, "index.ndjson"))) path = path.getParent();
|
||||
if (!roots.add(path)) throw ProtocolException.invalid("Duplicate DF source root: " + path);
|
||||
result.add(new Source(source.id(), path.toString(), source.targets()));
|
||||
}
|
||||
return result.stream().sorted(Comparator.comparing(Source::id)).toList();
|
||||
}
|
||||
private static byte[] read(Path path, int limit) {
|
||||
if (!Files.isRegularFile(path, LinkOption.NOFOLLOW_LINKS)) throw ProtocolException.validation("DF source is not a regular file: " + path);
|
||||
return Filespace.io(() -> {
|
||||
try (var input = Files.newInputStream(path, LinkOption.NOFOLLOW_LINKS)) {
|
||||
byte[] bytes = input.readNBytes(limit + 1);
|
||||
if (bytes.length > limit) throw ProtocolException.validation("Source exceeds " + limit + " byte limit: " + path);
|
||||
return bytes;
|
||||
}
|
||||
});
|
||||
}
|
||||
private static String utf8(byte[] bytes) {
|
||||
try { return StandardCharsets.UTF_8.newDecoder().onMalformedInput(CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPORT).decode(ByteBuffer.wrap(bytes)).toString(); }
|
||||
catch (CharacterCodingException e) { throw ProtocolException.validation("Source is not valid UTF-8"); }
|
||||
}
|
||||
private static void watch(Map<Path, byte[]> watched, Path path, byte[] bytes) {
|
||||
long size = watched.values().stream().mapToLong(b -> b.length).sum() + bytes.length - (watched.containsKey(path) ? watched.get(path).length : 0);
|
||||
if (size > MAX_BATCH_BYTES) throw ProtocolException.validation("DF request exceeds the 32 MiB captured-source limit");
|
||||
watched.put(path, bytes);
|
||||
}
|
||||
private static void verify(Map<Path, byte[]> watched) {
|
||||
for (var entry : watched.entrySet())
|
||||
if (!Arrays.equals(entry.getValue(), read(entry.getKey(), entry.getValue().length)))
|
||||
throw ProtocolException.validation("DF source changed since preview: " + entry.getKey());
|
||||
}
|
||||
private static Report error(Report report, String error) {
|
||||
var errors = new ArrayList<>(report.errors()); errors.add(error);
|
||||
return new Report(1, false, false, report.fingerprint(), report.sources(), report.discussions(), errors, Map.of());
|
||||
}
|
||||
|
||||
private Map<String, Existing> existing(Path root) {
|
||||
var result = new TreeMap<String, Existing>();
|
||||
for (var work : works.list(root)) for (var receipt : receipts(root, work.id())) {
|
||||
String key = key(receipt.sourceId(), receipt.dscId());
|
||||
String fingerprint = Revisions.hash(Documents.json(List.of(work, discussions.list(root, work.id()), artifacts.list(root, work.id()))));
|
||||
if (result.putIfAbsent(key, new Existing(receipt, work.id(), fingerprint)) != null)
|
||||
throw ProtocolException.validation("Duplicate imported discussion identity: " + key);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/** Owned receipts are validated without consulting or requiring the original source directory. */
|
||||
public List<Receipt> receipts(Path root, String workId) {
|
||||
var work = works.load(root, workId); var all = artifacts.list(root, workId);
|
||||
var imports = all.stream().filter(a -> a.origin().startsWith(RECEIPT_ORIGIN)).toList();
|
||||
if (imports.isEmpty()) return List.of();
|
||||
if (imports.size() != 1) throw ProtocolException.validation("A Work must have exactly one DF import identity: " + workId);
|
||||
artifacts.validate(root, workId); Path folder = works.folder(root, workId);
|
||||
var byArtifact = new HashMap<String, Artifact>(); all.forEach(a -> byArtifact.put(a.id(), a));
|
||||
var byDiscussion = new HashMap<String, DiscussionEntry>(); discussions.list(root, workId).forEach(d -> byDiscussion.put(d.id(), d));
|
||||
var result = new ArrayList<Receipt>();
|
||||
for (var manifest : imports) {
|
||||
var receipt = Documents.readJson(Filespace.resolve(folder, manifest.path()), Receipt.class);
|
||||
if (!receipt.workId().equals(workId) || !manifest.origin().equals(RECEIPT_ORIGIN + key(receipt.sourceId(), receipt.dscId())))
|
||||
throw ProtocolException.validation("Invalid DF import receipt identity: " + workId);
|
||||
var dsc = require(byArtifact, receipt.dscArtifactId());
|
||||
if (!dsc.sha256().equals(receipt.dscSha256())) throw ProtocolException.validation("DF discussion snapshot hash mismatch");
|
||||
var original = Documents.readJson(Filespace.resolve(folder, dsc.path()), ObjectNode.class);
|
||||
if (!text(original, "id").equals(receipt.dscId())) throw ProtocolException.validation("DF discussion snapshot ID mismatch");
|
||||
var indexed = new LinkedHashMap<String, String>(); JsonNode agendas = original.get("agendas");
|
||||
if (agendas == null || !agendas.isArray()) throw ProtocolException.validation("Missing original DF agendas");
|
||||
for (int n = 0; n < agendas.size(); n++) if (text(agendas.get(n), "status").equals("open")) {
|
||||
String id = text(agendas.get(n), "id");
|
||||
if (indexed.putIfAbsent(id, text(agendas.get(n), "file")) != null) throw ProtocolException.validation("Duplicate original DF agenda");
|
||||
}
|
||||
if (!indexed.keySet().equals(new LinkedHashSet<>(receipt.agendas().stream().map(ImportedAgenda::id).toList())))
|
||||
throw ProtocolException.validation("DF receipt does not preserve all original open agendas");
|
||||
for (var agenda : receipt.agendas()) {
|
||||
var artifact = require(byArtifact, agenda.artifactId());
|
||||
var entry = byDiscussion.get(agenda.discussionId());
|
||||
if (!artifact.sha256().equals(agenda.sha256()) || !Objects.equals(indexed.get(agenda.id()), agenda.file()) || entry == null
|
||||
|| !entry.discussionId().equals("df:" + receipt.sourceId() + ":" + agenda.id()))
|
||||
throw ProtocolException.validation("Invalid DF agenda provenance: " + agenda.id());
|
||||
var header = Documents.metadata(Filespace.resolve(folder, artifact.path()));
|
||||
if (!text(header, "id").equals(agenda.id()) || !text(header, "status").equals("open"))
|
||||
throw ProtocolException.validation("Invalid original agenda evidence: " + agenda.id());
|
||||
}
|
||||
String hash = contentHash(receipt.sourceId(), receipt.targets(), receipt.dscSha256(), receipt.agendas().stream()
|
||||
.map(a -> List.of(a.id(), a.file(), a.sha256())).toList());
|
||||
if (!hash.equals(receipt.contentHash())) throw ProtocolException.validation("DF import content hash mismatch");
|
||||
result.add(receipt);
|
||||
}
|
||||
return List.copyOf(result);
|
||||
}
|
||||
private static Artifact require(Map<String, Artifact> artifacts, String id) {
|
||||
var artifact = artifacts.get(id); if (artifact == null) throw ProtocolException.validation("Missing DF original evidence: " + id); return artifact;
|
||||
}
|
||||
public static String markdown(Report report) {
|
||||
var out = new StringBuilder("# Discussion Framework import\n\n");
|
||||
out.append("Valid: ").append(report.valid()).append("\n\nApplied: ").append(report.applied()).append("\n\nFingerprint: ").append(report.fingerprint()).append('\n');
|
||||
for (var source : report.sources()) out.append("\nSource ").append(source.id()).append(": ").append(source.path()).append("\nTargets: ").append(source.targets()).append('\n');
|
||||
for (var entry : report.discussions()) {
|
||||
out.append("\n- ").append(entry.sourceId()).append('/').append(entry.dscId()).append(": ").append(entry.action()).append(" — ").append(entry.reason());
|
||||
if (entry.workId() != null) out.append(" (").append(entry.workId()).append(')');
|
||||
out.append('\n');
|
||||
for (var agenda : entry.agendas()) out.append(" - ").append(agenda.id()).append(" [").append(agenda.status()).append("] ").append(agenda.file()).append(": ").append(agenda.reason()).append('\n');
|
||||
}
|
||||
for (String error : report.errors()) out.append("\nError: ").append(error).append('\n');
|
||||
if (!report.publishedWorks().isEmpty()) out.append("\nPublished Works: ").append(report.publishedWorks()).append('\n');
|
||||
return out.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
@org.springframework.modulith.ApplicationModule(allowedDependencies = {"filesystem", "project", "work", "discussion", "artifact"})
|
||||
package net.intrepid.aiengineering.legacyimport;
|
||||
@@ -7,8 +7,8 @@ import java.util.List;
|
||||
public final class ProtocolContract {
|
||||
private ProtocolContract() {}
|
||||
public static final String CLI_VERSION = "0.1.0";
|
||||
public static final int CURRENT = 1;
|
||||
public static final List<Integer> READABLE = List.of(1);
|
||||
public static final int CURRENT = 2;
|
||||
public static final List<Integer> READABLE = List.of(1, 2);
|
||||
/** Pre-versioned manifests describe the supported baseline contract, without rewriting them. */
|
||||
public static int effective(Integer declared) { return declared == null ? 1 : declared; }
|
||||
public static void require(Integer declared) {
|
||||
|
||||
@@ -46,7 +46,8 @@ public final class ProtocolGuide {
|
||||
if (!"ai-engineering".equals(protocol) || !"ai-engineering".equals(command)
|
||||
|| !"README.md".equals(entrypoint) || !"AGENTS.md".equals(instructions)
|
||||
|| !"ai-engineering.yaml".equals(configuration) || !"works".equals(works)
|
||||
|| !"explicit-attestation".equals(humanApproval) || !"external-human-or-agent".equals(execution) || legacyImport)
|
||||
|| !"explicit-attestation".equals(humanApproval) || !"external-human-or-agent".equals(execution)
|
||||
|| (legacyImport && (ProtocolContract.effective(protocolVersion) < 2 || capabilities == null || !capabilities.contains("discussion-import"))))
|
||||
throw ProtocolException.validation("Unsupported protocol discovery manifest");
|
||||
for (String value : List.of(entrypoint, instructions, configuration, works)) ProtocolException.text(value, "manifest path");
|
||||
aliases = List.copyOf(aliases); startup = List.copyOf(startup); capabilities = List.copyOf(capabilities);
|
||||
|
||||
@@ -71,8 +71,11 @@ public final class CompatibilityService {
|
||||
if (findings.getLast().state() == State.INVALID || findings.getLast().state() == State.UNSUPPORTED) return;
|
||||
var record = Documents.read(manifestPath, Artifact.class);
|
||||
Class<?> receipt = record.origin().startsWith(PlanCoordinator.RECEIPT_ORIGIN) ? PlanCoordinator.Receipt.class
|
||||
: record.origin().startsWith(EpicCoordinator.RECEIPT_ORIGIN) ? EpicCoordinator.Receipt.class : null;
|
||||
if (receipt != null) inspect(root, relative(root, Filespace.resolve(folder, record.path())), "completion-receipt", receipt, null, false, findings);
|
||||
: record.origin().startsWith(EpicCoordinator.RECEIPT_ORIGIN) ? EpicCoordinator.Receipt.class
|
||||
: record.origin().startsWith(net.intrepid.aiengineering.legacyimport.DiscussionImport.RECEIPT_ORIGIN)
|
||||
? net.intrepid.aiengineering.legacyimport.DiscussionImport.Receipt.class : null;
|
||||
if (receipt != null) inspect(root, relative(root, Filespace.resolve(folder, record.path())),
|
||||
receipt == net.intrepid.aiengineering.legacyimport.DiscussionImport.Receipt.class ? "discussion-import-receipt" : "completion-receipt", receipt, null, false, findings);
|
||||
});
|
||||
// Missing referenced records are not evidence of a readable historical format.
|
||||
try {
|
||||
@@ -140,7 +143,8 @@ public final class CompatibilityService {
|
||||
var versions = new LinkedHashMap<String, String>(); var missing = new ArrayList<String>();
|
||||
try {
|
||||
Path path = Filespace.resolve(root, relative);
|
||||
boolean json = type == ProtocolGuide.Manifest.class || type == PlanCoordinator.Receipt.class || type == EpicCoordinator.Receipt.class;
|
||||
boolean json = type == ProtocolGuide.Manifest.class || type == PlanCoordinator.Receipt.class || type == EpicCoordinator.Receipt.class
|
||||
|| type == net.intrepid.aiengineering.legacyimport.DiscussionImport.Receipt.class;
|
||||
ObjectNode metadata = markdown ? Documents.metadata(path) : json
|
||||
? Documents.readJson(path, ObjectNode.class) : Documents.read(path, ObjectNode.class);
|
||||
if (metadata == null) throw ProtocolException.validation("Expected record object");
|
||||
|
||||
@@ -91,6 +91,7 @@ public final class VerificationService {
|
||||
for (var step : plan.steps()) if (!work.artifacts().containsAll(step.evidence())) issues.add("Missing step evidence: " + step.id());
|
||||
}));
|
||||
check(issues, () -> artifacts.validate(root, id));
|
||||
check(issues, () -> new net.intrepid.aiengineering.legacyimport.DiscussionImportService().receipts(root, id));
|
||||
check(issues, () -> new TopicService().views(root, id));
|
||||
check(issues, () -> new SurveyService().list(root, id));
|
||||
check(issues, () -> new DispositionService().list(root, id));
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@org.springframework.modulith.ApplicationModule(allowedDependencies = {"filesystem", "project", "work", "discussion", "decision", "artifact", "planning", "agent"})
|
||||
@org.springframework.modulith.ApplicationModule(allowedDependencies = {"filesystem", "project", "work", "discussion", "decision", "artifact", "planning", "agent", "legacyimport"})
|
||||
package net.intrepid.aiengineering.verification;
|
||||
|
||||
@@ -33,6 +33,12 @@ public final class WorkService {
|
||||
}
|
||||
public Work create(Path root, String title, String description, String goal, String motivation,
|
||||
List<String> constraints, List<String> criteria, List<String> repositories, String author) {
|
||||
return createPrepared(root, title, description, goal, motivation, constraints, criteria, repositories, author, (folder, work) -> work);
|
||||
}
|
||||
/** Build initial child records before the Work becomes visible to readers. Caller shares the project lock. */
|
||||
public Work createPrepared(Path root, String title, String description, String goal, String motivation,
|
||||
List<String> constraints, List<String> criteria, List<String> repositories, String author,
|
||||
java.util.function.BiFunction<Path, Work, Work> prepare) {
|
||||
return Filespace.locked(root, () -> {
|
||||
list(root); // Refuse to allocate an ID in a corrupt project.
|
||||
// The sequence is canonical; a crash may leave gaps, but identities are never reused.
|
||||
@@ -51,10 +57,13 @@ public final class WorkService {
|
||||
Filespace.directory(staging);
|
||||
for (String dir : List.of("discussions", "decisions", "plans", "artifacts/references", "artifacts/experiments", "artifacts/evidence", "artifacts/outputs", "runs"))
|
||||
Filespace.directory(Filespace.resolve(staging, dir));
|
||||
Documents.writeDocument(staging.resolve("work.md"), work, false);
|
||||
var prepared = prepare.apply(staging, work);
|
||||
if (!prepared.id().equals(work.id()) || !prepared.createdAt().equals(work.createdAt()) || prepared.status() != Work.Status.OPEN)
|
||||
throw ProtocolException.validation("Prepared Work changed its identity or initial state");
|
||||
Documents.writeDocument(staging.resolve("work.md"), prepared, false);
|
||||
// Reserve before publishing. A crash can leave a gap, never reuse a reserved identity.
|
||||
Filespace.write(counter, Documents.yaml(new Sequence(2, "%04X".formatted(next))), Files.exists(counter));
|
||||
Filespace.moveDirectory(staging, target); return work;
|
||||
Filespace.moveDirectory(staging, target); return prepared;
|
||||
});
|
||||
}
|
||||
public record Sequence(int schemaVersion, String lastWork) {
|
||||
|
||||
Reference in New Issue
Block a user