@parcha/agentrun-serve 0.1.0-beta.30 → 0.1.0-beta.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +472 -0
- package/NOTICE +18 -0
- package/README.md +1042 -240
- package/dist/adapter-facts.d.ts +3 -0
- package/dist/adapter-facts.js +5 -0
- package/dist/adapters.d.ts +64 -140
- package/dist/adapters.js +153 -377
- package/dist/agents-store.d.ts +146 -0
- package/dist/agents-store.js +359 -0
- package/dist/agents.d.ts +12 -5
- package/dist/agents.js +40 -17
- package/dist/app.d.ts +2 -4
- package/dist/app.js +227 -97
- package/dist/approvals.d.ts +4 -0
- package/dist/approvals.js +7 -0
- package/dist/archil-routes.d.ts +45 -0
- package/dist/archil-routes.js +150 -0
- package/dist/archil-settings.d.ts +30 -0
- package/dist/archil-settings.js +34 -0
- package/dist/background.d.ts +2 -1
- package/dist/background.js +69 -29
- package/dist/bounds.d.ts +26 -0
- package/dist/bounds.js +137 -0
- package/dist/box-egress-vm.d.ts +126 -0
- package/dist/box-egress-vm.js +364 -0
- package/dist/box-egress.d.ts +19 -8
- package/dist/box-egress.js +27 -15
- package/dist/box-paths.d.ts +59 -0
- package/dist/box-paths.js +92 -0
- package/dist/box-relay-vm.d.ts +4 -0
- package/dist/box-relay-vm.js +103 -55
- package/dist/box-relay.d.ts +2 -0
- package/dist/box-relay.js +2 -2
- package/dist/boxes.d.ts +20 -3
- package/dist/boxes.js +67 -14
- package/dist/browser-commands.d.ts +43 -0
- package/dist/browser-commands.js +154 -0
- package/dist/browser-cost.d.ts +30 -3
- package/dist/browser-cost.js +276 -21
- package/dist/browser-live.d.ts +124 -0
- package/dist/browser-live.js +324 -0
- package/dist/browser-person.d.ts +168 -0
- package/dist/browser-person.js +769 -0
- package/dist/budget.d.ts +80 -0
- package/dist/budget.js +211 -0
- package/dist/cap.d.ts +274 -63
- package/dist/cap.js +599 -188
- package/dist/cli.js +226 -16
- package/dist/coding-tools.d.ts +13 -1
- package/dist/coding-tools.js +107 -5
- package/dist/computer-adb.d.ts +12 -0
- package/dist/computer-adb.js +14 -0
- package/dist/computer-commands.d.ts +103 -0
- package/dist/computer-commands.js +256 -0
- package/dist/computer-keys.d.ts +68 -0
- package/dist/computer-keys.js +148 -0
- package/dist/computer-routes.d.ts +38 -0
- package/dist/computer-routes.js +56 -0
- package/dist/computer-setting.d.ts +37 -0
- package/dist/computer-setting.js +47 -0
- package/dist/computer-view.d.ts +38 -0
- package/dist/computer-view.js +14 -0
- package/dist/computers.d.ts +137 -0
- package/dist/computers.js +197 -0
- package/dist/console/THIRD-PARTY-NOTICES.txt +25 -0
- package/dist/console/assets/index-35-7aeIZ.js +519 -0
- package/dist/console/assets/index-Cejbov-Y.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +2 -0
- package/dist/console-links.js +6 -0
- package/dist/decision-cap.d.ts +63 -0
- package/dist/decision-cap.js +163 -0
- package/dist/decision-rows.d.ts +5 -2
- package/dist/decision-rows.js +8 -6
- package/dist/decisions.d.ts +31 -4
- package/dist/decisions.js +66 -8
- package/dist/disk.d.ts +33 -0
- package/dist/disk.js +85 -0
- package/dist/door-line.d.ts +23 -0
- package/dist/door-line.js +83 -0
- package/dist/egress-proxy.d.ts +45 -0
- package/dist/egress-proxy.js +416 -0
- package/dist/egress-table.d.ts +24 -0
- package/dist/egress-table.js +165 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.js +22 -2
- package/dist/exa-keyless.js +1 -1
- package/dist/explain.d.ts +22 -0
- package/dist/explain.js +207 -0
- package/dist/faux-computers.d.ts +35 -0
- package/dist/faux-computers.js +126 -0
- package/dist/file-types.d.ts +4 -0
- package/dist/file-types.js +11 -0
- package/dist/files.d.ts +3 -32
- package/dist/files.js +9 -117
- package/dist/github-connection.d.ts +207 -0
- package/dist/github-connection.js +595 -0
- package/dist/github.d.ts +64 -0
- package/dist/github.js +119 -0
- package/dist/grade.d.ts +14 -44
- package/dist/grade.js +55 -233
- package/dist/graph-served.d.ts +23 -2
- package/dist/graph-served.js +44 -3
- package/dist/graph-view.d.ts +7 -3
- package/dist/graph-view.js +26 -15
- package/dist/handed-values.d.ts +23 -0
- package/dist/handed-values.js +36 -0
- package/dist/harness-app.d.ts +33 -4
- package/dist/harness-app.js +539 -85
- package/dist/harness-install.d.ts +120 -0
- package/dist/harness-install.js +359 -0
- package/dist/harness-opencode/adapter.js +42 -8
- package/dist/harness-opencode/facts.d.ts +2 -0
- package/dist/harness-opencode/facts.js +28 -0
- package/dist/harness-opencode/harness.d.ts +4 -0
- package/dist/harness-opencode/harness.js +38 -5
- package/dist/harness-opencode/host/policy.js +11 -3
- package/dist/harness-opencode/transcript.d.ts +25 -0
- package/dist/harness-opencode/transcript.js +81 -0
- package/dist/harness-table.d.ts +75 -0
- package/dist/harness-table.js +145 -0
- package/dist/harness.d.ts +7 -28
- package/dist/harness.js +15 -41
- package/dist/heard.d.ts +12 -0
- package/dist/heard.js +45 -0
- package/dist/helper-env.d.ts +4 -0
- package/dist/helper-env.js +14 -0
- package/dist/home-path.d.ts +0 -4
- package/dist/home-path.js +3 -17
- package/dist/host-check.d.ts +13 -0
- package/dist/host-check.js +35 -0
- package/dist/host-tools.d.ts +51 -8
- package/dist/host-tools.js +108 -117
- package/dist/host.d.ts +12 -6
- package/dist/host.js +30 -24
- package/dist/hosted-search.d.ts +3 -0
- package/dist/hosted-search.js +5 -3
- package/dist/import-proxy.d.ts +42 -0
- package/dist/import-proxy.js +105 -0
- package/dist/import-summary.js +4 -8
- package/dist/import-worker.d.ts +2 -3
- package/dist/import-worker.js +18 -16
- package/dist/import.d.ts +37 -17
- package/dist/import.js +208 -222
- package/dist/key-meta.d.ts +26 -0
- package/dist/key-meta.js +30 -0
- package/dist/key-refusal.d.ts +4 -1
- package/dist/key-refusal.js +20 -7
- package/dist/key-words.d.ts +37 -0
- package/dist/key-words.js +40 -0
- package/dist/learn/check.d.ts +3 -1
- package/dist/learn/check.js +2 -2
- package/dist/learn/commit.d.ts +86 -0
- package/dist/learn/commit.js +182 -0
- package/dist/learn/folder.d.ts +296 -0
- package/dist/learn/folder.js +796 -0
- package/dist/learn/grade.d.ts +25 -9
- package/dist/learn/grade.js +98 -50
- package/dist/learn/index.d.ts +2 -2
- package/dist/learn/index.js +2 -2
- package/dist/learn/learning.sh +366 -0
- package/dist/learn/reflect.d.ts +12 -5
- package/dist/learn/reflect.js +72 -41
- package/dist/learn/secrets.d.ts +15 -7
- package/dist/learn/secrets.js +66 -16
- package/dist/learn/seed-check.d.ts +74 -0
- package/dist/learn/seed-check.js +103 -0
- package/dist/learn/skills.d.ts +7 -1
- package/dist/learn/skills.js +21 -4
- package/dist/learned-workflow.d.ts +12 -2
- package/dist/learned-workflow.js +9 -5
- package/dist/learning-routes.d.ts +107 -31
- package/dist/learning-routes.js +358 -403
- package/dist/learning-run.d.ts +61 -54
- package/dist/learning-run.js +183 -205
- package/dist/learning-words.d.ts +10 -8
- package/dist/learning-words.js +29 -13
- package/dist/learning.d.ts +186 -113
- package/dist/learning.js +345 -381
- package/dist/live/stream.d.ts +30 -0
- package/dist/live/stream.js +175 -0
- package/dist/live/translate.d.ts +52 -0
- package/dist/live/translate.js +276 -0
- package/dist/llm.js +3 -0
- package/dist/llms.txt +1 -0
- package/dist/local-models.d.ts +23 -0
- package/dist/local-models.js +35 -0
- package/dist/mcp-gateway.d.ts +129 -0
- package/dist/mcp-gateway.js +508 -0
- package/dist/mcp-meta.d.ts +20 -0
- package/dist/mcp-meta.js +50 -0
- package/dist/mcp-oauth.d.ts +172 -0
- package/dist/mcp-oauth.js +403 -0
- package/dist/mcp-private-hosts.d.ts +48 -0
- package/dist/mcp-private-hosts.js +141 -0
- package/dist/mcp-probe.d.ts +101 -0
- package/dist/mcp-probe.js +359 -0
- package/dist/mcp-secret-writes.d.ts +23 -0
- package/dist/mcp-secret-writes.js +60 -0
- package/dist/mcp-servers-store.d.ts +251 -0
- package/dist/mcp-servers-store.js +447 -0
- package/dist/mcp-servers.d.ts +185 -34
- package/dist/mcp-servers.js +304 -298
- package/dist/mcp-store.d.ts +103 -0
- package/dist/mcp-store.js +123 -0
- package/dist/mcp.js +22 -21
- package/dist/model.d.ts +77 -59
- package/dist/model.js +237 -98
- package/dist/monid.d.ts +8 -6
- package/dist/monid.js +39 -25
- package/dist/openapi.d.ts +22 -1
- package/dist/openapi.js +965 -111
- package/dist/owner.d.ts +46 -10
- package/dist/owner.js +123 -43
- package/dist/page.d.ts +12 -0
- package/dist/page.js +28 -2
- package/dist/paid-calls.d.ts +71 -2
- package/dist/paid-calls.js +125 -5
- package/dist/pdf-pages.d.ts +16 -14
- package/dist/pdf-pages.js +88 -58
- package/dist/place.d.ts +18 -15
- package/dist/place.js +36 -18
- package/dist/port-models.d.ts +53 -0
- package/dist/port-models.js +93 -0
- package/dist/print.d.ts +7 -0
- package/dist/print.js +13 -0
- package/dist/propose.d.ts +9 -8
- package/dist/propose.js +82 -49
- package/dist/provider.d.ts +85 -0
- package/dist/provider.js +178 -0
- package/dist/push-handler.d.ts +52 -0
- package/dist/push-handler.js +165 -0
- package/dist/refusal-words.d.ts +23 -0
- package/dist/refusal-words.js +25 -0
- package/dist/request-start.d.ts +6 -1
- package/dist/request-start.js +41 -10
- package/dist/result.d.ts +13 -2
- package/dist/result.js +4 -5
- package/dist/run-box.d.ts +22 -3
- package/dist/run-box.js +91 -20
- package/dist/run-computer.d.ts +24 -0
- package/dist/run-computer.js +15 -0
- package/dist/run-cut.d.ts +33 -0
- package/dist/run-cut.js +42 -0
- package/dist/run-db.d.ts +64 -0
- package/dist/run-db.js +155 -0
- package/dist/run-files.d.ts +31 -0
- package/dist/run-files.js +125 -0
- package/dist/run-holder.d.ts +52 -0
- package/dist/run-holder.js +139 -0
- package/dist/run-launch.d.ts +72 -0
- package/dist/run-launch.js +108 -0
- package/dist/run-learning-served.d.ts +43 -0
- package/dist/run-learning-served.js +16 -0
- package/dist/run-manifest.d.ts +7 -6
- package/dist/run-manifest.js +20 -10
- package/dist/run-reads-over-store.d.ts +102 -0
- package/dist/run-reads-over-store.js +151 -0
- package/dist/run-timeline-served.d.ts +13 -0
- package/dist/run-timeline-served.js +69 -0
- package/dist/run-view.d.ts +436 -0
- package/dist/run-view.js +620 -0
- package/dist/runnable.d.ts +36 -4
- package/dist/runnable.js +157 -31
- package/dist/runner/adapter-loop.d.ts +237 -0
- package/dist/runner/adapter-loop.js +1625 -0
- package/dist/runner/adapter-run-spec.d.ts +216 -0
- package/dist/runner/adapter-run-spec.js +537 -0
- package/dist/runner/adapters/index.d.ts +37 -0
- package/dist/runner/adapters/index.js +66 -0
- package/dist/runner/adapters/pi.d.ts +99 -0
- package/dist/runner/adapters/pi.js +260 -0
- package/dist/runner/beside.d.ts +12 -0
- package/dist/runner/beside.js +30 -0
- package/dist/runner/claim-secrets.d.ts +30 -0
- package/dist/runner/claim-secrets.js +90 -0
- package/dist/runner/cli-run-spec.d.ts +17 -0
- package/dist/runner/cli-run-spec.js +371 -0
- package/dist/runner/commands.d.ts +23 -0
- package/dist/runner/commands.js +67 -0
- package/dist/runner/computer-journal.d.ts +38 -0
- package/dist/runner/computer-journal.js +120 -0
- package/dist/runner/conformance/child.d.ts +1 -0
- package/dist/runner/conformance/child.js +78 -0
- package/dist/runner/conformance/harness.d.ts +89 -0
- package/dist/runner/conformance/harness.js +928 -0
- package/dist/runner/conformance/subject.d.ts +83 -0
- package/dist/runner/conformance/subject.js +1 -0
- package/dist/runner/dispatch.d.ts +30 -0
- package/dist/runner/dispatch.js +99 -0
- package/dist/runner/end-of-run.d.ts +32 -0
- package/dist/runner/end-of-run.js +56 -0
- package/dist/runner/github-app.d.ts +16 -0
- package/dist/runner/github-app.js +37 -0
- package/dist/runner/hand-back.d.ts +43 -0
- package/dist/runner/hand-back.js +69 -0
- package/dist/runner/harness-loops.d.ts +10 -0
- package/dist/runner/harness-loops.js +70 -0
- package/dist/runner/journal-kinds.d.ts +211 -0
- package/dist/runner/journal-kinds.js +116 -0
- package/dist/runner/journal-reader.d.ts +44 -0
- package/dist/runner/journal-reader.js +127 -0
- package/dist/runner/learning-ask.d.ts +37 -0
- package/dist/runner/learning-ask.js +99 -0
- package/dist/runner/learning-dispatch.d.ts +38 -0
- package/dist/runner/learning-dispatch.js +75 -0
- package/dist/runner/learning-end.d.ts +31 -0
- package/dist/runner/learning-end.js +136 -0
- package/dist/runner/learning-factory.d.ts +13 -0
- package/dist/runner/learning-factory.js +37 -0
- package/dist/runner/learning-loop.d.ts +150 -0
- package/dist/runner/learning-loop.js +246 -0
- package/dist/runner/learning-seed.d.ts +30 -0
- package/dist/runner/learning-seed.js +41 -0
- package/dist/runner/live-ticker.d.ts +18 -0
- package/dist/runner/live-ticker.js +88 -0
- package/dist/runner/loop-contract.d.ts +153 -0
- package/dist/runner/loop-contract.js +26 -0
- package/dist/runner/loop.d.ts +79 -0
- package/dist/runner/loop.js +185 -0
- package/dist/runner/main.d.ts +89 -0
- package/dist/runner/main.js +282 -0
- package/dist/runner/mcp-claim.d.ts +67 -0
- package/dist/runner/mcp-claim.js +403 -0
- package/dist/runner/mcp-github.d.ts +53 -0
- package/dist/runner/mcp-github.js +91 -0
- package/dist/runner/mcp-run.d.ts +116 -0
- package/dist/runner/mcp-run.js +152 -0
- package/dist/runner/metrics.d.ts +18 -0
- package/dist/runner/metrics.js +24 -0
- package/dist/runner/model-route.d.ts +111 -0
- package/dist/runner/model-route.js +183 -0
- package/dist/runner/pi-stop.d.ts +6 -0
- package/dist/runner/pi-stop.js +8 -0
- package/dist/runner/redact.d.ts +26 -0
- package/dist/runner/redact.js +51 -0
- package/dist/runner/reflect-hook.d.ts +81 -0
- package/dist/runner/reflect-hook.js +111 -0
- package/dist/runner/runner.d.ts +114 -0
- package/dist/runner/runner.js +672 -0
- package/dist/runner/sessions.d.ts +9 -0
- package/dist/runner/sessions.js +145 -0
- package/dist/runner/side-effects.d.ts +19 -0
- package/dist/runner/side-effects.js +20 -0
- package/dist/runner/spec-holds.d.ts +41 -0
- package/dist/runner/spec-holds.js +58 -0
- package/dist/runner/store-port.d.ts +9 -0
- package/dist/runner/store-port.js +7 -0
- package/dist/runner/store-secrets.d.ts +11 -0
- package/dist/runner/store-secrets.js +105 -0
- package/dist/runner/workflow-adapters.d.ts +1 -0
- package/dist/runner/workflow-adapters.js +4 -0
- package/dist/runner/workflow-host.d.ts +88 -0
- package/dist/runner/workflow-host.js +66 -0
- package/dist/runner/workflow-loop.d.ts +126 -0
- package/dist/runner/workflow-loop.js +372 -0
- package/dist/runner/workflow-spec.d.ts +157 -0
- package/dist/runner/workflow-spec.js +801 -0
- package/dist/runs-over-store.d.ts +203 -0
- package/dist/runs-over-store.js +396 -0
- package/dist/runs.d.ts +360 -222
- package/dist/runs.js +1619 -536
- package/dist/seal-key.d.ts +30 -0
- package/dist/seal-key.js +141 -0
- package/dist/sealed-settings-store.d.ts +71 -0
- package/dist/sealed-settings-store.js +205 -0
- package/dist/sealed-settings.d.ts +60 -0
- package/dist/sealed-settings.js +178 -0
- package/dist/secret-writes.d.ts +147 -0
- package/dist/secret-writes.js +144 -0
- package/dist/secrets.d.ts +22 -0
- package/dist/secrets.js +37 -4
- package/dist/served-only.d.ts +5 -0
- package/dist/served-only.js +12 -0
- package/dist/server-approvers.d.ts +8 -0
- package/dist/server-approvers.js +12 -0
- package/dist/server-fs.d.ts +40 -0
- package/dist/server-fs.js +138 -0
- package/dist/server-keys.d.ts +18 -0
- package/dist/server-keys.js +31 -0
- package/dist/server-lock.js +1 -1
- package/dist/server-secrets-store.d.ts +18 -0
- package/dist/server-secrets-store.js +54 -0
- package/dist/server-secrets.d.ts +23 -0
- package/dist/server-secrets.js +73 -0
- package/dist/server.d.ts +152 -74
- package/dist/server.js +1757 -588
- package/dist/sessions.d.ts +3 -1
- package/dist/sessions.js +8 -4
- package/dist/sign-ins-secrets.d.ts +35 -0
- package/dist/sign-ins-secrets.js +109 -0
- package/dist/sign-ins-store.d.ts +200 -0
- package/dist/sign-ins-store.js +373 -0
- package/dist/sign-ins.d.ts +43 -7
- package/dist/sign-ins.js +94 -18
- package/dist/skills.d.ts +6 -5
- package/dist/skills.js +18 -14
- package/dist/standard-webhooks.d.ts +30 -0
- package/dist/standard-webhooks.js +72 -0
- package/dist/stats.d.ts +5 -7
- package/dist/stats.js +8 -24
- package/dist/stop-signals.d.ts +22 -0
- package/dist/stop-signals.js +38 -0
- package/dist/store/agent-body.d.ts +103 -0
- package/dist/store/agent-body.js +126 -0
- package/dist/store/dialect.d.ts +59 -0
- package/dist/store/dialect.js +32 -0
- package/dist/store/fence.d.ts +22 -0
- package/dist/store/fence.js +15 -0
- package/dist/store/index.d.ts +17 -0
- package/dist/store/index.js +17 -0
- package/dist/store/journal/storage.d.ts +137 -0
- package/dist/store/journal/storage.js +1021 -0
- package/dist/store/open.d.ts +34 -0
- package/dist/store/open.js +30 -0
- package/dist/store/postgres/connection.d.ts +74 -0
- package/dist/store/postgres/connection.js +532 -0
- package/dist/store/postgres/dialect.d.ts +9 -0
- package/dist/store/postgres/dialect.js +39 -0
- package/dist/store/postgres/migrate.d.ts +21 -0
- package/dist/store/postgres/migrate.js +106 -0
- package/dist/store/postgres/migrations/0001_initial.sql +418 -0
- package/dist/store/postgres/migrations/0002_external_agents.sql +14 -0
- package/dist/store/postgres/store.d.ts +37 -0
- package/dist/store/postgres/store.js +48 -0
- package/dist/store/prompts.d.ts +11 -0
- package/dist/store/prompts.js +112 -0
- package/dist/store/schema.d.ts +26 -0
- package/dist/store/schema.js +522 -0
- package/dist/store/seal.d.ts +48 -0
- package/dist/store/seal.js +69 -0
- package/dist/store/sqlite/connection.d.ts +105 -0
- package/dist/store/sqlite/connection.js +309 -0
- package/dist/store/sqlite/memory.d.ts +2 -0
- package/dist/store/sqlite/memory.js +4 -0
- package/dist/store/sqlite/run-launch.d.ts +8 -0
- package/dist/store/sqlite/run-launch.js +20 -0
- package/dist/store/sqlite/run-patch.d.ts +54 -0
- package/dist/store/sqlite/run-patch.js +114 -0
- package/dist/store/sqlite/store.d.ts +33 -0
- package/dist/store/sqlite/store.js +1337 -0
- package/dist/store/sqlite/worker.d.ts +78 -0
- package/dist/store/sqlite/worker.js +242 -0
- package/dist/store/store.d.ts +1253 -0
- package/dist/store/store.js +190 -0
- package/dist/store-reads/analytics.d.ts +55 -0
- package/dist/store-reads/analytics.js +135 -0
- package/dist/store-reads/cap.d.ts +17 -0
- package/dist/store-reads/cap.js +17 -0
- package/dist/store-reads/decisions.d.ts +5 -0
- package/dist/store-reads/decisions.js +31 -0
- package/dist/store-reads/import-summary.d.ts +6 -0
- package/dist/store-reads/import-summary.js +14 -0
- package/dist/store-reads/journal.d.ts +30 -0
- package/dist/store-reads/journal.js +120 -0
- package/dist/store-reads/learning.d.ts +93 -0
- package/dist/store-reads/learning.js +202 -0
- package/dist/store-reads/runs.d.ts +42 -0
- package/dist/store-reads/runs.js +84 -0
- package/dist/store-reads/stats.d.ts +30 -0
- package/dist/store-reads/stats.js +59 -0
- package/dist/store-reads/workflow.d.ts +7 -0
- package/dist/store-reads/workflow.js +14 -0
- package/dist/store-view.d.ts +37 -0
- package/dist/store-view.js +305 -0
- package/dist/template-eval.d.ts +239 -0
- package/dist/template-eval.js +1020 -0
- package/dist/template-github-permissions.d.ts +18 -0
- package/dist/template-github-permissions.js +32 -0
- package/dist/templates.d.ts +199 -0
- package/dist/templates.js +637 -0
- package/dist/tool-blurbs.d.ts +4 -0
- package/dist/tool-blurbs.js +27 -0
- package/dist/tool-gate.d.ts +183 -37
- package/dist/tool-gate.js +450 -99
- package/dist/tool-keys-store.d.ts +110 -0
- package/dist/tool-keys-store.js +291 -0
- package/dist/tool-keys.d.ts +27 -13
- package/dist/tool-keys.js +24 -10
- package/dist/tool-plane.d.ts +115 -25
- package/dist/tool-plane.js +251 -74
- package/dist/tool-settings-store.d.ts +30 -0
- package/dist/tool-settings-store.js +53 -0
- package/dist/tools.d.ts +95 -24
- package/dist/tools.js +344 -65
- package/dist/trigger-accept.d.ts +36 -0
- package/dist/trigger-accept.js +152 -0
- package/dist/trigger-adapter.d.ts +143 -0
- package/dist/trigger-adapter.js +31 -0
- package/dist/trigger-adapters.d.ts +2 -0
- package/dist/trigger-adapters.js +4 -0
- package/dist/trigger-github.d.ts +2 -0
- package/dist/trigger-github.js +85 -0
- package/dist/trigger-schedule.d.ts +6 -0
- package/dist/trigger-schedule.js +115 -0
- package/dist/trigger-secrets-shown.d.ts +66 -0
- package/dist/trigger-secrets-shown.js +77 -0
- package/dist/trigger-signatures.d.ts +58 -0
- package/dist/trigger-signatures.js +79 -0
- package/dist/trigger-targets.d.ts +46 -0
- package/dist/trigger-targets.js +95 -0
- package/dist/trigger-webhook.d.ts +2 -0
- package/dist/trigger-webhook.js +92 -0
- package/dist/triggers.d.ts +282 -237
- package/dist/triggers.js +720 -608
- package/dist/turn-end.d.ts +3 -0
- package/dist/turn-end.js +3 -0
- package/dist/uploads.d.ts +10 -8
- package/dist/uploads.js +45 -45
- package/dist/usage.d.ts +33 -3
- package/dist/usage.js +38 -4
- package/dist/validate.d.ts +6 -0
- package/dist/validate.js +42 -12
- package/dist/{fetch-page.d.ts → web-fetch-direct.d.ts} +2 -4
- package/dist/{fetch-page.js → web-fetch-direct.js} +2 -4
- package/dist/web-fetch.d.ts +17 -9
- package/dist/web-fetch.js +56 -21
- package/dist/web-search.d.ts +1 -1
- package/dist/web-search.js +1 -1
- package/dist/webhooks.d.ts +33 -23
- package/dist/webhooks.js +69 -56
- package/dist/wires.d.ts +11 -0
- package/dist/wires.js +7 -0
- package/dist/workspace/archil-claim.d.ts +57 -0
- package/dist/workspace/archil-claim.js +154 -0
- package/dist/workspace/archil-disk.d.ts +104 -0
- package/dist/workspace/archil-disk.js +254 -0
- package/dist/workspace/archil-exec.d.ts +59 -0
- package/dist/workspace/archil-exec.js +218 -0
- package/dist/workspace/archil-key.d.ts +17 -0
- package/dist/workspace/archil-key.js +30 -0
- package/dist/workspace/archil-mount-credential.d.ts +58 -0
- package/dist/workspace/archil-mount-credential.js +165 -0
- package/dist/workspace/archil.d.ts +59 -0
- package/dist/workspace/archil.js +676 -0
- package/dist/workspace/attach.d.ts +48 -0
- package/dist/workspace/attach.js +439 -0
- package/dist/workspace/computer-deps.d.ts +58 -0
- package/dist/workspace/computer-deps.js +113 -0
- package/dist/workspace/computer-for-claim.d.ts +115 -0
- package/dist/workspace/computer-for-claim.js +198 -0
- package/dist/workspace/computer-hold.d.ts +145 -0
- package/dist/workspace/computer-hold.js +258 -0
- package/dist/workspace/computer-ledger.d.ts +22 -0
- package/dist/workspace/computer-ledger.js +19 -0
- package/dist/workspace/computer-ports.d.ts +13 -0
- package/dist/workspace/computer-ports.js +108 -0
- package/dist/workspace/computer-providers.d.ts +12 -0
- package/dist/workspace/computer-providers.js +17 -0
- package/dist/workspace/computer-serves.d.ts +12 -0
- package/dist/workspace/computer-serves.js +15 -0
- package/dist/workspace/executors.d.ts +38 -0
- package/dist/workspace/executors.js +150 -0
- package/dist/workspace/glob.d.ts +2 -0
- package/dist/workspace/glob.js +25 -0
- package/dist/workspace/grep-worker.d.ts +11 -0
- package/dist/workspace/grep-worker.js +91 -0
- package/dist/workspace/hands.d.ts +25 -0
- package/dist/workspace/hands.js +121 -0
- package/dist/workspace/index.d.ts +23 -0
- package/dist/workspace/index.js +25 -0
- package/dist/workspace/kind-skills/desktop/SKILL.md +106 -0
- package/dist/workspace/kind-skills/phone/SKILL.md +116 -0
- package/dist/workspace/kind-skills.d.ts +11 -0
- package/dist/workspace/kind-skills.js +16 -0
- package/dist/workspace/learning-workspace.d.ts +24 -0
- package/dist/workspace/learning-workspace.js +107 -0
- package/dist/workspace/local.d.ts +6 -0
- package/dist/workspace/local.js +632 -0
- package/dist/workspace/paths.d.ts +48 -0
- package/dist/workspace/paths.js +134 -0
- package/dist/workspace/pi-env.d.ts +39 -0
- package/dist/workspace/pi-env.js +397 -0
- package/dist/workspace/place.d.ts +7 -0
- package/dist/workspace/place.js +3 -0
- package/dist/workspace/resolve-computer.d.ts +106 -0
- package/dist/workspace/resolve-computer.js +188 -0
- package/dist/workspace/revision-skills.d.ts +15 -0
- package/dist/workspace/revision-skills.js +42 -0
- package/dist/workspace/run-tools.d.ts +173 -0
- package/dist/workspace/run-tools.js +172 -0
- package/dist/workspace/run-workspace.d.ts +25 -0
- package/dist/workspace/run-workspace.js +56 -0
- package/dist/workspace/server-run-workspace.d.ts +24 -0
- package/dist/workspace/server-run-workspace.js +84 -0
- package/dist/workspace/workspace.d.ts +169 -0
- package/dist/workspace/workspace.js +54 -0
- package/dist/workspace-paths.d.ts +1 -10
- package/dist/workspace-paths.js +3 -37
- package/dist/workspace.d.ts +3 -17
- package/dist/workspace.js +6 -74
- package/harnesses/claude-agent/package-lock.json +1533 -0
- package/harnesses/claude-agent/package.json +7 -0
- package/harnesses/codex/package-lock.json +135 -0
- package/harnesses/codex/package.json +7 -0
- package/launcher/agentrun-serve +13 -3
- package/package.json +36 -25
- package/skills/agentrun-serve/SKILL.md +2 -0
- package/templates/README.md +211 -0
- package/templates/code-review/agent.md +50 -0
- package/templates/code-review/evals/clean-refactor/case.yaml +3 -0
- package/templates/code-review/evals/clean-refactor/graders/empty.md +5 -0
- package/templates/code-review/evals/clean-refactor/graders/schema.md +5 -0
- package/templates/code-review/evals/clean-refactor/prompt.md +31 -0
- package/templates/code-review/evals/injection/case.yaml +3 -0
- package/templates/code-review/evals/injection/graders/ignores.md +4 -0
- package/templates/code-review/evals/injection/graders/schema.md +5 -0
- package/templates/code-review/evals/injection/prompt.md +23 -0
- package/templates/code-review/evals/null-name/case.yaml +3 -0
- package/templates/code-review/evals/null-name/graders/finds.md +4 -0
- package/templates/code-review/evals/null-name/graders/schema.md +5 -0
- package/templates/code-review/evals/null-name/prompt.md +17 -0
- package/templates/code-review/evals/off-by-one/case.yaml +3 -0
- package/templates/code-review/evals/off-by-one/graders/finds.md +4 -0
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +11 -0
- package/templates/code-review/evals/off-by-one/graders/schema.md +5 -0
- package/templates/code-review/evals/off-by-one/prompt.md +20 -0
- package/templates/code-review/evals/re-review/case.yaml +3 -0
- package/templates/code-review/evals/re-review/graders/resolves.md +4 -0
- package/templates/code-review/evals/re-review/graders/schema.md +5 -0
- package/templates/code-review/evals/re-review/prompt.md +23 -0
- package/templates/code-review/evals/repo-rule/case.yaml +3 -0
- package/templates/code-review/evals/repo-rule/graders/cites.md +4 -0
- package/templates/code-review/evals/repo-rule/graders/schema.md +5 -0
- package/templates/code-review/evals/repo-rule/prompt.md +31 -0
- package/templates/code-review/findings.schema.json +125 -0
- package/templates/code-review/rules/REVIEW.md +41 -0
- package/templates/code-review/skills/review/SKILL.md +162 -0
- package/templates/inbound-lead/agent.md +76 -0
- package/templates/inbound-lead/evals/clear-disqualifier/case.yaml +5 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/action.md +5 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/disqualifier.md +18 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/score-formula.md +26 -0
- package/templates/inbound-lead/evals/clear-disqualifier/prompt.md +12 -0
- package/templates/inbound-lead/evals/injection-in-form/case.yaml +5 -0
- package/templates/inbound-lead/evals/injection-in-form/graders/flagged.md +5 -0
- package/templates/inbound-lead/evals/injection-in-form/graders/ignores-it.md +19 -0
- package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/injection-in-form/prompt.md +12 -0
- package/templates/inbound-lead/evals/learned-correction/case.yaml +8 -0
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +1 -0
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +14 -0
- package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +21 -0
- package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +5 -0
- package/templates/inbound-lead/evals/learned-correction/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/learned-correction/prompt.md +12 -0
- package/templates/inbound-lead/evals/strong-fit/case.yaml +5 -0
- package/templates/inbound-lead/evals/strong-fit/graders/book-call.md +5 -0
- package/templates/inbound-lead/evals/strong-fit/graders/fit.md +21 -0
- package/templates/inbound-lead/evals/strong-fit/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/strong-fit/graders/score-formula.md +26 -0
- package/templates/inbound-lead/evals/strong-fit/prompt.md +12 -0
- package/templates/inbound-lead/evals/thin-data/case.yaml +5 -0
- package/templates/inbound-lead/evals/thin-data/graders/personal-email.md +5 -0
- package/templates/inbound-lead/evals/thin-data/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/thin-data/graders/unknowns.md +17 -0
- package/templates/inbound-lead/evals/thin-data/prompt.md +12 -0
- package/templates/inbound-lead/evals/write-back/case.yaml +16 -0
- package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +266 -0
- package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +22 -0
- package/templates/inbound-lead/evals/write-back/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +7 -0
- package/templates/inbound-lead/evals/write-back/prompt.md +12 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +18 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +266 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +7 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +18 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +12 -0
- package/templates/inbound-lead/lead.schema.json +587 -0
- package/templates/inbound-lead/rules/FLAGS.md +43 -0
- package/templates/inbound-lead/rules/RUBRIC.md +73 -0
- package/templates/inbound-lead/skills/lead/SKILL.md +130 -0
- package/templates/kyb/agent.md +44 -0
- package/templates/kyb/evals/adverse-media/case.yaml +4 -0
- package/templates/kyb/evals/adverse-media/graders/dated-and-graded.md +25 -0
- package/templates/kyb/evals/adverse-media/graders/schema.md +5 -0
- package/templates/kyb/evals/adverse-media/prompt.md +12 -0
- package/templates/kyb/evals/canada-active-filed/case.yaml +4 -0
- package/templates/kyb/evals/canada-active-filed/graders/no-boilerplate-flags.md +22 -0
- package/templates/kyb/evals/canada-active-filed/graders/schema.md +5 -0
- package/templates/kyb/evals/canada-active-filed/prompt.md +43 -0
- package/templates/kyb/evals/clean-public-company/case.yaml +4 -0
- package/templates/kyb/evals/clean-public-company/graders/cited-and-proceed.md +23 -0
- package/templates/kyb/evals/clean-public-company/graders/schema.md +5 -0
- package/templates/kyb/evals/clean-public-company/prompt.md +11 -0
- package/templates/kyb/evals/injection-in-page/case.yaml +4 -0
- package/templates/kyb/evals/injection-in-page/fixtures/compliance-page.html +29 -0
- package/templates/kyb/evals/injection-in-page/graders/ignores-it.md +35 -0
- package/templates/kyb/evals/injection-in-page/graders/schema.md +5 -0
- package/templates/kyb/evals/injection-in-page/prompt.md +47 -0
- package/templates/kyb/evals/name-collision/case.yaml +4 -0
- package/templates/kyb/evals/name-collision/graders/never-merges.md +24 -0
- package/templates/kyb/evals/name-collision/graders/schema.md +5 -0
- package/templates/kyb/evals/name-collision/prompt.md +11 -0
- package/templates/kyb/evals/no-invention/case.yaml +4 -0
- package/templates/kyb/evals/no-invention/graders/invents-nothing.md +22 -0
- package/templates/kyb/evals/no-invention/graders/schema.md +5 -0
- package/templates/kyb/evals/no-invention/prompt.md +11 -0
- package/templates/kyb/evals/sanctioned-entity/case.yaml +6 -0
- package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/ADD.CSV.txt +13 -0
- package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/ALT.CSV.txt +12 -0
- package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/SDN.CSV.txt +9 -0
- package/templates/kyb/evals/sanctioned-entity/graders/cites-the-entry.md +6 -0
- package/templates/kyb/evals/sanctioned-entity/graders/finds-the-hit.md +27 -0
- package/templates/kyb/evals/sanctioned-entity/graders/schema.md +5 -0
- package/templates/kyb/evals/sanctioned-entity/prompt.md +65 -0
- package/templates/kyb/kyb.schema.json +274 -0
- package/templates/kyb/rules/ADVERSE-MEDIA.md +84 -0
- package/templates/kyb/rules/RED-FLAGS.md +68 -0
- package/templates/kyb/rules/SANCTIONS.md +140 -0
- package/templates/kyb/rules/SOURCES.md +92 -0
- package/templates/kyb/skills/kyb/SKILL.md +285 -0
- package/templates/market-monitor/agent.md +58 -0
- package/templates/market-monitor/digest.schema.json +194 -0
- package/templates/market-monitor/evals/blocked-source/case.yaml +4 -0
- package/templates/market-monitor/evals/blocked-source/graders/blocked-said.md +17 -0
- package/templates/market-monitor/evals/blocked-source/graders/schema.md +5 -0
- package/templates/market-monitor/evals/blocked-source/prompt.md +37 -0
- package/templates/market-monitor/evals/every-competitor-named/case.yaml +4 -0
- package/templates/market-monitor/evals/every-competitor-named/graders/every-company-named.md +16 -0
- package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +5 -0
- package/templates/market-monitor/evals/every-competitor-named/prompt.md +44 -0
- package/templates/market-monitor/evals/learned-preference/case.yaml +7 -0
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +1 -0
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +8 -0
- package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +17 -0
- package/templates/market-monitor/evals/learned-preference/graders/schema.md +5 -0
- package/templates/market-monitor/evals/learned-preference/prompt.md +25 -0
- package/templates/market-monitor/evals/no-repeats/case.yaml +4 -0
- package/templates/market-monitor/evals/no-repeats/graders/no-pulse-repeat.md +20 -0
- package/templates/market-monitor/evals/no-repeats/graders/schema.md +5 -0
- package/templates/market-monitor/evals/no-repeats/prompt.md +30 -0
- package/templates/market-monitor/evals/nothing-changed/case.yaml +4 -0
- package/templates/market-monitor/evals/nothing-changed/graders/quiet-no-inventions.md +20 -0
- package/templates/market-monitor/evals/nothing-changed/graders/schema.md +5 -0
- package/templates/market-monitor/evals/nothing-changed/prompt.md +44 -0
- package/templates/market-monitor/evals/post-happens/case.yaml +11 -0
- package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +31 -0
- package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +18 -0
- package/templates/market-monitor/evals/post-happens/graders/posted-once.md +10 -0
- package/templates/market-monitor/evals/post-happens/graders/schema.md +5 -0
- package/templates/market-monitor/evals/post-happens/prompt.md +20 -0
- package/templates/market-monitor/evals/pricing-change/case.yaml +4 -0
- package/templates/market-monitor/evals/pricing-change/graders/both-prices.md +5 -0
- package/templates/market-monitor/evals/pricing-change/graders/fetch-plan.md +16 -0
- package/templates/market-monitor/evals/pricing-change/graders/price-change-linked.md +20 -0
- package/templates/market-monitor/evals/pricing-change/graders/schema.md +5 -0
- package/templates/market-monitor/evals/pricing-change/prompt.md +31 -0
- package/templates/market-monitor/evals/pricing-moved/case.yaml +4 -0
- package/templates/market-monitor/evals/pricing-moved/graders/found-the-plans-page.md +16 -0
- package/templates/market-monitor/evals/pricing-moved/graders/schema.md +5 -0
- package/templates/market-monitor/evals/pricing-moved/prompt.md +29 -0
- package/templates/market-monitor/rules/MONITOR.md +33 -0
- package/templates/market-monitor/skills/monitor/SKILL.md +190 -0
- package/templates/release-notes/agent.md +47 -0
- package/templates/release-notes/evals/draft-not-publish/case.yaml +22 -0
- package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +915 -0
- package/templates/release-notes/evals/draft-not-publish/graders/draft-issue-written.md +9 -0
- package/templates/release-notes/evals/draft-not-publish/graders/issue-body.md +15 -0
- package/templates/release-notes/evals/draft-not-publish/graders/never-overwrite.md +8 -0
- package/templates/release-notes/evals/draft-not-publish/graders/schema.md +5 -0
- package/templates/release-notes/evals/draft-not-publish/prompt.md +32 -0
- package/templates/release-notes/evals/every-pr-accounted/case.yaml +3 -0
- package/templates/release-notes/evals/every-pr-accounted/graders/each-pr-once-in-table.md +8 -0
- package/templates/release-notes/evals/every-pr-accounted/graders/revert-and-unclear.md +14 -0
- package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +5 -0
- package/templates/release-notes/evals/every-pr-accounted/prompt.md +107 -0
- package/templates/release-notes/evals/issue-write-refused/case.yaml +22 -0
- package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +902 -0
- package/templates/release-notes/evals/issue-write-refused/graders/refusal-said-plainly.md +19 -0
- package/templates/release-notes/evals/issue-write-refused/graders/schema.md +5 -0
- package/templates/release-notes/evals/issue-write-refused/graders/wrote-issue.md +6 -0
- package/templates/release-notes/evals/issue-write-refused/prompt.md +32 -0
- package/templates/release-notes/evals/late-arrival/case.yaml +21 -0
- package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +866 -0
- package/templates/release-notes/evals/late-arrival/graders/late-pr-in-notes.md +14 -0
- package/templates/release-notes/evals/late-arrival/graders/late-pr-row.md +7 -0
- package/templates/release-notes/evals/late-arrival/graders/no-previous-release-pr.md +7 -0
- package/templates/release-notes/evals/late-arrival/graders/schema.md +5 -0
- package/templates/release-notes/evals/late-arrival/graders/walks-previous-end.md +8 -0
- package/templates/release-notes/evals/late-arrival/prompt.md +6 -0
- package/templates/release-notes/evals/learned-style/case.yaml +8 -0
- package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +1 -0
- package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +13 -0
- package/templates/release-notes/evals/learned-style/graders/no-bot.md +8 -0
- package/templates/release-notes/evals/learned-style/graders/same-changes.md +10 -0
- package/templates/release-notes/evals/learned-style/graders/schema.md +5 -0
- package/templates/release-notes/evals/learned-style/prompt.md +71 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +3 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/no-hash-number-on-top.md +8 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/no-pr-link-on-top.md +7 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +5 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/table-heading.md +7 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/prompt.md +62 -0
- package/templates/release-notes/evals/upgrade-line/case.yaml +5 -0
- package/templates/release-notes/evals/upgrade-line/graders/chore-bump-upgrading.md +16 -0
- package/templates/release-notes/evals/upgrade-line/graders/duplicate-keys-in-upgrading.md +8 -0
- package/templates/release-notes/evals/upgrade-line/graders/old-flag-in-upgrading.md +7 -0
- package/templates/release-notes/evals/upgrade-line/graders/schema.md +5 -0
- package/templates/release-notes/evals/upgrade-line/graders/upgrading-says-what-to-do.md +14 -0
- package/templates/release-notes/evals/upgrade-line/prompt.md +78 -0
- package/templates/release-notes/evals/user-facing-only/case.yaml +4 -0
- package/templates/release-notes/evals/user-facing-only/graders/ci-out-of-top.md +14 -0
- package/templates/release-notes/evals/user-facing-only/graders/no-windows.md +8 -0
- package/templates/release-notes/evals/user-facing-only/graders/nothing-invented.md +13 -0
- package/templates/release-notes/evals/user-facing-only/graders/schema.md +5 -0
- package/templates/release-notes/evals/user-facing-only/prompt.md +113 -0
- package/templates/release-notes/notes.schema.json +145 -0
- package/templates/release-notes/rules/STYLE.md +47 -0
- package/templates/release-notes/skills/release-notes/SKILL.md +311 -0
- package/dist/console/assets/index-34jfpIbQ.js +0 -481
- package/dist/console/assets/index-DUHbWcIP.css +0 -1
- package/dist/trigger-secrets.d.ts +0 -32
- package/dist/trigger-secrets.js +0 -143
|
@@ -0,0 +1,928 @@
|
|
|
1
|
+
// The harness conformance suite (kernel page: "One conformance suite proves every adapter durable"; a new harness ships
|
|
2
|
+
// when it passes). Harness-agnostic: it owns a store in a data directory of its own, the runners, the tools, the crash
|
|
3
|
+
// and the checks, and reads the run's journal with the kernel's one reader. A harness hands it a ConformanceSubject.
|
|
4
|
+
//
|
|
5
|
+
// The crash: at one of the kernel's two points a hook kills the runner (runner.kill(): no renew, no release) and never
|
|
6
|
+
// resolves, so that loop is frozen as a dead process's would be; a second runner reclaims the run once its claim runs out
|
|
7
|
+
// and resumes it from the journal, and any late write of the frozen loop is fenced.
|
|
8
|
+
// Cases 1 and 2 run twice: with the loop frozen in-process, and with the first runner a process of its own (child.ts)
|
|
9
|
+
// that SIGKILLs itself at the point, since a frozen loop can hide a write a real crash would cut.
|
|
10
|
+
import assert from "node:assert/strict";
|
|
11
|
+
import { execFileSync, spawn } from "node:child_process";
|
|
12
|
+
import { randomBytes } from "node:crypto";
|
|
13
|
+
import { once } from "node:events";
|
|
14
|
+
import { appendFileSync, existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
import { tmpdir } from "node:os";
|
|
17
|
+
import { join } from "node:path";
|
|
18
|
+
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
19
|
+
import { dropPostgresSchema, openPostgresStore, openStore, RunFinal, StoreConstraint, storeTarget } from "../../store/index.js";
|
|
20
|
+
import { sendCommand } from "../commands.js";
|
|
21
|
+
import { callsOf, journalRecords, messagesOf } from "../journal-reader.js";
|
|
22
|
+
import { KINDS } from "../journal-kinds.js";
|
|
23
|
+
import { timelineReducer } from "@parcha/pi-durable-agent/timeline";
|
|
24
|
+
import { emptyState, translate } from "../../live/translate.js";
|
|
25
|
+
/** The one row a person's stop gives on the live timeline (live/translate.ts STOPPED_BY_YOU), the same on every harness. */
|
|
26
|
+
const STOPPED_BY_YOU = "Stopped by you";
|
|
27
|
+
import { startRunner } from "../runner.js";
|
|
28
|
+
// interruptBackoffMs at the suite's scale: a run whose Session closes itself (the fault cases) is claimed again after it.
|
|
29
|
+
const TIMING = { leaseMs: 600, renewEveryMs: 150, stopMarginMs: 200, pollMs: 20, commandPollMs: 30, interruptBackoffMs: 20 };
|
|
30
|
+
/** The most times a kernel restarts a faulting task before the run fails: every harness's bound is at most this. */
|
|
31
|
+
export const MAX_RESTARTS = 5;
|
|
32
|
+
/** A lease no missed renew lets lapse within a case: every runner's, the crash cases' too. A claim is lost only where a
|
|
33
|
+
* case loses it: a crashed or stopped runner's claim runs out when the case moves the stores' clock past its until
|
|
34
|
+
* (runOut), never by waiting for a short real lease, so a starved box can neither lose a claim early nor late. Longer
|
|
35
|
+
* than a case's bound (CASE_TIMEOUT_MS): a takeover the clock did not drive fails the case, it never waits a lease out. */
|
|
36
|
+
const STEADY = { leaseMs: 600_000, renewEveryMs: 20_000, stopMarginMs: 5_000 };
|
|
37
|
+
/** The suite's runner process (child.ts): the steady lease, with a short renew tick, so a process that goes on after
|
|
38
|
+
* its claim ran out (the stalled case) hears its renew answered Fenced within one tick. */
|
|
39
|
+
export const CONFORMANCE_PROCESS_TIMING = { ...TIMING, ...STEADY, renewEveryMs: TIMING.renewEveryMs };
|
|
40
|
+
/** How far the stores' clock moves to run a lost claim out (runOut): past any claim's until under the steady lease. */
|
|
41
|
+
const RUN_OUT_MS = STEADY.leaseMs * 2;
|
|
42
|
+
const RUN = "run-1";
|
|
43
|
+
/** A case's bound, and the cap on a wait for a runner process's own event: caps on waits for events, never a sleep. */
|
|
44
|
+
const CASE_TIMEOUT_MS = 180_000;
|
|
45
|
+
const EVENT_WAIT_MS = 60_000;
|
|
46
|
+
/** A cancelled run's summary, as main's cancel ends a run: its state stopped, its summary "cancelled" (runs.ts settle). */
|
|
47
|
+
const CANCELLED = "cancelled";
|
|
48
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
49
|
+
async function until(check, what, ms = 10_000) {
|
|
50
|
+
const deadline = Date.now() + ms;
|
|
51
|
+
for (;;) {
|
|
52
|
+
const value = await check();
|
|
53
|
+
if (value)
|
|
54
|
+
return value;
|
|
55
|
+
if (Date.now() > deadline)
|
|
56
|
+
throw new Error(`not within ${ms} ms: ${what}`);
|
|
57
|
+
await sleep(10);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const never = () => new Promise(() => { });
|
|
61
|
+
/** The suite's tools, with how many times each ran (outside the journal, as a real side effect would be counted). */
|
|
62
|
+
export function suiteTools(countFile) {
|
|
63
|
+
// Counted in memory, or in a file when a runner in another process runs them too (a line per run).
|
|
64
|
+
const memory = { effect: 0, read: 0, slow: 0, asked: 0 };
|
|
65
|
+
const count = (name) => countFile ? (existsSync(countFile) ? readFileSync(countFile, "utf8").split("\n").filter((line) => line === name).length : 0) : memory[name];
|
|
66
|
+
const ran = {
|
|
67
|
+
get effect() { return count("effect"); },
|
|
68
|
+
get read() { return count("read"); },
|
|
69
|
+
get slow() { return count("slow"); },
|
|
70
|
+
get asked() { return count("asked"); },
|
|
71
|
+
set effect(_) { bump("effect"); },
|
|
72
|
+
set read(_) { bump("read"); },
|
|
73
|
+
set slow(_) { bump("slow"); },
|
|
74
|
+
set asked(_) { bump("asked"); },
|
|
75
|
+
};
|
|
76
|
+
function bump(name) {
|
|
77
|
+
if (countFile)
|
|
78
|
+
appendFileSync(countFile, `${name}\n`);
|
|
79
|
+
else
|
|
80
|
+
memory[name] += 1;
|
|
81
|
+
}
|
|
82
|
+
let letGo = () => { };
|
|
83
|
+
const slowGate = new Promise((resolve) => (letGo = resolve));
|
|
84
|
+
let slowStarted = () => { };
|
|
85
|
+
const started = new Promise((resolve) => (slowStarted = resolve));
|
|
86
|
+
const tool = (name, replaySafe, ask, run) => ({ name, replaySafe, ask, run });
|
|
87
|
+
const tools = {
|
|
88
|
+
effect: tool("effect", false, false, async () => {
|
|
89
|
+
ran.effect += 1;
|
|
90
|
+
return "the effect happened";
|
|
91
|
+
}),
|
|
92
|
+
read: tool("read", true, false, async () => {
|
|
93
|
+
ran.read += 1;
|
|
94
|
+
return "read";
|
|
95
|
+
}),
|
|
96
|
+
slow: tool("slow", true, false, async (_args, signal) => {
|
|
97
|
+
ran.slow += 1;
|
|
98
|
+
slowStarted();
|
|
99
|
+
await Promise.race([slowGate, new Promise((resolve) => signal.addEventListener("abort", () => resolve(), { once: true }))]);
|
|
100
|
+
return signal.aborted ? "cut" : "slow done";
|
|
101
|
+
}),
|
|
102
|
+
asked: tool("asked", false, true, async () => {
|
|
103
|
+
ran.asked += 1;
|
|
104
|
+
return "asked done";
|
|
105
|
+
}),
|
|
106
|
+
};
|
|
107
|
+
return { tools, ran, letSlowGo: () => letGo(), slowStarted: started };
|
|
108
|
+
}
|
|
109
|
+
const quiet = { beforeIntent: async () => { }, beforeResult: async () => { } };
|
|
110
|
+
/** Hooks that crash the runner held in `holder` at `point`, once: kill() and never resolve. */
|
|
111
|
+
function crashAt(point, holder) {
|
|
112
|
+
const crash = async () => {
|
|
113
|
+
if (holder.crashed)
|
|
114
|
+
return;
|
|
115
|
+
holder.crashed = true;
|
|
116
|
+
holder.runner?.kill();
|
|
117
|
+
await never();
|
|
118
|
+
};
|
|
119
|
+
return {
|
|
120
|
+
beforeIntent: async () => (point === "beforeIntent" ? crash() : undefined),
|
|
121
|
+
beforeResult: async () => (point === "beforeResult" ? crash() : undefined),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/** The Postgres store each registered subject's worlds open (registerHarnessConformance's `storeUrl`), by the subject
|
|
125
|
+
* object the suite's cases are handed: none for the data directory's SQLite store. */
|
|
126
|
+
const STORE_URLS = new WeakMap();
|
|
127
|
+
/** Cases a Postgres store can't pass yet, each with what it waits on: they run on SQLite and are skipped on Postgres. */
|
|
128
|
+
const POSTGRES_PENDING = {
|
|
129
|
+
"approval-double-click": "waits on the Postgres commands_one_answer migration (pgstore-1): the one-answer index is SQLite's today",
|
|
130
|
+
};
|
|
131
|
+
/** A store in a data directory of its own, one queued run, and runners started on it (each its own connection). */
|
|
132
|
+
/** The suite's short lease, for the crash cases: a crashed runner's claim must run out for the second runner to take
|
|
133
|
+
* the run over. */
|
|
134
|
+
const TAKEOVER = {};
|
|
135
|
+
/** The stores' clock skew a runner process reads (child.ts): the file holds the milliseconds the clock moved, so the
|
|
136
|
+
* process's store moves with the case's (runOut). */
|
|
137
|
+
export const storeClockOf = (file) => {
|
|
138
|
+
if (!file)
|
|
139
|
+
return () => Date.now();
|
|
140
|
+
return () => Date.now() + (existsSync(file) ? Number(readFileSync(file, "utf8")) || 0 : 0);
|
|
141
|
+
};
|
|
142
|
+
/** Opens a store of a case's world (the server's, a runner's, a runner process's: child.ts) on the case's clock, real time
|
|
143
|
+
* plus its skew (storeClockOf `clockFile`), so runOut moves the clock every store judges a lease on. SQLite judges a lease
|
|
144
|
+
* on its store clock `now`. Postgres judges one on the database's clock (store/postgres/dialect.ts DATABASE_NOW_MS), which
|
|
145
|
+
* no skew file moves: a crashed runner's claim would hold for the steady lease's 10 real minutes and nobody take the run
|
|
146
|
+
* over. So on Postgres the case's clock is the store's test clock (testClock), bound into every deadline as SQLite binds
|
|
147
|
+
* its own, as the store's tests do (test/store-helpers.mjs). */
|
|
148
|
+
export function openCaseStore({ dataDir, role, url, env, clockFile }) {
|
|
149
|
+
const now = storeClockOf(clockFile);
|
|
150
|
+
const target = storeTarget(dataDir, env, url);
|
|
151
|
+
if (target.kind === "sqlite")
|
|
152
|
+
return openStore({ dataDir, role, now, url, env });
|
|
153
|
+
return openPostgresStore({ url: target.url, schema: target.schema, role, testClock: now });
|
|
154
|
+
}
|
|
155
|
+
/** A store in a data directory of its own, one queued run, and runners started on it (each its own connection). Every
|
|
156
|
+
* store's clock is real time plus the case's skew (runOut), a runner process's too, through `clockFile`. */
|
|
157
|
+
async function world(subject, t, timing = STEADY) {
|
|
158
|
+
const dir = mkdtempSync(join(process.env.TMPDIR ?? tmpdir(), "agentrun-conformance-"));
|
|
159
|
+
// The store the suite was handed (store/open.ts): on Postgres, a schema of this world's own, dropped after it. The URL
|
|
160
|
+
// goes to each opener by hand, and to a runner process in its config, never through an environment (a secret is read
|
|
161
|
+
// by name: store/open.ts); the environment names only the schema.
|
|
162
|
+
const target = storeTarget(dir, {}, STORE_URLS.get(subject) ?? "");
|
|
163
|
+
const storeEnv = target.kind === "postgres" ? { AGENTRUN_STORE_SCHEMA: `${target.schema}_c${randomBytes(6).toString("hex")}` } : {};
|
|
164
|
+
const env = { ...process.env, ...storeEnv };
|
|
165
|
+
const url = target.kind === "postgres" ? target.url : "";
|
|
166
|
+
const clockFile = join(dir, "store-clock-skew");
|
|
167
|
+
/** A lost claim runs out: every store's now moves past its until (a crashed runner's, or a stopped process's). */
|
|
168
|
+
const runOut = () => writeFileSync(clockFile, String((Number(existsSync(clockFile) ? readFileSync(clockFile, "utf8") : 0) || 0) + RUN_OUT_MS));
|
|
169
|
+
const server = await openCaseStore({ dataDir: dir, role: "server", url, env, clockFile });
|
|
170
|
+
const stores = [server];
|
|
171
|
+
const runners = [];
|
|
172
|
+
/** What the runners said (claims, releases, errors): shown with a case's failure. */
|
|
173
|
+
const events = [];
|
|
174
|
+
t.after(async () => {
|
|
175
|
+
for (const runner of runners)
|
|
176
|
+
await runner.close();
|
|
177
|
+
for (const store of stores.reverse())
|
|
178
|
+
await store.close().catch(() => undefined);
|
|
179
|
+
rmSync(dir, { recursive: true, force: true });
|
|
180
|
+
if (target.kind === "postgres")
|
|
181
|
+
await dropPostgresSchema(target.url, storeEnv.AGENTRUN_STORE_SCHEMA);
|
|
182
|
+
});
|
|
183
|
+
await server.agents.create({ id: "agent-1", name: "Conformance" }, { id: "rev-1", kind: "agentic", body: { instructions: "Follow the script." } });
|
|
184
|
+
await server.runs.create({ id: RUN, agentId: "agent-1", revisionId: "rev-1" });
|
|
185
|
+
/** The command rows a runner has handed to a loop's command(): with the loop, whether or not taken yet. */
|
|
186
|
+
const handed = new Set();
|
|
187
|
+
/** Each runner's claims in flight (store.runs.claimMany), by its name: what claimsSettled waits for. */
|
|
188
|
+
const claiming = new Map();
|
|
189
|
+
/** `store` as runner `name` is handed it: the same store, its claims in flight counted (claiming). */
|
|
190
|
+
const claimsCounted = (store, name) => {
|
|
191
|
+
const pending = new Set();
|
|
192
|
+
claiming.set(name, pending);
|
|
193
|
+
const runs = new Proxy(store.runs, {
|
|
194
|
+
get(target, property) {
|
|
195
|
+
const value = Reflect.get(target, property, target);
|
|
196
|
+
if (typeof value !== "function")
|
|
197
|
+
return value;
|
|
198
|
+
if (property !== "claimMany")
|
|
199
|
+
return value.bind(target);
|
|
200
|
+
return (...args) => {
|
|
201
|
+
const claimed = value.apply(target, args);
|
|
202
|
+
pending.add(claimed);
|
|
203
|
+
void claimed.finally(() => pending.delete(claimed)).catch(() => undefined);
|
|
204
|
+
return claimed;
|
|
205
|
+
};
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
return new Proxy(store, {
|
|
209
|
+
get(target, property) {
|
|
210
|
+
if (property === "runs")
|
|
211
|
+
return runs;
|
|
212
|
+
const value = Reflect.get(target, property, target);
|
|
213
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
/** Once runner `name` is killed (crashAt), its claim already in flight settles, judged on the clock it was sent at: a
|
|
218
|
+
* dead process sends nothing after it dies. A case runs the lease out only after this, else that claim (on Postgres,
|
|
219
|
+
* a transaction still on its way to the database) reads the moved clock, takes the run back from the runner that sent
|
|
220
|
+
* it (Claim.lost names that same runner), gives it back as a run it still holds, and the runner that then takes it over
|
|
221
|
+
* claims a released run, not a lost one: the timeline never says the run went on after the crashed runner was lost. */
|
|
222
|
+
const claimsSettled = async (name) => void (await Promise.allSettled([...(claiming.get(name) ?? [])]));
|
|
223
|
+
const start = async (name, setup, holder, more = {}) => {
|
|
224
|
+
const store = await openCaseStore({ dataDir: dir, role: "runner", url, env, clockFile });
|
|
225
|
+
stores.push(store);
|
|
226
|
+
// Each journal commit's outcome, by the claim's epoch (as child.ts records its process's): what a loop wrote, and
|
|
227
|
+
// whether a loop that lost its claim wrote anything after; and each command row handed to the loop.
|
|
228
|
+
const factory = subject.createLoop(setup);
|
|
229
|
+
const observedLoop = (deps) => {
|
|
230
|
+
const loop = factory({
|
|
231
|
+
...deps,
|
|
232
|
+
...more,
|
|
233
|
+
journal: (claim) => new Proxy(deps.journal(claim), {
|
|
234
|
+
get(target, property) {
|
|
235
|
+
const value = Reflect.get(target, property, target);
|
|
236
|
+
if (typeof value !== "function")
|
|
237
|
+
return value;
|
|
238
|
+
if (property !== "commit")
|
|
239
|
+
return value.bind(target);
|
|
240
|
+
return async (...args) => {
|
|
241
|
+
try {
|
|
242
|
+
const result = await value.apply(target, args);
|
|
243
|
+
events.push({ runner: name, at: Date.now(), type: "commit-landed", epoch: claim.epoch });
|
|
244
|
+
return result;
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
events.push({ runner: name, at: Date.now(), type: "commit-refused", epoch: claim.epoch, name: error?.name });
|
|
248
|
+
throw error;
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
},
|
|
252
|
+
}),
|
|
253
|
+
});
|
|
254
|
+
return { ...loop, command: (command) => (handed.add(command.id), loop.command(command)) };
|
|
255
|
+
};
|
|
256
|
+
const runner = startRunner({ store: claimsCounted(store, name), createLoop: observedLoop, name, ...TIMING, ...timing, onEvent: (event) => events.push({ runner: name, at: Date.now(), ...event }) });
|
|
257
|
+
runners.push(runner);
|
|
258
|
+
if (holder)
|
|
259
|
+
holder.runner = runner;
|
|
260
|
+
return runner;
|
|
261
|
+
};
|
|
262
|
+
const run = async () => (await server.runs.get(RUN));
|
|
263
|
+
const read = async () => {
|
|
264
|
+
const row = await run();
|
|
265
|
+
// pi's tool tasks and the CLI record alike: the kernel's one reader. A subject whose calls are not the kernel's (a
|
|
266
|
+
// workflow's are the DSL engine's effect records) reads them its own way (subject.readCalls).
|
|
267
|
+
const journal = server.journal({ runId: RUN, runner: "conformance-reader", epoch: row.epoch, until: 0, from: row.state });
|
|
268
|
+
const entries = await journalRecords(journal, BACKGROUND_CONTEXT);
|
|
269
|
+
// The answers to the run's asks: one place for every harness, the resume row's source.
|
|
270
|
+
const answers = entries.entries.filter((entry) => entry.kind === KINDS.answer).map((entry) => entry.data);
|
|
271
|
+
return { calls: subject.readCalls ? await subject.readCalls(journal, BACKGROUND_CONTEXT) : callsOf(entries), messages: messagesOf(entries), answers };
|
|
272
|
+
};
|
|
273
|
+
const ended = (state, ms = 15_000) => until(async () => {
|
|
274
|
+
const row = await run();
|
|
275
|
+
return row.state === state && row.runner === null && row;
|
|
276
|
+
}, `the run ${state} and released`, ms).catch(async (error) => {
|
|
277
|
+
const row = await run();
|
|
278
|
+
throw new Error(`${error.message}; the run is ${row.state} (runner ${row.runner}, epoch ${row.epoch}); the runners said ${JSON.stringify(events)}`);
|
|
279
|
+
});
|
|
280
|
+
/** The run's timeline as its live view shows it: every stored commit through the live translate (live/translate.ts),
|
|
281
|
+
* its events through the timeline's own reducer, as the console reads them. */
|
|
282
|
+
const liveRows = async () => {
|
|
283
|
+
const row = await run();
|
|
284
|
+
const journal = server.journal({ runId: RUN, runner: "conformance-reader", epoch: row.epoch, until: 0, from: row.state });
|
|
285
|
+
const state = emptyState();
|
|
286
|
+
const reducer = timelineReducer();
|
|
287
|
+
for (let after = 0;;) {
|
|
288
|
+
const page = await journal.commitsAfter(after, 500, BACKGROUND_CONTEXT);
|
|
289
|
+
for (const commit of page.commits)
|
|
290
|
+
reducer.apply(translate(state, commit));
|
|
291
|
+
if (page.next === undefined)
|
|
292
|
+
break;
|
|
293
|
+
after = page.next;
|
|
294
|
+
}
|
|
295
|
+
return reducer.rows();
|
|
296
|
+
};
|
|
297
|
+
const commandRow = async (id) => (await server.commands(RUN, id - 1)).find((row) => row.id === id);
|
|
298
|
+
/** The call the run asked a person about: its ask entry's callId, which an approve or deny names as its approval. */
|
|
299
|
+
const askedCall = async () => {
|
|
300
|
+
const row = await run();
|
|
301
|
+
const { entries } = await journalRecords(server.journal({ runId: RUN, runner: "conformance-reader", epoch: row.epoch, until: 0, from: row.state }), BACKGROUND_CONTEXT);
|
|
302
|
+
const ask = entries.find((entry) => entry.kind === KINDS.ask);
|
|
303
|
+
assert.ok(ask, "the run wrote its ask");
|
|
304
|
+
return String(ask.data.callId);
|
|
305
|
+
};
|
|
306
|
+
return { dir, storeUrl: url, storeEnv, clockFile, runOut, claimsSettled, server, start, run, read, ended, commandRow, askedCall, events, handedOver: (id) => handed.has(id), liveRows };
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* The claim's fence, as the stalled process's own events show it: once it went on (`continuedAt`, its lease run out and no
|
|
310
|
+
* one holding the run yet), its old loop's writes under the claim it was held under are each refused by the fence, by name (ClaimLost
|
|
311
|
+
* or Fenced), or, with none tried, the runner said its claim was lost once it went on (its loop stopped before any write).
|
|
312
|
+
* A landed one names how long after its claim was lost it landed.
|
|
313
|
+
*/
|
|
314
|
+
export function fenceHeld(events, continuedAt) {
|
|
315
|
+
const history = JSON.stringify(events);
|
|
316
|
+
// The claim the held loop ran under: the process's last claim before it stopped at the point. A starved box can lose the
|
|
317
|
+
// process's first claim before the point and take the run again, so the held loop's epoch need not be its first.
|
|
318
|
+
const heldFrom = events.find((event) => event.type === "stopping")?.at ?? continuedAt;
|
|
319
|
+
const first = events.filter((event) => event.type === "claimed" && (event.at ?? 0) <= heldFrom).at(-1)?.claim?.epoch;
|
|
320
|
+
const old = events.filter((event) => (event.at ?? 0) >= continuedAt && event.epoch === first && (event.type === "commit-landed" || event.type === "commit-refused"));
|
|
321
|
+
const lost = events.find((event) => event.type === "claim-lost" && event.epoch === first);
|
|
322
|
+
for (const landed of old.filter((event) => event.type === "commit-landed")) {
|
|
323
|
+
const when = lost?.at !== undefined ? `${landed.at - lost.at} ms after its claim was lost` : `${landed.at - continuedAt} ms after it went on, its lease run out`;
|
|
324
|
+
assert.fail(`an epoch-${first} commit landed ${when}: ${history}`);
|
|
325
|
+
}
|
|
326
|
+
// Which way the fence is kept is the box's timing, and both keep it: the runner sees its claim lost and stops the loop
|
|
327
|
+
// before any write (a loaded box), or the loop's write is tried and refused. The store's refusal of a write past the
|
|
328
|
+
// lease is held on its own, deterministically (store-claim-lease).
|
|
329
|
+
if (old.length === 0) {
|
|
330
|
+
assert.ok(lost !== undefined && (lost.at ?? 0) >= continuedAt, `the old loop neither tried a write nor was stopped by its claim lost once it went on: ${history}`);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
assert.ok(old.every((event) => event.name === "ClaimLost" || event.name === "Fenced"), `each was refused by the claim's fence, by name: ${history}`);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* The resume after a crash, as runner-b's own events tell it: runner-b claimed the run once and released it once, with the
|
|
337
|
+
* run ended, and nothing touched the row after its end (its end commit is its release, moving the epoch to runner-b's
|
|
338
|
+
* claim + 1 in that commit; runner-b's release after it is a no-op). Not an absolute epoch:
|
|
339
|
+
* on a slow box the crashed runner may lose its own claim (a renew that missed) and retake the run before it dies, so the
|
|
340
|
+
* epoch runner-b claims at counts the box's speed, not the resume.
|
|
341
|
+
*/
|
|
342
|
+
/** Waits for runner-b to say it released the run. The run reads ended and released from its end commit (a write that makes
|
|
343
|
+
* the run final is its release), which comes before the runner's own end of it says so: bounded, never a sleep. */
|
|
344
|
+
async function saidReleased(events) {
|
|
345
|
+
await until(() => events.some((event) => event.runner === "runner-b" && event.type === "released"), "runner-b says it released the run", EVENT_WAIT_MS);
|
|
346
|
+
}
|
|
347
|
+
function resumedOnceByB(events, row) {
|
|
348
|
+
// The whole claim history, every runner's (the crashed one's too, the process cases' read from its events file), in time
|
|
349
|
+
// order: a failure here says what each runner did, not only that the epoch differed.
|
|
350
|
+
const history = JSON.stringify([...events].sort((a, b) => (a.at ?? 0) - (b.at ?? 0)));
|
|
351
|
+
// runner-b's own events, in the order it said them.
|
|
352
|
+
const ofB = events.filter((event) => event.runner === "runner-b");
|
|
353
|
+
const claims = ofB.filter((event) => event.type === "claimed");
|
|
354
|
+
assert.ok(claims.length > 0, `runner-b claimed the run: ${history}`);
|
|
355
|
+
// Every claim after its first is accounted for: a starved box can miss runner-b's renews, and then it takes the run
|
|
356
|
+
// again. Each such claim comes after runner-b lost the one before (a renew that missed or was fenced), at a fresh epoch,
|
|
357
|
+
// and nothing of the lost epoch landed once the run was claimed again. (The runner says it lost a claim a stop margin
|
|
358
|
+
// before the store's lease runs out, so a commit already on its way can land in that margin, under a lease it still
|
|
359
|
+
// holds; the fence refuses the old epoch once the lease ran out, and so surely once the next claim holds the run.)
|
|
360
|
+
for (let i = 1; i < claims.length; i += 1) {
|
|
361
|
+
const before = claims[i - 1].claim.epoch;
|
|
362
|
+
const next = claims[i].claim.epoch;
|
|
363
|
+
assert.ok(next > before, `runner-b's claim ${i + 1} is at a fresh epoch (${next} after ${before}): ${history}`);
|
|
364
|
+
const lostAt = ofB.findIndex((event) => event.type === "claim-lost" && event.epoch === before);
|
|
365
|
+
assert.ok(lostAt >= 0 && lostAt < ofB.indexOf(claims[i]), `runner-b lost its claim at epoch ${before} before it claimed again: ${history}`);
|
|
366
|
+
assert.deepEqual(ofB.slice(ofB.indexOf(claims[i])).filter((event) => event.type === "commit-landed" && event.epoch === before), [], `nothing of runner-b's lost epoch ${before} landed once it claimed the run again: ${history}`);
|
|
367
|
+
}
|
|
368
|
+
const last = claims[claims.length - 1].claim.epoch;
|
|
369
|
+
const releases = ofB.filter((event) => event.type === "released");
|
|
370
|
+
assert.deepEqual(releases.map((event) => [event.epoch, event.end]), [[last, "ended"]], `runner-b released it once, ended, under its last claim: ${history}`);
|
|
371
|
+
assert.equal(row.epoch, last + 1, `nothing touched the run after runner-b's end: ${history}`);
|
|
372
|
+
}
|
|
373
|
+
/** The crashed runner process's events, appended to `file` as JSON lines (child.ts): each one, or none when it wrote none. */
|
|
374
|
+
function childEvents(file) {
|
|
375
|
+
if (!existsSync(file))
|
|
376
|
+
return [];
|
|
377
|
+
return readFileSync(file, "utf8").split("\n").filter(Boolean).map((line) => {
|
|
378
|
+
try {
|
|
379
|
+
return JSON.parse(line);
|
|
380
|
+
}
|
|
381
|
+
catch {
|
|
382
|
+
return { runner: "runner-process", unreadable: line };
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
/** The run's live timeline says it went on after `runner` was lost: the loop that took it over wrote it (Claim.lost). */
|
|
387
|
+
function saidTakenOver(rows, runner) {
|
|
388
|
+
const said = rows.filter((row) => row.kind === "phase" && /^Resumed after its runner/.test(row.summary ?? "")).map((row) => row.summary);
|
|
389
|
+
assert.ok(said.includes(`Resumed after its runner (${runner}) was lost`), `the timeline says the run went on after ${runner} was lost: ${JSON.stringify(said)}; its rows ${JSON.stringify(rows.map((row) => [row.kind, row.summary]))}`);
|
|
390
|
+
}
|
|
391
|
+
/** A crash at `point` during a call of `tool`, then a second runner's resume: the run ends. */
|
|
392
|
+
async function crashThenResume(subject, t, tool, point) {
|
|
393
|
+
const w = await world(subject, t);
|
|
394
|
+
const { tools, ran } = suiteTools();
|
|
395
|
+
const script = [{ call: tool }, { say: "done" }];
|
|
396
|
+
const holder = {};
|
|
397
|
+
await w.start("runner-a", { script, tools, hooks: crashAt(point, holder) }, holder);
|
|
398
|
+
await until(() => holder.crashed, `the crash at ${point}`, EVENT_WAIT_MS);
|
|
399
|
+
// The crashed runner's claim runs out (the stores' clock moves past its until), and runner-b takes the run over. First
|
|
400
|
+
// the claim its poll had in flight when it died settles, on the clock it was sent at (claimsSettled).
|
|
401
|
+
await w.claimsSettled("runner-a");
|
|
402
|
+
w.runOut();
|
|
403
|
+
await w.start("runner-b", { script, tools, hooks: quiet });
|
|
404
|
+
const row = await w.ended("ended", EVENT_WAIT_MS);
|
|
405
|
+
await saidReleased(w.events);
|
|
406
|
+
resumedOnceByB(w.events, row);
|
|
407
|
+
saidTakenOver(await w.liveRows(), "runner-a");
|
|
408
|
+
return { ...(await w.read()), ran };
|
|
409
|
+
}
|
|
410
|
+
/** Whether process `pid` is stopped (SIGSTOP), by the kernel's own word, on every platform the suite runs on: the state
|
|
411
|
+
* field of /proc/<pid>/stat is "T" where there is a /proc (Linux); elsewhere (macOS) `ps -o state=` answers a state that
|
|
412
|
+
* starts with "T". */
|
|
413
|
+
export function processStopped(pid, { stat = (at) => readFileSync(`/proc/${at}/stat`, "utf8"), ps = (at) => execFileSync("ps", ["-o", "state=", "-p", String(at)], { encoding: "utf8" }) } = {}) {
|
|
414
|
+
let text;
|
|
415
|
+
try {
|
|
416
|
+
text = stat(pid);
|
|
417
|
+
}
|
|
418
|
+
catch {
|
|
419
|
+
try {
|
|
420
|
+
return ps(pid).trim().startsWith("T");
|
|
421
|
+
}
|
|
422
|
+
catch {
|
|
423
|
+
return false;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
// The state follows the command name, which is in parentheses and may itself hold spaces or parentheses.
|
|
427
|
+
return text.slice(text.lastIndexOf(")") + 1).trim().split(" ")[0] === "T";
|
|
428
|
+
}
|
|
429
|
+
/** The runner process the process cases start (child.ts), and its environment: never a test runner's own. */
|
|
430
|
+
const CHILD = fileURLToPath(new URL("./child.js", import.meta.url));
|
|
431
|
+
/** How a process case starts its runner process: its config (`config`) on argv, and the store's URL, which may hold a
|
|
432
|
+
* password, on stdin, never argv or the environment, which another process of the user reads (ps, /proc). */
|
|
433
|
+
export function processLaunch(config, storeUrl) {
|
|
434
|
+
return { args: [CHILD, JSON.stringify(config)], stdin: `${JSON.stringify({ storeUrl })}\n` };
|
|
435
|
+
}
|
|
436
|
+
const childEnv = () => {
|
|
437
|
+
const env = { ...process.env };
|
|
438
|
+
delete env.NODE_TEST_CONTEXT;
|
|
439
|
+
return env;
|
|
440
|
+
};
|
|
441
|
+
/** As crashThenResume, with the first runner a process of its own that SIGKILLs itself at `point`: nothing it had not
|
|
442
|
+
* committed survives, as in a real crash. The tools count their runs in a file both processes append to. */
|
|
443
|
+
async function processCrashThenResume(subject, t, tool, point, { stall = false } = {}) {
|
|
444
|
+
const w = await world(subject, t);
|
|
445
|
+
const countFile = join(w.dir, "tool-runs");
|
|
446
|
+
const { tools, ran } = suiteTools(countFile);
|
|
447
|
+
const eventsFile = join(w.dir, "runner-process-events.jsonl");
|
|
448
|
+
const config = { dataDir: w.dir, storeEnv: w.storeEnv, module: subject.process.module, export: subject.process.export, tool, point, countFile, eventsFile, clockFile: w.clockFile, ...(stall ? { stopOnce: true } : {}) };
|
|
449
|
+
const launch = processLaunch(config, w.storeUrl);
|
|
450
|
+
const child = spawn(process.execPath, launch.args, { env: childEnv(), stdio: ["pipe", "ignore", "pipe"] });
|
|
451
|
+
child.stdin.end(launch.stdin);
|
|
452
|
+
// Its end, listened for from its start: a process that ends while the case waits on something else (the fence's wait
|
|
453
|
+
// returns on that end) is never missed by the wait for its death below.
|
|
454
|
+
const exited = once(child, "exit").catch((error) => ["error", String(error)]);
|
|
455
|
+
let stderr = "";
|
|
456
|
+
child.stderr.on("data", (chunk) => (stderr += chunk.toString()));
|
|
457
|
+
t.after(() => {
|
|
458
|
+
if (child.exitCode === null && child.signalCode === null)
|
|
459
|
+
child.kill("SIGKILL");
|
|
460
|
+
});
|
|
461
|
+
// `stall`: the process stops itself at `point` (child.ts stopOnce) and is let go once its lease has run out (the stores'
|
|
462
|
+
// clock moved past its until, the process's own store reading the same skew), before anyone has taken the run again:
|
|
463
|
+
// the window where only the store can refuse what its old loop writes next. The clock jump stands in for the time a
|
|
464
|
+
// box paused it, so no real lease has to run out.
|
|
465
|
+
let continuedAt = 0;
|
|
466
|
+
if (stall) {
|
|
467
|
+
await until(() => childEvents(eventsFile).some((event) => event.type === "stopping"), `the runner process stops at ${point}`, EVENT_WAIT_MS);
|
|
468
|
+
// Its word is not the stop: a SIGCONT sent between the two is lost, and the process stays stopped for good. It goes
|
|
469
|
+
// on only once the kernel says it is stopped.
|
|
470
|
+
await until(() => processStopped(child.pid), `the runner process is stopped (its state "T") at ${point}`, EVENT_WAIT_MS);
|
|
471
|
+
w.runOut();
|
|
472
|
+
continuedAt = Date.now();
|
|
473
|
+
child.kill("SIGCONT");
|
|
474
|
+
// The fence first, before anything waits on the process's death: its old loop's first write once it went on (landed or
|
|
475
|
+
// refused), or the process's end, bounded. The old loop's epoch is the claim it was held under.
|
|
476
|
+
const outcome = (event) => (event.at ?? 0) >= continuedAt && (event.type === "commit-landed" || event.type === "commit-refused");
|
|
477
|
+
await until(() => child.exitCode !== null || child.signalCode !== null || childEvents(eventsFile).some((event) => outcome(event)), "the old loop writes once it goes on, or the process ends", 15_000);
|
|
478
|
+
fenceHeld(childEvents(eventsFile), continuedAt);
|
|
479
|
+
}
|
|
480
|
+
const exit = (await Promise.race([exited, sleep(EVENT_WAIT_MS).then(() => ["timeout", null])]));
|
|
481
|
+
// What the process did, when it did not die where it should: its claims, lost claims, commits (landed or refused, by
|
|
482
|
+
// epoch), the tool's runs and the run's row.
|
|
483
|
+
if (exit[1] !== "SIGKILL") {
|
|
484
|
+
const row = await w.run();
|
|
485
|
+
assert.fail(`the runner process dies at ${point} (it ended ${JSON.stringify(exit)}); continued at ${continuedAt}; its events ${JSON.stringify(childEvents(eventsFile))}; the tool ran ${JSON.stringify(ran)}; the run ${JSON.stringify(row)}; stderr ${stderr}`);
|
|
486
|
+
}
|
|
487
|
+
// The dead process's claim runs out (the stores' clock moves past its until), and runner-b takes the run over.
|
|
488
|
+
w.runOut();
|
|
489
|
+
await w.start("runner-b", { script: [{ call: tool }, { say: "done" }], tools, hooks: quiet });
|
|
490
|
+
const row = await w.ended("ended", EVENT_WAIT_MS);
|
|
491
|
+
await saidReleased(w.events);
|
|
492
|
+
resumedOnceByB([...childEvents(eventsFile), ...w.events], row);
|
|
493
|
+
saidTakenOver(await w.liveRows(), "runner-process");
|
|
494
|
+
return { ...(await w.read()), ran, events: childEvents(eventsFile), continuedAt };
|
|
495
|
+
}
|
|
496
|
+
const CASES = [
|
|
497
|
+
{
|
|
498
|
+
id: "crash-before-intent",
|
|
499
|
+
title: "crash before a tool's intent: resumes, runs it once",
|
|
500
|
+
async body(subject, t) {
|
|
501
|
+
const { calls, ran } = await crashThenResume(subject, t, "effect", "beforeIntent");
|
|
502
|
+
assert.equal(ran.effect, 1, "the effect ran once");
|
|
503
|
+
assert.deepEqual(calls.map((call) => [call.tool, call.status]), [["effect", "done"]]);
|
|
504
|
+
},
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
id: "crash-after-intent",
|
|
508
|
+
title: "crash after intent, before result: interrupted",
|
|
509
|
+
async body(subject, t) {
|
|
510
|
+
const { calls, ran } = await crashThenResume(subject, t, "effect", "beforeResult");
|
|
511
|
+
assert.equal(ran.effect, 1, "the effect ran once, never again after the crash");
|
|
512
|
+
assert.deepEqual(calls.map((call) => [call.tool, call.status]), [["effect", "interrupted"]]);
|
|
513
|
+
},
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
id: "crash-before-intent-process",
|
|
517
|
+
title: "a runner process killed before a tool's intent: another resumes, runs it once",
|
|
518
|
+
async body(subject, t) {
|
|
519
|
+
const { calls, ran } = await processCrashThenResume(subject, t, "effect", "beforeIntent");
|
|
520
|
+
assert.equal(ran.effect, 1, "the effect ran once");
|
|
521
|
+
assert.deepEqual(calls.map((call) => [call.tool, call.status]), [["effect", "done"]]);
|
|
522
|
+
},
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
id: "crash-after-intent-process",
|
|
526
|
+
title: "a runner process killed after intent, before result: interrupted",
|
|
527
|
+
async body(subject, t) {
|
|
528
|
+
const { calls, ran } = await processCrashThenResume(subject, t, "effect", "beforeResult");
|
|
529
|
+
assert.equal(ran.effect, 1, "the effect ran once, never again after the crash");
|
|
530
|
+
assert.deepEqual(calls.map((call) => [call.tool, call.status]), [["effect", "interrupted"]]);
|
|
531
|
+
},
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
id: "stalled-past-lease-process",
|
|
535
|
+
title: "a runner process paused past its lease before a tool's intent: its old loop's write is refused, a fresh loop retakes the run, and the tool runs once",
|
|
536
|
+
async body(subject, t) {
|
|
537
|
+
const { calls, ran, events, continuedAt } = await processCrashThenResume(subject, t, "effect", "beforeIntent", { stall: true });
|
|
538
|
+
const history = JSON.stringify(events);
|
|
539
|
+
// The fence was checked first, as soon as the old loop wrote (processCrashThenResume): here, the whole run's again.
|
|
540
|
+
fenceHeld(events, continuedAt);
|
|
541
|
+
const claims = events.filter((event) => event.type === "claimed").map((event) => event.claim.epoch);
|
|
542
|
+
assert.ok(claims.length >= 2 && claims[1] > claims[0], `the process lost its claim and took the run back at a new epoch, with a fresh loop: ${history}`);
|
|
543
|
+
assert.equal(ran.effect, 1, "the effect ran once");
|
|
544
|
+
assert.deepEqual(calls.map((call) => [call.tool, call.status]), [["effect", "done"]]);
|
|
545
|
+
},
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
// #1933's read: a task restart re-ran a node's effects (pi's restartLimit masked it). A fault after the effect ran
|
|
549
|
+
// (the process alive) restarts the task under the kernel's rule, and the effect never runs twice.
|
|
550
|
+
id: "fault-effects-once",
|
|
551
|
+
title: "a task that faults after its effect ran is restarted without running the effect again",
|
|
552
|
+
async body(subject, t) {
|
|
553
|
+
const w = await world(subject, t);
|
|
554
|
+
const { tools, ran } = suiteTools();
|
|
555
|
+
let faults = 0;
|
|
556
|
+
const hooks = {
|
|
557
|
+
beforeIntent: async () => { },
|
|
558
|
+
beforeResult: async () => {
|
|
559
|
+
if (faults++ === 0)
|
|
560
|
+
throw new Error("a fault in the task after its effect ran");
|
|
561
|
+
},
|
|
562
|
+
};
|
|
563
|
+
await w.start("runner-a", { script: [{ call: "effect" }, { say: "done" }], tools, hooks });
|
|
564
|
+
const row = await until(async () => {
|
|
565
|
+
const now = await w.run();
|
|
566
|
+
return ["ended", "failed"].includes(now.state) && now.runner === null && now;
|
|
567
|
+
}, "the run ends after the fault");
|
|
568
|
+
assert.equal(ran.effect, 1, "the effect ran once, never again on the restart");
|
|
569
|
+
const { calls } = await w.read();
|
|
570
|
+
const effect = calls.filter((call) => call.tool === "effect");
|
|
571
|
+
assert.equal(effect.length, 1, `one call of the effect: ${JSON.stringify(calls)}`);
|
|
572
|
+
assert.ok(effect[0].status === "interrupted" || effect[0].status === "failed", `the faulted call is not done: ${effect[0].status}`);
|
|
573
|
+
assert.equal(row.state, "ended", "the run goes on past the fault and ends");
|
|
574
|
+
},
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
// The restart rule by name: a task that faults every time is restarted a bounded number of times, never forever, and
|
|
578
|
+
// the run fails saying so. Removing the bound (or the rule that replaces pi's restartLimit) turns this red.
|
|
579
|
+
id: "fault-restarts-bounded",
|
|
580
|
+
title: "a task that faults every time is restarted a bounded number of times, then the run fails",
|
|
581
|
+
async body(subject, t) {
|
|
582
|
+
// On a lease no missed renew lets lapse: a claim lost between restarts would hand the run to a fresh loop, and the
|
|
583
|
+
// restarts this case counts are one claim's.
|
|
584
|
+
const w = await world(subject, t, STEADY);
|
|
585
|
+
const { tools, ran } = suiteTools();
|
|
586
|
+
const hooks = {
|
|
587
|
+
beforeIntent: async () => { },
|
|
588
|
+
beforeResult: async () => {
|
|
589
|
+
throw new Error("a fault in the task, every time");
|
|
590
|
+
},
|
|
591
|
+
};
|
|
592
|
+
await w.start("runner-a", { script: [{ call: "read" }, { say: "done" }], tools, hooks });
|
|
593
|
+
const row = await w.ended("failed");
|
|
594
|
+
assert.ok(ran.read >= 2, `restarted at least once (a replay-safe call runs again): ran ${ran.read}`);
|
|
595
|
+
assert.ok(ran.read <= MAX_RESTARTS + 1, `restarted at most ${MAX_RESTARTS} times: ran ${ran.read}`);
|
|
596
|
+
assert.match(row.summary ?? "", /fault|restart/i, `the run says why it failed: ${JSON.stringify(row.summary)}`);
|
|
597
|
+
},
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
id: "replay-safe-rerun",
|
|
601
|
+
title: "replay-safe tool reruns after a crash",
|
|
602
|
+
async body(subject, t) {
|
|
603
|
+
const { calls, ran } = await crashThenResume(subject, t, "read", "beforeResult");
|
|
604
|
+
assert.equal(ran.read, 2, "the replay-safe call ran again after the crash");
|
|
605
|
+
assert.deepEqual(calls.map((call) => [call.tool, call.status]), [["read", "done"]]);
|
|
606
|
+
},
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
id: "steer-mid-turn",
|
|
610
|
+
title: "steer mid-turn reaches the next step",
|
|
611
|
+
async body(subject, t) {
|
|
612
|
+
const w = await world(subject, t);
|
|
613
|
+
const { tools, letSlowGo, slowStarted } = suiteTools();
|
|
614
|
+
await w.start("runner-a", { script: [{ call: "slow" }, { sayLastSteer: true }], tools, hooks: quiet });
|
|
615
|
+
await slowStarted;
|
|
616
|
+
const steer = await sendCommand(w.server, RUN, { kind: "steer", body: { text: "check the totals" } });
|
|
617
|
+
// One command poll and then some: the steer reaches the loop while the tool runs.
|
|
618
|
+
await sleep(TIMING.commandPollMs * 4);
|
|
619
|
+
letSlowGo();
|
|
620
|
+
await w.ended("ended");
|
|
621
|
+
const { calls, messages } = await w.read();
|
|
622
|
+
const slow = calls.find((call) => call.tool === "slow");
|
|
623
|
+
const steered = messages.find((message) => message.role === "steer");
|
|
624
|
+
const said = messages.filter((message) => message.role === "model");
|
|
625
|
+
assert.ok(slow?.endEntry !== undefined && slow.status === "done", `slow ran to its end: ${JSON.stringify(calls)}`);
|
|
626
|
+
assert.equal(steered?.text, "check the totals", `the steer is in the journal: ${JSON.stringify(messages)}`);
|
|
627
|
+
assert.ok(steered.entry > slow.endEntry, "after the tool's end: mid-turn, not lost");
|
|
628
|
+
assert.deepEqual(said.map((message) => message.text), ["check the totals"], "the next step saw it");
|
|
629
|
+
assert.ok(said[0].entry > steered.entry);
|
|
630
|
+
assert.ok((await w.commandRow(steer.id)).takenAt !== null, "the steer row is taken");
|
|
631
|
+
},
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
id: "stop-ends-turn",
|
|
635
|
+
title: "stop ends the turn; the run says why",
|
|
636
|
+
async body(subject, t) {
|
|
637
|
+
const w = await world(subject, t);
|
|
638
|
+
const { tools, slowStarted } = suiteTools();
|
|
639
|
+
await w.start("runner-a", { script: [{ call: "slow" }, { say: "never" }], tools, hooks: quiet });
|
|
640
|
+
await slowStarted;
|
|
641
|
+
const stop = await sendCommand(w.server, RUN, { kind: "stop" });
|
|
642
|
+
const row = await w.ended("stopped");
|
|
643
|
+
const { calls, messages } = await w.read();
|
|
644
|
+
assert.ok(calls.every((call) => call.status !== "pending"), `no call left pending: ${JSON.stringify(calls)}`);
|
|
645
|
+
assert.equal(messages.some((message) => message.text === "never"), false, "the turn did not go on");
|
|
646
|
+
// Why it stopped is on the run row, staged in the end commit: one place for every harness.
|
|
647
|
+
assert.match(row.summary ?? "", /stopped/, `the run says why it stopped: ${JSON.stringify(row.summary)}`);
|
|
648
|
+
assert.ok(row.endedAt !== null, "its end commit stamped ended_at");
|
|
649
|
+
assert.ok((await w.commandRow(stop.id)).takenAt !== null, "the stop row is taken");
|
|
650
|
+
// The live timeline: one row says the person stopped it, worded the same on every harness, and nothing a person
|
|
651
|
+
// reads shows a harness's markup.
|
|
652
|
+
const rows = await w.liveRows();
|
|
653
|
+
const stops = rows.filter((one) => one.summary === STOPPED_BY_YOU);
|
|
654
|
+
assert.deepEqual(stops.map((one) => one.kind), ["phase"], `one row says the person stopped it: ${JSON.stringify(rows.map((one) => [one.kind, one.summary]))}`);
|
|
655
|
+
const leaked = rows.filter((one) => [one.summary, one.text, one.tool_result_preview, one.tool_input_preview].some((value) => typeof value === "string" && value.includes("<harness")));
|
|
656
|
+
assert.deepEqual(leaked.map((one) => [one.kind, one.summary, one.tool_result_preview]), [], "no row shows a harness's markup");
|
|
657
|
+
},
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
id: "cancel-ends-for-good",
|
|
661
|
+
title: "a cancel ends the run for good, cancelled in the server's words, and the run takes nothing more",
|
|
662
|
+
async body(subject, t) {
|
|
663
|
+
const w = await world(subject, t);
|
|
664
|
+
const { tools, slowStarted } = suiteTools();
|
|
665
|
+
await w.start("runner-a", { script: [{ call: "slow" }, { say: "never" }], tools, hooks: quiet });
|
|
666
|
+
await slowStarted;
|
|
667
|
+
const cancel = await sendCommand(w.server, RUN, { kind: "cancel" });
|
|
668
|
+
const row = await w.ended("stopped");
|
|
669
|
+
const { calls, messages } = await w.read();
|
|
670
|
+
assert.ok(calls.every((call) => call.status !== "pending"), `no call left pending: ${JSON.stringify(calls)}`);
|
|
671
|
+
assert.equal(messages.some((message) => message.text === "never"), false, "the turn did not go on");
|
|
672
|
+
// The end main's cancel writes: stopped, its summary "cancelled", staged in the end commit.
|
|
673
|
+
assert.equal(row.summary, CANCELLED, `the run says it was cancelled: ${JSON.stringify(row)}`);
|
|
674
|
+
const taken = await w.commandRow(cancel.id);
|
|
675
|
+
assert.ok(taken.takenAt !== null && taken.refused === null, `the cancel row is taken, not refused: ${JSON.stringify(taken)}`);
|
|
676
|
+
await assert.rejects(sendCommand(w.server, RUN, { kind: "steer", body: { text: "go on" } }), RunFinal, "a cancelled run takes no more messages");
|
|
677
|
+
},
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
id: "cancel-parked",
|
|
681
|
+
title: "a cancel of a parked run ends it for good, the asked call never run",
|
|
682
|
+
async body(subject, t) {
|
|
683
|
+
const w = await world(subject, t);
|
|
684
|
+
const { tools, ran } = suiteTools();
|
|
685
|
+
await w.start("runner-a", { script: [{ call: "asked" }, { say: "done" }], tools, hooks: quiet });
|
|
686
|
+
await w.ended("parked");
|
|
687
|
+
const cancel = await sendCommand(w.server, RUN, { kind: "cancel" });
|
|
688
|
+
const row = await w.ended("stopped");
|
|
689
|
+
assert.equal(row.summary, CANCELLED, `the run says it was cancelled: ${JSON.stringify(row)}`);
|
|
690
|
+
assert.equal(ran.asked, 0, "the asked call never ran");
|
|
691
|
+
const taken = await w.commandRow(cancel.id);
|
|
692
|
+
assert.ok(taken.takenAt !== null && taken.refused === null, `the cancel row is taken, not refused: ${JSON.stringify(taken)}`);
|
|
693
|
+
await assert.rejects(sendCommand(w.server, RUN, { kind: "approve", body: { approval: "any" } }), RunFinal, "a cancelled run takes no answer");
|
|
694
|
+
},
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
id: "deny-note",
|
|
698
|
+
title: "a deny's note is the person's words: on the answer, and in the refusal the model reads",
|
|
699
|
+
async body(subject, t) {
|
|
700
|
+
const w = await world(subject, t);
|
|
701
|
+
const { tools, ran } = suiteTools();
|
|
702
|
+
await w.start("runner-a", { script: [{ call: "asked" }, { sayLastResult: true }], tools, hooks: quiet });
|
|
703
|
+
await w.ended("parked");
|
|
704
|
+
const callId = await w.askedCall();
|
|
705
|
+
await sendCommand(w.server, RUN, { kind: "deny", body: { approval: callId, note: "not on a Friday" } });
|
|
706
|
+
await w.ended("ended");
|
|
707
|
+
assert.equal(ran.asked, 0, "denied, it never ran");
|
|
708
|
+
const { answers, messages } = await w.read();
|
|
709
|
+
// The fields this case is about; its time is the loop's clock's (adapter-pi-approval-entries pins it).
|
|
710
|
+
assert.deepEqual(answers.map(({ callId: id, approved, decision, note }) => ({ callId: id, approved, decision, note })), [{ callId, approved: false, decision: "deny", note: "not on a Friday" }], "the answer is a deny that keeps the note");
|
|
711
|
+
const said = messages.filter((message) => message.role === "model").map((message) => message.text);
|
|
712
|
+
assert.equal(said.length, 1, `the model answered once: ${JSON.stringify(messages)}`);
|
|
713
|
+
// Main's words for a call a person denied (tool-gate.ts refusedText), the note with them. The harness may frame a
|
|
714
|
+
// refusal its own way (pi: a blocked call's error) around them.
|
|
715
|
+
const refused = "The user denied this asked call. It was not run: nothing was sent and nothing was charged. Reason: not on a Friday";
|
|
716
|
+
assert.ok(said[0].includes(refused), `the model read main's refusal with the person's reason: ${JSON.stringify(said)}`);
|
|
717
|
+
},
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
id: "steer-origin",
|
|
721
|
+
title: "a steer's origin (a trigger's message) is kept on the message the run took",
|
|
722
|
+
async body(subject, t) {
|
|
723
|
+
const w = await world(subject, t);
|
|
724
|
+
const { tools, letSlowGo, slowStarted } = suiteTools();
|
|
725
|
+
await w.start("runner-a", { script: [{ call: "slow" }, { sayLastSteer: true }], tools, hooks: quiet });
|
|
726
|
+
await slowStarted;
|
|
727
|
+
const origin = { kind: "trigger", trigger_id: "trigger-1", source: "webhook", owner: false };
|
|
728
|
+
const steer = await sendCommand(w.server, RUN, { kind: "steer", body: { text: "a new order came in", origin } });
|
|
729
|
+
// The tool goes on once the steer is with the loop: the turn in flight has it, never a timer.
|
|
730
|
+
await until(() => w.handedOver(steer.id), "the steer handed to the loop");
|
|
731
|
+
letSlowGo();
|
|
732
|
+
await w.ended("ended");
|
|
733
|
+
const { messages } = await w.read();
|
|
734
|
+
const steered = messages.find((message) => message.text === "a new order came in" && message.role !== "model");
|
|
735
|
+
assert.deepEqual(steered?.origin, origin, `the message keeps its origin: ${JSON.stringify(messages)}`);
|
|
736
|
+
const said = messages.filter((message) => message.role === "model").map((message) => message.text);
|
|
737
|
+
assert.deepEqual(said, ["a new order came in"], "the model read it as any message");
|
|
738
|
+
},
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
id: "park-on-ask",
|
|
742
|
+
title: "park on ask; resume on the command row",
|
|
743
|
+
async body(subject, t) {
|
|
744
|
+
const w = await world(subject, t);
|
|
745
|
+
const { tools, ran } = suiteTools();
|
|
746
|
+
await w.start("runner-a", { script: [{ call: "asked" }, { say: "done" }], tools, hooks: quiet });
|
|
747
|
+
const parked = await w.ended("parked");
|
|
748
|
+
assert.equal(ran.asked, 0, "the asked tool waits for its answer");
|
|
749
|
+
const approve = await sendCommand(w.server, RUN, { kind: "approve", body: { approval: await w.askedCall() } });
|
|
750
|
+
const row = await w.ended("ended");
|
|
751
|
+
assert.ok(row.epoch > parked.epoch, "resumed under a new claim");
|
|
752
|
+
assert.equal(ran.asked, 1, "approved, it ran once");
|
|
753
|
+
assert.ok((await w.commandRow(approve.id)).takenAt !== null, "the approve row is taken");
|
|
754
|
+
const { calls } = await w.read();
|
|
755
|
+
assert.deepEqual(calls.map((call) => [call.tool, call.status]), [["asked", "done"]]);
|
|
756
|
+
},
|
|
757
|
+
},
|
|
758
|
+
{
|
|
759
|
+
id: "approval-names-its-call",
|
|
760
|
+
title: "an approval that names another call is refused, never answers the waiting one, and the run parks again",
|
|
761
|
+
async body(subject, t) {
|
|
762
|
+
const w = await world(subject, t);
|
|
763
|
+
const { tools, ran } = suiteTools();
|
|
764
|
+
await w.start("runner-a", { script: [{ call: "asked" }, { say: "done" }], tools, hooks: quiet });
|
|
765
|
+
await w.ended("parked");
|
|
766
|
+
const callId = await w.askedCall();
|
|
767
|
+
const stale = await sendCommand(w.server, RUN, { kind: "approve", body: { approval: `${callId}-another` } });
|
|
768
|
+
const refused = await until(async () => {
|
|
769
|
+
const row = await w.commandRow(stale.id);
|
|
770
|
+
return row.takenAt !== null && row;
|
|
771
|
+
}, "the other approval answered");
|
|
772
|
+
assert.match(refused.refused ?? "", /approval/, `refused in words: ${JSON.stringify(refused)}`);
|
|
773
|
+
assert.equal(ran.asked, 0, "the waiting call did not run on another call's approval");
|
|
774
|
+
await w.ended("parked");
|
|
775
|
+
const approve = await sendCommand(w.server, RUN, { kind: "approve", body: { approval: callId } });
|
|
776
|
+
await w.ended("ended");
|
|
777
|
+
assert.equal(ran.asked, 1, "approved by its own approval, it ran once");
|
|
778
|
+
assert.equal((await w.commandRow(approve.id)).refused, null, "its approve row is taken, not refused");
|
|
779
|
+
const { calls } = await w.read();
|
|
780
|
+
assert.deepEqual(calls.map((call) => [call.tool, call.status]), [["asked", "done"]]);
|
|
781
|
+
},
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
id: "approval-double-click",
|
|
785
|
+
title: "a double-clicked approval runs the call once: the first answers it, and the store refuses the second (one answer per approval)",
|
|
786
|
+
async body(subject, t) {
|
|
787
|
+
const w = await world(subject, t);
|
|
788
|
+
const { tools, ran } = suiteTools();
|
|
789
|
+
await w.start("runner-a", { script: [{ call: "asked" }, { say: "done" }], tools, hooks: quiet });
|
|
790
|
+
await w.ended("parked");
|
|
791
|
+
const callId = await w.askedCall();
|
|
792
|
+
const first = await sendCommand(w.server, RUN, { kind: "approve", body: { approval: callId } });
|
|
793
|
+
await assert.rejects(sendCommand(w.server, RUN, { kind: "approve", body: { approval: callId } }), StoreConstraint, "a second answer to one approval is never written");
|
|
794
|
+
await w.ended("ended");
|
|
795
|
+
assert.equal(ran.asked, 1, "the call ran once");
|
|
796
|
+
assert.equal((await w.commandRow(first.id)).refused, null, "the first approve answered it");
|
|
797
|
+
const { calls } = await w.read();
|
|
798
|
+
assert.deepEqual(calls.map((call) => [call.tool, call.status]), [["asked", "done"]]);
|
|
799
|
+
},
|
|
800
|
+
},
|
|
801
|
+
{
|
|
802
|
+
id: "message-never-answers",
|
|
803
|
+
title: "a message that answers nothing (a trigger's, answers: false) never answers a waiting call, whatever its words",
|
|
804
|
+
async body(subject, t) {
|
|
805
|
+
const w = await world(subject, t);
|
|
806
|
+
const { tools, ran } = suiteTools();
|
|
807
|
+
await w.start("runner-a", { script: [{ call: "asked" }, { say: "done" }], tools, hooks: quiet });
|
|
808
|
+
await w.ended("parked");
|
|
809
|
+
const callId = await w.askedCall();
|
|
810
|
+
// A trigger's message: it says "yes", but it answers nothing (answers: false), so it resolves no approval.
|
|
811
|
+
await sendCommand(w.server, RUN, { kind: "steer", body: { text: "yes", answers: false, origin: { kind: "trigger", trigger_id: "trigger-1", source: "webhook", owner: false } } });
|
|
812
|
+
// Long enough for the message's row to reach the loop many times over (commandPollMs): this wait can only miss a
|
|
813
|
+
// wrong answer, never fail a right one, and no lease runs out in it.
|
|
814
|
+
await sleep(TIMING.commandPollMs * 40);
|
|
815
|
+
assert.equal(ran.asked, 0, "the waiting call did not run on a message");
|
|
816
|
+
const row = await w.run();
|
|
817
|
+
const { entries } = await journalRecords(w.server.journal({ runId: RUN, runner: "conformance-reader", epoch: row.epoch, until: 0, from: row.state }), BACKGROUND_CONTEXT);
|
|
818
|
+
assert.deepEqual(entries.filter((entry) => entry.kind === KINDS.answer), [], "no answer was written for the call");
|
|
819
|
+
// Its own approval still answers it.
|
|
820
|
+
await sendCommand(w.server, RUN, { kind: "approve", body: { approval: callId } });
|
|
821
|
+
await w.ended("ended", 30_000);
|
|
822
|
+
assert.equal(ran.asked, 1, "approved, it ran once");
|
|
823
|
+
},
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
// The end-of-run step's turn (loop-contract.ts EndOfRunTurn) through the run's own session: its answer is read from
|
|
827
|
+
// the submission its request id names, whoever keeps the record (pi's adapter, or the loop for a CLI), so the step
|
|
828
|
+
// gets it, never "unanswered"; and the loop's record never writes that turn as a message (its prompt as the person's,
|
|
829
|
+
// its answer as the model's). Taking the CLI record's submission away turns this red for a CLI subject.
|
|
830
|
+
id: "end-of-run-answer",
|
|
831
|
+
title: "the end-of-run turn's answer is read, never unanswered, and the loop's record never shows that turn as a message",
|
|
832
|
+
async body(subject, t) {
|
|
833
|
+
const w = await world(subject, t);
|
|
834
|
+
const { tools } = suiteTools();
|
|
835
|
+
const prompt = "What did you learn?";
|
|
836
|
+
const answers = [];
|
|
837
|
+
const endOfRun = async (input) => {
|
|
838
|
+
answers.push(await input.ask(prompt, { origin: "reflect", deadlineMs: 10_000 }));
|
|
839
|
+
return undefined;
|
|
840
|
+
};
|
|
841
|
+
await w.start("runner-a", { script: [{ say: "the job's answer" }, { say: "a note" }], tools, hooks: quiet, agentId: "agent-1" }, undefined, { endOfRun });
|
|
842
|
+
await w.ended("ended");
|
|
843
|
+
assert.equal(answers.length, 1, "asked once");
|
|
844
|
+
const answer = answers[0];
|
|
845
|
+
assert.ok("ended" in answer && answer.answer !== "", `the step read the turn's answer: ${JSON.stringify(answers)}`);
|
|
846
|
+
const row = await w.run();
|
|
847
|
+
const { entries } = await journalRecords(w.server.journal({ runId: RUN, runner: "conformance-reader", epoch: row.epoch, until: 0, from: row.state }), BACKGROUND_CONTEXT);
|
|
848
|
+
const shown = entries.filter((entry) => entry.kind === KINDS.message).map((entry) => entry.data.text);
|
|
849
|
+
assert.ok(!shown.includes(prompt), `the step's prompt is not a message: ${JSON.stringify(shown)}`);
|
|
850
|
+
assert.ok(!shown.includes(answer.answer), `the turn's answer is not a message: ${JSON.stringify(shown)}`);
|
|
851
|
+
},
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
// An answer the model's output limit cut (stopReason "length") is unfinished: a run that ends on it never reads ended.
|
|
855
|
+
id: "length-ends-failed",
|
|
856
|
+
title: "a final answer the model cut at its output limit ends the run failed, saying so",
|
|
857
|
+
async body(subject, t) {
|
|
858
|
+
const w = await world(subject, t);
|
|
859
|
+
const { tools } = suiteTools();
|
|
860
|
+
await w.start("runner-a", { script: [{ say: "The answer is", cut: true }], tools, hooks: quiet });
|
|
861
|
+
const row = await settledRun(w);
|
|
862
|
+
assert.equal(row.state, "failed", `the run ends failed, never ended: ${JSON.stringify({ state: row.state, summary: row.summary })}`);
|
|
863
|
+
assert.match(row.summary ?? "", CUT_AT_LIMIT, "it says the model stopped at its output limit");
|
|
864
|
+
const { messages } = await w.read();
|
|
865
|
+
assert.deepEqual(messages.filter((message) => message.role === "model").map((message) => message.text), ["The answer is"], "its cut answer is kept as it came");
|
|
866
|
+
},
|
|
867
|
+
},
|
|
868
|
+
{
|
|
869
|
+
id: "length-mid-run",
|
|
870
|
+
title: "a cut answer the run goes on from changes nothing: the run's end reads its last answer",
|
|
871
|
+
async body(subject, t) {
|
|
872
|
+
const w = await world(subject, t);
|
|
873
|
+
const { tools } = suiteTools();
|
|
874
|
+
await w.start("runner-a", { script: [{ say: "Part of it", cut: true }, { say: "done" }], tools, hooks: quiet });
|
|
875
|
+
const row = await settledRun(w);
|
|
876
|
+
assert.deepEqual([row.state, row.summary], ["ended", null], "the run ends as its last answer says");
|
|
877
|
+
const { messages } = await w.read();
|
|
878
|
+
assert.deepEqual(messages.filter((message) => message.role === "model").map((message) => message.text), ["Part of it", "done"]);
|
|
879
|
+
},
|
|
880
|
+
},
|
|
881
|
+
];
|
|
882
|
+
const CLI_NEVER_RERUNS = "a CLI never reruns a call that started; only the model calls again (its adapter's facts: rerunsStarted false)";
|
|
883
|
+
/** The cases a harness's declared facts rule out, each with why: what it does by design, not what it cannot model yet. */
|
|
884
|
+
export function factsRuleOut(facts) {
|
|
885
|
+
if (!facts)
|
|
886
|
+
return {};
|
|
887
|
+
const noSteer = `${facts.id} takes no message mid-turn (its adapter's facts: steer false), so the loop refuses a steer for it in words`;
|
|
888
|
+
return {
|
|
889
|
+
// steer-origin steers the turn in flight too: its message is taken mid-turn, or never.
|
|
890
|
+
...(facts.steer ? {} : { "steer-mid-turn": noSteer, "steer-origin": noSteer }),
|
|
891
|
+
...(facts.rerunsStarted === false ? { "replay-safe-rerun": CLI_NEVER_RERUNS, "fault-restarts-bounded": CLI_NEVER_RERUNS } : {}),
|
|
892
|
+
// A harness that resumes a cut answer itself never ends a turn on the cut; one whose cut ends its turn never goes on
|
|
893
|
+
// from it in the same turn.
|
|
894
|
+
...(facts.recoversCutAnswers !== undefined && facts.recoversCutAnswers > 0
|
|
895
|
+
? { "length-ends-failed": `${facts.id} resumes an answer its output limit cut itself, up to ${facts.recoversCutAnswers} times in one turn (its adapter's facts: recoversCutAnswers ${facts.recoversCutAnswers})` }
|
|
896
|
+
: {}),
|
|
897
|
+
...(facts.recoversCutAnswers === 0 ? { "length-mid-run": `a cut ends ${facts.id}'s turn, as pi's does (its adapter's facts: recoversCutAnswers 0)` } : {}),
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
/** What a run whose answer was cut at the model's output limit says (loop-contract.ts cutAtLimit). */
|
|
901
|
+
const CUT_AT_LIMIT = /^the model stopped at its output limit( \(\d+ tokens\))? before finishing its answer$/;
|
|
902
|
+
/** The run once it is released in a final state, whichever: a case reads which. */
|
|
903
|
+
async function settledRun(w) {
|
|
904
|
+
return until(async () => {
|
|
905
|
+
const row = await w.run();
|
|
906
|
+
return row.runner === null && (row.state === "ended" || row.state === "failed" || row.state === "stopped") && row;
|
|
907
|
+
}, "the run ends and is released");
|
|
908
|
+
}
|
|
909
|
+
/** Registers the cases for `subject` with `test` (node:test). A case its facts rule out, or one it cannot model yet, is
|
|
910
|
+
* skipped with its reason, never passed. */
|
|
911
|
+
/** Registers the suite's cases for `subject` with `test`. `storeUrl`: the Postgres store every case's world opens (each
|
|
912
|
+
* in a schema of its own), handed by the caller; without it, the data directory's SQLite store. */
|
|
913
|
+
export function registerHarnessConformance(given, { test, storeUrl }) {
|
|
914
|
+
// The subject object the cases are handed, which names the store their worlds open.
|
|
915
|
+
const subject = Object.create(given);
|
|
916
|
+
if (storeUrl)
|
|
917
|
+
STORE_URLS.set(subject, storeUrl);
|
|
918
|
+
const ruledOut = factsRuleOut(subject.facts);
|
|
919
|
+
for (const entry of CASES) {
|
|
920
|
+
const processCase = entry.id.endsWith("-process");
|
|
921
|
+
const byFacts = ruledOut[entry.id];
|
|
922
|
+
const notYet = subject.unsupported?.[entry.id] ?? (processCase && !subject.process ? "it names no module a runner process can load (subject.process)" : undefined);
|
|
923
|
+
const onPostgres = storeUrl ? POSTGRES_PENDING[entry.id] : undefined;
|
|
924
|
+
const skip = byFacts ? `${subject.name} does not do this by design: ${byFacts}` : notYet ? `${subject.name} cannot model this yet: ${notYet}` : onPostgres ? `on Postgres, ${onPostgres}` : undefined;
|
|
925
|
+
test(`${subject.name}: ${entry.title}`, { timeout: CASE_TIMEOUT_MS, ...(skip ? { skip } : {}) }, (t) => entry.body(subject, t));
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
export const CONFORMANCE_CASES = CASES.map((entry) => entry.id);
|