@parcha/agentrun-serve 0.1.0-beta.57 → 0.1.0-beta.59
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 +376 -0
- package/README.md +393 -118
- 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/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 -4
- package/dist/api-only.js +2 -4
- package/dist/attach-conformance.js +5 -4
- package/dist/box-paths.d.ts +7 -5
- package/dist/box-paths.js +12 -8
- 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 +5 -0
- package/dist/chatgpt-plan.js +25 -11
- package/dist/claude-login-token.d.ts +121 -0
- package/dist/claude-login-token.js +797 -0
- package/dist/claude-login.d.ts +119 -34
- package/dist/claude-login.js +551 -79
- package/dist/claude-sign-in.d.ts +3 -0
- package/dist/claude-sign-in.js +10 -1
- package/dist/cli.js +325 -328
- 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 +40 -19
- package/dist/computer-attach.js +326 -62
- 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 +12 -11
- package/dist/computers.js +11 -8
- package/dist/console/THIRD-PARTY-NOTICES.txt +50 -0
- package/dist/console/assets/backend-BztxEAvb.js +166 -0
- package/dist/console/assets/index-LwNL4L9q.js +619 -0
- package/dist/console/assets/share-L84tlUDW.js +6 -0
- package/dist/console/assets/styles-CaRKlHke.js +291 -0
- package/dist/console/assets/styles-DQo8rzY-.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.d.ts +25 -4
- package/dist/dial-relay.js +139 -5
- 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 +13 -5
- package/dist/env-switch.js +24 -6
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fal-price.d.ts +12 -4
- package/dist/fal-price.js +110 -26
- package/dist/faux-computers.js +1 -1
- package/dist/filed-answer.d.ts +2 -2
- package/dist/filed-answer.js +2 -2
- 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.js +9 -6
- 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 +8 -0
- package/dist/harness-table.js +17 -6
- 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.d.ts +11 -8
- package/dist/import.js +437 -186
- package/dist/key-refusal.d.ts +9 -2
- package/dist/key-refusal.js +86 -32
- package/dist/learn/audit.d.ts +8 -5
- package/dist/learn/audit.js +15 -7
- package/dist/learn/compile.d.ts +5 -2
- package/dist/learn/compile.js +45 -21
- package/dist/learn/field-check.d.ts +111 -0
- package/dist/learn/field-check.js +174 -0
- package/dist/learn/ledger.d.ts +173 -0
- package/dist/learn/ledger.js +225 -0
- package/dist/learn/promote.d.ts +82 -39
- package/dist/learn/promote.js +61 -66
- package/dist/learn/secrets.d.ts +4 -0
- package/dist/learn/secrets.js +12 -0
- 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 +40 -21
- package/dist/learning-cost.js +30 -21
- package/dist/learning-setting.d.ts +6 -0
- package/dist/learning-setting.js +11 -1
- package/dist/listen-first.d.ts +5 -4
- package/dist/listen-first.js +4 -5
- package/dist/live-reach.d.ts +9 -0
- package/dist/live-reach.js +9 -0
- package/dist/mcp-api-only-origins.d.ts +23 -3
- package/dist/mcp-api-only-origins.js +57 -17
- package/dist/mcp-gateway.d.ts +16 -2
- package/dist/mcp-gateway.js +41 -3
- 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-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/micro.d.ts +2 -0
- package/dist/micro.js +2 -0
- package/dist/model-gateway.d.ts +1 -1
- package/dist/model-gateway.js +20 -36
- package/dist/model.d.ts +5 -4
- package/dist/model.js +7 -6
- package/dist/monid.d.ts +14 -1
- package/dist/monid.js +103 -26
- package/dist/ollama-provider.d.ts +23 -9
- package/dist/ollama-provider.js +49 -20
- package/dist/openapi.js +234 -61
- 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 +59 -34
- package/dist/place-offers.js +100 -58
- package/dist/place.d.ts +13 -14
- package/dist/place.js +56 -41
- package/dist/print.js +1 -1
- package/dist/provider.d.ts +5 -4
- package/dist/provider.js +26 -13
- package/dist/redact/match.d.ts +27 -9
- package/dist/redact/match.js +266 -57
- 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.js +16 -3
- package/dist/run-learning-served.d.ts +2 -2
- 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.js +3 -1
- package/dist/run-view.d.ts +1 -2
- package/dist/run-view.js +2 -1
- package/dist/runnable.js +2 -2
- package/dist/runner/adapter-loop.d.ts +35 -18
- package/dist/runner/adapter-loop.js +97 -63
- package/dist/runner/adapter-run-spec.d.ts +34 -14
- package/dist/runner/adapter-run-spec.js +120 -75
- package/dist/runner/adapters/pi.js +4 -2
- package/dist/runner/audit.d.ts +8 -5
- package/dist/runner/audit.js +37 -17
- package/dist/runner/beside.d.ts +9 -2
- package/dist/runner/beside.js +29 -13
- package/dist/runner/claim-secrets.d.ts +27 -18
- package/dist/runner/claim-secrets.js +61 -47
- package/dist/runner/cli-run-spec.d.ts +18 -0
- package/dist/runner/cli-run-spec.js +93 -46
- package/dist/runner/compare-end.d.ts +2 -1
- package/dist/runner/compare-end.js +25 -10
- package/dist/runner/conformance/harness.js +2 -3
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/harness-loops.js +3 -3
- package/dist/runner/held.d.ts +19 -4
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +22 -4
- package/dist/runner/learned-first.js +20 -4
- package/dist/runner/learning-end.d.ts +2 -8
- package/dist/runner/learning-end.js +11 -19
- 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.d.ts +11 -6
- package/dist/runner/main.js +24 -18
- package/dist/runner/mcp-claim.js +24 -7
- package/dist/runner/mcp-run.d.ts +3 -6
- package/dist/runner/mcp-run.js +3 -4
- 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 +10 -8
- package/dist/runner/presence.d.ts +11 -4
- package/dist/runner/presence.js +11 -6
- package/dist/runner/promotion.d.ts +25 -13
- package/dist/runner/promotion.js +125 -50
- package/dist/runner/redact.d.ts +3 -1
- package/dist/runner/redact.js +5 -3
- package/dist/runner/reflect-hook.js +1 -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 +38 -12
- package/dist/runner/run-child-host.js +231 -83
- package/dist/runner/run-child.js +11 -4
- package/dist/runner/runner-check.js +5 -1
- package/dist/runner/runner.d.ts +5 -3
- package/dist/runner/runner.js +14 -10
- package/dist/runner/save-slots.js +2 -1
- package/dist/runner/sdk-loop.js +8 -8
- package/dist/runner/spec-holds.d.ts +8 -1
- package/dist/runner/spec-holds.js +9 -4
- package/dist/runner/subagent.d.ts +11 -0
- package/dist/runner/subagent.js +17 -3
- package/dist/runner/workflow-calls.d.ts +9 -0
- package/dist/runner/workflow-calls.js +150 -0
- package/dist/runner/workflow-first.d.ts +138 -37
- package/dist/runner/workflow-first.js +230 -99
- package/dist/runner/workflow-spec.js +2 -2
- 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/runs.d.ts +6 -0
- package/dist/sdk/runs.js +89 -10
- 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 +51 -9
- package/dist/secrets.js +311 -21
- package/dist/server-keys.d.ts +4 -3
- package/dist/server-keys.js +4 -3
- package/dist/server-secrets-store.js +2 -4
- package/dist/server.d.ts +33 -10
- package/dist/server.js +454 -136
- 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/slots.d.ts +9 -0
- package/dist/slots.js +45 -0
- 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/0028_learning_ledger.sql +44 -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/store.js +4 -0
- package/dist/store/schema.d.ts +44 -4
- package/dist/store/schema.js +111 -11
- package/dist/store/seal.d.ts +4 -1
- 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 +19 -2
- package/dist/store/sqlite/run-patch.js +67 -2
- package/dist/store/sqlite/store.d.ts +3 -0
- package/dist/store/sqlite/store.js +177 -32
- package/dist/store/store-schema.js +3 -4
- package/dist/store/store.d.ts +74 -25
- package/dist/store/store.js +14 -11
- package/dist/store-reads/analytics.d.ts +2 -1
- package/dist/store-reads/analytics.js +7 -5
- package/dist/store-reads/learning.d.ts +102 -136
- package/dist/store-reads/learning.js +251 -302
- package/dist/store-reads/stats.d.ts +2 -2
- package/dist/store-reads/stats.js +13 -7
- package/dist/store-view.js +10 -7
- package/dist/suggestions.d.ts +1 -1
- package/dist/suggestions.js +29 -13
- package/dist/template-eval.d.ts +91 -9
- package/dist/template-eval.js +448 -105
- package/dist/template-import.d.ts +0 -10
- package/dist/template-import.js +5 -10
- 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 +14 -14
- package/dist/timeline/web-calls.js +18 -30
- 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 +50 -11
- package/dist/tool-plane.js +94 -30
- 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 +32 -0
- package/dist/web-holds.js +86 -0
- package/dist/web-run.d.ts +32 -5
- package/dist/web-run.js +75 -28
- package/dist/web-save.d.ts +4 -9
- package/dist/web-save.js +27 -55
- 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/attach.js +52 -19
- package/dist/workspace/attached-computers.d.ts +38 -11
- package/dist/workspace/attached-computers.js +81 -16
- package/dist/workspace/computer-deps.d.ts +29 -7
- package/dist/workspace/computer-deps.js +36 -18
- package/dist/workspace/computer-for-claim.d.ts +21 -4
- package/dist/workspace/computer-for-claim.js +166 -57
- 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 +8 -3
- package/dist/workspace/computer-providers.js +12 -5
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- 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.d.ts +91 -0
- package/dist/workspace/paired-route.js +152 -0
- 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 +6 -0
- package/dist/wrapped.d.ts +8 -2
- package/dist/wrapped.js +21 -6
- package/package.json +12 -13
- package/skills/agentrun-serve/SKILL.md +5 -2
- package/templates/README.md +25 -9
- package/dist/console/assets/backend-DVhHzJX2.js +0 -166
- package/dist/console/assets/index-Bwn1oTem.css +0 -1
- package/dist/console/assets/index-okP-y8PK.js +0 -747
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// run on one ahead of them while its runner floor is at most what they know (migrate.ts runnerFloorOf).
|
|
5
5
|
import { SchemaVersionUnknown, StoreAwaitsServer } from "../store.js";
|
|
6
6
|
import { backfillNativeCommandOwners } from '../native-command-owner.js';
|
|
7
|
+
import { backfillLedger } from "../sqlite/run-patch.js";
|
|
7
8
|
import { storeOver } from "../sqlite/store.js";
|
|
8
9
|
import { PgConnection, SCHEMA_NAME } from "./connection.js";
|
|
9
10
|
import { migrate, migrationsIn, placeOf, refuseBelowFloor, runnerFloorOf, versionOf } from "./migrate.js";
|
|
@@ -64,6 +65,9 @@ export async function openPostgresStore(options) {
|
|
|
64
65
|
}
|
|
65
66
|
if (role === "server")
|
|
66
67
|
await backfillNativeCommandOwners(connection);
|
|
68
|
+
// Every run an earlier build ended gets its ledger row once, here, as on SQLite (run-patch.ts backfillLedger).
|
|
69
|
+
if (role === "server")
|
|
70
|
+
await backfillLedger(connection, now);
|
|
67
71
|
if (role === "runner" && options.warn) {
|
|
68
72
|
const gap = now() - (await connection.clock());
|
|
69
73
|
if (Math.abs(gap) > CLOCK_WARN_MS) {
|
package/dist/store/schema.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const SCHEMA_VERSION =
|
|
1
|
+
export declare const SCHEMA_VERSION = 16;
|
|
2
2
|
/** One answer per approval of a run: a second approve or deny command naming the same approval is refused
|
|
3
3
|
* (StoreConstraint), so the first answer a person gives wins from the moment it is written, before the runner takes it
|
|
4
4
|
* (runs-over-store.ts approve). In STORE_DDL, and added at a server open to a store an earlier build of this version made. */
|
|
@@ -31,9 +31,18 @@ export declare const TRIGGERS_TEMPLATE_ID = "ALTER TABLE triggers ADD COLUMN tem
|
|
|
31
31
|
/** A run's census (RunLaunchRow.census, run-census.ts): in STORE_DDL, and added at a server open to a store an earlier
|
|
32
32
|
* build of this version made, as RUNS_LABELS is (a run ended before reads as never handed a secret). */
|
|
33
33
|
export declare const RUN_LAUNCH_CENSUS: string;
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
|
|
34
|
+
/** The census "pending" of 0.1.0-beta.57, which marked a launch holding sealed bytes until an end counted them. This build
|
|
35
|
+
* keeps no such state: the server open that makes RUN_LAUNCH_CENSUS_ERASED settles each one left as this build reads it,
|
|
36
|
+
* as Postgres migration 0029 does. A launch still holding its sealed bytes gets null (its end counts them), and one an
|
|
37
|
+
* end erased gets "unscanned" (nothing counted them, so its files are withheld). */
|
|
38
|
+
export declare const RUN_LAUNCH_CENSUS_SETTLE = "UPDATE run_launch SET census = CASE WHEN sealed IS NULL THEN '\"unscanned\"' ELSE NULL END WHERE census = '\"pending\"'";
|
|
39
|
+
/** An update that erases a launch's sealed bytes and leaves its census null writes "unscanned", as Postgres migration 0029's
|
|
40
|
+
* trigger does. This build's end always names a census when it erases them, so only an end by a runner of
|
|
41
|
+
* 0.1.0-beta.56 or earlier, still live beside this server, does that: its run's files are withheld, never read cut of
|
|
42
|
+
* the server's values alone. */
|
|
43
|
+
export declare const RUN_LAUNCH_CENSUS_ERASED = "CREATE TRIGGER IF NOT EXISTS run_launch_census_erased AFTER UPDATE OF sealed ON run_launch\n WHEN OLD.sealed IS NOT NULL AND NEW.sealed IS NULL AND OLD.census IS NULL AND NEW.census IS NULL\n BEGIN UPDATE run_launch SET census = '\"unscanned\"' WHERE run_id = NEW.run_id; END";
|
|
44
|
+
/** Whether the store holds RUN_LAUNCH_CENSUS_ERASED: a store no server of this build opened yet holds none. */
|
|
45
|
+
export declare const RUN_LAUNCH_CENSUS_ERASED_MADE = "SELECT 1 AS found FROM sqlite_master WHERE type = 'trigger' AND name = 'run_launch_census_erased'";
|
|
37
46
|
/** A template package imported from GitHub (POST /v2/templates/import), by its id (`github:<owner>/<repo>[/<path>]`): its
|
|
38
47
|
* source as given (ref and all), the full commit SHA read, the GitHub account that publishes it, and its files as read
|
|
39
48
|
* (`files`, a JSON object of path to base64). A re-import of the id replaces the row. The server checks the files again
|
|
@@ -103,6 +112,37 @@ export declare const HAND_BACKS_KEPT_MS: number;
|
|
|
103
112
|
* added at a server open to a store an earlier build of this version made, as COMPUTER_INTERVALS is: a claim made before
|
|
104
113
|
* it has no row. */
|
|
105
114
|
export declare const RUN_ATTEMPTS = "CREATE TABLE IF NOT EXISTS run_attempts (\n run_id TEXT NOT NULL,\n epoch INTEGER NOT NULL,\n turn INTEGER NOT NULL CHECK (turn >= 1),\n attempt INTEGER NOT NULL CHECK (attempt >= 1),\n cause TEXT CHECK (cause IS NULL OR cause IN ('drain', 'crash', 'lease_lapse', 'retry')),\n cut TEXT CHECK (cut IS NULL OR cut IN ('drain', 'lease_lapse', 'retry')),\n runner TEXT NOT NULL,\n from_state TEXT NOT NULL,\n journal_from INTEGER NOT NULL,\n claimed_at INTEGER NOT NULL,\n PRIMARY KEY (run_id, epoch)\n ) STRICT";
|
|
115
|
+
/** The learning ledger (learn/ledger.ts): one row a run, written by each patch that leaves the run ended (applyRunPatch,
|
|
116
|
+
* in that patch's transaction) and by a healed cost: who answered it (`path`, null when its end named none), the
|
|
117
|
+
* revision that ran it, why it was not served alone, the job's own $ and its rounds' look-back, and whether its cost is
|
|
118
|
+
* known (`cost`). Gone with the run's purge or delete (its cost stays on the run's tombstone). Figures only, no run
|
|
119
|
+
* text. In STORE_DDL, and made at a server open on a store an earlier build of this version made, which drops the
|
|
120
|
+
* `epoch` an earlier build kept on it (LEARNING_LEDGER_EPOCH). `workflow_calls`: its learned workflow calls
|
|
121
|
+
* (LedgerRow.workflowCalls) as JSON, `[]` for none; added where missing at a server open (LEARNING_LEDGER_ADDED), before
|
|
122
|
+
* the open's backfill records rows (run-patch.ts backfillLedger). */
|
|
123
|
+
export declare const LEARNING_LEDGER = "CREATE TABLE IF NOT EXISTS learning_ledger (\n run_id TEXT PRIMARY KEY,\n agent_id TEXT NOT NULL,\n started_at INTEGER NOT NULL,\n path TEXT CHECK (path IS NULL OR path IN ('agent', 'handed_back', 'workflow', 'replay', 'audit')),\n workflow TEXT,\n digest TEXT,\n not_served TEXT CHECK (not_served IS NULL OR not_served IN ('cost_stop', 'cut')),\n job_usd REAL,\n look_back_usd REAL,\n cost TEXT NOT NULL CHECK (cost IN ('known', 'unknown', 'at_most')),\n workflow_calls TEXT NOT NULL DEFAULT '[]' CHECK (json_valid(workflow_calls))\n ) STRICT";
|
|
124
|
+
/** The columns a learning_ledger an earlier build of this version made lacks, each added at a server open where missing:
|
|
125
|
+
* its rows' calls none (`[]`) until their run's next end writes them. */
|
|
126
|
+
export declare const LEARNING_LEDGER_ADDED: Readonly<Record<string, string>>;
|
|
127
|
+
export declare const LEARNING_LEDGER_AGENT = "CREATE INDEX IF NOT EXISTS learning_ledger_agent ON learning_ledger (agent_id)";
|
|
128
|
+
/** The agent's rows by path, newest first: what the read before the money rule's window walks (run-patch.ts
|
|
129
|
+
* BY_HAND_BEFORE), a few rows whatever the agent's history. In STORE_DDL, and made at every server open. */
|
|
130
|
+
export declare const LEARNING_LEDGER_BY_HAND = "CREATE INDEX IF NOT EXISTS learning_ledger_by_hand ON learning_ledger (agent_id, path, started_at, run_id)";
|
|
131
|
+
export declare const LEARNING_LEDGER_REPAIR: readonly string[];
|
|
132
|
+
/** Version 15 → 16 on SQLite (the server's open, sqlite/store.ts), given the ledger's columns now, after the open's DDL
|
|
133
|
+
* write (the mark's column, STORE_META_LEDGER_BACKFILLED, among it): where the ledger still has its epoch (one 15 kept),
|
|
134
|
+
* the rows that release could leave wrong deleted (LEARNING_LEDGER_REPAIR), the mark set back to 0 so the open's
|
|
135
|
+
* backfill records them again, and the epoch dropped; then the version, in one durable write. A store from 14 or before
|
|
136
|
+
* has a ledger made at this open, with no epoch: the version alone. */
|
|
137
|
+
export declare function ledgerUpgrade(ledgerColumns: ReadonlySet<string>): readonly string[];
|
|
138
|
+
export declare const STORE_META_LEDGER_BACKFILLED = "ALTER TABLE store_meta ADD COLUMN ledger_backfilled INTEGER NOT NULL DEFAULT 0 CHECK (ledger_backfilled IN (0, 1))";
|
|
139
|
+
/** Each learning cost, by the revision it is for (learn/ledger.ts SpendRow): a compile turn (`round`, the round that asked
|
|
140
|
+
* it), a check's replay run or an audit's shadow run (round 0, `of_run` the run it audits), with its $ (null: unknown).
|
|
141
|
+
* Written with its run's ledger row, replaced whole each time; gone with its run's purge or delete, and with the purge
|
|
142
|
+
* or delete of the run it audits. */
|
|
143
|
+
export declare const LEARNING_SPEND = "CREATE TABLE IF NOT EXISTS learning_spend (\n run_id TEXT NOT NULL,\n kind TEXT NOT NULL CHECK (kind IN ('compile', 'check', 'audit')),\n round INTEGER NOT NULL CHECK (round >= 0),\n agent_id TEXT NOT NULL,\n of_run TEXT,\n workflow TEXT,\n digest TEXT,\n usd REAL,\n at INTEGER NOT NULL,\n PRIMARY KEY (run_id, kind, round)\n ) STRICT";
|
|
144
|
+
export declare const LEARNING_SPEND_AGENT = "CREATE INDEX IF NOT EXISTS learning_spend_agent ON learning_spend (agent_id)";
|
|
145
|
+
export declare const LEARNING_SPEND_OF_RUN = "CREATE INDEX IF NOT EXISTS learning_spend_of_run ON learning_spend (of_run) WHERE of_run IS NOT NULL";
|
|
106
146
|
/** Version 13 → 14 on SQLite (the server's open, sqlite/store.ts), given the runs' and the agents' columns now: when each
|
|
107
147
|
* run and each agent was purged (null: none was), and the version, in one durable write. */
|
|
108
148
|
export declare function purgeUpgrade(runColumns: ReadonlySet<string>, agentColumns: ReadonlySet<string>): readonly string[];
|
package/dist/store/schema.js
CHANGED
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
// added the same way, and so is each runner's word that it is there and whether it refused to claim (runners, RUNNERS),
|
|
22
22
|
// and each computer a run made, from its create to its proven delete (computer_intervals, COMPUTER_INTERVALS). Each runner's
|
|
23
23
|
// version and slots (runners.version, .slots: RUNNERS_ADDED), each hand-back (hand_backs, HAND_BACKS) and each claim of a
|
|
24
|
-
// run with the turn it works and its attempt at it (run_attempts, RUN_ATTEMPTS) are added the same way
|
|
24
|
+
// run with the turn it works and its attempt at it (run_attempts, RUN_ATTEMPTS) are added the same way, and so is the
|
|
25
|
+
// learning ledger (learning_ledger, learning_spend: LEARNING_LEDGER, LEARNING_SPEND).
|
|
25
26
|
// Conventions: every time is INTEGER epoch milliseconds; JSON is TEXT checked by json_valid; money is REAL US dollars;
|
|
26
27
|
// sealed columns hold ciphertext only (sealed with the server's key outside the store), so the store never sees a secret
|
|
27
28
|
// in the clear. Foreign keys are on (the connection's pragma).
|
|
@@ -38,9 +39,11 @@
|
|
|
38
39
|
// such runner takes the dials the server relays to it (runners.host and .port, dial-relay.ts). Version 14 keeps when a run or
|
|
39
40
|
// an agent was purged (runs.purged_at, agents.purged_at; DELETE /runs/{id} and /agents/{id}, agent-delete.ts): its row is
|
|
40
41
|
// then a tombstone, its content gone and its cost kept. Version 15 keeps the disk a run's launch named as its own
|
|
41
|
-
// (runs.disk; a run on one learns nothing, learn/learning-of.ts).
|
|
42
|
-
// (
|
|
43
|
-
|
|
42
|
+
// (runs.disk; a run on one learns nothing, learn/learning-of.ts). Version 16 keeps no epoch on a learning ledger row
|
|
43
|
+
// (learning_ledger; 15 kept one, which a runner of 15 writes at each end and this build's end does not). The server
|
|
44
|
+
// upgrades these in place at its open (listingUpgrade from 11, relayUpgrade from 12, purgeUpgrade from 13, diskUpgrade
|
|
45
|
+
// from 14, then ledgerUpgrade from 15); a runner waits for it.
|
|
46
|
+
export const SCHEMA_VERSION = 16;
|
|
44
47
|
/** One answer per approval of a run: a second approve or deny command naming the same approval is refused
|
|
45
48
|
* (StoreConstraint), so the first answer a person gives wins from the moment it is written, before the runner takes it
|
|
46
49
|
* (runs-over-store.ts approve). In STORE_DDL, and added at a server open to a store an earlier build of this version made. */
|
|
@@ -84,9 +87,20 @@ export const TRIGGERS_TEMPLATE_ID = "ALTER TABLE triggers ADD COLUMN template_id
|
|
|
84
87
|
/** A run's census (RunLaunchRow.census, run-census.ts): in STORE_DDL, and added at a server open to a store an earlier
|
|
85
88
|
* build of this version made, as RUNS_LABELS is (a run ended before reads as never handed a secret). */
|
|
86
89
|
export const RUN_LAUNCH_CENSUS = `ALTER TABLE run_launch ADD COLUMN ${json("census", true)}`;
|
|
87
|
-
/**
|
|
88
|
-
*
|
|
89
|
-
|
|
90
|
+
/** The census "pending" of 0.1.0-beta.57, which marked a launch holding sealed bytes until an end counted them. This build
|
|
91
|
+
* keeps no such state: the server open that makes RUN_LAUNCH_CENSUS_ERASED settles each one left as this build reads it,
|
|
92
|
+
* as Postgres migration 0029 does. A launch still holding its sealed bytes gets null (its end counts them), and one an
|
|
93
|
+
* end erased gets "unscanned" (nothing counted them, so its files are withheld). */
|
|
94
|
+
export const RUN_LAUNCH_CENSUS_SETTLE = `UPDATE run_launch SET census = CASE WHEN sealed IS NULL THEN '"unscanned"' ELSE NULL END WHERE census = '"pending"'`;
|
|
95
|
+
/** An update that erases a launch's sealed bytes and leaves its census null writes "unscanned", as Postgres migration 0029's
|
|
96
|
+
* trigger does. This build's end always names a census when it erases them, so only an end by a runner of
|
|
97
|
+
* 0.1.0-beta.56 or earlier, still live beside this server, does that: its run's files are withheld, never read cut of
|
|
98
|
+
* the server's values alone. */
|
|
99
|
+
export const RUN_LAUNCH_CENSUS_ERASED = `CREATE TRIGGER IF NOT EXISTS run_launch_census_erased AFTER UPDATE OF sealed ON run_launch
|
|
100
|
+
WHEN OLD.sealed IS NOT NULL AND NEW.sealed IS NULL AND OLD.census IS NULL AND NEW.census IS NULL
|
|
101
|
+
BEGIN UPDATE run_launch SET census = '"unscanned"' WHERE run_id = NEW.run_id; END`;
|
|
102
|
+
/** Whether the store holds RUN_LAUNCH_CENSUS_ERASED: a store no server of this build opened yet holds none. */
|
|
103
|
+
export const RUN_LAUNCH_CENSUS_ERASED_MADE = `SELECT 1 AS found FROM sqlite_master WHERE type = 'trigger' AND name = 'run_launch_census_erased'`;
|
|
90
104
|
/** A template package imported from GitHub (POST /v2/templates/import), by its id (`github:<owner>/<repo>[/<path>]`): its
|
|
91
105
|
* source as given (ref and all), the full commit SHA read, the GitHub account that publishes it, and its files as read
|
|
92
106
|
* (`files`, a JSON object of path to base64). A re-import of the id replaces the row. The server checks the files again
|
|
@@ -223,6 +237,85 @@ export const RUN_ATTEMPTS = `CREATE TABLE IF NOT EXISTS run_attempts (
|
|
|
223
237
|
claimed_at INTEGER NOT NULL,
|
|
224
238
|
PRIMARY KEY (run_id, epoch)
|
|
225
239
|
) STRICT`;
|
|
240
|
+
/** The learning ledger (learn/ledger.ts): one row a run, written by each patch that leaves the run ended (applyRunPatch,
|
|
241
|
+
* in that patch's transaction) and by a healed cost: who answered it (`path`, null when its end named none), the
|
|
242
|
+
* revision that ran it, why it was not served alone, the job's own $ and its rounds' look-back, and whether its cost is
|
|
243
|
+
* known (`cost`). Gone with the run's purge or delete (its cost stays on the run's tombstone). Figures only, no run
|
|
244
|
+
* text. In STORE_DDL, and made at a server open on a store an earlier build of this version made, which drops the
|
|
245
|
+
* `epoch` an earlier build kept on it (LEARNING_LEDGER_EPOCH). `workflow_calls`: its learned workflow calls
|
|
246
|
+
* (LedgerRow.workflowCalls) as JSON, `[]` for none; added where missing at a server open (LEARNING_LEDGER_ADDED), before
|
|
247
|
+
* the open's backfill records rows (run-patch.ts backfillLedger). */
|
|
248
|
+
export const LEARNING_LEDGER = `CREATE TABLE IF NOT EXISTS learning_ledger (
|
|
249
|
+
run_id TEXT PRIMARY KEY,
|
|
250
|
+
agent_id TEXT NOT NULL,
|
|
251
|
+
started_at INTEGER NOT NULL,
|
|
252
|
+
path TEXT CHECK (path IS NULL OR path IN ('agent', 'handed_back', 'workflow', 'replay', 'audit')),
|
|
253
|
+
workflow TEXT,
|
|
254
|
+
digest TEXT,
|
|
255
|
+
not_served TEXT CHECK (not_served IS NULL OR not_served IN ('cost_stop', 'cut')),
|
|
256
|
+
job_usd REAL,
|
|
257
|
+
look_back_usd REAL,
|
|
258
|
+
cost TEXT NOT NULL CHECK (cost IN ('known', 'unknown', 'at_most')),
|
|
259
|
+
workflow_calls TEXT NOT NULL DEFAULT '[]' CHECK (json_valid(workflow_calls))
|
|
260
|
+
) STRICT`;
|
|
261
|
+
/** The columns a learning_ledger an earlier build of this version made lacks, each added at a server open where missing:
|
|
262
|
+
* its rows' calls none (`[]`) until their run's next end writes them. */
|
|
263
|
+
export const LEARNING_LEDGER_ADDED = {
|
|
264
|
+
workflow_calls: "ALTER TABLE learning_ledger ADD COLUMN workflow_calls TEXT NOT NULL DEFAULT '[]' CHECK (json_valid(workflow_calls))",
|
|
265
|
+
};
|
|
266
|
+
export const LEARNING_LEDGER_AGENT = "CREATE INDEX IF NOT EXISTS learning_ledger_agent ON learning_ledger (agent_id)";
|
|
267
|
+
/** The agent's rows by path, newest first: what the read before the money rule's window walks (run-patch.ts
|
|
268
|
+
* BY_HAND_BEFORE), a few rows whatever the agent's history. In STORE_DDL, and made at every server open. */
|
|
269
|
+
export const LEARNING_LEDGER_BY_HAND = "CREATE INDEX IF NOT EXISTS learning_ledger_by_hand ON learning_ledger (agent_id, path, started_at, run_id)";
|
|
270
|
+
/** The `epoch` version 15 kept on each ledger row (the run's epoch at the end that wrote it), dropped at the server open
|
|
271
|
+
* that brings the store to 16 (ledgerUpgrade; postgres 0030_learning_ledger_epoch.sql). */
|
|
272
|
+
const LEARNING_LEDGER_EPOCH = "ALTER TABLE learning_ledger DROP COLUMN epoch";
|
|
273
|
+
/** The rows the ledger's first release (the build with LEARNING_LEDGER_EPOCH) could leave wrong once no reader corrects
|
|
274
|
+
* them: a row whose end named no path (a run by hand it left null, a shadow that failed first, with no audit spend), one
|
|
275
|
+
* behind its run's epoch (an end of an earlier runner after it), an unknown cost its run has now, and an audit's shadow
|
|
276
|
+
* on another path. Their rows and spend rows are deleted, before the epoch is, and the open's backfill records them
|
|
277
|
+
* again from their runs (run-patch.ts backfillLedger). The same statements as postgres 0030_learning_ledger_epoch.sql. */
|
|
278
|
+
const WRONG_LEDGER_ROWS = `SELECT l.run_id FROM learning_ledger l JOIN runs ON runs.id = l.run_id
|
|
279
|
+
WHERE l.path IS NULL OR l.epoch <> runs.epoch OR (l.cost = 'unknown' AND runs.cost_usd IS NOT NULL)
|
|
280
|
+
OR (substr(l.run_id, 1, 6) = 'audit.' AND l.path <> 'audit')`;
|
|
281
|
+
export const LEARNING_LEDGER_REPAIR = [
|
|
282
|
+
`DELETE FROM learning_spend WHERE run_id IN (${WRONG_LEDGER_ROWS})`,
|
|
283
|
+
`DELETE FROM learning_ledger WHERE run_id IN (${WRONG_LEDGER_ROWS})`,
|
|
284
|
+
];
|
|
285
|
+
/** Version 15 → 16 on SQLite (the server's open, sqlite/store.ts), given the ledger's columns now, after the open's DDL
|
|
286
|
+
* write (the mark's column, STORE_META_LEDGER_BACKFILLED, among it): where the ledger still has its epoch (one 15 kept),
|
|
287
|
+
* the rows that release could leave wrong deleted (LEARNING_LEDGER_REPAIR), the mark set back to 0 so the open's
|
|
288
|
+
* backfill records them again, and the epoch dropped; then the version, in one durable write. A store from 14 or before
|
|
289
|
+
* has a ledger made at this open, with no epoch: the version alone. */
|
|
290
|
+
export function ledgerUpgrade(ledgerColumns) {
|
|
291
|
+
return [
|
|
292
|
+
...(ledgerColumns.has("epoch") ? [...LEARNING_LEDGER_REPAIR, "UPDATE store_meta SET ledger_backfilled = 0 WHERE singleton = 1", LEARNING_LEDGER_EPOCH] : []),
|
|
293
|
+
"UPDATE store_meta SET schema_version = 16 WHERE singleton = 1",
|
|
294
|
+
];
|
|
295
|
+
}
|
|
296
|
+
/** Whether every final run not purged has its ledger row (1), which backfillLedger writes once it has recorded the last:
|
|
297
|
+
* no later open reads the runs again. 0 on a store with runs no server recorded yet. In STORE_DDL, and added at a server
|
|
298
|
+
* open to a store an earlier build of this version made. */
|
|
299
|
+
const LEDGER_BACKFILLED = "ledger_backfilled INTEGER NOT NULL DEFAULT 0 CHECK (ledger_backfilled IN (0, 1))";
|
|
300
|
+
export const STORE_META_LEDGER_BACKFILLED = `ALTER TABLE store_meta ADD COLUMN ${LEDGER_BACKFILLED}`;
|
|
301
|
+
/** Each learning cost, by the revision it is for (learn/ledger.ts SpendRow): a compile turn (`round`, the round that asked
|
|
302
|
+
* it), a check's replay run or an audit's shadow run (round 0, `of_run` the run it audits), with its $ (null: unknown).
|
|
303
|
+
* Written with its run's ledger row, replaced whole each time; gone with its run's purge or delete, and with the purge
|
|
304
|
+
* or delete of the run it audits. */
|
|
305
|
+
export const LEARNING_SPEND = `CREATE TABLE IF NOT EXISTS learning_spend (
|
|
306
|
+
run_id TEXT NOT NULL,
|
|
307
|
+
kind TEXT NOT NULL CHECK (kind IN ('compile', 'check', 'audit')),
|
|
308
|
+
round INTEGER NOT NULL CHECK (round >= 0),
|
|
309
|
+
agent_id TEXT NOT NULL,
|
|
310
|
+
of_run TEXT,
|
|
311
|
+
workflow TEXT,
|
|
312
|
+
digest TEXT,
|
|
313
|
+
usd REAL,
|
|
314
|
+
at INTEGER NOT NULL,
|
|
315
|
+
PRIMARY KEY (run_id, kind, round)
|
|
316
|
+
) STRICT`;
|
|
317
|
+
export const LEARNING_SPEND_AGENT = "CREATE INDEX IF NOT EXISTS learning_spend_agent ON learning_spend (agent_id)";
|
|
318
|
+
export const LEARNING_SPEND_OF_RUN = "CREATE INDEX IF NOT EXISTS learning_spend_of_run ON learning_spend (of_run) WHERE of_run IS NOT NULL";
|
|
226
319
|
/** Version 13 → 14 on SQLite (the server's open, sqlite/store.ts), given the runs' and the agents' columns now: when each
|
|
227
320
|
* run and each agent was purged (null: none was), and the version, in one durable write. */
|
|
228
321
|
export function purgeUpgrade(runColumns, agentColumns) {
|
|
@@ -333,7 +426,8 @@ export const STORE_DDL = [
|
|
|
333
426
|
`CREATE TABLE IF NOT EXISTS store_meta (
|
|
334
427
|
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
335
428
|
schema_version INTEGER NOT NULL,
|
|
336
|
-
flushes INTEGER NOT NULL DEFAULT 0
|
|
429
|
+
flushes INTEGER NOT NULL DEFAULT 0,
|
|
430
|
+
${LEDGER_BACKFILLED}
|
|
337
431
|
) STRICT`,
|
|
338
432
|
// Agents and their revisions. A revision made from a template keeps its package: {name, version (SemVer), source
|
|
339
433
|
// builtin|git, ref, sha, parameters}.
|
|
@@ -682,6 +776,12 @@ export const STORE_DDL = [
|
|
|
682
776
|
COMPUTER_INTERVALS,
|
|
683
777
|
COMPUTER_INTERVALS_RUN,
|
|
684
778
|
RUN_ATTEMPTS,
|
|
779
|
+
LEARNING_LEDGER,
|
|
780
|
+
LEARNING_LEDGER_AGENT,
|
|
781
|
+
LEARNING_LEDGER_BY_HAND,
|
|
782
|
+
LEARNING_SPEND,
|
|
783
|
+
LEARNING_SPEND_AGENT,
|
|
784
|
+
LEARNING_SPEND_OF_RUN,
|
|
685
785
|
// An agent's saved browser sign-ins (design 2.1, the browser sign-in rules): one live row per agent and browser provider, its
|
|
686
786
|
// pointer (the vendor's context or profile id) sealed with the store's one rule (store/seal.ts, AAD
|
|
687
787
|
// sign_ins|<agent>:<provider>|pointer), which the store never opens. The owner sees its name ("default") and saved_at,
|
|
@@ -756,9 +856,9 @@ export const STORE_DDL = [
|
|
|
756
856
|
// written in the same transaction as the queued run, never after. `body` is the launch JSON (run-launch.ts: the first
|
|
757
857
|
// input, title, place, effort, cap, and the trigger and origin that started it); `sealed` holds any secret sealed with
|
|
758
858
|
// the server's key outside the store (AAD run_launch|<run_id>|sealed), or null when the launch holds none. `census` is
|
|
759
|
-
// null
|
|
760
|
-
//
|
|
761
|
-
//
|
|
859
|
+
// null until an end erases what the launch holds; then where in the run's files they sat when that end erased them
|
|
860
|
+
// (run-census.ts), never the secrets, or "unscanned" when it erased them with no census made under them (store.ts
|
|
861
|
+
// CENSUS_UNSCANNED).
|
|
762
862
|
`CREATE TABLE IF NOT EXISTS run_launch (
|
|
763
863
|
run_id TEXT PRIMARY KEY REFERENCES runs (id),
|
|
764
864
|
${json("body")},
|
package/dist/store/seal.d.ts
CHANGED
|
@@ -50,10 +50,13 @@ export declare function openMcpCredential(key: Buffer, row: {
|
|
|
50
50
|
readonly sealed: Uint8Array | null;
|
|
51
51
|
}): OpenedMcpCredential;
|
|
52
52
|
/** A run's binding of a per-run Composio server: the Composio user its calls run as, and the connected account when the
|
|
53
|
-
* caller names one. Never kept on the server's row: sealed in the run's launch alone.
|
|
53
|
+
* caller names one. Never kept on the server's row: sealed in the run's launch alone. `by`: who handed it, the API token
|
|
54
|
+
* or the owner's session, sealed with it so the run can't change it; each claim reads it against the owner's Composio
|
|
55
|
+
* users (composio-owners.ts). A binding sealed before the mark has none. */
|
|
54
56
|
export type ComposioBinding = {
|
|
55
57
|
readonly user_id: string;
|
|
56
58
|
readonly connected_account_id?: string;
|
|
59
|
+
readonly by?: "token" | "owner";
|
|
57
60
|
};
|
|
58
61
|
/** What a run's caller handed one MCP server (`mcp_auth.<server>`): a per_run server's headers, or a per-run Composio
|
|
59
62
|
* server's binding (its key stays the server's own); each with the origin of the server's url when it was handed, so a
|
|
@@ -7,22 +7,15 @@ import type { SqliteExecutor } from "./connection.js";
|
|
|
7
7
|
* member as written (readUsageMetadata, readLearningStarts) reads the column and retries on postgresUnicodeRefusal. */
|
|
8
8
|
export declare const readableJson: (dialect: Dialect, column: string) => string;
|
|
9
9
|
/** Writes a run's launch row inside `tx` (the same transaction as the queued run it belongs to): the run path and the
|
|
10
|
-
* trigger path both call it, so the row lands with its run or not at all.
|
|
11
|
-
* CENSUS_PENDING with them. */
|
|
10
|
+
* trigger path both call it, so the row lands with its run or not at all. Its census is null until an end writes one. */
|
|
12
11
|
export declare function writeLaunch(tx: Pick<SqliteExecutor, "run">, runId: string, launch: RunLaunchInput, at: number): Promise<void>;
|
|
13
|
-
/** The census a launch whose census is `census` and sealed bytes `sealed` takes when `next` is written as its sealed
|
|
14
|
-
* bytes: as it is when `next` holds none, or an end counted what it held before (its census); CENSUS_PENDING when it
|
|
15
|
-
* never held any; CENSUS_UNSCANNED over a CENSUS_PENDING whose sealed bytes an end erased without writing a census (a
|
|
16
|
-
* runner from before the census), so the files that end left are still read as uncounted. On Postgres the table holds
|
|
17
|
-
* the same rule too (migration 0027's trigger), for a server of an earlier build still writing during a rolling deploy.
|
|
18
|
-
* A SQLite store has one server, so no earlier server writes beside this one: the rule lives here alone. */
|
|
19
|
-
export declare function censusOnSeal(census: string | null, sealed: Uint8Array | null, next: Uint8Array | null): string | null;
|
|
20
12
|
/** The disk a launch body names as the run's own (runs.disk, RunRow.disk): its `archil_disk` of kind "launch", by its id
|
|
21
13
|
* (run-launch.ts launchBody writes it so); null for none, or its agent's own disk (the default disk). The one read of the
|
|
22
14
|
* body's disk the store makes, at every create of a run, so no path that queues a run can leave it out. */
|
|
23
15
|
export declare function launchDiskOf(launch: RunLaunchInput | undefined): string | null;
|
|
24
16
|
/** A message's launch secrets written over the run's (runs.command, runs.reopen), inside `tx`: the bytes as given, or a
|
|
25
|
-
* function's answer to the bytes the launch holds now, read in the same transaction.
|
|
17
|
+
* function's answer to the bytes the launch holds now, read in the same transaction. The census stays as the last end
|
|
18
|
+
* wrote it: that end's count of where its turn's secrets sat, which the next end merges with its own (censusAfter). */
|
|
26
19
|
export declare function writeLaunchSealed(tx: Pick<SqliteExecutor, "run" | "get">, runId: string, launchSealed: LaunchSealed): Promise<void>;
|
|
27
20
|
/** The run's launch row, read by the runner at its claim (and the server for views). StoreLaunchMissing when the run has
|
|
28
21
|
* none, never a default. */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// trigger path (store.triggers.fire) both write a run's launch row inside their own transaction, through one
|
|
3
3
|
// helper, with no second copy of the SQL. The launch body itself is opaque here (run-launch.ts owns its shape); sealed
|
|
4
4
|
// bytes are the caller's, which the store never opens.
|
|
5
|
-
import {
|
|
5
|
+
import { StoreLaunchMissing } from "../store.js";
|
|
6
6
|
const RUN_LAUNCH_COLUMNS = "run_id, body, sealed, census, created_at";
|
|
7
7
|
const runLaunchOf = (r) => ({ runId: r.run_id, body: JSON.parse(r.body), sealed: r.sealed === null ? null : Uint8Array.from(r.sealed), census: r.census, createdAt: r.created_at });
|
|
8
8
|
/** JSON text `column` (a launch body, a command's body, a journal record) as every read of one id, number or flag out of
|
|
@@ -11,24 +11,9 @@ const runLaunchOf = (r) => ({ runId: r.run_id, body: JSON.parse(r.body), sealed:
|
|
|
11
11
|
* member as written (readUsageMetadata, readLearningStarts) reads the column and retries on postgresUnicodeRefusal. */
|
|
12
12
|
export const readableJson = (dialect, column) => (dialect.name === "postgres" ? postgresReadableJson(column) : column);
|
|
13
13
|
/** Writes a run's launch row inside `tx` (the same transaction as the queued run it belongs to): the run path and the
|
|
14
|
-
* trigger path both call it, so the row lands with its run or not at all.
|
|
15
|
-
* CENSUS_PENDING with them. */
|
|
14
|
+
* trigger path both call it, so the row lands with its run or not at all. Its census is null until an end writes one. */
|
|
16
15
|
export function writeLaunch(tx, runId, launch, at) {
|
|
17
|
-
|
|
18
|
-
return tx.run("INSERT INTO run_launch (run_id, body, sealed, census, created_at) VALUES (?, ?, ?, ?, ?)", runId, JSON.stringify(launch.body ?? null), sealed, sealed === null ? null : CENSUS_PENDING, at);
|
|
19
|
-
}
|
|
20
|
-
/** The census a launch whose census is `census` and sealed bytes `sealed` takes when `next` is written as its sealed
|
|
21
|
-
* bytes: as it is when `next` holds none, or an end counted what it held before (its census); CENSUS_PENDING when it
|
|
22
|
-
* never held any; CENSUS_UNSCANNED over a CENSUS_PENDING whose sealed bytes an end erased without writing a census (a
|
|
23
|
-
* runner from before the census), so the files that end left are still read as uncounted. On Postgres the table holds
|
|
24
|
-
* the same rule too (migration 0027's trigger), for a server of an earlier build still writing during a rolling deploy.
|
|
25
|
-
* A SQLite store has one server, so no earlier server writes beside this one: the rule lives here alone. */
|
|
26
|
-
export function censusOnSeal(census, sealed, next) {
|
|
27
|
-
if (next === null)
|
|
28
|
-
return census;
|
|
29
|
-
if (census === null)
|
|
30
|
-
return CENSUS_PENDING;
|
|
31
|
-
return census === CENSUS_PENDING && sealed === null ? CENSUS_UNSCANNED : census;
|
|
16
|
+
return tx.run("INSERT INTO run_launch (run_id, body, sealed, created_at) VALUES (?, ?, ?, ?)", runId, JSON.stringify(launch.body ?? null), launch.sealed ?? null, at);
|
|
32
17
|
}
|
|
33
18
|
/** The disk a launch body names as the run's own (runs.disk, RunRow.disk): its `archil_disk` of kind "launch", by its id
|
|
34
19
|
* (run-launch.ts launchBody writes it so); null for none, or its agent's own disk (the default disk). The one read of the
|
|
@@ -43,13 +28,17 @@ export function launchDiskOf(launch) {
|
|
|
43
28
|
const { disk_id: id, kind } = disk;
|
|
44
29
|
return kind === "launch" && typeof id === "string" && id !== "" ? id : null;
|
|
45
30
|
}
|
|
31
|
+
/** The sealed bytes run `runId`'s launch holds now, read inside `tx`. */
|
|
32
|
+
async function sealedOf(tx, runId) {
|
|
33
|
+
const row = await tx.get("SELECT sealed FROM run_launch WHERE run_id = ?", runId);
|
|
34
|
+
return row?.sealed == null ? null : Uint8Array.from(row.sealed);
|
|
35
|
+
}
|
|
46
36
|
/** A message's launch secrets written over the run's (runs.command, runs.reopen), inside `tx`: the bytes as given, or a
|
|
47
|
-
* function's answer to the bytes the launch holds now, read in the same transaction.
|
|
37
|
+
* function's answer to the bytes the launch holds now, read in the same transaction. The census stays as the last end
|
|
38
|
+
* wrote it: that end's count of where its turn's secrets sat, which the next end merges with its own (censusAfter). */
|
|
48
39
|
export async function writeLaunchSealed(tx, runId, launchSealed) {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
const next = typeof launchSealed === "function" ? launchSealed(sealed) : launchSealed;
|
|
52
|
-
await tx.run("UPDATE run_launch SET sealed = ?, census = ? WHERE run_id = ?", next, censusOnSeal(row?.census ?? null, sealed, next), runId);
|
|
40
|
+
const next = typeof launchSealed === "function" ? launchSealed(await sealedOf(tx, runId)) : launchSealed;
|
|
41
|
+
await tx.run("UPDATE run_launch SET sealed = ? WHERE run_id = ?", next, runId);
|
|
53
42
|
}
|
|
54
43
|
/** The run's launch row, read by the runner at its claim (and the server for views). StoreLaunchMissing when the run has
|
|
55
44
|
* none, never a default. */
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { type AlsoRow, type Claim, type RunPatch, type RunRow, type RunState } from "../store.js";
|
|
2
2
|
import { type Dialect } from "../dialect.js";
|
|
3
|
-
import type { SqliteExecutor } from "./connection.js";
|
|
3
|
+
import type { SqliteExecutor, StoreConnection } from "./connection.js";
|
|
4
4
|
import { type StoreNow } from "../fence.js";
|
|
5
5
|
/** A WHERE condition on `runs`: the run is no built-in learning run (one a kept learning names, queued with it), which no
|
|
6
6
|
* list of runs names. */
|
|
7
7
|
export declare const NOT_A_LEARNING_RUN = "id NOT IN (SELECT learning_run_id FROM learning_proposals WHERE learning_run_id IS NOT NULL)";
|
|
8
|
+
/** Learning.byHandBefore on both stores (agent, the window's oldest run's start and id, how many): the agent's newest
|
|
9
|
+
* rows on the `agent` path (the one by-hand rule, learn/ledger.ts record) before that run, of a known cost, on no named
|
|
10
|
+
* disk, neither imported, archived, purged, a learning run nor a workflow revision's run (a standalone workflow's row is
|
|
11
|
+
* on the `agent` path, and the window, store-reads/learning.ts ledgerReadOf, leaves those runs out too). It walks
|
|
12
|
+
* schema.ts LEARNING_LEDGER_BY_HAND newest first and stops at `limit`: no sort of the agent's ledger. */
|
|
13
|
+
export declare const BY_HAND_BEFORE = "SELECT l.run_id, l.started_at, l.job_usd FROM learning_ledger l JOIN runs ON runs.id = l.run_id\n WHERE l.agent_id = ? AND l.path = 'agent' AND (l.started_at, l.run_id) < (?, ?) AND l.cost = 'known' AND l.job_usd IS NOT NULL\n AND runs.id NOT IN (SELECT learning_run_id FROM learning_proposals WHERE learning_run_id IS NOT NULL) AND runs.disk IS NULL AND runs.imported_from IS NULL AND runs.archived_at IS NULL AND runs.purged_at IS NULL\n AND NOT EXISTS (SELECT 1 FROM revisions WHERE revisions.id = runs.revision_id AND revisions.kind = 'workflow')\n ORDER BY l.started_at DESC, l.run_id DESC LIMIT ?";
|
|
8
14
|
/** The lock a write of a run's sign_in_handed and a sign-in's forget both take (Dialect.lockKey): the forget's check of
|
|
9
15
|
* the running runs' hashes and a launch's write of them are serialized, as SQLite's one writer serializes them. */
|
|
10
16
|
export declare const SIGN_IN_HANDED_LOCK = "sign_in_handed";
|
|
@@ -45,7 +51,18 @@ export declare const runOf: (r: RunRecord) => RunRow;
|
|
|
45
51
|
* `now` (the store's clock, read in the transaction). A final state with no `endedAt` is stamped `now`, and releases the
|
|
46
52
|
* run in the same statement. `dialect`: the connection's (store/dialect.ts), SQLite's by default. `clock`: the deadlines'
|
|
47
53
|
* clock (fence.ts storeNow) the fence and left_running_at read; `now` bound by default. */
|
|
48
|
-
export declare function applyRunPatch(tx: Pick<SqliteExecutor, "run" | "get">, claim: Pick<Claim, "runId" | "epoch">, patch: RunPatch, also: readonly AlsoRow[], now: number, dialect?: Dialect, clock?: StoreNow): Promise<RunRow>;
|
|
54
|
+
export declare function applyRunPatch(tx: Pick<SqliteExecutor, "run" | "get" | "all">, claim: Pick<Claim, "runId" | "epoch">, patch: RunPatch, also: readonly AlsoRow[], now: number, dialect?: Dialect, clock?: StoreNow): Promise<RunRow>;
|
|
55
|
+
/** Writes run `run`'s ledger row and spend rows (learn/ledger.ts record) through `tx`, from its row and every round its
|
|
56
|
+
* learning kept, in place of any it had: the one writer of learning_ledger and learning_spend (a run's end, a heal of
|
|
57
|
+
* its cost, an import, and the server's open: backfillLedger). */
|
|
58
|
+
export declare function recordLedger(tx: Pick<SqliteExecutor, "run" | "all" | "get">, run: RunRow, now: number): Promise<void>;
|
|
59
|
+
/** Records every final run that has no ledger row (UNRECORDED), as its end would have (recordLedger), at a server's open
|
|
60
|
+
* on either store: by id, BACKFILL_PAGE runs a transaction, each read again in it, so a stop partway keeps each page it
|
|
61
|
+
* committed and the next open records the rest. Then it marks the ledger whole (store_meta.ledger_backfilled), and no
|
|
62
|
+
* later open reads the runs again: each end, heal and import writes its own row, and no reader records one. Each run's
|
|
63
|
+
* row is locked before it is read again (a no-op on SQLite's one writer): on Postgres another server's heal or end of it
|
|
64
|
+
* in flight commits first and the read sees its row, so the backfill never writes over it with what it read before. */
|
|
65
|
+
export declare function backfillLedger(connection: Pick<StoreConnection, "all" | "dialect" | "get" | "transaction">, now: () => number): Promise<void>;
|
|
49
66
|
/** The one reopen a run that ended may take (runs.reopen, and a run's end with a person's message waiting): back to running
|
|
50
67
|
* with no runner (released: a runner claims it at once), its end's own fields cleared, its epoch, journal, cost and
|
|
51
68
|
* metrics kept. `where` holds only for an agentic run that ended completed or that a person stopped (state 'stopped',
|
|
@@ -6,10 +6,21 @@
|
|
|
6
6
|
import { CENSUS_UNSCANNED, endedReason, FINAL_STATES, Fenced } from "../store.js";
|
|
7
7
|
import { settledBody, SQLITE } from "../dialect.js";
|
|
8
8
|
import { claimFence, storeNow } from "../fence.js";
|
|
9
|
-
import { readableJson } from "./run-launch.js";
|
|
9
|
+
import { readableJson, readLaunch } from "./run-launch.js";
|
|
10
|
+
import { auditOfLaunch, learnsOfLaunch, record } from "../../learn/ledger.js";
|
|
10
11
|
/** A WHERE condition on `runs`: the run is no built-in learning run (one a kept learning names, queued with it), which no
|
|
11
12
|
* list of runs names. */
|
|
12
13
|
export const NOT_A_LEARNING_RUN = "id NOT IN (SELECT learning_run_id FROM learning_proposals WHERE learning_run_id IS NOT NULL)";
|
|
14
|
+
/** Learning.byHandBefore on both stores (agent, the window's oldest run's start and id, how many): the agent's newest
|
|
15
|
+
* rows on the `agent` path (the one by-hand rule, learn/ledger.ts record) before that run, of a known cost, on no named
|
|
16
|
+
* disk, neither imported, archived, purged, a learning run nor a workflow revision's run (a standalone workflow's row is
|
|
17
|
+
* on the `agent` path, and the window, store-reads/learning.ts ledgerReadOf, leaves those runs out too). It walks
|
|
18
|
+
* schema.ts LEARNING_LEDGER_BY_HAND newest first and stops at `limit`: no sort of the agent's ledger. */
|
|
19
|
+
export const BY_HAND_BEFORE = `SELECT l.run_id, l.started_at, l.job_usd FROM learning_ledger l JOIN runs ON runs.id = l.run_id
|
|
20
|
+
WHERE l.agent_id = ? AND l.path = 'agent' AND (l.started_at, l.run_id) < (?, ?) AND l.cost = 'known' AND l.job_usd IS NOT NULL
|
|
21
|
+
AND runs.${NOT_A_LEARNING_RUN} AND runs.disk IS NULL AND runs.imported_from IS NULL AND runs.archived_at IS NULL AND runs.purged_at IS NULL
|
|
22
|
+
AND NOT EXISTS (SELECT 1 FROM revisions WHERE revisions.id = runs.revision_id AND revisions.kind = 'workflow')
|
|
23
|
+
ORDER BY l.started_at DESC, l.run_id DESC LIMIT ?`;
|
|
13
24
|
/** The lock a write of a run's sign_in_handed and a sign-in's forget both take (Dialect.lockKey): the forget's check of
|
|
14
25
|
* the running runs' hashes and a launch's write of them are serialized, as SQLite's one writer serializes them. */
|
|
15
26
|
export const SIGN_IN_HANDED_LOCK = "sign_in_handed";
|
|
@@ -101,7 +112,61 @@ export async function applyRunPatch(tx, claim, patch, also, now, dialect = SQLIT
|
|
|
101
112
|
break;
|
|
102
113
|
}
|
|
103
114
|
}
|
|
104
|
-
|
|
115
|
+
const run = runOf(row);
|
|
116
|
+
// A run this patch leaves ended has its ledger row and spend rows (learn/ledger.ts record) in this same commit, over
|
|
117
|
+
// every round its learning kept, this patch's included: an end, a later end after a follow-up and a patch of an ended
|
|
118
|
+
// run's metrics each write them whole again.
|
|
119
|
+
if (FINAL_STATES.includes(run.state))
|
|
120
|
+
await recordLedger(tx, run, now);
|
|
121
|
+
return run;
|
|
122
|
+
}
|
|
123
|
+
/** Writes run `run`'s ledger row and spend rows (learn/ledger.ts record) through `tx`, from its row and every round its
|
|
124
|
+
* learning kept, in place of any it had: the one writer of learning_ledger and learning_spend (a run's end, a heal of
|
|
125
|
+
* its cost, an import, and the server's open: backfillLedger). */
|
|
126
|
+
export async function recordLedger(tx, run, now) {
|
|
127
|
+
const rounds = (await tx.all("SELECT round, proposal FROM learning_proposals WHERE run_id = ? ORDER BY round", run.id))
|
|
128
|
+
.map((one) => ({ round: Number(one.round), proposal: JSON.parse(one.proposal) }));
|
|
129
|
+
// An audit's shadow is booked on the run its launch audits, whatever its end named (one that failed first names none);
|
|
130
|
+
// a run whose end named no path is the agent's when its launch does not learn (learnsOfLaunch).
|
|
131
|
+
const body = (await readLaunch(tx, run.id).catch(() => undefined))?.body;
|
|
132
|
+
const auditOf = auditOfLaunch(run.id, body);
|
|
133
|
+
const { row, spend } = record({ id: run.id, agentId: run.agentId, startedAt: run.startedAt, costUsd: run.costUsd, costAtMostUsd: run.costAtMostUsd, metrics: run.metrics, rounds, learns: learnsOfLaunch(body), ...(auditOf === undefined ? {} : { auditOf }) });
|
|
134
|
+
await tx.run(`INSERT INTO learning_ledger (run_id, agent_id, started_at, path, workflow, digest, not_served, job_usd, look_back_usd, cost, workflow_calls) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
135
|
+
ON CONFLICT (run_id) DO UPDATE SET agent_id = excluded.agent_id, started_at = excluded.started_at, path = excluded.path, workflow = excluded.workflow, digest = excluded.digest,
|
|
136
|
+
not_served = excluded.not_served, job_usd = excluded.job_usd, look_back_usd = excluded.look_back_usd, cost = excluded.cost, workflow_calls = excluded.workflow_calls`, row.runId, row.agentId, row.startedAt, row.path, row.workflow, row.digest, row.notServed, row.jobUsd, row.lookBackUsd, row.cost, JSON.stringify(row.workflowCalls));
|
|
137
|
+
await tx.run("DELETE FROM learning_spend WHERE run_id = ?", run.id);
|
|
138
|
+
for (const one of spend) {
|
|
139
|
+
await tx.run("INSERT INTO learning_spend (run_id, kind, round, agent_id, of_run, workflow, digest, usd, at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", one.runId, one.kind, one.round, one.agentId, one.ofRun, one.workflow, one.digest, one.usd, now);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/** A final run with no ledger row, not purged (its purge took its row): one an earlier build ended. */
|
|
143
|
+
const UNRECORDED = `state IN (${FINAL_STATES.map((state) => `'${state}'`).join(", ")}) AND purged_at IS NULL AND NOT EXISTS (SELECT 1 FROM learning_ledger WHERE learning_ledger.run_id = runs.id)`;
|
|
144
|
+
/** How many runs backfillLedger records in one transaction. */
|
|
145
|
+
const BACKFILL_PAGE = 64;
|
|
146
|
+
/** Records every final run that has no ledger row (UNRECORDED), as its end would have (recordLedger), at a server's open
|
|
147
|
+
* on either store: by id, BACKFILL_PAGE runs a transaction, each read again in it, so a stop partway keeps each page it
|
|
148
|
+
* committed and the next open records the rest. Then it marks the ledger whole (store_meta.ledger_backfilled), and no
|
|
149
|
+
* later open reads the runs again: each end, heal and import writes its own row, and no reader records one. Each run's
|
|
150
|
+
* row is locked before it is read again (a no-op on SQLite's one writer): on Postgres another server's heal or end of it
|
|
151
|
+
* in flight commits first and the read sees its row, so the backfill never writes over it with what it read before. */
|
|
152
|
+
export async function backfillLedger(connection, now) {
|
|
153
|
+
if (Number((await connection.get("SELECT ledger_backfilled AS whole FROM store_meta WHERE singleton = 1"))?.whole) === 1)
|
|
154
|
+
return;
|
|
155
|
+
for (let after = "";;) {
|
|
156
|
+
const page = await connection.all(`SELECT id FROM runs WHERE id > ? AND ${UNRECORDED} ORDER BY id LIMIT ${BACKFILL_PAGE}`, after);
|
|
157
|
+
if (page.length === 0)
|
|
158
|
+
break;
|
|
159
|
+
await connection.transaction(async (tx) => {
|
|
160
|
+
for (const { id } of page) {
|
|
161
|
+
await connection.dialect.lockRow(tx, "runs", "id", id);
|
|
162
|
+
const row = await tx.get(`SELECT ${RUN_COLUMNS} FROM runs WHERE id = ? AND ${UNRECORDED}`, id);
|
|
163
|
+
if (row)
|
|
164
|
+
await recordLedger(tx, runOf(row), now());
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
after = page.at(-1).id;
|
|
168
|
+
}
|
|
169
|
+
await connection.transaction((tx) => tx.run("UPDATE store_meta SET ledger_backfilled = 1 WHERE singleton = 1").then(() => undefined));
|
|
105
170
|
}
|
|
106
171
|
/** The one reopen a run that ended may take (runs.reopen, and a run's end with a person's message waiting): back to running
|
|
107
172
|
* with no runner (released: a runner claims it at once), its end's own fields cleared, its epoch, journal, cost and
|
|
@@ -22,6 +22,9 @@ export type SqliteStoreOptions = (
|
|
|
22
22
|
/** How long a write waits for another process's lock before StoreBusy. */
|
|
23
23
|
busyTimeoutMs?: number;
|
|
24
24
|
};
|
|
25
|
+
/** The store's earlier versions the server upgrades in place at its open (openSqliteStore), which a runner waits for
|
|
26
|
+
* (StoreAwaitsServer); store-schema reports from the same set. */
|
|
27
|
+
export declare const SQLITE_UPGRADES: ReadonlySet<number>;
|
|
25
28
|
/** The columns a runner of this build needs that an earlier build of this same version may not have: the server adds each
|
|
26
29
|
* at its start (openSqliteStore), and a runner on a file without one waits for that server (StoreAwaitsServer, in `why`'s
|
|
27
30
|
* words; exit 3). store-schema reads the same list, so its report says "waits" where the runner would. */
|