@claude-flow/cli 3.32.29 → 3.32.32
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/.claude/helpers/helpers.manifest.json +2 -2
- package/catalog-manifest.json +2 -2
- package/dist/src/autopilot-state.d.ts +10 -0
- package/dist/src/autopilot-state.js +16 -0
- package/dist/src/commands/autopilot.js +10 -4
- package/dist/src/init/claudemd-generator.js +53 -2
- package/dist/src/mcp-tools/autopilot-tools.js +18 -3
- package/dist/src/mcp-tools/capability-brain.js +22 -22
- package/dist/src/mcp-tools/guidance-tools.js +1 -1
- package/dist/src/services/harness-flywheel-runtime.d.ts +21 -1
- package/dist/src/services/harness-flywheel-runtime.js +46 -24
- package/node_modules/@claude-flow/codex/.agents/skills/memory-management/SKILL.md +45 -0
- package/node_modules/@claude-flow/codex/.agents/skills/security-audit/SKILL.md +46 -0
- package/node_modules/@claude-flow/codex/.agents/skills/sparc-methodology/SKILL.md +46 -0
- package/node_modules/@claude-flow/codex/.agents/skills/swarm-orchestration/SKILL.md +53 -0
- package/node_modules/@claude-flow/codex/README.md +1044 -0
- package/node_modules/@claude-flow/codex/dist/cli.d.ts +9 -0
- package/node_modules/@claude-flow/codex/dist/cli.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/cli.js +686 -0
- package/node_modules/@claude-flow/codex/dist/cli.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/cli.d.ts +17 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/cli.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/cli.js +278 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/cli.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/index.d.ts +8 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/index.js +7 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.d.ts +143 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.js +621 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.d.ts +12 -0
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.js +730 -0
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/config-toml.d.ts +74 -0
- package/node_modules/@claude-flow/codex/dist/generators/config-toml.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/config-toml.js +922 -0
- package/node_modules/@claude-flow/codex/dist/generators/config-toml.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.d.ts +9 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.js +9 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.d.ts +20 -0
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.js +951 -0
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/build-evidence.d.ts +46 -0
- package/node_modules/@claude-flow/codex/dist/harness/build-evidence.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/build-evidence.js +126 -0
- package/node_modules/@claude-flow/codex/dist/harness/build-evidence.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/contract.d.ts +153 -0
- package/node_modules/@claude-flow/codex/dist/harness/contract.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/contract.js +44 -0
- package/node_modules/@claude-flow/codex/dist/harness/contract.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.d.ts +33 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.js +175 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.d.ts +42 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.js +140 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.d.ts +19 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.js +79 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/index.d.ts +9 -0
- package/node_modules/@claude-flow/codex/dist/harness/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/index.js +9 -0
- package/node_modules/@claude-flow/codex/dist/harness/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.d.ts +8 -0
- package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.js +10 -0
- package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/repository-state.d.ts +68 -0
- package/node_modules/@claude-flow/codex/dist/harness/repository-state.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/repository-state.js +403 -0
- package/node_modules/@claude-flow/codex/dist/harness/repository-state.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.d.ts +3 -0
- package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.js +14 -0
- package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/index.d.ts +53 -0
- package/node_modules/@claude-flow/codex/dist/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/index.js +54 -0
- package/node_modules/@claude-flow/codex/dist/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/initializer.d.ts +98 -0
- package/node_modules/@claude-flow/codex/dist/initializer.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/initializer.js +795 -0
- package/node_modules/@claude-flow/codex/dist/initializer.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/loop/cli.d.ts +3 -0
- package/node_modules/@claude-flow/codex/dist/loop/cli.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/loop/cli.js +123 -0
- package/node_modules/@claude-flow/codex/dist/loop/cli.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/loop/index.d.ts +58 -0
- package/node_modules/@claude-flow/codex/dist/loop/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/loop/index.js +230 -0
- package/node_modules/@claude-flow/codex/dist/loop/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/mcp-config.d.ts +28 -0
- package/node_modules/@claude-flow/codex/dist/mcp-config.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/mcp-config.js +121 -0
- package/node_modules/@claude-flow/codex/dist/mcp-config.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/migrations/index.d.ts +114 -0
- package/node_modules/@claude-flow/codex/dist/migrations/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/migrations/index.js +880 -0
- package/node_modules/@claude-flow/codex/dist/migrations/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/templates/index.d.ts +92 -0
- package/node_modules/@claude-flow/codex/dist/templates/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/templates/index.js +284 -0
- package/node_modules/@claude-flow/codex/dist/templates/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/types.d.ts +240 -0
- package/node_modules/@claude-flow/codex/dist/types.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/types.js +8 -0
- package/node_modules/@claude-flow/codex/dist/types.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/validators/index.d.ts +42 -0
- package/node_modules/@claude-flow/codex/dist/validators/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/validators/index.js +929 -0
- package/node_modules/@claude-flow/codex/dist/validators/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.d.ts +37 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.js +137 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/index.d.ts +2 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/index.js +2 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/package.json +122 -0
- package/node_modules/@claude-flow/plugin-agent-federation/README.md +49 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.d.ts +130 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.js +239 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.d.ts +34 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.js +69 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.d.ts +46 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.js +84 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.d.ts +27 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.js +46 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.d.ts +192 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.js +253 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.d.ts +211 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.js +501 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts +114 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js +356 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.d.ts +41 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.js +184 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.d.ts +150 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.js +128 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.d.ts +74 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.js +179 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.d.ts +13 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.js +189 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.d.ts +7 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.js +317 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.d.ts +45 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.js +71 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.d.ts +104 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.js +152 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.d.ts +55 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.js +105 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.d.ts +17 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.js +35 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.d.ts +69 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.js +149 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts +68 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.js +161 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts +58 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.js +122 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.d.ts +65 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.js +208 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.d.ts +51 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.js +147 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.d.ts +71 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.js +194 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.d.ts +156 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.js +292 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.d.ts +98 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.js +122 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.d.ts +89 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.js +165 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.d.ts +92 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.js +100 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.d.ts +70 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.js +104 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/index.d.ts +23 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/index.js +24 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/index.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.d.ts +10 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.js +439 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.d.ts +19 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.js +515 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.d.ts +72 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.js +269 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/version.d.ts +3 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/version.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/version.js +3 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/version.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/package.json +64 -0
- package/node_modules/@claude-flow/security/README.md +292 -0
- package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.d.ts +97 -0
- package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.js +537 -0
- package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/application/index.d.ts +7 -0
- package/node_modules/@claude-flow/security/dist/application/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/application/index.js +7 -0
- package/node_modules/@claude-flow/security/dist/application/index.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/application/services/security-application-service.d.ts +71 -0
- package/node_modules/@claude-flow/security/dist/application/services/security-application-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/application/services/security-application-service.js +153 -0
- package/node_modules/@claude-flow/security/dist/application/services/security-application-service.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/authorization/propagator.d.ts +148 -0
- package/node_modules/@claude-flow/security/dist/authorization/propagator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/authorization/propagator.js +182 -0
- package/node_modules/@claude-flow/security/dist/authorization/propagator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/credential-generator.d.ts +176 -0
- package/node_modules/@claude-flow/security/dist/credential-generator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/credential-generator.js +272 -0
- package/node_modules/@claude-flow/security/dist/credential-generator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/entities/security-context.d.ts +68 -0
- package/node_modules/@claude-flow/security/dist/domain/entities/security-context.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/entities/security-context.js +132 -0
- package/node_modules/@claude-flow/security/dist/domain/entities/security-context.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/index.d.ts +8 -0
- package/node_modules/@claude-flow/security/dist/domain/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/index.js +8 -0
- package/node_modules/@claude-flow/security/dist/domain/index.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.d.ts +71 -0
- package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.js +237 -0
- package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/index.d.ts +129 -0
- package/node_modules/@claude-flow/security/dist/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/index.js +176 -0
- package/node_modules/@claude-flow/security/dist/index.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/input-validator.d.ts +306 -0
- package/node_modules/@claude-flow/security/dist/input-validator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/input-validator.js +393 -0
- package/node_modules/@claude-flow/security/dist/input-validator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/keychain-adapter.d.ts +48 -0
- package/node_modules/@claude-flow/security/dist/keychain-adapter.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/keychain-adapter.js +0 -0
- package/node_modules/@claude-flow/security/dist/keychain-adapter.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.d.ts +133 -0
- package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.js +254 -0
- package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/browser.d.ts +31 -0
- package/node_modules/@claude-flow/security/dist/oauth/browser.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/browser.js +55 -0
- package/node_modules/@claude-flow/security/dist/oauth/browser.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/callback-server.d.ts +37 -0
- package/node_modules/@claude-flow/security/dist/oauth/callback-server.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/callback-server.js +86 -0
- package/node_modules/@claude-flow/security/dist/oauth/callback-server.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/client.d.ts +57 -0
- package/node_modules/@claude-flow/security/dist/oauth/client.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/client.js +120 -0
- package/node_modules/@claude-flow/security/dist/oauth/client.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/pkce.d.ts +25 -0
- package/node_modules/@claude-flow/security/dist/oauth/pkce.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/pkce.js +36 -0
- package/node_modules/@claude-flow/security/dist/oauth/pkce.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/password-hasher.d.ts +128 -0
- package/node_modules/@claude-flow/security/dist/password-hasher.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/password-hasher.js +190 -0
- package/node_modules/@claude-flow/security/dist/password-hasher.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/path-validator.d.ts +148 -0
- package/node_modules/@claude-flow/security/dist/path-validator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/path-validator.js +421 -0
- package/node_modules/@claude-flow/security/dist/path-validator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.d.ts +125 -0
- package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.js +186 -0
- package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/canonical.d.ts +5 -0
- package/node_modules/@claude-flow/security/dist/policy/canonical.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/canonical.js +30 -0
- package/node_modules/@claude-flow/security/dist/policy/canonical.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/engine.d.ts +34 -0
- package/node_modules/@claude-flow/security/dist/policy/engine.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/engine.js +285 -0
- package/node_modules/@claude-flow/security/dist/policy/engine.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/envelope.d.ts +9 -0
- package/node_modules/@claude-flow/security/dist/policy/envelope.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/envelope.js +90 -0
- package/node_modules/@claude-flow/security/dist/policy/envelope.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/evaluator.d.ts +4 -0
- package/node_modules/@claude-flow/security/dist/policy/evaluator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/evaluator.js +119 -0
- package/node_modules/@claude-flow/security/dist/policy/evaluator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/index.d.ts +7 -0
- package/node_modules/@claude-flow/security/dist/policy/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/index.js +7 -0
- package/node_modules/@claude-flow/security/dist/policy/index.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/product-plane.d.ts +238 -0
- package/node_modules/@claude-flow/security/dist/policy/product-plane.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/product-plane.js +1022 -0
- package/node_modules/@claude-flow/security/dist/policy/product-plane.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/types.d.ts +169 -0
- package/node_modules/@claude-flow/security/dist/policy/types.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/types.js +2 -0
- package/node_modules/@claude-flow/security/dist/policy/types.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/safe-executor.d.ts +180 -0
- package/node_modules/@claude-flow/security/dist/safe-executor.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/safe-executor.js +390 -0
- package/node_modules/@claude-flow/security/dist/safe-executor.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/token-generator.d.ts +224 -0
- package/node_modules/@claude-flow/security/dist/token-generator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/token-generator.js +351 -0
- package/node_modules/@claude-flow/security/dist/token-generator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/tool-output-guardrail.d.ts +126 -0
- package/node_modules/@claude-flow/security/dist/tool-output-guardrail.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/tool-output-guardrail.js +257 -0
- package/node_modules/@claude-flow/security/dist/tool-output-guardrail.js.map +1 -0
- package/node_modules/@claude-flow/security/package.json +44 -0
- package/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AAC,MAAM;gBACnB,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,UAAU,EAAE,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC;gBAC/C,MAAM;gBACN,QAAQ;gBACR,SAAS,EAAE,MAAM;gBACjB,KAAK;gBACL,UAAU,EAAE,IAAI,IAAI,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE;aAC1F,CAAC;QACJ,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;OAIG;IACK,SAAS,CAAC,IAAY;QAC5B,6DAA6D;QAC7D,kEAAkE;QAClE,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CAAC,4DAA4D,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACtG,CAAC;QACD,OAAO,UAAU,IAAI,CAAC,aAAa,IAAI,IAAI,EAAE,CAAC;IAChD,CAAC;CACF"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADR-111 Phase 5 — Witness attestation chain for WG mesh mutations.
|
|
3
|
+
*
|
|
4
|
+
* Every coordination change (peer added/suspended/evicted/reactivated,
|
|
5
|
+
* keypair rotated) appends a signed entry to an append-only log
|
|
6
|
+
* `.claude-flow/federation/wg-changes.log`. The signature is over a
|
|
7
|
+
* canonical JSON encoding of the entry's content fields, using the
|
|
8
|
+
* operator's federation Ed25519 key — the same identity that signs
|
|
9
|
+
* federation manifests, so anyone who already trusts the manifest chain
|
|
10
|
+
* automatically trusts the WG change chain.
|
|
11
|
+
*
|
|
12
|
+
* Append-only via O_APPEND open + entries chained by prevHash (sha256 of
|
|
13
|
+
* the previous entry's canonical bytes). Tampering with history requires
|
|
14
|
+
* forging a chain of signatures with the operator's key.
|
|
15
|
+
*
|
|
16
|
+
* The periodic ruflo witness regen (plugins/ruflo-core/scripts/witness/)
|
|
17
|
+
* includes wg-changes.log as one of its watched artifacts (operator wires
|
|
18
|
+
* this via witness-fixes.json).
|
|
19
|
+
*
|
|
20
|
+
* Pure service: emits the canonical bytes and the signature to write.
|
|
21
|
+
* Caller does the I/O so this stays unit-testable without fs mocks.
|
|
22
|
+
*/
|
|
23
|
+
import type { WgCommand } from './wg-mesh-service.js';
|
|
24
|
+
export type WgWitnessEventType = 'peer-added' | 'peer-removed-suspended' | 'peer-restored' | 'peer-evicted' | 'key-rotated' | 'interface-config-applied';
|
|
25
|
+
/**
|
|
26
|
+
* Canonical fields of a witness entry. The hash + signature are computed
|
|
27
|
+
* over these in a stable JSON encoding (sorted keys, no whitespace).
|
|
28
|
+
*/
|
|
29
|
+
export interface WgWitnessContent {
|
|
30
|
+
readonly version: '1';
|
|
31
|
+
readonly type: WgWitnessEventType;
|
|
32
|
+
readonly timestamp: string;
|
|
33
|
+
readonly nodeId: string;
|
|
34
|
+
/** Public key of the affected peer, if any. */
|
|
35
|
+
readonly peerPublicKey?: string;
|
|
36
|
+
/** Mesh IP affected, if any. */
|
|
37
|
+
readonly meshIP?: string;
|
|
38
|
+
/** wg command that was emitted, if any. */
|
|
39
|
+
readonly wgCommand?: string;
|
|
40
|
+
/** Human-readable rationale for the audit log. */
|
|
41
|
+
readonly rationale: string;
|
|
42
|
+
/** Hash of the previous entry in the chain (sha256 hex), or empty for the genesis entry. */
|
|
43
|
+
readonly prevHash: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Full witness entry as it appears on disk — content + the operator's
|
|
47
|
+
* Ed25519 signature over the canonical encoding of content.
|
|
48
|
+
*/
|
|
49
|
+
export interface WgWitnessEntry {
|
|
50
|
+
readonly content: WgWitnessContent;
|
|
51
|
+
readonly hash: string;
|
|
52
|
+
readonly signature: string;
|
|
53
|
+
}
|
|
54
|
+
export interface WgWitnessSigner {
|
|
55
|
+
/** Returns an Ed25519 signature (base64) over the given canonical bytes. */
|
|
56
|
+
sign(bytes: Buffer): Promise<string>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Stable JSON serialization for hashing/signing. Keys are sorted; no
|
|
60
|
+
* whitespace; undefined fields omitted. Same shape on every host so
|
|
61
|
+
* cross-host verifiers produce identical hashes.
|
|
62
|
+
*/
|
|
63
|
+
export declare function canonicalizeContent(content: WgWitnessContent): Buffer;
|
|
64
|
+
export declare function hashContent(content: WgWitnessContent): string;
|
|
65
|
+
export declare class WgWitnessService {
|
|
66
|
+
private readonly nodeId;
|
|
67
|
+
private readonly signer;
|
|
68
|
+
private lastHash;
|
|
69
|
+
constructor(nodeId: string, signer: WgWitnessSigner);
|
|
70
|
+
/**
|
|
71
|
+
* Override the previous-hash pointer (used when resuming from an existing
|
|
72
|
+
* log on disk). Caller reads the last entry from `wg-changes.log` and
|
|
73
|
+
* passes its `hash` here before appending more.
|
|
74
|
+
*/
|
|
75
|
+
setLastHash(hash: string): void;
|
|
76
|
+
/** Build + sign an entry. Caller is responsible for the actual append-write. */
|
|
77
|
+
build(type: WgWitnessEventType, fields: Omit<WgWitnessContent, 'version' | 'type' | 'timestamp' | 'nodeId' | 'prevHash'>): Promise<WgWitnessEntry>;
|
|
78
|
+
/**
|
|
79
|
+
* Convenience: take a WgCommand emitted by WgMeshService Phase 2/3 and
|
|
80
|
+
* produce a witness entry of the right type. Maps verb → eventType.
|
|
81
|
+
*/
|
|
82
|
+
attestWgCommand(cmd: WgCommand, meshIP?: string): Promise<WgWitnessEntry>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Verify a single entry's signature + hash. Caller verifies the chain by
|
|
86
|
+
* iterating entries and confirming each entry's `prevHash` equals the
|
|
87
|
+
* preceding entry's `hash`.
|
|
88
|
+
*/
|
|
89
|
+
export declare function verifyWitnessEntry(entry: WgWitnessEntry, verify: (bytes: Buffer, signature: string) => Promise<boolean>): Promise<boolean>;
|
|
90
|
+
/**
|
|
91
|
+
* Verify a full chain — every entry valid + chain link unbroken.
|
|
92
|
+
*/
|
|
93
|
+
export declare function verifyWitnessChain(entries: readonly WgWitnessEntry[], verify: (bytes: Buffer, signature: string) => Promise<boolean>): Promise<{
|
|
94
|
+
ok: boolean;
|
|
95
|
+
failedAt?: number;
|
|
96
|
+
reason?: string;
|
|
97
|
+
}>;
|
|
98
|
+
//# sourceMappingURL=wg-witness-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wg-witness-service.d.ts","sourceRoot":"","sources":["../../../src/domain/services/wg-witness-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,MAAM,kBAAkB,GAC1B,YAAY,GACZ,wBAAwB,GACxB,eAAe,GACf,cAAc,GACd,aAAa,GACb,0BAA0B,CAAC;AAE/B;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+CAA+C;IAC/C,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,gCAAgC;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,2CAA2C;IAC3C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,4FAA4F;IAC5F,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CA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AM,KAAK,OAAO,CAAC,OAAO,CAAC,GAC7D,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAc9D"}
|
package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADR-111 Phase 5 — Witness attestation chain for WG mesh mutations.
|
|
3
|
+
*
|
|
4
|
+
* Every coordination change (peer added/suspended/evicted/reactivated,
|
|
5
|
+
* keypair rotated) appends a signed entry to an append-only log
|
|
6
|
+
* `.claude-flow/federation/wg-changes.log`. The signature is over a
|
|
7
|
+
* canonical JSON encoding of the entry's content fields, using the
|
|
8
|
+
* operator's federation Ed25519 key — the same identity that signs
|
|
9
|
+
* federation manifests, so anyone who already trusts the manifest chain
|
|
10
|
+
* automatically trusts the WG change chain.
|
|
11
|
+
*
|
|
12
|
+
* Append-only via O_APPEND open + entries chained by prevHash (sha256 of
|
|
13
|
+
* the previous entry's canonical bytes). Tampering with history requires
|
|
14
|
+
* forging a chain of signatures with the operator's key.
|
|
15
|
+
*
|
|
16
|
+
* The periodic ruflo witness regen (plugins/ruflo-core/scripts/witness/)
|
|
17
|
+
* includes wg-changes.log as one of its watched artifacts (operator wires
|
|
18
|
+
* this via witness-fixes.json).
|
|
19
|
+
*
|
|
20
|
+
* Pure service: emits the canonical bytes and the signature to write.
|
|
21
|
+
* Caller does the I/O so this stays unit-testable without fs mocks.
|
|
22
|
+
*/
|
|
23
|
+
import { createHash } from 'node:crypto';
|
|
24
|
+
/**
|
|
25
|
+
* Stable JSON serialization for hashing/signing. Keys are sorted; no
|
|
26
|
+
* whitespace; undefined fields omitted. Same shape on every host so
|
|
27
|
+
* cross-host verifiers produce identical hashes.
|
|
28
|
+
*/
|
|
29
|
+
export function canonicalizeContent(content) {
|
|
30
|
+
const keys = Object.keys(content).sort();
|
|
31
|
+
const ordered = {};
|
|
32
|
+
for (const k of keys) {
|
|
33
|
+
if (content[k] !== undefined)
|
|
34
|
+
ordered[k] = content[k];
|
|
35
|
+
}
|
|
36
|
+
return Buffer.from(JSON.stringify(ordered), 'utf-8');
|
|
37
|
+
}
|
|
38
|
+
export function hashContent(content) {
|
|
39
|
+
return createHash('sha256').update(canonicalizeContent(content)).digest('hex');
|
|
40
|
+
}
|
|
41
|
+
export class WgWitnessService {
|
|
42
|
+
nodeId;
|
|
43
|
+
signer;
|
|
44
|
+
lastHash = '';
|
|
45
|
+
constructor(nodeId, signer) {
|
|
46
|
+
this.nodeId = nodeId;
|
|
47
|
+
this.signer = signer;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Override the previous-hash pointer (used when resuming from an existing
|
|
51
|
+
* log on disk). Caller reads the last entry from `wg-changes.log` and
|
|
52
|
+
* passes its `hash` here before appending more.
|
|
53
|
+
*/
|
|
54
|
+
setLastHash(hash) {
|
|
55
|
+
this.lastHash = hash;
|
|
56
|
+
}
|
|
57
|
+
/** Build + sign an entry. Caller is responsible for the actual append-write. */
|
|
58
|
+
async build(type, fields) {
|
|
59
|
+
const content = {
|
|
60
|
+
version: '1',
|
|
61
|
+
type,
|
|
62
|
+
timestamp: new Date().toISOString(),
|
|
63
|
+
nodeId: this.nodeId,
|
|
64
|
+
prevHash: this.lastHash,
|
|
65
|
+
...fields,
|
|
66
|
+
};
|
|
67
|
+
const canonical = canonicalizeContent(content);
|
|
68
|
+
const hash = createHash('sha256').update(canonical).digest('hex');
|
|
69
|
+
const signature = await this.signer.sign(canonical);
|
|
70
|
+
this.lastHash = hash;
|
|
71
|
+
return { content, hash, signature };
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Convenience: take a WgCommand emitted by WgMeshService Phase 2/3 and
|
|
75
|
+
* produce a witness entry of the right type. Maps verb → eventType.
|
|
76
|
+
*/
|
|
77
|
+
async attestWgCommand(cmd, meshIP) {
|
|
78
|
+
const typeMap = {
|
|
79
|
+
'add-peer': 'peer-added',
|
|
80
|
+
'set-allowed-ips': 'peer-restored',
|
|
81
|
+
'remove-allowed-ips': 'peer-removed-suspended',
|
|
82
|
+
'remove-peer': 'peer-evicted',
|
|
83
|
+
};
|
|
84
|
+
return this.build(typeMap[cmd.verb], {
|
|
85
|
+
peerPublicKey: cmd.peerPublicKey,
|
|
86
|
+
meshIP,
|
|
87
|
+
wgCommand: cmd.cmd,
|
|
88
|
+
rationale: cmd.rationale,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Verify a single entry's signature + hash. Caller verifies the chain by
|
|
94
|
+
* iterating entries and confirming each entry's `prevHash` equals the
|
|
95
|
+
* preceding entry's `hash`.
|
|
96
|
+
*/
|
|
97
|
+
export async function verifyWitnessEntry(entry, verify) {
|
|
98
|
+
const canonical = canonicalizeContent(entry.content);
|
|
99
|
+
const expectedHash = createHash('sha256').update(canonical).digest('hex');
|
|
100
|
+
if (entry.hash !== expectedHash)
|
|
101
|
+
return false;
|
|
102
|
+
return verify(canonical, entry.signature);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Verify a full chain — every entry valid + chain link unbroken.
|
|
106
|
+
*/
|
|
107
|
+
export async function verifyWitnessChain(entries, verify) {
|
|
108
|
+
let prevHash = '';
|
|
109
|
+
for (let i = 0; i < entries.length; i++) {
|
|
110
|
+
const e = entries[i];
|
|
111
|
+
if (e.content.prevHash !== prevHash) {
|
|
112
|
+
return { ok: false, failedAt: i, reason: 'broken-chain-link' };
|
|
113
|
+
}
|
|
114
|
+
const validEntry = await verifyWitnessEntry(e, verify);
|
|
115
|
+
if (!validEntry) {
|
|
116
|
+
return { ok: false, failedAt: i, reason: 'invalid-signature-or-hash' };
|
|
117
|
+
}
|
|
118
|
+
prevHash = e.hash;
|
|
119
|
+
}
|
|
120
|
+
return { ok: true };
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=wg-witness-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wg-witness-service.js","sourceRoot":"","sources":["../../../src/domain/services/wg-witness-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA+CzC;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAyB;IAC3D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAmC,CAAC;IAC1E,MAAM,OAAO,GAA4B,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,SAAS;YAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAAyB;IACnD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjF,CAAC;AAED,MAAM,OAAO,gBAAgB;IACV,MAAM,CAAS;IACf,MAAM,CAAkB;IACjC,QAAQ,GAAW,EAAE,CAAC;IAE9B,YAAY,MAAc,EAAE,MAAuB;QACjD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,IAAY;QACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;IAED,gFAAgF;IAChF,KAAK,CAAC,KAAK,CACT,IAAwB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AAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1E,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY;QAAE,OAAO,KAAK,CAAC;IAC9C,OAAO,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAAkC,EAClC,MAA8D;IAE9D,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACrB,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACpC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC;QACjE,CAAC;QACD,MAAM,UAAU,GAAG,MAAM,kBAAkB,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACvD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,2BAA2B,EAAE,CAAC;QACzE,CAAC;QACD,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC;IACpB,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Federation budget + hop counter (ADR-097 Phase 1).
|
|
3
|
+
*
|
|
4
|
+
* Carried in {@link FederationEnvelope} alongside the existing
|
|
5
|
+
* sourceNodeId/targetNodeId/payload. Sender supplies the original limits;
|
|
6
|
+
* each outbound hop increments hopCount and decrements remaining budget.
|
|
7
|
+
*
|
|
8
|
+
* Phase 1 enforces at the *send* side because there is no inbound
|
|
9
|
+
* dispatcher today (sendToNode is a stub — see researcher report).
|
|
10
|
+
* Phase 2 will move the decrement to receive once the inbound path lands.
|
|
11
|
+
*
|
|
12
|
+
* Security invariants pinned by the reviewer (audit_1776853149979 follow-up):
|
|
13
|
+
*
|
|
14
|
+
* 1. validateBudget rejects NaN, ±Infinity, negative numbers, and
|
|
15
|
+
* non-integer hop counts. Returns a discriminated result so callers
|
|
16
|
+
* cannot accidentally use a bad budget unchecked.
|
|
17
|
+
* 2. enforceBudget runs check-then-decrement in a single synchronous
|
|
18
|
+
* function with no awaits inside — two concurrent send calls cannot
|
|
19
|
+
* both pass the pre-check.
|
|
20
|
+
* 3. Errors return constant strings ("HOP_LIMIT_EXCEEDED" /
|
|
21
|
+
* "BUDGET_EXCEEDED") with no remaining-budget echo so a caller can't
|
|
22
|
+
* use the error response as an oracle for the threshold.
|
|
23
|
+
*/
|
|
24
|
+
/** Maximum hops a federation message may travel before the breaker opens. */
|
|
25
|
+
export declare const DEFAULT_MAX_HOPS = 8;
|
|
26
|
+
/**
|
|
27
|
+
* Caller-supplied budget. All fields are optional; omitted fields are
|
|
28
|
+
* treated as Infinity for the corresponding axis. Created via validateBudget;
|
|
29
|
+
* never construct directly.
|
|
30
|
+
*/
|
|
31
|
+
export interface Budget {
|
|
32
|
+
readonly maxHops: number;
|
|
33
|
+
readonly maxTokens: number;
|
|
34
|
+
readonly maxUsd: number;
|
|
35
|
+
}
|
|
36
|
+
/** Discriminated result of validating raw user input into a Budget. */
|
|
37
|
+
export type BudgetValidationResult = {
|
|
38
|
+
ok: true;
|
|
39
|
+
budget: Budget;
|
|
40
|
+
} | {
|
|
41
|
+
ok: false;
|
|
42
|
+
error: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Validate a raw budget object. Pure, no side effects. Caller obtains either
|
|
46
|
+
* a guaranteed-safe Budget or a structured error suitable for logging.
|
|
47
|
+
*
|
|
48
|
+
* Accepts undefined/null and returns a default unbounded budget (maxHops =
|
|
49
|
+
* DEFAULT_MAX_HOPS, tokens/usd = Infinity). This preserves backward
|
|
50
|
+
* compatibility for callers that don't pass a budget at all.
|
|
51
|
+
*/
|
|
52
|
+
export declare function validateBudget(raw: unknown, overrideMaxHops?: unknown): BudgetValidationResult;
|
|
53
|
+
/**
|
|
54
|
+
* Enforcement decision returned by enforceBudget. Discriminated so the
|
|
55
|
+
* caller can map directly to a constant-string error — no remaining-budget
|
|
56
|
+
* echo on the failure side (anti-oracle).
|
|
57
|
+
*/
|
|
58
|
+
export type BudgetEnforcement = {
|
|
59
|
+
ok: true;
|
|
60
|
+
nextHopCount: number;
|
|
61
|
+
remaining: Budget;
|
|
62
|
+
} | {
|
|
63
|
+
ok: false;
|
|
64
|
+
reason: 'HOP_LIMIT_EXCEEDED' | 'BUDGET_EXCEEDED';
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Atomic (single synchronous function, no internal awaits) hop check.
|
|
68
|
+
*
|
|
69
|
+
* Returns the hopCount value the OUTBOUND envelope should carry plus the
|
|
70
|
+
* remaining budget that downstream peers will see. Callers must use the
|
|
71
|
+
* returned values; mutating the input Budget is forbidden (it's readonly).
|
|
72
|
+
*
|
|
73
|
+
* Contract:
|
|
74
|
+
* - hopCount represents how many hops the message has already taken.
|
|
75
|
+
* - The next outbound hop increments it: nextHopCount = hopCount + 1.
|
|
76
|
+
* - The check fires AFTER increment: nextHopCount must be <= maxHops.
|
|
77
|
+
* - This means maxHops=0 refuses to forward at all, which matches the
|
|
78
|
+
* ADR's "no remote delegation allowed" semantic.
|
|
79
|
+
*
|
|
80
|
+
* tokensSpent / usdSpent are caller-reported actuals from the immediately
|
|
81
|
+
* preceding leg (or 0 on the originator). The check fires on the
|
|
82
|
+
* *post-spend* totals so a leg that overshoots is caught before the next
|
|
83
|
+
* outbound dispatch.
|
|
84
|
+
*/
|
|
85
|
+
export declare function enforceBudget(budget: Budget, hopCount: number, spent?: {
|
|
86
|
+
tokens: number;
|
|
87
|
+
usd: number;
|
|
88
|
+
}): BudgetEnforcement;
|
|
89
|
+
//# sourceMappingURL=federation-budget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"federation-budget.d.ts","sourceRoot":"","sources":["../../../src/domain/value-objects/federation-budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAQlC;;;;GAIG;AACH,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,uEAAuE;AACvE,MAAM,MAAM,sBAAsB,GAC9B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC5B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjC;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,OAAO,EACZ,eAAe,CAAC,EAAE,OAAO,GACxB,sBAAsB,CA6DxB;AAkCD;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GACzB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,oBAAoB,GAAG,iBAAiB,CAAA;CAAE,CAAC;AAEpE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,KAAK,GAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAA0B,GAC7D,iBAAiB,CAuBnB"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Federation budget + hop counter (ADR-097 Phase 1).
|
|
3
|
+
*
|
|
4
|
+
* Carried in {@link FederationEnvelope} alongside the existing
|
|
5
|
+
* sourceNodeId/targetNodeId/payload. Sender supplies the original limits;
|
|
6
|
+
* each outbound hop increments hopCount and decrements remaining budget.
|
|
7
|
+
*
|
|
8
|
+
* Phase 1 enforces at the *send* side because there is no inbound
|
|
9
|
+
* dispatcher today (sendToNode is a stub — see researcher report).
|
|
10
|
+
* Phase 2 will move the decrement to receive once the inbound path lands.
|
|
11
|
+
*
|
|
12
|
+
* Security invariants pinned by the reviewer (audit_1776853149979 follow-up):
|
|
13
|
+
*
|
|
14
|
+
* 1. validateBudget rejects NaN, ±Infinity, negative numbers, and
|
|
15
|
+
* non-integer hop counts. Returns a discriminated result so callers
|
|
16
|
+
* cannot accidentally use a bad budget unchecked.
|
|
17
|
+
* 2. enforceBudget runs check-then-decrement in a single synchronous
|
|
18
|
+
* function with no awaits inside — two concurrent send calls cannot
|
|
19
|
+
* both pass the pre-check.
|
|
20
|
+
* 3. Errors return constant strings ("HOP_LIMIT_EXCEEDED" /
|
|
21
|
+
* "BUDGET_EXCEEDED") with no remaining-budget echo so a caller can't
|
|
22
|
+
* use the error response as an oracle for the threshold.
|
|
23
|
+
*/
|
|
24
|
+
/** Maximum hops a federation message may travel before the breaker opens. */
|
|
25
|
+
export const DEFAULT_MAX_HOPS = 8;
|
|
26
|
+
/** Hard ceiling on caller-supplied maxUsd to prevent absurd integer math. */
|
|
27
|
+
const MAX_USD_CEILING = 1_000_000;
|
|
28
|
+
/** Hard ceiling on caller-supplied maxTokens. 1B tokens is more than any real session. */
|
|
29
|
+
const MAX_TOKENS_CEILING = 1_000_000_000;
|
|
30
|
+
/** Hard ceiling on hop count. */
|
|
31
|
+
const MAX_HOPS_CEILING = 64;
|
|
32
|
+
/**
|
|
33
|
+
* Validate a raw budget object. Pure, no side effects. Caller obtains either
|
|
34
|
+
* a guaranteed-safe Budget or a structured error suitable for logging.
|
|
35
|
+
*
|
|
36
|
+
* Accepts undefined/null and returns a default unbounded budget (maxHops =
|
|
37
|
+
* DEFAULT_MAX_HOPS, tokens/usd = Infinity). This preserves backward
|
|
38
|
+
* compatibility for callers that don't pass a budget at all.
|
|
39
|
+
*/
|
|
40
|
+
export function validateBudget(raw, overrideMaxHops) {
|
|
41
|
+
// Default unbounded budget when caller passes nothing.
|
|
42
|
+
if (raw == null && overrideMaxHops == null) {
|
|
43
|
+
return {
|
|
44
|
+
ok: true,
|
|
45
|
+
budget: {
|
|
46
|
+
maxHops: DEFAULT_MAX_HOPS,
|
|
47
|
+
maxTokens: Number.POSITIVE_INFINITY,
|
|
48
|
+
maxUsd: Number.POSITIVE_INFINITY,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
// Caller passed a bare maxHops without a budget object — accept it as a
|
|
53
|
+
// hop-only budget. Useful for "no remote delegation allowed" via
|
|
54
|
+
// maxHops: 0.
|
|
55
|
+
if (raw == null && overrideMaxHops != null) {
|
|
56
|
+
const hopCheck = checkHops(overrideMaxHops);
|
|
57
|
+
if (!hopCheck.ok)
|
|
58
|
+
return hopCheck;
|
|
59
|
+
return {
|
|
60
|
+
ok: true,
|
|
61
|
+
budget: {
|
|
62
|
+
maxHops: hopCheck.value,
|
|
63
|
+
maxTokens: Number.POSITIVE_INFINITY,
|
|
64
|
+
maxUsd: Number.POSITIVE_INFINITY,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (typeof raw !== 'object' || Array.isArray(raw)) {
|
|
69
|
+
return { ok: false, error: 'budget must be an object' };
|
|
70
|
+
}
|
|
71
|
+
const obj = raw;
|
|
72
|
+
const hopsRaw = overrideMaxHops ?? obj.maxHops;
|
|
73
|
+
const hopCheck = hopsRaw == null
|
|
74
|
+
? { ok: true, value: DEFAULT_MAX_HOPS }
|
|
75
|
+
: checkHops(hopsRaw);
|
|
76
|
+
if (!hopCheck.ok)
|
|
77
|
+
return hopCheck;
|
|
78
|
+
const tokensCheck = obj.maxTokens == null
|
|
79
|
+
? { ok: true, value: Number.POSITIVE_INFINITY }
|
|
80
|
+
: checkBound(obj.maxTokens, MAX_TOKENS_CEILING, 'maxTokens', true);
|
|
81
|
+
if (!tokensCheck.ok)
|
|
82
|
+
return tokensCheck;
|
|
83
|
+
const usdCheck = obj.maxUsd == null
|
|
84
|
+
? { ok: true, value: Number.POSITIVE_INFINITY }
|
|
85
|
+
: checkBound(obj.maxUsd, MAX_USD_CEILING, 'maxUsd', false);
|
|
86
|
+
if (!usdCheck.ok)
|
|
87
|
+
return usdCheck;
|
|
88
|
+
return {
|
|
89
|
+
ok: true,
|
|
90
|
+
budget: {
|
|
91
|
+
maxHops: hopCheck.value,
|
|
92
|
+
maxTokens: tokensCheck.value,
|
|
93
|
+
maxUsd: usdCheck.value,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function checkHops(v) {
|
|
98
|
+
if (typeof v !== 'number' || !Number.isFinite(v) || !Number.isInteger(v)) {
|
|
99
|
+
return { ok: false, error: 'maxHops must be a finite integer' };
|
|
100
|
+
}
|
|
101
|
+
if (v < 0)
|
|
102
|
+
return { ok: false, error: 'maxHops must be >= 0' };
|
|
103
|
+
if (v > MAX_HOPS_CEILING) {
|
|
104
|
+
return { ok: false, error: `maxHops exceeds ceiling (${MAX_HOPS_CEILING})` };
|
|
105
|
+
}
|
|
106
|
+
return { ok: true, value: v };
|
|
107
|
+
}
|
|
108
|
+
function checkBound(v, ceiling, label, requireInteger) {
|
|
109
|
+
if (typeof v !== 'number' || !Number.isFinite(v)) {
|
|
110
|
+
return { ok: false, error: `${label} must be a finite number` };
|
|
111
|
+
}
|
|
112
|
+
if (requireInteger && !Number.isInteger(v)) {
|
|
113
|
+
return { ok: false, error: `${label} must be an integer` };
|
|
114
|
+
}
|
|
115
|
+
if (v < 0)
|
|
116
|
+
return { ok: false, error: `${label} must be >= 0` };
|
|
117
|
+
if (v > ceiling) {
|
|
118
|
+
return { ok: false, error: `${label} exceeds ceiling (${ceiling})` };
|
|
119
|
+
}
|
|
120
|
+
return { ok: true, value: v };
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Atomic (single synchronous function, no internal awaits) hop check.
|
|
124
|
+
*
|
|
125
|
+
* Returns the hopCount value the OUTBOUND envelope should carry plus the
|
|
126
|
+
* remaining budget that downstream peers will see. Callers must use the
|
|
127
|
+
* returned values; mutating the input Budget is forbidden (it's readonly).
|
|
128
|
+
*
|
|
129
|
+
* Contract:
|
|
130
|
+
* - hopCount represents how many hops the message has already taken.
|
|
131
|
+
* - The next outbound hop increments it: nextHopCount = hopCount + 1.
|
|
132
|
+
* - The check fires AFTER increment: nextHopCount must be <= maxHops.
|
|
133
|
+
* - This means maxHops=0 refuses to forward at all, which matches the
|
|
134
|
+
* ADR's "no remote delegation allowed" semantic.
|
|
135
|
+
*
|
|
136
|
+
* tokensSpent / usdSpent are caller-reported actuals from the immediately
|
|
137
|
+
* preceding leg (or 0 on the originator). The check fires on the
|
|
138
|
+
* *post-spend* totals so a leg that overshoots is caught before the next
|
|
139
|
+
* outbound dispatch.
|
|
140
|
+
*/
|
|
141
|
+
export function enforceBudget(budget, hopCount, spent = { tokens: 0, usd: 0 }) {
|
|
142
|
+
const nextHopCount = hopCount + 1;
|
|
143
|
+
if (nextHopCount > budget.maxHops) {
|
|
144
|
+
return { ok: false, reason: 'HOP_LIMIT_EXCEEDED' };
|
|
145
|
+
}
|
|
146
|
+
// Negative spend is a programming error; treat as 0 rather than refunding
|
|
147
|
+
// the budget (which would let a malicious caller inflate remaining).
|
|
148
|
+
const ts = Math.max(0, spent.tokens);
|
|
149
|
+
const us = Math.max(0, spent.usd);
|
|
150
|
+
const remainingTokens = budget.maxTokens - ts;
|
|
151
|
+
const remainingUsd = budget.maxUsd - us;
|
|
152
|
+
if (remainingTokens < 0 || remainingUsd < 0) {
|
|
153
|
+
return { ok: false, reason: 'BUDGET_EXCEEDED' };
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
ok: true,
|
|
157
|
+
nextHopCount,
|
|
158
|
+
remaining: {
|
|
159
|
+
maxHops: budget.maxHops,
|
|
160
|
+
maxTokens: remainingTokens,
|
|
161
|
+
maxUsd: remainingUsd,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=federation-budget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"federation-budget.js","sourceRoot":"","sources":["../../../src/domain/value-objects/federation-budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,6EAA6E;AAC7E,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,6EAA6E;AAC7E,MAAM,eAAe,GAAG,SAAS,CAAC;AAClC,0FAA0F;AAC1F,MAAM,kBAAkB,GAAG,aAAa,CAAC;AACzC,iCAAiC;AACjC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAkB5B;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAY,EACZ,eAAyB;IAEzB,uDAAuD;IACvD,IAAI,GAAG,IAAI,IAAI,IAAI,eAAe,IAAI,IAAI,EAAE,CAAC;QAC3C,OAAO;YACL,EAAE,EAAE,IAAI;YACR,MAAM,EAAE;gBACN,OAAO,EAAE,gBAAgB;gBACzB,SAAS,EAAE,MAAM,CAAC,iBAAiB;gBACnC,MAAM,EAAE,MAAM,CAAC,iBAAiB;aACjC;SACF,CAAC;IACJ,CAAC;IAED,wEAAwE;IACxE,iEAAiE;IACjE,cAAc;IACd,IAAI,GAAG,IAAI,IAAI,IAAI,eAAe,IAAI,IAAI,EAAE,CAAC;QAC3C,MAAM,QAAQ,GAAG,SAAS,CAAC,eAAe,CAAC,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AO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAClD,CAAC;IACD,OAAO;QACL,EAAE,EAAE,IAAI;QACR,YAAY;QACZ,SAAS,EAAE;YACT,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,SAAS,EAAE,eAAe;YAC1B,MAAM,EAAE,YAAY;SACrB;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Federation peer state machine (ADR-097 Phase 2).
|
|
3
|
+
*
|
|
4
|
+
* Phase 1 shipped the budget envelope + enforcer that travels with every
|
|
5
|
+
* outbound message. Phase 2 adds the per-peer breaker: when a peer crosses a
|
|
6
|
+
* cost or failure threshold, transition it to SUSPENDED so subsequent
|
|
7
|
+
* `federation_send` calls short-circuit. After a cooldown the peer can
|
|
8
|
+
* recover; if it stays bad the breaker escalates to EVICTED.
|
|
9
|
+
*
|
|
10
|
+
* This module is the *value object* layer — pure, no I/O. The breaker
|
|
11
|
+
* service (Phase 2.b, separate file) reads cost-tracker telemetry, evaluates
|
|
12
|
+
* thresholds, and calls `transition` on the FederationNode entity. Decoupling
|
|
13
|
+
* the state machine from the policy lets tests pin transitions without
|
|
14
|
+
* standing up the cost bus.
|
|
15
|
+
*
|
|
16
|
+
* Security invariants pinned by the spec:
|
|
17
|
+
*
|
|
18
|
+
* 1. EVICTED is terminal under normal flow. The only way out is an
|
|
19
|
+
* explicit `reactivate` call (operator-initiated). This prevents a
|
|
20
|
+
* misbehaving peer from auto-recovering through the cooldown.
|
|
21
|
+
* 2. canTransition is the single source of truth for legality. Any path
|
|
22
|
+
* that mutates state MUST consult it; direct field writes are not
|
|
23
|
+
* permitted (entity getter/setter shape enforces this).
|
|
24
|
+
* 3. Reasons are constant strings, no remaining-budget echo on failure
|
|
25
|
+
* (matches Phase 1's anti-oracle posture).
|
|
26
|
+
* 4. Default cooldown is conservative (30 min) so a transient spike
|
|
27
|
+
* cannot ping-pong a peer ACTIVE↔SUSPENDED at high frequency.
|
|
28
|
+
*/
|
|
29
|
+
/** Lifecycle state of a federation peer. */
|
|
30
|
+
export declare enum FederationNodeState {
|
|
31
|
+
/** Default; healthy. `federation_send` accepts deliveries. */
|
|
32
|
+
ACTIVE = "ACTIVE",
|
|
33
|
+
/** Breaker tripped. Sends short-circuit with PEER_SUSPENDED. */
|
|
34
|
+
SUSPENDED = "SUSPENDED",
|
|
35
|
+
/** Removed from active rotation. Sends short-circuit with PEER_EVICTED. */
|
|
36
|
+
EVICTED = "EVICTED"
|
|
37
|
+
}
|
|
38
|
+
/** Reason a peer was suspended/evicted. Constant strings — no echo of caps. */
|
|
39
|
+
export type SuspensionReason = 'COST_THRESHOLD_EXCEEDED' | 'FAILURE_RATIO_EXCEEDED' | 'MANUAL_SUSPEND' | 'GRACE_PERIOD_EXPIRED' | 'MANUAL_EVICT';
|
|
40
|
+
/**
|
|
41
|
+
* Default cooldown a SUSPENDED peer must wait before being eligible for
|
|
42
|
+
* SUSPENDED → ACTIVE. 30 minutes matches the ADR-097 Part 2 spec and is
|
|
43
|
+
* intentionally well past the prompt-cache window so a recovery probe is
|
|
44
|
+
* cheap to amortize.
|
|
45
|
+
*/
|
|
46
|
+
export declare const DEFAULT_SUSPENSION_COOLDOWN_MS: number;
|
|
47
|
+
/**
|
|
48
|
+
* Default age at which a continuously-SUSPENDED peer is auto-escalated to
|
|
49
|
+
* EVICTED. 24 hours per spec — long enough to ride out a cost-tracker
|
|
50
|
+
* outage without false eviction, short enough that a genuinely-broken peer
|
|
51
|
+
* doesn't linger forever.
|
|
52
|
+
*/
|
|
53
|
+
export declare const DEFAULT_AUTO_EVICTION_AGE_MS: number;
|
|
54
|
+
/** A successful transition's reason payload (for the audit trail). */
|
|
55
|
+
export interface TransitionReason {
|
|
56
|
+
readonly reason: SuspensionReason;
|
|
57
|
+
/** Optional opaque correlation key — task ID, breaker run ID, etc. */
|
|
58
|
+
readonly correlationId?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Static legality table for state transitions. Returns true iff the
|
|
62
|
+
* `from -> to` edge is in the allowed set. Used by the entity to reject
|
|
63
|
+
* illegal mutations before applying them.
|
|
64
|
+
*
|
|
65
|
+
* Allowed edges:
|
|
66
|
+
* ACTIVE → SUSPENDED (breaker trips)
|
|
67
|
+
* SUSPENDED → ACTIVE (cooldown + probe success)
|
|
68
|
+
* SUSPENDED → EVICTED (grace expired, or manual evict)
|
|
69
|
+
* ACTIVE → EVICTED (manual evict only — skips suspend)
|
|
70
|
+
* EVICTED → ACTIVE (manual reactivate only)
|
|
71
|
+
*
|
|
72
|
+
* Disallowed (anything else, including self-loops, is a no-op error).
|
|
73
|
+
*/
|
|
74
|
+
export declare function canTransition(from: FederationNodeState, to: FederationNodeState): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Should a SUSPENDED peer be eligible for SUSPENDED → ACTIVE based purely
|
|
77
|
+
* on elapsed time? The breaker still has to confirm health via probe before
|
|
78
|
+
* it actually calls reactivate; this just answers "is the cooldown done?"
|
|
79
|
+
*
|
|
80
|
+
* Pure function of (suspendedAt, now, cooldownMs) so it's trivially
|
|
81
|
+
* deterministic in tests.
|
|
82
|
+
*/
|
|
83
|
+
export declare function isCooldownElapsed(suspendedAt: Date, now: Date, cooldownMs?: number): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Should a SUSPENDED peer be auto-escalated to EVICTED based on the age of
|
|
86
|
+
* its suspension? Returns true once the peer has been continuously
|
|
87
|
+
* SUSPENDED past the configured limit (default 24h). The breaker calls
|
|
88
|
+
* this on each tick and, if true, issues the SUSPENDED → EVICTED
|
|
89
|
+
* transition with reason GRACE_PERIOD_EXPIRED.
|
|
90
|
+
*/
|
|
91
|
+
export declare function shouldAutoEvict(suspendedAt: Date, now: Date, ageLimitMs?: number): boolean;
|
|
92
|
+
//# sourceMappingURL=federation-node-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"federation-node-state.d.ts","sourceRoot":"","sources":["../../../src/domain/value-objects/federation-node-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,4CAA4C;AAC5C,oBAAY,mBAAmB;IAC7B,8DAA8D;IAC9D,MAAM,WAAW;IACjB,gEAAgE;IAChE,SAAS,cAAc;IACvB,2EAA2E;IAC3E,OAAO,YAAY;CACpB;AAED,+EAA+E;AAC/E,MAAM,MAAM,gBAAgB,GACxB,yBAAyB,GACzB,wBAAwB,GACxB,gBAAgB,GAChB,sBAAsB,GACtB,cAAc,CAAC;AAEnB;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,QAAiB,CAAC;AAE7D;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,QAAsB,CAAC;AAEhE,sEAAsE;AACtE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,sEAAsE;IACtE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,mBAAmB,EACzB,EAAE,EAAE,mBAAmB,GACtB,OAAO,CAUT;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,IAAI,EACjB,GAAG,EAAE,IAAI,EACT,UAAU,GAAE,MAAuC,GAClD,OAAO,CAET;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,WAAW,EAAE,IAAI,EACjB,GAAG,EAAE,IAAI,EACT,UAAU,GAAE,MAAqC,GAChD,OAAO,CAET"}
|