@moo.md/hum 0.1.0 → 0.2.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/package.json +2 -2
- package/scripts/eval.ts +88 -50
- package/src/adapter-api.ts +46 -14
- package/src/adapters/admit.ts +2 -2
- package/src/adapters/argument.ts +1 -1
- package/src/adapters/claim.ts +18 -15
- package/src/adapters/claude-bg.ts +50 -27
- package/src/adapters/claude-p.ts +18 -23
- package/src/adapters/contract.ts +22 -10
- package/src/adapters/each-call.ts +9 -0
- package/src/adapters/fake.ts +6 -6
- package/src/adapters/git.ts +10 -18
- package/src/adapters/github-client.ts +102 -0
- package/src/adapters/github.ts +34 -142
- package/src/adapters/guard.ts +20 -9
- package/src/adapters/history.ts +12 -15
- package/src/adapters/item-file.ts +1 -1
- package/src/adapters/markdown.ts +49 -42
- package/src/adapters/marked.ts +6 -12
- package/src/adapters/model-call.ts +4 -4
- package/src/adapters/once.ts +5 -5
- package/src/adapters/owner-commit.ts +13 -11
- package/src/adapters/pull-requests.ts +11 -13
- package/src/adapters/registry.ts +7 -7
- package/src/adapters/roundup.ts +27 -35
- package/src/adapters/serial.ts +4 -5
- package/src/adapters/transcript.ts +13 -8
- package/src/cli/main.ts +1 -0
- package/src/cli/ops.ts +32 -14
- package/src/cli/service.ts +14 -8
- package/src/cli/setup.ts +8 -3
- package/src/cli/shared-watch.ts +3 -3
- package/src/config/checks.ts +14 -18
- package/src/config/machine.ts +5 -7
- package/src/config/refusal.ts +7 -0
- package/src/config/schema.ts +7 -7
- package/src/config/settings.ts +17 -2
- package/src/config/state-map.ts +5 -3
- package/src/decide/alignment.ts +4 -4
- package/src/decide/answer.ts +24 -22
- package/src/decide/kind.ts +1 -6
- package/src/decide/labels.ts +9 -9
- package/src/decide/merge.ts +6 -7
- package/src/decide/prose.ts +4 -4
- package/src/decide/question.ts +23 -20
- package/src/decide/review.ts +4 -2
- package/src/decide/risk.ts +25 -19
- package/src/decide/taste.ts +3 -3
- package/src/exec.ts +4 -3
- package/src/index.ts +14 -13
- package/src/loop/check-item.ts +3 -3
- package/src/loop/ci.ts +1 -1
- package/src/loop/github.ts +2 -2
- package/src/loop/groups.ts +13 -6
- package/src/loop/memory.ts +40 -28
- package/src/loop/notes.ts +5 -5
- package/src/loop/pair.ts +1 -1
- package/src/loop/pass.ts +18 -12
- package/src/loop/proof.ts +9 -7
- package/src/loop/prove-item.ts +1 -1
- package/src/loop/records.ts +12 -13
- package/src/loop/signals.ts +6 -6
- package/src/measure/inputs.ts +1 -1
- package/src/measure/measure.ts +4 -4
- package/src/measure/rate.ts +2 -0
- package/src/service/ci-tick.ts +2 -2
- package/src/service/supervise.ts +3 -2
- package/src/service/token.ts +3 -3
- package/src/service/wake.ts +2 -2
- package/src/service/workflows.ts +2 -2
- package/src/setup/propose.ts +4 -4
- package/src/setup/prove.ts +18 -12
- package/src/setup/scan.ts +31 -24
- package/src/setup/shipped.ts +8 -2
- package/src/setup/tables.ts +4 -3
- package/src/setup/waits.ts +9 -11
- package/src/setup/write.ts +17 -10
- package/src/slots/pool.ts +32 -24
- package/src/state/events.ts +1 -1
- package/src/state/faults.ts +13 -5
- package/src/state/format.ts +2 -2
- package/src/state/items.ts +9 -10
- package/src/state/open.ts +2 -2
- package/src/state/ops.ts +16 -10
- package/src/state/records.ts +5 -5
- package/src/state/runs.ts +33 -26
- package/src/state/saved.ts +44 -32
- package/src/status/file.ts +20 -1
- package/src/status/format.ts +47 -57
- package/src/status/sections.ts +2 -2
- package/src/worker/alignment-report.ts +4 -5
- package/src/worker/answers.ts +26 -24
- package/src/worker/base-check.ts +2 -2
- package/src/worker/kind.ts +23 -19
- package/src/worker/land.ts +114 -126
- package/src/worker/merged.ts +9 -7
- package/src/worker/open.ts +14 -12
- package/src/worker/prose-run.ts +3 -3
- package/src/worker/questions.ts +15 -12
- package/src/worker/scheduler.ts +4 -4
- package/src/worker/signature.ts +3 -3
- package/src/worker/tally.ts +0 -2
- package/src/worker/taste.ts +6 -15
- package/src/worker/thin-path.ts +148 -121
- package/src/worker/thread.ts +25 -0
- package/src/worker/worker.ts +77 -47
- package/surface.json +632 -2197
- package/src/slots/scan.ts +0 -26
package/src/worker/worker.ts
CHANGED
|
@@ -5,9 +5,10 @@ import pMemoize from "p-memoize";
|
|
|
5
5
|
import PQueue from "p-queue";
|
|
6
6
|
import pTimeout from "p-timeout";
|
|
7
7
|
import { createAsyncLogic } from "xstate";
|
|
8
|
-
import { ADAPTER_API_VERSION, type Answers, type ItemRef, type Questions, type WorkSource } from "../adapter-api.ts";
|
|
8
|
+
import { ADAPTER_API_VERSION, type Answers, type Holder, ItemId, type ItemRef, type Questions, type WorkSource } from "../adapter-api.ts";
|
|
9
9
|
import type { Runner } from "../adapters/claude-p.ts";
|
|
10
10
|
import type { Config } from "../config/load.ts";
|
|
11
|
+
import { invokedSources } from "../config/machine.ts";
|
|
11
12
|
import { type Kind, SCHEMA_VERSION } from "../config/schema.ts";
|
|
12
13
|
import { checkTokenAge } from "../service/token.ts";
|
|
13
14
|
import { listFiles } from "../state/fs.ts";
|
|
@@ -21,13 +22,13 @@ import { readHistory } from "../adapters/history.ts";
|
|
|
21
22
|
import { gitIn, PATCH } from "../adapters/git.ts";
|
|
22
23
|
import { join } from "node:path";
|
|
23
24
|
import { configuredModelCall, modelCallOver } from "../adapters/model-call.ts";
|
|
24
|
-
import {
|
|
25
|
+
import { type MemoryEntry, readMemory, type RefusedLine, unusedEntries, useOf } from "../loop/memory.ts";
|
|
25
26
|
import { runLoopPass, type LoopPass } from "../loop/pass.ts";
|
|
26
|
-
import { modelProposer,
|
|
27
|
+
import { modelProposer, doesTrustRepeats } from "../loop/pair.ts";
|
|
27
28
|
import { measureOf } from "../measure/measure.ts";
|
|
28
29
|
import { measureInputsOf } from "../measure/inputs.ts";
|
|
29
|
-
import { readStatus, writeHeartbeat, writeStatus } from "../status/file.ts";
|
|
30
|
-
import {
|
|
30
|
+
import { emptyStatus, readStatus, writeHeartbeat, writeStatus } from "../status/file.ts";
|
|
31
|
+
import type { Status } from "../status/format.ts";
|
|
31
32
|
import { newestChoices, openQuestions } from "../status/sections.ts";
|
|
32
33
|
import { commandTimeoutMs } from "../exec.ts";
|
|
33
34
|
import { SECOND_MS } from "../time.ts";
|
|
@@ -39,7 +40,7 @@ import type { SlotPool } from "../slots/pool.ts";
|
|
|
39
40
|
import { type AnswerScope, settleAnswers } from "./answers.ts";
|
|
40
41
|
import { recentlyAsked, releaseQuestions } from "./questions.ts";
|
|
41
42
|
import { OWNER_APPROVAL } from "../decide/merge.ts";
|
|
42
|
-
import { answerTo, type Checkout, claimTtlMs, DEFAULT_BASE,
|
|
43
|
+
import { answerTo, type Checkout, ownerWaitStage, claimTtlMs, DEFAULT_BASE, hasEndedStuck, park, rememberKinds, RUN_AGAIN, runThinPath, type ThinResult, isWaitingOnOwner } from "./thin-path.ts";
|
|
43
44
|
|
|
44
45
|
export type { TickResult } from "./lifecycle.ts";
|
|
45
46
|
|
|
@@ -62,15 +63,19 @@ export type WorkerOptions = {
|
|
|
62
63
|
readonly remote: string;
|
|
63
64
|
readonly base?: string;
|
|
64
65
|
readonly checks: readonly string[];
|
|
65
|
-
readonly holder:
|
|
66
|
+
readonly holder: Holder;
|
|
66
67
|
readonly workDir?: string;
|
|
67
68
|
/** Gives each pass its working copy; by default a `git clone`. */
|
|
68
69
|
readonly checkout?: Checkout;
|
|
69
|
-
/** The run slots behind `checkout`, if any: each tick asks them to keep slots ready. */
|
|
70
|
-
readonly slots?: Pick<SlotPool, "keepReady">;
|
|
70
|
+
/** The run slots behind `checkout`, if any: each tick asks them to keep slots ready, and the worker is idle once their upkeep ends. */
|
|
71
|
+
readonly slots?: Pick<SlotPool, "keepReady" | "idle">;
|
|
71
72
|
readonly dir?: string;
|
|
72
73
|
readonly where?: "mac" | "ci";
|
|
73
|
-
readonly now
|
|
74
|
+
readonly now: () => number;
|
|
75
|
+
/** The names of the variables the runs have, for the missing-secret check. */
|
|
76
|
+
readonly runnerVariables: ReadonlySet<string>;
|
|
77
|
+
/** A fresh id for each run's session. */
|
|
78
|
+
readonly newSessionId: () => string;
|
|
74
79
|
/** The engine this process runs; the update check compares the one installed in `repo` with it. */
|
|
75
80
|
readonly engineVersion?: string;
|
|
76
81
|
/** The newest published version; a failed or slow read shows no version. */
|
|
@@ -103,8 +108,25 @@ type InFlight = {
|
|
|
103
108
|
};
|
|
104
109
|
|
|
105
110
|
const ERROR_EXCERPT = 300;
|
|
111
|
+
|
|
106
112
|
const UNREAD_CODE = "item-unread";
|
|
107
113
|
|
|
114
|
+
const linesText = (lines: readonly number[]): string => `${lines.length === 1 ? "line" : "lines"} ${lines.join(", ")}`;
|
|
115
|
+
|
|
116
|
+
/** The card for each reason memory.md lines are refused. */
|
|
117
|
+
const MEMORY_CARDS = {
|
|
118
|
+
"no-source": {
|
|
119
|
+
code: "memory-format",
|
|
120
|
+
cause: (lines: readonly number[]) => `Runs skip memory.md ${linesText(lines)}: no "(source: …)".`,
|
|
121
|
+
fix: "Give the line a source, as in - <rule> (source: <where you said it>).",
|
|
122
|
+
},
|
|
123
|
+
"past-cap": {
|
|
124
|
+
code: "memory-full",
|
|
125
|
+
cause: (lines: readonly number[], maxBytes: number) => `Runs skip memory.md ${linesText(lines)}: past memoryMaxBytes (${maxBytes}).`,
|
|
126
|
+
fix: "Remove entries you no longer need, or raise memoryMaxBytes in .hum/hum.json.",
|
|
127
|
+
},
|
|
128
|
+
} as const satisfies Record<RefusedLine["why"], { code: string; cause: (lines: readonly number[], maxBytes: number) => string; fix: string }>;
|
|
129
|
+
|
|
108
130
|
/** Reads `read` at most once per `everyMs`; a failed read, or one slower than `timeoutMs`, shows no value, and that too is kept for the period. */
|
|
109
131
|
const readEvery = <T>(read: (() => Promise<T | undefined>) | undefined, { everyMs, timeoutMs }: { everyMs: number; timeoutMs: number }): (() => Promise<T | undefined>) =>
|
|
110
132
|
read === undefined
|
|
@@ -112,8 +134,7 @@ const readEvery = <T>(read: (() => Promise<T | undefined>) | undefined, { everyM
|
|
|
112
134
|
: pMemoize(() => pTimeout(read(), { milliseconds: timeoutMs, fallback: () => undefined }).catch(() => undefined), { cache: new ExpiryMap(everyMs) });
|
|
113
135
|
|
|
114
136
|
/** Sources that never settle, so a restored item can be stepped by its timers without starting a run. */
|
|
115
|
-
const neverSources = (kind: Kind) =>
|
|
116
|
-
Object.fromEntries(Object.values(kind.machine.states).flatMap((node) => (node.invoke ? [[node.invoke.src, createAsyncLogic({ run: () => new Promise<never>(() => {}) })]] : [])));
|
|
137
|
+
const neverSources = (kind: Kind) => invokedSources(kind, createAsyncLogic({ run: () => new Promise<never>(() => {}) }));
|
|
117
138
|
|
|
118
139
|
/** The declared delays of the state an item was saved in, shortest first. */
|
|
119
140
|
const delaysOf = (kind: Kind, saved: SavedSnapshot): number[] =>
|
|
@@ -155,7 +176,6 @@ export class Worker {
|
|
|
155
176
|
readonly #wakes = new EventTarget();
|
|
156
177
|
readonly #latest: () => Promise<string | undefined>;
|
|
157
178
|
readonly #ciTick: () => Promise<number | undefined>;
|
|
158
|
-
readonly #learn: (id: string) => Promise<Known>;
|
|
159
179
|
readonly #judge: ModelCall;
|
|
160
180
|
#watchToken: string | undefined;
|
|
161
181
|
/** Set while the worker has seen an update; no change lands until a worker on the new config takes it. */
|
|
@@ -167,22 +187,13 @@ export class Worker {
|
|
|
167
187
|
|
|
168
188
|
constructor(options: WorkerOptions) {
|
|
169
189
|
this.#o = options;
|
|
170
|
-
this.#now = options.now
|
|
190
|
+
this.#now = options.now;
|
|
171
191
|
this.#gate = options.gate ?? new PrefixGate({ now: this.#now });
|
|
172
192
|
const timeoutMs = options.config.hum.statusReadTimeoutSeconds * SECOND_MS;
|
|
173
193
|
|
|
174
194
|
this.#latest = readEvery(options.latestVersion, { everyMs: options.config.hum.latestVersionCacheSeconds * SECOND_MS, timeoutMs });
|
|
175
195
|
this.#ciTick = readEvery(options.ciTick, { everyMs: options.config.hum.ciTickCacheSeconds * SECOND_MS, timeoutMs });
|
|
176
|
-
this.#start = signatureOf(options.repo, options.engineVersion ?? ENGINE_VERSION, options.config.hum.itemsDir);
|
|
177
|
-
this.#learn = pMemoize(async (id: string): Promise<Known> => {
|
|
178
|
-
const item = await options.adapters.workSource.read(id);
|
|
179
|
-
|
|
180
|
-
return {
|
|
181
|
-
footprint: footprintOf(item),
|
|
182
|
-
|
|
183
|
-
title: item.title,
|
|
184
|
-
};
|
|
185
|
-
});
|
|
196
|
+
this.#start = signatureOf({ repo: options.repo, fallbackVersion: options.engineVersion ?? ENGINE_VERSION, itemsDir: options.config.hum.itemsDir });
|
|
186
197
|
this.#judge = options.judge ?? configuredModelCall(options.runner, options.config.hum, (item, tokens) => tallyOf(options.state, item).spend(tokens));
|
|
187
198
|
rememberKinds(options.state, options.config);
|
|
188
199
|
this.#recheckLandings();
|
|
@@ -206,8 +217,10 @@ export class Worker {
|
|
|
206
217
|
return [...this.#inFlight.keys()];
|
|
207
218
|
}
|
|
208
219
|
|
|
209
|
-
|
|
210
|
-
|
|
220
|
+
/** Resolves when no pass runs and no slot upkeep a pass asked for is left: a returned slot is ready again. */
|
|
221
|
+
async idle(): Promise<void> {
|
|
222
|
+
await this.#pool.onIdle();
|
|
223
|
+
await this.#o.slots?.idle();
|
|
211
224
|
}
|
|
212
225
|
|
|
213
226
|
/** Asks a serving worker for a tick now: a run ended, or an answer arrived. */
|
|
@@ -225,7 +238,7 @@ export class Worker {
|
|
|
225
238
|
#isAsleep(saved: SavedSnapshot): boolean {
|
|
226
239
|
const kind = this.#kindNamed(saved.kind)?.kind;
|
|
227
240
|
|
|
228
|
-
return kind !== undefined &&
|
|
241
|
+
return kind !== undefined && isWaitingOnOwner(kind, saved.state);
|
|
229
242
|
}
|
|
230
243
|
|
|
231
244
|
#dueWaits(t: number): DueWait[] {
|
|
@@ -266,7 +279,7 @@ export class Worker {
|
|
|
266
279
|
if (value !== saved.state) {
|
|
267
280
|
state.items.save(saved.itemId, kind, persistedSnapshot(actor));
|
|
268
281
|
|
|
269
|
-
if (
|
|
282
|
+
if (hasEndedStuck(kind, value))
|
|
270
283
|
park(
|
|
271
284
|
{ state, now: this.#now },
|
|
272
285
|
{
|
|
@@ -306,7 +319,7 @@ export class Worker {
|
|
|
306
319
|
if (!parked) return;
|
|
307
320
|
|
|
308
321
|
state.parked.remove(id);
|
|
309
|
-
state.faults.clear(`item-${parked.why}
|
|
322
|
+
state.faults.clear({ code: `item-${parked.why}`, item: id });
|
|
310
323
|
|
|
311
324
|
const landsAgain = state.landings.get(id) !== undefined && option !== RUN_AGAIN;
|
|
312
325
|
|
|
@@ -331,7 +344,7 @@ export class Worker {
|
|
|
331
344
|
const asleep = sleeping.get(id);
|
|
332
345
|
const kind = asleep && this.#kindNamed(asleep.kind)?.kind;
|
|
333
346
|
|
|
334
|
-
if (asleep && kind) return { stage: kind
|
|
347
|
+
if (asleep && kind) return { stage: ownerWaitStage(kind, asleep.state) };
|
|
335
348
|
|
|
336
349
|
return { stage: ready ? "waiting" : "ended" };
|
|
337
350
|
}
|
|
@@ -373,7 +386,7 @@ export class Worker {
|
|
|
373
386
|
await Promise.all(
|
|
374
387
|
[...new Set([...waiting, ...parked.map((p) => p.item), ...inbox, ...asked, ...this.#unread])].map((id) =>
|
|
375
388
|
this.#readThread(id, async () => {
|
|
376
|
-
const raw = await adapters.workSource.read(id);
|
|
389
|
+
const raw = await adapters.workSource.read(ItemId.parse(id));
|
|
377
390
|
const item = await settleAnswers({ state, workSource: adapters.workSource, judge: this.#judge, now: this.#now }, raw, this.#stageOf(id, raw.ready, asleep));
|
|
378
391
|
const held = parked.find((p) => p.item === id);
|
|
379
392
|
const lastAnswer = item.thread.findLast((e) => e.kind === "answer");
|
|
@@ -409,7 +422,7 @@ export class Worker {
|
|
|
409
422
|
try {
|
|
410
423
|
await read();
|
|
411
424
|
this.#unread.delete(id);
|
|
412
|
-
faults.clear(
|
|
425
|
+
faults.clear({ code: UNREAD_CODE, item: id });
|
|
413
426
|
} catch (error) {
|
|
414
427
|
this.#unread.add(id);
|
|
415
428
|
faults.raise({ code: UNREAD_CODE, item: id, cause: `The thread of ${id} could not be read: ${error instanceof Error ? error.message : String(error)}`.slice(0, ERROR_EXCERPT), fix: "hum reads it again each tick and goes on with the other items." });
|
|
@@ -422,7 +435,7 @@ export class Worker {
|
|
|
422
435
|
|
|
423
436
|
await Promise.all(
|
|
424
437
|
[...this.#inFlight].map(async ([id, run]) => {
|
|
425
|
-
const claim = await adapters.workSource.renew(id, holder, claimTtlMs(config)).catch(() => undefined);
|
|
438
|
+
const claim = await adapters.workSource.renew(ItemId.parse(id), holder, claimTtlMs(config)).catch(() => undefined);
|
|
426
439
|
|
|
427
440
|
if (claim?.won === false) run.abort.abort();
|
|
428
441
|
}),
|
|
@@ -449,10 +462,12 @@ export class Worker {
|
|
|
449
462
|
workDir: this.#o.workDir,
|
|
450
463
|
checkout: this.#o.checkout,
|
|
451
464
|
dir: this.#o.dir,
|
|
452
|
-
itemId: id,
|
|
465
|
+
itemId: ItemId.parse(id),
|
|
453
466
|
signal: abort.signal,
|
|
454
467
|
gate: this.#gate,
|
|
455
468
|
now: this.#now,
|
|
469
|
+
runnerVariables: this.#o.runnerVariables,
|
|
470
|
+
newSessionId: this.#o.newSessionId,
|
|
456
471
|
pulls: this.#o.pulls,
|
|
457
472
|
mayLand: () => this.#updating === undefined,
|
|
458
473
|
}).then(
|
|
@@ -488,19 +503,24 @@ export class Worker {
|
|
|
488
503
|
}
|
|
489
504
|
|
|
490
505
|
/** The memory.md rules the runs shown the file did not apply in the last `memoryUnusedRuns` of them. */
|
|
491
|
-
#unusedMemory(): string[] {
|
|
492
|
-
const { state, config
|
|
506
|
+
#unusedMemory(entries: readonly MemoryEntry[]): string[] {
|
|
507
|
+
const { state, config } = this.#o;
|
|
508
|
+
const { runsSoFar, lastUsed } = useOf(state.runs.all());
|
|
493
509
|
|
|
494
|
-
|
|
495
|
-
|
|
510
|
+
return unusedEntries({ entries, lastUsed, runsSoFar, limit: config.hum.memoryUnusedRuns }).map(({ rule }) => rule);
|
|
511
|
+
}
|
|
496
512
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
513
|
+
/** One card for each reason memory.md lines are refused, naming the lines as they stand; a reason no line has any more clears its card. */
|
|
514
|
+
#showRefusedMemory(refused: readonly RefusedLine[]): void {
|
|
515
|
+
const { faults } = this.#o.state;
|
|
500
516
|
|
|
501
|
-
|
|
517
|
+
for (const [why, { code, cause, fix }] of Object.entries(MEMORY_CARDS)) {
|
|
518
|
+
const lines = refused.flatMap((line) => (line.why === why ? [line.line] : []));
|
|
519
|
+
const now = lines.length === 0 ? undefined : cause(lines, this.#o.config.hum.memoryMaxBytes);
|
|
502
520
|
|
|
503
|
-
|
|
521
|
+
if (faults.list().some((card) => card.code === code && card.cause !== now)) faults.clear({ code });
|
|
522
|
+
|
|
523
|
+
if (now !== undefined) faults.raise({ code, cause: now, fix });
|
|
504
524
|
}
|
|
505
525
|
}
|
|
506
526
|
|
|
@@ -539,7 +559,7 @@ export class Worker {
|
|
|
539
559
|
history: () => readHistory(git, tip, config.hum),
|
|
540
560
|
hunkOf: async (sha, file) => (await git.run(["show", ...PATCH, "-U3", "--format=", sha, ...(file === undefined ? [] : ["--", file])])).stdout,
|
|
541
561
|
propose: modelProposer(call),
|
|
542
|
-
trusts: (models) =>
|
|
562
|
+
trusts: (models) => doesTrustRepeats(models, config.hum),
|
|
543
563
|
memoryPath: join(repo, ".hum", "memory.md"),
|
|
544
564
|
});
|
|
545
565
|
}
|
|
@@ -576,6 +596,9 @@ export class Worker {
|
|
|
576
596
|
|
|
577
597
|
const read = readStatus(state.statusPath);
|
|
578
598
|
const before = read.ok ? read.status : emptyStatus(signature.engineVersion, t);
|
|
599
|
+
const memory = readMemory(join(this.#o.repo, ".hum", "memory.md"), config.hum.memoryMaxBytes);
|
|
600
|
+
|
|
601
|
+
this.#showRefusedMemory(memory.refused);
|
|
579
602
|
const [latest, ci] = await Promise.all([this.#latest(), this.#ciTick()]);
|
|
580
603
|
const saved = new Map(state.items.saved().map((s) => [s.itemId, s.state]));
|
|
581
604
|
|
|
@@ -601,7 +624,7 @@ export class Worker {
|
|
|
601
624
|
})),
|
|
602
625
|
merged: [...this.#merged.splice(0), ...before.merged].slice(0, this.#o.config.hum.mergedShown),
|
|
603
626
|
possibleRepeats: state.possibleRepeats.list().map(({ a, b }) => ({ a, b })),
|
|
604
|
-
unusedMemory: this.#unusedMemory(),
|
|
627
|
+
unusedMemory: this.#unusedMemory(memory.entries),
|
|
605
628
|
measure: measureOf({ ...measureInputsOf(state), window: config.hum.measureWindow, globs: config.hum.paths.map(({ glob }) => glob) }) ?? null,
|
|
606
629
|
rules: state.learned.list().map(({ glob, level, item, at, commit }) => ({ glob, level, item, at, undo: { label: "Undo", command: `git revert ${commit}` } })),
|
|
607
630
|
});
|
|
@@ -629,6 +652,13 @@ export class Worker {
|
|
|
629
652
|
}
|
|
630
653
|
}
|
|
631
654
|
|
|
655
|
+
/** What the scheduler needs of an item, read fresh each tick so an owner's edit to its `touches:` counts. */
|
|
656
|
+
async #learn(id: string): Promise<Known> {
|
|
657
|
+
const item = await this.#o.adapters.workSource.read(ItemId.parse(id));
|
|
658
|
+
|
|
659
|
+
return { footprint: footprintOf(item), title: item.title };
|
|
660
|
+
}
|
|
661
|
+
|
|
632
662
|
/** Which waiting items start now, by the scheduler's rules, and starts them. */
|
|
633
663
|
async #startPicked(t: number, ready: readonly ItemRef[], sleeping: readonly SavedSnapshot[]): Promise<string[]> {
|
|
634
664
|
const { state, runner, config } = this.#o;
|
|
@@ -685,9 +715,9 @@ export class Worker {
|
|
|
685
715
|
|
|
686
716
|
await Promise.all(this.#dueWaits(t).map((due) => this.#fireDue(due, t)));
|
|
687
717
|
|
|
688
|
-
if (config.hum.ciToken) checkTokenAge(state.faults, config.hum.ciToken.setUp, t, config.hum.tokenWarnDays);
|
|
718
|
+
if (config.hum.ciToken) checkTokenAge(state.faults, { setUp: config.hum.ciToken.setUp, now: t, warnDays: config.hum.tokenWarnDays });
|
|
689
719
|
|
|
690
|
-
const signature = signatureOf(this.#o.repo, this.#o.engineVersion ?? ENGINE_VERSION, this.#o.config.hum.itemsDir);
|
|
720
|
+
const signature = signatureOf({ repo: this.#o.repo, fallbackVersion: this.#o.engineVersion ?? ENGINE_VERSION, itemsDir: this.#o.config.hum.itemsDir });
|
|
691
721
|
const update = this.#updateSeen(signature);
|
|
692
722
|
|
|
693
723
|
this.#updating = update;
|