feat: add Work guidance and adaptive Plan experiments
Test / Tests and coverage occurred while executing withChecks step.
Intrepid/AI Engineering/pipeline/head There was a failure building this commit
build / jvm (push) Canceled after 0s
build / native (macos-15, macos-arm64) (push) Canceled after 0s
build / native (ubuntu-24.04, linux-x86_64) (push) Canceled after 0s
build / native (windows-2025, windows-x86_64) (push) Canceled after 0s
Test / Tests and coverage occurred while executing withChecks step.
Intrepid/AI Engineering/pipeline/head There was a failure building this commit
build / jvm (push) Canceled after 0s
build / native (macos-15, macos-arm64) (push) Canceled after 0s
build / native (ubuntu-24.04, linux-x86_64) (push) Canceled after 0s
build / native (windows-2025, windows-x86_64) (push) Canceled after 0s
Persist explicit human discussion choices, DEC requests and approval policies. Add optional evidence-backed Plan experiments and align context, adapters and next actions under protocol contract 3. Include WRK-000B decisions, plan history and verification evidence: 167 JVM tests, 25 focused checks, Jenkins fixtures and native smoke coverage.
This commit is contained in:
@@ -37,7 +37,7 @@ class CompatibilityTest {
|
||||
return result;
|
||||
}
|
||||
private void baseline() throws Exception {
|
||||
init(); ok("work", "create", "Delivered baseline");
|
||||
init(); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "Delivered baseline");
|
||||
Path fixtures = Path.of(getClass().getResource("/compatibility/baseline-v1/.ai-engineering").toURI());
|
||||
try (var files = Files.walk(fixtures)) {
|
||||
for (Path path : files.filter(Files::isRegularFile).toList()) {
|
||||
@@ -52,7 +52,7 @@ class CompatibilityTest {
|
||||
var report = inspect();
|
||||
assertThat(report.state()).isEqualTo(CURRENT); assertThat(report.readable()).isTrue();
|
||||
assertThat(report.migrationRequired()).isFalse();
|
||||
assertThat(report.currentProtocolVersion()).isEqualTo(2);
|
||||
assertThat(report.currentProtocolVersion()).isEqualTo(3);
|
||||
assertThat(report.formats()).contains(FormatVersions.SEQUENCE, FormatVersions.DOCUMENT);
|
||||
assertThat(ok("project", "compatibility", "--format", "json")).contains("\"cliVersion\"", "\"readableVersions\"", "\"migrationRequired\" : false");
|
||||
assertThat(ok("status", "--format", "json")).contains("\"compatibility\"", "\"state\" : \"CURRENT\"");
|
||||
@@ -98,7 +98,7 @@ class CompatibilityTest {
|
||||
var result = run("project", "compatibility", "--format", "json");
|
||||
assertThat(result.code()).isEqualTo(4); assertThat(result.out()).contains("UNSUPPORTED", field, "99");
|
||||
assertThat(run("onboard").code()).isEqualTo(4);
|
||||
assertThat(run("work", "create", "Do not write").code()).isEqualTo(4);
|
||||
assertThat(run("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "Do not write").code()).isEqualTo(4);
|
||||
assertThat(snapshot(root)).isEqualTo(before);
|
||||
}
|
||||
}
|
||||
@@ -138,7 +138,7 @@ class CompatibilityTest {
|
||||
assertThat(inspect().state()).isEqualTo(INVALID);
|
||||
}
|
||||
@Test void completionReceiptFormatsAreInspectedButOrdinaryEvidenceIsNotParsedAsProtocol() throws Exception {
|
||||
init(); ok("work", "create", "Plan delivery");
|
||||
init(); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "Plan delivery");
|
||||
Files.writeString(root.resolve("evidence.txt"), "This is evidence, not YAML or JSON.\n");
|
||||
ok("artifact", "add", "WRK-0001", "--file", "evidence.txt", "--purpose", "Observed test result");
|
||||
ok("plan", "create", "WRK-0001", "--title", "Delivery");
|
||||
|
||||
@@ -205,6 +205,7 @@ class DiscussionImportTest {
|
||||
}
|
||||
@Test void completedArchivedImportsRemainUnchanged() throws Exception {
|
||||
init(); String id = apply(betaOnly()).publishedWorks().get("beta:DSC-0001");
|
||||
assertThat(cli(root, "work", "guidance", id, "--mode", "DIRECT", "--by", "fixture-owner", "--reason", "Explicit fixture choice", "--human-approved")).as(output).isZero();
|
||||
assertThat(cli(root, "work", "update", id, "--acceptance", "Original agenda remains available")).as(output).isZero();
|
||||
assertThat(cli(root, "work", "complete", id, "--by", "fixture-owner", "--summary", "Fixture original verified", "--human-approved",
|
||||
"--criterion", "1=ART-0001", "--no-integration-needed", "Disposable import fixture")).as(output).isZero();
|
||||
@@ -239,10 +240,10 @@ class DiscussionImportTest {
|
||||
String advertised = Files.readString(manifest);
|
||||
assertThat(advertised).contains("\"legacyImport\": true", "discussion-import");
|
||||
assertThat(new VerificationService().project(root).valid()).isTrue();
|
||||
Files.writeString(manifest, advertised.replace("\"legacyImport\": true", "\"legacyImport\": false").replace("\"protocolVersion\": 2", "\"protocolVersion\": 1"));
|
||||
Files.writeString(manifest, advertised.replace("\"legacyImport\": true", "\"legacyImport\": false").replace("\"protocolVersion\": 3", "\"protocolVersion\": 1"));
|
||||
assertThat(new VerificationService().project(root).valid()).isTrue();
|
||||
assertThat(new CompatibilityService().inspect(root).state()).isEqualTo(CompatibilityService.State.LEGACY_COMPATIBLE);
|
||||
Files.writeString(manifest, advertised.replace("\"protocolVersion\": 2", "\"protocolVersion\": 1"));
|
||||
Files.writeString(manifest, advertised.replace("\"protocolVersion\": 3", "\"protocolVersion\": 1"));
|
||||
assertThat(new VerificationService().project(root).valid()).isFalse();
|
||||
Files.writeString(manifest, advertised.replace("discussion-import", "unsupported-import"));
|
||||
assertThat(new CompatibilityService().inspect(root).readable()).isFalse();
|
||||
|
||||
@@ -17,7 +17,7 @@ class DiscussionRefinementTest {
|
||||
}
|
||||
private void ok(String... args) { int code = cli(args); assertThat(code).as(output).isZero(); }
|
||||
private Path work() { return root.resolve(".ai-engineering/works/WRK-0001-one"); }
|
||||
private void init() { ok("init", "--name", "Fixture"); ok("work", "create", "One", "--acceptance", "Continuity"); }
|
||||
private void init() { ok("init", "--name", "Fixture"); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "One", "--acceptance", "Continuity"); }
|
||||
@Test void legacyTopicViewDoesNotRewriteFilesAndSurveyAnswersKeepHistory() throws Exception {
|
||||
init(); byte[] original = Files.readAllBytes(work().resolve("work.md"));
|
||||
ok("topic", "list", "WRK-0001", "--format", "json"); assertThat(output).contains("main", "implicit");
|
||||
@@ -48,7 +48,7 @@ class DiscussionRefinementTest {
|
||||
assertThat(cli("survey", "answer", "WRK-0001", "SVY-0001", "QST-0001", "--choice", "9")).isEqualTo(2);
|
||||
assertThat(cli("survey", "answer", "WRK-0001", "SVY-0001", "QST-0001", "--choice", "1", "--choice", "2")).isEqualTo(2);
|
||||
assertThat(Files.readAllBytes(work().resolve("surveys/SVY-0001.md"))).isEqualTo(before);
|
||||
ok("work", "create", "Two");
|
||||
ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "Two");
|
||||
assertThat(cli("survey", "show", "WRK-0002", "SVY-0001")).isEqualTo(3);
|
||||
}
|
||||
@Test void agentsContinuePersistedDiscussionAndCannotApproveDecisions() throws Exception {
|
||||
|
||||
@@ -19,7 +19,7 @@ class DiscussionTextFileTest {
|
||||
output = out + err.toString(); return code;
|
||||
}
|
||||
private void ok(String... args) { int code = cli(root, args); assertThat(code).as(output).isZero(); }
|
||||
private void initialize() { ok("init", "--name", "Test"); ok("work", "create", "One"); }
|
||||
private void initialize() { ok("init", "--name", "Test"); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "One"); }
|
||||
@Test void importsExactUtf8TextRelativeToInvocationDirectoryAndPersistsIndependently() throws Exception {
|
||||
initialize(); ok("discussion", "add", "WRK-0001", "--kind", "QUESTION", "--text", "Which approach?");
|
||||
String prose = "\n## Proposta — árvore 日本語\r\n\r\n- First limit\n- Second limit\n\n```yaml\n---\nkey: value\n```\n";
|
||||
|
||||
@@ -22,7 +22,7 @@ class EpicSafetyTest {
|
||||
private Path folder(String id) { return new WorkService().folder(root, id); }
|
||||
private void init() throws Exception {
|
||||
ok("init", "--name", "Safety");
|
||||
for (String name : new String[]{"Parent", "Child", "Other"}) ok("work", "create", name, "--acceptance", "Reviewed fixture result");
|
||||
for (String name : new String[]{"Parent", "Child", "Other"}) ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", name, "--acceptance", "Reviewed fixture result");
|
||||
Files.writeString(root.resolve("evidence.txt"), "Synthetic observation\n");
|
||||
}
|
||||
private void setup() {
|
||||
|
||||
@@ -20,7 +20,7 @@ class EpicWorkflowTest {
|
||||
private void ok(String... args) { assertThat(cli(args)).as(output).isZero(); }
|
||||
private void init(int count) throws Exception {
|
||||
ok("init", "--name", "EPIC fixture");
|
||||
for (int i = 1; i <= count; i++) ok("work", "create", "Work " + i, "--acceptance", "Verified bounded delivery");
|
||||
for (int i = 1; i <= count; i++) ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "Work " + i, "--acceptance", "Verified bounded delivery");
|
||||
Files.writeString(root.resolve("evidence.txt"), "Explicitly synthetic delivery evidence\n");
|
||||
}
|
||||
private void configure(String id, String mode) { ok("epic", "configure", id, "--mode", mode, "--by", "fixture-agent", "--reason", "Coordinate work"); }
|
||||
|
||||
@@ -17,7 +17,7 @@ class IntegrityTest {
|
||||
}
|
||||
private void ok(String... args) { assertThat(cli(args)).as(lastOutput).isZero(); }
|
||||
private Path work() { return root.resolve(".ai-engineering/works/WRK-0001-one"); }
|
||||
private void initWork() { ok("init", "--name", "Test"); ok("work", "create", "One"); }
|
||||
private void initWork() { ok("init", "--name", "Test"); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "One"); }
|
||||
@Test void missingPayloadAndTamperedEvidenceAreDetected() throws Exception {
|
||||
initWork(); Path source = Files.writeString(root.resolve("source.txt"), "abc");
|
||||
ok("artifact", "add", "WRK-0001", "--file", source.toString(), "--purpose", "Test integrity");
|
||||
@@ -58,7 +58,7 @@ class IntegrityTest {
|
||||
}
|
||||
}
|
||||
@Test void lifecycleIsReversibleAndArtifactsAreWorkLocal() throws Exception {
|
||||
initWork(); ok("work", "create", "Two");
|
||||
initWork(); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "Two");
|
||||
ok("work", "status", "WRK-0001", "CANCELLED");
|
||||
ok("work", "reopen", "WRK-0001", "--by", "owner", "--reason", "Resume investigation");
|
||||
Path source = Files.writeString(root.resolve("result.txt"), "Only first Work\n");
|
||||
|
||||
@@ -26,7 +26,7 @@ class ListingTest {
|
||||
private String ok(String... args) { assertThat(cli(args)).as(output).isZero(); return output; }
|
||||
private JsonNode json(String text) { return Documents.parseJson(text, JsonNode.class); }
|
||||
private void init() { ok("init", "--name", "List project"); }
|
||||
private void create(String title) { ok("work", "create", title, "--acceptance", "Verified fixture"); }
|
||||
private void create(String title) { ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", title, "--acceptance", "Verified fixture"); }
|
||||
private void evidence(String work) throws Exception {
|
||||
Path result = Files.writeString(root.resolve("result.txt"), "Observed fixture result\n");
|
||||
ok("artifact", "add", work, "--file", result.toString(), "--purpose", "Observed fixture");
|
||||
|
||||
@@ -23,7 +23,7 @@ class OperationalSafetyTest {
|
||||
output = out + err.toString(); return code;
|
||||
}
|
||||
private void ok(String... args) { int code = cli(args); assertThat(code).as(output).isZero(); }
|
||||
private void init() { ok("init", "--name", "Test"); ok("work", "create", "One", "--acceptance", "A reproducible result"); }
|
||||
private void init() { ok("init", "--name", "Test"); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "One", "--acceptance", "A reproducible result"); }
|
||||
private Path folder() { return root.resolve(".ai-engineering/works/WRK-0001-one"); }
|
||||
private void artifact() throws Exception {
|
||||
Files.writeString(root.resolve("result.txt"), "Observed test run and command\n");
|
||||
|
||||
@@ -26,7 +26,7 @@ class OperationalWorkflowTest {
|
||||
String agents = Files.readString(root.resolve("AGENTS.md")); ok("onboard");
|
||||
assertThat(Files.readString(root.resolve("AGENTS.md"))).isEqualTo(agents);
|
||||
ok("guide", "--format", "json"); assertThat(output).contains("ai-engineering", "capabilities");
|
||||
ok("work", "create", "Deliver a small change", "--acceptance", "The result is reproducible");
|
||||
ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "Deliver a small change", "--acceptance", "The result is reproducible");
|
||||
ok("discussion", "add", "WRK-0001", "--kind", "QUESTION", "--text", "Which scope?");
|
||||
ok("discussion", "add", "WRK-0001", "--kind", "CONCLUSION", "--responds-to", "DSC-0001", "--text", "One small change");
|
||||
Path evidence = Files.writeString(root.resolve("result.txt"), "Verified fixture result\n");
|
||||
@@ -61,7 +61,7 @@ class OperationalWorkflowTest {
|
||||
ok("project", "validate");
|
||||
}
|
||||
@Test void acceptedDecisionsCanBeSupersededWithoutLosingHistory() {
|
||||
ok("init", "--name", "Test"); ok("work", "create", "One");
|
||||
ok("init", "--name", "Test"); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "One");
|
||||
ok("decision", "draft", "WRK-0001", "--title", "First", "--context", "Problem", "--approach", "A", "--rationale", "Reason");
|
||||
ok("decision", "accept", "WRK-0001", "DEC-0001", "--by", "owner", "--reason", "Agreed", "--human-approved");
|
||||
ok("decision", "revise", "WRK-0001", "DEC-0001", "--by", "agent", "--reason", "New evidence");
|
||||
@@ -71,7 +71,7 @@ class OperationalWorkflowTest {
|
||||
ok("project", "validate");
|
||||
}
|
||||
@Test void revisionTamperingIsDiagnosedAndReadinessShowsPendingWork() throws Exception {
|
||||
ok("init", "--name", "Test"); ok("work", "create", "One");
|
||||
ok("init", "--name", "Test"); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "One");
|
||||
ok("next-actions", "WRK-0001", "--format", "json"); assertThat(output).contains("REFINE_SCOPE");
|
||||
ok("decision", "draft", "WRK-0001", "--title", "First");
|
||||
ok("decision", "update", "WRK-0001", "DEC-0001", "--context", "Problem", "--by", "agent", "--reason", "Refinement");
|
||||
|
||||
@@ -23,7 +23,7 @@ class PlanConsolidationSafetyTest {
|
||||
private Work work() { return new WorkService().load(root, "WRK-0001"); }
|
||||
private Plan plan(String id) { return new PlanService().get(root, "WRK-0001", id); }
|
||||
private void init() throws Exception {
|
||||
ok("init", "--name", "Safety"); ok("work", "create", "Delivery", "--acceptance", "Recorded execution");
|
||||
ok("init", "--name", "Safety"); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "Delivery", "--acceptance", "Recorded execution");
|
||||
Files.writeString(root.resolve("evidence.txt"), "Synthetic result\n");
|
||||
ok("artifact", "add", "WRK-0001", "--file", "evidence.txt", "--purpose", "Fixture result");
|
||||
}
|
||||
@@ -89,7 +89,7 @@ class PlanConsolidationSafetyTest {
|
||||
var interrupted = new Work(delivered.schemaVersion(), delivered.id(), delivered.title(), delivered.description(), delivered.goal(), delivered.motivation(),
|
||||
delivered.constraints(), delivered.acceptanceCriteria(), Work.Status.OPEN, delivered.createdAt(), delivered.updatedAt(), delivered.author(), delivered.repositories(),
|
||||
delivered.discussions(), delivered.decisions(), delivered.artifacts(), delivered.plans(), List.of(), List.of(), false,
|
||||
delivered.topics(), delivered.surveys(), delivered.dispositions(), delivered.agentRuns(), delivered.epic());
|
||||
delivered.topics(), delivered.surveys(), delivered.dispositions(), delivered.agentRuns(), delivered.epic(), delivered.guidance());
|
||||
Documents.replaceFrontMatter(new WorkService().folder(root, delivered.id()).resolve("work.md"), interrupted);
|
||||
ok("work", "reconcile", "WRK-0001"); assertThat(work().artifacts()).isEqualTo(delivered.artifacts());
|
||||
assertThat(work().completions()).hasSize(1); ok("project", "validate");
|
||||
@@ -102,7 +102,7 @@ class PlanConsolidationSafetyTest {
|
||||
assertThat(plan("PLN-0001").revision()).isEqualTo(revision);
|
||||
}
|
||||
@Test void planCompletionNotifiesTheAuthorizedEpicWithoutASecondHumanClosure() throws Exception {
|
||||
init(); ok("work", "create", "Parent", "--acceptance", "Child delivery");
|
||||
init(); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "Parent", "--acceptance", "Child delivery");
|
||||
ok("epic", "configure", "WRK-0002", "--mode", "results", "--by", "human", "--reason", "Track result");
|
||||
plan("One", 1);
|
||||
ok("epic", "link", "WRK-0002", "WRK-0001", "--by", "human", "--reason", "Required delivery");
|
||||
|
||||
@@ -23,7 +23,7 @@ class PlanConsolidationTest {
|
||||
private Work work() { return new WorkService().load(root, "WRK-0001"); }
|
||||
private Plan plan(String id) { return new PlanService().get(root, "WRK-0001", id); }
|
||||
private void init() throws Exception {
|
||||
ok("init", "--name", "Consolidation"); ok("work", "create", "Delivery");
|
||||
ok("init", "--name", "Consolidation"); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "Delivery");
|
||||
Files.writeString(root.resolve("evidence.txt"), "Synthetic verified result\n");
|
||||
ok("artifact", "add", "WRK-0001", "--file", "evidence.txt", "--purpose", "Fixture result");
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class PlanDecisionPromotionTest {
|
||||
output = out + err.toString(); return code;
|
||||
}
|
||||
private void ok(String... args) { assertThat(cli(args)).as(output).isZero(); }
|
||||
private void init() { ok("init", "--name", "Promotion"); ok("work", "create", "One"); }
|
||||
private void init() { ok("init", "--name", "Promotion"); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "One"); }
|
||||
private void draft(String title) {
|
||||
ok("decision", "draft", "WRK-0001", "--title", title, "--context", "Problem", "--approach", "Approach", "--rationale", "Reason");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package net.intrepid.aiengineering;
|
||||
|
||||
import net.intrepid.aiengineering.cli.EngineeringCli;
|
||||
import net.intrepid.aiengineering.planning.*;
|
||||
import net.intrepid.aiengineering.work.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
class PlanExperimentsTest {
|
||||
@TempDir Path root;
|
||||
private String output;
|
||||
private int cli(String... args) {
|
||||
var out = new StringWriter(); var err = new StringWriter();
|
||||
int code = new EngineeringCli(root).execute(new PrintWriter(out), new PrintWriter(err), args);
|
||||
output = out + err.toString(); return code;
|
||||
}
|
||||
private void ok(String... args) { assertThat(cli(args)).as(output).isZero(); }
|
||||
private Plan plan() { return new PlanService().get(root, "WRK-0001", "PLN-0001"); }
|
||||
private void init() throws Exception {
|
||||
ok("init", "--name", "Experiments"); ok("work", "create", "Delivery");
|
||||
ok("work", "guidance", "WRK-0001", "--mode", "DIRECT", "--by", "fixture-human", "--reason", "Explicit fixture choice", "--human-approved");
|
||||
ok("decision", "draft", "WRK-0001", "--title", "Choose approach", "--context", "Latency problem", "--approach", "Measure and optimize", "--rationale", "Preserve compatibility");
|
||||
ok("decision", "accept", "WRK-0001", "DEC-0001", "--by", "fixture-human", "--reason", "Approve concrete DEC", "--human-approved");
|
||||
ok("plan", "create", "WRK-0001", "--title", "Delivery", "--decision", "DEC-0001");
|
||||
ok("plan", "step", "add", "WRK-0001", "PLN-0001", "--title", "Optimize");
|
||||
ok("plan", "step", "add", "WRK-0001", "PLN-0001", "--title", "Integrate", "--depends-on", "TSK-0001");
|
||||
ok("plan", "step", "add", "WRK-0001", "PLN-0001", "--title", "Independent documentation");
|
||||
Files.writeString(root.resolve("observation.txt"), "Synthetic experiment: latency 17ms, target 10ms.\n");
|
||||
ok("artifact", "add", "WRK-0001", "--file", "observation.txt", "--purpose", "Synthetic test evidence");
|
||||
}
|
||||
private int start(String hypothesis, String... extras) {
|
||||
var args = new ArrayList<>(List.of("plan", "experiment", "start", "WRK-0001", "PLN-0001", "--step", "TSK-0001",
|
||||
"--hypothesis", hypothesis, "--criterion", "Latency below 10ms", "--invocation", "Synthetic fixture measurement",
|
||||
"--by", "fixture-agent", "--reason", "Investigate before implementation"));
|
||||
args.addAll(List.of(extras)); return cli(args.toArray(String[]::new));
|
||||
}
|
||||
private int finish(String id, String outcome, String... extras) {
|
||||
var args = new ArrayList<>(List.of("plan", "experiment", "finish", "WRK-0001", "PLN-0001", id,
|
||||
"--outcome", outcome, "--observation", "Measured latency 17ms", "--interpretation", "Original hypothesis is insufficient",
|
||||
"--next-action", "Measure query cost", "--evidence", "ART-0001", "--by", "fixture-agent", "--reason", "Record measurement"));
|
||||
args.addAll(List.of(extras)); return cli(args.toArray(String[]::new));
|
||||
}
|
||||
private int step(String id, String status) { return cli("plan", "step", "status", "WRK-0001", "PLN-0001", id, status,
|
||||
"--by", "fixture-agent", "--reason", "Verified synthetic result", "--evidence", "ART-0001"); }
|
||||
@Test void relevantExperimentHasPriorCriteriaAndBlocksOnlyAffectedExecution() throws Exception {
|
||||
init(); assertThat(start("Cache removes latency")).as(output).isZero();
|
||||
var initial = plan().experiments().getFirst(); assertThat(initial.outcome()).isEqualTo(Experiment.Outcome.OPEN);
|
||||
assertThat(initial.observation()).isNull(); assertThat(initial.successCriterion()).contains("10ms");
|
||||
assertThat(step("TSK-0001", "ACTIVE")).isEqualTo(2);
|
||||
assertThat(step("TSK-0003", "COMPLETED")).as(output).isZero();
|
||||
ok("next-actions", "WRK-0001", "--format", "json"); assertThat(output).contains("OBSERVE_EXPERIMENT", "INVESTIGATE_EXPERIMENT");
|
||||
assertThat(finish("EXP-0001", "REFUTED")).as(output).isZero();
|
||||
assertThat(plan().experiments().getFirst().evidence()).containsExactly("ART-0001");
|
||||
assertThat(step("TSK-0001", "COMPLETED")).as(output).isZero();
|
||||
assertThat(step("TSK-0002", "COMPLETED")).as(output).isZero();
|
||||
assertThat(new WorkService().load(root, "WRK-0001").status()).isEqualTo(Work.Status.COMPLETED);
|
||||
var history = new PlanService().history(root, "WRK-0001", "PLN-0001");
|
||||
assertThat(history).anySatisfy(p -> assertThat(p.experiments()).anySatisfy(e -> assertThat(e.outcome()).isEqualTo(Experiment.Outcome.OPEN)));
|
||||
assertThat(history.getLast().experiments().getFirst().outcome()).isEqualTo(Experiment.Outcome.REFUTED);
|
||||
ok("project", "validate");
|
||||
}
|
||||
@Test void failedHypothesisRequiresExplicitReconsiderationBeforeRetry() throws Exception {
|
||||
init(); assertThat(start("Cache removes latency")).as(output).isZero(); assertThat(finish("EXP-0001", "REFUTED")).as(output).isZero();
|
||||
var before = plan();
|
||||
assertThat(start(" CACHE removes latency ")).isEqualTo(2); assertThat(output).contains("Reconsider"); assertThat(plan()).isEqualTo(before);
|
||||
assertThat(start("Cache removes latency", "--retry-of", "EXP-0001", "--reconsideration", "Prior measurement included cold startup; repeat with warm inputs")).as(output).isZero();
|
||||
assertThat(plan().experiments()).hasSize(2); assertThat(plan().experiments().getLast().retryOf()).isEqualTo("EXP-0001");
|
||||
assertThat(finish("EXP-0001", "CONFIRMED")).isEqualTo(2); assertThat(output).contains("immutable");
|
||||
assertThat(start("New hypothesis", "--retry-of", "EXP-0002", "--reconsideration", "Cannot retry an unobserved attempt")).isNotZero();
|
||||
ok("project", "validate");
|
||||
}
|
||||
@Test void questionedDecisionRequiresApprovedRevisionWhileIndependentWorkContinues() throws Exception {
|
||||
init(); assertThat(start("Cache removes latency")).as(output).isZero();
|
||||
assertThat(finish("EXP-0001", "REFUTED", "--questions-decision", "DEC-0001")).as(output).isZero();
|
||||
assertThat(step("TSK-0001", "ACTIVE")).isEqualTo(2);
|
||||
assertThat(step("TSK-0003", "COMPLETED")).as(output).isZero();
|
||||
ok("next-actions", "WRK-0001", "--format", "json"); assertThat(output).contains("REVISIT_DECISION");
|
||||
ok("work", "guidance", "WRK-0001", "--approval", "WAIVED", "--by", "fixture-human", "--reason", "Explicit fixture waiver", "--human-approved");
|
||||
assertThat(cli("plan", "update", "WRK-0001", "PLN-0001", "--clear-decisions", "--by", "fixture-agent", "--reason", "Try dropping the concern")).isEqualTo(2);
|
||||
assertThat(output).contains("dropping the reference");
|
||||
ok("work", "guidance", "WRK-0001", "--approval", "REQUIRED", "--by", "fixture-human", "--reason", "Restore fixture review", "--human-approved");
|
||||
assertThat(start("Query dominates latency")).as(output).isZero(); // Continued authorized investigation remains possible.
|
||||
assertThat(finish("EXP-0002", "CONFIRMED")).as(output).isZero();
|
||||
ok("decision", "revise", "WRK-0001", "DEC-0001", "--by", "fixture-agent", "--reason", "Measurement changed approach");
|
||||
assertThat(cli("plan", "update", "WRK-0001", "PLN-0001", "--decision", "DEC-0002", "--by", "fixture-agent", "--reason", "Use unapproved replacement")).isEqualTo(2);
|
||||
ok("decision", "accept", "WRK-0001", "DEC-0002", "--by", "fixture-human", "--reason", "Approve revised concrete DEC", "--human-approved");
|
||||
ok("plan", "update", "WRK-0001", "PLN-0001", "--decision", "DEC-0002", "--by", "fixture-agent", "--reason", "Use approved revision");
|
||||
assertThat(step("TSK-0001", "COMPLETED")).as(output).isZero(); assertThat(step("TSK-0002", "COMPLETED")).as(output).isZero();
|
||||
ok("project", "validate");
|
||||
}
|
||||
@Test void resultCannotClaimUnknownEvidenceAndNoExperimentIsRequiredForOrdinarySteps() throws Exception {
|
||||
init(); assertThat(plan().experiments()).isEmpty();
|
||||
assertThat(step("TSK-0003", "COMPLETED")).as(output).isZero();
|
||||
assertThat(start("Cache removes latency")).as(output).isZero(); var before = plan();
|
||||
assertThat(finish("EXP-0001", "REFUTED", "--evidence", "ART-9999")).isEqualTo(2); assertThat(plan()).isEqualTo(before);
|
||||
assertThat(finish("EXP-0001", "REFUTED", "--questions-decision", "DEC-9999")).isEqualTo(2); assertThat(plan()).isEqualTo(before);
|
||||
ok("project", "validate");
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class ProcessContinuityTest {
|
||||
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("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "Continue application", "--goal", "Preserve local context");
|
||||
Files.writeString(root.resolve("proposal.md"), "A simple folder is a complete engineering project\n\nRead from UTF-8.\n");
|
||||
cliWithoutGit("discussion", "add", "WRK-0001", "--text-file", "proposal.md");
|
||||
cliWithoutGit("artifact", "add", "WRK-0001", "--file", source.toString(), "--purpose", "Initial source evidence");
|
||||
@@ -61,7 +61,7 @@ class ProcessContinuityTest {
|
||||
commit.getInputStream().readAllBytes(); assertThat(commit.waitFor()).isZero();
|
||||
cli("repo", "add", repo, "--path", repo);
|
||||
}
|
||||
cli("work", "create", "Improve scene editor", "--repo", "runtime", "--repo", "studio", "--goal", "Continue across agents");
|
||||
cli("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "Improve scene editor", "--repo", "runtime", "--repo", "studio", "--goal", "Continue across agents");
|
||||
cli("discussion", "add", "WRK-0001", "--text", "Evaluate Canvas rendering", "--author", "agent-a");
|
||||
cli("decision", "draft", "WRK-0001", "--title", "Use layered Canvas");
|
||||
Path evidence = Files.writeString(root.resolve("result.txt"), "Observed rendering result\n");
|
||||
@@ -73,7 +73,7 @@ class ProcessContinuityTest {
|
||||
}
|
||||
@Test void refinementContinuesBetweenTwoAdaptersInIndependentProcessesWithoutGit() throws Exception {
|
||||
cliWithoutGit("init", "--name", "Refinement", "--general-adapter", "fixture-general", "--archive-policy", "reversible");
|
||||
cliWithoutGit("work", "create", "Refine", "--acceptance", "Persisted continuity");
|
||||
cliWithoutGit("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "Refine", "--acceptance", "Persisted continuity");
|
||||
cliWithoutGit("agent", "run", "WRK-0001", "--task", "Rendering: Compare layers\nSaving: Preserve the format", "--request-id", "refine");
|
||||
cliWithoutGit("survey", "answer", "WRK-0001", "SVY-0001", "QST-0001", "--choice", "1", "--author", "fixture-human");
|
||||
cliWithoutGit("survey", "answer", "WRK-0001", "SVY-0001", "QST-0001", "--text", "Refined direction", "--author", "fixture-human");
|
||||
@@ -92,7 +92,7 @@ class ProcessContinuityTest {
|
||||
@Test void epicResultsPropagateAcrossIndependentProcessesWithoutModelsOrGit() throws Exception {
|
||||
cliWithoutGit("init", "--name", "EPIC continuity");
|
||||
for (String title : List.of("Parent", "Required slice", "Reconsidered slice"))
|
||||
cliWithoutGit("work", "create", title, "--acceptance", "Reviewed fixture delivery");
|
||||
cliWithoutGit("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", title, "--acceptance", "Reviewed fixture delivery");
|
||||
cliWithoutGit("epic", "configure", "WRK-0001", "--by", "fixture-agent", "--reason", "Coordinate slices");
|
||||
for (String child : List.of("WRK-0002", "WRK-0003")) cliWithoutGit("epic", "link", "WRK-0001", child, "--by", "fixture-agent", "--reason", "Decomposition");
|
||||
cliWithoutGit("epic", "authorize", "WRK-0001", "--by", "fixture-owner", "--reason", "Reviewed aggregate criteria", "--human-approved");
|
||||
@@ -121,7 +121,7 @@ class ProcessContinuityTest {
|
||||
cliWithoutGit("init", ".", "--name", "Guided process fixture", "--interactive", "--input-file", "answers.txt");
|
||||
String config = cliWithoutGit("project", "show", "--format", "json");
|
||||
assertThat(config).contains("codex-cli", "claude-cli", "reviewer", "timeoutSeconds");
|
||||
cliWithoutGit("work", "create", "Continue configured project");
|
||||
cliWithoutGit("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "Continue configured project");
|
||||
String first = cliWithoutGit("work", "context", "WRK-0001", "--format", "json");
|
||||
assertThat(cliWithoutGit("work", "context", "WRK-0001", "--format", "json")).isEqualTo(first);
|
||||
cliWithoutGit("project", "validate");
|
||||
@@ -131,7 +131,7 @@ class ProcessContinuityTest {
|
||||
assertThat(Files.readString(root.resolve("AGENTS.md"))).contains(".ai-engineering/README.md");
|
||||
assertThat(Files.readString(root.resolve(".ai-engineering/protocol.json"))).contains("next-actions", "capabilities");
|
||||
assertThat(cliWithoutGit("guide")).contains("human-approved", "canonical");
|
||||
cliWithoutGit("work", "create", "One delivery", "--acceptance", "Recorded result survives a fresh process");
|
||||
cliWithoutGit("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "One delivery", "--acceptance", "Recorded result survives a fresh process");
|
||||
cliWithoutGit("decision", "draft", "WRK-0001", "--title", "Small approach", "--context", "Problem", "--approach", "A", "--rationale", "Bounded");
|
||||
cliWithoutGit("decision", "accept", "WRK-0001", "DEC-0001", "--by", "owner", "--reason", "Agreed", "--human-approved");
|
||||
cliWithoutGit("plan", "create", "WRK-0001", "--title", "Delivery", "--decision", "DEC-0001");
|
||||
|
||||
@@ -28,7 +28,7 @@ class ProtocolIntegrationTest {
|
||||
}
|
||||
@Test void portableMultiRepositoryContinuity() throws Exception {
|
||||
init(); repository("runtime"); repository("studio");
|
||||
ok("work", "create", "Improve scene editor", "--goal", "Portable rendering", "--repo", "runtime", "--repo", "studio",
|
||||
ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "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");
|
||||
@@ -46,7 +46,7 @@ class ProtocolIntegrationTest {
|
||||
assertThat(Files.exists(root.resolve(".git"))).isFalse();
|
||||
}
|
||||
@Test void independentWorksAndDeterministicExports() {
|
||||
init(); ok("work", "create", "One"); ok("work", "create", "Two");
|
||||
init(); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "One"); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "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");
|
||||
@@ -59,7 +59,7 @@ class ProtocolIntegrationTest {
|
||||
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");
|
||||
ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "Improve application", "--repo", "app");
|
||||
var snapshots = new net.intrepid.aiengineering.work.WorkService().load(root, "WRK-0001").repositories();
|
||||
ok("work", "update", "WRK-0001", "--goal", "Refine the application scope");
|
||||
assertThat(new net.intrepid.aiengineering.work.WorkService().load(root, "WRK-0001").repositories()).isEqualTo(snapshots);
|
||||
@@ -90,7 +90,7 @@ class ProtocolIntegrationTest {
|
||||
assertThat(run(root, "repo", "add", "escape", "--path", "escape").code()).isEqualTo(2);
|
||||
}
|
||||
@Test void validationDetectsMissingDecisionArtifactAndDuplicateWork() throws Exception {
|
||||
init(); ok("work", "create", "One");
|
||||
init(); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "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"));
|
||||
|
||||
@@ -20,7 +20,7 @@ class RefinementSafetyTest {
|
||||
int code=new EngineeringCli(root).execute(new PrintWriter(out),new PrintWriter(err),args); output=out+err.toString(); return code;
|
||||
}
|
||||
private void ok(String... args) { int code=cli(args); assertThat(code).as(output).isZero(); }
|
||||
private void init() { ok("init","--name","Test"); ok("work","create","One"); }
|
||||
private void init() { ok("init","--name","Test"); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy","One"); }
|
||||
private Path work() { return root.resolve(".ai-engineering/works/WRK-0001-one"); }
|
||||
@Test void malformedBundleIsFullyPreflightedBeforeAnyMutation() throws Exception {
|
||||
init();
|
||||
@@ -88,7 +88,7 @@ class RefinementSafetyTest {
|
||||
assertThat(Files.readString(path)).isEqualTo(old); ok("project","validate");
|
||||
}
|
||||
@Test void aTopicCannotBeUsedByAnotherWorkAndUnsafeRecordsFailValidation() throws Exception {
|
||||
init(); ok("topic","create","WRK-0001","Private"); ok("work","create","Two");
|
||||
init(); ok("topic","create","WRK-0001","Private"); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy","Two");
|
||||
assertThat(cli("discussion","add","WRK-0002","--topic","TOP-0001","--text","Wrong owner")).isIn(2,3);
|
||||
ok("survey","create","WRK-0001","--title","Unsafe");
|
||||
Path p=work().resolve("surveys/SVY-0001.md"); Files.writeString(p,Files.readString(p).replace("workId: \"WRK-0001\"","workId: \"WRK-0002\""));
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
package net.intrepid.aiengineering;
|
||||
|
||||
import net.intrepid.aiengineering.cli.EngineeringCli;
|
||||
import net.intrepid.aiengineering.work.*;
|
||||
import net.intrepid.aiengineering.decision.*;
|
||||
import net.intrepid.aiengineering.agent.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
class WorkGuidanceTest {
|
||||
@TempDir Path root;
|
||||
private String output;
|
||||
private int cli(String... args) {
|
||||
var out = new StringWriter(); var err = new StringWriter();
|
||||
int code = new EngineeringCli(root).execute(new PrintWriter(out), new PrintWriter(err), args);
|
||||
output = out + err.toString(); return code;
|
||||
}
|
||||
private void ok(String... args) { assertThat(cli(args)).as(output).isZero(); }
|
||||
private Work work() { return new WorkService().load(root, "WRK-0001"); }
|
||||
private void init() { ok("init", "--name", "Guidance"); ok("work", "create", "Delivery"); }
|
||||
private void mode(String mode) { ok("work", "guidance", "WRK-0001", "--mode", mode, "--by", "fixture-human", "--reason", "Explicit fixture choice", "--human-approved"); }
|
||||
private void policy(String value) { ok("work", "guidance", "WRK-0001", "--approval", value, "--by", "fixture-human", "--reason", "Explicit fixture policy", "--human-approved"); }
|
||||
private void request() { ok("work", "request-decision", "WRK-0001", "--by", "fixture-human", "--reason", "Discussion concluded; prepare next DEC", "--human-approved"); }
|
||||
private int draft() { return cli("decision", "draft", "WRK-0001", "--title", "Choice", "--context", "Problem", "--approach", "Small change", "--rationale", "Bounded scope"); }
|
||||
private int plan() { return cli("plan", "create", "WRK-0001", "--title", "Delivery", "--decision", "DEC-0001"); }
|
||||
private Map<String,String> snapshot() throws Exception {
|
||||
var result = new TreeMap<String,String>(); Path folder = new WorkService().folder(root, "WRK-0001");
|
||||
try (var files = Files.walk(folder)) { for (var p : files.filter(Files::isRegularFile).toList()) result.put(folder.relativize(p).toString(), Files.readString(p)); }
|
||||
return result;
|
||||
}
|
||||
@Test void absentModeAsksAndBlocksDecisionAndPlanWithoutWrites() throws Exception {
|
||||
init(); var before = snapshot();
|
||||
assertThat(work().guidance().mode()).isEqualTo(WorkGuidance.Mode.UNSPECIFIED);
|
||||
assertThat(work().guidance().approvalPolicy()).isEqualTo(WorkGuidance.ApprovalPolicy.REQUIRED);
|
||||
ok("next-actions", "WRK-0001", "--format", "json"); assertThat(output).contains("ASK_DISCUSSION_MODE").doesNotContain("CREATE_PLAN", "EXECUTE_STEP");
|
||||
assertThat(draft()).isEqualTo(2); assertThat(output).contains("Ask the human");
|
||||
assertThat(cli("plan", "create", "WRK-0001", "--title", "Bypass")).isEqualTo(2);
|
||||
assertThat(cli("work", "guidance", "WRK-0001", "--mode", "DIRECT", "--by", "agent", "--reason", "Guess")).isEqualTo(2);
|
||||
assertThat(snapshot()).isEqualTo(before);
|
||||
}
|
||||
@Test void directModeDoesNotWaiveApprovalAndCannotDropDecisionReferences() throws Exception {
|
||||
init(); mode("DIRECT"); assertThat(draft()).as(output).isZero(); var before = snapshot();
|
||||
assertThat(plan()).isEqualTo(2); assertThat(output).contains("Human approval"); assertThat(snapshot()).isEqualTo(before);
|
||||
ok("next-actions", "WRK-0001", "--format", "json"); assertThat(output).contains("REVIEW_DECISION").doesNotContain("CREATE_PLAN");
|
||||
ok("decision", "accept", "WRK-0001", "DEC-0001", "--by", "fixture-human", "--reason", "Approve concrete DEC", "--human-approved");
|
||||
assertThat(plan()).as(output).isZero();
|
||||
assertThat(cli("plan", "update", "WRK-0001", "PLN-0001", "--clear-decisions", "--by", "agent", "--reason", "Bypass approval")).isEqualTo(2);
|
||||
ok("work", "update", "WRK-0001", "--description", "Refinement");
|
||||
assertThat(work().guidance().mode()).isEqualTo(WorkGuidance.Mode.DIRECT);
|
||||
ok("work", "context", "WRK-0001", "--format", "json"); assertThat(output).contains("guidanceInstructions", "Human approval of the concrete DEC is required");
|
||||
ok("project", "validate");
|
||||
}
|
||||
@Test void exploratoryWaiverStillNeedsHumanRequestForEachDraftAndRevision() {
|
||||
init(); mode("EXPLORATORY"); policy("WAIVED");
|
||||
assertThat(cli("plan", "create", "WRK-0001", "--title", "Skip exploration")).isEqualTo(2);
|
||||
assertThat(draft()).isEqualTo(2); assertThat(output).contains("human must request");
|
||||
ok("next-actions", "WRK-0001", "--format", "json"); assertThat(output).contains("CONTINUE_DISCUSSION").doesNotContain("CREATE_PLAN");
|
||||
request(); assertThat(draft()).as(output).isZero(); assertThat(draft()).isEqualTo(2);
|
||||
assertThat(plan()).as(output).isZero();
|
||||
var decision = new DecisionService().get(root, "WRK-0001", "DEC-0001");
|
||||
assertThat(decision.approvals().getLast().humanApproved()).isFalse();
|
||||
assertThat(decision.approvals().getLast().origin()).isEqualTo(Decision.ApprovalOrigin.SYSTEM_PLAN);
|
||||
assertThat(cli("decision", "revise", "WRK-0001", "DEC-0001", "--by", "agent", "--reason", "New evidence")).isEqualTo(2);
|
||||
request(); ok("decision", "revise", "WRK-0001", "DEC-0001", "--by", "agent", "--reason", "New evidence");
|
||||
assertThat(work().guidance().decisionRequests()).extracting(WorkGuidance.Request::decisionId).containsExactly("DEC-0001", "DEC-0002");
|
||||
ok("project", "validate");
|
||||
}
|
||||
@Test void humanPolicyRevocationPreventsExecutionOfSystemPromotedDecision() {
|
||||
init(); mode("DIRECT"); policy("WAIVED"); assertThat(draft()).as(output).isZero(); assertThat(plan()).as(output).isZero();
|
||||
ok("plan", "step", "add", "WRK-0001", "PLN-0001", "--title", "Implement"); policy("REQUIRED");
|
||||
assertThat(cli("plan", "step", "status", "WRK-0001", "PLN-0001", "TSK-0001", "ACTIVE", "--by", "agent", "--reason", "Start")).isEqualTo(2);
|
||||
assertThat(output).contains("system promotion is not human approval");
|
||||
assertThat(cli("plan", "status", "WRK-0001", "PLN-0001", "ACTIVE", "--by", "agent", "--reason", "Bypass")).isEqualTo(2);
|
||||
ok("next-actions", "WRK-0001", "--format", "json"); assertThat(output).contains("REVIEW_PLAN_AUTHORITY").doesNotContain("EXECUTE_STEP");
|
||||
assertThat(work().guidance().history()).hasSize(3);
|
||||
policy("WAIVED"); ok("plan", "step", "status", "WRK-0001", "PLN-0001", "TSK-0001", "ACTIVE", "--by", "agent", "--reason", "Authorized again");
|
||||
}
|
||||
@Test void pendingSurveyCannotBeBypassedByCreatingPlan() throws Exception {
|
||||
init(); mode("DIRECT"); policy("WAIVED"); assertThat(draft()).as(output).isZero();
|
||||
ok("survey", "create", "WRK-0001", "--title", "Question");
|
||||
var before = snapshot(); assertThat(plan()).isEqualTo(2); assertThat(snapshot()).isEqualTo(before);
|
||||
ok("next-actions", "WRK-0001", "--format", "json"); assertThat(output).doesNotContain("CREATE_PLAN");
|
||||
}
|
||||
@Test void changingToExplorationRequiresHumanRequestEvenForAnExistingDraft() {
|
||||
init(); mode("DIRECT"); policy("WAIVED"); assertThat(draft()).as(output).isZero(); mode("EXPLORATORY");
|
||||
assertThat(plan()).isEqualTo(2); assertThat(output).contains("human must request");
|
||||
ok("next-actions", "WRK-0001", "--format", "json"); assertThat(output).contains("CONTINUE_DISCUSSION").doesNotContain("CREATE_PLAN");
|
||||
ok("work", "request-decision", "WRK-0001", "--decision", "DEC-0001", "--by", "fixture-human", "--reason", "Exploration finished; retain this DEC", "--human-approved");
|
||||
assertThat(plan()).as(output).isZero();
|
||||
ok("work", "create", "Another Work");
|
||||
var another = new WorkService().load(root, "WRK-0002");
|
||||
assertThat(another.guidance().mode()).isEqualTo(WorkGuidance.Mode.UNSPECIFIED);
|
||||
assertThat(another.guidance().approvalPolicy()).isEqualTo(WorkGuidance.ApprovalPolicy.REQUIRED);
|
||||
assertThat(another.guidance().decisionRequests()).isEmpty();
|
||||
}
|
||||
@Test void adapterCannotPublishPartialProposalBeforeAnUnrequestedExploratoryDecision() throws Exception {
|
||||
init(); mode("EXPLORATORY");
|
||||
var adapter = new AgentAdapter() {
|
||||
public String id() { return "fixture-guidance"; }
|
||||
public String classify(AgentContext c, String t) { return "analyze"; }
|
||||
public AgentProposal propose(AgentContext c, Request r) {
|
||||
return new AgentProposal(id(), true, "Fixture proposal", List.of(new AgentProposal.TopicDraft("new-topic", "Must not publish", "", List.of())),
|
||||
List.of(), List.of(), List.of(), new AgentProposal.DecisionDraft("Draft", "Problem", "Approach", "Reason", List.of()));
|
||||
}
|
||||
};
|
||||
var service = new AgentService(Map.of(adapter.id(), adapter)); service.configure(root, "general", adapter.id(), "general", "default", null);
|
||||
var before = snapshot();
|
||||
assertThatThrownBy(() -> service.run(root, "WRK-0001", "Propose a DEC", "analyze", "fixture", "request-1")).hasMessageContaining("human must request");
|
||||
assertThat(snapshot()).isEqualTo(before); assertThat(work().agentRuns()).isEmpty();
|
||||
}
|
||||
@Test void chosenModeAndAuthoritySurviveAFreshProcess() throws Exception {
|
||||
init(); mode("EXPLORATORY"); request();
|
||||
var command = List.of(Path.of(System.getProperty("java.home"), "bin", "java").toString(), "-jar", System.getProperty("cli.jar"),
|
||||
"--project", root.toString(), "work", "context", "WRK-0001", "--format", "json");
|
||||
Path log = root.resolve("fresh-process.log"); var process = new ProcessBuilder(command).redirectErrorStream(true).redirectOutput(log.toFile()).start();
|
||||
try {
|
||||
assertThat(process.waitFor(30, java.util.concurrent.TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(process.exitValue()).as(Files.readString(log)).isZero();
|
||||
assertThat(Files.readString(log)).contains("EXPLORATORY", "DEC-0001", "fixture-human", "only the human ends discussion");
|
||||
} finally { process.destroyForcibly(); }
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ class WorkHexadecimalTest {
|
||||
}
|
||||
@Test void hexadecimalWorkSupportsAllReferencesAndFreshContext() throws Exception {
|
||||
init(); sequence("schemaVersion: 1\nlastWork: 9\n");
|
||||
ok("work", "create", "Hex Work"); assertThat(output).contains("WRK-000A");
|
||||
ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "Hex Work"); assertThat(output).contains("WRK-000A");
|
||||
for (int index = 1; index <= 10; index++) ok("discussion", "add", "WRK-000A", "--text", "Entry " + index);
|
||||
assertThat(output).contains("DSC-0010"); // Child counters retain their decimal convention.
|
||||
Path evidence = Files.writeString(root.resolve("evidence.txt"), "Observation\n");
|
||||
@@ -82,7 +82,7 @@ class WorkHexadecimalTest {
|
||||
for (String yaml : List.of("schemaVersion: 2\nlastWork: \"FFFFFFFFF\"\n", "schemaVersion: 2\nlastWork: \"000a\"\n",
|
||||
"schemaVersion: 2\nlastWork: \"1000000000\"\n", "schemaVersion: 1\nlastWork: -1\n", "schemaVersion: 99\nlastWork: 1\n")) {
|
||||
sequence(yaml);
|
||||
assertThat(cli(root, "work", "create", "Must not exist")).as(output).isEqualTo(4);
|
||||
assertThat(cli(root, "work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "Must not exist")).as(output).isEqualTo(4);
|
||||
assertThat(Files.readString(counter())).isEqualTo(yaml);
|
||||
try (var files = Files.list(counter().getParent())) {
|
||||
assertThat(files.map(p -> p.getFileName().toString())).containsExactly(".sequence.yaml");
|
||||
|
||||
@@ -23,11 +23,11 @@ class WorkUpdateTest {
|
||||
private void ok(String... args) { int code = cli(args); assertThat(code).as(output).isZero(); }
|
||||
private void initialize() {
|
||||
ok("init", "--name", "Test");
|
||||
ok("work", "create", "One", "--description", "Description", "--goal", "Original goal", "--motivation", "Motivation",
|
||||
ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "One", "--description", "Description", "--goal", "Original goal", "--motivation", "Motivation",
|
||||
"--constraint", "Original constraint", "--acceptance", "Original criterion", "--author", "creator");
|
||||
}
|
||||
@Test void updatesFieldsWithoutChangingIdentityHistoryOrOtherWorks() throws Exception {
|
||||
initialize(); ok("work", "create", "Two");
|
||||
initialize(); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "Two");
|
||||
ok("discussion", "add", "WRK-0001", "--text", "Preserve this discussion");
|
||||
Path source = Files.writeString(root.resolve("evidence.txt"), "Observation\n");
|
||||
ok("artifact", "add", "WRK-0001", "--file", source.toString(), "--purpose", "Evidence");
|
||||
|
||||
Reference in New Issue
Block a user