mirror of
https://github.com/Heretek-OpenCode/heretek-opencode.git
synced 2026-11-09 10:39:36 -10:00
- state/: SDK type re-exports + JSONL prev-hash journal, snapshot, resume - dag/: topo sort, cycle detect, ready-set - scheduler/: run loop, rework cap=2 -> waiting_human, judge-split fix tasks, goalUnchanged drift guard - lanes/: bwrap|docker|dagger select, worktree lifecycle, refs/fleet-salvage/* - host/: opencode serve REST adapter (prompt/steer/wait/diff, polling fallback) - gates/: mechanical runner + budget enforcement, SDK GateReport shape - judges/: qa-functional + qa-adversarial prompts and report parsers - pipeline/: grill->research->spec->build->dualQA->humanPR stages + artifacts - cli/: grill|research|spec|run|status|approve|resume|steer - trust: git SHAs + journal chains + branch protection + human PR; no ceremony - tests: 29 pass (dag, journal, scheduler, goalUnchanged)
64 lines
2.3 KiB
TypeScript
64 lines
2.3 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { checkGoalDrift, goalUnchanged } from "../src/scheduler/index.js";
|
|
import type { GoalSnapshot } from "../src/scheduler/index.js";
|
|
|
|
const INITIAL: GoalSnapshot = {
|
|
intent: "Add CSV export to the reports page with a download button",
|
|
criteria: [
|
|
{ id: "c1", text: "Export button downloads a valid CSV file", verify: "cmd" },
|
|
{ id: "c2", text: "Export respects the current date filter", verify: "judge" },
|
|
],
|
|
};
|
|
|
|
describe("goalUnchanged", () => {
|
|
test("identical context is unchanged", () => {
|
|
expect(goalUnchanged(INITIAL, structuredClone(INITIAL))).toBe(true);
|
|
});
|
|
|
|
test("cosmetic rewording is unchanged", () => {
|
|
const current: GoalSnapshot = {
|
|
intent: "Add a CSV export to reports page, with download button!",
|
|
criteria: [
|
|
{ id: "c1", text: "Export button downloads a valid CSV file.", verify: "cmd" },
|
|
{ id: "c2", text: "Export respects the current date filter", verify: "judge" },
|
|
],
|
|
};
|
|
expect(goalUnchanged(INITIAL, current)).toBe(true);
|
|
});
|
|
|
|
test("mutated intent is drift", () => {
|
|
const current: GoalSnapshot = {
|
|
intent: "Rewrite the billing system in Rust",
|
|
criteria: INITIAL.criteria,
|
|
};
|
|
expect(goalUnchanged(INITIAL, current)).toBe(false);
|
|
expect(checkGoalDrift(INITIAL, current).reasons.some((r) => r.includes("intent"))).toBe(true);
|
|
});
|
|
|
|
test("dropped criterion is drift", () => {
|
|
const current: GoalSnapshot = { intent: INITIAL.intent, criteria: [INITIAL.criteria[0]!] };
|
|
expect(goalUnchanged(INITIAL, current)).toBe(false);
|
|
});
|
|
|
|
test("weakened verify method is drift", () => {
|
|
const current: GoalSnapshot = {
|
|
intent: INITIAL.intent,
|
|
criteria: [
|
|
{ id: "c1", text: "Export button downloads a valid CSV file", verify: "human" },
|
|
INITIAL.criteria[1]!,
|
|
],
|
|
};
|
|
const report = checkGoalDrift(INITIAL, current);
|
|
expect(report.unchanged).toBe(false);
|
|
expect(report.reasons.some((r) => r.includes("weakened"))).toBe(true);
|
|
});
|
|
|
|
test("added scope without a grill round is drift", () => {
|
|
const current: GoalSnapshot = {
|
|
intent: INITIAL.intent,
|
|
criteria: [...INITIAL.criteria, { id: "c9", text: "Also send exports by email nightly", verify: "cmd" }],
|
|
};
|
|
expect(goalUnchanged(INITIAL, current)).toBe(false);
|
|
});
|
|
});
|