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,241 @@
|
|
|
1
|
+
import { generateSigningKey } from "../manifest/sign.js";
|
|
2
|
+
import { canonical } from "../semantic/canonical.js";
|
|
3
|
+
import { GovernanceError } from "./types.js";
|
|
4
|
+
const Encoder = new TextEncoder();
|
|
5
|
+
const toBase64Url = (bytes) => {
|
|
6
|
+
const view = new Uint8Array(bytes);
|
|
7
|
+
let binary = "";
|
|
8
|
+
for (let index = 0; index < view.length; index += 1) {
|
|
9
|
+
binary += String.fromCharCode(view[index]);
|
|
10
|
+
}
|
|
11
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
12
|
+
};
|
|
13
|
+
const fromBase64Url = (text) => {
|
|
14
|
+
const padded = text.replace(/-/g, "+").replace(/_/g, "/");
|
|
15
|
+
const pad = padded.length % 4 ? "=".repeat(4 - (padded.length % 4)) : "";
|
|
16
|
+
const binary = atob(padded + pad);
|
|
17
|
+
return Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Generic canonical-value signatures for transport envelopes and audit
|
|
21
|
+
* checkpoints. The governance-specific functions below bind a digest to a
|
|
22
|
+
* subject; these helpers only sign the canonical JSON of `value`.
|
|
23
|
+
*/
|
|
24
|
+
export const signCanonicalValue = async (value, key) => {
|
|
25
|
+
const signature = await crypto.subtle.sign("Ed25519", key.privateKey, Encoder.encode(canonical(value)));
|
|
26
|
+
return toBase64Url(signature);
|
|
27
|
+
};
|
|
28
|
+
export const verifyCanonicalValue = async (value, signature, publicKey) => crypto.subtle.verify("Ed25519", publicKey, fromBase64Url(signature), Encoder.encode(canonical(value)));
|
|
29
|
+
export class GovernanceKeyring {
|
|
30
|
+
keys = new Map();
|
|
31
|
+
revoked = new Set();
|
|
32
|
+
revokedKids = new Set();
|
|
33
|
+
onEvent;
|
|
34
|
+
constructor(options = {}) {
|
|
35
|
+
this.onEvent = options.onEvent;
|
|
36
|
+
}
|
|
37
|
+
emit(action, signer, at, kid) {
|
|
38
|
+
this.onEvent?.({
|
|
39
|
+
action,
|
|
40
|
+
signer,
|
|
41
|
+
...(kid === (void 0) ? {} : { kid }),
|
|
42
|
+
at,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
add(signer, publicKey, record = {}) {
|
|
46
|
+
const existing = this.keys.get(signer) ?? [];
|
|
47
|
+
existing.push({
|
|
48
|
+
key: publicKey,
|
|
49
|
+
...(record.kid === (void 0) ? {} : { kid: record.kid }),
|
|
50
|
+
...(record.at === (void 0) ? {} : { addedAt: record.at }),
|
|
51
|
+
...(record.retiresAt === (void 0) ? {} : { retiresAt: record.retiresAt }),
|
|
52
|
+
});
|
|
53
|
+
this.keys.set(signer, existing);
|
|
54
|
+
this.emit("add", signer, record.at ?? Date.now(), record.kid);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Add a new key and retire the previous ones after the overlap window.
|
|
58
|
+
*/
|
|
59
|
+
rotate(signer, publicKey, options) {
|
|
60
|
+
const overlapMs = Math.max(0, options.overlapMs ?? 0);
|
|
61
|
+
const existing = this.keys.get(signer) ?? [];
|
|
62
|
+
for (let index = 0; index < existing.length; index += 1) {
|
|
63
|
+
if (existing[index].retiresAt === (void 0)) {
|
|
64
|
+
existing[index].retiresAt = options.at + overlapMs;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
existing.push({
|
|
68
|
+
key: publicKey,
|
|
69
|
+
...(options.kid === (void 0) ? {} : { kid: options.kid }),
|
|
70
|
+
addedAt: options.at,
|
|
71
|
+
});
|
|
72
|
+
this.keys.set(signer, existing);
|
|
73
|
+
this.emit("rotate", signer, options.at, options.kid);
|
|
74
|
+
}
|
|
75
|
+
revoke(signer) {
|
|
76
|
+
this.revoked.add(signer);
|
|
77
|
+
this.emit("revoke", signer, Date.now());
|
|
78
|
+
}
|
|
79
|
+
revokeKid(signer, kid) {
|
|
80
|
+
this.revokedKids.add(`${signer}#${kid}`);
|
|
81
|
+
this.emit("revoke-kid", signer, Date.now(), kid);
|
|
82
|
+
}
|
|
83
|
+
prune(at) {
|
|
84
|
+
const entries = [...this.keys.entries()];
|
|
85
|
+
for (let index = 0; index < entries.length; index += 1) {
|
|
86
|
+
const signer = entries[index][0];
|
|
87
|
+
const records = entries[index][1];
|
|
88
|
+
this.keys.set(signer, records.filter((record) => record.retiresAt === (void 0) || record.retiresAt > at));
|
|
89
|
+
}
|
|
90
|
+
this.emit("prune", "", at);
|
|
91
|
+
}
|
|
92
|
+
candidates(signer, kid, at = Date.now()) {
|
|
93
|
+
if (this.revoked.has(signer)) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
const records = (this.keys.get(signer) ?? []).filter((record) => (record.retiresAt === (void 0) || record.retiresAt > at) && !this.revokedKids.has(`${signer}#${record.kid ?? ""}`));
|
|
97
|
+
if (kid !== (void 0)) {
|
|
98
|
+
const matching = records.filter((record) => record.kid === kid);
|
|
99
|
+
if (matching.length > 0) {
|
|
100
|
+
return matching.map((record) => record.key);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return records.map((record) => record.key);
|
|
104
|
+
}
|
|
105
|
+
get(signer, kid, at = Date.now()) {
|
|
106
|
+
return this.candidates(signer, kid, at)[0];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export const generateGovernanceSigners = async (signers, kidPrefix = "gov") => {
|
|
110
|
+
const result = [];
|
|
111
|
+
for (let index = 0; index < signers.length; index += 1) {
|
|
112
|
+
const signer = signers[index];
|
|
113
|
+
result.push({ signer, key: await generateSigningKey(`${kidPrefix}.${signer}`) });
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
};
|
|
117
|
+
const signingBytes = (input) => Encoder.encode(canonical({
|
|
118
|
+
signer: input.signer,
|
|
119
|
+
subject: input.subject,
|
|
120
|
+
subjectId: input.subjectId,
|
|
121
|
+
subjectVersion: input.subjectVersion ?? null,
|
|
122
|
+
digest: input.digest,
|
|
123
|
+
}));
|
|
124
|
+
export const signGovernanceDigest = async (input) => {
|
|
125
|
+
const signature = await crypto.subtle.sign("Ed25519", input.signer.key.privateKey, signingBytes({
|
|
126
|
+
signer: input.signer.signer,
|
|
127
|
+
subject: input.subject,
|
|
128
|
+
subjectId: input.subjectId,
|
|
129
|
+
...(input.subjectVersion === (void 0) ? {} : { subjectVersion: input.subjectVersion }),
|
|
130
|
+
digest: input.digest,
|
|
131
|
+
}));
|
|
132
|
+
return {
|
|
133
|
+
signer: input.signer.signer,
|
|
134
|
+
kid: input.signer.key.kid,
|
|
135
|
+
alg: "ed25519",
|
|
136
|
+
sig: toBase64Url(signature),
|
|
137
|
+
digest: input.digest,
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
export const verifyGovernanceSignature = async (input) => {
|
|
141
|
+
if (input.signature.alg !== "ed25519") {
|
|
142
|
+
return { ok: false, reasons: [`unsupported algorithm ${input.signature.alg}`] };
|
|
143
|
+
}
|
|
144
|
+
if (input.signature.digest !== input.digest) {
|
|
145
|
+
return { ok: false, reasons: ["signature covers a different digest"] };
|
|
146
|
+
}
|
|
147
|
+
const candidates = input.keyring.candidates(input.signature.signer, input.signature.kid);
|
|
148
|
+
if (candidates.length === 0) {
|
|
149
|
+
return { ok: false, reasons: [`unknown or revoked signer ${input.signature.signer}`] };
|
|
150
|
+
}
|
|
151
|
+
for (let index = 0; index < candidates.length; index += 1) {
|
|
152
|
+
const valid = await crypto.subtle.verify("Ed25519", candidates[index], fromBase64Url(input.signature.sig), signingBytes({
|
|
153
|
+
signer: input.signature.signer,
|
|
154
|
+
subject: input.subject,
|
|
155
|
+
subjectId: input.subjectId,
|
|
156
|
+
...(input.subjectVersion === (void 0) ? {} : { subjectVersion: input.subjectVersion }),
|
|
157
|
+
digest: input.digest,
|
|
158
|
+
}));
|
|
159
|
+
if (valid) {
|
|
160
|
+
return { ok: true, reasons: [] };
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return { ok: false, reasons: ["signature does not verify"] };
|
|
164
|
+
};
|
|
165
|
+
export const signGovernanceObject = async (input) => {
|
|
166
|
+
if (input.signers.length === 0) {
|
|
167
|
+
throw new GovernanceError("manifest-unsigned", "at least one cryptographic signer is required");
|
|
168
|
+
}
|
|
169
|
+
const seen = new Set();
|
|
170
|
+
const signatures = [];
|
|
171
|
+
for (let index = 0; index < input.signers.length; index += 1) {
|
|
172
|
+
const signer = input.signers[index];
|
|
173
|
+
if (seen.has(signer.signer)) {
|
|
174
|
+
throw new GovernanceError("manifest-unsigned", `${signer.signer} signed twice`);
|
|
175
|
+
}
|
|
176
|
+
seen.add(signer.signer);
|
|
177
|
+
signatures.push(await signGovernanceDigest({
|
|
178
|
+
signer,
|
|
179
|
+
subject: input.subject,
|
|
180
|
+
subjectId: input.subjectId,
|
|
181
|
+
...(input.subjectVersion === (void 0) ? {} : { subjectVersion: input.subjectVersion }),
|
|
182
|
+
digest: input.digest,
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
kind: "governance-signatures",
|
|
187
|
+
subject: input.subject,
|
|
188
|
+
subjectId: input.subjectId,
|
|
189
|
+
...(input.subjectVersion === (void 0) ? {} : { subjectVersion: input.subjectVersion }),
|
|
190
|
+
subjectDigest: input.digest,
|
|
191
|
+
signatures,
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
export const verifyGovernanceBundle = async (input) => {
|
|
195
|
+
const reasons = [];
|
|
196
|
+
if (input.bundle.kind !== "governance-signatures") {
|
|
197
|
+
reasons.push("not a governance signature bundle");
|
|
198
|
+
}
|
|
199
|
+
if (input.bundle.subject !== input.expected.subject) {
|
|
200
|
+
reasons.push(`subject mismatch: ${input.bundle.subject}`);
|
|
201
|
+
}
|
|
202
|
+
if (input.bundle.subjectId !== input.expected.subjectId) {
|
|
203
|
+
reasons.push(`subject id mismatch: ${input.bundle.subjectId}`);
|
|
204
|
+
}
|
|
205
|
+
if (input.bundle.subjectVersion !== input.expected.subjectVersion) {
|
|
206
|
+
reasons.push("subject version mismatch");
|
|
207
|
+
}
|
|
208
|
+
if (input.bundle.subjectDigest !== input.expected.digest) {
|
|
209
|
+
reasons.push("bundle digest does not match the subject");
|
|
210
|
+
}
|
|
211
|
+
if (input.bundle.signatures.length === 0) {
|
|
212
|
+
reasons.push("bundle has no signatures");
|
|
213
|
+
}
|
|
214
|
+
const seen = new Set();
|
|
215
|
+
for (let index = 0; index < input.bundle.signatures.length; index += 1) {
|
|
216
|
+
const signature = input.bundle.signatures[index];
|
|
217
|
+
if (seen.has(signature.signer)) {
|
|
218
|
+
reasons.push(`${signature.signer} signed twice`);
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
seen.add(signature.signer);
|
|
222
|
+
const verified = await verifyGovernanceSignature({
|
|
223
|
+
signature,
|
|
224
|
+
subject: input.expected.subject,
|
|
225
|
+
subjectId: input.expected.subjectId,
|
|
226
|
+
...(input.expected.subjectVersion === (void 0) ? {} : { subjectVersion: input.expected.subjectVersion }),
|
|
227
|
+
digest: input.expected.digest,
|
|
228
|
+
keyring: input.keyring,
|
|
229
|
+
});
|
|
230
|
+
reasons.push(...verified.reasons);
|
|
231
|
+
}
|
|
232
|
+
if (input.requiredSigners !== (void 0)) {
|
|
233
|
+
for (let index = 0; index < input.requiredSigners.length; index += 1) {
|
|
234
|
+
const required = input.requiredSigners[index];
|
|
235
|
+
if (!seen.has(required)) {
|
|
236
|
+
reasons.push(`missing required signer ${required}`);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return { ok: reasons.length === 0, reasons };
|
|
241
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { AppendSink } from "../storage/appendLog.js";
|
|
2
|
+
import type { AttentionManifest } from "./attentionManifest.js";
|
|
3
|
+
import type { BoardReceipt } from "./context.js";
|
|
4
|
+
import type { SwitchCredential } from "./credential.js";
|
|
5
|
+
export type StoredGovernanceKind = "manifest" | "credential" | "receipt";
|
|
6
|
+
export interface GovernanceStoreSnapshot {
|
|
7
|
+
manifests: AttentionManifest[];
|
|
8
|
+
credentials: SwitchCredential[];
|
|
9
|
+
receipts: BoardReceipt[];
|
|
10
|
+
count: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class GovernanceStore {
|
|
13
|
+
private readonly log;
|
|
14
|
+
private readonly manifests;
|
|
15
|
+
private readonly credentials;
|
|
16
|
+
private readonly receipts;
|
|
17
|
+
private constructor();
|
|
18
|
+
static open(sink: AppendSink): Promise<GovernanceStore>;
|
|
19
|
+
private replay;
|
|
20
|
+
private apply;
|
|
21
|
+
saveManifest(manifest: AttentionManifest): Promise<void>;
|
|
22
|
+
saveCredential(credential: SwitchCredential): Promise<void>;
|
|
23
|
+
saveReceipt(receipt: BoardReceipt): Promise<void>;
|
|
24
|
+
getManifest(id: string): AttentionManifest | undefined;
|
|
25
|
+
getCredential(id: string): SwitchCredential | undefined;
|
|
26
|
+
getReceipt(id: string): BoardReceipt | undefined;
|
|
27
|
+
snapshot(): GovernanceStoreSnapshot;
|
|
28
|
+
verify(): {
|
|
29
|
+
ok: boolean;
|
|
30
|
+
reasons: string[];
|
|
31
|
+
};
|
|
32
|
+
get count(): number;
|
|
33
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable store for the governance objects themselves.
|
|
3
|
+
*
|
|
4
|
+
* The audit chain records that an act happened; this store keeps the object a
|
|
5
|
+
* later process needs to resume: the latest manifest per id, credentials and
|
|
6
|
+
* board receipts. It is an append-only JSONL event log, so replaying the file
|
|
7
|
+
* reconstructs the latest state without trusting the writer's memory.
|
|
8
|
+
*/
|
|
9
|
+
import { AppendLog } from "../storage/appendLog.js";
|
|
10
|
+
import { GovernanceError } from "./types.js";
|
|
11
|
+
const isRecord = (value) => typeof (value) === "object" && value !== null && !Array.isArray(value);
|
|
12
|
+
const isStoredRecord = (value) => isRecord(value) && (value.type === "manifest" || value.type === "credential" || value.type === "receipt") && isRecord(value.value);
|
|
13
|
+
export class GovernanceStore {
|
|
14
|
+
log;
|
|
15
|
+
manifests = new Map();
|
|
16
|
+
credentials = new Map();
|
|
17
|
+
receipts = new Map();
|
|
18
|
+
constructor(log) {
|
|
19
|
+
this.log = log;
|
|
20
|
+
}
|
|
21
|
+
static async open(sink) {
|
|
22
|
+
const log = await AppendLog.open(sink);
|
|
23
|
+
const store = new GovernanceStore(log);
|
|
24
|
+
store.replay();
|
|
25
|
+
return store;
|
|
26
|
+
}
|
|
27
|
+
replay() {
|
|
28
|
+
const entries = this.log.entries();
|
|
29
|
+
for (let index = 0; index < entries.length; index += 1) {
|
|
30
|
+
const payload = entries[index].payload;
|
|
31
|
+
if (!isStoredRecord(payload)) {
|
|
32
|
+
throw new GovernanceError("registry-invalid", `entry ${index} is not a governance record`);
|
|
33
|
+
}
|
|
34
|
+
this.apply(payload);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
apply(record) {
|
|
38
|
+
if (record.type === "manifest") {
|
|
39
|
+
const value = record.value;
|
|
40
|
+
const existing = this.manifests.get(value.id);
|
|
41
|
+
if (existing === (void 0) || existing.version <= value.version) {
|
|
42
|
+
this.manifests.set(value.id, value);
|
|
43
|
+
}
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (record.type === "credential") {
|
|
47
|
+
const value = record.value;
|
|
48
|
+
this.credentials.set(value.id, value);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const value = record.value;
|
|
52
|
+
this.receipts.set(value.id, value);
|
|
53
|
+
}
|
|
54
|
+
async saveManifest(manifest) {
|
|
55
|
+
await this.log.append("event", { type: "manifest", value: manifest });
|
|
56
|
+
this.apply({ type: "manifest", value: manifest });
|
|
57
|
+
}
|
|
58
|
+
async saveCredential(credential) {
|
|
59
|
+
await this.log.append("event", { type: "credential", value: credential });
|
|
60
|
+
this.apply({ type: "credential", value: credential });
|
|
61
|
+
}
|
|
62
|
+
async saveReceipt(receipt) {
|
|
63
|
+
await this.log.append("event", { type: "receipt", value: receipt });
|
|
64
|
+
this.apply({ type: "receipt", value: receipt });
|
|
65
|
+
}
|
|
66
|
+
getManifest(id) {
|
|
67
|
+
return this.manifests.get(id);
|
|
68
|
+
}
|
|
69
|
+
getCredential(id) {
|
|
70
|
+
return this.credentials.get(id);
|
|
71
|
+
}
|
|
72
|
+
getReceipt(id) {
|
|
73
|
+
return this.receipts.get(id);
|
|
74
|
+
}
|
|
75
|
+
snapshot() {
|
|
76
|
+
return {
|
|
77
|
+
manifests: [...this.manifests.values()].map((manifest) => JSON.parse(JSON.stringify(manifest))),
|
|
78
|
+
credentials: [...this.credentials.values()].map((credential) => JSON.parse(JSON.stringify(credential))),
|
|
79
|
+
receipts: [...this.receipts.values()].map((receipt) => JSON.parse(JSON.stringify(receipt))),
|
|
80
|
+
count: this.log.count,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
verify() {
|
|
84
|
+
return this.log.verify();
|
|
85
|
+
}
|
|
86
|
+
get count() {
|
|
87
|
+
return this.log.count;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Perspective and mode switching orchestration (spec section 12).
|
|
3
|
+
*
|
|
4
|
+
* The primitives already exist: credentials, manifests, context layers and the
|
|
5
|
+
* budget. This module sequences them into the flows the description names:
|
|
6
|
+
* peer switch, downgrade, mode switch and scenario switch. It also builds the
|
|
7
|
+
* escalation plan, including the independent strategic context that must not
|
|
8
|
+
* inherit the execution reasoning chain.
|
|
9
|
+
*/
|
|
10
|
+
import type { Budget, Ref, Timestamp } from "../types/common.js";
|
|
11
|
+
import type { ApprovalGrant, BehaviorConstraints, Elasticity, EvidenceFloor, ModeWeights, PerspectiveId, ScenarioId, SignerInput } from "./types.js";
|
|
12
|
+
import type { AttentionManifest } from "./attentionManifest.js";
|
|
13
|
+
import type { BudgetBinding, RederivePatch } from "./attentionManifest.js";
|
|
14
|
+
import type { CredentialVerdict, SwitchCredential } from "./credential.js";
|
|
15
|
+
import type { ScenarioModePlan } from "./matrix.js";
|
|
16
|
+
/**
|
|
17
|
+
* The three-party approval set for a switch. HR, legal and finance each own one
|
|
18
|
+
* subject; the general manager issues.
|
|
19
|
+
*/
|
|
20
|
+
export interface SwitchApprovals {
|
|
21
|
+
generalManager: ApprovalGrant;
|
|
22
|
+
legal: ApprovalGrant;
|
|
23
|
+
finance: ApprovalGrant;
|
|
24
|
+
humanResources: ApprovalGrant;
|
|
25
|
+
}
|
|
26
|
+
export interface PeerSwitchInput {
|
|
27
|
+
/**
|
|
28
|
+
* The perspective that asked for the switch.
|
|
29
|
+
*/
|
|
30
|
+
requester: PerspectiveId;
|
|
31
|
+
to: PerspectiveId;
|
|
32
|
+
reason: string;
|
|
33
|
+
scenario: ScenarioId;
|
|
34
|
+
modes?: Partial<ModeWeights>;
|
|
35
|
+
targetManifest: AttentionManifest;
|
|
36
|
+
visibleScope: Ref[];
|
|
37
|
+
payloadRefs?: Ref[];
|
|
38
|
+
quota: Budget;
|
|
39
|
+
elasticity: Elasticity;
|
|
40
|
+
constraints: BehaviorConstraints;
|
|
41
|
+
issuedAt: Timestamp;
|
|
42
|
+
ttlMs?: number;
|
|
43
|
+
at: Timestamp;
|
|
44
|
+
approvals: SwitchApprovals;
|
|
45
|
+
signers: readonly SignerInput[];
|
|
46
|
+
}
|
|
47
|
+
export interface PeerSwitchResult {
|
|
48
|
+
credential: SwitchCredential;
|
|
49
|
+
verdict: CredentialVerdict;
|
|
50
|
+
target: AttentionManifest;
|
|
51
|
+
steps: string[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Peer switch: HR confirms the target, legal clears the scope, finance freezes
|
|
55
|
+
* the quota, the general manager issues the credential, and the target loads
|
|
56
|
+
* its own manifest after the credential verifies.
|
|
57
|
+
*/
|
|
58
|
+
export declare const planPeerSwitch: (input: PeerSwitchInput) => PeerSwitchResult;
|
|
59
|
+
export interface DowngradeInput {
|
|
60
|
+
requester: PerspectiveId;
|
|
61
|
+
/**
|
|
62
|
+
* The strategic perspective being left behind (board or supervisory).
|
|
63
|
+
*/
|
|
64
|
+
from: PerspectiveId;
|
|
65
|
+
to: PerspectiveId;
|
|
66
|
+
reason: string;
|
|
67
|
+
targetManifest: AttentionManifest;
|
|
68
|
+
visibleScope: Ref[];
|
|
69
|
+
quota: Budget;
|
|
70
|
+
elasticity: Elasticity;
|
|
71
|
+
constraints: BehaviorConstraints;
|
|
72
|
+
issuedAt: Timestamp;
|
|
73
|
+
ttlMs?: number;
|
|
74
|
+
at: Timestamp;
|
|
75
|
+
approvals: {
|
|
76
|
+
generalManager: ApprovalGrant;
|
|
77
|
+
legal: ApprovalGrant;
|
|
78
|
+
finance: ApprovalGrant;
|
|
79
|
+
humanResources: ApprovalGrant;
|
|
80
|
+
};
|
|
81
|
+
signers: readonly SignerInput[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Downgrade: the strategic layer returns authority to an execution
|
|
85
|
+
* perspective. Finance approves the budget recovery, legal approves the
|
|
86
|
+
* post-downgrade behaviour constraints, HR confirms the target is available.
|
|
87
|
+
*/
|
|
88
|
+
export declare const planDowngrade: (input: DowngradeInput) => PeerSwitchResult;
|
|
89
|
+
export interface ModeSwitchInput {
|
|
90
|
+
manifest: AttentionManifest;
|
|
91
|
+
modes: Partial<ModeWeights>;
|
|
92
|
+
by: PerspectiveId;
|
|
93
|
+
at: Timestamp;
|
|
94
|
+
signoff: SignerInput;
|
|
95
|
+
approvals?: {
|
|
96
|
+
modeWeights?: ApprovalGrant;
|
|
97
|
+
finance?: ApprovalGrant;
|
|
98
|
+
legal?: ApprovalGrant;
|
|
99
|
+
};
|
|
100
|
+
evidenceFloor?: EvidenceFloor;
|
|
101
|
+
budget?: BudgetBinding;
|
|
102
|
+
}
|
|
103
|
+
export interface ModeSwitchResult {
|
|
104
|
+
manifest: AttentionManifest;
|
|
105
|
+
drift: number;
|
|
106
|
+
approvalRequired: boolean;
|
|
107
|
+
plan: ScenarioModePlan;
|
|
108
|
+
steps: string[];
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Mode switch: update the manifest's weights, floor and elasticity without
|
|
112
|
+
* switching the perspective. Drift above 0.15 needs the general manager; an
|
|
113
|
+
* elasticity change needs finance; a floor change needs legal.
|
|
114
|
+
*/
|
|
115
|
+
export declare const switchMode: (input: ModeSwitchInput) => ModeSwitchResult;
|
|
116
|
+
export interface ScenarioSwitchInput {
|
|
117
|
+
manifest: AttentionManifest;
|
|
118
|
+
scenario: ScenarioId;
|
|
119
|
+
modes?: Partial<ModeWeights>;
|
|
120
|
+
at: Timestamp;
|
|
121
|
+
signers: readonly SignerInput[];
|
|
122
|
+
approvals: {
|
|
123
|
+
scenario: ApprovalGrant;
|
|
124
|
+
board?: ApprovalGrant;
|
|
125
|
+
finance?: ApprovalGrant;
|
|
126
|
+
legal?: ApprovalGrant;
|
|
127
|
+
};
|
|
128
|
+
patch?: Omit<RederivePatch, "scenario" | "modes">;
|
|
129
|
+
/**
|
|
130
|
+
* Set when the new scenario is entered through the escalation path.
|
|
131
|
+
*/
|
|
132
|
+
crossScenarioEscalation?: boolean;
|
|
133
|
+
}
|
|
134
|
+
export interface ScenarioSwitchResult {
|
|
135
|
+
manifest: AttentionManifest;
|
|
136
|
+
plan: ScenarioModePlan;
|
|
137
|
+
steps: string[];
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Scenario switch: re-derive the manifest (version increments, parent digest
|
|
141
|
+
* recorded) instead of patching weights. A cross-scenario escalation also needs
|
|
142
|
+
* the board.
|
|
143
|
+
*/
|
|
144
|
+
export declare const switchScenario: (input: ScenarioSwitchInput) => ScenarioSwitchResult;
|
|
145
|
+
export type EscalationKind = "audit" | "strategy" | "final" | "compliance";
|
|
146
|
+
export interface EscalationInput {
|
|
147
|
+
from: PerspectiveId;
|
|
148
|
+
kind: EscalationKind;
|
|
149
|
+
reason: string;
|
|
150
|
+
evidence: Ref[];
|
|
151
|
+
at: Timestamp;
|
|
152
|
+
goal: string;
|
|
153
|
+
strategySummary: string;
|
|
154
|
+
approvals: {
|
|
155
|
+
initiate: ApprovalGrant;
|
|
156
|
+
reserve: ApprovalGrant;
|
|
157
|
+
readiness: ApprovalGrant;
|
|
158
|
+
authorization: ApprovalGrant;
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
export interface IndependentContext {
|
|
162
|
+
goal: string;
|
|
163
|
+
strategySummary: string;
|
|
164
|
+
evidence: Ref[];
|
|
165
|
+
request: string;
|
|
166
|
+
/**
|
|
167
|
+
* Always false: the strategic layer does not inherit the execution chain.
|
|
168
|
+
*/
|
|
169
|
+
inheritsPrivateReasoning: false;
|
|
170
|
+
}
|
|
171
|
+
export interface EscalationPlan {
|
|
172
|
+
target: PerspectiveId;
|
|
173
|
+
independent: IndependentContext;
|
|
174
|
+
approvals: ApprovalGrant[];
|
|
175
|
+
authorization: string;
|
|
176
|
+
steps: string[];
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Escalation plan: the finance reserve and HR readiness gates are the same for
|
|
180
|
+
* every type; the type decides who signs the authorisation. The strategic layer
|
|
181
|
+
* receives global core, evidence refs and the request summary only.
|
|
182
|
+
*/
|
|
183
|
+
export declare const planEscalation: (input: EscalationInput) => EscalationPlan;
|