@parcha/agentrun-serve 0.1.0-beta.42 → 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 (81) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +8 -7
  3. package/dist/console/assets/index-BrcDSBD8.css +1 -0
  4. package/dist/console/assets/{index-DYJ_wj27.js → index-Bz6IWncl.js} +186 -186
  5. package/dist/console/index.html +2 -2
  6. package/dist/decisions.js +0 -4
  7. package/dist/import-sources.js +25 -5
  8. package/dist/learn/audit.d.ts +123 -0
  9. package/dist/learn/audit.js +159 -0
  10. package/dist/learn/compile.d.ts +50 -74
  11. package/dist/learn/compile.js +90 -124
  12. package/dist/learn/folder.d.ts +9 -0
  13. package/dist/learn/folder.js +13 -2
  14. package/dist/learn/promote.d.ts +86 -200
  15. package/dist/learn/promote.js +57 -183
  16. package/dist/learn/replay-calls.d.ts +5 -0
  17. package/dist/learn/replay-calls.js +12 -1
  18. package/dist/learn/secrets.d.ts +8 -0
  19. package/dist/learn/secrets.js +12 -0
  20. package/dist/learn/skills.js +2 -4
  21. package/dist/learn/workflow-nodes.d.ts +1 -2
  22. package/dist/learn/workflow-nodes.js +2 -3
  23. package/dist/learned-nodes.d.ts +9 -34
  24. package/dist/learned-nodes.js +11 -23
  25. package/dist/learned-workflow.d.ts +6 -8
  26. package/dist/learned-workflow.js +18 -57
  27. package/dist/learning-batch.d.ts +13 -5
  28. package/dist/learning-batch.js +34 -8
  29. package/dist/learning-cost.d.ts +11 -4
  30. package/dist/learning-cost.js +4 -2
  31. package/dist/learning-routes.js +1 -1
  32. package/dist/learning-setting.d.ts +16 -1
  33. package/dist/learning-setting.js +34 -2
  34. package/dist/openapi.js +95 -55
  35. package/dist/run-launch.d.ts +6 -3
  36. package/dist/run-launch.js +2 -0
  37. package/dist/run-learning-served.d.ts +1 -1
  38. package/dist/runner/adapter-loop.d.ts +4 -0
  39. package/dist/runner/adapter-loop.js +17 -2
  40. package/dist/runner/adapter-run-spec.js +16 -5
  41. package/dist/runner/audit.d.ts +64 -0
  42. package/dist/runner/audit.js +338 -0
  43. package/dist/runner/beside.js +1 -1
  44. package/dist/runner/cli-run-spec.js +15 -5
  45. package/dist/runner/feedback-round.js +1 -4
  46. package/dist/runner/harness-loops.js +1 -15
  47. package/dist/runner/journal-kinds.d.ts +0 -7
  48. package/dist/runner/journal-kinds.js +0 -7
  49. package/dist/runner/learning-dispatch.d.ts +0 -16
  50. package/dist/runner/learning-dispatch.js +4 -47
  51. package/dist/runner/learning-end.d.ts +52 -13
  52. package/dist/runner/learning-end.js +124 -44
  53. package/dist/runner/learning-factory.d.ts +1 -1
  54. package/dist/runner/learning-factory.js +1 -4
  55. package/dist/runner/learning-loop.d.ts +2 -38
  56. package/dist/runner/learning-loop.js +8 -116
  57. package/dist/runner/main.js +1 -1
  58. package/dist/runner/promotion.d.ts +50 -54
  59. package/dist/runner/promotion.js +191 -583
  60. package/dist/runner/reflect-hook.d.ts +10 -0
  61. package/dist/runner/reflect-hook.js +6 -0
  62. package/dist/runner/workflow-first.d.ts +6 -5
  63. package/dist/runner/workflow-first.js +17 -12
  64. package/dist/server.js +61 -16
  65. package/dist/store/sqlite/store.js +1 -0
  66. package/dist/store/store.d.ts +3 -0
  67. package/dist/store-reads/learning.d.ts +17 -6
  68. package/dist/store-reads/learning.js +36 -23
  69. package/dist/store-reads/loop.d.ts +4 -39
  70. package/dist/store-reads/loop.js +10 -79
  71. package/dist/store-view.js +12 -2
  72. package/dist/workspace/run-tools.d.ts +1 -1
  73. package/dist/workspace/run-tools.js +14 -3
  74. package/package.json +9 -9
  75. package/dist/console/assets/index-C3gNPz58.css +0 -1
  76. package/dist/learn/general.d.ts +0 -69
  77. package/dist/learn/general.js +0 -75
  78. package/dist/learn/refit.d.ts +0 -48
  79. package/dist/learn/refit.js +0 -264
  80. package/dist/runner/step-guard.d.ts +0 -62
  81. package/dist/runner/step-guard.js +0 -93
package/dist/openapi.js CHANGED
@@ -20,11 +20,13 @@ import { LAUNCH_LOST, SETUP_LOST } from "./files.js";
20
20
  import { HARNESSES } from "./harness.js";
21
21
  import { LEARNING_LABEL, LEARNING_MODES, LEARNING_REASONS, LEARNING_STATES, RUN_LEARNING_USE } from "./learning.js";
22
22
  import { BATCH_CELL_MAX, BATCH_ROWS_MAX } from "./learning-batch.js";
23
+ import { AUDIT_DEFAULTS, AUDIT_MAX } from "./learning-setting.js";
23
24
  import { AFTER_STATES, CHEAPER_AFTER_RUNS, COST_CSV_COLUMNS, COST_WINDOW, COST_RUNS_DEFAULT, COST_RUNS_MAX, RUN_PATHS } from "./learning-cost.js";
24
25
  import { FEEDBACK_ROUNDS, FEEDBACK_STATUSES } from "./runner/feedback-round.js";
25
26
  import { EVAL_JOBS_MAX, EVAL_TEXT_MAX, EVALS_KEPT } from "./learning-evals.js";
26
- import { LOOP_COMPILES_MAX, LOOP_POINTS_MAX } from "./store-reads/loop.js";
27
- import { GRADE_SOURCES, GRADES_KEPT, LABEL_MAX, PROMOTE_BAR, REFIT_EVERY, REPLAY_INPUTS, REPLAY_MIN } from "./learn/promote.js";
27
+ import { COMPILE_AFTER_MAX } from "./learning-setting.js";
28
+ import { LOOP_COMPILES_MAX } from "./store-reads/loop.js";
29
+ import { GRADE_SOURCES, GRADES_KEPT, LABEL_MAX } from "./learn/promote.js";
28
30
  import { MODEL_SOURCES, THINKING_LEVELS } from "./model.js";
29
31
  import { BOX_IDS, BOX_NETWORKS, BOX_STATES } from "./place-offers.js";
30
32
  import { PLACE_MODES } from "./place.js";
@@ -1198,7 +1200,7 @@ const RUN_LEARNING = {
1198
1200
  from_notes: { type: "array", items: { type: "string" }, description: "The notes it absorbed, by file name: once merged, each carries `compiled_into: <workflow>` in its front matter and is still served on the by-hand path." },
1199
1201
  attempts: { type: "array", items: closed({ ok: { type: "boolean" }, errors: { type: "array", items: { type: "string" }, description: "What the static checks and the dry run refused of this attempt, sent back to the model for the next one." } }), description: "Each attempt in order: the first, then a retry for each refusal, at most 4." },
1200
1202
  digest: { type: ["string", "null"], description: "The kept draft's digest (the first 16 hex of its workflow.json's sha256): what a run serving it records as `workflow_digest`, and its promotion records' `digest`; null when no attempt passed." },
1201
- promoted: { type: ["boolean", "null"], description: "Whether the kept draft serves the agent's runs, from its promotion records (GET /agents/{agent_id}/learning/promotions): true once promoted (or a threshold refit of it was), false while held, null while it is replayed, before its first claim decides it, or when no attempt passed." },
1203
+ promoted: { type: ["boolean", "null"], description: "Whether the kept draft serves the agent's runs, from its promotion records (GET /agents/{agent_id}/learning/promotions): true once promoted, false while held, null while it is checked, before its first claim decides it, or when no attempt passed." },
1202
1204
  }), { type: "null" }], description: "The run's compile turn, when its end-of-run look-back wrote the agent's job as a learned workflow (the agent kept enough notes or ran the job enough, and has none yet; or its workflow handed a run back, cost more than by hand, or its promotion held it); null when the run compiled nothing." },
1203
1205
  draft_errors: { type: "array", items: { type: "string" }, description: "What the checks refused of a compiled draft that never passed after its retries, cut of the host's secrets; empty when none." },
1204
1206
  cost_usd: closed({ grade: { type: ["number", "null"], description: "The grade's, outside the run (GET /usage's `learning` meter); null before a grade ran, or when its cost is unknown. The end-of-run turn's cost is in the run's own totals." } }),
@@ -1248,12 +1250,12 @@ const COST_RUN = closed({
1248
1250
  n: { type: "integer", minimum: 1, description: "The run's number among the agent's runs counted here, oldest first: 1 is its first." },
1249
1251
  run_id: { type: "string" },
1250
1252
  started_at: DATE_TIME,
1251
- path: { enum: [...RUN_PATHS], description: "The path the run took: `workflow`, a learned workflow finished it alone (its job's only tool calls were learned_workflow calls, each answering, and nothing was said after its first message, so it was not asked to look back); `handed_back`, a learned workflow ran and the agent went on (it failed or escalated, or the agent worked on after it); `agent`, no learned workflow ran; `replay`, a replay run: a learned workflow's new revision run alone on one of the agent's graded inputs, at workflow cost, to decide whether it serves first (its cost is learning's, shown as its own run)." },
1253
+ path: { enum: [...RUN_PATHS], description: "The path the run took: `workflow`, a learned workflow finished it alone (its job's only tool calls were learned_workflow calls, each answering, and nothing was said after its first message, so it was not asked to look back); `handed_back`, a learned workflow ran and the agent went on (it failed or escalated, or the agent worked on after it); `agent`, no learned workflow ran; `replay`, a replay run: a learned workflow's new revision run alone on one of the agent's graded inputs, at workflow cost, to decide whether it serves first (its cost is learning's, shown as its own run); `audit`, never a row here: a shadow run auditing a served run is no run of the series, its cost that run's `learning_usd`." },
1252
1254
  workflow: { ...NULL_STRING, description: "The learned workflow the job called last, by name; null when it called none." },
1253
1255
  learned_revision: { ...NULL_STRING, description: "The commit of the agent's learning folder the run started from: the learned revision that served it. Null for a run that does not learn." },
1254
1256
  cost_usd: COST_USD("The job's own cost: what the run had cost when its answer was final, before it looked back; for a run that did not look back, its whole cost."),
1255
1257
  cost_upper_bound: { type: "boolean", description: "The run's stored cost is only a bound (its row's `costAtMostUsd`: a model request cut at its cap hold): `cost_usd` and `total_usd` are null, never a known cost. `summary` counts such a run as `at_most`, not `unknown`." },
1256
- learning_usd: COST_USD("What learning cost for the run: its end-of-run look-back and the grade of what it proposed, outside the run. 0 for a run that does not learn or kept nothing to grade; a grade still running adds nothing yet."),
1258
+ learning_usd: COST_USD("What learning cost for the run: its end-of-run look-back and the grade of what it proposed, outside the run. 0 for a run that does not learn or kept nothing to grade; a grade still running adds nothing yet. An audit's shadow run of it is its learning too: null while that shadow is queued or running, never $0."),
1257
1259
  total_usd: COST_USD("The run's all-in cost, `cost_usd` and `learning_usd` together; null when either is."),
1258
1260
  });
1259
1261
  const LEARNING_COST = closed({
@@ -1279,11 +1281,14 @@ const LEARNING_COST = closed({
1279
1281
  hand_backs: { oneOf: [closed({ ran: COUNT, back: COUNT }), { type: "null" }], description: "Of the runs a learned workflow ran first on from the takeover on (`path` `workflow` or `handed_back`), how many (`ran`) and how many it handed back to the agent (`back`); null before a takeover." },
1280
1282
  withheld: { oneOf: [closed({ unknown: { ...COUNT, description: "Runs whose cost is unknown." }, at_most: { ...COUNT, description: "Runs whose cost is known only as at most (`cost_upper_bound`)." } }), { type: "null" }], description: "After a takeover, the runs `before` and `after` would read whose cost is not known exactly: while any is, `times_cheaper` is null, so the ratio is never over a partial set. Null when every one is known, and before a takeover." },
1281
1283
  replay: { oneOf: [closed({
1282
- n: { ...COUNT, description: "The graded inputs it replayed." },
1283
- workflow_pct: { type: "number", minimum: 0, maximum: 100, description: "The workflow's accuracy on them, in percent to a tenth (a hand-back counts as the agent's answer)." },
1284
- agent_pct: { type: "number", minimum: 0, maximum: 100, description: "The agent's accuracy on them, in percent to a tenth." },
1285
- cleared: { type: "boolean", description: "The workflow was at most the promotion bar under the agent: the same accuracy, as promotion reads it." },
1286
- }), { type: "null" }], description: "The replay the serving promotion was decided on: the current champion of the learned workflow the newest served run ran. Null when none serves, or it was promoted with no replay (a dry run)." },
1284
+ n: { ...COUNT, description: "The inputs its check ran on." },
1285
+ workflow_pct: { type: "number", minimum: 0, maximum: 100, description: "The share of them it answered alone with the agent's own recorded answer, in percent to a tenth." },
1286
+ agent_pct: { type: "number", minimum: 0, maximum: 100, description: "The agent's accuracy on them, in percent: 100, its own answers being the label." },
1287
+ cleared: { type: "boolean", description: "The check passed: a serving champion was promoted on it." },
1288
+ agreed: { ...COUNT, description: "Of the inputs it answered alone (`alone`), how many said what the agent's own recorded answer said." },
1289
+ alone: { ...COUNT, description: "The inputs it answered alone (no hand-back, no failed step)." },
1290
+ agree_min: { type: "number", minimum: 0, maximum: 1, description: "The agreement bar it passed (the definition's `learning.agree_min`): `agreed` over `alone` at least this. Passing it says the workflow agreed with the agent that often, never that it is as accurate." },
1291
+ }), { type: "null" }], description: "The check the serving promotion was decided on: the current champion of the learned workflow the newest served run ran. Null when none serves." },
1287
1292
  }, "What the series shows, over every run it counts, `limit` aside."),
1288
1293
  });
1289
1294
  const EVAL_TEXT = (description, example) => ({ type: "string", minLength: 1, maxLength: EVAL_TEXT_MAX, description, example });
@@ -1309,27 +1314,26 @@ const LEARNING_EVAL = closed({
1309
1314
  /** PUT /runs/{run_id}/grade and GET /agents/{agent_id}/learning/promotions (learn/promote.ts, runner/promotion.ts). */
1310
1315
  const GRADE = closedWith(GRADE_FIELDS, { expected: { type: "object", description: "The fields a right answer's JSON holds, when the grade gave them." } });
1311
1316
  const REPLAY_SCORE = {
1312
- n: { ...COUNT, description: "The graded inputs it was decided on." },
1313
- agree: { ...COUNT, description: "How many of them the workflow answered alone with the agent's recorded answer." },
1314
- agent_acc: { type: "number", minimum: 0, maximum: 1, description: "The agent's accuracy on them: each graded run's grade when the agent answered it; on one a learned workflow answered alone and was graded wrong, the agent counts right (it never answered it), so a revision held on runs it served wrong serves again only by answering them right." },
1315
- wf_acc: { type: "number", minimum: 0, maximum: 1, description: "The workflow's accuracy on them, at its serving thresholds: an input it handed back counts as the agent's recorded answer, never as a failure. On an input graded wrong it is right only by the grade: the expected answer when the grade gave one; with none, on a run a learned workflow served, any answer but the one graded wrong, and on a run the agent answered, never (a different answer proves nothing)." },
1316
- delta: { type: "number", description: `\`wf_acc\` - \`agent_acc\`; it serves at ${-PROMOTE_BAR} or more.` },
1317
- handed_back: { ...COUNT, description: "How many of them it handed back; it answered `n` - `handed_back` alone. A revision that answered none alone is held: it would never serve." },
1317
+ n: { ...COUNT, description: "The inputs it was decided on (a replay stopped at a write is none)." },
1318
+ agree: { ...COUNT, description: "How many of them the workflow answered alone with the agent's own recorded answer." },
1319
+ agent_acc: { type: "number", minimum: 0, maximum: 1, description: "The agent's accuracy on them: 1, the agent's own recorded answers being the label." },
1320
+ wf_acc: { type: "number", minimum: 0, maximum: 1, description: "The workflow's accuracy on them: the share it answered alone as the agent did, plus the ones it handed back (a hand-back is the agent's answer), over `n`." },
1321
+ delta: { type: "number", description: "`wf_acc` - `agent_acc`." },
1322
+ handed_back: { ...COUNT, description: "How many of them it handed back; it answered `n` - `handed_back` alone." },
1318
1323
  };
1319
1324
  /** A replay's runs' outcomes, the one count of them: on its promotion record (`replay.outcomes`) and its read. */
1320
1325
  const SKIPPED_TOOLS = { type: "array", items: closed({ tool: { type: "string", description: "The tool's catalog name." }, inputs: { ...COUNT, description: "How many skipped inputs it stopped." }, no_read_only_hint: { type: "boolean", description: "An MCP tool its server lists with no `readOnlyHint` (and not `destructiveHint`): replay treats it as a write only because nothing says it reads. The hold's `reason` names these: if they only read, mark them read-only in the MCP server and the next replay runs them." } }), description: "The tools that stopped its skipped inputs, most inputs first." };
1321
1326
  const REPLAY_OUTCOMES = closed({
1322
- answered: { ...COUNT, description: "Replay runs the workflow answered alone, as each run did (guards read record-only: one answered under a guard's threshold counts here, and the score hands it back)." },
1327
+ answered: { ...COUNT, description: "Replay runs the workflow answered alone, as each run did." },
1323
1328
  handed_back: { ...COUNT, description: "Replay runs it handed back on." },
1324
1329
  failed: { ...COUNT, description: "Replay runs a step failed in, or still at work past the replay's deadline: no evidence either way, never scored." },
1325
1330
  skipped_write: { ...COUNT, description: "Replay runs stopped at a write (an MCP tool its server does not mark read-only, or any tool not known to read) that the graded run's recording does not have with the same arguments: a replay never runs a write, so these are neither scored nor wrong; a replay whose every input was skipped holds the revision." },
1326
- }, "How many of its replay runs ended each way: what each run did, never the serving thresholds' reading of it.");
1331
+ }, "How many of its replay runs ended each way: what each run did.");
1327
1332
  const PROMOTION = closedWith({
1328
1333
  workflow: { type: "string" },
1329
1334
  digest: { type: "string", description: "The revision the record decides: the first 16 hex of its workflow.json's sha256." },
1330
1335
  at: DATE_TIME,
1331
- decided: { enum: ["promote", "hold", "replaying", "queued", "skipped"], description: "`promote`: it serves first on the runs it fits. `hold`: it does not; the champion (the revision promoted last) takes them, else the agent, until a new revision. `replaying`: its replay runs are at work; the champion serves meanwhile, else the agent. `queued`: it came while another revision replayed; one revision replays at a time and a running replay finishes, so it replays next, at the first run's claim once that replay is decided (the finished replay's verdict stands). `skipped`: a newer revision (`skipped_by`) came while it was queued; only the newest queued revision replays next, so it never replayed and never serves." },
1332
- source: { enum: ["check", "replay", "dry_run", "refit", "graded"], description: `\`check\`: decided by its one check, a replay of it on the inputs of the agent's last \`compile_after\` completed runs scored against the agent's own recorded answers (\`check\` holds the numbers); a revision's first claim starts it. \`replay\`: decided on a replay of it on the agent's last ${REPLAY_INPUTS} graded inputs it fits, or those its owner asked for (POST .../revisions/{digest}/replays). \`dry_run\`: fewer than ${REPLAY_MIN} graded inputs, promoted on its passing dry run. \`refit\`: a threshold refit wrote this revision, decided on the rows it was fit on. \`graded\`: the graded runs it served fell more than ${PROMOTE_BAR * 100} points under the agent's accuracy by hand.` },
1336
+ decided: { enum: ["promote", "hold", "replaying"], description: "`promote`: it serves first on the runs it fits. `hold`: it does not; the champion (the revision promoted last) takes them, else the agent, until a new revision. A hold with `audit` is its audits' (a serving revision: at least the definition's `learning.hold_disagree` of its newest `learning.hold_window` audit rows, GET .../learning/audits, disagreed); one without it, its check's (`check`). `replaying`: its check's replay runs are at work; the champion serves meanwhile, else the agent. One revision of a workflow is checked at a time, and a running check finishes." },
1333
1337
  reason: { type: "string", description: "Why, in words, with the numbers." },
1334
1338
  }, {
1335
1339
  check: closedWith({
@@ -1343,26 +1347,60 @@ const PROMOTION = closedWith({
1343
1347
  alone: { ...COUNT, description: "How many of them it answered alone. Promoted when `alone`/`n` >= `alone_min` and `agreed`/`alone` >= `agree_min`." },
1344
1348
  of: { type: "array", items: { type: "string" }, description: "The agent's runs whose inputs it ran on, newest first." },
1345
1349
  cost_usd: { type: ["number", "null"], minimum: 0, description: "What its replay runs cost together; null when one's cost is unknown." },
1346
- outcomes: REPLAY_OUTCOMES,
1350
+ outcomes: { ...REPLAY_OUTCOMES, description: "How each input it ran on came out, one per input: a replay run never created, or not ended, by the check's deadline is `failed`." },
1351
+ unstarted: { ...COUNT, minimum: 1, description: "How many of its replay runs were never created by the check's deadline (the server stopped after reserving them, say), each a `failed` input. Left out when none. Every one: its replay's read is `failed`." },
1347
1352
  skipped_tools: SKIPPED_TOOLS,
1348
1353
  disagreements: { type: "array", items: closedWith({ run: { type: "string" }, input: { type: "string", description: "The run's input, as text or JSON, cut at 1200 characters." }, agent: NULL_STRING }, { draft: { type: "string", description: "What it answered instead." }, escalated: { type: "string", description: "Why it handed the input back." }, failed: { const: true, description: "A step failed on it, or its run was still at work past the check's deadline, or never created by then." } }), description: "On a hold: each input it did not agree on, which the agent's next run reads as data in its one recompile." },
1349
1354
  stopped: { const: true, description: "The recompile's check held it too, or there was nothing to check it on (no input of the agent's it takes, or every input skipped at a write: `n` 0, `reason` starting \"nothing to check it on\", which asks no recompile): nothing compiles again until a hold or its owner acts; the agent keeps the runs." },
1350
1355
  }),
1351
- replay: { ...closedWith(REPLAY_SCORE, { of: { type: "array", items: { type: "string" }, description: "The graded runs replayed." }, cost_usd: { type: ["number", "null"], minimum: 0, description: "What its replay runs cost together; null when one's cost is unknown." }, skipped_tools: SKIPPED_TOOLS, outcomes: REPLAY_OUTCOMES }), description: "The numbers it was decided on. A replay runs each read live (through a cache seeded from the graded run's recorded calls) and answers each write from that recording, never sending one." },
1352
1356
  runs: { type: "array", items: { type: "string" }, description: "Its replay runs (path `replay`)." },
1353
1357
  inputs: { type: "array", items: { type: "string" }, description: "On a replaying record: the graded run each of `runs` replays, in the same order. Its runs are reserved before they are created; one not created a few minutes on is created by the next claim." },
1354
1358
  replay_id: { type: "string", description: "The replay's id, on its replaying record and the one that decided it: GET .../revisions/{digest}/replays/{replay_id} reads it, whether a run's claim or its owner started it." },
1355
- refit: { ...closed({ from: { type: "string", description: "The digest it was refit from." }, guards: { type: "array", items: closedWith({ node: { type: "string" }, was: { type: ["number", "null"], description: "The guard's threshold before; null for an escalate." }, threshold: { type: ["number", "null"], description: "Its threshold after; null when it was switched off (the revision has no guard on that step, or no escalate by that label)." } }, { fit: { type: "object" }, escalate: { const: true, description: "An escalate node the replay recorded instead of obeying (its `when` reads a judge's field), switched off: the revision drops it." } }) } }), description: "What a refit changed: each guarded step's threshold before and after (null after: switched off), its new fit (`both` guards), and each escalate it switched off." },
1356
- checked: { ...COUNT, description: `The place among the agent's grades (each grade's order, one more than the grade before it) of the newest grade its last refit check read; it is checked again once ${REFIT_EVERY} more graded runs it served come after it.` },
1357
- since: { ...COUNT, description: "On a replay's promote: the place among the agent's grades of the newest grade when this promotion began, which names it. Its checks count only the graded runs this promotion served, so a revision promoted again after a hold is never held again on the grades it was held on, nor on a run served before it and graded after." },
1358
- held_on: { type: "array", items: { type: "string" }, description: `The runs it served that were graded wrong when its graded runs held it (newest first, at most ${REPLAY_INPUTS}), kept on that hold, on its next replay (those still graded that it fits, each among its inputs) and on that replay's hold. A replay promotes it only once it answered or handed back on each of them, and is within the bar on them alone (gains on other inputs never pay for repeating their wrong answers).` },
1359
1359
  commit: { type: "string", description: "The learning commit whose workflow.json is this revision's text: what it serves from as the champion while a newer revision replays." },
1360
- skipped_by: { type: "string", description: "A skipped revision's newer one: the digest that came while it was queued, and replays in its place." },
1360
+ audit: closedWith({
1361
+ window: { type: "integer", minimum: 1, description: "The definition's `learning.hold_window` when it was held." },
1362
+ disagree: { type: "integer", minimum: 1, description: "The definition's `learning.hold_disagree` when it was held." },
1363
+ rows: { ...COUNT, description: "The audit rows it was decided on: the newest `window` with a verdict." },
1364
+ disagreements: { type: "array", items: closedWith({
1365
+ run: { type: "string", description: "The run whose answer is the agent's: the shadow run, or the served run for a grade." },
1366
+ served: { type: "string", description: "The run the workflow served." },
1367
+ input: { type: "string", description: "The served run's input, as text or JSON, cut at 1200 characters." },
1368
+ agent: { ...NULL_STRING, description: "The agent's answer (the shadow run's), cut at 1200 characters; null for a grade's row." },
1369
+ draft: { ...NULL_STRING, description: "The served answer, cut at 1200 characters; null when it could not be read." },
1370
+ }, { graded: { const: true, description: "An owner's grade wrote this row: the served answer was graded wrong." } }), description: "Its disagreeing rows: the data its one recompile reads." },
1371
+ }, { stopped: { const: true, description: "A second audit hold within the definition's `learning.stop_window` served runs of the first: it stopped, no compile is asked, nothing serves again until a new revision lands." } }),
1372
+ });
1373
+ const AUDIT_LINE = closed({
1374
+ window: { type: "integer", minimum: 1, description: "The definition's `learning.hold_window`." },
1375
+ disagree: { type: "integer", minimum: 1, description: "The definition's `learning.hold_disagree`." },
1376
+ rows: { ...COUNT, description: "The serving revision's newest audit rows with a verdict, at most `window`." },
1377
+ disagreed: { ...COUNT, description: "How many of them disagreed: it is held once this reaches `disagree`." },
1361
1378
  });
1362
1379
  const SERVING = closed({
1363
1380
  workflow: { type: "string" },
1364
1381
  digest: { ...NULL_STRING, description: "The revision that serves first (the champion: the one promoted last, while its newest record still says promote); null when none does and the agent takes the runs." },
1365
1382
  replaying: { ...NULL_STRING, description: "A newer revision whose replay is at work, when there is one: it serves only once its replay promotes it; the champion serves meanwhile." },
1383
+ state: { enum: ["serving", "checking", "held", "stopped"], description: "`serving`: a revision serves first. `checking`: its newest revision's check is at work (the agent takes the runs meanwhile, or the champion). `held`: none serves, its newest record holds it (a check's or an audit's hold: the agent's next run recompiles it once). `stopped`: none serves and nothing compiles again (a recompile's check held it too, or a second audit hold within `learning.stop_window`, or a check whose every input stopped at a write) until a new revision lands." },
1384
+ check: { anyOf: [closed({ n: COUNT, agreed: COUNT, alone: COUNT, attempt: { enum: [1, 2] } }), { type: "null" }], description: "The numbers of the workflow's newest decided check: its inputs, those it agreed on, those it answered alone, which check of its compile it was; null when none was decided." },
1385
+ audit: { anyOf: [AUDIT_LINE, { type: "null" }], description: "Its audit line: the serving (else the newest) revision's newest audit rows against the hold bar; null when no revision has a record." },
1386
+ audits_off: { ...NULL_STRING, description: "Why none of the agent's runs is audited, e.g. `audits off: send_email can write`: its definition can call a tool that is not read-only (an MCP tool its server lists without `readOnlyHint`, or a built-in other than web_fetch, web_search, pdf_pages and llm, its computer's tools among them), which a shadow run would call a second time. Null when every tool it can call only reads: its served runs are audited." },
1387
+ not_auditable: { ...COUNT, description: "Of the serving revision's newest `learning.stop_window` served runs, those a trigger started: never audited (a shadow run gets none of a trigger's context, and could answer where it answers). 0 when none serves." },
1388
+ });
1389
+ const AUDIT_ROW = closedWith({
1390
+ run: { type: "string", description: "The served run." },
1391
+ shadow_run: { ...NULL_STRING, description: "Its shadow run (the same agent on the same input with learning off, GET /runs/{id}'s `audit_of` names the served run); null for a grade's row, or when none was started (`skipped`)." },
1392
+ workflow: { type: "string" },
1393
+ digest: { type: "string", description: "The revision that served it." },
1394
+ promoted_at: { type: ["string", "null"], format: "date-time", description: "The promotion of that revision the row counts for: its promote record's `at` (GET .../learning/promotions), the one serving when the shadow started or the grade was given. The hold rule counts only the rows of the revision's promotion now, so a revision its owner's replay promotes again after a hold starts on none. Null: none." },
1395
+ source: { enum: ["shadow", "grade"], description: "`shadow`: the shadow run's answer compared with the served one. `grade`: an owner's grade of a run the workflow answered alone (PUT /runs/{id}/grade)." },
1396
+ agreed: { type: ["boolean", "null"], description: "Whether the two answers say the same (a grade's: whether it was graded right); null when either answer is missing (a shadow that failed or `parked`, or none was started): no evidence, not counted." },
1397
+ served_cost: { type: ["number", "null"], minimum: 0, description: "What the served run cost; null when unknown." },
1398
+ shadow_cost: { type: ["number", "null"], minimum: 0, description: "What the shadow run cost (the agent's learning cost); null for a grade's row, or when unknown." },
1399
+ at: DATE_TIME,
1400
+ }, {
1401
+ turn: { type: "string", description: "The served run's answer the row is of: the id of its answer row in the run's timeline (GET /runs/{id}/timeline), its newest final answer when the audit began (or at the grade). A follow-up's later answer is never the one compared. Absent when the run had no answer." },
1402
+ skipped: { const: "no allowance", description: "No shadow was started: the served run's cap left less than a run's smallest cap ($0.01), or what it spent under it is not known. `agreed` is null: not counted." },
1403
+ parked: { const: true, description: "The shadow came to wait on a person (an approval its tool settings ask, a question, a raise of its cap: what the served run's cap left) and ended there at once, no one asked, so it has no answer. `agreed` is null: not counted." },
1366
1404
  });
1367
1405
  const BATCH_LESSONS = closed({ notes: { type: "array", items: { type: "string" } }, skills: { type: "array", items: { type: "string" } }, workflows: { type: "array", items: { type: "string" } } });
1368
1406
  const BATCH_ROW = closedWith({ n: { type: "integer", minimum: 1, description: "The row's number, 1 the first: rows run in this order." }, state: { enum: ["pending", "running", "done", "failed"], description: "`done`: the run answered, was told the reference, and that turn completed and its learning settled; `failed`: its run failed, was cancelled or waited on a person, its review was not sent, or its review's turn did not complete (`error` says). A row is failed only once its run has stopped." }, reference: { type: "string", description: "The reference answer, as the person gave it." } }, {
@@ -1370,7 +1408,7 @@ const BATCH_ROW = closedWith({ n: { type: "integer", minimum: 1, description: "T
1370
1408
  answer: { ...NULL_STRING, description: "The run's answer as compared (the `answer_field` of a JSON answer when the batch names one), cut at 2000 characters (compared whole: the review quotes it to 2000 characters and says when it was cut); null when it gave none." },
1371
1409
  right: { type: "boolean", description: "Whether the answer equals the reference once trimmed, case-folded and whitespace-collapsed (two numbers by value). A display: the learning grade is the judge." },
1372
1410
  reviewed: { type: "boolean", description: "The reference was sent to the run as a review, once." },
1373
- path: { enum: RUN_PATHS.filter((path) => path !== "replay"), description: "The path the run's job took, read when it answered, before its review (GET /agents/{agent_id}/learning/cost's `path`): whoever wrote its answer." },
1411
+ path: { enum: RUN_PATHS.filter((path) => path !== "replay" && path !== "audit"), description: "The path the run's job took, read when it answered, before its review (GET /agents/{agent_id}/learning/cost's `path`): whoever wrote its answer." },
1374
1412
  cost_usd: COST_USD("The job's own cost."), learning_usd: COST_USD("What learning cost for the run."), total_usd: COST_USD("Their sum; for a failed row, what its run cost."),
1375
1413
  learned: { ...BATCH_LESSONS, description: "The notes, skills and workflow drafts the run's learning kept, by name." },
1376
1414
  merged: { ...NULL_STRING, description: "The commit of the agent's learning folder its learning last merged (its job's round or its review's)." },
@@ -1402,7 +1440,7 @@ const LEARNING_EXTENSIONS = {
1402
1440
  "/runs/{run_id}/grade": {
1403
1441
  put: {
1404
1442
  operationId: "gradeRun", tags: ["runs"], summary: "Grade an ended run's answer: right or wrong, and the fields a right answer holds",
1405
- description: `A person's feedback or an eval's label on a run that ended, kept for its agent (one grade a run: a later one replaces it; the newest ${GRADES_KEPT} are kept). Promotion by replay reads them: a learned workflow's new revision serves first only after a replay on the agent's last ${REPLAY_INPUTS} graded inputs it fits is within ${PROMOTE_BAR * 100} points of the agent's own answers on them; with fewer than ${REPLAY_MIN}, on its passing dry run. With \`expected\`, a replay's answer is right when its JSON holds each of those fields; else when it says what the graded answer said. A replay run is never graded. The run's path never changes on a grade: a grade of a run its learned workflow answered alone, right or wrong, is kept and nothing more ($0; the workflow's graded hold reads it, and only a hold asks for its revision); a run the agent finished, graded with a \`label\`, opens again on a look-back on it. That round asks the agent no turn of the job's, only its end-of-run turn, and its spend is the run's learning (\`feedback\`).`,
1443
+ description: `A person's feedback or an eval's label on a run that ended, kept for its agent (one grade a run: a later one replaces it; the newest ${GRADES_KEPT} are kept). Promotion reads none: a revision's check is scored against the agent's own recorded answers. A replay run is never graded. The run's path never changes on a grade: a grade of a run its learned workflow answered alone, right or wrong, is kept and nothing more ($0); a run the agent finished, graded with a \`label\`, opens again on a look-back on it. That round asks the agent no turn of the job's, only its end-of-run turn, and its spend is the run's learning (\`feedback\`).`,
1406
1444
  parameters: [ref("parameters/RunId")],
1407
1445
  requestBody: { required: true, content: { "application/json": { schema: { type: "object", additionalProperties: false, required: ["correct"], properties: { correct: { type: "boolean" }, expected: { type: "object", description: "The fields a right answer's JSON holds." }, source: { enum: [...GRADE_SOURCES], default: "feedback" }, label: { type: "string", maxLength: LABEL_MAX, description: "The grade's words (a teacher's label, a reviewer's note): what the run's look-back reads." } } } } } },
1408
1446
  responses: { "200": json(GRADE, "The run's grade."), ...errors(400, 401, 404, 429, 500) },
@@ -1411,8 +1449,8 @@ const LEARNING_EXTENSIONS = {
1411
1449
  },
1412
1450
  "/agents/{agent_id}/learning/loop": {
1413
1451
  get: {
1414
- operationId: "getLearningLoop", tags: ["agents"], summary: "The self-learning loop's own record: each compile turn, and each guarded step of the learned workflows",
1415
- description: `What the console's Learning tab tells of the loop beside the cost series. \`compiles\`: the agent's compile turns, newest first (the newest ${LOOP_COMPILES_MAX}): the workflow a run's compile turn wrote, the notes it absorbed, each attempt and what the checks refused, its draft's digest and whether that revision was promoted; a follow-up's round compiles on its own, so a run can list one turn a round; a turn whose draft never passed is listed with its \`draft_errors\`, never silent. \`guards\`: each guarded step of each learned workflow revision that ran (served first or replayed), with its signal and threshold, how many runs it served first on and how many it handed back, how many the workflow answered alone were graded right and wrong (each over every run), and each run's p (its newest ${LOOP_POINTS_MAX}), with whether the run was right when its answer was the workflow's own and was graded. A replay run reads its guards at a record-only threshold, so it is counted apart (\`replays\`) and in none of the others. Aggregates and the checks' own words only: no input or answer. Each text cut of the host's secrets and of its run's handed values; a run whose handed values can't be read here shows no error text (\`withheld\`).`,
1452
+ operationId: "getLearningLoop", tags: ["agents"], summary: "The self-learning loop's own record: each compile turn",
1453
+ description: `What the console's Learning tab tells of the loop beside the cost series. \`compiles\`: the agent's compile turns, newest first (the newest ${LOOP_COMPILES_MAX}): the workflow a run's compile turn wrote, the notes it absorbed, each attempt and what the checks refused, its draft's digest and whether that revision was promoted; a follow-up's round compiles on its own, so a run can list one turn a round; a turn whose draft never passed is listed with its \`draft_errors\`, never silent. Aggregates and the checks' own words only: no input or answer. Each text cut of the host's secrets and of its run's handed values; a run whose handed values can't be read here shows no error text (\`withheld\`).`,
1416
1454
  parameters: [AGENT_ID],
1417
1455
  responses: { "200": json(closed({
1418
1456
  agent: { type: "string" },
@@ -1425,34 +1463,29 @@ const LEARNING_EXTENSIONS = {
1425
1463
  from_notes: { type: "array", items: { type: "string" }, description: "The notes it absorbed, by file name (each marked \`compiled_into\` once it merged)." },
1426
1464
  attempts: { type: "array", items: closed({ ok: { type: "boolean" }, errors: { type: "array", items: { type: "string" } } }), description: "Each attempt in order: whether its checks and dry run passed, and what they refused." },
1427
1465
  digest: { ...NULL_STRING, description: "The kept draft's digest; null when none passed." },
1428
- promoted: { type: ["boolean", "null"], description: "Whether that revision was promoted, as its records say now: true promoted (or a refit of it was), false held or skipped, null queued, undecided or none passed. It may no longer serve: the promotions read's \`serving\` says which revision does." },
1466
+ promoted: { type: ["boolean", "null"], description: "Whether that revision was promoted, as its records say now: true promoted, false held, null undecided or none passed. It may no longer serve: the promotions read's \`serving\` says which revision does." },
1429
1467
  draft_errors: { type: "array", items: { type: "string" }, description: "A draft that never passed: its last errors. A draft its check had nothing to run on (its promotion `check.stopped` with `n` 0): its record's reason, starting \"nothing to check it on\". Empty otherwise." },
1430
1468
  withheld: { type: "boolean", description: "The run's handed values can't be read here: its error texts are left out (the counts stand)." },
1431
1469
  }), description: "Newest first." },
1432
- guards: { type: "array", items: closed({
1433
- workflow: { type: "string" },
1434
- digest: { type: "string", description: "The revision the step ran in." },
1435
- node: { type: "string", description: "The step's label." },
1436
- signal: { enum: ["self", "jev", "both"], description: "\`self\`: the step's own confidence; \`jev\`: one Jev call over its input and output; \`both\`: their fitted logistic (min of the two before a fit)." },
1437
- threshold: { type: ["number", "null"], minimum: 0, maximum: 1, description: "Under it the step hands the run back to the agent, as the runs it served first on read it; null when only replays ran it." },
1438
- runs: { ...COUNT, description: "Runs this revision served first on that this step guarded, each once however many checks a map made of it (replays left out, and checks of another workflow's call in the same run)." },
1439
- escalated: { ...COUNT, description: "How many of them it handed back (one of the run's checks of it did)." },
1440
- right: { ...COUNT, description: "How many of them the workflow answered alone and were graded right." },
1441
- wrong: { ...COUNT, description: "How many of them the workflow answered alone and were graded wrong." },
1442
- grades_past: { ...COUNT, description: `How many of them the workflow answered alone whose grade, if one was given, is no longer kept (the agent keeps its newest ${GRADES_KEPT} grades): in neither \`right\` nor \`wrong\`, and not known to be ungraded.` },
1443
- replays: { ...COUNT, description: "Replay runs of this revision that read this step: in none of the other counts, nor in \`points\` (a replay reads its guards at a record-only threshold, so its row says nothing of a hand-back)." },
1444
- points: { type: "array", items: closed({ run_id: { type: "string" }, p: { type: ["number", "null"], minimum: 0, maximum: 1, description: "The least p the run's checks of this step read, to 4 places; null when a signal was missing on one (always handed back)." }, escalated: { type: "boolean" }, correct: { type: ["boolean", "null"], description: "The run's grade, on a run the workflow answered alone; null otherwise." } }), description: `The runs it served first on, oldest first: the newest ${LOOP_POINTS_MAX}.` },
1445
- }) },
1446
- }), "The loop's compile turns and guarded steps."), ...errors(401, 403, 404, 429, 500) },
1470
+ }), "The loop's compile turns."), ...errors(401, 403, 404, 429, 500) },
1447
1471
  "x-agentrun-serve": "learningloop/1",
1448
1472
  },
1449
1473
  },
1450
1474
  "/agents/{agent_id}/learning/promotions": {
1451
1475
  get: {
1452
1476
  operationId: "listLearningPromotions", tags: ["agents"], summary: "Each learned workflow revision's promotion: its replay's numbers and whether it serves",
1453
- description: "Every promotion record of the agent's learned workflows, oldest first: a new revision's replay on the agent's graded inputs (replaying, then promoted or held, with its numbers), one promoted on its dry run, a threshold refit's new revision, a serving revision held on its graded runs. A revision serves only once its replay promotes it; the champion (the revision promoted last) keeps serving while a newer one replays or after it is held, and `serving` says which digest serves and which replays. One revision replays at a time and a running replay finishes: a newer one that comes meanwhile is queued, and replays next; one queued before it is skipped, its record naming the newer one. Aggregates only: no input or answer. What the console's Learning tab marks on its cost chart.",
1477
+ description: "Every promotion record of the agent's learned workflows, oldest first: a new revision's one check, a replay of it on the inputs of the agent's last completed runs scored against the agent's own recorded answers (replaying, then promoted or held, with its numbers), a draft held with nothing to check it on, a compile whose drafts all failed their checks (a hold with nothing checked, its reason naming the failed checks: the compile's attempt; a recompile's stops), or a serving revision held by its audits (GET .../learning/audits; the hold's `audit` holds the rows). A revision serves only once its check promotes it; the champion (the revision promoted last) keeps serving while a newer one is checked or after it is held, and `serving` says which digest serves and which is checked, each workflow's state, its newest check's numbers and its audit line. One revision of a workflow is checked at a time and a running check finishes. A hold's disagreements (a check's, an audit's) quote inputs and answers, cut as the agent's other learning reads cut them. What the console's Learning tab marks on its cost chart.",
1478
+ parameters: [AGENT_ID],
1479
+ responses: { "200": json(closed({ agent: { type: "string" }, promotions: { type: "array", items: PROMOTION }, serving: { type: "array", items: SERVING, description: "Each learned workflow with a record: the revision that serves, the one replaying, its state, its check's numbers and its audit line." } }), "The agent's promotion records, and what serves."), ...errors(401, 403, 404, 429, 500) },
1480
+ "x-agentrun-serve": "promotion/1",
1481
+ },
1482
+ },
1483
+ "/agents/{agent_id}/learning/audits": {
1484
+ get: {
1485
+ operationId: "listLearningAudits", tags: ["agents"], summary: "The audit ledger of the agent's serving learned workflows",
1486
+ description: "One row per finished audit, oldest first, as the agent's learning folder keeps them (audits.jsonl): a run a promoted learned workflow served first (answered alone or handed back) is audited at 1 in `learning.audit_every` (drawn from its id): its shadow run, the same agent on the same input with learning off, answers it again, and the row says whether the two answers say the same and what each run cost (the shadow's is the agent's learning cost; the shadow is no row of the run list, and GET /runs/{id} reads it with `audit_of`). A capped run's shadow starts at its end, capped at what its cap left, so the two never spend past it: with less than a run's smallest cap left, none starts (`skipped`). A shadow never waits on a person: one that would (an approval, a question, a raise of its cap) ends there at once with no answer (`parked`); neither is counted. Each row compares the served run's answer at the audit's start (`turn`), never a follow-up's. An owner's grade of a run the workflow answered alone is a row too. The hold rule reads them (`learning.hold_window`, `learning.hold_disagree`).",
1454
1487
  parameters: [AGENT_ID],
1455
- responses: { "200": json(closed({ agent: { type: "string" }, promotions: { type: "array", items: PROMOTION }, serving: { type: "array", items: SERVING, description: "Each learned workflow with a record: the revision that serves and the one replaying." } }), "The agent's promotion records, and what serves."), ...errors(401, 403, 404, 429, 500) },
1488
+ responses: { "200": json(closed({ agent: { type: "string" }, audits: { type: "array", items: AUDIT_ROW } }), "The agent's audit rows."), ...errors(401, 403, 404, 429, 500) },
1456
1489
  "x-agentrun-serve": "promotion/1",
1457
1490
  },
1458
1491
  },
@@ -1614,23 +1647,23 @@ const LEARNING_EXTENSIONS = {
1614
1647
  },
1615
1648
  "/agents/{agent_id}/learning/workflows/{name}/revisions/{digest}/replays": {
1616
1649
  post: {
1617
- operationId: "startLearnedWorkflowReplay", tags: ["agents"], summary: "Replay a learned workflow's revision on the agent's graded inputs: re-check a held revision, or an edited one",
1618
- description: `Starts the replay a run's claim starts for a new revision (GET /agents/{agent_id}/learning/promotions explains them): one replay run of the agent per graded input, each the workflow alone at workflow cost, its reads live and its writes answered only from the graded run's recording, never sent. \`inputs\`: \`held\` (the default), the graded runs the revision's last replay or hold was decided on, or, with none, the agent's newest ${REPLAY_INPUTS}; a number from 1 to ${GRADES_KEPT}, that many of the agent's newest graded runs. Either way, a revision held on runs it served that were graded wrong is replayed on those too (its hold's \`held_on\`), and promoted only once it answered or handed back on each and is within the bar on them alone. Each is a graded run the agent answered (path \`agent\` or \`handed_back\`) or the workflow answered alone (\`workflow\`), with no uploaded file, whose input the revision takes. Its record is a replay's (\`source: replay\`, \`replaying\` then promoted or held, with its numbers, as a claim-started one is), decided once every replay run ended: at a run's claim that lays the revision, or at its read (GET .../replays/{replay_id}). A promoted revision serves first, and a held one may be refit, as after any replay. Its replay runs are handed no per-run MCP credentials. The revision is \`digest\`, the first 16 hex of its workflow.json's sha256: one a promotion record names (read at its commit), or the one on the learning folder's main. 404 for an unknown agent, workflow or revision. 409 \`replay_conflict\` when it is replaying already, another revision of the workflow replays (one at a time, and a running replay finishes: a revision queued behind it, \`queued\` in the promotions, replays at the first run's claim once it ends, no POST needed), it is promoted (it serves already), fewer than ${REPLAY_MIN} of the graded inputs asked for fit it (a replay on fewer could only hold it, so nothing is reserved and no run starts), or the agent's runs take no learned workflow here. 409 \`agent_not_runnable\` for an archived agent, as a run's start is: nothing is reserved. 400 for any other \`inputs\`. Only the owner, signed in with their password, starts one: the console's password session alone, from this server's own origin with a JSON body; every token is 403 \`forbidden\`.`,
1650
+ operationId: "startLearnedWorkflowReplay", tags: ["agents"], summary: "Re-check a learned workflow's revision on the agent's own runs: a held revision, or an edited one",
1651
+ description: `Starts the one check a run's claim starts for a new revision (GET /agents/{agent_id}/learning/promotions explains it): one replay run of the agent per input, each the workflow alone at workflow cost, its reads live and its writes answered only from the agent's own run's recording, never sent, scored against the agent's own recorded answers. \`inputs\`: \`held\` (the default), the runs the revision's last check ran on, or, with none, the agent's last \`compile_after\` completed runs; a number from 1 to ${COMPILE_AFTER_MAX}, that many of the agent's newest completed runs. Each is a completed run of the agent's own (path \`agent\` or \`handed_back\`), with no uploaded file, whose input the revision takes. Its record is a check's (\`replaying\` then promoted or held, with its numbers, as a claim-started one is), decided once every replay run ended: at a run's claim that lays the revision, or at its read (GET .../replays/{replay_id}). Its replay runs are handed no per-run MCP credentials. The revision is \`digest\`, the first 16 hex of its workflow.json's sha256: one a promotion record names (read at its commit), or the one on the learning folder's main. 404 for an unknown agent, workflow or revision. 409 \`replay_conflict\` when it is replaying already, another revision of the workflow replays (one at a time, and a running check finishes), it is promoted (it serves already), none of the inputs asked for fits it (nothing is reserved and no run starts), or the agent's runs take no learned workflow here. 409 \`agent_not_runnable\` for an archived agent, as a run's start is: nothing is reserved. 400 for any other \`inputs\`. Only the owner, signed in with their password, starts one: the console's password session alone, from this server's own origin with a JSON body; every token is 403 \`forbidden\`.`,
1619
1652
  security: [{ ownerSession: [] }],
1620
1653
  parameters: [AGENT_ID, { name: "name", in: "path", required: true, description: "The learned workflow's folder name, `workflows/<name>/`.", schema: { type: "string" } }, { name: "digest", in: "path", required: true, description: "The revision: the first 16 hex of its workflow.json's sha256.", schema: { type: "string" } }],
1621
- requestBody: { required: true, content: { "application/json": { schema: { type: "object", additionalProperties: false, properties: { inputs: { oneOf: [{ const: "held" }, { type: "integer", minimum: 1, maximum: GRADES_KEPT }], default: "held", description: "`held`: the graded inputs it was last decided on; a number: the agent's newest that many." } } } } } },
1654
+ requestBody: { required: true, content: { "application/json": { schema: { type: "object", additionalProperties: false, properties: { inputs: { oneOf: [{ const: "held" }, { type: "integer", minimum: 1, maximum: COMPILE_AFTER_MAX }], default: "held", description: "`held`: the runs it was last checked on; a number: the agent's newest that many completed runs." } } } } } },
1622
1655
  responses: { "202": { description: "The replay started: its runs are queued.", headers: { Location: ref("headers/Location") }, content: { "application/json": { schema: closed({ replay: { type: "string", description: "The replay's id." }, inputs: { ...COUNT, description: "How many graded inputs it replays: one replay run each." } }) } } }, ...errors(400, 401, 403, 404, 409, 422, 429, 500) }, ...MARK,
1623
1656
  },
1624
1657
  },
1625
1658
  "/agents/{agent_id}/learning/workflows/{name}/revisions/{digest}/replays/{replay_id}": {
1626
1659
  get: {
1627
1660
  operationId: "getLearnedWorkflowReplay", tags: ["agents"], summary: "Read a replay's result: running, done or failed, its counts and its score (start one from the console's Learning tab)",
1628
- description: "A replay a run's claim or the agent's owner started. This read decides it as a claim would, once every replay run ended or its deadline passed (promoted within 2 points of the agent, else held, then one refit), so a replay of a revision no run lays is decided too. It never starts a run: a replay whose launch was interrupted (the server stopped before creating its runs) reads `running` until its deadline. `status`: `running` while it replays, `done` once promoted or held (`decided`, with its `reason`; a newer revision that came meanwhile queued behind it, never cancelling it), `failed` when none of its runs started by its deadline (held, nothing replayed; its `reason` says so and to start it again with POST). `outcomes` counts its replay runs so far (once decided, those it was decided on, as its promotion record keeps them): `answered` alone, `handed_back` (the agent's recorded answer), `failed` (no evidence either way), `skipped_write` (a write its recording does not have). `score` is the decided record's, else the runs ended so far at the revision's serving thresholds. Aggregates only, its words cut as the promotions list's are.",
1661
+ description: "A replay a run's claim or the agent's owner started. This read decides it as a claim would, once every replay run ended or its deadline passed (promoted when it clears the check's bar, else held), so a replay of a revision no run lays is decided too. It never starts a run: a replay whose launch was interrupted (the server stopped before creating its runs) reads `running` until its deadline. `status`: `running` while it replays, `done` once promoted or held (`decided`, with its `reason`), `failed` when none of its runs started by its deadline (held, nothing replayed; its `reason` says so and to start it again with POST). `outcomes` counts its replay runs so far (once decided, those it was decided on, as its promotion record keeps them): `answered` alone, `handed_back` (the agent's recorded answer), `failed` (no evidence either way), `skipped_write` (a write its recording does not have). `score` is the decided record's. Aggregates only, its words cut as the promotions list's are.",
1629
1662
  parameters: [AGENT_ID, { name: "name", in: "path", required: true, description: "The learned workflow's folder name.", schema: { type: "string" } }, { name: "digest", in: "path", required: true, description: "The revision's digest.", schema: { type: "string" } }, { name: "replay_id", in: "path", required: true, description: "The replay's id: POST .../replays answered it, and its promotion records carry it (`replay_id`).", schema: { type: "string" } }],
1630
1663
  responses: { "200": json(closedWith({
1631
1664
  replay: { type: "string" }, workflow: { type: "string" }, digest: { type: "string" },
1632
1665
  status: { enum: ["running", "done", "failed"] },
1633
- inputs: { ...COUNT, description: "Its replay runs: one per graded input." },
1666
+ inputs: { ...COUNT, description: "Its replay runs: one per input." },
1634
1667
  outcomes: REPLAY_OUTCOMES,
1635
1668
  score: closed(REPLAY_SCORE),
1636
1669
  cost_usd: { type: ["number", "null"], minimum: 0, description: "What its replay runs cost together; null while one's cost is unknown (one not created or not ended yet), never a part of it." },
@@ -3004,6 +3037,7 @@ const FIELD_EXTENSIONS = {
3004
3037
  "x-agentrun-serve": "imported/1",
3005
3038
  },
3006
3039
  trigger: RUN_TRIGGER,
3040
+ audit_of: { ...NULL_STRING, description: "On the run read: a shadow run's served run. A run a promoted learned workflow served first may be audited (the agent definition's `learning.audit_every`): its shadow, the same agent on the same input with learning off, started at the served run's end and capped at what the served run's cap left, is no row of the run list, and its cost is in the served run's `cost.usd` (null while the shadow is queued or running: never $0) and the agent's learning cost (GET /agents/{agent_id}/learning/audits). Null for any other run.", "x-agentrun-serve": "promotion/1" },
3007
3041
  },
3008
3042
  InputIssue: {
3009
3043
  code: { type: "string", description: "A workflow definition's issue: the DSL's validation code (`STATE_PATH_UNPRODUCED`, say), with `field` the path to it under `definition.workflow`.", "x-agentrun-serve": "validate/1" },
@@ -3166,7 +3200,13 @@ const FIELD_EXTENSIONS = {
3166
3200
  compile_after: { type: "integer", minimum: 1, maximum: 200, default: 20, description: "The job compiles into a learned workflow once the agent has this many completed runs of its own." },
3167
3201
  agree_min: { type: "number", minimum: 0, maximum: 1, default: 0.8, description: "The draft's one check replays it on the inputs of those runs: promoted only when, of the inputs it answered alone, at least this share say what the agent's own recorded answer said." },
3168
3202
  alone_min: { type: "number", minimum: 0, maximum: 1, default: 0.7, description: "...and only when it answered at least this share of them alone (no escalate, no failed step). Under either bar it is recompiled once with the inputs it did not agree on, checked the same way, then promoted or stopped: nothing compiles again." },
3169
- } }], default: false, description: "Whether an agentic revision's runs learn, and what: `true`, notes, skills and learned workflows; an object, the same with the loop's numbers set on it (`compile_after`, `agree_min`, `alone_min`, each optional: one left out is its default; `true` is every default); `\"notes\"`, notes and skills alone (a run is never given a learned workflow nor asked to draft one); `false`, nothing. A run that learns starts from what its agent has learned, its notes in its instructions under `# Learned` (each whole within the server's learning budget, else the index and the notes changed last, whole) and in `.learning/` in its working directory, and once it answers or fails is asked one more turn to add notes there, which are checked, graded and merged. Kept when a definition says so, true, false, `\"notes\"` or an object (its numbers in one order); a number out of range or an unknown key is a 422 `wrong_type`; absent, off, and an answer shows none. An edit that leaves it out keeps the agent's. A workflow revision keeps none. On a server whose learning is off (`capabilities.features.learning`), no run learns, whatever this says.", "x-agentrun-serve": "learning/1" },
3203
+ audit_every: { type: "integer", minimum: 1, maximum: AUDIT_MAX, default: AUDIT_DEFAULTS.audit_every, description: "Once a learned workflow serves, 1 in this many of the runs it serves (answered alone or handed back) is audited: drawn from the run's id, the same agent runs the same input again with learning off (a shadow run, hidden from the run list, its cost the agent's learning cost), and the two answers are compared (one row of GET .../learning/audits)." },
3204
+ audit_every_later: { type: "integer", minimum: 1, maximum: AUDIT_MAX, default: AUDIT_DEFAULTS.audit_every_later, description: "1 in this many once the workflow's revision served `audit_later_after` runs." },
3205
+ audit_later_after: { type: "integer", minimum: 1, maximum: AUDIT_MAX, default: AUDIT_DEFAULTS.audit_later_after, description: "The served runs after which `audit_every_later` applies." },
3206
+ hold_window: { type: "integer", minimum: 1, maximum: AUDIT_MAX, default: AUDIT_DEFAULTS.hold_window, description: "The audit rows of the serving revision the hold rule reads: its newest this many (an owner's grade on a served run is one too)." },
3207
+ hold_disagree: { type: "integer", minimum: 1, maximum: AUDIT_MAX, default: AUDIT_DEFAULTS.hold_disagree, description: "When at least this many of those rows disagree, the workflow stops serving (a hold, source `audit`) and is recompiled once with them as data, then checked again: promoted serves again, otherwise it stops. At most `hold_window`." },
3208
+ stop_window: { type: "integer", minimum: 1, maximum: AUDIT_MAX, default: AUDIT_DEFAULTS.stop_window, description: "A second hold within this many served runs of the first stops the workflow for good, asking no compile." },
3209
+ } }], default: false, description: "Whether an agentic revision's runs learn, and what: `true`, notes, skills and learned workflows; an object, the same with the loop's numbers set on it (`compile_after`, `agree_min`, `alone_min`, `audit_every`, `audit_every_later`, `audit_later_after`, `hold_window`, `hold_disagree`, `stop_window`, each optional: one left out is its default; `true` is every default); `\"notes\"`, notes and skills alone (a run is never given a learned workflow nor asked to draft one); `false`, nothing. A run that learns starts from what its agent has learned, its notes in its instructions under `# Learned` (each whole within the server's learning budget, else the index and the notes changed last, whole) and in `.learning/` in its working directory, and once it answers or fails is asked one more turn to add notes there, which are checked, graded and merged. Kept when a definition says so, true, false, `\"notes\"` or an object (its numbers in one order); a number out of range or an unknown key is a 422 `wrong_type`; absent, off, and an answer shows none. An edit that leaves it out keeps the agent's. A workflow revision keeps none. On a server whose learning is off (`capabilities.features.learning`), no run learns, whatever this says.", "x-agentrun-serve": "learning/1" },
3170
3210
  checkout: { enum: ["pull_request", "none"], description: "What the server checks out in each run's folder before its first turn, an agentic definition's alone. `pull_request`: the pull request the run's GitHub event names (a GitHub trigger's firing: its repository, number, head and base), at its head, detached, in `repo/`, with its base and their merge base fetched beside it (refs `pr/head`, `pr/base`, `pr/merge-base`). The fetch is the server's own, one command on the run's folder, with an installation token of the server's GitHub App narrowed to that repository and `contents: read`, which the agent never holds: it is never in the folder, the checkout's git config, its remote's URL, the agent's environment or the log. With no App, or one not installed there, the fetch is anonymous, which a public repository answers. The run's system prompt says what was checked out, or why nothing was (no pull request named, the fetch failed), so it can read the change another way, such as the GitHub MCP. The checkout is removed when the run's claim ends. An edit that leaves it out keeps the agent's; `none` clears it. A template sets it from its manifest's `checkout`.", "x-agentrun-serve": "checkout/1" },
3171
3211
  },
3172
3212
  AgentCreate: {
@@ -84,10 +84,13 @@ export interface RunLaunch {
84
84
  /** `false`: the run never starts on a learned workflow, even one that fits its input (RunCreate `workflow_first`,
85
85
  * runner/workflow-first.ts); its agent takes it from its first turn. Absent: a fitting one serves first. */
86
86
  readonly workflowFirst?: false;
87
- /** A replay run (runner/promotion.ts): learned workflow `workflow` at `digest`, run alone on graded run `of`'s input to
88
- * decide whether that revision serves first (learn/promote.ts). Its guards read record-only (learn/promote.ts recordOnly), a hand-back ends it
89
- * with no agent turn, and it asks nothing at its end. Absent: a run of its own. */
87
+ /** A replay run (runner/promotion.ts): learned workflow `workflow` at `digest`, run alone on the agent's own run `of`'s input to
88
+ * decide whether that revision serves first (learn/promote.ts). A hand-back ends it with no agent turn, and it asks nothing at its end. Absent: a run of its own. */
90
89
  readonly replay?: Replay;
90
+ /** A shadow run (runner/audit.ts): the audit of run `of`, which learned workflow `workflow` at `digest` served. The same
91
+ * agent on the same input with learning off: its answer is what the served answer is compared with (learn/audit.ts),
92
+ * it is no row of the run list, and it asks nothing at its end. Absent: a run of its own. */
93
+ readonly audit?: Replay;
91
94
  /** The trigger and firing that started the run, or none for a person's run. */
92
95
  readonly trigger?: RunTrigger;
93
96
  /** Who the first message is from, when not the person: kept only through the fail-safe below. */
@@ -70,6 +70,7 @@ export function launchBody(launch) {
70
70
  ...(launch.learning ? { learning: { given: launch.learning.given.map((note) => ({ file: note.file, name: note.name })), seed: launch.learning.seed, section: launch.learning.section, ...(launch.learning.seedNotes !== undefined ? { seedNotes: launch.learning.seedNotes } : {}), ...(launch.learning.notesLeftOut?.length ? { notesLeftOut: [...launch.learning.notesLeftOut] } : {}), ...(launch.learning.skills?.length ? { skills: [...launch.learning.skills] } : {}), ...(launch.learning.notesOnly ? { notesOnly: true } : {}), ...(launch.learning.workflows?.length ? { workflows: [...launch.learning.workflows] } : {}), ...(launch.learning.gradeModel ? { gradeModel: launch.learning.gradeModel } : {}), ...(launch.learning.seedFailed ? { seedFailed: launch.learning.seedFailed } : {}), ...(launch.learning.use ? { use: true } : {}) } } : {}),
71
71
  ...(launch.workflowFirst === false ? { workflow_first: false } : {}),
72
72
  ...(launch.replay ? { replay: { of: launch.replay.of, workflow: launch.replay.workflow, digest: launch.replay.digest } } : {}),
73
+ ...(launch.audit ? { audit: { of: launch.audit.of, workflow: launch.audit.workflow, digest: launch.audit.digest } } : {}),
73
74
  ...(launch.trigger ? { trigger: launch.trigger } : {}),
74
75
  ...(launch.inputOrigin ? { input_origin: launch.inputOrigin } : {}),
75
76
  ...(launch.followUp ? { follow_up: true } : {}),
@@ -124,6 +125,7 @@ export function readLaunchBody(stored) {
124
125
  ...(stored.learning !== undefined ? { learning: readLearning(stored.learning) ?? { given: [], seed: null, section: "" } } : {}),
125
126
  ...(stored.workflow_first === false ? { workflowFirst: false } : {}),
126
127
  ...(readReplay(stored.replay) ? { replay: readReplay(stored.replay) } : {}),
128
+ ...(readReplay(stored.audit) ? { audit: readReplay(stored.audit) } : {}),
127
129
  ...(trigger ? { trigger } : {}),
128
130
  ...(inputOrigin ? { inputOrigin } : {}),
129
131
  ...(stored.follow_up === true ? { followUp: true } : {}),
@@ -74,7 +74,7 @@ export declare function servedRunLearning(deps: {
74
74
  feedback_status: "running" | "ended" | "not_run" | null;
75
75
  source: "feedback" | "eval";
76
76
  graded_at: string;
77
- path: "agent" | "workflow" | "handed_back" | "replay";
77
+ path: "agent" | "workflow" | "handed_back" | "replay" | "audit";
78
78
  workflow_digest: string | null;
79
79
  feedback: "look_back" | null;
80
80
  run_id: string;
@@ -207,6 +207,10 @@ export interface AdapterRunSpec {
207
207
  * words the loop says so in on the run's timeline as it parks (computer-deps.ts computerKeptWords). Absent: a park lets
208
208
  * the computer go. */
209
209
  readonly keptWords?: string;
210
+ /** The run waits on no one (an audit's shadow run, runner/audit.ts AUDIT_PARKED): where it would park (an approval, a
211
+ * raise of its cap, a person's answer) it ends failed at once in these words, saying what it would wait on, every call
212
+ * still waiting withdrawn in the end's commit (parkClaim). Absent: it parks. */
213
+ readonly neverWaits?: string;
210
214
  /** What the spec's tool host bindings registered (tools.ts ToolHost's onConversation, beforeResume, beforeRelease),
211
215
  * run where main's per-run process runs them (app.ts): each agent conversation's creating commit, once the claim's
212
216
  * Harness is open and before anything in it resumes, and when the claim lets the run go (its end, a park, a
@@ -73,6 +73,14 @@ function cardOf(tool, shown, args) {
73
73
  const COMMAND_REQUEST_PREFIX = commandRequest(0).replace(/0$/, "");
74
74
  /** What a CLI's request held at a cut turn (TurnCut) is refused with: the turn ended at the person's question. */
75
75
  const TURN_CUT_AT_QUESTION = "the turn ended at its question to the person";
76
+ /** What a run that waits on no one (AdapterRunSpec.neverWaits) would have waited on, by its park's cause: its end says so. */
77
+ const WAITS_ON = {
78
+ approval: "a person's approval of a tool call",
79
+ answer: "a person's answer to its question",
80
+ cap: "a raise of its cap",
81
+ refusal: "a raise of its cap",
82
+ workflow: "a person's approval of a tool call",
83
+ };
76
84
  function turnCut() {
77
85
  let armedAt;
78
86
  let ask;
@@ -3767,6 +3775,12 @@ function adapterLoop(specOf, options, deps) {
3767
3775
  * the park cuts (its call held at the tool bridge) may still be streaming its answer: closed under it, its booking
3768
3776
  * would be lost and the next claim would book the turn cut, at an unknown price. Past the bound, it is that cut. */
3769
3777
  async function parkClaim(on, theGate, cause) {
3778
+ // A run that waits on no one (AdapterRunSpec.neverWaits) ends here instead: its park's entry (the ask, the budget, the
3779
+ // question) landed with it parked, and this end, in the same claim, withdraws what waits (writeEnd), books what it
3780
+ // spent, and lets nothing go parked.
3781
+ const never = specNow?.neverWaits;
3782
+ if (never !== undefined && root)
3783
+ return writeEnd(on, root, theGate, { state: "failed", summary: `${never}: it would wait on ${WAITS_ON[cause]}` }, []);
3770
3784
  await releaseHost(on);
3771
3785
  await bookingsSettled();
3772
3786
  await keepAtPark(on, cause);
@@ -3876,8 +3890,9 @@ function adapterLoop(specOf, options, deps) {
3876
3890
  ...(data.metrics !== undefined ? { metrics: data.metrics } : {}),
3877
3891
  };
3878
3892
  // A person's stop or cancel withdraws every call still waiting for its answer, in the end's own commit: the approval
3879
- // card reads answered (withdrawn), never waiting for good on a final run.
3880
- const byPerson = data.state === "stopped" || stopReason?.kind === "command";
3893
+ // card reads answered (withdrawn), never waiting for good on a final run. So does the end of a run that waits on no one
3894
+ // (neverWaits): the ask its park wrote is withdrawn with it.
3895
+ const byPerson = data.state === "stopped" || stopReason?.kind === "command" || specNow?.neverWaits !== undefined;
3881
3896
  // A cancel's calls read cancelled with their run; a stop's, withdrawn.
3882
3897
  const withdrawn = byPerson ? withdrawnAnswers(await entriesOf(theGate.journal, conversation.id, context), isoNow(), stopReason?.kind === "command" && stopReason.cancel ? "canceled" : "withdrawn") : [];
3883
3898
  // A CLI's call on the record from its gate and never sent (parked, or its runner gone before its send): its record ends
@@ -47,6 +47,7 @@ import { journalEntries } from "./journal-reader.js";
47
47
  import { hashedMcpOf, piShaped } from "../store-reads/journal.js";
48
48
  import { claimPromotion, promotionGate, replayCallsFor, replayClaimed, replayLaid, toolFlowsFor } from "./promotion.js";
49
49
  import { pathMetrics, servedOf, workflowFirstOf } from "./workflow-first.js";
50
+ import { AUDIT_PARKED, settleAudits, withAudit } from "./audit.js";
50
51
  import { pastRunsOverStore, runPathOverStore } from "../store-reads/learning.js";
51
52
  import { specBuilt } from "./spec-holds.js";
52
53
  import { archilClaim, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
@@ -429,7 +430,8 @@ async function adapterSpec(launch, run, deps, claim, holds) {
429
430
  const tierRoute = tierRoutes.get(by);
430
431
  return tierRoute && tierRoute.model === id ? capModelOf(tierRoute) : undefined;
431
432
  },
432
- // What its learning runs' grades took beside it, read by every gate with its own sessions (none: it queues none).
433
+ // What its learning runs' grades and its audit's shadow took beside it, read by every gate with its own sessions
434
+ // (none: it queues none).
433
435
  ...(besideOf ? { beside: besideOf } : {}),
434
436
  // The most requests on free models it makes, capped or not (AGENTRUN_FREE_MODEL_REQUESTS).
435
437
  freeRequests: freeModelRequestsOf(deps.env),
@@ -457,13 +459,17 @@ async function adapterSpec(launch, run, deps, claim, holds) {
457
459
  // chose them, scoped as the revision's own: each provider the run's gate does not deny, held by the run's one redactor,
458
460
  // onto the tools' environment alone. The model's route was built on the revision's keys above, so a decision key never
459
461
  // becomes its model's.
460
- // A replay run lays the workflow it replays record-only (runner/promotion.ts replayLaid).
462
+ // A replay run lays only the workflow it replays (runner/promotion.ts replayLaid).
461
463
  const laidFlows = replayLaid(launch, seedLaid?.workflows ?? []);
462
464
  // The learned workflow the run starts on, before its agent's first turn, when one fits its input (workflow-first.ts),
463
465
  // chosen before the learned_workflow tool is bound, so the tool runs the text that serves. Only a promoted digest
464
466
  // serves (runner/promotion.ts: replayed on the agent's graded inputs first, or promoted on its dry run with fewer than
465
467
  // five); while the folder's revision replays or is held, the champion (the digest promoted last) serves in its place
466
468
  // (laidFor). Or the one the money rule stopped, over the agent's past runs (costLineOf): the agent takes the run.
469
+ // The audits that finished since are written first (runner/audit.ts settleAudits): a hold they make decides this claim.
470
+ const audits = { store: deps.store, agentId: runRow.agentId, revisionId: runRow.revisionId, context, log, folder: learningFolder, shown, sealKey: deps.sealKey };
471
+ if (launch.learning && !launch.replay && !launch.audit)
472
+ await settleAudits(audits);
467
473
  const promotion = claimPromotion({
468
474
  store: deps.store, agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, launch, context, log, folder: learningFolder, shown, sealKey: deps.sealKey,
469
475
  });
@@ -581,8 +587,10 @@ async function adapterSpec(launch, run, deps, claim, holds) {
581
587
  // Its learning folder is where the run's place keeps it — Mode 1 the agent's folder under the data directory, Mode 2 the
582
588
  // agent's folder on THIS claim's Archil disk (the proposal is checked against the seed on the disk, never this machine's
583
589
  // local path) — so the end-of-run step reads the run's own Workspace, the one the run worked in.
584
- // A replay run asks nothing at its end: it is the promotion's, never the agent's to learn from.
585
- const endOfRun = launch.replay ? undefined : learningEndOfRun(launch, {
590
+ // A replay run or an audit's shadow run asks nothing at its end: it is the promotion's, never the agent's to learn from.
591
+ // A run the promoted workflow served first starts its shadow audit after the step, drawn at 1 in k (runner/audit.ts
592
+ // withAudit): at its end, so the shadow's cap is what the run's own left.
593
+ const endOfRun = launch.replay || launch.audit ? undefined : withAudit(learningEndOfRun(launch, {
586
594
  store: deps.store,
587
595
  data: deps.data,
588
596
  ...(deps.env ? { env: deps.env } : {}),
@@ -598,7 +606,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
598
606
  learningFolder: archil === undefined
599
607
  ? (agentId) => learningFolderOf(deps.data, agentId)
600
608
  : (agentId) => learningWorkspace({ mode: "archil", agentId, archil }),
601
- });
609
+ }), { ...audits, launch });
602
610
  return {
603
611
  adapter,
604
612
  session,
@@ -623,6 +631,9 @@ async function adapterSpec(launch, run, deps, claim, holds) {
623
631
  // The tool host's install lifecycle (its bindings' onConversation/beforeResume/beforeRelease), run by the adapter loop.
624
632
  lifecycle: life,
625
633
  agentId: runRow.agentId,
634
+ // An audit's shadow run waits on no one: where it would park (an approval, a raise of its cap, a person's answer) it
635
+ // ends at once, its row `parked` (runner/audit.ts).
636
+ ...(launch.audit ? { neverWaits: AUDIT_PARKED } : {}),
626
637
  // The run's computer as the claim made it, with the person's hold on a desktop or phone: the loop shows the hold up,
627
638
  // applies a take-over and a hand-back to it, and answers the computer call channel's rows on it.
628
639
  ...(loopComputer ? { computer: loopComputer } : {}),