@zhin.js/agent 1.1.13 → 1.1.14
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/README.md +40 -20
- package/lib/ai-event-bus.d.ts +1 -1
- package/lib/ai-hook-handlers.d.ts +1 -1
- package/lib/assistant/config.d.ts +3 -17
- package/lib/assistant/config.d.ts.map +1 -1
- package/lib/assistant/config.js +1 -8
- package/lib/assistant/config.js.map +1 -1
- package/lib/assistant/index.d.ts +6 -9
- package/lib/assistant/index.d.ts.map +1 -1
- package/lib/assistant/index.js +4 -6
- package/lib/assistant/index.js.map +1 -1
- package/lib/assistant/job-engine.d.ts +0 -4
- package/lib/assistant/job-engine.d.ts.map +1 -1
- package/lib/assistant/job-engine.js +0 -2
- package/lib/assistant/job-engine.js.map +1 -1
- package/lib/assistant/job-store.d.ts +1 -8
- package/lib/assistant/job-store.d.ts.map +1 -1
- package/lib/assistant/job-store.js +3 -9
- package/lib/assistant/job-store.js.map +1 -1
- package/lib/assistant/job-worker.d.ts +2 -3
- package/lib/assistant/job-worker.d.ts.map +1 -1
- package/lib/assistant/job-worker.js +15 -25
- package/lib/assistant/job-worker.js.map +1 -1
- package/lib/assistant/runtime-contract.d.ts +22 -0
- package/lib/assistant/runtime-contract.d.ts.map +1 -0
- package/lib/assistant/runtime-contract.js +2 -0
- package/lib/assistant/runtime-contract.js.map +1 -0
- package/lib/assistant/types.d.ts +0 -10
- package/lib/assistant/types.d.ts.map +1 -1
- package/lib/assistant/types.js +0 -4
- package/lib/assistant/types.js.map +1 -1
- package/lib/authoring/bridge.d.ts +1 -1
- package/lib/authoring/index.d.ts +0 -4
- package/lib/authoring/index.d.ts.map +1 -1
- package/lib/authoring/index.js +0 -2
- package/lib/authoring/index.js.map +1 -1
- package/lib/authoring/types.d.ts +3 -39
- package/lib/authoring/types.d.ts.map +1 -1
- package/lib/authoring/types.js.map +1 -1
- package/lib/builtin/bash-tool.d.ts.map +1 -1
- package/lib/builtin/bash-tool.js +15 -2
- package/lib/builtin/bash-tool.js.map +1 -1
- package/lib/builtin/five-agent/index.d.ts +0 -1
- package/lib/builtin/five-agent/index.d.ts.map +1 -1
- package/lib/builtin/five-agent/index.js +0 -1
- package/lib/builtin/five-agent/index.js.map +1 -1
- package/lib/builtin/five-agent/role-capability-policy.d.ts +1 -1
- package/lib/builtin/five-agent/role-capability-policy.d.ts.map +1 -1
- package/lib/builtin/five-agent/role-capability-policy.js +1 -1
- package/lib/builtin/five-agent/role-capability-policy.js.map +1 -1
- package/lib/builtin/spawn-task-tool.d.ts +1 -1
- package/lib/builtin/spawn-task-tool.d.ts.map +1 -1
- package/lib/builtin/spawn-task-tool.js +4 -100
- package/lib/builtin/spawn-task-tool.js.map +1 -1
- package/lib/builtin-tools.d.ts +0 -2
- package/lib/builtin-tools.d.ts.map +1 -1
- package/lib/builtin-tools.js +0 -6
- package/lib/builtin-tools.js.map +1 -1
- package/lib/common-adapter-tools.d.ts +1 -1
- package/lib/config/agent-interfaces.d.ts +2 -1
- package/lib/config/agent-interfaces.d.ts.map +1 -1
- package/lib/config/index.d.ts +3 -3
- package/lib/config/index.d.ts.map +1 -1
- package/lib/config/index.js +2 -2
- package/lib/config/index.js.map +1 -1
- package/lib/config/keyword-triggers.d.ts +0 -1
- package/lib/config/keyword-triggers.d.ts.map +1 -1
- package/lib/config/keyword-triggers.js +0 -1
- package/lib/config/keyword-triggers.js.map +1 -1
- package/lib/config/normalize-ai-config.d.ts.map +1 -1
- package/lib/config/normalize-ai-config.js +9 -0
- package/lib/config/normalize-ai-config.js.map +1 -1
- package/lib/config/validate-ai-config.d.ts +1 -0
- package/lib/config/validate-ai-config.d.ts.map +1 -1
- package/lib/config/validate-ai-config.js +179 -0
- package/lib/config/validate-ai-config.js.map +1 -1
- package/lib/config/zhin-agent-config.d.ts +0 -3
- package/lib/config/zhin-agent-config.d.ts.map +1 -1
- package/lib/config/zhin-agent-constants.d.ts +0 -3
- package/lib/config/zhin-agent-constants.d.ts.map +1 -1
- package/lib/config/zhin-agent-constants.js +0 -14
- package/lib/config/zhin-agent-constants.js.map +1 -1
- package/lib/config/zhin-agent-defaults.d.ts.map +1 -1
- package/lib/config/zhin-agent-defaults.js +0 -3
- package/lib/config/zhin-agent-defaults.js.map +1 -1
- package/lib/config/zhin-agent-dependencies.d.ts +4 -5
- package/lib/config/zhin-agent-dependencies.d.ts.map +1 -1
- package/lib/context/context-system.d.ts +2 -1
- package/lib/context/context-system.d.ts.map +1 -1
- package/lib/context/context-system.js +1 -0
- package/lib/context/context-system.js.map +1 -1
- package/lib/context/context-tail-limit.d.ts +2 -2
- package/lib/context/context-tail-limit.d.ts.map +1 -1
- package/lib/context/context-tail-limit.js +2 -3
- package/lib/context/context-tail-limit.js.map +1 -1
- package/lib/context/im-turn-context-adapter.d.ts +1 -2
- package/lib/context/im-turn-context-adapter.d.ts.map +1 -1
- package/lib/context/im-turn-context-adapter.js +1 -5
- package/lib/context/im-turn-context-adapter.js.map +1 -1
- package/lib/context/turn-envelope.d.ts +1 -1
- package/lib/context/turn-envelope.d.ts.map +1 -1
- package/lib/context/turn-envelope.js +4 -0
- package/lib/context/turn-envelope.js.map +1 -1
- package/lib/context/turn-user-message.d.ts +1 -1
- package/lib/context/turn-user-message.d.ts.map +1 -1
- package/lib/context/turn-user-message.js +3 -3
- package/lib/context/turn-user-message.js.map +1 -1
- package/lib/core/agent-core-run.d.ts.map +1 -1
- package/lib/core/agent-core-run.js +36 -12
- package/lib/core/agent-core-run.js.map +1 -1
- package/lib/core/agent-loop-standalone.d.ts +1 -1
- package/lib/core/agent-loop-standalone.js +13 -6
- package/lib/core/agent-loop-standalone.js.map +1 -1
- package/lib/core/tool-execution-authority.d.ts +2 -2
- package/lib/core/tool-execution-authority.d.ts.map +1 -1
- package/lib/data-governance/data-governance.d.ts +198 -0
- package/lib/data-governance/data-governance.d.ts.map +1 -0
- package/lib/data-governance/data-governance.js +660 -0
- package/lib/data-governance/data-governance.js.map +1 -0
- package/lib/data-governance/database-payload-lifecycle-repository.d.ts +68 -0
- package/lib/data-governance/database-payload-lifecycle-repository.d.ts.map +1 -0
- package/lib/data-governance/database-payload-lifecycle-repository.js +226 -0
- package/lib/data-governance/database-payload-lifecycle-repository.js.map +1 -0
- package/lib/data-governance/disclosure-manifest.d.ts +110 -0
- package/lib/data-governance/disclosure-manifest.d.ts.map +1 -0
- package/lib/data-governance/disclosure-manifest.js +264 -0
- package/lib/data-governance/disclosure-manifest.js.map +1 -0
- package/lib/data-governance/encrypted-database-payload-vault.d.ts +107 -0
- package/lib/data-governance/encrypted-database-payload-vault.d.ts.map +1 -0
- package/lib/data-governance/encrypted-database-payload-vault.js +236 -0
- package/lib/data-governance/encrypted-database-payload-vault.js.map +1 -0
- package/lib/data-governance/encrypted-file-payload-vault.d.ts +117 -0
- package/lib/data-governance/encrypted-file-payload-vault.d.ts.map +1 -0
- package/lib/data-governance/encrypted-file-payload-vault.js +507 -0
- package/lib/data-governance/encrypted-file-payload-vault.js.map +1 -0
- package/lib/data-governance/file-payload-lifecycle-repository.d.ts +19 -0
- package/lib/data-governance/file-payload-lifecycle-repository.d.ts.map +1 -0
- package/lib/data-governance/file-payload-lifecycle-repository.js +194 -0
- package/lib/data-governance/file-payload-lifecycle-repository.js.map +1 -0
- package/lib/data-governance/governance-authority-repository.d.ts +148 -0
- package/lib/data-governance/governance-authority-repository.d.ts.map +1 -0
- package/lib/data-governance/governance-authority-repository.js +439 -0
- package/lib/data-governance/governance-authority-repository.js.map +1 -0
- package/lib/data-governance/governed-payload-write-saga.d.ts +126 -0
- package/lib/data-governance/governed-payload-write-saga.d.ts.map +1 -0
- package/lib/data-governance/governed-payload-write-saga.js +471 -0
- package/lib/data-governance/governed-payload-write-saga.js.map +1 -0
- package/lib/data-governance/payload-hold-overdue-projection.d.ts +57 -0
- package/lib/data-governance/payload-hold-overdue-projection.d.ts.map +1 -0
- package/lib/data-governance/payload-hold-overdue-projection.js +80 -0
- package/lib/data-governance/payload-hold-overdue-projection.js.map +1 -0
- package/lib/data-governance/payload-lifecycle.d.ts +359 -0
- package/lib/data-governance/payload-lifecycle.d.ts.map +1 -0
- package/lib/data-governance/payload-lifecycle.js +930 -0
- package/lib/data-governance/payload-lifecycle.js.map +1 -0
- package/lib/data-governance/payload-vault-storage-handoff.d.ts +255 -0
- package/lib/data-governance/payload-vault-storage-handoff.d.ts.map +1 -0
- package/lib/data-governance/payload-vault-storage-handoff.js +471 -0
- package/lib/data-governance/payload-vault-storage-handoff.js.map +1 -0
- package/lib/defaults/hooks.d.ts +2 -2
- package/lib/defaults/hooks.d.ts.map +1 -1
- package/lib/defaults/hooks.js +2 -2
- package/lib/defaults/hooks.js.map +1 -1
- package/lib/defaults/subagents.d.ts +2 -2
- package/lib/defaults/subagents.d.ts.map +1 -1
- package/lib/defaults/subagents.js +2 -2
- package/lib/defaults/subagents.js.map +1 -1
- package/lib/defaults/tools.d.ts +1 -2
- package/lib/defaults/tools.js +2 -2
- package/lib/defaults/tools.js.map +1 -1
- package/lib/discovery/agent-surface-info.d.ts +0 -2
- package/lib/discovery/agent-surface-info.d.ts.map +1 -1
- package/lib/discovery/agent-surface-info.js +0 -5
- package/lib/discovery/agent-surface-info.js.map +1 -1
- package/lib/discovery/agent-surface.d.ts.map +1 -1
- package/lib/discovery/agent-surface.js +0 -39
- package/lib/discovery/agent-surface.js.map +1 -1
- package/lib/event/agent-stream-hooks.d.ts +1 -1
- package/lib/event/hook-stream-sink.d.ts +1 -1
- package/lib/event/publish-agent-stream.d.ts +3 -3
- package/lib/event/publish-agent-stream.d.ts.map +1 -1
- package/lib/event/publish-agent-stream.js +1 -1
- package/lib/event/publish-agent-stream.js.map +1 -1
- package/lib/event/session-events.d.ts +1 -1
- package/lib/event/turn-event.d.ts +22 -2
- package/lib/event/turn-event.d.ts.map +1 -1
- package/lib/event/turn-event.js.map +1 -1
- package/lib/event/turn-to-agent-stream.js +6 -0
- package/lib/event/turn-to-agent-stream.js.map +1 -1
- package/lib/features/agent-feature.d.ts +1 -1
- package/lib/features/mcp-feature.d.ts +1 -1
- package/lib/index.d.ts +99 -33
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +94 -21
- package/lib/index.js.map +1 -1
- package/lib/ingress/capability-ingress.d.ts +5 -5
- package/lib/ingress/capability-ingress.d.ts.map +1 -1
- package/lib/ingress/capability-ingress.js +26 -26
- package/lib/ingress/capability-ingress.js.map +1 -1
- package/lib/init/activate-ai-database-storage.d.ts +5 -3
- package/lib/init/activate-ai-database-storage.d.ts.map +1 -1
- package/lib/init/activate-ai-database-storage.js +23 -32
- package/lib/init/activate-ai-database-storage.js.map +1 -1
- package/lib/init/configure-zhin-agent.d.ts +1 -1
- package/lib/init/configure-zhin-agent.d.ts.map +1 -1
- package/lib/init/configure-zhin-agent.js +3 -5
- package/lib/init/configure-zhin-agent.js.map +1 -1
- package/lib/init/define-ai-database-models.d.ts.map +1 -1
- package/lib/init/define-ai-database-models.js +21 -5
- package/lib/init/define-ai-database-models.js.map +1 -1
- package/lib/init/dispose-zhin-agent.d.ts +1 -3
- package/lib/init/dispose-zhin-agent.d.ts.map +1 -1
- package/lib/init/dispose-zhin-agent.js +0 -2
- package/lib/init/dispose-zhin-agent.js.map +1 -1
- package/lib/init/introspection-collectors.d.ts +1 -1
- package/lib/init/introspection-collectors.d.ts.map +1 -1
- package/lib/init/introspection-collectors.js +13 -14
- package/lib/init/introspection-collectors.js.map +1 -1
- package/lib/internal/agent-host.d.ts +5 -8
- package/lib/internal/agent-host.d.ts.map +1 -1
- package/lib/internal/host-types.d.ts +4 -0
- package/lib/internal/host-types.d.ts.map +1 -1
- package/lib/journal/persistent-turn-journal.d.ts +5 -1
- package/lib/journal/persistent-turn-journal.d.ts.map +1 -1
- package/lib/journal/persistent-turn-journal.js +11 -1
- package/lib/journal/persistent-turn-journal.js.map +1 -1
- package/lib/mcp-client/bridge.d.ts +1 -1
- package/lib/mcp-client/connection.d.ts +1 -1
- package/lib/mcp-client/index.d.ts +1 -1
- package/lib/media/media-normalize.d.ts +9 -5
- package/lib/media/media-normalize.d.ts.map +1 -1
- package/lib/media/media-normalize.js +125 -69
- package/lib/media/media-normalize.js.map +1 -1
- package/lib/media/media-publisher.d.ts.map +1 -1
- package/lib/media/media-publisher.js +48 -3
- package/lib/media/media-publisher.js.map +1 -1
- package/lib/media/vision-capability.js +1 -1
- package/lib/media/vision-capability.js.map +1 -1
- package/lib/memory/index.d.ts +1 -1
- package/lib/memory/index.d.ts.map +1 -1
- package/lib/plugin-ai-hook-bus.d.ts +1 -1
- package/lib/plugin-runtime/agent-host-port.d.ts +66 -4
- package/lib/plugin-runtime/agent-host-port.d.ts.map +1 -1
- package/lib/plugin-runtime/agent-host-port.js.map +1 -1
- package/lib/plugin-runtime/agent-runtime.d.ts +3 -0
- package/lib/plugin-runtime/agent-runtime.d.ts.map +1 -1
- package/lib/plugin-runtime/agent-runtime.js +73 -3
- package/lib/plugin-runtime/agent-runtime.js.map +1 -1
- package/lib/plugin-runtime/agent-trace-runtime.d.ts +37 -0
- package/lib/plugin-runtime/agent-trace-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/agent-trace-runtime.js +150 -0
- package/lib/plugin-runtime/agent-trace-runtime.js.map +1 -0
- package/lib/plugin-runtime/capability-tools.js +2 -2
- package/lib/plugin-runtime/capability-tools.js.map +1 -1
- package/lib/plugin-runtime/database-overlay-pack-promotion-repository.d.ts +70 -0
- package/lib/plugin-runtime/database-overlay-pack-promotion-repository.d.ts.map +1 -0
- package/lib/plugin-runtime/database-overlay-pack-promotion-repository.js +203 -0
- package/lib/plugin-runtime/database-overlay-pack-promotion-repository.js.map +1 -0
- package/lib/plugin-runtime/deferred-capability-plan.d.ts +26 -0
- package/lib/plugin-runtime/deferred-capability-plan.d.ts.map +1 -1
- package/lib/plugin-runtime/deferred-capability-plan.js +98 -4
- package/lib/plugin-runtime/deferred-capability-plan.js.map +1 -1
- package/lib/plugin-runtime/full-agent-turn-engine.js +48 -5
- package/lib/plugin-runtime/full-agent-turn-engine.js.map +1 -1
- package/lib/plugin-runtime/host-mcp-projection.d.ts +1 -1
- package/lib/plugin-runtime/index.d.ts +66 -0
- package/lib/plugin-runtime/index.d.ts.map +1 -1
- package/lib/plugin-runtime/index.js +65 -0
- package/lib/plugin-runtime/index.js.map +1 -1
- package/lib/plugin-runtime/native-interaction-tools.js +1 -1
- package/lib/plugin-runtime/native-interaction-tools.js.map +1 -1
- package/lib/plugin-runtime/native-semantic-memory-tools.d.ts +17 -0
- package/lib/plugin-runtime/native-semantic-memory-tools.d.ts.map +1 -0
- package/lib/plugin-runtime/native-semantic-memory-tools.js +169 -0
- package/lib/plugin-runtime/native-semantic-memory-tools.js.map +1 -0
- package/lib/plugin-runtime/turn-intent-resolver.d.ts +20 -0
- package/lib/plugin-runtime/turn-intent-resolver.d.ts.map +1 -0
- package/lib/plugin-runtime/turn-intent-resolver.js +8 -0
- package/lib/plugin-runtime/turn-intent-resolver.js.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-authority.d.ts +5 -0
- package/lib/plugin-runtime/workroom-acceptance-authority.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-authority.js +14 -0
- package/lib/plugin-runtime/workroom-acceptance-authority.js.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-fact-providers.d.ts +233 -0
- package/lib/plugin-runtime/workroom-acceptance-fact-providers.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-fact-providers.js +517 -0
- package/lib/plugin-runtime/workroom-acceptance-fact-providers.js.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-internal-providers.d.ts +139 -0
- package/lib/plugin-runtime/workroom-acceptance-internal-providers.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-internal-providers.js +430 -0
- package/lib/plugin-runtime/workroom-acceptance-internal-providers.js.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-policy.d.ts +4 -0
- package/lib/plugin-runtime/workroom-acceptance-policy.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-policy.js +20 -0
- package/lib/plugin-runtime/workroom-acceptance-policy.js.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-production-composition.d.ts +175 -0
- package/lib/plugin-runtime/workroom-acceptance-production-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-production-composition.js +793 -0
- package/lib/plugin-runtime/workroom-acceptance-production-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-provider-composition.d.ts +186 -0
- package/lib/plugin-runtime/workroom-acceptance-provider-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-provider-composition.js +553 -0
- package/lib/plugin-runtime/workroom-acceptance-provider-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-accepted-source-runtime.d.ts +75 -0
- package/lib/plugin-runtime/workroom-accepted-source-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-accepted-source-runtime.js +267 -0
- package/lib/plugin-runtime/workroom-accepted-source-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-assignment-authority-grant-runtime.d.ts +42 -0
- package/lib/plugin-runtime/workroom-assignment-authority-grant-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-assignment-authority-grant-runtime.js +90 -0
- package/lib/plugin-runtime/workroom-assignment-authority-grant-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-assignment-authority-provider.d.ts +159 -0
- package/lib/plugin-runtime/workroom-assignment-authority-provider.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-assignment-authority-provider.js +595 -0
- package/lib/plugin-runtime/workroom-assignment-authority-provider.js.map +1 -0
- package/lib/plugin-runtime/workroom-assignment-knowledge-composition.d.ts +58 -0
- package/lib/plugin-runtime/workroom-assignment-knowledge-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-assignment-knowledge-composition.js +218 -0
- package/lib/plugin-runtime/workroom-assignment-knowledge-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-authority-writer.d.ts +47 -0
- package/lib/plugin-runtime/workroom-data-governance-authority-writer.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-authority-writer.js +115 -0
- package/lib/plugin-runtime/workroom-data-governance-authority-writer.js.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-composition.d.ts +28 -0
- package/lib/plugin-runtime/workroom-data-governance-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-composition.js +41 -0
- package/lib/plugin-runtime/workroom-data-governance-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-root-provider.d.ts +51 -0
- package/lib/plugin-runtime/workroom-data-governance-root-provider.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-root-provider.js +66 -0
- package/lib/plugin-runtime/workroom-data-governance-root-provider.js.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-runtime.d.ts +134 -0
- package/lib/plugin-runtime/workroom-data-governance-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-runtime.js +1253 -0
- package/lib/plugin-runtime/workroom-data-governance-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-storage.d.ts +66 -0
- package/lib/plugin-runtime/workroom-data-governance-storage.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-storage.js +160 -0
- package/lib/plugin-runtime/workroom-data-governance-storage.js.map +1 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-composition.d.ts +37 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-composition.js +131 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-console.d.ts +238 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-console.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-console.js +495 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-console.js.map +1 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-human-ingress.d.ts +15 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-human-ingress.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-human-ingress.js +119 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-human-ingress.js.map +1 -0
- package/lib/plugin-runtime/workroom-dynamic-planning-provider.d.ts +142 -0
- package/lib/plugin-runtime/workroom-dynamic-planning-provider.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-dynamic-planning-provider.js +301 -0
- package/lib/plugin-runtime/workroom-dynamic-planning-provider.js.map +1 -0
- package/lib/plugin-runtime/workroom-dynamic-planning.d.ts +4 -0
- package/lib/plugin-runtime/workroom-dynamic-planning.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-dynamic-planning.js +13 -0
- package/lib/plugin-runtime/workroom-dynamic-planning.js.map +1 -0
- package/lib/plugin-runtime/workroom-effect-composition.d.ts +37 -0
- package/lib/plugin-runtime/workroom-effect-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-effect-composition.js +69 -0
- package/lib/plugin-runtime/workroom-effect-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-effect-production.d.ts +133 -0
- package/lib/plugin-runtime/workroom-effect-production.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-effect-production.js +272 -0
- package/lib/plugin-runtime/workroom-effect-production.js.map +1 -0
- package/lib/plugin-runtime/workroom-effect-runtime.d.ts +72 -0
- package/lib/plugin-runtime/workroom-effect-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-effect-runtime.js +179 -0
- package/lib/plugin-runtime/workroom-effect-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-governed-dispatch-composition.d.ts +27 -0
- package/lib/plugin-runtime/workroom-governed-dispatch-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-governed-dispatch-composition.js +40 -0
- package/lib/plugin-runtime/workroom-governed-dispatch-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-governed-dispatch-reasons.d.ts +10 -0
- package/lib/plugin-runtime/workroom-governed-dispatch-reasons.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-governed-dispatch-reasons.js +20 -0
- package/lib/plugin-runtime/workroom-governed-dispatch-reasons.js.map +1 -0
- package/lib/plugin-runtime/workroom-journal-payload-composition.d.ts +16 -0
- package/lib/plugin-runtime/workroom-journal-payload-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-journal-payload-composition.js +69 -0
- package/lib/plugin-runtime/workroom-journal-payload-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-local-agent-core-adapter.d.ts +17 -0
- package/lib/plugin-runtime/workroom-local-agent-core-adapter.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-local-agent-core-adapter.js +101 -0
- package/lib/plugin-runtime/workroom-local-agent-core-adapter.js.map +1 -0
- package/lib/plugin-runtime/workroom-local-agent-loop.d.ts +90 -0
- package/lib/plugin-runtime/workroom-local-agent-loop.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-local-agent-loop.js +303 -0
- package/lib/plugin-runtime/workroom-local-agent-loop.js.map +1 -0
- package/lib/plugin-runtime/workroom-local-assignment-authority.d.ts +5 -0
- package/lib/plugin-runtime/workroom-local-assignment-authority.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-local-assignment-authority.js +16 -0
- package/lib/plugin-runtime/workroom-local-assignment-authority.js.map +1 -0
- package/lib/plugin-runtime/workroom-local-assignment-runtime.d.ts +33 -0
- package/lib/plugin-runtime/workroom-local-assignment-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-local-assignment-runtime.js +189 -0
- package/lib/plugin-runtime/workroom-local-assignment-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-local-assignment-supply.d.ts +39 -0
- package/lib/plugin-runtime/workroom-local-assignment-supply.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-local-assignment-supply.js +107 -0
- package/lib/plugin-runtime/workroom-local-assignment-supply.js.map +1 -0
- package/lib/plugin-runtime/workroom-overlay-pack-promotion.d.ts +145 -0
- package/lib/plugin-runtime/workroom-overlay-pack-promotion.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-overlay-pack-promotion.js +516 -0
- package/lib/plugin-runtime/workroom-overlay-pack-promotion.js.map +1 -0
- package/lib/plugin-runtime/workroom-payload-processor-recall.d.ts +91 -0
- package/lib/plugin-runtime/workroom-payload-processor-recall.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-payload-processor-recall.js +189 -0
- package/lib/plugin-runtime/workroom-payload-processor-recall.js.map +1 -0
- package/lib/plugin-runtime/workroom-plan-gate-authority.d.ts +7 -0
- package/lib/plugin-runtime/workroom-plan-gate-authority.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-plan-gate-authority.js +40 -0
- package/lib/plugin-runtime/workroom-plan-gate-authority.js.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-capacity.d.ts +132 -0
- package/lib/plugin-runtime/workroom-portfolio-capacity.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-capacity.js +189 -0
- package/lib/plugin-runtime/workroom-portfolio-capacity.js.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-checkpoint-ack.d.ts +38 -0
- package/lib/plugin-runtime/workroom-portfolio-checkpoint-ack.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-checkpoint-ack.js +103 -0
- package/lib/plugin-runtime/workroom-portfolio-checkpoint-ack.js.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-control-composition.d.ts +30 -0
- package/lib/plugin-runtime/workroom-portfolio-control-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-control-composition.js +102 -0
- package/lib/plugin-runtime/workroom-portfolio-control-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-control-runtime.d.ts +41 -0
- package/lib/plugin-runtime/workroom-portfolio-control-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-control-runtime.js +208 -0
- package/lib/plugin-runtime/workroom-portfolio-control-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-grant-assignment.d.ts +141 -0
- package/lib/plugin-runtime/workroom-portfolio-grant-assignment.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-grant-assignment.js +331 -0
- package/lib/plugin-runtime/workroom-portfolio-grant-assignment.js.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-kernel-authority.d.ts +23 -0
- package/lib/plugin-runtime/workroom-portfolio-kernel-authority.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-kernel-authority.js +82 -0
- package/lib/plugin-runtime/workroom-portfolio-kernel-authority.js.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-sponsor.d.ts +96 -0
- package/lib/plugin-runtime/workroom-portfolio-sponsor.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-sponsor.js +313 -0
- package/lib/plugin-runtime/workroom-portfolio-sponsor.js.map +1 -0
- package/lib/plugin-runtime/workroom-preemption-runtime.d.ts +57 -0
- package/lib/plugin-runtime/workroom-preemption-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-preemption-runtime.js +163 -0
- package/lib/plugin-runtime/workroom-preemption-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-priority-authority.d.ts +11 -0
- package/lib/plugin-runtime/workroom-priority-authority.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-priority-authority.js +72 -0
- package/lib/plugin-runtime/workroom-priority-authority.js.map +1 -0
- package/lib/plugin-runtime/workroom-profile-authority-composition.d.ts +61 -0
- package/lib/plugin-runtime/workroom-profile-authority-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-profile-authority-composition.js +231 -0
- package/lib/plugin-runtime/workroom-profile-authority-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-profile-authority-runtime.d.ts +228 -0
- package/lib/plugin-runtime/workroom-profile-authority-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-profile-authority-runtime.js +1132 -0
- package/lib/plugin-runtime/workroom-profile-authority-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-projection-outbound.d.ts +10 -0
- package/lib/plugin-runtime/workroom-projection-outbound.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-projection-outbound.js +35 -0
- package/lib/plugin-runtime/workroom-projection-outbound.js.map +1 -0
- package/lib/plugin-runtime/workroom-projection-runtime.d.ts +87 -0
- package/lib/plugin-runtime/workroom-projection-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-projection-runtime.js +421 -0
- package/lib/plugin-runtime/workroom-projection-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-remote-assignment-authority.d.ts +9 -0
- package/lib/plugin-runtime/workroom-remote-assignment-authority.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-remote-assignment-authority.js +20 -0
- package/lib/plugin-runtime/workroom-remote-assignment-authority.js.map +1 -0
- package/lib/plugin-runtime/workroom-remote-callback-runtime.d.ts +38 -0
- package/lib/plugin-runtime/workroom-remote-callback-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-remote-callback-runtime.js +80 -0
- package/lib/plugin-runtime/workroom-remote-callback-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-remote-executor.d.ts +20 -0
- package/lib/plugin-runtime/workroom-remote-executor.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-remote-executor.js +42 -0
- package/lib/plugin-runtime/workroom-remote-executor.js.map +1 -0
- package/lib/plugin-runtime/workroom-reviewer-authority-runtime.d.ts +72 -0
- package/lib/plugin-runtime/workroom-reviewer-authority-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-reviewer-authority-runtime.js +142 -0
- package/lib/plugin-runtime/workroom-reviewer-authority-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-risk-acceptance-runtime.d.ts +112 -0
- package/lib/plugin-runtime/workroom-risk-acceptance-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-risk-acceptance-runtime.js +376 -0
- package/lib/plugin-runtime/workroom-risk-acceptance-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-run-profile-pin-authority.d.ts +42 -0
- package/lib/plugin-runtime/workroom-run-profile-pin-authority.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-run-profile-pin-authority.js +125 -0
- package/lib/plugin-runtime/workroom-run-profile-pin-authority.js.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-composition.d.ts +25 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-composition.js +79 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-contract.d.ts +16 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-contract.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-contract.js +49 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-contract.js.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-request-authority.d.ts +63 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-request-authority.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-request-authority.js +233 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-request-authority.js.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-supply.d.ts +37 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-supply.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-supply.js +122 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-supply.js.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-route-registry.d.ts +27 -0
- package/lib/plugin-runtime/workroom-scheduler-route-registry.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-route-registry.js +136 -0
- package/lib/plugin-runtime/workroom-scheduler-route-registry.js.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-runtime.d.ts +84 -0
- package/lib/plugin-runtime/workroom-scheduler-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-runtime.js +231 -0
- package/lib/plugin-runtime/workroom-scheduler-runtime.js.map +1 -0
- package/lib/portfolio/capacity-control-outbox.d.ts +174 -0
- package/lib/portfolio/capacity-control-outbox.d.ts.map +1 -0
- package/lib/portfolio/capacity-control-outbox.js +338 -0
- package/lib/portfolio/capacity-control-outbox.js.map +1 -0
- package/lib/portfolio/database-capacity-control-outbox.d.ts +62 -0
- package/lib/portfolio/database-capacity-control-outbox.d.ts.map +1 -0
- package/lib/portfolio/database-capacity-control-outbox.js +166 -0
- package/lib/portfolio/database-capacity-control-outbox.js.map +1 -0
- package/lib/portfolio/file-capacity-control-outbox.d.ts +10 -0
- package/lib/portfolio/file-capacity-control-outbox.d.ts.map +1 -0
- package/lib/portfolio/file-capacity-control-outbox.js +113 -0
- package/lib/portfolio/file-capacity-control-outbox.js.map +1 -0
- package/lib/portfolio/file-portfolio-journal.d.ts +11 -0
- package/lib/portfolio/file-portfolio-journal.d.ts.map +1 -0
- package/lib/portfolio/file-portfolio-journal.js +196 -0
- package/lib/portfolio/file-portfolio-journal.js.map +1 -0
- package/lib/portfolio/portfolio-admission.d.ts +95 -0
- package/lib/portfolio/portfolio-admission.d.ts.map +1 -0
- package/lib/portfolio/portfolio-admission.js +1080 -0
- package/lib/portfolio/portfolio-admission.js.map +1 -0
- package/lib/portfolio/portfolio-journal.d.ts +359 -0
- package/lib/portfolio/portfolio-journal.d.ts.map +1 -0
- package/lib/portfolio/portfolio-journal.js +844 -0
- package/lib/portfolio/portfolio-journal.js.map +1 -0
- package/lib/portfolio/resource-bundle.d.ts +136 -0
- package/lib/portfolio/resource-bundle.d.ts.map +1 -0
- package/lib/portfolio/resource-bundle.js +387 -0
- package/lib/portfolio/resource-bundle.js.map +1 -0
- package/lib/portfolio/sponsor-projection.d.ts +78 -0
- package/lib/portfolio/sponsor-projection.d.ts.map +1 -0
- package/lib/portfolio/sponsor-projection.js +135 -0
- package/lib/portfolio/sponsor-projection.js.map +1 -0
- package/lib/prompt/assembly.d.ts.map +1 -1
- package/lib/prompt/assembly.js +1 -3
- package/lib/prompt/assembly.js.map +1 -1
- package/lib/prompt/prompt-builder.d.ts +1 -1
- package/lib/prompt/prompt-builder.d.ts.map +1 -1
- package/lib/prompt/system-prompt.d.ts +1 -1
- package/lib/prompt/system-prompt.js +2 -2
- package/lib/prompt/system-prompt.js.map +1 -1
- package/lib/reserved-tools.d.ts.map +1 -1
- package/lib/reserved-tools.js +0 -1
- package/lib/reserved-tools.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/hook-registry.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/hook-registry.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/index.d.ts +4 -11
- package/lib/{orchestrator → resource-hub}/index.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/index.js +4 -8
- package/lib/{orchestrator → resource-hub}/index.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/mcp-lifecycle.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/mcp-lifecycle.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/mcp-registry.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/mcp-registry.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/resolve-subagent-tools.d.ts +3 -3
- package/lib/resource-hub/resolve-subagent-tools.d.ts.map +1 -0
- package/lib/{orchestrator → resource-hub}/resolve-subagent-tools.js +18 -13
- package/lib/resource-hub/resolve-subagent-tools.js.map +1 -0
- package/lib/{orchestrator → resource-hub}/resource-registry.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/resource-registry.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/role-configs.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/role-configs.js +0 -2
- package/lib/{orchestrator → resource-hub}/role-configs.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/skill-registry.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/skill-registry.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/subagent-registry.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/subagent-registry.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/tool-registry.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/tool-registry.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/tool-selection.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/tool-selection.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/types.d.ts +1 -1
- package/lib/{orchestrator → resource-hub}/types.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/types.js.map +1 -1
- package/lib/routing/workroom-bot-identity.d.ts +22 -0
- package/lib/routing/workroom-bot-identity.d.ts.map +1 -0
- package/lib/routing/workroom-bot-identity.js +46 -0
- package/lib/routing/workroom-bot-identity.js.map +1 -0
- package/lib/schedule-domain/budget-guard.d.ts +1 -1
- package/lib/schedule-domain/budget-guard.d.ts.map +1 -1
- package/lib/schedule-domain/budget-guard.js +9 -1
- package/lib/schedule-domain/budget-guard.js.map +1 -1
- package/lib/schedule-domain/execution-domain.d.ts +1 -0
- package/lib/schedule-domain/execution-domain.d.ts.map +1 -1
- package/lib/schedule-domain/execution-domain.js +3 -1
- package/lib/schedule-domain/execution-domain.js.map +1 -1
- package/lib/schedule-domain/schedule-execution-queue.d.ts +24 -0
- package/lib/schedule-domain/schedule-execution-queue.d.ts.map +1 -0
- package/lib/schedule-domain/schedule-execution-queue.js +123 -0
- package/lib/schedule-domain/schedule-execution-queue.js.map +1 -0
- package/lib/seam/seam-integration.d.ts +1 -1
- package/lib/seam/seam-integration.js +1 -1
- package/lib/seam/skill-service.d.ts +1 -1
- package/lib/security/exec-policy.d.ts +11 -1
- package/lib/security/exec-policy.d.ts.map +1 -1
- package/lib/security/exec-policy.js +16 -4
- package/lib/security/exec-policy.js.map +1 -1
- package/lib/security/policy-facade.d.ts.map +1 -1
- package/lib/security/policy-facade.js +60 -5
- package/lib/security/policy-facade.js.map +1 -1
- package/lib/security/sandbox-docker.js +1 -1
- package/lib/security/sandbox-docker.js.map +1 -1
- package/lib/security/sandbox.d.ts +2 -0
- package/lib/security/sandbox.d.ts.map +1 -1
- package/lib/security/sandbox.js +16 -4
- package/lib/security/sandbox.js.map +1 -1
- package/lib/security/turn-file-authority.d.ts +1 -1
- package/lib/security/turn-file-authority.d.ts.map +1 -1
- package/lib/security/turn-file-authority.js +10 -3
- package/lib/security/turn-file-authority.js.map +1 -1
- package/lib/security/turn-sandbox-authority.d.ts +13 -0
- package/lib/security/turn-sandbox-authority.d.ts.map +1 -0
- package/lib/security/turn-sandbox-authority.js +42 -0
- package/lib/security/turn-sandbox-authority.js.map +1 -0
- package/lib/service.d.ts +2 -0
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +2 -1
- package/lib/service.js.map +1 -1
- package/lib/session/approval-port.d.ts +2 -0
- package/lib/session/approval-port.d.ts.map +1 -1
- package/lib/session/approval-port.js.map +1 -1
- package/lib/session/index.d.ts +2 -6
- package/lib/session/index.d.ts.map +1 -1
- package/lib/session/index.js +2 -4
- package/lib/session/index.js.map +1 -1
- package/lib/session/session-io.d.ts +2 -6
- package/lib/session/session-io.d.ts.map +1 -1
- package/lib/session/session-io.js +4 -20
- package/lib/session/session-io.js.map +1 -1
- package/lib/session/session-system.d.ts +0 -2
- package/lib/session/session-system.d.ts.map +1 -1
- package/lib/session/session-system.js +2 -13
- package/lib/session/session-system.js.map +1 -1
- package/lib/session/turn-ingress-session.d.ts +1 -5
- package/lib/session/turn-ingress-session.d.ts.map +1 -1
- package/lib/session/turn-ingress-session.js +27 -29
- package/lib/session/turn-ingress-session.js.map +1 -1
- package/lib/session-tree-runtime.d.ts +15 -0
- package/lib/session-tree-runtime.d.ts.map +1 -0
- package/lib/{session-tree-runtime-registry.js → session-tree-runtime.js} +5 -15
- package/lib/session-tree-runtime.js.map +1 -0
- package/lib/skill/index.d.ts +2 -2
- package/lib/skill/index.d.ts.map +1 -1
- package/lib/skill/index.js +1 -1
- package/lib/skill/skill-registry-as-service.d.ts +1 -1
- package/lib/skill/skill-system.d.ts +4 -4
- package/lib/skill/skill-system.d.ts.map +1 -1
- package/lib/skill/skill-system.js +2 -2
- package/lib/skill/skill-system.js.map +1 -1
- package/lib/subagent/subagent-runtime.d.ts +2 -7
- package/lib/subagent/subagent-runtime.d.ts.map +1 -1
- package/lib/subagent/subagent-runtime.js +4 -43
- package/lib/subagent/subagent-runtime.js.map +1 -1
- package/lib/subagent/subagent-system-init.d.ts.map +1 -1
- package/lib/subagent/subagent-system-init.js +0 -2
- package/lib/subagent/subagent-system-init.js.map +1 -1
- package/lib/subagent-ai-events.d.ts +1 -1
- package/lib/subagent-ai-events.js +1 -1
- package/lib/subagent-preset.d.ts +1 -1
- package/lib/subagent-preset.d.ts.map +1 -1
- package/lib/subagent-prompt.d.ts +0 -2
- package/lib/subagent-prompt.d.ts.map +1 -1
- package/lib/subagent-prompt.js +3 -3
- package/lib/subagent-prompt.js.map +1 -1
- package/lib/task-executor.d.ts +1 -0
- package/lib/task-executor.d.ts.map +1 -1
- package/lib/task-executor.js +4 -1
- package/lib/task-executor.js.map +1 -1
- package/lib/tool/classic-tool-execution-authority.js +2 -2
- package/lib/tool/classic-tool-execution-authority.js.map +1 -1
- package/lib/tool/context-tools.d.ts +1 -4
- package/lib/tool/context-tools.d.ts.map +1 -1
- package/lib/tool/context-tools.js +0 -50
- package/lib/tool/context-tools.js.map +1 -1
- package/lib/tool/contracts.d.ts +1 -1
- package/lib/tool/conversation-reference-tool.d.ts +5 -0
- package/lib/tool/conversation-reference-tool.d.ts.map +1 -0
- package/lib/tool/conversation-reference-tool.js +40 -0
- package/lib/tool/conversation-reference-tool.js.map +1 -0
- package/lib/tool/index.d.ts +1 -0
- package/lib/tool/index.d.ts.map +1 -1
- package/lib/tool/index.js +1 -0
- package/lib/tool/index.js.map +1 -1
- package/lib/tool/prepare-turn-tools.d.ts.map +1 -1
- package/lib/tool/prepare-turn-tools.js +7 -22
- package/lib/tool/prepare-turn-tools.js.map +1 -1
- package/lib/tool/runtime.d.ts +3 -4
- package/lib/tool/runtime.d.ts.map +1 -1
- package/lib/tool/runtime.js +0 -1
- package/lib/tool/runtime.js.map +1 -1
- package/lib/tool/sources.d.ts +3 -4
- package/lib/tool/sources.d.ts.map +1 -1
- package/lib/tool/sources.js +2 -6
- package/lib/tool/sources.js.map +1 -1
- package/lib/tool/tool-approval-once-store.d.ts +1 -1
- package/lib/tool/tool-approval-once-store.js +1 -1
- package/lib/tool/tool-system.d.ts.map +1 -1
- package/lib/tool/tool-system.js.map +1 -1
- package/lib/tool/turn-tool-runtime.d.ts +2 -1
- package/lib/tool/turn-tool-runtime.d.ts.map +1 -1
- package/lib/tool/turn-tool-runtime.js +76 -21
- package/lib/tool/turn-tool-runtime.js.map +1 -1
- package/lib/tool-bridge.d.ts +2 -2
- package/lib/tool-bridge.js +1 -1
- package/lib/tool-catalog/deferred-turn-controller.d.ts +1 -1
- package/lib/tool-catalog/tool-catalog.d.ts +1 -1
- package/lib/turn/auto-continue.d.ts +1 -1
- package/lib/turn/deferred-delivery.d.ts +1 -1
- package/lib/turn/inbound-media.d.ts +12 -8
- package/lib/turn/inbound-media.d.ts.map +1 -1
- package/lib/turn/inbound-media.js +61 -42
- package/lib/turn/inbound-media.js.map +1 -1
- package/lib/turn/inbound-queue-config.d.ts +1 -1
- package/lib/turn/inbound-queue-runtime.d.ts +1 -1
- package/lib/turn/inbound-turn-queue.d.ts +1 -1
- package/lib/turn/index.d.ts +1 -1
- package/lib/turn/index.d.ts.map +1 -1
- package/lib/turn/index.js.map +1 -1
- package/lib/turn/persist-deferred-context.d.ts +1 -1
- package/lib/turn/persist-subagent-context.d.ts +1 -1
- package/lib/turn/process-stream.d.ts +1 -1
- package/lib/turn/prompt-api.d.ts +1 -1
- package/lib/turn/prompt-controller.d.ts +6 -0
- package/lib/turn/prompt-controller.d.ts.map +1 -1
- package/lib/turn/prompt-controller.js +58 -5
- package/lib/turn/prompt-controller.js.map +1 -1
- package/lib/turn/turn-ingress.d.ts +55 -5
- package/lib/turn/turn-ingress.d.ts.map +1 -1
- package/lib/turn/turn-ingress.js +18 -0
- package/lib/turn/turn-ingress.js.map +1 -1
- package/lib/turn/turn-pipeline.d.ts.map +1 -1
- package/lib/turn/turn-pipeline.js +5 -4
- package/lib/turn/turn-pipeline.js.map +1 -1
- package/lib/utils/keyed-mutex.d.ts +1 -1
- package/lib/utils/keyed-mutex.d.ts.map +1 -1
- package/lib/utils/keyed-mutex.js +32 -5
- package/lib/utils/keyed-mutex.js.map +1 -1
- package/lib/workroom/acceptance-control.d.ts +76 -0
- package/lib/workroom/acceptance-control.d.ts.map +1 -0
- package/lib/workroom/acceptance-control.js +335 -0
- package/lib/workroom/acceptance-control.js.map +1 -0
- package/lib/workroom/acceptance-policy.d.ts +152 -0
- package/lib/workroom/acceptance-policy.d.ts.map +1 -0
- package/lib/workroom/acceptance-policy.js +610 -0
- package/lib/workroom/acceptance-policy.js.map +1 -0
- package/lib/workroom/accepted-source-memory-application.d.ts +113 -0
- package/lib/workroom/accepted-source-memory-application.d.ts.map +1 -0
- package/lib/workroom/accepted-source-memory-application.js +327 -0
- package/lib/workroom/accepted-source-memory-application.js.map +1 -0
- package/lib/workroom/accepted-source-projector.d.ts +89 -0
- package/lib/workroom/accepted-source-projector.d.ts.map +1 -0
- package/lib/workroom/accepted-source-projector.js +281 -0
- package/lib/workroom/accepted-source-projector.js.map +1 -0
- package/lib/workroom/assignment-authority-grant-application.d.ts +125 -0
- package/lib/workroom/assignment-authority-grant-application.d.ts.map +1 -0
- package/lib/workroom/assignment-authority-grant-application.js +317 -0
- package/lib/workroom/assignment-authority-grant-application.js.map +1 -0
- package/lib/workroom/assignment-authority-grant-repository.d.ts +151 -0
- package/lib/workroom/assignment-authority-grant-repository.d.ts.map +1 -0
- package/lib/workroom/assignment-authority-grant-repository.js +387 -0
- package/lib/workroom/assignment-authority-grant-repository.js.map +1 -0
- package/lib/workroom/assignment-executor.d.ts +110 -0
- package/lib/workroom/assignment-executor.d.ts.map +1 -0
- package/lib/workroom/assignment-executor.js +371 -0
- package/lib/workroom/assignment-executor.js.map +1 -0
- package/lib/workroom/assignment-observation-ingress.d.ts +21 -0
- package/lib/workroom/assignment-observation-ingress.d.ts.map +1 -0
- package/lib/workroom/assignment-observation-ingress.js +24 -0
- package/lib/workroom/assignment-observation-ingress.js.map +1 -0
- package/lib/workroom/canonical-value.d.ts +7 -0
- package/lib/workroom/canonical-value.d.ts.map +1 -0
- package/lib/workroom/canonical-value.js +32 -0
- package/lib/workroom/canonical-value.js.map +1 -0
- package/lib/workroom/catalog-definition.d.ts +49 -0
- package/lib/workroom/catalog-definition.d.ts.map +1 -0
- package/lib/workroom/catalog-definition.js +2 -0
- package/lib/workroom/catalog-definition.js.map +1 -0
- package/lib/workroom/catalog.d.ts +80 -0
- package/lib/workroom/catalog.d.ts.map +1 -0
- package/lib/workroom/catalog.js +372 -0
- package/lib/workroom/catalog.js.map +1 -0
- package/lib/workroom/database-project-knowledge-journal.d.ts +62 -0
- package/lib/workroom/database-project-knowledge-journal.d.ts.map +1 -0
- package/lib/workroom/database-project-knowledge-journal.js +161 -0
- package/lib/workroom/database-project-knowledge-journal.js.map +1 -0
- package/lib/workroom/durable-file-store.d.ts +52 -0
- package/lib/workroom/durable-file-store.d.ts.map +1 -0
- package/lib/workroom/durable-file-store.js +117 -0
- package/lib/workroom/durable-file-store.js.map +1 -0
- package/lib/workroom/dynamic-workflow-planner.d.ts +86 -0
- package/lib/workroom/dynamic-workflow-planner.d.ts.map +1 -0
- package/lib/workroom/dynamic-workflow-planner.js +260 -0
- package/lib/workroom/dynamic-workflow-planner.js.map +1 -0
- package/lib/workroom/effect-blocker-repository.d.ts +35 -0
- package/lib/workroom/effect-blocker-repository.d.ts.map +1 -0
- package/lib/workroom/effect-blocker-repository.js +174 -0
- package/lib/workroom/effect-blocker-repository.js.map +1 -0
- package/lib/workroom/effect-ledger.d.ts +191 -0
- package/lib/workroom/effect-ledger.d.ts.map +1 -0
- package/lib/workroom/effect-ledger.js +443 -0
- package/lib/workroom/effect-ledger.js.map +1 -0
- package/lib/workroom/file-accepted-source-memory-repository.d.ts +15 -0
- package/lib/workroom/file-accepted-source-memory-repository.d.ts.map +1 -0
- package/lib/workroom/file-accepted-source-memory-repository.js +133 -0
- package/lib/workroom/file-accepted-source-memory-repository.js.map +1 -0
- package/lib/workroom/file-effect-ledger.d.ts +10 -0
- package/lib/workroom/file-effect-ledger.d.ts.map +1 -0
- package/lib/workroom/file-effect-ledger.js +118 -0
- package/lib/workroom/file-effect-ledger.js.map +1 -0
- package/lib/workroom/file-human-ingress-application.d.ts +10 -0
- package/lib/workroom/file-human-ingress-application.d.ts.map +1 -0
- package/lib/workroom/file-human-ingress-application.js +177 -0
- package/lib/workroom/file-human-ingress-application.js.map +1 -0
- package/lib/workroom/file-human-ingress.d.ts +24 -0
- package/lib/workroom/file-human-ingress.d.ts.map +1 -0
- package/lib/workroom/file-human-ingress.js +234 -0
- package/lib/workroom/file-human-ingress.js.map +1 -0
- package/lib/workroom/file-interaction-space-binding-repository.d.ts +24 -0
- package/lib/workroom/file-interaction-space-binding-repository.d.ts.map +1 -0
- package/lib/workroom/file-interaction-space-binding-repository.js +293 -0
- package/lib/workroom/file-interaction-space-binding-repository.js.map +1 -0
- package/lib/workroom/file-profile-journal.d.ts +32 -0
- package/lib/workroom/file-profile-journal.d.ts.map +1 -0
- package/lib/workroom/file-profile-journal.js +308 -0
- package/lib/workroom/file-profile-journal.js.map +1 -0
- package/lib/workroom/git-workspace-gateway.d.ts +149 -0
- package/lib/workroom/git-workspace-gateway.d.ts.map +1 -0
- package/lib/workroom/git-workspace-gateway.js +248 -0
- package/lib/workroom/git-workspace-gateway.js.map +1 -0
- package/lib/workroom/human-ingress-application.d.ts +126 -0
- package/lib/workroom/human-ingress-application.d.ts.map +1 -0
- package/lib/workroom/human-ingress-application.js +414 -0
- package/lib/workroom/human-ingress-application.js.map +1 -0
- package/lib/workroom/human-ingress-orchestrator.d.ts +99 -0
- package/lib/workroom/human-ingress-orchestrator.d.ts.map +1 -0
- package/lib/workroom/human-ingress-orchestrator.js +234 -0
- package/lib/workroom/human-ingress-orchestrator.js.map +1 -0
- package/lib/workroom/human-ingress-source-reader.d.ts +29 -0
- package/lib/workroom/human-ingress-source-reader.d.ts.map +1 -0
- package/lib/workroom/human-ingress-source-reader.js +119 -0
- package/lib/workroom/human-ingress-source-reader.js.map +1 -0
- package/lib/workroom/human-ingress.d.ts +182 -0
- package/lib/workroom/human-ingress.d.ts.map +1 -0
- package/lib/workroom/human-ingress.js +526 -0
- package/lib/workroom/human-ingress.js.map +1 -0
- package/lib/workroom/interaction-space-binding-service.d.ts +57 -0
- package/lib/workroom/interaction-space-binding-service.d.ts.map +1 -0
- package/lib/workroom/interaction-space-binding-service.js +197 -0
- package/lib/workroom/interaction-space-binding-service.js.map +1 -0
- package/lib/workroom/interaction-space-router.d.ts +75 -0
- package/lib/workroom/interaction-space-router.d.ts.map +1 -0
- package/lib/workroom/interaction-space-router.js +243 -0
- package/lib/workroom/interaction-space-router.js.map +1 -0
- package/lib/workroom/journal-model.d.ts +40 -0
- package/lib/workroom/journal-model.d.ts.map +1 -0
- package/lib/workroom/journal-model.js +12 -0
- package/lib/workroom/journal-model.js.map +1 -0
- package/lib/workroom/journal.d.ts +214 -0
- package/lib/workroom/journal.d.ts.map +1 -0
- package/lib/workroom/journal.js +1935 -0
- package/lib/workroom/journal.js.map +1 -0
- package/lib/workroom/kernel-contracts.d.ts +167 -0
- package/lib/workroom/kernel-contracts.d.ts.map +1 -0
- package/lib/workroom/kernel-contracts.js +2 -0
- package/lib/workroom/kernel-contracts.js.map +1 -0
- package/lib/workroom/kernel-state.d.ts +5 -0
- package/lib/workroom/kernel-state.d.ts.map +1 -0
- package/lib/workroom/kernel-state.js +819 -0
- package/lib/workroom/kernel-state.js.map +1 -0
- package/lib/workroom/legacy-embedded-payload-migration.d.ts +89 -0
- package/lib/workroom/legacy-embedded-payload-migration.d.ts.map +1 -0
- package/lib/workroom/legacy-embedded-payload-migration.js +312 -0
- package/lib/workroom/legacy-embedded-payload-migration.js.map +1 -0
- package/lib/workroom/legacy-run-offline-migration.d.ts +84 -0
- package/lib/workroom/legacy-run-offline-migration.d.ts.map +1 -0
- package/lib/workroom/legacy-run-offline-migration.js +470 -0
- package/lib/workroom/legacy-run-offline-migration.js.map +1 -0
- package/lib/workroom/local-assignment-executor.d.ts +59 -0
- package/lib/workroom/local-assignment-executor.d.ts.map +1 -0
- package/lib/workroom/local-assignment-executor.js +197 -0
- package/lib/workroom/local-assignment-executor.js.map +1 -0
- package/lib/workroom/local-assignment-issuance.d.ts +68 -0
- package/lib/workroom/local-assignment-issuance.d.ts.map +1 -0
- package/lib/workroom/local-assignment-issuance.js +128 -0
- package/lib/workroom/local-assignment-issuance.js.map +1 -0
- package/lib/workroom/plan-approval-control.d.ts +52 -0
- package/lib/workroom/plan-approval-control.d.ts.map +1 -0
- package/lib/workroom/plan-approval-control.js +9 -0
- package/lib/workroom/plan-approval-control.js.map +1 -0
- package/lib/workroom/plan-revision.d.ts +44 -0
- package/lib/workroom/plan-revision.d.ts.map +1 -0
- package/lib/workroom/plan-revision.js +133 -0
- package/lib/workroom/plan-revision.js.map +1 -0
- package/lib/workroom/profile-compiler.d.ts +130 -0
- package/lib/workroom/profile-compiler.d.ts.map +1 -0
- package/lib/workroom/profile-compiler.js +357 -0
- package/lib/workroom/profile-compiler.js.map +1 -0
- package/lib/workroom/profile-registry.d.ts +191 -0
- package/lib/workroom/profile-registry.d.ts.map +1 -0
- package/lib/workroom/profile-registry.js +698 -0
- package/lib/workroom/profile-registry.js.map +1 -0
- package/lib/workroom/project-knowledge-registry.d.ts +136 -0
- package/lib/workroom/project-knowledge-registry.d.ts.map +1 -0
- package/lib/workroom/project-knowledge-registry.js +429 -0
- package/lib/workroom/project-knowledge-registry.js.map +1 -0
- package/lib/workroom/projection-outbox.d.ts +254 -0
- package/lib/workroom/projection-outbox.d.ts.map +1 -0
- package/lib/workroom/projection-outbox.js +1312 -0
- package/lib/workroom/projection-outbox.js.map +1 -0
- package/lib/workroom/remote-assignment-dispatch-command.d.ts +31 -0
- package/lib/workroom/remote-assignment-dispatch-command.d.ts.map +1 -0
- package/lib/workroom/remote-assignment-dispatch-command.js +56 -0
- package/lib/workroom/remote-assignment-dispatch-command.js.map +1 -0
- package/lib/workroom/remote-assignment-issuance.d.ts +88 -0
- package/lib/workroom/remote-assignment-issuance.d.ts.map +1 -0
- package/lib/workroom/remote-assignment-issuance.js +201 -0
- package/lib/workroom/remote-assignment-issuance.js.map +1 -0
- package/lib/workroom/remote-callback-application.d.ts +115 -0
- package/lib/workroom/remote-callback-application.d.ts.map +1 -0
- package/lib/workroom/remote-callback-application.js +570 -0
- package/lib/workroom/remote-callback-application.js.map +1 -0
- package/lib/workroom/remote-callback-gateway.d.ts +60 -0
- package/lib/workroom/remote-callback-gateway.d.ts.map +1 -0
- package/lib/workroom/remote-callback-gateway.js +173 -0
- package/lib/workroom/remote-callback-gateway.js.map +1 -0
- package/lib/workroom/remote-callback-inbox.d.ts +278 -0
- package/lib/workroom/remote-callback-inbox.d.ts.map +1 -0
- package/lib/workroom/remote-callback-inbox.js +1088 -0
- package/lib/workroom/remote-callback-inbox.js.map +1 -0
- package/lib/workroom/remote-callback-reconciliation-worker.d.ts +60 -0
- package/lib/workroom/remote-callback-reconciliation-worker.d.ts.map +1 -0
- package/lib/workroom/remote-callback-reconciliation-worker.js +197 -0
- package/lib/workroom/remote-callback-reconciliation-worker.js.map +1 -0
- package/lib/workroom/remote-dispatch-admission.d.ts +45 -0
- package/lib/workroom/remote-dispatch-admission.d.ts.map +1 -0
- package/lib/workroom/remote-dispatch-admission.js +187 -0
- package/lib/workroom/remote-dispatch-admission.js.map +1 -0
- package/lib/workroom/remote-dispatch-outbox.d.ts +203 -0
- package/lib/workroom/remote-dispatch-outbox.d.ts.map +1 -0
- package/lib/workroom/remote-dispatch-outbox.js +765 -0
- package/lib/workroom/remote-dispatch-outbox.js.map +1 -0
- package/lib/workroom/remote-dispatch-scheduler.d.ts +36 -0
- package/lib/workroom/remote-dispatch-scheduler.d.ts.map +1 -0
- package/lib/workroom/remote-dispatch-scheduler.js +133 -0
- package/lib/workroom/remote-dispatch-scheduler.js.map +1 -0
- package/lib/workroom/remote-dispatch-worker.d.ts +22 -0
- package/lib/workroom/remote-dispatch-worker.d.ts.map +1 -0
- package/lib/workroom/remote-dispatch-worker.js +124 -0
- package/lib/workroom/remote-dispatch-worker.js.map +1 -0
- package/lib/workroom/remote-dispatch.d.ts +79 -0
- package/lib/workroom/remote-dispatch.d.ts.map +1 -0
- package/lib/workroom/remote-dispatch.js +220 -0
- package/lib/workroom/remote-dispatch.js.map +1 -0
- package/lib/workroom/role-capability-snapshot.d.ts +88 -0
- package/lib/workroom/role-capability-snapshot.d.ts.map +1 -0
- package/lib/workroom/role-capability-snapshot.js +456 -0
- package/lib/workroom/role-capability-snapshot.js.map +1 -0
- package/lib/workroom/runtime.d.ts +109 -0
- package/lib/workroom/runtime.d.ts.map +1 -0
- package/lib/workroom/runtime.js +450 -0
- package/lib/workroom/runtime.js.map +1 -0
- package/lib/workroom/scheduler-priority-control.d.ts +35 -0
- package/lib/workroom/scheduler-priority-control.d.ts.map +1 -0
- package/lib/workroom/scheduler-priority-control.js +9 -0
- package/lib/workroom/scheduler-priority-control.js.map +1 -0
- package/lib/workroom/workflow-plan-builder.d.ts +88 -0
- package/lib/workroom/workflow-plan-builder.d.ts.map +1 -0
- package/lib/workroom/workflow-plan-builder.js +232 -0
- package/lib/workroom/workflow-plan-builder.js.map +1 -0
- package/lib/workroom/workroom-assignment-knowledge-context.d.ts +102 -0
- package/lib/workroom/workroom-assignment-knowledge-context.d.ts.map +1 -0
- package/lib/workroom/workroom-assignment-knowledge-context.js +127 -0
- package/lib/workroom/workroom-assignment-knowledge-context.js.map +1 -0
- package/lib/workroom/workroom-kernel.d.ts +141 -0
- package/lib/workroom/workroom-kernel.d.ts.map +1 -0
- package/lib/workroom/workroom-kernel.js +1325 -0
- package/lib/workroom/workroom-kernel.js.map +1 -0
- package/lib/workroom/workroom-preemption.d.ts +65 -0
- package/lib/workroom/workroom-preemption.d.ts.map +1 -0
- package/lib/workroom/workroom-preemption.js +213 -0
- package/lib/workroom/workroom-preemption.js.map +1 -0
- package/lib/workroom/workroom-scheduler-application.d.ts +43 -0
- package/lib/workroom/workroom-scheduler-application.d.ts.map +1 -0
- package/lib/workroom/workroom-scheduler-application.js +71 -0
- package/lib/workroom/workroom-scheduler-application.js.map +1 -0
- package/lib/workroom/workroom-scheduler.d.ts +135 -0
- package/lib/workroom/workroom-scheduler.d.ts.map +1 -0
- package/lib/workroom/workroom-scheduler.js +649 -0
- package/lib/workroom/workroom-scheduler.js.map +1 -0
- package/lib/workroom/workroom-task-report-store.d.ts +131 -0
- package/lib/workroom/workroom-task-report-store.d.ts.map +1 -0
- package/lib/workroom/workroom-task-report-store.js +528 -0
- package/lib/workroom/workroom-task-report-store.js.map +1 -0
- package/lib/zhin-agent/index.d.ts +7 -22
- package/lib/zhin-agent/index.d.ts.map +1 -1
- package/lib/zhin-agent/index.js +5 -33
- package/lib/zhin-agent/index.js.map +1 -1
- package/lib/zhin-agent/runtime-modules.d.ts +3 -3
- package/lib/zhin-agent/runtime-modules.d.ts.map +1 -1
- package/lib/zhin-agent/runtime-modules.js +3 -3
- package/lib/zhin-agent/runtime-modules.js.map +1 -1
- package/package.json +10 -16
- package/lib/a2a/delegation-message.d.ts +0 -14
- package/lib/a2a/delegation-message.d.ts.map +0 -1
- package/lib/a2a/delegation-message.js +0 -53
- package/lib/a2a/delegation-message.js.map +0 -1
- package/lib/a2a/task-state.d.ts +0 -9
- package/lib/a2a/task-state.d.ts.map +0 -1
- package/lib/a2a/task-state.js +0 -53
- package/lib/a2a/task-state.js.map +0 -1
- package/lib/assistant/runtime-registry.d.ts +0 -23
- package/lib/assistant/runtime-registry.d.ts.map +0 -1
- package/lib/assistant/runtime-registry.js +0 -27
- package/lib/assistant/runtime-registry.js.map +0 -1
- package/lib/authoring/define-dynamic.d.ts +0 -4
- package/lib/authoring/define-dynamic.d.ts.map +0 -1
- package/lib/authoring/define-dynamic.js +0 -8
- package/lib/authoring/define-dynamic.js.map +0 -1
- package/lib/authoring/define-state.d.ts +0 -4
- package/lib/authoring/define-state.d.ts.map +0 -1
- package/lib/authoring/define-state.js +0 -8
- package/lib/authoring/define-state.js.map +0 -1
- package/lib/builtin/five-agent/strategy.d.ts +0 -4
- package/lib/builtin/five-agent/strategy.d.ts.map +0 -1
- package/lib/builtin/five-agent/strategy.js +0 -42
- package/lib/builtin/five-agent/strategy.js.map +0 -1
- package/lib/builtin/memory-search-tool.d.ts +0 -2
- package/lib/builtin/memory-search-tool.d.ts.map +0 -1
- package/lib/builtin/memory-search-tool.js +0 -58
- package/lib/builtin/memory-search-tool.js.map +0 -1
- package/lib/builtin/memory-upsert-tool.d.ts +0 -2
- package/lib/builtin/memory-upsert-tool.d.ts.map +0 -1
- package/lib/builtin/memory-upsert-tool.js +0 -72
- package/lib/builtin/memory-upsert-tool.js.map +0 -1
- package/lib/builtin/orchestration-tools.d.ts +0 -7
- package/lib/builtin/orchestration-tools.d.ts.map +0 -1
- package/lib/builtin/orchestration-tools.js +0 -259
- package/lib/builtin/orchestration-tools.js.map +0 -1
- package/lib/connection/authorization-flow.d.ts +0 -26
- package/lib/connection/authorization-flow.d.ts.map +0 -1
- package/lib/connection/authorization-flow.js +0 -76
- package/lib/connection/authorization-flow.js.map +0 -1
- package/lib/connection/index.d.ts +0 -3
- package/lib/connection/index.d.ts.map +0 -1
- package/lib/connection/index.js +0 -2
- package/lib/connection/index.js.map +0 -1
- package/lib/dynamic/dynamic-registry.d.ts +0 -34
- package/lib/dynamic/dynamic-registry.d.ts.map +0 -1
- package/lib/dynamic/dynamic-registry.js +0 -52
- package/lib/dynamic/dynamic-registry.js.map +0 -1
- package/lib/init/bootstrap-gate.d.ts +0 -6
- package/lib/init/bootstrap-gate.d.ts.map +0 -1
- package/lib/init/bootstrap-gate.js +0 -28
- package/lib/init/bootstrap-gate.js.map +0 -1
- package/lib/memory-entry-registry.d.ts +0 -13
- package/lib/memory-entry-registry.d.ts.map +0 -1
- package/lib/memory-entry-registry.js +0 -24
- package/lib/memory-entry-registry.js.map +0 -1
- package/lib/orchestration-memory-hook.d.ts +0 -3
- package/lib/orchestration-memory-hook.d.ts.map +0 -1
- package/lib/orchestration-memory-hook.js +0 -22
- package/lib/orchestration-memory-hook.js.map +0 -1
- package/lib/orchestration-runtime-registry.d.ts +0 -16
- package/lib/orchestration-runtime-registry.d.ts.map +0 -1
- package/lib/orchestration-runtime-registry.js +0 -20
- package/lib/orchestration-runtime-registry.js.map +0 -1
- package/lib/orchestrator/agent-dispatcher.d.ts +0 -171
- package/lib/orchestrator/agent-dispatcher.d.ts.map +0 -1
- package/lib/orchestrator/agent-dispatcher.js +0 -415
- package/lib/orchestrator/agent-dispatcher.js.map +0 -1
- package/lib/orchestrator/bootstrap-executors.d.ts +0 -7
- package/lib/orchestrator/bootstrap-executors.d.ts.map +0 -1
- package/lib/orchestrator/bootstrap-executors.js +0 -73
- package/lib/orchestrator/bootstrap-executors.js.map +0 -1
- package/lib/orchestrator/orchestration-mappers.d.ts +0 -9
- package/lib/orchestrator/orchestration-mappers.d.ts.map +0 -1
- package/lib/orchestrator/orchestration-mappers.js +0 -117
- package/lib/orchestrator/orchestration-mappers.js.map +0 -1
- package/lib/orchestrator/orchestration-repository.d.ts +0 -91
- package/lib/orchestrator/orchestration-repository.d.ts.map +0 -1
- package/lib/orchestrator/orchestration-repository.js +0 -389
- package/lib/orchestrator/orchestration-repository.js.map +0 -1
- package/lib/orchestrator/orchestration-service.d.ts +0 -133
- package/lib/orchestrator/orchestration-service.d.ts.map +0 -1
- package/lib/orchestrator/orchestration-service.js +0 -582
- package/lib/orchestrator/orchestration-service.js.map +0 -1
- package/lib/orchestrator/orchestration-source.d.ts +0 -5
- package/lib/orchestrator/orchestration-source.d.ts.map +0 -1
- package/lib/orchestrator/orchestration-source.js +0 -22
- package/lib/orchestrator/orchestration-source.js.map +0 -1
- package/lib/orchestrator/orchestration-types.d.ts +0 -88
- package/lib/orchestrator/orchestration-types.d.ts.map +0 -1
- package/lib/orchestrator/orchestration-types.js +0 -2
- package/lib/orchestrator/orchestration-types.js.map +0 -1
- package/lib/orchestrator/remote-agent-registry.d.ts +0 -37
- package/lib/orchestrator/remote-agent-registry.d.ts.map +0 -1
- package/lib/orchestrator/remote-agent-registry.js +0 -178
- package/lib/orchestrator/remote-agent-registry.js.map +0 -1
- package/lib/orchestrator/remote-task-executor.d.ts +0 -10
- package/lib/orchestrator/remote-task-executor.d.ts.map +0 -1
- package/lib/orchestrator/remote-task-executor.js +0 -231
- package/lib/orchestrator/remote-task-executor.js.map +0 -1
- package/lib/orchestrator/remote-task-poller.d.ts +0 -18
- package/lib/orchestrator/remote-task-poller.d.ts.map +0 -1
- package/lib/orchestrator/remote-task-poller.js +0 -84
- package/lib/orchestrator/remote-task-poller.js.map +0 -1
- package/lib/orchestrator/resolve-subagent-tools.d.ts.map +0 -1
- package/lib/orchestrator/resolve-subagent-tools.js.map +0 -1
- package/lib/orchestrator/task-queue.d.ts +0 -167
- package/lib/orchestrator/task-queue.d.ts.map +0 -1
- package/lib/orchestrator/task-queue.js +0 -416
- package/lib/orchestrator/task-queue.js.map +0 -1
- package/lib/session/passive-group-buffer.d.ts +0 -15
- package/lib/session/passive-group-buffer.d.ts.map +0 -1
- package/lib/session/passive-group-buffer.js +0 -50
- package/lib/session/passive-group-buffer.js.map +0 -1
- package/lib/session/passive-group-session.d.ts +0 -10
- package/lib/session/passive-group-session.d.ts.map +0 -1
- package/lib/session/passive-group-session.js +0 -32
- package/lib/session/passive-group-session.js.map +0 -1
- package/lib/session-tree-runtime-registry.d.ts +0 -22
- package/lib/session-tree-runtime-registry.d.ts.map +0 -1
- package/lib/session-tree-runtime-registry.js.map +0 -1
- package/lib/state/agent-state-store.d.ts +0 -18
- package/lib/state/agent-state-store.d.ts.map +0 -1
- package/lib/state/agent-state-store.js +0 -50
- package/lib/state/agent-state-store.js.map +0 -1
- /package/lib/{orchestrator → resource-hub}/hook-registry.d.ts +0 -0
- /package/lib/{orchestrator → resource-hub}/hook-registry.js +0 -0
- /package/lib/{orchestrator → resource-hub}/mcp-lifecycle.d.ts +0 -0
- /package/lib/{orchestrator → resource-hub}/mcp-lifecycle.js +0 -0
- /package/lib/{orchestrator → resource-hub}/mcp-registry.d.ts +0 -0
- /package/lib/{orchestrator → resource-hub}/mcp-registry.js +0 -0
- /package/lib/{orchestrator → resource-hub}/resource-registry.d.ts +0 -0
- /package/lib/{orchestrator → resource-hub}/resource-registry.js +0 -0
- /package/lib/{orchestrator → resource-hub}/role-configs.d.ts +0 -0
- /package/lib/{orchestrator → resource-hub}/skill-registry.d.ts +0 -0
- /package/lib/{orchestrator → resource-hub}/skill-registry.js +0 -0
- /package/lib/{orchestrator → resource-hub}/subagent-registry.d.ts +0 -0
- /package/lib/{orchestrator → resource-hub}/subagent-registry.js +0 -0
- /package/lib/{orchestrator → resource-hub}/tool-registry.d.ts +0 -0
- /package/lib/{orchestrator → resource-hub}/tool-registry.js +0 -0
- /package/lib/{orchestrator → resource-hub}/tool-selection.d.ts +0 -0
- /package/lib/{orchestrator → resource-hub}/tool-selection.js +0 -0
- /package/lib/{orchestrator → resource-hub}/types.js +0 -0
|
@@ -0,0 +1,1080 @@
|
|
|
1
|
+
import { PortfolioSequenceConflictError, parsePortfolioCapacityRequest, parsePortfolioPolicySnapshot, parsePortfolioProjectPolicy, parsePortfolioResourceBundle, } from './portfolio-journal.js';
|
|
2
|
+
import { compareCanonicalWorkroomText, canonicalWorkroomJson, deepFreezeWorkroomValue as deepFreeze, digestCanonicalWorkroomValue as digest, } from '../workroom/canonical-value.js';
|
|
3
|
+
const CAPACITY_HOLDING = new Set([
|
|
4
|
+
'offered', 'consumed', 'reclaim_requested',
|
|
5
|
+
]);
|
|
6
|
+
const BUDGET_HOLDING = new Set([
|
|
7
|
+
'offered', 'consumed', 'reclaim_requested', 'usage_pending', 'usage_unknown',
|
|
8
|
+
]);
|
|
9
|
+
const LANE_ORDER = {
|
|
10
|
+
urgent: 0, high: 1, normal: 2, low: 3,
|
|
11
|
+
};
|
|
12
|
+
/** Journal-backed Portfolio resource authority. It never writes Workroom facts. */
|
|
13
|
+
export class PortfolioAdmissionApplication {
|
|
14
|
+
options;
|
|
15
|
+
#maxCasAttempts;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.options = options;
|
|
18
|
+
this.#maxCasAttempts = options.maxCasAttempts ?? 3;
|
|
19
|
+
}
|
|
20
|
+
async read() {
|
|
21
|
+
return replayPortfolioAdmission(this.options.portfolioId, await this.options.repository.read(this.options.portfolioId));
|
|
22
|
+
}
|
|
23
|
+
async pinPolicy(policy, governance) {
|
|
24
|
+
const canonical = parsePortfolioPolicySnapshot(policy);
|
|
25
|
+
assertGovernance(governance, canonical.digest, 0);
|
|
26
|
+
await this.#commit(state => {
|
|
27
|
+
if (state.policy) {
|
|
28
|
+
if (state.policy.digest === canonical.digest)
|
|
29
|
+
return [];
|
|
30
|
+
throw new Error('Portfolio Policy is already pinned');
|
|
31
|
+
}
|
|
32
|
+
return [this.#draft('portfolio.policy_pinned', canonical.digest, state.now, {
|
|
33
|
+
policy: canonical,
|
|
34
|
+
governance,
|
|
35
|
+
})];
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async updateProjectPolicy(policy, governance) {
|
|
39
|
+
await this.updateProjectPolicies([policy], { [policy.projectId]: governance });
|
|
40
|
+
}
|
|
41
|
+
async updateProjectPolicies(policies, governance) {
|
|
42
|
+
const canonical = policies.map(parsePortfolioProjectPolicy)
|
|
43
|
+
.sort((left, right) => compareCanonicalWorkroomText(left.projectId, right.projectId));
|
|
44
|
+
if (canonical.length === 0 || new Set(canonical.map(policy => policy.projectId)).size !== canonical.length) {
|
|
45
|
+
throw new Error('Portfolio Project Policy atomic batch is empty or duplicated');
|
|
46
|
+
}
|
|
47
|
+
await this.#commit(state => {
|
|
48
|
+
const portfolio = requirePolicy(state);
|
|
49
|
+
let previousBudget = 0;
|
|
50
|
+
let candidateBudget = 0;
|
|
51
|
+
for (const candidate of canonical) {
|
|
52
|
+
const previous = portfolio.projects[candidate.projectId];
|
|
53
|
+
if (!previous || candidate.revision !== previous.revision + 1) {
|
|
54
|
+
throw new Error('Portfolio Project Policy revision is stale');
|
|
55
|
+
}
|
|
56
|
+
previousBudget += previous.hardBudgetMicros;
|
|
57
|
+
candidateBudget += candidate.hardBudgetMicros;
|
|
58
|
+
assertGovernance(governance[candidate.projectId], digest(candidate), previous.revision);
|
|
59
|
+
}
|
|
60
|
+
if (previousBudget !== candidateBudget) {
|
|
61
|
+
throw new Error('Portfolio Project Policy budget transfer must conserve its exact batch total');
|
|
62
|
+
}
|
|
63
|
+
return canonical.map(candidate => this.#draft('project.policy_updated', `${candidate.projectId}:${candidate.revision}`, state.now, { policy: candidate, governance: governance[candidate.projectId] }));
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
async setPriorityOverride(override, governance) {
|
|
67
|
+
await this.#commit(state => {
|
|
68
|
+
const policy = requirePolicy(state);
|
|
69
|
+
const request = requireRequest(state, override.requestId).request;
|
|
70
|
+
const project = policy.projects[override.projectId];
|
|
71
|
+
if (!project || request.projectId !== override.projectId
|
|
72
|
+
|| request.payloadDigest !== override.requestPayloadDigest
|
|
73
|
+
|| override.policyRevision !== project.revision
|
|
74
|
+
|| override.expiresAt <= state.now) {
|
|
75
|
+
throw new Error('Portfolio Priority Override exact request/policy scope is stale');
|
|
76
|
+
}
|
|
77
|
+
assertGovernance(governance, digest(override), project.revision);
|
|
78
|
+
const existing = state.overrides[override.overrideId];
|
|
79
|
+
if (existing) {
|
|
80
|
+
if (canonicalWorkroomJson(existing) !== canonicalWorkroomJson(override)) {
|
|
81
|
+
throw new Error('Portfolio Priority Override identity conflict');
|
|
82
|
+
}
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
return [this.#draft('priority.override_set', override.overrideId, state.now, {
|
|
86
|
+
override,
|
|
87
|
+
governance,
|
|
88
|
+
})];
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
async submit(request, bundleAuthority) {
|
|
92
|
+
const canonical = parsePortfolioCapacityRequest(request);
|
|
93
|
+
await this.#commit(state => {
|
|
94
|
+
const policy = requirePolicy(state);
|
|
95
|
+
const project = policy.projects[canonical.projectId];
|
|
96
|
+
if (!project || project.revision !== canonical.projectPolicyRevision) {
|
|
97
|
+
throw new Error('Capacity Request Project Policy revision is stale');
|
|
98
|
+
}
|
|
99
|
+
assertBundleAuthority(canonical, bundleAuthority, policy);
|
|
100
|
+
const existing = state.requests[canonical.requestId];
|
|
101
|
+
if (existing) {
|
|
102
|
+
if (canonicalWorkroomJson(existing.request) !== canonicalWorkroomJson(canonical)
|
|
103
|
+
|| canonicalWorkroomJson(existing.bundleAuthority) !== canonicalWorkroomJson(bundleAuthority)) {
|
|
104
|
+
throw new Error('Capacity Request identity conflict');
|
|
105
|
+
}
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
const outstanding = Object.values(state.requests).filter(item => item.request.projectId === canonical.projectId
|
|
109
|
+
&& portfolioRequestStatus(state, item.request.requestId) !== 'settled').length;
|
|
110
|
+
if (outstanding >= project.maxOutstandingRequests) {
|
|
111
|
+
throw new Error('Capacity Request exceeds Project outstanding cap');
|
|
112
|
+
}
|
|
113
|
+
return [this.#draft('capacity.requested', canonical.requestId, state.now, {
|
|
114
|
+
request: canonical,
|
|
115
|
+
bundleAuthority,
|
|
116
|
+
})];
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async decideAdmission() {
|
|
120
|
+
let offered = null;
|
|
121
|
+
await this.#commit(state => {
|
|
122
|
+
offered = null;
|
|
123
|
+
const decision = decideAdmission(state);
|
|
124
|
+
if (!decision)
|
|
125
|
+
return [];
|
|
126
|
+
if ('reclaimId' in decision) {
|
|
127
|
+
return [this.#draft('capacity.reclaim_requested', decision.reclaimId, state.now, {
|
|
128
|
+
reclaim: decision,
|
|
129
|
+
})];
|
|
130
|
+
}
|
|
131
|
+
offered = decision;
|
|
132
|
+
return [this.#draft('capacity.grant_offered', decision.grantId, state.now, {
|
|
133
|
+
grant: decision,
|
|
134
|
+
})];
|
|
135
|
+
});
|
|
136
|
+
return offered;
|
|
137
|
+
}
|
|
138
|
+
async consume(input, authority) {
|
|
139
|
+
await this.#commit(state => {
|
|
140
|
+
const policy = requirePolicy(state);
|
|
141
|
+
const grant = requireGrant(state, input.grantId);
|
|
142
|
+
if (grant.status === 'consumed' && grant.projectId === input.projectId
|
|
143
|
+
&& grant.fence === input.fence && grant.assignmentRef === input.assignmentRef) {
|
|
144
|
+
assertKernelAuthority(this.options.portfolioId, grant, authority, {
|
|
145
|
+
action: 'consume', assignmentRef: input.assignmentRef,
|
|
146
|
+
});
|
|
147
|
+
return [];
|
|
148
|
+
}
|
|
149
|
+
if (grant.projectId !== input.projectId || grant.fence !== input.fence
|
|
150
|
+
|| grant.status !== 'offered' || grant.offerExpiresAt <= state.now) {
|
|
151
|
+
throw new Error('Capacity Grant consume scope/fence/offer is stale');
|
|
152
|
+
}
|
|
153
|
+
assertKernelAuthority(this.options.portfolioId, grant, authority, {
|
|
154
|
+
action: 'consume', assignmentRef: input.assignmentRef,
|
|
155
|
+
});
|
|
156
|
+
return [this.#draft('capacity.grant_consumed', `${grant.grantId}:${grant.fence}`, state.now, {
|
|
157
|
+
grantId: grant.grantId,
|
|
158
|
+
projectId: grant.projectId,
|
|
159
|
+
fence: grant.fence,
|
|
160
|
+
assignmentRef: input.assignmentRef,
|
|
161
|
+
consumedAt: state.now,
|
|
162
|
+
leaseExpiresAt: state.now + policy.leaseTtlTicks,
|
|
163
|
+
maxLeaseExpiresAt: state.now + policy.maxLeaseQuantumTicks,
|
|
164
|
+
authority,
|
|
165
|
+
})];
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
async failAssignment(input, authority) {
|
|
169
|
+
await this.#commit(state => {
|
|
170
|
+
const grant = requireGrant(state, input.grantId);
|
|
171
|
+
const action = {
|
|
172
|
+
action: 'assignment_failed',
|
|
173
|
+
assignmentRef: input.assignmentRef,
|
|
174
|
+
failureReason: input.reason,
|
|
175
|
+
kernelSequence: input.kernelSequence,
|
|
176
|
+
kernelFactDigest: input.kernelFactDigest,
|
|
177
|
+
};
|
|
178
|
+
if (grant.status === 'assignment_failed' && grant.projectId === input.projectId
|
|
179
|
+
&& grant.fence === input.fence && grant.assignmentRef === input.assignmentRef) {
|
|
180
|
+
assertKernelAuthority(this.options.portfolioId, grant, authority, action);
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
if (grant.status !== 'consumed' || grant.projectId !== input.projectId
|
|
184
|
+
|| grant.fence !== input.fence || grant.assignmentRef !== input.assignmentRef) {
|
|
185
|
+
throw new Error('Capacity Grant Assignment failure scope/fence/status is stale');
|
|
186
|
+
}
|
|
187
|
+
assertKernelAuthority(this.options.portfolioId, grant, authority, action);
|
|
188
|
+
return [this.#draft('capacity.grant_assignment_failed', `${grant.grantId}:${grant.fence}:${input.assignmentRef}`, state.now, {
|
|
189
|
+
...input, failedAt: state.now, authority,
|
|
190
|
+
})];
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
async renewLease(input, authority) {
|
|
194
|
+
await this.#commit(state => {
|
|
195
|
+
const policy = requirePolicy(state);
|
|
196
|
+
const grant = requireGrant(state, input.grantId);
|
|
197
|
+
const action = renewalAuthorityAction(state, policy, input.assignmentRef, input.heartbeatSequence);
|
|
198
|
+
if (grant.status === 'consumed' && grant.projectId === input.projectId
|
|
199
|
+
&& grant.fence === input.fence && grant.assignmentRef === input.assignmentRef
|
|
200
|
+
&& grant.lastHeartbeatSequence === input.heartbeatSequence) {
|
|
201
|
+
assertKernelAuthority(this.options.portfolioId, grant, authority, action);
|
|
202
|
+
return [];
|
|
203
|
+
}
|
|
204
|
+
if (grant.status !== 'consumed' || grant.projectId !== input.projectId
|
|
205
|
+
|| grant.fence !== input.fence || grant.assignmentRef !== input.assignmentRef
|
|
206
|
+
|| grant.leaseExpiresAt === undefined || grant.leaseExpiresAt <= state.now
|
|
207
|
+
|| grant.maxLeaseExpiresAt === undefined) {
|
|
208
|
+
throw new Error('Capacity Grant Lease renewal scope/fence/status is stale');
|
|
209
|
+
}
|
|
210
|
+
if (state.clockSequence < 0 || !state.clockDigest) {
|
|
211
|
+
throw new Error('Capacity Grant Lease renewal requires a current Portfolio clock fact');
|
|
212
|
+
}
|
|
213
|
+
const previousHeartbeatSequence = grant.lastHeartbeatSequence ?? 0;
|
|
214
|
+
const previousHeartbeatAt = grant.lastHeartbeatAt ?? grant.consumedAt;
|
|
215
|
+
const renewalCount = grant.renewalCount ?? 0;
|
|
216
|
+
if (input.heartbeatSequence !== previousHeartbeatSequence + 1
|
|
217
|
+
|| state.now < previousHeartbeatAt + policy.leaseHeartbeatTicks) {
|
|
218
|
+
throw new Error('Capacity Grant Lease heartbeat sequence/time is stale');
|
|
219
|
+
}
|
|
220
|
+
if (renewalCount >= policy.maxLeaseRenewals) {
|
|
221
|
+
throw new Error('Capacity Grant Lease renewal limit is exhausted');
|
|
222
|
+
}
|
|
223
|
+
const pendingReclaim = Object.values(state.reclaims).some(reclaim => reclaim.status === 'pending');
|
|
224
|
+
const starvedReservation = Object.values(state.requests).some(item => portfolioRequestStatus(state, item.request.requestId) === 'pending'
|
|
225
|
+
&& state.now >= item.request.starvationAt);
|
|
226
|
+
if (pendingReclaim || starvedReservation) {
|
|
227
|
+
throw new Error('Capacity Grant Lease renewal is reserved for reclaim/starvation');
|
|
228
|
+
}
|
|
229
|
+
const leaseExpiresAt = Math.min(state.now + policy.leaseTtlTicks, grant.maxLeaseExpiresAt);
|
|
230
|
+
if (leaseExpiresAt <= grant.leaseExpiresAt) {
|
|
231
|
+
throw new Error('Capacity Grant Lease max quantum is exhausted');
|
|
232
|
+
}
|
|
233
|
+
assertKernelAuthority(this.options.portfolioId, grant, authority, action);
|
|
234
|
+
return [this.#draft('capacity.grant_lease_renewed', `${grant.grantId}:${grant.fence}:${input.heartbeatSequence}`, state.now, {
|
|
235
|
+
grantId: grant.grantId,
|
|
236
|
+
projectId: grant.projectId,
|
|
237
|
+
fence: grant.fence,
|
|
238
|
+
assignmentRef: input.assignmentRef,
|
|
239
|
+
heartbeatSequence: input.heartbeatSequence,
|
|
240
|
+
renewedAt: state.now,
|
|
241
|
+
previousLeaseExpiresAt: grant.leaseExpiresAt,
|
|
242
|
+
leaseExpiresAt,
|
|
243
|
+
maxLeaseExpiresAt: grant.maxLeaseExpiresAt,
|
|
244
|
+
policyDigest: policy.digest,
|
|
245
|
+
clockSequence: state.clockSequence,
|
|
246
|
+
clockDigest: state.clockDigest,
|
|
247
|
+
usageSettlementCursor: state.usageSettlementCursor,
|
|
248
|
+
authority,
|
|
249
|
+
})];
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
async acknowledgeReclaim(input, authority) {
|
|
253
|
+
await this.#commit(state => {
|
|
254
|
+
const reclaim = requireReclaim(state, input.reclaimId);
|
|
255
|
+
const grant = requireGrant(state, reclaim.grantId);
|
|
256
|
+
if (reclaim.status === input.outcome && reclaim.projectId === input.projectId
|
|
257
|
+
&& grant.fence === input.fence) {
|
|
258
|
+
if (reclaim.checkpointRef !== input.checkpointRef
|
|
259
|
+
|| reclaim.checkpointDigest !== input.checkpointDigest) {
|
|
260
|
+
throw new Error('Capacity Reclaim checkpoint idempotency drift');
|
|
261
|
+
}
|
|
262
|
+
assertKernelAuthority(this.options.portfolioId, grant, authority, {
|
|
263
|
+
action: 'reclaim_acknowledge', assignmentRef: grant.assignmentRef,
|
|
264
|
+
reclaimId: reclaim.reclaimId, outcome: input.outcome,
|
|
265
|
+
...(input.checkpointRef === undefined ? {} : { checkpointRef: input.checkpointRef }),
|
|
266
|
+
...(input.checkpointDigest === undefined ? {} : { checkpointDigest: input.checkpointDigest }),
|
|
267
|
+
});
|
|
268
|
+
return [];
|
|
269
|
+
}
|
|
270
|
+
if (reclaim.status !== 'pending' || reclaim.projectId !== input.projectId
|
|
271
|
+
|| grant.fence !== input.fence || grant.status !== 'reclaim_requested') {
|
|
272
|
+
throw new Error('Capacity Reclaim acknowledgement scope/fence is stale');
|
|
273
|
+
}
|
|
274
|
+
if (input.outcome === 'checkpointed' && (!input.checkpointRef || !input.checkpointDigest)) {
|
|
275
|
+
throw new Error('Checkpointed Capacity Reclaim requires checkpoint ref/digest');
|
|
276
|
+
}
|
|
277
|
+
if (input.outcome === 'declined' && (input.checkpointRef || input.checkpointDigest)) {
|
|
278
|
+
throw new Error('Declined Capacity Reclaim cannot claim a checkpoint');
|
|
279
|
+
}
|
|
280
|
+
assertKernelAuthority(this.options.portfolioId, grant, authority, {
|
|
281
|
+
action: 'reclaim_acknowledge', assignmentRef: grant.assignmentRef,
|
|
282
|
+
reclaimId: reclaim.reclaimId, outcome: input.outcome,
|
|
283
|
+
...(input.checkpointRef === undefined ? {} : { checkpointRef: input.checkpointRef }),
|
|
284
|
+
...(input.checkpointDigest === undefined ? {} : { checkpointDigest: input.checkpointDigest }),
|
|
285
|
+
});
|
|
286
|
+
return [this.#draft('capacity.reclaim_acknowledged', reclaim.reclaimId, state.now, {
|
|
287
|
+
reclaimId: reclaim.reclaimId,
|
|
288
|
+
grantId: grant.grantId,
|
|
289
|
+
projectId: grant.projectId,
|
|
290
|
+
fence: grant.fence,
|
|
291
|
+
outcome: input.outcome,
|
|
292
|
+
...(input.checkpointRef === undefined ? {} : { checkpointRef: input.checkpointRef }),
|
|
293
|
+
...(input.checkpointDigest === undefined ? {} : { checkpointDigest: input.checkpointDigest }),
|
|
294
|
+
authority,
|
|
295
|
+
})];
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
async settleUsage(authority) {
|
|
299
|
+
await this.#commit(state => {
|
|
300
|
+
const grant = requireGrant(state, authority.grantId);
|
|
301
|
+
assertUsageAuthority(this.options.portfolioId, grant, authority);
|
|
302
|
+
if (grant.fence !== authority.fence
|
|
303
|
+
|| !['consumed', 'reclaim_requested', 'usage_pending', 'usage_unknown'].includes(grant.status)) {
|
|
304
|
+
if (grant.status === 'settled'
|
|
305
|
+
&& grant.actualCostMicros === authority.actualCostMicros
|
|
306
|
+
&& grant.settlementRef === authority.settlementRef
|
|
307
|
+
&& grant.receiptId === authority.receiptId
|
|
308
|
+
&& grant.receiptDigest === authority.receiptDigest
|
|
309
|
+
&& grant.authenticatedBy === authority.authenticatedBy)
|
|
310
|
+
return [];
|
|
311
|
+
throw new Error('Capacity Usage Receipt scope/fence/status is stale');
|
|
312
|
+
}
|
|
313
|
+
if (!Number.isSafeInteger(authority.actualCostMicros) || authority.actualCostMicros < 0) {
|
|
314
|
+
throw new Error('Capacity Usage actual cost is invalid');
|
|
315
|
+
}
|
|
316
|
+
return [this.#draft('capacity.usage_settled', authority.receiptId, state.now, {
|
|
317
|
+
receiptId: authority.receiptId,
|
|
318
|
+
grantId: authority.grantId,
|
|
319
|
+
fence: authority.fence,
|
|
320
|
+
actualCostMicros: authority.actualCostMicros,
|
|
321
|
+
settlementRef: authority.settlementRef,
|
|
322
|
+
authenticatedBy: authority.authenticatedBy,
|
|
323
|
+
authority,
|
|
324
|
+
})];
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
async advanceClock(authority) {
|
|
328
|
+
await this.#commit(state => {
|
|
329
|
+
assertClockAuthority(this.options.portfolioId, authority);
|
|
330
|
+
const { now } = authority;
|
|
331
|
+
if (!Number.isSafeInteger(now) || now <= state.now)
|
|
332
|
+
throw new Error('Portfolio clock must advance');
|
|
333
|
+
const drafts = [this.#draft('clock.advanced', String(now), now, { now, authority })];
|
|
334
|
+
for (const grant of Object.values(state.grants)) {
|
|
335
|
+
if (grant.status === 'offered' && grant.offerExpiresAt <= now) {
|
|
336
|
+
drafts.push(this.#draft('capacity.grant_expired', `${grant.grantId}:${grant.fence}`, now, {
|
|
337
|
+
grantId: grant.grantId, fence: grant.fence,
|
|
338
|
+
}));
|
|
339
|
+
}
|
|
340
|
+
else if ((grant.status === 'consumed' || grant.status === 'reclaim_requested')
|
|
341
|
+
&& grant.leaseExpiresAt !== undefined && grant.leaseExpiresAt <= now) {
|
|
342
|
+
drafts.push(this.#draft('capacity.grant_lease_lost', `${grant.grantId}:${grant.fence}`, now, {
|
|
343
|
+
grantId: grant.grantId, fence: grant.fence, usage: 'unknown',
|
|
344
|
+
}));
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
for (const reclaim of Object.values(state.reclaims)) {
|
|
348
|
+
if (reclaim.status === 'pending' && reclaim.deadline <= now) {
|
|
349
|
+
const grant = requireGrant(state, reclaim.grantId);
|
|
350
|
+
drafts.push(this.#draft('capacity.reclaim_timed_out', reclaim.reclaimId, now, {
|
|
351
|
+
reclaimId: reclaim.reclaimId, grantId: grant.grantId, fence: grant.fence,
|
|
352
|
+
}));
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return drafts;
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
async normalizeService(divisor) {
|
|
359
|
+
await this.#commit(state => {
|
|
360
|
+
if (!Number.isSafeInteger(divisor) || divisor < 2) {
|
|
361
|
+
throw new Error('Portfolio service normalization divisor must be at least two');
|
|
362
|
+
}
|
|
363
|
+
const projectService = {};
|
|
364
|
+
for (const projectId of Object.keys(requirePolicy(state).projects).sort()) {
|
|
365
|
+
projectService[projectId] = Math.floor(dominantService(state, projectId) / divisor);
|
|
366
|
+
}
|
|
367
|
+
const normalizationId = `normalization:${state.sequence + 1}`;
|
|
368
|
+
return [this.#draft('service.normalized', normalizationId, state.now, {
|
|
369
|
+
normalization: { normalizationId, divisor, projectService },
|
|
370
|
+
})];
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
async #commit(decide) {
|
|
374
|
+
for (let attempt = 1; attempt <= this.#maxCasAttempts; attempt += 1) {
|
|
375
|
+
const state = await this.read();
|
|
376
|
+
const drafts = decide(state);
|
|
377
|
+
if (drafts.length === 0)
|
|
378
|
+
return;
|
|
379
|
+
try {
|
|
380
|
+
await this.options.repository.append(this.options.portfolioId, state.sequence, drafts);
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
catch (error) {
|
|
384
|
+
if (!(error instanceof PortfolioSequenceConflictError) || attempt === this.#maxCasAttempts)
|
|
385
|
+
throw error;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
throw new Error('Portfolio admission CAS retry loop exhausted');
|
|
389
|
+
}
|
|
390
|
+
#draft(type, identity, occurredAt, payload) {
|
|
391
|
+
return {
|
|
392
|
+
eventId: this.options.ids.eventId(type, identity),
|
|
393
|
+
occurredAt,
|
|
394
|
+
type,
|
|
395
|
+
payload,
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
export function replayPortfolioAdmission(portfolioId, facts) {
|
|
400
|
+
let state = deepFreeze({
|
|
401
|
+
portfolioId, sequence: -1, now: 0,
|
|
402
|
+
clockSequence: -1, usageSettlementCursor: -1,
|
|
403
|
+
requests: {}, grants: {}, reclaims: {}, overrides: {},
|
|
404
|
+
normalizedService: {}, normalizedAtSequence: -1,
|
|
405
|
+
});
|
|
406
|
+
for (const [index, fact] of facts.entries()) {
|
|
407
|
+
if (fact.portfolioId !== portfolioId || fact.sequence !== index) {
|
|
408
|
+
throw new Error('Portfolio Journal replay sequence/scope drift');
|
|
409
|
+
}
|
|
410
|
+
state = evolve(state, fact);
|
|
411
|
+
}
|
|
412
|
+
return deepFreeze(state);
|
|
413
|
+
}
|
|
414
|
+
export function portfolioRequestStatus(state, requestId) {
|
|
415
|
+
requireRequest(state, requestId);
|
|
416
|
+
const highestFenceGrant = Object.values(state.grants)
|
|
417
|
+
.filter(grant => grant.requestId === requestId)
|
|
418
|
+
.sort((left, right) => right.fence - left.fence)[0];
|
|
419
|
+
if (!highestFenceGrant || highestFenceGrant.status === 'expired'
|
|
420
|
+
|| highestFenceGrant.status === 'assignment_failed')
|
|
421
|
+
return 'pending';
|
|
422
|
+
if (highestFenceGrant.status === 'settled')
|
|
423
|
+
return 'settled';
|
|
424
|
+
if (highestFenceGrant.status === 'usage_pending' || highestFenceGrant.status === 'usage_unknown') {
|
|
425
|
+
return 'usage_blocked';
|
|
426
|
+
}
|
|
427
|
+
return 'granted';
|
|
428
|
+
}
|
|
429
|
+
export function portfolioProjectBudget(state, projectId) {
|
|
430
|
+
const project = requirePolicy(state).projects[projectId];
|
|
431
|
+
if (!project)
|
|
432
|
+
throw new Error(`Unknown Portfolio Project ${projectId}`);
|
|
433
|
+
const grants = Object.values(state.grants).filter(grant => grant.projectId === projectId);
|
|
434
|
+
const spentMicros = grants.filter(grant => grant.status === 'settled')
|
|
435
|
+
.reduce((sum, grant) => sum + (grant.actualCostMicros ?? 0), 0);
|
|
436
|
+
const reservedMicros = grants.filter(grant => BUDGET_HOLDING.has(grant.status))
|
|
437
|
+
.reduce((sum, grant) => sum + grant.reservedCostMicros, 0);
|
|
438
|
+
return deepFreeze({
|
|
439
|
+
limitMicros: project.hardBudgetMicros,
|
|
440
|
+
spentMicros,
|
|
441
|
+
reservedMicros,
|
|
442
|
+
availableMicros: project.hardBudgetMicros - spentMicros - reservedMicros,
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
export function portfolioRequestBlockers(state, requestId) {
|
|
446
|
+
return Object.freeze(blockers(state, requireRequest(state, requestId)));
|
|
447
|
+
}
|
|
448
|
+
function evolve(state, fact) {
|
|
449
|
+
let next = { ...state, sequence: fact.sequence };
|
|
450
|
+
switch (fact.type) {
|
|
451
|
+
case 'portfolio.policy_pinned':
|
|
452
|
+
if (state.policy)
|
|
453
|
+
throw new Error('Portfolio Policy fact is duplicated');
|
|
454
|
+
assertGovernance(fact.payload.governance, fact.payload.policy.digest, 0);
|
|
455
|
+
return { ...next, policy: fact.payload.policy };
|
|
456
|
+
case 'project.policy_updated': {
|
|
457
|
+
const current = requirePolicy(state);
|
|
458
|
+
const previous = current.projects[fact.payload.policy.projectId];
|
|
459
|
+
if (!previous || fact.payload.policy.revision !== previous.revision + 1) {
|
|
460
|
+
throw new Error('Persisted Portfolio Project Policy revision drift');
|
|
461
|
+
}
|
|
462
|
+
assertGovernance(fact.payload.governance, digest(fact.payload.policy), previous.revision);
|
|
463
|
+
return {
|
|
464
|
+
...next,
|
|
465
|
+
policy: {
|
|
466
|
+
...current,
|
|
467
|
+
projects: { ...current.projects, [fact.payload.policy.projectId]: fact.payload.policy },
|
|
468
|
+
},
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
case 'priority.override_set': {
|
|
472
|
+
const request = requireRequest(state, fact.payload.override.requestId).request;
|
|
473
|
+
const project = requirePolicy(state).projects[fact.payload.override.projectId];
|
|
474
|
+
if (!project || request.payloadDigest !== fact.payload.override.requestPayloadDigest
|
|
475
|
+
|| fact.payload.override.policyRevision !== project.revision) {
|
|
476
|
+
throw new Error('Persisted Portfolio Priority Override scope drift');
|
|
477
|
+
}
|
|
478
|
+
assertGovernance(fact.payload.governance, digest(fact.payload.override), project.revision);
|
|
479
|
+
return { ...next, overrides: { ...state.overrides, [fact.payload.override.overrideId]: fact.payload.override } };
|
|
480
|
+
}
|
|
481
|
+
case 'capacity.requested': {
|
|
482
|
+
if (!fact.payload.bundleAuthority)
|
|
483
|
+
throw new Error('Production Capacity Request lacks validated Bundle authority');
|
|
484
|
+
assertBundleAuthority(fact.payload.request, fact.payload.bundleAuthority, requirePolicy(state));
|
|
485
|
+
return {
|
|
486
|
+
...next,
|
|
487
|
+
requests: {
|
|
488
|
+
...state.requests,
|
|
489
|
+
[fact.payload.request.requestId]: {
|
|
490
|
+
request: fact.payload.request,
|
|
491
|
+
bundleAuthority: fact.payload.bundleAuthority,
|
|
492
|
+
requestedAt: fact.occurredAt,
|
|
493
|
+
requestedSequence: fact.sequence,
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
case 'capacity.grant_offered': {
|
|
499
|
+
const item = requireRequest(state, fact.payload.grant.requestId);
|
|
500
|
+
assertGrantMatchesRequest(fact.payload.grant, item, state);
|
|
501
|
+
if (fact.payload.grant.issuedSequence !== fact.sequence) {
|
|
502
|
+
throw new Error('Capacity Grant offered sequence drift');
|
|
503
|
+
}
|
|
504
|
+
return { ...next, grants: { ...state.grants, [fact.payload.grant.grantId]: fact.payload.grant } };
|
|
505
|
+
}
|
|
506
|
+
case 'capacity.grant_consumed': {
|
|
507
|
+
const grant = requireGrant(state, fact.payload.grantId);
|
|
508
|
+
const policy = requirePolicy(state);
|
|
509
|
+
if (grant.status !== 'offered' || grant.projectId !== fact.payload.projectId
|
|
510
|
+
|| grant.fence !== fact.payload.fence || grant.offerExpiresAt <= fact.payload.consumedAt
|
|
511
|
+
|| fact.payload.leaseExpiresAt !== fact.payload.consumedAt + policy.leaseTtlTicks
|
|
512
|
+
|| fact.payload.maxLeaseExpiresAt !== fact.payload.consumedAt + policy.maxLeaseQuantumTicks) {
|
|
513
|
+
throw new Error('Persisted Capacity Grant consume drift');
|
|
514
|
+
}
|
|
515
|
+
assertKernelAuthority(state.portfolioId, grant, fact.payload.authority, {
|
|
516
|
+
action: 'consume', assignmentRef: fact.payload.assignmentRef,
|
|
517
|
+
});
|
|
518
|
+
return updateGrant(next, grant.grantId, {
|
|
519
|
+
status: 'consumed', assignmentRef: fact.payload.assignmentRef,
|
|
520
|
+
consumedAt: fact.payload.consumedAt, leaseExpiresAt: fact.payload.leaseExpiresAt,
|
|
521
|
+
maxLeaseExpiresAt: fact.payload.maxLeaseExpiresAt,
|
|
522
|
+
renewalCount: 0, lastHeartbeatSequence: 0, lastHeartbeatAt: fact.payload.consumedAt,
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
case 'capacity.grant_assignment_failed': {
|
|
526
|
+
const grant = requireFence(state, fact.payload.grantId, fact.payload.fence);
|
|
527
|
+
const action = {
|
|
528
|
+
action: 'assignment_failed',
|
|
529
|
+
assignmentRef: fact.payload.assignmentRef,
|
|
530
|
+
failureReason: fact.payload.reason,
|
|
531
|
+
kernelSequence: fact.payload.kernelSequence,
|
|
532
|
+
kernelFactDigest: fact.payload.kernelFactDigest,
|
|
533
|
+
};
|
|
534
|
+
if (grant.status !== 'consumed' || grant.projectId !== fact.payload.projectId
|
|
535
|
+
|| grant.assignmentRef !== fact.payload.assignmentRef) {
|
|
536
|
+
throw new Error('Persisted Capacity Grant Assignment failure drift');
|
|
537
|
+
}
|
|
538
|
+
assertKernelAuthority(state.portfolioId, grant, fact.payload.authority, action);
|
|
539
|
+
return updateGrant(next, grant.grantId, { status: 'assignment_failed' });
|
|
540
|
+
}
|
|
541
|
+
case 'capacity.grant_lease_renewed': {
|
|
542
|
+
const grant = requireFence(state, fact.payload.grantId, fact.payload.fence);
|
|
543
|
+
const policy = requirePolicy(state);
|
|
544
|
+
const action = renewalAuthorityAction(state, policy, fact.payload.assignmentRef, fact.payload.heartbeatSequence);
|
|
545
|
+
const pendingReclaim = Object.values(state.reclaims).some(reclaim => reclaim.status === 'pending');
|
|
546
|
+
const starvedReservation = Object.values(state.requests).some(item => portfolioRequestStatus(state, item.request.requestId) === 'pending'
|
|
547
|
+
&& state.now >= item.request.starvationAt);
|
|
548
|
+
if (grant.status !== 'consumed' || grant.projectId !== fact.payload.projectId
|
|
549
|
+
|| grant.assignmentRef !== fact.payload.assignmentRef
|
|
550
|
+
|| grant.leaseExpiresAt !== fact.payload.previousLeaseExpiresAt
|
|
551
|
+
|| grant.maxLeaseExpiresAt !== fact.payload.maxLeaseExpiresAt
|
|
552
|
+
|| fact.payload.heartbeatSequence !== (grant.lastHeartbeatSequence ?? 0) + 1
|
|
553
|
+
|| fact.payload.renewedAt !== state.now
|
|
554
|
+
|| fact.payload.renewedAt < (grant.lastHeartbeatAt ?? grant.consumedAt) + policy.leaseHeartbeatTicks
|
|
555
|
+
|| fact.payload.policyDigest !== policy.digest
|
|
556
|
+
|| fact.payload.clockSequence !== state.clockSequence
|
|
557
|
+
|| fact.payload.clockDigest !== state.clockDigest
|
|
558
|
+
|| fact.payload.usageSettlementCursor !== state.usageSettlementCursor
|
|
559
|
+
|| fact.payload.leaseExpiresAt !== Math.min(state.now + policy.leaseTtlTicks, fact.payload.maxLeaseExpiresAt)
|
|
560
|
+
|| (grant.renewalCount ?? 0) >= policy.maxLeaseRenewals
|
|
561
|
+
|| pendingReclaim || starvedReservation) {
|
|
562
|
+
throw new Error('Persisted Capacity Grant Lease renewal drift');
|
|
563
|
+
}
|
|
564
|
+
assertKernelAuthority(state.portfolioId, grant, fact.payload.authority, action);
|
|
565
|
+
return updateGrant(next, grant.grantId, {
|
|
566
|
+
leaseExpiresAt: fact.payload.leaseExpiresAt,
|
|
567
|
+
renewalCount: (grant.renewalCount ?? 0) + 1,
|
|
568
|
+
lastHeartbeatSequence: fact.payload.heartbeatSequence,
|
|
569
|
+
lastHeartbeatAt: fact.payload.renewedAt,
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
case 'capacity.grant_expired': {
|
|
573
|
+
const grant = requireFence(state, fact.payload.grantId, fact.payload.fence);
|
|
574
|
+
if (grant.status !== 'offered')
|
|
575
|
+
throw new Error('Only an offered Capacity Grant can expire');
|
|
576
|
+
return updateGrant(next, grant.grantId, { status: 'expired' });
|
|
577
|
+
}
|
|
578
|
+
case 'capacity.grant_lease_lost': {
|
|
579
|
+
const grant = requireFence(state, fact.payload.grantId, fact.payload.fence);
|
|
580
|
+
if (grant.status !== 'consumed' && grant.status !== 'reclaim_requested') {
|
|
581
|
+
throw new Error('Only a consumed Capacity Grant can lose its lease');
|
|
582
|
+
}
|
|
583
|
+
return updateGrant(next, grant.grantId, { status: 'usage_unknown' });
|
|
584
|
+
}
|
|
585
|
+
case 'capacity.usage_settled': {
|
|
586
|
+
const grant = requireFence(state, fact.payload.grantId, fact.payload.fence);
|
|
587
|
+
assertUsageAuthority(state.portfolioId, grant, fact.payload.authority);
|
|
588
|
+
if (fact.payload.authenticatedBy !== fact.payload.authority.authenticatedBy) {
|
|
589
|
+
throw new Error('Persisted Usage Gateway authenticator drift');
|
|
590
|
+
}
|
|
591
|
+
if (!['consumed', 'reclaim_requested', 'usage_pending', 'usage_unknown'].includes(grant.status)) {
|
|
592
|
+
throw new Error('Persisted Capacity Usage settlement status drift');
|
|
593
|
+
}
|
|
594
|
+
return updateGrant({ ...next, usageSettlementCursor: fact.sequence }, grant.grantId, {
|
|
595
|
+
status: 'settled', actualCostMicros: fact.payload.actualCostMicros,
|
|
596
|
+
settlementRef: fact.payload.settlementRef,
|
|
597
|
+
receiptId: fact.payload.receiptId,
|
|
598
|
+
receiptDigest: fact.payload.authority.receiptDigest,
|
|
599
|
+
authenticatedBy: fact.payload.authenticatedBy,
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
case 'capacity.reclaim_requested': {
|
|
603
|
+
const grant = requireGrant(state, fact.payload.reclaim.grantId);
|
|
604
|
+
const request = requireRequest(state, grant.requestId).request;
|
|
605
|
+
const candidate = fact.payload.reclaim.reservedForRequestId === undefined
|
|
606
|
+
? undefined
|
|
607
|
+
: requireRequest(state, fact.payload.reclaim.reservedForRequestId);
|
|
608
|
+
if (grant.status !== 'consumed' || request.preemptibility !== 'checkpointable'
|
|
609
|
+
|| !candidate
|
|
610
|
+
|| canonicalWorkroomJson(createReclaim(state, grant, candidate))
|
|
611
|
+
!== canonicalWorkroomJson(fact.payload.reclaim)) {
|
|
612
|
+
throw new Error('Persisted Capacity Reclaim attempts to preempt atomic/stale work');
|
|
613
|
+
}
|
|
614
|
+
next = { ...next, reclaims: { ...state.reclaims, [fact.payload.reclaim.reclaimId]: fact.payload.reclaim } };
|
|
615
|
+
return updateGrant(next, grant.grantId, { status: 'reclaim_requested' });
|
|
616
|
+
}
|
|
617
|
+
case 'capacity.reclaim_acknowledged': {
|
|
618
|
+
const reclaim = requireReclaim(state, fact.payload.reclaimId);
|
|
619
|
+
const grant = requireFence(state, fact.payload.grantId, fact.payload.fence);
|
|
620
|
+
if (reclaim.status !== 'pending' || reclaim.projectId !== fact.payload.projectId) {
|
|
621
|
+
throw new Error('Persisted Capacity Reclaim acknowledgement drift');
|
|
622
|
+
}
|
|
623
|
+
assertKernelAuthority(state.portfolioId, grant, fact.payload.authority, {
|
|
624
|
+
action: 'reclaim_acknowledge', assignmentRef: grant.assignmentRef,
|
|
625
|
+
reclaimId: reclaim.reclaimId, outcome: fact.payload.outcome,
|
|
626
|
+
...(fact.payload.checkpointRef === undefined ? {} : { checkpointRef: fact.payload.checkpointRef }),
|
|
627
|
+
...(fact.payload.checkpointDigest === undefined ? {} : { checkpointDigest: fact.payload.checkpointDigest }),
|
|
628
|
+
});
|
|
629
|
+
next = {
|
|
630
|
+
...next,
|
|
631
|
+
reclaims: {
|
|
632
|
+
...state.reclaims,
|
|
633
|
+
[reclaim.reclaimId]: {
|
|
634
|
+
...reclaim,
|
|
635
|
+
status: fact.payload.outcome,
|
|
636
|
+
...(fact.payload.checkpointRef === undefined ? {} : { checkpointRef: fact.payload.checkpointRef }),
|
|
637
|
+
...(fact.payload.checkpointDigest === undefined ? {} : { checkpointDigest: fact.payload.checkpointDigest }),
|
|
638
|
+
},
|
|
639
|
+
},
|
|
640
|
+
};
|
|
641
|
+
return updateGrant(next, grant.grantId, {
|
|
642
|
+
status: fact.payload.outcome === 'checkpointed' ? 'usage_pending' : 'consumed',
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
case 'capacity.reclaim_timed_out': {
|
|
646
|
+
const reclaim = requireReclaim(state, fact.payload.reclaimId);
|
|
647
|
+
const grant = requireFence(state, fact.payload.grantId, fact.payload.fence);
|
|
648
|
+
next = {
|
|
649
|
+
...next,
|
|
650
|
+
reclaims: { ...state.reclaims, [reclaim.reclaimId]: { ...reclaim, status: 'timed_out' } },
|
|
651
|
+
};
|
|
652
|
+
return grant.status === 'reclaim_requested'
|
|
653
|
+
? updateGrant(next, grant.grantId, { status: 'consumed' })
|
|
654
|
+
: next;
|
|
655
|
+
}
|
|
656
|
+
case 'clock.advanced':
|
|
657
|
+
assertClockAuthority(state.portfolioId, fact.payload.authority);
|
|
658
|
+
if (fact.payload.authority.now !== fact.payload.now) {
|
|
659
|
+
throw new Error('Persisted Portfolio clock authority time drift');
|
|
660
|
+
}
|
|
661
|
+
if (fact.payload.now <= state.now)
|
|
662
|
+
throw new Error('Persisted Portfolio clock did not advance');
|
|
663
|
+
return {
|
|
664
|
+
...next,
|
|
665
|
+
now: fact.payload.now,
|
|
666
|
+
clockSequence: fact.sequence,
|
|
667
|
+
clockDigest: fact.payload.authority.clockDigest,
|
|
668
|
+
};
|
|
669
|
+
case 'service.normalized':
|
|
670
|
+
return {
|
|
671
|
+
...next,
|
|
672
|
+
normalizedService: fact.payload.normalization.projectService,
|
|
673
|
+
normalizedAtSequence: fact.sequence,
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
function decideAdmission(state) {
|
|
678
|
+
const heads = projectHeads(state).sort((left, right) => compareRequests(state, left, right));
|
|
679
|
+
for (const head of heads) {
|
|
680
|
+
if (blockers(state, head).length === 0)
|
|
681
|
+
return createGrant(state, head);
|
|
682
|
+
}
|
|
683
|
+
for (const head of heads) {
|
|
684
|
+
const blocked = blockers(state, head);
|
|
685
|
+
if (blocked.length > 0 && blocked.every(item => item.startsWith('capacity:'))) {
|
|
686
|
+
const victim = reclaimVictim(state, head);
|
|
687
|
+
if (victim)
|
|
688
|
+
return createReclaim(state, victim, head);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
return null;
|
|
692
|
+
}
|
|
693
|
+
function projectHeads(state) {
|
|
694
|
+
const byProject = new Map();
|
|
695
|
+
for (const request of Object.values(state.requests)) {
|
|
696
|
+
if (portfolioRequestStatus(state, request.request.requestId) !== 'pending')
|
|
697
|
+
continue;
|
|
698
|
+
if (requirePolicy(state).projects[request.request.projectId]?.status !== 'active')
|
|
699
|
+
continue;
|
|
700
|
+
const entries = byProject.get(request.request.projectId) ?? [];
|
|
701
|
+
entries.push(request);
|
|
702
|
+
byProject.set(request.request.projectId, entries);
|
|
703
|
+
}
|
|
704
|
+
return [...byProject.values()].map(entries => entries.sort((left, right) => left.request.localOrder - right.request.localOrder
|
|
705
|
+
|| left.request.schedulerSequence - right.request.schedulerSequence
|
|
706
|
+
|| compareCanonicalWorkroomText(left.request.requestId, right.request.requestId))[0]);
|
|
707
|
+
}
|
|
708
|
+
function compareRequests(state, left, right) {
|
|
709
|
+
const leftStarved = state.now >= left.request.starvationAt;
|
|
710
|
+
const rightStarved = state.now >= right.request.starvationAt;
|
|
711
|
+
if (leftStarved !== rightStarved)
|
|
712
|
+
return leftStarved ? -1 : 1;
|
|
713
|
+
if (leftStarved && left.request.starvationAt !== right.request.starvationAt) {
|
|
714
|
+
return left.request.starvationAt - right.request.starvationAt;
|
|
715
|
+
}
|
|
716
|
+
const lane = LANE_ORDER[effectiveLane(state, left.request)] - LANE_ORDER[effectiveLane(state, right.request)];
|
|
717
|
+
if (lane !== 0)
|
|
718
|
+
return lane;
|
|
719
|
+
const service = projectedDominantService(state, left) - projectedDominantService(state, right);
|
|
720
|
+
if (service !== 0)
|
|
721
|
+
return service;
|
|
722
|
+
const deadline = (left.request.deadlineAt ?? Number.POSITIVE_INFINITY)
|
|
723
|
+
- (right.request.deadlineAt ?? Number.POSITIVE_INFINITY);
|
|
724
|
+
if (deadline !== 0)
|
|
725
|
+
return deadline;
|
|
726
|
+
return left.request.schedulerSequence - right.request.schedulerSequence
|
|
727
|
+
|| compareCanonicalWorkroomText(left.request.requestId, right.request.requestId);
|
|
728
|
+
}
|
|
729
|
+
function blockers(state, request) {
|
|
730
|
+
const policy = requirePolicy(state);
|
|
731
|
+
const project = policy.projects[request.request.projectId];
|
|
732
|
+
const result = [];
|
|
733
|
+
if (project.status !== 'active')
|
|
734
|
+
result.push(`project:${project.status}`);
|
|
735
|
+
const active = Object.values(state.grants).filter(grant => grant.projectId === project.projectId
|
|
736
|
+
&& CAPACITY_HOLDING.has(grant.status));
|
|
737
|
+
if (active.length >= project.maxConcurrentGrants)
|
|
738
|
+
result.push('project:concurrency');
|
|
739
|
+
const burst = Object.values(state.grants).filter(grant => grant.projectId === project.projectId
|
|
740
|
+
&& grant.issuedAt === state.now).length;
|
|
741
|
+
if (burst >= project.burstLimit)
|
|
742
|
+
result.push('project:burst');
|
|
743
|
+
const reserved = request.bundleAuthority.reservedCostMicros;
|
|
744
|
+
if (portfolioProjectBudget(state, project.projectId).availableMicros < reserved)
|
|
745
|
+
result.push('project:budget');
|
|
746
|
+
if (portfolioGlobalBudget(state).availableMicros < reserved)
|
|
747
|
+
result.push('global:budget');
|
|
748
|
+
for (const demand of request.request.resourceBundle.demands) {
|
|
749
|
+
const pool = policy.pools[demand.poolId];
|
|
750
|
+
const used = Object.values(state.grants).filter(grant => CAPACITY_HOLDING.has(grant.status))
|
|
751
|
+
.reduce((sum, grant) => sum
|
|
752
|
+
+ (grant.resourceBundle.demands.find(item => item.poolId === demand.poolId)?.capacityUnits ?? 0), 0);
|
|
753
|
+
if (used + demand.capacityUnits > pool.capacityUnits)
|
|
754
|
+
result.push(`capacity:${demand.poolId}`);
|
|
755
|
+
if (rateUsed(state, demand.poolId) + demand.rateUnits > pool.rateUnitsPerWindow) {
|
|
756
|
+
result.push(`rate:${demand.poolId}`);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
return result;
|
|
760
|
+
}
|
|
761
|
+
function createGrant(state, request) {
|
|
762
|
+
const policy = requirePolicy(state);
|
|
763
|
+
const authority = request.bundleAuthority;
|
|
764
|
+
const fence = Object.values(state.grants).filter(grant => grant.requestId === request.request.requestId)
|
|
765
|
+
.reduce((highest, grant) => Math.max(highest, grant.fence), 0) + 1;
|
|
766
|
+
return deepFreeze({
|
|
767
|
+
grantId: `capacity-grant:${encodeURIComponent(request.request.requestId)}:${fence}`,
|
|
768
|
+
requestId: request.request.requestId,
|
|
769
|
+
projectId: request.request.projectId,
|
|
770
|
+
fence,
|
|
771
|
+
resourceBundle: request.request.resourceBundle,
|
|
772
|
+
requestDigest: authority.requestDigest,
|
|
773
|
+
resourceBundleDigest: authority.resourceBundleDigest,
|
|
774
|
+
catalogGenerationId: authority.catalogGenerationId,
|
|
775
|
+
catalogRevision: authority.catalogRevision,
|
|
776
|
+
catalogDigest: authority.catalogDigest,
|
|
777
|
+
profileRevisionId: authority.profileRevisionId,
|
|
778
|
+
profileDigest: authority.profileDigest,
|
|
779
|
+
profileCeilingDigest: authority.profileCeilingDigest,
|
|
780
|
+
validatedBundleDigest: authority.validatedBundleDigest,
|
|
781
|
+
reservedCostMicros: authority.reservedCostMicros,
|
|
782
|
+
portfolioPolicyRevision: policy.revision,
|
|
783
|
+
portfolioPolicyDigest: policy.digest,
|
|
784
|
+
projectPolicyRevision: policy.projects[request.request.projectId].revision,
|
|
785
|
+
lane: effectiveLane(state, request.request),
|
|
786
|
+
issuedAt: state.now,
|
|
787
|
+
issuedSequence: state.sequence + 1,
|
|
788
|
+
offerExpiresAt: state.now + policy.offerTtlTicks,
|
|
789
|
+
status: 'offered',
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
function reclaimVictim(state, candidate) {
|
|
793
|
+
const candidateLane = LANE_ORDER[effectiveLane(state, candidate.request)];
|
|
794
|
+
const pools = new Set(candidate.request.resourceBundle.demands.map(item => item.poolId));
|
|
795
|
+
return Object.values(state.grants).filter(grant => {
|
|
796
|
+
const request = state.requests[grant.requestId]?.request;
|
|
797
|
+
return grant.status === 'consumed'
|
|
798
|
+
&& request?.preemptibility === 'checkpointable'
|
|
799
|
+
&& grant.projectId !== candidate.request.projectId
|
|
800
|
+
&& grant.resourceBundle.demands.some(item => pools.has(item.poolId))
|
|
801
|
+
&& (state.now >= candidate.request.starvationAt || candidateLane < LANE_ORDER[grant.lane]);
|
|
802
|
+
}).sort((left, right) => LANE_ORDER[right.lane] - LANE_ORDER[left.lane]
|
|
803
|
+
|| right.issuedAt - left.issuedAt || compareCanonicalWorkroomText(right.grantId, left.grantId))[0];
|
|
804
|
+
}
|
|
805
|
+
function createReclaim(state, grant, candidate) {
|
|
806
|
+
return deepFreeze({
|
|
807
|
+
reclaimId: `capacity-reclaim:${encodeURIComponent(grant.grantId)}:${grant.fence}`,
|
|
808
|
+
grantId: grant.grantId,
|
|
809
|
+
projectId: grant.projectId,
|
|
810
|
+
reservedForRequestId: candidate.request.requestId,
|
|
811
|
+
requestedAt: state.now,
|
|
812
|
+
deadline: state.now + requirePolicy(state).reclaimTtlTicks,
|
|
813
|
+
reason: state.now >= candidate.request.starvationAt ? 'starvation_bound' : 'higher_portfolio_priority',
|
|
814
|
+
status: 'pending',
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
function projectedDominantService(state, request) {
|
|
818
|
+
const project = requirePolicy(state).projects[request.request.projectId];
|
|
819
|
+
let dominant = (state.normalizedService[project.projectId] ?? 0) / 1_000_000;
|
|
820
|
+
for (const pool of Object.values(requirePolicy(state).pools)) {
|
|
821
|
+
const historical = Object.values(state.grants)
|
|
822
|
+
.filter(grant => grant.projectId === project.projectId
|
|
823
|
+
&& grant.status !== 'expired'
|
|
824
|
+
&& grant.issuedSequence > state.normalizedAtSequence)
|
|
825
|
+
.reduce((sum, grant) => sum
|
|
826
|
+
+ (grant.resourceBundle.demands.find(item => item.poolId === pool.poolId)?.capacityUnits ?? 0), 0);
|
|
827
|
+
const requested = request.request.resourceBundle.demands
|
|
828
|
+
.find(item => item.poolId === pool.poolId)?.capacityUnits ?? 0;
|
|
829
|
+
dominant = Math.max(dominant, (historical + requested) / pool.capacityUnits / project.weight);
|
|
830
|
+
}
|
|
831
|
+
return dominant;
|
|
832
|
+
}
|
|
833
|
+
function dominantService(state, projectId) {
|
|
834
|
+
const project = requirePolicy(state).projects[projectId];
|
|
835
|
+
if (!project)
|
|
836
|
+
throw new Error(`Unknown Portfolio Project ${projectId}`);
|
|
837
|
+
let dominant = (state.normalizedService[projectId] ?? 0) / 1_000_000;
|
|
838
|
+
for (const pool of Object.values(requirePolicy(state).pools)) {
|
|
839
|
+
const historical = Object.values(state.grants)
|
|
840
|
+
.filter(grant => grant.projectId === projectId && grant.status !== 'expired'
|
|
841
|
+
&& grant.issuedSequence > state.normalizedAtSequence)
|
|
842
|
+
.reduce((sum, grant) => sum
|
|
843
|
+
+ (grant.resourceBundle.demands.find(item => item.poolId === pool.poolId)?.capacityUnits ?? 0), 0);
|
|
844
|
+
dominant = Math.max(dominant, historical / pool.capacityUnits / project.weight);
|
|
845
|
+
}
|
|
846
|
+
return Math.floor(dominant * 1_000_000);
|
|
847
|
+
}
|
|
848
|
+
function effectiveLane(state, request) {
|
|
849
|
+
const override = Object.values(state.overrides).find(item => item.requestId === request.requestId && item.projectId === request.projectId
|
|
850
|
+
&& item.requestPayloadDigest === request.payloadDigest && item.expiresAt > state.now);
|
|
851
|
+
return override?.lane ?? requirePolicy(state).projects[request.projectId].lane;
|
|
852
|
+
}
|
|
853
|
+
function rateUsed(state, poolId) {
|
|
854
|
+
const pool = requirePolicy(state).pools[poolId];
|
|
855
|
+
const start = Math.floor(state.now / pool.rateWindowTicks) * pool.rateWindowTicks;
|
|
856
|
+
return Object.values(state.grants).reduce((sum, grant) => {
|
|
857
|
+
const units = grant.resourceBundle.demands.find(item => item.poolId === poolId)?.rateUnits ?? 0;
|
|
858
|
+
if (grant.status === 'offered')
|
|
859
|
+
return sum + units;
|
|
860
|
+
if (grant.consumedAt !== undefined && grant.consumedAt >= start)
|
|
861
|
+
return sum + units;
|
|
862
|
+
return sum;
|
|
863
|
+
}, 0);
|
|
864
|
+
}
|
|
865
|
+
function portfolioGlobalBudget(state) {
|
|
866
|
+
const grants = Object.values(state.grants);
|
|
867
|
+
const spentMicros = grants.filter(grant => grant.status === 'settled')
|
|
868
|
+
.reduce((sum, grant) => sum + (grant.actualCostMicros ?? 0), 0);
|
|
869
|
+
const reservedMicros = grants.filter(grant => BUDGET_HOLDING.has(grant.status))
|
|
870
|
+
.reduce((sum, grant) => sum + grant.reservedCostMicros, 0);
|
|
871
|
+
return {
|
|
872
|
+
spentMicros, reservedMicros,
|
|
873
|
+
availableMicros: requirePolicy(state).globalBudgetMicros - spentMicros - reservedMicros,
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
function assertBundleAuthority(request, authority, policy) {
|
|
877
|
+
if (authority.requestDigest !== portfolioCapacityRequestDigest(request)
|
|
878
|
+
|| authority.resourceBundleDigest !== digest(parsePortfolioResourceBundle(request.resourceBundle))
|
|
879
|
+
|| authority.profileRevisionId !== request.workRef.profileRevisionId
|
|
880
|
+
|| authority.profileDigest !== request.workRef.profileDigest
|
|
881
|
+
|| authority.reservedCostMicros !== reservedCost(policy, request)
|
|
882
|
+
|| authority.validatedBundleDigest !== portfolioValidatedBundleDigest(authority)) {
|
|
883
|
+
throw new Error('Validated Atomic Resource Bundle authority/request drift');
|
|
884
|
+
}
|
|
885
|
+
const project = policy.projects[request.projectId];
|
|
886
|
+
if (!project || request.resourceBundle.demands.some(demand => !project.allowedPools.includes(demand.poolId))) {
|
|
887
|
+
throw new Error('Validated Atomic Resource Bundle is outside Portfolio Project Policy');
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
function assertGrantMatchesRequest(grant, request, state) {
|
|
891
|
+
const authority = request.bundleAuthority;
|
|
892
|
+
const policy = requirePolicy(state);
|
|
893
|
+
const fence = Object.values(state.grants).filter(item => item.requestId === request.request.requestId)
|
|
894
|
+
.reduce((highest, item) => Math.max(highest, item.fence), 0) + 1;
|
|
895
|
+
if (grant.status !== 'offered'
|
|
896
|
+
|| grant.grantId !== `capacity-grant:${encodeURIComponent(request.request.requestId)}:${fence}`
|
|
897
|
+
|| grant.fence !== fence
|
|
898
|
+
|| grant.requestId !== request.request.requestId
|
|
899
|
+
|| grant.projectId !== request.request.projectId
|
|
900
|
+
|| grant.requestDigest !== authority.requestDigest
|
|
901
|
+
|| grant.resourceBundleDigest !== authority.resourceBundleDigest
|
|
902
|
+
|| grant.validatedBundleDigest !== authority.validatedBundleDigest
|
|
903
|
+
|| grant.catalogGenerationId !== authority.catalogGenerationId
|
|
904
|
+
|| grant.catalogRevision !== authority.catalogRevision
|
|
905
|
+
|| grant.catalogDigest !== authority.catalogDigest
|
|
906
|
+
|| grant.profileRevisionId !== authority.profileRevisionId
|
|
907
|
+
|| grant.profileDigest !== authority.profileDigest
|
|
908
|
+
|| grant.profileCeilingDigest !== authority.profileCeilingDigest
|
|
909
|
+
|| grant.reservedCostMicros !== authority.reservedCostMicros
|
|
910
|
+
|| grant.portfolioPolicyRevision !== policy.revision
|
|
911
|
+
|| grant.portfolioPolicyDigest !== policy.digest
|
|
912
|
+
|| grant.projectPolicyRevision !== policy.projects[grant.projectId]?.revision
|
|
913
|
+
|| grant.lane !== effectiveLane(state, request.request)
|
|
914
|
+
|| grant.issuedAt !== state.now
|
|
915
|
+
|| grant.offerExpiresAt !== state.now + policy.offerTtlTicks
|
|
916
|
+
|| canonicalWorkroomJson(grant.resourceBundle) !== canonicalWorkroomJson(request.request.resourceBundle)) {
|
|
917
|
+
throw new Error('Capacity Grant drifted from validated Atomic Resource Bundle');
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
export function portfolioCapacityRequestDigest(request) {
|
|
921
|
+
return digest(parsePortfolioCapacityRequest(request));
|
|
922
|
+
}
|
|
923
|
+
export function portfolioValidatedBundleDigest(authority) {
|
|
924
|
+
const { validatedBundleDigest: _ignored, ...claims } = authority;
|
|
925
|
+
return digest(claims);
|
|
926
|
+
}
|
|
927
|
+
function reservedCost(policy, request) {
|
|
928
|
+
return request.resourceBundle.demands.reduce((sum, demand) => {
|
|
929
|
+
const price = policy.pools[demand.poolId]?.priceMicrosPerBudgetUnit;
|
|
930
|
+
if (price === undefined)
|
|
931
|
+
throw new Error(`Unknown Portfolio Resource Pool ${demand.poolId}`);
|
|
932
|
+
const cost = demand.budgetUnits * price;
|
|
933
|
+
if (!Number.isSafeInteger(cost) || !Number.isSafeInteger(sum + cost)) {
|
|
934
|
+
throw new Error('Portfolio budget reservation overflows');
|
|
935
|
+
}
|
|
936
|
+
return sum + cost;
|
|
937
|
+
}, 0);
|
|
938
|
+
}
|
|
939
|
+
function assertGovernance(proof, targetDigest, expectedRevision) {
|
|
940
|
+
if (!proof || proof.targetDigest !== targetDigest || proof.expectedRevision !== expectedRevision
|
|
941
|
+
|| !proof.principalId || !proof.authorizedBy
|
|
942
|
+
|| !/^sha256:[a-f0-9]{64}$/u.test(proof.reasonDigest)) {
|
|
943
|
+
throw new Error('Portfolio Governance proof scope/revision is stale');
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
export function portfolioKernelCommandDigest(claims) {
|
|
947
|
+
return digest(claims);
|
|
948
|
+
}
|
|
949
|
+
export function portfolioUsageReceiptDigest(claims) {
|
|
950
|
+
return digest(claims);
|
|
951
|
+
}
|
|
952
|
+
export function portfolioClockDigest(claims) {
|
|
953
|
+
return digest(claims);
|
|
954
|
+
}
|
|
955
|
+
function assertKernelAuthority(portfolioId, grant, authority, action) {
|
|
956
|
+
const claims = {
|
|
957
|
+
portfolioId: authority.portfolioId,
|
|
958
|
+
action: authority.action,
|
|
959
|
+
projectId: authority.projectId,
|
|
960
|
+
requestId: authority.requestId,
|
|
961
|
+
grantId: authority.grantId,
|
|
962
|
+
fence: authority.fence,
|
|
963
|
+
assignmentRef: authority.assignmentRef,
|
|
964
|
+
...(authority.reclaimId === undefined ? {} : { reclaimId: authority.reclaimId }),
|
|
965
|
+
...(authority.outcome === undefined ? {} : { outcome: authority.outcome }),
|
|
966
|
+
...(authority.checkpointRef === undefined ? {} : { checkpointRef: authority.checkpointRef }),
|
|
967
|
+
...(authority.checkpointDigest === undefined ? {} : { checkpointDigest: authority.checkpointDigest }),
|
|
968
|
+
...(authority.heartbeatSequence === undefined ? {} : { heartbeatSequence: authority.heartbeatSequence }),
|
|
969
|
+
...(authority.clockSequence === undefined ? {} : { clockSequence: authority.clockSequence }),
|
|
970
|
+
...(authority.clockDigest === undefined ? {} : { clockDigest: authority.clockDigest }),
|
|
971
|
+
...(authority.policyDigest === undefined ? {} : { policyDigest: authority.policyDigest }),
|
|
972
|
+
...(authority.usageSettlementCursor === undefined
|
|
973
|
+
? {}
|
|
974
|
+
: { usageSettlementCursor: authority.usageSettlementCursor }),
|
|
975
|
+
...(authority.failureReason === undefined ? {} : { failureReason: authority.failureReason }),
|
|
976
|
+
...(authority.kernelSequence === undefined ? {} : { kernelSequence: authority.kernelSequence }),
|
|
977
|
+
...(authority.kernelFactDigest === undefined ? {} : { kernelFactDigest: authority.kernelFactDigest }),
|
|
978
|
+
};
|
|
979
|
+
const expected = {
|
|
980
|
+
portfolioId,
|
|
981
|
+
action: action.action,
|
|
982
|
+
projectId: grant.projectId,
|
|
983
|
+
requestId: grant.requestId,
|
|
984
|
+
grantId: grant.grantId,
|
|
985
|
+
fence: grant.fence,
|
|
986
|
+
assignmentRef: action.assignmentRef,
|
|
987
|
+
...(action.reclaimId === undefined ? {} : { reclaimId: action.reclaimId }),
|
|
988
|
+
...(action.outcome === undefined ? {} : { outcome: action.outcome }),
|
|
989
|
+
...(action.checkpointRef === undefined ? {} : { checkpointRef: action.checkpointRef }),
|
|
990
|
+
...(action.checkpointDigest === undefined ? {} : { checkpointDigest: action.checkpointDigest }),
|
|
991
|
+
...(action.heartbeatSequence === undefined ? {} : { heartbeatSequence: action.heartbeatSequence }),
|
|
992
|
+
...(action.clockSequence === undefined ? {} : { clockSequence: action.clockSequence }),
|
|
993
|
+
...(action.clockDigest === undefined ? {} : { clockDigest: action.clockDigest }),
|
|
994
|
+
...(action.policyDigest === undefined ? {} : { policyDigest: action.policyDigest }),
|
|
995
|
+
...(action.usageSettlementCursor === undefined
|
|
996
|
+
? {}
|
|
997
|
+
: { usageSettlementCursor: action.usageSettlementCursor }),
|
|
998
|
+
...(action.failureReason === undefined ? {} : { failureReason: action.failureReason }),
|
|
999
|
+
...(action.kernelSequence === undefined ? {} : { kernelSequence: action.kernelSequence }),
|
|
1000
|
+
...(action.kernelFactDigest === undefined ? {} : { kernelFactDigest: action.kernelFactDigest }),
|
|
1001
|
+
};
|
|
1002
|
+
if (!authority.authorizedBy || canonicalWorkroomJson(claims) !== canonicalWorkroomJson(expected)
|
|
1003
|
+
|| authority.commandDigest !== portfolioKernelCommandDigest(claims)) {
|
|
1004
|
+
throw new Error('Owning Workroom Kernel command authority scope is stale');
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
function renewalAuthorityAction(state, policy, assignmentRef, heartbeatSequence) {
|
|
1008
|
+
if (state.clockSequence < 0 || !state.clockDigest) {
|
|
1009
|
+
throw new Error('Capacity Grant Lease renewal requires a current Portfolio clock fact');
|
|
1010
|
+
}
|
|
1011
|
+
return {
|
|
1012
|
+
action: 'renew',
|
|
1013
|
+
assignmentRef,
|
|
1014
|
+
heartbeatSequence,
|
|
1015
|
+
clockSequence: state.clockSequence,
|
|
1016
|
+
clockDigest: state.clockDigest,
|
|
1017
|
+
policyDigest: policy.digest,
|
|
1018
|
+
usageSettlementCursor: state.usageSettlementCursor,
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
function assertUsageAuthority(portfolioId, grant, authority) {
|
|
1022
|
+
const claims = {
|
|
1023
|
+
portfolioId: authority.portfolioId,
|
|
1024
|
+
receiptId: authority.receiptId,
|
|
1025
|
+
requestId: authority.requestId,
|
|
1026
|
+
grantId: authority.grantId,
|
|
1027
|
+
fence: authority.fence,
|
|
1028
|
+
actualCostMicros: authority.actualCostMicros,
|
|
1029
|
+
settlementRef: authority.settlementRef,
|
|
1030
|
+
};
|
|
1031
|
+
if (!authority.authenticatedBy || authority.portfolioId !== portfolioId
|
|
1032
|
+
|| authority.requestId !== grant.requestId || authority.grantId !== grant.grantId
|
|
1033
|
+
|| authority.fence !== grant.fence
|
|
1034
|
+
|| authority.receiptDigest !== portfolioUsageReceiptDigest(claims)) {
|
|
1035
|
+
throw new Error('Usage Gateway receipt authority scope is stale');
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
function assertClockAuthority(portfolioId, authority) {
|
|
1039
|
+
const claims = { portfolioId: authority.portfolioId, now: authority.now };
|
|
1040
|
+
if (!authority.authorizedBy || authority.portfolioId !== portfolioId
|
|
1041
|
+
|| authority.clockDigest !== portfolioClockDigest(claims)) {
|
|
1042
|
+
throw new Error('Portfolio Kernel clock authority scope is stale');
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
function requirePolicy(state) {
|
|
1046
|
+
if (!state.policy)
|
|
1047
|
+
throw new Error('Portfolio Policy authority is unavailable');
|
|
1048
|
+
return state.policy;
|
|
1049
|
+
}
|
|
1050
|
+
function requireRequest(state, requestId) {
|
|
1051
|
+
const request = state.requests[requestId];
|
|
1052
|
+
if (!request)
|
|
1053
|
+
throw new Error(`Unknown Capacity Request ${requestId}`);
|
|
1054
|
+
return request;
|
|
1055
|
+
}
|
|
1056
|
+
function requireGrant(state, grantId) {
|
|
1057
|
+
const grant = state.grants[grantId];
|
|
1058
|
+
if (!grant)
|
|
1059
|
+
throw new Error(`Unknown Capacity Grant ${grantId}`);
|
|
1060
|
+
return grant;
|
|
1061
|
+
}
|
|
1062
|
+
function requireFence(state, grantId, fence) {
|
|
1063
|
+
const grant = requireGrant(state, grantId);
|
|
1064
|
+
if (grant.fence !== fence)
|
|
1065
|
+
throw new Error('Capacity Grant fence is stale');
|
|
1066
|
+
return grant;
|
|
1067
|
+
}
|
|
1068
|
+
function requireReclaim(state, reclaimId) {
|
|
1069
|
+
const reclaim = state.reclaims[reclaimId];
|
|
1070
|
+
if (!reclaim)
|
|
1071
|
+
throw new Error(`Unknown Capacity Reclaim ${reclaimId}`);
|
|
1072
|
+
return reclaim;
|
|
1073
|
+
}
|
|
1074
|
+
function updateGrant(state, grantId, patch) {
|
|
1075
|
+
return {
|
|
1076
|
+
...state,
|
|
1077
|
+
grants: { ...state.grants, [grantId]: { ...requireGrant(state, grantId), ...patch } },
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
//# sourceMappingURL=portfolio-admission.js.map
|