even-keel 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ All notable changes to Even Keel are documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.2.4] - 2026-11-11
8
+
9
+ ### Fixed
10
+
11
+ - A project without a counted CI no longer takes main for green when the session merged without running its check. Main counts as green only when the check hook reports it passed on the merged tree (`checkpoint` plugin 0.14.1). A merge without that report, made by a session without the `checkpoint` package for one, is checked in the next task's folder before that task starts.
12
+
7
13
  ## [0.2.3] - 2026-11-07
8
14
 
9
15
  ### Fixed
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The reports of the checks before the merge, by project and task, as the `checkpoint` hook sends them. Only a report
3
+ * proves the check ran; in memory, so after a restart a push of main without one is checked in the next task's place.
4
+ */
5
+ export class CheckReports {
6
+ reports = new Map();
7
+ report(project, task, report) {
8
+ this.reports.set(`${project}\n${task}`, report);
9
+ }
10
+ of(project, task) {
11
+ return this.reports.get(`${project}\n${task}`);
12
+ }
13
+ }
14
+ /** The report in a request's body; `null` — not one. */
15
+ export function checkReportOf(body) {
16
+ if (typeof body !== 'object' || body === null)
17
+ return null;
18
+ const { tree, commands } = body;
19
+ if (typeof tree !== 'string' || !/^[0-9a-f]{40}([0-9a-f]{24})?$/.test(tree))
20
+ return null;
21
+ if (!Array.isArray(commands) || !commands.every((command) => typeof command === 'string'))
22
+ return null;
23
+ return { tree, commands };
24
+ }
@@ -57,7 +57,7 @@ export class Cleanups {
57
57
  }
58
58
  /** Cleans up after a done task and, once main is pushed, awaits the CI's verdict on it. */
59
59
  async closeUp(project, task) {
60
- const tree = (await this.main?.taskTree(project, task)) ?? null;
60
+ const tree = this.main?.reportedTree(project, task) ?? null;
61
61
  const outcome = await this.cleanUp(project, task, this.reviews.cleanupOf(project, task));
62
62
  this.reviews.closedUp(project, task);
63
63
  this.syncRetries.delete(project);
@@ -46,16 +46,16 @@ export class MainCheck {
46
46
  const run = this.afterRuns.get(project);
47
47
  return run === undefined ? undefined : { commit: run.commit, since: run.since };
48
48
  }
49
- /** The tree of the task's branch, read before its cleanup deletes the branch; `null` — unknown. */
50
- async taskTree(project, task) {
49
+ /** The tree the check before the task's merge reported, read before its cleanup; `null` — no report. */
50
+ reportedTree(project, task) {
51
51
  try {
52
- return await this.deps.taskTree(project, task);
52
+ return this.deps.reportedTree(project, task);
53
53
  }
54
54
  catch {
55
55
  return null;
56
56
  }
57
57
  }
58
- /** After the cleanup of a done task synced main: the CI's verdict on the commit is awaited. */
58
+ /** After the cleanup of a done task synced main: the CI's verdict on the commit is awaited; `tree` — `reportedTree`. */
59
59
  async pushed(project, task, tree) {
60
60
  let commit;
61
61
  try {
@@ -81,7 +81,13 @@ export class MainCheck {
81
81
  const checked = tree !== null && (await this.deps.tree(project, commit).catch(() => null)) === tree;
82
82
  const earlier = [...(gate.local?.tasks ?? []), ...(gate.check?.tasks ?? [])];
83
83
  delete gate.local;
84
- const push = { commit, at: this.now().toISOString(), tasks: [...earlier, task], ...(checked ? { checked: true } : {}) };
84
+ const push = {
85
+ commit,
86
+ at: this.now().toISOString(),
87
+ tasks: [...earlier, task],
88
+ ...(checked ? { checked: true } : {}),
89
+ ...(tree === null && this.deps.checking(project).commands.length > 0 ? { unreported: true } : {}),
90
+ };
85
91
  if (this.deps.verdict(project, commit, push.at).state === 'none') {
86
92
  delete gate.check;
87
93
  this.withoutCi(project, gate, push, []);
@@ -338,12 +344,14 @@ export class MainCheck {
338
344
  if (reasons.length > 0)
339
345
  this.log(`ci: ${project}: the CI cannot judge ${commit} (${why}); the project's check takes it`);
340
346
  if (push.checked === true)
341
- this.passed(project, gate, push, 'is the tree the check passed before the merge');
342
- else if (!recheck)
347
+ this.passed(project, gate, push, 'is the tree the check before the merge reported');
348
+ // Without a report nothing shows the check ran, whatever the trees: the check of main is not the user's to skip then.
349
+ else if (!recheck && push.unreported !== true)
343
350
  this.unchecked(project, gate, push, 'main moved past the checked branch, and the check of main is off');
344
351
  else {
345
352
  gate.local = push;
346
- this.log(`ci: ${project}: ${commit} is checked in the next task's place before it starts`);
353
+ const why = push.unreported === true ? ': the check before the merge did not report' : '';
354
+ this.log(`ci: ${project}: ${commit} is checked in the next task's place before it starts${why}`);
347
355
  }
348
356
  }
349
357
  passed(project, gate, push, how) {
@@ -76,11 +76,12 @@ export function mainCheckDeps(deps) {
76
76
  create: (project, task) => deps.create({ project, ...task }),
77
77
  comment: deps.comment,
78
78
  prepare: deps.prepare,
79
- async taskTree(project, task) {
80
- const repo = deps.repo(project);
81
- const refs = await deps.git(repo, ['for-each-ref', '--format=%(objectname)', `refs/heads/${task.toLowerCase()}`]);
82
- const commit = refs.code === 0 ? refs.out.split(/\r?\n/).find((line) => line.trim() !== '') : undefined;
83
- return commit === undefined ? null : revision(repo, `${commit.trim()}^{tree}`);
79
+ // A check of other commands than the project's now proves nothing about them.
80
+ reportedTree(project, task) {
81
+ const report = deps.reported(project, task);
82
+ const commands = deps.commands(project);
83
+ const same = report !== undefined && report.commands.length === commands.length && report.commands.every((command, at) => command === commands[at]);
84
+ return same ? report.tree : null;
84
85
  },
85
86
  tree: (project, commit) => revision(deps.repo(project), `${commit}^{tree}`),
86
87
  checking(project) {
@@ -10,6 +10,7 @@ import { guardedServer } from './server-guard.js';
10
10
  import { englishOf, fail, noticeOf } from './notice/notice.js';
11
11
  import { isTaskId, parsePeriodQuery, parseStatsFilter, } from './stats/model.js';
12
12
  import { parseChangeIds, parseCompareQuery, parseRulesQuery, } from './stats/rules.js';
13
+ import { checkReportOf } from './chain/checkreports.js';
13
14
  import { statusMovesOf } from './chain/moves.js';
14
15
  import { CLAUDE } from './claude/name.js';
15
16
  import { HOOK_EVENTS } from './sessions/mail.js';
@@ -190,6 +191,24 @@ async function route(deps, request, response) {
190
191
  sendJson(response, 200, check);
191
192
  return;
192
193
  }
194
+ if (request.method === 'POST' && mergeCheck !== null) {
195
+ let known;
196
+ try {
197
+ const report = checkReportOf(await readJsonBody(request, MAX_BODY_BYTES));
198
+ if (report === null)
199
+ throw fail('request.required', { field: 'tree' });
200
+ known = deps.checkReport(decodeURIComponent(mergeCheck[1]), report);
201
+ }
202
+ catch (error) {
203
+ sendFailure(response, error);
204
+ return;
205
+ }
206
+ if (known)
207
+ sendJson(response, 200, { ok: true });
208
+ else
209
+ response.writeHead(404).end();
210
+ return;
211
+ }
193
212
  const standards = /^\/api\/sessions\/([^/]+)\/standards$/.exec(path);
194
213
  if (request.method === 'GET' && standards !== null) {
195
214
  const check = deps.mergeCheck(decodeURIComponent(standards[1]));
@@ -402,6 +402,7 @@ export async function wireDispatcher(ctx) {
402
402
  watches: (project) => (ctx.ciWatches.found ? ctx.ciWatches.shown(project) : null),
403
403
  settings: (project) => ctx.configStore.current.settings[project]?.ci ?? DEFAULT_CI,
404
404
  commands: (project) => ctx.configStore.current.settings[project]?.check ?? [],
405
+ reported: (project, task) => ctx.checkReports.of(project, task),
405
406
  language: () => ctx.configStore.current.language ?? ctx.promptLanguage(),
406
407
  promptLanguage: ctx.promptLanguage,
407
408
  create: async (task) => (await ctx.linkOf(task.project)?.run(async (tracker) => tracker.create?.(task))) ?? null,
@@ -384,6 +384,13 @@ export function wireServer(ctx) {
384
384
  const commands = settings === undefined ? [] : mergeCheck(settings.check, settings.ci, views);
385
385
  return { commands, branch: ctx.branchOf(run.project), standards: settings?.standards ?? [] };
386
386
  },
387
+ checkReport: (sessionId, report) => {
388
+ const run = handoffsOf(ctx.launches, sessionId);
389
+ if (run === undefined)
390
+ return false;
391
+ ctx.checkReports.report(run.project, run.task, report);
392
+ return true;
393
+ },
387
394
  tools: async (project) => {
388
395
  const repo = ctx.configStore.current.projects[project];
389
396
  if (repo === undefined)
@@ -23,6 +23,7 @@ import { englishOf, fail, noticeOf, withLabels } from './notice/notice.js';
23
23
  import { guardToken } from './guard.js';
24
24
  import { ProjectRemotes } from './projects/remotes.js';
25
25
  import { Approvals } from './sessions/approvals.js';
26
+ import { CheckReports } from './chain/checkreports.js';
26
27
  import { createChat } from './sessions/chat.js';
27
28
  import { Mailbox } from './sessions/mailbox.js';
28
29
  import { settleMail } from './sessions/mailRelay.js';
@@ -134,6 +135,7 @@ const context = {
134
135
  get changelogs() { return changelogs; },
135
136
  get chatTitles() { return chatTitles; },
136
137
  get checkMergeTarget() { return checkMergeTarget; },
138
+ get checkReports() { return checkReports; },
137
139
  get choiceFor() { return choiceFor; },
138
140
  get ciOn() { return ciOn; },
139
141
  get ciTokenOf() { return ciTokenOf; },
@@ -410,6 +412,7 @@ const packages = accountsService.wirePackages(context);
410
412
  */
411
413
  function briefOn(project, reader = project) { return accountsService.briefOn(context, project, reader); }
412
414
  const approvals = new Approvals({ language: () => configStore.current.language ?? promptLanguage(), unattended: () => configStore.current.unattended });
415
+ const checkReports = new CheckReports();
413
416
  const runtimes = accountsService.wireRuntimes(context);
414
417
  /** The agent of an account folder: every session of the folder runs on it. */
415
418
  const agentOf = accountsService.wireAgentOf(context);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "even-keel",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Runs Claude Code sessions over a tracker's tasks one after another, in the order of their blocks relations",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "checkpoint",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "description": "Context checkpoints for Even Keel chain sessions of Claude Code, Codex and OpenCode: once the context passes 200k tokens (and every 50k after, every 25k past 250k), the session is asked to write a handoff note and end its turn with `CHECKPOINT: <path>`, so that Even Keel continues the task in a fresh session instead of re-reading the whole context on every turn. A session that writes the note but forgets the line is sent back to add it. The context and the note come from Even Keel, which reads the transcripts of both agents, so a session it did not start is left alone. The first threshold is the project's calibrated one, and a task that has had three handoffs is asked only from 300k; on a small context window the late and hard thresholds come down to 85 % and 95 % of it. A project that turns handoffs by context off in Even Keel gets no nudge at all and is left to the agent's own compaction. Thresholds: CHECKPOINT_FIRST_TOKENS, CHECKPOINT_STEP_TOKENS, CHECKPOINT_LATE_TOKENS, CHECKPOINT_LATE_STEP_TOKENS, CHECKPOINT_HARD_TOKENS and CHECKPOINT_MAX_HANDOFFS. In a chain session of a project without a CI to judge its main branch, the merge of the task branch waits for the project's check commands from Even Keel and is blocked while they fail. A message the user writes from Even Keel's chat to a working session reaches it mid-turn: before or after its next tool call, at its stop (the turn goes on), or in place of a question it was about to ask. A tool call Claude Code stops on a permission dialog for is asked on Even Keel's page too, and the user's \"Allow\" or \"Deny\" there answers the dialog without stopping the session. An MCP call Claude Code made before loading the tool's schema, whose numbers or lists went as strings and failed the server's validation, gets a hint in the context: load the schema with ToolSearch and repeat the call. A project's standards, set on Even Keel's page (a document of the repository and the files it guards): the first read of a guarded file brings the document into the context, the first edit of one before that is refused with the document, a compaction brings it again, and a standard that asks for it holds the merge (in PR mode, the PULL REQUEST mark) of a branch that changed its files until `.temp/shot/` has shots newer than the change and `.temp/<document>-check.md` answers each question of the document's section \"The check\". OpenCode sessions get the nudges and the chat's messages after each tool call, the standards, the merge check and the CHECKPOINT line from the plugin's OpenCode plugin (opencode/checkpoint.mjs): a turn that wrote the note gets the line added to its last text instead of being sent back.",
5
5
  "author": {
6
6
  "name": "Even Keel"
@@ -30,7 +30,7 @@ Even Keel takes it from there: it stops the session and starts a new one in the
30
30
 
31
31
  ## The check before the merge
32
32
 
33
- A third hook, on `PreToolUse` of Bash, guards the merge of a chain session. When a command runs `git … merge … <branch>` with the branch of the session's own worktree — the session bringing its task into `main` — the hook asks Even Keel for the project's check (`/api/sessions/<id>/check`, the `commands.check` of the project). Even Keel gives the commands only when no CI it counts will judge `main`: the project counts none, or one does not answer. The hook runs them in order in the worktree, through the system shell, 20 minutes each at most; the first that fails blocks the merge, and its command, exit code and the last 60 lines of output go back to the session to fix. A command without `merge`, a merge of another branch, `--abort`, a session Even Keel did not start, or Even Keel not answering within two seconds — the hook lets the command through.
33
+ A third hook, on `PreToolUse` of Bash, guards the merge of a chain session. When a command runs `git … merge … <branch>` with the branch of the session's own worktree — the session bringing its task into `main` — the hook asks Even Keel for the project's check (`/api/sessions/<id>/check`, the `commands.check` of the project). Even Keel gives the commands only when no CI it counts will judge `main`: the project counts none, or one does not answer. The hook runs them in order in the worktree, through the system shell, 20 minutes each at most; the first that fails blocks the merge, and its command, exit code and the last 60 lines of output go back to the session to fix. When every command passes on a worktree without uncommitted changes to tracked files, the hook reports the tree of its `HEAD` and the commands to Even Keel (`POST` to the same address): only that report lets Even Keel count the pushed `main` as checked, and a push without one is checked again before the next task. A command without `merge`, a merge of another branch, `--abort`, a session Even Keel did not start, or Even Keel not answering within two seconds — the hook lets the command through.
34
34
 
35
35
  The refusal is an explicit `permissionDecision: deny`, which also blocks nested shell calls from Codex code mode. Codex 0.164.0 was seen to ignore exit code 2 alone for those calls.
36
36
 
@@ -86,6 +86,16 @@ export async function checkOf(sessionId) {
86
86
  return { commands, standards: standardsIn(body), main: typeof body?.branch === "string" && body.branch !== "" ? body.branch : "main" };
87
87
  }
88
88
 
89
+ /** Tells Even Keel the project's check before the merge passed on `tree` (EKR-103); a failure is the caller's to swallow. */
90
+ export async function reportCheck(sessionId, tree, commands) {
91
+ await fetch(`${base()}/api/sessions/${encodeURIComponent(sessionId)}/check`, {
92
+ method: "POST",
93
+ headers: { "content-type": "application/json" },
94
+ body: JSON.stringify({ tree, commands }),
95
+ signal: AbortSignal.timeout(2000),
96
+ });
97
+ }
98
+
89
99
  function standardsIn(body) {
90
100
  if (!Array.isArray(body?.standards)) return [];
91
101
  return body.standards.filter((standard) => typeof standard?.doc === "string" && standard.doc !== "" && Array.isArray(standard.files));
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  // PreToolUse guard on Bash: a chain session's merge of its task branch waits for the project's check,
3
3
  // run in the task's worktree. Even Keel gives the commands only when no CI it counts will judge main;
4
- // a failed command blocks the merge, and its output goes back to the session to fix.
4
+ // a failed command blocks the merge, and its output goes back to the session to fix. A passed check is reported with
5
+ // the tree it ran on: only that report lets Even Keel count main checked after the push (EKR-103).
5
6
  import { readFileSync } from "node:fs";
6
- import { checkOf } from "./evenkeel.mjs";
7
+ import { checkOf, reportCheck } from "./evenkeel.mjs";
7
8
  import { mergeRefusal } from "./merges.mjs";
8
9
 
9
10
  function readInput() {
@@ -18,7 +19,12 @@ async function main() {
18
19
  const input = readInput();
19
20
  if (!input || input.tool_name !== "Bash" || !input.session_id) return;
20
21
  const cwd = process.env.CLAUDE_PROJECT_DIR || input.cwd || input.tool_input?.workdir || ".";
21
- const text = await mergeRefusal(input.tool_input?.command, cwd, () => checkOf(input.session_id));
22
+ const text = await mergeRefusal(
23
+ input.tool_input?.command,
24
+ cwd,
25
+ () => checkOf(input.session_id),
26
+ (tree, commands) => reportCheck(input.session_id, tree, commands),
27
+ );
22
28
  if (text === null) return;
23
29
  // An explicit denial: Codex 0.164.0 ignores exit code 2 alone for the nested shell calls of code mode.
24
30
  process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "deny", permissionDecisionReason: text } }));
@@ -85,8 +85,10 @@ export function runCommand(command, cwd, timeoutMs = COMMAND_TIMEOUT_MS) {
85
85
  * What stops `command` when it merges the task branch of the worktree at `cwd` and the project's check fails, or the
86
86
  * check of a standard whose files the branch changed is not done (`standardsRefusal`): the refusal text, or null — no
87
87
  * such merge, no check, or every command passed. `checkOf` asks Even Keel; when it fails, the merge goes on.
88
+ * Once every command passed, `report` tells Even Keel the tree they passed on (EKR-103): only that report counts main
89
+ * as checked after the push. A worktree with changes to tracked files is no tree of a commit, so it is not reported.
88
90
  */
89
- export async function mergeRefusal(command, cwd, checkOf) {
91
+ export async function mergeRefusal(command, cwd, checkOf, report = async () => {}) {
90
92
  if (!String(command ?? "").includes("merge")) return null;
91
93
  const root = await git(cwd, ["rev-parse", "--show-toplevel"]);
92
94
  const branch = root === "" ? "" : await git(root, ["branch", "--show-current"]);
@@ -99,5 +101,16 @@ export async function mergeRefusal(command, cwd, checkOf) {
99
101
  const run = await runCommand(step, root);
100
102
  if (run.code !== 0) return refusal(step, run.code, run.output);
101
103
  }
104
+ if (check.commands.length > 0) await reportTree(root, check.commands, report);
102
105
  return null;
103
106
  }
107
+
108
+ async function reportTree(root, commands, report) {
109
+ const changes = await new Promise((resolve) => {
110
+ execFile("git", ["status", "--porcelain", "--untracked-files=no"], { cwd: root, encoding: "utf8", windowsHide: true }, (error, stdout) => resolve(error ? null : stdout.trim()));
111
+ });
112
+ if (changes !== "") return;
113
+ const tree = await git(root, ["rev-parse", "HEAD^{tree}"]);
114
+ // Even Keel not taking the report leaves main unchecked, never the merge blocked.
115
+ if (tree !== "") await Promise.resolve(report(tree, commands)).catch(() => {});
116
+ }
@@ -3,14 +3,15 @@
3
3
  // what the hook commands of Claude Code and Codex ask (../hooks/evenkeel.mjs) — the checkpoint nudge due and the
4
4
  // chat's waiting messages — and puts them after the tool's output, the only way into the context in the middle of
5
5
  // a turn. A delivered message is also kept in the call's metadata, where Even Keel's feed finds it. Before a shell
6
- // call that merges the task branch it runs the project's check, and an error thrown there keeps the call from running.
6
+ // call that merges the task branch it runs the project's check, and an error thrown there keeps the call from running;
7
+ // a passed check is reported to Even Keel with the tree it ran on, as the hook command does.
7
8
  // The project's standards (../hooks/standards.mjs) work as in the hook commands: a read of a guarded file gets the
8
9
  // document after its output, a first edit before it is refused by an error, and a compaction forgets what was given.
9
10
  // `opencode run` has no Stop to block, so a turn that wrote the handoff note and ends without the CHECKPOINT line gets
10
11
  // the line added to its text as it completes; for the same reason PR mode's mark is not held for the standards. A
11
12
  // subagent runs in a session of its own, which Even Keel does not know, so it is left alone. Only `server` is
12
13
  // exported: OpenCode takes the module's exports for plugins.
13
- import { checkOf, checkpointNote, mailOf, noteAtEnd, STATE_DIR, standardsOf } from "../hooks/evenkeel.mjs";
14
+ import { checkOf, checkpointNote, mailOf, noteAtEnd, reportCheck, STATE_DIR, standardsOf } from "../hooks/evenkeel.mjs";
14
15
  import { hasMark } from "../hooks/handoff.mjs";
15
16
  import { mergeRefusal } from "../hooks/merges.mjs";
16
17
  import { callOf, clearGiven, due, givenStore, standardsAt } from "../hooks/standards.mjs";
@@ -52,7 +53,12 @@ export const server = async ({ directory }) => {
52
53
  return;
53
54
  }
54
55
  // Even Keel not answering, or git failing, must never block a merge.
55
- const text = await mergeRefusal(output?.args?.command, directory, () => checkOf(input.sessionID)).catch(() => null);
56
+ const text = await mergeRefusal(
57
+ output?.args?.command,
58
+ directory,
59
+ () => checkOf(input.sessionID),
60
+ (tree, commands) => reportCheck(input.sessionID, tree, commands),
61
+ ).catch(() => null);
56
62
  if (text !== null) throw new Error(text);
57
63
  },
58
64
  "tool.execute.after": async (input, output) => {