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
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Filesystem catalog: project, personal, and bundled sources.
|
|
4
4
|
*
|
|
5
|
-
* Discovery is deterministic
|
|
6
|
-
*
|
|
5
|
+
* Discovery is deterministic. Direct callers read disk on every call; the server
|
|
6
|
+
* can supply bounded source reuse after admission. Callers launching a batch retain the snapshot
|
|
7
7
|
* and reuse that object for every job.
|
|
8
8
|
*
|
|
9
9
|
* Project files are read only when `projectTrusted` is true. Pass Pi's
|
|
@@ -69,12 +69,12 @@ export function listScopedAgents(input, scope) {
|
|
|
69
69
|
throw new Error("Unsafe project config directory");
|
|
70
70
|
const directory = scope === "project" ? projectCatalogPaths(input.cwd, config).agents : userCatalogPaths(input.userRoot).agents;
|
|
71
71
|
const occurrences = new Map();
|
|
72
|
-
collectDirectory(directory, scope, "agent", occurrences, diagnostics);
|
|
72
|
+
collectDirectory(directory, scope, "agent", occurrences, diagnostics, input.sources);
|
|
73
73
|
const agents = [...occurrences.values()].flat().flatMap(item => item.parse.definition?.kind === "agent"
|
|
74
74
|
? [{ path: item.path, definition: item.parse.definition }] : []);
|
|
75
75
|
return { agents, diagnostics };
|
|
76
76
|
}
|
|
77
|
-
/**
|
|
77
|
+
/** Discover authorized sources. Identical bytes produce the same content digest. */
|
|
78
78
|
export function loadCatalog(input) {
|
|
79
79
|
const loadedAt = new Date().toISOString();
|
|
80
80
|
const diagnostics = [];
|
|
@@ -91,8 +91,8 @@ export function loadCatalog(input) {
|
|
|
91
91
|
groups.set(scope, new Map());
|
|
92
92
|
if (input.projectTrusted) {
|
|
93
93
|
const project = projectCatalogPaths(input.cwd, configDirName);
|
|
94
|
-
collectDirectory(project.roles, "project", "role", groups.get("project"), diagnostics);
|
|
95
|
-
collectDirectory(project.agents, "project", "agent", groups.get("project"), diagnostics);
|
|
94
|
+
collectDirectory(project.roles, "project", "role", groups.get("project"), diagnostics, input.sources);
|
|
95
|
+
collectDirectory(project.agents, "project", "agent", groups.get("project"), diagnostics, input.sources);
|
|
96
96
|
}
|
|
97
97
|
else {
|
|
98
98
|
const project = projectCatalogPaths(input.cwd, configDirName);
|
|
@@ -101,8 +101,8 @@ export function loadCatalog(input) {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
const user = userCatalogPaths(input.userRoot);
|
|
104
|
-
collectDirectory(user.roles, "user", "role", groups.get("user"), diagnostics);
|
|
105
|
-
collectDirectory(user.agents, "user", "agent", groups.get("user"), diagnostics);
|
|
104
|
+
collectDirectory(user.roles, "user", "role", groups.get("user"), diagnostics, input.sources);
|
|
105
|
+
collectDirectory(user.agents, "user", "agent", groups.get("user"), diagnostics, input.sources);
|
|
106
106
|
const bundledRoles = input.bundledRoot ?? bundledRolesRoot();
|
|
107
107
|
if (!existsSync(bundledRoles)) {
|
|
108
108
|
diagnostics.push(diagnostic(DiagnosticCodes.bundledMissing, `Bundled role directory ${bundledRoles} is missing.`, {
|
|
@@ -114,23 +114,21 @@ export function loadCatalog(input) {
|
|
|
114
114
|
}));
|
|
115
115
|
}
|
|
116
116
|
else {
|
|
117
|
-
collectDirectory(bundledRoles, "bundled", "role", groups.get("bundled"), diagnostics);
|
|
117
|
+
collectDirectory(bundledRoles, "bundled", "role", groups.get("bundled"), diagnostics, input.sources);
|
|
118
118
|
}
|
|
119
119
|
if (input.bundledAgentsRoot) {
|
|
120
|
-
collectDirectory(input.bundledAgentsRoot, "bundled", "agent", groups.get("bundled"), diagnostics);
|
|
120
|
+
collectDirectory(input.bundledAgentsRoot, "bundled", "agent", groups.get("bundled"), diagnostics, input.sources);
|
|
121
121
|
}
|
|
122
122
|
const { entries, blocked } = selectIdentities(groups, diagnostics);
|
|
123
123
|
const savedSettings = {};
|
|
124
124
|
const preferenceSources = {};
|
|
125
|
-
const preferenceDigests = [];
|
|
126
125
|
const scopes = [
|
|
127
126
|
{ scope: "user", root: user.root },
|
|
128
127
|
...(input.projectTrusted ? [{ scope: "project", root: projectCatalogPaths(input.cwd, configDirName).root }] : []),
|
|
129
128
|
];
|
|
130
129
|
for (const { scope, root } of scopes) {
|
|
131
130
|
try {
|
|
132
|
-
const preferences = readCatalogPreferences(root);
|
|
133
|
-
preferenceDigests.push(preferences.digest);
|
|
131
|
+
const preferences = input.sources?.preferences?.(root) ?? readCatalogPreferences(root);
|
|
134
132
|
for (const entry of entries) {
|
|
135
133
|
if (scope === "user" && entry.scope === "project")
|
|
136
134
|
continue;
|
|
@@ -141,8 +139,8 @@ export function loadCatalog(input) {
|
|
|
141
139
|
if (own.bundled) {
|
|
142
140
|
const fallbacks = entry.scope === "bundled" ? [entry] : entry.unused.filter(source => source.scope === "bundled");
|
|
143
141
|
const fallback = fallbacks.length === 1 ? fallbacks[0] : undefined;
|
|
144
|
-
const raw = fallback ? readFileSync(fallback.path, "utf8") : undefined;
|
|
145
|
-
const parsed = raw === undefined ? undefined : parseDefinition(raw, fallback.path);
|
|
142
|
+
const raw = fallback ? (input.sources?.read(fallback.path) ?? readFileSync(fallback.path, "utf8")) : undefined;
|
|
143
|
+
const parsed = raw === undefined ? undefined : (input.sources?.parse(raw, fallback.path) ?? parseDefinition(raw, fallback.path));
|
|
146
144
|
if (!fallback || !parsed?.ok || parsed.definition?.id !== entry.id || parsed.diagnostics.some(item => item.blocking)
|
|
147
145
|
|| contentDigest(raw) !== fallback.contentDigest) {
|
|
148
146
|
const failure = diagnostic("catalog-preferences", `Cannot inherit bundled runtime defaults for ${entry.id}: a single valid bundled definition is required.`, {
|
|
@@ -182,8 +180,8 @@ export function loadCatalog(input) {
|
|
|
182
180
|
}
|
|
183
181
|
}
|
|
184
182
|
}
|
|
185
|
-
const snapshot = finishSnapshot(entries, blocked, diagnostics, loadedAt);
|
|
186
|
-
const digest = contentDigest(JSON.stringify([snapshot.digest,
|
|
183
|
+
const snapshot = finishSnapshot(entries, blocked, diagnostics, loadedAt, input.sources);
|
|
184
|
+
const digest = contentDigest(JSON.stringify([snapshot.digest, savedSettings, preferenceSources]));
|
|
187
185
|
return deepFreeze({ ...snapshot, digest, revision: digest, savedSettings, preferenceSources });
|
|
188
186
|
}
|
|
189
187
|
export function refreshCatalog(input) {
|
|
@@ -372,7 +370,7 @@ export function saveDefinition(input) {
|
|
|
372
370
|
export function isSafeConfigDirName(name) {
|
|
373
371
|
return /^\.[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(name) || /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(name);
|
|
374
372
|
}
|
|
375
|
-
function collectDirectory(directory, scope, directoryKind, into, diagnostics) {
|
|
373
|
+
function collectDirectory(directory, scope, directoryKind, into, diagnostics, sources) {
|
|
376
374
|
let stats;
|
|
377
375
|
try {
|
|
378
376
|
stats = lstatSync(directory);
|
|
@@ -449,7 +447,7 @@ function collectDirectory(directory, scope, directoryKind, into, diagnostics) {
|
|
|
449
447
|
continue;
|
|
450
448
|
let raw;
|
|
451
449
|
try {
|
|
452
|
-
raw = readFileSync(path, "utf8");
|
|
450
|
+
raw = sources?.read(path) ?? readFileSync(path, "utf8");
|
|
453
451
|
}
|
|
454
452
|
catch (error) {
|
|
455
453
|
diagnostics.push(diagnostic(DiagnosticCodes.ioError, `Could not read ${path}: ${error.message}`, {
|
|
@@ -462,7 +460,7 @@ function collectDirectory(directory, scope, directoryKind, into, diagnostics) {
|
|
|
462
460
|
}
|
|
463
461
|
let parse;
|
|
464
462
|
try {
|
|
465
|
-
parse = parseDefinition(raw, path);
|
|
463
|
+
parse = sources?.parse(raw, path) ?? parseDefinition(raw, path);
|
|
466
464
|
}
|
|
467
465
|
catch (error) {
|
|
468
466
|
const detail = error instanceof Error ? error.message : String(error);
|
|
@@ -586,11 +584,11 @@ function unusedSource(occurrence, reason) {
|
|
|
586
584
|
reason,
|
|
587
585
|
};
|
|
588
586
|
}
|
|
589
|
-
function finishSnapshot(entries, blocked, diagnostics, loadedAt) {
|
|
587
|
+
function finishSnapshot(entries, blocked, diagnostics, loadedAt, sources) {
|
|
590
588
|
const roleEntries = [];
|
|
591
589
|
const agentEntries = [];
|
|
592
590
|
for (const entry of entries) {
|
|
593
|
-
const frozen = deepFreeze(cloneEntry(entry));
|
|
591
|
+
const frozen = sources?.entry?.(entry) ?? deepFreeze(cloneEntry(entry));
|
|
594
592
|
if (frozen.kind === "role")
|
|
595
593
|
roleEntries.push([frozen.id, frozen]);
|
|
596
594
|
else
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Generated canonical coordinator. Do not edit directly.
|
|
2
|
+
/** Additive observation journal. Triggers also cover already-running old writers. */
|
|
3
|
+
export function ensureAssignmentChanges(ctx) {
|
|
4
|
+
ctx.transaction(() => {
|
|
5
|
+
ctx.db.exec(`CREATE TABLE IF NOT EXISTS assignment_change_source (
|
|
6
|
+
singleton INTEGER PRIMARY KEY CHECK(singleton=1), generation TEXT NOT NULL);
|
|
7
|
+
INSERT OR IGNORE INTO assignment_change_source VALUES(1, lower(hex(randomblob(16))));
|
|
8
|
+
CREATE TABLE IF NOT EXISTS assignment_changes (
|
|
9
|
+
seq INTEGER PRIMARY KEY AUTOINCREMENT, entity TEXT NOT NULL, entity_id TEXT NOT NULL DEFAULT '',
|
|
10
|
+
assignment_id TEXT, session_id TEXT NOT NULL, workspace TEXT NOT NULL,
|
|
11
|
+
changed_at INTEGER NOT NULL DEFAULT (unixepoch()*1000));
|
|
12
|
+
CREATE INDEX IF NOT EXISTS waits_assignment_observation ON waits
|
|
13
|
+
(owner_kind,owner_session_id,owner_workspace,json_extract(origin_json,'$.assignmentRef'),created_at DESC,generation DESC);
|
|
14
|
+
CREATE INDEX IF NOT EXISTS resume_claims_wait_observation ON resume_claims(wait_id,generation,attempt_id);
|
|
15
|
+
CREATE TABLE IF NOT EXISTS background_input_versions (
|
|
16
|
+
operation_id TEXT PRIMARY KEY, revision INTEGER NOT NULL);
|
|
17
|
+
CREATE TRIGGER IF NOT EXISTS assignment_changes_retention AFTER INSERT ON assignment_changes
|
|
18
|
+
BEGIN DELETE FROM assignment_changes WHERE seq <= NEW.seq - 4096; END;`);
|
|
19
|
+
// Repair is an operation-ID keyset, not an observer equality lookup.
|
|
20
|
+
// A leading observer column competes with the ordered recent-terminal index.
|
|
21
|
+
if (ctx.db.prepare("PRAGMA index_info(background_operation_repair)").all().length > 1)
|
|
22
|
+
ctx.db.exec("DROP INDEX background_operation_repair");
|
|
23
|
+
ctx.db.exec("CREATE INDEX IF NOT EXISTS background_operation_repair ON operations(operation_id) WHERE observer_kind='local-supervisor'");
|
|
24
|
+
const sources = [
|
|
25
|
+
{ table: "waits", select: (r) => `SELECT 'wait', ${r}.wait_id || ':' || ${r}.generation, json_extract(${r}.origin_json,'$.assignmentRef'), ${r}.owner_session_id, ${r}.owner_workspace WHERE ${r}.owner_kind='worker-conversation'` },
|
|
26
|
+
{ table: "resume_claims", select: (r) => `SELECT 'claim', ${r}.claim_id, json_extract(w.origin_json,'$.assignmentRef'), w.owner_session_id, w.owner_workspace FROM waits w WHERE w.wait_id=${r}.wait_id AND w.generation=${r}.generation AND w.owner_kind='worker-conversation'` },
|
|
27
|
+
{ table: "assignment_bindings", select: (r) => `SELECT 'binding', ${r}.assignment_id, ${r}.assignment_id, json_extract(${r}.owner_json,'$.sessionId'), json_extract(${r}.owner_json,'$.workspace')` },
|
|
28
|
+
{ table: "assignment_attempts", select: (r) => `SELECT 'attempt', ${r}.attempt_id, b.assignment_id, json_extract(b.owner_json,'$.sessionId'), json_extract(b.owner_json,'$.workspace') FROM assignment_bindings b WHERE b.assignment_id=${r}.assignment_id` },
|
|
29
|
+
{ table: "assignment_outcomes", select: (r) => `SELECT 'outcome', ${r}.assignment_id, ${r}.assignment_id, json_extract(${r}.record_json,'$.owner.sessionId'), json_extract(${r}.record_json,'$.owner.workspace')` },
|
|
30
|
+
{ table: "outbox_events", select: (r) => `SELECT 'receipt', ${r}.event_id, b.assignment_id, json_extract(b.owner_json,'$.sessionId'), json_extract(b.owner_json,'$.workspace') FROM assignment_bindings b WHERE b.assignment_id=${r}.operation_id UNION ALL SELECT 'receipt', ${r}.event_id, json_extract(w.origin_json,'$.assignmentRef'), w.owner_session_id, w.owner_workspace FROM waits w WHERE w.wait_id=${r}.wait_id AND w.generation=${r}.generation AND w.owner_kind='worker-conversation'` },
|
|
31
|
+
];
|
|
32
|
+
for (const { table, select } of sources)
|
|
33
|
+
for (const action of ["INSERT", "UPDATE", "DELETE"]) {
|
|
34
|
+
const records = action === "UPDATE" ? ["OLD", "NEW"] : [action === "DELETE" ? "OLD" : "NEW"];
|
|
35
|
+
ctx.db.exec(`CREATE TRIGGER IF NOT EXISTS assignment_change_${table}_${action.toLowerCase()} AFTER ${action} ON ${table} BEGIN ${records.map(r => `INSERT INTO assignment_changes(entity,entity_id,assignment_id,session_id,workspace) ${select(r)};`).join(" ")} END;`);
|
|
36
|
+
}
|
|
37
|
+
// These are observation inputs, not execution or delivery authority. Old
|
|
38
|
+
// cooperative SQL writers inherit the same atomic invalidation triggers.
|
|
39
|
+
const backgroundSources = [
|
|
40
|
+
{ table: "operations", select: (r) => `SELECT ${r}.operation_id, 1 WHERE ${r}.observer_kind='local-supervisor'` },
|
|
41
|
+
{ table: "waits", select: (r) => `SELECT d.operation_id, 1 FROM wait_dependencies d JOIN operations o ON o.operation_id=d.operation_id WHERE d.wait_id=${r}.wait_id AND d.generation=${r}.generation AND o.observer_kind='local-supervisor'` },
|
|
42
|
+
{ table: "wait_dependencies", select: (r) => `SELECT ${r}.operation_id, 1 WHERE EXISTS(SELECT 1 FROM operations o WHERE o.operation_id=${r}.operation_id AND o.observer_kind='local-supervisor')` },
|
|
43
|
+
{ table: "background_parent_callbacks", select: (r) => `SELECT ${r}.operation_id, 1 WHERE 1` },
|
|
44
|
+
{ table: "coordinator_state", select: (r) => `SELECT o.operation_id, 1 FROM operations o WHERE ${r}.key LIKE 'result-supervision-v1:%' AND o.operation_id=substr(${r}.key,length('result-supervision-v1:')+1) AND o.observer_kind='local-supervisor'` },
|
|
45
|
+
];
|
|
46
|
+
// Version 1 installed one-column SELECTs into a two-column INSERT. Replace
|
|
47
|
+
// only these owned triggers, atomically, without resetting source positions.
|
|
48
|
+
const replaceBackgroundTriggers = ctx.db.prepare("SELECT value FROM schema_meta WHERE key='background_input_triggers_version'").get()?.value !== "2";
|
|
49
|
+
for (const { table, select } of backgroundSources)
|
|
50
|
+
for (const action of ["INSERT", "UPDATE", "DELETE"]) {
|
|
51
|
+
if (replaceBackgroundTriggers)
|
|
52
|
+
ctx.db.exec(`DROP TRIGGER IF EXISTS background_input_${table}_${action.toLowerCase()}`);
|
|
53
|
+
const records = action === "UPDATE" ? ["OLD", "NEW"] : [action === "DELETE" ? "OLD" : "NEW"];
|
|
54
|
+
ctx.db.exec(`CREATE TRIGGER IF NOT EXISTS background_input_${table}_${action.toLowerCase()}
|
|
55
|
+
${action === "DELETE" ? "BEFORE" : "AFTER"} ${action} ON ${table} BEGIN
|
|
56
|
+
${records.map(r => `INSERT INTO background_input_versions(operation_id,revision) ${select(r)}
|
|
57
|
+
ON CONFLICT(operation_id) DO UPDATE SET revision=revision+1;`).join(" ")}
|
|
58
|
+
END;`);
|
|
59
|
+
}
|
|
60
|
+
if (replaceBackgroundTriggers)
|
|
61
|
+
ctx.db.prepare("INSERT OR REPLACE INTO schema_meta(key,value) VALUES('background_input_triggers_version','2')").run();
|
|
62
|
+
ctx.db.exec(`CREATE TRIGGER IF NOT EXISTS background_journal_insert AFTER INSERT ON background_input_versions BEGIN
|
|
63
|
+
INSERT INTO assignment_changes(entity,entity_id,assignment_id,session_id,workspace)
|
|
64
|
+
SELECT 'background:operation', NEW.operation_id, NEW.operation_id, owner_session_id, owner_workspace FROM operations WHERE operation_id=NEW.operation_id;
|
|
65
|
+
END;
|
|
66
|
+
CREATE TRIGGER IF NOT EXISTS background_journal_update AFTER UPDATE ON background_input_versions BEGIN
|
|
67
|
+
INSERT INTO assignment_changes(entity,entity_id,assignment_id,session_id,workspace)
|
|
68
|
+
SELECT 'background:operation', NEW.operation_id, NEW.operation_id, owner_session_id, owner_workspace FROM operations WHERE operation_id=NEW.operation_id;
|
|
69
|
+
END;
|
|
70
|
+
CREATE TRIGGER IF NOT EXISTS background_journal_previous_scope AFTER UPDATE ON operations
|
|
71
|
+
WHEN OLD.observer_kind='local-supervisor' AND (OLD.owner_session_id<>NEW.owner_session_id OR OLD.owner_workspace<>NEW.owner_workspace OR OLD.owner_kind<>NEW.owner_kind)
|
|
72
|
+
BEGIN INSERT INTO assignment_changes(entity,entity_id,assignment_id,session_id,workspace)
|
|
73
|
+
VALUES('background:operation',OLD.operation_id,OLD.operation_id,OLD.owner_session_id,OLD.owner_workspace); END;`);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Generated canonical coordinator. Do not edit directly.
|
|
2
2
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
|
+
import { bumpChangeRevision } from "./discovery.mjs";
|
|
3
4
|
import { StoreError } from "./errors.mjs";
|
|
4
5
|
import { columnText, getRow, getRows, run } from "./sqlite.mjs";
|
|
5
6
|
import { requireWait, readPins } from "./rows.mjs";
|
|
@@ -107,6 +108,7 @@ export function recordAssignmentOutcome(ctx, input) {
|
|
|
107
108
|
for (const e of retained)
|
|
108
109
|
run(ctx, `INSERT OR IGNORE INTO evidence_pins (pin_id, wait_id, generation, operation_id, terminal_revision, kind, ref, summary, detail_lost, bytes, pinned_at) VALUES (?, ?, 1, ?, ?, ?, ?, ?, ?, ?, ?)`, `pin_${randomUUID()}`, eventId, e.operationId, e.terminalRevision, e.kind, e.ref, e.summary ?? null, e.detailLost ? 1 : 0, e.bytes ?? null, at);
|
|
109
110
|
run(ctx, `INSERT INTO outbox_events (event_id, event_type, operation_id, terminal_revision, wait_id, generation, recipient_kind, recipient_session_id, recipient_workspace, recipient_branch_id, recipient_goal_id, state, created_at) VALUES (?, 'assignment-outcome', ?, ?, ?, 1, ?, ?, ?, ?, ?, 'pending', ?)`, eventId, assignmentId, revision, eventId, recipient.kind, recipient.sessionId, recipient.workspace, recipient.branchId ?? null, recipient.goalId ?? null, at);
|
|
111
|
+
bumpChangeRevision(ctx);
|
|
110
112
|
return record;
|
|
111
113
|
});
|
|
112
114
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Generated canonical coordinator. Do not edit directly.
|
|
2
|
+
/** Pending parent notifications are obligations, independent of UI retention. */
|
|
3
|
+
import { bumpChangeRevision } from './discovery.mjs';
|
|
4
|
+
import { mapOperation } from './rows.mjs';
|
|
5
|
+
import { getRow, getRows, run } from './sqlite.mjs';
|
|
6
|
+
import { requireBoolean, requireCounter, requireId, requirePath } from './validate.mjs';
|
|
7
|
+
const pageSize = (limit = 256) => Math.max(1, Math.min(256, requireCounter('limit', limit)));
|
|
8
|
+
const scopeValues = (scope) => [requirePath('workspace', scope.workspace), requireId('sessionId', scope.sessionId)];
|
|
9
|
+
export function setParentCallbackPending(ctx, taskId, pending) {
|
|
10
|
+
taskId = requireId('taskId', taskId);
|
|
11
|
+
pending = requireBoolean('pending', pending);
|
|
12
|
+
return ctx.transaction(() => {
|
|
13
|
+
const operation = getRow(ctx, "SELECT operation_id, owner_workspace, owner_session_id FROM operations WHERE task_id=? AND owner_kind='parent-session' AND observer_kind='local-supervisor'", taskId);
|
|
14
|
+
if (!operation)
|
|
15
|
+
return false;
|
|
16
|
+
const changed = pending
|
|
17
|
+
? run(ctx, `INSERT OR IGNORE INTO background_parent_callbacks(operation_id,owner_kind,owner_workspace,owner_session_id)
|
|
18
|
+
VALUES (?,'parent-session',?,?)`, String(operation.operation_id), String(operation.owner_workspace), String(operation.owner_session_id))
|
|
19
|
+
: run(ctx, 'DELETE FROM background_parent_callbacks WHERE operation_id=?', String(operation.operation_id));
|
|
20
|
+
if (changed > 0)
|
|
21
|
+
bumpChangeRevision(ctx);
|
|
22
|
+
return changed > 0;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export function listPendingParentCallbacks(ctx, scope, options = {}) {
|
|
26
|
+
return getRows(ctx, `SELECT o.* FROM background_parent_callbacks p JOIN operations o ON o.operation_id=p.operation_id
|
|
27
|
+
WHERE p.owner_kind='parent-session' AND p.owner_workspace=? AND p.owner_session_id=? AND p.operation_id>? AND o.terminal_revision>0
|
|
28
|
+
ORDER BY p.operation_id LIMIT ?`, ...scopeValues(scope), options.after === undefined ? '' : requireId('after', options.after), pageSize(options.limit)).map(mapOperation);
|
|
29
|
+
}
|
|
30
|
+
export function listRecentBackgroundTerminals(ctx, options) {
|
|
31
|
+
const params = [requireCounter('since', options.since)];
|
|
32
|
+
let where = "observer_kind='local-supervisor' AND terminal_revision>0 AND terminal_at>=?";
|
|
33
|
+
if (options.owner) {
|
|
34
|
+
where += " AND owner_kind='parent-session' AND owner_workspace=? AND owner_session_id=?";
|
|
35
|
+
params.push(...scopeValues(options.owner));
|
|
36
|
+
}
|
|
37
|
+
if (options.after) {
|
|
38
|
+
where += ' AND (terminal_at,operation_id)>(?,?)';
|
|
39
|
+
params.push(requireCounter('after.terminalAt', options.after.terminalAt), requireId('after.operationId', options.after.operationId));
|
|
40
|
+
}
|
|
41
|
+
params.push(pageSize(options.limit));
|
|
42
|
+
return getRows(ctx, `SELECT * FROM operations WHERE ${where} ORDER BY terminal_at,operation_id LIMIT ?`, ...params).map(mapOperation);
|
|
43
|
+
}
|
|
44
|
+
/** Call from the canonical manager in bounded batches, yielding between pages. */
|
|
45
|
+
export function seedPendingParentCallbacks(ctx, options = {}) {
|
|
46
|
+
return ctx.transaction(() => {
|
|
47
|
+
const migration = getRow(ctx, 'SELECT * FROM background_parent_callback_migration WHERE singleton=1');
|
|
48
|
+
if (Number(migration.done))
|
|
49
|
+
return { done: true, seeded: 0 };
|
|
50
|
+
const limit = pageSize(options.limit);
|
|
51
|
+
const rows = getRows(ctx, `SELECT operation_id,owner_workspace,owner_session_id FROM operations
|
|
52
|
+
WHERE owner_kind='parent-session' AND observer_kind='local-supervisor' AND operation_id>? AND operation_id<=?
|
|
53
|
+
ORDER BY operation_id LIMIT ?`, String(migration.after_operation_id), String(migration.through_operation_id), limit);
|
|
54
|
+
let seeded = 0;
|
|
55
|
+
for (const row of rows)
|
|
56
|
+
seeded += Number(run(ctx, `INSERT OR IGNORE INTO background_parent_callbacks(operation_id,owner_kind,owner_workspace,owner_session_id)
|
|
57
|
+
VALUES (?,'parent-session',?,?)`, String(row.operation_id), String(row.owner_workspace), String(row.owner_session_id)));
|
|
58
|
+
const after = rows.length ? String(rows.at(-1).operation_id) : String(migration.after_operation_id);
|
|
59
|
+
const done = rows.length < limit || after === migration.through_operation_id;
|
|
60
|
+
run(ctx, 'UPDATE background_parent_callback_migration SET after_operation_id=?,done=? WHERE singleton=1', after, done ? 1 : 0);
|
|
61
|
+
if (seeded)
|
|
62
|
+
bumpChangeRevision(ctx);
|
|
63
|
+
return { done, seeded };
|
|
64
|
+
});
|
|
65
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Generated canonical coordinator. Do not edit directly.
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
const prefix = 'background-request-v1:';
|
|
4
|
+
// A partial index excludes returned history. CASE protects other coordinator
|
|
5
|
+
// records and makes corrupt request rows visible to recovery rather than hiding them.
|
|
6
|
+
const pendingPredicate = "key GLOB 'background-request-v1:*' AND CASE WHEN json_valid(value) THEN COALESCE(json_extract(value, '$.state'), '') != 'returned' ELSE 1 END";
|
|
7
|
+
export const BACKGROUND_PENDING_QUERY = `SELECT value FROM coordinator_state INDEXED BY background_requests_pending WHERE ${pendingPredicate} ORDER BY key LIMIT ?`;
|
|
8
|
+
function storageKey(owner, key) { return prefix + createHash('sha256').update(JSON.stringify([owner, key])).digest('hex'); }
|
|
9
|
+
export class BackgroundRequests {
|
|
10
|
+
context;
|
|
11
|
+
alive;
|
|
12
|
+
constructor(context, alive) {
|
|
13
|
+
this.context = context;
|
|
14
|
+
this.alive = alive;
|
|
15
|
+
alive();
|
|
16
|
+
context.db.exec(`CREATE INDEX IF NOT EXISTS background_requests_pending ON coordinator_state(key) WHERE ${pendingPredicate}`);
|
|
17
|
+
}
|
|
18
|
+
read(owner, key) {
|
|
19
|
+
this.alive();
|
|
20
|
+
const row = this.context.db.prepare('SELECT value FROM coordinator_state WHERE key=?').get(storageKey(owner, key));
|
|
21
|
+
return row ? JSON.parse(String(row.value)) : undefined;
|
|
22
|
+
}
|
|
23
|
+
write(value) {
|
|
24
|
+
this.context.db.prepare('INSERT OR REPLACE INTO coordinator_state (key,value) VALUES (?,?)').run(storageKey(value.owner, value.key), JSON.stringify(value));
|
|
25
|
+
}
|
|
26
|
+
accept(owner, key, digest, writerFence) {
|
|
27
|
+
this.alive();
|
|
28
|
+
return this.context.transaction(() => {
|
|
29
|
+
const prior = this.read(owner, key);
|
|
30
|
+
if (prior) {
|
|
31
|
+
if (prior.digest !== digest)
|
|
32
|
+
throw new Error('request-conflict: Background request key changed content');
|
|
33
|
+
return { prior: true, record: prior };
|
|
34
|
+
}
|
|
35
|
+
const record = { owner, key, digest, state: 'accepted', operations: [], acceptedAt: Date.now(), lastProgressAt: Date.now(), writerFence };
|
|
36
|
+
this.write(record);
|
|
37
|
+
return { prior: false, record };
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
dispatch(owner, key) {
|
|
41
|
+
this.update(owner, key, value => {
|
|
42
|
+
if (value.state !== 'accepted')
|
|
43
|
+
throw new Error('Background request already dispatched');
|
|
44
|
+
value.state = 'dispatching';
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
operation(owner, key, operation) {
|
|
48
|
+
this.update(owner, key, value => {
|
|
49
|
+
if (value.state !== 'dispatching')
|
|
50
|
+
throw new Error('Background request is not dispatching');
|
|
51
|
+
if (value.operations.some(prior => prior.operationId === operation.operationId))
|
|
52
|
+
throw new Error('Background operation already prepared');
|
|
53
|
+
value.operations.push(operation);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
finish(owner, key, result) { this.update(owner, key, value => { value.result = result; value.state = 'returned'; }); }
|
|
57
|
+
update(owner, key, change) {
|
|
58
|
+
this.alive();
|
|
59
|
+
this.context.transaction(() => {
|
|
60
|
+
const value = this.read(owner, key);
|
|
61
|
+
if (!value)
|
|
62
|
+
throw new Error('Background request not admitted');
|
|
63
|
+
change(value);
|
|
64
|
+
value.lastProgressAt = Date.now();
|
|
65
|
+
this.write(value);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
lifecycleReasons() {
|
|
69
|
+
return this.pending().map(record => ({ kind: 'task', id: storageKey(record.owner, record.key),
|
|
70
|
+
owner: record.owner, state: record.state, acceptedAt: record.acceptedAt ?? null,
|
|
71
|
+
writerFence: record.writerFence ?? null,
|
|
72
|
+
lastProgressAt: record.lastProgressAt ?? null, executionDeadline: null, nextDeadline: null,
|
|
73
|
+
operations: record.operations.map(({ operationId, taskId }) => ({ operationId, taskId })),
|
|
74
|
+
recovery: 'drain-accepted-background-request-until-journal-return-or-authoritative-handoff' }));
|
|
75
|
+
}
|
|
76
|
+
hasPending() {
|
|
77
|
+
this.alive();
|
|
78
|
+
return Boolean(this.context.db.prepare(`SELECT 1 FROM coordinator_state INDEXED BY background_requests_pending WHERE ${pendingPredicate} LIMIT 1`).get());
|
|
79
|
+
}
|
|
80
|
+
pending(limit = 128) {
|
|
81
|
+
this.alive();
|
|
82
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 128)
|
|
83
|
+
throw new Error('Background recovery batch limit must be 1..128');
|
|
84
|
+
return this.context.db.prepare(BACKGROUND_PENDING_QUERY).all(limit).map(row => JSON.parse(String(row.value)));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -35,9 +35,11 @@ export function readDiscoveryClaim(ctx, scope) {
|
|
|
35
35
|
/** Read scope transfer and its discovery claim from one SQLite snapshot. */
|
|
36
36
|
export function readDiscoveryState(ctx, scope) {
|
|
37
37
|
scope = requireId("scope", scope);
|
|
38
|
-
const row = getRow(ctx, `SELECT d.*, EXISTS(SELECT 1 FROM coordinator_state WHERE key = ?) AS managed
|
|
38
|
+
const row = getRow(ctx, `SELECT d.*, EXISTS(SELECT 1 FROM coordinator_state WHERE key = ?) AS managed,
|
|
39
|
+
EXISTS(SELECT 1 FROM operations INDEXED BY operations_assignment_cleanup
|
|
40
|
+
WHERE assignment_attempt_id IS NOT NULL) AS has_assignment_tasks
|
|
39
41
|
FROM (SELECT 1) LEFT JOIN discovery_claims d ON d.scope = ?`, "result-scope-v1:" + scope, scope);
|
|
40
|
-
return { managed: Number(row.managed) === 1, claim: row.scope == null ? null : mapClaim(row) };
|
|
42
|
+
return { managed: Number(row.managed) === 1, claim: row.scope == null ? null : mapClaim(row), hasAssignmentTasks: Number(row.has_assignment_tasks) === 1 };
|
|
41
43
|
}
|
|
42
44
|
export function tryClaimDiscovery(ctx, input) {
|
|
43
45
|
const scope = requireId("scope", input.scope);
|
|
@@ -13,13 +13,14 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { StoreError } from "./errors.mjs";
|
|
15
15
|
import { mapOperation, ownerFromRow, readOperation, requireOperation } from "./rows.mjs";
|
|
16
|
-
import { columnText, getRows, isUniqueViolation, run, } from "./sqlite.mjs";
|
|
17
|
-
import { describeOwnerDiff, normalizeOwner, optionalText, requireBoolean, requireEnum, requireEvidenceKind, requireId, requireObserver, requireOptionalCounter, requireText, sameOwner, } from "./validate.mjs";
|
|
16
|
+
import { columnJson, columnText, getRow, getRows, isUniqueViolation, run, } from "./sqlite.mjs";
|
|
17
|
+
import { describeOwnerDiff, normalizeOwner, optionalText, requireBoolean, requireCounter, requireEnum, requireEvidenceKind, requireId, requireObserver, requireOptionalCounter, requireText, sameOwner, } from "./validate.mjs";
|
|
18
18
|
import { mapOutbox } from "./rows.mjs";
|
|
19
19
|
import { settleWaitsForOperation } from "./waits.mjs";
|
|
20
20
|
import { bumpChangeRevision } from "./discovery.mjs";
|
|
21
21
|
const HEALTH_VALUES = ["active", "unmonitored", "lost"];
|
|
22
22
|
const OUTCOME_VALUES = ["succeeded", "failed", "cancelled", "lost"];
|
|
23
|
+
const ASSIGNMENT_CLEANUP_PAGE_MAX = 256;
|
|
23
24
|
function normalizeSupervision(value) {
|
|
24
25
|
if (value === undefined || value === null)
|
|
25
26
|
return null;
|
|
@@ -69,6 +70,9 @@ export function registerOperation(ctx, input) {
|
|
|
69
70
|
const taskId = requireId("taskId", input.taskId);
|
|
70
71
|
const launchToken = requireId("launchToken", input.launchToken);
|
|
71
72
|
const owner = normalizeOwner("owner", input.owner);
|
|
73
|
+
const assignmentAttemptId = input.assignmentAttemptId === undefined
|
|
74
|
+
? undefined
|
|
75
|
+
: requireId("assignmentAttemptId", input.assignmentAttemptId);
|
|
72
76
|
const observer = requireObserver("observer", input.observer);
|
|
73
77
|
const supervision = normalizeSupervision(input.supervision);
|
|
74
78
|
const authorityRef = optionalText("authorityRef", input.authorityRef, 512);
|
|
@@ -89,6 +93,8 @@ export function registerOperation(ctx, input) {
|
|
|
89
93
|
differences.push("taskId");
|
|
90
94
|
if (existing.launchToken !== launchToken)
|
|
91
95
|
differences.push("launchToken");
|
|
96
|
+
if (existing.assignmentAttemptId !== assignmentAttemptId)
|
|
97
|
+
differences.push("assignmentAttemptId");
|
|
92
98
|
if (!sameOwner(existing.owner, owner)) {
|
|
93
99
|
differences.push(`owner (${describeOwnerDiff(existing.owner, owner)})`);
|
|
94
100
|
}
|
|
@@ -106,14 +112,28 @@ export function registerOperation(ctx, input) {
|
|
|
106
112
|
return { operation: existing, created: false };
|
|
107
113
|
}
|
|
108
114
|
assertTaskAvailable();
|
|
115
|
+
if (assignmentAttemptId !== undefined) {
|
|
116
|
+
const binding = getRow(ctx, `SELECT b.owner_json, o.assignment_id AS terminal_assignment_id
|
|
117
|
+
FROM assignment_attempts a
|
|
118
|
+
JOIN assignment_bindings b ON b.assignment_id = a.assignment_id
|
|
119
|
+
LEFT JOIN assignment_outcomes o ON o.assignment_id = a.assignment_id
|
|
120
|
+
WHERE a.attempt_id = ?`, assignmentAttemptId);
|
|
121
|
+
const capturedOwner = binding && columnJson(binding, "owner_json");
|
|
122
|
+
if (!binding || !capturedOwner || !sameOwner(capturedOwner, owner)) {
|
|
123
|
+
throw new StoreError("foreign-owner", "Operation owner must match the captured owner of a registered assignment attempt.");
|
|
124
|
+
}
|
|
125
|
+
if (binding.terminal_assignment_id !== null) {
|
|
126
|
+
throw new StoreError("validation", "A terminal assignment cannot register a new operation.");
|
|
127
|
+
}
|
|
128
|
+
}
|
|
109
129
|
const at = ctx.now();
|
|
110
130
|
try {
|
|
111
131
|
run(ctx, `INSERT INTO operations (
|
|
112
132
|
operation_id, task_id, launch_token,
|
|
113
|
-
owner_kind, owner_session_id, owner_workspace, owner_branch_id, owner_goal_id,
|
|
133
|
+
owner_kind, owner_session_id, owner_workspace, owner_branch_id, owner_goal_id, assignment_attempt_id,
|
|
114
134
|
observer_kind, observer_version, supervision_json, supervision_host_id, authority_ref, intent_ref,
|
|
115
135
|
phase, health, health_reason, terminal_revision, created_at, updated_at
|
|
116
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'running', 'active', NULL, 0, ?, ?)`, operationId, taskId, launchToken, owner.kind, owner.sessionId, owner.workspace, owner.branchId ?? null, owner.goalId ?? null, observer.kind, observer.version, supervision ? JSON.stringify(supervision) : null, supervision?.hostId ?? null, authorityRef, intentRef, at, at);
|
|
136
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'running', 'active', NULL, 0, ?, ?)`, operationId, taskId, launchToken, owner.kind, owner.sessionId, owner.workspace, owner.branchId ?? null, owner.goalId ?? null, assignmentAttemptId ?? null, observer.kind, observer.version, supervision ? JSON.stringify(supervision) : null, supervision?.hostId ?? null, authorityRef, intentRef, at, at);
|
|
117
137
|
}
|
|
118
138
|
catch (error) {
|
|
119
139
|
// Another process may have registered the same launch (or the same task)
|
|
@@ -292,6 +312,26 @@ export function listOperations(ctx, filter = {}) {
|
|
|
292
312
|
return getRows(ctx, `SELECT *, EXISTS(SELECT 1 FROM coordinator_state s WHERE s.key = 'result-supervision-v1:' || operations.operation_id) AS result_managed FROM operations ${where} ORDER BY created_at, operation_id`, ...params)
|
|
293
313
|
.map(row => ({ ...mapOperation(row), resultManaged: Number(row.result_managed) === 1 }));
|
|
294
314
|
}
|
|
315
|
+
export function listAssignmentCleanupOperations(ctx, limit, afterOperationId) {
|
|
316
|
+
const requested = requireCounter("limit", limit);
|
|
317
|
+
if (requested === 0)
|
|
318
|
+
throw new StoreError("validation", "Invalid limit: must be at least 1");
|
|
319
|
+
const cursor = afterOperationId === undefined ? "" : requireId("afterOperationId", afterOperationId);
|
|
320
|
+
// Seek the partial index in cursor order rather than sorting all running operations.
|
|
321
|
+
return getRows(ctx, `SELECT op.*, EXISTS(SELECT 1 FROM coordinator_state s
|
|
322
|
+
WHERE s.key = 'result-supervision-v1:' || op.operation_id) AS result_managed
|
|
323
|
+
FROM operations op INDEXED BY operations_assignment_cleanup
|
|
324
|
+
JOIN assignment_attempts a ON a.attempt_id = op.assignment_attempt_id
|
|
325
|
+
JOIN assignment_outcomes o ON o.assignment_id = a.assignment_id
|
|
326
|
+
WHERE op.assignment_attempt_id IS NOT NULL AND op.operation_id > ?
|
|
327
|
+
AND (op.terminal_revision = 0 OR op.terminal_outcome = 'lost'
|
|
328
|
+
OR EXISTS (SELECT 1 FROM operation_evidence e WHERE e.operation_id = op.operation_id
|
|
329
|
+
AND e.terminal_revision = op.terminal_revision AND e.kind = 'terminal-record'
|
|
330
|
+
AND e.summary LIKE '%groupCleanup=unproven%'))
|
|
331
|
+
AND NOT EXISTS (SELECT 1 FROM coordinator_state s WHERE s.key = 'assignment-cleanup-verified:' || op.operation_id)
|
|
332
|
+
ORDER BY op.operation_id LIMIT ?`, cursor, Math.min(requested, ASSIGNMENT_CLEANUP_PAGE_MAX))
|
|
333
|
+
.map(row => ({ ...mapOperation(row), resultManaged: Number(row.result_managed) === 1 }));
|
|
334
|
+
}
|
|
295
335
|
/** Running operations assigned to one supervising host, using the phase/host index. */
|
|
296
336
|
export function listRunningSupervisedBy(ctx, hostId) {
|
|
297
337
|
return getRows(ctx, "SELECT *, EXISTS(SELECT 1 FROM coordinator_state s WHERE s.key = 'result-supervision-v1:' || operations.operation_id) AS result_managed FROM operations WHERE phase = 'running' AND supervision_host_id = ? ORDER BY created_at, operation_id", requireId("hostId", hostId)).map(row => ({ ...mapOperation(row), resultManaged: Number(row.result_managed) === 1 }));
|
|
@@ -4,6 +4,18 @@ import { getRow, run } from "./sqlite.mjs";
|
|
|
4
4
|
import { getOperation, recordSupervision, recordTerminalOutcome } from "./operations.mjs";
|
|
5
5
|
import { requireId, requirePath } from "./validate.mjs";
|
|
6
6
|
const PREFIX = "result-supervision-v1:";
|
|
7
|
+
/** A bounded observation page. A gap requires restoring active authority, not history. */
|
|
8
|
+
export function resultSupervisionChanges(ctx, after) {
|
|
9
|
+
const generation = String(ctx.db.prepare("SELECT generation FROM assignment_change_source WHERE singleton=1").get().generation);
|
|
10
|
+
const bounds = ctx.db.prepare("SELECT min(seq) AS first, max(seq) AS last FROM assignment_changes").get();
|
|
11
|
+
const last = Number(bounds.last ?? 0);
|
|
12
|
+
const reset = !after || after.generation !== generation || after.seq > last
|
|
13
|
+
|| (bounds.first !== null && after.seq < Number(bounds.first) - 1);
|
|
14
|
+
const rows = reset ? [] : ctx.db.prepare("SELECT seq, entity, entity_id FROM assignment_changes WHERE seq>? ORDER BY seq LIMIT 128").all(after.seq);
|
|
15
|
+
const seq = reset ? last : Number(rows.at(-1)?.seq ?? after.seq);
|
|
16
|
+
return { generation, seq, reset, more: seq < last,
|
|
17
|
+
operationIds: [...new Set(rows.filter(row => row.entity === "background:operation").map(row => String(row.entity_id)))] };
|
|
18
|
+
}
|
|
7
19
|
export function resultSupervisions(ctx, activeOnly = false) {
|
|
8
20
|
const rows = activeOnly
|
|
9
21
|
? 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)
|
|
@@ -27,11 +27,13 @@ export function getOperationRowByTask(ctx, taskId) {
|
|
|
27
27
|
return getRow(ctx, "SELECT * FROM operations WHERE task_id = ?", taskId);
|
|
28
28
|
}
|
|
29
29
|
export function mapOperation(row) {
|
|
30
|
+
const assignmentAttemptId = columnNullableText(row, "assignment_attempt_id");
|
|
30
31
|
return {
|
|
31
32
|
operationId: columnText(row, "operation_id"),
|
|
32
33
|
taskId: columnText(row, "task_id"),
|
|
33
34
|
launchToken: columnText(row, "launch_token"),
|
|
34
35
|
owner: ownerFromRow(row),
|
|
36
|
+
...(assignmentAttemptId === null ? {} : { assignmentAttemptId }),
|
|
35
37
|
observer: {
|
|
36
38
|
kind: columnText(row, "observer_kind"),
|
|
37
39
|
version: columnText(row, "observer_version"),
|