@plurnk/plurnk-service 1.17.0 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.defaults +95 -14
- package/README.md +5 -3
- package/SPEC.md +1756 -1442
- package/dist/Paths.js +3 -3
- package/dist/build-info.json +1 -1
- package/dist/content/body-preview.d.ts +1 -0
- package/dist/content/body-preview.d.ts.map +1 -1
- package/dist/content/body-preview.js +8 -10
- package/dist/content/body-preview.js.map +1 -1
- package/dist/content/edit-receipt.d.ts.map +1 -1
- package/dist/content/edit-receipt.js +30 -29
- package/dist/content/edit-receipt.js.map +1 -1
- package/dist/content/line-anchors.d.ts.map +1 -1
- package/dist/content/line-anchors.js +17 -5
- package/dist/content/line-anchors.js.map +1 -1
- package/dist/content/read-projector.d.ts +2 -2
- package/dist/content/read-projector.d.ts.map +1 -1
- package/dist/content/read-projector.js +81 -39
- package/dist/content/read-projector.js.map +1 -1
- package/dist/content/read-resolve.d.ts +1 -0
- package/dist/content/read-resolve.d.ts.map +1 -1
- package/dist/content/read-resolve.js +13 -10
- package/dist/content/read-resolve.js.map +1 -1
- package/dist/content/scope-format.d.ts +9 -0
- package/dist/content/scope-format.d.ts.map +1 -0
- package/dist/content/scope-format.js +28 -0
- package/dist/content/scope-format.js.map +1 -0
- package/dist/core/AdministrativeLoop.d.ts +8 -0
- package/dist/core/AdministrativeLoop.d.ts.map +1 -0
- package/dist/core/AdministrativeLoop.js +16 -0
- package/dist/core/AdministrativeLoop.js.map +1 -0
- package/dist/core/AdmittedTurnExecutor.d.ts +2 -2
- package/dist/core/AdmittedTurnExecutor.d.ts.map +1 -1
- package/dist/core/AdmittedTurnExecutor.js +26 -26
- package/dist/core/AdmittedTurnExecutor.js.map +1 -1
- package/dist/core/BareBatchRunner.d.ts +1 -2
- package/dist/core/BareBatchRunner.d.ts.map +1 -1
- package/dist/core/BareBatchRunner.js +7 -12
- package/dist/core/BareBatchRunner.js.map +1 -1
- package/dist/core/BudgetReadout.d.ts.map +1 -1
- package/dist/core/BudgetReadout.js +3 -4
- package/dist/core/BudgetReadout.js.map +1 -1
- package/dist/core/CapabilityPolicies.d.ts +4 -2
- package/dist/core/CapabilityPolicies.d.ts.map +1 -1
- package/dist/core/CapabilityPolicies.js +23 -2
- package/dist/core/CapabilityPolicies.js.map +1 -1
- package/dist/core/CapabilityResolver.d.ts +2 -2
- package/dist/core/CapabilityResolver.d.ts.map +1 -1
- package/dist/core/CapabilityResolver.js +46 -36
- package/dist/core/CapabilityResolver.js.map +1 -1
- package/dist/core/ChannelWrite.d.ts +4 -6
- package/dist/core/ChannelWrite.d.ts.map +1 -1
- package/dist/core/ChannelWrite.js +8 -8
- package/dist/core/ChannelWrite.js.map +1 -1
- package/dist/core/ChannelWrite.sql +17 -11
- package/dist/core/ClientInteractions.d.ts +11 -1
- package/dist/core/ClientInteractions.d.ts.map +1 -1
- package/dist/core/ClientInteractions.js +26 -2
- package/dist/core/ClientInteractions.js.map +1 -1
- package/dist/core/CoreSchemeServices.d.ts.map +1 -1
- package/dist/core/CoreSchemeServices.js +1 -0
- package/dist/core/CoreSchemeServices.js.map +1 -1
- package/dist/core/DataStatementRunner.d.ts.map +1 -1
- package/dist/core/DataStatementRunner.js +198 -148
- package/dist/core/DataStatementRunner.js.map +1 -1
- package/dist/core/Dispatcher.d.ts +18 -5
- package/dist/core/Dispatcher.d.ts.map +1 -1
- package/dist/core/Dispatcher.js +135 -114
- package/dist/core/Dispatcher.js.map +1 -1
- package/dist/core/Dispatcher.sql +11 -26
- package/dist/core/DurableStatement.d.ts +4 -1
- package/dist/core/DurableStatement.d.ts.map +1 -1
- package/dist/core/DurableStatement.js +4 -4
- package/dist/core/DurableStatement.js.map +1 -1
- package/dist/core/EditMutations.d.ts.map +1 -1
- package/dist/core/EditMutations.js +5 -2
- package/dist/core/EditMutations.js.map +1 -1
- package/dist/core/Engine.d.ts +11 -9
- package/dist/core/Engine.d.ts.map +1 -1
- package/dist/core/Engine.js +27 -65
- package/dist/core/Engine.js.map +1 -1
- package/dist/core/Engine.sql +2 -22
- package/dist/core/EnvFlags.d.ts.map +1 -1
- package/dist/core/EnvFlags.js +4 -2
- package/dist/core/EnvFlags.js.map +1 -1
- package/dist/core/ExecutionOutputs.sql +8 -0
- package/dist/core/ExecutorRegistry.d.ts +4 -0
- package/dist/core/ExecutorRegistry.d.ts.map +1 -1
- package/dist/core/ExecutorRegistry.js +3 -1
- package/dist/core/ExecutorRegistry.js.map +1 -1
- package/dist/core/KillHandler.d.ts.map +1 -1
- package/dist/core/KillHandler.js +7 -12
- package/dist/core/KillHandler.js.map +1 -1
- package/dist/core/Knob.d.ts +9 -0
- package/dist/core/Knob.d.ts.map +1 -0
- package/dist/core/Knob.js +50 -0
- package/dist/core/Knob.js.map +1 -0
- package/dist/core/LogBody.d.ts.map +1 -1
- package/dist/core/LogBody.js +8 -36
- package/dist/core/LogBody.js.map +1 -1
- package/dist/core/LogEntryProjection.d.ts.map +1 -1
- package/dist/core/LogEntryProjection.js +8 -10
- package/dist/core/LogEntryProjection.js.map +1 -1
- package/dist/core/LogVisibility.d.ts.map +1 -1
- package/dist/core/LogVisibility.js +2 -1
- package/dist/core/LogVisibility.js.map +1 -1
- package/dist/core/LogWriter.d.ts.map +1 -1
- package/dist/core/LogWriter.js +11 -9
- package/dist/core/LogWriter.js.map +1 -1
- package/dist/core/LoopDriver.d.ts +1 -1
- package/dist/core/LoopDriver.d.ts.map +1 -1
- package/dist/core/LoopDriver.js +24 -32
- package/dist/core/LoopDriver.js.map +1 -1
- package/dist/core/LoopLifecycle.d.ts +4 -17
- package/dist/core/LoopLifecycle.d.ts.map +1 -1
- package/dist/core/LoopLifecycle.js +20 -22
- package/dist/core/LoopLifecycle.js.map +1 -1
- package/dist/core/LoopLifecycle.sql +36 -49
- package/dist/core/LoopOutcome.d.ts +10 -0
- package/dist/core/LoopOutcome.d.ts.map +1 -0
- package/dist/core/LoopOutcome.js +28 -0
- package/dist/core/LoopOutcome.js.map +1 -0
- package/dist/core/LoopPolicies.d.ts +7 -0
- package/dist/core/LoopPolicies.d.ts.map +1 -0
- package/dist/core/LoopPolicies.js +37 -0
- package/dist/core/LoopPolicies.js.map +1 -0
- package/dist/core/MessageResources.d.ts +15 -0
- package/dist/core/MessageResources.d.ts.map +1 -0
- package/dist/core/MessageResources.js +46 -0
- package/dist/core/MessageResources.js.map +1 -0
- package/dist/core/MessageResources.sql +36 -0
- package/dist/core/ModelCall.d.ts.map +1 -1
- package/dist/core/ModelCall.js +2 -6
- package/dist/core/ModelCall.js.map +1 -1
- package/dist/core/ModelCall.sql +7 -36
- package/dist/core/OperatorConfig.d.ts +2 -1
- package/dist/core/OperatorConfig.d.ts.map +1 -1
- package/dist/core/OperatorConfig.js +14 -6
- package/dist/core/OperatorConfig.js.map +1 -1
- package/dist/core/PacketBuilder.d.ts.map +1 -1
- package/dist/core/PacketBuilder.js +20 -35
- package/dist/core/PacketBuilder.js.map +1 -1
- package/dist/core/PacketBuilder.sql +24 -6
- package/dist/core/PatternSelection.d.ts +1 -1
- package/dist/core/PatternSelection.d.ts.map +1 -1
- package/dist/core/ProposalLifecycle.d.ts +3 -1
- package/dist/core/ProposalLifecycle.d.ts.map +1 -1
- package/dist/core/ProposalLifecycle.js +93 -28
- package/dist/core/ProposalLifecycle.js.map +1 -1
- package/dist/core/ProviderInstantiate.d.ts +1 -0
- package/dist/core/ProviderInstantiate.d.ts.map +1 -1
- package/dist/core/ProviderInstantiate.js +12 -7
- package/dist/core/ProviderInstantiate.js.map +1 -1
- package/dist/core/ReasoningView.d.ts +1 -2
- package/dist/core/ReasoningView.d.ts.map +1 -1
- package/dist/core/ReasoningView.js +9 -20
- package/dist/core/ReasoningView.js.map +1 -1
- package/dist/core/ResourceBindings.d.ts.map +1 -1
- package/dist/core/ResourceBindings.js +5 -4
- package/dist/core/ResourceBindings.js.map +1 -1
- package/dist/core/ResourceMutations.d.ts +4 -4
- package/dist/core/ResourceMutations.d.ts.map +1 -1
- package/dist/core/ResourceMutations.js +2 -3
- package/dist/core/ResourceMutations.js.map +1 -1
- package/dist/core/ResourceSelector.d.ts +10 -3
- package/dist/core/ResourceSelector.d.ts.map +1 -1
- package/dist/core/ResourceSelector.js +52 -13
- package/dist/core/ResourceSelector.js.map +1 -1
- package/dist/core/ResourceTransfers.d.ts.map +1 -1
- package/dist/core/ResourceTransfers.js +4 -2
- package/dist/core/ResourceTransfers.js.map +1 -1
- package/dist/core/RuntimeWorker.d.ts.map +1 -1
- package/dist/core/RuntimeWorker.js +6 -1
- package/dist/core/RuntimeWorker.js.map +1 -1
- package/dist/core/RuntimeWorker.sql +7 -1
- package/dist/core/SchemeRegistry.d.ts +2 -0
- package/dist/core/SchemeRegistry.d.ts.map +1 -1
- package/dist/core/SchemeRegistry.js +12 -6
- package/dist/core/SchemeRegistry.js.map +1 -1
- package/dist/core/StoredPacket.d.ts +3 -1
- package/dist/core/StoredPacket.d.ts.map +1 -1
- package/dist/core/StoredPacket.js +7 -3
- package/dist/core/StoredPacket.js.map +1 -1
- package/dist/core/StrikeRail.d.ts +2 -2
- package/dist/core/StrikeRail.d.ts.map +1 -1
- package/dist/core/StrikeRail.js +15 -7
- package/dist/core/StrikeRail.js.map +1 -1
- package/dist/core/TerminalResult.d.ts +2 -2
- package/dist/core/TerminalResult.d.ts.map +1 -1
- package/dist/core/TerminalResult.js +15 -8
- package/dist/core/TerminalResult.js.map +1 -1
- package/dist/core/ToolInputSchema.d.ts.map +1 -1
- package/dist/core/ToolInputSchema.js +24 -8
- package/dist/core/ToolInputSchema.js.map +1 -1
- package/dist/core/ToolResources.d.ts +1 -0
- package/dist/core/ToolResources.d.ts.map +1 -1
- package/dist/core/ToolResources.js +50 -26
- package/dist/core/ToolResources.js.map +1 -1
- package/dist/core/Turn.d.ts +3 -1
- package/dist/core/Turn.d.ts.map +1 -1
- package/dist/core/Turn.js +4 -1
- package/dist/core/Turn.js.map +1 -1
- package/dist/core/Turn.sql +14 -2
- package/dist/core/TurnDispositionHandler.d.ts +13 -23
- package/dist/core/TurnDispositionHandler.d.ts.map +1 -1
- package/dist/core/TurnDispositionHandler.js +30 -180
- package/dist/core/TurnDispositionHandler.js.map +1 -1
- package/dist/core/TurnMaterialization.d.ts +9 -7
- package/dist/core/TurnMaterialization.d.ts.map +1 -1
- package/dist/core/TurnMaterialization.js +66 -46
- package/dist/core/TurnMaterialization.js.map +1 -1
- package/dist/core/TurnMaterialization.sql +23 -6
- package/dist/core/TurnOps.d.ts.map +1 -1
- package/dist/core/TurnOps.js +2 -2
- package/dist/core/TurnOps.js.map +1 -1
- package/dist/core/TurnRunner.d.ts +2 -8
- package/dist/core/TurnRunner.d.ts.map +1 -1
- package/dist/core/TurnRunner.js +1116 -1123
- package/dist/core/TurnRunner.js.map +1 -1
- package/dist/core/TurnRunner.sql +1 -24
- package/dist/core/TurnSources.sql +42 -11
- package/dist/core/WorkerControlHandler.d.ts.map +1 -1
- package/dist/core/WorkerControlHandler.js +23 -0
- package/dist/core/WorkerControlHandler.js.map +1 -1
- package/dist/core/WorkerName.d.ts +3 -6
- package/dist/core/WorkerName.d.ts.map +1 -1
- package/dist/core/WorkerName.js +10 -26
- package/dist/core/WorkerName.js.map +1 -1
- package/dist/core/WorkspaceGate.js +4 -4
- package/dist/core/WorkspaceGate.js.map +1 -1
- package/dist/core/ambient.sql +45 -19
- package/dist/core/attachments.d.ts +3 -1
- package/dist/core/attachments.d.ts.map +1 -1
- package/dist/core/attachments.js +4 -0
- package/dist/core/attachments.js.map +1 -1
- package/dist/core/caps/CoreInteractionCaps.d.ts +1 -1
- package/dist/core/caps/CoreInteractionCaps.d.ts.map +1 -1
- package/dist/core/caps/CoreInteractionCaps.js +4 -2
- package/dist/core/caps/CoreInteractionCaps.js.map +1 -1
- package/dist/core/caps/DbChannelCaps.js +6 -6
- package/dist/core/caps/DbChannelCaps.js.map +1 -1
- package/dist/core/caps/DbEntryCaps.js +1 -1
- package/dist/core/caps/DbEntryCaps.js.map +1 -1
- package/dist/core/caps/DbMessageCaps.d.ts +10 -0
- package/dist/core/caps/DbMessageCaps.d.ts.map +1 -0
- package/dist/core/caps/DbMessageCaps.js +39 -0
- package/dist/core/caps/DbMessageCaps.js.map +1 -0
- package/dist/core/caps/DbProjectionCaps.d.ts +2 -2
- package/dist/core/caps/DbProjectionCaps.d.ts.map +1 -1
- package/dist/core/caps/DbProjectionCaps.js +10 -4
- package/dist/core/caps/DbProjectionCaps.js.map +1 -1
- package/dist/core/caps/SchemeCtxImpl.d.ts +3 -1
- package/dist/core/caps/SchemeCtxImpl.d.ts.map +1 -1
- package/dist/core/caps/SchemeCtxImpl.js +11 -0
- package/dist/core/caps/SchemeCtxImpl.js.map +1 -1
- package/dist/core/env-catalog.d.ts +28 -0
- package/dist/core/env-catalog.d.ts.map +1 -0
- package/dist/core/env-catalog.js +99 -0
- package/dist/core/env-catalog.js.map +1 -0
- package/dist/core/file-materialization.js +1 -1
- package/dist/core/file-materialization.js.map +1 -1
- package/dist/core/fork.sql +7 -6
- package/dist/core/git-state.d.ts +3 -2
- package/dist/core/git-state.d.ts.map +1 -1
- package/dist/core/git-state.js +38 -21
- package/dist/core/git-state.js.map +1 -1
- package/dist/core/operation-target-groups.d.ts.map +1 -1
- package/dist/core/operation-target-groups.js +2 -1
- package/dist/core/operation-target-groups.js.map +1 -1
- package/dist/core/packet-inject.js +1 -1
- package/dist/core/packet-wire.d.ts +11 -0
- package/dist/core/packet-wire.d.ts.map +1 -1
- package/dist/core/packet-wire.js +382 -333
- package/dist/core/packet-wire.js.map +1 -1
- package/dist/core/plurnk-uri.d.ts +4 -5
- package/dist/core/plurnk-uri.d.ts.map +1 -1
- package/dist/core/plurnk-uri.js +10 -31
- package/dist/core/plurnk-uri.js.map +1 -1
- package/dist/core/scheme-types.d.ts +3 -1
- package/dist/core/scheme-types.d.ts.map +1 -1
- package/dist/core/scheme-types.js +1 -1
- package/dist/core/scheme-types.js.map +1 -1
- package/dist/core/teaching.d.ts.map +1 -1
- package/dist/core/teaching.js +2 -1
- package/dist/core/teaching.js.map +1 -1
- package/dist/core/types.d.ts +1 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/worker-ops.sql +3 -8
- package/dist/digest/Digest.d.ts.map +1 -1
- package/dist/digest/Digest.js +37 -30
- package/dist/digest/Digest.js.map +1 -1
- package/dist/digest/DigestRender.d.ts +2 -0
- package/dist/digest/DigestRender.d.ts.map +1 -1
- package/dist/digest/DigestRender.js +97 -9
- package/dist/digest/DigestRender.js.map +1 -1
- package/dist/digest/DigestRequiem.d.ts.map +1 -1
- package/dist/digest/DigestRequiem.js +13 -15
- package/dist/digest/DigestRequiem.js.map +1 -1
- package/dist/digest/digest-db.d.ts +3 -0
- package/dist/digest/digest-db.d.ts.map +1 -0
- package/dist/digest/digest-db.js +68 -0
- package/dist/digest/digest-db.js.map +1 -0
- package/dist/digest/digest-paths.d.ts +6 -0
- package/dist/digest/digest-paths.d.ts.map +1 -0
- package/dist/digest/digest-paths.js +23 -0
- package/dist/digest/digest-paths.js.map +1 -0
- package/dist/digest/digest-rows.d.ts +21 -0
- package/dist/digest/digest-rows.d.ts.map +1 -1
- package/dist/digest/digest.sql +24 -5
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/observe/genai.d.ts +2 -2
- package/dist/observe/genai.d.ts.map +1 -1
- package/dist/observe/genai.js +15 -5
- package/dist/observe/genai.js.map +1 -1
- package/dist/schemes/EffectPolicy.d.ts +0 -2
- package/dist/schemes/EffectPolicy.d.ts.map +1 -1
- package/dist/schemes/EffectPolicy.js +25 -36
- package/dist/schemes/EffectPolicy.js.map +1 -1
- package/dist/schemes/Exec.d.ts +4 -5
- package/dist/schemes/Exec.d.ts.map +1 -1
- package/dist/schemes/Exec.js +129 -82
- package/dist/schemes/Exec.js.map +1 -1
- package/dist/schemes/ExecOutputScheme.d.ts +6 -5
- package/dist/schemes/ExecOutputScheme.d.ts.map +1 -1
- package/dist/schemes/ExecOutputScheme.js +49 -16
- package/dist/schemes/ExecOutputScheme.js.map +1 -1
- package/dist/schemes/ExecScheduler.js +2 -2
- package/dist/schemes/ExecScheduler.js.map +1 -1
- package/dist/schemes/File.d.ts.map +1 -1
- package/dist/schemes/File.js +30 -21
- package/dist/schemes/File.js.map +1 -1
- package/dist/schemes/Log.d.ts +4 -4
- package/dist/schemes/Log.d.ts.map +1 -1
- package/dist/schemes/Log.js +30 -10
- package/dist/schemes/Log.js.map +1 -1
- package/dist/schemes/QuestionTool.d.ts.map +1 -1
- package/dist/schemes/QuestionTool.js +15 -2
- package/dist/schemes/QuestionTool.js.map +1 -1
- package/dist/schemes/TurnSource.d.ts +3 -2
- package/dist/schemes/TurnSource.d.ts.map +1 -1
- package/dist/schemes/TurnSource.js +87 -41
- package/dist/schemes/TurnSource.js.map +1 -1
- package/dist/schemes/Worker.d.ts.map +1 -1
- package/dist/schemes/Worker.js +22 -56
- package/dist/schemes/Worker.js.map +1 -1
- package/dist/schemes/_entry-crud.js +6 -6
- package/dist/schemes/_entry-crud.js.map +1 -1
- package/dist/schemes/_entry-crud.sql +37 -17
- package/dist/schemes/_entry-find.d.ts.map +1 -1
- package/dist/schemes/_entry-find.js +6 -5
- package/dist/schemes/_entry-find.js.map +1 -1
- package/dist/schemes/_entry-fts.d.ts.map +1 -1
- package/dist/schemes/_entry-fts.js +6 -3
- package/dist/schemes/_entry-fts.js.map +1 -1
- package/dist/schemes/_entry-fts.sql +25 -6
- package/dist/schemes/_entry-manifest.d.ts +1 -1
- package/dist/schemes/_entry-manifest.d.ts.map +1 -1
- package/dist/schemes/_entry-manifest.js +10 -17
- package/dist/schemes/_entry-manifest.js.map +1 -1
- package/dist/schemes/_entry-manifest.sql +1 -1
- package/dist/schemes/_entry-ops.js +4 -4
- package/dist/schemes/_entry-ops.js.map +1 -1
- package/dist/schemes/_entry-ops.sql +2 -2
- package/dist/schemes/_entry-readable.d.ts.map +1 -1
- package/dist/schemes/_entry-readable.js +5 -4
- package/dist/schemes/_entry-readable.js.map +1 -1
- package/dist/schemes/_entry-send.js +2 -2
- package/dist/schemes/_entry-send.js.map +1 -1
- package/dist/schemes/_search-exclusion.d.ts +1 -0
- package/dist/schemes/_search-exclusion.d.ts.map +1 -1
- package/dist/schemes/_search-exclusion.js +12 -0
- package/dist/schemes/_search-exclusion.js.map +1 -1
- package/dist/schemes/_search-index.d.ts +5 -1
- package/dist/schemes/_search-index.d.ts.map +1 -1
- package/dist/schemes/_search-index.js +99 -59
- package/dist/schemes/_search-index.js.map +1 -1
- package/dist/schemes/_search-index.sql +17 -0
- package/dist/schemes/exec-abort.d.ts.map +1 -1
- package/dist/schemes/exec-abort.js +5 -4
- package/dist/schemes/exec-abort.js.map +1 -1
- package/dist/schemes/exec-env.d.ts +3 -0
- package/dist/schemes/exec-env.d.ts.map +1 -1
- package/dist/schemes/exec-env.js +66 -15
- package/dist/schemes/exec-env.js.map +1 -1
- package/dist/schemes/exec-lifetime.d.ts +11 -0
- package/dist/schemes/exec-lifetime.d.ts.map +1 -0
- package/dist/schemes/exec-lifetime.js +29 -0
- package/dist/schemes/exec-lifetime.js.map +1 -0
- package/dist/schemes/exec-runtime.d.ts +1 -1
- package/dist/schemes/exec-runtime.d.ts.map +1 -1
- package/dist/schemes/exec-runtime.js +1 -1
- package/dist/schemes/exec-runtime.js.map +1 -1
- package/dist/server/ClientReads.d.ts.map +1 -1
- package/dist/server/ClientReads.js +5 -2
- package/dist/server/ClientReads.js.map +1 -1
- package/dist/server/Daemon.d.ts +31 -7
- package/dist/server/Daemon.d.ts.map +1 -1
- package/dist/server/Daemon.js +137 -60
- package/dist/server/Daemon.js.map +1 -1
- package/dist/server/DaemonModule.d.ts +25 -6
- package/dist/server/DaemonModule.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.d.ts +13 -11
- package/dist/server/DrainSupervisor.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.js +87 -98
- package/dist/server/DrainSupervisor.js.map +1 -1
- package/dist/server/EnvFunctionality.d.ts +52 -0
- package/dist/server/EnvFunctionality.d.ts.map +1 -0
- package/dist/server/EnvFunctionality.js +199 -0
- package/dist/server/EnvFunctionality.js.map +1 -0
- package/dist/server/Functionality.d.ts +4 -2
- package/dist/server/Functionality.d.ts.map +1 -1
- package/dist/server/Functionality.js +250 -106
- package/dist/server/Functionality.js.map +1 -1
- package/dist/server/FunctionalityManager.d.ts +5 -1
- package/dist/server/FunctionalityManager.d.ts.map +1 -1
- package/dist/server/FunctionalityManager.js +24 -8
- package/dist/server/FunctionalityManager.js.map +1 -1
- package/dist/server/HttpListener.d.ts +16 -0
- package/dist/server/HttpListener.d.ts.map +1 -0
- package/dist/server/HttpListener.js +81 -0
- package/dist/server/HttpListener.js.map +1 -0
- package/dist/server/MembersFunctionality.d.ts.map +1 -1
- package/dist/server/MembersFunctionality.js +12 -17
- package/dist/server/MembersFunctionality.js.map +1 -1
- package/dist/server/PlurnkSkill.d.ts.map +1 -1
- package/dist/server/PlurnkSkill.js +1 -0
- package/dist/server/PlurnkSkill.js.map +1 -1
- package/dist/server/Retention.d.ts +14 -0
- package/dist/server/Retention.d.ts.map +1 -1
- package/dist/server/Retention.js +52 -4
- package/dist/server/Retention.js.map +1 -1
- package/dist/server/Retention.sql +55 -1
- package/dist/server/ServiceModules.d.ts.map +1 -1
- package/dist/server/ServiceModules.js +2 -0
- package/dist/server/ServiceModules.js.map +1 -1
- package/dist/server/SkillsFunctionality.d.ts +2 -0
- package/dist/server/SkillsFunctionality.d.ts.map +1 -1
- package/dist/server/SkillsFunctionality.js +27 -17
- package/dist/server/SkillsFunctionality.js.map +1 -1
- package/dist/server/WorkspaceCapabilities.d.ts.map +1 -1
- package/dist/server/WorkspaceCapabilities.js +1 -0
- package/dist/server/WorkspaceCapabilities.js.map +1 -1
- package/dist/server/WorkspaceResidency.d.ts +2 -0
- package/dist/server/WorkspaceResidency.d.ts.map +1 -1
- package/dist/server/WorkspaceResidency.js +27 -0
- package/dist/server/WorkspaceResidency.js.map +1 -1
- package/dist/server/WorkspaceStorage.d.ts +8 -0
- package/dist/server/WorkspaceStorage.d.ts.map +1 -0
- package/dist/server/WorkspaceStorage.js +26 -0
- package/dist/server/WorkspaceStorage.js.map +1 -0
- package/dist/server/client-input.d.ts +4 -3
- package/dist/server/client-input.d.ts.map +1 -1
- package/dist/server/client-input.js +25 -27
- package/dist/server/client-input.js.map +1 -1
- package/dist/server/dispatch-as-plurnk.js +2 -2
- package/dist/server/dispatch-as-plurnk.js.map +1 -1
- package/dist/server/drain.sql +69 -132
- package/dist/server/envelope.d.ts +2 -3
- package/dist/server/envelope.d.ts.map +1 -1
- package/dist/server/envelope.js +7 -21
- package/dist/server/envelope.js.map +1 -1
- package/dist/server/envelope.sql +10 -6
- package/dist/server/exec-poll-backoff.js +3 -3
- package/dist/server/exec-poll-backoff.js.map +1 -1
- package/dist/server/lifecycle-recovery.sql +12 -38
- package/dist/server/logEntry.sql +2 -2
- package/dist/server/loopDocs.js +3 -3
- package/dist/server/loopDocs.sql +4 -2
- package/dist/server/model-catalog.d.ts.map +1 -1
- package/dist/server/model-catalog.js +2 -2
- package/dist/server/model-catalog.js.map +1 -1
- package/dist/server/seam-loop.sql +0 -1
- package/dist/server/workspace-capabilities.sql +45 -0
- package/dist/server/workspace-storage.sql +8 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +37 -11
- package/dist/service.js.map +1 -1
- package/docs/copy-move.md +31 -0
- package/docs/env.md +67 -0
- package/docs/members.md +4 -4
- package/docs/skills.md +2 -2
- package/migrations/002_workers.sql +41 -17
- package/migrations/003_loops.sql +82 -28
- package/migrations/004_inference.sql +53 -12
- package/migrations/005_entries.sql +135 -14
- package/migrations/006_log.sql +79 -24
- package/migrations/007_subscriptions.sql +10 -15
- package/package.json +45 -36
- package/dist/core/PromptFrames.d.ts +0 -12
- package/dist/core/PromptFrames.d.ts.map +0 -1
- package/dist/core/PromptFrames.js +0 -28
- package/dist/core/PromptFrames.js.map +0 -1
- package/dist/schemes/Prompt.d.ts +0 -8
- package/dist/schemes/Prompt.d.ts.map +0 -1
- package/dist/schemes/Prompt.js +0 -25
- package/dist/schemes/Prompt.js.map +0 -1
|
@@ -6,6 +6,7 @@ var _a;
|
|
|
6
6
|
// generated executor family whose host verbs propose. An explicit
|
|
7
7
|
// client mutation and an accepted model proposal converge on `invoke`.
|
|
8
8
|
import { Validator } from "@plurnk/plurnk-contracts";
|
|
9
|
+
import discoverySchema from "@plurnk/plurnk-contracts/schema/FunctionalityDiscoverQuery.json" with { type: "json" };
|
|
9
10
|
import { isDeepStrictEqual } from "node:util";
|
|
10
11
|
import { DocFile } from "@plurnk/plurnk-execs";
|
|
11
12
|
import FunctionalityManager, { FUNCTIONALITY_VERBS, functionalityRuntimeDecl, } from "./FunctionalityManager.js";
|
|
@@ -14,6 +15,10 @@ import { generatedPathname } from "../core/plurnk-uri.js";
|
|
|
14
15
|
const STATE_VERSION = 1;
|
|
15
16
|
const FAMILY = /^[a-z][a-z0-9]*$/u;
|
|
16
17
|
const ALIAS = /^[a-z][a-z0-9-]*$/u;
|
|
18
|
+
// A family may declare its own alias grammar ({§functionality-adapter}); the coordinator enforces it
|
|
19
|
+
// wherever an alias enters: admission, the service projection, and persisted state.
|
|
20
|
+
const aliasPattern = (adapter) => adapter.aliasPattern ?? ALIAS;
|
|
21
|
+
const scopesOf = (adapter) => adapter.scopes ?? ["workspace"];
|
|
17
22
|
const EMPTY_STATE = Object.freeze({ version: STATE_VERSION, definitions: Object.freeze({}) });
|
|
18
23
|
const SCHEMA = (name) => ({ $ref: `https://schemas.plurnk.xyz/v0/${name}.json` });
|
|
19
24
|
const ALIAS_INPUT = Object.freeze({
|
|
@@ -49,21 +54,37 @@ class Functionality {
|
|
|
49
54
|
throw new Error(`Functionality namespace owner '${namespaceOwner}' is already registered.`);
|
|
50
55
|
if (!isRecord(adapter.definitionSchema))
|
|
51
56
|
throw new Error(`Functionality family '${family}' requires a definition schema.`);
|
|
57
|
+
const scopes = scopesOf(adapter);
|
|
58
|
+
if (scopes.length === 0 || new Set(scopes).size !== scopes.length || scopes.some((scope) => scope !== "workspace" && scope !== "worker")) {
|
|
59
|
+
throw new Error(`Functionality family '${family}' declares invalid scopes.`);
|
|
60
|
+
}
|
|
61
|
+
const scopeProperties = scopes.length > 1
|
|
62
|
+
? { scope: { enum: [...scopes], description: `Definition scope; model calls default to ${scopes[0]}.` } }
|
|
63
|
+
: {};
|
|
64
|
+
const scopedInput = (schema) => {
|
|
65
|
+
if (scopes.length === 1)
|
|
66
|
+
return schema;
|
|
67
|
+
const { $id: _id, ...source } = schema;
|
|
68
|
+
if (!isRecord(source.properties))
|
|
69
|
+
throw new Error(`Functionality ${family} input has no property map.`);
|
|
70
|
+
return { ...source, properties: { ...source.properties, ...scopeProperties } };
|
|
71
|
+
};
|
|
52
72
|
const schemas = Object.freeze({
|
|
53
|
-
list: EMPTY_INPUT,
|
|
54
|
-
discover: SCHEMA("FunctionalityDiscoverQuery"),
|
|
73
|
+
list: scopedInput(EMPTY_INPUT),
|
|
74
|
+
discover: scopes.length === 1 ? SCHEMA("FunctionalityDiscoverQuery") : scopedInput(discoverySchema),
|
|
55
75
|
add: Object.freeze({
|
|
56
76
|
type: "object",
|
|
57
77
|
additionalProperties: false,
|
|
58
78
|
required: ["definition"],
|
|
59
79
|
properties: {
|
|
80
|
+
...scopeProperties,
|
|
60
81
|
alias: { type: "string", minLength: 1 },
|
|
61
82
|
definition: adapter.definitionSchema,
|
|
62
83
|
},
|
|
63
84
|
}),
|
|
64
|
-
enable: ALIAS_INPUT,
|
|
65
|
-
disable: ALIAS_INPUT,
|
|
66
|
-
remove: ALIAS_INPUT,
|
|
85
|
+
enable: scopedInput(ALIAS_INPUT),
|
|
86
|
+
disable: scopedInput(ALIAS_INPUT),
|
|
87
|
+
remove: scopedInput(ALIAS_INPUT),
|
|
67
88
|
});
|
|
68
89
|
// {§functionality-model-projection} — the taught `add` example must satisfy the schema it teaches.
|
|
69
90
|
if (adapter.example !== undefined) {
|
|
@@ -79,23 +100,28 @@ class Functionality {
|
|
|
79
100
|
activate: (context) => this.#activate(adapter, context),
|
|
80
101
|
deactivate: (identity) => this.#deactivate(adapter, identity),
|
|
81
102
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
: verb === "
|
|
90
|
-
? "
|
|
91
|
-
: "
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
// {§functionality-scope} The action context binds one of the family's supported scopes.
|
|
104
|
+
for (const scope of scopes) {
|
|
105
|
+
for (const verb of FUNCTIONALITY_VERBS) {
|
|
106
|
+
this.#host.registerModuleAction({
|
|
107
|
+
name: `${scope}.${family}.${verb}`,
|
|
108
|
+
scope,
|
|
109
|
+
inputSchema: schemas[verb],
|
|
110
|
+
outputSchema: SCHEMA(verb === "list"
|
|
111
|
+
? "FunctionalityListResult"
|
|
112
|
+
: verb === "discover"
|
|
113
|
+
? "FunctionalityDiscoverResult"
|
|
114
|
+
: "FunctionalityMutationResult"),
|
|
115
|
+
handler: async (params, context) => {
|
|
116
|
+
if (context.scope === "worldless" || context.scope !== scope)
|
|
117
|
+
throw new Error(`${scope}.${family}.${verb} requires a ${scope}-scoped context.`);
|
|
118
|
+
const identity = context.scope === "worker"
|
|
119
|
+
? { workspaceId: context.workspaceId, workerId: context.workerId, scope }
|
|
120
|
+
: { workspaceId: context.workspaceId, scope };
|
|
121
|
+
return (await this.invoke(family, verb, params, identity, "action")).body;
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
}
|
|
99
125
|
}
|
|
100
126
|
return {
|
|
101
127
|
invoke: (verb, params, identity) => this.invoke(family, verb, params, identity, "action"),
|
|
@@ -109,7 +135,7 @@ class Functionality {
|
|
|
109
135
|
// workspace exclusivity it could never win.
|
|
110
136
|
async refresh(family, identity, options = {}) {
|
|
111
137
|
const adapter = this.#adapter(family);
|
|
112
|
-
await this.#serialize(identity.workspaceId, family, async () => {
|
|
138
|
+
await this.#serialize(this.#key(identity.workspaceId, family), async () => {
|
|
113
139
|
const current = this.#families.get(this.#key(identity.workspaceId, family));
|
|
114
140
|
if (current === undefined)
|
|
115
141
|
return;
|
|
@@ -158,7 +184,7 @@ class Functionality {
|
|
|
158
184
|
return out;
|
|
159
185
|
}
|
|
160
186
|
// The one lifecycle entry for both projections ({§functionality-model-mutation}).
|
|
161
|
-
async invoke(family, verb, params, identity, caller) {
|
|
187
|
+
async invoke(family, verb, params, identity, caller, options = {}) {
|
|
162
188
|
const adapter = this.#adapter(family);
|
|
163
189
|
const schema = this.#schemas.get(family)[verb];
|
|
164
190
|
const validation = Validator.validateJsonSchemaInstance(schema, params);
|
|
@@ -170,11 +196,38 @@ class Functionality {
|
|
|
170
196
|
});
|
|
171
197
|
}
|
|
172
198
|
const input = params;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
199
|
+
const scope = (input.scope ?? identity.scope ?? scopesOf(adapter)[0]);
|
|
200
|
+
if (!scopesOf(adapter).includes(scope) || (identity.scope !== undefined && identity.scope !== scope)) {
|
|
201
|
+
throw failure(family, "scope-mismatch", 400, `The ${family} operation's scope does not match its bound context.`, { retryable: false });
|
|
202
|
+
}
|
|
203
|
+
identity = { ...identity, scope };
|
|
204
|
+
if (verb === "discover") {
|
|
205
|
+
const { scope: _scope, ...query } = input;
|
|
206
|
+
return { status: 200, body: await this.#discover(adapter, query, identity, options) };
|
|
177
207
|
}
|
|
208
|
+
// {§functionality-scope} — a worker-scoped family's list and mutations act for the invoking
|
|
209
|
+
// Worker. The state is that Worker's and nothing resident changes, so they serialize on the
|
|
210
|
+
// Worker's own lane and take no workspace exclusivity: a Worker shapes its environment while
|
|
211
|
+
// its siblings run.
|
|
212
|
+
if (scope === "worker") {
|
|
213
|
+
const workerId = _a.#workerOf(adapter, identity);
|
|
214
|
+
return this.#serialize(`${this.#key(identity.workspaceId, family)}:${workerId}`, () => this.#invokeForWorker(adapter, verb, input, identity, workerId, caller, options));
|
|
215
|
+
}
|
|
216
|
+
if (verb === "list")
|
|
217
|
+
return { status: 200, body: await this.#list(adapter, identity) };
|
|
218
|
+
return this.#host.mutateWorkspace(identity.workspaceId, adapter.namespaceOwner, caller, () => this.#serialize(this.#key(identity.workspaceId, family), () => this.#mutate(adapter, verb, input, identity, caller, options)));
|
|
219
|
+
}
|
|
220
|
+
// A worker-scoped verb that names no Worker is a defect at the projection, never a client
|
|
221
|
+
// failure: both projections name the Worker ({§functionality-model-projection}).
|
|
222
|
+
static #workerOf(adapter, identity) {
|
|
223
|
+
if (identity.workerId === undefined)
|
|
224
|
+
throw new Error(`${adapter.family} is worker-scoped; the invocation names no Worker.`);
|
|
225
|
+
return identity.workerId;
|
|
226
|
+
}
|
|
227
|
+
// The origin a definition carries when this family owns it locally. Service definitions
|
|
228
|
+
// always come from the adapter's own `available()`; everything else is the family's own.
|
|
229
|
+
static #localOrigin(identity) {
|
|
230
|
+
return identity.scope ?? "workspace";
|
|
178
231
|
}
|
|
179
232
|
#adapter(family) {
|
|
180
233
|
const adapter = this.#adapters.get(family);
|
|
@@ -185,8 +238,7 @@ class Functionality {
|
|
|
185
238
|
#key(workspaceId, family) {
|
|
186
239
|
return `${workspaceId}:${family}`;
|
|
187
240
|
}
|
|
188
|
-
#serialize(
|
|
189
|
-
const key = this.#key(workspaceId, family);
|
|
241
|
+
#serialize(key, work) {
|
|
190
242
|
const previous = this.#queues.get(key) ?? Promise.resolve();
|
|
191
243
|
const next = previous.catch(() => undefined).then(work);
|
|
192
244
|
this.#queues.set(key, next);
|
|
@@ -194,13 +246,13 @@ class Functionality {
|
|
|
194
246
|
}
|
|
195
247
|
async #activate(adapter, context) {
|
|
196
248
|
const identity = { workspaceId: context.workspaceId };
|
|
197
|
-
await this.#serialize(identity.workspaceId, adapter.family, async () => {
|
|
249
|
+
await this.#serialize(this.#key(identity.workspaceId, adapter.family), async () => {
|
|
198
250
|
const state = await this.#loadState(adapter, identity.workspaceId);
|
|
199
251
|
await this.#publish(adapter, identity, state, { failure: "publish-unavailable", retain: context.retain, gate: "none" });
|
|
200
252
|
});
|
|
201
253
|
}
|
|
202
254
|
async #deactivate(adapter, identity) {
|
|
203
|
-
await this.#serialize(identity.workspaceId, adapter.family, async () => {
|
|
255
|
+
await this.#serialize(this.#key(identity.workspaceId, adapter.family), async () => {
|
|
204
256
|
const key = this.#key(identity.workspaceId, adapter.family);
|
|
205
257
|
const family = this.#families.get(key);
|
|
206
258
|
this.#families.delete(key);
|
|
@@ -210,30 +262,42 @@ class Functionality {
|
|
|
210
262
|
});
|
|
211
263
|
}
|
|
212
264
|
async #loadState(adapter, workspaceId) {
|
|
213
|
-
|
|
265
|
+
return _a.#parseState(adapter, await this.#host.readWorkspaceModuleState(workspaceId, adapter.namespaceOwner), `workspace ${workspaceId}`, "workspace");
|
|
266
|
+
}
|
|
267
|
+
async #loadWorkerState(adapter, workerId) {
|
|
268
|
+
return _a.#parseState(adapter, await this.#host.readWorkerModuleState(workerId, adapter.namespaceOwner), `worker ${workerId}`, "worker");
|
|
269
|
+
}
|
|
270
|
+
static #parseState(adapter, raw, where, scope) {
|
|
214
271
|
if (raw === null)
|
|
215
272
|
return EMPTY_STATE;
|
|
216
273
|
if (!isRecord(raw) || raw.version !== STATE_VERSION || !isRecord(raw.definitions)) {
|
|
217
|
-
throw new Error(`Functionality state for ${adapter.family} in
|
|
274
|
+
throw new Error(`Functionality state for ${adapter.family} in ${where} is not a version ${STATE_VERSION} record.`);
|
|
218
275
|
}
|
|
219
276
|
const definitions = {};
|
|
220
277
|
for (const [alias, value] of Object.entries(raw.definitions)) {
|
|
221
|
-
if (!
|
|
278
|
+
if (!aliasPattern(adapter).test(alias) || !isRecord(value))
|
|
222
279
|
throw new Error(`Functionality state for ${adapter.family} has an invalid alias '${alias}'.`);
|
|
223
|
-
const { origin, enabled, definition } = value;
|
|
224
|
-
if ((origin !== "service" && origin !== "workspace") || typeof enabled !== "boolean") {
|
|
280
|
+
const { origin, enabled, definition, inherited } = value;
|
|
281
|
+
if ((origin !== "service" && origin !== "workspace" && origin !== "worker") || typeof enabled !== "boolean") {
|
|
225
282
|
throw new Error(`Functionality state for ${adapter.family} alias '${alias}' is malformed.`);
|
|
226
283
|
}
|
|
227
|
-
if (origin === "workspace") {
|
|
284
|
+
if (origin !== "service" && origin !== scope && !(scope === "worker" && origin === "workspace" && scopesOf(adapter).includes("workspace"))) {
|
|
285
|
+
throw new Error(`Functionality state for ${adapter.family} alias '${alias}' has an invalid origin for ${scope} scope.`);
|
|
286
|
+
}
|
|
287
|
+
if (inherited !== undefined && (typeof inherited !== "string" || inherited.length === 0 || scope !== "worker")) {
|
|
288
|
+
throw new Error(`Functionality state for ${adapter.family} alias '${alias}' carries an invalid inheritance.`);
|
|
289
|
+
}
|
|
290
|
+
const provenance = inherited === undefined ? {} : { inherited };
|
|
291
|
+
if (origin === scope) {
|
|
228
292
|
const result = Validator.validateJsonSchemaInstance(adapter.definitionSchema, definition);
|
|
229
293
|
if (!result.valid)
|
|
230
294
|
throw new Error(`Functionality state for ${adapter.family} alias '${alias}' holds an invalid definition.`);
|
|
231
|
-
definitions[alias] = { origin, enabled, definition: definition };
|
|
295
|
+
definitions[alias] = { origin, enabled, definition: definition, ...provenance };
|
|
232
296
|
}
|
|
233
297
|
else {
|
|
234
298
|
if (definition !== undefined)
|
|
235
|
-
throw new Error(`Functionality state for ${adapter.family} alias '${alias}' persists a
|
|
236
|
-
definitions[alias] = { origin, enabled };
|
|
299
|
+
throw new Error(`Functionality state for ${adapter.family} alias '${alias}' persists a lower-layer definition.`);
|
|
300
|
+
definitions[alias] = { origin, enabled, ...provenance };
|
|
237
301
|
}
|
|
238
302
|
}
|
|
239
303
|
return { version: STATE_VERSION, definitions };
|
|
@@ -243,33 +307,41 @@ class Functionality {
|
|
|
243
307
|
}
|
|
244
308
|
async #effective(adapter, identity, state) {
|
|
245
309
|
const effective = new Map();
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
310
|
+
const local = _a.#localOrigin(identity);
|
|
311
|
+
const inheritsWorkspace = identity.scope === "worker" && scopesOf(adapter).includes("workspace");
|
|
312
|
+
const lower = inheritsWorkspace
|
|
313
|
+
? [...(await this.#effective(adapter, { workspaceId: identity.workspaceId, scope: "workspace" }, await this.#loadState(adapter, identity.workspaceId))).values()]
|
|
314
|
+
: (await adapter.available(identity)).map((entry) => ({ ...entry, origin: "service" }));
|
|
315
|
+
for (const service of lower) {
|
|
316
|
+
if (!aliasPattern(adapter).test(service.alias))
|
|
317
|
+
throw new Error(`${adapter.family} service alias '${service.alias}' must match ${aliasPattern(adapter)}.`);
|
|
249
318
|
const record = state.definitions[service.alias];
|
|
250
|
-
const
|
|
251
|
-
|
|
319
|
+
const overlay = record !== undefined && record.origin !== local ? record : undefined;
|
|
320
|
+
const enabled = overlay === undefined ? service.enabled : overlay.enabled && (!inheritsWorkspace || service.enabled);
|
|
321
|
+
const inherited = overlay?.inherited === undefined ? {} : { inherited: overlay.inherited };
|
|
322
|
+
effective.set(service.alias, { alias: service.alias, origin: service.origin, definition: service.definition, enabled, ...inherited });
|
|
252
323
|
}
|
|
253
324
|
for (const [alias, record] of Object.entries(state.definitions)) {
|
|
254
|
-
if (record.origin !==
|
|
325
|
+
if (record.origin !== local)
|
|
255
326
|
continue;
|
|
256
|
-
|
|
327
|
+
const inherited = record.inherited === undefined ? {} : { inherited: record.inherited };
|
|
328
|
+
effective.set(alias, { alias, origin: local, definition: record.definition, enabled: record.enabled, ...inherited });
|
|
257
329
|
}
|
|
258
330
|
return new Map([...effective].toSorted(([left], [right]) => left.localeCompare(right)));
|
|
259
331
|
}
|
|
260
332
|
#projection(definition, outcome) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
333
|
+
const base = {
|
|
334
|
+
alias: definition.alias, origin: definition.origin, definition: definition.definition,
|
|
335
|
+
...(definition.inherited === undefined ? {} : { inherited: definition.inherited }),
|
|
336
|
+
};
|
|
337
|
+
if (!definition.enabled)
|
|
338
|
+
return { ...base, state: "disabled" };
|
|
264
339
|
if (outcome === undefined)
|
|
265
340
|
throw new Error(`enabled ${definition.alias} has no preparation outcome`);
|
|
266
341
|
switch (outcome.state) {
|
|
267
|
-
case "active": return {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
};
|
|
271
|
-
case "unavailable": return { alias: definition.alias, origin: definition.origin, state: "unavailable", definition: definition.definition, problem: outcome.problem };
|
|
272
|
-
case "authorization-required": return { alias: definition.alias, origin: definition.origin, state: "authorization-required", definition: definition.definition, authorization: outcome.authorization };
|
|
342
|
+
case "active": return { ...base, state: "active", ...(outcome.detail === undefined ? {} : { detail: outcome.detail }) };
|
|
343
|
+
case "unavailable": return { ...base, state: "unavailable", problem: outcome.problem };
|
|
344
|
+
case "authorization-required": return { ...base, state: "authorization-required", authorization: outcome.authorization };
|
|
273
345
|
}
|
|
274
346
|
}
|
|
275
347
|
async #list(adapter, identity) {
|
|
@@ -283,34 +355,33 @@ class Functionality {
|
|
|
283
355
|
definitions: [...effective.values()].map((definition) => this.#projection(definition, outcomes.get(definition.alias))),
|
|
284
356
|
});
|
|
285
357
|
}
|
|
286
|
-
async #discover(adapter, query, identity) {
|
|
287
|
-
const candidates = await adapter.discover(query, identity);
|
|
358
|
+
async #discover(adapter, query, identity, options) {
|
|
359
|
+
const candidates = await adapter.discover(query, identity, options);
|
|
288
360
|
return Validator.assertFunctionalityDiscoverResult({ family: adapter.family, candidates: [...candidates] });
|
|
289
361
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
const
|
|
296
|
-
const definitions = { ...family.state.definitions };
|
|
362
|
+
// The verb semantics, one implementation for every family ({§functionality-scope}): the next
|
|
363
|
+
// state, the alias it concerns, and how the mutation reports. Only publication differs by scope.
|
|
364
|
+
async #transition(adapter, verb, input, identity, caller, state, effective, options) {
|
|
365
|
+
const local = _a.#localOrigin(identity);
|
|
366
|
+
const here = local === "worker" ? "this worker" : "this workspace";
|
|
367
|
+
const definitions = { ...state.definitions };
|
|
297
368
|
let alias;
|
|
298
369
|
let status = 200;
|
|
299
370
|
let removed = false;
|
|
300
371
|
switch (verb) {
|
|
301
372
|
case "add": {
|
|
302
|
-
const admitted = await adapter.admit(input, identity, caller);
|
|
373
|
+
const admitted = await adapter.admit(input, identity, caller, options);
|
|
303
374
|
alias = admitted.alias;
|
|
304
|
-
if (!
|
|
305
|
-
throw failure(adapter.family, "alias-invalid", 400, `Alias '${alias}' must match ${
|
|
306
|
-
// A
|
|
375
|
+
if (!aliasPattern(adapter).test(alias))
|
|
376
|
+
throw failure(adapter.family, "alias-invalid", 400, `Alias '${alias}' must match ${aliasPattern(adapter)}.`, { alias, retryable: false });
|
|
377
|
+
// A local definition may shadow a service definition of the same
|
|
307
378
|
// alias; removing it reveals the service baseline again, disabled.
|
|
308
379
|
const current = effective.get(alias);
|
|
309
|
-
if (current?.origin ===
|
|
310
|
-
throw failure(adapter.family, "alias-exists", 409, `'${alias}' already has a different
|
|
380
|
+
if (current?.origin === local && !isDeepStrictEqual(current.definition, admitted.definition)) {
|
|
381
|
+
throw failure(adapter.family, "alias-exists", 409, `'${alias}' already has a different ${local} definition.`, { alias, recovery: "Use the existing definition, or remove it before adding its replacement.", retryable: false });
|
|
311
382
|
}
|
|
312
|
-
definitions[alias] = { origin:
|
|
313
|
-
status = current?.origin ===
|
|
383
|
+
definitions[alias] = { origin: local, definition: admitted.definition, enabled: true };
|
|
384
|
+
status = current?.origin === local ? 200 : 201;
|
|
314
385
|
break;
|
|
315
386
|
}
|
|
316
387
|
case "enable":
|
|
@@ -318,42 +389,36 @@ class Functionality {
|
|
|
318
389
|
alias = input.alias;
|
|
319
390
|
const current = effective.get(alias);
|
|
320
391
|
if (current === undefined)
|
|
321
|
-
throw failure(adapter.family, "alias-unknown", 404, `'${alias}' is not available to
|
|
322
|
-
definitions[alias] = current.origin ===
|
|
323
|
-
? { origin:
|
|
324
|
-
: { origin:
|
|
392
|
+
throw failure(adapter.family, "alias-unknown", 404, `'${alias}' is not available to ${here}.`, { alias, retryable: false });
|
|
393
|
+
definitions[alias] = current.origin === local
|
|
394
|
+
? { origin: local, definition: current.definition, enabled: verb === "enable" }
|
|
395
|
+
: { origin: current.origin, enabled: verb === "enable" };
|
|
325
396
|
break;
|
|
326
397
|
}
|
|
327
398
|
case "remove": {
|
|
328
399
|
alias = input.alias;
|
|
329
400
|
const current = effective.get(alias);
|
|
330
401
|
if (current === undefined)
|
|
331
|
-
throw failure(adapter.family, "alias-unknown", 404, `'${alias}' is not available to
|
|
402
|
+
throw failure(adapter.family, "alias-unknown", 404, `'${alias}' is not available to ${here}.`, { alias, retryable: false });
|
|
332
403
|
if (current.origin === "service")
|
|
333
404
|
throw failure(adapter.family, "alias-service-owned", 409, `'${alias}' is a service definition and cannot be removed here.`, { alias, recovery: `Disable it, or change the service configuration that contributes it.`, retryable: false });
|
|
405
|
+
if (current.origin !== local)
|
|
406
|
+
throw failure(adapter.family, "alias-workspace-owned", 409, `'${alias}' is a workspace definition; remove it in workspace scope or disable it here.`, { alias, retryable: false });
|
|
334
407
|
await adapter.forget?.({ alias, definition: current.definition }, identity);
|
|
335
408
|
delete definitions[alias];
|
|
336
|
-
const revealed = (await adapter
|
|
409
|
+
const revealed = (await this.#effective(adapter, identity, EMPTY_STATE)).get(alias);
|
|
337
410
|
if (revealed)
|
|
338
|
-
definitions[alias] = { origin:
|
|
411
|
+
definitions[alias] = { origin: revealed.origin, enabled: false };
|
|
339
412
|
removed = true;
|
|
340
413
|
break;
|
|
341
414
|
}
|
|
342
415
|
default: throw new Error(`unreachable verb ${verb}`);
|
|
343
416
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
const retry = verb === "enable" && family.prepared?.outcomes.get(alias)?.state !== "active";
|
|
348
|
-
const publication = await this.#publish(adapter, identity, nextState, {
|
|
349
|
-
failure: caller === "action" ? "reject" : "publish-unavailable",
|
|
350
|
-
retain: () => this.#host.retainWorkspace(identity.workspaceId),
|
|
351
|
-
gate: "none",
|
|
352
|
-
forceAlias: retry ? alias : null,
|
|
353
|
-
});
|
|
354
|
-
const effectiveAfter = await this.#effective(adapter, identity, nextState);
|
|
417
|
+
return { definitions, alias, status, removed };
|
|
418
|
+
}
|
|
419
|
+
#mutationResult(adapter, { alias, status, removed }, effectiveAfter, outcomes) {
|
|
355
420
|
const definition = effectiveAfter.get(alias);
|
|
356
|
-
const projection = definition === undefined ? undefined : this.#projection(definition,
|
|
421
|
+
const projection = definition === undefined ? undefined : this.#projection(definition, outcomes.get(alias));
|
|
357
422
|
const body = Validator.assertFunctionalityMutationResult({
|
|
358
423
|
status: projection?.state === "authorization-required" ? 202 : status,
|
|
359
424
|
family: adapter.family,
|
|
@@ -363,6 +428,89 @@ class Functionality {
|
|
|
363
428
|
});
|
|
364
429
|
return { status: body.status, body };
|
|
365
430
|
}
|
|
431
|
+
async #mutate(adapter, verb, input, identity, caller, options) {
|
|
432
|
+
const key = this.#key(identity.workspaceId, adapter.family);
|
|
433
|
+
const family = this.#families.get(key);
|
|
434
|
+
if (family === undefined)
|
|
435
|
+
throw failure(adapter.family, "workspace-not-resident", 409, `Workspace ${identity.workspaceId} has no resident ${adapter.family} Functionality.`, { recovery: "Retry through a workspace operation, then retry.", retryable: false });
|
|
436
|
+
const effective = await this.#effective(adapter, identity, family.state);
|
|
437
|
+
const transition = await this.#transition(adapter, verb, input, identity, caller, family.state, effective, options);
|
|
438
|
+
const nextState = { version: STATE_VERSION, definitions: transition.definitions };
|
|
439
|
+
// Re-enabling an alias that is not active retries its preparation; an
|
|
440
|
+
// already-active alias keeps its live attachment.
|
|
441
|
+
const retry = verb === "enable" && family.prepared?.outcomes.get(transition.alias)?.state !== "active";
|
|
442
|
+
const publication = await this.#publish(adapter, identity, nextState, {
|
|
443
|
+
failure: caller === "action" ? "reject" : "publish-unavailable",
|
|
444
|
+
retain: () => this.#host.retainWorkspace(identity.workspaceId),
|
|
445
|
+
gate: "none",
|
|
446
|
+
forceAlias: retry ? transition.alias : null,
|
|
447
|
+
});
|
|
448
|
+
const effectiveAfter = await this.#effective(adapter, identity, nextState);
|
|
449
|
+
return this.#mutationResult(adapter, transition, effectiveAfter, publication.outcomes);
|
|
450
|
+
}
|
|
451
|
+
// {§functionality-scope} — the Worker's own lane. State is read at each verb rather than held: the
|
|
452
|
+
// spawn reads the same row, and a Worker's row is written at its creation, so nothing in memory
|
|
453
|
+
// could be more current than the table.
|
|
454
|
+
async #invokeForWorker(adapter, verb, input, identity, workerId, caller, options) {
|
|
455
|
+
if (!this.#families.has(this.#key(identity.workspaceId, adapter.family)))
|
|
456
|
+
throw failure(adapter.family, "workspace-not-resident", 409, `Workspace ${identity.workspaceId} has no resident ${adapter.family} Functionality.`, { recovery: "Retry through a workspace operation, then retry.", retryable: false });
|
|
457
|
+
const state = await this.#loadWorkerState(adapter, workerId);
|
|
458
|
+
const effective = await this.#effective(adapter, identity, state);
|
|
459
|
+
if (verb === "list") {
|
|
460
|
+
const prepared = await this.#prepareForWorker(adapter, identity, effective, "publish-unavailable");
|
|
461
|
+
await prepared.commit();
|
|
462
|
+
return { status: 200, body: Validator.assertFunctionalityListResult({
|
|
463
|
+
family: adapter.family,
|
|
464
|
+
definitions: [...effective.values()].map((definition) => this.#projection(definition, prepared.outcomes.get(definition.alias))),
|
|
465
|
+
}) };
|
|
466
|
+
}
|
|
467
|
+
const transition = await this.#transition(adapter, verb, input, identity, caller, state, effective, options);
|
|
468
|
+
const nextState = { version: STATE_VERSION, definitions: transition.definitions };
|
|
469
|
+
const effectiveAfter = await this.#effective(adapter, identity, nextState);
|
|
470
|
+
const prepared = await this.#prepareForWorker(adapter, identity, effectiveAfter, caller === "action" ? "reject" : "publish-unavailable");
|
|
471
|
+
try {
|
|
472
|
+
await this.#host.replaceWorkerModuleState(workerId, adapter.namespaceOwner, _a.#persisted(nextState));
|
|
473
|
+
}
|
|
474
|
+
catch (cause) {
|
|
475
|
+
return _a.#abort(prepared, cause);
|
|
476
|
+
}
|
|
477
|
+
await prepared.commit();
|
|
478
|
+
return this.#mutationResult(adapter, transition, effectiveAfter, prepared.outcomes);
|
|
479
|
+
}
|
|
480
|
+
// A worker-scoped family's preparation yields outcomes only. It holds no residency — no runtimes,
|
|
481
|
+
// documents or snapshot ({§module-workspace-residency}) — because its definitions are read at the
|
|
482
|
+
// spawn that uses them rather than leased and cooled; the coordinator enforces that here.
|
|
483
|
+
async #prepareForWorker(adapter, identity, effective, failureMode) {
|
|
484
|
+
const enabled = _a.#enabled(effective);
|
|
485
|
+
const prepared = await adapter.prepare({
|
|
486
|
+
workspaceId: identity.workspaceId, enabled, previous: null, failure: failureMode,
|
|
487
|
+
retain: () => this.#host.retainWorkspace(identity.workspaceId),
|
|
488
|
+
});
|
|
489
|
+
try {
|
|
490
|
+
_a.#checkOutcomes(adapter, enabled, prepared);
|
|
491
|
+
if ((prepared.runtimes?.length ?? 0) > 0 || prepared.documents.length > 0 || prepared.snapshot !== null) {
|
|
492
|
+
throw new Error(`${adapter.family} is worker-scoped and holds no residency, yet its preparation published runtimes, documents or a snapshot.`);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
catch (cause) {
|
|
496
|
+
return _a.#abort(prepared, cause);
|
|
497
|
+
}
|
|
498
|
+
return prepared;
|
|
499
|
+
}
|
|
500
|
+
static #enabled(effective) {
|
|
501
|
+
const enabled = new Map();
|
|
502
|
+
for (const definition of effective.values()) {
|
|
503
|
+
if (definition.enabled)
|
|
504
|
+
enabled.set(definition.alias, definition.definition);
|
|
505
|
+
}
|
|
506
|
+
return enabled;
|
|
507
|
+
}
|
|
508
|
+
static #checkOutcomes(adapter, enabled, prepared) {
|
|
509
|
+
for (const alias of enabled.keys()) {
|
|
510
|
+
if (!prepared.outcomes.has(alias))
|
|
511
|
+
throw new Error(`${adapter.family} preparation reported no outcome for enabled alias '${alias}'.`);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
366
514
|
// {§functionality-publication} — prepare, publish runtimes and state in one
|
|
367
515
|
// host replacement, then commit; on any failure abort and keep the previous
|
|
368
516
|
// snapshot authoritative. An execution stream stays pending until its
|
|
@@ -370,12 +518,10 @@ class Functionality {
|
|
|
370
518
|
async #publish(adapter, identity, nextState, options) {
|
|
371
519
|
const key = this.#key(identity.workspaceId, adapter.family);
|
|
372
520
|
const previous = this.#families.get(key)?.prepared ?? null;
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
enabled.set(definition.alias, definition.definition);
|
|
378
|
-
}
|
|
521
|
+
// A worker-scoped family's workspace publication carries only its manager: what is enabled
|
|
522
|
+
// is decided per Worker, at each verb and each spawn ({§functionality-scope}).
|
|
523
|
+
const effective = !scopesOf(adapter).includes("workspace") ? new Map() : await this.#effective(adapter, { ...identity, scope: "workspace" }, nextState);
|
|
524
|
+
const enabled = _a.#enabled(effective);
|
|
379
525
|
const prepared = await adapter.prepare({
|
|
380
526
|
workspaceId: identity.workspaceId,
|
|
381
527
|
enabled,
|
|
@@ -386,11 +532,8 @@ class Functionality {
|
|
|
386
532
|
});
|
|
387
533
|
let runtimes;
|
|
388
534
|
try {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
throw new Error(`${adapter.family} preparation reported no outcome for enabled alias '${alias}'.`);
|
|
392
|
-
}
|
|
393
|
-
for (const runtime of prepared.runtimes) {
|
|
535
|
+
_a.#checkOutcomes(adapter, enabled, prepared);
|
|
536
|
+
for (const runtime of prepared.runtimes ?? []) {
|
|
394
537
|
if (runtime.namespaceOwner !== adapter.namespaceOwner) {
|
|
395
538
|
throw new Error(`${adapter.family} prepared a runtime owned by '${runtime.namespaceOwner}' instead of '${adapter.namespaceOwner}'.`);
|
|
396
539
|
}
|
|
@@ -400,11 +543,12 @@ class Functionality {
|
|
|
400
543
|
decl: functionalityRuntimeDecl(adapter.family, adapter.summary, await this.#documentBody(adapter)),
|
|
401
544
|
executor: new FunctionalityManager({
|
|
402
545
|
family: adapter.family, workspaceId: identity.workspaceId, coordinator: this,
|
|
403
|
-
inputSchemas: this.#schemas.get(adapter.family), example: adapter.example, discovery: adapter.discovery,
|
|
546
|
+
traits: adapter.traits, inputSchemas: this.#schemas.get(adapter.family), example: adapter.example, discovery: adapter.discovery,
|
|
404
547
|
}),
|
|
405
548
|
availability: { available: true, detail: "workspace Functionality manager" },
|
|
549
|
+
...(adapter.scheme === undefined ? {} : { scheme: adapter.scheme }),
|
|
406
550
|
};
|
|
407
|
-
runtimes = [manager, ...prepared.runtimes];
|
|
551
|
+
runtimes = [manager, ...(prepared.runtimes ?? [])];
|
|
408
552
|
}
|
|
409
553
|
catch (cause) {
|
|
410
554
|
return _a.#abort(prepared, cause);
|