claude-flow-novice 1.6.1 → 1.6.3
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/agents/cfn-loop/product-owner.md +54 -4
- package/.claude/commands/cfn-claude-sync.md +303 -0
- package/.claude/commands/cfn-loop-epic.md +290 -0
- package/.claude/commands/cfn-loop-single.md +168 -0
- package/.claude/commands/cfn-loop-sprints.md +384 -0
- package/.claude/commands/cfn-loop.md +180 -0
- package/.claude/commands/metrics-summary.md +58 -0
- package/.claude/commands/parse-epic.md +357 -0
- package/.claude/settings.json +5 -4
- package/.claude/settings.local.json +9 -2
- package/.claude-flow-novice/.claude/agents/cfn-loop/product-owner.md +792 -0
- package/.claude-flow-novice/dist/mcp/server.js +21 -2
- package/.claude-flow-novice/dist/src/api/auth-service.js +84 -38
- package/.claude-flow-novice/dist/src/api/auth-service.js.map +1 -1
- package/.claude-flow-novice/dist/src/api/claude-client.js +138 -3
- package/.claude-flow-novice/dist/src/api/claude-client.js.map +1 -1
- package/.claude-flow-novice/dist/src/cfn-loop/phase-orchestrator-example.js +1 -1
- package/.claude-flow-novice/dist/src/cfn-loop/scope-control.js +247 -0
- package/.claude-flow-novice/dist/src/cfn-loop/scope-control.js.map +1 -0
- package/.claude-flow-novice/dist/src/cli/commands/swarm.js +32 -15
- package/.claude-flow-novice/dist/src/cli/commands/swarm.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/commands/transparency.js +455 -0
- package/.claude-flow-novice/dist/src/cli/commands/transparency.js.map +1 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/CLAUDE.md +129 -13
- package/.claude-flow-novice/dist/src/components/visualizations/index.js +9 -0
- package/.claude-flow-novice/dist/src/components/visualizations/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js +462 -0
- package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/config-translator.js +248 -0
- package/.claude-flow-novice/dist/src/coordination/config-translator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js +287 -0
- package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/distributed-consensus.js +68 -9
- package/.claude-flow-novice/dist/src/coordination/distributed-consensus.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/feature-flags.js +166 -0
- package/.claude-flow-novice/dist/src/coordination/feature-flags.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/queen-agent.js +18 -4
- package/.claude-flow-novice/dist/src/coordination/queen-agent.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/role-assignment.js +6 -110
- package/.claude-flow-novice/dist/src/coordination/role-assignment.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/cache/artifact-cache-optimizer.js +632 -0
- package/.claude-flow-novice/dist/src/coordination/v2/cache/artifact-cache-optimizer.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/cache/index.js +11 -0
- package/.claude-flow-novice/dist/src/coordination/v2/cache/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/checkpoints/checkpoint-compressor.js +318 -0
- package/.claude-flow-novice/dist/src/coordination/v2/checkpoints/checkpoint-compressor.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.example.js +364 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.example.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.js +492 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/hierarchical-coordinator.js +786 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/hierarchical-coordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/index.js +16 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/parent-child-manager.js +342 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/parent-child-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/swarm-coordinator-v2.js +601 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/swarm-coordinator-v2.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/help-request-metrics.js +211 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/help-request-metrics.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/index.js +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/core/message-broker.js +365 -6
- package/.claude-flow-novice/dist/src/coordination/v2/core/message-broker.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/core/resource-manager-safe.js +478 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/resource-manager-safe.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine-config.js +5 -2
- package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine-config.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine.js +189 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/deadlock/deadlock-detector.js +424 -0
- package/.claude-flow-novice/dist/src/coordination/v2/deadlock/deadlock-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/deadlock/index.js +9 -0
- package/.claude-flow-novice/dist/src/coordination/v2/deadlock/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/deadlock/resource-manager.js +669 -0
- package/.claude-flow-novice/dist/src/coordination/v2/deadlock/resource-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/artifact-storage.js +451 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/artifact-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/cycle-detector.js +271 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/cycle-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-graph.js +335 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-graph.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-manager.js +439 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-request.js +92 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-request.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/index.js +21 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/topological-sort.js +223 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/topological-sort.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-coordinator.js +436 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-coordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-matcher.js +278 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-matcher.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request-handler.js +317 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request-handler.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request.js +273 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/index.js +15 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/waiting-agent-pool.js +512 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/waiting-agent-pool.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/index.js +6 -0
- package/.claude-flow-novice/dist/src/coordination/v2/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/integration/help-deadlock-integration.js +557 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/help-deadlock-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/index.js +14 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.example.js +212 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.example.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.js +552 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/memory/dependency-storage.js +367 -0
- package/.claude-flow-novice/dist/src/coordination/v2/memory/dependency-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/memory/index.js +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/memory/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channel.js +371 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/dependency-channel.js +355 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/dependency-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/help-channel.js +424 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/help-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/index.js +16 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/state-channel.js +295 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/state-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/task-channel.js +411 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/task-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/index.js +14 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-bus.js +387 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-bus.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-persistence.js +589 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-persistence.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-router.js +444 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-router.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/checkpoint-manager.js +29 -8
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/checkpoint-manager.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/help-coordinator.js +470 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/help-coordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/hierarchical-background-integration.js +450 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/hierarchical-background-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/index.js +5 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/multi-level-control.js +545 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/multi-level-control.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-controller.js +44 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-controller.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-message-integration.js +415 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-message-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/session-pool-optimizer.js +615 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/session-pool-optimizer.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/security/payload-validator.js +259 -0
- package/.claude-flow-novice/dist/src/coordination/v2/security/payload-validator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/transparency/index.js +17 -0
- package/.claude-flow-novice/dist/src/coordination/v2/transparency/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-integration.js +357 -0
- package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-system.js +679 -0
- package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-system.js.map +1 -0
- package/.claude-flow-novice/dist/src/core/agent-manager.js +30 -0
- package/.claude-flow-novice/dist/src/core/agent-manager.js.map +1 -1
- package/.claude-flow-novice/dist/src/mcp/server.js +21 -2
- package/.claude-flow-novice/dist/src/mcp/server.js.map +1 -1
- package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js +719 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/datadog-collector.js +363 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/datadog-collector.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/index.js +97 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/newrelic-collector.js +384 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/newrelic-collector.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/performance-optimizer.js +612 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/performance-optimizer.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/metrics-collector.js +282 -0
- package/.claude-flow-novice/dist/src/monitoring/metrics-collector.js.map +1 -0
- package/.claude-flow-novice/dist/src/observability/metrics-counter.js +268 -0
- package/.claude-flow-novice/dist/src/observability/metrics-counter.js.map +1 -0
- package/.claude-flow-novice/dist/src/observability/metrics-storage.js +265 -0
- package/.claude-flow-novice/dist/src/observability/metrics-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/observability/telemetry.js +26 -0
- package/.claude-flow-novice/dist/src/observability/telemetry.js.map +1 -1
- package/.claude-flow-novice/dist/src/providers/tiered-router.js +64 -10
- package/.claude-flow-novice/dist/src/providers/tiered-router.js.map +1 -1
- package/.claude-flow-novice/dist/src/providers/zai-provider.js +196 -97
- package/.claude-flow-novice/dist/src/providers/zai-provider.js.map +1 -1
- package/.claude-flow-novice/dist/src/slash-commands/cfn-claude-sync.js +533 -0
- package/.claude-flow-novice/dist/src/slash-commands/index.js +5 -0
- package/.claude-flow-novice/dist/src/slash-commands/metrics-summary-class.js +74 -0
- package/.claude-flow-novice/dist/src/slash-commands/metrics-summary.js +335 -0
- package/.claude-flow-novice/dist/src/slash-commands/register-all-commands.js +12 -0
- package/.claude-flow-novice/dist/src/verification/checkpoint-compression-demo.js +96 -0
- package/.claude-flow-novice/dist/src/verification/checkpoint-compression-demo.js.map +1 -0
- package/.claude-flow-novice/dist/src/verification/checkpoint-compression.js +406 -0
- package/.claude-flow-novice/dist/src/verification/checkpoint-compression.js.map +1 -0
- package/.claude-flow-novice/dist/src/verification/checkpoint-manager.js +35 -5
- package/.claude-flow-novice/dist/src/verification/checkpoint-manager.js.map +1 -1
- package/.claude-flow-novice/dist/src/web/api/apm-routes.js +355 -0
- package/.claude-flow-novice/dist/src/web/api/apm-routes.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/config/api-config.js +186 -0
- package/.claude-flow-novice/dist/src/web/api/config/api-config.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/auth.js +205 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/auth.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/cache.js +262 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/cache.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/error-handler.js +250 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/error-handler.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/request-logger.js +217 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/request-logger.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/validation.js +325 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/validation.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/routes/events.js +465 -0
- package/.claude-flow-novice/dist/src/web/api/routes/events.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/routes/hierarchy.js +302 -0
- package/.claude-flow-novice/dist/src/web/api/routes/hierarchy.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/routes/index.js +14 -0
- package/.claude-flow-novice/dist/src/web/api/routes/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/routes/metrics.js +561 -0
- package/.claude-flow-novice/dist/src/web/api/routes/metrics.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/routes/status.js +450 -0
- package/.claude-flow-novice/dist/src/web/api/routes/status.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/server.js +451 -0
- package/.claude-flow-novice/dist/src/web/api/server.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/dashboard/hooks/useWebSocket.js +385 -0
- package/.claude-flow-novice/dist/src/web/dashboard/hooks/useWebSocket.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/dashboard/index.js +87 -0
- package/.claude-flow-novice/dist/src/web/dashboard/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/dashboard/types.js +6 -0
- package/.claude-flow-novice/dist/src/web/dashboard/types.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/frontend/src/utils/security.js +425 -0
- package/.claude-flow-novice/dist/src/web/frontend/src/utils/security.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/security/security-middleware.js +379 -0
- package/.claude-flow-novice/dist/src/web/security/security-middleware.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/websocket/apm-websocket-handler.js +441 -0
- package/.claude-flow-novice/dist/src/web/websocket/apm-websocket-handler.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/websocket/websocket-manager.js +255 -1
- package/.claude-flow-novice/dist/src/web/websocket/websocket-manager.js.map +1 -1
- package/.claude-flow-novice/metrics.db +0 -0
- package/.claude-flow-novice/metrics.db-shm +0 -0
- package/.claude-flow-novice/metrics.db-wal +0 -0
- package/AGENT_PERFORMANCE_GUIDELINES.md +88 -0
- package/CLAUDE.md +60 -3
- package/MEMORY_LEAK_ROOT_CAUSE.md +149 -0
- package/README.md +27 -0
- package/config/hooks/post-edit-pipeline.js +36 -2
- package/examples/metrics-counter-demo.ts +106 -0
- package/examples/persistent-metrics-demo.ts +83 -0
- package/examples/phase-5-multi-level-control.ts +282 -0
- package/examples/session-pool-optimizer-example.ts +311 -0
- package/package.json +18 -4
- package/scripts/check-routing-stats.cjs +122 -0
- package/scripts/monitor-loop.sh +65 -0
- package/scripts/monitor-memory.sh +47 -0
- package/scripts/monitor.py +43 -0
- package/scripts/pre-publish-validation.cjs +212 -0
- package/scripts/test-provider-routing.cjs +228 -0
- package/scripts/test-routing-telemetry.cjs +147 -0
- package/scripts/test-zai-10k.cjs +81 -0
- package/scripts/test-zai-api.cjs +191 -0
- package/scripts/test-zai-diagnostic.cjs +151 -0
- package/scripts/test-zai-final.cjs +128 -0
- package/scripts/test-zai-with-env.cjs +85 -0
- package/scripts/validate-coordination-cli.js +69 -0
- package/scripts/validate-coordination-toggle-integration.cjs +501 -0
- package/src/cli/simple-commands/init/templates/CLAUDE.md +29 -0
- package/src/observability/metrics-counter.ts +347 -0
- package/src/observability/metrics-storage.ts +356 -0
- package/src/observability/telemetry.ts +658 -0
- package/src/slash-commands/cfn-claude-sync.js +533 -0
- package/src/slash-commands/index.js +5 -0
- package/src/slash-commands/metrics-summary-class.js +74 -0
- package/src/slash-commands/metrics-summary.js +335 -0
- package/src/slash-commands/register-all-commands.js +12 -0
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @module coordination/v2/core/message-broker
|
|
12
12
|
*/ import { EventEmitter } from 'events';
|
|
13
|
+
import { RateLimiter } from 'limiter';
|
|
13
14
|
import { MessagePriority, MessageUtils, DeliverySemantics } from './message.js';
|
|
15
|
+
import { PayloadValidator } from '../security/payload-validator.js';
|
|
14
16
|
/**
|
|
15
17
|
* Message broker error.
|
|
16
18
|
*/ export class MessageBrokerError extends Error {
|
|
@@ -30,6 +32,9 @@ import { MessagePriority, MessageUtils, DeliverySemantics } from './message.js';
|
|
|
30
32
|
dequeue() {
|
|
31
33
|
return this.items.shift();
|
|
32
34
|
}
|
|
35
|
+
peek() {
|
|
36
|
+
return this.items[0];
|
|
37
|
+
}
|
|
33
38
|
get length() {
|
|
34
39
|
return this.items.length;
|
|
35
40
|
}
|
|
@@ -87,6 +92,17 @@ import { MessagePriority, MessageUtils, DeliverySemantics } from './message.js';
|
|
|
87
92
|
stats;
|
|
88
93
|
processing;
|
|
89
94
|
subscriptionCounter;
|
|
95
|
+
// SEC-DOS-001: Per-sender queue tracking and dead letter queue
|
|
96
|
+
senderQueueSizes;
|
|
97
|
+
deadLetterQueue;
|
|
98
|
+
// SEC-DOS-002: Rate limiting
|
|
99
|
+
rateLimiters;
|
|
100
|
+
rateLimiterCleanupInterval;
|
|
101
|
+
// SEC-INJ-001: Payload validation
|
|
102
|
+
payloadValidator;
|
|
103
|
+
// SEC-MEM-001: Subscription tracking and limits
|
|
104
|
+
agentSubscriptions;
|
|
105
|
+
subscriptionCleanupInterval;
|
|
90
106
|
/**
|
|
91
107
|
* Creates a new message broker instance.
|
|
92
108
|
*
|
|
@@ -99,13 +115,35 @@ import { MessagePriority, MessageUtils, DeliverySemantics } from './message.js';
|
|
|
99
115
|
this.messageQueue = new PriorityQueue();
|
|
100
116
|
this.subscriptionCounter = 0;
|
|
101
117
|
this.processing = false;
|
|
118
|
+
// SEC-DOS-001: Initialize per-sender queue tracking
|
|
119
|
+
this.senderQueueSizes = new Map();
|
|
120
|
+
this.deadLetterQueue = new PriorityQueue();
|
|
121
|
+
// SEC-DOS-002: Initialize rate limiters
|
|
122
|
+
this.rateLimiters = new Map();
|
|
123
|
+
// SEC-MEM-001: Initialize subscription tracking
|
|
124
|
+
this.agentSubscriptions = new Map();
|
|
102
125
|
this.config = {
|
|
103
126
|
maxQueueSize: config?.maxQueueSize ?? 10000,
|
|
127
|
+
maxQueueSizePerSender: config?.maxQueueSizePerSender ?? 100,
|
|
128
|
+
enableDeadLetterQueue: config?.enableDeadLetterQueue ?? true,
|
|
129
|
+
priorityEvictionThreshold: config?.priorityEvictionThreshold ?? 0.9,
|
|
104
130
|
defaultRequestTimeout: config?.defaultRequestTimeout ?? 30000,
|
|
105
131
|
enableStats: config?.enableStats ?? true,
|
|
106
132
|
maxConcurrency: config?.maxConcurrency ?? 100,
|
|
107
|
-
|
|
133
|
+
maxSubscriptions: config?.maxSubscriptions ?? 10000,
|
|
134
|
+
maxSubscriptionsPerAgent: config?.maxSubscriptionsPerAgent ?? 100,
|
|
135
|
+
subscriptionTTL: config?.subscriptionTTL ?? 3600000,
|
|
136
|
+
cleanupIntervalMs: config?.cleanupIntervalMs ?? 60000,
|
|
137
|
+
authorizationProvider: config?.authorizationProvider,
|
|
138
|
+
rateLimit: config?.rateLimit ? {
|
|
139
|
+
maxMessagesPerSecond: config.rateLimit.maxMessagesPerSecond ?? 100,
|
|
140
|
+
maxBurstSize: config.rateLimit.maxBurstSize ?? 10,
|
|
141
|
+
strategy: config.rateLimit.strategy ?? 'token-bucket'
|
|
142
|
+
} : undefined,
|
|
143
|
+
payloadValidation: config?.payloadValidation
|
|
108
144
|
};
|
|
145
|
+
// SEC-INJ-001: Initialize payload validator
|
|
146
|
+
this.payloadValidator = new PayloadValidator(this.config.payloadValidation);
|
|
109
147
|
this.stats = {
|
|
110
148
|
totalPublished: 0,
|
|
111
149
|
totalDelivered: 0,
|
|
@@ -115,6 +153,12 @@ import { MessagePriority, MessageUtils, DeliverySemantics } from './message.js';
|
|
|
115
153
|
messagesByPriority: {},
|
|
116
154
|
avgDeliveryTime: 0
|
|
117
155
|
};
|
|
156
|
+
// SEC-DOS-002: Start rate limiter cleanup if rate limiting is enabled
|
|
157
|
+
if (this.config.rateLimit) {
|
|
158
|
+
this.startRateLimiterCleanup();
|
|
159
|
+
}
|
|
160
|
+
// SEC-MEM-001: Start subscription cleanup for TTL expiration
|
|
161
|
+
this.startSubscriptionCleanup();
|
|
118
162
|
}
|
|
119
163
|
// ============================================
|
|
120
164
|
// Pub/Sub Pattern
|
|
@@ -145,6 +189,16 @@ import { MessagePriority, MessageUtils, DeliverySemantics } from './message.js';
|
|
|
145
189
|
if (typeof config.handler !== 'function') {
|
|
146
190
|
throw new MessageBrokerError('Subscription handler must be a function');
|
|
147
191
|
}
|
|
192
|
+
// SEC-MEM-001: Check global subscription limit
|
|
193
|
+
if (this.stats.totalSubscriptions >= this.config.maxSubscriptions) {
|
|
194
|
+
throw new MessageBrokerError(`Maximum subscriptions reached (max: ${this.config.maxSubscriptions})`);
|
|
195
|
+
}
|
|
196
|
+
// SEC-MEM-001: Check per-agent subscription limit
|
|
197
|
+
const subscriberId = config.subscriberId || 'anonymous';
|
|
198
|
+
const agentSubs = this.agentSubscriptions.get(subscriberId) || new Set();
|
|
199
|
+
if (agentSubs.size >= this.config.maxSubscriptionsPerAgent) {
|
|
200
|
+
throw new MessageBrokerError(`Subscriber ${subscriberId} exceeded subscription limit (max: ${this.config.maxSubscriptionsPerAgent})`);
|
|
201
|
+
}
|
|
148
202
|
// SEC-012: Check subscription authorization
|
|
149
203
|
if (this.config.authorizationProvider && config.subscriberId) {
|
|
150
204
|
const authorized = await this.config.authorizationProvider.canSubscribe(config.subscriberId, config.topic);
|
|
@@ -153,13 +207,16 @@ import { MessagePriority, MessageUtils, DeliverySemantics } from './message.js';
|
|
|
153
207
|
}
|
|
154
208
|
}
|
|
155
209
|
const subscriptionId = `sub-${++this.subscriptionCounter}-${Date.now()}`;
|
|
210
|
+
// SEC-MEM-001: Create subscription with TTL expiration
|
|
156
211
|
const internalSub = {
|
|
157
212
|
id: subscriptionId,
|
|
158
213
|
topic: config.topic,
|
|
159
214
|
handler: config.handler,
|
|
160
215
|
priority: config.priority ?? 0,
|
|
161
216
|
createdAt: Date.now(),
|
|
162
|
-
filter: config.filter
|
|
217
|
+
filter: config.filter,
|
|
218
|
+
expiresAt: Date.now() + this.config.subscriptionTTL,
|
|
219
|
+
subscriberId
|
|
163
220
|
};
|
|
164
221
|
// Add to subscriptions map
|
|
165
222
|
if (!this.subscriptions.has(config.topic)) {
|
|
@@ -169,6 +226,9 @@ import { MessagePriority, MessageUtils, DeliverySemantics } from './message.js';
|
|
|
169
226
|
topicSubs.push(internalSub);
|
|
170
227
|
// Sort by priority (higher priority first)
|
|
171
228
|
topicSubs.sort((a, b)=>b.priority - a.priority);
|
|
229
|
+
// SEC-MEM-001: Track subscription by agent
|
|
230
|
+
agentSubs.add(subscriptionId);
|
|
231
|
+
this.agentSubscriptions.set(subscriberId, agentSubs);
|
|
172
232
|
this.stats.totalSubscriptions++;
|
|
173
233
|
return {
|
|
174
234
|
id: subscriptionId,
|
|
@@ -187,8 +247,19 @@ import { MessagePriority, MessageUtils, DeliverySemantics } from './message.js';
|
|
|
187
247
|
const subs = this.subscriptions.get(topic);
|
|
188
248
|
const index = subs.findIndex((sub)=>sub.id === subscriptionId);
|
|
189
249
|
if (index !== -1) {
|
|
250
|
+
const sub = subs[index];
|
|
190
251
|
subs.splice(index, 1);
|
|
191
252
|
this.stats.totalSubscriptions--;
|
|
253
|
+
// SEC-MEM-001: Clean up agent subscription tracking
|
|
254
|
+
if (sub.subscriberId) {
|
|
255
|
+
const agentSubs = this.agentSubscriptions.get(sub.subscriberId);
|
|
256
|
+
if (agentSubs) {
|
|
257
|
+
agentSubs.delete(subscriptionId);
|
|
258
|
+
if (agentSubs.size === 0) {
|
|
259
|
+
this.agentSubscriptions.delete(sub.subscriberId);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
192
263
|
// Clean up empty topic entries
|
|
193
264
|
if (subs.length === 0) {
|
|
194
265
|
this.subscriptions.delete(topic);
|
|
@@ -217,13 +288,70 @@ import { MessagePriority, MessageUtils, DeliverySemantics } from './message.js';
|
|
|
217
288
|
MessageUtils.validateConfig(config);
|
|
218
289
|
// SEC-007: Validate topic name to prevent injection
|
|
219
290
|
this.validateTopicName(config.topic);
|
|
291
|
+
// SEC-INJ-001: Validate and sanitize payload BEFORE processing
|
|
292
|
+
const validationResult = this.payloadValidator.validate(config.payload);
|
|
293
|
+
if (!validationResult.valid) {
|
|
294
|
+
this.emitter.emit('validation:failed', {
|
|
295
|
+
errors: validationResult.errors,
|
|
296
|
+
senderId: config.senderId,
|
|
297
|
+
topic: config.topic
|
|
298
|
+
});
|
|
299
|
+
throw new MessageBrokerError(`Payload validation failed: ${validationResult.errors.join(', ')}`);
|
|
300
|
+
}
|
|
301
|
+
// SEC-INJ-001: Sanitize payload to prevent injection attacks
|
|
302
|
+
const sanitizedPayload = this.payloadValidator.sanitize(config.payload);
|
|
303
|
+
const senderId = config.senderId || 'anonymous';
|
|
304
|
+
// SEC-DOS-002: Rate limiting - Check FIRST before any processing
|
|
305
|
+
if (this.config.rateLimit) {
|
|
306
|
+
const allowed = await this.checkRateLimit(senderId);
|
|
307
|
+
if (!allowed) {
|
|
308
|
+
this.emitter.emit('rate-limit:exceeded', {
|
|
309
|
+
senderId,
|
|
310
|
+
topic: config.topic
|
|
311
|
+
});
|
|
312
|
+
throw new MessageBrokerError(`Rate limit exceeded for sender ${senderId}`);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
// SEC-DOS-001: Per-sender queue limit - Check BEFORE global limit
|
|
316
|
+
// CRITICAL: Read and increment atomically to prevent race condition
|
|
317
|
+
const currentSenderSize = this.senderQueueSizes.get(senderId) || 0;
|
|
318
|
+
// Debug logging for per-sender queue tracking
|
|
319
|
+
if (process.env.DEBUG_MESSAGE_BROKER) {
|
|
320
|
+
console.log(`[MessageBroker PUBLISH] Sender ${senderId}: ${currentSenderSize} messages (limit: ${this.config.maxQueueSizePerSender}), queue processing: ${this.processing}`);
|
|
321
|
+
}
|
|
322
|
+
if (currentSenderSize >= this.config.maxQueueSizePerSender) {
|
|
323
|
+
throw new MessageBrokerError(`Sender ${senderId} exceeded queue limit (${currentSenderSize}/${this.config.maxQueueSizePerSender})`);
|
|
324
|
+
}
|
|
325
|
+
// SEC-DOS-001: Increment IMMEDIATELY after check to reserve slot (before async processing)
|
|
326
|
+
this.senderQueueSizes.set(senderId, currentSenderSize + 1);
|
|
327
|
+
if (process.env.DEBUG_MESSAGE_BROKER) {
|
|
328
|
+
console.log(`[MessageBroker PUBLISH] After increment: ${this.senderQueueSizes.get(senderId)}`);
|
|
329
|
+
}
|
|
330
|
+
// SEC-DOS-001: Global queue limit with priority eviction
|
|
220
331
|
if (this.messageQueue.length >= this.config.maxQueueSize) {
|
|
221
|
-
|
|
332
|
+
// If queue is at priority eviction threshold, evict low-priority messages
|
|
333
|
+
const evictionThreshold = Math.floor(this.config.maxQueueSize * this.config.priorityEvictionThreshold);
|
|
334
|
+
if (this.messageQueue.length >= evictionThreshold) {
|
|
335
|
+
const messagePriority = MessageUtils.normalizePriority(config.priority);
|
|
336
|
+
const evicted = this.evictLowPriorityMessages(messagePriority);
|
|
337
|
+
if (evicted.length === 0) {
|
|
338
|
+
throw new MessageBrokerError(`Message queue full (max: ${this.config.maxQueueSize}, no evictable messages)`);
|
|
339
|
+
}
|
|
340
|
+
this.emitter.emit('queue:high-pressure', {
|
|
341
|
+
queueSize: this.messageQueue.length,
|
|
342
|
+
evicted: evicted.length,
|
|
343
|
+
evictedMessages: evicted,
|
|
344
|
+
threshold: evictionThreshold
|
|
345
|
+
});
|
|
346
|
+
} else {
|
|
347
|
+
throw new MessageBrokerError(`Message queue full (max: ${this.config.maxQueueSize})`);
|
|
348
|
+
}
|
|
222
349
|
}
|
|
350
|
+
// SEC-INJ-001: Use sanitized payload in message
|
|
223
351
|
const message = {
|
|
224
352
|
id: MessageUtils.generateMessageId(),
|
|
225
353
|
topic: config.topic,
|
|
226
|
-
payload:
|
|
354
|
+
payload: sanitizedPayload,
|
|
227
355
|
priority: MessageUtils.normalizePriority(config.priority),
|
|
228
356
|
timestamp: Date.now(),
|
|
229
357
|
replyTo: config.replyTo,
|
|
@@ -234,6 +362,7 @@ import { MessagePriority, MessageUtils, DeliverySemantics } from './message.js';
|
|
|
234
362
|
metadata: config.metadata
|
|
235
363
|
};
|
|
236
364
|
this.messageQueue.enqueue(message);
|
|
365
|
+
// SEC-DOS-001: Sender queue size already incremented at line 517 (atomic check-and-increment)
|
|
237
366
|
if (this.config.enableStats) {
|
|
238
367
|
this.stats.totalPublished++;
|
|
239
368
|
this.stats.messagesByTopic[message.topic] = (this.stats.messagesByTopic[message.topic] || 0) + 1;
|
|
@@ -361,19 +490,60 @@ import { MessagePriority, MessageUtils, DeliverySemantics } from './message.js';
|
|
|
361
490
|
this.processing = true;
|
|
362
491
|
try {
|
|
363
492
|
while(this.messageQueue.length > 0){
|
|
364
|
-
|
|
493
|
+
// SEC-DOS-001-RACE: Peek at message first to check for matching handlers
|
|
494
|
+
const message = this.messageQueue.peek();
|
|
365
495
|
if (!message) break;
|
|
496
|
+
// Check if there are any matching handlers BEFORE dequeuing
|
|
497
|
+
const hasHandlers = this.hasMatchingHandlers(message);
|
|
498
|
+
// SEC-DOS-001-RACE: Only dequeue if handlers exist to prevent race condition
|
|
499
|
+
if (!hasHandlers) {
|
|
500
|
+
break;
|
|
501
|
+
}
|
|
502
|
+
// Now dequeue the message
|
|
503
|
+
this.messageQueue.dequeue();
|
|
504
|
+
// SEC-DOS-001: Deliver first, then decrement (counter represents "in-flight" messages)
|
|
366
505
|
await this.deliverMessage(message);
|
|
506
|
+
// SEC-DOS-001: Decrement AFTER successful delivery (message no longer in-flight)
|
|
507
|
+
const senderId = message.senderId || 'anonymous';
|
|
508
|
+
const senderSize = this.senderQueueSizes.get(senderId) || 0;
|
|
509
|
+
if (senderSize > 0) {
|
|
510
|
+
this.senderQueueSizes.set(senderId, senderSize - 1);
|
|
511
|
+
if (process.env.DEBUG_MESSAGE_BROKER) {
|
|
512
|
+
console.log(`[MessageBroker DELIVER] Decremented ${senderId}: ${senderSize} -> ${this.senderQueueSizes.get(senderId)}`);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
367
515
|
}
|
|
368
516
|
} finally{
|
|
369
517
|
this.processing = false;
|
|
370
518
|
}
|
|
371
519
|
}
|
|
372
520
|
/**
|
|
521
|
+
* Checks if there are any matching handlers for a message (without delivering).
|
|
522
|
+
* Used to prevent dequeuing messages when no subscribers exist.
|
|
523
|
+
*/ hasMatchingHandlers(message) {
|
|
524
|
+
// Check for pending request/reply handlers
|
|
525
|
+
if (message.correlationId && this.pendingRequests.has(message.correlationId)) {
|
|
526
|
+
return true;
|
|
527
|
+
}
|
|
528
|
+
// Check for topic subscribers
|
|
529
|
+
for (const topicPattern of Array.from(this.subscriptions.keys())){
|
|
530
|
+
if (MessageUtils.matchesTopic(message.topic, topicPattern)) {
|
|
531
|
+
const subs = this.subscriptions.get(topicPattern);
|
|
532
|
+
if (subs.length > 0) {
|
|
533
|
+
return true;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
373
540
|
* Delivers a message to all matching subscribers.
|
|
541
|
+
* Returns true if message was delivered to any handler, false otherwise.
|
|
374
542
|
*/ async deliverMessage(message) {
|
|
375
543
|
const startTime = Date.now();
|
|
376
544
|
const matchingHandlers = [];
|
|
545
|
+
// SEC-MEM-001: Clean up expired subscriptions before delivery
|
|
546
|
+
this.cleanupExpiredSubscriptions();
|
|
377
547
|
// Find matching subscriptions
|
|
378
548
|
for (const topicPattern of Array.from(this.subscriptions.keys())){
|
|
379
549
|
const subs = this.subscriptions.get(topicPattern);
|
|
@@ -425,11 +595,14 @@ import { MessagePriority, MessageUtils, DeliverySemantics } from './message.js';
|
|
|
425
595
|
});
|
|
426
596
|
}
|
|
427
597
|
}
|
|
598
|
+
// SEC-DOS-001: Sender queue size already decremented in processQueue() after dequeue (line 729-734)
|
|
428
599
|
// Update delivery time statistics
|
|
429
|
-
if (this.config.enableStats) {
|
|
600
|
+
if (this.config.enableStats && matchingHandlers.length > 0) {
|
|
430
601
|
const deliveryTime = Date.now() - startTime;
|
|
431
602
|
this.stats.avgDeliveryTime = (this.stats.avgDeliveryTime * (this.stats.totalDelivered - 1) + deliveryTime) / this.stats.totalDelivered;
|
|
432
603
|
}
|
|
604
|
+
// Return true if message was delivered to any handler
|
|
605
|
+
return matchingHandlers.length > 0;
|
|
433
606
|
}
|
|
434
607
|
// ============================================
|
|
435
608
|
// Statistics and Monitoring
|
|
@@ -518,6 +691,179 @@ import { MessagePriority, MessageUtils, DeliverySemantics } from './message.js';
|
|
|
518
691
|
}
|
|
519
692
|
}
|
|
520
693
|
// ============================================
|
|
694
|
+
// SEC-DOS-001 & SEC-DOS-002: DoS Protection Methods
|
|
695
|
+
// ============================================
|
|
696
|
+
/**
|
|
697
|
+
* SEC-DOS-002: Checks rate limit for a sender using token bucket algorithm.
|
|
698
|
+
*
|
|
699
|
+
* @param senderId - Sender identifier
|
|
700
|
+
* @returns True if request is allowed, false if rate limit exceeded
|
|
701
|
+
*/ async checkRateLimit(senderId) {
|
|
702
|
+
if (!this.config.rateLimit) {
|
|
703
|
+
return true; // Rate limiting disabled
|
|
704
|
+
}
|
|
705
|
+
let limiter = this.rateLimiters.get(senderId);
|
|
706
|
+
if (!limiter) {
|
|
707
|
+
// Create new rate limiter for this sender
|
|
708
|
+
limiter = new RateLimiter({
|
|
709
|
+
tokensPerInterval: this.config.rateLimit.maxMessagesPerSecond,
|
|
710
|
+
interval: 'second',
|
|
711
|
+
fireImmediately: true
|
|
712
|
+
});
|
|
713
|
+
this.rateLimiters.set(senderId, limiter);
|
|
714
|
+
}
|
|
715
|
+
try {
|
|
716
|
+
const remainingTokens = await limiter.removeTokens(1);
|
|
717
|
+
return remainingTokens >= 0;
|
|
718
|
+
} catch (error) {
|
|
719
|
+
// Rate limit exceeded
|
|
720
|
+
return false;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* SEC-DOS-002: Periodically cleanup idle rate limiters to prevent memory leaks.
|
|
725
|
+
*/ startRateLimiterCleanup() {
|
|
726
|
+
this.rateLimiterCleanupInterval = setInterval(()=>{
|
|
727
|
+
// Remove rate limiters that haven't been used recently
|
|
728
|
+
// In production, you would track last access time
|
|
729
|
+
// For now, we clear limiters periodically to prevent unbounded growth
|
|
730
|
+
if (this.rateLimiters.size > 1000) {
|
|
731
|
+
// Keep only the most recent 500 limiters (simple cleanup strategy)
|
|
732
|
+
const entries = Array.from(this.rateLimiters.entries());
|
|
733
|
+
const toKeep = entries.slice(-500);
|
|
734
|
+
this.rateLimiters.clear();
|
|
735
|
+
toKeep.forEach(([key, value])=>this.rateLimiters.set(key, value));
|
|
736
|
+
}
|
|
737
|
+
}, 60000); // Cleanup every 60 seconds
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* SEC-DOS-001: Evicts low-priority messages when queue is full.
|
|
741
|
+
* Only evicts enough messages to make room for 1 new message.
|
|
742
|
+
*
|
|
743
|
+
* @param incomingPriority - Priority of the incoming message
|
|
744
|
+
* @returns Array of evicted messages
|
|
745
|
+
*/ evictLowPriorityMessages(incomingPriority) {
|
|
746
|
+
const evicted = [];
|
|
747
|
+
// SEC-DOS-001-RACE: Only evict 1 message to make room for the incoming message
|
|
748
|
+
// Don't evict ALL lower-priority messages
|
|
749
|
+
const items = this.messageQueue.items;
|
|
750
|
+
if (!items || items.length === 0) {
|
|
751
|
+
return evicted;
|
|
752
|
+
}
|
|
753
|
+
// Find lowest priority message
|
|
754
|
+
let lowestIndex = 0;
|
|
755
|
+
let lowestPriority = items[0].priority;
|
|
756
|
+
for(let i = 1; i < items.length; i++){
|
|
757
|
+
if (items[i].priority < lowestPriority) {
|
|
758
|
+
lowestPriority = items[i].priority;
|
|
759
|
+
lowestIndex = i;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
// Only evict if priority is lower than incoming
|
|
763
|
+
if (lowestPriority < incomingPriority) {
|
|
764
|
+
const candidate = items[lowestIndex];
|
|
765
|
+
items.splice(lowestIndex, 1);
|
|
766
|
+
// Move to dead letter queue if enabled
|
|
767
|
+
if (this.config.enableDeadLetterQueue) {
|
|
768
|
+
this.deadLetterQueue.enqueue(candidate);
|
|
769
|
+
}
|
|
770
|
+
// Decrement sender queue size
|
|
771
|
+
const senderId = candidate.senderId || 'anonymous';
|
|
772
|
+
const senderSize = this.senderQueueSizes.get(senderId) || 0;
|
|
773
|
+
if (senderSize > 0) {
|
|
774
|
+
this.senderQueueSizes.set(senderId, senderSize - 1);
|
|
775
|
+
}
|
|
776
|
+
evicted.push(candidate);
|
|
777
|
+
}
|
|
778
|
+
return evicted;
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Gets the current size of the dead letter queue.
|
|
782
|
+
*
|
|
783
|
+
* @returns Number of messages in dead letter queue
|
|
784
|
+
*/ getDeadLetterQueueSize() {
|
|
785
|
+
return this.deadLetterQueue.length;
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* SEC-DOS-002: Returns the number of active rate limiters.
|
|
789
|
+
*/ getRateLimiterCount() {
|
|
790
|
+
return this.rateLimiters.size;
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Retrieves messages from the dead letter queue.
|
|
794
|
+
*
|
|
795
|
+
* @param count - Number of messages to retrieve (default: all)
|
|
796
|
+
* @returns Array of dead letter messages
|
|
797
|
+
*/ getDeadLetterMessages(count) {
|
|
798
|
+
const items = this.deadLetterQueue.items;
|
|
799
|
+
if (!items) return [];
|
|
800
|
+
if (count === undefined) {
|
|
801
|
+
return [
|
|
802
|
+
...items
|
|
803
|
+
];
|
|
804
|
+
}
|
|
805
|
+
return items.slice(0, count);
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Clears the dead letter queue.
|
|
809
|
+
*/ clearDeadLetterQueue() {
|
|
810
|
+
this.deadLetterQueue.clear();
|
|
811
|
+
}
|
|
812
|
+
// ============================================
|
|
813
|
+
// SEC-MEM-001: Subscription Cleanup
|
|
814
|
+
// ============================================
|
|
815
|
+
/**
|
|
816
|
+
* Starts periodic subscription cleanup to expire old subscriptions (SEC-MEM-001).
|
|
817
|
+
* Runs periodically to remove expired subscriptions based on TTL.
|
|
818
|
+
*/ startSubscriptionCleanup() {
|
|
819
|
+
const cleanupInterval = this.config.cleanupIntervalMs ?? 60000;
|
|
820
|
+
this.subscriptionCleanupInterval = setInterval(()=>{
|
|
821
|
+
this.cleanupExpiredSubscriptions();
|
|
822
|
+
}, cleanupInterval);
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Synchronously removes expired subscriptions (SEC-MEM-001).
|
|
826
|
+
* Called by background timer and immediately before publishing.
|
|
827
|
+
*
|
|
828
|
+
* @returns Number of subscriptions removed
|
|
829
|
+
*/ cleanupExpiredSubscriptions() {
|
|
830
|
+
const now = Date.now();
|
|
831
|
+
let expiredCount = 0;
|
|
832
|
+
for (const topic of Array.from(this.subscriptions.keys())){
|
|
833
|
+
const subs = this.subscriptions.get(topic);
|
|
834
|
+
const validSubs = subs.filter((sub)=>{
|
|
835
|
+
if (sub.expiresAt && now >= sub.expiresAt) {
|
|
836
|
+
// Expired subscription
|
|
837
|
+
expiredCount++;
|
|
838
|
+
// Clean up agent tracking
|
|
839
|
+
if (sub.subscriberId) {
|
|
840
|
+
const agentSubs = this.agentSubscriptions.get(sub.subscriberId);
|
|
841
|
+
if (agentSubs) {
|
|
842
|
+
agentSubs.delete(sub.id);
|
|
843
|
+
if (agentSubs.size === 0) {
|
|
844
|
+
this.agentSubscriptions.delete(sub.subscriberId);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
this.stats.totalSubscriptions--;
|
|
849
|
+
return false; // Remove expired subscription
|
|
850
|
+
}
|
|
851
|
+
return true; // Keep valid subscription
|
|
852
|
+
});
|
|
853
|
+
if (validSubs.length === 0) {
|
|
854
|
+
this.subscriptions.delete(topic);
|
|
855
|
+
} else if (validSubs.length !== subs.length) {
|
|
856
|
+
this.subscriptions.set(topic, validSubs);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
if (expiredCount > 0) {
|
|
860
|
+
this.emitter.emit('subscriptions:expired', {
|
|
861
|
+
count: expiredCount
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
return expiredCount;
|
|
865
|
+
}
|
|
866
|
+
// ============================================
|
|
521
867
|
// Lifecycle Management
|
|
522
868
|
// ============================================
|
|
523
869
|
/**
|
|
@@ -532,6 +878,19 @@ import { MessagePriority, MessageUtils, DeliverySemantics } from './message.js';
|
|
|
532
878
|
pending.reject(new MessageBrokerError('Broker cleared'));
|
|
533
879
|
}
|
|
534
880
|
this.pendingRequests.clear();
|
|
881
|
+
// SEC-MEM-001: Clear subscription tracking
|
|
882
|
+
this.agentSubscriptions.clear();
|
|
883
|
+
// SEC-DOS-002: Clear rate limiters
|
|
884
|
+
this.rateLimiters.clear();
|
|
885
|
+
if (this.rateLimiterCleanupInterval) {
|
|
886
|
+
clearInterval(this.rateLimiterCleanupInterval);
|
|
887
|
+
this.rateLimiterCleanupInterval = undefined;
|
|
888
|
+
}
|
|
889
|
+
// SEC-MEM-001: Clear subscription cleanup interval
|
|
890
|
+
if (this.subscriptionCleanupInterval) {
|
|
891
|
+
clearInterval(this.subscriptionCleanupInterval);
|
|
892
|
+
this.subscriptionCleanupInterval = undefined;
|
|
893
|
+
}
|
|
535
894
|
this.stats.totalSubscriptions = 0;
|
|
536
895
|
this.emitter.removeAllListeners();
|
|
537
896
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/coordination/v2/core/message-broker.ts"],"names":["EventEmitter","MessagePriority","MessageUtils","DeliverySemantics","MessageBrokerError","Error","message","name","PriorityQueue","items","enqueue","item","push","sort","a","b","priority","dequeue","shift","length","size","clear","MessageBroker","emitter","subscriptions","pendingRequests","messageQueue","config","stats","processing","subscriptionCounter","setMaxListeners","Map","maxQueueSize","defaultRequestTimeout","enableStats","maxConcurrency","authorizationProvider","totalPublished","totalDelivered","totalFailed","totalSubscriptions","messagesByTopic","messagesByPriority","avgDeliveryTime","subscribe","topic","validateTopicName","handler","subscriberId","authorized","canSubscribe","subscriptionId","Date","now","internalSub","id","createdAt","filter","has","set","topicSubs","get","unsubscribe","Array","from","keys","subs","index","findIndex","sub","splice","delete","publish","validateConfig","generateMessageId","payload","normalizePriority","timestamp","replyTo","correlationId","senderId","recipientId","deliverySemantics","AT_LEAST_ONCE","metadata","processQueue","catch","error","console","broadcast","request","options","generateCorrelationId","timeout","NORMAL","replyTopic","Promise","resolve","reject","timeoutId","setTimeout","expectedSender","resolved","clearTimeout","reply","success","createReply","deliverMessage","startTime","matchingHandlers","topicPattern","matchesTopic","pendingRequest","warn","emit","subscription","deliveryTime","getStats","resetStats","getSubscriptions","result","values","getQueueSize","getPendingRequestCount","includes","validTopicPattern","test","pending","removeAllListeners","shutdown","onError","on"],"mappings":"AAAA;;;;;;;;;;;CAWC,GAED,SAASA,YAAY,QAAQ,SAAS;AACtC,SAIEC,eAAe,EAEfC,YAAY,EAMZC,iBAAiB,QACZ,eAAe;AAEtB;;CAEC,GACD,OAAO,MAAMC,2BAA2BC;IACtC,YAAYC,OAAe,CAAE;QAC3B,KAAK,CAACA;QACN,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AA2BA;;CAEC,GACD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,CAAC0G,kBAAkB;IACjC;IAEA;;;;;;GAMC,GACD,MAAMC,SAASpC,UAAkB,IAAI,EAAiB;QACpD,MAAMe,YAAYxD,KAAKC,GAAG;QAE1B,0BAA0B;QAC1B,MAAO,IAAI,CAAC5B,YAAY,CAACP,MAAM,GAAG,KAAKkC,KAAKC,GAAG,KAAKuD,YAAYf,QAAS;YACvE,MAAM,IAAIG,QAAQC,CAAAA,UAAWG,WAAWH,SAAS;QACnD;QAEA,IAAI,CAAC7E,KAAK;IACZ;IAEA;;;;GAIC,GACD8G,QAAQnF,OAA6B,EAAQ;QAC3C,IAAI,CAACzB,OAAO,CAAC6G,EAAE,CAAC,SAASpF;IAC3B;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/coordination/v2/core/message-broker.ts"],"names":["EventEmitter","RateLimiter","MessagePriority","MessageUtils","DeliverySemantics","PayloadValidator","MessageBrokerError","Error","message","name","PriorityQueue","items","enqueue","item","push","sort","a","b","priority","dequeue","shift","peek","length","size","clear","MessageBroker","emitter","subscriptions","pendingRequests","messageQueue","config","stats","processing","subscriptionCounter","senderQueueSizes","deadLetterQueue","rateLimiters","rateLimiterCleanupInterval","payloadValidator","agentSubscriptions","subscriptionCleanupInterval","setMaxListeners","Map","maxQueueSize","maxQueueSizePerSender","enableDeadLetterQueue","priorityEvictionThreshold","defaultRequestTimeout","enableStats","maxConcurrency","maxSubscriptions","maxSubscriptionsPerAgent","subscriptionTTL","cleanupIntervalMs","authorizationProvider","rateLimit","maxMessagesPerSecond","maxBurstSize","strategy","undefined","payloadValidation","totalPublished","totalDelivered","totalFailed","totalSubscriptions","messagesByTopic","messagesByPriority","avgDeliveryTime","startRateLimiterCleanup","startSubscriptionCleanup","subscribe","topic","validateTopicName","handler","subscriberId","agentSubs","get","Set","authorized","canSubscribe","subscriptionId","Date","now","internalSub","id","createdAt","filter","expiresAt","has","set","topicSubs","add","unsubscribe","Array","from","keys","subs","index","findIndex","sub","splice","delete","publish","validateConfig","validationResult","validate","payload","valid","emit","errors","senderId","join","sanitizedPayload","sanitize","allowed","checkRateLimit","currentSenderSize","process","env","DEBUG_MESSAGE_BROKER","console","log","evictionThreshold","Math","floor","messagePriority","normalizePriority","evicted","evictLowPriorityMessages","queueSize","evictedMessages","threshold","generateMessageId","timestamp","replyTo","correlationId","recipientId","deliverySemantics","AT_LEAST_ONCE","metadata","processQueue","catch","error","broadcast","request","options","generateCorrelationId","timeout","NORMAL","replyTopic","Promise","resolve","reject","timeoutId","setTimeout","expectedSender","resolved","clearTimeout","reply","success","createReply","hasHandlers","hasMatchingHandlers","deliverMessage","senderSize","topicPattern","matchesTopic","startTime","matchingHandlers","cleanupExpiredSubscriptions","pendingRequest","warn","subscription","deliveryTime","getStats","resetStats","getSubscriptions","result","values","getQueueSize","getPendingRequestCount","includes","validTopicPattern","test","limiter","tokensPerInterval","interval","fireImmediately","remainingTokens","removeTokens","setInterval","entries","toKeep","slice","forEach","key","value","incomingPriority","lowestIndex","lowestPriority","i","candidate","getDeadLetterQueueSize","getRateLimiterCount","getDeadLetterMessages","count","clearDeadLetterQueue","cleanupInterval","expiredCount","validSubs","pending","clearInterval","removeAllListeners","shutdown","onError","on"],"mappings":"AAAA;;;;;;;;;;;CAWC,GAED,SAASA,YAAY,QAAQ,SAAS;AACtC,SAASC,WAAW,QAAQ,UAAU;AACtC,SAIEC,eAAe,EAEfC,YAAY,EAMZC,iBAAiB,QACZ,eAAe;AACtB,SAASC,gBAAgB,QAA+B,mCAAmC;AAE3F;;CAEC,GACD,OAAO,MAAMC,2BAA2BC;IACtC,YAAYC,OAAe,CAAE;QAC3B,KAAK,CAACA;QACN,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AA6BA;;CAEC,GACD,IAAA,AAAMC,gBAAN,MAAMA;IACIC,QAAa,EAAE,CAAC;IAExBC,QAAQC,IAAO,EAAQ;QACrB,IAAI,CAACF,KAAK,CAACG,IAAI,CAACD;QAChB,IAAI,CAACF,KAAK,CAACI,IAAI,CAAC,CA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