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
|
@@ -1,45 +1,120 @@
|
|
|
1
1
|
import { processMatchesStart } from "../daemon-owner.ts";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import { readFileSync, statSync } from "node:fs";
|
|
3
|
+
import { readFileSync, statSync, mkdirSync, watch, type FSWatcher } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
6
6
|
// @ts-expect-error Generated canonical passive runner observation.
|
|
7
7
|
import { snapshot } from "./domain/background/snapshot.mjs";
|
|
8
8
|
// @ts-expect-error Generated canonical registry queries.
|
|
9
|
-
import { observeMetasForOrigin, belongsToOrigin, readMeta } from "./domain/background/registry.mjs";
|
|
9
|
+
import { observeMetasForOrigin, observeRecentMetasForOrigin, recentMetaDeadline, observationRevisionForOrigin, belongsToOrigin, readMeta, getRegistryIoMetrics } from "./domain/background/registry.mjs";
|
|
10
10
|
import { BackgroundHistory } from "./background-history.ts";
|
|
11
11
|
import type { WorkScope } from "./read-model.ts";
|
|
12
|
+
import { ENTITY_BUDGET } from "./work-budget.ts";
|
|
13
|
+
import { isSqliteLockContention } from "./log-checkpoints.ts";
|
|
14
|
+
// @ts-expect-error Shared durable observation inbox, not execution authority.
|
|
15
|
+
import { AssignmentInbox } from "./domain/assignment-inbox.mjs";
|
|
16
|
+
|
|
17
|
+
type BackgroundScope = { origin: { cwd: string; sessionId?: string }; rows: any[]; references: number;
|
|
18
|
+
pending: any[]; pendingRevision?: number; recent: any[]; recentRevision?: number };
|
|
19
|
+
const DISCOVERY_PAGE_SIZE = 256;
|
|
20
|
+
const malformedHistoryContext = Symbol("malformed terminal history context");
|
|
12
21
|
|
|
13
22
|
/** Root-owned query connection; never opens a supervisor or mutates source facts. */
|
|
14
23
|
export class BackgroundObservation {
|
|
15
|
-
private
|
|
24
|
+
private ownDb: any;
|
|
25
|
+
private readConnection?: (refresh?: boolean) => any;
|
|
26
|
+
private get db(): any { return this.readConnection ? this.readConnection(false) : this.ownDb; }
|
|
27
|
+
private get observationActive() { return Boolean(this.db?.observationActive); }
|
|
16
28
|
private identity?: string;
|
|
17
29
|
private knownCoordinator = false;
|
|
18
30
|
private rows: any[] = [];
|
|
31
|
+
private terminalProjections = new Map<string, { version: string; authority: string; operation: any; inspection: any; row: any; dependencyVersion?: number }>();
|
|
32
|
+
private hasInputVersions = false;
|
|
33
|
+
private inbox: any;
|
|
34
|
+
private indexDb: any;
|
|
35
|
+
private initialized = false;
|
|
36
|
+
get ready() { return this.initialized && !this.closed; }
|
|
37
|
+
private dirtyOperations = new Set<string>();
|
|
38
|
+
private scopeVersions = new Map<string, number>();
|
|
39
|
+
private watchers = new Map<string, FSWatcher>();
|
|
40
|
+
private repairAfter = "";
|
|
41
|
+
private repairIds = new Set<string>();
|
|
42
|
+
private changedOperations = new Map<string, any>();
|
|
43
|
+
private scheduled = false;
|
|
44
|
+
private expiry?: ReturnType<typeof setTimeout>;
|
|
45
|
+
private closed = false;
|
|
46
|
+
private repairComplete = false;
|
|
47
|
+
private changed: () => void;
|
|
19
48
|
private signature = "";
|
|
20
49
|
private root: string;
|
|
21
50
|
private directory: string;
|
|
22
51
|
private enabled = false;
|
|
52
|
+
private allRequested = false;
|
|
23
53
|
private history?: BackgroundHistory;
|
|
24
|
-
private legacy = new Map<string,
|
|
25
|
-
|
|
54
|
+
private legacy = new Map<string, BackgroundScope>();
|
|
55
|
+
private recentRevision?: number;
|
|
56
|
+
private recent: any[] = [];
|
|
57
|
+
status: "ready" | "rebuilding" | "degraded" = "rebuilding";
|
|
26
58
|
reason?: string;
|
|
27
|
-
get connectionCount() { return this.
|
|
59
|
+
get connectionCount() { return this.readConnection ? 0 : this.ownDb ? 1 : 0; }
|
|
28
60
|
get scopeCount() { return this.legacy.size; }
|
|
61
|
+
prepareQuery(): void {
|
|
62
|
+
if (!this.ready) return;
|
|
63
|
+
if (this.observationActive) return;
|
|
64
|
+
if (!this.enabled || !this.db || !this.hasInputVersions) return;
|
|
65
|
+
// Native mutations can commit between the last scheduled observation and
|
|
66
|
+
// the next list. Reuse the durable bounded inbox before cache validation.
|
|
67
|
+
const batch = this.inbox.receive(this.db, this.identity);
|
|
68
|
+
if (batch.size && this.refresh()) this.changed();
|
|
69
|
+
if (this.inbox.metrics.more || this.inbox.metrics.pending) this.schedule();
|
|
70
|
+
}
|
|
71
|
+
sourceRevision(scope: WorkScope): string[] {
|
|
72
|
+
if (!this.ready) return [];
|
|
73
|
+
if (!scope.cwd) return [];
|
|
74
|
+
return [observationRevisionForOrigin({ cwd: scope.cwd, sessionId: scope.sessionId }),
|
|
75
|
+
...(scope.sessionId ? [observationRevisionForOrigin({ cwd: scope.cwd })] : [])];
|
|
76
|
+
}
|
|
77
|
+
nextDeadline(scope: WorkScope): number | null {
|
|
78
|
+
if (!this.ready) return null;
|
|
79
|
+
if (!scope.cwd) return null;
|
|
80
|
+
const deadlines = [...recentMetaDeadline({ cwd: scope.cwd, sessionId: scope.sessionId }),
|
|
81
|
+
...(scope.sessionId ? recentMetaDeadline({ cwd: scope.cwd }) : [])];
|
|
82
|
+
return deadlines.length ? Math.min(...deadlines) : null;
|
|
83
|
+
}
|
|
84
|
+
get registryMetrics() { return getRegistryIoMetrics(); }
|
|
85
|
+
private get inboxMetrics() {
|
|
86
|
+
if (this.ready) {
|
|
87
|
+
try { return this.inbox.metrics; }
|
|
88
|
+
catch (error) { if (!isSqliteLockContention(error)) throw error; }
|
|
89
|
+
}
|
|
90
|
+
return { available: false, received: null, applied: null, pending: null };
|
|
91
|
+
}
|
|
92
|
+
get changeMetrics() { const metrics = this.inboxMetrics, available = this.ready && metrics.available !== false;
|
|
93
|
+
return { ...metrics, coverage: this.hasInputVersions ? "cooperative-journal-and-exact-files" : "legacy-bounded-repair",
|
|
94
|
+
operationRepairComplete: available && this.repairComplete, repairAfter: available ? this.repairAfter : null, queuedHints: this.dirtyOperations.size,
|
|
95
|
+
fileCoverage: "active-and-retained; historical-files-only-when-history-requested" }; }
|
|
29
96
|
livenessReasons(options: { refresh?: boolean } = {}) {
|
|
97
|
+
if (!this.ready) throw new Error("Background inbox coverage is unverified");
|
|
30
98
|
if (options.refresh !== false) {
|
|
31
99
|
this.enabled = true;
|
|
32
100
|
this.refresh();
|
|
33
101
|
}
|
|
34
102
|
if (!this.db) return [];
|
|
35
|
-
const version = this.db.prepare("SELECT value FROM schema_meta WHERE key = 'schema_version'").get()?.value;
|
|
36
|
-
if (!["1", "2", "3", "4"].includes(version)) return [];
|
|
37
103
|
let operations: any[] = [];
|
|
38
|
-
try {
|
|
104
|
+
try {
|
|
105
|
+
// The file may be visible before its writer commits the initial schema.
|
|
106
|
+
// Keep publication alive and report unverified background state until refresh.
|
|
107
|
+
const version = this.db.prepare("SELECT value FROM schema_meta WHERE key = 'schema_version'").get()?.value;
|
|
108
|
+
if (!["1", "2", "3", "4"].includes(version)) return [];
|
|
109
|
+
operations = this.db.prepare("SELECT * FROM operations WHERE phase = 'running' AND observer_kind = 'local-supervisor' AND terminal_revision = 0").all();
|
|
110
|
+
}
|
|
39
111
|
catch (error) { this.status = "degraded"; this.reason = String(error); return []; }
|
|
40
112
|
return operations.flatMap((op: any) => {
|
|
41
113
|
try {
|
|
42
|
-
const
|
|
114
|
+
const directory = this.directoryFor(op);
|
|
115
|
+
const cached = this.terminalProjections.get(op.operation_id);
|
|
116
|
+
const inspection = cached?.authority === JSON.stringify([op, directory]) ? cached.inspection : snapshot(directory, op.task_id);
|
|
117
|
+
if (!cached || cached.authority !== JSON.stringify([op, directory])) this.metrics.runnerSnapshots++;
|
|
43
118
|
const claim = inspection?.claim;
|
|
44
119
|
return claim && !inspection.terminal && inspection.token === op.launch_token && processMatchesStart(claim.pid, claim.pidStartTime)
|
|
45
120
|
? [{ kind: "runner", id: op.task_id, owner: { kind: op.owner_kind, sessionId: op.owner_session_id, workspace: op.owner_workspace }, operationId: op.operation_id,
|
|
@@ -49,7 +124,39 @@ export class BackgroundObservation {
|
|
|
49
124
|
} catch (error) { this.status = "degraded"; this.reason = String(error); return []; }
|
|
50
125
|
});
|
|
51
126
|
}
|
|
52
|
-
readonly metrics = { runnerSnapshots: 0, activeQueries: 0, historyQueries: 0
|
|
127
|
+
readonly metrics = { runnerSnapshots: 0, activeQueries: 0, historyQueries: 0, inputStats: 0, dependencyQueries: 0, projectionHits: 0,
|
|
128
|
+
repairEntries: 0, exactHints: 0, journalEntities: 0, overflows: 0, activeRows: 0, exactOperationQueries: 0,
|
|
129
|
+
sourceWork: { active: { stats: 0, waits: 0, snapshots: 0 }, repair: { stats: 0, waits: 0, snapshots: 0 }, history: { stats: 0, waits: 0, snapshots: 0 } } };
|
|
130
|
+
private schedule() {
|
|
131
|
+
if (!this.ready || this.scheduled) return;
|
|
132
|
+
this.scheduled = true;
|
|
133
|
+
setImmediate(() => { this.scheduled = false; if (!this.closed && this.refresh()) this.changed(); });
|
|
134
|
+
}
|
|
135
|
+
private oweRepair() {
|
|
136
|
+
this.inbox.db.prepare(`INSERT OR REPLACE INTO ${this.inbox.prefix}background_file_repair VALUES(1,?,'',0)`).run(this.identity ?? "");
|
|
137
|
+
this.repairAfter = ""; this.repairComplete = false;
|
|
138
|
+
}
|
|
139
|
+
private observeDirectory(directory: string) {
|
|
140
|
+
if (this.watchers.has(directory)) return;
|
|
141
|
+
try {
|
|
142
|
+
const watcher = watch(directory, { recursive: true }, (_event, file) => {
|
|
143
|
+
if (this.closed) return;
|
|
144
|
+
const match = file && /^(?:observed[/\\]([^/\\]+)\.json|tasks[/\\]([^/\\]+)[/\\](?:launch|claim|command|result|lost|stop|cleanup)\.json)$/.exec(String(file));
|
|
145
|
+
if (match) {
|
|
146
|
+
const op = this.db?.prepare("SELECT operation_id FROM operations WHERE task_id=? AND observer_kind='local-supervisor'").get(match[1] ?? match[2]);
|
|
147
|
+
if (op) {
|
|
148
|
+
if (this.dirtyOperations.size < 256) this.dirtyOperations.add(op.operation_id);
|
|
149
|
+
else { this.oweRepair(); this.metrics.overflows++; }
|
|
150
|
+
this.history?.invalidateOperation(op.operation_id); this.metrics.exactHints++;
|
|
151
|
+
}
|
|
152
|
+
} else if (!file) { this.oweRepair(); this.metrics.overflows++; }
|
|
153
|
+
else return;
|
|
154
|
+
this.schedule();
|
|
155
|
+
});
|
|
156
|
+
watcher.on("error", () => { watcher.close(); this.watchers.delete(directory); this.status = "degraded"; this.reason = "Background watcher failed; bounded repair required"; this.oweRepair(); this.schedule(); });
|
|
157
|
+
this.watchers.set(directory, watcher);
|
|
158
|
+
} catch (error) { if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error; }
|
|
159
|
+
}
|
|
53
160
|
private directoryFor(op: any): string {
|
|
54
161
|
if (!op.supervision_host_id?.startsWith("server:")) return this.directory;
|
|
55
162
|
const row = this.db.prepare("SELECT value FROM coordinator_state WHERE key = ?").get(`result-supervision-v1:${op.operation_id}`);
|
|
@@ -58,82 +165,315 @@ export class BackgroundObservation {
|
|
|
58
165
|
if (grant.launchToken !== op.launch_token || typeof grant.directory !== "string") throw new Error("Captured runner execution identity differs");
|
|
59
166
|
return grant.directory;
|
|
60
167
|
}
|
|
61
|
-
constructor(root: string, directory = join(tmpdir(), process.env.VITEST_POOL_ID ? `pi-better-background-tasks-vitest-${process.env.VITEST_POOL_ID}` : "pi-better-background-tasks", "supervisor"), indexDb?: any, changed = () => {}) {
|
|
168
|
+
constructor(root: string, directory = join(tmpdir(), process.env.VITEST_POOL_ID ? `pi-better-background-tasks-vitest-${process.env.VITEST_POOL_ID}` : "pi-better-background-tasks", "supervisor"), indexDb?: any, changed = () => {}, readConnection?: (refresh?: boolean) => any, options: { defer?: boolean } = {}) {
|
|
169
|
+
this.readConnection = readConnection;
|
|
170
|
+
this.changed = changed;
|
|
62
171
|
this.root = root; this.directory = directory;
|
|
172
|
+
this.indexDb = indexDb;
|
|
173
|
+
mkdirSync(join(root, "runtime-read-repair"), { recursive: true });
|
|
174
|
+
// Create the owner's in-memory history tables once, never per acquisition attempt.
|
|
63
175
|
if (indexDb) this.history = new BackgroundHistory(indexDb, directory, () => {
|
|
176
|
+
if (!this.ready) throw new Error("Background inbox coverage is unverified");
|
|
64
177
|
if (this.status === "degraded") throw new Error(this.reason);
|
|
65
178
|
return this.db;
|
|
66
|
-
}, operations => this.project(operations), changed);
|
|
179
|
+
}, operations => this.project(operations, false), changed, op => this.directoryFor(op));
|
|
180
|
+
if (!options.defer) this.initialize();
|
|
181
|
+
}
|
|
182
|
+
initialize(): void {
|
|
183
|
+
if (this.closed) throw new Error("Background observation is closed");
|
|
184
|
+
if (this.ready) return;
|
|
185
|
+
if (this.indexDb?.isTransaction) throw new Error("Background initialization requires an unpinned owner");
|
|
186
|
+
if (this.inbox) throw new Error("Background inbox cleanup is incomplete");
|
|
187
|
+
const inbox = this.indexDb
|
|
188
|
+
? new AssignmentInbox(join(this.root, "runtime-read-repair", "background.sqlite"), this.indexDb, { entityPrefix: "background:" })
|
|
189
|
+
: new AssignmentInbox(join(this.root, "runtime-read-repair", "background.sqlite"), { entityPrefix: "background:" });
|
|
190
|
+
try {
|
|
191
|
+
inbox.db.exec(`CREATE TABLE IF NOT EXISTS ${inbox.prefix}background_file_repair(singleton INTEGER PRIMARY KEY CHECK(singleton=1), identity TEXT, after_id TEXT, complete INTEGER)`);
|
|
192
|
+
const repair = inbox.db.prepare(`SELECT * FROM ${inbox.prefix}background_file_repair WHERE singleton=1`).get();
|
|
193
|
+
if (repair) { this.identity = repair.identity || undefined; this.knownCoordinator = Boolean(this.identity); this.repairAfter = repair.after_id; this.repairComplete = Boolean(repair.complete); }
|
|
194
|
+
this.inbox = inbox;
|
|
195
|
+
this.initialized = true;
|
|
196
|
+
} catch (error) {
|
|
197
|
+
try { inbox.close(); }
|
|
198
|
+
catch (cleanup) {
|
|
199
|
+
this.inbox = inbox;
|
|
200
|
+
throw new AggregateError([error, cleanup], "Background initialization and owned cleanup failed");
|
|
201
|
+
}
|
|
202
|
+
throw error;
|
|
203
|
+
}
|
|
67
204
|
}
|
|
68
205
|
refresh(): boolean {
|
|
206
|
+
if (!this.ready) return false;
|
|
207
|
+
if (this.observationActive) return false;
|
|
69
208
|
if (!this.enabled) return false;
|
|
209
|
+
let observation: { commit(): void; release(): void } | undefined;
|
|
210
|
+
const previous = { rows: this.rows, signature: this.signature, legacy: new Map([...this.legacy].map(([key, value]) => [key, { ...value }])),
|
|
211
|
+
terminalProjections: new Map(this.terminalProjections), scopeVersions: new Map(this.scopeVersions), recent: this.recent,
|
|
212
|
+
recentRevision: this.recentRevision, repairAfter: this.repairAfter, repairComplete: this.repairComplete,
|
|
213
|
+
dirtyOperations: new Set(this.dirtyOperations), changedOperations: new Map(this.changedOperations) };
|
|
70
214
|
try {
|
|
71
215
|
const { DatabaseSync } = createRequire(import.meta.url)("node:sqlite");
|
|
72
216
|
const path = join(this.root, "operation-coordinator.sqlite");
|
|
73
217
|
let identity;
|
|
74
218
|
try { const info = statSync(path, { bigint: true }); identity = `${info.dev}:${info.ino}`; }
|
|
75
219
|
catch (error) { if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error; }
|
|
76
|
-
if (identity !== this.identity) { this.history?.invalidate(); this.
|
|
220
|
+
if (identity !== this.identity) { this.repairAfter = ""; this.repairComplete = false; this.scopeVersions.clear(); this.terminalProjections.clear(); this.recentRevision = undefined; this.recent = []; for (const entry of this.legacy.values()) { entry.pendingRevision = undefined; entry.recentRevision = undefined; entry.recent = []; } this.history?.invalidate(); this.ownDb?.close(); this.ownDb = undefined; this.identity = identity; }
|
|
77
221
|
if (!identity && this.knownCoordinator) throw new Error("Coordinator source disappeared; retaining the previous observation");
|
|
78
222
|
if (identity) {
|
|
79
|
-
this.
|
|
223
|
+
if (this.readConnection) {
|
|
224
|
+
const source = this.readConnection();
|
|
225
|
+
observation = source?.beginSnapshot?.();
|
|
226
|
+
}
|
|
227
|
+
else this.ownDb ??= new DatabaseSync(path, { readOnly: true });
|
|
80
228
|
this.knownCoordinator = true;
|
|
81
229
|
const version = this.db.prepare("SELECT value FROM schema_meta WHERE key = 'schema_version'").get()?.value;
|
|
82
230
|
if (!["1", "2", "3", "4"].includes(version)) throw new Error("Unsupported coordinator schema");
|
|
231
|
+
this.hasInputVersions = Boolean(this.db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='background_input_versions'").get());
|
|
83
232
|
}
|
|
84
233
|
this.metrics.activeQueries++;
|
|
234
|
+
let batch: any;
|
|
235
|
+
if (this.db && this.hasInputVersions) {
|
|
236
|
+
batch = this.inbox.receive(this.db, this.identity);
|
|
237
|
+
for (const [scope, seq] of batch) if (scope !== "*") {
|
|
238
|
+
const [session, workspace, operationId] = JSON.parse(scope);
|
|
239
|
+
this.dirtyOperations.add(operationId);
|
|
240
|
+
this.scopeVersions.set(JSON.stringify([workspace, session]), Number(seq));
|
|
241
|
+
this.history?.invalidateOperation(operationId);
|
|
242
|
+
this.metrics.journalEntities++;
|
|
243
|
+
}
|
|
244
|
+
if (batch.has("*")) { this.terminalProjections.clear(); this.recentRevision = undefined; for (const entry of this.legacy.values()) { entry.recentRevision = undefined; entry.pendingRevision = undefined; } this.history?.invalidate(); }
|
|
245
|
+
}
|
|
246
|
+
const revision = this.hasInputVersions ? Math.max(0, ...this.scopeVersions.values())
|
|
247
|
+
: Number(this.db?.prepare("SELECT value FROM coordinator_state WHERE key = 'change_revision'").get()?.value ?? 0);
|
|
248
|
+
this.repairIds.clear();
|
|
249
|
+
if (this.db) {
|
|
250
|
+
const repair = this.db.prepare("SELECT operation_id FROM operations WHERE observer_kind='local-supervisor' AND operation_id>? ORDER BY operation_id LIMIT ?").all(this.repairAfter, ENTITY_BUDGET);
|
|
251
|
+
for (const op of repair) { this.repairIds.add(op.operation_id); this.metrics.repairEntries++; }
|
|
252
|
+
this.repairAfter = repair.length === ENTITY_BUDGET ? repair.at(-1).operation_id : "";
|
|
253
|
+
if (!this.repairAfter) this.repairComplete = true;
|
|
254
|
+
const saved = this.inbox.db.prepare(`SELECT * FROM ${this.inbox.prefix}background_file_repair WHERE singleton=1`).get();
|
|
255
|
+
if (!saved || saved.identity !== (this.identity ?? "") || saved.after_id !== this.repairAfter || saved.complete !== Number(this.repairComplete))
|
|
256
|
+
this.inbox.db.prepare(`INSERT OR REPLACE INTO ${this.inbox.prefix}background_file_repair VALUES(1,?,?,?)`).run(this.identity ?? "", this.repairAfter, Number(this.repairComplete));
|
|
257
|
+
}
|
|
258
|
+
const hasPendingIndex = Boolean(this.db?.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='background_parent_callbacks'").get());
|
|
259
|
+
this.changedOperations.clear();
|
|
260
|
+
if (this.db) for (const id of new Set([...this.dirtyOperations, ...this.repairIds])) {
|
|
261
|
+
this.metrics.exactOperationQueries++;
|
|
262
|
+
this.changedOperations.set(id, this.db.prepare("SELECT * FROM operations WHERE operation_id=?").get(id));
|
|
263
|
+
}
|
|
85
264
|
const operations = this.db ? this.db.prepare("SELECT * FROM operations WHERE phase = 'running' AND observer_kind = 'local-supervisor'").all() : [];
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
265
|
+
this.metrics.activeRows += operations.length;
|
|
266
|
+
// Active snapshots retain a bounded recent window. Complete history is
|
|
267
|
+
// available through the separately paginated history index.
|
|
268
|
+
if (this.allRequested && this.db && (this.recentRevision === undefined || !this.hasInputVersions && this.recentRevision !== revision)) {
|
|
269
|
+
this.recent = this.db.prepare(`SELECT * FROM operations WHERE observer_kind='local-supervisor'
|
|
270
|
+
AND terminal_at >= ? AND terminal_revision > 0
|
|
271
|
+
ORDER BY terminal_at DESC, operation_id DESC LIMIT ?`).all(Date.now() - 30000, DISCOVERY_PAGE_SIZE);
|
|
272
|
+
this.recentRevision = revision;
|
|
273
|
+
} else if (this.allRequested) {
|
|
274
|
+
const recent = new Map(this.recent.map(op => [op.operation_id, op]));
|
|
275
|
+
for (const [id, op] of this.changedOperations) {
|
|
276
|
+
if (op?.observer_kind === "local-supervisor" && op.terminal_revision > 0 && Date.now() - op.terminal_at < 30000) recent.set(id, op);
|
|
277
|
+
else recent.delete(id);
|
|
278
|
+
}
|
|
279
|
+
this.recent = [...recent.values()].sort((a, b) => b.terminal_at - a.terminal_at || b.operation_id.localeCompare(a.operation_id)).slice(0, DISCOVERY_PAGE_SIZE);
|
|
280
|
+
this.recentRevision = revision;
|
|
92
281
|
}
|
|
282
|
+
this.recent = this.recent.filter(op => Date.now() - op.terminal_at < 30000);
|
|
283
|
+
operations.push(...this.recent);
|
|
93
284
|
const rows = this.project(operations);
|
|
285
|
+
// A passive runner may finish before its manager publishes the outcome.
|
|
286
|
+
// Invalidate history on that exact state transition, not on scope/projection
|
|
287
|
+
// churn (which would continually restart a yielding history build).
|
|
288
|
+
const previousRows = new Map(this.rows.map(row => [row.id, row]));
|
|
289
|
+
for (const row of rows) { const previous = previousRows.get(row.id); if (previous
|
|
290
|
+
&& (previous.status !== row.status || previous.active !== row.active)) this.history?.invalidateOperation(row.operationId); }
|
|
94
291
|
for (const entry of this.legacy.values()) {
|
|
95
|
-
const
|
|
292
|
+
const scopedRevision = this.hasInputVersions ? this.scopeVersions.get(JSON.stringify([entry.origin.cwd, entry.origin.sessionId])) ?? 0 : revision;
|
|
293
|
+
if (hasPendingIndex) this.refreshPending(entry, scopedRevision);
|
|
294
|
+
this.refreshRecent(entry, scopedRevision);
|
|
295
|
+
const active = this.visibleLegacy(entry.origin);
|
|
96
296
|
const retained = entry.rows.map(row => readMeta(row.id)).filter((row: any) => row && row.dismissedAt === undefined
|
|
97
297
|
&& row.status !== "running" && (!row.endedAt || Date.now() - row.endedAt < 30000));
|
|
98
|
-
entry.rows = [...
|
|
298
|
+
entry.rows = [...new Map([...retained, ...active].map(row => [row.id, row])).values()];
|
|
99
299
|
}
|
|
100
|
-
const signature = JSON.stringify([rows, [...this.legacy.values()].flatMap(entry => entry.rows).sort((a, b) => a.id.localeCompare(b.id))]);
|
|
300
|
+
const signature = JSON.stringify([rows, [...this.legacy.values()].flatMap(entry => [...entry.rows, ...entry.recent, ...this.pendingRows(entry)]).sort((a, b) => a.id.localeCompare(b.id))]);
|
|
101
301
|
const changed = signature !== this.signature || this.status !== "ready";
|
|
102
|
-
|
|
302
|
+
// Projection churn must not cancel a yielding history build. Its own
|
|
303
|
+
// source versions and watchers invalidate only changed source facts.
|
|
103
304
|
this.rows = rows; this.signature = signature; this.status = "ready"; this.reason = undefined;
|
|
305
|
+
// History's source fence must see this newly verified observation, not
|
|
306
|
+
// reject recovery because the previous pass found a partial legacy write.
|
|
307
|
+
for (const id of this.repairIds) this.history?.repairOperation(this.changedOperations.get(id), id);
|
|
104
308
|
this.history?.reconcile();
|
|
309
|
+
if (batch) this.inbox.acknowledge(batch, true);
|
|
310
|
+
this.dirtyOperations.clear();
|
|
311
|
+
if (this.inbox.metrics.more || this.inbox.metrics.pending) this.schedule();
|
|
312
|
+
if (this.expiry) clearTimeout(this.expiry);
|
|
313
|
+
const deadlines = [...this.recent.map(op => op.terminal_at + 30000), ...[...this.legacy.values()].flatMap(entry => [
|
|
314
|
+
...entry.recent.map(row => row.endedAt + 30000), ...recentMetaDeadline(entry.origin),
|
|
315
|
+
...(entry.origin.sessionId ? recentMetaDeadline({ cwd: entry.origin.cwd }) : [])])].filter(Number.isFinite);
|
|
316
|
+
if (deadlines.length) { this.expiry = setTimeout(() => this.schedule(), Math.max(1, Math.min(...deadlines) - Date.now())); this.expiry.unref(); }
|
|
317
|
+
observation?.commit();
|
|
105
318
|
return changed;
|
|
106
319
|
} catch (error) {
|
|
320
|
+
observation?.release();
|
|
321
|
+
Object.assign(this, previous);
|
|
107
322
|
const reason = String(error);
|
|
108
323
|
const changed = this.status !== "degraded" || this.reason !== reason;
|
|
109
324
|
this.status = "degraded"; this.reason = reason;
|
|
110
325
|
return changed;
|
|
326
|
+
} finally { observation?.release(); }
|
|
327
|
+
}
|
|
328
|
+
/** Captured assignment, never the newest assignment in a reused conversation. */
|
|
329
|
+
private workerParent(op: any, context: any): any {
|
|
330
|
+
if (op.owner_kind !== "worker-conversation") return undefined;
|
|
331
|
+
if (!this.db.prepare("SELECT 1 FROM sqlite_master WHERE name='assignment_bindings'").get()) return undefined;
|
|
332
|
+
let bindings: any[];
|
|
333
|
+
if (typeof context.workerAttemptId === "string") {
|
|
334
|
+
bindings = this.db.prepare(`SELECT b.* FROM assignment_bindings b JOIN assignment_attempts a
|
|
335
|
+
ON a.assignment_id=b.assignment_id WHERE a.attempt_id=?`).all(context.workerAttemptId);
|
|
336
|
+
} else {
|
|
337
|
+
// Older launches are visible only when a durable wait proves the assignment.
|
|
338
|
+
bindings = this.db.prepare(`SELECT DISTINCT b.* FROM assignment_bindings b JOIN waits w
|
|
339
|
+
ON json_extract(w.origin_json,'$.assignmentRef')=b.assignment_id
|
|
340
|
+
JOIN wait_dependencies d ON d.wait_id=w.wait_id AND d.generation=w.generation
|
|
341
|
+
WHERE d.operation_id=?`).all(op.operation_id);
|
|
111
342
|
}
|
|
343
|
+
if (bindings.length !== 1) return undefined;
|
|
344
|
+
const owner = JSON.parse(bindings[0].owner_json), recipient = JSON.parse(bindings[0].recipient_json);
|
|
345
|
+
if (owner.kind !== op.owner_kind || owner.sessionId !== op.owner_session_id || owner.workspace !== op.owner_workspace
|
|
346
|
+
|| (owner.branchId ?? null) !== (op.owner_branch_id ?? null) || (owner.goalId ?? null) !== (op.owner_goal_id ?? null) || recipient.kind !== "parent-session") return undefined;
|
|
347
|
+
return {parentAgentId: owner.sessionId, parentRecipient: recipient, readOnly: true};
|
|
112
348
|
}
|
|
113
|
-
private project(operations: any[]) {
|
|
349
|
+
private project(operations: any[], useCache = true) {
|
|
114
350
|
return operations.map((op: any) => {
|
|
115
|
-
|
|
351
|
+
try {
|
|
116
352
|
const directory = this.directoryFor(op);
|
|
353
|
+
this.observeDirectory(directory);
|
|
354
|
+
const saved = this.terminalProjections.get(op.operation_id);
|
|
355
|
+
const cached = saved && { ...saved };
|
|
356
|
+
const authority = JSON.stringify([op, directory]);
|
|
357
|
+
const work = !useCache ? this.metrics.sourceWork.history : this.repairIds.has(op.operation_id) && !this.dirtyOperations.has(op.operation_id)
|
|
358
|
+
? this.metrics.sourceWork.repair : this.metrics.sourceWork.active;
|
|
359
|
+
const dependencyVersion = this.hasInputVersions
|
|
360
|
+
? Number(this.db.prepare("SELECT revision FROM background_input_versions WHERE operation_id=?").get(op.operation_id)?.revision ?? 0)
|
|
361
|
+
: undefined;
|
|
362
|
+
const observedPath = join(directory, "observed", `${op.task_id}.json`);
|
|
363
|
+
const paths = [observedPath,
|
|
364
|
+
...["launch.json", "claim.json", "command.json", "result.json", "lost.json", "stop.json", "cleanup.json"]
|
|
365
|
+
.map(name => join(directory, "tasks", op.task_id, name))];
|
|
366
|
+
const identities = paths.map(path => {
|
|
367
|
+
this.metrics.inputStats++;
|
|
368
|
+
work.stats++;
|
|
369
|
+
try { const info = statSync(path, { bigint: true }); return `${info.dev}:${info.ino}:${info.size}:${info.mtimeNs}:${info.ctimeNs}`; }
|
|
370
|
+
catch (error) { if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error; }
|
|
371
|
+
return "missing";
|
|
372
|
+
});
|
|
373
|
+
let waits = cached?.row.waits;
|
|
374
|
+
if (dependencyVersion === undefined || !cached || cached.authority !== authority || cached.dependencyVersion !== dependencyVersion) {
|
|
375
|
+
this.metrics.dependencyQueries++;
|
|
376
|
+
work.waits++;
|
|
377
|
+
waits = this.db.prepare(`SELECT w.wait_id, w.generation, w.phase FROM waits w JOIN wait_dependencies d
|
|
378
|
+
ON w.wait_id = d.wait_id AND w.generation = d.generation WHERE d.operation_id = ?
|
|
379
|
+
AND w.owner_kind = ? AND w.owner_session_id = ? AND w.owner_workspace = ?
|
|
380
|
+
AND w.phase NOT IN ('consumed', 'cancelled') AND w.dispatch_disarmed = 0
|
|
381
|
+
ORDER BY w.wait_id, w.generation`).all(op.operation_id, op.owner_kind, op.owner_session_id, op.owner_workspace)
|
|
382
|
+
.map((w: any) => ({ waitId: w.wait_id, generation: w.generation, phase: w.phase }));
|
|
383
|
+
}
|
|
384
|
+
const readContext = () => {
|
|
385
|
+
try { return JSON.parse(readFileSync(observedPath, "utf8")); }
|
|
386
|
+
catch (error) {
|
|
387
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") return {};
|
|
388
|
+
if (!useCache && op.terminal_revision > 0 && error instanceof SyntaxError) return malformedHistoryContext;
|
|
389
|
+
throw error;
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
const workerContext = op.owner_kind === "worker-conversation" ? readContext() : undefined;
|
|
393
|
+
const parent = workerContext && this.workerParent(op, workerContext);
|
|
394
|
+
const version = JSON.stringify([op, directory, identities, waits, parent]);
|
|
395
|
+
// Both paths validate authority, file identities and dependencies above.
|
|
396
|
+
// History mode changes accounting/invalidation, not projection identity.
|
|
397
|
+
if (cached?.version === version) { cached.dependencyVersion = dependencyVersion; this.terminalProjections.set(op.operation_id, cached); this.metrics.projectionHits++; return cached.row; }
|
|
398
|
+
if (useCache) this.history?.invalidateOperation(op.operation_id);
|
|
399
|
+
this.metrics.runnerSnapshots++;
|
|
400
|
+
work.snapshots++;
|
|
117
401
|
const inspection = snapshot(directory, op.task_id);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
catch (error) { if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error; }
|
|
402
|
+
const context = workerContext ?? readContext();
|
|
403
|
+
if (context === malformedHistoryContext) return { id: op.task_id, unreadable: true };
|
|
121
404
|
const terminal = inspection?.terminal === true || op.terminal_revision > 0;
|
|
122
405
|
const status = inspection?.terminal ? inspection.status : op.terminal_revision > 0 ? op.terminal_outcome : inspection?.status ?? "running";
|
|
123
|
-
const
|
|
124
|
-
ON w.wait_id = d.wait_id AND w.generation = d.generation WHERE d.operation_id = ?
|
|
125
|
-
AND w.owner_kind = ? AND w.owner_session_id = ? AND w.owner_workspace = ?
|
|
126
|
-
AND w.phase NOT IN ('consumed', 'cancelled') AND w.dispatch_disarmed = 0`).all(op.operation_id, op.owner_kind, op.owner_session_id, op.owner_workspace)
|
|
127
|
-
.map((w: any) => ({ waitId: w.wait_id, generation: w.generation, phase: w.phase }));
|
|
128
|
-
return { durable: true, id: op.task_id, operationId: op.operation_id, kind: context.kind ?? inspection?.kind ?? "process",
|
|
406
|
+
const row = { ...parent, durable: true, id: op.task_id, operationId: op.operation_id, kind: context.kind ?? inspection?.kind ?? "process",
|
|
129
407
|
status, active: !terminal, terminal, attention: terminal && status !== "succeeded", waits,
|
|
130
|
-
|
|
408
|
+
terminalRevision: op.terminal_revision, terminalOutcome: op.terminal_outcome,
|
|
409
|
+
owner: { kind: op.owner_kind, sessionId: op.owner_session_id, workspace: op.owner_workspace, branchId: op.owner_branch_id ?? null },
|
|
131
410
|
startedAt: inspection?.result?.startedAt ?? inspection?.launch.createdAt ?? op.created_at,
|
|
132
411
|
endedAt: inspection?.result?.endedAt ?? op.terminal_at ?? undefined,
|
|
133
412
|
cwd: inspection?.launch.cwd ?? op.owner_workspace, name: context.name, command: context.command, argv: context.argv,
|
|
134
|
-
dismissedAt: context.dismissedAt, exitCode: inspection?.result?.exitCode ?? null,
|
|
413
|
+
dismissedAt: context.dismissedAt, exitCode: inspection?.result?.exitCode ?? null,
|
|
414
|
+
signal: inspection?.result?.signal ?? null, logPaths: inspection?.logs ?? {} };
|
|
415
|
+
this.terminalProjections.delete(op.operation_id);
|
|
416
|
+
this.terminalProjections.set(op.operation_id, { version, authority, operation: op, inspection, row, dependencyVersion });
|
|
417
|
+
if (this.terminalProjections.size > 4096) this.terminalProjections.delete(this.terminalProjections.keys().next().value!);
|
|
418
|
+
return row;
|
|
419
|
+
} catch (error) { this.dirtyOperations.add(op.operation_id); throw error; }
|
|
135
420
|
}).filter(Boolean);
|
|
136
421
|
}
|
|
422
|
+
private pendingRows(entry: BackgroundScope): any[] { return entry.pending; }
|
|
423
|
+
private refreshPending(entry: BackgroundScope, revision: number): void {
|
|
424
|
+
if (!entry.origin.sessionId || entry.pendingRevision === revision) return;
|
|
425
|
+
// These compact pointers only notify the frontend that obligations exist.
|
|
426
|
+
// The canonical manager independently pages and resolves every obligation.
|
|
427
|
+
entry.pending = this.db.prepare(`SELECT o.operation_id,o.task_id,o.owner_kind,o.owner_workspace,o.owner_session_id,o.owner_branch_id,
|
|
428
|
+
o.terminal_outcome,o.terminal_at,o.created_at FROM background_parent_callbacks c
|
|
429
|
+
JOIN operations o ON o.operation_id=c.operation_id
|
|
430
|
+
WHERE c.owner_kind='parent-session' AND c.owner_workspace=? AND c.owner_session_id=? AND o.terminal_revision>0
|
|
431
|
+
ORDER BY c.operation_id LIMIT ?`).all(entry.origin.cwd, entry.origin.sessionId, DISCOVERY_PAGE_SIZE)
|
|
432
|
+
.map((op: any) => ({ durable: true, id: op.task_id, operationId: op.operation_id, callbackPending: true,
|
|
433
|
+
owner: { kind: op.owner_kind, workspace: op.owner_workspace, sessionId: op.owner_session_id, branchId: op.owner_branch_id ?? null },
|
|
434
|
+
status: op.terminal_outcome, terminal: true, active: false, startedAt: op.created_at, endedAt: op.terminal_at }));
|
|
435
|
+
entry.pendingRevision = revision;
|
|
436
|
+
}
|
|
437
|
+
private belongsToDurableOrigin(row: any, origin: { cwd?: string; sessionId?: string }): boolean {
|
|
438
|
+
return row.owner.kind === "parent-session"
|
|
439
|
+
? row.owner.workspace === origin.cwd && row.owner.sessionId === origin.sessionId
|
|
440
|
+
: row.parentRecipient?.workspace === origin.cwd && row.parentRecipient?.sessionId === origin.sessionId;
|
|
441
|
+
}
|
|
442
|
+
private refreshRecent(entry: BackgroundScope, revision: number): void {
|
|
443
|
+
if (!this.db) return;
|
|
444
|
+
if (entry.recentRevision === undefined || !this.hasInputVersions && entry.recentRevision !== revision) {
|
|
445
|
+
const operations = this.db.prepare(`SELECT * FROM operations o WHERE observer_kind='local-supervisor' AND (
|
|
446
|
+
(owner_kind='parent-session' AND owner_workspace=?1 AND owner_session_id=?2) OR
|
|
447
|
+
${this.db.prepare("SELECT 1 FROM sqlite_master WHERE name='assignment_bindings'").get() ? `(owner_kind='worker-conversation' AND EXISTS (SELECT 1 FROM assignment_bindings b
|
|
448
|
+
WHERE json_extract(b.owner_json,'$.sessionId')=o.owner_session_id
|
|
449
|
+
AND json_extract(b.owner_json,'$.workspace')=o.owner_workspace
|
|
450
|
+
AND json_extract(b.recipient_json,'$.workspace')=?1 AND json_extract(b.recipient_json,'$.sessionId')=?2))` : '0'})
|
|
451
|
+
AND terminal_revision>0 AND terminal_at>=?3 ORDER BY terminal_at DESC,operation_id DESC LIMIT ?4`)
|
|
452
|
+
.all(entry.origin.cwd, entry.origin.sessionId ?? "", Date.now() - 30000, DISCOVERY_PAGE_SIZE);
|
|
453
|
+
entry.recent = this.project(operations).filter(row => this.belongsToDurableOrigin(row, entry.origin));
|
|
454
|
+
entry.recentRevision = revision;
|
|
455
|
+
} else {
|
|
456
|
+
const rows = new Map(entry.recent.filter(row => Date.now() - row.endedAt < 30000).map(row => [row.operationId, row]));
|
|
457
|
+
// Retained visible terminals must observe atomic file replacement even
|
|
458
|
+
// before a watcher hint arrives or the historical repair cursor reaches them.
|
|
459
|
+
for (const id of rows.keys()) if (!this.changedOperations.has(id)) {
|
|
460
|
+
let op = this.terminalProjections.get(id)?.operation;
|
|
461
|
+
if (!op) { this.metrics.exactOperationQueries++; op = this.db.prepare("SELECT * FROM operations WHERE operation_id=?").get(id); }
|
|
462
|
+
const row = op && this.project([op])[0];
|
|
463
|
+
if (row && this.belongsToDurableOrigin(row, entry.origin)) rows.set(id, row);
|
|
464
|
+
else rows.delete(id);
|
|
465
|
+
}
|
|
466
|
+
for (const [id, op] of this.changedOperations) {
|
|
467
|
+
const direct = op?.owner_kind === "parent-session" && op.owner_workspace === entry.origin.cwd && op.owner_session_id === (entry.origin.sessionId ?? "");
|
|
468
|
+
const row = (direct || op?.owner_kind === "worker-conversation") && op.observer_kind === "local-supervisor"
|
|
469
|
+
&& op.terminal_revision > 0 && Date.now() - op.terminal_at < 30000 && this.project([op])[0];
|
|
470
|
+
if (row && this.belongsToDurableOrigin(row, entry.origin)) rows.set(id, row);
|
|
471
|
+
else rows.delete(id);
|
|
472
|
+
}
|
|
473
|
+
entry.recent = [...rows.values()].sort((a, b) => b.endedAt - a.endedAt || b.operationId.localeCompare(a.operationId)).slice(0, DISCOVERY_PAGE_SIZE);
|
|
474
|
+
entry.recentRevision = revision;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
137
477
|
private legacyScope(scope: { cwd?: string; sessionId?: string }) {
|
|
138
478
|
if (!scope.cwd) throw new Error("Background activity requires an exact workspace");
|
|
139
479
|
const key = JSON.stringify([scope.cwd, scope.sessionId]);
|
|
@@ -145,36 +485,58 @@ export class BackgroundObservation {
|
|
|
145
485
|
this.legacy.delete(oldest[0]);
|
|
146
486
|
}
|
|
147
487
|
const origin = { cwd: scope.cwd, sessionId: scope.sessionId };
|
|
148
|
-
entry = { origin, rows:
|
|
488
|
+
entry = { origin, rows: this.ready ? this.visibleLegacy(origin) : [], references: 0, pending: [], recent: [] };
|
|
489
|
+
if (this.ready && this.status !== "degraded" && this.db?.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='background_parent_callbacks'").get())
|
|
490
|
+
this.refreshPending(entry, Number(this.db.prepare("SELECT value FROM coordinator_state WHERE key='change_revision'").get()?.value ?? 0));
|
|
491
|
+
if (this.ready && this.status !== "degraded" && this.db) this.refreshRecent(entry, Number(this.db.prepare("SELECT value FROM coordinator_state WHERE key='change_revision'").get()?.value ?? 0));
|
|
149
492
|
}
|
|
150
493
|
this.legacy.delete(key); this.legacy.set(key, entry);
|
|
151
494
|
return entry;
|
|
152
495
|
}
|
|
496
|
+
private visibleLegacy(origin: { cwd: string; sessionId?: string }): any[] {
|
|
497
|
+
return [...new Map([...observeMetasForOrigin(origin), ...observeRecentMetasForOrigin(origin),
|
|
498
|
+
...(origin.sessionId ? observeRecentMetasForOrigin({ cwd: origin.cwd }).filter((row: any) => !row.callbackOrigin) : [])]
|
|
499
|
+
.map((row: any) => [row.id, row])).values()];
|
|
500
|
+
}
|
|
153
501
|
retain(scope: { cwd?: string; sessionId?: string }) {
|
|
502
|
+
if (!this.ready) this.enabled = true;
|
|
154
503
|
const entry = this.legacyScope(scope);
|
|
155
504
|
entry.references++;
|
|
156
505
|
let released = false;
|
|
157
506
|
return () => { if (!released) { released = true; entry.references--; } };
|
|
158
507
|
}
|
|
159
508
|
read(scope: WorkScope, index?: any): any[] {
|
|
160
|
-
if (!this.
|
|
509
|
+
if (!this.ready) { this.enabled = true; return []; }
|
|
510
|
+
const newlyGlobal = scope.backgroundAll && !this.allRequested;
|
|
511
|
+
if (scope.backgroundAll) this.allRequested = true;
|
|
512
|
+
if (!this.enabled || newlyGlobal) { this.enabled = true; this.refresh(); }
|
|
161
513
|
const legacy = this.legacyScope(scope);
|
|
162
514
|
if (scope.backgroundHistory) { this.metrics.historyQueries++; return index.records.map((record: any) => record.meta); }
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
515
|
+
// Retained terminals stay visible by default, but a sidecar dismissal must
|
|
516
|
+
// be observed even before its watcher notification is delivered.
|
|
517
|
+
if (!this.observationActive && this.status !== "degraded" && this.db) this.refreshRecent(legacy, legacy.recentRevision ?? 0);
|
|
518
|
+
const legacyRows = this.observationActive || this.status === "degraded" ? legacy.rows : this.visibleLegacy(legacy.origin);
|
|
519
|
+
const exact = scope.id && this.status !== "degraded" && this.db
|
|
520
|
+
? this.project(this.db.prepare("SELECT * FROM operations WHERE task_id=? AND observer_kind='local-supervisor'").all(scope.id)) : [];
|
|
521
|
+
const rows = [...new Map([...this.pendingRows(legacy), ...this.rows, ...(scope.backgroundAll ? [] : legacy.recent), ...exact].map(row => [row.id, row])).values()];
|
|
522
|
+
return [...rows.filter(row => (!scope.id || row.id === scope.id) && row.dismissedAt === undefined
|
|
523
|
+
&& (scope.backgroundAll ? row.owner.kind === "parent-session" : this.belongsToDurableOrigin(row, scope)) && (!scope.active || row.active)),
|
|
524
|
+
...legacyRows.filter((row: any) => (!scope.id || row.id === scope.id) && (scope.backgroundAll || !row.callbackOrigin || belongsToOrigin(row, legacy.origin)
|
|
168
525
|
&& (scope.sessionId || row.spawnPid === scope.processId)) && (!scope.active || row.status === "running"))];
|
|
169
526
|
}
|
|
170
527
|
close(): Promise<void> {
|
|
171
|
-
|
|
172
|
-
this.
|
|
528
|
+
this.closed = true;
|
|
529
|
+
if (this.expiry) clearTimeout(this.expiry);
|
|
530
|
+
for (const watcher of this.watchers.values()) watcher.close();
|
|
531
|
+
this.watchers.clear(); this.inbox?.close(); this.inbox = undefined;
|
|
532
|
+
if (this.history) return this.history.close().then(() => { this.ownDb?.close(); this.ownDb = undefined; });
|
|
533
|
+
this.ownDb?.close(); this.ownDb = undefined; return Promise.resolve();
|
|
173
534
|
}
|
|
174
|
-
get historyStatus() { return this.history?.
|
|
535
|
+
get historyStatus() { return this.history?.queryStatus ?? "degraded"; }
|
|
175
536
|
get historyReason() { return this.history?.reason; }
|
|
176
537
|
get historyMetrics() { return this.history?.metrics; }
|
|
177
538
|
historyIndex(scope: WorkScope) {
|
|
539
|
+
if (!this.ready) throw new Error("Background inbox coverage is unverified");
|
|
178
540
|
this.read({ ...scope, backgroundHistory: false });
|
|
179
541
|
if (!this.history) throw new Error("Background history requires the shared root index");
|
|
180
542
|
return this.history.read(scope);
|