Fix goal state recovery, approval invalidation and worker tracking

Unify Log boundaries, serialize completion edits, preserve immutable session state and solo recovery, and match stock worker execution events. Remove unused plan views and brittle prose checks; correct installation and context guidance.

Co-Authored-By: Pi/OpenAI <288921227+claudypoo@users.noreply.github.com>
This commit is contained in:
wassnameandPi/OpenAI committed 2026-09-12 15:01:43 +08:00
1 parent 31eb3a59c6
commit 6fa518fc49
10 files changed
+394 -207

No files matched your search

+13 -34
View File
@@ -1,40 +1,19 @@
import { expect, it } from "vitest";
import { planViews } from "../src/plan-view.js";
it("keeps outcome, preferences and discriminators without tasks or history", () => {
const plan = "# Outcome\nBeat random, not just plot it.\n## User preferences\nKeep costs low.\n## Goals\n1. [ ] goal: repair\n - discriminator: beats random\n - subtle failure mode: plot exists but result fails\n - tasks:\n 1. [x] draw plot\n - evidence:\n - old output\n2. [ ] goal: confirm\n## Task list\n- [ ] run it\n## Appendix\nunapproved idea";
const views = planViews(plan);
for (const text of ["Beat random", "Keep costs low", "goal: repair", "discriminator: beats random", "subtle failure mode", "goal: confirm"]) expect(views.short).toContain(text);
for (const text of ["draw plot", "old output", "run it", "unapproved idea"]) expect(views.short).not.toContain(text);
expect(views.long).toContain("draw plot");
expect(views.long).toContain("old output");
expect(views.long).not.toContain("unapproved idea");
it.each(["", " "])("ignores %sindented identity bookkeeping and Log edits, but reviews tasks and goals", indent => {
const base = `# Plan\n- [ ] goal: result\n - tasks:\n - [ ] run it\n${indent}- worker session: /saved.jsonl\n## Log\nfirst entry`;
const view = planViews(base).notify;
expect(planViews(base.replace("/saved.jsonl", "/moved.jsonl")).notify).toBe(view);
expect(planViews(base.replace("first entry", "second entry")).notify).toBe(view);
expect(planViews(base.replace("- [ ] run it", "- [x] run it")).notify).not.toBe(view);
expect(planViews(base.replace("[ ] goal: result", "[x] goal: result")).notify).not.toBe(view);
});
it("omits only named worker identity fields from review while retaining them in full context", () => {
const base = "# Plan\n- preferred worker model: provider/model\n- [ ] goal: result\n - discriminator: exact bytes";
const metadata = "\n- Active worker: worker-1\n- worker session: /saved.jsonl\n- worker intercom session: uuid";
expect(planViews(base + metadata).short).toBe(planViews(base).short);
expect(planViews(base + metadata).long).toContain("/saved.jsonl");
expect(planViews(base.replace("exact bytes", "approximate match")).short).not.toBe(planViews(base).short);
expect(planViews(base.replace("[ ]", "[x]")).short).not.toBe(planViews(base).short);
});
it("notifies on goal and task changes but not on identity bookkeeping or log edits", () => {
const base = "# Plan\n- [ ] goal: result\n## Task list\n- [ ] run it\n- worker session: /saved.jsonl\n## Log\nfirst entry";
const baseView = planViews(base).notify;
// identity bookkeeping: silent
expect(planViews(base.replace("/saved.jsonl", "/moved.jsonl")).notify).toBe(baseView);
// log edits: silent
expect(planViews(base.replace("first entry", "second entry")).notify).toBe(baseView);
// worker ticking a task: review event (field catch, LUCID3 2026-09-10)
expect(planViews(base.replace("- [ ] run it", "- [x] run it")).notify).not.toBe(baseView);
// goal edits: review event
expect(planViews(base.replace("[ ] goal: result", "[x] goal: result")).notify).not.toBe(baseView);
});
it("stops at history and preserves a manual goal tick", () => {
const view = planViews("# Plan\n1. [x] goal: result\n## Log\n1. [ ] goal: historical");
expect(view.short).toContain("[x] goal: result");
expect(view.long).not.toContain("historical");
it("uses Log as the boundary even when Interview precedes Goals", () => {
const plan = "# Plan\n## Interview\nOriginal discussion\n## Goals\n- [ ] goal: output\n### Log\n- [ ] goal: archived";
const view = planViews(plan).notify;
expect(view).toContain("goal: output");
expect(view).not.toContain("archived");
expect(planViews(plan.replace("goal: output", "goal: changed output")).notify).not.toBe(view);
});