@parcha/agentrun-serve 0.1.0-beta.42 → 0.1.0-beta.44

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 (181) hide show
  1. package/CHANGELOG.md +126 -0
  2. package/README.md +221 -31
  3. package/dist/cli.js +42 -8
  4. package/dist/composio-preset.d.ts +4 -3
  5. package/dist/composio-preset.js +12 -4
  6. package/dist/composio-triggers.d.ts +20 -2
  7. package/dist/composio-triggers.js +183 -17
  8. package/dist/computer-lost.d.ts +11 -0
  9. package/dist/computer-lost.js +19 -0
  10. package/dist/computer-record.d.ts +10 -2
  11. package/dist/computer-record.js +50 -18
  12. package/dist/computer-setting.d.ts +1 -0
  13. package/dist/computer-setting.js +2 -2
  14. package/dist/console/assets/index-BUktRvS-.css +1 -0
  15. package/dist/console/assets/index-nB9kTfIN.js +711 -0
  16. package/dist/console/index.html +2 -2
  17. package/dist/decisions.js +0 -4
  18. package/dist/errors.d.ts +1 -0
  19. package/dist/errors.js +3 -0
  20. package/dist/harness-table.d.ts +51 -3
  21. package/dist/harness-table.js +101 -13
  22. package/dist/harness.d.ts +18 -1
  23. package/dist/harness.js +21 -9
  24. package/dist/host.d.ts +12 -10
  25. package/dist/host.js +18 -16
  26. package/dist/import-sources.js +25 -5
  27. package/dist/import-worker.d.ts +3 -0
  28. package/dist/import-worker.js +7 -5
  29. package/dist/import.d.ts +22 -1
  30. package/dist/import.js +141 -28
  31. package/dist/learn/audit.d.ts +123 -0
  32. package/dist/learn/audit.js +159 -0
  33. package/dist/learn/check.d.ts +3 -0
  34. package/dist/learn/check.js +1 -1
  35. package/dist/learn/compile.d.ts +50 -74
  36. package/dist/learn/compile.js +90 -124
  37. package/dist/learn/delete.d.ts +17 -0
  38. package/dist/learn/delete.js +44 -0
  39. package/dist/learn/folder.d.ts +9 -0
  40. package/dist/learn/folder.js +13 -2
  41. package/dist/learn/promote.d.ts +92 -200
  42. package/dist/learn/promote.js +65 -187
  43. package/dist/learn/replay-calls.d.ts +5 -0
  44. package/dist/learn/replay-calls.js +12 -1
  45. package/dist/learn/secrets.d.ts +8 -0
  46. package/dist/learn/secrets.js +12 -0
  47. package/dist/learn/skills.d.ts +4 -0
  48. package/dist/learn/skills.js +19 -5
  49. package/dist/learn/workflow-nodes.d.ts +23 -3
  50. package/dist/learn/workflow-nodes.js +30 -12
  51. package/dist/learned-nodes.d.ts +9 -34
  52. package/dist/learned-nodes.js +11 -23
  53. package/dist/learned-workflow.d.ts +6 -8
  54. package/dist/learned-workflow.js +18 -57
  55. package/dist/learning-batch.d.ts +13 -5
  56. package/dist/learning-batch.js +34 -8
  57. package/dist/learning-cost.d.ts +111 -4
  58. package/dist/learning-cost.js +120 -3
  59. package/dist/learning-evals.d.ts +2 -0
  60. package/dist/learning-evals.js +4 -3
  61. package/dist/learning-routes.d.ts +8 -0
  62. package/dist/learning-routes.js +18 -1
  63. package/dist/learning-setting.d.ts +16 -1
  64. package/dist/learning-setting.js +34 -2
  65. package/dist/learning.d.ts +1 -1
  66. package/dist/listen-first.d.ts +30 -0
  67. package/dist/listen-first.js +115 -0
  68. package/dist/llms.txt +2 -1
  69. package/dist/mcp-servers-store.d.ts +12 -12
  70. package/dist/model.d.ts +8 -4
  71. package/dist/model.js +16 -8
  72. package/dist/openapi.js +203 -87
  73. package/dist/owner.d.ts +8 -0
  74. package/dist/owner.js +11 -0
  75. package/dist/paid-calls.d.ts +6 -0
  76. package/dist/paid-calls.js +11 -1
  77. package/dist/place.d.ts +8 -3
  78. package/dist/place.js +13 -9
  79. package/dist/provider.js +15 -1
  80. package/dist/run-launch.d.ts +6 -3
  81. package/dist/run-launch.js +2 -0
  82. package/dist/run-learning-served.d.ts +1 -1
  83. package/dist/run-model-key.d.ts +64 -0
  84. package/dist/run-model-key.js +147 -0
  85. package/dist/runner/adapter-loop.d.ts +10 -0
  86. package/dist/runner/adapter-loop.js +26 -4
  87. package/dist/runner/adapter-run-spec.d.ts +6 -3
  88. package/dist/runner/adapter-run-spec.js +83 -25
  89. package/dist/runner/adapters/index.d.ts +4 -2
  90. package/dist/runner/adapters/index.js +13 -4
  91. package/dist/runner/audit.d.ts +68 -0
  92. package/dist/runner/audit.js +349 -0
  93. package/dist/runner/beside.d.ts +2 -1
  94. package/dist/runner/beside.js +6 -3
  95. package/dist/runner/claim-secrets.d.ts +49 -0
  96. package/dist/runner/claim-secrets.js +110 -1
  97. package/dist/runner/cli-run-spec.d.ts +2 -1
  98. package/dist/runner/cli-run-spec.js +44 -15
  99. package/dist/runner/commands.d.ts +3 -6
  100. package/dist/runner/feedback-round.d.ts +3 -2
  101. package/dist/runner/feedback-round.js +8 -7
  102. package/dist/runner/harness-loops.js +31 -23
  103. package/dist/runner/journal-kinds.d.ts +5 -7
  104. package/dist/runner/journal-kinds.js +0 -7
  105. package/dist/runner/learning-dispatch.d.ts +0 -16
  106. package/dist/runner/learning-dispatch.js +4 -47
  107. package/dist/runner/learning-end.d.ts +55 -13
  108. package/dist/runner/learning-end.js +128 -44
  109. package/dist/runner/learning-factory.d.ts +1 -1
  110. package/dist/runner/learning-factory.js +1 -4
  111. package/dist/runner/learning-loop.d.ts +2 -38
  112. package/dist/runner/learning-loop.js +8 -116
  113. package/dist/runner/loop-contract.d.ts +6 -0
  114. package/dist/runner/loop-contract.js +4 -0
  115. package/dist/runner/loop.js +6 -2
  116. package/dist/runner/main.d.ts +1 -0
  117. package/dist/runner/main.js +25 -8
  118. package/dist/runner/memory-claim.d.ts +9 -6
  119. package/dist/runner/memory-claim.js +12 -9
  120. package/dist/runner/promotion.d.ts +55 -54
  121. package/dist/runner/promotion.js +232 -585
  122. package/dist/runner/reflect-hook.d.ts +14 -0
  123. package/dist/runner/reflect-hook.js +28 -3
  124. package/dist/runner/runner.js +57 -4
  125. package/dist/runner/store-secrets.js +9 -5
  126. package/dist/runner/workflow-first.d.ts +6 -5
  127. package/dist/runner/workflow-first.js +17 -12
  128. package/dist/runner/workflow-spec.js +10 -2
  129. package/dist/runs-over-store.d.ts +5 -4
  130. package/dist/runs-over-store.js +13 -3
  131. package/dist/sdk/workflows.d.ts +1 -1
  132. package/dist/server.d.ts +64 -50
  133. package/dist/server.js +516 -134
  134. package/dist/store/index.d.ts +2 -2
  135. package/dist/store/index.js +1 -1
  136. package/dist/store/seal.d.ts +20 -2
  137. package/dist/store/seal.js +24 -8
  138. package/dist/store/sqlite/run-launch.d.ts +4 -1
  139. package/dist/store/sqlite/run-launch.js +12 -0
  140. package/dist/store/sqlite/store.d.ts +3 -2
  141. package/dist/store/sqlite/store.js +119 -16
  142. package/dist/store/store.d.ts +41 -3
  143. package/dist/store-reads/analytics.js +11 -1
  144. package/dist/store-reads/learning.d.ts +57 -7
  145. package/dist/store-reads/learning.js +194 -28
  146. package/dist/store-reads/loop.d.ts +4 -39
  147. package/dist/store-reads/loop.js +10 -79
  148. package/dist/store-reads/stats.js +13 -3
  149. package/dist/store-view.d.ts +5 -1
  150. package/dist/store-view.js +12 -1
  151. package/dist/telemetry.d.ts +59 -0
  152. package/dist/telemetry.js +153 -0
  153. package/dist/tool-keys-store.d.ts +1 -1
  154. package/dist/tool-keys.d.ts +2 -2
  155. package/dist/tool-plane.d.ts +12 -12
  156. package/dist/tools.d.ts +11 -11
  157. package/dist/tools.js +18 -5
  158. package/dist/trigger-adapter.d.ts +3 -0
  159. package/dist/trigger-adapters.d.ts +4 -0
  160. package/dist/trigger-adapters.js +13 -0
  161. package/dist/trigger-composio.d.ts +58 -1
  162. package/dist/trigger-composio.js +160 -6
  163. package/dist/triggers.d.ts +4 -0
  164. package/dist/triggers.js +22 -3
  165. package/dist/validate.d.ts +11 -7
  166. package/dist/validate.js +8 -7
  167. package/dist/workspace/computer-for-claim.d.ts +15 -5
  168. package/dist/workspace/computer-for-claim.js +228 -32
  169. package/dist/workspace/resolve-computer.d.ts +8 -2
  170. package/dist/workspace/resolve-computer.js +1 -1
  171. package/dist/workspace/run-tools.d.ts +1 -1
  172. package/dist/workspace/run-tools.js +14 -3
  173. package/package.json +10 -9
  174. package/dist/console/assets/index-C3gNPz58.css +0 -1
  175. package/dist/console/assets/index-DYJ_wj27.js +0 -711
  176. package/dist/learn/general.d.ts +0 -69
  177. package/dist/learn/general.js +0 -75
  178. package/dist/learn/refit.d.ts +0 -48
  179. package/dist/learn/refit.js +0 -264
  180. package/dist/runner/step-guard.d.ts +0 -62
  181. package/dist/runner/step-guard.js +0 -93
@@ -4,7 +4,7 @@ import { type CompileAsk, type CompileTrace } from "../learn/compile.js";
4
4
  import type { RunPath } from "../learning-cost.js";
5
5
  import { type RunLaunch } from "../run-launch.js";
6
6
  import { type SignInReader } from "../run-view.js";
7
- import type { Store } from "../store/store.js";
7
+ import { type AlsoRow, type Store } from "../store/store.js";
8
8
  import type { EndOfRunTurn } from "./loop-contract.js";
9
9
  /** What the step reads: the run's store, the data directory (the server's tool settings a draft's tools are read with),
10
10
  * the agent's learning folder (where the run's place keeps it), the runner's environment (the host's secrets a
@@ -35,17 +35,33 @@ export interface LearningEndDeps {
35
35
  } | undefined>;
36
36
  /** The runner's log: what the compile turn left out for holding a secret, by name and count, never a value. */
37
37
  readonly log?: (line: string) => void;
38
+ /** Why model spend beside the run is skipped (claim-secrets.ts claimSpendOff): its learning run's grade, which runs after
39
+ * the run's turn ended, is not queued then, in these words. Absent: it is queued. */
40
+ readonly spendOff?: (what: string) => string | undefined;
38
41
  }
39
42
  /** The end-of-run step for a run launched with `launch`: undefined when its launch records no learning start (a run that
40
43
  * does not learn is asked nothing and keeps nothing), else the reflect hook over the run's store. */
41
44
  export declare function learningEndOfRun(launch: RunLaunch, deps: LearningEndDeps): EndOfRunTurn | undefined;
42
45
  /** What every cap gate of run `runId` reads as spent beside it on its behalf (adapter-loop.ts RunCapConfig.beside): its
43
- * learning runs' grades (Store.learning.spentBeside, the one figure), for a capped run that learns, the only run whose
44
- * ends queue them; none for any other, whose gates read only its own sessions. */
45
- export declare function spentBesideOf(launch: RunLaunch, store: Pick<Store, "learning">, runId: string): (() => Promise<number | null>) | undefined;
46
+ * learning runs' grades and its audit's shadow run (besideOf), for a capped run with a learning start, the only run
47
+ * whose ends queue them (one that only uses what its agent learned queues no grade, but may start a shadow); none for any
48
+ * other, whose gates read only its own sessions. */
49
+ export declare function spentBesideOf(launch: RunLaunch, store: Pick<Store, "learning" | "runs">, runId: string): (() => Promise<number | null>) | undefined;
50
+ /** What was spent beside run `runId` on its behalf, the one figure its cap gates and its grades' caps read: its learning
51
+ * runs' grades (Store.learning.spentBeside; `beforeRound`: its earlier rounds' alone) and its audit's shadow run
52
+ * (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
53
+ * it has not (the most it may take) or when it ended at a cost not known, 0 when none was started. Null: unknown. */
54
+ export declare function besideOf(store: Pick<Store, "learning" | "runs">, runId: string, options?: {
55
+ beforeRound?: number;
56
+ }): Promise<number | null>;
57
+ /** 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
58
+ * (capNowOf: its newest raise's, else `launchCapUsd`), less what it spent under it (capSpendOf over `entries`, its
59
+ * journal: its job, its look-back, every grade an earlier round queued) and the cap of the grade this end queues
60
+ * (`queued`, the end's rows: it is not in the store until the end commits). Null when that spend is unknown. */
61
+ export declare function auditRoomOf(store: Pick<Store, "learning" | "runs">, runId: string, launchCapUsd: number, entries: readonly EntryLike[], queued: readonly AlsoRow[]): Promise<number | null>;
46
62
  /** What capped run `runId` has spent under its cap, as every gate of the run reads it: its sessions' booking as the kernel
47
63
  * cap counts it (metrics.ts bookedCapSpend over `entries`, its journal) and what was spent beside it on its behalf
48
- * (Learning.spentBeside; `beforeRound`: its earlier rounds' grades alone). Null when either is unknown.
64
+ * (besideOf: its grades, `beforeRound` its earlier rounds' alone, and its audit's shadow). Null when either is unknown.
49
65
  *
50
66
  * 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
51
67
  * 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
@@ -54,7 +70,7 @@ export declare function spentBesideOf(launch: RunLaunch, store: Pick<Store, "lea
54
70
  * unknown (a held figure is the cap's, never a charge). Only a request held at no figure (none is, under a cap) leaves
55
71
  * the spend itself unknown: then nothing more is sent under the cap, and the words say the spend is unknown, as the
56
72
  * kernel's unknownSpend refusal does, never "no room". */
57
- export declare function capSpendOf(store: Pick<Store, "learning">, runId: string, entries: readonly EntryLike[], beforeRound?: number): Promise<number | null>;
73
+ export declare function capSpendOf(store: Pick<Store, "learning" | "runs">, runId: string, entries: readonly EntryLike[], beforeRound?: number): Promise<number | null>;
58
74
  /** The cap the grade of round `round` of run `runId` runs under (its learning run's max_cost_usd), so the run's grades
59
75
  * never take it past its cap: the cap the run is held to now (capNowOf: its newest raise's, else `launchCapUsd`), less
60
76
  * what the run spent under it (its job, its follow-ups and every look-back) and what was spent beside it on its behalf by
@@ -62,6 +78,17 @@ export declare function capSpendOf(store: Pick<Store, "learning">, runId: string
62
78
  * when that spend is unknown, or a read fails: the grade is then not run, said so (said.gradeUnknownSpend), never run
63
79
  * with a room nobody knows and never told it has none. */
64
80
  export declare function gradeCapOf(store: Store, runId: string, round: number, launchCapUsd: number): Promise<number | null>;
81
+ /** A workflow text written straight onto the agent's learning folder as a merge by `runId`, from the claim's `seed`: the
82
+ * one direct commit a runner makes outside a learning run (a compile turn's revision). A file changed on main since the
83
+ * seed is a conflict, never written over. The learning commit it landed as, or null when it did not (the reason is
84
+ * logged). The folder is always released. */
85
+ export declare function commitDirect(deps: {
86
+ readonly folder: () => LearningFolder;
87
+ readonly log: (line: string) => void;
88
+ }, files: {
89
+ path: string;
90
+ text: string;
91
+ }[], reason: string, runId: string, seed?: string): Promise<string | null>;
65
92
  /** The learning run of round `round` of run `runId`'s learning: `<runId>-learning` for its first, `<runId>-learning-<n>`
66
93
  * for each later one. */
67
94
  export declare const learningRunIdOf: (runId: string, round?: number) => string;
@@ -98,6 +125,20 @@ export declare function workflowNameOf(calls: readonly {
98
125
  tool: string;
99
126
  args: Record<string, unknown>;
100
127
  }[]): string | null;
128
+ /** Compile once: run `runId`'s compile turn whose drafts all failed their checks is the compile's attempt, kept as a
129
+ * promotion record of the shape a check's stop has (runner/promotion.ts stopUnchecked): a hold with nothing checked,
130
+ * its reason (DRAFT_FAILED) naming the failed checks. A first compile's earns the one recompile, as a check's hold
131
+ * does (the agent's next due run compiles once more: learn/compile.ts newCompileAttempt); a recompile's (a revision of
132
+ * a held workflow, or a new one after a first compile's failed drafts) stops (compileStoppedOf, heldNamesOf): nothing
133
+ * compiles it again. One record per run (its digest is the run's), written once: a claim that ends the run again
134
+ * writes none. */
135
+ export declare function recordDraftFailed(deps: Pick<LearningEndDeps, "store" | "log">, input: {
136
+ runId: string;
137
+ agentId: string;
138
+ compile: CompileAsk;
139
+ workflow: string;
140
+ errors: readonly string[];
141
+ }): Promise<void>;
101
142
  /** One earlier run as the compile turn reads it (learn/compile.ts CompileTrace), from its timeline (traceFrom). */
102
143
  export declare function traceOf(store: Store, runId: string, refuse: readonly string[]): Promise<CompileTrace>;
103
144
  /** A run's trace from its timeline rows, the end-of-run turn's (LEARNING_LABEL) left out: its first message (the
@@ -108,13 +149,14 @@ export declare function traceOf(store: Store, runId: string, refuse: readonly st
108
149
  * shape. */
109
150
  export declare function traceFrom(timeline: readonly TimelineEvent[], refuse: readonly string[]): CompileTrace;
110
151
  /** The compile turn's facts for run `runId` of agent `agentId` (learn/compile.ts): a revision of the learned workflow
111
- * that fits the run's input and whose promotion holds it at main's digest (runner/promotion.ts: its replay on the
112
- * agent's graded inputs, or its graded served runs, fell under the bar; its champion served the run, or the agent did by
113
- * hand), its text as main holds it, with the hold's numbers, once per hold (none when any run since the hold compiled
114
- * it, read from the agent's kept learning; a check's hold with the inputs it disagreed on, a stopped check's none);
115
- * else, when the job is due (compileDue: the run completed, the agent has no learned workflow active or waiting, none
116
- * of its last COMPILE_QUIET_RUNS runs compiled, and it has its definition's compile_after completed agent runs), a new
117
- * one. Nothing else asks one: a hand-back, a wrong grade of a served answer and the money rule's
152
+ * that fits the run's input and whose promotion holds it at main's digest (runner/promotion.ts: its one check on the
153
+ * agent's own runs fell under the bar; its champion served the run, or the agent did by hand), its text as main holds
154
+ * it, with the check's numbers and the inputs it disagreed on, once per hold (none when any run since the hold compiled
155
+ * it, read from the agent's kept learning; a stopped check's none); else, when the job is due (compileDue: the run
156
+ * completed, the agent has no learned workflow active or waiting, and it has its definition's compile_after completed
157
+ * agent runs), a new one, compiled once: none while the last compile's passing draft waits on its grade
158
+ * (draftAwaitingGrade), one more after a first compile whose drafts all failed their checks, and none after a
159
+ * recompile's (recordDraftFailed). Nothing else asks one: a hand-back, a wrong grade of a served answer and the money rule's
118
160
  * stop are single runs, which the hold reads among many. Either way the
119
161
  * agent's active notes whole, the traces of its last COMPILE_TRACES completed runs before this one, the tools a call node
120
162
  * may run (draftTools) with what each takes and gives, its decision providers, the run's input (`input`, its fields for
@@ -24,20 +24,22 @@
24
24
  // runner's run has no door token: its loop runs in the runner's process.
25
25
  // A proposal queues the learning run (learning_run), which the runner's dispatch runs on the learning loop
26
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";
27
28
  import { mkdtemp, readFile, rm } from "node:fs/promises";
28
29
  import { tmpdir } from "node:os";
29
30
  import { join } from "node:path";
30
31
  import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
31
32
  import { isMessageRow } from "../timeline/index.js";
32
33
  import { Hearing } from "../heard.js";
34
+ import { learningCommit } from "../learn/commit.js";
33
35
  import { readLearning, readSnapshot } from "../learn/folder.js";
34
- import { completedRun, lastOwnRuns, compileDue, compilePrompt, compileReference, COMPILE_QUIET_RUNS, COMPILE_TRACES, heldNamesOf } from "../learn/compile.js";
36
+ import { completedRun, compileStoppedOf, lastOwnRuns, compileDue, compilePrompt, compileReference, COMPILE_TRACES, DRAFT_FAILED, heldNamesOf, newCompileAttempt } from "../learn/compile.js";
35
37
  import { loopOf } from "../learning-setting.js";
36
- import { promotionOf, promotionsOf, scoreOf } from "../learn/promote.js";
38
+ import { CHECK_TEXT_MAX, promotionOf, promotionsOf, recordPromotion } from "../learn/promote.js";
37
39
  import { draftDecisionProviders } from "../learn/skills.js";
38
40
  import { DECISION_PROVIDER_KEYS } from "../tool-plane.js";
39
41
  import { handedValuesOf } from "../handed-values.js";
40
- import { MIN_SECRET, redactSecrets } from "../learn/secrets.js";
42
+ import { excerptShown, MIN_SECRET, redactSecrets } from "../learn/secrets.js";
41
43
  import { LEARNED_WORKFLOW_TOOL } from "../learned-workflow.js";
42
44
  import { META_TOOLS } from "../meta-tool-names.js";
43
45
  import { holdsSecret, LEARNING_LABEL, PROPOSAL, secretsShown } from "../learning.js";
@@ -46,6 +48,8 @@ import { said, STOPPED } from "../learning-words.js";
46
48
  import { proposeRun } from "../propose.js";
47
49
  import { learningStartOf, readLaunchBody, seedFailed } from "../run-launch.js";
48
50
  import { costOf } from "../run-view.js";
51
+ import { FINAL_STATES } from "../store/store.js";
52
+ import { shadowRunId } from "../learn/audit.js";
49
53
  import { getMcpServer } from "../mcp-store.js";
50
54
  import { readApprovers } from "../server-approvers.js";
51
55
  import { runEntries, runReflect, runTimeline, withFeedback, withoutFeedbackRounds } from "../store-reads/journal.js";
@@ -67,16 +71,20 @@ export function learningEndOfRun(launch, deps) {
67
71
  const env = deps.env ?? process.env;
68
72
  // The grade model the server named at the run's start (its learning start's), none: the agent's own grades it.
69
73
  const gradeModel = start.gradeModel;
74
+ // The learning run's grade runs after the run's turn ended: never on a run's own key (erased with that end), and never
75
+ // on none.
76
+ const gradeOff = deps.spendOff ? () => deps.spendOff?.("The learning run's grade") : undefined;
70
77
  const hookFor = (runId, round, before) => createReflectHook({
71
78
  round,
79
+ ...(gradeOff ? { gradeOff } : {}),
72
80
  ...(before ? { before } : {}),
73
81
  // reflectSkip's facts: a run its cap stopped has no room left, and one whose spend is unknown under a cap cannot be
74
82
  // kept within it. The cap is the run's now (capNowOf: its newest raise's, else its launch's), the one its requests
75
83
  // were admitted under, never the launch's alone. A person's stop comes to the hook as its `cut`.
76
84
  // Its spend under that cap is what the run's own gates read (capSpendOf: a request with no price of its own at the
77
85
  // figure it was held at), never the cost a person is shown, which is unknown once one request's is. What its earlier
78
- // rounds' grades took beside it counts toward that cap as its own spend does (Learning.spentBeside, the figure its
79
- // gates read). Either unknown: the spend is unknown, said so, never read as the whole cap.
86
+ // rounds' grades and its audit's shadow took beside it counts toward that cap as its own spend does (besideOf, the
87
+ // figure its gates read). Either unknown: the spend is unknown, said so, never read as the whole cap.
80
88
  facts: async (runId) => {
81
89
  const [rows, entries] = await Promise.all([
82
90
  runTimeline(deps.store, runId, BACKGROUND_CONTEXT, { settled: false }),
@@ -106,6 +114,7 @@ export function learningEndOfRun(launch, deps) {
106
114
  // workflows looks back only on its owner's feedback (ownerSaid).
107
115
  ...(start.notesOnly ? {} : {
108
116
  compileFacts: (input) => compileAskOf(deps, { ...input, input: launch.input, seedWorkflows: start.workflows?.length ?? 0 }),
117
+ compileFailed: (input) => recordDraftFailed(deps, input),
109
118
  ownerSaid: async (runId) => {
110
119
  const [entries, rows] = await Promise.all([runEntries(deps.store, runId, BACKGROUND_CONTEXT), runTimeline(deps.store, runId, BACKGROUND_CONTEXT, { settled: false })]);
111
120
  return ownerSaid(entries, rows);
@@ -177,17 +186,46 @@ export function learningEndOfRun(launch, deps) {
177
186
  };
178
187
  }
179
188
  /** What every cap gate of run `runId` reads as spent beside it on its behalf (adapter-loop.ts RunCapConfig.beside): its
180
- * learning runs' grades (Store.learning.spentBeside, the one figure), for a capped run that learns, the only run whose
181
- * ends queue them; none for any other, whose gates read only its own sessions. */
189
+ * learning runs' grades and its audit's shadow run (besideOf), for a capped run with a learning start, the only run
190
+ * whose ends queue them (one that only uses what its agent learned queues no grade, but may start a shadow); none for any
191
+ * other, whose gates read only its own sessions. */
182
192
  export function spentBesideOf(launch, store, runId) {
183
- const start = learningStartOf(launch);
184
- if (launch.maxCostUsd === undefined || !start || start.use)
193
+ if (launch.maxCostUsd === undefined || !learningStartOf(launch))
185
194
  return undefined;
186
- return () => store.learning.spentBeside(runId);
195
+ return () => besideOf(store, runId);
196
+ }
197
+ /** What was spent beside run `runId` on its behalf, the one figure its cap gates and its grades' caps read: its learning
198
+ * runs' grades (Store.learning.spentBeside; `beforeRound`: its earlier rounds' alone) and its audit's shadow run
199
+ * (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
200
+ * it has not (the most it may take) or when it ended at a cost not known, 0 when none was started. Null: unknown. */
201
+ export async function besideOf(store, runId, options = {}) {
202
+ const [grades, shadow] = await Promise.all([store.learning.spentBeside(runId, options), shadowBesideOf(store, runId)]);
203
+ return grades === null || shadow === null ? null : grades + shadow;
204
+ }
205
+ async function shadowBesideOf(store, runId) {
206
+ const id = shadowRunId(runId);
207
+ const shadow = await store.runs.get(id);
208
+ if (!shadow)
209
+ return 0;
210
+ const figure = (usd) => typeof usd === "number" && Number.isFinite(usd) && usd >= 0;
211
+ if (FINAL_STATES.includes(shadow.state) && figure(shadow.costUsd))
212
+ return shadow.costUsd;
213
+ const cap = readLaunchBody((await store.runs.launch(id)).body)?.maxCostUsd;
214
+ return figure(cap) ? cap : null;
215
+ }
216
+ /** 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
217
+ * (capNowOf: its newest raise's, else `launchCapUsd`), less what it spent under it (capSpendOf over `entries`, its
218
+ * journal: its job, its look-back, every grade an earlier round queued) and the cap of the grade this end queues
219
+ * (`queued`, the end's rows: it is not in the store until the end commits). Null when that spend is unknown. */
220
+ export async function auditRoomOf(store, runId, launchCapUsd, entries, queued) {
221
+ const capUsd = capNowOf(launchCapUsd, entries);
222
+ const spent = await capSpendOf(store, runId, entries);
223
+ const grade = queued.find((row) => row.table === "learning_run")?.row.capUsd ?? 0;
224
+ return spent === null ? null : capUsd - spent - grade;
187
225
  }
188
226
  /** What capped run `runId` has spent under its cap, as every gate of the run reads it: its sessions' booking as the kernel
189
227
  * cap counts it (metrics.ts bookedCapSpend over `entries`, its journal) and what was spent beside it on its behalf
190
- * (Learning.spentBeside; `beforeRound`: its earlier rounds' grades alone). Null when either is unknown.
228
+ * (besideOf: its grades, `beforeRound` its earlier rounds' alone, and its audit's shadow). Null when either is unknown.
191
229
  *
192
230
  * 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
193
231
  * 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
@@ -200,7 +238,7 @@ export async function capSpendOf(store, runId, entries, beforeRound) {
200
238
  const spent = bookedCapSpend(entries);
201
239
  if (spent === null)
202
240
  return null;
203
- const beside = await store.learning.spentBeside(runId, beforeRound === undefined ? {} : { beforeRound });
241
+ const beside = await besideOf(store, runId, beforeRound === undefined ? {} : { beforeRound });
204
242
  return beside === null ? null : spent + beside;
205
243
  }
206
244
  /** The cap the grade of round `round` of run `runId` runs under (its learning run's max_cost_usd), so the run's grades
@@ -220,6 +258,22 @@ export async function gradeCapOf(store, runId, round, launchCapUsd) {
220
258
  return null;
221
259
  }
222
260
  }
261
+ /** A workflow text written straight onto the agent's learning folder as a merge by `runId`, from the claim's `seed`: the
262
+ * one direct commit a runner makes outside a learning run (a compile turn's revision). A file changed on main since the
263
+ * seed is a conflict, never written over. The learning commit it landed as, or null when it did not (the reason is
264
+ * logged). The folder is always released. */
265
+ export async function commitDirect(deps, files, reason, runId, seed) {
266
+ const folder = deps.folder();
267
+ try {
268
+ const done = await learningCommit(folder.workspace, { kind: "merge", runId, reason, files, graded: {}, ...(seed ? { seed } : {}) });
269
+ if (!done.ok)
270
+ deps.log(`learning: a direct commit could not be written (${done.reason})`);
271
+ return done.ok ? done.commit : null;
272
+ }
273
+ finally {
274
+ await folder.end();
275
+ }
276
+ }
223
277
  /** The learning run of round `round` of run `runId`'s learning: `<runId>-learning` for its first, `<runId>-learning-<n>`
224
278
  * for each later one. */
225
279
  export const learningRunIdOf = (runId, round = 1) => (round > 1 ? `${runId}-learning-${round}` : `${runId}-learning`);
@@ -368,6 +422,42 @@ async function loopOfRun(store, runId) {
368
422
  return loopOf(undefined);
369
423
  }
370
424
  }
425
+ /** Compile once: run `runId`'s compile turn whose drafts all failed their checks is the compile's attempt, kept as a
426
+ * promotion record of the shape a check's stop has (runner/promotion.ts stopUnchecked): a hold with nothing checked,
427
+ * its reason (DRAFT_FAILED) naming the failed checks. A first compile's earns the one recompile, as a check's hold
428
+ * does (the agent's next due run compiles once more: learn/compile.ts newCompileAttempt); a recompile's (a revision of
429
+ * a held workflow, or a new one after a first compile's failed drafts) stops (compileStoppedOf, heldNamesOf): nothing
430
+ * compiles it again. One record per run (its digest is the run's), written once: a claim that ends the run again
431
+ * writes none. */
432
+ export async function recordDraftFailed(deps, input) {
433
+ try {
434
+ const records = await promotionsOf(deps.store.settings, input.agentId);
435
+ const attempt = input.compile.mode === "revise" ? 2 : newCompileAttempt(records);
436
+ const { compile_after, agree_min, alone_min } = await loopOfRun(deps.store, input.runId);
437
+ const workflow = input.compile.mode === "revise" ? input.compile.workflow : input.workflow;
438
+ const digest = createHash("sha256").update(`draft-failed\n${input.runId}`).digest("hex").slice(0, 16);
439
+ const failed = input.errors.join("; ").slice(0, CHECK_TEXT_MAX) || "no draft passed";
440
+ 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"}`;
441
+ const check = { compile_after, agree_min, alone_min, attempt, n: 0, agreed: 0, alone: 0, of: [], ...(attempt === 2 ? { stopped: true } : {}) };
442
+ const kept = await recordPromotion(deps.store.settings, input.agentId, { workflow, digest, at: new Date().toISOString(), decided: "hold", reason, check }, (was) => was === undefined);
443
+ if (kept.won)
444
+ deps.log?.(`learning: run ${input.runId}: the compile of ${workflow} failed its checks (attempt ${attempt}${attempt === 2 ? ", stopped" : ""})`);
445
+ }
446
+ catch (error) {
447
+ deps.log?.(`learning: run ${input.runId}: the compile's failed drafts were not recorded: ${error instanceof Error ? error.message : String(error)}`);
448
+ }
449
+ }
450
+ /** Whether a new workflow's compile is waiting on its grade: a run's kept learning carries a draft that passed its
451
+ * checks (a compiled digest) whose learning run, which grades and merges it, has not ended. It is the compile: none
452
+ * is asked until it lands (a learned workflow then) or is dropped. Read from the agent's kept learning whose grade has
453
+ * not ended (Learning.grading: every one, however many runs kept learning since, never a window of the newest); one
454
+ * that can't be read waits. */
455
+ async function draftAwaitingGrade(store, agentId) {
456
+ const grading = await store.learning.grading(agentId).catch(() => undefined);
457
+ if (!grading)
458
+ return true;
459
+ return grading.some((one) => typeof one.proposal?.compiled?.digest === "string");
460
+ }
371
461
  /** 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. */
372
462
  const TRACE_CALLS = 20;
373
463
  const TRACE_TEXT = 600;
@@ -383,7 +473,8 @@ export async function traceOf(store, runId, refuse) {
383
473
  * shape. */
384
474
  export function traceFrom(timeline, refuse) {
385
475
  const rows = withoutFeedbackRounds(timeline).filter((row) => row.agent_label !== LEARNING_LABEL);
386
- const cut = (text) => redactSecrets(String(text ?? ""), refuse, Number.POSITIVE_INFINITY).replace(/\s+/g, " ").trim().slice(0, TRACE_TEXT);
476
+ const shown = { text: (text) => redactSecrets(text, refuse, Number.POSITIVE_INFINITY).replace(/\s+/g, " ").trim() };
477
+ const cut = (text) => excerptShown(String(text ?? ""), shown, TRACE_TEXT);
387
478
  const messages = rows.filter(isMessageRow);
388
479
  const failed = new Set(rows.filter((row) => row.kind === "tool_result" && row.tool_status === "failed").map((row) => row.tool_use_id));
389
480
  const models = modelsOwn(rows);
@@ -393,13 +484,14 @@ export function traceFrom(timeline, refuse) {
393
484
  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)) };
394
485
  }
395
486
  /** The compile turn's facts for run `runId` of agent `agentId` (learn/compile.ts): a revision of the learned workflow
396
- * that fits the run's input and whose promotion holds it at main's digest (runner/promotion.ts: its replay on the
397
- * agent's graded inputs, or its graded served runs, fell under the bar; its champion served the run, or the agent did by
398
- * hand), its text as main holds it, with the hold's numbers, once per hold (none when any run since the hold compiled
399
- * it, read from the agent's kept learning; a check's hold with the inputs it disagreed on, a stopped check's none);
400
- * else, when the job is due (compileDue: the run completed, the agent has no learned workflow active or waiting, none
401
- * of its last COMPILE_QUIET_RUNS runs compiled, and it has its definition's compile_after completed agent runs), a new
402
- * one. Nothing else asks one: a hand-back, a wrong grade of a served answer and the money rule's
487
+ * that fits the run's input and whose promotion holds it at main's digest (runner/promotion.ts: its one check on the
488
+ * agent's own runs fell under the bar; its champion served the run, or the agent did by hand), its text as main holds
489
+ * it, with the check's numbers and the inputs it disagreed on, once per hold (none when any run since the hold compiled
490
+ * it, read from the agent's kept learning; a stopped check's none); else, when the job is due (compileDue: the run
491
+ * completed, the agent has no learned workflow active or waiting, and it has its definition's compile_after completed
492
+ * agent runs), a new one, compiled once: none while the last compile's passing draft waits on its grade
493
+ * (draftAwaitingGrade), one more after a first compile whose drafts all failed their checks, and none after a
494
+ * recompile's (recordDraftFailed). Nothing else asks one: a hand-back, a wrong grade of a served answer and the money rule's
403
495
  * stop are single runs, which the hold reads among many. Either way the
404
496
  * agent's active notes whole, the traces of its last COMPILE_TRACES completed runs before this one, the tools a call node
405
497
  * may run (draftTools) with what each takes and gives, its decision providers, the run's input (`input`, its fields for
@@ -408,8 +500,7 @@ export function traceFrom(timeline, refuse) {
408
500
  * when the folder can't be read. */
409
501
  export async function compileAskOf(deps, input) {
410
502
  // A revision is asked only of a workflow its promotion holds, once per hold. One run is one sample: a hand-back, a wrong
411
- // grade of a served answer or the money rule's stop asks for none (with a 10-15% base error rate on both sides, one
412
- // wrong answer says nothing about the workflow); the hold, read over many runs, does.
503
+ // grade of a served answer or the money rule's stop asks for none; the hold, read over many runs, does.
413
504
  // The workflows whose newest revision other than their champion (learn/promote.ts championOf: it serves while that one
414
505
  // is held) is held: the run's own may be one (its champion served it, or it went by hand).
415
506
  const records = await promotionsOf(deps.store.settings, input.agentId).catch(() => []);
@@ -418,28 +509,18 @@ export async function compileAskOf(deps, input) {
418
509
  // completed agent runs, the ending one counted.
419
510
  const { compile_after: compileAfter } = await loopOfRun(deps.store, input.runId);
420
511
  // The agent's latest runs, newest first: those after the ending one in the list started before it.
421
- const listed = await deps.store.runs.list({ agentId: input.agentId, limit: Math.max(200, 2 * compileAfter + COMPILE_QUIET_RUNS) });
512
+ const listed = await deps.store.runs.list({ agentId: input.agentId, limit: Math.max(200, 2 * compileAfter) });
422
513
  const at = listed.findIndex((run) => run.id === input.runId);
423
514
  const earlier = (at < 0 ? listed : listed.slice(at + 1)).filter((run) => run.agentId === input.agentId);
424
515
  const done = earlier.filter(completedRun);
425
516
  const byHand = (await lastOwnRuns(deps.store, input.agentId, compileAfter, input.runId)).length;
426
- let compiledLately = false;
427
- const dueWith = (workflows) => compileDue({ completed: input.outcome === "completed", runs: byHand + (input.outcome === "completed" ? 1 : 0), workflows, compiledLately, compileAfter });
517
+ const dueWith = (workflows) => compileDue({ completed: input.outcome === "completed", runs: byHand + (input.outcome === "completed" ? 1 : 0), workflows, compileAfter });
428
518
  const compiledOf = (kept) => kept?.proposal?.compiled;
429
- // Every learning round a run kept: its newest, and each before it (a follow-up opened the run again after it).
430
- const roundsOf = async (runId) => {
431
- const newest = await deps.store.learning.proposal(runId).catch(() => undefined);
432
- if (!newest)
433
- return [];
434
- return [newest, ...(await Promise.all(Array.from({ length: Math.max(0, newest.round - 1) }, (_, i) => deps.store.learning.proposal(runId, i + 1).catch(() => undefined))))];
435
- };
436
- // A compile in any learning round of the agent's last runs (a draft still waiting for its grade, or one that failed)
437
- // asks no new one now: a follow-up's round keeps no compile of its own, so a run's earlier rounds are read too.
438
- const lately = (await Promise.all(earlier.slice(0, COMPILE_QUIET_RUNS).map((run) => roundsOf(run.id)))).flat();
439
- compiledLately = lately.some((kept) => compiledOf(kept) !== undefined);
519
+ // Compile once: a recompile whose drafts failed their checks stopped the agent's new compiles (recordDraftFailed).
520
+ const stopped = compileStoppedOf(records);
440
521
  // First by what the run started from (its seed's notes and the workflows it was offered): a run not due by them
441
522
  // opens no folder, unless one of its workflows is held. Main is read below for the turn itself, and decides again.
442
- if (!heldNames.size && !dueWith(input.seedWorkflows ?? 0))
523
+ if (!heldNames.size && (stopped || !dueWith(input.seedWorkflows ?? 0)))
443
524
  return undefined;
444
525
  const dsl = await import("@parcha/agentrun-dsl");
445
526
  // Every text the turn is told passes the check a run's start makes (learning.ts holdsSecret, as chooseWorkflows reads a
@@ -475,7 +556,7 @@ export async function compileAskOf(deps, input) {
475
556
  }
476
557
  const fitting = active.filter((one) => fits(one, input.input, dsl.resolveSchemaForWorkflow));
477
558
  const record = fitting.length === 1 ? promotionOf(records, fitting[0].name, workflowDigest(fitting[0])) : undefined;
478
- if (record?.decided === "hold")
559
+ if (record?.decided === "hold" && !record.check?.stopped && !record.audit?.stopped)
479
560
  [held, current] = [record, fitting[0].workflow];
480
561
  }
481
562
  // An agent with a learned workflow compiles nothing new: its notes' text is not read.
@@ -515,13 +596,18 @@ export async function compileAskOf(deps, input) {
515
596
  const kept = await deps.store.learning.proposals(input.agentId, { limit: HELD_ASKED_READ }).catch(() => undefined);
516
597
  if (!kept || kept.some((one) => !(one.createdAt < since) && compiledOf(one)?.workflow === read.held.workflow))
517
598
  return sayLeftOut(), undefined;
518
- const { workflow, digest, source, reason, replay, check } = read.held;
519
- // A check's disagreements are the agent's own inputs and answers: cut of the run's secrets as a trace is (traceFrom).
599
+ const { workflow, digest, reason, check, audit } = read.held;
600
+ // 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
601
+ // (traceFrom).
520
602
  const cut = (text) => redactSecrets(text, input.refuse, Number.POSITIVE_INFINITY);
521
603
  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;
522
- held = { workflow, digest, source, reason, ...(replay ? { replay: scoreOf(replay) } : {}), ...(checked ? { check: checked } : {}) };
604
+ 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;
605
+ held = { workflow, digest, reason, ...(checked ? { check: checked } : {}), ...(audited ? { audit: audited } : {}) };
523
606
  }
524
- if (!held && !dueWith(read.workflows))
607
+ if (!held && (stopped || !dueWith(read.workflows)))
608
+ return sayLeftOut(), undefined;
609
+ // A new workflow is compiled once: not while the last compile's passing draft waits on its grade.
610
+ if (!held && (await draftAwaitingGrade(deps.store, input.agentId)))
525
611
  return sayLeftOut(), undefined;
526
612
  // 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
527
613
  // input spelled in JSON escapes, a shape the cut does not take) is left out whole.
@@ -536,8 +622,6 @@ export async function compileAskOf(deps, input) {
536
622
  const { tools, decisions, outputSchema, workflowAdapters, described: sdkCatalog } = await draftTools(deps, input.runId);
537
623
  const allowed = draftDecisionProviders(decisions);
538
624
  const judges = workflowAdapters !== undefined ? workflowAdapters.includes("runJudge") : allowed.length > 0;
539
- // No Jev by default: a draft's steps are asked for no Jev guard, whether or not the run can call Jev (per-step Jev guards
540
- // gave no judgment that moved a served answer; a check in code does that job).
541
625
  const described = sdkCatalog ?? await describedOf(tools, deps.store);
542
626
  const object = input.input !== null && typeof input.input === "object" && !Array.isArray(input.input);
543
627
  leftOut.input = object && holds(input.input);
@@ -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;