feat: adopt local SQLite engineering memory and quality gates
This commit is contained in:
@@ -49,6 +49,12 @@ public final class CompatibilityService {
|
||||
try { ProtocolGuide.validate(root); }
|
||||
catch (RuntimeException e) { invalid(findings, ".ai-engineering/protocol.json", "entry-contract", e.getMessage()); }
|
||||
}
|
||||
try { if (SqliteDatabase.active(root)) return inspectSqlite(root, findings); }
|
||||
catch (RuntimeException failure) {
|
||||
findings.add(new Finding(".ai-engineering/aie.db", "sqlite", failure.getMessage() != null && failure.getMessage().contains("Unsupported") ? State.UNSUPPORTED : State.INVALID,
|
||||
Map.of(), List.of(), failure.getMessage() == null ? "Invalid SQLite storage" : failure.getMessage()));
|
||||
return report(findings, true);
|
||||
}
|
||||
Path workspace = Filespace.resolve(root, ".ai-engineering/works");
|
||||
Path sequence = Filespace.resolve(root, ".ai-engineering/works/.sequence.yaml");
|
||||
if (Files.exists(sequence)) inspect(root, root.relativize(sequence).toString(), "sequence", WorkService.Sequence.class, null, false, findings);
|
||||
@@ -95,11 +101,44 @@ public final class CompatibilityService {
|
||||
}
|
||||
} catch (RuntimeException ignored) { /* The Work's parse diagnostic was already recorded above. */ }
|
||||
});
|
||||
// Presence/version inspection is independent from structural/evidence validation.
|
||||
return report(findings, false);
|
||||
}
|
||||
private Report inspectSqlite(Path root, List<Finding> findings) {
|
||||
SqliteDatabase.read(root, connection -> {
|
||||
findings.add(new Finding(".ai-engineering/aie.db", "sqlite", State.CURRENT,
|
||||
Map.of("schemaVersion", Integer.toString(SqliteDatabase.SCHEMA_VERSION)), List.of(), "Explicit SQLite backend; no file conversion on read."));
|
||||
try (var statement = connection.createStatement(); var rows = statement.executeQuery("SELECT work_id,kind,local_id,revision FROM record_identity ORDER BY work_id,kind,local_id,revision")) {
|
||||
while (rows.next()) {
|
||||
String work = rows.getString(1), kind = rows.getString(2), id = rows.getString(3); int revision = rows.getInt(4);
|
||||
String path = ".ai-engineering/aie.db#" + work + "/" + kind + "/" + id + "/r" + revision;
|
||||
try {
|
||||
Class<?> type = switch (kind) {
|
||||
case "work" -> Work.class; case "discussion" -> DiscussionEntry.class; case "decision" -> Decision.class;
|
||||
case "plan" -> Plan.class; case "topic" -> Topic.class; case "survey" -> Survey.class; case "disposition" -> Disposition.class;
|
||||
case "epic" -> Epic.class; case "run" -> AgentRun.class; case "artifact" -> Artifact.class;
|
||||
case "gate" -> QualityGates.Result.class; case "receipt" -> net.intrepid.aiengineering.artifact.ProtocolReceipt.class;
|
||||
default -> throw ProtocolException.validation("Unknown SQLite record kind: " + kind);
|
||||
};
|
||||
SqliteRecords.get(root, work, kind, id, revision, type);
|
||||
if (SqliteRecords.current(root, work, kind, id) == 0) throw ProtocolException.validation("Missing current record pointer");
|
||||
findings.add(new Finding(path, kind, State.CURRENT, Map.of("schemaVersion", "1"), List.of(), "Readable typed SQLite record."));
|
||||
} catch (RuntimeException failure) {
|
||||
findings.add(new Finding(path, kind, failure.getMessage() != null && failure.getMessage().contains("Unsupported") ? State.UNSUPPORTED : State.INVALID,
|
||||
Map.of(), List.of(), failure.getMessage() == null ? "Invalid SQLite record" : failure.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
return report(findings, true);
|
||||
}
|
||||
private Report report(List<Finding> findings, boolean sqlite) {
|
||||
// Presence/version inspection is independent from completion readiness.
|
||||
State state = findings.stream().map(Finding::state).max(Comparator.naturalOrder()).orElse(State.CURRENT);
|
||||
boolean readable = state == State.CURRENT || state == State.LEGACY_COMPATIBLE;
|
||||
var guidance = new ArrayList<String>();
|
||||
if (readable) guidance.add("No migration is required. Keep readable historical and COMPLETED Works in their existing formats.");
|
||||
if (readable) guidance.add(sqlite ? "SQLite is selected explicitly. Use the CLI for engineering memory; reads do not migrate data."
|
||||
: "No migration is required for legacy reading. Keep readable historical and COMPLETED Works in their existing formats.");
|
||||
else guidance.add("Unsupported versions require a compatible CLI; invalid files require deliberate repair. No migration route is inferred.");
|
||||
guidance.add("onboard refreshes entry instructions only, with backups; it does not convert Works or their history.");
|
||||
guidance.add("Compatibility describes storage readability, not completion readiness or evidence integrity. Run aie project validate separately.");
|
||||
|
||||
Reference in New Issue
Block a user