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,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AMP v0.1 — protocol surfaces: message envelope (A-surface) and model verbs (M-surface).
|
|
3
|
+
* Mirrors docs/schemas/message.schema.json and docs/schemas/verb.schema.json.
|
|
4
|
+
*/
|
|
5
|
+
import type { Budget, Id, Ref, Signature, Tier, Timestamp } from "../types/common.js";
|
|
6
|
+
import type { InterruptClass } from "../attention/socialTypes.js";
|
|
7
|
+
export type Performative = "inform" | "request" | "propose" | "commit" | "decline" | "cancel" | "release";
|
|
8
|
+
/**
|
|
9
|
+
* Closed error enum. `retryable` is a property of the code, not of the message.
|
|
10
|
+
*/
|
|
11
|
+
export type ErrorCode = "denied" | "unavailable" | "invalid" | "expired" | "conflict" | "budget_exceeded" | "unsupported" | "internal";
|
|
12
|
+
export interface MessagePayload {
|
|
13
|
+
claim?: Ref;
|
|
14
|
+
warrant?: Ref;
|
|
15
|
+
target?: Ref;
|
|
16
|
+
class?: InterruptClass;
|
|
17
|
+
why_now?: string;
|
|
18
|
+
if_ignored?: string;
|
|
19
|
+
cost?: Budget;
|
|
20
|
+
proposal?: string;
|
|
21
|
+
ref?: Ref;
|
|
22
|
+
request?: Id;
|
|
23
|
+
reason?: string;
|
|
24
|
+
code?: ErrorCode;
|
|
25
|
+
note?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* One envelope, seven performatives. Every field is observable; nothing encodes sincerity.
|
|
29
|
+
*/
|
|
30
|
+
export interface Message {
|
|
31
|
+
amp: "0.1";
|
|
32
|
+
kind: "message";
|
|
33
|
+
id: Id;
|
|
34
|
+
type: Performative;
|
|
35
|
+
from: Ref;
|
|
36
|
+
to: Ref;
|
|
37
|
+
thread: Id;
|
|
38
|
+
reply_to?: Id;
|
|
39
|
+
sent: Timestamp;
|
|
40
|
+
ttl?: number;
|
|
41
|
+
payload: MessagePayload;
|
|
42
|
+
signature?: Signature;
|
|
43
|
+
}
|
|
44
|
+
export type VerbName = "attend" | "plan" | "act" | "ask" | "note" | "reflect" | "read";
|
|
45
|
+
export interface ExpectationCall {
|
|
46
|
+
observation: string;
|
|
47
|
+
check: string;
|
|
48
|
+
}
|
|
49
|
+
export interface AttendCall {
|
|
50
|
+
amp: "0.1";
|
|
51
|
+
kind: "call";
|
|
52
|
+
verb: "attend";
|
|
53
|
+
id?: Id;
|
|
54
|
+
target: Ref;
|
|
55
|
+
why: string;
|
|
56
|
+
budget?: Budget;
|
|
57
|
+
}
|
|
58
|
+
export interface PlanCall {
|
|
59
|
+
amp: "0.1";
|
|
60
|
+
kind: "call";
|
|
61
|
+
verb: "plan";
|
|
62
|
+
id?: Id;
|
|
63
|
+
goal: Ref;
|
|
64
|
+
process?: Ref;
|
|
65
|
+
mode?: "draft" | "commit";
|
|
66
|
+
}
|
|
67
|
+
export interface ActCall {
|
|
68
|
+
amp: "0.1";
|
|
69
|
+
kind: "call";
|
|
70
|
+
verb: "act";
|
|
71
|
+
id?: Id;
|
|
72
|
+
action: string;
|
|
73
|
+
ref?: Ref;
|
|
74
|
+
args?: Record<string, unknown>;
|
|
75
|
+
expect?: ExpectationCall;
|
|
76
|
+
budget?: Budget;
|
|
77
|
+
}
|
|
78
|
+
export interface AskCall {
|
|
79
|
+
amp: "0.1";
|
|
80
|
+
kind: "call";
|
|
81
|
+
verb: "ask";
|
|
82
|
+
id?: Id;
|
|
83
|
+
question: string;
|
|
84
|
+
to?: Ref;
|
|
85
|
+
class?: InterruptClass;
|
|
86
|
+
urgency?: 1 | 2 | 3 | 4 | 5;
|
|
87
|
+
expires?: Timestamp;
|
|
88
|
+
}
|
|
89
|
+
export interface NoteCall {
|
|
90
|
+
amp: "0.1";
|
|
91
|
+
kind: "call";
|
|
92
|
+
verb: "note";
|
|
93
|
+
id?: Id;
|
|
94
|
+
assertion: string;
|
|
95
|
+
as: "claim" | "hypothesis" | "unknown" | "concept";
|
|
96
|
+
/**
|
|
97
|
+
* May be proposed; the Warrant Engine may reject or lower it (W-5).
|
|
98
|
+
*/
|
|
99
|
+
tier?: Tier;
|
|
100
|
+
evidence?: Ref[];
|
|
101
|
+
refutes_if?: string;
|
|
102
|
+
label?: string;
|
|
103
|
+
}
|
|
104
|
+
export interface ReflectCall {
|
|
105
|
+
amp: "0.1";
|
|
106
|
+
kind: "call";
|
|
107
|
+
verb: "reflect";
|
|
108
|
+
id?: Id;
|
|
109
|
+
scope?: "turn" | "task" | "session";
|
|
110
|
+
}
|
|
111
|
+
export interface ReadCall {
|
|
112
|
+
amp: "0.1";
|
|
113
|
+
kind: "call";
|
|
114
|
+
verb: "read";
|
|
115
|
+
id?: Id;
|
|
116
|
+
handle: string;
|
|
117
|
+
cursor: number;
|
|
118
|
+
limit?: number;
|
|
119
|
+
}
|
|
120
|
+
export type VerbCall = AttendCall | PlanCall | ActCall | AskCall | NoteCall | ReflectCall | ReadCall;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Delegation, Lease } from "../delegate/team.js";
|
|
2
|
+
import type { DelegationDoc, LeaseDoc } from "../cooperation/collaboration.js";
|
|
3
|
+
/**
|
|
4
|
+
* Wire mapping for collaboration objects.
|
|
5
|
+
*
|
|
6
|
+
* The runtime uses camelCase; the wire uses snake_case and stable names because
|
|
7
|
+
* a delegation crosses domains and must not depend on an implementation's
|
|
8
|
+
* internal naming. Round-tripping is tested, not assumed.
|
|
9
|
+
*/
|
|
10
|
+
export declare const toDelegationDoc: (delegation: Delegation) => DelegationDoc;
|
|
11
|
+
export declare const fromDelegationDoc: (doc: DelegationDoc) => Delegation;
|
|
12
|
+
export declare const toLeaseDoc: (lease: Lease) => LeaseDoc;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire mapping for collaboration objects.
|
|
3
|
+
*
|
|
4
|
+
* The runtime uses camelCase; the wire uses snake_case and stable names because
|
|
5
|
+
* a delegation crosses domains and must not depend on an implementation's
|
|
6
|
+
* internal naming. Round-tripping is tested, not assumed.
|
|
7
|
+
*/
|
|
8
|
+
export const toDelegationDoc = (delegation) => {
|
|
9
|
+
return {
|
|
10
|
+
amp: "0.1",
|
|
11
|
+
kind: "delegation",
|
|
12
|
+
id: delegation.id,
|
|
13
|
+
parent: delegation.parent,
|
|
14
|
+
granter: delegation.granter,
|
|
15
|
+
delegatee: delegation.delegatee,
|
|
16
|
+
goal_digest: delegation.goalDigest,
|
|
17
|
+
scope: delegation.scope,
|
|
18
|
+
budget: delegation.budget,
|
|
19
|
+
deadline: delegation.deadline,
|
|
20
|
+
may_redelegate: delegation.mayRedelegate,
|
|
21
|
+
depth: delegation.depth,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export const fromDelegationDoc = (doc) => {
|
|
25
|
+
const delegation = {
|
|
26
|
+
id: doc.id,
|
|
27
|
+
granter: doc.granter,
|
|
28
|
+
delegatee: doc.delegatee,
|
|
29
|
+
goalDigest: doc.goal_digest,
|
|
30
|
+
scope: doc.scope,
|
|
31
|
+
budget: doc.budget,
|
|
32
|
+
deadline: doc.deadline,
|
|
33
|
+
mayRedelegate: doc.may_redelegate,
|
|
34
|
+
depth: doc.depth,
|
|
35
|
+
};
|
|
36
|
+
if (doc.parent !== (void 0)) {
|
|
37
|
+
delegation.parent = doc.parent;
|
|
38
|
+
}
|
|
39
|
+
return delegation;
|
|
40
|
+
};
|
|
41
|
+
export const toLeaseDoc = (lease) => {
|
|
42
|
+
return {
|
|
43
|
+
amp: "0.1",
|
|
44
|
+
kind: "lease",
|
|
45
|
+
id: lease.id,
|
|
46
|
+
delegation: lease.delegation,
|
|
47
|
+
task_id: lease.taskId,
|
|
48
|
+
holder: lease.holder,
|
|
49
|
+
fence: lease.fence,
|
|
50
|
+
goal_digest: lease.goalDigest,
|
|
51
|
+
budget: lease.budget,
|
|
52
|
+
deadline: lease.deadline,
|
|
53
|
+
status: lease.status,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./receipt.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./receipt.js";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AMP v0.1 — settlement objects: receipt | event.
|
|
3
|
+
* Mirrors docs/schemas/receipt.schema.json.
|
|
4
|
+
*
|
|
5
|
+
* Receipts are the only ground truth for calibration; events are the append-only log.
|
|
6
|
+
*/
|
|
7
|
+
import type { Confidence, Digest, Handle, Id, Ref, Timestamp, Usage } from "../types/common.js";
|
|
8
|
+
export type ReceiptOp = "attend" | "act" | "ask" | "note" | "plan" | "reflect" | "read";
|
|
9
|
+
export type Outcome = "success" | "partial" | "failure" | "blocked";
|
|
10
|
+
export interface Receipt {
|
|
11
|
+
amp: "0.1";
|
|
12
|
+
kind: "receipt";
|
|
13
|
+
id: Id;
|
|
14
|
+
op: ReceiptOp;
|
|
15
|
+
target?: Ref;
|
|
16
|
+
at: Timestamp;
|
|
17
|
+
ms?: number;
|
|
18
|
+
usage: Usage;
|
|
19
|
+
outcome: Outcome;
|
|
20
|
+
/**
|
|
21
|
+
* Recorded before the action; compared with realized_voi to calibrate the controller.
|
|
22
|
+
*/
|
|
23
|
+
predicted_voi?: Confidence;
|
|
24
|
+
realized_voi?: Confidence;
|
|
25
|
+
handle?: Handle;
|
|
26
|
+
note?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Named AmpEvent to avoid shadowing the DOM `Event`.
|
|
30
|
+
*/
|
|
31
|
+
export interface AmpEvent {
|
|
32
|
+
amp: "0.1";
|
|
33
|
+
kind: "event";
|
|
34
|
+
id: Id;
|
|
35
|
+
at: Timestamp;
|
|
36
|
+
actor: Ref;
|
|
37
|
+
type: string;
|
|
38
|
+
caused_by?: Id;
|
|
39
|
+
refs?: Ref[];
|
|
40
|
+
digest: Digest;
|
|
41
|
+
payload?: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
export type SettlementObject = Receipt | AmpEvent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ContentEntry {
|
|
2
|
+
path: string;
|
|
3
|
+
digest: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const collectDirectory: (root: string) => Promise<ContentEntry[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Deterministic digest of a directory's current content.
|
|
8
|
+
*/
|
|
9
|
+
export declare const digestDirectory: (root: string) => Promise<string>;
|
|
10
|
+
export declare const diffDirectory: (root: string, expected: readonly ContentEntry[]) => Promise<ContentEntry[]>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content digest for a module directory.
|
|
3
|
+
*
|
|
4
|
+
* A declaration that only records a path proves almost nothing. This module
|
|
5
|
+
* hashes every file under the directory into a sorted manifest, then hashes the
|
|
6
|
+
* manifest, so a declaration can bind the actual code. `verifyModuleContent`
|
|
7
|
+
* recomputes it and reports drift.
|
|
8
|
+
*/
|
|
9
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import { digestOf } from "../semantic/canonical.js";
|
|
12
|
+
import { sha256Hex } from "../semantic/sha256.js";
|
|
13
|
+
const Skip = new Set(["node_modules", ".git", ".tscheck", "dist"]);
|
|
14
|
+
const walk = async (root, current, out) => {
|
|
15
|
+
const entries = await readdir(current, { withFileTypes: true });
|
|
16
|
+
entries.sort((left, right) => left.name.localeCompare(right.name));
|
|
17
|
+
for (const entry of entries) {
|
|
18
|
+
if (Skip.has(entry.name)) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const full = path.join(current, entry.name);
|
|
22
|
+
if (entry.isDirectory()) {
|
|
23
|
+
await walk(root, full, out);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (!entry.isFile()) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const text = await readFile(full, "utf8");
|
|
30
|
+
out.push({ path: path.relative(root, full).split(path.sep).join("/"), digest: sha256Hex(text) });
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export const collectDirectory = async (root) => {
|
|
34
|
+
const entries = [];
|
|
35
|
+
await walk(root, root, entries);
|
|
36
|
+
return entries;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Deterministic digest of a directory's current content.
|
|
40
|
+
*/
|
|
41
|
+
export const digestDirectory = async (root) => {
|
|
42
|
+
return digestOf(await collectDirectory(root));
|
|
43
|
+
};
|
|
44
|
+
export const diffDirectory = async (root, expected) => {
|
|
45
|
+
const actual = await collectDirectory(root);
|
|
46
|
+
const expectedMap = new Map(expected.map((entry) => [entry.path, entry.digest]));
|
|
47
|
+
const changed = [];
|
|
48
|
+
for (const entry of actual) {
|
|
49
|
+
if (expectedMap.get(entry.path) !== entry.digest) {
|
|
50
|
+
changed.push(entry);
|
|
51
|
+
}
|
|
52
|
+
expectedMap.delete(entry.path);
|
|
53
|
+
}
|
|
54
|
+
for (const [missingPath, digest] of expectedMap) {
|
|
55
|
+
changed.push({ path: missingPath, digest });
|
|
56
|
+
}
|
|
57
|
+
return changed;
|
|
58
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { attest, declareConcept, declareModule, dependencies, hasDependencyCycle, linkConcept, linkDependency, verifyModuleContent, verifyRegistry, } from "./registry.js";
|
|
2
|
+
export type { AttestationResult, ConceptInput, ConceptLinkRole, DeclarationResult, DependencyRow, ModuleInput, ModuleKind, RegistryStatus, } from "./registry.js";
|
|
3
|
+
export { collectDirectory, diffDirectory, digestDirectory } from "./content.js";
|
|
4
|
+
export type { ContentEntry } from "./content.js";
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry: concepts and modules as first-class rows.
|
|
3
|
+
*
|
|
4
|
+
* A directory existing on disk is not evidence that a module is part of the
|
|
5
|
+
* architecture. Declaring it writes an immutable `module.<id>.v<n>` object into
|
|
6
|
+
* the hash chain and updates the current row; the row points at that object, so
|
|
7
|
+
* "this module exists, at version n, with this description" is checkable.
|
|
8
|
+
*/
|
|
9
|
+
import type { DatabaseSync } from "node:sqlite";
|
|
10
|
+
import type { ConceptEntity, ModuleEntity } from "../database/entity/registry.js";
|
|
11
|
+
export type RegistryStatus = "proposed" | "active" | "deprecated";
|
|
12
|
+
export type ModuleKind = "kernel" | "database" | "domain" | "protocol" | "module" | "structure" | "tool" | "boundary";
|
|
13
|
+
export type ConceptLinkRole = "owns" | "uses" | "constrains" | "implements";
|
|
14
|
+
export interface ConceptInput {
|
|
15
|
+
id: string;
|
|
16
|
+
label: string;
|
|
17
|
+
definition: string;
|
|
18
|
+
status?: RegistryStatus;
|
|
19
|
+
}
|
|
20
|
+
export interface ModuleInput {
|
|
21
|
+
id: string;
|
|
22
|
+
kind: ModuleKind;
|
|
23
|
+
entry: string;
|
|
24
|
+
description: string;
|
|
25
|
+
status?: RegistryStatus;
|
|
26
|
+
/**
|
|
27
|
+
* Digest of the directory content at declaration time; enables drift checks.
|
|
28
|
+
*/
|
|
29
|
+
contentDigest?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface DeclarationResult<T> {
|
|
32
|
+
row: T;
|
|
33
|
+
objectId: string;
|
|
34
|
+
hash: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Verification outcome shared by the registry checks.
|
|
38
|
+
*/
|
|
39
|
+
type VerifyReport = {
|
|
40
|
+
ok: boolean;
|
|
41
|
+
reasons: string[];
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Signature of the concept declarer.
|
|
45
|
+
*/
|
|
46
|
+
type ConceptDeclarer = (db: DatabaseSync, input: ConceptInput, at: string) => DeclarationResult<ConceptEntity>;
|
|
47
|
+
export declare const declareConcept: ConceptDeclarer;
|
|
48
|
+
/**
|
|
49
|
+
* Signature of the module declarer.
|
|
50
|
+
*/
|
|
51
|
+
type ModuleDeclarer = (db: DatabaseSync, input: ModuleInput, at: string) => DeclarationResult<ModuleEntity>;
|
|
52
|
+
export declare const declareModule: ModuleDeclarer;
|
|
53
|
+
/**
|
|
54
|
+
* Signature of the concept-to-module linker.
|
|
55
|
+
*/
|
|
56
|
+
type ConceptLinker = (db: DatabaseSync, moduleId: string, conceptId: string, role: ConceptLinkRole) => boolean;
|
|
57
|
+
export declare const linkConcept: ConceptLinker;
|
|
58
|
+
export interface AttestationResult {
|
|
59
|
+
aid: number;
|
|
60
|
+
objectId: string;
|
|
61
|
+
hash: string;
|
|
62
|
+
}
|
|
63
|
+
export interface DependencyRow {
|
|
64
|
+
moduleId: string;
|
|
65
|
+
dependsOn: string;
|
|
66
|
+
reason?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Signature of the module dependency reader.
|
|
70
|
+
*/
|
|
71
|
+
type DependencyReader = (db: DatabaseSync, moduleId: string) => DependencyRow[];
|
|
72
|
+
export declare const dependencies: DependencyReader;
|
|
73
|
+
/**
|
|
74
|
+
* Signature of the module dependency linker.
|
|
75
|
+
*/
|
|
76
|
+
type DependencyLinker = (db: DatabaseSync, moduleId: string, dependencyId: string, reason?: string) => boolean;
|
|
77
|
+
export declare const linkDependency: DependencyLinker;
|
|
78
|
+
/**
|
|
79
|
+
* Signature of the dependency cycle detector.
|
|
80
|
+
*/
|
|
81
|
+
type CycleDetector = (db: DatabaseSync) => boolean;
|
|
82
|
+
/**
|
|
83
|
+
* DFS over the dependency graph; uses the structure library's Stack/Set.
|
|
84
|
+
*/
|
|
85
|
+
export declare const hasDependencyCycle: CycleDetector;
|
|
86
|
+
/**
|
|
87
|
+
* Signature of the module content verifier.
|
|
88
|
+
*/
|
|
89
|
+
type ModuleContentVerifier = (db: DatabaseSync, compute: (entry: string) => Promise<string>) => Promise<VerifyReport>;
|
|
90
|
+
/**
|
|
91
|
+
* Recompute each module directory's digest and compare it with the declaration.
|
|
92
|
+
*/
|
|
93
|
+
export declare const verifyModuleContent: ModuleContentVerifier;
|
|
94
|
+
/**
|
|
95
|
+
* Signature of the registry attester.
|
|
96
|
+
*/
|
|
97
|
+
type Attester = (db: DatabaseSync, subjectKind: "concept" | "module", subjectId: string, claimId: string, at: string) => AttestationResult;
|
|
98
|
+
/**
|
|
99
|
+
* Attest a registry row with a claim. The attestation is an `evidence` object
|
|
100
|
+
* in the chain plus a row that points at it, so a module can be justified by
|
|
101
|
+
* something stronger than "the directory exists".
|
|
102
|
+
*/
|
|
103
|
+
export declare const attest: Attester;
|
|
104
|
+
/**
|
|
105
|
+
* Signature of the registry verifier.
|
|
106
|
+
*/
|
|
107
|
+
type RegistryVerifier = (db: DatabaseSync) => VerifyReport;
|
|
108
|
+
export declare const verifyRegistry: RegistryVerifier;
|
|
109
|
+
export {};
|