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,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared vocabulary for the attention-governance layer.
|
|
3
|
+
*
|
|
4
|
+
* The governance layer implements the nine constructs described by the
|
|
5
|
+
* Attention Manifest Protocol: the attention manifest, three-layer context,
|
|
6
|
+
* perspective registry, switch credential, Bayesian control, legal behaviour
|
|
7
|
+
* norms, three-ledger budget, scenario x interaction-mode matrix, and the
|
|
8
|
+
* seven-phase workflow with approvals.
|
|
9
|
+
*
|
|
10
|
+
* This module holds only value types, constants and the shared error. Every
|
|
11
|
+
* other governance module depends on it; it depends on none of them, which
|
|
12
|
+
* keeps the layer acyclic.
|
|
13
|
+
*/
|
|
14
|
+
import type { Budget, Digest, Id, Ref, Tier, Timestamp } from "../types/common.js";
|
|
15
|
+
export type { Budget, Digest, Id, Ref, Tier, Timestamp } from "../types/common.js";
|
|
16
|
+
/**
|
|
17
|
+
* The five canonical scenarios. They replace the earlier eight-kind mix as the
|
|
18
|
+
* governance label; `src/governance/matrix.ts` keeps an explicit adapter for
|
|
19
|
+
* the legacy kinds so context profiling still works.
|
|
20
|
+
*/
|
|
21
|
+
export type ScenarioId = "chat" | "writing" | "office" | "research" | "engineering";
|
|
22
|
+
export declare const ScenarioIds: readonly ScenarioId[];
|
|
23
|
+
/**
|
|
24
|
+
* The four interaction modes. `diverge` is the governance name for the
|
|
25
|
+
* existing `inspire` interaction mode; they are bridged, not duplicated.
|
|
26
|
+
*/
|
|
27
|
+
export type ModeId = "affect" | "think" | "diverge" | "converge";
|
|
28
|
+
export declare const ModeIds: readonly ModeId[];
|
|
29
|
+
/**
|
|
30
|
+
* A normalized weight vector: every entry is in [0, 1] and the sum is 1.
|
|
31
|
+
*/
|
|
32
|
+
export type ModeWeights = Record<ModeId, number>;
|
|
33
|
+
/**
|
|
34
|
+
* The thirteen perspectives of the governance template.
|
|
35
|
+
*
|
|
36
|
+
* Finance, human resources and administration are rule modules or
|
|
37
|
+
* infrastructure, not switchable perspectives; they are still addressable as
|
|
38
|
+
* approving or signing departments.
|
|
39
|
+
*/
|
|
40
|
+
export type PerspectiveId = "shareholders" | "board" | "supervisory" | "general-manager" | "customer-service" | "writing" | "strategy" | "human-resources" | "marketing" | "technology" | "legal" | "finance" | "administration" | "operations";
|
|
41
|
+
export declare const PerspectiveIds: readonly PerspectiveId[];
|
|
42
|
+
/**
|
|
43
|
+
* Strategic and management layers are dormant or resident; execution
|
|
44
|
+
* perspectives are activated per task; rule modules are always on.
|
|
45
|
+
*/
|
|
46
|
+
export type PerspectiveLayer = "strategic" | "management" | "execution" | "rule";
|
|
47
|
+
/**
|
|
48
|
+
* How a perspective participates in a scenario (spec section 9.8).
|
|
49
|
+
*/
|
|
50
|
+
export type Activation = "default" | "on-demand" | "dormant";
|
|
51
|
+
/**
|
|
52
|
+
* Attention budget elasticity (spec section 9.6).
|
|
53
|
+
*/
|
|
54
|
+
export type Elasticity = "low" | "medium" | "high";
|
|
55
|
+
/**
|
|
56
|
+
* Escalation trigger sensitivity (spec section 9.7).
|
|
57
|
+
*/
|
|
58
|
+
export type Sensitivity = "very-low" | "low" | "medium" | "high";
|
|
59
|
+
export declare const SensitivityRank: Record<Sensitivity, number>;
|
|
60
|
+
/**
|
|
61
|
+
* Legal gate strictness per scenario (spec section 7.3).
|
|
62
|
+
*/
|
|
63
|
+
export type GateStrictness = "loose" | "medium" | "medium-strict" | "strict";
|
|
64
|
+
/**
|
|
65
|
+
* Which ledger a budget binding or charge belongs to (spec section 8).
|
|
66
|
+
* `agent` is a sub-agent's own quota, funded by a transfer from its parent.
|
|
67
|
+
*/
|
|
68
|
+
export type LedgerScope = "global" | "perspective" | "agent" | "reserve";
|
|
69
|
+
/**
|
|
70
|
+
* Governance evidence floors use their own order (F1 strongest) so the
|
|
71
|
+
* description's "T1/T2/T3" never collides with the protocol's T0-T4 strength
|
|
72
|
+
* order. `FloorTier` maps them onto the existing tier system.
|
|
73
|
+
*/
|
|
74
|
+
export type EvidenceFloor = "F1" | "F2" | "F3";
|
|
75
|
+
export declare const EvidenceFloorIds: readonly EvidenceFloor[];
|
|
76
|
+
/**
|
|
77
|
+
* Minimum protocol tier that satisfies each governance floor.
|
|
78
|
+
*
|
|
79
|
+
* The description uses T1 as the strictest floor, while AMP's T0-T4 axis is
|
|
80
|
+
* strictly increasing in strength (T1 sourced, T2 observed, T3 tested). The
|
|
81
|
+
* mapping keeps the description's intent: F1 demands tested evidence, F2
|
|
82
|
+
* observed evidence, F3 sourced evidence.
|
|
83
|
+
*/
|
|
84
|
+
export declare const FloorTier: Record<EvidenceFloor, Tier>;
|
|
85
|
+
export declare const TierRank: Record<Tier, number>;
|
|
86
|
+
export declare const FloorRank: Record<EvidenceFloor, number>;
|
|
87
|
+
/**
|
|
88
|
+
* Elasticity limits. The specification fixes the high (auto +50%, post audit)
|
|
89
|
+
* and low (freeze beyond +20%) cases; medium is an explicit engineering
|
|
90
|
+
* choice: approval-gated up to +35% and audited afterwards.
|
|
91
|
+
*/
|
|
92
|
+
export interface ElasticityLimit {
|
|
93
|
+
/**
|
|
94
|
+
* Fraction of the cap that may be appended without an approval.
|
|
95
|
+
*/
|
|
96
|
+
autoRatio: number;
|
|
97
|
+
/**
|
|
98
|
+
* Hard ceiling; beyond it the ledger freezes.
|
|
99
|
+
*/
|
|
100
|
+
hardRatio: number;
|
|
101
|
+
/**
|
|
102
|
+
* Whether spending between cap and hardRatio needs a finance approval.
|
|
103
|
+
*/
|
|
104
|
+
requiresApproval: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Whether appended spend is settled by a post-hoc audit.
|
|
107
|
+
*/
|
|
108
|
+
postAudit: boolean;
|
|
109
|
+
}
|
|
110
|
+
export declare const ElasticityLimits: Record<Elasticity, ElasticityLimit>;
|
|
111
|
+
/**
|
|
112
|
+
* Behaviour constraints injected by the legal department into a manifest or a
|
|
113
|
+
* switch credential (spec section 7.2).
|
|
114
|
+
*/
|
|
115
|
+
export interface BehaviorConstraints {
|
|
116
|
+
allowed: string[];
|
|
117
|
+
forbidden: string[];
|
|
118
|
+
obligations: string[];
|
|
119
|
+
escalation: string[];
|
|
120
|
+
/**
|
|
121
|
+
* Evidence floor the legal department insists on, possibly stricter than
|
|
122
|
+
* the scenario x mode floor.
|
|
123
|
+
*/
|
|
124
|
+
evidence: EvidenceFloor;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* A governance sign-off. It is deliberately not a cryptographic signature:
|
|
128
|
+
* the protocol signs the digest of the object and records which department
|
|
129
|
+
* approved it, so a missing counter-signature is visible in an audit.
|
|
130
|
+
*/
|
|
131
|
+
export type SignoffRole = "issuer" | "legal" | "finance" | "board" | "human";
|
|
132
|
+
export interface Signoff {
|
|
133
|
+
role: SignoffRole;
|
|
134
|
+
by: PerspectiveId;
|
|
135
|
+
at: Timestamp;
|
|
136
|
+
digest: Digest;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* An unsigned sign-off as supplied by a caller; `issue*` fills in the digest
|
|
140
|
+
* after computing it, so a caller cannot accidentally sign the wrong body.
|
|
141
|
+
*/
|
|
142
|
+
export interface SignerInput {
|
|
143
|
+
role: SignoffRole;
|
|
144
|
+
by: PerspectiveId;
|
|
145
|
+
at: Timestamp;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* A versioned manifest reference, safe to copy between layers.
|
|
149
|
+
*/
|
|
150
|
+
export interface ManifestRef {
|
|
151
|
+
id: Id;
|
|
152
|
+
version: number;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* An escalation request carried by a receipt or a workflow record.
|
|
156
|
+
*/
|
|
157
|
+
export interface EscalationRef {
|
|
158
|
+
to: PerspectiveId;
|
|
159
|
+
reason: string;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* A verification result. Codes are stable; detail is for humans.
|
|
163
|
+
*/
|
|
164
|
+
export interface VerificationVerdict {
|
|
165
|
+
ok: boolean;
|
|
166
|
+
code?: string;
|
|
167
|
+
detail?: string;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* A credential's budget quota and elasticity.
|
|
171
|
+
*/
|
|
172
|
+
export interface CredentialBudget {
|
|
173
|
+
quota: Budget;
|
|
174
|
+
elasticity: Elasticity;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Approval subjects from the responsibility table (spec section 10).
|
|
178
|
+
*/
|
|
179
|
+
export type ApprovalSubject = "budget.initial" | "budget.allocation" | "budget.freeze" | "budget.elasticity" | "budget.top-up" | "budget.settlement" | "budget.reserve" | "budget.major-top-up" | "credential.issue" | "credential.compliance" | "manifest.derive" | "manifest.constraints" | "manifest.evidence-floor" | "manifest.focus" | "manifest.waiver" | "mode.weights" | "scenario.judgement" | "complexity.grade" | "perspective.assignment" | "perspective.routing" | "perspective.readiness" | "escalation.initiate" | "escalation.audit" | "escalation.strategic" | "escalation.final" | "strategy.version" | "capability.change" | "arbitration.major" | "audit.evidence" | "audit.behavior" | "audit.budget" | "audit.archive" | "requirement.complete" | "requirement.change" | "requirement.satisfaction" | "acceptance.criteria" | "goal.change" | "liability.attribution" | "final.ruling" | "tool.high-risk" | "board.write" | "freeze.appeal";
|
|
180
|
+
/**
|
|
181
|
+
* A recorded approval. `granted: false` is a rejection, not an absence.
|
|
182
|
+
*/
|
|
183
|
+
export interface ApprovalGrant {
|
|
184
|
+
id: Id;
|
|
185
|
+
subject: ApprovalSubject;
|
|
186
|
+
by: PerspectiveId;
|
|
187
|
+
at: Timestamp;
|
|
188
|
+
granted: boolean;
|
|
189
|
+
note?: string;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Budget arithmetic is per dimension; these are the dimensions a ledger can
|
|
193
|
+
* cap. A missing cap means "not metered on this dimension".
|
|
194
|
+
*/
|
|
195
|
+
export type BudgetDimension = "tokens" | "ms" | "calls" | "interrupts" | "money";
|
|
196
|
+
export declare const BudgetDimensions: readonly BudgetDimension[];
|
|
197
|
+
export type GovernanceCode = "invalid-scenario" | "invalid-mode-weights" | "unknown-perspective" | "manifest-expired" | "manifest-scope" | "manifest-unsigned" | "manifest-self-signed" | "manifest-version-conflict" | "manifest-rederive-required" | "approval-required" | "approval-not-permitted" | "approval-self" | "credential-incomplete" | "credential-invalid" | "credential-expired" | "credential-not-yet-valid" | "credential-tampered" | "credential-scope" | "credential-target" | "credential-revoked" | "credential-manifest" | "budget-frozen" | "budget-invalid" | "budget-frozen" | "budget-exhausted" | "budget-reserve" | "legal-frozen" | "legal-breaker" | "workflow-phase" | "workflow-step" | "workflow-artifact" | "context-denied" | "registry-invalid" | "probability-invalid";
|
|
198
|
+
/**
|
|
199
|
+
* A fail-closed governance rejection: the caller gets a code, not a silently
|
|
200
|
+
* degraded policy.
|
|
201
|
+
*/
|
|
202
|
+
export declare class GovernanceError extends Error {
|
|
203
|
+
readonly code: GovernanceCode;
|
|
204
|
+
constructor(code: GovernanceCode, detail: string);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Stable key for a Ref so scopes can be compared without object identity.
|
|
208
|
+
*/
|
|
209
|
+
export declare const refKey: (ref: Ref) => string;
|
|
210
|
+
/**
|
|
211
|
+
* A shallow read-only copy of a Budget with every dimension defaulted to zero.
|
|
212
|
+
*/
|
|
213
|
+
export declare const budgetTotals: (budget: Budget) => Required<Budget>;
|
|
214
|
+
/**
|
|
215
|
+
* Description-only digest used when a caller does not have the full object;
|
|
216
|
+
* never used for integrity checks.
|
|
217
|
+
*/
|
|
218
|
+
export declare const auditLine: (parts: readonly string[]) => string;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export const ScenarioIds = ["chat", "writing", "office", "research", "engineering"];
|
|
2
|
+
export const ModeIds = ["affect", "think", "diverge", "converge"];
|
|
3
|
+
export const PerspectiveIds = [
|
|
4
|
+
"shareholders",
|
|
5
|
+
"board",
|
|
6
|
+
"supervisory",
|
|
7
|
+
"general-manager",
|
|
8
|
+
"customer-service",
|
|
9
|
+
"writing",
|
|
10
|
+
"strategy",
|
|
11
|
+
"human-resources",
|
|
12
|
+
"marketing",
|
|
13
|
+
"technology",
|
|
14
|
+
"legal",
|
|
15
|
+
"finance",
|
|
16
|
+
"administration",
|
|
17
|
+
"operations",
|
|
18
|
+
];
|
|
19
|
+
export const SensitivityRank = { "very-low": 0, low: 1, medium: 2, high: 3 };
|
|
20
|
+
export const EvidenceFloorIds = ["F1", "F2", "F3"];
|
|
21
|
+
/**
|
|
22
|
+
* Minimum protocol tier that satisfies each governance floor.
|
|
23
|
+
*
|
|
24
|
+
* The description uses T1 as the strictest floor, while AMP's T0-T4 axis is
|
|
25
|
+
* strictly increasing in strength (T1 sourced, T2 observed, T3 tested). The
|
|
26
|
+
* mapping keeps the description's intent: F1 demands tested evidence, F2
|
|
27
|
+
* observed evidence, F3 sourced evidence.
|
|
28
|
+
*/
|
|
29
|
+
export const FloorTier = {
|
|
30
|
+
F1: "T3",
|
|
31
|
+
F2: "T2",
|
|
32
|
+
F3: "T1",
|
|
33
|
+
};
|
|
34
|
+
export const TierRank = { T0: 0, T1: 1, T2: 2, T3: 3, T4: 4 };
|
|
35
|
+
export const FloorRank = { F1: 0, F2: 1, F3: 2 };
|
|
36
|
+
export const ElasticityLimits = {
|
|
37
|
+
low: { autoRatio: 0.2, hardRatio: 0.2, requiresApproval: false, postAudit: false },
|
|
38
|
+
medium: { autoRatio: 0, hardRatio: 0.35, requiresApproval: true, postAudit: true },
|
|
39
|
+
high: { autoRatio: 0.5, hardRatio: 0.5, requiresApproval: false, postAudit: true },
|
|
40
|
+
};
|
|
41
|
+
export const BudgetDimensions = ["tokens", "ms", "calls", "interrupts", "money"];
|
|
42
|
+
/**
|
|
43
|
+
* A fail-closed governance rejection: the caller gets a code, not a silently
|
|
44
|
+
* degraded policy.
|
|
45
|
+
*/
|
|
46
|
+
export class GovernanceError extends Error {
|
|
47
|
+
code;
|
|
48
|
+
constructor(code, detail) {
|
|
49
|
+
super(`${code}: ${detail}`);
|
|
50
|
+
this.name = "GovernanceError";
|
|
51
|
+
this.code = code;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Stable key for a Ref so scopes can be compared without object identity.
|
|
56
|
+
*/
|
|
57
|
+
export const refKey = (ref) => `${ref.kind}:${ref.id}`;
|
|
58
|
+
/**
|
|
59
|
+
* A shallow read-only copy of a Budget with every dimension defaulted to zero.
|
|
60
|
+
*/
|
|
61
|
+
export const budgetTotals = (budget) => ({
|
|
62
|
+
tokens: budget.tokens ?? 0,
|
|
63
|
+
ms: budget.ms ?? 0,
|
|
64
|
+
calls: budget.calls ?? 0,
|
|
65
|
+
interrupts: budget.interrupts ?? 0,
|
|
66
|
+
money: budget.money ?? 0,
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* Description-only digest used when a caller does not have the full object;
|
|
70
|
+
* never used for integrity checks.
|
|
71
|
+
*/
|
|
72
|
+
export const auditLine = (parts) => parts.join(" | ");
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The seven-phase workflow with approvals (spec section 11).
|
|
3
|
+
*
|
|
4
|
+
* The workflow is the only place that decides whether a phase may advance. It
|
|
5
|
+
* enforces three rules that the rest of the protocol depends on:
|
|
6
|
+
* - an approval cannot be issued by the perspective that requested it;
|
|
7
|
+
* - a phase gate needs its artefacts and its approvals, not just a mood;
|
|
8
|
+
* - execution cannot start without a triple-signed switch credential.
|
|
9
|
+
*
|
|
10
|
+
* The phase table is data, so a change to a step is reviewable as a diff.
|
|
11
|
+
*/
|
|
12
|
+
import type { Id, Timestamp } from "../types/common.js";
|
|
13
|
+
import type { ApprovalGrant, ApprovalSubject, ModeWeights, PerspectiveId, ScenarioId, SignoffRole } from "./types.js";
|
|
14
|
+
import type { SwitchCredential } from "./credential.js";
|
|
15
|
+
export type PhaseId = "intake" | "planning" | "preparation" | "execution" | "audit" | "escalation" | "archive";
|
|
16
|
+
export declare const PhaseOrder: readonly PhaseId[];
|
|
17
|
+
export type EscalationType = "audit" | "strategy" | "final" | "compliance";
|
|
18
|
+
/**
|
|
19
|
+
* One step of a phase: who acts, what they do, what they produce.
|
|
20
|
+
*/
|
|
21
|
+
export interface StepSpec {
|
|
22
|
+
id: string;
|
|
23
|
+
phase: PhaseId;
|
|
24
|
+
owner: PerspectiveId;
|
|
25
|
+
action: string;
|
|
26
|
+
produces: string;
|
|
27
|
+
optional?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface Artifact {
|
|
30
|
+
id: Id;
|
|
31
|
+
kind: string;
|
|
32
|
+
by: PerspectiveId;
|
|
33
|
+
at: Timestamp;
|
|
34
|
+
signoffs?: SignoffRole[];
|
|
35
|
+
digest?: string;
|
|
36
|
+
note?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface WorkflowApproval extends ApprovalGrant {
|
|
39
|
+
requestedBy: PerspectiveId;
|
|
40
|
+
}
|
|
41
|
+
export interface PhaseTransition {
|
|
42
|
+
from: PhaseId | "none";
|
|
43
|
+
to: PhaseId;
|
|
44
|
+
by: PerspectiveId;
|
|
45
|
+
at: Timestamp;
|
|
46
|
+
note: string;
|
|
47
|
+
}
|
|
48
|
+
export interface EscalationRecord {
|
|
49
|
+
type: EscalationType;
|
|
50
|
+
reason: string;
|
|
51
|
+
evidenceRefs: number;
|
|
52
|
+
by: PerspectiveId;
|
|
53
|
+
at: Timestamp;
|
|
54
|
+
target: PerspectiveId;
|
|
55
|
+
returnPhase: PhaseId;
|
|
56
|
+
}
|
|
57
|
+
export interface WorkflowState {
|
|
58
|
+
id: Id;
|
|
59
|
+
scenario: ScenarioId;
|
|
60
|
+
modes: ModeWeights;
|
|
61
|
+
phase: PhaseId;
|
|
62
|
+
status: "open" | "blocked" | "complete" | "terminated";
|
|
63
|
+
completedSteps: string[];
|
|
64
|
+
artifacts: Artifact[];
|
|
65
|
+
approvals: WorkflowApproval[];
|
|
66
|
+
manifest?: {
|
|
67
|
+
id: Id;
|
|
68
|
+
version: number;
|
|
69
|
+
};
|
|
70
|
+
credential?: {
|
|
71
|
+
id: Id;
|
|
72
|
+
signoffs: SignoffRole[];
|
|
73
|
+
expires: Timestamp;
|
|
74
|
+
digest: string;
|
|
75
|
+
};
|
|
76
|
+
escalation?: EscalationRecord;
|
|
77
|
+
history: PhaseTransition[];
|
|
78
|
+
blockedReason?: string;
|
|
79
|
+
}
|
|
80
|
+
export interface StartInput {
|
|
81
|
+
id: Id;
|
|
82
|
+
scenario: ScenarioId;
|
|
83
|
+
modes?: Partial<ModeWeights>;
|
|
84
|
+
at: Timestamp;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The phase table. Actions are short because the artefacts carry the detail.
|
|
88
|
+
*/
|
|
89
|
+
export declare const PhaseSteps: Record<PhaseId, readonly StepSpec[]>;
|
|
90
|
+
/**
|
|
91
|
+
* The workflow engine. It is deliberately linear: `escalate` side-branches and
|
|
92
|
+
* `resume` returns, and `advance` is the only door to the next phase.
|
|
93
|
+
*/
|
|
94
|
+
export declare class Workflow {
|
|
95
|
+
private readonly state;
|
|
96
|
+
private counter;
|
|
97
|
+
constructor(state: WorkflowState);
|
|
98
|
+
static start(input: StartInput): Workflow;
|
|
99
|
+
current(): WorkflowState;
|
|
100
|
+
steps(): StepSpec[];
|
|
101
|
+
/**
|
|
102
|
+
* Complete one step of the current phase and record its artefact.
|
|
103
|
+
*/
|
|
104
|
+
complete(stepId: string, by: PerspectiveId, at: Timestamp, note?: string): WorkflowState;
|
|
105
|
+
/**
|
|
106
|
+
* Complete a step and record a richer artefact in one operation. Use this
|
|
107
|
+
* when the artefact carries sign-offs or a digest (a credential, an audit
|
|
108
|
+
* receipt); `complete` records the plain artefact.
|
|
109
|
+
*/
|
|
110
|
+
attach(stepId: string, by: PerspectiveId, artifact: Omit<Artifact, "id" | "by">): WorkflowState;
|
|
111
|
+
/**
|
|
112
|
+
* Internal artefact recorder. The public `attach` guards the credential
|
|
113
|
+
* kind; `attachCredential` enters here only after verifying a real one.
|
|
114
|
+
*/
|
|
115
|
+
private recordArtifact;
|
|
116
|
+
/**
|
|
117
|
+
* Attach a real, verified switch credential to the preparation phase and
|
|
118
|
+
* bind it to the state. The workflow never trusts a caller-supplied digest
|
|
119
|
+
* string.
|
|
120
|
+
*/
|
|
121
|
+
attachCredential(credential: SwitchCredential, at: Timestamp): WorkflowState;
|
|
122
|
+
/**
|
|
123
|
+
* Record an approval. The approver must own the subject and must differ
|
|
124
|
+
* from the requester.
|
|
125
|
+
*/
|
|
126
|
+
approve(input: {
|
|
127
|
+
subject: ApprovalSubject;
|
|
128
|
+
by: PerspectiveId;
|
|
129
|
+
at: Timestamp;
|
|
130
|
+
requestedBy: PerspectiveId;
|
|
131
|
+
granted?: boolean;
|
|
132
|
+
note?: string;
|
|
133
|
+
}): WorkflowState;
|
|
134
|
+
hasApproval(subject: ApprovalSubject): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Advance to the next phase. Only the general manager may call this, and
|
|
137
|
+
* only when the gate is satisfied.
|
|
138
|
+
*/
|
|
139
|
+
advance(by: PerspectiveId, at: Timestamp): WorkflowState;
|
|
140
|
+
/**
|
|
141
|
+
* Enter the escalation branch from any phase except archive.
|
|
142
|
+
*/
|
|
143
|
+
escalate(input: {
|
|
144
|
+
by: PerspectiveId;
|
|
145
|
+
at: Timestamp;
|
|
146
|
+
type: EscalationType;
|
|
147
|
+
reason: string;
|
|
148
|
+
evidenceRefs: number;
|
|
149
|
+
}): WorkflowState;
|
|
150
|
+
/**
|
|
151
|
+
* Leave the escalation branch for the phase that asked for it.
|
|
152
|
+
*/
|
|
153
|
+
resume(by: PerspectiveId, at: Timestamp): WorkflowState;
|
|
154
|
+
/**
|
|
155
|
+
* Attach the manifest reference the execution phase uses. The credential is
|
|
156
|
+
* bound only through {@link attachCredential}.
|
|
157
|
+
*/
|
|
158
|
+
bind(context: {
|
|
159
|
+
manifest?: {
|
|
160
|
+
id: Id;
|
|
161
|
+
version: number;
|
|
162
|
+
};
|
|
163
|
+
}): WorkflowState;
|
|
164
|
+
block(reason: string): WorkflowState;
|
|
165
|
+
unblock(): WorkflowState;
|
|
166
|
+
terminate(at: Timestamp, reason: string): WorkflowState;
|
|
167
|
+
finish(at: Timestamp): WorkflowState;
|
|
168
|
+
hasArtifact(kind: string): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Invariant report used by checks and by the archive phase.
|
|
171
|
+
*/
|
|
172
|
+
verify(): string[];
|
|
173
|
+
private archiveGateProblems;
|
|
174
|
+
}
|