mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-06 01:18:14 +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>
164 lines
5.5 KiB
TypeScript
164 lines
5.5 KiB
TypeScript
// Pure tests for the feedback work-phase honesty layer. The one regression
|
|
// this file exists to pin: a DISPATCHED row with NO run record is STUCK
|
|
// (retryable, poll stops), never a perpetual QUEUED — the run row is created
|
|
// before the status flips, so "no record" always means failed-create or
|
|
// pruned, and QUEUED-forever had no exit (endless 8s polls, no Retry button,
|
|
// and the dispatch route's duplicate-guard treating it as un-retryable).
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
deriveFeedbackWork,
|
|
FEEDBACK_WORK_PHASE,
|
|
type FeedbackRunSnapshot,
|
|
} from "../../src/lib/feedback/work-phase";
|
|
import { FEEDBACK_STATUS } from "../../src/lib/constants/statuses";
|
|
import { ORCH_STATE, ORCHESTRATION_OUTCOME } from "../../src/lib/orchestration/contract";
|
|
|
|
function snap(over: Partial<FeedbackRunSnapshot>): FeedbackRunSnapshot {
|
|
return {
|
|
id: "run-1",
|
|
state: ORCH_STATE.WAITING,
|
|
outcome: null,
|
|
startedAt: new Date(),
|
|
finishedAt: null,
|
|
deliveredAt: null,
|
|
error: null,
|
|
...over,
|
|
};
|
|
}
|
|
|
|
// Terminal statuses ignore the run entirely.
|
|
assert.equal(
|
|
deriveFeedbackWork(FEEDBACK_STATUS.ARCHIVED, null).phase,
|
|
FEEDBACK_WORK_PHASE.ARCHIVED,
|
|
);
|
|
assert.equal(deriveFeedbackWork(FEEDBACK_STATUS.RESOLVED, null).phase, FEEDBACK_WORK_PHASE.DONE);
|
|
assert.equal(deriveFeedbackWork(FEEDBACK_STATUS.NEW, null).phase, FEEDBACK_WORK_PHASE.NOT_STARTED);
|
|
|
|
// THE regression pin: dispatched + no run record = STUCK, not queued.
|
|
const runless = deriveFeedbackWork(FEEDBACK_STATUS.DISPATCHED, null);
|
|
assert.equal(
|
|
runless.phase,
|
|
FEEDBACK_WORK_PHASE.STUCK,
|
|
"run-less dispatched row must be STUCK (retryable)",
|
|
);
|
|
|
|
// Live states.
|
|
assert.equal(
|
|
deriveFeedbackWork(FEEDBACK_STATUS.DISPATCHED, snap({ state: ORCH_STATE.RUNNING })).phase,
|
|
FEEDBACK_WORK_PHASE.WORKING,
|
|
);
|
|
assert.equal(
|
|
deriveFeedbackWork(FEEDBACK_STATUS.DISPATCHED, snap({ startedAt: new Date(Date.now() - 10_000) }))
|
|
.phase,
|
|
FEEDBACK_WORK_PHASE.QUEUED,
|
|
"young undelivered run is queued",
|
|
);
|
|
assert.equal(
|
|
deriveFeedbackWork(
|
|
FEEDBACK_STATUS.DISPATCHED,
|
|
snap({ startedAt: new Date(Date.now() - 5 * 60_000) }),
|
|
).phase,
|
|
FEEDBACK_WORK_PHASE.STUCK,
|
|
"undelivered past the starting window is stuck",
|
|
);
|
|
assert.equal(
|
|
deriveFeedbackWork(
|
|
FEEDBACK_STATUS.DISPATCHED,
|
|
snap({ startedAt: new Date(Date.now() - 5 * 60_000), deliveredAt: new Date().toISOString() }),
|
|
).phase,
|
|
FEEDBACK_WORK_PHASE.WORKING,
|
|
"delivered within the thinking window is working",
|
|
);
|
|
assert.equal(
|
|
deriveFeedbackWork(
|
|
FEEDBACK_STATUS.DISPATCHED,
|
|
snap({ startedAt: new Date(Date.now() - 20 * 60_000), deliveredAt: new Date().toISOString() }),
|
|
).phase,
|
|
FEEDBACK_WORK_PHASE.STUCK,
|
|
"delivered but silent past the thinking window is stuck",
|
|
);
|
|
|
|
// Closed states.
|
|
assert.equal(
|
|
deriveFeedbackWork(
|
|
FEEDBACK_STATUS.DISPATCHED,
|
|
snap({
|
|
state: ORCH_STATE.CLOSED,
|
|
outcome: ORCHESTRATION_OUTCOME.SUCCESS,
|
|
finishedAt: new Date(),
|
|
}),
|
|
).phase,
|
|
FEEDBACK_WORK_PHASE.DONE,
|
|
);
|
|
assert.equal(
|
|
deriveFeedbackWork(
|
|
FEEDBACK_STATUS.DISPATCHED,
|
|
snap({
|
|
state: ORCH_STATE.CLOSED,
|
|
outcome: ORCHESTRATION_OUTCOME.ERROR,
|
|
finishedAt: new Date(),
|
|
}),
|
|
).phase,
|
|
FEEDBACK_WORK_PHASE.FAILED,
|
|
);
|
|
assert.equal(
|
|
deriveFeedbackWork(FEEDBACK_STATUS.DISPATCHED, snap({ outcome: ORCHESTRATION_OUTCOME.HANG }))
|
|
.phase,
|
|
FEEDBACK_WORK_PHASE.FAILED,
|
|
);
|
|
|
|
// Never the word the layer exists to kill.
|
|
for (const status of [
|
|
FEEDBACK_STATUS.NEW,
|
|
FEEDBACK_STATUS.DISPATCHED,
|
|
FEEDBACK_STATUS.RESOLVED,
|
|
] as const) {
|
|
assert.ok(
|
|
!deriveFeedbackWork(status, null).label.toLowerCase().includes("dispatched"),
|
|
"labels never say 'dispatched'",
|
|
);
|
|
}
|
|
|
|
// A detail line must EARN its row: it exists only to say what the badge cannot.
|
|
// "No agent has been asked to fix this yet." said nothing the "Not started"
|
|
// badge and the "Implement" button had not already said, and the fleet strip
|
|
// printed it once per row — five identical sentences on five new items.
|
|
assert.equal(
|
|
deriveFeedbackWork(FEEDBACK_STATUS.NEW, null).detail,
|
|
null,
|
|
"Not started carries no detail — the badge and the Implement button already say it",
|
|
);
|
|
|
|
// Not generalised on purpose. "Adds information" is a judgement about meaning,
|
|
// and every mechanical proxy tried here (must contain an imperative; must not
|
|
// prefix-match the label) either missed the sentence above or failed honest
|
|
// copy like "Starting — waiting for the agent to pick it up." So this stays a
|
|
// single pin plus a reviewer's eye, rather than a green check that proves
|
|
// nothing.
|
|
|
|
// A raw run error is a diagnostic, not advice. /control printed one verbatim,
|
|
// twice: "Corrected 2026-08-24: repo evidence in the run window belonged to a
|
|
// sibling run; this run was acked verified:false and never started." The
|
|
// detail line is written for a human; the executor's text goes behind a
|
|
// disclosure the reader opens on purpose.
|
|
{
|
|
const note = "Corrected 2026-08-24: repo evidence in the run window belonged to a sibling run";
|
|
const failed = deriveFeedbackWork(
|
|
FEEDBACK_STATUS.DISPATCHED,
|
|
snap({ state: ORCH_STATE.ERROR, error: note }),
|
|
);
|
|
assert.equal(failed.phase, FEEDBACK_WORK_PHASE.FAILED);
|
|
assert.equal(
|
|
failed.diagnostic,
|
|
note,
|
|
"the error is kept — it is the most useful text when a run really did fail",
|
|
);
|
|
assert.ok(
|
|
failed.detail && !failed.detail.includes("Corrected"),
|
|
"...but the line addressed to the reader is written for the reader",
|
|
);
|
|
assert.ok(failed.detail!.includes("Retry"), "and it still says what to do next");
|
|
}
|
|
|
|
console.log("✓ feedback work-phase tests passed");
|