@parcha/agentrun-serve 0.1.0-beta.58 → 0.1.0-beta.60
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 +402 -1
- package/README.md +516 -190
- package/dist/acp-package.d.ts +5 -1
- package/dist/acp-package.js +19 -2
- package/dist/adapters.d.ts +23 -2
- package/dist/adapters.js +106 -33
- package/dist/agent-delete.d.ts +6 -9
- package/dist/agent-delete.js +5 -3
- package/dist/agent-package.js +11 -1
- package/dist/agents-store.js +1 -1
- package/dist/answer-text.d.ts +3 -0
- package/dist/answer-text.js +22 -0
- package/dist/api-only.d.ts +2 -2
- package/dist/api-only.js +3 -3
- package/dist/archil-routes.d.ts +4 -1
- package/dist/archil-routes.js +15 -12
- package/dist/archil-settings.d.ts +18 -8
- package/dist/archil-settings.js +35 -17
- package/dist/attach-conformance.js +5 -4
- package/dist/box-paths.d.ts +3 -2
- package/dist/box-paths.js +5 -4
- package/dist/browser-computer.d.ts +3 -8
- package/dist/browser-computer.js +12 -35
- package/dist/browser-cost.js +94 -20
- package/dist/capacity.d.ts +1 -1
- package/dist/capacity.js +3 -3
- package/dist/chatgpt-plan.d.ts +7 -0
- package/dist/chatgpt-plan.js +35 -11
- package/dist/claude-login-token.d.ts +20 -11
- package/dist/claude-login-token.js +175 -107
- package/dist/claude-login.d.ts +124 -33
- package/dist/claude-login.js +562 -85
- package/dist/claude-sign-in.d.ts +3 -0
- package/dist/claude-sign-in.js +10 -1
- package/dist/cli-learning/connections.js +1 -1
- package/dist/cli.js +323 -292
- package/dist/composio-made.d.ts +1 -6
- package/dist/composio-made.js +1 -6
- package/dist/composio-owners.d.ts +26 -0
- package/dist/composio-owners.js +36 -0
- package/dist/composio-preset.d.ts +56 -23
- package/dist/composio-preset.js +173 -77
- package/dist/composio-triggers.d.ts +4 -4
- package/dist/composio-triggers.js +6 -7
- package/dist/compute-cost.js +11 -2
- package/dist/computer-attach.d.ts +6 -3
- package/dist/computer-attach.js +41 -29
- package/dist/computer-held-routes.d.ts +1 -1
- package/dist/computer-held-routes.js +9 -4
- package/dist/computer-keys.d.ts +11 -1
- package/dist/computer-keys.js +26 -1
- package/dist/computer-record.js +3 -1
- package/dist/computer-view.d.ts +5 -3
- package/dist/computer-view.js +10 -6
- package/dist/computer-viewer.js +36 -7
- package/dist/computers.d.ts +2 -1
- package/dist/computers.js +6 -3
- package/dist/console/THIRD-PARTY-NOTICES.txt +50 -0
- package/dist/console/assets/backend-QnwGVBeU.js +166 -0
- package/dist/console/assets/index-DZi-muIj.js +629 -0
- package/dist/console/assets/share-pz61zIn9.js +6 -0
- package/dist/console/assets/styles-CcceGcu2.js +291 -0
- package/dist/console/assets/styles-fjQBFfMv.css +1 -0
- package/dist/console/index.html +4 -3
- package/dist/console/share.html +17 -0
- package/dist/decisions.d.ts +17 -7
- package/dist/decisions.js +41 -15
- package/dist/dial-relay.js +10 -4
- package/dist/docker-daemon.js +4 -5
- package/dist/docker-host-addresses.js +29 -11
- package/dist/email/account.d.ts +6 -0
- package/dist/email/account.js +6 -0
- package/dist/email/authentication.d.ts +21 -0
- package/dist/email/authentication.js +106 -0
- package/dist/email/email-faux.d.ts +11 -2
- package/dist/email/email-faux.js +21 -5
- package/dist/email/mail.d.ts +25 -0
- package/dist/email/mail.js +58 -2
- package/dist/email/names.js +2 -2
- package/dist/email/tools.d.ts +9 -4
- package/dist/email/tools.js +95 -13
- package/dist/env-switch.d.ts +12 -2
- package/dist/env-switch.js +23 -3
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/factory-activity.d.ts +68 -0
- package/dist/factory-activity.js +153 -0
- package/dist/factory-runs.d.ts +11 -0
- package/dist/factory-runs.js +52 -0
- package/dist/fal-price.d.ts +11 -1
- package/dist/fal-price.js +33 -0
- package/dist/faux-computers.js +1 -1
- package/dist/filed-answer.d.ts +2 -2
- package/dist/filed-answer.js +2 -2
- package/dist/filed-tool.d.ts +32 -0
- package/dist/filed-tool.js +122 -0
- package/dist/graph-served.d.ts +10 -5
- package/dist/graph-served.js +40 -10
- package/dist/handed-values.js +1 -2
- package/dist/harness-check.d.ts +2 -1
- package/dist/harness-check.js +45 -12
- package/dist/harness-keys.d.ts +1 -2
- package/dist/harness-keys.js +10 -8
- package/dist/harness-opencode/facts.js +2 -0
- package/dist/harness-recipe-entry.d.ts +9 -3
- package/dist/harness-recipe-entry.js +18 -9
- package/dist/harness-recipe.d.ts +21 -0
- package/dist/harness-recipe.js +25 -3
- package/dist/harness-table.d.ts +12 -0
- package/dist/harness-table.js +21 -6
- package/dist/harness.js +6 -2
- package/dist/helper-env.d.ts +4 -1
- package/dist/helper-env.js +4 -1
- package/dist/host-check.d.ts +2 -3
- package/dist/host-check.js +13 -7
- package/dist/hosted-search.js +1 -1
- package/dist/import-worker.js +2 -2
- package/dist/import.d.ts +20 -8
- package/dist/import.js +448 -187
- package/dist/key-refusal.d.ts +14 -2
- package/dist/key-refusal.js +97 -33
- package/dist/learn/audit.d.ts +28 -27
- package/dist/learn/audit.js +87 -62
- package/dist/learn/check.js +1 -1
- package/dist/learn/commit.d.ts +35 -43
- package/dist/learn/commit.js +62 -270
- package/dist/learn/compile.d.ts +9 -6
- package/dist/learn/compile.js +51 -28
- package/dist/learn/corrections.js +1 -1
- package/dist/learn/delete.d.ts +5 -12
- package/dist/learn/delete.js +17 -30
- package/dist/learn/field-check.d.ts +111 -0
- package/dist/learn/field-check.js +174 -0
- package/dist/learn/forget-run.d.ts +16 -0
- package/dist/learn/forget-run.js +53 -0
- package/dist/learn/index.js +1 -1
- package/dist/learn/learning-of.d.ts +0 -4
- package/dist/learn/learning-of.js +0 -5
- package/dist/learn/ledger.d.ts +32 -29
- package/dist/learn/ledger.js +26 -19
- package/dist/learn/{folder.d.ts → legacy/folder.d.ts} +2 -1
- package/dist/learn/{folder.js → legacy/folder.js} +4 -7
- package/dist/learn/legacy/place.d.ts +16 -0
- package/dist/{workspace/learning-workspace.js → learn/legacy/place.js} +12 -42
- package/dist/learn/legacy/scrub.d.ts +28 -0
- package/dist/learn/legacy/scrub.js +258 -0
- package/dist/learn/promote.d.ts +119 -102
- package/dist/learn/promote.js +119 -262
- package/dist/learn/reset-ledger.d.ts +18 -0
- package/dist/learn/reset-ledger.js +14 -0
- package/dist/learn/rows.d.ts +186 -0
- package/dist/learn/rows.js +376 -0
- package/dist/learn/secrets.d.ts +4 -0
- package/dist/learn/secrets.js +12 -0
- package/dist/learn/workflow-draft.d.ts +4 -1
- package/dist/learn/workflow-draft.js +12 -2
- package/dist/learned-nodes.d.ts +8 -5
- package/dist/learned-nodes.js +8 -5
- package/dist/learned-workflow.d.ts +2 -1
- package/dist/learned-workflow.js +13 -10
- package/dist/learning-cost.d.ts +25 -8
- package/dist/learning-cost.js +23 -8
- package/dist/learning-reset.d.ts +1 -1
- package/dist/learning-reset.js +9 -11
- package/dist/learning-routes.d.ts +60 -81
- package/dist/learning-routes.js +187 -360
- package/dist/learning-setting.d.ts +6 -0
- package/dist/learning-setting.js +11 -1
- package/dist/learning-words.d.ts +2 -0
- package/dist/learning-words.js +2 -0
- package/dist/learning.d.ts +18 -24
- package/dist/learning.js +35 -66
- package/dist/listen-first.d.ts +5 -4
- package/dist/listen-first.js +4 -5
- package/dist/live-reach.d.ts +7 -0
- package/dist/live-reach.js +7 -0
- package/dist/mcp-api-only-origins.d.ts +15 -0
- package/dist/mcp-api-only-origins.js +40 -0
- package/dist/mcp-gateway.d.ts +22 -2
- package/dist/mcp-gateway.js +85 -11
- package/dist/mcp-oauth.d.ts +1 -1
- package/dist/mcp-oauth.js +3 -2
- package/dist/mcp-probe.d.ts +3 -0
- package/dist/mcp-probe.js +3 -0
- package/dist/mcp-resources.d.ts +1 -1
- package/dist/mcp-secret-writes.d.ts +24 -2
- package/dist/mcp-secret-writes.js +30 -2
- package/dist/mcp-servers-store.d.ts +52 -14
- package/dist/mcp-servers-store.js +165 -61
- package/dist/mcp-sources.d.ts +1 -2
- package/dist/mcp-sources.js +1 -2
- package/dist/mcp-store.d.ts +5 -5
- package/dist/mcp-store.js +3 -3
- package/dist/mcp.js +1 -1
- package/dist/model-gateway.d.ts +1 -1
- package/dist/model-gateway.js +20 -36
- package/dist/native/discovery.d.ts +6 -0
- package/dist/native/discovery.js +14 -1
- package/dist/native/remote.d.ts +5 -0
- package/dist/native/remote.js +16 -0
- package/dist/native/runtime.js +3 -2
- package/dist/observation/observer.d.ts +6 -6
- package/dist/ollama-provider.d.ts +23 -9
- package/dist/ollama-provider.js +49 -20
- package/dist/openapi.js +290 -79
- package/dist/otel/genai.d.ts +83 -7
- package/dist/otel/genai.js +69 -9
- package/dist/otel/tracer.d.ts +42 -13
- package/dist/otel/tracer.js +241 -56
- package/dist/page.d.ts +7 -1
- package/dist/page.js +76 -22
- package/dist/paid-calls.d.ts +6 -4
- package/dist/paid-calls.js +15 -7
- package/dist/place-offers.d.ts +58 -34
- package/dist/place-offers.js +96 -54
- package/dist/place.d.ts +41 -20
- package/dist/place.js +97 -47
- package/dist/print.js +1 -1
- package/dist/provider.d.ts +3 -2
- package/dist/provider.js +17 -8
- package/dist/purged-workflow.d.ts +0 -33
- package/dist/purged-workflow.js +3 -71
- package/dist/redact/match.d.ts +42 -9
- package/dist/redact/match.js +356 -54
- package/dist/run-census.d.ts +1 -1
- package/dist/run-census.js +4 -5
- package/dist/run-cut.js +4 -5
- package/dist/run-export-store.d.ts +15 -0
- package/dist/run-export-store.js +30 -0
- package/dist/run-export.d.ts +139 -0
- package/dist/run-export.js +379 -0
- package/dist/run-file-cut.d.ts +5 -0
- package/dist/run-file-cut.js +13 -0
- package/dist/run-launch.d.ts +3 -3
- package/dist/run-launch.js +16 -3
- package/dist/run-learning-served.d.ts +3 -3
- package/dist/run-learning-served.js +1 -1
- package/dist/run-listing.d.ts +1 -1
- package/dist/run-model-key.d.ts +15 -6
- package/dist/run-model-key.js +30 -31
- package/dist/run-reads-over-store.js +4 -4
- package/dist/run-secrets.js +3 -5
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +8 -5
- package/dist/runnable.js +26 -9
- package/dist/runner/adapter-loop.d.ts +35 -18
- package/dist/runner/adapter-loop.js +94 -47
- package/dist/runner/adapter-run-spec.d.ts +14 -1
- package/dist/runner/adapter-run-spec.js +73 -46
- package/dist/runner/adapters/pi.js +4 -2
- package/dist/runner/audit.d.ts +10 -9
- package/dist/runner/audit.js +64 -67
- package/dist/runner/beside.js +5 -6
- package/dist/runner/claim-secrets.d.ts +10 -3
- package/dist/runner/claim-secrets.js +29 -13
- package/dist/runner/cli-run-spec.d.ts +18 -0
- package/dist/runner/cli-run-spec.js +87 -58
- package/dist/runner/compare-end.d.ts +2 -3
- package/dist/runner/compare-end.js +30 -11
- package/dist/runner/conformance/harness.js +2 -3
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/disk-free.d.ts +15 -4
- package/dist/runner/disk-free.js +25 -7
- package/dist/runner/feedback-round.d.ts +1 -1
- package/dist/runner/feedback-round.js +2 -2
- package/dist/runner/harness-loops.js +3 -4
- package/dist/runner/held.d.ts +5 -12
- package/dist/runner/held.js +0 -25
- package/dist/runner/journal-kinds.d.ts +8 -2
- package/dist/runner/journal-kinds.js +23 -5
- package/dist/runner/learned-first.d.ts +0 -2
- package/dist/runner/learned-first.js +23 -7
- package/dist/runner/learning-end.d.ts +14 -24
- package/dist/runner/learning-end.js +52 -94
- package/dist/runner/learning-seed.d.ts +13 -16
- package/dist/runner/learning-seed.js +13 -23
- package/dist/runner/live-ticker.js +7 -5
- package/dist/runner/loop-contract.d.ts +0 -2
- package/dist/runner/loop.d.ts +7 -0
- package/dist/runner/loop.js +1 -0
- package/dist/runner/main.js +13 -12
- package/dist/runner/mcp-claim.js +21 -5
- package/dist/runner/mcp-run.d.ts +4 -0
- package/dist/runner/mcp-run.js +2 -0
- package/dist/runner/meta-tools.js +3 -2
- package/dist/runner/metrics.d.ts +7 -0
- package/dist/runner/metrics.js +19 -0
- package/dist/runner/model-route.d.ts +10 -7
- package/dist/runner/model-route.js +79 -15
- package/dist/runner/native-loop.js +12 -11
- package/dist/runner/presence.d.ts +1 -4
- package/dist/runner/presence.js +6 -8
- package/dist/runner/promotion.d.ts +39 -36
- package/dist/runner/promotion.js +168 -112
- package/dist/runner/redact.d.ts +3 -1
- package/dist/runner/redact.js +5 -3
- package/dist/runner/reflect-hook.d.ts +2 -2
- package/dist/runner/reflect-hook.js +4 -1
- package/dist/runner/responses-fetch.d.ts +36 -0
- package/dist/runner/responses-fetch.js +511 -0
- package/dist/runner/run-child-host.d.ts +21 -14
- package/dist/runner/run-child-host.js +187 -141
- package/dist/runner/run-child.js +11 -4
- package/dist/runner/runner-check.js +5 -1
- package/dist/runner/runner.d.ts +3 -4
- package/dist/runner/runner.js +13 -9
- package/dist/runner/sdk-loop.js +10 -12
- package/dist/runner/spec-holds.d.ts +8 -1
- package/dist/runner/spec-holds.js +9 -4
- package/dist/runner/workflow-calls.d.ts +9 -0
- package/dist/runner/workflow-calls.js +150 -0
- package/dist/runner/workflow-first.d.ts +120 -32
- package/dist/runner/workflow-first.js +218 -94
- package/dist/runner/workflow-spec.js +1 -1
- package/dist/runs-over-store.js +8 -7
- package/dist/save-once.d.ts +14 -0
- package/dist/save-once.js +31 -0
- package/dist/scrub-command.d.ts +34 -31
- package/dist/scrub-command.js +116 -147
- package/dist/sdk/check.d.ts +1 -4
- package/dist/sdk/check.js +2 -3
- package/dist/sdk/runs.d.ts +26 -7
- package/dist/sdk/runs.js +194 -78
- package/dist/seal-key.js +4 -4
- package/dist/secret-cut.d.ts +3 -0
- package/dist/secret-cut.js +7 -1
- package/dist/secret-rules.d.ts +8 -1
- package/dist/secret-rules.js +482 -53
- package/dist/secrets.d.ts +55 -9
- package/dist/secrets.js +345 -21
- package/dist/server-fs.d.ts +1 -1
- package/dist/server-fs.js +1 -1
- package/dist/server-keys.d.ts +10 -3
- package/dist/server-keys.js +16 -3
- package/dist/server-secrets-store.js +2 -4
- package/dist/server.d.ts +30 -18
- package/dist/server.js +520 -238
- package/dist/share-context.d.ts +22 -0
- package/dist/share-context.js +76 -0
- package/dist/shell-lex.d.ts +105 -0
- package/dist/shell-lex.js +646 -0
- package/dist/sign-ins-store.d.ts +5 -7
- package/dist/sign-ins-store.js +12 -16
- package/dist/sign-ins.d.ts +7 -11
- package/dist/sign-ins.js +40 -41
- package/dist/skills/agentrun-serve/SKILL.md +5 -2
- package/dist/source-sync/auxiliary.js +2 -2
- package/dist/start-switches.d.ts +6 -5
- package/dist/start-switches.js +8 -4
- package/dist/stats.d.ts +5 -1
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.js +2 -2
- package/dist/store/dialect.d.ts +4 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/mcp-record-keys.d.ts +10 -0
- package/dist/store/mcp-record-keys.js +13 -0
- package/dist/store/postgres/dialect.js +2 -0
- package/dist/store/postgres/migrations/0029_run_launch_census_settle.sql +28 -0
- package/dist/store/postgres/migrations/0030_learning_ledger_epoch.sql +40 -0
- package/dist/store/postgres/migrations/0031_learning_ledger_calls.sql +12 -0
- package/dist/store/postgres/migrations/0032_learning_rows.sql +65 -0
- package/dist/store/postgres/store.js +4 -0
- package/dist/store/schema.d.ts +60 -11
- package/dist/store/schema.js +147 -17
- package/dist/store/seal.d.ts +4 -1
- package/dist/store/sqlite/learning-rows.d.ts +23 -0
- package/dist/store/sqlite/learning-rows.js +559 -0
- package/dist/store/sqlite/run-launch.d.ts +3 -10
- package/dist/store/sqlite/run-launch.js +12 -23
- package/dist/store/sqlite/run-patch.d.ts +17 -10
- package/dist/store/sqlite/run-patch.js +50 -13
- package/dist/store/sqlite/store.d.ts +9 -0
- package/dist/store/sqlite/store.js +194 -46
- package/dist/store/store-schema.js +3 -4
- package/dist/store/store.d.ts +286 -38
- package/dist/store/store.js +27 -11
- package/dist/store-reads/analytics.d.ts +2 -1
- package/dist/store-reads/analytics.js +7 -5
- package/dist/store-reads/journal.d.ts +33 -3
- package/dist/store-reads/journal.js +99 -4
- package/dist/store-reads/learning.d.ts +50 -45
- package/dist/store-reads/learning.js +153 -116
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-reads/stats.d.ts +2 -2
- package/dist/store-reads/stats.js +13 -7
- package/dist/store-view.d.ts +24 -2
- package/dist/store-view.js +49 -17
- package/dist/suggestions.d.ts +1 -1
- package/dist/suggestions.js +29 -13
- package/dist/template-eval.d.ts +72 -9
- package/dist/template-eval.js +358 -64
- package/dist/templates.d.ts +10 -2
- package/dist/templates.js +31 -4
- package/dist/timeline/labels.d.ts +1 -1
- package/dist/timeline/labels.js +4 -3
- package/dist/timeline/timeline.d.ts +23 -11
- package/dist/timeline/timeline.js +115 -31
- package/dist/timeline/web-calls.d.ts +8 -6
- package/dist/timeline/web-calls.js +10 -6
- package/dist/tool-gate.d.ts +13 -1
- package/dist/tool-gate.js +43 -3
- package/dist/tool-keys-store.js +2 -4
- package/dist/tool-keys.d.ts +11 -0
- package/dist/tool-keys.js +16 -0
- package/dist/tool-plane.d.ts +54 -13
- package/dist/tool-plane.js +103 -32
- package/dist/tools.d.ts +5 -1
- package/dist/tools.js +7 -7
- package/dist/trigger-email.js +12 -6
- package/dist/triggers.d.ts +15 -34
- package/dist/triggers.js +119 -126
- package/dist/validate.d.ts +8 -1
- package/dist/validate.js +163 -23
- package/dist/web-fake.d.ts +2 -1
- package/dist/web-fake.js +8 -6
- package/dist/web-fetch.d.ts +8 -6
- package/dist/web-fetch.js +13 -11
- package/dist/web-holds.d.ts +34 -0
- package/dist/web-holds.js +89 -0
- package/dist/web-run.d.ts +32 -5
- package/dist/web-run.js +76 -28
- package/dist/web-save.js +23 -12
- package/dist/web-search.js +14 -25
- package/dist/wires.d.ts +4 -3
- package/dist/wires.js +5 -4
- package/dist/workspace/archil-claim.d.ts +12 -5
- package/dist/workspace/archil-claim.js +45 -5
- package/dist/workspace/archil-exec.js +1 -1
- package/dist/workspace/archil.d.ts +1 -1
- package/dist/workspace/archil.js +1 -1
- package/dist/workspace/attach.js +52 -19
- package/dist/workspace/attached-computers.d.ts +6 -2
- package/dist/workspace/attached-computers.js +5 -4
- package/dist/workspace/computer-deps.d.ts +23 -6
- package/dist/workspace/computer-deps.js +38 -18
- package/dist/workspace/computer-for-claim.d.ts +21 -4
- package/dist/workspace/computer-for-claim.js +160 -54
- package/dist/workspace/computer-intervals.d.ts +2 -0
- package/dist/workspace/computer-intervals.js +1 -1
- package/dist/workspace/computer-janitor.d.ts +48 -14
- package/dist/workspace/computer-janitor.js +153 -44
- package/dist/workspace/computer-kept.d.ts +158 -32
- package/dist/workspace/computer-kept.js +288 -63
- package/dist/workspace/computer-providers.d.ts +19 -4
- package/dist/workspace/computer-providers.js +40 -6
- package/dist/workspace/index.d.ts +2 -3
- package/dist/workspace/index.js +2 -3
- package/dist/workspace/local.js +41 -1
- package/dist/workspace/mount-revoke-left.d.ts +31 -0
- package/dist/workspace/mount-revoke-left.js +72 -0
- package/dist/workspace/paired-route.js +4 -5
- package/dist/workspace/paths.d.ts +0 -4
- package/dist/workspace/paths.js +0 -6
- package/dist/workspace/resolve-computer.d.ts +5 -2
- package/dist/workspace/resolve-computer.js +9 -3
- package/dist/workspace/run-end-computers.d.ts +11 -5
- package/dist/workspace/run-end-computers.js +153 -28
- package/dist/workspace/run-tools.d.ts +22 -3
- package/dist/workspace/run-tools.js +17 -5
- package/dist/workspace/run-workspace.d.ts +14 -1
- package/dist/workspace/run-workspace.js +34 -1
- package/dist/workspace/workspace.d.ts +7 -1
- package/dist/workspace/workspace.js +1 -1
- package/package.json +13 -14
- package/skills/agentrun-serve/SKILL.md +5 -2
- package/templates/README.md +22 -6
- package/templates/TOOLS.md +46 -0
- package/dist/console/assets/backend-CSAWUqtZ.js +0 -166
- package/dist/console/assets/index-Bwn1oTem.css +0 -1
- package/dist/console/assets/index-DPh29cyz.js +0 -747
- package/dist/workspace/learning-workspace.d.ts +0 -24
- /package/dist/learn/{learning.sh → legacy/learning.sh} +0 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// The computer janitor of this server: at the runner's start, then every JANITOR_EVERY_MS, each computer this server made
|
|
2
2
|
// that is past its deadline is ended. A run's release ends its computer; the janitor is for the ones a crashed runner
|
|
3
|
-
// left, on
|
|
3
|
+
// left, on every provider of the registry whose vendor never ends them itself: each whose capabilities().lifetime is
|
|
4
|
+
// "janitor", read off its built provider at every sweep (sweepServerComputers). One whose lifetime is "vendor" is
|
|
5
|
+
// skipped: its vendor ends its machines at their lifetime.
|
|
4
6
|
//
|
|
5
7
|
// Which computers it may end:
|
|
6
8
|
// - a provider's whose keys this server has (saved, or in its environment); Docker takes none, so it is always asked;
|
|
@@ -13,14 +15,22 @@
|
|
|
13
15
|
// - past its deadline, by the computer package's sweep (janitor.ts): the deadline label, or over the provider's cap; or
|
|
14
16
|
// its run is over (final in the store), whatever its deadline: the run's end lets go of every claim's computer
|
|
15
17
|
// (run-end-computers.ts), and this is for one a server that stopped before then left.
|
|
16
|
-
// What a computer leaves outside itself (Docker's egress
|
|
17
|
-
//
|
|
18
|
+
// What a computer leaves outside itself (Docker's egress proxy and volume) goes with its release. One a release never
|
|
19
|
+
// took (a server that stopped partway through a teardown) is the provider's sweepLeftovers', asked for this server's
|
|
20
|
+
// alone (leftoverMine): one whose agentrun.run label (or its hash) names a run in this store, or whose owner names this
|
|
21
|
+
// server, by the same labels the computers go by. Another server's on the same Docker host is never touched; it goes at
|
|
22
|
+
// that server's own next sweep.
|
|
18
23
|
//
|
|
19
24
|
// A desktop or a phone kept at a run's park (computer-kept.ts) goes by its own row, on any provider: each sweep ends one
|
|
20
|
-
// past its time or whose run ended,
|
|
21
|
-
// runner still there is that runner's (computer-kept.ts
|
|
22
|
-
//
|
|
23
|
-
//
|
|
25
|
+
// past its time or whose run ended, with the mount credential of a run folder it held on Archil, and the janitor wakes
|
|
26
|
+
// again at the earliest time still ahead. One pinned to another runner still there is that runner's (computer-kept.ts
|
|
27
|
+
// heldElsewhere): the kept pass leaves its row, its credential with it. The provider sweep ends only a machine past its
|
|
28
|
+
// deadline or whose run is final, which no one uses. Its row is marked ending before that delete (endingKeptMachine), so
|
|
29
|
+
// a follow-up never takes the machine back mid-delete, and ended once the delete took it (finishedKept), so the run's
|
|
30
|
+
// next park writes its own keep; a row a claim is taking back is left, and the machine with it, said as a failed delete.
|
|
31
|
+
// A machine kept on Archil has its park's mount credential removed before its row is marked ended, as the kept pass
|
|
32
|
+
// removes it: no pass removes a credential for an ended row. A remove that fails leaves the row ending, and the kept pass
|
|
33
|
+
// that then ends it removes the credential.
|
|
24
34
|
//
|
|
25
35
|
// A provider whose sweep fails is logged, once per distinct failure, and the others are swept. It runs only where its
|
|
26
36
|
// start asks for it (the CLI's runner and the runner subcommand), never under --faux, and never two sweeps at once. Its
|
|
@@ -30,13 +40,18 @@
|
|
|
30
40
|
// An agent's own computer (a persistent setting, agent-computer.ts) is this server's when its owner names this server's
|
|
31
41
|
// id, never by its run: it goes only when its agent no longer wants it (ownerGoneOf: gone, archived, or no longer
|
|
32
42
|
// persistent on that provider), never by a deadline. Without the store's settings and agents, none is this server's.
|
|
33
|
-
import { epochOf, ok, ownerOf, RUN_HASH_LABEL, RUN_LABEL, runHash, sweep } from "@parcha/agentrun-computer";
|
|
43
|
+
import { epochOf, fail, ok, ownerOf, RUN_HASH_LABEL, RUN_LABEL, runHash, sweep } from "@parcha/agentrun-computer";
|
|
44
|
+
import { loadArchilSettings } from "../archil-settings.js";
|
|
34
45
|
import { KEY_TABLE, providerOptions } from "../computer-keys.js";
|
|
35
46
|
import { FAUX_ENV } from "../model.js";
|
|
36
47
|
import { FINAL_STATES } from "../store/index.js";
|
|
37
48
|
import { deleteUnderHold, ownerGoneOf, serverIdOf, wantsOn } from "./agent-computer.js";
|
|
38
|
-
import {
|
|
49
|
+
import { archilApiKey } from "./archil-key.js";
|
|
50
|
+
import { removeRunMountTokens } from "./archil-mount-credential.js";
|
|
51
|
+
import { endingKeptMachine, finishedKept, readKept, sweepKept } from "./computer-kept.js";
|
|
52
|
+
import { MOUNT_TTL_MS } from "./archil-claim.js";
|
|
39
53
|
import { storeLedger } from "./computer-ledger.js";
|
|
54
|
+
import { sweepMountRevokes } from "./mount-revoke-left.js";
|
|
40
55
|
import { providerKeys } from "./resolve-computer.js";
|
|
41
56
|
import { intervalWrites } from "./computer-intervals.js";
|
|
42
57
|
/** How often the janitor sweeps after its first sweep at the runner's start. */
|
|
@@ -50,6 +65,12 @@ const runsByHash = (store) => {
|
|
|
50
65
|
let read;
|
|
51
66
|
return () => (read ??= store.runs.list({}).then((rows) => new Map(rows.map((row) => [runHash(row.id), row.id]))));
|
|
52
67
|
};
|
|
68
|
+
/** The run a computer's labels name: by its run label, or its hash's (runsByHash); undefined for none of this store's. */
|
|
69
|
+
async function runOf(labels, byHash) {
|
|
70
|
+
const named = labels[RUN_LABEL];
|
|
71
|
+
const hash = labels[RUN_HASH_LABEL];
|
|
72
|
+
return typeof named === "string" && named !== "" ? named : typeof hash === "string" && hash !== "" ? (await byHash()).get(hash) : undefined;
|
|
73
|
+
}
|
|
53
74
|
/** Whether a listed computer is this server's and no claim holds it: its run (by its label, or its hash's) is in this
|
|
54
75
|
* store, and no claim holds the run now (by the store's clock), or one holds it at a later epoch than the computer's.
|
|
55
76
|
* "over" for one of these whose run is over (final in the store): no claim of the run will use it again. An agent's own
|
|
@@ -61,9 +82,7 @@ async function sweepable(store, info, byHash, serverId) {
|
|
|
61
82
|
const owner = info.owner ?? (label.ok ? label.value : undefined);
|
|
62
83
|
if (info.owned === true || owner !== undefined || !label.ok)
|
|
63
84
|
return serverId !== undefined && owner?.server === serverId;
|
|
64
|
-
const
|
|
65
|
-
const hash = labels[RUN_HASH_LABEL];
|
|
66
|
-
const runId = typeof named === "string" && named !== "" ? named : typeof hash === "string" && hash !== "" ? (await byHash()).get(hash) : undefined;
|
|
85
|
+
const runId = await runOf(labels, byHash);
|
|
67
86
|
if (runId === undefined)
|
|
68
87
|
return false;
|
|
69
88
|
const run = await store.runs.get(runId);
|
|
@@ -77,16 +96,40 @@ async function sweepable(store, info, byHash, serverId) {
|
|
|
77
96
|
return false;
|
|
78
97
|
return FINAL_STATES.includes(run.state) ? "over" : true;
|
|
79
98
|
}
|
|
80
|
-
/**
|
|
99
|
+
/** Whether a leftover with these labels is this server's to remove: an agent's (an owner label) when its owner names
|
|
100
|
+
* `serverId`; otherwise when its run (by its label, or its hash's) is in this store and no claim holds it now
|
|
101
|
+
* (runs.heldAt, by the store's clock). A held run's runner may be making the computer this part belongs to: create
|
|
102
|
+
* makes the proxy before the computer. The provider reads the computer after this answer (Docker's sweepLeftovers),
|
|
103
|
+
* and that read is final: a computer is made only under a held claim, its name is its claim's (runId#epoch), so once
|
|
104
|
+
* none holds the run, no create at that claim is left, and a later claim's computer has another name. */
|
|
105
|
+
async function leftoverMine(store, labels, byHash, serverId) {
|
|
106
|
+
const label = ownerOf(labels);
|
|
107
|
+
if (!label.ok || label.value !== undefined)
|
|
108
|
+
return label.ok && serverId !== undefined && label.value?.server === serverId;
|
|
109
|
+
const named = labels[RUN_LABEL];
|
|
110
|
+
const hash = labels[RUN_HASH_LABEL];
|
|
111
|
+
const runId = typeof named === "string" && named !== "" ? named : typeof hash === "string" && hash !== "" ? (await byHash()).get(hash) : undefined;
|
|
112
|
+
if (runId === undefined || (await store.runs.get(runId)) === undefined)
|
|
113
|
+
return false;
|
|
114
|
+
return (await store.runs.heldAt(runId)) === undefined;
|
|
115
|
+
}
|
|
116
|
+
/** `provider` as the sweep sees it: its list cut to this server's computers that no claim holds, and its leftovers pass
|
|
117
|
+
* (where it has one) cut to this server's (leftoverMine).
|
|
81
118
|
* A computer of a run that is over is listed past its deadline (the run's end is its deadline), so the sweep ends it
|
|
82
119
|
* now: a server that stopped before its run's end let go of an earlier claim's computer (run-end-computers.ts) leaves
|
|
83
120
|
* it for this sweep, never for its day-long deadline. Each call goes to the provider itself, so its own state is used
|
|
84
121
|
* as it is. */
|
|
85
|
-
function thisServers(provider, store, byHash, serverId, at, ended,
|
|
122
|
+
function thisServers(provider, store, byHash, serverId, at, ended, keeps) {
|
|
86
123
|
// The agents' own computers the list kept, by id: their delete goes under the agent's hold (deleteUnderHold), which
|
|
87
124
|
// also clears the agent's record of it, so its view no longer shows it deleting.
|
|
88
125
|
const ownedBy = new Map();
|
|
126
|
+
// The machines the list kept that their run's park row keeps, by id, each that run: the row is marked ending before
|
|
127
|
+
// the delete (endingKeptMachine), and a row a claim has is left with its machine. A machine whose run's row could not
|
|
128
|
+
// be read is left too, in the store's words: it may be kept, and a delete unmarked could go under a claim's attach.
|
|
129
|
+
const keptRun = new Map();
|
|
130
|
+
const unread = new Map();
|
|
89
131
|
const { settings, agents } = store;
|
|
132
|
+
const leftovers = provider.sweepLeftovers?.bind(provider);
|
|
90
133
|
return {
|
|
91
134
|
id: provider.id,
|
|
92
135
|
version: provider.version,
|
|
@@ -96,13 +139,33 @@ function thisServers(provider, store, byHash, serverId, at, ended, spared) {
|
|
|
96
139
|
attach: (target, context) => provider.attach(target, context),
|
|
97
140
|
network: (ref, policy, context) => provider.network(ref, policy, context),
|
|
98
141
|
connect: (ref) => provider.connect(ref),
|
|
142
|
+
...(leftovers === undefined ? {} : { sweepLeftovers: (context) => leftovers({ ...context, mine: (labels) => leftoverMine(store, labels, byHash, serverId) }) }),
|
|
99
143
|
async release(ref, how, context) {
|
|
144
|
+
const why = how === "delete" ? unread.get(ref.id) : undefined;
|
|
145
|
+
if (why !== undefined)
|
|
146
|
+
return fail("refused", `its run's kept row could not be read (${why}), so it was left`);
|
|
147
|
+
const run = how === "delete" ? keptRun.get(ref.id) : undefined;
|
|
148
|
+
/** The machine's row as marked ending here: ended once the delete took it, a credential on Archil removed first
|
|
149
|
+
* (finishedKept). */
|
|
150
|
+
let finished;
|
|
151
|
+
if (run !== undefined && keeps) {
|
|
152
|
+
const marked = await endingKeptMachine(keeps.settings, run, { provider: keeps.entry, id: ref.id });
|
|
153
|
+
if (marked.kind === "left")
|
|
154
|
+
return fail("refused", `it is kept at run ${run}'s park and a claim is taking it back or has it, so it was left`);
|
|
155
|
+
if (marked.kind === "unmarked")
|
|
156
|
+
return fail("refused", `it is kept at run ${run}'s park and its row could not be marked ending (${marked.why}), so it was left for the row's time`);
|
|
157
|
+
const kept = marked.kept;
|
|
158
|
+
if (kept && kept.provider === keeps.entry && kept.id === ref.id)
|
|
159
|
+
finished = () => finishedKept(keeps.settings, run, kept, keeps.revokeMount);
|
|
160
|
+
}
|
|
100
161
|
const agent = ownedBy.get(ref.id);
|
|
101
162
|
if (how !== "delete" || agent === undefined || settings === undefined) {
|
|
102
163
|
const released = await provider.release(ref, how, context);
|
|
103
164
|
// A run's computer the sweep deleted: its interval ends (computer-intervals.ts), on the provider's ok alone.
|
|
104
|
-
if (released.ok && how === "delete")
|
|
165
|
+
if (released.ok && how === "delete") {
|
|
105
166
|
await ended(ref.id);
|
|
167
|
+
await finished?.();
|
|
168
|
+
}
|
|
106
169
|
return released;
|
|
107
170
|
}
|
|
108
171
|
// Asked again under the hold: the agent may want it back since ownerGone was read (this server's owners carry no
|
|
@@ -116,12 +179,21 @@ function thisServers(provider, store, byHash, serverId, at, ended, spared) {
|
|
|
116
179
|
return listed;
|
|
117
180
|
const kept = [];
|
|
118
181
|
for (const info of listed.value) {
|
|
119
|
-
// A machine kept at a park for another runner still there (sparedKept): that runner's to end, never this sweep's.
|
|
120
|
-
if (spared(info.ref.id))
|
|
121
|
-
continue;
|
|
122
182
|
const mine = await sweepable(store, info, byHash, serverId);
|
|
123
183
|
if (!mine)
|
|
124
184
|
continue;
|
|
185
|
+
// Its run's kept row, read before any delete: whether it keeps this machine.
|
|
186
|
+
const runId = keeps ? await runOf(info.labels, byHash) : undefined;
|
|
187
|
+
if (keeps && runId !== undefined) {
|
|
188
|
+
try {
|
|
189
|
+
const row = await readKept(keeps.settings, runId);
|
|
190
|
+
if (row && !row.ended && row.provider === keeps.entry && row.id === info.ref.id)
|
|
191
|
+
keptRun.set(info.ref.id, runId);
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
unread.set(info.ref.id, error instanceof Error ? error.message : String(error));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
125
197
|
const label = ownerOf(info.labels);
|
|
126
198
|
const owner = info.owner ?? (label.ok ? label.value : undefined);
|
|
127
199
|
if (owner !== undefined)
|
|
@@ -150,11 +222,8 @@ async function bounded(ms, signal, work) {
|
|
|
150
222
|
}
|
|
151
223
|
}
|
|
152
224
|
/** One sweep of every provider this server can list: each provider whose keys it has and whose computers the janitor
|
|
153
|
-
* ends, its computers past their deadline that are this server's and unheld ended. A
|
|
154
|
-
*
|
|
155
|
-
* provider both runners list (a dial vendor's account, a shared Docker engine) would otherwise end, once its run is
|
|
156
|
-
* over, a machine the kept pass left to its runner. Where the kept rows can't be read, each provider is answered as not
|
|
157
|
-
* swept this pass. A provider that fails is answered in its words; nothing throws. */
|
|
225
|
+
* ends, its computers past their deadline that are this server's and unheld ended. A provider that fails is answered
|
|
226
|
+
* in its words; nothing throws. */
|
|
158
227
|
export async function sweepServerComputers(deps, signal) {
|
|
159
228
|
const { store, computers } = deps;
|
|
160
229
|
const writes = intervalWrites(store, deps.log, deps.now);
|
|
@@ -163,16 +232,10 @@ export async function sweepServerComputers(deps, signal) {
|
|
|
163
232
|
const byHash = runsByHash(store);
|
|
164
233
|
// This server's id and its agents: its agents' own computers are swept by their owner (ownerGoneOf).
|
|
165
234
|
const { settings, agents } = store;
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
spared = await sparedKept({ settings, ...(store.runners ? { runners: store.runners } : {}), ...(deps.self ? { self: deps.self } : {}) });
|
|
171
|
-
}
|
|
172
|
-
catch (error) {
|
|
173
|
-
spared = { unread: `the computers kept at a park could not be read, so none of its computers is swept this pass: ${error instanceof Error ? error.message : String(error)}` };
|
|
174
|
-
}
|
|
175
|
-
}
|
|
235
|
+
// A kept machine on Archil this sweep deletes has its park's mount credential removed before its row is marked ended,
|
|
236
|
+
// its ttl judged on the store's clock, as the kept pass judges it. Without the runs' environment, its row is left
|
|
237
|
+
// ending for the kept pass.
|
|
238
|
+
const revokeMount = settings && deps.env ? keptMountRevoke({ settings, sealedKeys: store.sealedKeys, env: deps.env, sealKey: deps.sealKey, ...(deps.mountControl ? { mountControl: deps.mountControl } : {}) }, () => store.sealedKeys.clock()) : undefined;
|
|
176
239
|
const serverId = settings && agents ? await serverIdOf({ settings }) : undefined;
|
|
177
240
|
const out = [];
|
|
178
241
|
for (const entry of computers.kinds.PROVIDERS) {
|
|
@@ -191,13 +254,8 @@ export async function sweepServerComputers(deps, signal) {
|
|
|
191
254
|
// A vendor that ends its own computers needs no janitor.
|
|
192
255
|
if (provider.capabilities().lifetime !== "janitor")
|
|
193
256
|
continue;
|
|
194
|
-
if (typeof spared !== "function") {
|
|
195
|
-
out.push({ provider: entry.id, swept: { ok: false, error: { code: "unreachable", message: spared.unread } } });
|
|
196
|
-
continue;
|
|
197
|
-
}
|
|
198
|
-
const leaves = spared;
|
|
199
257
|
const ownerGone = serverId !== undefined && settings && agents ? ownerGoneOf({ agents, settings, runs: store.runs }, serverId, entry.id) : undefined;
|
|
200
|
-
out.push({ provider: entry.id, swept: await bounded(deps.providerMs ?? JANITOR_PROVIDER_MS, signal, (cut) => sweep(thisServers(provider, store, byHash, serverId, at, (id) => writes.ended(entry.id, id),
|
|
258
|
+
out.push({ provider: entry.id, swept: await bounded(deps.providerMs ?? JANITOR_PROVIDER_MS, signal, (cut) => sweep(thisServers(provider, store, byHash, serverId, at, (id) => writes.ended(entry.id, id), settings ? { settings, entry: entry.id, ...(revokeMount ? { revokeMount } : {}) } : undefined), { now: new Date(at), signal: cut, ...(ownerGone ? { ownerGone } : {}) })) });
|
|
201
259
|
}
|
|
202
260
|
catch (error) {
|
|
203
261
|
out.push({ provider: entry.id, swept: { ok: false, error: { code: "refused", message: error instanceof Error ? error.message : String(error) } } });
|
|
@@ -205,15 +263,54 @@ export async function sweepServerComputers(deps, signal) {
|
|
|
205
263
|
}
|
|
206
264
|
return out;
|
|
207
265
|
}
|
|
266
|
+
/** The remove of a kept row's Archil mount credential (computer-kept.ts KeptMountRevoke), as every end of a row kept on
|
|
267
|
+
* Archil asks it (the kept pass, the provider sweep, a run's end): the run's credentials up to the row's epoch removed,
|
|
268
|
+
* by name, on the disk its row names (the park's), with this server's Archil key read as the claims read it
|
|
269
|
+
* (archil-key.ts): no run lookup, so a run deleted since, or an agent whose disk changed, still has it removed. A row
|
|
270
|
+
* that names no disk has none removed, said on `log`, and its credential ends at its ttl. Past its keep's time plus
|
|
271
|
+
* MOUNT_TTL_MS, by `now` (the store's clock, the one `until` was stamped on), no remove is asked: the credential was
|
|
272
|
+
* minted before the park, so it has ended at its ttl. `signal` cuts its calls to Archil (the janitor's bound passed).
|
|
273
|
+
* Throws where the remove failed, or this server's Archil settings are gone. */
|
|
274
|
+
export function keptMountRevoke(deps, now) {
|
|
275
|
+
return async (runId, kept, signal) => {
|
|
276
|
+
const { disk } = kept;
|
|
277
|
+
if (disk === undefined) {
|
|
278
|
+
deps.log?.(`the computer janitor removed no mount credential of run ${runId}: its kept computer held the run's folder on Archil, but its row names no disk, so the credential lapses at its ttl`);
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
if ((await now()) >= kept.until + MOUNT_TTL_MS)
|
|
282
|
+
return;
|
|
283
|
+
const archil = await loadArchilSettings({ settings: deps.settings }, deps.env);
|
|
284
|
+
if (!archil)
|
|
285
|
+
throw new Error("its mount credential was not removed: this server's Archil settings are gone");
|
|
286
|
+
const { value } = await archilApiKey({ env: deps.env, keys: deps.sealedKeys, sealKey: deps.sealKey });
|
|
287
|
+
await removeRunMountTokens({ region: archil.region, key: () => value, disk, ...deps.mountControl }, runId, kept.epoch, signal ? { signal } : {});
|
|
288
|
+
};
|
|
289
|
+
}
|
|
208
290
|
/** The pass over the desktops and phones kept at a run's park (computer-kept.ts sweepKept): one past its time, or whose
|
|
209
291
|
* run ended, is ended through its provider, made with this server's keys, whatever its lifetime (a vendor's own end is
|
|
210
|
-
* hours away); one pinned to another runner still there (the store's runners) is left to that runner.
|
|
211
|
-
* the
|
|
292
|
+
* hours away); one pinned to another runner still there (the store's runners) is left to that runner. One that held the
|
|
293
|
+
* run's folder on Archil has the run's mount credentials up to its epoch removed (keptMountRevoke). Past its keep's time
|
|
294
|
+
* plus MOUNT_TTL_MS no remove is asked, so a remove that can never succeed (Archil turned off, its key gone, a refusal
|
|
295
|
+
* for good) no longer keeps the row ending and said at every pass. The removes a claim that kept nothing left at its
|
|
296
|
+
* end (mount-revoke-left.ts) are asked the same way, each bounded by `deleteMs` and its row removed once its remove
|
|
297
|
+
* answers. Undefined without the store's settings, where none is kept. Never throws. */
|
|
212
298
|
export async function sweepKeptComputers(deps) {
|
|
213
299
|
const { store, computers } = deps;
|
|
214
300
|
const writes = intervalWrites(store, deps.log, deps.now);
|
|
215
|
-
|
|
301
|
+
const { settings } = store;
|
|
302
|
+
if (!settings)
|
|
216
303
|
return undefined;
|
|
304
|
+
// Each row's `until` was stamped on the store's clock (computer-kept.ts Kept.until), so it is judged on it: its end and
|
|
305
|
+
// the give-up of its credential's remove (past `until` plus MOUNT_TTL_MS) alike.
|
|
306
|
+
let now;
|
|
307
|
+
try {
|
|
308
|
+
now = await store.sealedKeys.clock();
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
return { ended: [], failed: [`the store's clock could not be read, so no kept computer's time could be judged this pass: ${error instanceof Error ? error.message : String(error)}`] };
|
|
312
|
+
}
|
|
313
|
+
const revokeMount = keptMountRevoke({ settings, sealedKeys: store.sealedKeys, env: deps.env, sealKey: deps.sealKey, ...(deps.mountControl ? { mountControl: deps.mountControl } : {}), ...(deps.log ? { log: deps.log } : {}) }, async () => now);
|
|
217
314
|
const keysOf = providerKeys(computers.kinds, computers.keyOf ?? (async () => undefined));
|
|
218
315
|
const providerOf = async (id) => {
|
|
219
316
|
const make = Object.hasOwn(computers.providers, id) ? computers.providers[id] : undefined;
|
|
@@ -222,7 +319,12 @@ export async function sweepKeptComputers(deps) {
|
|
|
222
319
|
const options = providerOptions(id, await keysOf(id), computers.settings ?? {}, computers.keyTable ?? KEY_TABLE);
|
|
223
320
|
return options.ok ? make(options.options, { ledger: storeLedger(store.computerLedger, id) }) : undefined;
|
|
224
321
|
};
|
|
225
|
-
|
|
322
|
+
const bound = deps.deleteMs === undefined ? {} : { deleteMs: deps.deleteMs };
|
|
323
|
+
const kept = await sweepKept({ settings, runs: store.runs, now, providerOf, deleted: (provider, id) => writes.ended(provider, id), revokeMount, ...bound, ...(store.runners ? { runners: store.runners } : {}), ...(deps.self ? { self: deps.self } : {}) });
|
|
324
|
+
// The removes a claim that kept nothing left at its end (mount-revoke-left.ts), by the same remove, its give-up and its
|
|
325
|
+
// bound, so one Archil does not answer never holds the pass from its provider sweep and its next wake.
|
|
326
|
+
const left = await sweepMountRevokes({ settings, revoke: revokeMount, ...bound });
|
|
327
|
+
return left.failed.length === 0 ? kept : { ...kept, failed: [...kept.failed, ...left.failed] };
|
|
226
328
|
}
|
|
227
329
|
/** The janitor: one sweep now, then one every `everyMs`, never two at once, and a kept pass at the earliest time a kept
|
|
228
330
|
* computer is due (sweepKeptComputers; each delete bounded, KEPT_DELETE_MS), so a park's keep ends on time though the
|
|
@@ -251,6 +353,11 @@ export function startJanitor(deps) {
|
|
|
251
353
|
wake = undefined;
|
|
252
354
|
if (kept.next === undefined)
|
|
253
355
|
return;
|
|
356
|
+
// `next` is on the store's clock, so the wait is reckoned from it. Unread: no wake, and the next sweep (everyMs)
|
|
357
|
+
// passes over the rows again.
|
|
358
|
+
const at = await deps.store.sealedKeys.clock().catch(() => undefined);
|
|
359
|
+
if (at === undefined || cut.signal.aborted)
|
|
360
|
+
return;
|
|
254
361
|
wake = setTimeout(() => {
|
|
255
362
|
if (cut.signal.aborted)
|
|
256
363
|
return;
|
|
@@ -258,7 +365,7 @@ export function startJanitor(deps) {
|
|
|
258
365
|
missed = true;
|
|
259
366
|
else
|
|
260
367
|
void alone(keptPass);
|
|
261
|
-
}, Math.max(0, kept.next -
|
|
368
|
+
}, Math.max(0, kept.next - at) + 1_000);
|
|
262
369
|
wake.unref();
|
|
263
370
|
};
|
|
264
371
|
/** `work` as the one sweep under way; a wake missed meanwhile runs the kept pass once it is done. */
|
|
@@ -294,6 +401,8 @@ export function startJanitor(deps) {
|
|
|
294
401
|
said.delete(provider);
|
|
295
402
|
if (swept.value.deleted.length > 0)
|
|
296
403
|
deps.log(`the computer janitor ended ${provider}'s computers past their deadline: ${swept.value.deleted.join(", ")}`);
|
|
404
|
+
if ((swept.value.leftovers ?? []).length > 0)
|
|
405
|
+
deps.log(`the computer janitor removed what ${provider}'s computers left behind: ${(swept.value.leftovers ?? []).join(", ")}`);
|
|
297
406
|
}
|
|
298
407
|
});
|
|
299
408
|
const first = once();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ComputerProvider, type MountKind, type ProviderEntry } from "@parcha/agentrun-computer";
|
|
2
|
-
import { type Runners, type Settings, type Store } from "../store/index.js";
|
|
2
|
+
import { type Claim, type Runners, type Settings, type Store } from "../store/index.js";
|
|
3
3
|
/** How long a park keeps the run's computer for its resume: 10 minutes. */
|
|
4
4
|
export declare const KEEP_MS: number;
|
|
5
5
|
/** KEEP_MS in words. */
|
|
@@ -7,7 +7,8 @@ export declare const KEEP_WORDS = "10 minutes";
|
|
|
7
7
|
/** What a run parked for: a tool's approval, an answer to its question (ask_person), a raise of its spend cap, its turn
|
|
8
8
|
* ended at a refusal of the cap's (paused there), or its learned workflow's call's approval. */
|
|
9
9
|
export type ParkCause = "approval" | "answer" | "cap" | "refusal" | "workflow";
|
|
10
|
-
/** The live view's end at a park: why it parked, and the time its computer is kept until (ms)
|
|
10
|
+
/** The live view's end at a park: why it parked, and the time its computer is kept until (ms), on the parking process's
|
|
11
|
+
* own clock (the viewer counts down from it there), not the row's store-clock `until`. */
|
|
11
12
|
export type ParkedEnd = {
|
|
12
13
|
readonly parked: ParkCause;
|
|
13
14
|
readonly until: number;
|
|
@@ -21,15 +22,27 @@ export declare const computerLapsedWords: (kind: string) => string;
|
|
|
21
22
|
* (pinnedOf), that runner was gone by the resume, and the claiming runner could not reach it. Never names the runner:
|
|
22
23
|
* a runner's name carries its host's. */
|
|
23
24
|
export declare const computerLostWords: (kind: string) => string;
|
|
25
|
+
/** Why the run's computer at its resume is a new one: the one kept at its park was pinned to the runner that kept it,
|
|
26
|
+
* that runner was still there but could not take the run back (refusing claims, or its word late), and the claiming
|
|
27
|
+
* runner could not reach the machine, so it went on on a new one and that runner ends the kept one (restoreKept). Never
|
|
28
|
+
* names the runner. */
|
|
29
|
+
export declare const computerHeldWords: (kind: string) => string;
|
|
24
30
|
/** The live view's words once the kept computer's time passed, the run still parked. */
|
|
25
31
|
export declare const lapsedWords: (kind: string) => string;
|
|
26
|
-
/** The
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
/** The live view's words, the run still parked, for a kept computer whose end began before its time: a claim that could
|
|
33
|
+
* not reach it went on without it (restoreKept), or a later park kept nothing beside another runner's row (keepKept).
|
|
34
|
+
* Its time did not pass, and nothing happens at it for this run, so no reason is given. */
|
|
35
|
+
export declare const unkeptWords: (kind: string) => string;
|
|
36
|
+
/** The settings key of `runId`'s kept computer (the store's KEPT_PREFIX, which its claim rule reads). */
|
|
29
37
|
export declare const keptKeyOf: (runId: string) => string;
|
|
30
38
|
/** A computer kept at a park: its provider (by id), its kind, its ref, the claim epoch its labels carry (a later claim
|
|
31
|
-
* reads its mount back under that epoch), and the time it is kept until (ms). `
|
|
32
|
-
*
|
|
39
|
+
* reads its mount back under that epoch), and the time it is kept until (ms). `until` is on the store's clock (the
|
|
40
|
+
* deadlines': the database's on Postgres, Store.sealedKeys.clock), stamped from it at the park, and every reader judges
|
|
41
|
+
* it on that clock: the claim rule's pin (in SQL), a claim's take-back, the janitor's pass, the run's computer view and
|
|
42
|
+
* the run read's `computer.released` (computer-held-routes.ts releasedAtPark).
|
|
43
|
+
* The parking runner's own timer counts KEEP_MS from the stamp on its own clock. `ending`: its delete has begun and may
|
|
44
|
+
* not have finished, or a later claim went on without it and left it to its runner to end (restoreKept, keepKept);
|
|
45
|
+
* `ended`: it is gone. Either way no claim takes it. */
|
|
33
46
|
export type Kept = {
|
|
34
47
|
readonly provider: string;
|
|
35
48
|
readonly kind: "desktop" | "phone" | "sandbox";
|
|
@@ -40,10 +53,18 @@ export type Kept = {
|
|
|
40
53
|
/** The kind of the run's folder it holds (a bind, an Archil mount or a synced folder); none: it holds none. A claim
|
|
41
54
|
* takes it back only to hold the folder the same way (computer-for-claim.ts reattach). */
|
|
42
55
|
readonly folder?: MountKind;
|
|
56
|
+
/** The Archil disk the run's mount credential is on, where `folder` is archil: the janitor that ends the row removes
|
|
57
|
+
* the credential there, whatever became of the run's row or its agent's disk since. Absent: none is removed, and the
|
|
58
|
+
* credential ends at its ttl. */
|
|
59
|
+
readonly disk?: string;
|
|
43
60
|
/** The runner that kept it and that runner's process (its presence incarnation), where only that runner can reach it
|
|
44
61
|
* again (pinnedOf): both or neither. Absent: any runner takes it back. */
|
|
45
62
|
readonly runner?: string;
|
|
46
63
|
readonly incarnation?: string;
|
|
64
|
+
/** The epoch of the claim taking it back (takeKept): that claim is reaching it, or could not write what came of that.
|
|
65
|
+
* No claim takes it, no park writes over it, and at its time it is ended as any row (endKept, sweepKept), so a
|
|
66
|
+
* take-back that never wrote its end (its process died, the store failed it) leaves the machine a row to end it. */
|
|
67
|
+
readonly taking?: number;
|
|
47
68
|
readonly ending?: true;
|
|
48
69
|
readonly ended?: true;
|
|
49
70
|
};
|
|
@@ -66,39 +87,136 @@ export type KeptHolders = {
|
|
|
66
87
|
readonly runners?: Pick<Runners, "live">;
|
|
67
88
|
readonly self?: KeptHolder;
|
|
68
89
|
};
|
|
69
|
-
/** The one rule
|
|
70
|
-
* row is pinned to a runner other than `self` that is
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
90
|
+
/** The one rule the janitor's kept pass leaves a kept row by (sweepKept), a park leaves another's row by (keepKept), and a
|
|
91
|
+
* claim gives a row back by (computer-for-claim.ts reattach): its row is pinned to a runner other than `self` that is
|
|
92
|
+
* still there under the row's incarnation (seen within RUNNER_STALE_MS, refusing claims or not: store KEPT_PREFIX
|
|
93
|
+
* states the one meaning, and why the claim rule alone also asks that it claims). Only that runner's engine or hub has
|
|
94
|
+
* the machine, so a delete from here either finds nothing (and marks the row ended, leaking it) or, where both runners
|
|
95
|
+
* list it (a dial vendor's account, a shared Docker engine), ends a machine its runner still keeps. The provider sweep
|
|
96
|
+
* asks nothing of this: it ends only a machine past its deadline or whose run is final, which has no user. The runners
|
|
97
|
+
* are read once per maker's call. A read that fails counts every pinned row as held elsewhere: ending another runner's
|
|
98
|
+
* machine blind would leak it or take it. */
|
|
75
99
|
export declare function heldElsewhere(holders: KeptHolders): (kept: Pick<Kept, "runner" | "incarnation">) => Promise<boolean>;
|
|
76
|
-
/** The kept machines a provider sweep leaves this pass, by provider id and computer id: each row not yet ended whose
|
|
77
|
-
* machine is held elsewhere (heldElsewhere, the kept pass's own rule). Throws when the rows can't be read: the sweep
|
|
78
|
-
* then can't tell which machines are kept, and must not guess. */
|
|
79
|
-
export declare function sparedKept(deps: KeptHolders & {
|
|
80
|
-
readonly settings: Pick<KeptSettings, "all">;
|
|
81
|
-
}): Promise<(provider: string, id: string) => boolean>;
|
|
82
100
|
/** How long one delete of a kept computer may take at the janitor's pass: past it the pass goes on, the row is left
|
|
83
101
|
* ending, and the next pass deletes it again (a Docker command has no timeout of its own). */
|
|
84
102
|
export declare const KEPT_DELETE_MS = 60000;
|
|
85
103
|
/** The settings the kept rows live in. */
|
|
86
|
-
export type KeptSettings = Pick<Settings, "get" | "put" | "replaceIf" | "removeIf" | "remove" | "all">;
|
|
104
|
+
export type KeptSettings = Pick<Settings, "get" | "put" | "putIfAbsent" | "replaceIf" | "removeIf" | "remove" | "all">;
|
|
87
105
|
/** A row's value as a Kept, or undefined for anything else. */
|
|
88
106
|
export declare function keptOf(value: unknown): Kept | undefined;
|
|
89
107
|
/** `runId`'s kept computer, as its row reads now; undefined when there is none. */
|
|
90
108
|
export declare function readKept(settings: Pick<KeptSettings, "get">, runId: string): Promise<Kept | undefined>;
|
|
91
|
-
/** Writes `kept` as `runId`'s kept computer
|
|
92
|
-
* reads the same text. */
|
|
109
|
+
/** Writes `kept` as `runId`'s kept computer, whatever the row held. Its fields in one order, so a later compare-and-set
|
|
110
|
+
* reads the same text. A park writes through keepKept. */
|
|
93
111
|
export declare function writeKept(settings: Pick<KeptSettings, "put">, runId: string, kept: Kept): Promise<Kept>;
|
|
94
|
-
/**
|
|
95
|
-
*
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Writes `kept` as `runId`'s kept computer at the claim's park, by compare-and-set: from no row (putIfAbsent), or from the
|
|
114
|
+
* row as read (replaceIf). Its row as written, or undefined when the park keeps nothing.
|
|
115
|
+
*
|
|
116
|
+
* A row not yet ended that is pinned to another runner still there (`holders`, heldElsewhere: store KEPT_PREFIX's one
|
|
117
|
+
* meaning of there), that a claim is taking back (Kept.taking: it may be reaching the machine, or could not write what
|
|
118
|
+
* came of that), or that reads ending (its end begun, a claim that gave it back, a stop: whoever kept it, there or not)
|
|
119
|
+
* is never written over. Its end at its time (endKept) compares the row with the one its park wrote, and a janitor ends
|
|
120
|
+
* an ending row of a runner gone, so a row written over would leave its machine running with nothing to end it. The park
|
|
121
|
+
* keeps nothing then. Its row is marked ending where it is not yet: this claim went on without that machine, so no claim
|
|
122
|
+
* may take it back as the run's (a claim still reaching it then never uses it), and its end still finishes a row so
|
|
123
|
+
* marked. Any other row is replaced, as before: no runner, this claim's own runner, a runner gone (its row as its park
|
|
124
|
+
* wrote it), or one ended. A write that lost reads again, up to KEEP_TRIES times; past them the park keeps nothing.
|
|
125
|
+
* Throws where the store throws.
|
|
126
|
+
*
|
|
127
|
+
* Every write is under `claim`, the parking claim (Settings.putIfAbsent's and replaceIf's claim: the fence checked in the
|
|
128
|
+
* write's own transaction). A park runs before its claim's park commit, so a claim that lost the run by then (its lease
|
|
129
|
+
* ran out, and another claim may have parked and kept since) is refused (Fenced, thrown) and writes and marks nothing:
|
|
130
|
+
* the row the run's current claim wrote stays as it wrote it.
|
|
131
|
+
*/
|
|
132
|
+
export declare function keepKept(settings: Pick<KeptSettings, "get" | "putIfAbsent" | "replaceIf">, runId: string, kept: Kept, holders: KeptHolders, claim?: Claim): Promise<Kept | undefined>;
|
|
133
|
+
/** What came of marking a kept row ending before its machine's delete (endingKept): `marked`, the row reads ending or
|
|
134
|
+
* ended now (or holds no keep the delete could take from a claim), so the delete may go on, and `kept` is the row as it
|
|
135
|
+
* reads ending, for finishedKept once that delete took its machine; `left`, the row is a later claim's keep, or a claim
|
|
136
|
+
* is taking it back, so its machine `id` is that claim's and is not deleted; `unmarked`, no try marked it (`why`), so
|
|
137
|
+
* its machine `id`, where the row was read, is not deleted either: it is left for the row's own time (its keeper's end,
|
|
138
|
+
* or a janitor's pass). */
|
|
139
|
+
export type KeptEnding = {
|
|
140
|
+
readonly kind: "marked";
|
|
141
|
+
readonly kept?: Kept;
|
|
142
|
+
} | {
|
|
143
|
+
readonly kind: "left";
|
|
144
|
+
readonly id?: string;
|
|
145
|
+
} | {
|
|
146
|
+
readonly kind: "unmarked";
|
|
147
|
+
readonly id?: string;
|
|
148
|
+
readonly why: string;
|
|
149
|
+
};
|
|
150
|
+
/** Marks `runId`'s kept row ending at the run's end (run-end-computers.ts), for the claim at `epoch` that ended the run:
|
|
151
|
+
* the run is final, so a machine kept at or before that claim has no user, whichever runner kept it or older claim is
|
|
152
|
+
* taking it back. No claim takes it back after, so the run's end deleting it and its keeper's end agree; the keeper's
|
|
153
|
+
* end at its time, or any janitor's pass, finishes the row. A row of a later claim (its machine made at a later epoch,
|
|
154
|
+
* or a later claim taking it back: a follow-up that queued the run again while this end waited on the store) is left
|
|
155
|
+
* as that claim wrote it, and so is its machine (`left`). A store that fails the mark is asked again (markEnding);
|
|
156
|
+
* `unmarked` past every try, and the run's end then deletes no machine the row names. */
|
|
157
|
+
export declare function endingKept(settings: Pick<KeptSettings, "get" | "replaceIf">, runId: string, epoch: number): Promise<KeptEnding>;
|
|
158
|
+
/** Marks `runId`'s kept row ending before a janitor's provider sweep deletes `machine`, the one the row kept when the
|
|
159
|
+
* sweep listed it (computer-janitor.ts thisServers). The sweep ends only a machine past its deadline or whose run is final, but the row's
|
|
160
|
+
* runner may still be there and its row unmarked (that runner died before its run's end ran, or the end could not mark
|
|
161
|
+
* it): marked first, no claim takes the machine back mid-delete. A row a claim is taking back, or one gone since the
|
|
162
|
+
* read (a claim took it), is a claim's: `left`, and the sweep leaves the machine. A row that keeps another machine
|
|
163
|
+
* now, or already reads ending or ended, needs no mark. */
|
|
164
|
+
export declare function endingKeptMachine(settings: Pick<KeptSettings, "get" | "replaceIf">, runId: string, machine: {
|
|
165
|
+
readonly provider: string;
|
|
166
|
+
readonly id: string;
|
|
167
|
+
}): Promise<KeptEnding>;
|
|
168
|
+
/** Takes `row` off `runId`'s row, only while it still reads so: a keep written for a park that never followed. */
|
|
169
|
+
export declare function dropKept(settings: Pick<KeptSettings, "removeIf">, runId: string, row: Kept): Promise<boolean>;
|
|
170
|
+
/** Marks `kept` taking on its row for the claim at `epoch` that resumes in time (Kept.taking), under `claim` (the store's
|
|
171
|
+
* fence: a claim that lost the run takes nothing): the row as marked when this call took it, undefined when its end (or
|
|
172
|
+
* another claim) had it first. The row stays while the claim reaches the machine: it holds it once keptTaken takes the
|
|
173
|
+
* mark off, and goes on without it through restoreKept. */
|
|
174
|
+
export declare function takeKept(settings: Pick<KeptSettings, "replaceIf">, runId: string, kept: Kept, epoch: number, claim?: Claim): Promise<Kept | undefined>;
|
|
175
|
+
/** The claim that marked `taking` (takeKept) reached its machine: the row taken off, only while it still reads so. True
|
|
176
|
+
* when the machine is the claim's; false when the row changed since (its end began at its time, a park or a stop marked
|
|
177
|
+
* it ending), and the claim must not use it. A write the store fails is tried again; past GIVE_BACK_TRIES it throws. */
|
|
178
|
+
export declare function keptTaken(settings: Pick<KeptSettings, "removeIf">, runId: string, taking: Kept): Promise<boolean>;
|
|
179
|
+
/** The claim that marked `taking` (takeKept) goes on without its machine (it could not reach it, or could not say it
|
|
180
|
+
* holds it): the row turned ending, whoever kept it and whether that runner is there or not, so no claim takes that
|
|
181
|
+
* machine back as the run's (nor does the claim rule pin the run to it). Its runner's end at its time (endKept, which
|
|
182
|
+
* finishes a row its park wrote that reads ending) or its janitor's next pass deletes it; once it is gone, or where any
|
|
183
|
+
* runner reaches it, any janitor's pass does. A row this claim took the mark off (it reached the machine, then failed
|
|
184
|
+
* before it could use it) is put back so, only while the key has none. A write the store fails is tried again. True when
|
|
185
|
+
* the row reads ending (or ended) after; false when it does not (the store failed every try, and the row is left marked
|
|
186
|
+
* taking, which is ended at its time all the same). */
|
|
187
|
+
export declare function restoreKept(settings: Pick<KeptSettings, "get" | "putIfAbsent" | "replaceIf">, runId: string, taking: Kept): Promise<boolean>;
|
|
188
|
+
/** Ends a kept computer at its time: its row marked ending, only while it still reads `kept`, or `kept` marked taking by
|
|
189
|
+
* a claim (one that is reaching it, or could not write what came of that: its time is over all the same, and the claim
|
|
190
|
+
* never uses it once the mark is gone, keptTaken), then `end` (its delete), then the row marked ended. A claim that took
|
|
191
|
+
* it since (the row gone) or a park that wrote another has it. A row already ending (a process that died mid-way, a
|
|
192
|
+
* delete that failed, a claim that gave it back, a park that kept nothing else or a stop: restoreKept, keepKept,
|
|
193
|
+
* endingKept) is deleted again. A delete that fails leaves the row ending, for the janitor's next pass, and throws its
|
|
194
|
+
* words. True when this call ended it. */
|
|
195
|
+
export declare function endKept(settings: Pick<KeptSettings, "get" | "replaceIf">, runId: string, kept: Kept, end: () => Promise<void>): Promise<boolean>;
|
|
196
|
+
/** Marks `runId`'s kept row ended once a delete that marked it ending (a run's end, a janitor's provider sweep: the
|
|
197
|
+
* `kept` of KeptEnding's `marked`) took its machine: only while the row still reads that ending row, so a row changed
|
|
198
|
+
* since is left. A row left ending refuses every later park of the run (keepKept) until a janitor's pass ends it, so a
|
|
199
|
+
* follow-up to a stopped run would keep nothing; ended, the next park writes over it. The delete's caller says only
|
|
200
|
+
* where its provider answered ok for that very machine, so a machine its list never showed (another runner's engine)
|
|
201
|
+
* keeps its row ending for its keeper to end. A row whose machine held the run's folder on Archil, its credential's
|
|
202
|
+
* disk named (Kept.disk), is marked ended only once `revokeMount` removed that credential: an ended row is one no
|
|
203
|
+
* janitor pass removes a credential for, so one marked ended first would leave it valid for its ttl with no machine.
|
|
204
|
+
* Without `revokeMount`, or with one that throws, the row is left ending, and the janitor's kept pass (sweepKept)
|
|
205
|
+
* removes the credential and ends it. Never throws: a row left ending is still ended at its time. */
|
|
206
|
+
export declare function finishedKept(settings: Pick<KeptSettings, "replaceIf">, runId: string, kept: Kept, revokeMount?: KeptMountRevoke): Promise<boolean>;
|
|
207
|
+
/** Removes `runId`'s kept row at the run's end (run-end-computers.ts: the claim at `epoch` ended the run), after its
|
|
208
|
+
* deletes answered or its bound passed: one read of the row, then a remove only while it still reads as read. Removed
|
|
209
|
+
* only where it reads ended (its machine gone: this end's delete marked it so, finishedKept, or its keeper's end at its
|
|
210
|
+
* time or a janitor's pass did before) and was kept at or before `epoch`. Whoever ended it, the run is final, so no
|
|
211
|
+
* resume of this run is left to read it and say why its computer is new; removed, a follow-up that queues the run again
|
|
212
|
+
* reads no keep and never says that lapse. A row that reads ending (a delete not done or not proven), none, and a later
|
|
213
|
+
* claim's keep are left. True when removed; false when left, or when the read or the remove failed. Never throws. */
|
|
214
|
+
export declare function forgetEnded(settings: Pick<KeptSettings, "get" | "removeIf">, runId: string, epoch: number): Promise<boolean>;
|
|
215
|
+
/** Removes run `runId`'s Archil mount credentials of `kept`'s claim epoch and earlier, by their names, on the disk its
|
|
216
|
+
* row names (computer-janitor.ts keptMountRevoke): what every end of a row kept on Archil asks before it marks the row
|
|
217
|
+
* ended (sweepKept, finishedKept). Throws where the remove failed. `signal`: aborted to cut its calls to Archil (the
|
|
218
|
+
* janitor's bound passed). */
|
|
219
|
+
export type KeptMountRevoke = (runId: string, kept: Kept, signal?: AbortSignal) => Promise<void>;
|
|
102
220
|
/** What the janitor's pass over the kept computers did: the names it ended, the failures in words, and the earliest
|
|
103
221
|
* time still ahead (its next wake), if any. */
|
|
104
222
|
export type KeptSweep = {
|
|
@@ -109,16 +227,18 @@ export type KeptSweep = {
|
|
|
109
227
|
/**
|
|
110
228
|
* The janitor's pass over every kept row: one whose run is final in the store, or no longer there, has its computer
|
|
111
229
|
* deleted (unless its time already ended it) and the row removed; one past its time, or left ending, is ended (endKept),
|
|
112
|
-
* each delete bounded by `deleteMs` (KEPT_DELETE_MS)
|
|
230
|
+
* each delete bounded by `deleteMs` (KEPT_DELETE_MS), and one on Archil has its mount credentials removed (`revokeMount`).
|
|
231
|
+
* The rest are left, the earliest of their times answered as `next`.
|
|
113
232
|
* `providerOf`: the provider a row names, made with this server's keys, or undefined when this server can't make it (its
|
|
114
233
|
* keys gone): that row is left and said. A row pinned to a runner other than this one (`self`) that is still there under
|
|
115
|
-
* the row's incarnation (`runners`, seen within
|
|
234
|
+
* the row's incarnation (`runners`, seen within RUNNER_STALE_MS) is left whatever its time or its run: only that
|
|
116
235
|
* runner's engine or hub has its machine, so a delete from here would find nothing, mark it ended and leak the machine.
|
|
117
236
|
* That runner's own timer, or its janitor, ends it; once it is gone the row is ended here as any other. Never throws.
|
|
118
237
|
*/
|
|
119
238
|
export declare function sweepKept(deps: {
|
|
120
239
|
readonly settings: KeptSettings;
|
|
121
240
|
readonly runs: Pick<Store["runs"], "get">;
|
|
241
|
+
/** Now on the store's clock, the one each row's `until` is stamped on (Kept.until). */
|
|
122
242
|
readonly now: number;
|
|
123
243
|
readonly providerOf: (id: string) => Promise<ComputerProvider | undefined>;
|
|
124
244
|
readonly deleteMs?: number;
|
|
@@ -130,6 +250,12 @@ export declare function sweepKept(deps: {
|
|
|
130
250
|
readonly runners?: Pick<Runners, "live">;
|
|
131
251
|
/** The runner this sweep runs in (its name and presence incarnation): the rows pinned to it are its own to end. */
|
|
132
252
|
readonly self?: KeptHolder;
|
|
253
|
+
/** Removes run `runId`'s Archil mount credentials of the row's claim epoch and earlier, by their names: asked after
|
|
254
|
+
* the delete of a row whose computer held the run's folder on Archil, within the same bound. No claim removes that
|
|
255
|
+
* credential once the janitor ends the row (a stop takes no row; a resume that starts no computer never reads it).
|
|
256
|
+
* One that throws leaves the row ending, for the next pass. Handed a signal aborted once that bound passes, cutting its
|
|
257
|
+
* calls to Archil. */
|
|
258
|
+
readonly revokeMount?: KeptMountRevoke;
|
|
133
259
|
}): Promise<KeptSweep>;
|
|
134
260
|
/** Deletes the kept computer through its provider; one already gone (its run's end let it go, run-end-computers.ts, or
|
|
135
261
|
* its vendor ended it) is as good as deleted. Throws the provider's words on any other failure. True when the
|