@parcha/agentrun-serve 0.1.0-beta.41 → 0.1.0-beta.43

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.
Files changed (164) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/NOTICE +2 -0
  3. package/README.md +85 -19
  4. package/dist/agent-rows.d.ts +1 -1
  5. package/dist/agents-store.js +3 -1
  6. package/dist/calendar/address.d.ts +49 -0
  7. package/dist/calendar/address.js +153 -0
  8. package/dist/calendar/fetch.d.ts +24 -0
  9. package/dist/calendar/fetch.js +146 -0
  10. package/dist/calendar/ics-faux.d.ts +39 -0
  11. package/dist/calendar/ics-faux.js +236 -0
  12. package/dist/calendar/labels.d.ts +3 -0
  13. package/dist/calendar/labels.js +61 -0
  14. package/dist/calendar/names.d.ts +52 -0
  15. package/dist/calendar/names.js +54 -0
  16. package/dist/calendar/parse.d.ts +108 -0
  17. package/dist/calendar/parse.js +625 -0
  18. package/dist/calendar/routes.d.ts +17 -0
  19. package/dist/calendar/routes.js +81 -0
  20. package/dist/calendar/tools.d.ts +23 -0
  21. package/dist/calendar/tools.js +124 -0
  22. package/dist/cli.js +3 -1
  23. package/dist/computer-record.d.ts +55 -0
  24. package/dist/computer-record.js +315 -0
  25. package/dist/computer-setting.d.ts +1 -0
  26. package/dist/computer-setting.js +15 -2
  27. package/dist/computers.js +2 -14
  28. package/dist/console/assets/index-BrcDSBD8.css +1 -0
  29. package/dist/console/assets/index-Bz6IWncl.js +711 -0
  30. package/dist/console/index.html +2 -2
  31. package/dist/decisions.js +0 -4
  32. package/dist/eval-feed.d.ts +2 -2
  33. package/dist/eval-feed.js +9 -5
  34. package/dist/feed/parse.d.ts +3 -2
  35. package/dist/feed/parse.js +9 -18
  36. package/dist/feed/pointer.d.ts +2 -0
  37. package/dist/feed/pointer.js +17 -0
  38. package/dist/file-types.js +1 -0
  39. package/dist/host-command.d.ts +3 -0
  40. package/dist/host-command.js +18 -0
  41. package/dist/host.d.ts +3 -0
  42. package/dist/host.js +3 -0
  43. package/dist/import-sources.js +25 -5
  44. package/dist/learn/audit.d.ts +123 -0
  45. package/dist/learn/audit.js +159 -0
  46. package/dist/learn/check.d.ts +14 -0
  47. package/dist/learn/check.js +194 -14
  48. package/dist/learn/compile.d.ts +75 -78
  49. package/dist/learn/compile.js +175 -176
  50. package/dist/learn/folder.d.ts +9 -0
  51. package/dist/learn/folder.js +13 -2
  52. package/dist/learn/promote.d.ts +138 -196
  53. package/dist/learn/promote.js +68 -184
  54. package/dist/learn/replay-calls.d.ts +5 -0
  55. package/dist/learn/replay-calls.js +12 -1
  56. package/dist/learn/secrets.d.ts +8 -0
  57. package/dist/learn/secrets.js +12 -0
  58. package/dist/learn/skills.js +2 -4
  59. package/dist/learn/workflow-nodes.d.ts +1 -2
  60. package/dist/learn/workflow-nodes.js +2 -3
  61. package/dist/learned-nodes.d.ts +9 -34
  62. package/dist/learned-nodes.js +11 -23
  63. package/dist/learned-workflow.d.ts +6 -8
  64. package/dist/learned-workflow.js +18 -57
  65. package/dist/learning-batch.d.ts +13 -5
  66. package/dist/learning-batch.js +34 -8
  67. package/dist/learning-cost.d.ts +11 -4
  68. package/dist/learning-cost.js +4 -2
  69. package/dist/learning-routes.js +1 -1
  70. package/dist/learning-setting.d.ts +38 -0
  71. package/dist/learning-setting.js +83 -0
  72. package/dist/learning-words.d.ts +3 -0
  73. package/dist/learning-words.js +3 -0
  74. package/dist/learning.d.ts +3 -2
  75. package/dist/learning.js +5 -3
  76. package/dist/mcp-oauth.d.ts +8 -0
  77. package/dist/mcp-oauth.js +7 -0
  78. package/dist/mcp-private-hosts.d.ts +13 -0
  79. package/dist/mcp-private-hosts.js +16 -0
  80. package/dist/openapi.d.ts +1 -0
  81. package/dist/openapi.js +195 -59
  82. package/dist/run-files.d.ts +6 -2
  83. package/dist/run-files.js +29 -7
  84. package/dist/run-launch.d.ts +6 -3
  85. package/dist/run-launch.js +2 -0
  86. package/dist/run-learning-served.d.ts +2 -2
  87. package/dist/run-reads-over-store.d.ts +5 -1
  88. package/dist/run-reads-over-store.js +8 -4
  89. package/dist/run-recordings.d.ts +20 -0
  90. package/dist/run-recordings.js +133 -0
  91. package/dist/runner/adapter-loop.d.ts +5 -1
  92. package/dist/runner/adapter-loop.js +20 -8
  93. package/dist/runner/adapter-run-spec.d.ts +16 -1
  94. package/dist/runner/adapter-run-spec.js +36 -11
  95. package/dist/runner/audit.d.ts +64 -0
  96. package/dist/runner/audit.js +338 -0
  97. package/dist/runner/beside.js +2 -2
  98. package/dist/runner/cli-run-spec.js +25 -12
  99. package/dist/runner/feedback-round.d.ts +9 -25
  100. package/dist/runner/feedback-round.js +19 -40
  101. package/dist/runner/harness-loops.js +1 -15
  102. package/dist/runner/journal-kinds.d.ts +0 -7
  103. package/dist/runner/journal-kinds.js +0 -7
  104. package/dist/runner/learning-dispatch.d.ts +0 -16
  105. package/dist/runner/learning-dispatch.js +4 -47
  106. package/dist/runner/learning-end.d.ts +62 -13
  107. package/dist/runner/learning-end.js +180 -74
  108. package/dist/runner/learning-factory.d.ts +1 -1
  109. package/dist/runner/learning-factory.js +1 -4
  110. package/dist/runner/learning-loop.d.ts +2 -38
  111. package/dist/runner/learning-loop.js +8 -116
  112. package/dist/runner/main.d.ts +11 -0
  113. package/dist/runner/main.js +30 -3
  114. package/dist/runner/mcp-run.d.ts +2 -2
  115. package/dist/runner/promotion.d.ts +78 -50
  116. package/dist/runner/promotion.js +371 -503
  117. package/dist/runner/reflect-hook.d.ts +15 -0
  118. package/dist/runner/reflect-hook.js +28 -14
  119. package/dist/runner/store-secrets.js +3 -1
  120. package/dist/runner/workflow-first.d.ts +6 -11
  121. package/dist/runner/workflow-first.js +24 -25
  122. package/dist/runs-over-store.d.ts +1 -1
  123. package/dist/sdk/runs.js +2 -1
  124. package/dist/secrets.js +2 -2
  125. package/dist/server.d.ts +4 -3
  126. package/dist/server.js +132 -26
  127. package/dist/store/agent-body.d.ts +5 -3
  128. package/dist/store/agent-body.js +14 -10
  129. package/dist/store/sqlite/store.js +1 -0
  130. package/dist/store/store.d.ts +3 -0
  131. package/dist/store-reads/learning.d.ts +18 -7
  132. package/dist/store-reads/learning.js +36 -23
  133. package/dist/store-reads/loop.d.ts +5 -39
  134. package/dist/store-reads/loop.js +21 -80
  135. package/dist/store-view.d.ts +5 -0
  136. package/dist/store-view.js +16 -2
  137. package/dist/template-eval.d.ts +7 -0
  138. package/dist/template-eval.js +54 -6
  139. package/dist/templates.d.ts +3 -1
  140. package/dist/templates.js +14 -1
  141. package/dist/timeline/computer.js +2 -1
  142. package/dist/tool-list.js +1 -0
  143. package/dist/tools.d.ts +7 -0
  144. package/dist/tools.js +11 -0
  145. package/dist/trigger-feed.js +67 -18
  146. package/dist/validate.js +7 -2
  147. package/dist/workspace/computer-for-claim.d.ts +7 -0
  148. package/dist/workspace/computer-for-claim.js +12 -2
  149. package/dist/workspace/paths.d.ts +4 -0
  150. package/dist/workspace/paths.js +9 -0
  151. package/dist/workspace/resolve-computer.d.ts +3 -1
  152. package/dist/workspace/run-tools.d.ts +1 -1
  153. package/dist/workspace/run-tools.js +14 -3
  154. package/launcher/agentrun-serve +31 -24
  155. package/package.json +10 -9
  156. package/templates/README.md +11 -2
  157. package/dist/console/assets/index-C3gNPz58.css +0 -1
  158. package/dist/console/assets/index-COGhx_2Z.js +0 -711
  159. package/dist/learn/general.d.ts +0 -69
  160. package/dist/learn/general.js +0 -75
  161. package/dist/learn/refit.d.ts +0 -48
  162. package/dist/learn/refit.js +0 -264
  163. package/dist/runner/step-guard.d.ts +0 -62
  164. package/dist/runner/step-guard.js +0 -93
@@ -5,9 +5,11 @@
5
5
  // - whether it looks back (learning-run.ts reflectSkip): its cap and its spend so far, read as its view reads them;
6
6
  // - its prompt's facts: how many notes its seed held (launch seedNotes);
7
7
  // - the compile turn's facts (compileAskOf, learn/compile.ts): whether the job is due to be compiled (its notes, its
8
- // completed runs, no learned workflow yet), or a workflow that handed the run back or that the money rule stopped
9
- // wants a revision; its notes whole, its last runs' traces, the tools a workflow may name (draftTools) and the DSL's
10
- // own language for writing one;
8
+ // completed runs, no learned workflow yet), or a workflow its promotion holds wants a revision (once per hold); its
9
+ // notes whole, its last runs' traces, the tools a workflow may name (draftTools) and the DSL's own language for
10
+ // writing one;
11
+ // - whether it looks back at all (ownerSaid): a run of a job that compiles workflows is asked its look-back only when
12
+ // its owner gave feedback (a grade's words, or a message after its first); its compile turn, when due, is asked alone;
11
13
  // - what the person said in the run and a trigger's input (heard.ts Hearing over its entries, the end-of-run turn's
12
14
  // own left out), as learning-run.ts turnOf reads them;
13
15
  // - whether the job gave nothing new to look back on (onlyLearnedWorkflows over its timeline): a run whose only tool
@@ -22,19 +24,22 @@
22
24
  // runner's run has no door token: its loop runs in the runner's process.
23
25
  // A proposal queues the learning run (learning_run), which the runner's dispatch runs on the learning loop
24
26
  // (harness-loops.ts: harness "learning"), to grade and merge it. A run whose seed could not be read keeps that drop.
27
+ import { createHash } from "node:crypto";
25
28
  import { mkdtemp, readFile, rm } from "node:fs/promises";
26
29
  import { tmpdir } from "node:os";
27
30
  import { join } from "node:path";
28
31
  import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
29
32
  import { isMessageRow } from "../timeline/index.js";
30
33
  import { Hearing } from "../heard.js";
34
+ import { learningCommit } from "../learn/commit.js";
31
35
  import { readLearning, readSnapshot } from "../learn/folder.js";
32
- import { compileDue, compilePrompt, compileReference, COMPILE_AFTER_RUNS, COMPILE_QUIET_RUNS, COMPILE_TRACES, heldNamesOf } from "../learn/compile.js";
33
- import { promotionOf, promotionsOf, scoreOf } from "../learn/promote.js";
36
+ import { completedRun, compileStoppedOf, lastOwnRuns, compileDue, compilePrompt, compileReference, COMPILE_TRACES, DRAFT_FAILED, heldNamesOf, newCompileAttempt } from "../learn/compile.js";
37
+ import { loopOf } from "../learning-setting.js";
38
+ import { CHECK_TEXT_MAX, promotionOf, promotionsOf, recordPromotion } from "../learn/promote.js";
34
39
  import { draftDecisionProviders } from "../learn/skills.js";
35
40
  import { DECISION_PROVIDER_KEYS } from "../tool-plane.js";
36
41
  import { handedValuesOf } from "../handed-values.js";
37
- import { MIN_SECRET, redactSecrets } from "../learn/secrets.js";
42
+ import { excerptShown, MIN_SECRET, redactSecrets } from "../learn/secrets.js";
38
43
  import { LEARNED_WORKFLOW_TOOL } from "../learned-workflow.js";
39
44
  import { META_TOOLS } from "../meta-tool-names.js";
40
45
  import { holdsSecret, LEARNING_LABEL, PROPOSAL, secretsShown } from "../learning.js";
@@ -43,12 +48,14 @@ import { said, STOPPED } from "../learning-words.js";
43
48
  import { proposeRun } from "../propose.js";
44
49
  import { learningStartOf, readLaunchBody, seedFailed } from "../run-launch.js";
45
50
  import { costOf } from "../run-view.js";
51
+ import { FINAL_STATES } from "../store/store.js";
52
+ import { shadowRunId } from "../learn/audit.js";
46
53
  import { getMcpServer } from "../mcp-store.js";
47
54
  import { readApprovers } from "../server-approvers.js";
48
55
  import { runEntries, runReflect, runTimeline, withFeedback, withoutFeedbackRounds } from "../store-reads/journal.js";
49
56
  import { capNowOf } from "./journal-kinds.js";
50
57
  import { bookedCapSpend, bookedSpend } from "./metrics.js";
51
- import { fits, reviseOf, servedAnswerOf, servedOf, workflowDigest } from "./workflow-first.js";
58
+ import { fits, workflowDigest } from "./workflow-first.js";
52
59
  import { pendingFeedbackOf } from "./feedback-round.js";
53
60
  import { createReflectHook } from "./reflect-hook.js";
54
61
  import { sdkDraftTools } from "../sdk/workflows.js";
@@ -72,8 +79,8 @@ export function learningEndOfRun(launch, deps) {
72
79
  // were admitted under, never the launch's alone. A person's stop comes to the hook as its `cut`.
73
80
  // Its spend under that cap is what the run's own gates read (capSpendOf: a request with no price of its own at the
74
81
  // figure it was held at), never the cost a person is shown, which is unknown once one request's is. What its earlier
75
- // rounds' grades took beside it counts toward that cap as its own spend does (Learning.spentBeside, the figure its
76
- // gates read). Either unknown: the spend is unknown, said so, never read as the whole cap.
82
+ // rounds' grades and its audit's shadow took beside it counts toward that cap as its own spend does (besideOf, the
83
+ // figure its gates read). Either unknown: the spend is unknown, said so, never read as the whole cap.
77
84
  facts: async (runId) => {
78
85
  const [rows, entries] = await Promise.all([
79
86
  runTimeline(deps.store, runId, BACKGROUND_CONTEXT, { settled: false }),
@@ -99,8 +106,16 @@ export function learningEndOfRun(launch, deps) {
99
106
  // new"), whatever the job did: said here, never left to the words' row counting as a message of the job's.
100
107
  nothingNew: async (runId) => !pendingFeedbackOf(await runEntries(deps.store, runId, BACKGROUND_CONTEXT)) && onlyLearnedWorkflows(await runTimeline(deps.store, runId, BACKGROUND_CONTEXT, { settled: false })),
101
108
  promptFacts: async () => ({ active: start.seedNotes ?? start.given.length }),
102
- // A notes run (`learning: "notes"`) compiles nothing.
103
- ...(start.notesOnly ? {} : { compileFacts: (input) => compileAskOf(deps, { ...input, input: launch.input, ...(start.seedNotes !== undefined ? { seedNotes: start.seedNotes } : {}), seedWorkflows: start.workflows?.length ?? 0 }) }),
109
+ // A notes run (`learning: "notes"`) compiles nothing, and looks back on every run. A run of a job that compiles
110
+ // workflows looks back only on its owner's feedback (ownerSaid).
111
+ ...(start.notesOnly ? {} : {
112
+ compileFacts: (input) => compileAskOf(deps, { ...input, input: launch.input, seedWorkflows: start.workflows?.length ?? 0 }),
113
+ compileFailed: (input) => recordDraftFailed(deps, input),
114
+ ownerSaid: async (runId) => {
115
+ const [entries, rows] = await Promise.all([runEntries(deps.store, runId, BACKGROUND_CONTEXT), runTimeline(deps.store, runId, BACKGROUND_CONTEXT, { settled: false })]);
116
+ return ownerSaid(entries, rows);
117
+ },
118
+ }),
104
119
  asked: async (runId) => {
105
120
  const [entries, reflect] = await Promise.all([runEntries(deps.store, runId, BACKGROUND_CONTEXT), runReflect(deps.store, runId, BACKGROUND_CONTEXT)]);
106
121
  const hearing = new Hearing();
@@ -167,17 +182,46 @@ export function learningEndOfRun(launch, deps) {
167
182
  };
168
183
  }
169
184
  /** What every cap gate of run `runId` reads as spent beside it on its behalf (adapter-loop.ts RunCapConfig.beside): its
170
- * learning runs' grades (Store.learning.spentBeside, the one figure), for a capped run that learns, the only run whose
171
- * ends queue them; none for any other, whose gates read only its own sessions. */
185
+ * learning runs' grades and its audit's shadow run (besideOf), for a capped run with a learning start, the only run
186
+ * whose ends queue them (one that only uses what its agent learned queues no grade, but may start a shadow); none for any
187
+ * other, whose gates read only its own sessions. */
172
188
  export function spentBesideOf(launch, store, runId) {
173
- const start = learningStartOf(launch);
174
- if (launch.maxCostUsd === undefined || !start || start.use)
189
+ if (launch.maxCostUsd === undefined || !learningStartOf(launch))
175
190
  return undefined;
176
- return () => store.learning.spentBeside(runId);
191
+ return () => besideOf(store, runId);
192
+ }
193
+ /** What was spent beside run `runId` on its behalf, the one figure its cap gates and its grades' caps read: its learning
194
+ * runs' grades (Store.learning.spentBeside; `beforeRound`: its earlier rounds' alone) and its audit's shadow run
195
+ * (runner/audit.ts, started at its end with what its cap left): the shadow at its cost once it ended, at its own cap while
196
+ * it has not (the most it may take) or when it ended at a cost not known, 0 when none was started. Null: unknown. */
197
+ export async function besideOf(store, runId, options = {}) {
198
+ const [grades, shadow] = await Promise.all([store.learning.spentBeside(runId, options), shadowBesideOf(store, runId)]);
199
+ return grades === null || shadow === null ? null : grades + shadow;
200
+ }
201
+ async function shadowBesideOf(store, runId) {
202
+ const id = shadowRunId(runId);
203
+ const shadow = await store.runs.get(id);
204
+ if (!shadow)
205
+ return 0;
206
+ const figure = (usd) => typeof usd === "number" && Number.isFinite(usd) && usd >= 0;
207
+ if (FINAL_STATES.includes(shadow.state) && figure(shadow.costUsd))
208
+ return shadow.costUsd;
209
+ const cap = readLaunchBody((await store.runs.launch(id)).body)?.maxCostUsd;
210
+ return figure(cap) ? cap : null;
211
+ }
212
+ /** What run `runId`'s cap leaves its audit's shadow run at its end (runner/audit.ts startAudit): the cap it is held to now
213
+ * (capNowOf: its newest raise's, else `launchCapUsd`), less what it spent under it (capSpendOf over `entries`, its
214
+ * journal: its job, its look-back, every grade an earlier round queued) and the cap of the grade this end queues
215
+ * (`queued`, the end's rows: it is not in the store until the end commits). Null when that spend is unknown. */
216
+ export async function auditRoomOf(store, runId, launchCapUsd, entries, queued) {
217
+ const capUsd = capNowOf(launchCapUsd, entries);
218
+ const spent = await capSpendOf(store, runId, entries);
219
+ const grade = queued.find((row) => row.table === "learning_run")?.row.capUsd ?? 0;
220
+ return spent === null ? null : capUsd - spent - grade;
177
221
  }
178
222
  /** What capped run `runId` has spent under its cap, as every gate of the run reads it: its sessions' booking as the kernel
179
223
  * cap counts it (metrics.ts bookedCapSpend over `entries`, its journal) and what was spent beside it on its behalf
180
- * (Learning.spentBeside; `beforeRound`: its earlier rounds' grades alone). Null when either is unknown.
224
+ * (besideOf: its grades, `beforeRound` its earlier rounds' alone, and its audit's shadow). Null when either is unknown.
181
225
  *
182
226
  * The rule for a cost no one knows (a request answered with no price of its own, one cut short or lost): under a cap it
183
227
  * counts at the figure the cap held it at when it was admitted (its worst case at the model's price, and a lost one's
@@ -190,7 +234,7 @@ export async function capSpendOf(store, runId, entries, beforeRound) {
190
234
  const spent = bookedCapSpend(entries);
191
235
  if (spent === null)
192
236
  return null;
193
- const beside = await store.learning.spentBeside(runId, beforeRound === undefined ? {} : { beforeRound });
237
+ const beside = await besideOf(store, runId, beforeRound === undefined ? {} : { beforeRound });
194
238
  return beside === null ? null : spent + beside;
195
239
  }
196
240
  /** The cap the grade of round `round` of run `runId` runs under (its learning run's max_cost_usd), so the run's grades
@@ -210,6 +254,22 @@ export async function gradeCapOf(store, runId, round, launchCapUsd) {
210
254
  return null;
211
255
  }
212
256
  }
257
+ /** A workflow text written straight onto the agent's learning folder as a merge by `runId`, from the claim's `seed`: the
258
+ * one direct commit a runner makes outside a learning run (a compile turn's revision). A file changed on main since the
259
+ * seed is a conflict, never written over. The learning commit it landed as, or null when it did not (the reason is
260
+ * logged). The folder is always released. */
261
+ export async function commitDirect(deps, files, reason, runId, seed) {
262
+ const folder = deps.folder();
263
+ try {
264
+ const done = await learningCommit(folder.workspace, { kind: "merge", runId, reason, files, graded: {}, ...(seed ? { seed } : {}) });
265
+ if (!done.ok)
266
+ deps.log(`learning: a direct commit could not be written (${done.reason})`);
267
+ return done.ok ? done.commit : null;
268
+ }
269
+ finally {
270
+ await folder.end();
271
+ }
272
+ }
213
273
  /** The learning run of round `round` of run `runId`'s learning: `<runId>-learning` for its first, `<runId>-learning-<n>`
214
274
  * for each later one. */
215
275
  export const learningRunIdOf = (runId, round = 1) => (round > 1 ? `${runId}-learning-${round}` : `${runId}-learning`);
@@ -244,6 +304,17 @@ export function onlyLearnedWorkflows(rows) {
244
304
  const answered = new Set(results.filter(models).map((row) => row.tool_use_id));
245
305
  return calls.every((row) => answered.has(row.tool_use_id));
246
306
  }
307
+ /** Whether a run carries its owner's feedback, the only thing a run of a job that compiles workflows is looked back on
308
+ * for: a grade's words its end closes (a feedback round, feedback-round.ts pendingFeedbackOf over its root `entries`),
309
+ * or a person's message after its first in its timeline `rows` (a follow-up, or a word while it ran: traceFrom's
310
+ * feedback), the end-of-run turn's own, a grade's round's and a subagent's (a child conversation's rows carry its
311
+ * spawning call, parent_tool_use_id: its task prompt is the job's, not the owner's) rows left out. */
312
+ export function ownerSaid(entries, rows) {
313
+ if (pendingFeedbackOf(entries))
314
+ return true;
315
+ const messages = withoutFeedbackRounds(rows).filter((row) => row.agent_label !== LEARNING_LABEL && !row.parent_tool_use_id && isMessageRow(row));
316
+ return messages.slice(1).some((row) => row.kind === "user_message");
317
+ }
247
318
  /** The path a run took (learning-cost.ts RunPath), by its timeline `rows` as runTimeline labels them (its end-of-run
248
319
  * turn's rows, LEARNING_LABEL, are the learning's and left out): `workflow` when its job did only what
249
320
  * onlyLearnedWorkflows asks of a run with nothing new to look back on, `handed_back` when it called a learned workflow
@@ -336,8 +407,53 @@ async function describedOf(tools, store) {
336
407
  }
337
408
  /** The most of an agent's kept learning, newest first, read for a held workflow's ask since its hold (compileAskOf). */
338
409
  const HELD_ASKED_READ = 200;
339
- /** Whether a store run ended completed (its state `ended`, a plain completion). */
340
- const completedRun = (run) => run.state === "ended" && (run.outcome === null || run.outcome === "completed");
410
+ /** The loop's numbers (learning-setting.ts loopOf) of the revision run `runId` runs: its definition's `learning`. */
411
+ async function loopOfRun(store, runId) {
412
+ try {
413
+ const run = await store.runs.get(runId);
414
+ const revision = run ? await store.agents.revision(run.revisionId) : undefined;
415
+ return loopOf(revision?.body?.learning);
416
+ }
417
+ catch {
418
+ return loopOf(undefined);
419
+ }
420
+ }
421
+ /** Compile once: run `runId`'s compile turn whose drafts all failed their checks is the compile's attempt, kept as a
422
+ * promotion record of the shape a check's stop has (runner/promotion.ts stopUnchecked): a hold with nothing checked,
423
+ * its reason (DRAFT_FAILED) naming the failed checks. A first compile's earns the one recompile, as a check's hold
424
+ * does (the agent's next due run compiles once more: learn/compile.ts newCompileAttempt); a recompile's (a revision of
425
+ * a held workflow, or a new one after a first compile's failed drafts) stops (compileStoppedOf, heldNamesOf): nothing
426
+ * compiles it again. One record per run (its digest is the run's), written once: a claim that ends the run again
427
+ * writes none. */
428
+ export async function recordDraftFailed(deps, input) {
429
+ try {
430
+ const records = await promotionsOf(deps.store.settings, input.agentId);
431
+ const attempt = input.compile.mode === "revise" ? 2 : newCompileAttempt(records);
432
+ const { compile_after, agree_min, alone_min } = await loopOfRun(deps.store, input.runId);
433
+ const workflow = input.compile.mode === "revise" ? input.compile.workflow : input.workflow;
434
+ const digest = createHash("sha256").update(`draft-failed\n${input.runId}`).digest("hex").slice(0, 16);
435
+ const failed = input.errors.join("; ").slice(0, CHECK_TEXT_MAX) || "no draft passed";
436
+ const reason = `${DRAFT_FAILED}: ${failed}. ${attempt === 2 ? "It was the recompile, so it stops: nothing compiles again until its owner acts" : "It is not promoted; the next due run compiles it once more"}`;
437
+ const check = { compile_after, agree_min, alone_min, attempt, n: 0, agreed: 0, alone: 0, of: [], ...(attempt === 2 ? { stopped: true } : {}) };
438
+ const kept = await recordPromotion(deps.store.settings, input.agentId, { workflow, digest, at: new Date().toISOString(), decided: "hold", reason, check }, (was) => was === undefined);
439
+ if (kept.won)
440
+ deps.log?.(`learning: run ${input.runId}: the compile of ${workflow} failed its checks (attempt ${attempt}${attempt === 2 ? ", stopped" : ""})`);
441
+ }
442
+ catch (error) {
443
+ deps.log?.(`learning: run ${input.runId}: the compile's failed drafts were not recorded: ${error instanceof Error ? error.message : String(error)}`);
444
+ }
445
+ }
446
+ /** Whether a new workflow's compile is waiting on its grade: a run's kept learning carries a draft that passed its
447
+ * checks (a compiled digest) whose learning run, which grades and merges it, has not ended. It is the compile: none
448
+ * is asked until it lands (a learned workflow then) or is dropped. Read from the agent's kept learning whose grade has
449
+ * not ended (Learning.grading: every one, however many runs kept learning since, never a window of the newest); one
450
+ * that can't be read waits. */
451
+ async function draftAwaitingGrade(store, agentId) {
452
+ const grading = await store.learning.grading(agentId).catch(() => undefined);
453
+ if (!grading)
454
+ return true;
455
+ return grading.some((one) => typeof one.proposal?.compiled?.digest === "string");
456
+ }
341
457
  /** The most tool calls of one run a trace keeps, and the most of a call's input or a message it holds, in characters. */
342
458
  const TRACE_CALLS = 20;
343
459
  const TRACE_TEXT = 600;
@@ -353,7 +469,8 @@ export async function traceOf(store, runId, refuse) {
353
469
  * shape. */
354
470
  export function traceFrom(timeline, refuse) {
355
471
  const rows = withoutFeedbackRounds(timeline).filter((row) => row.agent_label !== LEARNING_LABEL);
356
- const cut = (text) => redactSecrets(String(text ?? ""), refuse, Number.POSITIVE_INFINITY).replace(/\s+/g, " ").trim().slice(0, TRACE_TEXT);
472
+ const shown = { text: (text) => redactSecrets(text, refuse, Number.POSITIVE_INFINITY).replace(/\s+/g, " ").trim() };
473
+ const cut = (text) => excerptShown(String(text ?? ""), shown, TRACE_TEXT);
357
474
  const messages = rows.filter(isMessageRow);
358
475
  const failed = new Set(rows.filter((row) => row.kind === "tool_result" && row.tool_status === "failed").map((row) => row.tool_use_id));
359
476
  const models = modelsOwn(rows);
@@ -363,54 +480,44 @@ export function traceFrom(timeline, refuse) {
363
480
  return { input: first ? cut(first.text ?? first.summary) : "", calls, answer: cut(answer), feedback: messages.slice(1).filter((row) => row.kind === "user_message").map((row) => cut(row.text ?? row.summary)) };
364
481
  }
365
482
  /** The compile turn's facts for run `runId` of agent `agentId` (learn/compile.ts): a revision of the learned workflow
366
- * that handed the run back or that the money rule stopped (workflow-first.ts servedOf, reviseOf), its text as main holds
367
- * it; or of the one that fits the run's input and whose promotion holds it at main's digest (runner/promotion.ts: its
368
- * replay on the agent's graded inputs, or its graded served runs, fell under the bar; its champion served the run, or the
369
- * agent did by hand), with the
370
- * hold's numbers, once per hold (none when any run since the hold compiled it, read from the agent's kept learning); else, when the job is due (compileDue: the run completed, the agent has no learned workflow active or waiting, none
371
- * of its last COMPILE_QUIET_RUNS runs compiled, and it keeps enough notes or has run enough), a new one. Either way the
483
+ * that fits the run's input and whose promotion holds it at main's digest (runner/promotion.ts: its one check on the
484
+ * agent's own runs fell under the bar; its champion served the run, or the agent did by hand), its text as main holds
485
+ * it, with the check's numbers and the inputs it disagreed on, once per hold (none when any run since the hold compiled
486
+ * it, read from the agent's kept learning; a stopped check's none); else, when the job is due (compileDue: the run
487
+ * completed, the agent has no learned workflow active or waiting, and it has its definition's compile_after completed
488
+ * agent runs), a new one, compiled once: none while the last compile's passing draft waits on its grade
489
+ * (draftAwaitingGrade), one more after a first compile whose drafts all failed their checks, and none after a
490
+ * recompile's (recordDraftFailed). Nothing else asks one: a hand-back, a wrong grade of a served answer and the money rule's
491
+ * stop are single runs, which the hold reads among many. Either way the
372
492
  * agent's active notes whole, the traces of its last COMPILE_TRACES completed runs before this one, the tools a call node
373
493
  * may run (draftTools) with what each takes and gives, its decision providers, the run's input (`input`, its fields for
374
494
  * the workflow's input schema), the agent's output schema when it has one (its final output's shape) and the DSL's
375
495
  * language with this host's addendum. Undefined when it compiles nothing, or
376
496
  * when the folder can't be read. */
377
497
  export async function compileAskOf(deps, input) {
378
- const entries = await runEntries(deps.store, input.runId, BACKGROUND_CONTEXT).catch(() => []);
379
- const served = servedOf(entries);
380
- const stopped = reviseOf(entries);
381
- // A wrong grade of the answer its workflow gave alone (a `revise` feedback round this end closes): that workflow.
382
- const fed = pendingFeedbackOf(entries);
383
- const gradedOf = fed?.round === "revise" && fed.workflow ? fed.workflow : undefined;
384
- let revising = served?.outcome === "handed_back" ? served.workflow : (stopped?.workflow ?? gradedOf);
498
+ // A revision is asked only of a workflow its promotion holds, once per hold. One run is one sample: a hand-back, a wrong
499
+ // grade of a served answer or the money rule's stop asks for none; the hold, read over many runs, does.
385
500
  // The workflows whose newest revision other than their champion (learn/promote.ts championOf: it serves while that one
386
501
  // is held) is held: the run's own may be one (its champion served it, or it went by hand).
387
- const records = revising ? [] : await promotionsOf(deps.store.settings, input.agentId).catch(() => []);
502
+ const records = await promotionsOf(deps.store.settings, input.agentId).catch(() => []);
388
503
  const heldNames = heldNamesOf(records);
504
+ // The loop's numbers on the agent's definition (the revision this run runs): the first compile waits for compile_after
505
+ // completed agent runs, the ending one counted.
506
+ const { compile_after: compileAfter } = await loopOfRun(deps.store, input.runId);
389
507
  // The agent's latest runs, newest first: those after the ending one in the list started before it.
390
- const listed = await deps.store.runs.list({ agentId: input.agentId, limit: 200 });
508
+ const listed = await deps.store.runs.list({ agentId: input.agentId, limit: Math.max(200, 2 * compileAfter) });
391
509
  const at = listed.findIndex((run) => run.id === input.runId);
392
510
  const earlier = (at < 0 ? listed : listed.slice(at + 1)).filter((run) => run.agentId === input.agentId);
393
511
  const done = earlier.filter(completedRun);
394
- let compiledLately = false;
395
- const dueWith = (notes, workflows) => compileDue({ completed: input.outcome === "completed", notes, runs: Math.min(done.length, COMPILE_AFTER_RUNS) + (input.outcome === "completed" ? 1 : 0), workflows, compiledLately });
512
+ const byHand = (await lastOwnRuns(deps.store, input.agentId, compileAfter, input.runId)).length;
513
+ const dueWith = (workflows) => compileDue({ completed: input.outcome === "completed", runs: byHand + (input.outcome === "completed" ? 1 : 0), workflows, compileAfter });
396
514
  const compiledOf = (kept) => kept?.proposal?.compiled;
397
- // Every learning round a run kept: its newest, and each before it (a follow-up opened the run again after it).
398
- const roundsOf = async (runId) => {
399
- const newest = await deps.store.learning.proposal(runId).catch(() => undefined);
400
- if (!newest)
401
- return [];
402
- return [newest, ...(await Promise.all(Array.from({ length: Math.max(0, newest.round - 1) }, (_, i) => deps.store.learning.proposal(runId, i + 1).catch(() => undefined))))];
403
- };
404
- if (!revising) {
405
- // A compile in any learning round of the agent's last runs (a draft still waiting for its grade, or one that failed)
406
- // asks none now: a follow-up's round keeps no compile of its own, so a run's earlier rounds are read too.
407
- const lately = (await Promise.all(earlier.slice(0, COMPILE_QUIET_RUNS).map((run) => roundsOf(run.id)))).flat();
408
- compiledLately = lately.some((kept) => compiledOf(kept) !== undefined);
409
- // First by what the run started from (its seed's notes and the workflows it was offered): a run not due by them
410
- // opens no folder, unless one of its workflows is held. Main is read below for the turn itself, and decides again.
411
- if (!heldNames.size && !dueWith(input.seedNotes ?? 0, input.seedWorkflows ?? 0))
412
- return undefined;
413
- }
515
+ // Compile once: a recompile whose drafts failed their checks stopped the agent's new compiles (recordDraftFailed).
516
+ const stopped = compileStoppedOf(records);
517
+ // First by what the run started from (its seed's notes and the workflows it was offered): a run not due by them
518
+ // opens no folder, unless one of its workflows is held. Main is read below for the turn itself, and decides again.
519
+ if (!heldNames.size && (stopped || !dueWith(input.seedWorkflows ?? 0)))
520
+ return undefined;
414
521
  const dsl = await import("@parcha/agentrun-dsl");
415
522
  // Every text the turn is told passes the check a run's start makes (learning.ts holdsSecret, as chooseWorkflows reads a
416
523
  // learned workflow) over what the run must never learn (`refuse`): one that holds a secret is left out whole, never sent
@@ -432,24 +539,24 @@ export async function compileAskOf(deps, input) {
432
539
  leftOut.workflows.add(shown.name(name));
433
540
  return undefined;
434
541
  };
435
- let current = revising ? await textOf(revising) : undefined;
542
+ let current;
436
543
  let held;
437
- if (!revising && heldNames.size) {
544
+ if (heldNames.size) {
438
545
  // The one active workflow that fits the run's input (the one workflow-first would serve), held at main's digest.
439
546
  const active = [];
440
547
  for (const one of workflows)
441
- if (one.status === "active") {
548
+ if (one.status === "active" && heldNames.has(one.name)) {
442
549
  const text = await textOf(one.name);
443
550
  if (text !== undefined)
444
551
  active.push({ name: one.name, workflow: text });
445
552
  }
446
553
  const fitting = active.filter((one) => fits(one, input.input, dsl.resolveSchemaForWorkflow));
447
554
  const record = fitting.length === 1 ? promotionOf(records, fitting[0].name, workflowDigest(fitting[0])) : undefined;
448
- if (record?.decided === "hold")
555
+ if (record?.decided === "hold" && !record.check?.stopped && !record.audit?.stopped)
449
556
  [held, current] = [record, fitting[0].workflow];
450
557
  }
451
558
  // An agent with a learned workflow compiles nothing new: its notes' text is not read.
452
- if (!revising && !held && workflows.length)
559
+ if (!held && workflows.length)
453
560
  return { notes: [], workflows: workflows.length };
454
561
  const notes = [];
455
562
  for (const note of snapshot?.notes ?? []) {
@@ -476,9 +583,6 @@ export async function compileAskOf(deps, input) {
476
583
  if (parts.length)
477
584
  deps.log?.(`learning: run ${input.runId}: the compile turn left out what holds a secret: ${parts.join(", ")}`);
478
585
  };
479
- // A revision of a workflow main no longer holds (a person retired it), or whose text holds a secret, asks for none.
480
- if (revising && read.current === undefined)
481
- return sayLeftOut(), undefined;
482
586
  let held;
483
587
  if (read.held) {
484
588
  // Once per hold: a run since it that compiled this workflow asked already, whatever came of it (its revision is on its
@@ -488,11 +592,18 @@ export async function compileAskOf(deps, input) {
488
592
  const kept = await deps.store.learning.proposals(input.agentId, { limit: HELD_ASKED_READ }).catch(() => undefined);
489
593
  if (!kept || kept.some((one) => !(one.createdAt < since) && compiledOf(one)?.workflow === read.held.workflow))
490
594
  return sayLeftOut(), undefined;
491
- const { workflow, digest, source, reason, replay } = read.held;
492
- held = { workflow, digest, source, reason, ...(replay ? { replay: scoreOf(replay) } : {}) };
493
- revising = workflow;
595
+ const { workflow, digest, reason, check, audit } = read.held;
596
+ // A check's or an audit's disagreements are the agent's own inputs and answers: cut of the run's secrets as a trace is
597
+ // (traceFrom).
598
+ const cut = (text) => redactSecrets(text, input.refuse, Number.POSITIVE_INFINITY);
599
+ const checked = check ? { ...check, ...(check.disagreements ? { disagreements: check.disagreements.map((one) => ({ ...one, input: cut(one.input), agent: one.agent === null ? null : cut(one.agent), ...(one.draft !== undefined ? { draft: cut(one.draft) } : {}), ...(one.escalated !== undefined ? { escalated: cut(one.escalated) } : {}) })) } : {}) } : undefined;
600
+ const audited = audit ? { ...audit, disagreements: audit.disagreements.map((one) => ({ ...one, input: cut(one.input), agent: one.agent === null ? null : cut(one.agent), draft: one.draft === null ? null : cut(one.draft) })) } : undefined;
601
+ held = { workflow, digest, reason, ...(checked ? { check: checked } : {}), ...(audited ? { audit: audited } : {}) };
494
602
  }
495
- if (!revising && !dueWith(read.notes.length, read.workflows))
603
+ if (!held && (stopped || !dueWith(read.workflows)))
604
+ return sayLeftOut(), undefined;
605
+ // A new workflow is compiled once: not while the last compile's passing draft waits on its grade.
606
+ if (!held && (await draftAwaitingGrade(deps.store, input.agentId)))
496
607
  return sayLeftOut(), undefined;
497
608
  // An earlier run's trace is cut of each value it held (traceFrom); one that still holds a secret (a value in a call's
498
609
  // input spelled in JSON escapes, a shape the cut does not take) is left out whole.
@@ -507,19 +618,14 @@ export async function compileAskOf(deps, input) {
507
618
  const { tools, decisions, outputSchema, workflowAdapters, described: sdkCatalog } = await draftTools(deps, input.runId);
508
619
  const allowed = draftDecisionProviders(decisions);
509
620
  const judges = workflowAdapters !== undefined ? workflowAdapters.includes("runJudge") : allowed.length > 0;
510
- // Jev by default: a run that can call Jev (a decision provider its gate does not deny) asks every step for a guard it reads.
511
- const jev = workflowAdapters === undefined && allowed.includes("jev");
512
621
  const described = sdkCatalog ?? await describedOf(tools, deps.store);
513
622
  const object = input.input !== null && typeof input.input === "object" && !Array.isArray(input.input);
514
623
  leftOut.input = object && holds(input.input);
515
624
  const fields = object && !leftOut.input ? { input: input.input } : {};
516
625
  const bridge = workflowAdapters !== undefined ? { workflowAdapters } : {};
517
- const base = { ...bridge, reference: compileReference(dsl, { tools, judges, jev, ...bridge }), notes: read.notes, traces, tools, described, judges, jev, ...fields, ...(outputSchema !== undefined ? { outputSchema } : {}) };
518
- // A wrong grade of the answer its workflow gave alone: that answer and the grade's words, cut of the runner's secrets.
519
- const cut = (text) => redactSecrets(text, input.refuse, Number.POSITIVE_INFINITY);
520
- const graded = revising && gradedOf && fed ? { answer: cut(servedAnswerOf(entries)?.answer ?? ""), words: cut(fed.text) } : undefined;
626
+ const base = { ...bridge, reference: compileReference(dsl, { tools, judges, ...bridge }), notes: read.notes, traces, tools, described, judges, ...fields, ...(outputSchema !== undefined ? { outputSchema } : {}) };
521
627
  // A revision is of main's text as read here, whatever the run started from: that commit is its conflict base (`base`).
522
- const ask = !revising ? { mode: "new", ...base } : { mode: "revise", workflow: revising, current: read.current, ...(read.main ? { base: read.main } : {}), ...(served?.outcome === "handed_back" ? { handedBack: true } : stopped ? { revise: { workflow: stopped.workflow, served_usd: stopped.served_usd, by_hand_usd: stopped.by_hand_usd, runs: stopped.runs } } : graded ? { graded } : held ? { held } : {}), ...base };
628
+ const ask = !held ? { mode: "new", ...base } : { mode: "revise", workflow: held.workflow, current: read.current, ...(read.main ? { base: read.main } : {}), held, ...base };
523
629
  sayLeftOut();
524
630
  // Last, the prompt itself, whatever it is told now or later (a tool's description, the agent's output schema): one that
525
631
  // still holds a secret asks nothing.
@@ -3,7 +3,7 @@ import { type LearningLoopDeps } from "./learning-loop.js";
3
3
  import type { LoopFactory } from "./loop-contract.js";
4
4
  /** The harness a learning run's launch names (store/sqlite/run-patch.ts learningLaunchOf). */
5
5
  export declare const LEARNING_HARNESS = "learning";
6
- export interface LearningFactoryDeps extends Pick<LearningLoopDeps, "ask" | "now" | "general" | "generalThreshold"> {
6
+ export interface LearningFactoryDeps extends Pick<LearningLoopDeps, "ask" | "now"> {
7
7
  readonly store: Pick<Store, "runs" | "agents" | "learning">;
8
8
  /** The server's data directory: where each agent's learning folder is. */
9
9
  readonly data: string;
@@ -8,8 +8,7 @@
8
8
  // readMain main as the grader reads it, from the folder's snapshot (learn/commit.ts readMain);
9
9
  // commit the folder's one write (learn/commit.ts learningCommit);
10
10
  // merged the run's merge when it is on main already, with the texts its own commit holds (learn/commit.ts mergedAt),
11
- // for a resume after its commit;
12
- // general the generality pre-check (learn/general.ts), on this host's Jev, when it has one (passed in by the wiring).
11
+ // for a resume after its commit.
13
12
  import { learningCommit, mainTexts, mergedAt, readMain } from "../learn/commit.js";
14
13
  import { learningWorkspace } from "../learn/folder.js";
15
14
  import { createLearningLoop } from "./learning-loop.js";
@@ -46,8 +45,6 @@ export function learningLoopFactory(deps) {
46
45
  mainTexts: (ws, paths) => mainTexts(ws, paths),
47
46
  merged: (ws, runId, paths, round) => mergedAt(ws, runId, paths, round),
48
47
  ...(deps.now ? { now: deps.now } : {}),
49
- ...(deps.general ? { general: deps.general } : {}),
50
- ...(deps.generalThreshold !== undefined ? { generalThreshold: deps.generalThreshold } : {}),
51
48
  ...(deps.log ? { log: deps.log } : {}),
52
49
  });
53
50
  }
@@ -1,5 +1,4 @@
1
1
  import type { LearningProposal } from "../store/store.js";
2
- import { type GeneralScores, type GeneralSource } from "../learn/general.js";
3
2
  import { type IndexEntry, type NoteText, type Verdict } from "../learn/grade.js";
4
3
  import type { LearnedFile, NoteLearned, Tokens } from "../learning.js";
5
4
  import type { Journal, Loop, LoopDeps } from "./loop-contract.js";
@@ -66,14 +65,6 @@ export declare class GradeOverCap extends Error {
66
65
  /** `booked`: the grade's records when it was refused (GradeBooked), what it spent before it. */
67
66
  constructor(message: string, forGood: boolean, booked?: GradeBooked | undefined);
68
67
  }
69
- /** A generality check its learning run's cap refused before any of its requests left (learning-dispatch.ts general: its
70
- * worst case over the cap left): nothing of it was sent or spent, and it is skipped as `unchecked` "no_budget"
71
- * (GENERAL_NO_BUDGET), said so, the grader then judged against the cap on its own. `forGood`: no room could ever send it
72
- * (its provider's price unknown here), not only none now. */
73
- export declare class GeneralOverCap extends Error {
74
- readonly forGood: boolean;
75
- constructor(message: string, forGood: boolean);
76
- }
77
68
  /** The grade's own records after an ask (learning-ask.ts bookedAsk: its session's booking): what every grade request of
78
69
  * the learning run spent, an earlier attempt's included (null: unknown, as a cut one's), and how many left. What the
79
70
  * grade ends with is read from these, never summed in memory alone: a runner that restarted before the grade was saved
@@ -162,13 +153,10 @@ export interface LearningLoopDeps {
162
153
  readMain(ws: unknown, proposal: KeptProposal): Promise<GradeMain | {
163
154
  readonly problems: readonly Problem[];
164
155
  }>;
165
- /** One grader call, through the kernel's model proxy and the cap, booked to the agent's learning meter. `beside`: what
166
- * the grade spent outside its records, at most (the generality check's dollars, else its worst case), which the cap's
167
- * room for the call leaves out. */
156
+ /** One grader call, through the kernel's model proxy and the cap, booked to the agent's learning meter. */
168
157
  ask(request: {
169
158
  readonly prompt: string;
170
159
  readonly maxTokens: number;
171
- readonly beside?: number;
172
160
  }, signal: AbortSignal, run: GraderRun): Promise<{
173
161
  readonly text: unknown;
174
162
  readonly usd: number | null;
@@ -188,30 +176,18 @@ export interface LearningLoopDeps {
188
176
  } | undefined>;
189
177
  /** The clock (epoch ms), for a parked run's wake. */
190
178
  now?(): number;
191
- /** The generality pre-check (learn/general.ts): each proposed note's Jev probability that it holds for inputs other
192
- * than the one it came from, by file, and what it cost. Undefined, or one that answers undefined (no Jev key on this
193
- * host), skips it: every note goes to the grader. One that throws (Jev down) skips it too: what it spent is unknown, and
194
- * the skip is kept on the grade's entry (`unchecked`) and said in the log. `sending` is called once, before its first
195
- * paid request leaves, with their worst case under a cap (`held`): the loop marks the check sent there, durably
196
- * (journal-kinds.ts learningGeneralSent). Under a cap, `before` is what an earlier attempt's cut check may have spent
197
- * (its worst case), which the room for this one leaves out; one that doesn't fit throws GeneralOverCap, sending nothing. */
198
- general?(notes: readonly NoteText[], source: GeneralSource, signal: AbortSignal, run: string, sending?: (held?: number) => Promise<void>, before?: number): Promise<GeneralScores | undefined>;
199
- /** The bar a note's score must reach to go on to the grader (default GENERAL_THRESHOLD). */
200
- generalThreshold?: number;
201
179
  /** One line of the runner's log. */
202
180
  log?(line: string): void;
203
181
  }
204
182
  /** The journal's learning entries' data (journal-kinds.ts learningGraded, learningDropped, learningMerged), as the reader
205
183
  * of a run's learning end reads them (store-reads/learning.ts). What a grade spent: its dollars and tokens, each null when
206
- * any ask's are unknown. `unchecked`: why the generality pre-check could not run (its provider's error), so the grader read
207
- * every note; the run's learning end says the check was skipped. */
184
+ * any ask's are unknown. */
208
185
  export type GradedData = {
209
186
  readonly source: string;
210
187
  readonly verdict: Verdict;
211
188
  readonly usd: number | null;
212
189
  readonly tokens?: Tokens | null;
213
190
  readonly graded: Readonly<Record<string, string>>;
214
- readonly unchecked?: string;
215
191
  };
216
192
  export type DroppedData = {
217
193
  readonly source: string;
@@ -220,7 +196,6 @@ export type DroppedData = {
220
196
  readonly problems?: readonly Problem[];
221
197
  readonly usd?: number | null;
222
198
  readonly tokens?: Tokens | null;
223
- readonly unchecked?: string;
224
199
  };
225
200
  /** `verdict`: each item's final decision once the merge settled it (takenOnMain's and the commit's left-out notes dropped,
226
201
  * with their words), which the run's learning end reads in place of the grade's (store-reads/learning.ts). */
@@ -232,17 +207,6 @@ export type MergedData = {
232
207
  readonly detail: string;
233
208
  readonly verdict: Verdict;
234
209
  };
235
- /** The generality check's end (journal-kinds.ts learningGeneral): its scores, or why it could not run (GENERAL_NO_BUDGET:
236
- * no room under the cap), and what it spent (null once unknown: a request that failed, or one an earlier attempt sent and
237
- * a restart cut). `held`: under a cap, the most every attempt's requests may have spent (each sent mark's worst case), the
238
- * bound the grader's room leaves out when `usd` is unknown. */
239
- export type GeneralData = {
240
- readonly source: string;
241
- readonly scores?: Readonly<Record<string, number>>;
242
- readonly unchecked?: string;
243
- readonly usd: number | null;
244
- readonly held?: number;
245
- };
246
210
  /** The why of a note whose name main already holds with other text, which it does not supersede: never written over,
247
211
  * and the rest of what the run learned merges. */
248
212
  export declare const NOTE_NAME_TAKEN: (name: string) => string;