@moo.md/hum 0.0.0-stage → 0.1.0
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/defaults/hum.json +321 -0
- package/defaults/kinds/check.json +183 -0
- package/defaults/kinds/docs.json +151 -0
- package/defaults/kinds/feature.json +202 -0
- package/defaults/kinds/fix.json +183 -0
- package/defaults/kinds/hotfix.json +164 -0
- package/defaults/roles/build.md +3 -0
- package/defaults/roles/fix.md +1 -0
- package/defaults/roles/plan.md +3 -0
- package/defaults/roles/review.md +3 -0
- package/evals/alignment/RESULTS.md +8 -0
- package/evals/alignment/cases.jsonl +128 -0
- package/evals/alignment/sample.jsonl +20 -0
- package/evals/kind/RESULTS.md +5 -0
- package/evals/kind/cases.jsonl +24 -0
- package/evals/plan-outcome/RESULTS.md +4 -0
- package/evals/plan-outcome/cases.jsonl +12 -0
- package/evals/repeat-pair/RESULTS.md +4 -0
- package/evals/repeat-pair/cases.jsonl +51 -0
- package/evals/reply-option/RESULTS.md +3 -0
- package/evals/reply-option/cases.jsonl +45 -0
- package/evals/review-verdict/RESULTS.md +4 -0
- package/evals/review-verdict/cases.jsonl +12 -0
- package/package.json +88 -4
- package/schema/hum.schema.json +1355 -0
- package/scripts/eval.ts +244 -0
- package/src/adapter-api.ts +134 -0
- package/src/adapters/admit.ts +111 -0
- package/src/adapters/argument.ts +11 -0
- package/src/adapters/claim.ts +93 -0
- package/src/adapters/claude-bg.ts +392 -0
- package/src/adapters/claude-p.ts +599 -0
- package/src/adapters/contract.ts +231 -0
- package/src/adapters/fake.ts +157 -0
- package/src/adapters/git.ts +156 -0
- package/src/adapters/github.ts +479 -0
- package/src/adapters/guard.ts +152 -0
- package/src/adapters/history.ts +215 -0
- package/src/adapters/item-file.ts +102 -0
- package/src/adapters/limit.ts +67 -0
- package/src/adapters/markdown.ts +365 -0
- package/src/adapters/marked.ts +127 -0
- package/src/adapters/model-call.ts +75 -0
- package/src/adapters/once.ts +45 -0
- package/src/adapters/owner-commit.ts +60 -0
- package/src/adapters/pull-requests.ts +253 -0
- package/src/adapters/registry.ts +156 -0
- package/src/adapters/roundup.ts +293 -0
- package/src/adapters/serial.ts +22 -0
- package/src/adapters/transcript.ts +99 -0
- package/src/cli/commands.ts +46 -0
- package/src/cli/main.ts +8 -0
- package/src/cli/ops.ts +224 -0
- package/src/cli/service.ts +156 -0
- package/src/cli/setup.ts +141 -0
- package/src/cli/shared-watch.ts +127 -0
- package/src/config/change.ts +54 -0
- package/src/config/checks.ts +217 -0
- package/src/config/git-ref-name.d.ts +3 -0
- package/src/config/hash.ts +6 -0
- package/src/config/json.ts +6 -0
- package/src/config/load.ts +88 -0
- package/src/config/machine.ts +20 -0
- package/src/config/migrate.ts +61 -0
- package/src/config/refusal.ts +58 -0
- package/src/config/schema.ts +465 -0
- package/src/config/settings.ts +6 -0
- package/src/config/state-map.ts +76 -0
- package/src/decide/alignment.ts +79 -0
- package/src/decide/answer.ts +131 -0
- package/src/decide/kind.ts +39 -0
- package/src/decide/labels.ts +137 -0
- package/src/decide/merge.ts +102 -0
- package/src/decide/prose.ts +109 -0
- package/src/decide/question.ts +159 -0
- package/src/decide/review.ts +10 -0
- package/src/decide/risk.ts +216 -0
- package/src/decide/taste.ts +37 -0
- package/src/exec.ts +85 -0
- package/src/index.ts +200 -0
- package/src/loop/breaks.ts +8 -0
- package/src/loop/check-item.ts +76 -0
- package/src/loop/ci.ts +8 -0
- package/src/loop/github.ts +81 -0
- package/src/loop/groups.ts +108 -0
- package/src/loop/memory.ts +70 -0
- package/src/loop/notes.ts +76 -0
- package/src/loop/pair.ts +39 -0
- package/src/loop/pass.ts +99 -0
- package/src/loop/proof.ts +85 -0
- package/src/loop/prove-item.ts +33 -0
- package/src/loop/records.ts +75 -0
- package/src/loop/signals.ts +130 -0
- package/src/measure/inputs.ts +28 -0
- package/src/measure/measure.ts +68 -0
- package/src/service/cards.ts +24 -0
- package/src/service/ci-tick.ts +28 -0
- package/src/service/launchd.ts +16 -0
- package/src/service/supervise.ts +145 -0
- package/src/service/systemd.ts +44 -0
- package/src/service/token.ts +21 -0
- package/src/service/unit.ts +29 -0
- package/src/service/wake.ts +30 -0
- package/src/service/workflows.ts +97 -0
- package/src/setup/propose.ts +120 -0
- package/src/setup/prove.ts +216 -0
- package/src/setup/scan.ts +186 -0
- package/src/setup/scratch.ts +81 -0
- package/src/setup/shipped.ts +15 -0
- package/src/setup/tables.ts +101 -0
- package/src/setup/waits.ts +58 -0
- package/src/setup/write.ts +161 -0
- package/src/slots/env.ts +42 -0
- package/src/slots/pool.ts +329 -0
- package/src/slots/scan.ts +26 -0
- package/src/slots/worktree.ts +17 -0
- package/src/state/events.ts +52 -0
- package/src/state/faults.ts +73 -0
- package/src/state/format.ts +50 -0
- package/src/state/fs.ts +100 -0
- package/src/state/items.ts +195 -0
- package/src/state/open.ts +80 -0
- package/src/state/ops.ts +76 -0
- package/src/state/records.ts +35 -0
- package/src/state/runs.ts +99 -0
- package/src/state/saved.ts +119 -0
- package/src/status/file.ts +49 -0
- package/src/status/format.ts +132 -0
- package/src/status/sections.ts +14 -0
- package/src/status/version.ts +2 -0
- package/src/time.ts +7 -0
- package/src/worker/alignment-report.ts +18 -0
- package/src/worker/answers.ts +153 -0
- package/src/worker/base-check.ts +45 -0
- package/src/worker/checks.ts +40 -0
- package/src/worker/kind.ts +68 -0
- package/src/worker/land.ts +509 -0
- package/src/worker/lifecycle.ts +97 -0
- package/src/worker/merged.ts +29 -0
- package/src/worker/open.ts +100 -0
- package/src/worker/prose-run.ts +56 -0
- package/src/worker/questions.ts +89 -0
- package/src/worker/scheduler.ts +135 -0
- package/src/worker/signature.ts +41 -0
- package/src/worker/tally.ts +25 -0
- package/src/worker/taste.ts +38 -0
- package/src/worker/thin-path.ts +886 -0
- package/src/worker/worker.ts +750 -0
- package/surface.json +8787 -0
- package/README.md +0 -3
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import pMemoize from "p-memoize";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import type { RawComment } from "./notes.ts";
|
|
4
|
+
|
|
5
|
+
/** What the reads need of a GitHub client: one REST call. */
|
|
6
|
+
export type Requester = { readonly request: (route: string, params?: Readonly<Record<string, string | number>>) => Promise<{ readonly data: unknown }> };
|
|
7
|
+
|
|
8
|
+
const PAGE_SIZE = 100;
|
|
9
|
+
const BOT = "Bot";
|
|
10
|
+
|
|
11
|
+
const ReviewComment = z.object({
|
|
12
|
+
id: z.number(),
|
|
13
|
+
user: z.object({ login: z.string(), type: z.string() }).nullable(),
|
|
14
|
+
body: z.string(),
|
|
15
|
+
commit_id: z.string(),
|
|
16
|
+
path: z.string().optional(),
|
|
17
|
+
line: z.number().nullable().optional(),
|
|
18
|
+
diff_hunk: z.string().optional(),
|
|
19
|
+
created_at: z.string(),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const Jobs = z.object({ jobs: z.array(z.object({ id: z.number() })) });
|
|
23
|
+
const Runs = z.object({ workflow_runs: z.array(z.object({ id: z.number() })) });
|
|
24
|
+
|
|
25
|
+
const pagesOf = async <T>(read: (page: number) => Promise<T[]>): Promise<T[]> => {
|
|
26
|
+
const all: T[] = [];
|
|
27
|
+
|
|
28
|
+
for (let page = 1; ; page++) {
|
|
29
|
+
const found = await read(page);
|
|
30
|
+
|
|
31
|
+
all.push(...found);
|
|
32
|
+
|
|
33
|
+
if (found.length < PAGE_SIZE) return all;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Every pull request review comment on the repo since a time, as raw comments. */
|
|
38
|
+
export const reviewComments = async (client: Requester, repo: string, since: number): Promise<RawComment[]> =>
|
|
39
|
+
(
|
|
40
|
+
await pagesOf(async (page) =>
|
|
41
|
+
z.array(ReviewComment).parse((await client.request(`GET /repos/${repo}/pulls/comments`, { per_page: PAGE_SIZE, page, since: new Date(since).toISOString(), sort: "created", direction: "asc" })).data),
|
|
42
|
+
)
|
|
43
|
+
).map((found) => ({
|
|
44
|
+
kind: "comment",
|
|
45
|
+
id: String(found.id),
|
|
46
|
+
author: found.user?.login ?? "",
|
|
47
|
+
isBot: found.user?.type === BOT,
|
|
48
|
+
body: found.body,
|
|
49
|
+
commit: found.commit_id,
|
|
50
|
+
file: found.path,
|
|
51
|
+
line: found.line ?? undefined,
|
|
52
|
+
hunk: found.diff_hunk,
|
|
53
|
+
at: Date.parse(found.created_at),
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
/** The logs of the newest runs on the base branch that started after a time, one text per job. */
|
|
57
|
+
export const ciLogsOf =
|
|
58
|
+
(client: Requester, repo: string, base: string, runsRead: number) =>
|
|
59
|
+
async (since: number): Promise<string[]> => {
|
|
60
|
+
const { workflow_runs: runs } = Runs.parse((await client.request(`GET /repos/${repo}/actions/runs`, { branch: base, per_page: runsRead, created: `>=${new Date(since).toISOString()}` })).data);
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
await Promise.all(
|
|
64
|
+
runs.map(async ({ id }) => {
|
|
65
|
+
const { jobs } = Jobs.parse((await client.request(`GET /repos/${repo}/actions/runs/${id}/jobs`)).data);
|
|
66
|
+
|
|
67
|
+
return Promise.all(jobs.map(async (job) => String((await client.request(`GET /repos/${repo}/actions/jobs/${job.id}/logs`)).data)));
|
|
68
|
+
}),
|
|
69
|
+
)
|
|
70
|
+
).flat(2);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/** The reads of a repo on GitHub, connected on first use with the owner's own login. */
|
|
74
|
+
export const githubLoopReads = (repo: string, base: string, runsRead: number, connect: () => Promise<Requester>) => {
|
|
75
|
+
const connected = pMemoize(connect);
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
comments: async (since: number) => reviewComments(await connected(), repo, since),
|
|
79
|
+
ciLogs: async (since: number) => ciLogsOf(await connected(), repo, base, runsRead)(since),
|
|
80
|
+
};
|
|
81
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { extname } from "node:path";
|
|
3
|
+
import type { State } from "../state/open.ts";
|
|
4
|
+
import { noteKey, type RepeatGroup, type ReviewNote } from "./records.ts";
|
|
5
|
+
import { type Pairing, pairing, prepare } from "./signals.ts";
|
|
6
|
+
|
|
7
|
+
/** A model's answer to whether two notes state one rule; `undefined` when it abstained. */
|
|
8
|
+
export type Proposal = { readonly same: boolean; readonly models: readonly string[] } | undefined;
|
|
9
|
+
|
|
10
|
+
export type Proposer = (a: ReviewNote, b: ReviewNote) => Promise<Proposal>;
|
|
11
|
+
|
|
12
|
+
export type GroupingOptions = {
|
|
13
|
+
readonly state: State;
|
|
14
|
+
/** Row 14's model call: asked only about notes no signal pairs. */
|
|
15
|
+
readonly propose: Proposer;
|
|
16
|
+
/** Whether a model's proposal files a check alone: its precision on labelled pairs reached the owner's bar. */
|
|
17
|
+
readonly trusts: (models: readonly string[]) => boolean;
|
|
18
|
+
/** Told when a note's language left a signal unapplied, so it is never silent. */
|
|
19
|
+
readonly onUnapplied: (extension: string, signals: readonly string[]) => void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const noteOf = (state: State, key: string): ReviewNote => {
|
|
23
|
+
const note = state.notes.get(key);
|
|
24
|
+
|
|
25
|
+
if (!note) throw new Error(`group member ${key} has no saved note`);
|
|
26
|
+
|
|
27
|
+
return note;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** The first group a deterministic signal puts the note in, with every group it pairs with. */
|
|
31
|
+
const pairedGroups = (state: State, note: ReviewNote, groups: readonly RepeatGroup[], onUnapplied: GroupingOptions["onUnapplied"]): RepeatGroup[] => {
|
|
32
|
+
const target = prepare(note);
|
|
33
|
+
|
|
34
|
+
const report = ({ unapplied }: Pairing): void => {
|
|
35
|
+
if (unapplied.length > 0) onUnapplied(extname(note.file ?? "") || "(none)", unapplied);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return groups.filter((group) =>
|
|
39
|
+
group.notes.some((key) => {
|
|
40
|
+
const found = pairing(prepare(noteOf(state, key)), target);
|
|
41
|
+
|
|
42
|
+
report(found);
|
|
43
|
+
|
|
44
|
+
return found.signal !== undefined;
|
|
45
|
+
}),
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const byAge = (state: State) => (a: RepeatGroup, b: RepeatGroup): number => noteOf(state, a.key).at - noteOf(state, b.key).at || (a.key < b.key ? -1 : 1);
|
|
50
|
+
|
|
51
|
+
const join = (state: State, group: RepeatGroup, key: string): RepeatGroup => {
|
|
52
|
+
const joined = { ...group, notes: group.notes.includes(key) ? group.notes : [...group.notes, key] };
|
|
53
|
+
|
|
54
|
+
state.repeats.put(group.key, joined);
|
|
55
|
+
|
|
56
|
+
return joined;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** Joins the groups the note pairs with into the oldest one. */
|
|
60
|
+
const mergeInto = (state: State, groups: readonly RepeatGroup[], key: string): void => {
|
|
61
|
+
const [oldest, ...rest] = groups.toSorted(byAge(state));
|
|
62
|
+
|
|
63
|
+
if (!oldest) return;
|
|
64
|
+
|
|
65
|
+
const merged = { ...oldest, notes: [...new Set([oldest, ...rest].flatMap(({ notes }) => notes))], commented: [...new Set([oldest, ...rest].flatMap(({ commented }) => commented))] };
|
|
66
|
+
|
|
67
|
+
for (const other of rest) state.repeats.remove(other.key);
|
|
68
|
+
|
|
69
|
+
join(state, merged, key);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const keyOfPair = (a: string, b: string): string => createHash("sha1").update([a, b].sort().join("|")).digest("hex").slice(0, 16);
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Puts each new note in the group whose notes it repeats. Signals decide first, in order. A note no signal pairs
|
|
76
|
+
* goes to the model with one note of each group; a pair it calls alike joins the group only once the model is trusted,
|
|
77
|
+
* and waits as a possible repeat before that. A note with no group starts its own.
|
|
78
|
+
*/
|
|
79
|
+
export const groupNotes = async ({ state, propose, trusts, onUnapplied }: GroupingOptions, fresh: readonly ReviewNote[]): Promise<void> => {
|
|
80
|
+
for (const note of fresh.toSorted((a, b) => a.at - b.at)) {
|
|
81
|
+
const key = noteKey(note);
|
|
82
|
+
const groups = state.repeats.list();
|
|
83
|
+
const found = pairedGroups(state, note, groups, onUnapplied);
|
|
84
|
+
|
|
85
|
+
if (found.length > 0) {
|
|
86
|
+
mergeInto(state, found, key);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
let placed = false;
|
|
91
|
+
|
|
92
|
+
for (const group of groups.toSorted(byAge(state))) {
|
|
93
|
+
const proposal = await propose(noteOf(state, group.key), note);
|
|
94
|
+
|
|
95
|
+
if (proposal?.same !== true) continue;
|
|
96
|
+
|
|
97
|
+
if (trusts(proposal.models)) {
|
|
98
|
+
join(state, group, key);
|
|
99
|
+
placed = true;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
state.possibleRepeats.put(keyOfPair(group.key, key), { a: group.key, b: key, models: [...proposal.models], at: note.at });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!placed) state.repeats.put(key, { key, notes: [key], commented: [], misses: [] });
|
|
107
|
+
}
|
|
108
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import type { Finished } from "../adapters/claude-p.ts";
|
|
4
|
+
|
|
5
|
+
export type MemoryEntry = { readonly rule: string; readonly source: string };
|
|
6
|
+
|
|
7
|
+
/** One entry per line: `- <rule> (source: <where the owner said it>)`. */
|
|
8
|
+
const ENTRY_LINE = /^- (.+) \(source: (.+)\)$/;
|
|
9
|
+
|
|
10
|
+
export class MemoryFormatError extends Error {
|
|
11
|
+
override name = "MemoryFormatError";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class MemoryFull extends Error {
|
|
15
|
+
override name = "MemoryFull";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const squash = (rule: string): string => rule.toLowerCase().replace(/\s+/g, " ").trim();
|
|
19
|
+
|
|
20
|
+
/** The entries of a memory file. A list line with no source is refused: every entry names where it came from. */
|
|
21
|
+
export const parseMemory = (text: string): MemoryEntry[] =>
|
|
22
|
+
text.split("\n").flatMap((line, at): MemoryEntry[] => {
|
|
23
|
+
if (!line.startsWith("- ")) return [];
|
|
24
|
+
|
|
25
|
+
const [, rule, source] = ENTRY_LINE.exec(line) ?? [];
|
|
26
|
+
|
|
27
|
+
if (rule === undefined || source === undefined) throw new MemoryFormatError(`memory.md line ${at + 1} has no "(source: …)": ${line.slice(0, 80)}`);
|
|
28
|
+
|
|
29
|
+
return [{ rule, source }];
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export const renderMemory = (entries: readonly MemoryEntry[]): string => entries.map(({ rule, source }) => `- ${rule} (source: ${source})\n`).join("");
|
|
33
|
+
|
|
34
|
+
/** A new entry on a rule already held replaces it, so one rule has one entry; past the byte cap the entry is refused. */
|
|
35
|
+
export const addEntry = (entries: readonly MemoryEntry[], entry: MemoryEntry, maxBytes: number): MemoryEntry[] => {
|
|
36
|
+
const next = [...entries.filter(({ rule }) => squash(rule) !== squash(entry.rule)), entry];
|
|
37
|
+
|
|
38
|
+
if (Buffer.byteLength(renderMemory(next)) > maxBytes) throw new MemoryFull(`memory.md would pass ${maxBytes} bytes; remove an entry first`);
|
|
39
|
+
|
|
40
|
+
return next;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** The entries left once a check covers the rules whose sources are `covered`. */
|
|
44
|
+
export const withoutCovered = (entries: readonly MemoryEntry[], covered: ReadonlySet<string>): MemoryEntry[] => entries.filter(({ source }) => !covered.has(source));
|
|
45
|
+
|
|
46
|
+
/** Entries no run used within the last `limit` runs: `lastUsed` is the run number of an entry's last use, absent when none used it. */
|
|
47
|
+
export const unusedEntries = (entries: readonly MemoryEntry[], lastUsed: ReadonlyMap<string, number>, runsSoFar: number, limit: number): MemoryEntry[] =>
|
|
48
|
+
entries.filter(({ rule }) => runsSoFar - (lastUsed.get(rule) ?? 0) >= limit);
|
|
49
|
+
|
|
50
|
+
/** The entries of the file at `path`; none when it is absent. */
|
|
51
|
+
export const readMemory = (path: string): MemoryEntry[] => (existsSync(path) ? parseMemory(readFileSync(path, "utf8")) : []);
|
|
52
|
+
|
|
53
|
+
/** What a run reads of memory.md: its rules, numbered, and the ask to name the ones it applied. */
|
|
54
|
+
export const memorySection = (entries: readonly MemoryEntry[]): string =>
|
|
55
|
+
entries.length === 0 ? "" : `\n\n## Standing rules\n${entries.map(({ rule }, at) => `${at + 1}. ${rule}`).join("\n")}\nIn "memoryUsed", give the number of each rule you applied.`;
|
|
56
|
+
|
|
57
|
+
const Applied = z.object({ memoryUsed: z.array(z.int().positive()) });
|
|
58
|
+
|
|
59
|
+
/** The rules a run says it applied, from the numbers in its answer; numbers beyond the list name nothing. */
|
|
60
|
+
export const rulesUsed = ({ structured }: Pick<Finished, "structured">, entries: readonly MemoryEntry[]): string[] =>
|
|
61
|
+
(Applied.safeParse(structured).data?.memoryUsed ?? []).flatMap((number) => entries[number - 1]?.rule ?? []);
|
|
62
|
+
|
|
63
|
+
export type MemoryUse = { readonly runsSoFar: number; readonly lastUsed: ReadonlyMap<string, number> };
|
|
64
|
+
|
|
65
|
+
/** From the runs that were shown memory.md, oldest first: how many there were, and the run each rule was last used in. */
|
|
66
|
+
export const useOf = (runs: readonly { readonly memoryUsed?: readonly string[] }[]): MemoryUse => {
|
|
67
|
+
const shown = runs.flatMap(({ memoryUsed }) => (memoryUsed === undefined ? [] : [memoryUsed]));
|
|
68
|
+
|
|
69
|
+
return { runsSoFar: shown.length, lastUsed: new Map(shown.flatMap((rules, at) => rules.map((rule): [string, number] => [rule, at + 1]))) };
|
|
70
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { PastChange } from "../decide/labels.ts";
|
|
2
|
+
import { breakOf, type LabelRules } from "../decide/labels.ts";
|
|
3
|
+
import type { SettledAnswer } from "../state/saved.ts";
|
|
4
|
+
import type { State } from "../state/open.ts";
|
|
5
|
+
import { type NoteSource, noteKey, type ReviewNote } from "./records.ts";
|
|
6
|
+
|
|
7
|
+
/** What an integration reads from the review surface, before the owner's own are told from the rest. */
|
|
8
|
+
export type RawComment = {
|
|
9
|
+
readonly kind: "comment" | "review";
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly author: string;
|
|
12
|
+
readonly isBot: boolean;
|
|
13
|
+
readonly body: string;
|
|
14
|
+
/** The commit the comment sits on. */
|
|
15
|
+
readonly commit: string;
|
|
16
|
+
readonly file?: string;
|
|
17
|
+
readonly line?: number;
|
|
18
|
+
readonly hunk?: string;
|
|
19
|
+
readonly at: number;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const SOURCE_OF_KIND: Readonly<Record<RawComment["kind"], NoteSource>> = { comment: "review-comment", review: "review-body" };
|
|
23
|
+
|
|
24
|
+
/** The owner's comments and review bodies; a bot's, another person's and an empty body are not review notes. */
|
|
25
|
+
export const ownerNotes = (raw: readonly RawComment[], owners: readonly string[]): ReviewNote[] =>
|
|
26
|
+
raw.flatMap((found): ReviewNote[] =>
|
|
27
|
+
owners.includes(found.author) && !found.isBot && found.body.trim() !== ""
|
|
28
|
+
? [{ source: SOURCE_OF_KIND[found.kind], sourceId: found.id, change: found.commit, file: found.file, line: found.line, hunk: found.hunk ?? "", text: found.body.trim(), at: found.at }]
|
|
29
|
+
: [],
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
/** The option that approves a plan; every other answer changed it. */
|
|
33
|
+
export const APPROVAL_OPTION = "approve";
|
|
34
|
+
|
|
35
|
+
/** An answer that changed the plan: one applied, and not an approval. */
|
|
36
|
+
export const planChangingNotes = (answers: readonly SettledAnswer[]): ReviewNote[] =>
|
|
37
|
+
answers
|
|
38
|
+
.flatMap(({ item, ordinal, text, at, disposition, option }): ReviewNote[] =>
|
|
39
|
+
disposition === "applied" && option !== APPROVAL_OPTION ? [{ source: "plan-answer", sourceId: `${item}:${ordinal}`, change: item, item, hunk: "", text, at }] : [],
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
/** The revert or fix commit behind each broken change, with the hunk it made. */
|
|
43
|
+
export const breakNotes = (changes: readonly PastChange[], rules: LabelRules, hunkOf: (sha: string, file: string | undefined) => Promise<string>): Promise<ReviewNote[]> =>
|
|
44
|
+
Promise.all(
|
|
45
|
+
changes.flatMap((change, at) => {
|
|
46
|
+
const found = breakOf(changes, at, rules);
|
|
47
|
+
|
|
48
|
+
if (!found) return [];
|
|
49
|
+
|
|
50
|
+
const file = found.by.files.find((path) => change.files.includes(path));
|
|
51
|
+
|
|
52
|
+
return [
|
|
53
|
+
hunkOf(found.by.sha, file).then(
|
|
54
|
+
(hunk): ReviewNote => ({
|
|
55
|
+
source: found.label === "reverted" ? "revert" : "fix",
|
|
56
|
+
sourceId: found.by.sha,
|
|
57
|
+
change: change.sha,
|
|
58
|
+
file,
|
|
59
|
+
hunk,
|
|
60
|
+
text: `${found.by.subject}\n${found.by.body}`.trim(),
|
|
61
|
+
at: found.by.committedAt ?? at,
|
|
62
|
+
}),
|
|
63
|
+
),
|
|
64
|
+
];
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
/** Saves each note once, keyed by its source and source id; the ones this call added are returned. */
|
|
69
|
+
export const saveNotes = (state: State, notes: readonly ReviewNote[]): ReviewNote[] =>
|
|
70
|
+
notes.filter((note) => {
|
|
71
|
+
if (state.notes.get(noteKey(note))) return false;
|
|
72
|
+
|
|
73
|
+
state.notes.put(noteKey(note), note);
|
|
74
|
+
|
|
75
|
+
return true;
|
|
76
|
+
});
|
package/src/loop/pair.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Question } from "../adapters/model-call.ts";
|
|
3
|
+
import type { ModelCall } from "../adapters/model-call.ts";
|
|
4
|
+
import type { HumConfig } from "../config/schema.ts";
|
|
5
|
+
import { DATA_RULE, fenced } from "../decide/prose.ts";
|
|
6
|
+
import { LOOP_SPEND_PREFIX } from "../measure/inputs.ts";
|
|
7
|
+
import type { Proposer } from "./groups.ts";
|
|
8
|
+
import { noteKey, type ReviewNote } from "./records.ts";
|
|
9
|
+
|
|
10
|
+
const SamePair = z.strictObject({ same: z.boolean() });
|
|
11
|
+
|
|
12
|
+
const described = (label: string, { text, file }: ReviewNote): string => fenced(label, file === undefined ? text : `${file}\n${text}`);
|
|
13
|
+
|
|
14
|
+
/** The cheap model call that says whether two review notes state one rule. */
|
|
15
|
+
export const pairQuestion = (a: ReviewNote, b: ReviewNote): Question<z.infer<typeof SamePair>> => ({
|
|
16
|
+
boundary: "repeat-pair",
|
|
17
|
+
prompt: [
|
|
18
|
+
"Two review notes follow. Say whether they ask for the same thing: the same behaviour to do or to avoid, whatever the wording. One may be a terse complaint and the other a formal rule. Notes about the same area that ask for different things are not the same.",
|
|
19
|
+
DATA_RULE,
|
|
20
|
+
described("note-a", a),
|
|
21
|
+
described("note-b", b),
|
|
22
|
+
'Answer with JSON {"same": true} or {"same": false}.',
|
|
23
|
+
].join("\n\n"),
|
|
24
|
+
answer: SamePair,
|
|
25
|
+
item: `${LOOP_SPEND_PREFIX}${noteKey(b)}`,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/** Row 14's model call as a proposer; an abstention is no proposal. */
|
|
29
|
+
export const modelProposer =
|
|
30
|
+
(call: ModelCall): Proposer =>
|
|
31
|
+
async (a, b) => {
|
|
32
|
+
const judged = await call(pairQuestion(a, b));
|
|
33
|
+
|
|
34
|
+
return judged.kind === "picked" ? { same: judged.value.same, models: judged.models } : undefined;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Whether every model id behind a proposal reached the owner's precision bar on labelled pairs. */
|
|
38
|
+
export const trustsRepeats = (models: readonly string[], { measuredModels, repeatPrecision }: Pick<HumConfig, "measuredModels" | "repeatPrecision">): boolean =>
|
|
39
|
+
models.length > 0 && models.every((model) => (measuredModels["repeat-pair"]?.[model] ?? 0) >= repeatPrecision);
|
package/src/loop/pass.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import type { WorkSource } from "../adapter-api.ts";
|
|
3
|
+
import type { Config } from "../config/load.ts";
|
|
4
|
+
import type { PastChange } from "../decide/labels.ts";
|
|
5
|
+
import type { State } from "../state/open.ts";
|
|
6
|
+
import { checkNameOf, fileChecks, filedFrom } from "./check-item.ts";
|
|
7
|
+
import { type CiLogs, logNames } from "./ci.ts";
|
|
8
|
+
import { type Proposer, groupNotes } from "./groups.ts";
|
|
9
|
+
import { parseMemory, renderMemory, withoutCovered } from "./memory.ts";
|
|
10
|
+
import { breakNotes, ownerNotes, planChangingNotes, type RawComment, saveNotes } from "./notes.ts";
|
|
11
|
+
import { type RepeatGroup, type ReviewNote, noteKey } from "./records.ts";
|
|
12
|
+
|
|
13
|
+
export type LoopPass = {
|
|
14
|
+
readonly state: State;
|
|
15
|
+
readonly config: Config;
|
|
16
|
+
readonly workSource: Pick<WorkSource, "fileFollowUp" | "comment">;
|
|
17
|
+
readonly now: () => number;
|
|
18
|
+
/** The owner's review comments and bodies since a time. */
|
|
19
|
+
readonly comments: (since: number) => Promise<readonly RawComment[]>;
|
|
20
|
+
/** The merged changes on the base, oldest first. */
|
|
21
|
+
readonly history: () => Promise<readonly PastChange[]>;
|
|
22
|
+
readonly hunkOf: (sha: string, file: string | undefined) => Promise<string>;
|
|
23
|
+
readonly propose: Proposer;
|
|
24
|
+
readonly trusts: (models: readonly string[]) => boolean;
|
|
25
|
+
readonly ciLogs: CiLogs;
|
|
26
|
+
/** The repo's `.hum/memory.md`, when it has one. */
|
|
27
|
+
readonly memoryPath?: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const EPOCH = 0;
|
|
31
|
+
|
|
32
|
+
/** Review comments are read from the newest one already saved; the saved key makes any overlap add nothing. */
|
|
33
|
+
const sinceOfLastComment = (state: State): number => Math.max(EPOCH, ...state.notes.list().filter(({ source }) => source === "review-comment").map(({ at }) => at));
|
|
34
|
+
|
|
35
|
+
const unappliedCard = (state: State) => (extension: string, signals: readonly string[]) => {
|
|
36
|
+
state.faults.raise({
|
|
37
|
+
code: "signal-not-applied",
|
|
38
|
+
item: extension,
|
|
39
|
+
cause: `Hunks in ${extension} files are not parsed, so ${signals.join(" and ")} did not run on them.`,
|
|
40
|
+
fix: "The other signals still decide; add the language to the parsed languages to apply these.",
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** Step 1: the owner's notes from each source, saved once. Returns the ones this pass added. */
|
|
45
|
+
export const collectNotes = async ({ state, config, comments, history, hunkOf }: LoopPass): Promise<ReviewNote[]> =>
|
|
46
|
+
saveNotes(state, [
|
|
47
|
+
...ownerNotes(await comments(sinceOfLastComment(state)), config.hum.ownerLogins),
|
|
48
|
+
...planChangingNotes(state.answers.list()),
|
|
49
|
+
...(await breakNotes(await history(), config.hum.changeLabels, hunkOf)),
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
/** Step 6: a landed check item whose name the next CI run's log shows. */
|
|
53
|
+
export const confirmChecks = async ({ state, ciLogs, now }: Pick<LoopPass, "state" | "ciLogs" | "now">): Promise<void> => {
|
|
54
|
+
for (const group of state.repeats.list()) {
|
|
55
|
+
const merge = group.item === undefined ? undefined : state.merges.get(group.item);
|
|
56
|
+
|
|
57
|
+
if (group.checked || !merge) continue;
|
|
58
|
+
|
|
59
|
+
const logs = await ciLogs(merge.at);
|
|
60
|
+
|
|
61
|
+
if (logs.some((log) => logNames(log, group.key))) state.repeats.put(group.key, { ...group, checked: { at: now(), check: checkNameOf(group.key) } });
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const missesOf = (state: State, group: RepeatGroup): ReviewNote[] =>
|
|
66
|
+
group.checked === undefined ? [] : group.notes.flatMap((key) => state.notes.get(key) ?? []).filter((note) => note.at > (group.checked?.at ?? 0) && !group.misses.includes(noteKey(note)));
|
|
67
|
+
|
|
68
|
+
/** Step 7: memory.md drops the entries a check now covers, and a note that came after the check ran reopens its item as a miss. */
|
|
69
|
+
export const closeLoop = async ({ state, workSource, memoryPath }: Pick<LoopPass, "state" | "workSource" | "memoryPath">): Promise<void> => {
|
|
70
|
+
const covered = new Set(state.repeats.list().flatMap((group) => (group.checked ? group.notes : [])));
|
|
71
|
+
|
|
72
|
+
if (memoryPath !== undefined && covered.size > 0 && existsSync(memoryPath)) {
|
|
73
|
+
const held = parseMemory(readFileSync(memoryPath, "utf8"));
|
|
74
|
+
const kept = withoutCovered(held, covered);
|
|
75
|
+
|
|
76
|
+
if (kept.length < held.length) writeFileSync(memoryPath, renderMemory(kept));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
for (const group of state.repeats.list()) {
|
|
80
|
+
const missed = missesOf(state, group);
|
|
81
|
+
|
|
82
|
+
if (group.item === undefined || missed.length === 0) continue;
|
|
83
|
+
|
|
84
|
+
for (const note of missed)
|
|
85
|
+
await workSource.fileFollowUp(filedFrom(group.key), { title: `Check missed ${note.sourceId}: ${group.item}`, body: `Kind: fix\n\nThe check for ${group.item} ran in CI and a later review note still repeated its rule.\n\n> ${note.text}\n\n\`\`\`diff\n${note.hunk}\n\`\`\`\n\nThe hunk is a failing case the check must catch.` });
|
|
86
|
+
|
|
87
|
+
state.repeats.put(group.key, { ...group, misses: [...group.misses, ...missed.map(noteKey)] });
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/** One pass of the loop: collect, find repeats, file checks, confirm CI ran them, close the loop. */
|
|
92
|
+
export const runLoopPass = async (pass: LoopPass): Promise<void> => {
|
|
93
|
+
const { state, config, workSource, propose, trusts } = pass;
|
|
94
|
+
|
|
95
|
+
await groupNotes({ state, propose, trusts, onUnapplied: unappliedCard(state) }, await collectNotes(pass));
|
|
96
|
+
await fileChecks({ state, workSource, repeatAt: config.hum.repeatAt, checkKind: config.hum.checkKind });
|
|
97
|
+
await confirmChecks(pass);
|
|
98
|
+
await closeLoop(pass);
|
|
99
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import type { Git } from "../adapters/git.ts";
|
|
5
|
+
import { runChecks } from "../worker/checks.ts";
|
|
6
|
+
import type { ReviewNote } from "./records.ts";
|
|
7
|
+
|
|
8
|
+
export type ProofOptions = {
|
|
9
|
+
/** The repo the commits are in. */
|
|
10
|
+
readonly git: Git;
|
|
11
|
+
/** The check item's commit: the base with the new check on it. */
|
|
12
|
+
readonly head: string;
|
|
13
|
+
readonly base: string;
|
|
14
|
+
/** The notes whose commits the check must fail on. */
|
|
15
|
+
readonly notes: readonly ReviewNote[];
|
|
16
|
+
/** The repo's checks, which include the new one. */
|
|
17
|
+
readonly checks: readonly string[];
|
|
18
|
+
readonly timeoutMs: number;
|
|
19
|
+
readonly now: () => number;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type ProofResult = {
|
|
23
|
+
readonly passed: boolean;
|
|
24
|
+
readonly reason?: string;
|
|
25
|
+
/** Worktrees made: one per note commit and one for the head. */
|
|
26
|
+
readonly worktrees: number;
|
|
27
|
+
readonly ms: number;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const isCommit = async (git: Git, sha: string): Promise<boolean> => (await git.run(["cat-file", "-e", `${sha}^{commit}`])).code === 0;
|
|
31
|
+
|
|
32
|
+
/** The files the check item adds or changes against the base. */
|
|
33
|
+
const checkFiles = async (git: Git, base: string, head: string): Promise<string[]> =>
|
|
34
|
+
(await git.raw(["diff", "--name-only", "--diff-filter=AM", `${base}...${head}`])).split("\n").filter(Boolean);
|
|
35
|
+
|
|
36
|
+
/** Runs `body` in a detached worktree at `sha`, removed afterwards whatever happens. */
|
|
37
|
+
export const inWorktreeAt = async <T>(git: Git, sha: string, body: (folder: string) => Promise<T>): Promise<T> => {
|
|
38
|
+
const folder = mkdtempSync(join(tmpdir(), "hum-proof-"));
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
await git.raw(["worktree", "add", "--detach", "--quiet", folder, sha]);
|
|
42
|
+
|
|
43
|
+
return await body(folder);
|
|
44
|
+
} finally {
|
|
45
|
+
await git.run(["worktree", "remove", "--force", folder]);
|
|
46
|
+
rmSync(folder, { recursive: true, force: true });
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A check is real when it fails on the commit each note pointed at and passes on the base with the check on it. Each
|
|
52
|
+
* note's commit is checked out with the check's files laid over it. A note that points at no commit cannot be proved
|
|
53
|
+
* and counts against the check.
|
|
54
|
+
*/
|
|
55
|
+
export const proveCheck = async ({ git, head, base, notes, checks, timeoutMs, now }: ProofOptions): Promise<ProofResult> => {
|
|
56
|
+
const started = now();
|
|
57
|
+
let worktrees = 0;
|
|
58
|
+
|
|
59
|
+
const done = (reason?: string): ProofResult => ({ passed: reason === undefined, reason, worktrees, ms: now() - started });
|
|
60
|
+
|
|
61
|
+
const files = await checkFiles(git, base, head);
|
|
62
|
+
const commits = [...new Set(notes.map(({ change }) => change))];
|
|
63
|
+
const provable = (await Promise.all(commits.map(async (sha) => ((await isCommit(git, sha)) ? [sha] : [])))).flat();
|
|
64
|
+
|
|
65
|
+
if (provable.length === 0) return done("no note points at a commit the check can run on");
|
|
66
|
+
|
|
67
|
+
for (const sha of provable) {
|
|
68
|
+
const failure = await inWorktreeAt(git, sha, async (folder) => {
|
|
69
|
+
worktrees++;
|
|
70
|
+
await git.raw(["-C", folder, "checkout", head, "--", ...files]);
|
|
71
|
+
|
|
72
|
+
return runChecks(checks, folder, { timeoutMs });
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
if (failure === undefined) return done(`the check passes on ${sha}, the commit a note points at`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const failure = await inWorktreeAt(git, head, async (folder) => {
|
|
79
|
+
worktrees++;
|
|
80
|
+
|
|
81
|
+
return runChecks(checks, folder, { timeoutMs });
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return failure === undefined ? done() : done(`the checks fail on the check item's own commit: ${failure.slice(0, 300)}`);
|
|
85
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Git } from "../adapters/git.ts";
|
|
2
|
+
import type { Config } from "../config/load.ts";
|
|
3
|
+
import type { State } from "../state/open.ts";
|
|
4
|
+
import { checksTimeoutMs } from "../worker/checks.ts";
|
|
5
|
+
import { proveCheck } from "./proof.ts";
|
|
6
|
+
|
|
7
|
+
export type ProveItem = {
|
|
8
|
+
readonly state: State;
|
|
9
|
+
readonly config: Config;
|
|
10
|
+
readonly git: Git;
|
|
11
|
+
readonly item: string;
|
|
12
|
+
readonly base: string;
|
|
13
|
+
readonly checks: readonly string[];
|
|
14
|
+
readonly now: () => number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Proves the check a check item made, against the notes of the repeat group it was filed for, and saves what the
|
|
19
|
+
* proof cost. `undefined` when the item belongs to no group, so there is no note to prove it against.
|
|
20
|
+
*/
|
|
21
|
+
export const proveCheckItem = async ({ state, config, git, item, base, checks, now }: ProveItem) => {
|
|
22
|
+
const group = state.repeats.list().find((found) => found.item === item);
|
|
23
|
+
|
|
24
|
+
if (!group) return undefined;
|
|
25
|
+
|
|
26
|
+
const notes = group.notes.flatMap((key) => state.notes.get(key) ?? []);
|
|
27
|
+
const head = (await git.raw(["rev-parse", "HEAD"])).trim();
|
|
28
|
+
const proof = await proveCheck({ git, head, base: `origin/${base}`, notes, checks, timeoutMs: checksTimeoutMs(config.hum), now });
|
|
29
|
+
|
|
30
|
+
state.proofs.put(item, { item, at: now(), passed: proof.passed, reason: proof.reason, worktrees: proof.worktrees, ms: proof.ms });
|
|
31
|
+
|
|
32
|
+
return proof;
|
|
33
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
const name = z.string().min(1);
|
|
4
|
+
const time = z.int().nonnegative();
|
|
5
|
+
|
|
6
|
+
/** Where a review note comes from. */
|
|
7
|
+
export const NOTE_SOURCES = ["review-comment", "review-body", "plan-answer", "revert", "fix"] as const;
|
|
8
|
+
|
|
9
|
+
export type NoteSource = (typeof NOTE_SOURCES)[number];
|
|
10
|
+
|
|
11
|
+
/** One correction the owner made to hum's work, saved before anything acts on it and keyed by its source and source id. */
|
|
12
|
+
export const ReviewNote = z.strictObject({
|
|
13
|
+
source: z.enum(NOTE_SOURCES),
|
|
14
|
+
sourceId: name,
|
|
15
|
+
/** What the note is about: the commit a comment sits on, the change a revert or fix names, or the item a plan answer corrected. */
|
|
16
|
+
change: name,
|
|
17
|
+
/** The item the note is known to belong to; a commit is matched to its item when the measure counts. */
|
|
18
|
+
item: name.optional(),
|
|
19
|
+
file: name.optional(),
|
|
20
|
+
line: z.int().positive().optional(),
|
|
21
|
+
/** The diff hunk the note points at; empty when the source has none. */
|
|
22
|
+
hunk: z.string(),
|
|
23
|
+
text: name,
|
|
24
|
+
at: time,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export type ReviewNote = z.infer<typeof ReviewNote>;
|
|
28
|
+
|
|
29
|
+
/** A note's key in the saved records. */
|
|
30
|
+
export const noteKey = ({ source, sourceId }: Pick<ReviewNote, "source" | "sourceId">): string => `${source}:${sourceId}`;
|
|
31
|
+
|
|
32
|
+
/** Notes that state one rule. The key is its first note's, so a later note joins instead of starting another group. */
|
|
33
|
+
export const RepeatGroup = z.strictObject({
|
|
34
|
+
key: name,
|
|
35
|
+
notes: z.array(name),
|
|
36
|
+
/** The check item filed for the group. */
|
|
37
|
+
item: name.optional(),
|
|
38
|
+
/** Notes already added to the item's thread. */
|
|
39
|
+
commented: z.array(name),
|
|
40
|
+
/** The check landed and CI ran it. */
|
|
41
|
+
checked: z.strictObject({ at: time, check: name }).optional(),
|
|
42
|
+
/** Notes that came after the check ran in CI. */
|
|
43
|
+
misses: z.array(name),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export type RepeatGroup = z.infer<typeof RepeatGroup>;
|
|
47
|
+
|
|
48
|
+
/** Two notes only a model found alike, waiting for its precision to reach the owner's bar. */
|
|
49
|
+
export const PossibleRepeat = z.strictObject({ a: name, b: name, models: z.array(name), at: time });
|
|
50
|
+
|
|
51
|
+
export type PossibleRepeat = z.infer<typeof PossibleRepeat>;
|
|
52
|
+
|
|
53
|
+
/** A merged change: what the measure counts. */
|
|
54
|
+
export const Merge = z.strictObject({ item: name, sha: name, at: time, paths: z.array(name) });
|
|
55
|
+
|
|
56
|
+
export type Merge = z.infer<typeof Merge>;
|
|
57
|
+
|
|
58
|
+
/** A test of the base that failed after an item's change merged. */
|
|
59
|
+
export const Break = z.strictObject({ item: name, sha: name, at: time, paths: z.array(name), level: name, failure: z.string(), onBreak: z.enum(["follow-up", "block"]), followUp: name });
|
|
60
|
+
|
|
61
|
+
export type Break = z.infer<typeof Break>;
|
|
62
|
+
|
|
63
|
+
/** What proving a check cost: the commits it ran on, and the time it took. */
|
|
64
|
+
export const Proof = z.strictObject({
|
|
65
|
+
item: name,
|
|
66
|
+
at: time,
|
|
67
|
+
passed: z.boolean(),
|
|
68
|
+
/** Why it failed, when it did. */
|
|
69
|
+
reason: z.string().optional(),
|
|
70
|
+
/** Worktrees made: one per note commit and one for the check's own head. */
|
|
71
|
+
worktrees: z.int().nonnegative(),
|
|
72
|
+
ms: z.int().nonnegative(),
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export type Proof = z.infer<typeof Proof>;
|