@vauban-org/agent-sdk 0.17.4 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRACT.md +6401 -813
- package/dist/adapters/llm/anthropic-direct.d.ts +1 -0
- package/dist/adapters/llm/anthropic-direct.d.ts.map +1 -1
- package/dist/adapters/llm/anthropic-direct.js +43 -0
- package/dist/adapters/llm/anthropic-direct.js.map +1 -1
- package/dist/adapters/llm/cascade.d.ts.map +1 -1
- package/dist/adapters/llm/cascade.js +57 -14
- package/dist/adapters/llm/cascade.js.map +1 -1
- package/dist/adapters/llm/litellm.d.ts +2 -0
- package/dist/adapters/llm/litellm.d.ts.map +1 -1
- package/dist/adapters/llm/litellm.js +44 -0
- package/dist/adapters/llm/litellm.js.map +1 -1
- package/dist/compute/difficulty-estimator.d.ts +53 -0
- package/dist/compute/difficulty-estimator.d.ts.map +1 -0
- package/dist/compute/difficulty-estimator.js +82 -0
- package/dist/compute/difficulty-estimator.js.map +1 -0
- package/dist/compute/strategies/mixture-of-agents.d.ts +40 -0
- package/dist/compute/strategies/mixture-of-agents.d.ts.map +1 -0
- package/dist/compute/strategies/mixture-of-agents.js +110 -0
- package/dist/compute/strategies/mixture-of-agents.js.map +1 -0
- package/dist/compute/strategies/tree-of-thoughts.d.ts +48 -0
- package/dist/compute/strategies/tree-of-thoughts.d.ts.map +1 -0
- package/dist/compute/strategies/tree-of-thoughts.js +242 -0
- package/dist/compute/strategies/tree-of-thoughts.js.map +1 -0
- package/dist/compute/strategies/two-phase-orient.d.ts +72 -0
- package/dist/compute/strategies/two-phase-orient.d.ts.map +1 -0
- package/dist/compute/strategies/two-phase-orient.js +85 -0
- package/dist/compute/strategies/two-phase-orient.js.map +1 -0
- package/dist/constitution/types.d.ts +10 -10
- package/dist/container/protocol.d.ts +134 -0
- package/dist/container/protocol.d.ts.map +1 -0
- package/dist/container/protocol.js +157 -0
- package/dist/container/protocol.js.map +1 -0
- package/dist/container/runtime.d.ts +140 -0
- package/dist/container/runtime.d.ts.map +1 -0
- package/dist/container/runtime.js +256 -0
- package/dist/container/runtime.js.map +1 -0
- package/dist/events/catalogue.d.ts +327 -30
- package/dist/events/catalogue.d.ts.map +1 -1
- package/dist/events/catalogue.js +18 -0
- package/dist/events/catalogue.js.map +1 -1
- package/dist/events/index.d.ts +9 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +9 -0
- package/dist/events/index.js.map +1 -1
- package/dist/events/schemas/agent.completed.v1.d.ts +4 -4
- package/dist/events/schemas/agent.failed.v1.d.ts +2 -2
- package/dist/events/schemas/agent.hitl_resolved.v1.d.ts +2 -2
- package/dist/events/schemas/agent.started.v1.d.ts +2 -2
- package/dist/events/schemas/brain.skill.extracted.v1.d.ts +4 -4
- package/dist/events/schemas/cc.cost.anomaly_detected.v1.d.ts +2 -2
- package/dist/events/schemas/cc.cost.recorded.v1.d.ts +4 -4
- package/dist/events/schemas/citadel.sprint.analyzed.v1.d.ts +55 -0
- package/dist/events/schemas/citadel.sprint.analyzed.v1.d.ts.map +1 -0
- package/dist/events/schemas/citadel.sprint.analyzed.v1.js +22 -0
- package/dist/events/schemas/citadel.sprint.analyzed.v1.js.map +1 -0
- package/dist/events/schemas/citadel.sprint.closed.v1.d.ts +2 -2
- package/dist/events/schemas/forge.inbox.reply_classified.v1.d.ts +33 -0
- package/dist/events/schemas/forge.inbox.reply_classified.v1.d.ts.map +1 -0
- package/dist/events/schemas/forge.inbox.reply_classified.v1.js +15 -0
- package/dist/events/schemas/forge.inbox.reply_classified.v1.js.map +1 -0
- package/dist/events/schemas/forge.lead.qualified.v1.d.ts +2 -2
- package/dist/events/schemas/forge.outreach.sent.v1.d.ts +4 -4
- package/dist/events/schemas/incident.detected.v1.d.ts +2 -2
- package/dist/events/schemas/vauban-finance.forecast.generated.v1.d.ts +21 -0
- package/dist/events/schemas/vauban-finance.forecast.generated.v1.d.ts.map +1 -0
- package/dist/events/schemas/vauban-finance.forecast.generated.v1.js +11 -0
- package/dist/events/schemas/vauban-finance.forecast.generated.v1.js.map +1 -0
- package/dist/events/schemas/vauban-finance.trade.executed.v1.d.ts +24 -0
- package/dist/events/schemas/vauban-finance.trade.executed.v1.d.ts.map +1 -0
- package/dist/events/schemas/vauban-finance.trade.executed.v1.js +12 -0
- package/dist/events/schemas/vauban-finance.trade.executed.v1.js.map +1 -0
- package/dist/events/schemas/vauban.goal.checked.v1.d.ts +21 -0
- package/dist/events/schemas/vauban.goal.checked.v1.d.ts.map +1 -0
- package/dist/events/schemas/vauban.goal.checked.v1.js +11 -0
- package/dist/events/schemas/vauban.goal.checked.v1.js.map +1 -0
- package/dist/events/schemas/vauban.rebalancing.checked.v1.d.ts +21 -0
- package/dist/events/schemas/vauban.rebalancing.checked.v1.d.ts.map +1 -0
- package/dist/events/schemas/vauban.rebalancing.checked.v1.js +11 -0
- package/dist/events/schemas/vauban.rebalancing.checked.v1.js.map +1 -0
- package/dist/events/schemas/vauban.tax.checked.v1.d.ts +21 -0
- package/dist/events/schemas/vauban.tax.checked.v1.d.ts.map +1 -0
- package/dist/events/schemas/vauban.tax.checked.v1.js +11 -0
- package/dist/events/schemas/vauban.tax.checked.v1.js.map +1 -0
- package/dist/events/schemas/vauban.vault.analyzed.v1.d.ts +59 -0
- package/dist/events/schemas/vauban.vault.analyzed.v1.d.ts.map +1 -0
- package/dist/events/schemas/vauban.vault.analyzed.v1.js +19 -0
- package/dist/events/schemas/vauban.vault.analyzed.v1.js.map +1 -0
- package/dist/events/schemas/vauban.vault.compounded.v1.d.ts +24 -0
- package/dist/events/schemas/vauban.vault.compounded.v1.d.ts.map +1 -0
- package/dist/events/schemas/vauban.vault.compounded.v1.js +12 -0
- package/dist/events/schemas/vauban.vault.compounded.v1.js.map +1 -0
- package/dist/identity/agent-persona.d.ts +73 -0
- package/dist/identity/agent-persona.d.ts.map +1 -0
- package/dist/identity/agent-persona.js +165 -0
- package/dist/identity/agent-persona.js.map +1 -0
- package/dist/identity/persona-prompt.d.ts +25 -0
- package/dist/identity/persona-prompt.d.ts.map +1 -0
- package/dist/identity/persona-prompt.js +71 -0
- package/dist/identity/persona-prompt.js.map +1 -0
- package/dist/identity/persona-schema.d.ts +120 -0
- package/dist/identity/persona-schema.d.ts.map +1 -0
- package/dist/identity/persona-schema.js +103 -0
- package/dist/identity/persona-schema.js.map +1 -0
- package/dist/index.d.ts +37 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -1
- package/dist/index.js.map +1 -1
- package/dist/loop/index.d.ts +1 -1
- package/dist/loop/index.d.ts.map +1 -1
- package/dist/loop/index.js.map +1 -1
- package/dist/loop/minimal-loop.js +293 -287
- package/dist/loop/sdk-loop.d.ts +1 -3
- package/dist/loop/sdk-loop.d.ts.map +1 -1
- package/dist/loop/sdk-loop.js +1 -1
- package/dist/loop/sdk-loop.js.map +1 -1
- package/dist/memory/episodic-rrf.d.ts +114 -0
- package/dist/memory/episodic-rrf.d.ts.map +1 -0
- package/dist/memory/episodic-rrf.js +148 -0
- package/dist/memory/episodic-rrf.js.map +1 -0
- package/dist/mesh/attenuation.d.ts +78 -0
- package/dist/mesh/attenuation.d.ts.map +1 -0
- package/dist/mesh/attenuation.js +141 -0
- package/dist/mesh/attenuation.js.map +1 -0
- package/dist/mesh/delegate.d.ts +96 -0
- package/dist/mesh/delegate.d.ts.map +1 -0
- package/dist/mesh/delegate.js +172 -0
- package/dist/mesh/delegate.js.map +1 -0
- package/dist/mesh/dispatcher.d.ts +119 -0
- package/dist/mesh/dispatcher.d.ts.map +1 -0
- package/dist/mesh/dispatcher.js +207 -0
- package/dist/mesh/dispatcher.js.map +1 -0
- package/dist/mesh/index.d.ts +12 -0
- package/dist/mesh/index.d.ts.map +1 -0
- package/dist/mesh/index.js +11 -0
- package/dist/mesh/index.js.map +1 -0
- package/dist/mesh/types.d.ts +30 -0
- package/dist/mesh/types.d.ts.map +1 -0
- package/dist/mesh/types.js +11 -0
- package/dist/mesh/types.js.map +1 -0
- package/dist/orchestration/ooda/skills.d.ts +104 -0
- package/dist/orchestration/ooda/skills.d.ts.map +1 -1
- package/dist/orchestration/ooda/skills.js +106 -0
- package/dist/orchestration/ooda/skills.js.map +1 -1
- package/dist/orchestration/ooda/types.d.ts +3 -8
- package/dist/orchestration/ooda/types.d.ts.map +1 -1
- package/dist/ports/bastion-action.contract.test.d.ts +11 -0
- package/dist/ports/bastion-action.contract.test.d.ts.map +1 -0
- package/dist/ports/bastion-action.contract.test.js +238 -0
- package/dist/ports/bastion-action.contract.test.js.map +1 -0
- package/dist/ports/bastion-action.d.ts +133 -0
- package/dist/ports/bastion-action.d.ts.map +1 -0
- package/dist/ports/bastion-action.js +73 -0
- package/dist/ports/bastion-action.js.map +1 -0
- package/dist/ports/brain.d.ts +31 -0
- package/dist/ports/brain.d.ts.map +1 -1
- package/dist/ports/brain.js +115 -1
- package/dist/ports/brain.js.map +1 -1
- package/dist/ports/citadel-action.contract.test.d.ts +11 -0
- package/dist/ports/citadel-action.contract.test.d.ts.map +1 -0
- package/dist/ports/citadel-action.contract.test.js +317 -0
- package/dist/ports/citadel-action.contract.test.js.map +1 -0
- package/dist/ports/citadel-action.d.ts +111 -0
- package/dist/ports/citadel-action.d.ts.map +1 -0
- package/dist/ports/citadel-action.js +62 -0
- package/dist/ports/citadel-action.js.map +1 -0
- package/dist/ports/compliance-contract.d.ts +123 -0
- package/dist/ports/compliance-contract.d.ts.map +1 -0
- package/dist/ports/compliance-contract.js +35 -0
- package/dist/ports/compliance-contract.js.map +1 -0
- package/dist/ports/db.d.ts +38 -0
- package/dist/ports/db.d.ts.map +1 -1
- package/dist/ports/db.js +88 -1
- package/dist/ports/db.js.map +1 -1
- package/dist/ports/delegation.contract.test.d.ts +9 -0
- package/dist/ports/delegation.contract.test.d.ts.map +1 -0
- package/dist/ports/delegation.contract.test.js +337 -0
- package/dist/ports/delegation.contract.test.js.map +1 -0
- package/dist/ports/delegation.d.ts +134 -0
- package/dist/ports/delegation.d.ts.map +1 -0
- package/dist/ports/delegation.js +105 -0
- package/dist/ports/delegation.js.map +1 -0
- package/dist/ports/event-bus.d.ts +29 -13
- package/dist/ports/event-bus.d.ts.map +1 -1
- package/dist/ports/event-bus.js +106 -1
- package/dist/ports/event-bus.js.map +1 -1
- package/dist/ports/federation.contract.test.d.ts +9 -0
- package/dist/ports/federation.contract.test.d.ts.map +1 -0
- package/dist/ports/federation.contract.test.js +279 -0
- package/dist/ports/federation.contract.test.js.map +1 -0
- package/dist/ports/federation.d.ts +140 -0
- package/dist/ports/federation.d.ts.map +1 -0
- package/dist/ports/federation.js +57 -0
- package/dist/ports/federation.js.map +1 -0
- package/dist/ports/index.d.ts +28 -2
- package/dist/ports/index.d.ts.map +1 -1
- package/dist/ports/index.js +17 -2
- package/dist/ports/index.js.map +1 -1
- package/dist/ports/llm-provider.d.ts +37 -0
- package/dist/ports/llm-provider.d.ts.map +1 -1
- package/dist/ports/llm-provider.js +99 -1
- package/dist/ports/llm-provider.js.map +1 -1
- package/dist/ports/logger.d.ts +27 -0
- package/dist/ports/logger.d.ts.map +1 -1
- package/dist/ports/logger.js +87 -0
- package/dist/ports/logger.js.map +1 -1
- package/dist/ports/manifest-registry.contract.test.d.ts +9 -0
- package/dist/ports/manifest-registry.contract.test.d.ts.map +1 -0
- package/dist/ports/manifest-registry.contract.test.js +246 -0
- package/dist/ports/manifest-registry.contract.test.js.map +1 -0
- package/dist/ports/manifest-registry.d.ts +116 -0
- package/dist/ports/manifest-registry.d.ts.map +1 -0
- package/dist/ports/manifest-registry.js +79 -0
- package/dist/ports/manifest-registry.js.map +1 -0
- package/dist/ports/observability.contract.test.d.ts +12 -0
- package/dist/ports/observability.contract.test.d.ts.map +1 -0
- package/dist/ports/observability.contract.test.js +260 -0
- package/dist/ports/observability.contract.test.js.map +1 -0
- package/dist/ports/observability.d.ts +98 -0
- package/dist/ports/observability.d.ts.map +1 -0
- package/dist/ports/observability.js +59 -0
- package/dist/ports/observability.js.map +1 -0
- package/dist/ports/outcome.d.ts +26 -0
- package/dist/ports/outcome.d.ts.map +1 -1
- package/dist/ports/outcome.js +62 -1
- package/dist/ports/outcome.js.map +1 -1
- package/dist/ports/privacy.contract.test.d.ts +12 -0
- package/dist/ports/privacy.contract.test.d.ts.map +1 -0
- package/dist/ports/privacy.contract.test.js +325 -0
- package/dist/ports/privacy.contract.test.js.map +1 -0
- package/dist/ports/privacy.d.ts +132 -0
- package/dist/ports/privacy.d.ts.map +1 -0
- package/dist/ports/privacy.js +83 -0
- package/dist/ports/privacy.js.map +1 -0
- package/dist/ports/tenant-context.contract.test.d.ts +14 -0
- package/dist/ports/tenant-context.contract.test.d.ts.map +1 -0
- package/dist/ports/tenant-context.contract.test.js +352 -0
- package/dist/ports/tenant-context.contract.test.js.map +1 -0
- package/dist/ports/tenant-context.d.ts +103 -0
- package/dist/ports/tenant-context.d.ts.map +1 -0
- package/dist/ports/tenant-context.js +48 -0
- package/dist/ports/tenant-context.js.map +1 -0
- package/dist/ports/vauban-finance-action.contract.test.d.ts +11 -0
- package/dist/ports/vauban-finance-action.contract.test.d.ts.map +1 -0
- package/dist/ports/vauban-finance-action.contract.test.js +260 -0
- package/dist/ports/vauban-finance-action.contract.test.js.map +1 -0
- package/dist/ports/vauban-finance-action.d.ts +106 -0
- package/dist/ports/vauban-finance-action.d.ts.map +1 -0
- package/dist/ports/vauban-finance-action.js +60 -0
- package/dist/ports/vauban-finance-action.js.map +1 -0
- package/dist/ports/workflow-runtime.d.ts +204 -0
- package/dist/ports/workflow-runtime.d.ts.map +1 -0
- package/dist/ports/workflow-runtime.js +72 -0
- package/dist/ports/workflow-runtime.js.map +1 -0
- package/dist/proof/cert-verify.d.ts +80 -0
- package/dist/proof/cert-verify.d.ts.map +1 -0
- package/dist/proof/cert-verify.js +178 -0
- package/dist/proof/cert-verify.js.map +1 -0
- package/dist/replay/replay.d.ts.map +1 -1
- package/dist/replay/replay.js +5 -1
- package/dist/replay/replay.js.map +1 -1
- package/dist/retry/index.d.ts +129 -0
- package/dist/retry/index.d.ts.map +1 -0
- package/dist/retry/index.js +156 -0
- package/dist/retry/index.js.map +1 -0
- package/dist/retry/presets.d.ts +39 -0
- package/dist/retry/presets.d.ts.map +1 -0
- package/dist/retry/presets.js +69 -0
- package/dist/retry/presets.js.map +1 -0
- package/dist/skill-loop/ab-runner.d.ts +67 -0
- package/dist/skill-loop/ab-runner.d.ts.map +1 -0
- package/dist/skill-loop/ab-runner.js +160 -0
- package/dist/skill-loop/ab-runner.js.map +1 -0
- package/dist/skill-loop/adoption.d.ts +67 -0
- package/dist/skill-loop/adoption.d.ts.map +1 -0
- package/dist/skill-loop/adoption.js +126 -0
- package/dist/skill-loop/adoption.js.map +1 -0
- package/dist/skill-loop/candidate.d.ts +45 -0
- package/dist/skill-loop/candidate.d.ts.map +1 -0
- package/dist/skill-loop/candidate.js +43 -0
- package/dist/skill-loop/candidate.js.map +1 -0
- package/dist/skill-loop/evaluator.d.ts +42 -0
- package/dist/skill-loop/evaluator.d.ts.map +1 -0
- package/dist/skill-loop/evaluator.js +184 -0
- package/dist/skill-loop/evaluator.js.map +1 -0
- package/dist/skill-loop/index.d.ts +27 -0
- package/dist/skill-loop/index.d.ts.map +1 -0
- package/dist/skill-loop/index.js +27 -0
- package/dist/skill-loop/index.js.map +1 -0
- package/dist/skill-loop/reflexion-replay.d.ts +87 -0
- package/dist/skill-loop/reflexion-replay.d.ts.map +1 -0
- package/dist/skill-loop/reflexion-replay.js +110 -0
- package/dist/skill-loop/reflexion-replay.js.map +1 -0
- package/dist/skill-loop/sign-off.d.ts +88 -0
- package/dist/skill-loop/sign-off.d.ts.map +1 -0
- package/dist/skill-loop/sign-off.js +146 -0
- package/dist/skill-loop/sign-off.js.map +1 -0
- package/dist/skill-loop/value-metric.d.ts +55 -0
- package/dist/skill-loop/value-metric.d.ts.map +1 -0
- package/dist/skill-loop/value-metric.js +69 -0
- package/dist/skill-loop/value-metric.js.map +1 -0
- package/dist/skill-loop/versioning.d.ts +36 -0
- package/dist/skill-loop/versioning.d.ts.map +1 -0
- package/dist/skill-loop/versioning.js +47 -0
- package/dist/skill-loop/versioning.js.map +1 -0
- package/dist/skill-manifest/anchor.d.ts +91 -0
- package/dist/skill-manifest/anchor.d.ts.map +1 -0
- package/dist/skill-manifest/anchor.js +331 -0
- package/dist/skill-manifest/anchor.js.map +1 -0
- package/dist/skill-manifest/builder.d.ts +47 -0
- package/dist/skill-manifest/builder.d.ts.map +1 -0
- package/dist/skill-manifest/builder.js +93 -0
- package/dist/skill-manifest/builder.js.map +1 -0
- package/dist/skill-manifest/index.d.ts +13 -0
- package/dist/skill-manifest/index.d.ts.map +1 -0
- package/dist/skill-manifest/index.js +9 -0
- package/dist/skill-manifest/index.js.map +1 -0
- package/dist/skill-manifest/types.d.ts +67 -0
- package/dist/skill-manifest/types.d.ts.map +1 -0
- package/dist/skill-manifest/types.js +16 -0
- package/dist/skill-manifest/types.js.map +1 -0
- package/dist/skill-manifest/verifier.d.ts +42 -0
- package/dist/skill-manifest/verifier.d.ts.map +1 -0
- package/dist/skill-manifest/verifier.js +136 -0
- package/dist/skill-manifest/verifier.js.map +1 -0
- package/dist/skills/brain-query.d.ts +4 -4
- package/dist/skills/brain-store.d.ts +6 -6
- package/dist/skills/errors.d.ts +15 -0
- package/dist/skills/errors.d.ts.map +1 -1
- package/dist/skills/errors.js +21 -0
- package/dist/skills/errors.js.map +1 -1
- package/dist/skills/hitl-request.d.ts +2 -2
- package/dist/skills/index.d.ts +3 -1
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +4 -1
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/markdown/loader.d.ts +52 -0
- package/dist/skills/markdown/loader.d.ts.map +1 -0
- package/dist/skills/markdown/loader.js +93 -0
- package/dist/skills/markdown/loader.js.map +1 -0
- package/dist/skills/markdown/schema.d.ts +432 -0
- package/dist/skills/markdown/schema.d.ts.map +1 -0
- package/dist/skills/markdown/schema.js +121 -0
- package/dist/skills/markdown/schema.js.map +1 -0
- package/dist/skills/poc-md-loader/markdown-loader.d.ts +77 -0
- package/dist/skills/poc-md-loader/markdown-loader.d.ts.map +1 -0
- package/dist/skills/poc-md-loader/markdown-loader.js +125 -0
- package/dist/skills/poc-md-loader/markdown-loader.js.map +1 -0
- package/dist/skills/poc-md-loader/runner.d.ts +24 -0
- package/dist/skills/poc-md-loader/runner.d.ts.map +1 -0
- package/dist/skills/poc-md-loader/runner.js +57 -0
- package/dist/skills/poc-md-loader/runner.js.map +1 -0
- package/dist/skills/poc-md-loader/vitest.poc.config.d.ts +3 -0
- package/dist/skills/poc-md-loader/vitest.poc.config.d.ts.map +1 -0
- package/dist/skills/poc-md-loader/vitest.poc.config.js +13 -0
- package/dist/skills/poc-md-loader/vitest.poc.config.js.map +1 -0
- package/dist/skills/poc-md-loader/web-search/script.d.ts +33 -0
- package/dist/skills/poc-md-loader/web-search/script.d.ts.map +1 -0
- package/dist/skills/poc-md-loader/web-search/script.js +75 -0
- package/dist/skills/poc-md-loader/web-search/script.js.map +1 -0
- package/dist/skills/record-outcome.d.ts +4 -4
- package/dist/skills/send-email.d.ts.map +1 -1
- package/dist/skills/send-email.js +15 -3
- package/dist/skills/send-email.js.map +1 -1
- package/dist/skills/slack-notify.d.ts +4 -4
- package/dist/skills/starknet-balance.d.ts +1 -1
- package/dist/skills/telegram-notify.d.ts +4 -4
- package/dist/skills/web-search.d.ts +1 -1
- package/dist/testing/contracts/event-bus.contract.d.ts.map +1 -1
- package/dist/testing/contracts/event-bus.contract.js +14 -12
- package/dist/testing/contracts/event-bus.contract.js.map +1 -1
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/test-brain-port.d.ts +4 -0
- package/dist/testing/test-brain-port.d.ts.map +1 -1
- package/dist/testing/test-brain-port.js +75 -20
- package/dist/testing/test-brain-port.js.map +1 -1
- package/dist/testing/test-event-bus.d.ts.map +1 -1
- package/dist/testing/test-event-bus.js +89 -36
- package/dist/testing/test-event-bus.js.map +1 -1
- package/dist/trace/schema.d.ts +1 -1
- package/dist/trace/schema.d.ts.map +1 -1
- package/dist/trace/schema.js +1 -1
- package/dist/trace/schema.js.map +1 -1
- package/dist/verify/formal/index.d.ts +44 -0
- package/dist/verify/formal/index.d.ts.map +1 -0
- package/dist/verify/formal/index.js +98 -0
- package/dist/verify/formal/index.js.map +1 -0
- package/dist/verify/formal/policy.d.ts +105 -0
- package/dist/verify/formal/policy.d.ts.map +1 -0
- package/dist/verify/formal/policy.js +159 -0
- package/dist/verify/formal/policy.js.map +1 -0
- package/dist/verify/formal/result.d.ts +50 -0
- package/dist/verify/formal/result.d.ts.map +1 -0
- package/dist/verify/formal/result.js +21 -0
- package/dist/verify/formal/result.js.map +1 -0
- package/dist/verify/formal/solver.d.ts +67 -0
- package/dist/verify/formal/solver.d.ts.map +1 -0
- package/dist/verify/formal/solver.js +184 -0
- package/dist/verify/formal/solver.js.map +1 -0
- package/dist/verify/formal/spec-language.d.ts +80 -0
- package/dist/verify/formal/spec-language.d.ts.map +1 -0
- package/dist/verify/formal/spec-language.js +219 -0
- package/dist/verify/formal/spec-language.js.map +1 -0
- package/docs/attestation.md +199 -0
- package/docs/identity.md +193 -0
- package/package.json +22 -1
- package/src/adapters/llm/anthropic-direct.ts +51 -0
- package/src/adapters/llm/cascade.ts +64 -19
- package/src/adapters/llm/litellm.ts +49 -0
- package/src/compute/difficulty-estimator.ts +111 -0
- package/src/compute/strategies/mixture-of-agents.ts +150 -0
- package/src/compute/strategies/tree-of-thoughts.ts +293 -0
- package/src/compute/strategies/two-phase-orient.ts +147 -0
- package/src/container/protocol.ts +243 -0
- package/src/container/runtime.ts +424 -0
- package/src/db/migrations/026_formal_verify_results.sql +30 -0
- package/src/events/catalogue.ts +54 -0
- package/src/events/index.ts +9 -0
- package/src/events/schemas/citadel.sprint.analyzed.v1.ts +23 -0
- package/src/events/schemas/forge.inbox.reply_classified.v1.ts +15 -0
- package/src/events/schemas/vauban-finance.forecast.generated.v1.ts +11 -0
- package/src/events/schemas/vauban-finance.trade.executed.v1.ts +12 -0
- package/src/events/schemas/vauban.goal.checked.v1.ts +11 -0
- package/src/events/schemas/vauban.rebalancing.checked.v1.ts +11 -0
- package/src/events/schemas/vauban.tax.checked.v1.ts +11 -0
- package/src/events/schemas/vauban.vault.analyzed.v1.ts +21 -0
- package/src/events/schemas/vauban.vault.compounded.v1.ts +12 -0
- package/src/identity/agent-persona.ts +203 -0
- package/src/identity/persona-prompt.ts +84 -0
- package/src/identity/persona-schema.ts +127 -0
- package/src/index.ts +338 -1
- package/src/loop/index.ts +0 -1
- package/src/loop/sdk-loop.ts +5 -8
- package/src/memory/episodic-rrf.ts +224 -0
- package/src/mesh/attenuation.ts +190 -0
- package/src/mesh/delegate.ts +254 -0
- package/src/mesh/dispatcher.ts +301 -0
- package/src/mesh/index.ts +39 -0
- package/src/mesh/types.ts +31 -0
- package/src/orchestration/ooda/skills.ts +177 -0
- package/src/orchestration/ooda/types.ts +3 -9
- package/src/ports/bastion-action.contract.test.ts +355 -0
- package/src/ports/bastion-action.ts +198 -0
- package/src/ports/brain.ts +177 -15
- package/src/ports/citadel-action.contract.test.ts +430 -0
- package/src/ports/citadel-action.ts +174 -0
- package/src/ports/compliance-contract.ts +191 -0
- package/src/ports/db.ts +98 -0
- package/src/ports/delegation.contract.test.ts +428 -0
- package/src/ports/delegation.ts +211 -0
- package/src/ports/event-bus.ts +133 -18
- package/src/ports/federation.contract.test.ts +355 -0
- package/src/ports/federation.ts +190 -0
- package/src/ports/index.ts +186 -1
- package/src/ports/llm-provider.ts +123 -0
- package/src/ports/logger.ts +104 -0
- package/src/ports/manifest-registry.contract.test.ts +324 -0
- package/src/ports/manifest-registry.ts +188 -0
- package/src/ports/observability.contract.test.ts +315 -0
- package/src/ports/observability.ts +150 -0
- package/src/ports/outcome.ts +69 -0
- package/src/ports/privacy.contract.test.ts +413 -0
- package/src/ports/privacy.ts +207 -0
- package/src/ports/tenant-context.contract.test.ts +454 -0
- package/src/ports/tenant-context.ts +150 -0
- package/src/ports/vauban-finance-action.contract.test.ts +335 -0
- package/src/ports/vauban-finance-action.ts +166 -0
- package/src/ports/workflow-runtime.ts +327 -0
- package/src/proof/cert-verify.ts +249 -0
- package/src/replay/replay.ts +11 -8
- package/src/retry/index.ts +227 -0
- package/src/retry/presets.ts +75 -0
- package/src/skill-loop/ab-runner.ts +196 -0
- package/src/skill-loop/adoption.ts +188 -0
- package/src/skill-loop/candidate.ts +75 -0
- package/src/skill-loop/evaluator.ts +238 -0
- package/src/skill-loop/index.ts +51 -0
- package/src/skill-loop/reflexion-replay.ts +173 -0
- package/src/skill-loop/sign-off.ts +247 -0
- package/src/skill-loop/value-metric.ts +120 -0
- package/src/skill-loop/versioning.ts +75 -0
- package/src/skill-manifest/anchor.ts +401 -0
- package/src/skill-manifest/builder.ts +129 -0
- package/src/skill-manifest/index.ts +18 -0
- package/src/skill-manifest/types.ts +72 -0
- package/src/skill-manifest/verifier.ts +198 -0
- package/src/skills/errors.ts +30 -2
- package/src/skills/index.ts +19 -0
- package/src/skills/markdown/loader.ts +129 -0
- package/src/skills/markdown/schema.ts +144 -0
- package/src/skills/poc-md-loader/e2e-parity.test.ts +237 -0
- package/src/skills/poc-md-loader/markdown-loader.ts +161 -0
- package/src/skills/poc-md-loader/runner.ts +82 -0
- package/src/skills/poc-md-loader/vitest.poc.config.ts +13 -0
- package/src/skills/poc-md-loader/web-search/SKILL.md +42 -0
- package/src/skills/poc-md-loader/web-search/script.ts +109 -0
- package/src/skills/send-email.ts +15 -3
- package/src/testing/contracts/event-bus.contract.ts +16 -14
- package/src/testing/test-brain-port.ts +98 -24
- package/src/testing/test-event-bus.ts +104 -43
- package/src/trace/schema.ts +1 -1
- package/src/verify/formal/index.ts +154 -0
- package/src/verify/formal/policy.ts +253 -0
- package/src/verify/formal/result.ts +52 -0
- package/src/verify/formal/solver.ts +235 -0
- package/src/verify/formal/spec-language.ts +274 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CitadelActionPort — host adapter for Citadel governance operations.
|
|
3
|
+
*
|
|
4
|
+
* Implements tiered access control (T1-T4) per BYOA (Bring Your Own Agent) framework.
|
|
5
|
+
* Only T3+ agents can seal sprints, T1 is read-only, T4 requires on-chain signing.
|
|
6
|
+
*
|
|
7
|
+
* Source: MASTER-PLAN-v5.md §1.3 (CC service layer) + vauban-gouvernance/rules/ai/tiered-gates.md
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// ─── Types ─────────────────────────────────────────────────────────────────
|
|
11
|
+
|
|
12
|
+
export type AgentTier = "T1" | "T2" | "T3" | "T4";
|
|
13
|
+
export type TaskStatus =
|
|
14
|
+
| "todo"
|
|
15
|
+
| "in_progress"
|
|
16
|
+
| "done"
|
|
17
|
+
| "blocked"
|
|
18
|
+
| "rejected";
|
|
19
|
+
|
|
20
|
+
export interface SprintInput {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly goal?: string;
|
|
23
|
+
readonly start_date?: string; // ISO 8601
|
|
24
|
+
readonly end_date?: string;
|
|
25
|
+
readonly project_slug: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface TaskRef {
|
|
29
|
+
readonly ref: string; // format: "project:sprint-N:task-id"
|
|
30
|
+
readonly project: string;
|
|
31
|
+
readonly sprint: string;
|
|
32
|
+
readonly task_id: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface VerificationEvidence {
|
|
36
|
+
readonly passed: boolean;
|
|
37
|
+
readonly evidence_text: string;
|
|
38
|
+
readonly evidence_hash: string; // sha256 hex
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface DecisionInput {
|
|
42
|
+
readonly decision: string;
|
|
43
|
+
readonly context: string;
|
|
44
|
+
readonly options: readonly string[];
|
|
45
|
+
readonly chosen: string;
|
|
46
|
+
readonly rationale: string;
|
|
47
|
+
readonly tags?: readonly string[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface ActionContext {
|
|
51
|
+
readonly agentId: string;
|
|
52
|
+
readonly agentTier: AgentTier;
|
|
53
|
+
readonly runId: string;
|
|
54
|
+
readonly tenantId?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ─── Results ─────────────────────────────────────────────────────────────────
|
|
58
|
+
|
|
59
|
+
export interface SprintRef {
|
|
60
|
+
readonly sprint_id: string;
|
|
61
|
+
readonly project_slug: string;
|
|
62
|
+
readonly name: string;
|
|
63
|
+
readonly created_at: Date;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface SealedSprintClaim {
|
|
67
|
+
readonly sprint_id: string;
|
|
68
|
+
readonly sealed_at: Date;
|
|
69
|
+
readonly verification_evidence_hash: string;
|
|
70
|
+
readonly sealed_by_agent: string;
|
|
71
|
+
readonly anchor_id?: string; // L3 blockchain anchor
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface DecisionClaim {
|
|
75
|
+
readonly decision_id: string;
|
|
76
|
+
readonly created_at: Date;
|
|
77
|
+
readonly archived_to_brain: boolean;
|
|
78
|
+
readonly cascade_triggered?: boolean; // ADR cascade hook
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// ─── Port interface ────────────────────────────────────────────────────────
|
|
82
|
+
|
|
83
|
+
export interface CitadelActionPort {
|
|
84
|
+
/**
|
|
85
|
+
* Create a new sprint in a project.
|
|
86
|
+
* T2+ only. T1 throws CitadelTierViolationError.
|
|
87
|
+
*/
|
|
88
|
+
createSprint(input: SprintInput, ctx: ActionContext): Promise<SprintRef>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Update task status within a sprint.
|
|
92
|
+
* T2+ can transition: todo→in_progress, in_progress→done, *→blocked.
|
|
93
|
+
* T3+ can seal (→done with verification).
|
|
94
|
+
*/
|
|
95
|
+
updateTaskStatus(
|
|
96
|
+
ref: TaskRef,
|
|
97
|
+
status: TaskStatus,
|
|
98
|
+
ctx: ActionContext
|
|
99
|
+
): Promise<void>;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Seal a completed sprint with verification evidence.
|
|
103
|
+
* T3+ only. Emits SealedSprintClaim (anchor to L3 deferred Phase 1+).
|
|
104
|
+
* Verification evidence hash proves execution of verification_scenario.
|
|
105
|
+
*/
|
|
106
|
+
sealSprint(
|
|
107
|
+
sprintId: string,
|
|
108
|
+
evidence: VerificationEvidence,
|
|
109
|
+
ctx: ActionContext
|
|
110
|
+
): Promise<SealedSprintClaim>;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Record a decision to governance layer.
|
|
114
|
+
* T2+ can record. T3+ triggers optional ADR cascade hook.
|
|
115
|
+
* Returns DecisionClaim with Brain archive status.
|
|
116
|
+
*/
|
|
117
|
+
recordDecision(
|
|
118
|
+
decision: DecisionInput,
|
|
119
|
+
ctx: ActionContext
|
|
120
|
+
): Promise<DecisionClaim>;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// ─── Typed errors ─────────────────────────────────────────────────────────
|
|
124
|
+
|
|
125
|
+
export class CitadelTierViolationError extends Error {
|
|
126
|
+
constructor(
|
|
127
|
+
message: string,
|
|
128
|
+
public readonly required_tier: AgentTier,
|
|
129
|
+
public readonly actual_tier: AgentTier,
|
|
130
|
+
public readonly operation: string,
|
|
131
|
+
public readonly cause?: unknown
|
|
132
|
+
) {
|
|
133
|
+
super(message);
|
|
134
|
+
this.name = "CitadelTierViolationError";
|
|
135
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export class CitadelTaskRefNotFoundError extends Error {
|
|
140
|
+
constructor(
|
|
141
|
+
public readonly task_ref: string,
|
|
142
|
+
public readonly cause?: unknown
|
|
143
|
+
) {
|
|
144
|
+
super(`Task not found: ${task_ref}`);
|
|
145
|
+
this.name = "CitadelTaskRefNotFoundError";
|
|
146
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export class CitadelSprintNotActiveError extends Error {
|
|
151
|
+
constructor(
|
|
152
|
+
public readonly sprint_id: string,
|
|
153
|
+
public readonly current_status: string,
|
|
154
|
+
public readonly cause?: unknown
|
|
155
|
+
) {
|
|
156
|
+
super(
|
|
157
|
+
`Sprint ${sprint_id} is not active (status: ${current_status}). Cannot seal.`
|
|
158
|
+
);
|
|
159
|
+
this.name = "CitadelSprintNotActiveError";
|
|
160
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export class CitadelInvalidStateTransitionError extends Error {
|
|
165
|
+
constructor(
|
|
166
|
+
public readonly current_status: TaskStatus,
|
|
167
|
+
public readonly requested_status: TaskStatus,
|
|
168
|
+
public readonly cause?: unknown
|
|
169
|
+
) {
|
|
170
|
+
super(`Invalid state transition: ${current_status} → ${requested_status}`);
|
|
171
|
+
this.name = "CitadelInvalidStateTransitionError";
|
|
172
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ComplianceContractPort — runtime compliance gate for the Vauban Integration Spine.
|
|
3
|
+
*
|
|
4
|
+
* Implements the G-2 Cedar pivot from S5 spec:
|
|
5
|
+
* - pre-step: block or warn before capability invocation
|
|
6
|
+
* - post-step: audit trail after invocation
|
|
7
|
+
* - validateManifest: conflict detection at registration
|
|
8
|
+
*
|
|
9
|
+
* Cedar policy bundles: eu.gdpr / eu.mica / eu.tfr (V0 scope per S5 Q5.1).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// ─── Jurisdictions ────────────────────────────────────────────────────────────
|
|
13
|
+
|
|
14
|
+
export type Jurisdiction = "FR.v1" | "EU.v1" | "CH.v1" | "UK.v1" | "SG.v1";
|
|
15
|
+
|
|
16
|
+
export const SUPPORTED_JURISDICTIONS_V0: Jurisdiction[] = ["FR.v1", "EU.v1"];
|
|
17
|
+
|
|
18
|
+
// ─── Legal basis refs (S5 §4 encoding) ───────────────────────────────────────
|
|
19
|
+
|
|
20
|
+
export type LegalBasisRef =
|
|
21
|
+
| "gdpr.art6_1_a" // consent
|
|
22
|
+
| "gdpr.art6_1_b" // contract performance
|
|
23
|
+
| "gdpr.art6_1_c" // legal obligation
|
|
24
|
+
| "gdpr.art6_1_f" // legitimate interests
|
|
25
|
+
| "mica.art14" // MiCA disclosure obligation
|
|
26
|
+
| "tfr.art4" // TFR data retention obligation
|
|
27
|
+
| "cjeu.c520_21"; // CJEU C-520/21 mandate path
|
|
28
|
+
|
|
29
|
+
export type LegalBasisDomain =
|
|
30
|
+
| "processing"
|
|
31
|
+
| "retention"
|
|
32
|
+
| "transfer"
|
|
33
|
+
| "consent";
|
|
34
|
+
|
|
35
|
+
export interface LegalBasisDecl {
|
|
36
|
+
domain: LegalBasisDomain;
|
|
37
|
+
basis: LegalBasisRef;
|
|
38
|
+
scope?: Jurisdiction[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ─── Data classification ──────────────────────────────────────────────────────
|
|
42
|
+
|
|
43
|
+
export type DataClass = "public" | "internal" | "confidential" | "secret";
|
|
44
|
+
|
|
45
|
+
// ─── Rule model (S5 §3.2) ────────────────────────────────────────────────────
|
|
46
|
+
|
|
47
|
+
export type EnforcementLevel = "block" | "warn" | "log";
|
|
48
|
+
export type RuleSource = "declared" | "normative";
|
|
49
|
+
|
|
50
|
+
export interface ComplianceRule {
|
|
51
|
+
readonly id: string;
|
|
52
|
+
readonly source: RuleSource;
|
|
53
|
+
readonly jurisdiction: Jurisdiction;
|
|
54
|
+
readonly legal_ref: LegalBasisRef;
|
|
55
|
+
readonly enforcement: EnforcementLevel;
|
|
56
|
+
readonly rationale: string;
|
|
57
|
+
readonly authority?: string; // e.g. "EDPB Guidelines 8/2020"
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// ─── ComplianceContract (S5 §3.1) ────────────────────────────────────────────
|
|
61
|
+
|
|
62
|
+
export type ComplianceMode = "strict" | "audit_only";
|
|
63
|
+
|
|
64
|
+
export interface ComplianceContract {
|
|
65
|
+
readonly jurisdictions: Jurisdiction[];
|
|
66
|
+
readonly legal_bases: LegalBasisDecl[];
|
|
67
|
+
readonly data_class: DataClass;
|
|
68
|
+
readonly mode: ComplianceMode;
|
|
69
|
+
readonly tier: string;
|
|
70
|
+
readonly rules: ComplianceRule[];
|
|
71
|
+
readonly retention: string; // ISO duration e.g. "P7Y"
|
|
72
|
+
readonly audit_format?: "json" | "pdf";
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ─── Invocation context ───────────────────────────────────────────────────────
|
|
76
|
+
|
|
77
|
+
export interface CapabilityInvocation {
|
|
78
|
+
readonly action: string; // e.g. "bastion.swap", "brain.archive", "glacis.attest"
|
|
79
|
+
readonly tenantId: string;
|
|
80
|
+
readonly dataClass: DataClass;
|
|
81
|
+
readonly legalBasis?: LegalBasisRef;
|
|
82
|
+
readonly jurisdiction?: Jurisdiction;
|
|
83
|
+
readonly requiresConsent?: boolean;
|
|
84
|
+
readonly requiresVerifiedHuman?: boolean;
|
|
85
|
+
readonly stepIndex?: number;
|
|
86
|
+
readonly workflowRunId?: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface TenantContext {
|
|
90
|
+
readonly tenantId: string;
|
|
91
|
+
readonly glacisMode: "verified" | "degraded_verified" | "unverified";
|
|
92
|
+
readonly verifiedHuman: boolean;
|
|
93
|
+
readonly jurisdictions: Jurisdiction[];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ─── Decision types ───────────────────────────────────────────────────────────
|
|
97
|
+
|
|
98
|
+
export interface ComplianceViolation {
|
|
99
|
+
readonly ruleId: string;
|
|
100
|
+
readonly articleRef: string; // e.g. "GDPR Art 6(1)(a)"
|
|
101
|
+
readonly description: string;
|
|
102
|
+
readonly severity: "block" | "warn";
|
|
103
|
+
readonly remediationHint?: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type ComplianceGate =
|
|
107
|
+
| { readonly decision: "proceed"; readonly warnings: ComplianceViolation[] }
|
|
108
|
+
| { readonly decision: "block"; readonly violation: ComplianceViolation };
|
|
109
|
+
|
|
110
|
+
export interface ComplianceAuditResult {
|
|
111
|
+
readonly decision: "proceed" | "block" | "warn";
|
|
112
|
+
readonly violations: ComplianceViolation[];
|
|
113
|
+
readonly auditClaimEmitted: boolean;
|
|
114
|
+
readonly evaluatedRules: number;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// ─── Manifest validation ──────────────────────────────────────────────────────
|
|
118
|
+
|
|
119
|
+
export interface PolicyConflict {
|
|
120
|
+
readonly rule1Id: string;
|
|
121
|
+
readonly rule2Id: string;
|
|
122
|
+
readonly description: string;
|
|
123
|
+
readonly status: "CONFLICT" | "CONFLICT_UNDETERMINED";
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface ManifestValidationResult {
|
|
127
|
+
readonly valid: boolean;
|
|
128
|
+
readonly conflicts: PolicyConflict[];
|
|
129
|
+
readonly missingLegalBases: string[];
|
|
130
|
+
readonly jurisdictionWarnings: string[];
|
|
131
|
+
readonly evaluationTimeMs: number;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ─── Port interface ───────────────────────────────────────────────────────────
|
|
135
|
+
|
|
136
|
+
export interface ComplianceContractPort {
|
|
137
|
+
/**
|
|
138
|
+
* Pre-step gate — called before any capability invocation.
|
|
139
|
+
* In 'strict' mode: block on first violation.
|
|
140
|
+
* In 'audit_only' mode: never block, accumulate warnings.
|
|
141
|
+
*/
|
|
142
|
+
preStep(
|
|
143
|
+
invocation: CapabilityInvocation,
|
|
144
|
+
contract: ComplianceContract,
|
|
145
|
+
ctx: TenantContext
|
|
146
|
+
): Promise<ComplianceGate>;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Post-step audit — called after capability invocation to emit audit claims.
|
|
150
|
+
* Always runs regardless of pre-step outcome.
|
|
151
|
+
*/
|
|
152
|
+
postStep(
|
|
153
|
+
invocation: CapabilityInvocation,
|
|
154
|
+
contract: ComplianceContract,
|
|
155
|
+
ctx: TenantContext
|
|
156
|
+
): Promise<ComplianceAuditResult>;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Manifest validation — called at registration, before any workflow runs.
|
|
160
|
+
* Cedar conflict detection per G-3. Timeout → CONFLICT_UNDETERMINED (not fail).
|
|
161
|
+
*/
|
|
162
|
+
validateManifest(
|
|
163
|
+
contract: ComplianceContract,
|
|
164
|
+
opts?: { timeoutMs?: number }
|
|
165
|
+
): Promise<ManifestValidationResult>;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// ─── Typed errors ─────────────────────────────────────────────────────────────
|
|
169
|
+
|
|
170
|
+
export class CompliancePolicyError extends Error {
|
|
171
|
+
constructor(
|
|
172
|
+
message: string,
|
|
173
|
+
public readonly ruleId: string,
|
|
174
|
+
public readonly cause?: unknown
|
|
175
|
+
) {
|
|
176
|
+
super(message);
|
|
177
|
+
this.name = "CompliancePolicyError";
|
|
178
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export class ComplianceEvaluationTimeoutError extends Error {
|
|
183
|
+
constructor(
|
|
184
|
+
public readonly timeoutMs: number,
|
|
185
|
+
public readonly cause?: unknown
|
|
186
|
+
) {
|
|
187
|
+
super(`Compliance evaluation timed out after ${timeoutMs}ms`);
|
|
188
|
+
this.name = "ComplianceEvaluationTimeoutError";
|
|
189
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
190
|
+
}
|
|
191
|
+
}
|
package/src/ports/db.ts
CHANGED
|
@@ -2,6 +2,104 @@
|
|
|
2
2
|
* DbPort — re-export of the existing minimal DbClient shape from
|
|
3
3
|
* tracking/agent-run-tracker. Alias DbPort is the port-suffixed name
|
|
4
4
|
* used across other ports; DbClient remains exported for back-compat.
|
|
5
|
+
*
|
|
6
|
+
* OTel instrumentation: import { createTracedDbPort } to wrap any
|
|
7
|
+
* DbPort implementation with OpenTelemetry spans per query.
|
|
8
|
+
* Gracefully degrades to noop spans when no OTel SDK is installed.
|
|
5
9
|
*/
|
|
10
|
+
|
|
11
|
+
import type { Span } from "@opentelemetry/api";
|
|
12
|
+
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
13
|
+
import type { DbClient } from "../tracking/agent-run-tracker.js";
|
|
14
|
+
|
|
15
|
+
const PORT_TRACER = trace.getTracer("vauban-agent-sdk.ports", "0.1.0");
|
|
16
|
+
|
|
6
17
|
export type { DbClient as DbPort } from "../tracking/agent-run-tracker.js";
|
|
7
18
|
export type { DbClient } from "../tracking/agent-run-tracker.js";
|
|
19
|
+
|
|
20
|
+
// ─── Typed errors ─────────────────────────────────────────────────────────────
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Thrown when the database connection is lost (ECONNREFUSED, pool exhausted,
|
|
24
|
+
* or TLS handshake failed). Callers should retry with exponential backoff
|
|
25
|
+
* once the connection pool is re-established.
|
|
26
|
+
*/
|
|
27
|
+
export class DbConnectionLostError extends Error {
|
|
28
|
+
constructor(message: string, public readonly cause?: unknown) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.name = "DbConnectionLostError";
|
|
31
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Thrown when a database query exceeds the configured statement_timeout or
|
|
37
|
+
* the caller-supplied timeoutMs. The query may have been cancelled by the
|
|
38
|
+
* server — retrying the same query without changes is unlikely to succeed.
|
|
39
|
+
*/
|
|
40
|
+
export class DbQueryTimeoutError extends Error {
|
|
41
|
+
/** The SQL statement that timed out (truncated for logging). */
|
|
42
|
+
readonly queryPreview: string;
|
|
43
|
+
/** Timeout that was exceeded, in milliseconds. */
|
|
44
|
+
readonly timeoutMs: number;
|
|
45
|
+
|
|
46
|
+
constructor(
|
|
47
|
+
message: string,
|
|
48
|
+
queryPreview: string,
|
|
49
|
+
timeoutMs: number,
|
|
50
|
+
public readonly cause?: unknown
|
|
51
|
+
) {
|
|
52
|
+
super(message);
|
|
53
|
+
this.name = "DbQueryTimeoutError";
|
|
54
|
+
this.queryPreview = queryPreview;
|
|
55
|
+
this.timeoutMs = timeoutMs;
|
|
56
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Wrap any DbPort implementation with OTel spans per query() call.
|
|
62
|
+
* The span captures the SQL preview (first 200 chars) and params count.
|
|
63
|
+
* Gracefully degrades to noop spans when no OTel SDK is installed.
|
|
64
|
+
*
|
|
65
|
+
* Usage:
|
|
66
|
+
* const raw: DbPort = pgPool;
|
|
67
|
+
* const traced = createTracedDbPort(raw);
|
|
68
|
+
* const { rows } = await traced.query("SELECT ...") // emits "db.query" span
|
|
69
|
+
*/
|
|
70
|
+
export function createTracedDbPort(impl: DbClient): DbClient {
|
|
71
|
+
return {
|
|
72
|
+
async query<T extends object>(
|
|
73
|
+
sql: string,
|
|
74
|
+
params?: unknown[]
|
|
75
|
+
): Promise<{ rows: T[]; rowCount?: number | undefined }> {
|
|
76
|
+
return PORT_TRACER.startActiveSpan(
|
|
77
|
+
"db.query",
|
|
78
|
+
{
|
|
79
|
+
attributes: {
|
|
80
|
+
"db.sql_preview": sql.slice(0, 200),
|
|
81
|
+
"db.params_count": params?.length ?? 0,
|
|
82
|
+
"vauban.port.name": "db",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
async (span: Span) => {
|
|
86
|
+
try {
|
|
87
|
+
const result = await impl.query<T>(sql, params);
|
|
88
|
+
span.setAttributes({
|
|
89
|
+
"db.row_count": result.rowCount ?? result.rows.length,
|
|
90
|
+
});
|
|
91
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
92
|
+
return result;
|
|
93
|
+
} catch (err) {
|
|
94
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
95
|
+
span.setStatus({ code: SpanStatusCode.ERROR, message });
|
|
96
|
+
if (err instanceof Error) span.recordException(err);
|
|
97
|
+
throw err;
|
|
98
|
+
} finally {
|
|
99
|
+
span.end();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|