claude-flow-novice 2.15.3 → 2.15.5
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/cfn-extras/skills/advanced-features/cfn-agent-swap/recommend-swap.sh +59 -59
- package/.claude/cfn-extras/skills/analytics/cfn-improvement-recommender/recommend-improvements.sh +91 -91
- package/.claude/cfn-extras/skills/analytics/cfn-pattern-extraction/extract-patterns.sh +79 -79
- package/.claude/cfn-extras/skills/analytics/cfn-retrospective-report/generate-report.sh +100 -100
- package/.claude/cfn-extras/skills/analytics/cfn-telemetry/start-telemetry.sh +110 -110
- package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/add-bullet.sh +145 -145
- package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/log-merge.sh +67 -67
- package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/monitor-injection-performance.sh +137 -137
- package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/optimize-injection-pipeline.sh +168 -168
- package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/query-reflections.sh +35 -35
- package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/store-reflection.sh +45 -45
- package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/track-ab-test.sh +41 -41
- package/.claude/cfn-extras/skills/deprecated/cfn-ace-system/update-reflection.sh +41 -41
- package/.claude/cfn-extras/skills/deprecated/cfn-cli-setup/validate-cli-environment.sh +191 -191
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/create-campaign.sh +231 -231
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/get-campaign-performance.sh +190 -190
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/pause-campaign.sh +142 -142
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/set-budget.sh +181 -181
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/update-bid-strategy.sh +133 -133
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/get-conversation-history.sh +121 -121
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/qualify-lead.sh +156 -156
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/schedule-demo.sh +181 -181
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/send-message.sh +137 -137
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/transfer-to-human.sh +179 -179
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/create-campaign.sh +183 -183
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/get-delivery-status.sh +139 -139
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/opt-out.sh +150 -150
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/schedule-campaign.sh +187 -187
- package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/send-sms.sh +181 -181
- package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/test-web-portal-skill.sh +50 -50
- package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/validate-deployment.sh +84 -84
- package/.claude/cfn-extras/skills/utility/cfn-environment-sanitization/sanitize-environment.sh +243 -243
- package/.claude/commands/cfn-loop-cli.md +29 -6
- package/.claude/commands/switch-api.md +31 -10
- package/.claude/hooks/cfn-lint-sql-injection.sh +61 -0
- package/.claude/hooks/cfn-post-edit-cfn-retrospective.sh +33 -2
- package/.claude/hooks/cfn-pre-edit-security-warning.sh +40 -0
- package/.claude/skills/cfn-agent-spawning/spawn-agent.sh +22 -24
- package/.claude/skills/cfn-docker-agent-spawning/SKILL.md +28 -4
- package/.claude/skills/cfn-docker-agent-spawning/spawn-agent.sh +3 -1
- package/.claude/skills/cfn-docker-loop-orchestration/orchestrate.sh +224 -20
- package/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh +550 -46
- package/.claude/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +277 -0
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +238 -29
- package/.claude/skills/cfn-loop-orchestration/security_utils.sh +24 -0
- package/.claude/skills/cfn-loop-orchestration/test-iteration-context-injection.sh +366 -0
- package/.claude/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +319 -0
- package/.claude/skills/cfn-redis-coordination/agent-log.sh +4 -0
- package/.claude/skills/cfn-redis-coordination/agent-log.sh.bak +124 -0
- package/.claude/skills/cfn-redis-coordination/agent-recovery.sh +2 -2
- package/.claude/skills/cfn-redis-coordination/collect-confidence-scores.sh +30 -0
- package/.claude/skills/cfn-redis-coordination/get-context.sh +33 -0
- package/.claude/skills/cfn-redis-coordination/get-success-criteria.sh +54 -0
- package/.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh +6 -2
- package/.claude/skills/cfn-redis-coordination/redis-cli-wrapper.sh +24 -3
- package/.claude/skills/cfn-redis-coordination/redis-functions.sh +34 -0
- package/.claude/skills/cfn-redis-coordination/report-completion.sh +24 -31
- package/.claude/skills/cfn-redis-coordination/store-context.sh +4 -0
- package/.claude/skills/cfn-redis-coordination/store-success-criteria.sh +85 -0
- package/.claude/skills/cfn-redis-coordination/update-all-scripts.sh +67 -0
- package/.claude/skills/cfn-sqlite-memory/ttl-cleanup.sh +17 -25
- package/.claude/skills/cfn-transparency-middleware/test-e2e.sh +15 -0
- package/.claude/skills/cfn-transparency-middleware/tests/input-validation.sh +15 -0
- package/README.md +116 -475
- package/claude-assets/agents/cfn-dev-team/README.md +103 -0
- package/claude-assets/agents/cfn-dev-team/architecture/goal-planner.md +1 -1
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +77 -15
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +355 -6
- package/claude-assets/agents/cfn-dev-team/coordinators/consensus-builder.md +82 -1
- package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +82 -1
- package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +77 -15
- package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +99 -12
- package/claude-assets/agents/cfn-dev-team/dev-ops/github-commit-agent.md +1 -1
- package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +97 -0
- package/claude-assets/agents/cfn-dev-team/dev-ops/monitoring-specialist.md +20 -1
- package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +97 -0
- package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +110 -13
- package/claude-assets/agents/cfn-dev-team/developers/data/data-engineer.md +106 -15
- package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +115 -11
- package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +94 -7
- package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +87 -9
- package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +85 -7
- package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +160 -28
- package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +101 -19
- package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +108 -14
- package/claude-assets/agents/cfn-dev-team/reviewers/{reviewer.md → code-reviewer.md} +95 -8
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +107 -7
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +98 -7
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +95 -7
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +136 -9
- package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +108 -1
- package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +107 -13
- package/claude-assets/agents/cfn-dev-team/testers/contract-tester.md +737 -0
- package/claude-assets/agents/cfn-dev-team/testers/e2e/playwright-tester.md +1 -1
- package/claude-assets/agents/cfn-dev-team/testers/integration-tester.md +828 -0
- package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +106 -7
- package/claude-assets/agents/cfn-dev-team/testers/load-testing-specialist.md +77 -0
- package/claude-assets/agents/cfn-dev-team/testers/mutation-testing-specialist.md +684 -0
- package/claude-assets/agents/cfn-dev-team/testers/playwright-tester.md +110 -1
- package/claude-assets/agents/cfn-dev-team/testers/tester.md +94 -7
- package/claude-assets/agents/cfn-dev-team/utility/code-booster.md +1 -3
- package/claude-assets/agents/cfn-dev-team/utility/epic-creator.md +87 -13
- package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +103 -7
- package/claude-assets/agents/cfn-dev-team/utility/researcher.md +1 -3
- package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +94 -7
- package/claude-assets/agents/docker-coordinators/cfn-docker-v3-coordinator.md +46 -0
- package/claude-assets/agents/project-only-agents/npm-package-specialist.md +1 -1
- package/claude-assets/cfn-extras/skills/advanced-features/cfn-agent-swap/recommend-swap.sh +59 -59
- package/claude-assets/cfn-extras/skills/analytics/cfn-improvement-recommender/recommend-improvements.sh +91 -91
- package/claude-assets/cfn-extras/skills/analytics/cfn-pattern-extraction/extract-patterns.sh +79 -79
- package/claude-assets/cfn-extras/skills/analytics/cfn-retrospective-report/generate-report.sh +100 -100
- package/claude-assets/cfn-extras/skills/analytics/cfn-telemetry/start-telemetry.sh +110 -110
- package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/add-bullet.sh +145 -145
- package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/log-merge.sh +67 -67
- package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/monitor-injection-performance.sh +137 -137
- package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/optimize-injection-pipeline.sh +168 -168
- package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/query-reflections.sh +35 -35
- package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/store-reflection.sh +45 -45
- package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/track-ab-test.sh +41 -41
- package/claude-assets/cfn-extras/skills/deprecated/cfn-ace-system/update-reflection.sh +41 -41
- package/claude-assets/cfn-extras/skills/deprecated/cfn-cli-setup/validate-cli-environment.sh +191 -191
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/create-campaign.sh +231 -231
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/get-campaign-performance.sh +190 -190
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/pause-campaign.sh +142 -142
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/set-budget.sh +181 -181
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/update-bid-strategy.sh +133 -133
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/get-conversation-history.sh +121 -121
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/qualify-lead.sh +156 -156
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/schedule-demo.sh +181 -181
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/send-message.sh +137 -137
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/transfer-to-human.sh +179 -179
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/create-campaign.sh +183 -183
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/get-delivery-status.sh +139 -139
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/opt-out.sh +150 -150
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/schedule-campaign.sh +187 -187
- package/claude-assets/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/send-sms.sh +181 -181
- package/claude-assets/cfn-extras/skills/ui-portal/cfn-web-portal/test-web-portal-skill.sh +50 -50
- package/claude-assets/cfn-extras/skills/ui-portal/cfn-web-portal/validate-deployment.sh +84 -84
- package/claude-assets/cfn-extras/skills/utility/cfn-environment-sanitization/sanitize-environment.sh +243 -243
- package/claude-assets/commands/cfn-loop-cli.md +29 -6
- package/claude-assets/commands/switch-api.md +31 -10
- package/claude-assets/hooks/cfn-lint-sql-injection.sh +61 -0
- package/claude-assets/hooks/cfn-post-edit-cfn-retrospective.sh +33 -2
- package/claude-assets/hooks/cfn-pre-edit-security-warning.sh +40 -0
- package/claude-assets/hooks/detect-hardcoded-credentials.sh +212 -0
- package/claude-assets/skills/SKILL_TEMPLATE.md +774 -0
- package/claude-assets/skills/agent-lifecycle/execute-lifecycle-hook.sh +84 -113
- package/claude-assets/skills/agent-lifecycle/simple-audit.sh +33 -6
- package/claude-assets/skills/agent-template-generator/SKILL.md +440 -0
- package/claude-assets/skills/agent-template-generator/generate-agent.sh +405 -0
- package/claude-assets/skills/agent-validation-linter/SKILL.md +589 -0
- package/claude-assets/skills/agent-validation-linter/lint-agents.sh +271 -0
- package/claude-assets/skills/bootstrap/bash-fundamentals.md +786 -0
- package/claude-assets/skills/bootstrap/database-connection.md +464 -0
- package/claude-assets/skills/bootstrap/error-handling.md +580 -0
- package/claude-assets/skills/bootstrap/file-operations.md +699 -0
- package/claude-assets/skills/bootstrap/skill-loader.md +616 -0
- package/claude-assets/skills/bootstrap/sqlite-params.sh +287 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh +22 -24
- package/claude-assets/skills/cfn-automatic-memory-persistence/test-memory-persistence.sh +17 -16
- package/claude-assets/skills/cfn-deployment/SKILL.md +293 -0
- package/claude-assets/skills/cfn-deployment/execute.sh +21 -0
- package/claude-assets/skills/cfn-docker-agent-spawning/SKILL.md +28 -4
- package/claude-assets/skills/cfn-docker-agent-spawning/spawn-agent.sh +3 -1
- package/claude-assets/skills/cfn-docker-loop-orchestration/orchestrate.sh +224 -20
- package/claude-assets/skills/cfn-environment-sanitization/sanitize-environment.sh +38 -0
- package/claude-assets/skills/cfn-error-batching-strategy/lib/core-functions.sh +47 -47
- package/claude-assets/skills/cfn-file-operations/SKILL.md +290 -0
- package/claude-assets/skills/cfn-file-operations/execute.sh +129 -0
- package/claude-assets/skills/cfn-file-operations/lib/atomic-write.sh +294 -0
- package/claude-assets/skills/cfn-file-operations/lib/lock.sh +361 -0
- package/claude-assets/skills/cfn-file-operations/test.sh +369 -0
- package/claude-assets/skills/cfn-log-operations/SKILL.md +308 -0
- package/claude-assets/skills/cfn-log-operations/execute.sh +420 -0
- package/claude-assets/skills/cfn-log-operations/lib/rotate.sh +406 -0
- package/claude-assets/skills/cfn-log-operations/lib/search.sh +448 -0
- package/claude-assets/skills/cfn-log-operations/test.sh +394 -0
- package/claude-assets/skills/cfn-loop-orchestration/helpers/gate-check.sh +550 -46
- package/claude-assets/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +277 -0
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +238 -29
- package/claude-assets/skills/cfn-loop-orchestration/security_utils.sh +24 -0
- package/claude-assets/skills/cfn-loop-orchestration/test-iteration-context-injection.sh +366 -0
- package/claude-assets/skills/cfn-parameterized-queries/SKILL.md +339 -0
- package/claude-assets/skills/cfn-playbook/query-playbook.sh +19 -15
- package/claude-assets/skills/cfn-playbook/update-playbook.sh +25 -14
- package/claude-assets/skills/cfn-process-instrumentation/instrument-process.sh +44 -0
- package/claude-assets/skills/cfn-promotion/SKILL.md +305 -0
- package/claude-assets/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +319 -0
- package/claude-assets/skills/cfn-redis-coordination/agent-log.sh +4 -0
- package/claude-assets/skills/cfn-redis-coordination/agent-log.sh.bak +124 -0
- package/claude-assets/skills/cfn-redis-coordination/agent-recovery.sh +2 -2
- package/claude-assets/skills/cfn-redis-coordination/collect-confidence-scores.sh +30 -0
- package/claude-assets/skills/cfn-redis-coordination/get-context.sh +33 -0
- package/claude-assets/skills/cfn-redis-coordination/get-success-criteria.sh +54 -0
- package/claude-assets/skills/cfn-redis-coordination/invoke-waiting-mode.sh +6 -2
- package/claude-assets/skills/cfn-redis-coordination/redis-cli-wrapper.sh +24 -3
- package/claude-assets/skills/cfn-redis-coordination/redis-functions.sh +34 -0
- package/claude-assets/skills/cfn-redis-coordination/report-completion.sh +24 -31
- package/claude-assets/skills/cfn-redis-coordination/store-context.sh +4 -0
- package/claude-assets/skills/cfn-redis-coordination/store-success-criteria.sh +85 -0
- package/claude-assets/skills/cfn-redis-coordination/update-all-scripts.sh +67 -0
- package/claude-assets/skills/cfn-skill-loader/SKILL.md +466 -0
- package/claude-assets/skills/cfn-skill-loader/execute.sh +344 -0
- package/claude-assets/skills/cfn-sqlite-memory/ttl-cleanup.sh +17 -25
- package/claude-assets/skills/cfn-task-audit/get-audit-data.sh +42 -21
- package/claude-assets/skills/cfn-task-audit/store-task-audit.sh +17 -10
- package/claude-assets/skills/cfn-test-runner/detect-regressions.sh +17 -14
- package/claude-assets/skills/cfn-test-runner/detect-regressions.sh.backup-1763392821 +55 -0
- package/claude-assets/skills/cfn-test-runner/store-benchmarks.sh +17 -19
- package/claude-assets/skills/cfn-transparency-middleware/test-e2e.sh +15 -0
- package/claude-assets/skills/cfn-transparency-middleware/tests/input-validation.sh +15 -0
- package/claude-assets/skills/cfn-utilities/SKILL.md +237 -0
- package/claude-assets/skills/cfn-utilities/execute.sh +32 -0
- package/claude-assets/skills/cfn-utilities/lib/errors.sh +56 -0
- package/claude-assets/skills/cfn-utilities/lib/file-ops.sh +164 -0
- package/claude-assets/skills/cfn-utilities/lib/logging.sh +77 -0
- package/claude-assets/skills/cfn-utilities/lib/retry.sh +127 -0
- package/claude-assets/skills/cfn-utilities/test.sh +317 -0
- package/claude-assets/skills/integration/agent-handoff.sh +62 -64
- package/claude-assets/skills/json-validation/SKILL.md +431 -0
- package/claude-assets/skills/json-validation/test-validate-success-criteria.sh +421 -0
- package/claude-assets/skills/json-validation/validate-success-criteria.sh +197 -0
- package/claude-assets/skills/redis-coordination/validate-parameters.sh +34 -0
- package/claude-assets/skills/workflow-codification/DEPLOY_QUICK_REFERENCE.md +106 -0
- package/claude-assets/skills/workflow-codification/PROPAGATE_UPDATE_QUICK_REFERENCE.md +366 -0
- package/claude-assets/skills/workflow-codification/deploy-approved-skill.sh +481 -0
- package/claude-assets/skills/workflow-codification/deploy-approved-skill.sh.backup-1763392820 +512 -0
- package/claude-assets/skills/workflow-codification/lib/security-utils.sh +204 -0
- package/claude-assets/skills/workflow-codification/propagate-skill-update.sh +648 -0
- package/claude-assets/skills/workflow-codification/propagate-skill-update.sh.backup-1763392820 +664 -0
- package/claude-assets/skills/workflow-codification/test-integration.sh +15 -0
- package/claude-assets/skills/workflow-codification/test-metadata-update.sh +350 -0
- package/claude-assets/skills/workflow-codification/track-cost-savings.sh +55 -14
- package/claude-assets/skills/workflow-codification/track-cost-savings.sh.backup-1763392821 +445 -0
- package/claude-assets/skills/workflow-codification/track-edge-case.sh +27 -60
- package/claude-assets/skills/workflow-codification/workflow-codification.db +0 -0
- package/dist/ace/ace-curator.js +10 -2
- package/dist/ace/ace-curator.js.map +1 -1
- package/dist/ace/ace-generator.js +4 -0
- package/dist/ace/ace-generator.js.map +1 -1
- package/dist/ace/ace-reflector.js +1 -1
- package/dist/ace/ace-reflector.js.map +1 -1
- package/dist/ace/context-injection.js +24 -2
- package/dist/ace/context-injection.js.map +1 -1
- package/dist/agents/task-agent-integration.js +1 -1
- package/dist/agents/task-agent-integration.js.map +1 -1
- package/dist/api/health-endpoints.js +390 -0
- package/dist/api/health-endpoints.js.map +1 -0
- package/dist/cli/agent-executor.js +4 -1
- package/dist/cli/agent-executor.js.map +1 -1
- package/dist/cli/agent-prompt-builder.js +89 -1
- package/dist/cli/agent-prompt-builder.js.map +1 -1
- package/dist/cli/agent-spawn.js +130 -37
- package/dist/cli/agent-spawn.js.map +1 -1
- package/dist/cli/config-manager.js +109 -91
- package/dist/cli/config-manager.js.map +1 -1
- package/dist/cli/conversation-fork-cleanup.js +201 -0
- package/dist/cli/conversation-fork-cleanup.js.map +1 -0
- package/dist/cli/conversation-fork.js +16 -3
- package/dist/cli/conversation-fork.js.map +1 -1
- package/dist/cli/skill-cache-validator.js +412 -0
- package/dist/cli/skill-cache-validator.js.map +1 -0
- package/dist/cli/skill-cli.js +991 -0
- package/dist/cli/skill-cli.js.map +1 -0
- package/dist/cli/skill-execution-logger.js +284 -0
- package/dist/cli/skill-execution-logger.js.map +1 -0
- package/dist/cli/skill-loader.js +457 -0
- package/dist/cli/skill-loader.js.map +1 -0
- package/dist/coordination/event-bus.js +2 -2
- package/dist/coordination/event-bus.js.map +1 -1
- package/dist/coordination/fleet-manager.js +1 -1
- package/dist/coordination/fleet-manager.js.map +1 -1
- package/dist/coordination/index.js +23 -9
- package/dist/coordination/index.js.map +1 -1
- package/dist/coordination/types/fleet-manager.types.js.map +1 -1
- package/dist/db/migration-manager.js +483 -0
- package/dist/db/migration-manager.js.map +1 -0
- package/dist/db/skills-query.js +535 -0
- package/dist/db/skills-query.js.map +1 -0
- package/dist/integration/DatabaseHandoff.js +1 -1
- package/dist/integration/DatabaseHandoff.js.map +1 -1
- package/dist/jobs/edge-case-analyzer.js +367 -0
- package/dist/jobs/edge-case-analyzer.js.map +1 -0
- package/dist/jobs/promotion-sla-enforcer.js +288 -0
- package/dist/jobs/promotion-sla-enforcer.js.map +1 -0
- package/dist/lib/agent-output-parser.js.map +1 -1
- package/dist/lib/agent-output-validator.js.map +1 -1
- package/dist/lib/agent-workspace.js +281 -0
- package/dist/lib/agent-workspace.js.map +1 -0
- package/dist/lib/atomic-file-writer.js +377 -0
- package/dist/lib/atomic-file-writer.js.map +1 -0
- package/dist/lib/backup-manager.js +779 -0
- package/dist/lib/backup-manager.js.map +1 -0
- package/dist/lib/checkpoint-manager.js +837 -0
- package/dist/lib/checkpoint-manager.js.map +1 -0
- package/dist/lib/circuit-breaker.js +340 -0
- package/dist/lib/circuit-breaker.js.map +1 -0
- package/dist/lib/completion-signal-handler.js +243 -0
- package/dist/lib/completion-signal-handler.js.map +1 -0
- package/dist/lib/config-manager.js +312 -0
- package/dist/lib/config-manager.js.map +1 -0
- package/dist/lib/config-migrator.js +386 -0
- package/dist/lib/config-migrator.js.map +1 -0
- package/dist/lib/config-validator.js.map +1 -1
- package/dist/lib/correlation-cache.js +311 -0
- package/dist/lib/correlation-cache.js.map +1 -0
- package/dist/lib/correlation.js +263 -0
- package/dist/lib/correlation.js.map +1 -0
- package/dist/lib/database-service/connection-pool-manager.js +520 -0
- package/dist/lib/database-service/connection-pool-manager.js.map +1 -0
- package/dist/lib/database-service/correlation.js +329 -0
- package/dist/lib/database-service/correlation.js.map +1 -0
- package/dist/lib/database-service/errors.js +120 -0
- package/dist/lib/database-service/errors.js.map +1 -0
- package/dist/lib/database-service/index.js +168 -0
- package/dist/lib/database-service/index.js.map +1 -0
- package/dist/lib/database-service/postgres-adapter.js +526 -0
- package/dist/lib/database-service/postgres-adapter.js.map +1 -0
- package/dist/lib/database-service/redis-adapter.js +360 -0
- package/dist/lib/database-service/redis-adapter.js.map +1 -0
- package/dist/lib/database-service/sqlite-adapter.js +544 -0
- package/dist/lib/database-service/sqlite-adapter.js.map +1 -0
- package/dist/lib/database-service/transaction-manager.js +773 -0
- package/dist/lib/database-service/transaction-manager.js.map +1 -0
- package/dist/lib/database-service/types.js +23 -0
- package/dist/lib/database-service/types.js.map +1 -0
- package/dist/lib/deadlock-resolver.js +292 -0
- package/dist/lib/deadlock-resolver.js.map +1 -0
- package/dist/lib/distributed-lock.js +451 -0
- package/dist/lib/distributed-lock.js.map +1 -0
- package/dist/lib/edge-case-deduplicator.js +227 -0
- package/dist/lib/edge-case-deduplicator.js.map +1 -0
- package/dist/lib/encryption-manager.js +322 -0
- package/dist/lib/encryption-manager.js.map +1 -0
- package/dist/lib/error-aggregator.js +234 -0
- package/dist/lib/error-aggregator.js.map +1 -0
- package/dist/lib/errors.js +287 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/file-lock-manager.js +578 -0
- package/dist/lib/file-lock-manager.js.map +1 -0
- package/dist/lib/file-operations.js +367 -0
- package/dist/lib/file-operations.js.map +1 -0
- package/dist/lib/idempotent-write.js +237 -0
- package/dist/lib/idempotent-write.js.map +1 -0
- package/dist/lib/integration-schema-validator.js +522 -0
- package/dist/lib/integration-schema-validator.js.map +1 -0
- package/dist/lib/lock-health-monitor.js +298 -0
- package/dist/lib/lock-health-monitor.js.map +1 -0
- package/dist/lib/log-shipper.js +422 -0
- package/dist/lib/log-shipper.js.map +1 -0
- package/dist/lib/logging.js +146 -0
- package/dist/lib/logging.js.map +1 -0
- package/dist/lib/message-deduplicator.js +439 -0
- package/dist/lib/message-deduplicator.js.map +1 -0
- package/dist/lib/multi-system-query.js +604 -0
- package/dist/lib/multi-system-query.js.map +1 -0
- package/dist/lib/orphan-detector.js +332 -0
- package/dist/lib/orphan-detector.js.map +1 -0
- package/dist/lib/password-generator.js +166 -0
- package/dist/lib/password-generator.js.map +1 -0
- package/dist/lib/path-validator.js +429 -0
- package/dist/lib/path-validator.js.map +1 -0
- package/dist/lib/query-translator.js +905 -0
- package/dist/lib/query-translator.js.map +1 -0
- package/dist/lib/queue-recovery.js +469 -0
- package/dist/lib/queue-recovery.js.map +1 -0
- package/dist/lib/redis-queue-manager.js +512 -0
- package/dist/lib/redis-queue-manager.js.map +1 -0
- package/dist/lib/reflection-archiver.js +272 -0
- package/dist/lib/reflection-archiver.js.map +1 -0
- package/dist/lib/retry-manager.js +453 -0
- package/dist/lib/retry-manager.js.map +1 -0
- package/dist/lib/retry.js +262 -0
- package/dist/lib/retry.js.map +1 -0
- package/dist/lib/schema-transform.js +695 -0
- package/dist/lib/schema-transform.js.map +1 -0
- package/dist/lib/schema-validator.js +491 -0
- package/dist/lib/schema-validator.js.map +1 -0
- package/dist/lib/skill-cache.js +297 -0
- package/dist/lib/skill-cache.js.map +1 -0
- package/dist/lib/skill-content-manager.js +337 -0
- package/dist/lib/skill-content-manager.js.map +1 -0
- package/dist/lib/skill-frontmatter-parser.js +237 -0
- package/dist/lib/skill-frontmatter-parser.js.map +1 -0
- package/dist/lib/skill-git-integration.js +275 -0
- package/dist/lib/skill-git-integration.js.map +1 -0
- package/dist/lib/skill-markdown-validator.js +396 -0
- package/dist/lib/skill-markdown-validator.js.map +1 -0
- package/dist/lib/skill-output-parser.js +312 -0
- package/dist/lib/skill-output-parser.js.map +1 -0
- package/dist/lib/unified-query-api.js +467 -0
- package/dist/lib/unified-query-api.js.map +1 -0
- package/dist/middleware/auth-middleware.js +350 -0
- package/dist/middleware/auth-middleware.js.map +1 -0
- package/dist/middleware/schema-validation.js +347 -0
- package/dist/middleware/schema-validation.js.map +1 -0
- package/dist/providers/anthropic-provider.js +1 -1
- package/dist/providers/anthropic-provider.js.map +1 -1
- package/dist/providers/provider-factory.js +2 -2
- package/dist/providers/provider-factory.js.map +1 -1
- package/dist/services/edge-case-analyzer.js +321 -0
- package/dist/services/edge-case-analyzer.js.map +1 -0
- package/dist/services/edge-case-deduplicator.js +266 -0
- package/dist/services/edge-case-deduplicator.js.map +1 -0
- package/dist/services/edge-case-detector.js +337 -0
- package/dist/services/edge-case-detector.js.map +1 -0
- package/dist/services/edge-case-tracker.js +547 -0
- package/dist/services/edge-case-tracker.js.map +1 -0
- package/dist/services/health-check-system.js +586 -0
- package/dist/services/health-check-system.js.map +1 -0
- package/dist/services/metrics-logger.js +412 -0
- package/dist/services/metrics-logger.js.map +1 -0
- package/dist/services/patch-generator.js +378 -0
- package/dist/services/patch-generator.js.map +1 -0
- package/dist/services/patch-validator.js +337 -0
- package/dist/services/patch-validator.js.map +1 -0
- package/dist/services/performance-monitor.js +811 -0
- package/dist/services/performance-monitor.js.map +1 -0
- package/dist/services/promotion-pipeline.js +918 -0
- package/dist/services/promotion-pipeline.js.map +1 -0
- package/dist/services/promotion-validator.js +394 -0
- package/dist/services/promotion-validator.js.map +1 -0
- package/dist/services/reflection-logger.js +388 -0
- package/dist/services/reflection-logger.js.map +1 -0
- package/dist/services/skill-deployment.js +472 -0
- package/dist/services/skill-deployment.js.map +1 -0
- package/dist/services/skill-loader.js +427 -0
- package/dist/services/skill-loader.js.map +1 -0
- package/dist/services/skill-promotion.js +372 -0
- package/dist/services/skill-promotion.js.map +1 -0
- package/dist/services/skill-validator.js +454 -0
- package/dist/services/skill-validator.js.map +1 -0
- package/dist/services/skill-versioning.js +244 -0
- package/dist/services/skill-versioning.js.map +1 -0
- package/dist/services/workspace-supervisor.js +597 -0
- package/dist/services/workspace-supervisor.js.map +1 -0
- package/dist/types/edge-case.js +45 -0
- package/dist/types/edge-case.js.map +1 -0
- package/docs/BUG_19_MEMORY_LEAK_TASK_MODE.md +405 -0
- package/docs/MEMORY_CLEANUP_GUIDE.md +358 -0
- package/docs/MEMORY_LEAK_FIX_SUMMARY.md +322 -0
- package/docs/REDIS_CLEANUP_EXECUTIVE_SUMMARY.md +319 -0
- package/docs/REDIS_CLEANUP_VERIFICATION_REPORT.md +574 -0
- package/package.json +35 -4
- package/readme/README.md +53 -5
- package/scripts/backup-cleanup.sh +627 -0
- package/scripts/cleanup-workspaces.sh +412 -0
- package/scripts/cleanup-yaml-configs.sh +141 -0
- package/scripts/deploy-approved-skills.sh +263 -0
- package/scripts/health-check.sh +447 -0
- package/scripts/log-aggregator.sh +554 -0
- package/scripts/log-monitor.sh +629 -0
- package/scripts/manage-agent-workspaces.sh +434 -0
- package/scripts/migrate-schema.sh +533 -0
- package/scripts/promote-staged-skills.sh +423 -0
- package/scripts/verify-no-secrets.sh +88 -35
- package/scripts/verify-redis-cleanup.sh +173 -0
- package/tests/README.md +84 -0
- package/tests/test-memory-leak-task-mode.sh +435 -0
- package/.claude/cfn-extras/agents/deprecated-coordinators/adaptive-coordinator.md.backup +0 -161
- package/.claude/cfn-extras/agents/deprecated-coordinators/blocking-coordinator-example.md.backup +0 -728
- package/.claude/cfn-extras/agents/deprecated-coordinators/mesh-coordinator.md.backup +0 -131
- package/.claude/skills/agent-lifecycle/SKILL.md +0 -60
- package/.claude/skills/agent-lifecycle/execute-lifecycle-hook.sh +0 -573
- package/.claude/skills/agent-lifecycle/simple-audit.sh +0 -31
- package/.claude/skills/cfn-agent-spawning/spawn-agent.sh.backup +0 -273
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh.backup +0 -949
- package/README.md.backup_before_replace +0 -781
- package/claude-assets/cfn-extras/agents/deprecated-coordinators/adaptive-coordinator.md.backup +0 -161
- package/claude-assets/cfn-extras/agents/deprecated-coordinators/blocking-coordinator-example.md.backup +0 -728
- package/claude-assets/cfn-extras/agents/deprecated-coordinators/mesh-coordinator.md.backup +0 -131
- package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh.backup +0 -273
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh.backup +0 -949
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Redis Cleanup Verification Script
|
|
3
|
+
#
|
|
4
|
+
# Quick health check for Redis cleanup mechanisms
|
|
5
|
+
# Run this anytime to verify no process leaks or memory issues
|
|
6
|
+
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
|
|
9
|
+
# Colors
|
|
10
|
+
RED='\033[0;31m'
|
|
11
|
+
GREEN='\033[0;32m'
|
|
12
|
+
YELLOW='\033[1;33m'
|
|
13
|
+
NC='\033[0m' # No Color
|
|
14
|
+
|
|
15
|
+
# Configuration
|
|
16
|
+
REDIS_HOST="${CFN_REDIS_HOST:-localhost}"
|
|
17
|
+
REDIS_PORT="${CFN_REDIS_PORT:-6379}"
|
|
18
|
+
|
|
19
|
+
# Counters
|
|
20
|
+
ISSUES_FOUND=0
|
|
21
|
+
|
|
22
|
+
echo "======================================"
|
|
23
|
+
echo "Redis Cleanup Verification"
|
|
24
|
+
echo "======================================"
|
|
25
|
+
echo ""
|
|
26
|
+
echo "Configuration:"
|
|
27
|
+
echo " Redis: $REDIS_HOST:$REDIS_PORT"
|
|
28
|
+
echo " Date: $(date)"
|
|
29
|
+
echo ""
|
|
30
|
+
|
|
31
|
+
# Test 1: Redis connectivity
|
|
32
|
+
echo "1. Checking Redis connectivity..."
|
|
33
|
+
if redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" ping >/dev/null 2>&1; then
|
|
34
|
+
echo -e " ${GREEN}✓${NC} Redis is reachable"
|
|
35
|
+
else
|
|
36
|
+
echo -e " ${RED}✗${NC} Cannot connect to Redis"
|
|
37
|
+
ISSUES_FOUND=$((ISSUES_FOUND + 1))
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
# Test 2: Process leak detection
|
|
41
|
+
echo ""
|
|
42
|
+
echo "2. Checking for redis-cli process leaks..."
|
|
43
|
+
REDIS_CLI_COUNT=$(pgrep -f "redis-cli" | wc -l || echo "0")
|
|
44
|
+
if [ "$REDIS_CLI_COUNT" -eq 0 ]; then
|
|
45
|
+
echo -e " ${GREEN}✓${NC} No redis-cli processes found (expected)"
|
|
46
|
+
else
|
|
47
|
+
echo -e " ${YELLOW}⚠${NC} Found $REDIS_CLI_COUNT redis-cli processes"
|
|
48
|
+
ps aux | grep "redis-cli" | grep -v grep
|
|
49
|
+
ISSUES_FOUND=$((ISSUES_FOUND + 1))
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
# Test 3: Redis memory usage
|
|
53
|
+
echo ""
|
|
54
|
+
echo "3. Checking Redis memory usage..."
|
|
55
|
+
REDIS_MEMORY=$(redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" info memory 2>/dev/null | grep "used_memory_human:" | cut -d: -f2 | tr -d '\r\n' || echo "unknown")
|
|
56
|
+
echo " Memory used: $REDIS_MEMORY"
|
|
57
|
+
|
|
58
|
+
# Extract numeric value (handle M/K/G suffixes)
|
|
59
|
+
MEMORY_NUM=$(echo "$REDIS_MEMORY" | grep -oE '[0-9]+' | head -1)
|
|
60
|
+
MEMORY_UNIT=$(echo "$REDIS_MEMORY" | grep -oE '[A-Z]' | head -1)
|
|
61
|
+
|
|
62
|
+
if [ "$MEMORY_UNIT" = "G" ]; then
|
|
63
|
+
# Over 1 GB is concerning
|
|
64
|
+
echo -e " ${RED}⚠${NC} High memory usage (>1 GB)"
|
|
65
|
+
ISSUES_FOUND=$((ISSUES_FOUND + 1))
|
|
66
|
+
elif [ "$MEMORY_UNIT" = "M" ] && [ "$MEMORY_NUM" -gt 500 ]; then
|
|
67
|
+
# Over 500 MB is a warning
|
|
68
|
+
echo -e " ${YELLOW}⚠${NC} Elevated memory usage (>500 MB)"
|
|
69
|
+
else
|
|
70
|
+
echo -e " ${GREEN}✓${NC} Memory usage is normal"
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
# Test 4: Keys without TTL
|
|
74
|
+
echo ""
|
|
75
|
+
echo "4. Checking for keys without TTL..."
|
|
76
|
+
NO_TTL_COUNT=0
|
|
77
|
+
|
|
78
|
+
# Check message keys
|
|
79
|
+
MESSAGE_KEYS=$(redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" keys "swarm:*:*:messages" 2>/dev/null | wc -l || echo "0")
|
|
80
|
+
if [ "$MESSAGE_KEYS" -gt 0 ]; then
|
|
81
|
+
while read -r key; do
|
|
82
|
+
if [ -z "$key" ]; then continue; fi
|
|
83
|
+
TTL=$(redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" ttl "$key" 2>/dev/null || echo "-2")
|
|
84
|
+
if [ "$TTL" -eq -1 ]; then
|
|
85
|
+
echo -e " ${YELLOW}⚠${NC} No TTL: $key"
|
|
86
|
+
NO_TTL_COUNT=$((NO_TTL_COUNT + 1))
|
|
87
|
+
fi
|
|
88
|
+
done < <(redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" keys "swarm:*:*:messages" 2>/dev/null)
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
# Check fork keys
|
|
92
|
+
FORK_KEYS=$(redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" keys "swarm:*:*:fork:*:messages" 2>/dev/null | wc -l || echo "0")
|
|
93
|
+
if [ "$FORK_KEYS" -gt 0 ]; then
|
|
94
|
+
while read -r key; do
|
|
95
|
+
if [ -z "$key" ]; then continue; fi
|
|
96
|
+
TTL=$(redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" ttl "$key" 2>/dev/null || echo "-2")
|
|
97
|
+
if [ "$TTL" -eq -1 ]; then
|
|
98
|
+
echo -e " ${YELLOW}⚠${NC} No TTL: $key"
|
|
99
|
+
NO_TTL_COUNT=$((NO_TTL_COUNT + 1))
|
|
100
|
+
fi
|
|
101
|
+
done < <(redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" keys "swarm:*:*:fork:*:messages" 2>/dev/null)
|
|
102
|
+
fi
|
|
103
|
+
|
|
104
|
+
if [ "$NO_TTL_COUNT" -eq 0 ]; then
|
|
105
|
+
echo -e " ${GREEN}✓${NC} All keys have TTL"
|
|
106
|
+
else
|
|
107
|
+
echo -e " ${RED}✗${NC} $NO_TTL_COUNT keys without TTL"
|
|
108
|
+
ISSUES_FOUND=$((ISSUES_FOUND + 1))
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
# Test 5: Key count
|
|
112
|
+
echo ""
|
|
113
|
+
echo "5. Checking key counts..."
|
|
114
|
+
TOTAL_MESSAGE_KEYS=$(redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" keys "swarm:*:*:messages" 2>/dev/null | wc -l || echo "0")
|
|
115
|
+
TOTAL_FORK_KEYS=$(redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" keys "swarm:*:*:fork:*" 2>/dev/null | wc -l || echo "0")
|
|
116
|
+
TOTAL_RESULT_KEYS=$(redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" keys "swarm:*:*:result:*" 2>/dev/null | wc -l || echo "0")
|
|
117
|
+
|
|
118
|
+
echo " Message keys: $TOTAL_MESSAGE_KEYS"
|
|
119
|
+
echo " Fork keys: $TOTAL_FORK_KEYS"
|
|
120
|
+
echo " Result keys: $TOTAL_RESULT_KEYS"
|
|
121
|
+
|
|
122
|
+
if [ "$TOTAL_MESSAGE_KEYS" -gt 100 ]; then
|
|
123
|
+
echo -e " ${YELLOW}⚠${NC} High message key count (>100)"
|
|
124
|
+
fi
|
|
125
|
+
|
|
126
|
+
# Test 6: Node.js processes
|
|
127
|
+
echo ""
|
|
128
|
+
echo "6. Checking Node.js processes..."
|
|
129
|
+
NODE_COUNT=$(pgrep -f "node" | wc -l || echo "0")
|
|
130
|
+
echo " Node.js processes: $NODE_COUNT"
|
|
131
|
+
|
|
132
|
+
if [ "$NODE_COUNT" -gt 20 ]; then
|
|
133
|
+
echo -e " ${YELLOW}⚠${NC} High Node.js process count (>20)"
|
|
134
|
+
echo " Top 5 by memory:"
|
|
135
|
+
ps aux | grep -E "node|ts-node" | grep -v grep | sort -k4 -rn | head -5
|
|
136
|
+
fi
|
|
137
|
+
|
|
138
|
+
# Summary
|
|
139
|
+
echo ""
|
|
140
|
+
echo "======================================"
|
|
141
|
+
echo "Summary"
|
|
142
|
+
echo "======================================"
|
|
143
|
+
|
|
144
|
+
if [ "$ISSUES_FOUND" -eq 0 ]; then
|
|
145
|
+
echo -e "${GREEN}✓ All checks passed - No issues found${NC}"
|
|
146
|
+
echo ""
|
|
147
|
+
echo "Redis cleanup is working correctly."
|
|
148
|
+
exit 0
|
|
149
|
+
else
|
|
150
|
+
echo -e "${RED}✗ Found $ISSUES_FOUND issue(s)${NC}"
|
|
151
|
+
echo ""
|
|
152
|
+
echo "Recommended actions:"
|
|
153
|
+
|
|
154
|
+
if [ "$REDIS_CLI_COUNT" -gt 0 ]; then
|
|
155
|
+
echo " - Kill redis-cli processes: pkill -f redis-cli"
|
|
156
|
+
fi
|
|
157
|
+
|
|
158
|
+
if [ "$NO_TTL_COUNT" -gt 0 ]; then
|
|
159
|
+
echo " - Set TTL on keys without expiration"
|
|
160
|
+
echo " node -e \"const { setMessageListTTL } = require('./dist/cli/conversation-fork-cleanup.js'); setMessageListTTL('task-id', 'agent-id', 86400);\""
|
|
161
|
+
fi
|
|
162
|
+
|
|
163
|
+
if [ "$MEMORY_NUM" -gt 500 ] && [ "$MEMORY_UNIT" = "M" ]; then
|
|
164
|
+
echo " - Consider emergency cleanup (WARNING: deletes all conversation history)"
|
|
165
|
+
echo " node -e \"const { emergencyCleanupAll } = require('./dist/cli/conversation-fork-cleanup.js'); emergencyCleanupAll();\""
|
|
166
|
+
fi
|
|
167
|
+
|
|
168
|
+
echo ""
|
|
169
|
+
echo "For detailed analysis, run:"
|
|
170
|
+
echo " ./tests/test-memory-leak-task-mode.sh"
|
|
171
|
+
|
|
172
|
+
exit 1
|
|
173
|
+
fi
|
package/tests/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Claude Flow Novice Test Suite
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This test suite validates the core functionality and resilience of the Claude Flow Novice system across multiple layers and scenarios.
|
|
6
|
+
|
|
7
|
+
## Test Layers
|
|
8
|
+
|
|
9
|
+
### Layer 0: Agent Tooling Validation
|
|
10
|
+
- Verifies individual tool functionality
|
|
11
|
+
- Ensures tools can be instantiated and used
|
|
12
|
+
- Tests error handling and coordination
|
|
13
|
+
|
|
14
|
+
### Layer 1: Mesh Coordination
|
|
15
|
+
- Redis pub/sub integration tests
|
|
16
|
+
- Validates agent communication patterns
|
|
17
|
+
- Checks distributed messaging reliability
|
|
18
|
+
|
|
19
|
+
### Layer 2: Review Handoff
|
|
20
|
+
- Dynamic reviewer pool testing
|
|
21
|
+
- Validates context transfer mechanisms
|
|
22
|
+
- Ensures smooth agent transitions
|
|
23
|
+
|
|
24
|
+
### Layer 3: Error Handling
|
|
25
|
+
- 50% error injection scenarios
|
|
26
|
+
- Circuit breaker and fallback mechanisms
|
|
27
|
+
- Resilience and recovery validation
|
|
28
|
+
|
|
29
|
+
## Running Tests
|
|
30
|
+
|
|
31
|
+
### Prerequisites
|
|
32
|
+
- Node.js 18+
|
|
33
|
+
- Redis
|
|
34
|
+
- Docker (optional, for containerized testing)
|
|
35
|
+
|
|
36
|
+
### Commands
|
|
37
|
+
```bash
|
|
38
|
+
# Run all tests
|
|
39
|
+
npm test
|
|
40
|
+
|
|
41
|
+
# Run specific test layer
|
|
42
|
+
npm test -- --testNamePattern="Layer 0"
|
|
43
|
+
|
|
44
|
+
# Generate coverage report
|
|
45
|
+
npm run test:coverage
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Coverage Requirements
|
|
49
|
+
|
|
50
|
+
| Layer | Branches | Functions | Lines | Statements |
|
|
51
|
+
|-------|----------|-----------|-------|------------|
|
|
52
|
+
| Layer 0 | 90% | 85% | 95% | 90% |
|
|
53
|
+
| Layer 1 | 85% | 80% | 90% | 85% |
|
|
54
|
+
| Layer 2 | 80% | 75% | 85% | 80% |
|
|
55
|
+
| Layer 3 | 75% | 70% | 80% | 75% |
|
|
56
|
+
|
|
57
|
+
## Chaos Testing
|
|
58
|
+
|
|
59
|
+
Includes resilience tests for:
|
|
60
|
+
- Redis connection failures
|
|
61
|
+
- SQLite data corruption
|
|
62
|
+
- Coordinator process termination
|
|
63
|
+
|
|
64
|
+
## Best Practices
|
|
65
|
+
|
|
66
|
+
- All tests use TypeScript
|
|
67
|
+
- Strict mode enforcement
|
|
68
|
+
- Clear, descriptive assertions
|
|
69
|
+
- Proper resource cleanup
|
|
70
|
+
- Deterministic test environments
|
|
71
|
+
|
|
72
|
+
## Troubleshooting
|
|
73
|
+
|
|
74
|
+
1. Ensure Redis is running
|
|
75
|
+
2. Check network configurations
|
|
76
|
+
3. Verify dependency versions
|
|
77
|
+
4. Run with increased verbosity: `npm test -- --verbose`
|
|
78
|
+
|
|
79
|
+
## Contributing
|
|
80
|
+
|
|
81
|
+
- Add new tests in respective layer directories
|
|
82
|
+
- Follow existing patterns
|
|
83
|
+
- Update coverage documentation
|
|
84
|
+
- Write clear, concise test descriptions
|
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Memory Leak Test for Task Mode
|
|
3
|
+
#
|
|
4
|
+
# Tests memory accumulation patterns in Task Mode CFN Loop execution
|
|
5
|
+
# Validates conversation fork cleanup and TTL enforcement
|
|
6
|
+
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
|
|
9
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
10
|
+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
11
|
+
|
|
12
|
+
# Redis connection
|
|
13
|
+
REDIS_HOST="${CFN_REDIS_HOST:-localhost}"
|
|
14
|
+
REDIS_PORT="${CFN_REDIS_PORT:-6379}"
|
|
15
|
+
REDIS_PASSWORD="${CFN_REDIS_PASSWORD:-}"
|
|
16
|
+
|
|
17
|
+
# Test configuration
|
|
18
|
+
TEST_TASK_ID="test-memory-leak-$(date +%s)"
|
|
19
|
+
TEST_AGENT_ID="test-agent-$$"
|
|
20
|
+
MESSAGE_TTL=300 # 5 minutes for testing
|
|
21
|
+
FORK_TTL=300 # 5 minutes for testing
|
|
22
|
+
|
|
23
|
+
# Color output
|
|
24
|
+
RED='\033[0;31m'
|
|
25
|
+
GREEN='\033[0;32m'
|
|
26
|
+
YELLOW='\033[1;33m'
|
|
27
|
+
NC='\033[0m' # No Color
|
|
28
|
+
|
|
29
|
+
# Test counters
|
|
30
|
+
TESTS_RUN=0
|
|
31
|
+
TESTS_PASSED=0
|
|
32
|
+
TESTS_FAILED=0
|
|
33
|
+
|
|
34
|
+
# Redis command builder
|
|
35
|
+
redis_cmd() {
|
|
36
|
+
local cmd="redis-cli -h $REDIS_HOST -p $REDIS_PORT"
|
|
37
|
+
if [ -n "$REDIS_PASSWORD" ]; then
|
|
38
|
+
cmd="$cmd -a $REDIS_PASSWORD"
|
|
39
|
+
fi
|
|
40
|
+
echo "$cmd"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
# Helper: Print test result
|
|
44
|
+
print_result() {
|
|
45
|
+
local test_name="$1"
|
|
46
|
+
local result="$2"
|
|
47
|
+
local message="$3"
|
|
48
|
+
|
|
49
|
+
TESTS_RUN=$((TESTS_RUN + 1))
|
|
50
|
+
|
|
51
|
+
if [ "$result" = "PASS" ]; then
|
|
52
|
+
echo -e "${GREEN}✓${NC} $test_name: $message"
|
|
53
|
+
TESTS_PASSED=$((TESTS_PASSED + 1))
|
|
54
|
+
else
|
|
55
|
+
echo -e "${RED}✗${NC} $test_name: $message"
|
|
56
|
+
TESTS_FAILED=$((TESTS_FAILED + 1))
|
|
57
|
+
fi
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# Helper: Store test message
|
|
61
|
+
store_message() {
|
|
62
|
+
local task_id="$1"
|
|
63
|
+
local agent_id="$2"
|
|
64
|
+
local role="$3"
|
|
65
|
+
local iteration="$4"
|
|
66
|
+
|
|
67
|
+
local key="swarm:${task_id}:${agent_id}:messages"
|
|
68
|
+
local message="{\"role\":\"$role\",\"content\":\"Test message\",\"iteration\":$iteration,\"timestamp\":\"$(date -Iseconds)\"}"
|
|
69
|
+
|
|
70
|
+
$(redis_cmd) rpush "$key" "$message" >/dev/null
|
|
71
|
+
$(redis_cmd) expire "$key" "$MESSAGE_TTL" >/dev/null
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
# Helper: Create test fork
|
|
75
|
+
create_fork() {
|
|
76
|
+
local task_id="$1"
|
|
77
|
+
local agent_id="$2"
|
|
78
|
+
local iteration="$3"
|
|
79
|
+
|
|
80
|
+
local fork_id="fork-${iteration}-testfork"
|
|
81
|
+
local fork_key="swarm:${task_id}:${agent_id}:fork:${fork_id}:messages"
|
|
82
|
+
local meta_key="swarm:${task_id}:${agent_id}:fork:${fork_id}:meta"
|
|
83
|
+
|
|
84
|
+
# Store fork messages
|
|
85
|
+
for i in $(seq 1 "$iteration"); do
|
|
86
|
+
local message="{\"role\":\"user\",\"content\":\"Fork message $i\",\"iteration\":$i,\"timestamp\":\"$(date -Iseconds)\"}"
|
|
87
|
+
$(redis_cmd) rpush "$fork_key" "$message" >/dev/null
|
|
88
|
+
done
|
|
89
|
+
|
|
90
|
+
# Set TTL on fork messages (CRITICAL for memory leak fix)
|
|
91
|
+
$(redis_cmd) expire "$fork_key" "$FORK_TTL" >/dev/null
|
|
92
|
+
|
|
93
|
+
# Store fork metadata with TTL
|
|
94
|
+
local metadata="{\"forkId\":\"$fork_id\",\"taskId\":\"$task_id\",\"agentId\":\"$agent_id\",\"createdAt\":\"$(date -Iseconds)\",\"parentIteration\":$iteration,\"messageCount\":$iteration}"
|
|
95
|
+
$(redis_cmd) setex "$meta_key" "$FORK_TTL" "$metadata" >/dev/null
|
|
96
|
+
|
|
97
|
+
echo "$fork_id"
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
# Helper: Get key count matching pattern
|
|
101
|
+
count_keys() {
|
|
102
|
+
local pattern="$1"
|
|
103
|
+
local keys=$($(redis_cmd) keys "$pattern" 2>/dev/null | grep -v '^$' || true)
|
|
104
|
+
if [ -z "$keys" ]; then
|
|
105
|
+
echo "0"
|
|
106
|
+
else
|
|
107
|
+
echo "$keys" | wc -l
|
|
108
|
+
fi
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
# Helper: Get list length
|
|
112
|
+
get_list_length() {
|
|
113
|
+
local key="$1"
|
|
114
|
+
local length=$($(redis_cmd) llen "$key" 2>/dev/null || echo "0")
|
|
115
|
+
echo "$length"
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
# Helper: Get TTL
|
|
119
|
+
get_ttl() {
|
|
120
|
+
local key="$1"
|
|
121
|
+
local ttl=$($(redis_cmd) ttl "$key" 2>/dev/null || echo "-2")
|
|
122
|
+
echo "$ttl"
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
# Helper: Get memory usage (approximate)
|
|
126
|
+
get_redis_memory() {
|
|
127
|
+
$(redis_cmd) info memory | grep "used_memory_human:" | cut -d: -f2 | tr -d '\r\n'
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
# Setup test environment
|
|
131
|
+
setup() {
|
|
132
|
+
echo "========================================="
|
|
133
|
+
echo "Memory Leak Test - Task Mode"
|
|
134
|
+
echo "========================================="
|
|
135
|
+
echo ""
|
|
136
|
+
echo "Configuration:"
|
|
137
|
+
echo " Task ID: $TEST_TASK_ID"
|
|
138
|
+
echo " Agent ID: $TEST_AGENT_ID"
|
|
139
|
+
echo " Message TTL: ${MESSAGE_TTL}s"
|
|
140
|
+
echo " Fork TTL: ${FORK_TTL}s"
|
|
141
|
+
echo " Redis: $REDIS_HOST:$REDIS_PORT"
|
|
142
|
+
echo ""
|
|
143
|
+
|
|
144
|
+
# Check Redis connection
|
|
145
|
+
if ! $(redis_cmd) ping >/dev/null 2>&1; then
|
|
146
|
+
echo -e "${RED}ERROR${NC}: Cannot connect to Redis at $REDIS_HOST:$REDIS_PORT"
|
|
147
|
+
exit 1
|
|
148
|
+
fi
|
|
149
|
+
|
|
150
|
+
echo -e "${GREEN}✓${NC} Redis connection successful"
|
|
151
|
+
echo ""
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
# Cleanup test data
|
|
155
|
+
cleanup() {
|
|
156
|
+
echo ""
|
|
157
|
+
echo "Cleaning up test data..."
|
|
158
|
+
|
|
159
|
+
# Delete test keys
|
|
160
|
+
$(redis_cmd) del "swarm:${TEST_TASK_ID}:*" >/dev/null 2>&1 || true
|
|
161
|
+
|
|
162
|
+
# Pattern-based cleanup
|
|
163
|
+
local patterns=(
|
|
164
|
+
"swarm:${TEST_TASK_ID}:*:messages"
|
|
165
|
+
"swarm:${TEST_TASK_ID}:*:fork:*:messages"
|
|
166
|
+
"swarm:${TEST_TASK_ID}:*:fork:*:meta"
|
|
167
|
+
"swarm:${TEST_TASK_ID}:*:current-fork"
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
for pattern in "${patterns[@]}"; do
|
|
171
|
+
local keys=$($(redis_cmd) keys "$pattern" 2>/dev/null || true)
|
|
172
|
+
if [ -n "$keys" ]; then
|
|
173
|
+
echo "$keys" | xargs -r $(redis_cmd) del >/dev/null 2>&1 || true
|
|
174
|
+
fi
|
|
175
|
+
done
|
|
176
|
+
|
|
177
|
+
echo -e "${GREEN}✓${NC} Cleanup complete"
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
# Test 1: Message list has TTL
|
|
181
|
+
test_message_ttl() {
|
|
182
|
+
echo "Test 1: Message List TTL"
|
|
183
|
+
|
|
184
|
+
store_message "$TEST_TASK_ID" "$TEST_AGENT_ID" "user" 1
|
|
185
|
+
|
|
186
|
+
local key="swarm:${TEST_TASK_ID}:${TEST_AGENT_ID}:messages"
|
|
187
|
+
local ttl=$(get_ttl "$key")
|
|
188
|
+
|
|
189
|
+
if [ "$ttl" -gt 0 ] && [ "$ttl" -le "$MESSAGE_TTL" ]; then
|
|
190
|
+
print_result "Message TTL" "PASS" "TTL set correctly ($ttl seconds)"
|
|
191
|
+
else
|
|
192
|
+
print_result "Message TTL" "FAIL" "TTL not set (got: $ttl, expected: >0 and <=$MESSAGE_TTL)"
|
|
193
|
+
fi
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
# Test 2: Fork messages have TTL
|
|
197
|
+
test_fork_message_ttl() {
|
|
198
|
+
echo "Test 2: Fork Message TTL"
|
|
199
|
+
|
|
200
|
+
# Store some messages first
|
|
201
|
+
for i in {1..5}; do
|
|
202
|
+
store_message "$TEST_TASK_ID" "$TEST_AGENT_ID" "user" "$i"
|
|
203
|
+
store_message "$TEST_TASK_ID" "$TEST_AGENT_ID" "assistant" "$i"
|
|
204
|
+
done
|
|
205
|
+
|
|
206
|
+
# Create fork
|
|
207
|
+
local fork_id=$(create_fork "$TEST_TASK_ID" "$TEST_AGENT_ID" 3)
|
|
208
|
+
local fork_key="swarm:${TEST_TASK_ID}:${TEST_AGENT_ID}:fork:${fork_id}:messages"
|
|
209
|
+
|
|
210
|
+
local ttl=$(get_ttl "$fork_key")
|
|
211
|
+
|
|
212
|
+
if [ "$ttl" -gt 0 ] && [ "$ttl" -le "$FORK_TTL" ]; then
|
|
213
|
+
print_result "Fork Message TTL" "PASS" "TTL set correctly ($ttl seconds)"
|
|
214
|
+
else
|
|
215
|
+
print_result "Fork Message TTL" "FAIL" "TTL not set on fork messages (got: $ttl, expected: >0 and <=$FORK_TTL)"
|
|
216
|
+
fi
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
# Test 3: Memory accumulation with iterations
|
|
220
|
+
test_memory_accumulation() {
|
|
221
|
+
echo "Test 3: Memory Accumulation (10 iterations)"
|
|
222
|
+
|
|
223
|
+
local initial_memory=$(get_redis_memory)
|
|
224
|
+
echo " Initial memory: $initial_memory"
|
|
225
|
+
|
|
226
|
+
# Simulate 10 iterations with 3 agents each
|
|
227
|
+
for iter in {1..10}; do
|
|
228
|
+
for agent in {1..3}; do
|
|
229
|
+
local agent_id="${TEST_AGENT_ID}-agent${agent}"
|
|
230
|
+
store_message "$TEST_TASK_ID" "$agent_id" "user" "$iter"
|
|
231
|
+
store_message "$TEST_TASK_ID" "$agent_id" "assistant" "$iter"
|
|
232
|
+
|
|
233
|
+
# Create fork every 2 iterations
|
|
234
|
+
if [ $((iter % 2)) -eq 0 ]; then
|
|
235
|
+
create_fork "$TEST_TASK_ID" "$agent_id" "$iter" >/dev/null
|
|
236
|
+
fi
|
|
237
|
+
done
|
|
238
|
+
done
|
|
239
|
+
|
|
240
|
+
# Count keys
|
|
241
|
+
local message_count=$(count_keys "swarm:${TEST_TASK_ID}:*:messages")
|
|
242
|
+
local fork_count=$(count_keys "swarm:${TEST_TASK_ID}:*:fork:*:messages")
|
|
243
|
+
|
|
244
|
+
local final_memory=$(get_redis_memory)
|
|
245
|
+
echo " Final memory: $final_memory"
|
|
246
|
+
echo " Message keys: $message_count"
|
|
247
|
+
echo " Fork keys: $fork_count"
|
|
248
|
+
|
|
249
|
+
# All keys should have TTL
|
|
250
|
+
local keys_without_ttl=0
|
|
251
|
+
for key in $($(redis_cmd) keys "swarm:${TEST_TASK_ID}:*" 2>/dev/null); do
|
|
252
|
+
local ttl=$(get_ttl "$key")
|
|
253
|
+
if [ "$ttl" -eq -1 ]; then
|
|
254
|
+
keys_without_ttl=$((keys_without_ttl + 1))
|
|
255
|
+
fi
|
|
256
|
+
done
|
|
257
|
+
|
|
258
|
+
if [ "$keys_without_ttl" -eq 0 ]; then
|
|
259
|
+
print_result "Memory Accumulation" "PASS" "All keys have TTL (no indefinite retention)"
|
|
260
|
+
else
|
|
261
|
+
print_result "Memory Accumulation" "FAIL" "$keys_without_ttl keys without TTL (memory leak risk)"
|
|
262
|
+
fi
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
# Test 4: Cleanup utility integration
|
|
266
|
+
test_cleanup_utility() {
|
|
267
|
+
echo "Test 4: Cleanup Utility"
|
|
268
|
+
|
|
269
|
+
# Use a dedicated agent ID for this test
|
|
270
|
+
local cleanup_agent_id="${TEST_AGENT_ID}-cleanup"
|
|
271
|
+
|
|
272
|
+
# Store messages
|
|
273
|
+
for i in {1..20}; do
|
|
274
|
+
store_message "$TEST_TASK_ID" "$cleanup_agent_id" "user" "$i"
|
|
275
|
+
done
|
|
276
|
+
|
|
277
|
+
# Create multiple forks
|
|
278
|
+
for i in {2..10..2}; do
|
|
279
|
+
create_fork "$TEST_TASK_ID" "$cleanup_agent_id" "$i" >/dev/null
|
|
280
|
+
done
|
|
281
|
+
|
|
282
|
+
# Count before cleanup (only for this specific agent)
|
|
283
|
+
local before_count=$(count_keys "swarm:${TEST_TASK_ID}:${cleanup_agent_id}:*")
|
|
284
|
+
|
|
285
|
+
# Run cleanup utility (using Node.js with environment variables)
|
|
286
|
+
cd "$PROJECT_ROOT"
|
|
287
|
+
CFN_REDIS_HOST="$REDIS_HOST" CFN_REDIS_PORT="$REDIS_PORT" node -e "
|
|
288
|
+
const { cleanupTaskMessages } = require('./dist/cli/conversation-fork-cleanup.js');
|
|
289
|
+
cleanupTaskMessages('$TEST_TASK_ID', '$cleanup_agent_id');
|
|
290
|
+
" 2>/dev/null || {
|
|
291
|
+
print_result "Cleanup Utility" "SKIP" "Cleanup utility not built (run: npm run build)"
|
|
292
|
+
return
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
# Count after cleanup (only for this specific agent)
|
|
296
|
+
local after_count=$(count_keys "swarm:${TEST_TASK_ID}:${cleanup_agent_id}:*")
|
|
297
|
+
|
|
298
|
+
if [ "$after_count" -eq 0 ]; then
|
|
299
|
+
print_result "Cleanup Utility" "PASS" "All keys removed ($before_count → $after_count)"
|
|
300
|
+
else
|
|
301
|
+
print_result "Cleanup Utility" "FAIL" "Cleanup incomplete ($before_count → $after_count, expected: 0)"
|
|
302
|
+
fi
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
# Test 5: TTL enforcement (expiration test)
|
|
306
|
+
test_ttl_enforcement() {
|
|
307
|
+
echo "Test 5: TTL Enforcement (5 second expiration)"
|
|
308
|
+
|
|
309
|
+
# Create key with very short TTL
|
|
310
|
+
local short_ttl=5
|
|
311
|
+
local key="swarm:${TEST_TASK_ID}:${TEST_AGENT_ID}:test-expiration"
|
|
312
|
+
|
|
313
|
+
$(redis_cmd) rpush "$key" "test-message" >/dev/null
|
|
314
|
+
$(redis_cmd) expire "$key" "$short_ttl" >/dev/null
|
|
315
|
+
|
|
316
|
+
echo " Waiting ${short_ttl}s for expiration..."
|
|
317
|
+
sleep $((short_ttl + 1))
|
|
318
|
+
|
|
319
|
+
local exists=$($(redis_cmd) exists "$key")
|
|
320
|
+
|
|
321
|
+
if [ "$exists" -eq 0 ]; then
|
|
322
|
+
print_result "TTL Enforcement" "PASS" "Key expired after ${short_ttl}s"
|
|
323
|
+
else
|
|
324
|
+
print_result "TTL Enforcement" "FAIL" "Key still exists after TTL"
|
|
325
|
+
fi
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
# Test 6: Fork metadata and message consistency
|
|
329
|
+
test_fork_consistency() {
|
|
330
|
+
echo "Test 6: Fork Metadata/Message Consistency"
|
|
331
|
+
|
|
332
|
+
# Store messages
|
|
333
|
+
for i in {1..5}; do
|
|
334
|
+
store_message "$TEST_TASK_ID" "$TEST_AGENT_ID" "user" "$i"
|
|
335
|
+
done
|
|
336
|
+
|
|
337
|
+
# Create fork
|
|
338
|
+
local fork_id=$(create_fork "$TEST_TASK_ID" "$TEST_AGENT_ID" 3)
|
|
339
|
+
|
|
340
|
+
# Check both have same TTL
|
|
341
|
+
local meta_key="swarm:${TEST_TASK_ID}:${TEST_AGENT_ID}:fork:${fork_id}:meta"
|
|
342
|
+
local msg_key="swarm:${TEST_TASK_ID}:${TEST_AGENT_ID}:fork:${fork_id}:messages"
|
|
343
|
+
|
|
344
|
+
local meta_ttl=$(get_ttl "$meta_key")
|
|
345
|
+
local msg_ttl=$(get_ttl "$msg_key")
|
|
346
|
+
|
|
347
|
+
# TTLs should be within 5 seconds of each other
|
|
348
|
+
local ttl_diff=$((meta_ttl - msg_ttl))
|
|
349
|
+
ttl_diff=${ttl_diff#-} # Absolute value
|
|
350
|
+
|
|
351
|
+
if [ "$ttl_diff" -le 5 ]; then
|
|
352
|
+
print_result "Fork Consistency" "PASS" "Metadata and messages have consistent TTL (diff: ${ttl_diff}s)"
|
|
353
|
+
else
|
|
354
|
+
print_result "Fork Consistency" "FAIL" "TTL mismatch (meta: ${meta_ttl}s, msg: ${msg_ttl}s, diff: ${ttl_diff}s)"
|
|
355
|
+
fi
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
# Test 7: Memory statistics utility
|
|
359
|
+
test_memory_statistics() {
|
|
360
|
+
echo "Test 7: Memory Statistics"
|
|
361
|
+
|
|
362
|
+
# Store messages
|
|
363
|
+
for i in {1..10}; do
|
|
364
|
+
store_message "$TEST_TASK_ID" "$TEST_AGENT_ID" "user" "$i"
|
|
365
|
+
store_message "$TEST_TASK_ID" "$TEST_AGENT_ID" "assistant" "$i"
|
|
366
|
+
done
|
|
367
|
+
|
|
368
|
+
# Create forks
|
|
369
|
+
create_fork "$TEST_TASK_ID" "$TEST_AGENT_ID" 5 >/dev/null
|
|
370
|
+
|
|
371
|
+
# Get statistics (using Node.js with environment variables)
|
|
372
|
+
cd "$PROJECT_ROOT"
|
|
373
|
+
local stats=$(CFN_REDIS_HOST="$REDIS_HOST" CFN_REDIS_PORT="$REDIS_PORT" node -e "
|
|
374
|
+
const { getTaskMemoryStats } = require('./dist/cli/conversation-fork-cleanup.js');
|
|
375
|
+
const stats = getTaskMemoryStats('$TEST_TASK_ID', '$TEST_AGENT_ID');
|
|
376
|
+
console.log(JSON.stringify(stats));
|
|
377
|
+
" 2>/dev/null || echo "{}")
|
|
378
|
+
|
|
379
|
+
if [ "$stats" != "{}" ]; then
|
|
380
|
+
local message_count=$(echo "$stats" | grep -o '"messageCount":[0-9]*' | cut -d: -f2)
|
|
381
|
+
local fork_count=$(echo "$stats" | grep -o '"forkCount":[0-9]*' | cut -d: -f2)
|
|
382
|
+
|
|
383
|
+
if [ "$message_count" -gt 0 ] && [ "$fork_count" -gt 0 ]; then
|
|
384
|
+
print_result "Memory Statistics" "PASS" "Stats collected (messages: $message_count, forks: $fork_count)"
|
|
385
|
+
else
|
|
386
|
+
print_result "Memory Statistics" "FAIL" "Stats invalid (messages: $message_count, forks: $fork_count)"
|
|
387
|
+
fi
|
|
388
|
+
else
|
|
389
|
+
print_result "Memory Statistics" "SKIP" "Statistics utility not built"
|
|
390
|
+
fi
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
# Main test execution
|
|
394
|
+
main() {
|
|
395
|
+
setup
|
|
396
|
+
|
|
397
|
+
echo "Running memory leak tests..."
|
|
398
|
+
echo ""
|
|
399
|
+
|
|
400
|
+
test_message_ttl
|
|
401
|
+
test_fork_message_ttl
|
|
402
|
+
test_memory_accumulation
|
|
403
|
+
test_cleanup_utility
|
|
404
|
+
test_ttl_enforcement
|
|
405
|
+
test_fork_consistency
|
|
406
|
+
test_memory_statistics
|
|
407
|
+
|
|
408
|
+
cleanup
|
|
409
|
+
|
|
410
|
+
# Print summary
|
|
411
|
+
echo ""
|
|
412
|
+
echo "========================================="
|
|
413
|
+
echo "Test Summary"
|
|
414
|
+
echo "========================================="
|
|
415
|
+
echo -e "Total: $TESTS_RUN"
|
|
416
|
+
echo -e "${GREEN}Passed: $TESTS_PASSED${NC}"
|
|
417
|
+
if [ "$TESTS_FAILED" -gt 0 ]; then
|
|
418
|
+
echo -e "${RED}Failed: $TESTS_FAILED${NC}"
|
|
419
|
+
else
|
|
420
|
+
echo -e "Failed: $TESTS_FAILED"
|
|
421
|
+
fi
|
|
422
|
+
echo ""
|
|
423
|
+
|
|
424
|
+
# Exit code
|
|
425
|
+
if [ "$TESTS_FAILED" -gt 0 ]; then
|
|
426
|
+
echo -e "${RED}TESTS FAILED${NC}"
|
|
427
|
+
exit 1
|
|
428
|
+
else
|
|
429
|
+
echo -e "${GREEN}ALL TESTS PASSED${NC}"
|
|
430
|
+
exit 0
|
|
431
|
+
fi
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
# Run tests
|
|
435
|
+
main "$@"
|