@vauban-org/agent-sdk 1.0.0 → 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 +46 -46
- 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 +6 -6
- package/dist/events/schemas/citadel.sprint.closed.v1.d.ts +2 -2
- package/dist/events/schemas/forge.inbox.reply_classified.v1.d.ts +6 -6
- 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.goal.checked.v1.d.ts +2 -2
- package/dist/events/schemas/vauban.rebalancing.checked.v1.d.ts +2 -2
- package/dist/events/schemas/vauban.tax.checked.v1.d.ts +2 -2
- package/dist/events/schemas/vauban.vault.analyzed.v1.d.ts +6 -6
- 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/minimal-loop.js +293 -287
- 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/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 -0
- 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/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 +34 -17
- 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/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/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/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 -0
- 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/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,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/verify/formal/spec-language.ts
|
|
3
|
+
*
|
|
4
|
+
* Sprint-587 — DSL for axiom specifications, compiled to SMT-LIB v2.
|
|
5
|
+
*
|
|
6
|
+
* Design philosophy (inspired by FormalJudge, arXiv:2602.11136) : agent-cycle
|
|
7
|
+
* properties are expressed as small, typed pre/post-condition tuples. Each
|
|
8
|
+
* condition is mapped to an SMT-LIB fragment by {@link compileToSmt}, which
|
|
9
|
+
* frames the property as a NEGATION of the post-conditions under the
|
|
10
|
+
* pre-conditions. This way, Z3 returning `sat` means a counterexample exists
|
|
11
|
+
* (= UNSAFE) and `unsat` means the post-conditions hold (= SAFE).
|
|
12
|
+
*
|
|
13
|
+
* Bound types : Reals for budgets and ratios, Bools for binary properties,
|
|
14
|
+
* Sets-as-symbols for scope subset checks.
|
|
15
|
+
*
|
|
16
|
+
* @module verify/formal/spec-language
|
|
17
|
+
*/
|
|
18
|
+
function ensureDecl(ctx, decl, name) {
|
|
19
|
+
if (ctx.declared.has(name))
|
|
20
|
+
return;
|
|
21
|
+
ctx.declared.add(name);
|
|
22
|
+
ctx.declarations.push(decl);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Lower a single Condition into SMT-LIB assertions appended to `ctx`.
|
|
26
|
+
* `negated` flag : when true, the condition is being added as a negated
|
|
27
|
+
* post-condition (i.e. we want to find a counterexample).
|
|
28
|
+
*/
|
|
29
|
+
function lowerCondition(c, ctx, negated) {
|
|
30
|
+
switch (c.type) {
|
|
31
|
+
case "budget_constraint": {
|
|
32
|
+
// parent_budget >= 0, child_budget >= 0, child_budget <= parent_budget * fraction
|
|
33
|
+
ensureDecl(ctx, "(declare-const parent_budget Real)", "parent_budget");
|
|
34
|
+
ensureDecl(ctx, "(declare-const child_budget Real)", "child_budget");
|
|
35
|
+
// Positivity is part of the pre-state, always assert.
|
|
36
|
+
ctx.assertions.push("(assert (>= parent_budget 0))");
|
|
37
|
+
ctx.assertions.push("(assert (>= child_budget 0))");
|
|
38
|
+
const expr = `(<= child_budget (* parent_budget ${c.child_max_fraction}))`;
|
|
39
|
+
ctx.assertions.push(`(assert ${negated ? `(not ${expr})` : expr})`);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
case "scope_subset": {
|
|
43
|
+
// Encode each child element as a Bool : it must be present in parent.
|
|
44
|
+
// We do this by reducing to a boolean conjunction over the listed
|
|
45
|
+
// child elements. Mismatches surface as a counterexample.
|
|
46
|
+
const parentSet = new Set(c.parent_scope);
|
|
47
|
+
const childOk = c.child_scope.every((s) => parentSet.has(s));
|
|
48
|
+
// No declarations needed — fold the result statically into a bool.
|
|
49
|
+
const expr = childOk ? "true" : "false";
|
|
50
|
+
ctx.assertions.push(`(assert ${negated ? `(not ${expr})` : expr})`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
case "no_pii_in_output": {
|
|
54
|
+
const name = c.pii_count_var ?? "pii_count";
|
|
55
|
+
ensureDecl(ctx, `(declare-const ${name} Int)`, name);
|
|
56
|
+
// pii_count >= 0 (always)
|
|
57
|
+
ctx.assertions.push(`(assert (>= ${name} 0))`);
|
|
58
|
+
const expr = `(= ${name} 0)`;
|
|
59
|
+
ctx.assertions.push(`(assert ${negated ? `(not ${expr})` : expr})`);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
case "cost_positive_roi": {
|
|
63
|
+
ensureDecl(ctx, "(declare-const cost Real)", "cost");
|
|
64
|
+
ensureDecl(ctx, "(declare-const value Real)", "value");
|
|
65
|
+
ctx.assertions.push("(assert (> cost 0))");
|
|
66
|
+
ctx.assertions.push("(assert (>= value 0))");
|
|
67
|
+
const expr = `(>= (/ value cost) ${c.min_roi_ratio})`;
|
|
68
|
+
ctx.assertions.push(`(assert ${negated ? `(not ${expr})` : expr})`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
case "response_time": {
|
|
72
|
+
ensureDecl(ctx, "(declare-const response_ms Real)", "response_ms");
|
|
73
|
+
ctx.assertions.push("(assert (>= response_ms 0))");
|
|
74
|
+
const expr = `(<= response_ms ${c.max_ms})`;
|
|
75
|
+
ctx.assertions.push(`(assert ${negated ? `(not ${expr})` : expr})`);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
case "custom_smt": {
|
|
79
|
+
const frag = c.smt_fragment.trim();
|
|
80
|
+
// The custom fragment is expected to be a parenthesised assertion body.
|
|
81
|
+
if (negated) {
|
|
82
|
+
ctx.assertions.push(`(assert (not ${frag}))`);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
ctx.assertions.push(`(assert ${frag})`);
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Compile an {@link AxiomSpec} into an SMT-LIB v2 program string.
|
|
93
|
+
*
|
|
94
|
+
* Pattern : preconditions are asserted as-is ; postconditions are joined by
|
|
95
|
+
* conjunction and asserted NEGATED. A counterexample (z3 returns `sat`)
|
|
96
|
+
* therefore means : "pre-conditions hold AND at least one post-condition
|
|
97
|
+
* fails" — i.e. an UNSAFE outcome.
|
|
98
|
+
*
|
|
99
|
+
* Includes `(check-sat)` and `(get-model)` as terminating commands.
|
|
100
|
+
*/
|
|
101
|
+
export function compileToSmt(spec) {
|
|
102
|
+
const ctx = {
|
|
103
|
+
declared: new Set(),
|
|
104
|
+
declarations: [],
|
|
105
|
+
assertions: [],
|
|
106
|
+
};
|
|
107
|
+
// Header — set logic to QF_LRA (quantifier-free linear real arithmetic
|
|
108
|
+
// plus integers) which covers all our supported condition kinds.
|
|
109
|
+
const header = ["(set-logic ALL)", `; AxiomSpec : ${spec.axiom}`];
|
|
110
|
+
// Preconditions : assert as-is (positive form).
|
|
111
|
+
for (const pre of spec.preconditions) {
|
|
112
|
+
lowerCondition(pre, ctx, false);
|
|
113
|
+
}
|
|
114
|
+
// Postconditions : conjoin and negate.
|
|
115
|
+
// Strategy : assert each one negated separately using De Morgan. We want
|
|
116
|
+
// NOT (post1 AND post2 AND …) ≡ (NOT post1) OR (NOT post2) OR …
|
|
117
|
+
// For check-sat-as-counterexample, we want the solver to find *any*
|
|
118
|
+
// violation, so we encode the disjunction with an auxiliary Bool flag
|
|
119
|
+
// per postcondition. Simpler equivalent : assert (or (not post1) (not post2) …).
|
|
120
|
+
if (spec.postconditions.length === 0) {
|
|
121
|
+
// Empty postcondition set : trivially SAFE (no obligation to verify).
|
|
122
|
+
ctx.assertions.push("(assert false)");
|
|
123
|
+
}
|
|
124
|
+
else if (spec.postconditions.length === 1) {
|
|
125
|
+
lowerCondition(spec.postconditions[0], ctx, true);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// Build per-postcondition expression strings via a side-context, then
|
|
129
|
+
// emit a single `(assert (or ...))`.
|
|
130
|
+
const subCtx = {
|
|
131
|
+
declared: ctx.declared,
|
|
132
|
+
declarations: ctx.declarations,
|
|
133
|
+
assertions: [],
|
|
134
|
+
};
|
|
135
|
+
const negatedExprs = [];
|
|
136
|
+
for (const post of spec.postconditions) {
|
|
137
|
+
const before = subCtx.assertions.length;
|
|
138
|
+
lowerCondition(post, subCtx, true);
|
|
139
|
+
// The last appended assertion is "(assert <neg expr>)" or pre-assertions.
|
|
140
|
+
// To recover only the negated post-condition body, we accept that some
|
|
141
|
+
// conditions append additional non-negotiable preconditions (positivity).
|
|
142
|
+
// Those are valid in any case and stay in the main assertion list.
|
|
143
|
+
for (let i = before; i < subCtx.assertions.length; i++) {
|
|
144
|
+
const a = subCtx.assertions[i];
|
|
145
|
+
// Heuristic : split positivity asserts (>= x 0) and the negated body.
|
|
146
|
+
// The negated body always contains "(not ".
|
|
147
|
+
if (a.includes("(not ")) {
|
|
148
|
+
// Extract the inner expr "(not …)" inside the outer assert.
|
|
149
|
+
const inner = a.slice("(assert ".length, -1);
|
|
150
|
+
negatedExprs.push(inner);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Drop the negated body assertions from subCtx so we only keep
|
|
154
|
+
// the positivity ones in the main assertion list.
|
|
155
|
+
subCtx.assertions = subCtx.assertions.filter((a) => !a.includes("(not "));
|
|
156
|
+
}
|
|
157
|
+
ctx.assertions = subCtx.assertions;
|
|
158
|
+
ctx.assertions.push(`(assert (or ${negatedExprs.join(" ")}))`);
|
|
159
|
+
}
|
|
160
|
+
return [
|
|
161
|
+
...header,
|
|
162
|
+
...ctx.declarations,
|
|
163
|
+
...ctx.assertions,
|
|
164
|
+
"(check-sat)",
|
|
165
|
+
"(get-model)",
|
|
166
|
+
].join("\n");
|
|
167
|
+
}
|
|
168
|
+
// ---------------------------------------------------------------------------
|
|
169
|
+
// Pre-built specs for the 5 Vauban axioms
|
|
170
|
+
// ---------------------------------------------------------------------------
|
|
171
|
+
/**
|
|
172
|
+
* Default per-axiom AxiomSpec presets. Consumers can override the timeout
|
|
173
|
+
* or augment with additional conditions before passing to `formalVerify`.
|
|
174
|
+
*
|
|
175
|
+
* Robuste : 5s — engineering robustness, may need richer checks
|
|
176
|
+
* Institutionnel : 10s — strongest spec, PII + scope-subset + budget
|
|
177
|
+
* SOTA : 2s — lightweight (single ROI check on cost)
|
|
178
|
+
* AntiFragile : 1s — response-time bound only
|
|
179
|
+
* Profitable : 1s — cost-vs-value ROI check
|
|
180
|
+
*/
|
|
181
|
+
export const AXIOM_SPECS = {
|
|
182
|
+
Robuste: {
|
|
183
|
+
axiom: "Robuste",
|
|
184
|
+
preconditions: [],
|
|
185
|
+
postconditions: [
|
|
186
|
+
{ type: "budget_constraint", child_max_fraction: 1.0 },
|
|
187
|
+
{ type: "response_time", max_ms: 30_000 },
|
|
188
|
+
],
|
|
189
|
+
timeout_ms: 5000,
|
|
190
|
+
},
|
|
191
|
+
Institutionnel: {
|
|
192
|
+
axiom: "Institutionnel",
|
|
193
|
+
preconditions: [],
|
|
194
|
+
postconditions: [
|
|
195
|
+
{ type: "no_pii_in_output" },
|
|
196
|
+
{ type: "budget_constraint", child_max_fraction: 1.0 },
|
|
197
|
+
],
|
|
198
|
+
timeout_ms: 10_000,
|
|
199
|
+
},
|
|
200
|
+
SOTA: {
|
|
201
|
+
axiom: "SOTA",
|
|
202
|
+
preconditions: [],
|
|
203
|
+
postconditions: [{ type: "cost_positive_roi", min_roi_ratio: 1.0 }],
|
|
204
|
+
timeout_ms: 2000,
|
|
205
|
+
},
|
|
206
|
+
AntiFragile: {
|
|
207
|
+
axiom: "AntiFragile",
|
|
208
|
+
preconditions: [],
|
|
209
|
+
postconditions: [{ type: "response_time", max_ms: 60_000 }],
|
|
210
|
+
timeout_ms: 1000,
|
|
211
|
+
},
|
|
212
|
+
Profitable: {
|
|
213
|
+
axiom: "Profitable",
|
|
214
|
+
preconditions: [],
|
|
215
|
+
postconditions: [{ type: "cost_positive_roi", min_roi_ratio: 1.5 }],
|
|
216
|
+
timeout_ms: 1000,
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
//# sourceMappingURL=spec-language.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-language.js","sourceRoot":"","sources":["../../../src/verify/formal/spec-language.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA4CH,SAAS,UAAU,CAAC,GAAmB,EAAE,IAAY,EAAE,IAAY;IACjE,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO;IACnC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACvB,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,SAAS,cAAc,CACrB,CAAY,EACZ,GAAmB,EACnB,OAAgB;IAEhB,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;QACf,KAAK,mBAAmB,CAAC,CAAC,CAAC;YACzB,kFAAkF;YAClF,UAAU,CAAC,GAAG,EAAE,oCAAoC,EA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199 @@
|
|
|
1
|
+
# Run Certificate Verification (Standalone)
|
|
2
|
+
|
|
3
|
+
**Module:** `@vauban-org/agent-sdk/proof/cert-verify` · **Since:** CC v3.1 sprint-562 (Livrable D, 2026-05-14)
|
|
4
|
+
|
|
5
|
+
The standalone verifier in `src/proof/cert-verify.ts` verifies a `SignedRunProofCertificate` without any database or network dependency. It is the verification counterpart to the CC server's signing surface (`src/proof/ed25519-signer.ts`) and implements [draft-vauban-skill-attestation-00 §5](https://datatracker.ietf.org/doc/draft-vauban-skill-attestation/).
|
|
6
|
+
|
|
7
|
+
Suitable for: CI pipelines, third-party integrators, audits, and the `preste attest verify` CLI command.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { verifyRunCertificate } from "@vauban-org/agent-sdk/proof/cert-verify";
|
|
13
|
+
import { readFileSync } from "node:fs";
|
|
14
|
+
|
|
15
|
+
const cert = JSON.parse(readFileSync("cert.json", "utf-8"));
|
|
16
|
+
|
|
17
|
+
const result = verifyRunCertificate(cert);
|
|
18
|
+
|
|
19
|
+
if (!result.valid) {
|
|
20
|
+
console.error(`Verification failed: ${result.reason} — ${result.details}`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
console.log("Certificate valid. hash:", result.recomputed_cert_hash_felt252);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Imports
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import {
|
|
33
|
+
verifyRunCertificate,
|
|
34
|
+
computeCertHashFelt252,
|
|
35
|
+
publicKeyFromSpkiB64,
|
|
36
|
+
CERT_MARKER_FELT,
|
|
37
|
+
} from "@vauban-org/agent-sdk/proof/cert-verify";
|
|
38
|
+
|
|
39
|
+
import type {
|
|
40
|
+
CertVerifyResult,
|
|
41
|
+
CertVerifyFailReason,
|
|
42
|
+
CertVerifyOptions,
|
|
43
|
+
SignedRunProofCertificateLike,
|
|
44
|
+
SignaturePayload,
|
|
45
|
+
} from "@vauban-org/agent-sdk/proof/cert-verify";
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Types
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
interface CertVerifyResult {
|
|
54
|
+
valid: boolean;
|
|
55
|
+
reason?: CertVerifyFailReason; // only when valid === false
|
|
56
|
+
details?: string; // human-readable context
|
|
57
|
+
recomputed_cert_hash_felt252: string; // always present — useful for debug
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
type CertVerifyFailReason =
|
|
61
|
+
| "missing_signature" // cert.signature field absent
|
|
62
|
+
| "wrong_alg" // alg !== "Ed25519"
|
|
63
|
+
| "hash_mismatch" // embedded cert_hash_felt252 != recomputed
|
|
64
|
+
| "kid_mismatch" // expectedKid set and does not match
|
|
65
|
+
| "pubkey_unresolvable" // SPKI base64 malformed or not Ed25519
|
|
66
|
+
| "signature_invalid" // Ed25519 verify returns false
|
|
67
|
+
| "malformed_signature"; // signature.value is not valid base64 / wrong length
|
|
68
|
+
|
|
69
|
+
interface CertVerifyOptions {
|
|
70
|
+
expectedPublicKey?: KeyObject; // Node.js KeyObject (bypass embedded SPKI)
|
|
71
|
+
expectedKid?: string; // pin to a specific key ID
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## `verifyRunCertificate(cert, opts?)`
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
function verifyRunCertificate(
|
|
81
|
+
cert: SignedRunProofCertificateLike,
|
|
82
|
+
opts?: CertVerifyOptions
|
|
83
|
+
): CertVerifyResult
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Returns synchronously — all crypto is Node.js built-in `node:crypto`. Never throws on verification failure; only throws when `cert` is not a plain object.
|
|
87
|
+
|
|
88
|
+
`recomputed_cert_hash_felt252` is always returned regardless of outcome — use it to debug `hash_mismatch` failures without a separate call.
|
|
89
|
+
|
|
90
|
+
### Basic verification
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
const result = verifyRunCertificate(cert);
|
|
94
|
+
if (!result.valid) {
|
|
95
|
+
console.error(`Invalid: ${result.reason} — ${result.details}`);
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Pin to a known public key (recommended for production)
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { publicKeyFromSpkiB64, verifyRunCertificate } from "@vauban-org/agent-sdk/proof/cert-verify";
|
|
103
|
+
|
|
104
|
+
const pubkey = publicKeyFromSpkiB64(process.env["CC_ATTEST_PUBKEY_SPKI_B64"]!);
|
|
105
|
+
|
|
106
|
+
const result = verifyRunCertificate(cert, { expectedPublicKey: pubkey });
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`publicKeyFromSpkiB64` throws if the base64 is malformed or the key is not Ed25519. Call it once at startup and cache the `KeyObject`.
|
|
110
|
+
|
|
111
|
+
### Pin to a key ID
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
const result = verifyRunCertificate(cert, {
|
|
115
|
+
expectedKid: "cc-attest-2026-05",
|
|
116
|
+
});
|
|
117
|
+
// → reason: "kid_mismatch" if cert was signed with a different key
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### CI pipeline — exit code gate
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
import { verifyRunCertificate } from "@vauban-org/agent-sdk/proof/cert-verify";
|
|
124
|
+
import { readFileSync } from "node:fs";
|
|
125
|
+
|
|
126
|
+
const cert = JSON.parse(readFileSync("cert.json", "utf-8"));
|
|
127
|
+
const { valid, reason, recomputed_cert_hash_felt252 } = verifyRunCertificate(cert);
|
|
128
|
+
|
|
129
|
+
console.log(`hash: ${recomputed_cert_hash_felt252}`);
|
|
130
|
+
process.exit(valid ? 0 : 1);
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Verification algorithm
|
|
136
|
+
|
|
137
|
+
Implements draft-vauban-skill-attestation-00 §5. Seven sequential checks — the first failure stops the chain:
|
|
138
|
+
|
|
139
|
+
| Step | Check | Failure reason |
|
|
140
|
+
|------|-------|----------------|
|
|
141
|
+
| 1 | `cert.signature` field is present | `missing_signature` |
|
|
142
|
+
| 2 | `signature.alg === "Ed25519"` | `wrong_alg` |
|
|
143
|
+
| 3 | Strip `signature`, JCS-canonicalize (RFC 8785 subset: sorted keys, `-0 → 0`), SHA-256 first 31 bytes → felt252, Poseidon(`[0x1, sha_felt, CERT_MARKER_FELT]`) — compare with `signature.cert_hash_felt252` | `hash_mismatch` |
|
|
144
|
+
| 4 | If `opts.expectedKid` set, compare with `signature.kid` | `kid_mismatch` |
|
|
145
|
+
| 5 | Resolve public key: `opts.expectedPublicKey` if provided, else `publicKeyFromSpkiB64(signature.pubkey_spki_b64)` | `pubkey_unresolvable` |
|
|
146
|
+
| 6 | Decode `signature.value` from base64, assert 64 bytes | `malformed_signature` |
|
|
147
|
+
| 7 | Ed25519 verify: `crypto.verify(null, felt252Bytes(recomputed), pubkey, sigBytes)` | `signature_invalid` |
|
|
148
|
+
|
|
149
|
+
**`CERT_MARKER_FELT`** is the domain separator — UTF-8 `"run_cert"` encoded as a felt252 (right-aligned, zero-padded). It prevents cross-context signature reuse: a signature over a different cert type cannot satisfy the Poseidon preimage.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## `computeCertHashFelt252(cert)`
|
|
154
|
+
|
|
155
|
+
Standalone hash computation — useful for debugging `hash_mismatch` failures.
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
import { computeCertHashFelt252 } from "@vauban-org/agent-sdk/proof/cert-verify";
|
|
159
|
+
|
|
160
|
+
const expected = cert.signature?.cert_hash_felt252;
|
|
161
|
+
const recomputed = computeCertHashFelt252(cert);
|
|
162
|
+
|
|
163
|
+
if (expected !== recomputed) {
|
|
164
|
+
console.error("Hash mismatch:");
|
|
165
|
+
console.error(" embedded :", expected);
|
|
166
|
+
console.error(" recomputed:", recomputed);
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
`computeCertHashFelt252` strips the embedded `signature` field before hashing — calling it on a signed cert and on the pre-signature cert produces the same result.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Security considerations
|
|
175
|
+
|
|
176
|
+
!!! warning "Treat embedded `pubkey_spki_b64` as a key-discovery hint, not a security guarantee"
|
|
177
|
+
The `pubkey_spki_b64` field in `signature` helps resolve the signing key for display and debugging, but an attacker can substitute it with their own public key and produce a valid self-consistent signature.
|
|
178
|
+
|
|
179
|
+
For production use, always pin to a known public key via `opts.expectedPublicKey` (loaded from a trusted source such as an environment variable, K8s secret, or a JWKS registry keyed on `signature.kid`). Never accept a certificate as authoritative based solely on its embedded public key.
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## `preste attest verify` CLI
|
|
184
|
+
|
|
185
|
+
The standalone verifier is the engine behind the CLI command:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
preste attest verify cert.json
|
|
189
|
+
# Exit 0: certificate valid
|
|
190
|
+
# Exit 1: verification failed — reason printed to stderr
|
|
191
|
+
|
|
192
|
+
preste attest verify cert.json --kid cc-attest-2026-05
|
|
193
|
+
# Adds kid pinning
|
|
194
|
+
|
|
195
|
+
preste attest verify cert.json --pubkey "$CC_ATTEST_PUBKEY_SPKI_B64"
|
|
196
|
+
# Pins to an explicit SPKI base64 public key
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
The CLI sets `process.exitCode` to `1` on failure so it composes naturally with `&&` in shell scripts and CI steps.
|
package/docs/identity.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# Agent Identity & Persona
|
|
2
|
+
|
|
3
|
+
**Module:** `@vauban-org/agent-sdk` · **Since:** CC v3.1 sprint-562 (Livrable E, 2026-05-14)
|
|
4
|
+
|
|
5
|
+
An `AgentPersona` is a structured description of how an agent communicates — tone, formality, domain expertise, and response-shape preferences. The persona travels from Brain Tier 3 (semantic storage) through the CC server as a system-prompt prefix, and can be overridden locally via `~/.preste/persona.yaml`.
|
|
6
|
+
|
|
7
|
+
## Quick start
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import {
|
|
11
|
+
buildPersonaPromptBlock,
|
|
12
|
+
mergePersona,
|
|
13
|
+
DEFAULT_PERSONA,
|
|
14
|
+
validatePersona,
|
|
15
|
+
} from "@vauban-org/agent-sdk";
|
|
16
|
+
import type { AgentPersona } from "@vauban-org/agent-sdk";
|
|
17
|
+
|
|
18
|
+
const persona: AgentPersona = {
|
|
19
|
+
identity: {
|
|
20
|
+
name: "ARCHITECT",
|
|
21
|
+
role: "Senior Cairo/TypeScript engineer",
|
|
22
|
+
tone: "concise",
|
|
23
|
+
formality: "technical",
|
|
24
|
+
language: "en",
|
|
25
|
+
},
|
|
26
|
+
domain_expertise: ["Starknet", "TypeScript", "ZK proofs"],
|
|
27
|
+
communication: {
|
|
28
|
+
acknowledgment_style: "minimal",
|
|
29
|
+
explain_reasoning: "on_error",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const systemPrompt =
|
|
34
|
+
"You are an agent in the Vauban ecosystem." +
|
|
35
|
+
buildPersonaPromptBlock(persona);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The `buildPersonaPromptBlock` call appends the block only when actionable fields are present — it is safe to concatenate unconditionally.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## `AgentPersona` schema
|
|
43
|
+
|
|
44
|
+
All fields are optional. Zod validation enforces the limits below; `PersonaSchema.parse(input)` throws on violation.
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
interface AgentPersona {
|
|
48
|
+
identity?: {
|
|
49
|
+
name?: string; // max 64 chars
|
|
50
|
+
role?: string; // max 256 chars
|
|
51
|
+
tone?: "concise" | "detailed" | "pedagogical";
|
|
52
|
+
formality?: "casual" | "formal" | "technical";
|
|
53
|
+
language?: string; // BCP 47, e.g. "en", "fr-FR"
|
|
54
|
+
};
|
|
55
|
+
traits?: string[]; // max 16 items, max 64 chars each
|
|
56
|
+
domain_expertise?: string[]; // max 32 items, max 128 chars each
|
|
57
|
+
communication?: {
|
|
58
|
+
max_response_length?: number;
|
|
59
|
+
use_analogies?: boolean;
|
|
60
|
+
explain_reasoning?: "always" | "on_error" | "never";
|
|
61
|
+
acknowledgment_style?: "minimal" | "detailed" | "none";
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`DEFAULT_PERSONA` is applied before any user-defined value:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const DEFAULT_PERSONA: AgentPersona = {
|
|
70
|
+
identity: { tone: "concise", formality: "technical", language: "en" },
|
|
71
|
+
traits: [],
|
|
72
|
+
domain_expertise: [],
|
|
73
|
+
communication: { explain_reasoning: "on_error", acknowledgment_style: "minimal" },
|
|
74
|
+
};
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## `buildPersonaPromptBlock(persona)`
|
|
80
|
+
|
|
81
|
+
Converts an `AgentPersona` to a compact system-prompt block bounded by `--- persona ---` / `--- end persona ---` markers.
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { buildPersonaPromptBlock } from "@vauban-org/agent-sdk";
|
|
85
|
+
|
|
86
|
+
const block = buildPersonaPromptBlock({
|
|
87
|
+
identity: { name: "SCRIBE", tone: "pedagogical", formality: "formal" },
|
|
88
|
+
domain_expertise: ["technical writing", "API documentation"],
|
|
89
|
+
communication: { explain_reasoning: "always" },
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// block ===
|
|
93
|
+
// \n--- persona ---
|
|
94
|
+
// You are SCRIBE.
|
|
95
|
+
// Communication style: pedagogical, formal.
|
|
96
|
+
// Domain expertise: technical writing, API documentation.
|
|
97
|
+
// Always explain your reasoning step by step.
|
|
98
|
+
// --- end persona ---
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Properties:**
|
|
102
|
+
|
|
103
|
+
- Returns `""` when the persona has no actionable fields — safe for unconditional concatenation.
|
|
104
|
+
- `language` field only emits an instruction when it differs from `"en"`.
|
|
105
|
+
- Empty `traits` / `domain_expertise` arrays produce no output.
|
|
106
|
+
- The leading `\n` ensures correct spacing when appended to an existing system prompt.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Merge semantics
|
|
111
|
+
|
|
112
|
+
`mergePersona(base, local)` applies `local` on top of `base` field-by-field. Brain Tier 3 is the base; `~/.preste/persona.yaml` is the local override.
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
import { mergePersona, DEFAULT_PERSONA } from "@vauban-org/agent-sdk";
|
|
116
|
+
|
|
117
|
+
const brainPersona: AgentPersona = {
|
|
118
|
+
identity: { name: "BUILDER", tone: "concise" },
|
|
119
|
+
domain_expertise: ["Cairo", "TypeScript"],
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const localOverride: AgentPersona = {
|
|
123
|
+
identity: { tone: "detailed" }, // overrides tone only
|
|
124
|
+
domain_expertise: ["Rust"], // REPLACES the array entirely
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const resolved = mergePersona(
|
|
128
|
+
mergePersona(DEFAULT_PERSONA, brainPersona),
|
|
129
|
+
localOverride,
|
|
130
|
+
);
|
|
131
|
+
// resolved.identity.name === "BUILDER" (from brainPersona)
|
|
132
|
+
// resolved.identity.tone === "detailed" (from localOverride)
|
|
133
|
+
// resolved.domain_expertise === ["Rust"] (array replaced, not extended)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
!!! warning "Array replacement semantics"
|
|
137
|
+
`traits` and `domain_expertise` are **replaced**, not extended. If you want to extend the Brain-stored array, concatenate before calling `mergePersona`:
|
|
138
|
+
```typescript
|
|
139
|
+
const extended = mergePersona(base, {
|
|
140
|
+
...local,
|
|
141
|
+
domain_expertise: [...(base.domain_expertise ?? []), ...(local.domain_expertise ?? [])],
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## System-level injection (CC server)
|
|
148
|
+
|
|
149
|
+
Set `CC_AGENT_PERSONA_JSON` on the CC server to inject the persona as a system message prefix for every agent call, without modifying agent code.
|
|
150
|
+
|
|
151
|
+
**Generate the env value:**
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
echo '{"identity":{"name":"ARCHITECT","role":"Senior Cairo/TypeScript engineer","tone":"concise","formality":"technical"},"domain_expertise":["Starknet","TypeScript","ZK proofs"],"communication":{"acknowledgment_style":"minimal","explain_reasoning":"on_error"}}' | base64 -w0
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
export CC_AGENT_PERSONA_JSON="<base64 output>"
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
The CC server decodes, validates via `PersonaSchema.parse`, and calls `buildPersonaPromptBlock` before prepending to each agent system message.
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## CLI persona management
|
|
166
|
+
|
|
167
|
+
The `preste persona` sub-command manages the local `~/.preste/persona.yaml` override file.
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
preste persona show # display resolved persona (Brain + local merge)
|
|
171
|
+
preste persona set --name ARCHITECT --role "..." --tone concise --formality technical
|
|
172
|
+
preste persona export persona.yaml # write to YAML file
|
|
173
|
+
preste persona import persona.yaml # load from YAML file (validates schema)
|
|
174
|
+
preste persona reset # delete ~/.preste/persona.yaml (revert to Brain-only)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
`preste persona show` prints the fully-resolved persona (Brain base + local override + defaults) and the rendered `buildPersonaPromptBlock` output so you can inspect what the model will receive.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Validation
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
import { validatePersona } from "@vauban-org/agent-sdk";
|
|
185
|
+
|
|
186
|
+
try {
|
|
187
|
+
const persona = validatePersona(untrustedInput);
|
|
188
|
+
} catch (err) {
|
|
189
|
+
// ZodError — inspect err.issues for field-level messages
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
`validatePersona` wraps `PersonaSchema.parse` and throws `ZodError` on invalid input. Call it at ingestion boundaries (e.g., when loading `~/.preste/persona.yaml` or deserializing from Brain).
|