@plurnk/plurnk-service 1.18.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 +76 -13
- package/README.md +5 -3
- package/SPEC.md +924 -689
- 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 +79 -37
- package/dist/content/read-projector.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 -1
- package/dist/core/AdmittedTurnExecutor.d.ts.map +1 -1
- package/dist/core/AdmittedTurnExecutor.js +19 -19
- 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 +6 -3
- package/dist/core/CapabilityResolver.js.map +1 -1
- package/dist/core/ChannelWrite.d.ts +3 -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.js +6 -6
- package/dist/core/DataStatementRunner.js.map +1 -1
- package/dist/core/Dispatcher.d.ts +12 -4
- package/dist/core/Dispatcher.d.ts.map +1 -1
- package/dist/core/Dispatcher.js +112 -90
- 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/ExecutorRegistry.d.ts.map +1 -1
- package/dist/core/ExecutorRegistry.js +2 -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 +6 -35
- package/dist/core/LogBody.js.map +1 -1
- package/dist/core/LogEntryProjection.d.ts.map +1 -1
- package/dist/core/LogEntryProjection.js +4 -0
- 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.js +2 -2
- 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 +23 -29
- 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/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 +85 -22
- 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/SchemeRegistry.d.ts +2 -0
- package/dist/core/SchemeRegistry.d.ts.map +1 -1
- package/dist/core/SchemeRegistry.js +11 -5
- 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.map +1 -1
- package/dist/core/StrikeRail.js +9 -3
- 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 +45 -23
- 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 -21
- package/dist/core/TurnDispositionHandler.d.ts.map +1 -1
- package/dist/core/TurnDispositionHandler.js +32 -190
- 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 +63 -41
- package/dist/core/TurnMaterialization.js.map +1 -1
- package/dist/core/TurnMaterialization.sql +23 -6
- package/dist/core/TurnOps.js +1 -1
- package/dist/core/TurnRunner.d.ts +1 -3
- package/dist/core/TurnRunner.d.ts.map +1 -1
- package/dist/core/TurnRunner.js +148 -189
- 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/WorkerName.d.ts +1 -1
- package/dist/core/WorkerName.d.ts.map +1 -1
- package/dist/core/WorkerName.js +3 -3
- package/dist/core/WorkerName.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/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 +37 -20
- package/dist/core/git-state.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 +112 -88
- 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 +35 -30
- package/dist/digest/Digest.js.map +1 -1
- package/dist/digest/DigestRender.d.ts +1 -0
- package/dist/digest/DigestRender.d.ts.map +1 -1
- package/dist/digest/DigestRender.js +53 -1
- 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 +15 -0
- package/dist/digest/digest-rows.d.ts.map +1 -1
- package/dist/digest/digest.sql +13 -3
- 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 +74 -62
- 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/File.d.ts.map +1 -1
- package/dist/schemes/File.js +28 -20
- 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 +29 -9
- package/dist/schemes/Log.js.map +1 -1
- package/dist/schemes/QuestionTool.d.ts.map +1 -1
- package/dist/schemes/QuestionTool.js +14 -1
- 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 +80 -35
- 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 +19 -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 +5 -3
- package/dist/schemes/_entry-manifest.js.map +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.js +4 -4
- package/dist/schemes/_search-index.js.map +1 -1
- package/dist/schemes/exec-abort.d.ts.map +1 -1
- package/dist/schemes/exec-abort.js +4 -3
- package/dist/schemes/exec-abort.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/server/ClientReads.d.ts.map +1 -1
- package/dist/server/ClientReads.js +3 -1
- package/dist/server/ClientReads.js.map +1 -1
- package/dist/server/Daemon.d.ts +30 -7
- package/dist/server/Daemon.d.ts.map +1 -1
- package/dist/server/Daemon.js +107 -48
- package/dist/server/Daemon.js.map +1 -1
- package/dist/server/DaemonModule.d.ts +19 -5
- 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 +12 -3
- package/dist/server/EnvFunctionality.d.ts.map +1 -1
- package/dist/server/EnvFunctionality.js +19 -14
- package/dist/server/EnvFunctionality.js.map +1 -1
- package/dist/server/Functionality.d.ts +2 -2
- package/dist/server/Functionality.d.ts.map +1 -1
- package/dist/server/Functionality.js +97 -62
- package/dist/server/Functionality.js.map +1 -1
- package/dist/server/FunctionalityManager.d.ts +3 -1
- package/dist/server/FunctionalityManager.d.ts.map +1 -1
- package/dist/server/FunctionalityManager.js +11 -5
- 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 -16
- 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 +11 -0
- package/dist/server/Retention.d.ts.map +1 -1
- package/dist/server/Retention.js +47 -2
- package/dist/server/Retention.js.map +1 -1
- package/dist/server/Retention.sql +32 -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 +22 -15
- 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/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 +24 -26
- 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 -2
- package/dist/server/envelope.d.ts.map +1 -1
- package/dist/server/envelope.js +7 -9
- 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 +8 -35
- 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-storage.sql +8 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +21 -10
- package/dist/service.js.map +1 -1
- package/docs/copy-move.md +31 -0
- package/docs/env.md +19 -7
- package/docs/skills.md +2 -2
- package/migrations/002_workers.sql +26 -17
- package/migrations/003_loops.sql +82 -28
- package/migrations/005_entries.sql +135 -22
- package/migrations/006_log.sql +77 -25
- package/migrations/007_subscriptions.sql +10 -15
- package/package.json +35 -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
|
@@ -1,206 +1,48 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
import { TurnDisposition } from "@plurnk/plurnk-contracts";
|
|
3
1
|
import TerminalResult from "./TerminalResult.js";
|
|
4
|
-
|
|
5
|
-
import ErrorDetail from "./ErrorDetail.js";
|
|
6
|
-
import { promptLoopPrefix } from "./plurnk-uri.js";
|
|
7
|
-
const observedResultsGuidance = "If your final response has already been sent and these results require no further work or response revision, submit only TASK.";
|
|
8
|
-
class TurnDispositionHandler {
|
|
2
|
+
export default class TurnDispositionHandler {
|
|
9
3
|
#db;
|
|
10
|
-
#cancelDescendants;
|
|
11
4
|
#lifecycle;
|
|
12
|
-
#nextPacketBoundaries;
|
|
13
5
|
#unobservedFailureCount;
|
|
14
6
|
#pendingSet;
|
|
15
7
|
#hasLiveWork;
|
|
16
|
-
|
|
17
|
-
#statusResult;
|
|
18
|
-
constructor({ db, cancelDescendants, lifecycle, nextPacketBoundaries, unobservedFailureCount, pendingSet, hasLiveWork, failure, statusResult }) {
|
|
8
|
+
constructor({ db, lifecycle, unobservedFailureCount, pendingSet, hasLiveWork }) {
|
|
19
9
|
this.#db = db;
|
|
20
|
-
this.#cancelDescendants = cancelDescendants;
|
|
21
10
|
this.#lifecycle = lifecycle;
|
|
22
|
-
this.#nextPacketBoundaries = nextPacketBoundaries;
|
|
23
11
|
this.#unobservedFailureCount = unobservedFailureCount;
|
|
24
12
|
this.#pendingSet = pendingSet;
|
|
25
13
|
this.#hasLiveWork = hasLiveWork;
|
|
26
|
-
this.#failure = failure;
|
|
27
|
-
this.#statusResult = statusResult;
|
|
28
14
|
}
|
|
29
|
-
async handle(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
? "Wait timing was not applied because no waiting intent was selected." : null;
|
|
35
|
-
const withTimingDetail = (result) => timingDetail === null
|
|
36
|
-
? result : { ...result, detail: [result.detail, timingDetail].filter(Boolean).join(" ") };
|
|
37
|
-
if (intent === "missing") {
|
|
38
|
-
return withTimingDetail(this.#failure("task-inventory-missing", 409, "No tasks were supplied. Submit a nonempty TASK inventory."));
|
|
39
|
-
}
|
|
40
|
-
if (intent === "continue" || intent === "todo")
|
|
41
|
-
return withTimingDetail({ status: 102 });
|
|
42
|
-
// {§worker-wait-timing}: explicit timing is an obligation in its own
|
|
43
|
-
// right; otherwise {§wait-obligation-matrix} decides an untimed join.
|
|
44
|
-
if (intent === "wait") {
|
|
45
|
-
const marks = statement.lineMarker?.marks;
|
|
46
|
-
const timeout = marks?.[0] ?? -1;
|
|
47
|
-
const poll = marks?.[1];
|
|
48
|
-
if ((marks?.length ?? 0) > 2 || timeout < -1 || (poll !== undefined && poll < 0)
|
|
49
|
-
|| [timeout, poll].some((value) => value !== undefined
|
|
50
|
-
&& (!Number.isSafeInteger(value) || value * 60_000 + Date.now() > 8.64e15))) {
|
|
51
|
-
return this.#failure("wait-timing-invalid", 400, "TASK wait timing accepts <timeout[,poll]> in whole minutes: timeout is -1 or nonnegative; poll is nonnegative.");
|
|
52
|
-
}
|
|
53
|
-
const seconds = timeout < 0 ? -1 : timeout * 60;
|
|
54
|
-
const timing = {
|
|
55
|
-
...(timeout < 0 ? {} : { timeoutMs: timeout * 60_000 }),
|
|
56
|
-
...(poll === undefined ? {} : { pollMs: poll * 60_000 }),
|
|
57
|
-
};
|
|
58
|
-
if (timeout >= 0 || (poll ?? 0) > 0 || await this.#hasLiveWork(workerId)) {
|
|
59
|
-
if (!await this.#lifecycle.park(loopId, timing)) {
|
|
60
|
-
return this.#statusResult(await this.#lifecycle.status(loopId), "loop-already-terminal", "The loop was already terminal when TASK attempted to wait.");
|
|
61
|
-
}
|
|
62
|
-
return { status: 202, attrs: { waiting: seconds, ...(poll === undefined ? {} : { polling: poll * 60 }) } };
|
|
63
|
-
}
|
|
64
|
-
// Retrievals, fast stream conclusions, and child conclusions are
|
|
65
|
-
// all complete-but-unobserved. Their wake edge may already have
|
|
66
|
-
// fired, so do not park; continue directly to the packet that
|
|
67
|
-
// materializes them.
|
|
68
|
-
const boundaries = await this.#nextPacketBoundaries(workerId, turnId);
|
|
69
|
-
if (boundaries.operations.length > 0 || boundaries.streamTerminations.length > 0 || boundaries.childTerminations) {
|
|
70
|
-
return { status: 102 };
|
|
71
|
-
}
|
|
72
|
-
const failCount = await this.#unobservedFailureCount(turnId);
|
|
73
|
-
if (failCount > 0)
|
|
74
|
-
return { status: 102 };
|
|
75
|
-
return { status: 102, detail: "Nothing is in flight and no timed or polled wait is set. Continuing." };
|
|
76
|
-
}
|
|
77
|
-
// Both terminals cross the observation barrier ({§completion-defers-to-results}): a
|
|
78
|
-
// model's claim over prompts the loop has not published, failures this turn has not
|
|
79
|
-
// seen, or settled results the next packet carries is deferred one packet and never
|
|
80
|
-
// struck. A completion over live work is the join a scope's exit implies: the loop parks
|
|
81
|
-
// until the work settles ({§completion-joins-live-work}); an abandonment cancels it. A
|
|
82
|
-
// `_plurnk` maintenance program closes only its own administrative loop; it must not
|
|
83
|
-
// claim, consume, or be blocked by model work elsewhere in the same Worker.
|
|
84
|
-
if ((status === 200 || status === 499) && ctx.origin === "model") {
|
|
85
|
-
const deferred = await this.#barrier(ctx, status === 200 ? "Completion" : "Abandonment");
|
|
86
|
-
if (deferred !== null)
|
|
87
|
-
return withTimingDetail(deferred);
|
|
88
|
-
}
|
|
89
|
-
// [200] — terminate. A refused attempt is recorded faithfully (status_rx=409, never
|
|
90
|
-
// erased); the loop stays a continue; the strike couples in runTurn. [499] abandons and
|
|
91
|
-
// cancels the descendant scope.
|
|
92
|
-
if (status === 200) {
|
|
93
|
-
const finished = await this.#lifecycle.finish(loopId, TerminalResult.success(null));
|
|
94
|
-
return withTimingDetail(this.#statusResult(finished !== null ? 200 : await this.#lifecycle.status(loopId), "loop-already-terminal", "The loop was already terminal when TASK attempted to conclude it."));
|
|
95
|
-
}
|
|
96
|
-
if (status === 499) {
|
|
97
|
-
const reason = ErrorDetail.preview(statement.body.filter(({ status: state }) => state === "failed").map(({ content }) => content).join("\n"));
|
|
98
|
-
const failure = withTimingDetail(this.#failure("scope-abandoned", 499, "All tasks in the final inventory failed.", {}, {
|
|
99
|
-
...(reason.length === 0 ? {} : { reason }),
|
|
100
|
-
retryable: false,
|
|
101
|
-
}));
|
|
102
|
-
const seqs = await this.#db.engine_loop_turn_seqs.get({
|
|
103
|
-
loop_id: loopId,
|
|
104
|
-
turn_id: turnId,
|
|
105
|
-
});
|
|
106
|
-
if (seqs === undefined) {
|
|
107
|
-
throw new Error(`TASK: no coordinate for loop=${loopId} turn=${turnId}`);
|
|
108
|
-
}
|
|
109
|
-
Results.attachInstance(failure, `log:///${seqs.loop_seq}/${seqs.turn_seq}/${ctx.sequence}/TASK`);
|
|
110
|
-
const finished = await this.#lifecycle.finish(loopId, failure);
|
|
111
|
-
if (finished === null)
|
|
112
|
-
return this.#statusResult(await this.#lifecycle.status(loopId), "loop-already-terminal", "The loop was already terminal when TASK attempted to abandon it.");
|
|
113
|
-
await this.#cancelDescendants?.(workerId, reason || "all tasks in the parent inventory failed");
|
|
114
|
-
return failure;
|
|
115
|
-
}
|
|
116
|
-
return { status };
|
|
117
|
-
}
|
|
118
|
-
// {§completion-defers-to-prompts} Prompt frames this loop contains but has not published
|
|
119
|
-
// (the same rows the next turn boundary publishes, {§prompt-loop-containment}).
|
|
120
|
-
async #undeliveredPromptCount(workerId, loopId) {
|
|
121
|
-
const loopSeq = (await this.#db.engine_loop_sequence.get({ loop_id: loopId }))?.sequence ?? loopId;
|
|
122
|
-
const prefix = promptLoopPrefix(loopSeq);
|
|
123
|
-
const rows = await this.#db.drain_undelivered_prompts_for_loop.all({
|
|
124
|
-
worker_id: workerId, pattern: `${prefix}%`, prefix_len: prefix.length, loop_id: loopId,
|
|
125
|
-
});
|
|
126
|
-
return rows.filter((row) => typeof row.content === "string" && row.content.length > 0).length;
|
|
127
|
-
}
|
|
128
|
-
// {§completion-defers-to-results} — the observation barrier, in the order the graph demands:
|
|
129
|
-
// a prompt the loop has not published; then, for a completion, live work, which parks the
|
|
130
|
-
// loop as a join; then this turn's unseen failures; then the
|
|
131
|
-
// settled results the next packet carries. Every deferral is 102 with the read-time receipt
|
|
132
|
-
// and its pending facts in `attrs`; null means the claim may conclude now.
|
|
133
|
-
async #barrier({ workerId, loopId, turnId }, verb) {
|
|
134
|
-
const concludes = verb === "Completion" ? "complete" : "conclude";
|
|
135
|
-
// {§completion-defers-to-prompts} — a prompt that arrived during this turn is published
|
|
136
|
-
// by the next packet; concluding over it would answer a conversation the model has not
|
|
137
|
-
// seen. Not the model's fault, so a deferral, never a strike.
|
|
138
|
-
const undelivered = await this.#undeliveredPromptCount(workerId, loopId);
|
|
139
|
-
if (undelivered > 0) {
|
|
140
|
-
return {
|
|
141
|
-
status: 102,
|
|
142
|
-
detail: `${verb} deferred: ${undelivered} new prompt${undelivered === 1 ? "" : "s"} arrived during this turn. `
|
|
143
|
-
+ `${undelivered === 1 ? "It is" : "They are"} in this packet; a response and a TASK now ${concludes}.`,
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
const { pending, receipts } = await this.#pendingSet(workerId, turnId);
|
|
147
|
-
const live = pending.filter((kind) => kind === "streams" || kind === "workers");
|
|
148
|
-
if (verb === "Completion" && live.length > 0) {
|
|
149
|
-
// {§completion-joins-live-work} — a completion over live work is the join a scope's
|
|
150
|
-
// exit implies: the loop parks until the work settles, the wake carries what concluded,
|
|
151
|
-
// and the next TASK decides with it in the packet. Never a strike.
|
|
152
|
-
if (!await this.#lifecycle.park(loopId)) {
|
|
153
|
-
return this.#statusResult(await this.#lifecycle.status(loopId), "loop-already-terminal", "The loop was already terminal when TASK attempted to conclude it.");
|
|
154
|
-
}
|
|
155
|
-
return { status: 202, detail: _a.joinDetail(live), attrs: { waiting: -1, pending: [...pending] } };
|
|
156
|
-
}
|
|
157
|
-
// A failed operation is also an unobserved result: it does not enter the model's Log
|
|
158
|
-
// until the next packet.
|
|
159
|
-
const failCount = await this.#unobservedFailureCount(turnId);
|
|
160
|
-
if (failCount > 0) {
|
|
161
|
-
return {
|
|
162
|
-
status: 102,
|
|
163
|
-
detail: `${verb} deferred: ${failCount} operation${failCount === 1 ? "" : "s"} failed in the same turn. `
|
|
164
|
-
+ `The failure${failCount === 1 ? " is" : "s are"} in this packet. ${observedResultsGuidance}`,
|
|
165
|
-
attrs: { failures: failCount },
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
const settled = pending.filter((kind) => kind !== "streams" && kind !== "workers");
|
|
169
|
-
if (settled.length === 0)
|
|
170
|
-
return null;
|
|
171
|
-
// The receipt is read one packet later, beside the results it names, so it speaks from
|
|
172
|
-
// that moment. The model decides whether the results change its work or response.
|
|
173
|
-
const detail = settled.every((kind) => kind === "receipts")
|
|
174
|
-
? _a.deferredReceiptsDetail(receipts, verb)
|
|
175
|
-
: _a.deferredWorkDetail(settled, verb);
|
|
176
|
-
return { status: 102, detail, attrs: { pending: settled } };
|
|
177
|
-
}
|
|
178
|
-
// {§completion-defers-to-results} Receipts-only deferral, worded at read time.
|
|
179
|
-
static deferredReceiptsDetail(receipts, verb = "Completion") {
|
|
180
|
-
const plural = receipts.length > 1;
|
|
181
|
-
return `${verb} deferred until ${ErrorDetail.preview(receipts.join(", "))} reached a packet. ${plural ? "They are" : "It is"} in this packet. ${observedResultsGuidance}`;
|
|
182
|
-
}
|
|
183
|
-
// {§completion-joins-live-work} The join receipt, read when the wake lands.
|
|
184
|
-
static joinDetail(live) {
|
|
185
|
-
const parts = [];
|
|
186
|
-
if (live.includes("workers"))
|
|
187
|
-
parts.push("child workers were still running");
|
|
188
|
-
if (live.includes("streams"))
|
|
189
|
-
parts.push("an execution was still running");
|
|
190
|
-
return `Completion joined: ${parts.join(" and ")}. The loop waited, and what concluded is in this packet. ${observedResultsGuidance}`;
|
|
15
|
+
async handle(ctx) {
|
|
16
|
+
// {§wait-obligation-matrix}: record intent now; settle the complete program before parking.
|
|
17
|
+
return await this.#hasLiveWork(ctx.loopId)
|
|
18
|
+
? { status: 202, attrs: { waiting: -1 } }
|
|
19
|
+
: { status: 102, detail: "Nothing is in flight. Continuing." };
|
|
191
20
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
21
|
+
async settle(ctx, wait) {
|
|
22
|
+
const { workerId, loopId, turnId, origin } = ctx;
|
|
23
|
+
const status = await this.#lifecycle.status(loopId);
|
|
24
|
+
if (![100, 102, 202].includes(status))
|
|
25
|
+
return status;
|
|
26
|
+
// Administrative programs do not conclude the worker's model loop (including turn0).
|
|
27
|
+
if (origin !== "model")
|
|
28
|
+
return 200;
|
|
29
|
+
const arrivals = await this.#db.drain_unpublished_messages_for_loop.all({ loop_id: loopId });
|
|
30
|
+
if (arrivals.length > 0)
|
|
31
|
+
return 102;
|
|
32
|
+
const unanswered = await this.#db.message_unanswered_count.get({ loop_id: loopId });
|
|
33
|
+
if (unanswered === undefined)
|
|
34
|
+
throw new Error("The loop has no message count.");
|
|
35
|
+
const { pending } = await this.#pendingSet(workerId, turnId, loopId);
|
|
36
|
+
const live = pending.some((kind) => kind === "streams" || kind === "workers" || kind === "events");
|
|
37
|
+
if (live && (wait || unanswered.count === 0)) {
|
|
38
|
+
// The obligation itself is the waker: a concluding stream, child or event requeues this loop.
|
|
39
|
+
return await this.#lifecycle.park(loopId, { wakenBy: "obligations" }) ? 202 : this.#lifecycle.status(loopId);
|
|
40
|
+
}
|
|
41
|
+
if (wait || unanswered.count > 0 || pending.length > 0 || await this.#unobservedFailureCount(turnId) > 0)
|
|
42
|
+
return 102;
|
|
43
|
+
// {§completion-defers-to-messages}: recheck unanswered arrivals atomically with conclusion.
|
|
44
|
+
const finished = await this.#lifecycle.finish(loopId, TerminalResult.success(null), { requireAnswered: true });
|
|
45
|
+
return finished === null ? this.#lifecycle.status(loopId) : 200;
|
|
202
46
|
}
|
|
203
47
|
}
|
|
204
|
-
_a = TurnDispositionHandler;
|
|
205
|
-
export default TurnDispositionHandler;
|
|
206
48
|
//# sourceMappingURL=TurnDispositionHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TurnDispositionHandler.js","sourceRoot":"","sources":["../../src/core/TurnDispositionHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TurnDispositionHandler.js","sourceRoot":"","sources":["../../src/core/TurnDispositionHandler.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { UrlPath } from "@plurnk/plurnk-contracts";
|
|
2
1
|
import type { Db } from "./Db.ts";
|
|
3
2
|
import { type FsDivergence } from "./git-membership.ts";
|
|
4
3
|
import { type GitStatusSnapshot } from "./git-state.ts";
|
|
4
|
+
import type { Mimetypes } from "@plurnk/plurnk-mimetypes";
|
|
5
5
|
export default class TurnMaterialization {
|
|
6
6
|
#private;
|
|
7
|
-
constructor({ db, weighContent }: {
|
|
7
|
+
constructor({ db, weighContent, mimetypes }: {
|
|
8
8
|
db: Db;
|
|
9
9
|
weighContent: (text: string) => number;
|
|
10
|
+
mimetypes: Mimetypes;
|
|
10
11
|
});
|
|
11
12
|
materializeEnvironmentDeltas(args: {
|
|
12
13
|
workspaceId: number;
|
|
@@ -14,23 +15,24 @@ export default class TurnMaterialization {
|
|
|
14
15
|
loopId: number;
|
|
15
16
|
turnId: number;
|
|
16
17
|
fromSequence: number;
|
|
17
|
-
}): Promise<number>;
|
|
18
|
+
}): Promise<number[]>;
|
|
18
19
|
materializeStreamDeltas(args: {
|
|
19
20
|
workspaceId: number;
|
|
20
21
|
workerId: number;
|
|
21
22
|
loopId: number;
|
|
22
23
|
turnId: number;
|
|
23
24
|
fromSequence: number;
|
|
24
|
-
}): Promise<number>;
|
|
25
|
+
}): Promise<number[]>;
|
|
25
26
|
logFsFictions(workspaceId: number, divergences: FsDivergence[], gitStatus: GitStatusSnapshot | null): Promise<void>;
|
|
26
|
-
|
|
27
|
+
writeArrivalLog({ workerId, loopId, turnId, sequence, body, source, resource, selfAddressed, }: {
|
|
27
28
|
workerId: number;
|
|
28
29
|
loopId: number;
|
|
29
30
|
turnId: number;
|
|
30
31
|
sequence: number;
|
|
31
|
-
|
|
32
|
-
content: string;
|
|
32
|
+
body: string;
|
|
33
33
|
source: string | null;
|
|
34
|
+
resource: string;
|
|
35
|
+
selfAddressed?: boolean;
|
|
34
36
|
}): Promise<number>;
|
|
35
37
|
}
|
|
36
38
|
//# sourceMappingURL=TurnMaterialization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TurnMaterialization.d.ts","sourceRoot":"","sources":["../../src/core/TurnMaterialization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"TurnMaterialization.d.ts","sourceRoot":"","sources":["../../src/core/TurnMaterialization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAgBxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,CAAC,OAAO,OAAO,mBAAmB;;IAKpC,YAAY,EAAE,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE;QACzC,EAAE,EAAE,EAAE,CAAC;QACP,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;QACvC,SAAS,EAAE,SAAS,CAAC;KACxB,EAIA;IAEK,4BAA4B,CAAC,IAAI,EAAE;QACrC,WAAW,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;KAC/F,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAwHpB;IAGK,uBAAuB,CAAC,IAAI,EAAE;QAChC,WAAW,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;KAC/F,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAgGpB;IAKK,aAAa,CACf,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,YAAY,EAAE,EAC3B,SAAS,EAAE,iBAAiB,GAAG,IAAI,GACpC,OAAO,CAAC,IAAI,CAAC,CAgEf;IAQK,eAAe,CAAC,EAClB,QAAQ,EACR,MAAM,EACN,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,aAAqB,GACxB,EAAE;QACC,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,QAAQ,EAAE,MAAM,CAAC;QAGjB,aAAa,CAAC,EAAE,OAAO,CAAC;KAC3B,GAAG,OAAO,CAAC,MAAM,CAAC,CA0ClB;CAKJ"}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { editedSpan } from "../content/index.js";
|
|
2
2
|
import ReadResolve from "../content/read-resolve.js";
|
|
3
|
+
import ReadProjector from "../content/read-projector.js";
|
|
4
|
+
import TurnSource from "../schemes/TurnSource.js";
|
|
5
|
+
import { loopOutcome } from "./LoopOutcome.js";
|
|
3
6
|
import { authorityParts } from "./plurnk-uri.js";
|
|
4
7
|
import Results from "./results.js";
|
|
5
8
|
import TerminalResult from "./TerminalResult.js";
|
|
6
9
|
import LoopLifecycle from "./LoopLifecycle.js";
|
|
7
10
|
import WorkerControlAddress from "./WorkerControlAddress.js";
|
|
8
11
|
import Turn from "./Turn.js";
|
|
12
|
+
import AdministrativeLoop from "./AdministrativeLoop.js";
|
|
9
13
|
import RuntimeWorker from "./RuntimeWorker.js";
|
|
10
14
|
import LogBody from "./LogBody.js";
|
|
11
15
|
import LogVisibility from "./LogVisibility.js";
|
|
12
16
|
export default class TurnMaterialization {
|
|
13
17
|
#db;
|
|
14
18
|
#weighContent;
|
|
15
|
-
|
|
19
|
+
#mimetypes;
|
|
20
|
+
constructor({ db, weighContent, mimetypes }) {
|
|
16
21
|
this.#db = db;
|
|
17
22
|
this.#weighContent = weighContent;
|
|
23
|
+
this.#mimetypes = mimetypes;
|
|
18
24
|
}
|
|
19
25
|
async materializeEnvironmentDeltas(args) {
|
|
20
26
|
const { workspaceId, workerId, loopId, turnId, fromSequence } = args;
|
|
@@ -22,7 +28,7 @@ export default class TurnMaterialization {
|
|
|
22
28
|
const window = rows[0];
|
|
23
29
|
if (window === undefined)
|
|
24
30
|
throw new Error(`ambient pull: worker ${workerId} has no observation window`);
|
|
25
|
-
|
|
31
|
+
const entryIds = [];
|
|
26
32
|
for (const r of rows) {
|
|
27
33
|
if (r.event_id === null || r.producer_worker_id === null || r.producer_worker_name === null || r.kind === null
|
|
28
34
|
|| r.at === null || r.op === null || r.tx === null || r.mimetype_tx === null
|
|
@@ -36,6 +42,7 @@ export default class TurnMaterialization {
|
|
|
36
42
|
throw new Error(`ambient loop-termination event ${r.event_id} status ${r.status_rx} does not match its terminal result status ${terminal.status}`);
|
|
37
43
|
}
|
|
38
44
|
let attrs = r.attrs ?? "{}";
|
|
45
|
+
let rx = r.rx;
|
|
39
46
|
if (terminal !== null) {
|
|
40
47
|
const inherited = JSON.parse(attrs);
|
|
41
48
|
if (inherited === null || typeof inherited !== "object" || Array.isArray(inherited)) {
|
|
@@ -46,9 +53,22 @@ export default class TurnMaterialization {
|
|
|
46
53
|
kind: "loop_termination",
|
|
47
54
|
...(r.terminated_by === null ? {} : { terminatedBy: r.terminated_by }),
|
|
48
55
|
});
|
|
56
|
+
// {§loop-answer} the row IS what the child said, at the child's own loop address.
|
|
57
|
+
const sequence = Number(r.pathname?.slice(1) ?? "0");
|
|
58
|
+
const outcome = r.hostname === null || !Number.isSafeInteger(sequence)
|
|
59
|
+
? null
|
|
60
|
+
: await loopOutcome(this.#db, workspaceId, r.hostname, sequence);
|
|
61
|
+
const resource = outcome?.resource ?? `ops://${r.hostname}${r.pathname}`;
|
|
62
|
+
rx = JSON.stringify(await ReadProjector.project({
|
|
63
|
+
statement: { op: "READ", target: null, lineMarker: null, matcher: null, metadata: null,
|
|
64
|
+
body: null, aside: null, position: { line: 1, column: 1 } },
|
|
65
|
+
manifest: TurnSource.manifestFor("ops"), publishesLineAnchors: false,
|
|
66
|
+
target: resource, identity: resource, mimetypes: this.#mimetypes,
|
|
67
|
+
representation: TerminalResult.representation(outcome?.result ?? terminal, resource, r.terminated_by),
|
|
68
|
+
}));
|
|
49
69
|
}
|
|
50
70
|
const inserted = await this.#db.engine_insert_ambient_delta.get({
|
|
51
|
-
worker_id: workerId, loop_id: loopId, turn_id: turnId, sequence: fromSequence +
|
|
71
|
+
worker_id: workerId, loop_id: loopId, turn_id: turnId, sequence: fromSequence + entryIds.length,
|
|
52
72
|
at: r.at,
|
|
53
73
|
event_id: r.event_id,
|
|
54
74
|
source: WorkerControlAddress.render(r.producer_worker_name),
|
|
@@ -65,22 +85,20 @@ export default class TurnMaterialization {
|
|
|
65
85
|
line_marker: r.line_marker,
|
|
66
86
|
tx: r.tx,
|
|
67
87
|
mimetype_tx: r.mimetype_tx,
|
|
68
|
-
rx
|
|
88
|
+
rx,
|
|
69
89
|
mimetype_rx: r.mimetype_rx,
|
|
70
90
|
status: r.status_rx,
|
|
71
91
|
weight: LogBody.weight({
|
|
72
92
|
op: r.op,
|
|
73
93
|
attrs,
|
|
74
94
|
tx: r.tx,
|
|
75
|
-
rx
|
|
95
|
+
rx,
|
|
76
96
|
mimetypeTx: r.mimetype_tx,
|
|
77
97
|
mimetypeRx: r.mimetype_rx,
|
|
78
98
|
}, this.#weighContent),
|
|
79
99
|
state: r.state,
|
|
80
100
|
outcome: r.outcome,
|
|
81
|
-
|
|
82
|
-
// a child's activity rows fold.
|
|
83
|
-
folded: LogVisibility.serialize(terminal !== null ? LogVisibility.OPEN : LogVisibility.FOLDED),
|
|
101
|
+
folded: LogVisibility.serialize(terminal !== null || r.kind === "reply" ? LogVisibility.OPEN : LogVisibility.FOLDED),
|
|
84
102
|
attrs,
|
|
85
103
|
});
|
|
86
104
|
const materialized = inserted ?? await this.#db.engine_ambient_delta_id.get({
|
|
@@ -90,7 +108,7 @@ export default class TurnMaterialization {
|
|
|
90
108
|
if (materialized === undefined)
|
|
91
109
|
throw new Error(`ambient event ${r.event_id} has no observer log row after materialization`);
|
|
92
110
|
if (inserted !== undefined)
|
|
93
|
-
|
|
111
|
+
entryIds.push(inserted.id);
|
|
94
112
|
}
|
|
95
113
|
await this.#db.engine_advance_ambient_cursor.get({
|
|
96
114
|
workspace_id: workspaceId,
|
|
@@ -98,12 +116,12 @@ export default class TurnMaterialization {
|
|
|
98
116
|
cursor: window.cursor,
|
|
99
117
|
boundary: window.boundary,
|
|
100
118
|
});
|
|
101
|
-
return
|
|
119
|
+
return entryIds;
|
|
102
120
|
}
|
|
103
121
|
async materializeStreamDeltas(args) {
|
|
104
122
|
const { workerId, loopId, turnId, fromSequence } = args;
|
|
105
123
|
const channels = await this.#db.engine_worker_stream_channels.all({ worker_id: workerId });
|
|
106
|
-
|
|
124
|
+
const entryIds = [];
|
|
107
125
|
// {§exec-stream} — a concluded stream lands one row per channel that has content; an empty
|
|
108
126
|
// sibling channel is a fact on that row (`channels`), never a row of its own, and only a
|
|
109
127
|
// stream that printed nothing at all lands one bodyless row on its default channel
|
|
@@ -152,12 +170,12 @@ export default class TurnMaterialization {
|
|
|
152
170
|
if (skipped.has(ch.publication_id))
|
|
153
171
|
continue;
|
|
154
172
|
const terminal = Results.assert(JSON.parse(ch.producer_result ?? "null"));
|
|
155
|
-
const sequence = fromSequence +
|
|
156
|
-
const source = ch.source;
|
|
173
|
+
const sequence = fromSequence + entryIds.length;
|
|
157
174
|
const page = await ReadResolve.resolve({ content: ch.content, mimetype: ch.mimetype, lineMarker: null });
|
|
158
175
|
const emptySiblings = siblings.get(ch.publication_id) ?? {};
|
|
159
176
|
const result = Results.assert({
|
|
160
177
|
...terminal,
|
|
178
|
+
terminal: true,
|
|
161
179
|
...(terminal.problem === undefined ? {} : { problem: { ...terminal.problem } }),
|
|
162
180
|
content: page.content ?? "",
|
|
163
181
|
mimetype: page.mimetype,
|
|
@@ -166,7 +184,7 @@ export default class TurnMaterialization {
|
|
|
166
184
|
...(page.range === undefined ? {} : { range: page.range }),
|
|
167
185
|
...(page.range !== undefined || page.region === undefined ? {} : { region: page.region }),
|
|
168
186
|
});
|
|
169
|
-
if (result.problem !== undefined) {
|
|
187
|
+
if (result.problem !== undefined && result.problem.instance === undefined) {
|
|
170
188
|
const seqs = await this.#db.engine_loop_turn_seqs.get({
|
|
171
189
|
loop_id: loopId,
|
|
172
190
|
turn_id: turnId,
|
|
@@ -176,10 +194,9 @@ export default class TurnMaterialization {
|
|
|
176
194
|
Results.attachInstance(result, `log:///${seqs.loop_seq}/${seqs.turn_seq}/${sequence}/READ`);
|
|
177
195
|
}
|
|
178
196
|
const rx = JSON.stringify(result);
|
|
179
|
-
await this.#db.engine_insert_stream_delta.
|
|
197
|
+
const inserted = await this.#db.engine_insert_stream_delta.get({
|
|
180
198
|
worker_id: workerId, loop_id: loopId, turn_id: turnId, sequence,
|
|
181
199
|
subscription_publication_id: ch.publication_id,
|
|
182
|
-
source,
|
|
183
200
|
scheme: ch.runtime, hostname: targetParts.hostname, port: targetParts.port,
|
|
184
201
|
pathname: ch.coord, fragment: visibleFragment,
|
|
185
202
|
rx,
|
|
@@ -192,12 +209,14 @@ export default class TurnMaterialization {
|
|
|
192
209
|
mimetypeRx: "application/json",
|
|
193
210
|
}, this.#weighContent),
|
|
194
211
|
status: terminal.status,
|
|
195
|
-
attrs: JSON.stringify({ streamEnd: ch.content.length
|
|
212
|
+
attrs: JSON.stringify({ streamEnd: ch.content.length }),
|
|
196
213
|
folded: LogVisibility.serialize(LogVisibility.OPEN), // {§exec-stream} — the conclusion is initially visible
|
|
197
214
|
});
|
|
198
|
-
|
|
215
|
+
if (inserted === undefined)
|
|
216
|
+
throw new Error(`stream publication ${ch.publication_id} produced no log row`);
|
|
217
|
+
entryIds.push(inserted.id);
|
|
199
218
|
}
|
|
200
|
-
return
|
|
219
|
+
return entryIds;
|
|
201
220
|
}
|
|
202
221
|
// {§env-delta-filesystem-narration} {§membership-emi-divergence-signal}
|
|
203
222
|
// — record project-file divergence once through the reserved actor.
|
|
@@ -206,9 +225,7 @@ export default class TurnMaterialization {
|
|
|
206
225
|
return;
|
|
207
226
|
const gitByPath = new Map(gitStatus?.files.map(({ path, status }) => [path, status]) ?? []);
|
|
208
227
|
const workerId = await RuntimeWorker.ensure(this.#db, workspaceId);
|
|
209
|
-
const loop = await this.#db
|
|
210
|
-
if (loop === undefined)
|
|
211
|
-
throw new Error("logFsFictions: loop insert returned no row");
|
|
228
|
+
const loop = await AdministrativeLoop.open(this.#db, workerId);
|
|
212
229
|
const turn = await Turn.open(this.#db, { loopId: loop.id, producer: "_plurnk", kind: "operation" });
|
|
213
230
|
let turnOpen = true;
|
|
214
231
|
try {
|
|
@@ -272,8 +289,13 @@ export default class TurnMaterialization {
|
|
|
272
289
|
throw cause;
|
|
273
290
|
}
|
|
274
291
|
}
|
|
275
|
-
|
|
276
|
-
|
|
292
|
+
// {§message-arrival} — an arrival is an inbound SEND row: the sender's statement as the row's
|
|
293
|
+
// sent side, published by the harness (origin `_plurnk`) with the causal `source` when another
|
|
294
|
+
// actor caused it ({§message-causal-source}). `attrs.kind = "message"` tells it from the
|
|
295
|
+
// engine's other harness-published SEND rows: observed activity and addressed replies.
|
|
296
|
+
async writeArrivalLog({ workerId, loopId, turnId, sequence, body, source, resource, selfAddressed = false, }) {
|
|
297
|
+
const tx = JSON.stringify({ op: "SEND", aside: null, target: null, metadata: null, lineMarker: null, matcher: null, body: { raw: body } });
|
|
298
|
+
const rx = JSON.stringify({ status: 200, resource });
|
|
277
299
|
const row = await this.#db.engine_insert_log_entry.get({
|
|
278
300
|
worker_id: workerId,
|
|
279
301
|
loop_id: loopId,
|
|
@@ -282,37 +304,37 @@ export default class TurnMaterialization {
|
|
|
282
304
|
origin: "_plurnk",
|
|
283
305
|
source,
|
|
284
306
|
model_call_id: null,
|
|
285
|
-
op: "
|
|
307
|
+
op: "SEND",
|
|
286
308
|
signal: null,
|
|
287
|
-
scheme:
|
|
288
|
-
username:
|
|
289
|
-
password:
|
|
290
|
-
hostname:
|
|
291
|
-
port:
|
|
292
|
-
pathname:
|
|
293
|
-
query:
|
|
294
|
-
fragment:
|
|
309
|
+
scheme: null,
|
|
310
|
+
username: null,
|
|
311
|
+
password: null,
|
|
312
|
+
hostname: null,
|
|
313
|
+
port: null,
|
|
314
|
+
pathname: null,
|
|
315
|
+
query: null,
|
|
316
|
+
fragment: null,
|
|
295
317
|
lineMarker: null,
|
|
296
|
-
tx
|
|
297
|
-
mimetype_tx: "
|
|
318
|
+
tx,
|
|
319
|
+
mimetype_tx: "application/json",
|
|
298
320
|
rx,
|
|
299
321
|
mimetype_rx: "application/json",
|
|
300
322
|
status_rx: 200,
|
|
301
323
|
weight: LogBody.weight({
|
|
302
|
-
op: "
|
|
303
|
-
attrs: {},
|
|
304
|
-
tx
|
|
324
|
+
op: "SEND",
|
|
325
|
+
attrs: selfAddressed ? { kind: "message", selfAddressed: true } : { kind: "message" },
|
|
326
|
+
tx,
|
|
305
327
|
rx,
|
|
306
|
-
mimetypeTx: "
|
|
328
|
+
mimetypeTx: "application/json",
|
|
307
329
|
mimetypeRx: "application/json",
|
|
308
330
|
}, this.#weighContent),
|
|
309
331
|
state: "resolved",
|
|
310
332
|
outcome: null,
|
|
311
|
-
attrs: "{}
|
|
333
|
+
attrs: JSON.stringify(selfAddressed ? { kind: "message", selfAddressed: true } : { kind: "message" }),
|
|
312
334
|
initial_folded: LogVisibility.serialize(LogVisibility.OPEN),
|
|
313
335
|
});
|
|
314
336
|
if (row === undefined)
|
|
315
|
-
throw new Error("
|
|
337
|
+
throw new Error("TurnMaterialization.writeArrivalLog: INSERT ... RETURNING produced no row");
|
|
316
338
|
return row.id;
|
|
317
339
|
}
|
|
318
340
|
}
|