attention-manifest-protocol 0.4.0 → 0.4.2
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/CHANGELOG.md +250 -226
- package/CHANGELOG.zh-CN.md +63 -39
- package/README.md +22 -1
- package/README.zh-CN.md +22 -1
- package/docs/probes/calibration-imported.json +141 -141
- package/docs/probes/eval-recorded-replay.json +597 -597
- package/docs/probes/eval-replay.json +124 -124
- package/docs/probes/eval-summary.json +42 -42
- package/docs/probes/runtime-eval.json +4230 -4230
- package/lib/attention/attention.d.ts +153 -0
- package/lib/attention/attention.js +209 -0
- package/lib/attention/budget.d.ts +31 -0
- package/lib/attention/budget.js +55 -0
- package/lib/attention/cognition.d.ts +230 -0
- package/lib/attention/cognition.js +245 -0
- package/lib/attention/index.d.ts +8 -0
- package/lib/attention/index.js +7 -0
- package/lib/attention/interrupts.d.ts +97 -0
- package/lib/attention/interrupts.js +151 -0
- package/lib/attention/resource.d.ts +167 -0
- package/lib/attention/resource.js +148 -0
- package/lib/attention/social.d.ts +74 -0
- package/lib/attention/social.js +153 -0
- package/lib/attention/socialTypes.d.ts +102 -0
- package/lib/attention/socialTypes.js +1 -0
- package/lib/authz/authz.d.ts +75 -0
- package/lib/authz/authz.js +176 -0
- package/lib/authz/index.d.ts +1 -0
- package/lib/authz/index.js +1 -0
- package/lib/bayes/calibration.d.ts +67 -0
- package/lib/bayes/calibration.js +114 -0
- package/lib/bayes/calibrationRegistry.d.ts +39 -0
- package/lib/bayes/calibrationRegistry.js +61 -0
- package/lib/bayes/calibrationSelection.d.ts +40 -0
- package/lib/bayes/calibrationSelection.js +89 -0
- package/lib/bayes/engine.d.ts +163 -0
- package/lib/bayes/engine.js +354 -0
- package/lib/bayes/index.d.ts +6 -0
- package/lib/bayes/index.js +6 -0
- package/lib/bayes/reliability.d.ts +27 -0
- package/lib/bayes/reliability.js +38 -0
- package/lib/bayes/scopedPriors.d.ts +34 -0
- package/lib/bayes/scopedPriors.js +70 -0
- package/lib/boundary/frame.d.ts +63 -0
- package/lib/boundary/frame.js +239 -0
- package/lib/boundary/ids.d.ts +8 -0
- package/lib/boundary/ids.js +12 -0
- package/lib/boundary/index.d.ts +12 -0
- package/lib/boundary/index.js +8 -0
- package/lib/boundary/refTable.d.ts +49 -0
- package/lib/boundary/refTable.js +92 -0
- package/lib/boundary/toolCall.d.ts +33 -0
- package/lib/boundary/toolCall.js +173 -0
- package/lib/concept/concept.d.ts +67 -0
- package/lib/concept/concept.js +1 -0
- package/lib/concept/conceptBudget.d.ts +56 -0
- package/lib/concept/conceptBudget.js +281 -0
- package/lib/concept/conceptBudgetTypes.d.ts +74 -0
- package/lib/concept/conceptBudgetTypes.js +1 -0
- package/lib/concept/index.d.ts +3 -0
- package/lib/concept/index.js +3 -0
- package/lib/concurrency/idempotency.d.ts +16 -0
- package/lib/concurrency/idempotency.js +21 -0
- package/lib/concurrency/index.d.ts +5 -0
- package/lib/concurrency/index.js +5 -0
- package/lib/concurrency/mutex.d.ts +13 -0
- package/lib/concurrency/mutex.js +26 -0
- package/lib/concurrency/namedLocks.d.ts +7 -0
- package/lib/concurrency/namedLocks.js +31 -0
- package/lib/concurrency/retry.d.ts +23 -0
- package/lib/concurrency/retry.js +38 -0
- package/lib/concurrency/worker.d.ts +42 -0
- package/lib/concurrency/worker.js +67 -0
- package/lib/context/agentContext.d.ts +58 -0
- package/lib/context/agentContext.js +197 -0
- package/lib/context/ast.d.ts +98 -0
- package/lib/context/ast.js +414 -0
- package/lib/context/contentStore.d.ts +16 -0
- package/lib/context/contentStore.js +61 -0
- package/lib/context/context.d.ts +15 -0
- package/lib/context/context.js +39 -0
- package/lib/context/contextIndex.d.ts +40 -0
- package/lib/context/contextIndex.js +64 -0
- package/lib/context/document.d.ts +102 -0
- package/lib/context/document.js +22 -0
- package/lib/context/fileStorePath.d.ts +1 -0
- package/lib/context/fileStorePath.js +13 -0
- package/lib/context/index.d.ts +22 -0
- package/lib/context/index.js +11 -0
- package/lib/context/lifecycle.d.ts +91 -0
- package/lib/context/lifecycle.js +163 -0
- package/lib/context/projections.d.ts +20 -0
- package/lib/context/projections.js +127 -0
- package/lib/context/workspace.d.ts +111 -0
- package/lib/context/workspace.js +318 -0
- package/lib/context/workspaceProtocol.d.ts +30 -0
- package/lib/context/workspaceProtocol.js +49 -0
- package/lib/context/workspaceService.d.ts +63 -0
- package/lib/context/workspaceService.js +352 -0
- package/lib/cooperation/board.d.ts +47 -0
- package/lib/cooperation/board.js +66 -0
- package/lib/cooperation/collaboration.d.ts +55 -0
- package/lib/cooperation/collaboration.js +1 -0
- package/lib/cooperation/index.d.ts +6 -0
- package/lib/cooperation/index.js +6 -0
- package/lib/cooperation/merge.d.ts +69 -0
- package/lib/cooperation/merge.js +109 -0
- package/lib/cooperation/metrics.d.ts +39 -0
- package/lib/cooperation/metrics.js +17 -0
- package/lib/cooperation/session.d.ts +75 -0
- package/lib/cooperation/session.js +74 -0
- package/lib/cooperation/unified.d.ts +38 -0
- package/lib/cooperation/unified.js +40 -0
- package/lib/database/adapter/adapters.d.ts +24 -0
- package/lib/database/adapter/adapters.js +31 -0
- package/lib/database/adapter/index.d.ts +4 -0
- package/lib/database/adapter/index.js +4 -0
- package/lib/database/adapter/runtimeSink.d.ts +20 -0
- package/lib/database/adapter/runtimeSink.js +50 -0
- package/lib/database/adapter/sessionStore.d.ts +11 -0
- package/lib/database/adapter/sessionStore.js +23 -0
- package/lib/database/adapter/turnStore.d.ts +10 -0
- package/lib/database/adapter/turnStore.js +15 -0
- package/lib/database/entity/agent.d.ts +133 -0
- package/lib/database/entity/agent.js +61 -0
- package/lib/database/entity/entity.d.ts +715 -0
- package/lib/database/entity/entity.js +372 -0
- package/lib/database/entity/handle.d.ts +31 -0
- package/lib/database/entity/handle.js +53 -0
- package/lib/database/entity/index.d.ts +32 -0
- package/lib/database/entity/index.js +22 -0
- package/lib/database/entity/message.d.ts +27 -0
- package/lib/database/entity/message.js +52 -0
- package/lib/database/entity/meta.d.ts +11 -0
- package/lib/database/entity/meta.js +1 -0
- package/lib/database/entity/object.d.ts +23 -0
- package/lib/database/entity/object.js +24 -0
- package/lib/database/entity/outbox.d.ts +9 -0
- package/lib/database/entity/outbox.js +5 -0
- package/lib/database/entity/process.d.ts +30 -0
- package/lib/database/entity/process.js +40 -0
- package/lib/database/entity/registry.d.ts +81 -0
- package/lib/database/entity/registry.js +91 -0
- package/lib/database/entity/runtimeApproval.d.ts +23 -0
- package/lib/database/entity/runtimeApproval.js +5 -0
- package/lib/database/entity/runtimeSession.d.ts +7 -0
- package/lib/database/entity/runtimeSession.js +5 -0
- package/lib/database/entity/runtimeTurn.d.ts +9 -0
- package/lib/database/entity/runtimeTurn.js +5 -0
- package/lib/database/entity/thread.d.ts +35 -0
- package/lib/database/entity/thread.js +55 -0
- package/lib/database/entity/window.d.ts +39 -0
- package/lib/database/entity/window.js +56 -0
- package/lib/database/entity/worker.d.ts +42 -0
- package/lib/database/entity/worker.js +58 -0
- package/lib/database/index.d.ts +6 -0
- package/lib/database/index.js +6 -0
- package/lib/database/repository/addressSpaceRepository.d.ts +18 -0
- package/lib/database/repository/addressSpaceRepository.js +40 -0
- package/lib/database/repository/agentRepository.d.ts +41 -0
- package/lib/database/repository/agentRepository.js +398 -0
- package/lib/database/repository/base.d.ts +31 -0
- package/lib/database/repository/base.js +23 -0
- package/lib/database/repository/executionRepository.d.ts +64 -0
- package/lib/database/repository/executionRepository.js +379 -0
- package/lib/database/repository/handleRepository.d.ts +35 -0
- package/lib/database/repository/handleRepository.js +57 -0
- package/lib/database/repository/index.d.ts +20 -0
- package/lib/database/repository/index.js +17 -0
- package/lib/database/repository/messageRepository.d.ts +33 -0
- package/lib/database/repository/messageRepository.js +45 -0
- package/lib/database/repository/objectRepository.d.ts +43 -0
- package/lib/database/repository/objectRepository.js +60 -0
- package/lib/database/repository/outboxRepository.d.ts +15 -0
- package/lib/database/repository/outboxRepository.js +51 -0
- package/lib/database/repository/processRepository.d.ts +31 -0
- package/lib/database/repository/processRepository.js +48 -0
- package/lib/database/repository/registryRepository.d.ts +72 -0
- package/lib/database/repository/registryRepository.js +95 -0
- package/lib/database/repository/repository.d.ts +322 -0
- package/lib/database/repository/repository.js +332 -0
- package/lib/database/repository/runtimeApprovalRepository.d.ts +14 -0
- package/lib/database/repository/runtimeApprovalRepository.js +35 -0
- package/lib/database/repository/runtimeSessionRepository.d.ts +9 -0
- package/lib/database/repository/runtimeSessionRepository.js +21 -0
- package/lib/database/repository/runtimeTurnRepository.d.ts +10 -0
- package/lib/database/repository/runtimeTurnRepository.js +32 -0
- package/lib/database/repository/socialRepository.d.ts +22 -0
- package/lib/database/repository/socialRepository.js +155 -0
- package/lib/database/repository/threadRepository.d.ts +29 -0
- package/lib/database/repository/threadRepository.js +48 -0
- package/lib/database/repository/windowRepository.d.ts +46 -0
- package/lib/database/repository/windowRepository.js +68 -0
- package/lib/database/repository/workerRepository.d.ts +38 -0
- package/lib/database/repository/workerRepository.js +61 -0
- package/lib/database/service/database.d.ts +55 -0
- package/lib/database/service/database.js +77 -0
- package/lib/database/service/handleService.d.ts +20 -0
- package/lib/database/service/handleService.js +34 -0
- package/lib/database/service/index.d.ts +16 -0
- package/lib/database/service/index.js +11 -0
- package/lib/database/service/messageService.d.ts +26 -0
- package/lib/database/service/messageService.js +40 -0
- package/lib/database/service/objectService.d.ts +32 -0
- package/lib/database/service/objectService.js +31 -0
- package/lib/database/service/processService.d.ts +22 -0
- package/lib/database/service/processService.js +45 -0
- package/lib/database/service/registryServices.d.ts +43 -0
- package/lib/database/service/registryServices.js +60 -0
- package/lib/database/service/service.d.ts +131 -0
- package/lib/database/service/service.js +153 -0
- package/lib/database/service/stepService.d.ts +23 -0
- package/lib/database/service/stepService.js +35 -0
- package/lib/database/service/threadService.d.ts +23 -0
- package/lib/database/service/threadService.js +48 -0
- package/lib/database/service/windowService.d.ts +15 -0
- package/lib/database/service/windowService.js +22 -0
- package/lib/database/service/workerService.d.ts +28 -0
- package/lib/database/service/workerService.js +34 -0
- package/lib/database/sql/index.d.ts +3 -0
- package/lib/database/sql/index.js +2 -0
- package/lib/database/sql/schema.d.ts +5 -0
- package/lib/database/sql/schema.js +416 -0
- package/lib/database/sql/sql.d.ts +290 -0
- package/lib/database/sql/sql.js +430 -0
- package/lib/database/store/database.d.ts +75 -0
- package/lib/database/store/database.js +143 -0
- package/lib/database/store/index.d.ts +3 -0
- package/lib/database/store/index.js +2 -0
- package/lib/database/store/store.d.ts +145 -0
- package/lib/database/store/store.js +192 -0
- package/lib/delegate/index.d.ts +2 -0
- package/lib/delegate/index.js +2 -0
- package/lib/delegate/team.d.ts +92 -0
- package/lib/delegate/team.js +200 -0
- package/lib/delegate/teamTypes.d.ts +43 -0
- package/lib/delegate/teamTypes.js +1 -0
- package/lib/diagnosis/checklist.d.ts +16 -0
- package/lib/diagnosis/checklist.js +61 -0
- package/lib/diagnosis/context.d.ts +19 -0
- package/lib/diagnosis/context.js +79 -0
- package/lib/diagnosis/frame.d.ts +34 -0
- package/lib/diagnosis/frame.js +230 -0
- package/lib/diagnosis/index.d.ts +5 -0
- package/lib/diagnosis/index.js +5 -0
- package/lib/diagnosis/router.d.ts +22 -0
- package/lib/diagnosis/router.js +47 -0
- package/lib/diagnosis/types.d.ts +78 -0
- package/lib/diagnosis/types.js +2 -0
- package/lib/error/agentError.d.ts +9 -0
- package/lib/error/agentError.js +13 -0
- package/lib/error/ampError.d.ts +14 -0
- package/lib/error/ampError.js +19 -0
- package/lib/error/authzError.d.ts +10 -0
- package/lib/error/authzError.js +11 -0
- package/lib/error/boundaryRejection.d.ts +16 -0
- package/lib/error/boundaryRejection.js +14 -0
- package/lib/error/index.d.ts +7 -0
- package/lib/error/index.js +7 -0
- package/lib/error/kernelError.d.ts +11 -0
- package/lib/error/kernelError.js +12 -0
- package/lib/error/mailboxError.d.ts +5 -0
- package/lib/error/mailboxError.js +6 -0
- package/lib/error/windowError.d.ts +8 -0
- package/lib/error/windowError.js +9 -0
- package/lib/evaluation/agreement.d.ts +22 -0
- package/lib/evaluation/agreement.js +82 -0
- package/lib/evaluation/index.d.ts +2 -0
- package/lib/evaluation/index.js +2 -0
- package/lib/evaluation/labels.d.ts +56 -0
- package/lib/evaluation/labels.js +206 -0
- package/lib/evidence/evidenceGraph.d.ts +37 -0
- package/lib/evidence/evidenceGraph.js +165 -0
- package/lib/evidence/index.d.ts +4 -0
- package/lib/evidence/index.js +2 -0
- package/lib/evidence/revalidation.d.ts +70 -0
- package/lib/evidence/revalidation.js +146 -0
- package/lib/execution/exec.d.ts +151 -0
- package/lib/execution/exec.js +282 -0
- package/lib/execution/handles.d.ts +25 -0
- package/lib/execution/handles.js +45 -0
- package/lib/execution/index.d.ts +3 -0
- package/lib/execution/index.js +3 -0
- package/lib/execution/pin.d.ts +60 -0
- package/lib/execution/pin.js +103 -0
- package/lib/frame/frame.d.ts +61 -0
- package/lib/frame/frame.js +1 -0
- package/lib/frame/index.d.ts +1 -0
- package/lib/frame/index.js +1 -0
- package/lib/goal/goal.d.ts +19 -0
- package/lib/goal/goal.js +21 -0
- package/lib/goal/index.d.ts +2 -0
- package/lib/goal/index.js +1 -0
- package/lib/goal/plan.d.ts +125 -0
- package/lib/goal/plan.js +60 -0
- package/lib/governance/attentionManifest.d.ts +279 -0
- package/lib/governance/attentionManifest.js +467 -0
- package/lib/governance/audit.d.ts +123 -0
- package/lib/governance/audit.js +263 -0
- package/lib/governance/budget.d.ts +219 -0
- package/lib/governance/budget.js +424 -0
- package/lib/governance/context.d.ts +159 -0
- package/lib/governance/context.js +229 -0
- package/lib/governance/control.d.ts +65 -0
- package/lib/governance/control.js +89 -0
- package/lib/governance/cooperation.d.ts +163 -0
- package/lib/governance/cooperation.js +350 -0
- package/lib/governance/credential.d.ts +117 -0
- package/lib/governance/credential.js +229 -0
- package/lib/governance/httpServer.d.ts +18 -0
- package/lib/governance/httpServer.js +74 -0
- package/lib/governance/index.d.ts +32 -0
- package/lib/governance/index.js +32 -0
- package/lib/governance/legal.d.ts +222 -0
- package/lib/governance/legal.js +371 -0
- package/lib/governance/matrix.d.ts +170 -0
- package/lib/governance/matrix.js +365 -0
- package/lib/governance/perspectives.d.ts +98 -0
- package/lib/governance/perspectives.js +340 -0
- package/lib/governance/signing.d.ts +131 -0
- package/lib/governance/signing.js +241 -0
- package/lib/governance/store.d.ts +33 -0
- package/lib/governance/store.js +89 -0
- package/lib/governance/switching.d.ts +183 -0
- package/lib/governance/switching.js +257 -0
- package/lib/governance/toolPolicy.d.ts +37 -0
- package/lib/governance/toolPolicy.js +42 -0
- package/lib/governance/transport.d.ts +76 -0
- package/lib/governance/transport.js +124 -0
- package/lib/governance/types.d.ts +218 -0
- package/lib/governance/types.js +72 -0
- package/lib/governance/workflow.d.ts +174 -0
- package/lib/governance/workflow.js +612 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +11 -0
- package/lib/interaction/index.d.ts +1 -0
- package/lib/interaction/index.js +1 -0
- package/lib/interaction/interaction.d.ts +83 -0
- package/lib/interaction/interaction.js +256 -0
- package/lib/ipc/index.d.ts +4 -0
- package/lib/ipc/index.js +3 -0
- package/lib/ipc/mailbox.d.ts +37 -0
- package/lib/ipc/mailbox.js +77 -0
- package/lib/ipc/memorySocialStore.d.ts +14 -0
- package/lib/ipc/memorySocialStore.js +83 -0
- package/lib/ipc/social.d.ts +80 -0
- package/lib/ipc/social.js +1 -0
- package/lib/kernel/index.d.ts +2 -0
- package/lib/kernel/index.js +1 -0
- package/lib/kernel/scheduler.d.ts +195 -0
- package/lib/kernel/scheduler.js +334 -0
- package/lib/ledger/checkpoint.d.ts +116 -0
- package/lib/ledger/checkpoint.js +223 -0
- package/lib/ledger/index.d.ts +4 -0
- package/lib/ledger/index.js +4 -0
- package/lib/ledger/ledger.d.ts +21 -0
- package/lib/ledger/ledger.js +23 -0
- package/lib/ledger/persistence.d.ts +46 -0
- package/lib/ledger/persistence.js +106 -0
- package/lib/ledger/share.d.ts +29 -0
- package/lib/ledger/share.js +39 -0
- package/lib/lock/index.d.ts +2 -0
- package/lib/lock/index.js +1 -0
- package/lib/lock/lease.d.ts +23 -0
- package/lib/lock/lease.js +42 -0
- package/lib/manifest/agentCard.d.ts +35 -0
- package/lib/manifest/agentCard.js +38 -0
- package/lib/manifest/cardSign.d.ts +25 -0
- package/lib/manifest/cardSign.js +70 -0
- package/lib/manifest/federation.d.ts +64 -0
- package/lib/manifest/federation.js +187 -0
- package/lib/manifest/federationTypes.d.ts +51 -0
- package/lib/manifest/federationTypes.js +1 -0
- package/lib/manifest/index.d.ts +8 -0
- package/lib/manifest/index.js +8 -0
- package/lib/manifest/keys.d.ts +221 -0
- package/lib/manifest/keys.js +484 -0
- package/lib/manifest/manifest.d.ts +102 -0
- package/lib/manifest/manifest.js +1 -0
- package/lib/manifest/sign.d.ts +38 -0
- package/lib/manifest/sign.js +90 -0
- package/lib/manifest/trust.d.ts +54 -0
- package/lib/manifest/trust.js +87 -0
- package/lib/mission/index.d.ts +2 -0
- package/lib/mission/index.js +1 -0
- package/lib/mission/missionQueue.d.ts +19 -0
- package/lib/mission/missionQueue.js +62 -0
- package/lib/module/index.d.ts +9 -0
- package/lib/module/index.js +9 -0
- package/lib/module/llm/deepseek.d.ts +43 -0
- package/lib/module/llm/deepseek.js +162 -0
- package/lib/module/llm/llm.d.ts +64 -0
- package/lib/module/llm/llm.js +16 -0
- package/lib/module/mcp/client.d.ts +32 -0
- package/lib/module/mcp/client.js +84 -0
- package/lib/module/mcp/http.d.ts +32 -0
- package/lib/module/mcp/http.js +83 -0
- package/lib/module/mcp/protocol.d.ts +62 -0
- package/lib/module/mcp/protocol.js +20 -0
- package/lib/module/mcp/server.d.ts +22 -0
- package/lib/module/mcp/server.js +138 -0
- package/lib/module/mcp/transport.d.ts +19 -0
- package/lib/module/mcp/transport.js +16 -0
- package/lib/module/mcp/workspaceServer.d.ts +20 -0
- package/lib/module/mcp/workspaceServer.js +90 -0
- package/lib/module/sandbox/sandbox.d.ts +24 -0
- package/lib/module/sandbox/sandbox.js +5 -0
- package/lib/module/tool/mcpExecutor.d.ts +18 -0
- package/lib/module/tool/mcpExecutor.js +41 -0
- package/lib/module/tool/policy.d.ts +30 -0
- package/lib/module/tool/policy.js +23 -0
- package/lib/module/tool/redact.d.ts +9 -0
- package/lib/module/tool/redact.js +19 -0
- package/lib/module/tool/tool.d.ts +26 -0
- package/lib/module/tool/tool.js +24 -0
- package/lib/module/tool/workspaceExecutor.d.ts +12 -0
- package/lib/module/tool/workspaceExecutor.js +25 -0
- package/lib/policy/guard.d.ts +115 -0
- package/lib/policy/guard.js +154 -0
- package/lib/policy/index.d.ts +2 -0
- package/lib/policy/index.js +2 -0
- package/lib/policy/policy.d.ts +249 -0
- package/lib/policy/policy.js +364 -0
- package/lib/process/agent.d.ts +295 -0
- package/lib/process/agent.js +1 -0
- package/lib/process/agentService.d.ts +87 -0
- package/lib/process/agentService.js +128 -0
- package/lib/process/agentStore.d.ts +35 -0
- package/lib/process/agentStore.js +328 -0
- package/lib/process/executionStore.d.ts +79 -0
- package/lib/process/executionStore.js +71 -0
- package/lib/process/index.d.ts +5 -0
- package/lib/process/index.js +5 -0
- package/lib/process/process.d.ts +120 -0
- package/lib/process/process.js +111 -0
- package/lib/process/transitions.d.ts +11 -0
- package/lib/process/transitions.js +8 -0
- package/lib/progress/index.d.ts +2 -0
- package/lib/progress/index.js +1 -0
- package/lib/progress/progress.d.ts +26 -0
- package/lib/progress/progress.js +42 -0
- package/lib/protocol/a2a.d.ts +51 -0
- package/lib/protocol/a2a.js +79 -0
- package/lib/protocol/channel.d.ts +25 -0
- package/lib/protocol/channel.js +27 -0
- package/lib/protocol/envelope.d.ts +180 -0
- package/lib/protocol/envelope.js +495 -0
- package/lib/protocol/httpChannel.d.ts +33 -0
- package/lib/protocol/httpChannel.js +59 -0
- package/lib/protocol/index.d.ts +6 -0
- package/lib/protocol/index.js +6 -0
- package/lib/protocol/protocol.d.ts +120 -0
- package/lib/protocol/protocol.js +1 -0
- package/lib/protocol/wire.d.ts +12 -0
- package/lib/protocol/wire.js +55 -0
- package/lib/receipt/index.d.ts +1 -0
- package/lib/receipt/index.js +1 -0
- package/lib/receipt/receipt.d.ts +43 -0
- package/lib/receipt/receipt.js +1 -0
- package/lib/registry/content.d.ts +10 -0
- package/lib/registry/content.js +58 -0
- package/lib/registry/index.d.ts +4 -0
- package/lib/registry/index.js +2 -0
- package/lib/registry/registry.d.ts +109 -0
- package/lib/registry/registry.js +299 -0
- package/lib/runtime/action.d.ts +46 -0
- package/lib/runtime/action.js +39 -0
- package/lib/runtime/behavior.d.ts +110 -0
- package/lib/runtime/behavior.js +179 -0
- package/lib/runtime/behaviorTuning.d.ts +59 -0
- package/lib/runtime/behaviorTuning.js +95 -0
- package/lib/runtime/cognitiveRuntime.d.ts +189 -0
- package/lib/runtime/cognitiveRuntime.js +490 -0
- package/lib/runtime/escalation.d.ts +22 -0
- package/lib/runtime/escalation.js +15 -0
- package/lib/runtime/governedTask.d.ts +57 -0
- package/lib/runtime/governedTask.js +150 -0
- package/lib/runtime/index.d.ts +15 -0
- package/lib/runtime/index.js +15 -0
- package/lib/runtime/kernelRuntime.d.ts +33 -0
- package/lib/runtime/kernelRuntime.js +105 -0
- package/lib/runtime/operation.d.ts +30 -0
- package/lib/runtime/operation.js +1 -0
- package/lib/runtime/replay.d.ts +24 -0
- package/lib/runtime/replay.js +38 -0
- package/lib/runtime/routing.d.ts +12 -0
- package/lib/runtime/routing.js +44 -0
- package/lib/runtime/safety.d.ts +15 -0
- package/lib/runtime/safety.js +28 -0
- package/lib/runtime/session.d.ts +147 -0
- package/lib/runtime/session.js +214 -0
- package/lib/runtime/sessionStore.d.ts +24 -0
- package/lib/runtime/sessionStore.js +20 -0
- package/lib/runtime/telemetry.d.ts +24 -0
- package/lib/runtime/telemetry.js +33 -0
- package/lib/runtime/turnStore.d.ts +16 -0
- package/lib/runtime/turnStore.js +15 -0
- package/lib/scenario/index.d.ts +1 -0
- package/lib/scenario/index.js +1 -0
- package/lib/scenario/scenario.d.ts +52 -0
- package/lib/scenario/scenario.js +210 -0
- package/lib/semantic/canonical.d.ts +6 -0
- package/lib/semantic/canonical.js +22 -0
- package/lib/semantic/index.d.ts +2 -0
- package/lib/semantic/index.js +2 -0
- package/lib/semantic/sha256.d.ts +1 -0
- package/lib/semantic/sha256.js +66 -0
- package/lib/storage/appendLog.d.ts +145 -0
- package/lib/storage/appendLog.js +299 -0
- package/lib/storage/fileAppendSink.d.ts +7 -0
- package/lib/storage/fileAppendSink.js +34 -0
- package/lib/storage/index.d.ts +2 -0
- package/lib/storage/index.js +2 -0
- package/lib/store/bindCache.d.ts +9 -0
- package/lib/store/bindCache.js +18 -0
- package/lib/store/cache.d.ts +48 -0
- package/lib/store/cache.js +162 -0
- package/lib/store/context.d.ts +10 -0
- package/lib/store/context.js +27 -0
- package/lib/store/handleStore.d.ts +9 -0
- package/lib/store/handleStore.js +25 -0
- package/lib/store/index.d.ts +9 -0
- package/lib/store/index.js +8 -0
- package/lib/store/messageStore.d.ts +9 -0
- package/lib/store/messageStore.js +25 -0
- package/lib/store/objectStore.d.ts +9 -0
- package/lib/store/objectStore.js +25 -0
- package/lib/store/processStore.d.ts +9 -0
- package/lib/store/processStore.js +25 -0
- package/lib/store/threadStore.d.ts +9 -0
- package/lib/store/threadStore.js +25 -0
- package/lib/store/windowStore.d.ts +9 -0
- package/lib/store/windowStore.js +25 -0
- package/lib/structure/abstractSyntaxTree.d.ts +181 -0
- package/lib/structure/abstractSyntaxTree.js +400 -0
- package/lib/structure/avlTree.d.ts +125 -0
- package/lib/structure/avlTree.js +369 -0
- package/lib/structure/binarySearchTree.d.ts +125 -0
- package/lib/structure/binarySearchTree.js +306 -0
- package/lib/structure/binaryTree.d.ts +174 -0
- package/lib/structure/binaryTree.js +495 -0
- package/lib/structure/bloomFilter.d.ts +126 -0
- package/lib/structure/bloomFilter.js +177 -0
- package/lib/structure/compare.d.ts +55 -0
- package/lib/structure/compare.js +96 -0
- package/lib/structure/cuckooFilter.d.ts +149 -0
- package/lib/structure/cuckooFilter.js +267 -0
- package/lib/structure/deque.d.ts +117 -0
- package/lib/structure/deque.js +205 -0
- package/lib/structure/filterKey.d.ts +19 -0
- package/lib/structure/filterKey.js +28 -0
- package/lib/structure/hash.d.ts +129 -0
- package/lib/structure/hash.js +241 -0
- package/lib/structure/heap.d.ts +152 -0
- package/lib/structure/heap.js +227 -0
- package/lib/structure/index.d.ts +20 -0
- package/lib/structure/index.js +20 -0
- package/lib/structure/iterator.d.ts +6 -0
- package/lib/structure/iterator.js +16 -0
- package/lib/structure/lru.d.ts +235 -0
- package/lib/structure/lru.js +524 -0
- package/lib/structure/ordered.d.ts +89 -0
- package/lib/structure/ordered.js +336 -0
- package/lib/structure/priority.d.ts +499 -0
- package/lib/structure/priority.js +756 -0
- package/lib/structure/queue.d.ts +90 -0
- package/lib/structure/queue.js +154 -0
- package/lib/structure/redBlackTree.d.ts +142 -0
- package/lib/structure/redBlackTree.js +644 -0
- package/lib/structure/segmentTree.d.ts +129 -0
- package/lib/structure/segmentTree.js +205 -0
- package/lib/structure/stack.d.ts +77 -0
- package/lib/structure/stack.js +107 -0
- package/lib/structure/unordered.d.ts +99 -0
- package/lib/structure/unordered.js +341 -0
- package/lib/thread/index.d.ts +2 -0
- package/lib/thread/index.js +2 -0
- package/lib/thread/thread.d.ts +107 -0
- package/lib/thread/thread.js +81 -0
- package/lib/thread/transitions.d.ts +8 -0
- package/lib/thread/transitions.js +9 -0
- package/lib/types/common.d.ts +80 -0
- package/lib/types/common.js +5 -0
- package/lib/types/index.d.ts +23 -0
- package/lib/types/index.js +1 -0
- package/lib/warrant/epistemic.d.ts +141 -0
- package/lib/warrant/epistemic.js +1 -0
- package/lib/warrant/index.d.ts +3 -0
- package/lib/warrant/index.js +3 -0
- package/lib/warrant/inquiry.d.ts +69 -0
- package/lib/warrant/inquiry.js +119 -0
- package/lib/warrant/warrant.d.ts +46 -0
- package/lib/warrant/warrant.js +153 -0
- package/lib/window/compaction.d.ts +57 -0
- package/lib/window/compaction.js +334 -0
- package/lib/window/compactionTypes.d.ts +113 -0
- package/lib/window/compactionTypes.js +1 -0
- package/lib/window/index.d.ts +7 -0
- package/lib/window/index.js +3 -0
- package/lib/window/page.d.ts +16 -0
- package/lib/window/page.js +2 -0
- package/lib/window/window.d.ts +68 -0
- package/lib/window/window.js +194 -0
- package/package.json +22 -1
- package/src/authz/index.ts +1 -0
- package/src/concept/index.ts +3 -0
- package/src/concurrency/index.ts +5 -0
- package/src/cooperation/index.ts +6 -0
- package/src/delegate/index.ts +2 -0
- package/src/error/index.ts +7 -0
- package/src/evaluation/index.ts +2 -0
- package/src/execution/index.ts +3 -0
- package/src/frame/index.ts +1 -0
- package/src/index.ts +11 -0
- package/src/ledger/index.ts +4 -0
- package/src/manifest/index.ts +8 -0
- package/src/policy/index.ts +2 -0
- package/src/protocol/index.ts +6 -0
- package/src/receipt/index.ts +1 -0
- package/src/semantic/index.ts +2 -0
- package/src/storage/index.ts +2 -0
- package/src/structure/index.ts +20 -0
- package/src/thread/index.ts +2 -0
- package/src/warrant/index.ts +3 -0
- package/src/window/index.ts +7 -4
- package/tools/rewrite-declaration-extensions.ts +98 -0
- package/tsconfig.build.json +14 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { FloorRank, FloorTier, GovernanceError, ModeIds, ScenarioIds, SensitivityRank } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default weights, copied exactly from spec section 9.1. Each row sums to 1.
|
|
4
|
+
*/
|
|
5
|
+
export const DefaultModeWeights = {
|
|
6
|
+
chat: { affect: 0.5, think: 0.2, diverge: 0.2, converge: 0.1 },
|
|
7
|
+
writing: { affect: 0.1, think: 0.2, diverge: 0.5, converge: 0.2 },
|
|
8
|
+
office: { affect: 0.1, think: 0.3, diverge: 0.1, converge: 0.5 },
|
|
9
|
+
research: { affect: 0.05, think: 0.4, diverge: 0.4, converge: 0.15 },
|
|
10
|
+
engineering: { affect: 0.05, think: 0.35, diverge: 0.1, converge: 0.5 },
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Evidence floors per scenario and mode (spec section 9.4), translated from
|
|
14
|
+
* the description's T1/T2/T3 wording into the governance F1/F2/F3 order.
|
|
15
|
+
*/
|
|
16
|
+
export const EvidenceFloorTable = {
|
|
17
|
+
chat: { affect: "F3", think: "F3", diverge: "F3", converge: "F3" },
|
|
18
|
+
writing: { affect: "F3", think: "F2", diverge: "F3", converge: "F2" },
|
|
19
|
+
office: { affect: "F2", think: "F2", diverge: "F2", converge: "F2" },
|
|
20
|
+
research: { affect: "F2", think: "F1", diverge: "F2", converge: "F2" },
|
|
21
|
+
engineering: { affect: "F2", think: "F1", diverge: "F2", converge: "F1" },
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Frame cadence for re-evaluating ignored items (spec section 9.5).
|
|
25
|
+
*/
|
|
26
|
+
export const RevisitIntervalTable = {
|
|
27
|
+
chat: { affect: 10, think: 5, diverge: 8, converge: 10 },
|
|
28
|
+
writing: { affect: 8, think: 5, diverge: 2, converge: 4 },
|
|
29
|
+
office: { affect: 8, think: 4, diverge: 6, converge: 4 },
|
|
30
|
+
research: { affect: 10, think: 3, diverge: 2, converge: 4 },
|
|
31
|
+
engineering: { affect: 10, think: 3, diverge: 4, converge: 2 },
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Budget elasticity per scenario and mode (spec section 9.6).
|
|
35
|
+
*/
|
|
36
|
+
export const ElasticityTable = {
|
|
37
|
+
chat: { affect: "low", think: "low", diverge: "medium", converge: "low" },
|
|
38
|
+
writing: { affect: "low", think: "medium", diverge: "high", converge: "medium" },
|
|
39
|
+
office: { affect: "low", think: "medium", diverge: "low", converge: "medium" },
|
|
40
|
+
research: { affect: "low", think: "high", diverge: "high", converge: "medium" },
|
|
41
|
+
engineering: { affect: "low", think: "high", diverge: "medium", converge: "high" },
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Escalation-trigger sensitivity (spec section 9.7).
|
|
45
|
+
*/
|
|
46
|
+
export const SensitivityTable = {
|
|
47
|
+
chat: { affect: "very-low", think: "low", diverge: "low", converge: "low" },
|
|
48
|
+
writing: { affect: "low", think: "medium", diverge: "low", converge: "medium" },
|
|
49
|
+
office: { affect: "low", think: "medium", diverge: "medium", converge: "medium" },
|
|
50
|
+
research: { affect: "medium", think: "high", diverge: "medium", converge: "high" },
|
|
51
|
+
engineering: { affect: "medium", think: "high", diverge: "medium", converge: "high" },
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Which perspectives a scenario activates by default.
|
|
55
|
+
*/
|
|
56
|
+
export const PerspectiveActivationTable = {
|
|
57
|
+
chat: {
|
|
58
|
+
default: ["customer-service"],
|
|
59
|
+
onDemand: ["marketing"],
|
|
60
|
+
dormant: ["strategy", "technology", "supervisory", "board"],
|
|
61
|
+
note: "Market research is rare in chat and stays dormant most of the time.",
|
|
62
|
+
},
|
|
63
|
+
writing: {
|
|
64
|
+
default: ["customer-service", "writing"],
|
|
65
|
+
onDemand: ["marketing", "strategy"],
|
|
66
|
+
dormant: ["technology", "supervisory"],
|
|
67
|
+
},
|
|
68
|
+
office: {
|
|
69
|
+
default: ["customer-service", "operations"],
|
|
70
|
+
onDemand: ["finance", "legal"],
|
|
71
|
+
dormant: ["strategy", "technology", "marketing"],
|
|
72
|
+
},
|
|
73
|
+
research: {
|
|
74
|
+
default: ["customer-service", "strategy", "marketing"],
|
|
75
|
+
onDemand: ["technology", "supervisory"],
|
|
76
|
+
dormant: ["operations"],
|
|
77
|
+
},
|
|
78
|
+
engineering: {
|
|
79
|
+
default: ["customer-service", "technology", "operations"],
|
|
80
|
+
onDemand: ["legal", "supervisory", "strategy"],
|
|
81
|
+
dormant: ["marketing"],
|
|
82
|
+
note: "Marketing is dormant but can be pulled in for user-facing impact review.",
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
export const ModeAdjustments = {
|
|
86
|
+
affect: {
|
|
87
|
+
focusBias: "narrow",
|
|
88
|
+
focusDelta: 0,
|
|
89
|
+
revisitMultiplier: 1,
|
|
90
|
+
elasticityBias: 0,
|
|
91
|
+
gateBias: -1,
|
|
92
|
+
note: "Focus on emotional signals and relationship maintenance; loosen the gate, keep behaviour conservative.",
|
|
93
|
+
},
|
|
94
|
+
think: {
|
|
95
|
+
focusBias: "neutral",
|
|
96
|
+
focusDelta: 0,
|
|
97
|
+
revisitMultiplier: 1,
|
|
98
|
+
elasticityBias: 0,
|
|
99
|
+
gateBias: 1,
|
|
100
|
+
note: "Focus on the evidence chain and causal structure; raise the check frequency.",
|
|
101
|
+
},
|
|
102
|
+
diverge: {
|
|
103
|
+
focusBias: "broad",
|
|
104
|
+
focusDelta: 2,
|
|
105
|
+
revisitMultiplier: 0.5,
|
|
106
|
+
elasticityBias: 1,
|
|
107
|
+
gateBias: 0,
|
|
108
|
+
note: "Widen the focus set, revisit ignored items twice as often, allow more budget slack.",
|
|
109
|
+
},
|
|
110
|
+
converge: {
|
|
111
|
+
focusBias: "narrow",
|
|
112
|
+
focusDelta: -2,
|
|
113
|
+
revisitMultiplier: 1.5,
|
|
114
|
+
elasticityBias: -1,
|
|
115
|
+
gateBias: 0,
|
|
116
|
+
note: "Shrink the focus to the candidate set, tighten the budget, make escalation triggers more sensitive.",
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
const ElasticityRank = { low: 0, medium: 1, high: 2 };
|
|
120
|
+
const GateStrictnessByScenario = {
|
|
121
|
+
chat: "loose",
|
|
122
|
+
writing: "medium",
|
|
123
|
+
office: "medium",
|
|
124
|
+
research: "medium-strict",
|
|
125
|
+
engineering: "strict",
|
|
126
|
+
};
|
|
127
|
+
const ActiveThreshold = 0.15;
|
|
128
|
+
/**
|
|
129
|
+
* Validate a scenario id at runtime; unknown values fail closed.
|
|
130
|
+
*/
|
|
131
|
+
export const requireScenario = (value) => {
|
|
132
|
+
if (!ScenarioIds.includes(value)) {
|
|
133
|
+
throw new GovernanceError("invalid-scenario", `${value} is not a canonical scenario`);
|
|
134
|
+
}
|
|
135
|
+
return value;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Normalize a partial weight vector onto the mode simplex.
|
|
139
|
+
*
|
|
140
|
+
* Negative, non-finite and all-zero vectors are rejected: a manifest without a
|
|
141
|
+
* mode is not a valid manifest.
|
|
142
|
+
*/
|
|
143
|
+
export const normalizeModeWeights = (input) => {
|
|
144
|
+
const result = { affect: 0, think: 0, diverge: 0, converge: 0 };
|
|
145
|
+
let total = 0;
|
|
146
|
+
for (let index = 0; index < ModeIds.length; index += 1) {
|
|
147
|
+
const mode = ModeIds[index];
|
|
148
|
+
const raw = input[mode] ?? 0;
|
|
149
|
+
if (!Number.isFinite(raw) || raw < 0) {
|
|
150
|
+
throw new GovernanceError("invalid-mode-weights", `${mode} must be a finite non-negative number`);
|
|
151
|
+
}
|
|
152
|
+
result[mode] = raw;
|
|
153
|
+
total += raw;
|
|
154
|
+
}
|
|
155
|
+
if (total <= 0) {
|
|
156
|
+
throw new GovernanceError("invalid-mode-weights", "at least one mode weight must be positive");
|
|
157
|
+
}
|
|
158
|
+
for (let index = 0; index < ModeIds.length; index += 1) {
|
|
159
|
+
const mode = ModeIds[index];
|
|
160
|
+
result[mode] = result[mode] / total;
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Modes sorted by weight, descending; ties keep the canonical order.
|
|
166
|
+
*/
|
|
167
|
+
export const rankModes = (weights) => {
|
|
168
|
+
const ranked = [...ModeIds];
|
|
169
|
+
ranked.sort((left, right) => weights[right] - weights[left] || ModeIds.indexOf(left) - ModeIds.indexOf(right));
|
|
170
|
+
return ranked;
|
|
171
|
+
};
|
|
172
|
+
export const dominantMode = (weights) => rankModes(weights)[0];
|
|
173
|
+
/**
|
|
174
|
+
* Modes receiving at least 15% of attention. One mode always qualifies
|
|
175
|
+
* because the vector sums to 1.
|
|
176
|
+
*/
|
|
177
|
+
export const activeModes = (weights, threshold = ActiveThreshold) => {
|
|
178
|
+
const active = ModeIds.filter((mode) => weights[mode] >= threshold);
|
|
179
|
+
return active.length === 0 ? [dominantMode(weights)] : active;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Strictest floor across the active modes: a mixed task inherits the hardest
|
|
183
|
+
* evidence demand, never the easiest.
|
|
184
|
+
*/
|
|
185
|
+
export const evidenceFloorFor = (scenario, weights) => {
|
|
186
|
+
const modes = activeModes(weights);
|
|
187
|
+
let strictest = "F3";
|
|
188
|
+
for (let index = 0; index < modes.length; index += 1) {
|
|
189
|
+
const floor = EvidenceFloorTable[scenario][modes[index]];
|
|
190
|
+
if (FloorRank[floor] < FloorRank[strictest]) {
|
|
191
|
+
strictest = floor;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return strictest;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Revisit cadence for ignored items: the most frequent cadence among active
|
|
198
|
+
* modes, so a divergence-heavy mix does not let ignored items go stale.
|
|
199
|
+
*/
|
|
200
|
+
export const revisitIntervalFor = (scenario, weights) => {
|
|
201
|
+
const modes = activeModes(weights);
|
|
202
|
+
let interval = Number.POSITIVE_INFINITY;
|
|
203
|
+
for (let index = 0; index < modes.length; index += 1) {
|
|
204
|
+
interval = Math.min(interval, RevisitIntervalTable[scenario][modes[index]]);
|
|
205
|
+
}
|
|
206
|
+
return Math.max(2, Number.isFinite(interval) ? interval : 10);
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Budget elasticity: the most restrictive active mode wins, unless a mode
|
|
210
|
+
* explicitly raises it and no other mode forbids it. Safety-first by design.
|
|
211
|
+
*/
|
|
212
|
+
export const elasticityFor = (scenario, weights) => {
|
|
213
|
+
const modes = activeModes(weights);
|
|
214
|
+
let elasticity = "high";
|
|
215
|
+
for (let index = 0; index < modes.length; index += 1) {
|
|
216
|
+
const candidate = ElasticityTable[scenario][modes[index]];
|
|
217
|
+
if (ElasticityRank[candidate] < ElasticityRank[elasticity]) {
|
|
218
|
+
elasticity = candidate;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return elasticity;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Escalation sensitivity: the most sensitive active mode wins.
|
|
225
|
+
*/
|
|
226
|
+
export const sensitivityFor = (scenario, weights) => {
|
|
227
|
+
const modes = activeModes(weights);
|
|
228
|
+
let sensitivity = "very-low";
|
|
229
|
+
for (let index = 0; index < modes.length; index += 1) {
|
|
230
|
+
const candidate = SensitivityTable[scenario][modes[index]];
|
|
231
|
+
if (SensitivityRank[candidate] > SensitivityRank[sensitivity]) {
|
|
232
|
+
sensitivity = candidate;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return sensitivity;
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Focus-set size: divergence widens it, convergence shrinks it (spec 9.2).
|
|
239
|
+
*/
|
|
240
|
+
export const focusLimitFor = (weights) => {
|
|
241
|
+
const raw = 3 + Math.round(4 * weights.diverge) - Math.round(2 * weights.converge);
|
|
242
|
+
return Math.max(1, Math.min(9, raw));
|
|
243
|
+
};
|
|
244
|
+
export const gateStrictnessFor = (scenario) => GateStrictnessByScenario[scenario];
|
|
245
|
+
export const resolveScenarioModes = (scenario, override) => {
|
|
246
|
+
const checked = requireScenario(scenario);
|
|
247
|
+
const modes = override === (void 0) ? { ...DefaultModeWeights[checked] } : normalizeModeWeights(override);
|
|
248
|
+
const ranked = rankModes(modes);
|
|
249
|
+
const floor = evidenceFloorFor(checked, modes);
|
|
250
|
+
const plan = {
|
|
251
|
+
scenario: checked,
|
|
252
|
+
modes,
|
|
253
|
+
dominant: ranked[0],
|
|
254
|
+
secondary: ranked[1],
|
|
255
|
+
active: activeModes(modes),
|
|
256
|
+
evidenceFloor: floor,
|
|
257
|
+
requiredTier: FloorTier[floor],
|
|
258
|
+
revisitEvery: revisitIntervalFor(checked, modes),
|
|
259
|
+
elasticity: elasticityFor(checked, modes),
|
|
260
|
+
sensitivity: sensitivityFor(checked, modes),
|
|
261
|
+
gateStrictness: gateStrictnessFor(checked),
|
|
262
|
+
focusLimit: focusLimitFor(modes),
|
|
263
|
+
rationale: `${checked} -> ${ranked
|
|
264
|
+
.slice(0, 2)
|
|
265
|
+
.map((mode) => `${mode} ${modes[mode].toFixed(2)}`)
|
|
266
|
+
.join(" + ")}; floor ${floor} (${FloorTier[floor]}), revisit every ${revisitIntervalFor(checked, modes)} frames, elasticity ${elasticityFor(checked, modes)}`,
|
|
267
|
+
};
|
|
268
|
+
return plan;
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* Active-mode adjustments, used by the manifest deriver to explain itself.
|
|
272
|
+
*/
|
|
273
|
+
export const modeAdjustments = (weights) => {
|
|
274
|
+
const active = activeModes(weights);
|
|
275
|
+
return active.map((mode) => ({ mode, weight: weights[mode], adjustment: ModeAdjustments[mode] }));
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* Largest single-dimension drift between two weight vectors.
|
|
279
|
+
*/
|
|
280
|
+
export const modeDrift = (from, to) => {
|
|
281
|
+
let drift = 0;
|
|
282
|
+
for (let index = 0; index < ModeIds.length; index += 1) {
|
|
283
|
+
const mode = ModeIds[index];
|
|
284
|
+
drift = Math.max(drift, Math.abs(from[mode] - to[mode]));
|
|
285
|
+
}
|
|
286
|
+
return drift;
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* Mode changes above 0.15 need the general manager's approval (spec 9.3).
|
|
290
|
+
*/
|
|
291
|
+
export const driftRequiresApproval = (from, to) => modeDrift(from, to) > 0.15 + 1e-9;
|
|
292
|
+
/**
|
|
293
|
+
* A scenario change always re-derives the manifest; it is never a patch.
|
|
294
|
+
*/
|
|
295
|
+
export const scenarioChangeRequiresRederive = (from, to) => from !== to;
|
|
296
|
+
/**
|
|
297
|
+
* Bridge: the five canonical scenarios all exist as legacy scenario kinds.
|
|
298
|
+
*/
|
|
299
|
+
export const legacyScenarioMix = (scenario) => {
|
|
300
|
+
const mix = {};
|
|
301
|
+
mix[scenario] = 1;
|
|
302
|
+
return mix;
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* Bridge: map a legacy eight-kind mix onto its dominant canonical scenario.
|
|
306
|
+
*/
|
|
307
|
+
export const canonicalScenarioOf = (mix) => {
|
|
308
|
+
const legacy = mix;
|
|
309
|
+
const order = ["chat", "writing", "office", "collaboration", "investigation", "research", "engineering", "iteration"];
|
|
310
|
+
let best = "chat";
|
|
311
|
+
let bestWeight = 0;
|
|
312
|
+
for (let index = 0; index < order.length; index += 1) {
|
|
313
|
+
const kind = order[index];
|
|
314
|
+
const weight = legacy[kind] ?? 0;
|
|
315
|
+
if (weight > bestWeight) {
|
|
316
|
+
best = kind;
|
|
317
|
+
bestWeight = weight;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (bestWeight <= 0) {
|
|
321
|
+
throw new GovernanceError("invalid-scenario", "a scenario mix must contain at least one positive weight");
|
|
322
|
+
}
|
|
323
|
+
return scenarioOfLegacy(best);
|
|
324
|
+
};
|
|
325
|
+
/**
|
|
326
|
+
* Bridge: collapse the three scenario kinds that have no canonical peer.
|
|
327
|
+
*/
|
|
328
|
+
export const scenarioOfLegacy = (kind) => {
|
|
329
|
+
switch (kind) {
|
|
330
|
+
case "collaboration":
|
|
331
|
+
return "office";
|
|
332
|
+
case "investigation":
|
|
333
|
+
return "research";
|
|
334
|
+
case "iteration":
|
|
335
|
+
return "engineering";
|
|
336
|
+
default:
|
|
337
|
+
return kind;
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
/**
|
|
341
|
+
* Bridge: the legacy interaction vocabulary uses `inspire` where governance
|
|
342
|
+
* says `diverge`.
|
|
343
|
+
*/
|
|
344
|
+
export const legacyInteractionMix = (weights) => {
|
|
345
|
+
const mapping = { affect: "affect", think: "think", diverge: "inspire", converge: "converge" };
|
|
346
|
+
const mix = {};
|
|
347
|
+
for (let index = 0; index < ModeIds.length; index += 1) {
|
|
348
|
+
const mode = ModeIds[index];
|
|
349
|
+
mix[mapping[mode]] = weights[mode];
|
|
350
|
+
}
|
|
351
|
+
return mix;
|
|
352
|
+
};
|
|
353
|
+
/**
|
|
354
|
+
* Bridge: derive governance modes from a legacy interaction mix. Missing
|
|
355
|
+
* `orchestrate` weight is folded into `converge`, the planning mode.
|
|
356
|
+
*/
|
|
357
|
+
export const modesFromLegacyInteraction = (mix) => {
|
|
358
|
+
const orchestrate = mix.orchestrate ?? 0;
|
|
359
|
+
return normalizeModeWeights({
|
|
360
|
+
affect: mix.affect ?? 0,
|
|
361
|
+
think: mix.think ?? 0,
|
|
362
|
+
diverge: mix.inspire ?? 0,
|
|
363
|
+
converge: (mix.converge ?? 0) + orchestrate,
|
|
364
|
+
});
|
|
365
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The perspective registry (spec section 4, section 12.1).
|
|
3
|
+
*
|
|
4
|
+
* A perspective is a governed attention stance with a manifest, a budget and
|
|
5
|
+
* an approval role. The registry is deliberately data-only: the manifest,
|
|
6
|
+
* credential and workflow modules read it instead of hard-coding a role name.
|
|
7
|
+
*
|
|
8
|
+
* Finance, human resources and administration are rule modules or
|
|
9
|
+
* infrastructure, not switchable perspectives; they remain addressable so
|
|
10
|
+
* their approval and accounting duties can be expressed.
|
|
11
|
+
*/
|
|
12
|
+
import type { Activation, ApprovalSubject, PerspectiveId, PerspectiveLayer, ScenarioId } from "./types.js";
|
|
13
|
+
import type { ScenarioPerspectives } from "./matrix.js";
|
|
14
|
+
/**
|
|
15
|
+
* One registry row.
|
|
16
|
+
*/
|
|
17
|
+
export interface PerspectiveDefinition {
|
|
18
|
+
id: PerspectiveId;
|
|
19
|
+
labelZh: string;
|
|
20
|
+
labelEn: string;
|
|
21
|
+
layer: PerspectiveLayer;
|
|
22
|
+
/**
|
|
23
|
+
* What this perspective attends to when its manifest is loaded.
|
|
24
|
+
*/
|
|
25
|
+
focus: string[];
|
|
26
|
+
/**
|
|
27
|
+
* Activation cadence in prose; the scenario table decides per task.
|
|
28
|
+
*/
|
|
29
|
+
frequency: string;
|
|
30
|
+
switchable: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* May this perspective be the target of a same-level switch credential?
|
|
33
|
+
* Strategic perspectives require the escalation path instead.
|
|
34
|
+
*/
|
|
35
|
+
directSwitch: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* May this perspective counter-sign a switch credential?
|
|
38
|
+
*/
|
|
39
|
+
signsCredentials: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Approval subjects this perspective owns.
|
|
42
|
+
*/
|
|
43
|
+
approve: ApprovalSubject[];
|
|
44
|
+
/**
|
|
45
|
+
* True for the independent evidence audit path.
|
|
46
|
+
*/
|
|
47
|
+
independentAudit: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The canonical registry. Order follows the governance template.
|
|
51
|
+
*/
|
|
52
|
+
export declare const PerspectiveRegistry: Record<PerspectiveId, PerspectiveDefinition>;
|
|
53
|
+
/**
|
|
54
|
+
* The standing perspectives of section 12.1 (the writing desk is a
|
|
55
|
+
* scenario-specific view and is excluded from the standing count).
|
|
56
|
+
*/
|
|
57
|
+
export declare const StandingPerspectives: readonly PerspectiveId[];
|
|
58
|
+
/**
|
|
59
|
+
* Look up a perspective, failing closed for unknown ids.
|
|
60
|
+
*/
|
|
61
|
+
export declare const perspective: (id: string) => PerspectiveDefinition;
|
|
62
|
+
export declare const isKnownPerspective: (id: string) => id is PerspectiveId;
|
|
63
|
+
/**
|
|
64
|
+
* Rule modules and infrastructure are not switchable perspectives.
|
|
65
|
+
*/
|
|
66
|
+
export declare const isRuleModule: (id: PerspectiveId) => boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Strategic perspectives are reached through escalation, never a same-level
|
|
69
|
+
* switch credential.
|
|
70
|
+
*/
|
|
71
|
+
export declare const requiresEscalation: (id: PerspectiveId) => boolean;
|
|
72
|
+
export declare const canApprove: (id: PerspectiveId, subject: ApprovalSubject) => boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Who may approve a subject, in registry order (used for routing refusals).
|
|
75
|
+
*/
|
|
76
|
+
export declare const approversOf: (subject: ApprovalSubject) => PerspectiveId[];
|
|
77
|
+
/**
|
|
78
|
+
* A same-level switch credential is issued by the general manager to a
|
|
79
|
+
* non-strategic, directly switchable perspective.
|
|
80
|
+
*/
|
|
81
|
+
export declare const canIssueCredential: (from: PerspectiveId, to: PerspectiveId) => boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Which strategic target an escalation type may reach.
|
|
84
|
+
*/
|
|
85
|
+
export declare const escalationTarget: (type: "audit" | "strategy" | "final" | "compliance") => PerspectiveId;
|
|
86
|
+
/**
|
|
87
|
+
* Scenario activation for one perspective (spec section 9.8).
|
|
88
|
+
*/
|
|
89
|
+
export declare const activationFor: (id: PerspectiveId, scenario: ScenarioId) => Activation;
|
|
90
|
+
/**
|
|
91
|
+
* The activation plan for a scenario, with copies so callers cannot mutate the
|
|
92
|
+
* table.
|
|
93
|
+
*/
|
|
94
|
+
export declare const perspectivesForScenario: (scenario: ScenarioId) => ScenarioPerspectives;
|
|
95
|
+
/**
|
|
96
|
+
* Registry self-check; used by checks and on first import in development.
|
|
97
|
+
*/
|
|
98
|
+
export declare const validatePerspectiveRegistry: () => string[];
|