pi-better-server 0.4.0 → 0.6.0
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/package.json +8 -1
- package/scripts/copy-pi-test-providers.mjs +10 -0
- package/scripts/event-publication/README.md +26 -0
- package/scripts/event-publication/commit.mjs +21 -0
- package/scripts/event-publication/measure.mjs +87 -0
- package/scripts/event-publication/writer.mjs +6 -0
- package/scripts/measure-full-runtime/frontend.ts +24 -0
- package/scripts/measure-full-runtime/hosted-extension.ts +28 -0
- package/scripts/measure-full-runtime/probe.mjs +29 -0
- package/scripts/measure-full-runtime/recovery-trace-loader.mjs +51 -0
- package/scripts/measure-full-runtime/recovery-trace.mjs +16 -0
- package/scripts/measure-full-runtime.mjs +146 -0
- package/scripts/measure-shared-reads/probe.mjs +26 -2
- package/scripts/measure-shared-reads.mjs +44 -9
- package/scripts/private-runtime/package-lock.json +66 -4
- package/scripts/private-runtime/package.json +10 -2
- package/scripts/source-provenance.mjs +31 -0
- package/scripts/test-on-pi.sh +3 -9
- package/src/handshake.ts +1 -1
- package/src/hosted-session.ts +32 -4
- package/src/maintenance.ts +35 -7
- package/src/registry.ts +28 -4
- package/src/runtime/attempt-invalidation.ts +54 -0
- package/src/runtime/background-history.ts +151 -45
- package/src/runtime/background-policy.ts +27 -0
- package/src/runtime/background-tools.ts +389 -0
- package/src/runtime/background.ts +410 -48
- package/src/runtime/cancellation.ts +28 -7
- package/src/runtime/catalog-sources.ts +199 -0
- package/src/runtime/catalog.ts +53 -21
- package/src/runtime/client.ts +22 -2
- package/src/runtime/domain/assignment-inbox.mjs +119 -0
- package/src/runtime/domain/assignment-observation.d.mts +1 -1
- package/src/runtime/domain/assignment-observation.mjs +71 -33
- package/src/runtime/domain/background/process-identity.mjs +20 -2
- package/src/runtime/domain/background/process.mjs +3 -3
- package/src/runtime/domain/background/registry.mjs +89 -4
- package/src/runtime/domain/background/types.mjs +1 -0
- package/src/runtime/domain/background-service/adapter-contract.domain.mjs +83 -0
- package/src/runtime/domain/background-service/adapter-contract.ts +70 -0
- package/src/runtime/domain/background-service/batch.domain.mjs +91 -0
- package/src/runtime/domain/background-service/batch.ts +111 -0
- package/src/runtime/domain/background-service/conditions.domain.mjs +94 -0
- package/src/runtime/domain/background-service/conditions.ts +99 -0
- package/src/runtime/domain/background-service/delivery-observer.domain.mjs +37 -0
- package/src/runtime/domain/background-service/delivery-observer.ts +42 -0
- package/src/runtime/domain/background-service/failures.domain.mjs +209 -0
- package/src/runtime/domain/background-service/failures.ts +212 -0
- package/src/runtime/domain/background-service/goal-provider.domain.mjs +193 -0
- package/src/runtime/domain/background-service/goal-provider.ts +209 -0
- package/src/runtime/domain/background-service/index.domain.mjs +54 -0
- package/src/runtime/domain/background-service/index.ts +55 -0
- package/src/runtime/domain/background-service/logs.domain.mjs +129 -0
- package/src/runtime/domain/background-service/logs.ts +134 -0
- package/src/runtime/domain/background-service/maintenance.domain.mjs +95 -0
- package/src/runtime/domain/background-service/maintenance.ts +98 -0
- package/src/runtime/domain/background-service/managed-authority.domain.mjs +32 -0
- package/src/runtime/domain/background-service/managed-authority.ts +30 -0
- package/src/runtime/domain/background-service/managed-client.domain.mjs +79 -0
- package/src/runtime/domain/background-service/managed-client.ts +73 -0
- package/src/runtime/domain/background-service/managed-frontend.domain.mjs +225 -0
- package/src/runtime/domain/background-service/managed-frontend.ts +176 -0
- package/src/runtime/domain/background-service/navigator-provider.domain.mjs +492 -0
- package/src/runtime/domain/background-service/navigator-provider.ts +485 -0
- package/src/runtime/domain/background-service/observed-wait-client.domain.mjs +6 -0
- package/src/runtime/domain/background-service/observed-wait-client.ts +10 -0
- package/src/runtime/domain/background-service/observed-waits.domain.mjs +4080 -0
- package/src/runtime/domain/background-service/observed-waits.ts +4513 -0
- package/src/runtime/domain/background-service/output.domain.mjs +867 -0
- package/src/runtime/domain/background-service/output.ts +952 -0
- package/src/runtime/domain/background-service/process-identity.domain.mjs +129 -0
- package/src/runtime/domain/background-service/process-identity.ts +134 -0
- package/src/runtime/domain/background-service/process.domain.mjs +512 -0
- package/src/runtime/domain/background-service/process.ts +532 -0
- package/src/runtime/domain/background-service/prompt.domain.mjs +58 -0
- package/src/runtime/domain/background-service/prompt.ts +72 -0
- package/src/runtime/domain/background-service/registry.domain.mjs +460 -0
- package/src/runtime/domain/background-service/registry.ts +450 -0
- package/src/runtime/domain/background-service/remote-task-preset.domain.mjs +67 -0
- package/src/runtime/domain/background-service/remote-task-preset.ts +127 -0
- package/src/runtime/domain/background-service/runtime.domain.mjs +1511 -0
- package/src/runtime/domain/background-service/runtime.ts +1636 -0
- package/src/runtime/domain/background-service/sandbox.domain.mjs +735 -0
- package/src/runtime/domain/background-service/sandbox.ts +913 -0
- package/src/runtime/domain/background-service/shared-callback-batcher.domain.mjs +777 -0
- package/src/runtime/domain/background-service/shared-callback-batcher.ts +956 -0
- package/src/runtime/domain/background-service/shared-execution-policy.domain.mjs +50 -0
- package/src/runtime/domain/background-service/shared-execution-policy.ts +61 -0
- package/src/runtime/domain/background-service/shared-failure-observations.domain.mjs +1078 -0
- package/src/runtime/domain/background-service/shared-failure-observations.ts +1166 -0
- package/src/runtime/domain/background-service/shared-harness-settings.domain.mjs +126 -0
- package/src/runtime/domain/background-service/shared-harness-settings.ts +116 -0
- package/src/runtime/domain/background-service/shared-log-utils.domain.mjs +1223 -0
- package/src/runtime/domain/background-service/shared-log-utils.ts +1492 -0
- package/src/runtime/domain/background-service/shared-navigator-panels.domain.mjs +289 -0
- package/src/runtime/domain/background-service/shared-navigator-panels.ts +272 -0
- package/src/runtime/domain/background-service/shared-navigator.domain.mjs +1930 -0
- package/src/runtime/domain/background-service/shared-navigator.ts +1962 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/assignment-inbox.mjs +144 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/assignment-observation.mjs +189 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/index.domain.mjs +51 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/index.ts +122 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-changes.domain.mjs +75 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-changes.ts +73 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.domain.mjs +163 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.ts +174 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-parent-callbacks.domain.mjs +66 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-parent-callbacks.ts +68 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.domain.mjs +87 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.ts +90 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.domain.mjs +97 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.ts +139 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/errors.domain.mjs +12 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/errors.ts +79 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.domain.mjs +342 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.ts +513 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/outbox.domain.mjs +283 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/outbox.ts +458 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/recovery.domain.mjs +52 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/recovery.ts +55 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.domain.mjs +114 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.ts +140 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.domain.mjs +280 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.ts +442 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.domain.mjs +420 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.ts +441 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/sqlite.domain.mjs +194 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/sqlite.ts +239 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.domain.mjs +275 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.ts +585 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.domain.mjs +120 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.ts +142 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/task-cancellation.domain.mjs +188 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/task-cancellation.ts +224 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.domain.mjs +25 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.ts +707 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/upgrade.domain.mjs +22 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/upgrade.ts +22 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/validate.domain.mjs +234 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/validate.ts +241 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/waits.domain.mjs +851 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/waits.ts +1424 -0
- package/src/runtime/domain/background-service/shared-permission-blocker.domain.mjs +40 -0
- package/src/runtime/domain/background-service/shared-permission-blocker.ts +48 -0
- package/src/runtime/domain/background-service/shared-render-scheduler.domain.mjs +41 -0
- package/src/runtime/domain/background-service/shared-render-scheduler.ts +47 -0
- package/src/runtime/domain/background-service/shared-sandbox-core.domain.mjs +1531 -0
- package/src/runtime/domain/background-service/shared-sandbox-core.ts +1757 -0
- package/src/runtime/domain/background-service/shared-sandbox-diagnostics.domain.mjs +591 -0
- package/src/runtime/domain/background-service/shared-sandbox-diagnostics.ts +491 -0
- package/src/runtime/domain/background-service/shared-ssh-core/index.domain.mjs +698 -0
- package/src/runtime/domain/background-service/shared-ssh-core/index.ts +979 -0
- package/src/runtime/domain/background-service/shared-stall-detector.domain.mjs +37 -0
- package/src/runtime/domain/background-service/shared-stall-detector.ts +69 -0
- package/src/runtime/domain/background-service/shared-work-client.mjs +303 -0
- package/src/runtime/domain/background-service/stall-attention.domain.mjs +29 -0
- package/src/runtime/domain/background-service/stall-attention.ts +31 -0
- package/src/runtime/domain/background-service/stall.domain.mjs +57 -0
- package/src/runtime/domain/background-service/stall.ts +57 -0
- package/src/runtime/domain/background-service/supervisor/README.md +111 -0
- package/src/runtime/domain/background-service/supervisor/emit-runner.mjs +90 -0
- package/src/runtime/domain/background-service/supervisor/generated/conditions.mjs +96 -0
- package/src/runtime/domain/background-service/supervisor/generated/identity.mjs +95 -0
- package/src/runtime/domain/background-service/supervisor/generated/process-identity.mjs +131 -0
- package/src/runtime/domain/background-service/supervisor/generated/process.mjs +514 -0
- package/src/runtime/domain/background-service/supervisor/generated/runner.mjs +872 -0
- package/src/runtime/domain/background-service/supervisor/generated/store.mjs +609 -0
- package/src/runtime/domain/background-service/supervisor/generated/types.mjs +50 -0
- package/src/runtime/domain/background-service/supervisor/identity.domain.mjs +93 -0
- package/src/runtime/domain/background-service/supervisor/identity.ts +99 -0
- package/src/runtime/domain/background-service/supervisor/index.domain.mjs +22 -0
- package/src/runtime/domain/background-service/supervisor/index.ts +37 -0
- package/src/runtime/domain/background-service/supervisor/invocation.domain.mjs +30 -0
- package/src/runtime/domain/background-service/supervisor/invocation.ts +44 -0
- package/src/runtime/domain/background-service/supervisor/runner.domain.mjs +870 -0
- package/src/runtime/domain/background-service/supervisor/runner.ts +982 -0
- package/src/runtime/domain/background-service/supervisor/store.domain.mjs +605 -0
- package/src/runtime/domain/background-service/supervisor/store.ts +651 -0
- package/src/runtime/domain/background-service/supervisor/supervisor.domain.mjs +721 -0
- package/src/runtime/domain/background-service/supervisor/supervisor.ts +804 -0
- package/src/runtime/domain/background-service/supervisor/types.domain.mjs +48 -0
- package/src/runtime/domain/background-service/supervisor/types.ts +394 -0
- package/src/runtime/domain/background-service/task-diagnostics.domain.mjs +60 -0
- package/src/runtime/domain/background-service/task-diagnostics.ts +71 -0
- package/src/runtime/domain/background-service/tools.domain.mjs +1050 -0
- package/src/runtime/domain/background-service/tools.ts +1142 -0
- package/src/runtime/domain/background-service/types.domain.mjs +5 -0
- package/src/runtime/domain/background-service/types.ts +236 -0
- package/src/runtime/domain/background-service/work-observation.domain.mjs +176 -0
- package/src/runtime/domain/background-service/work-observation.ts +144 -0
- package/src/runtime/domain/catalog/catalog-store.d.mts +9 -1
- package/src/runtime/domain/catalog/catalog-store.mjs +20 -22
- package/src/runtime/domain/coordinator/src/assignment-changes.mjs +75 -0
- package/src/runtime/domain/coordinator/src/assignment-outcomes.mjs +2 -0
- package/src/runtime/domain/coordinator/src/background-parent-callbacks.mjs +65 -0
- package/src/runtime/domain/coordinator/src/background-requests.mjs +86 -0
- package/src/runtime/domain/coordinator/src/discovery.mjs +4 -2
- package/src/runtime/domain/coordinator/src/operations.mjs +44 -4
- package/src/runtime/domain/coordinator/src/result-supervision.mjs +12 -0
- package/src/runtime/domain/coordinator/src/rows.mjs +2 -0
- package/src/runtime/domain/coordinator/src/schema.mjs +73 -21
- package/src/runtime/domain/coordinator/src/store.mjs +32 -3
- package/src/runtime/domain/coordinator/src/subagent-launch.mjs +119 -0
- package/src/runtime/domain/coordinator/src/types.mjs +1 -1
- package/src/runtime/domain/coordinator/src/upgrade.mjs +22 -0
- package/src/runtime/domain/health-observation.d.mts +3 -1
- package/src/runtime/domain/health-observation.mjs +189 -190
- package/src/runtime/domain/log-cursor.d.mts +2 -0
- package/src/runtime/domain/log-cursor.mjs +85 -16
- package/src/runtime/domain/parse.d.mts +4 -1
- package/src/runtime/domain/parse.mjs +50 -5
- package/src/runtime/domain/sandbox-policy/README.md +633 -0
- package/src/runtime/domain/sandbox-policy/background-admission.domain.mjs +83 -0
- package/src/runtime/domain/sandbox-policy/background-admission.ts +75 -0
- package/src/runtime/domain/sandbox-policy/commands.domain.mjs +245 -0
- package/src/runtime/domain/sandbox-policy/commands.ts +336 -0
- package/src/runtime/domain/sandbox-policy/deny-rules.domain.mjs +440 -0
- package/src/runtime/domain/sandbox-policy/deny-rules.ts +620 -0
- package/src/runtime/domain/sandbox-policy/diagnostics-command.domain.mjs +30 -0
- package/src/runtime/domain/sandbox-policy/diagnostics-command.ts +27 -0
- package/src/runtime/domain/sandbox-policy/events.domain.mjs +49 -0
- package/src/runtime/domain/sandbox-policy/events.ts +85 -0
- package/src/runtime/domain/sandbox-policy/files.domain.mjs +153 -0
- package/src/runtime/domain/sandbox-policy/files.ts +224 -0
- package/src/runtime/domain/sandbox-policy/index.domain.mjs +289 -0
- package/src/runtime/domain/sandbox-policy/index.ts +386 -0
- package/src/runtime/domain/sandbox-policy/package.json +66 -0
- package/src/runtime/domain/sandbox-policy/permission-settings.domain.mjs +36 -0
- package/src/runtime/domain/sandbox-policy/permission-settings.ts +46 -0
- package/src/runtime/domain/sandbox-policy/permissions-page.domain.mjs +309 -0
- package/src/runtime/domain/sandbox-policy/permissions-page.ts +295 -0
- package/src/runtime/domain/sandbox-policy/permissions.domain.mjs +98 -0
- package/src/runtime/domain/sandbox-policy/permissions.ts +125 -0
- package/src/runtime/domain/sandbox-policy/policy.domain.mjs +80 -0
- package/src/runtime/domain/sandbox-policy/policy.ts +102 -0
- package/src/runtime/domain/sandbox-policy/preferences.domain.mjs +55 -0
- package/src/runtime/domain/sandbox-policy/preferences.ts +82 -0
- package/src/runtime/domain/sandbox-policy/rules-page.domain.mjs +138 -0
- package/src/runtime/domain/sandbox-policy/rules-page.ts +176 -0
- package/src/runtime/domain/sandbox-policy/session-permissions.domain.mjs +22 -0
- package/src/runtime/domain/sandbox-policy/session-permissions.ts +24 -0
- package/src/runtime/domain/sandbox-policy/shared-harness-settings.domain.mjs +126 -0
- package/src/runtime/domain/sandbox-policy/shared-harness-settings.ts +116 -0
- package/src/runtime/domain/sandbox-policy/shared-permission-blocker.domain.mjs +40 -0
- package/src/runtime/domain/sandbox-policy/shared-permission-blocker.ts +48 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-core.domain.mjs +1531 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-core.ts +1757 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-diagnostics.domain.mjs +591 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-diagnostics.ts +491 -0
- package/src/runtime/domain/sandbox-policy/shared-task-application.domain.mjs +185 -0
- package/src/runtime/domain/sandbox-policy/shared-task-application.ts +185 -0
- package/src/runtime/domain/sandbox-policy/shared-task-apply-patch.domain.mjs +416 -0
- package/src/runtime/domain/sandbox-policy/shared-task-apply-patch.ts +409 -0
- package/src/runtime/domain/sandbox-policy/shared-task-exec.domain.mjs +325 -0
- package/src/runtime/domain/sandbox-policy/shared-task-exec.ts +335 -0
- package/src/runtime/domain/sandbox-policy/shared-task-files.domain.mjs +346 -0
- package/src/runtime/domain/sandbox-policy/shared-task-files.ts +342 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-identity.domain.mjs +140 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-identity.ts +126 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-list.domain.mjs +220 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-list.ts +209 -0
- package/src/runtime/domain/sandbox-policy/shared-task-sandbox.domain.mjs +227 -0
- package/src/runtime/domain/sandbox-policy/shared-task-sandbox.ts +224 -0
- package/src/runtime/domain/sandbox-policy/shared-task-tools.domain.mjs +92 -0
- package/src/runtime/domain/sandbox-policy/shared-task-tools.ts +123 -0
- package/src/runtime/domain/sandbox-policy/shell.domain.mjs +93 -0
- package/src/runtime/domain/sandbox-policy/shell.ts +129 -0
- package/src/runtime/domain/sandbox-policy/state.domain.mjs +307 -0
- package/src/runtime/domain/sandbox-policy/state.ts +408 -0
- package/src/runtime/domain/sandbox-policy/status.domain.mjs +64 -0
- package/src/runtime/domain/sandbox-policy/status.ts +76 -0
- package/src/runtime/domain/sandbox-policy/subagent-admission.domain.mjs +69 -0
- package/src/runtime/domain/sandbox-policy/subagent-admission.ts +60 -0
- package/src/runtime/domain/subagents/CONTEXT.md +202 -0
- package/src/runtime/domain/subagents/PRODUCT.md +49 -0
- package/src/runtime/domain/subagents/README.md +201 -0
- package/src/runtime/domain/subagents/agent-catalog.mjs +64 -0
- package/src/runtime/domain/subagents/agent-commands.domain.mjs +822 -0
- package/src/runtime/domain/subagents/agent-commands.ts +905 -0
- package/src/runtime/domain/subagents/agent-inspection.domain.mjs +398 -0
- package/src/runtime/domain/subagents/agent-inspection.ts +574 -0
- package/src/runtime/domain/subagents/agent-operations.domain.mjs +40 -0
- package/src/runtime/domain/subagents/agent-operations.ts +61 -0
- package/src/runtime/domain/subagents/agent-session-settings.domain.mjs +112 -0
- package/src/runtime/domain/subagents/agent-session-settings.ts +118 -0
- package/src/runtime/domain/subagents/agents-catalog-tool.domain.mjs +84 -0
- package/src/runtime/domain/subagents/agents-catalog-tool.ts +118 -0
- package/src/runtime/domain/subagents/assignment-outcomes.domain.mjs +276 -0
- package/src/runtime/domain/subagents/assignment-outcomes.ts +212 -0
- package/src/runtime/domain/subagents/assignment-projection.mjs +261 -0
- package/src/runtime/domain/subagents/assignment-report.domain.mjs +174 -0
- package/src/runtime/domain/subagents/assignment-report.ts +156 -0
- package/src/runtime/domain/subagents/batch.mjs +275 -0
- package/src/runtime/domain/subagents/callback-fields.domain.mjs +72 -0
- package/src/runtime/domain/subagents/callback-fields.ts +95 -0
- package/src/runtime/domain/subagents/capacity.mjs +108 -0
- package/src/runtime/domain/subagents/catalog-editor.domain.mjs +98 -0
- package/src/runtime/domain/subagents/catalog-editor.ts +125 -0
- package/src/runtime/domain/subagents/catalog-host-admission.domain.mjs +104 -0
- package/src/runtime/domain/subagents/catalog-host-admission.ts +85 -0
- package/src/runtime/domain/subagents/catalog-identity.domain.mjs +222 -0
- package/src/runtime/domain/subagents/catalog-identity.ts +258 -0
- package/src/runtime/domain/subagents/catalog-overlay.domain.mjs +9 -0
- package/src/runtime/domain/subagents/catalog-overlay.ts +10 -0
- package/src/runtime/domain/subagents/catalog-preferences.domain.mjs +164 -0
- package/src/runtime/domain/subagents/catalog-preferences.ts +139 -0
- package/src/runtime/domain/subagents/catalog-resolver.domain.mjs +366 -0
- package/src/runtime/domain/subagents/catalog-resolver.ts +540 -0
- package/src/runtime/domain/subagents/catalog-runtime.domain.mjs +570 -0
- package/src/runtime/domain/subagents/catalog-runtime.ts +680 -0
- package/src/runtime/domain/subagents/catalog-schema.domain.mjs +1331 -0
- package/src/runtime/domain/subagents/catalog-schema.ts +1563 -0
- package/src/runtime/domain/subagents/catalog-skill-edits.domain.mjs +95 -0
- package/src/runtime/domain/subagents/catalog-skill-edits.ts +116 -0
- package/src/runtime/domain/subagents/catalog-store.domain.mjs +808 -0
- package/src/runtime/domain/subagents/catalog-store.ts +1006 -0
- package/src/runtime/domain/subagents/catalog-ui.domain.mjs +651 -0
- package/src/runtime/domain/subagents/catalog-ui.ts +611 -0
- package/src/runtime/domain/subagents/child-apply-patch.domain.mjs +13 -0
- package/src/runtime/domain/subagents/child-apply-patch.ts +13 -0
- package/src/runtime/domain/subagents/child-codemode.domain.mjs +16 -0
- package/src/runtime/domain/subagents/child-codemode.ts +17 -0
- package/src/runtime/domain/subagents/child-dependencies.mjs +193 -0
- package/src/runtime/domain/subagents/child-incidents.domain.mjs +170 -0
- package/src/runtime/domain/subagents/child-incidents.ts +169 -0
- package/src/runtime/domain/subagents/child-operations.domain.mjs +986 -0
- package/src/runtime/domain/subagents/child-operations.ts +1191 -0
- package/src/runtime/domain/subagents/child-ownership.domain.mjs +205 -0
- package/src/runtime/domain/subagents/child-ownership.ts +160 -0
- package/src/runtime/domain/subagents/child-preflight.mjs +38 -0
- package/src/runtime/domain/subagents/child-process-list.domain.mjs +7 -0
- package/src/runtime/domain/subagents/child-process-list.ts +8 -0
- package/src/runtime/domain/subagents/child-runtime.mjs +67 -0
- package/src/runtime/domain/subagents/child-steer.domain.mjs +109 -0
- package/src/runtime/domain/subagents/child-steer.ts +102 -0
- package/src/runtime/domain/subagents/cleanup.domain.mjs +818 -0
- package/src/runtime/domain/subagents/cleanup.ts +1017 -0
- package/src/runtime/domain/subagents/codex-import.domain.mjs +575 -0
- package/src/runtime/domain/subagents/codex-import.ts +717 -0
- package/src/runtime/domain/subagents/completion.domain.mjs +6 -0
- package/src/runtime/domain/subagents/completion.mjs +152 -0
- package/src/runtime/domain/subagents/completion.ts +11 -0
- package/src/runtime/domain/subagents/config.domain.mjs +248 -0
- package/src/runtime/domain/subagents/config.json +15 -0
- package/src/runtime/domain/subagents/config.ts +328 -0
- package/src/runtime/domain/subagents/continuation-authority.domain.mjs +38 -0
- package/src/runtime/domain/subagents/continuation-authority.ts +31 -0
- package/src/runtime/domain/subagents/continuation-runtime.domain.mjs +89 -0
- package/src/runtime/domain/subagents/continuation-runtime.ts +88 -0
- package/src/runtime/domain/subagents/continuation.domain.mjs +942 -0
- package/src/runtime/domain/subagents/continuation.ts +1051 -0
- package/src/runtime/domain/subagents/delegation.domain.mjs +19 -0
- package/src/runtime/domain/subagents/delegation.ts +24 -0
- package/src/runtime/domain/subagents/effective-settings.domain.mjs +130 -0
- package/src/runtime/domain/subagents/effective-settings.ts +184 -0
- package/src/runtime/domain/subagents/extensions.domain.mjs +6 -0
- package/src/runtime/domain/subagents/extensions.mjs +164 -0
- package/src/runtime/domain/subagents/extensions.ts +19 -0
- package/src/runtime/domain/subagents/failures.domain.mjs +362 -0
- package/src/runtime/domain/subagents/failures.ts +319 -0
- package/src/runtime/domain/subagents/finalization.domain.mjs +168 -0
- package/src/runtime/domain/subagents/finalization.ts +218 -0
- package/src/runtime/domain/subagents/git-remotes.domain.mjs +351 -0
- package/src/runtime/domain/subagents/git-remotes.ts +413 -0
- package/src/runtime/domain/subagents/git-workspace.domain.mjs +337 -0
- package/src/runtime/domain/subagents/git-workspace.ts +430 -0
- package/src/runtime/domain/subagents/goal-provider.domain.mjs +125 -0
- package/src/runtime/domain/subagents/goal-provider.ts +132 -0
- package/src/runtime/domain/subagents/health-observation.domain.mjs +617 -0
- package/src/runtime/domain/subagents/health-observation.ts +818 -0
- package/src/runtime/domain/subagents/health-surface.mjs +284 -0
- package/src/runtime/domain/subagents/health.domain.mjs +261 -0
- package/src/runtime/domain/subagents/health.ts +343 -0
- package/src/runtime/domain/subagents/historical-attention.domain.mjs +37 -0
- package/src/runtime/domain/subagents/historical-attention.ts +35 -0
- package/src/runtime/domain/subagents/incident-model.domain.mjs +322 -0
- package/src/runtime/domain/subagents/incident-model.ts +358 -0
- package/src/runtime/domain/subagents/index.domain.mjs +4731 -0
- package/src/runtime/domain/subagents/index.ts +4781 -0
- package/src/runtime/domain/subagents/launch-abort.domain.mjs +13 -0
- package/src/runtime/domain/subagents/launch-abort.ts +21 -0
- package/src/runtime/domain/subagents/launch-context.domain.mjs +24 -0
- package/src/runtime/domain/subagents/launch-context.ts +23 -0
- package/src/runtime/domain/subagents/launch-digest.mjs +6 -0
- package/src/runtime/domain/subagents/lifecycle.domain.mjs +265 -0
- package/src/runtime/domain/subagents/lifecycle.ts +360 -0
- package/src/runtime/domain/subagents/list.domain.mjs +2 -0
- package/src/runtime/domain/subagents/list.mjs +152 -0
- package/src/runtime/domain/subagents/list.ts +19 -0
- package/src/runtime/domain/subagents/log-cursor.domain.mjs +217 -0
- package/src/runtime/domain/subagents/log-cursor.ts +268 -0
- package/src/runtime/domain/subagents/managed-background-capability.domain.mjs +10 -0
- package/src/runtime/domain/subagents/managed-background-capability.ts +9 -0
- package/src/runtime/domain/subagents/managed-failure-worker.mjs +36 -0
- package/src/runtime/domain/subagents/managed-launch-bootstrap.mjs +48 -0
- package/src/runtime/domain/subagents/managed-launch-client.domain.mjs +75 -0
- package/src/runtime/domain/subagents/managed-launch-client.ts +59 -0
- package/src/runtime/domain/subagents/managed-launch-host.domain.mjs +627 -0
- package/src/runtime/domain/subagents/managed-launch-host.ts +504 -0
- package/src/runtime/domain/subagents/managed-launch-journal.mjs +17 -0
- package/src/runtime/domain/subagents/managed-launch-ownership.domain.mjs +29 -0
- package/src/runtime/domain/subagents/managed-launch-ownership.ts +22 -0
- package/src/runtime/domain/subagents/managed-launch-port.domain.mjs +2 -0
- package/src/runtime/domain/subagents/managed-launch-port.ts +25 -0
- package/src/runtime/domain/subagents/managed-launch-recovery.domain.mjs +29 -0
- package/src/runtime/domain/subagents/managed-launch-recovery.ts +45 -0
- package/src/runtime/domain/subagents/managed-worker-bridge.domain.mjs +63 -0
- package/src/runtime/domain/subagents/managed-worker-bridge.ts +48 -0
- package/src/runtime/domain/subagents/managed-worker.mjs +13 -0
- package/src/runtime/domain/subagents/model-resolution-core.domain.mjs +822 -0
- package/src/runtime/domain/subagents/model-resolution-core.ts +1074 -0
- package/src/runtime/domain/subagents/model-resolution.domain.mjs +22 -0
- package/src/runtime/domain/subagents/model-resolution.ts +32 -0
- package/src/runtime/domain/subagents/navigator.domain.mjs +6 -0
- package/src/runtime/domain/subagents/navigator.mjs +1233 -0
- package/src/runtime/domain/subagents/navigator.ts +39 -0
- package/src/runtime/domain/subagents/operation-bridge-types.domain.mjs +1012 -0
- package/src/runtime/domain/subagents/operation-bridge-types.ts +1156 -0
- package/src/runtime/domain/subagents/outage-observations.domain.mjs +84 -0
- package/src/runtime/domain/subagents/outage-observations.ts +73 -0
- package/src/runtime/domain/subagents/output-payload.domain.mjs +767 -0
- package/src/runtime/domain/subagents/output-payload.ts +987 -0
- package/src/runtime/domain/subagents/owned-exit.domain.mjs +12 -0
- package/src/runtime/domain/subagents/owned-exit.ts +12 -0
- package/src/runtime/domain/subagents/package.json +86 -0
- package/src/runtime/domain/subagents/park-checkpoint.domain.mjs +55 -0
- package/src/runtime/domain/subagents/park-checkpoint.ts +61 -0
- package/src/runtime/domain/subagents/parse.domain.mjs +1218 -0
- package/src/runtime/domain/subagents/parse.ts +1451 -0
- package/src/runtime/domain/subagents/permission-policy.domain.mjs +232 -0
- package/src/runtime/domain/subagents/permission-policy.ts +291 -0
- package/src/runtime/domain/subagents/process-identity.mjs +33 -0
- package/src/runtime/domain/subagents/registry.domain.mjs +1584 -0
- package/src/runtime/domain/subagents/registry.ts +1904 -0
- package/src/runtime/domain/subagents/role-assignment.domain.mjs +104 -0
- package/src/runtime/domain/subagents/role-assignment.ts +141 -0
- package/src/runtime/domain/subagents/roles/role.architect.md +13 -0
- package/src/runtime/domain/subagents/roles/role.developer.md +16 -0
- package/src/runtime/domain/subagents/roles/role.explorer.md +13 -0
- package/src/runtime/domain/subagents/roles/role.product-manager.md +13 -0
- package/src/runtime/domain/subagents/roles/role.researcher.md +13 -0
- package/src/runtime/domain/subagents/roles/role.reviewer.md +13 -0
- package/src/runtime/domain/subagents/roles/role.writer.md +12 -0
- package/src/runtime/domain/subagents/sandbox.domain.mjs +64 -0
- package/src/runtime/domain/subagents/sandbox.ts +92 -0
- package/src/runtime/domain/subagents/session-selection.domain.mjs +32 -0
- package/src/runtime/domain/subagents/session-selection.ts +35 -0
- package/src/runtime/domain/subagents/session-store.domain.mjs +489 -0
- package/src/runtime/domain/subagents/session-store.ts +468 -0
- package/src/runtime/domain/subagents/settings-page.domain.mjs +313 -0
- package/src/runtime/domain/subagents/settings-page.ts +363 -0
- package/src/runtime/domain/subagents/shared-callback-batcher.domain.mjs +777 -0
- package/src/runtime/domain/subagents/shared-callback-batcher.ts +956 -0
- package/src/runtime/domain/subagents/shared-catalog.domain.mjs +70 -0
- package/src/runtime/domain/subagents/shared-catalog.ts +61 -0
- package/src/runtime/domain/subagents/shared-execution-policy.domain.mjs +50 -0
- package/src/runtime/domain/subagents/shared-execution-policy.ts +61 -0
- package/src/runtime/domain/subagents/shared-failure-observations.domain.mjs +1078 -0
- package/src/runtime/domain/subagents/shared-failure-observations.ts +1166 -0
- package/src/runtime/domain/subagents/shared-harness-settings.domain.mjs +126 -0
- package/src/runtime/domain/subagents/shared-harness-settings.ts +116 -0
- package/src/runtime/domain/subagents/shared-log-utils.domain.mjs +1223 -0
- package/src/runtime/domain/subagents/shared-log-utils.ts +1492 -0
- package/src/runtime/domain/subagents/shared-navigator-panels.domain.mjs +289 -0
- package/src/runtime/domain/subagents/shared-navigator-panels.ts +272 -0
- package/src/runtime/domain/subagents/shared-navigator.domain.mjs +1930 -0
- package/src/runtime/domain/subagents/shared-navigator.ts +1962 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-inbox.mjs +144 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-observation.mjs +189 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/index.domain.mjs +51 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/index.ts +122 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-changes.domain.mjs +75 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-changes.ts +73 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.domain.mjs +163 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.ts +174 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-parent-callbacks.domain.mjs +66 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-parent-callbacks.ts +68 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.domain.mjs +87 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.ts +90 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.domain.mjs +97 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.ts +139 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/errors.domain.mjs +12 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/errors.ts +79 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.domain.mjs +342 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.ts +513 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/outbox.domain.mjs +283 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/outbox.ts +458 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/recovery.domain.mjs +52 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/recovery.ts +55 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.domain.mjs +114 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.ts +140 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.domain.mjs +280 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.ts +442 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.domain.mjs +420 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.ts +441 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/sqlite.domain.mjs +194 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/sqlite.ts +239 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.domain.mjs +275 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.ts +585 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.domain.mjs +120 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.ts +142 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/task-cancellation.domain.mjs +188 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/task-cancellation.ts +224 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.domain.mjs +25 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.ts +707 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/upgrade.domain.mjs +22 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/upgrade.ts +22 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/validate.domain.mjs +234 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/validate.ts +241 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/waits.domain.mjs +851 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/waits.ts +1424 -0
- package/src/runtime/domain/subagents/shared-permission-blocker.domain.mjs +40 -0
- package/src/runtime/domain/subagents/shared-permission-blocker.ts +48 -0
- package/src/runtime/domain/subagents/shared-render-scheduler.domain.mjs +41 -0
- package/src/runtime/domain/subagents/shared-render-scheduler.ts +47 -0
- package/src/runtime/domain/subagents/shared-sandbox-core.domain.mjs +1531 -0
- package/src/runtime/domain/subagents/shared-sandbox-core.ts +1757 -0
- package/src/runtime/domain/subagents/shared-sandbox-diagnostics.domain.mjs +591 -0
- package/src/runtime/domain/subagents/shared-sandbox-diagnostics.ts +491 -0
- package/src/runtime/domain/subagents/shared-stall-detector.domain.mjs +37 -0
- package/src/runtime/domain/subagents/shared-stall-detector.ts +69 -0
- package/src/runtime/domain/subagents/shared-task-application.domain.mjs +185 -0
- package/src/runtime/domain/subagents/shared-task-application.ts +185 -0
- package/src/runtime/domain/subagents/shared-task-apply-patch.domain.mjs +416 -0
- package/src/runtime/domain/subagents/shared-task-apply-patch.ts +409 -0
- package/src/runtime/domain/subagents/shared-task-exec.domain.mjs +325 -0
- package/src/runtime/domain/subagents/shared-task-exec.ts +335 -0
- package/src/runtime/domain/subagents/shared-task-files.domain.mjs +346 -0
- package/src/runtime/domain/subagents/shared-task-files.ts +342 -0
- package/src/runtime/domain/subagents/shared-task-process-identity.domain.mjs +140 -0
- package/src/runtime/domain/subagents/shared-task-process-identity.ts +126 -0
- package/src/runtime/domain/subagents/shared-task-process-list.domain.mjs +220 -0
- package/src/runtime/domain/subagents/shared-task-process-list.ts +209 -0
- package/src/runtime/domain/subagents/shared-task-sandbox.domain.mjs +227 -0
- package/src/runtime/domain/subagents/shared-task-sandbox.ts +224 -0
- package/src/runtime/domain/subagents/shared-task-tools.domain.mjs +92 -0
- package/src/runtime/domain/subagents/shared-task-tools.ts +123 -0
- package/src/runtime/domain/subagents/shared-work-client.mjs +303 -0
- package/src/runtime/domain/subagents/shared-worktree-context.domain.mjs +142 -0
- package/src/runtime/domain/subagents/shared-worktree-context.ts +158 -0
- package/src/runtime/domain/subagents/skill-picker.domain.mjs +316 -0
- package/src/runtime/domain/subagents/skill-picker.ts +353 -0
- package/src/runtime/domain/subagents/skills.domain.mjs +138 -0
- package/src/runtime/domain/subagents/skills.ts +183 -0
- package/src/runtime/domain/subagents/spawn.domain.mjs +72 -0
- package/src/runtime/domain/subagents/spawn.ts +80 -0
- package/src/runtime/domain/subagents/stop.domain.mjs +184 -0
- package/src/runtime/domain/subagents/stop.ts +217 -0
- package/src/runtime/domain/subagents/subagent-tools.domain.mjs +101 -0
- package/src/runtime/domain/subagents/subagent-tools.ts +137 -0
- package/src/runtime/domain/subagents/task-guard.domain.mjs +163 -0
- package/src/runtime/domain/subagents/task-guard.ts +144 -0
- package/src/runtime/domain/subagents/task-policy.domain.mjs +201 -0
- package/src/runtime/domain/subagents/task-policy.ts +236 -0
- package/src/runtime/domain/subagents/task-runtime.mjs +53 -0
- package/src/runtime/domain/subagents/task-tool-owner.domain.mjs +18 -0
- package/src/runtime/domain/subagents/task-tool-owner.ts +21 -0
- package/src/runtime/domain/subagents/thinking.domain.mjs +22 -0
- package/src/runtime/domain/subagents/thinking.ts +28 -0
- package/src/runtime/domain/subagents/tier-policy.domain.mjs +75 -0
- package/src/runtime/domain/subagents/tier-policy.ts +126 -0
- package/src/runtime/domain/subagents/timing-notifications.domain.mjs +51 -0
- package/src/runtime/domain/subagents/timing-notifications.ts +37 -0
- package/src/runtime/domain/subagents/timing.domain.mjs +487 -0
- package/src/runtime/domain/subagents/timing.ts +634 -0
- package/src/runtime/domain/subagents/tools.domain.mjs +558 -0
- package/src/runtime/domain/subagents/tools.ts +629 -0
- package/src/runtime/domain/subagents/widget.domain.mjs +6 -0
- package/src/runtime/domain/subagents/widget.mjs +246 -0
- package/src/runtime/domain/subagents/widget.ts +30 -0
- package/src/runtime/domain/subagents/work-observation.domain.mjs +316 -0
- package/src/runtime/domain/subagents/work-observation.ts +248 -0
- package/src/runtime/domain/subagents/worker-catalog.domain.mjs +120 -0
- package/src/runtime/domain/subagents/worker-catalog.ts +162 -0
- package/src/runtime/domain/subagents/worker-operations-host.domain.mjs +1009 -0
- package/src/runtime/domain/subagents/worker-operations-host.ts +1238 -0
- package/src/runtime/domain/subagents/worker-waits.domain.mjs +2336 -0
- package/src/runtime/domain/subagents/worker-waits.ts +2878 -0
- package/src/runtime/domain/subagents/workspace-scope.domain.mjs +52 -0
- package/src/runtime/domain/subagents/workspace-scope.ts +50 -0
- package/src/runtime/health-config.ts +27 -11
- package/src/runtime/log-checkpoints.ts +117 -0
- package/src/runtime/mutation-store.ts +5 -4
- package/src/runtime/queries.ts +27 -3
- package/src/runtime/query-executor.ts +178 -34
- package/src/runtime/query-worker.mjs +119 -22
- package/src/runtime/read-model.ts +939 -113
- package/src/runtime/read-watchdog-probe.ts +4 -0
- package/src/runtime/result-supervision.ts +188 -16
- package/src/runtime/source-watch.ts +175 -0
- package/src/runtime/subagent-launch.ts +73 -0
- package/src/runtime/work-budget.ts +130 -0
- package/src/runtime/work-client.d.mts +8 -0
- package/src/runtime/work-client.mjs +150 -7
- package/src/server.ts +185 -22
- package/src/session-activity.ts +26 -4
- package/src/version.ts +1 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Generated fixed launch domain from packages/pi-better-background-tasks/src/shared-operation-coordinator/src/result-supervision.ts. Do not edit directly.
|
|
2
|
+
// Generated from packages/operation-coordinator/src/result-supervision.ts. Do not edit directly.
|
|
3
|
+
import { isDeepStrictEqual } from "node:util";
|
|
4
|
+
import { getRow, run } from "./sqlite.domain.mjs";
|
|
5
|
+
import { getOperation, recordSupervision, recordTerminalOutcome } from "./operations.domain.mjs";
|
|
6
|
+
import { requireId, requirePath } from "./validate.domain.mjs";
|
|
7
|
+
const PREFIX = "result-supervision-v1:";
|
|
8
|
+
/** A bounded observation page. A gap requires restoring active authority, not history. */
|
|
9
|
+
export function resultSupervisionChanges(ctx, after) {
|
|
10
|
+
const generation = String(ctx.db.prepare("SELECT generation FROM assignment_change_source WHERE singleton=1").get().generation);
|
|
11
|
+
const bounds = ctx.db.prepare("SELECT min(seq) AS first, max(seq) AS last FROM assignment_changes").get();
|
|
12
|
+
const last = Number(bounds.last ?? 0);
|
|
13
|
+
const reset = !after || after.generation !== generation || after.seq > last
|
|
14
|
+
|| (bounds.first !== null && after.seq < Number(bounds.first) - 1);
|
|
15
|
+
const rows = reset ? [] : ctx.db.prepare("SELECT seq, entity, entity_id FROM assignment_changes WHERE seq>? ORDER BY seq LIMIT 128").all(after.seq);
|
|
16
|
+
const seq = reset ? last : Number(rows.at(-1)?.seq ?? after.seq);
|
|
17
|
+
return { generation, seq, reset, more: seq < last,
|
|
18
|
+
operationIds: [...new Set(rows.filter(row => row.entity === "background:operation").map(row => String(row.entity_id)))] };
|
|
19
|
+
}
|
|
20
|
+
export function resultSupervisions(ctx, activeOnly = false) {
|
|
21
|
+
const rows = activeOnly
|
|
22
|
+
? ctx.db.prepare("SELECT s.value FROM operations o JOIN coordinator_state s ON s.key = ? || o.operation_id WHERE o.phase = 'running'").all(PREFIX)
|
|
23
|
+
: ctx.db.prepare("SELECT value FROM coordinator_state WHERE key LIKE ?").all(`${PREFIX}%`);
|
|
24
|
+
return rows
|
|
25
|
+
.map(row => JSON.parse(String(row.value)));
|
|
26
|
+
}
|
|
27
|
+
export function resultSupervision(ctx, operationId) {
|
|
28
|
+
const row = getRow(ctx, "SELECT value FROM coordinator_state WHERE key = ?", PREFIX + requireId("operationId", operationId));
|
|
29
|
+
return row ? JSON.parse(String(row.value)) : null;
|
|
30
|
+
}
|
|
31
|
+
/** The admitting host has stopped its local route before this exact-owner CAS. */
|
|
32
|
+
export function handoffResultSupervision(ctx, input) {
|
|
33
|
+
const operationId = requireId("operationId", input.operationId);
|
|
34
|
+
const hostId = requireId("hostId", input.hostId);
|
|
35
|
+
const epoch = requireId("epoch", input.epoch);
|
|
36
|
+
const directory = requirePath("directory", input.directory);
|
|
37
|
+
return ctx.transaction(() => {
|
|
38
|
+
const previous = resultSupervision(ctx, operationId);
|
|
39
|
+
if (previous) {
|
|
40
|
+
if (previous.directory !== directory || previous.hostId !== hostId || previous.epoch !== epoch
|
|
41
|
+
|| !isDeepStrictEqual(previous.capability, input.capability)) {
|
|
42
|
+
throw new Error("supervision-conflict: repeated handoff changed destination or captured authority");
|
|
43
|
+
}
|
|
44
|
+
return previous;
|
|
45
|
+
}
|
|
46
|
+
const operation = getOperation(ctx, operationId);
|
|
47
|
+
if (!operation || operation.supervision?.hostId !== input.expectedHostId)
|
|
48
|
+
throw new Error("permission-unavailable: exact supervision owner changed");
|
|
49
|
+
const grant = { operationId, directory, hostId, epoch, launchToken: operation.launchToken,
|
|
50
|
+
authorityRef: operation.authorityRef, owner: operation.owner, ...(input.capability ? { capability: input.capability } : {}) };
|
|
51
|
+
recordSupervision(ctx, { operationId, owner: operation.owner, expectedHostId: input.expectedHostId,
|
|
52
|
+
supervision: { hostId }, health: "active" });
|
|
53
|
+
run(ctx, "INSERT INTO coordinator_state (key, value) VALUES (?, ?)", PREFIX + operationId, JSON.stringify(grant));
|
|
54
|
+
return grant;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** A wait's dependency set transfers together, or none of it does. */
|
|
58
|
+
export function handoffResultSupervisions(ctx, inputs) {
|
|
59
|
+
return ctx.transaction(() => inputs.map(input => handoffResultSupervision(ctx, input)));
|
|
60
|
+
}
|
|
61
|
+
export function resultScopeManaged(ctx, scope) {
|
|
62
|
+
return !!getRow(ctx, "SELECT value FROM coordinator_state WHERE key = ?", "result-scope-v1:" + requireId("scope", scope));
|
|
63
|
+
}
|
|
64
|
+
export function handoffResultScope(ctx, input) {
|
|
65
|
+
return ctx.transaction(() => {
|
|
66
|
+
const claim = getRow(ctx, "SELECT host_id, token FROM discovery_claims WHERE scope = ?", requireId("scope", input.scope));
|
|
67
|
+
if (claim ? !input.expectedDiscovery || claim.host_id !== input.expectedDiscovery.hostId || claim.token !== input.expectedDiscovery.token : input.expectedDiscovery !== null) {
|
|
68
|
+
throw new Error("supervision-conflict: discovery owner changed during handoff");
|
|
69
|
+
}
|
|
70
|
+
const grants = handoffResultSupervisions(ctx, input.grants);
|
|
71
|
+
// Registration precedes sidecar creation. Check durable records inside
|
|
72
|
+
// this transaction, including old records whose scope is unknown.
|
|
73
|
+
const stranded = getRow(ctx, `SELECT operation_id FROM operations o
|
|
74
|
+
WHERE phase = 'running' AND observer_kind = 'local-supervisor'
|
|
75
|
+
AND COALESCE(json_extract(supervision_json, '$.resultAdapter'), 0) != 1
|
|
76
|
+
AND (json_extract(supervision_json, '$.resultScope') IS NULL
|
|
77
|
+
OR json_extract(supervision_json, '$.resultScope') = ?)
|
|
78
|
+
AND NOT EXISTS (SELECT 1 FROM coordinator_state s WHERE s.key = ? || o.operation_id)
|
|
79
|
+
LIMIT 1`, input.scope, PREFIX);
|
|
80
|
+
if (stranded)
|
|
81
|
+
throw new Error("permission-unavailable: untransferred legacy operation prevents scope handoff");
|
|
82
|
+
run(ctx, "DELETE FROM discovery_claims WHERE scope = ?", input.scope);
|
|
83
|
+
run(ctx, "INSERT OR IGNORE INTO coordinator_state (key, value) VALUES (?, 'managed')", "result-scope-v1:" + input.scope);
|
|
84
|
+
return grants;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/** Called by the singleton server after proving the preceding server has exited. */
|
|
88
|
+
export function recoverResultSupervision(ctx, input) {
|
|
89
|
+
ctx.transaction(() => {
|
|
90
|
+
const previous = resultSupervision(ctx, input.operationId);
|
|
91
|
+
if (!previous || previous.launchToken !== input.launchToken || previous.directory !== input.directory
|
|
92
|
+
|| previous.authorityRef !== input.authorityRef || JSON.stringify(previous.owner) !== JSON.stringify(input.owner)
|
|
93
|
+
|| JSON.stringify(previous.capability) !== JSON.stringify(input.capability)) {
|
|
94
|
+
throw new Error("supervision-conflict: execution or captured authority changed");
|
|
95
|
+
}
|
|
96
|
+
const operation = getOperation(ctx, input.operationId);
|
|
97
|
+
if (operation.terminalRevision > 0)
|
|
98
|
+
return;
|
|
99
|
+
recordSupervision(ctx, { operationId: input.operationId, owner: operation.owner,
|
|
100
|
+
expectedHostId: previous.hostId, supervision: { hostId: input.hostId }, health: "active" });
|
|
101
|
+
run(ctx, "UPDATE coordinator_state SET value = ? WHERE key = ?", JSON.stringify(input), PREFIX + input.operationId);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
export function publishSupervisedResult(ctx, input) {
|
|
105
|
+
return ctx.transaction(() => {
|
|
106
|
+
const grant = resultSupervision(ctx, input.operationId);
|
|
107
|
+
const operation = getOperation(ctx, input.operationId);
|
|
108
|
+
if (!grant || grant.epoch !== input.epoch || operation?.supervision?.hostId !== grant.hostId
|
|
109
|
+
|| operation.launchToken !== grant.launchToken || input.publication.operationId !== input.operationId) {
|
|
110
|
+
throw new Error("stale-runtime-epoch: result supervision changed");
|
|
111
|
+
}
|
|
112
|
+
return recordTerminalOutcome(ctx, input.publication);
|
|
113
|
+
});
|
|
114
|
+
}
|
package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// Generated from packages/operation-coordinator/src/result-supervision.ts. Do not edit directly.
|
|
2
|
+
import { isDeepStrictEqual } from "node:util";
|
|
3
|
+
import { getRow, run, type StoreContext } from "./sqlite.ts";
|
|
4
|
+
import { getOperation, recordSupervision, recordTerminalOutcome } from "./operations.ts";
|
|
5
|
+
import { requireId, requirePath } from "./validate.ts";
|
|
6
|
+
import type { RecordTerminalOutcomeInput } from "./types.ts";
|
|
7
|
+
import type { OwnerIdentity } from "./types.ts";
|
|
8
|
+
|
|
9
|
+
const PREFIX = "result-supervision-v1:";
|
|
10
|
+
/** A bounded observation page. A gap requires restoring active authority, not history. */
|
|
11
|
+
export function resultSupervisionChanges(ctx: StoreContext, after?: { generation: string; seq: number }) {
|
|
12
|
+
const generation = String(ctx.db.prepare("SELECT generation FROM assignment_change_source WHERE singleton=1").get()!.generation);
|
|
13
|
+
const bounds = ctx.db.prepare("SELECT min(seq) AS first, max(seq) AS last FROM assignment_changes").get()!;
|
|
14
|
+
const last = Number(bounds.last ?? 0);
|
|
15
|
+
const reset = !after || after.generation !== generation || after.seq > last
|
|
16
|
+
|| (bounds.first !== null && after.seq < Number(bounds.first) - 1);
|
|
17
|
+
const rows = reset ? [] : ctx.db.prepare("SELECT seq, entity, entity_id FROM assignment_changes WHERE seq>? ORDER BY seq LIMIT 128").all(after!.seq);
|
|
18
|
+
const seq = reset ? last : Number(rows.at(-1)?.seq ?? after!.seq);
|
|
19
|
+
return { generation, seq, reset, more: seq < last,
|
|
20
|
+
operationIds: [...new Set(rows.filter(row => row.entity === "background:operation").map(row => String(row.entity_id)))] };
|
|
21
|
+
}
|
|
22
|
+
export interface ResultSupervision {
|
|
23
|
+
operationId: string;
|
|
24
|
+
directory: string;
|
|
25
|
+
launchToken: string;
|
|
26
|
+
authorityRef: string | null;
|
|
27
|
+
hostId: string;
|
|
28
|
+
epoch: string;
|
|
29
|
+
owner: OwnerIdentity;
|
|
30
|
+
capability?: { adapter: string; captured: unknown; current: unknown };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function resultSupervisions(ctx: StoreContext, activeOnly = false): ResultSupervision[] {
|
|
34
|
+
const rows = activeOnly
|
|
35
|
+
? ctx.db.prepare("SELECT s.value FROM operations o JOIN coordinator_state s ON s.key = ? || o.operation_id WHERE o.phase = 'running'").all(PREFIX)
|
|
36
|
+
: ctx.db.prepare("SELECT value FROM coordinator_state WHERE key LIKE ?").all(`${PREFIX}%`);
|
|
37
|
+
return rows
|
|
38
|
+
.map(row => JSON.parse(String(row.value)));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function resultSupervision(ctx: StoreContext, operationId: string): ResultSupervision | null {
|
|
42
|
+
const row = getRow(ctx, "SELECT value FROM coordinator_state WHERE key = ?", PREFIX + requireId("operationId", operationId));
|
|
43
|
+
return row ? JSON.parse(String(row.value)) : null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The admitting host has stopped its local route before this exact-owner CAS. */
|
|
47
|
+
export function handoffResultSupervision(ctx: StoreContext, input: {
|
|
48
|
+
operationId: string; expectedHostId: string; directory: string; hostId: string; epoch: string;
|
|
49
|
+
capability?: ResultSupervision["capability"];
|
|
50
|
+
}): ResultSupervision {
|
|
51
|
+
const operationId = requireId("operationId", input.operationId);
|
|
52
|
+
const hostId = requireId("hostId", input.hostId);
|
|
53
|
+
const epoch = requireId("epoch", input.epoch);
|
|
54
|
+
const directory = requirePath("directory", input.directory);
|
|
55
|
+
return ctx.transaction(() => {
|
|
56
|
+
const previous = resultSupervision(ctx, operationId);
|
|
57
|
+
if (previous) {
|
|
58
|
+
if (previous.directory !== directory || previous.hostId !== hostId || previous.epoch !== epoch
|
|
59
|
+
|| !isDeepStrictEqual(previous.capability, input.capability)) {
|
|
60
|
+
throw new Error("supervision-conflict: repeated handoff changed destination or captured authority");
|
|
61
|
+
}
|
|
62
|
+
return previous;
|
|
63
|
+
}
|
|
64
|
+
const operation = getOperation(ctx, operationId);
|
|
65
|
+
if (!operation || operation.supervision?.hostId !== input.expectedHostId) throw new Error("permission-unavailable: exact supervision owner changed");
|
|
66
|
+
const grant = { operationId, directory, hostId, epoch, launchToken: operation.launchToken,
|
|
67
|
+
authorityRef: operation.authorityRef, owner: operation.owner, ...(input.capability ? { capability: input.capability } : {}) };
|
|
68
|
+
recordSupervision(ctx, { operationId, owner: operation.owner, expectedHostId: input.expectedHostId,
|
|
69
|
+
supervision: { hostId }, health: "active" });
|
|
70
|
+
run(ctx, "INSERT INTO coordinator_state (key, value) VALUES (?, ?)", PREFIX + operationId, JSON.stringify(grant));
|
|
71
|
+
return grant;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** A wait's dependency set transfers together, or none of it does. */
|
|
76
|
+
export function handoffResultSupervisions(ctx: StoreContext, inputs: Parameters<typeof handoffResultSupervision>[1][]): ResultSupervision[] {
|
|
77
|
+
return ctx.transaction(() => inputs.map(input => handoffResultSupervision(ctx, input)));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function resultScopeManaged(ctx: StoreContext, scope: string): boolean {
|
|
81
|
+
return !!getRow(ctx, "SELECT value FROM coordinator_state WHERE key = ?", "result-scope-v1:" + requireId("scope", scope));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function handoffResultScope(ctx: StoreContext, input: {
|
|
85
|
+
scope: string;
|
|
86
|
+
expectedDiscovery: { hostId: string; token: string } | null;
|
|
87
|
+
grants: Parameters<typeof handoffResultSupervision>[1][];
|
|
88
|
+
}): ResultSupervision[] {
|
|
89
|
+
return ctx.transaction(() => {
|
|
90
|
+
const claim = getRow(ctx, "SELECT host_id, token FROM discovery_claims WHERE scope = ?", requireId("scope", input.scope));
|
|
91
|
+
if (claim ? !input.expectedDiscovery || claim.host_id !== input.expectedDiscovery.hostId || claim.token !== input.expectedDiscovery.token : input.expectedDiscovery !== null) {
|
|
92
|
+
throw new Error("supervision-conflict: discovery owner changed during handoff");
|
|
93
|
+
}
|
|
94
|
+
const grants = handoffResultSupervisions(ctx, input.grants);
|
|
95
|
+
// Registration precedes sidecar creation. Check durable records inside
|
|
96
|
+
// this transaction, including old records whose scope is unknown.
|
|
97
|
+
const stranded = getRow(ctx, `SELECT operation_id FROM operations o
|
|
98
|
+
WHERE phase = 'running' AND observer_kind = 'local-supervisor'
|
|
99
|
+
AND COALESCE(json_extract(supervision_json, '$.resultAdapter'), 0) != 1
|
|
100
|
+
AND (json_extract(supervision_json, '$.resultScope') IS NULL
|
|
101
|
+
OR json_extract(supervision_json, '$.resultScope') = ?)
|
|
102
|
+
AND NOT EXISTS (SELECT 1 FROM coordinator_state s WHERE s.key = ? || o.operation_id)
|
|
103
|
+
LIMIT 1`, input.scope, PREFIX);
|
|
104
|
+
if (stranded) throw new Error("permission-unavailable: untransferred legacy operation prevents scope handoff");
|
|
105
|
+
run(ctx, "DELETE FROM discovery_claims WHERE scope = ?", input.scope);
|
|
106
|
+
run(ctx, "INSERT OR IGNORE INTO coordinator_state (key, value) VALUES (?, 'managed')", "result-scope-v1:" + input.scope);
|
|
107
|
+
return grants;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Called by the singleton server after proving the preceding server has exited. */
|
|
112
|
+
export function recoverResultSupervision(ctx: StoreContext, input: ResultSupervision): void {
|
|
113
|
+
ctx.transaction(() => {
|
|
114
|
+
const previous = resultSupervision(ctx, input.operationId);
|
|
115
|
+
if (!previous || previous.launchToken !== input.launchToken || previous.directory !== input.directory
|
|
116
|
+
|| previous.authorityRef !== input.authorityRef || JSON.stringify(previous.owner) !== JSON.stringify(input.owner)
|
|
117
|
+
|| JSON.stringify(previous.capability) !== JSON.stringify(input.capability)) {
|
|
118
|
+
throw new Error("supervision-conflict: execution or captured authority changed");
|
|
119
|
+
}
|
|
120
|
+
const operation = getOperation(ctx, input.operationId)!;
|
|
121
|
+
if (operation.terminalRevision > 0) return;
|
|
122
|
+
recordSupervision(ctx, { operationId: input.operationId, owner: operation.owner,
|
|
123
|
+
expectedHostId: previous.hostId, supervision: { hostId: input.hostId }, health: "active" });
|
|
124
|
+
run(ctx, "UPDATE coordinator_state SET value = ? WHERE key = ?", JSON.stringify(input), PREFIX + input.operationId);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function publishSupervisedResult(ctx: StoreContext, input: {
|
|
129
|
+
operationId: string; epoch: string; publication: RecordTerminalOutcomeInput;
|
|
130
|
+
}) {
|
|
131
|
+
return ctx.transaction(() => {
|
|
132
|
+
const grant = resultSupervision(ctx, input.operationId);
|
|
133
|
+
const operation = getOperation(ctx, input.operationId);
|
|
134
|
+
if (!grant || grant.epoch !== input.epoch || operation?.supervision?.hostId !== grant.hostId
|
|
135
|
+
|| operation.launchToken !== grant.launchToken || input.publication.operationId !== input.operationId) {
|
|
136
|
+
throw new Error("stale-runtime-epoch: result supervision changed");
|
|
137
|
+
}
|
|
138
|
+
return recordTerminalOutcome(ctx, input.publication);
|
|
139
|
+
});
|
|
140
|
+
}
|
package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.domain.mjs
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
// Generated fixed launch domain from packages/pi-better-background-tasks/src/shared-operation-coordinator/src/rows.ts. Do not edit directly.
|
|
2
|
+
// Generated from packages/operation-coordinator/src/rows.ts. Do not edit directly.
|
|
3
|
+
/**
|
|
4
|
+
* Row mapping for the coordinator store.
|
|
5
|
+
*
|
|
6
|
+
* Reads are strict: a column that does not match its declared shape raises
|
|
7
|
+
* `store-corruption` instead of being coerced, so a damaged journal is reported
|
|
8
|
+
* rather than silently reinterpreted.
|
|
9
|
+
*/
|
|
10
|
+
import { columnBoolean, columnJson, columnNullableNumber, columnNullableText, columnNumber, columnText, getRow, getRows, } from "./sqlite.domain.mjs";
|
|
11
|
+
import { StoreError } from "./errors.domain.mjs";
|
|
12
|
+
// ---- owner identity -----------------------------------------------------
|
|
13
|
+
export function ownerFromRow(row, prefix = "owner") {
|
|
14
|
+
const kind = columnText(row, `${prefix}_kind`);
|
|
15
|
+
return {
|
|
16
|
+
kind,
|
|
17
|
+
sessionId: columnText(row, `${prefix}_session_id`),
|
|
18
|
+
workspace: columnText(row, `${prefix}_workspace`),
|
|
19
|
+
branchId: columnNullableText(row, `${prefix}_branch_id`),
|
|
20
|
+
goalId: columnNullableText(row, `${prefix}_goal_id`),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
// ---- operations ---------------------------------------------------------
|
|
24
|
+
export function getOperationRow(ctx, operationId) {
|
|
25
|
+
return getRow(ctx, "SELECT * FROM operations WHERE operation_id = ?", operationId);
|
|
26
|
+
}
|
|
27
|
+
export function getOperationRowByTask(ctx, taskId) {
|
|
28
|
+
return getRow(ctx, "SELECT * FROM operations WHERE task_id = ?", taskId);
|
|
29
|
+
}
|
|
30
|
+
export function mapOperation(row) {
|
|
31
|
+
const assignmentAttemptId = columnNullableText(row, "assignment_attempt_id");
|
|
32
|
+
return {
|
|
33
|
+
operationId: columnText(row, "operation_id"),
|
|
34
|
+
taskId: columnText(row, "task_id"),
|
|
35
|
+
launchToken: columnText(row, "launch_token"),
|
|
36
|
+
owner: ownerFromRow(row),
|
|
37
|
+
...(assignmentAttemptId === null ? {} : { assignmentAttemptId }),
|
|
38
|
+
observer: {
|
|
39
|
+
kind: columnText(row, "observer_kind"),
|
|
40
|
+
version: columnText(row, "observer_version"),
|
|
41
|
+
},
|
|
42
|
+
supervision: columnJson(row, "supervision_json"),
|
|
43
|
+
authorityRef: columnNullableText(row, "authority_ref"),
|
|
44
|
+
intentRef: columnNullableText(row, "intent_ref"),
|
|
45
|
+
phase: columnText(row, "phase"),
|
|
46
|
+
health: columnText(row, "health"),
|
|
47
|
+
healthReason: columnNullableText(row, "health_reason"),
|
|
48
|
+
terminalRevision: columnNumber(row, "terminal_revision"),
|
|
49
|
+
terminalOutcome: columnNullableText(row, "terminal_outcome"),
|
|
50
|
+
terminalEventId: columnNullableText(row, "terminal_event_id"),
|
|
51
|
+
terminalDetailLost: columnBoolean(row, "terminal_detail_lost"),
|
|
52
|
+
terminalReason: columnNullableText(row, "terminal_reason"),
|
|
53
|
+
createdAt: columnNumber(row, "created_at"),
|
|
54
|
+
updatedAt: columnNumber(row, "updated_at"),
|
|
55
|
+
terminalAt: columnNullableNumber(row, "terminal_at"),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export function readOperation(ctx, operationId) {
|
|
59
|
+
const row = getOperationRow(ctx, operationId);
|
|
60
|
+
return row ? mapOperation(row) : null;
|
|
61
|
+
}
|
|
62
|
+
export function requireOperation(ctx, operationId) {
|
|
63
|
+
const row = getOperationRow(ctx, operationId);
|
|
64
|
+
if (!row) {
|
|
65
|
+
throw new StoreError("unknown-operation", `No durable operation is registered as ${operationId}. Register the launch before reporting a terminal outcome or waiting on it.`);
|
|
66
|
+
}
|
|
67
|
+
return mapOperation(row);
|
|
68
|
+
}
|
|
69
|
+
export function mapOperationEvidence(row) {
|
|
70
|
+
const summary = columnNullableText(row, "summary");
|
|
71
|
+
const bytes = columnNullableNumber(row, "bytes");
|
|
72
|
+
const record = {
|
|
73
|
+
operationId: columnText(row, "operation_id"),
|
|
74
|
+
terminalRevision: columnNumber(row, "terminal_revision"),
|
|
75
|
+
ordinal: columnNumber(row, "ordinal"),
|
|
76
|
+
kind: columnText(row, "kind"),
|
|
77
|
+
ref: columnText(row, "ref"),
|
|
78
|
+
detailLost: columnBoolean(row, "detail_lost"),
|
|
79
|
+
capturedAt: columnNumber(row, "captured_at"),
|
|
80
|
+
};
|
|
81
|
+
if (summary !== null)
|
|
82
|
+
record.summary = summary;
|
|
83
|
+
if (bytes !== null)
|
|
84
|
+
record.bytes = bytes;
|
|
85
|
+
return record;
|
|
86
|
+
}
|
|
87
|
+
export function readOperationEvidence(ctx, operationId, terminalRevision) {
|
|
88
|
+
const rows = terminalRevision === undefined
|
|
89
|
+
? getRows(ctx, "SELECT * FROM operation_evidence WHERE operation_id = ? ORDER BY terminal_revision, ordinal", operationId)
|
|
90
|
+
: getRows(ctx, "SELECT * FROM operation_evidence WHERE operation_id = ? AND terminal_revision = ? ORDER BY ordinal", operationId, terminalRevision);
|
|
91
|
+
return rows.map(mapOperationEvidence);
|
|
92
|
+
}
|
|
93
|
+
// ---- waits --------------------------------------------------------------
|
|
94
|
+
export function getWaitRow(ctx, waitId, generation) {
|
|
95
|
+
return getRow(ctx, "SELECT * FROM waits WHERE wait_id = ? AND generation = ?", waitId, generation);
|
|
96
|
+
}
|
|
97
|
+
export function latestWaitGeneration(ctx, waitId) {
|
|
98
|
+
const row = getRow(ctx, "SELECT MAX(generation) AS generation FROM waits WHERE wait_id = ?", waitId);
|
|
99
|
+
if (!row)
|
|
100
|
+
return null;
|
|
101
|
+
const value = columnNullableNumber(row, "generation");
|
|
102
|
+
return value ?? null;
|
|
103
|
+
}
|
|
104
|
+
export function readWaitRow(ctx, waitId, generation) {
|
|
105
|
+
if (generation !== undefined)
|
|
106
|
+
return getWaitRow(ctx, waitId, generation) ?? null;
|
|
107
|
+
const latest = latestWaitGeneration(ctx, waitId);
|
|
108
|
+
if (latest === null)
|
|
109
|
+
return null;
|
|
110
|
+
return getWaitRow(ctx, waitId, latest) ?? null;
|
|
111
|
+
}
|
|
112
|
+
export function requireWaitRow(ctx, waitId, generation) {
|
|
113
|
+
const row = getWaitRow(ctx, waitId, generation);
|
|
114
|
+
if (!row) {
|
|
115
|
+
throw new StoreError("unknown-wait", `No wait generation ${generation} is registered for ${waitId}. Read the current generation before acting on it.`);
|
|
116
|
+
}
|
|
117
|
+
return row;
|
|
118
|
+
}
|
|
119
|
+
export function readDependencies(ctx, waitId, generation) {
|
|
120
|
+
return getRows(ctx, "SELECT * FROM wait_dependencies WHERE wait_id = ? AND generation = ? ORDER BY ordinal", waitId, generation).map((row) => ({
|
|
121
|
+
operationId: columnText(row, "operation_id"),
|
|
122
|
+
link: columnText(row, "link"),
|
|
123
|
+
terminalRevision: columnNumber(row, "terminal_revision"),
|
|
124
|
+
terminalOutcome: columnNullableText(row, "terminal_outcome"),
|
|
125
|
+
settledAt: columnNullableNumber(row, "settled_at"),
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
export function dependencyState(ctx, waitId, generation) {
|
|
129
|
+
const dependencies = readDependencies(ctx, waitId, generation);
|
|
130
|
+
const settled = dependencies.length > 0 && dependencies.every((dep) => dep.terminalRevision > 0);
|
|
131
|
+
const settledTimes = dependencies
|
|
132
|
+
.map((dep) => dep.settledAt)
|
|
133
|
+
.filter((value) => value !== null);
|
|
134
|
+
return {
|
|
135
|
+
dependencies,
|
|
136
|
+
settled,
|
|
137
|
+
settledAt: settled && settledTimes.length > 0 ? Math.max(...settledTimes) : null,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export function mapWait(ctx, row) {
|
|
141
|
+
const waitId = columnText(row, "wait_id");
|
|
142
|
+
const generation = columnNumber(row, "generation");
|
|
143
|
+
const state = dependencyState(ctx, waitId, generation);
|
|
144
|
+
const acknowledgement = columnJson(row, "acknowledgement_json");
|
|
145
|
+
return {
|
|
146
|
+
waitId,
|
|
147
|
+
generation,
|
|
148
|
+
owner: ownerFromRow(row),
|
|
149
|
+
phase: columnText(row, "phase"),
|
|
150
|
+
phaseReason: columnNullableText(row, "phase_reason"),
|
|
151
|
+
cancelEpoch: columnNumber(row, "cancel_epoch"),
|
|
152
|
+
continuationNote: columnText(row, "continuation_note"),
|
|
153
|
+
park: columnJson(row, "park_json"),
|
|
154
|
+
origin: columnJson(row, "origin_json"),
|
|
155
|
+
dependencies: state.dependencies,
|
|
156
|
+
settled: state.settled,
|
|
157
|
+
settledAt: state.settledAt,
|
|
158
|
+
acknowledgement: acknowledgement
|
|
159
|
+
? { ...acknowledgement, disposition: acknowledgement.disposition }
|
|
160
|
+
: null,
|
|
161
|
+
createdAt: columnNumber(row, "created_at"),
|
|
162
|
+
updatedAt: columnNumber(row, "updated_at"),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
export function readWait(ctx, waitId, generation) {
|
|
166
|
+
const row = readWaitRow(ctx, waitId, generation);
|
|
167
|
+
return row ? mapWait(ctx, row) : null;
|
|
168
|
+
}
|
|
169
|
+
export function requireWait(ctx, waitId, generation) {
|
|
170
|
+
return mapWait(ctx, requireWaitRow(ctx, waitId, generation));
|
|
171
|
+
}
|
|
172
|
+
// ---- resume claims ------------------------------------------------------
|
|
173
|
+
export function mapClaim(row) {
|
|
174
|
+
return {
|
|
175
|
+
claimId: columnText(row, "claim_id"),
|
|
176
|
+
claimToken: columnText(row, "claim_token"),
|
|
177
|
+
waitId: columnText(row, "wait_id"),
|
|
178
|
+
generation: columnNumber(row, "generation"),
|
|
179
|
+
cancelEpoch: columnNumber(row, "cancel_epoch"),
|
|
180
|
+
state: columnText(row, "state"),
|
|
181
|
+
attemptId: columnNullableText(row, "attempt_id"),
|
|
182
|
+
launchToken: columnNullableText(row, "launch_token"),
|
|
183
|
+
lease: columnJson(row, "lease_json") ?? { ownerId: "unknown" },
|
|
184
|
+
reservedCheckpointId: columnText(row, "reserved_checkpoint_id"),
|
|
185
|
+
claimedAt: columnNumber(row, "claimed_at"),
|
|
186
|
+
publishedAt: columnNullableNumber(row, "published_at"),
|
|
187
|
+
releasedAt: columnNullableNumber(row, "released_at"),
|
|
188
|
+
invalidatedAt: columnNullableNumber(row, "invalidated_at"),
|
|
189
|
+
reason: columnNullableText(row, "reason"),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
export function readClaim(ctx, claimId) {
|
|
193
|
+
const row = getRow(ctx, "SELECT * FROM resume_claims WHERE claim_id = ?", claimId);
|
|
194
|
+
return row ? mapClaim(row) : null;
|
|
195
|
+
}
|
|
196
|
+
export function readActiveClaim(ctx, waitId, generation) {
|
|
197
|
+
const row = getRow(ctx, "SELECT * FROM resume_claims WHERE wait_id = ? AND generation = ? AND state IN ('claimed', 'published')", waitId, generation);
|
|
198
|
+
return row ? mapClaim(row) : null;
|
|
199
|
+
}
|
|
200
|
+
export function requireClaim(ctx, claimId) {
|
|
201
|
+
const claim = readClaim(ctx, claimId);
|
|
202
|
+
if (!claim) {
|
|
203
|
+
throw new StoreError("claim-state", `No resume claim ${claimId} is recorded. Claims are created by claimResume and are not caller-supplied.`);
|
|
204
|
+
}
|
|
205
|
+
return claim;
|
|
206
|
+
}
|
|
207
|
+
// ---- evidence reads and pins -------------------------------------------
|
|
208
|
+
export function mapEvidenceRead(row) {
|
|
209
|
+
return {
|
|
210
|
+
waitId: columnText(row, "wait_id"),
|
|
211
|
+
generation: columnNumber(row, "generation"),
|
|
212
|
+
operationId: columnText(row, "operation_id"),
|
|
213
|
+
terminalRevision: columnNumber(row, "terminal_revision"),
|
|
214
|
+
reader: {
|
|
215
|
+
kind: columnText(row, "reader_kind"),
|
|
216
|
+
sessionId: columnText(row, "reader_session_id"),
|
|
217
|
+
workspace: columnText(row, "reader_workspace"),
|
|
218
|
+
branchId: columnNullableText(row, "reader_branch_id"),
|
|
219
|
+
goalId: columnNullableText(row, "reader_goal_id"),
|
|
220
|
+
},
|
|
221
|
+
readAt: columnNumber(row, "read_at"),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
export function mapEvidencePin(row) {
|
|
225
|
+
return {
|
|
226
|
+
pinId: columnText(row, "pin_id"),
|
|
227
|
+
waitId: columnText(row, "wait_id"),
|
|
228
|
+
generation: columnNumber(row, "generation"),
|
|
229
|
+
operationId: columnText(row, "operation_id"),
|
|
230
|
+
terminalRevision: columnNumber(row, "terminal_revision"),
|
|
231
|
+
kind: columnText(row, "kind"),
|
|
232
|
+
ref: columnText(row, "ref"),
|
|
233
|
+
summary: columnNullableText(row, "summary"),
|
|
234
|
+
detailLost: columnBoolean(row, "detail_lost"),
|
|
235
|
+
bytes: columnNullableNumber(row, "bytes"),
|
|
236
|
+
pinnedAt: columnNumber(row, "pinned_at"),
|
|
237
|
+
releasedAt: columnNullableNumber(row, "released_at"),
|
|
238
|
+
releaseReason: columnNullableText(row, "release_reason"),
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
export function readPins(ctx, waitId, generation, includeReleased) {
|
|
242
|
+
const rows = includeReleased
|
|
243
|
+
? getRows(ctx, "SELECT * FROM evidence_pins WHERE wait_id = ? AND generation = ? ORDER BY pinned_at, pin_id", waitId, generation)
|
|
244
|
+
: getRows(ctx, "SELECT * FROM evidence_pins WHERE wait_id = ? AND generation = ? AND released_at IS NULL ORDER BY pinned_at, pin_id", waitId, generation);
|
|
245
|
+
return rows.map(mapEvidencePin);
|
|
246
|
+
}
|
|
247
|
+
export function readPinsForRevision(ctx, waitId, generation, operationId, terminalRevision) {
|
|
248
|
+
return getRows(ctx, `SELECT * FROM evidence_pins
|
|
249
|
+
WHERE wait_id = ? AND generation = ? AND operation_id = ? AND terminal_revision = ?
|
|
250
|
+
ORDER BY pinned_at, pin_id`, waitId, generation, operationId, terminalRevision).map(mapEvidencePin);
|
|
251
|
+
}
|
|
252
|
+
// ---- outbox -------------------------------------------------------------
|
|
253
|
+
export function mapOutbox(ctx, row) {
|
|
254
|
+
const waitId = columnText(row, "wait_id");
|
|
255
|
+
const generation = columnNumber(row, "generation");
|
|
256
|
+
const operationId = columnText(row, "operation_id");
|
|
257
|
+
const terminalRevision = columnNumber(row, "terminal_revision");
|
|
258
|
+
return {
|
|
259
|
+
eventId: columnText(row, "event_id"),
|
|
260
|
+
type: columnText(row, "event_type"),
|
|
261
|
+
operationId,
|
|
262
|
+
terminalRevision,
|
|
263
|
+
waitId,
|
|
264
|
+
generation,
|
|
265
|
+
recipient: ownerFromRow(row, "recipient"),
|
|
266
|
+
evidence: row.event_type === "assignment-outcome" ? readPins(ctx, waitId, generation, false) : readPinsForRevision(ctx, waitId, generation, operationId, terminalRevision),
|
|
267
|
+
state: columnText(row, "state"),
|
|
268
|
+
attempts: columnNumber(row, "attempts"),
|
|
269
|
+
dispatchClaim: columnJson(row, "dispatch_claim_json"),
|
|
270
|
+
createdAt: columnNumber(row, "created_at"),
|
|
271
|
+
claimedAt: columnNullableNumber(row, "claimed_at"),
|
|
272
|
+
deliveredAt: columnNullableNumber(row, "delivered_at"),
|
|
273
|
+
acknowledgedAt: columnNullableNumber(row, "acknowledged_at"),
|
|
274
|
+
voidedAt: columnNullableNumber(row, "voided_at"),
|
|
275
|
+
reason: columnNullableText(row, "reason"),
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
export function readOutboxRow(ctx, eventId) {
|
|
279
|
+
return getRow(ctx, "SELECT * FROM outbox_events WHERE event_id = ?", eventId) ?? null;
|
|
280
|
+
}
|