mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 15:08:38 +01:00
* chore: add a formatter, matching the style this repo already writes singleQuote=false was chosen by counting this repo's own imports, not by fleet decree. The fleet is genuinely split and the two repos that already had a .prettierrc disagreed with each other, so there was no standard to restore. Quote style does not cross repo boundaries; having a gate does. Markdown is ignored for now — prettier rewraps prose, which would bury the real diff. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * style: format with prettier (1062 files) Mechanical. No behaviour change. This SHA is listed in .git-blame-ignore-revs so `git blame` skips it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore: teach git blame to skip the reformat Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(lint): reattach two guards the reformat detached Both effects were one-liners, so a trailing eslint-disable-line covered the setState call: useEffect(() => { setSelected(new Set()); }, [q.length]); // eslint-disable-line ... prettier expanded the block. The comment stayed on the closing line while the call moved above it, so the guard protected nothing and the rule its author had deliberately silenced failed the build. This is the second shape of the same defect — hirnli had the eslint-disable-NEXT-line variant. Both come from the same fact: an eslint directive binds to a line number, so reformatting can silently unbind it, which makes 'mechanical, no behaviour change' false for any bulk reformat. * chore(desktop): bump the runner version the reformat requires desktop-release-drift enforces that anything built into Fleet Runner which differs from the last released tag must carry a version ahead of that tag — main read 0.8.15 and fleet-runner-v0.8.15 already shipped. A whole-repo reformat changes bytes under desktop/, so the gate fires. The alternative was adding desktop/ to .prettierignore, which would buy a quiet PR by carving a permanent hole in the formatter's coverage — the precise shape of silent drift this test was written to catch. Bumping is what the rule asks for and costs one patch release whose only content is whitespace. * chore: merge main and re-format A whole-repo reformat conflicts with any concurrent commit, and a conflicting PR runs no checks at all while reporting nothing. Conflicts resolved to main, which is correct because this branch changes formatting and nothing else. * chore: leave desktop/ out of this reformat desktop-release-drift is right to refuse this. Everything under desktop/ is built into Fleet Runner, so changing it means shipping: bump the version AND add a FLEET_RUNNER_RELEASES entry, whose stated audience is 'person who installed Fleet Runner and wants to know what changed'. For a whitespace-only build the honest answer is 'nothing', so that release should not exist — and I should not write release notes claiming otherwise. I had bumped to 0.8.16 to get the gate green. That was the wrong direction: publishing a build to three OS runners to keep a formatting PR quiet. Reverted. desktop/ is excluded in .prettierignore with the reasoning recorded there, to be formatted alongside the next real runner change, where the bump and the notes are true anyway. --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
149 lines
6.5 KiB
TypeScript
149 lines
6.5 KiB
TypeScript
// Self-test for the definition-of-done stop-gate decision (pure part).
|
|
// Run: npx tsx scripts/test/dod-gate.ts
|
|
import { applyDoDGate, DEFAULT_GOAL_MAX_TURNS } from "@/lib/orchestration/dod-gate";
|
|
import { isCheckableDoneBar } from "@/lib/project-health";
|
|
import { ESCALATION_HUMAN_STREAK } from "@/lib/orchestration/escalation-ladder";
|
|
import type { RunClosePatch } from "@/lib/orchestration/close-from-session";
|
|
|
|
let pass = 0,
|
|
fail = 0;
|
|
function ok(name: string, cond: boolean) {
|
|
if (cond) {
|
|
pass++;
|
|
console.log(` ✓ ${name}`);
|
|
} else {
|
|
fail++;
|
|
console.log(` ✗ ${name}`);
|
|
}
|
|
}
|
|
|
|
const base = (outcome: RunClosePatch["outcome"]): RunClosePatch => ({
|
|
state: outcome === "error" ? "error" : "done",
|
|
outcome,
|
|
summary: { done: "did the thing", next: "" } as RunClosePatch["summary"],
|
|
finishedAt: new Date(0),
|
|
});
|
|
|
|
// 1. success + met → unchanged
|
|
const r1 = applyDoDGate(base("success"), { met: true, gap: "" });
|
|
ok("success + DoD met → stays success", r1.outcome === "success");
|
|
|
|
// 2. success + NOT met → downgraded to partial, gap surfaced in next
|
|
const r2 = applyDoDGate(base("success"), { met: false, gap: "tests not run" });
|
|
ok("success + DoD unmet → partial", r2.outcome === "partial");
|
|
ok(
|
|
"success + DoD unmet → gap written to next",
|
|
typeof r2.summary.next === "string" && r2.summary.next.includes("tests not run"),
|
|
);
|
|
ok(
|
|
"success + DoD unmet → next signals not-done",
|
|
r2.summary.next!.toLowerCase().includes("not yet met"),
|
|
);
|
|
|
|
// 3. partial + NOT met → unchanged (only gates success)
|
|
const r3 = applyDoDGate(base("partial"), { met: false, gap: "x" });
|
|
ok("partial + DoD unmet → stays partial (not re-gated)", r3.outcome === "partial");
|
|
|
|
// 4. error + NOT met → unchanged
|
|
const r4 = applyDoDGate(base("error"), { met: false, gap: "x" });
|
|
ok("error + DoD unmet → stays error", r4.outcome === "error");
|
|
|
|
// 5. empty gap still produces an actionable next
|
|
const r5 = applyDoDGate(base("success"), { met: false, gap: "" });
|
|
ok(
|
|
"success + DoD unmet + empty gap → still has actionable next",
|
|
!!r5.summary.next && r5.summary.next.length > 10,
|
|
);
|
|
|
|
// ── Turn cap (goal-mode) ─────────────────────────────────────────────────────
|
|
// 6. under the cap → still downgrades (loop continues)
|
|
const r6 = applyDoDGate(
|
|
base("success"),
|
|
{ met: false, gap: "flaky" },
|
|
{ maxTurns: 3, priorPartials: 1 },
|
|
);
|
|
ok("unmet + under cap → still downgrades to partial", r6.outcome === "partial");
|
|
|
|
// 7. AT the cap → stops downgrading (keeps success so the loop halts) + flags it
|
|
const r7 = applyDoDGate(
|
|
base("success"),
|
|
{ met: false, gap: "flaky" },
|
|
{ maxTurns: 3, priorPartials: 3 },
|
|
);
|
|
ok("unmet + at cap → keeps success (loop halts)", r7.outcome === "success");
|
|
ok(
|
|
"unmet + at cap → next records the cap + escalation",
|
|
!!r7.summary.next && r7.summary.next.toLowerCase().includes("after 3 attempt"),
|
|
);
|
|
|
|
// 8. cap set but goal MET → unchanged success (cap never engages)
|
|
const r8 = applyDoDGate(base("success"), { met: true, gap: "" }, { maxTurns: 3, priorPartials: 5 });
|
|
ok("met + over cap → stays success, no cap note", r8.outcome === "success" && !r8.summary.next);
|
|
|
|
// 9. no cap (maxTurns null) → loops forever. Reachable ONLY via an explicit
|
|
// goal_max_turns=0 now that the default is bounded; see DEFAULT_GOAL_MAX_TURNS.
|
|
const r9 = applyDoDGate(
|
|
base("success"),
|
|
{ met: false, gap: "x" },
|
|
{ maxTurns: null, priorPartials: 99 },
|
|
);
|
|
ok("unmet + explicit no-cap → downgrades forever (opt-in only)", r9.outcome === "partial");
|
|
|
|
// 10. The default bound exists and is the ladder's human rung — an unbounded
|
|
// goal loop is invisible to the failure brake AND the escalation ladder
|
|
// (a partial streak is not a failure streak), so "loop forever" must not be
|
|
// what a project gets by saying nothing.
|
|
ok(
|
|
"default goal cap is bounded",
|
|
Number.isFinite(DEFAULT_GOAL_MAX_TURNS) && DEFAULT_GOAL_MAX_TURNS > 0,
|
|
);
|
|
ok(
|
|
"default goal cap is SSOT'd to the ladder's human rung",
|
|
DEFAULT_GOAL_MAX_TURNS === ESCALATION_HUMAN_STREAK,
|
|
);
|
|
|
|
// 11. A project that has been looping at the default cap stops looping.
|
|
const r11 = applyDoDGate(
|
|
base("success"),
|
|
{ met: false, gap: "five integrity layers still missing" },
|
|
{ maxTurns: DEFAULT_GOAL_MAX_TURNS, priorPartials: DEFAULT_GOAL_MAX_TURNS },
|
|
);
|
|
ok("unmet at default cap → stops looping (success, flagged)", r11.outcome === "success");
|
|
ok(
|
|
"capped close names the gap so the human alert is actionable",
|
|
!!r11.summary.next && r11.summary.next.includes("five integrity layers still missing"),
|
|
);
|
|
|
|
// ── Is the BAR itself gradeable? ───────────────────────────────────────────
|
|
// Everything above tests what happens once a bar is judged unmet. This tests
|
|
// the upstream failure that made that path fire constantly: bars written as
|
|
// descriptions of the finished product. On 2026-08-04, 10 of 19 projects had
|
|
// one, and the fleet closed 26 partial / 10 timeout / 3 success in a week —
|
|
// the agents were fine, the bar was ungradeable.
|
|
const PRODUCT_DESCRIPTIONS = [
|
|
"Placement decisions are made with compatibility scores, and outcomes are tracked to improve future recommendations",
|
|
"Transactions are atomic, money is not a float, Swiss law governs, data belongs to its owner",
|
|
"Not explicitly defined, but implies that a product is done when it is live, profitable, and meets its targets",
|
|
"Clean, readable code, no wasted space, every pixel earns its place",
|
|
"Five layers of data integrity: client-side validation, server route validation, constraints, property-based checks",
|
|
];
|
|
for (const bar of PRODUCT_DESCRIPTIONS) {
|
|
ok(`ungradeable bar rejected: "${bar.slice(0, 42)}…"`, !isCheckableDoneBar(bar));
|
|
}
|
|
|
|
const CHECKABLE_BARS = [
|
|
"`npm run verify` passes, with its real output in the handoff (lint:/tsc:/tests:). Work is committed and pushed.",
|
|
"`pnpm verify` passes. If the change is user-visible: merged, and Deploy green for that commit.",
|
|
"tsc + lint clean, tests pass, deploys green",
|
|
"The change is applied to the box and proven: the affected unit is active and its health check passes.",
|
|
];
|
|
for (const bar of CHECKABLE_BARS) {
|
|
ok(`gradeable bar accepted: "${bar.slice(0, 42)}…"`, isCheckableDoneBar(bar));
|
|
}
|
|
|
|
ok("empty bar is not gradeable", !isCheckableDoneBar(""));
|
|
ok("missing bar is not gradeable", !isCheckableDoneBar(undefined));
|
|
|
|
console.log(`\n${fail === 0 ? "✓" : "✗"} dod-gate: ${pass} passed, ${fail} failed`);
|
|
process.exit(fail === 0 ? 0 : 1);
|