kynjal-cli 3.1.3 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/core/coder.md +1 -1
- package/.claude/agents/core/planner.md +2 -2
- package/.claude/agents/core/researcher.md +1 -1
- package/.claude/agents/core/reviewer.md +1 -1
- package/.claude/agents/core/tester.md +1 -1
- package/.claude/agents/data/data-ml-model.md +4 -4
- package/.claude/agents/development/dev-backend-api.md +4 -4
- package/.claude/agents/documentation/docs-api-openapi.md +4 -4
- package/.claude/agents/github/code-review-swarm.md +2 -2
- package/.claude/agents/github/issue-tracker.md +2 -2
- package/.claude/agents/github/pr-manager.md +2 -2
- package/.claude/agents/github/release-manager.md +2 -2
- package/.claude/agents/github/workflow-automation.md +2 -2
- package/.claude/agents/sparc/architecture.md +3 -3
- package/.claude/agents/sparc/pseudocode.md +2 -2
- package/.claude/agents/sparc/refinement.md +3 -3
- package/.claude/agents/sparc/specification.md +2 -2
- package/.claude/agents/swarm/adaptive-coordinator.md +1 -1
- package/.claude/agents/swarm/hierarchical-coordinator.md +1 -1
- package/.claude/agents/swarm/mesh-coordinator.md +1 -1
- package/.claude/agents/templates/base-template-generator.md +25 -4
- package/.claude/agents/templates/sparc-coordinator.md +3 -3
- package/.claude/helpers/auto-commit.sh +1 -1
- package/.claude/helpers/auto-memory-hook.mjs +27 -9
- package/.claude/helpers/hook-handler.cjs +58 -18
- package/.claude/helpers/statusline.cjs +14 -33
- package/.claude/helpers/statusline.js +3 -3
- package/.claude/settings.json +9 -9
- package/.claude/skills/reasoningbank-intelligence/SKILL.md +2 -2
- package/.claude/skills/swarm-orchestration/SKILL.md +1 -1
- package/README.md +383 -170
- package/bin/cli.js +6 -6
- package/bin/mcp-server.js +1 -1
- package/bin/preinstall.cjs +2 -0
- package/dist/src/appliance/gguf-engine.js +664 -0
- package/dist/src/appliance/gguf-engine.js.map +1 -0
- package/dist/src/appliance/ruvllm-bridge.js +492 -0
- package/dist/src/appliance/ruvllm-bridge.js.map +1 -0
- package/dist/src/appliance/rvfa-builder.js +383 -0
- package/dist/src/appliance/rvfa-builder.js.map +1 -0
- package/dist/src/appliance/rvfa-distribution.js +533 -0
- package/dist/src/appliance/rvfa-distribution.js.map +1 -0
- package/dist/src/appliance/rvfa-format.js +465 -0
- package/dist/src/appliance/rvfa-format.js.map +1 -0
- package/dist/src/appliance/rvfa-runner.js +373 -0
- package/dist/src/appliance/rvfa-runner.js.map +1 -0
- package/dist/src/appliance/rvfa-signing.js +469 -0
- package/dist/src/appliance/rvfa-signing.js.map +1 -0
- package/dist/src/benchmarks/pretrain/index.js +542 -331
- package/dist/src/benchmarks/pretrain/index.js.map +1 -1
- package/dist/src/commands/agent.d.ts.map +1 -1
- package/dist/src/commands/agent.js +725 -502
- package/dist/src/commands/agent.js.map +1 -1
- package/dist/src/commands/analyze.js +1548 -1218
- package/dist/src/commands/analyze.js.map +1 -1
- package/dist/src/commands/appliance-advanced.d.ts +9 -0
- package/dist/src/commands/appliance-advanced.d.ts.map +1 -0
- package/dist/src/commands/appliance-advanced.js +324 -0
- package/dist/src/commands/appliance-advanced.js.map +1 -0
- package/dist/src/commands/appliance.d.ts +8 -0
- package/dist/src/commands/appliance.d.ts.map +1 -0
- package/dist/src/commands/appliance.js +581 -0
- package/dist/src/commands/appliance.js.map +1 -0
- package/dist/src/commands/benchmark.js +523 -372
- package/dist/src/commands/benchmark.js.map +1 -1
- package/dist/src/commands/claims.js +364 -274
- package/dist/src/commands/claims.js.map +1 -1
- package/dist/src/commands/cleanup.d.ts +13 -0
- package/dist/src/commands/cleanup.d.ts.map +1 -0
- package/dist/src/commands/cleanup.js +262 -0
- package/dist/src/commands/cleanup.js.map +1 -0
- package/dist/src/commands/completions.js +118 -477
- package/dist/src/commands/completions.js.map +1 -1
- package/dist/src/commands/config.js +303 -237
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/daemon.d.ts.map +1 -1
- package/dist/src/commands/daemon.js +597 -425
- package/dist/src/commands/daemon.js.map +1 -1
- package/dist/src/commands/deployment.js +275 -194
- package/dist/src/commands/deployment.js.map +1 -1
- package/dist/src/commands/doctor.d.ts.map +1 -1
- package/dist/src/commands/doctor.js +690 -460
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/embeddings.js +1543 -1293
- package/dist/src/commands/embeddings.js.map +1 -1
- package/dist/src/commands/guidance.js +596 -449
- package/dist/src/commands/guidance.js.map +1 -1
- package/dist/src/commands/hive-mind.js +938 -854
- package/dist/src/commands/hive-mind.js.map +1 -1
- package/dist/src/commands/hooks.d.ts.map +1 -1
- package/dist/src/commands/hooks.js +3677 -2570
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.js +322 -122
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init.d.ts +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +943 -787
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/issues.js +558 -383
- package/dist/src/commands/issues.js.map +1 -1
- package/dist/src/commands/mcp.d.ts.map +1 -1
- package/dist/src/commands/mcp.js +605 -475
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory.d.ts.map +1 -1
- package/dist/src/commands/memory.js +1031 -814
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/migrate.js +347 -282
- package/dist/src/commands/migrate.js.map +1 -1
- package/dist/src/commands/neural.d.ts.map +1 -1
- package/dist/src/commands/neural.js +1563 -1283
- package/dist/src/commands/neural.js.map +1 -1
- package/dist/src/commands/performance.js +643 -497
- package/dist/src/commands/performance.js.map +1 -1
- package/dist/src/commands/plugins.js +841 -668
- package/dist/src/commands/plugins.js.map +1 -1
- package/dist/src/commands/process.js +447 -392
- package/dist/src/commands/process.js.map +1 -1
- package/dist/src/commands/progress.js +256 -162
- package/dist/src/commands/progress.js.map +1 -1
- package/dist/src/commands/providers.js +220 -150
- package/dist/src/commands/providers.js.map +1 -1
- package/dist/src/commands/route.js +665 -520
- package/dist/src/commands/route.js.map +1 -1
- package/dist/src/commands/ruvector/backup.js +651 -505
- package/dist/src/commands/ruvector/backup.js.map +1 -1
- package/dist/src/commands/ruvector/benchmark.js +401 -349
- package/dist/src/commands/ruvector/benchmark.js.map +1 -1
- package/dist/src/commands/ruvector/import.js +267 -225
- package/dist/src/commands/ruvector/import.js.map +1 -1
- package/dist/src/commands/ruvector/index.js +75 -37
- package/dist/src/commands/ruvector/index.js.map +1 -1
- package/dist/src/commands/ruvector/init.js +359 -336
- package/dist/src/commands/ruvector/init.js.map +1 -1
- package/dist/src/commands/ruvector/migrate.js +322 -335
- package/dist/src/commands/ruvector/migrate.js.map +1 -1
- package/dist/src/commands/ruvector/optimize.js +431 -375
- package/dist/src/commands/ruvector/optimize.js.map +1 -1
- package/dist/src/commands/ruvector/setup.js +117 -703
- package/dist/src/commands/ruvector/setup.js.map +1 -1
- package/dist/src/commands/ruvector/status.js +419 -364
- package/dist/src/commands/ruvector/status.js.map +1 -1
- package/dist/src/commands/security.d.ts.map +1 -1
- package/dist/src/commands/security.js +610 -456
- package/dist/src/commands/security.js.map +1 -1
- package/dist/src/commands/session.d.ts +1 -1
- package/dist/src/commands/session.js +627 -505
- package/dist/src/commands/session.js.map +1 -1
- package/dist/src/commands/start.d.ts +1 -1
- package/dist/src/commands/start.js +368 -271
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.d.ts +1 -1
- package/dist/src/commands/status.d.ts.map +1 -1
- package/dist/src/commands/status.js +492 -379
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/swarm.js +488 -408
- package/dist/src/commands/swarm.js.map +1 -1
- package/dist/src/commands/task.d.ts +1 -1
- package/dist/src/commands/task.js +539 -424
- package/dist/src/commands/task.js.map +1 -1
- package/dist/src/commands/transfer-store.js +412 -322
- package/dist/src/commands/transfer-store.js.map +1 -1
- package/dist/src/commands/update.js +291 -196
- package/dist/src/commands/update.js.map +1 -1
- package/dist/src/commands/workflow.js +486 -386
- package/dist/src/commands/workflow.js.map +1 -1
- package/dist/src/config-adapter.js +40 -39
- package/dist/src/config-adapter.js.map +1 -1
- package/dist/src/index.js +416 -312
- package/dist/src/index.js.map +1 -1
- package/dist/src/infrastructure/in-memory-repositories.js +507 -246
- package/dist/src/infrastructure/in-memory-repositories.js.map +1 -1
- package/dist/src/init/claudemd-generator.js +78 -368
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/executor.js +1019 -1345
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/helpers-generator.js +60 -635
- package/dist/src/init/helpers-generator.js.map +1 -1
- package/dist/src/init/index.d.ts +1 -1
- package/dist/src/init/index.d.ts.map +1 -1
- package/dist/src/init/index.js +1 -1
- package/dist/src/init/index.js.map +1 -1
- package/dist/src/init/mcp-generator.d.ts +0 -1
- package/dist/src/init/mcp-generator.d.ts.map +1 -1
- package/dist/src/init/mcp-generator.js +62 -42
- package/dist/src/init/mcp-generator.js.map +1 -1
- package/dist/src/init/settings-generator.d.ts.map +1 -1
- package/dist/src/init/settings-generator.js +167 -100
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/statusline-generator.d.ts +16 -8
- package/dist/src/init/statusline-generator.d.ts.map +1 -1
- package/dist/src/init/statusline-generator.js +20 -1300
- package/dist/src/init/statusline-generator.js.map +1 -1
- package/dist/src/init/types.d.ts +15 -5
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/init/types.js +66 -76
- package/dist/src/init/types.js.map +1 -1
- package/dist/src/mcp-client.js +130 -76
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.js +758 -445
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +492 -391
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/agentdb-tools.d.ts +30 -0
- package/dist/src/mcp-tools/agentdb-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/agentdb-tools.js +758 -0
- package/dist/src/mcp-tools/agentdb-tools.js.map +1 -0
- package/dist/src/mcp-tools/analyze-tools.js +236 -172
- package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
- package/dist/src/mcp-tools/auto-install.js +142 -80
- package/dist/src/mcp-tools/auto-install.js.map +1 -1
- package/dist/src/mcp-tools/browser-tools.js +375 -252
- package/dist/src/mcp-tools/browser-tools.js.map +1 -1
- package/dist/src/mcp-tools/claims-tools.js +565 -473
- package/dist/src/mcp-tools/claims-tools.js.map +1 -1
- package/dist/src/mcp-tools/config-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/config-tools.js +284 -190
- package/dist/src/mcp-tools/config-tools.js.map +1 -1
- package/dist/src/mcp-tools/coordination-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/coordination-tools.js +600 -349
- package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
- package/dist/src/mcp-tools/daa-tools.js +367 -289
- package/dist/src/mcp-tools/daa-tools.js.map +1 -1
- package/dist/src/mcp-tools/embeddings-tools.js +693 -582
- package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
- package/dist/src/mcp-tools/github-tools.js +312 -261
- package/dist/src/mcp-tools/github-tools.js.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.js +718 -423
- package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +2726 -1978
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/index.d.ts +2 -0
- package/dist/src/mcp-tools/index.d.ts.map +1 -1
- package/dist/src/mcp-tools/index.js +2 -0
- package/dist/src/mcp-tools/index.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +514 -329
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/neural-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/neural-tools.js +428 -326
- package/dist/src/mcp-tools/neural-tools.js.map +1 -1
- package/dist/src/mcp-tools/performance-tools.js +480 -420
- package/dist/src/mcp-tools/performance-tools.js.map +1 -1
- package/dist/src/mcp-tools/progress-tools.js +278 -204
- package/dist/src/mcp-tools/progress-tools.js.map +1 -1
- package/dist/src/mcp-tools/ruvllm-tools.d.ts +9 -0
- package/dist/src/mcp-tools/ruvllm-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/ruvllm-tools.js +399 -0
- package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -0
- package/dist/src/mcp-tools/security-tools.js +429 -297
- package/dist/src/mcp-tools/security-tools.js.map +1 -1
- package/dist/src/mcp-tools/session-tools.js +234 -185
- package/dist/src/mcp-tools/session-tools.js.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.d.ts +2 -1
- package/dist/src/mcp-tools/swarm-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.js +303 -64
- package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
- package/dist/src/mcp-tools/system-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/system-tools.js +352 -200
- package/dist/src/mcp-tools/system-tools.js.map +1 -1
- package/dist/src/mcp-tools/task-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/task-tools.js +357 -189
- package/dist/src/mcp-tools/task-tools.js.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.js +196 -148
- package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
- package/dist/src/mcp-tools/transfer-tools.js +333 -186
- package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
- package/dist/src/mcp-tools/wasm-agent-tools.d.ts +9 -0
- package/dist/src/mcp-tools/wasm-agent-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/wasm-agent-tools.js +377 -0
- package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -0
- package/dist/src/mcp-tools/workflow-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/workflow-tools.js +471 -335
- package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
- package/dist/src/memory/ewc-consolidation.js +345 -173
- package/dist/src/memory/ewc-consolidation.js.map +1 -1
- package/dist/src/memory/intelligence.js +841 -359
- package/dist/src/memory/intelligence.js.map +1 -1
- package/dist/src/memory/memory-bridge.js +1964 -0
- package/dist/src/memory/memory-bridge.js.map +1 -0
- package/dist/src/memory/memory-initializer.js +1895 -1602
- package/dist/src/memory/memory-initializer.js.map +1 -1
- package/dist/src/memory/sona-optimizer.js +329 -199
- package/dist/src/memory/sona-optimizer.js.map +1 -1
- package/dist/src/output.d.ts +2 -2
- package/dist/src/output.d.ts.map +1 -1
- package/dist/src/output.js +273 -242
- package/dist/src/output.js.map +1 -1
- package/dist/src/parser.js +217 -124
- package/dist/src/parser.js.map +1 -1
- package/dist/src/plugins/manager.js +531 -278
- package/dist/src/plugins/manager.js.map +1 -1
- package/dist/src/plugins/store/discovery.js +362 -275
- package/dist/src/plugins/store/discovery.js.map +1 -1
- package/dist/src/plugins/store/index.js +105 -48
- package/dist/src/plugins/store/index.js.map +1 -1
- package/dist/src/plugins/store/search.js +107 -69
- package/dist/src/plugins/store/search.js.map +1 -1
- package/dist/src/plugins/tests/demo-plugin-store.js +160 -113
- package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -1
- package/dist/src/plugins/tests/standalone-test.js +223 -172
- package/dist/src/plugins/tests/standalone-test.js.map +1 -1
- package/dist/src/plugins/tests/test-plugin-store.js +228 -190
- package/dist/src/plugins/tests/test-plugin-store.js.map +1 -1
- package/dist/src/production/circuit-breaker.js +126 -62
- package/dist/src/production/circuit-breaker.js.map +1 -1
- package/dist/src/production/error-handler.js +156 -86
- package/dist/src/production/error-handler.js.map +1 -1
- package/dist/src/production/monitoring.js +220 -139
- package/dist/src/production/monitoring.js.map +1 -1
- package/dist/src/production/rate-limiter.js +93 -74
- package/dist/src/production/rate-limiter.js.map +1 -1
- package/dist/src/production/retry.js +167 -75
- package/dist/src/production/retry.js.map +1 -1
- package/dist/src/prompt.js +560 -436
- package/dist/src/prompt.js.map +1 -1
- package/dist/src/runtime/headless.js +289 -200
- package/dist/src/runtime/headless.js.map +1 -1
- package/dist/src/ruvector/agent-wasm.js +511 -0
- package/dist/src/ruvector/agent-wasm.js.map +1 -0
- package/dist/src/ruvector/ast-analyzer.js +232 -145
- package/dist/src/ruvector/ast-analyzer.js.map +1 -1
- package/dist/src/ruvector/coverage-router.js +419 -287
- package/dist/src/ruvector/coverage-router.js.map +1 -1
- package/dist/src/ruvector/coverage-tools.js +101 -56
- package/dist/src/ruvector/coverage-tools.js.map +1 -1
- package/dist/src/ruvector/diff-classifier.js +451 -324
- package/dist/src/ruvector/diff-classifier.js.map +1 -1
- package/dist/src/ruvector/enhanced-model-router.js +337 -251
- package/dist/src/ruvector/enhanced-model-router.js.map +1 -1
- package/dist/src/ruvector/flash-attention.js +254 -223
- package/dist/src/ruvector/flash-attention.js.map +1 -1
- package/dist/src/ruvector/graph-analyzer.js +680 -486
- package/dist/src/ruvector/graph-analyzer.js.map +1 -1
- package/dist/src/ruvector/index.js +113 -27
- package/dist/src/ruvector/index.js.map +1 -1
- package/dist/src/ruvector/lora-adapter.js +248 -155
- package/dist/src/ruvector/lora-adapter.js.map +1 -1
- package/dist/src/ruvector/model-router.js +248 -175
- package/dist/src/ruvector/model-router.js.map +1 -1
- package/dist/src/ruvector/moe-router.js +286 -228
- package/dist/src/ruvector/moe-router.js.map +1 -1
- package/dist/src/ruvector/q-learning-router.js +338 -257
- package/dist/src/ruvector/q-learning-router.js.map +1 -1
- package/dist/src/ruvector/ruvllm-wasm.js +527 -0
- package/dist/src/ruvector/ruvllm-wasm.js.map +1 -0
- package/dist/src/ruvector/semantic-router.js +67 -60
- package/dist/src/ruvector/semantic-router.js.map +1 -1
- package/dist/src/ruvector/vector-db.js +205 -119
- package/dist/src/ruvector/vector-db.js.map +1 -1
- package/dist/src/services/agentic-flow-bridge.js +168 -0
- package/dist/src/services/agentic-flow-bridge.js.map +1 -0
- package/dist/src/services/claim-service.js +940 -615
- package/dist/src/services/claim-service.js.map +1 -1
- package/dist/src/services/container-worker-pool.js +669 -399
- package/dist/src/services/container-worker-pool.js.map +1 -1
- package/dist/src/services/headless-worker-executor.js +467 -441
- package/dist/src/services/headless-worker-executor.js.map +1 -1
- package/dist/src/services/index.d.ts +5 -5
- package/dist/src/services/index.d.ts.map +1 -1
- package/dist/src/services/index.js +4 -4
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/registry-api.js +201 -93
- package/dist/src/services/registry-api.js.map +1 -1
- package/dist/src/services/ruvector-training.js +414 -144
- package/dist/src/services/ruvector-training.js.map +1 -1
- package/dist/src/services/worker-daemon.js +928 -531
- package/dist/src/services/worker-daemon.js.map +1 -1
- package/dist/src/services/worker-queue.js +550 -331
- package/dist/src/services/worker-queue.js.map +1 -1
- package/dist/src/suggest.js +55 -45
- package/dist/src/suggest.js.map +1 -1
- package/dist/src/transfer/anonymization/index.js +37 -29
- package/dist/src/transfer/anonymization/index.js.map +1 -1
- package/dist/src/transfer/deploy-seraphine.d.ts +1 -1
- package/dist/src/transfer/deploy-seraphine.js +156 -129
- package/dist/src/transfer/deploy-seraphine.js.map +1 -1
- package/dist/src/transfer/export.js +142 -84
- package/dist/src/transfer/export.js.map +1 -1
- package/dist/src/transfer/index.d.ts +1 -1
- package/dist/src/transfer/index.d.ts.map +1 -1
- package/dist/src/transfer/index.js +2 -0
- package/dist/src/transfer/index.js.map +1 -1
- package/dist/src/transfer/ipfs/client.js +337 -179
- package/dist/src/transfer/ipfs/client.js.map +1 -1
- package/dist/src/transfer/ipfs/upload.js +434 -290
- package/dist/src/transfer/ipfs/upload.js.map +1 -1
- package/dist/src/transfer/models/seraphine.js +58 -58
- package/dist/src/transfer/models/seraphine.js.map +1 -1
- package/dist/src/transfer/serialization/cfp.js +37 -33
- package/dist/src/transfer/serialization/cfp.js.map +1 -1
- package/dist/src/transfer/storage/gcs.js +248 -139
- package/dist/src/transfer/storage/gcs.js.map +1 -1
- package/dist/src/transfer/store/discovery.js +353 -243
- package/dist/src/transfer/store/discovery.js.map +1 -1
- package/dist/src/transfer/store/download.js +365 -243
- package/dist/src/transfer/store/download.js.map +1 -1
- package/dist/src/transfer/store/index.js +130 -63
- package/dist/src/transfer/store/index.js.map +1 -1
- package/dist/src/transfer/store/publish.js +258 -184
- package/dist/src/transfer/store/publish.js.map +1 -1
- package/dist/src/transfer/store/registry.js +73 -51
- package/dist/src/transfer/store/registry.js.map +1 -1
- package/dist/src/transfer/store/search.js +96 -64
- package/dist/src/transfer/store/search.js.map +1 -1
- package/dist/src/transfer/store/tests/standalone-test.js +231 -174
- package/dist/src/transfer/store/tests/standalone-test.js.map +1 -1
- package/dist/src/transfer/test-seraphine.js +130 -95
- package/dist/src/transfer/test-seraphine.js.map +1 -1
- package/dist/src/transfer/tests/test-store.js +239 -194
- package/dist/src/transfer/tests/test-store.js.map +1 -1
- package/dist/src/types.js +56 -27
- package/dist/src/types.js.map +1 -1
- package/dist/src/update/checker.js +183 -106
- package/dist/src/update/checker.js.map +1 -1
- package/dist/src/update/executor.js +198 -135
- package/dist/src/update/executor.js.map +1 -1
- package/dist/src/update/index.js +85 -38
- package/dist/src/update/index.js.map +1 -1
- package/dist/src/update/rate-limiter.js +31 -19
- package/dist/src/update/rate-limiter.js.map +1 -1
- package/dist/src/update/validator.js +64 -38
- package/dist/src/update/validator.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -10
- package/.claude/agents/custom/accessibility-auditor.yaml +0 -56
- package/.claude/agents/custom/design-architect.yaml +0 -48
- package/.claude/agents/custom/ui-developer.yaml +0 -46
- package/.claude/agents/custom/ux-researcher.yaml +0 -60
- package/dist/src/benchmarks/pretrain/index.d.ts +0 -58
- package/dist/src/benchmarks/pretrain/index.d.ts.map +0 -1
- package/dist/src/commands/index.d.ts +0 -108
- package/dist/src/commands/index.d.ts.map +0 -1
- package/dist/src/config-adapter.d.ts +0 -15
- package/dist/src/config-adapter.d.ts.map +0 -1
- package/dist/src/index.d.ts +0 -76
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/infrastructure/in-memory-repositories.d.ts +0 -68
- package/dist/src/infrastructure/in-memory-repositories.d.ts.map +0 -1
- package/dist/src/init/claudemd-generator.d.ts +0 -25
- package/dist/src/init/claudemd-generator.d.ts.map +0 -1
- package/dist/src/init/executor.d.ts +0 -41
- package/dist/src/init/executor.d.ts.map +0 -1
- package/dist/src/init/helpers-generator.d.ts +0 -60
- package/dist/src/init/helpers-generator.d.ts.map +0 -1
- package/dist/src/mcp-client.d.ts +0 -92
- package/dist/src/mcp-client.d.ts.map +0 -1
- package/dist/src/mcp-server.d.ts +0 -161
- package/dist/src/mcp-server.d.ts.map +0 -1
- package/dist/src/mcp-tools/auto-install.d.ts +0 -83
- package/dist/src/mcp-tools/auto-install.d.ts.map +0 -1
- package/dist/src/mcp-tools/types.d.ts +0 -31
- package/dist/src/mcp-tools/types.d.ts.map +0 -1
- package/dist/src/memory/ewc-consolidation.d.ts +0 -271
- package/dist/src/memory/ewc-consolidation.d.ts.map +0 -1
- package/dist/src/memory/intelligence.d.ts +0 -285
- package/dist/src/memory/intelligence.d.ts.map +0 -1
- package/dist/src/memory/memory-initializer.d.ts +0 -396
- package/dist/src/memory/memory-initializer.d.ts.map +0 -1
- package/dist/src/memory/sona-optimizer.d.ts +0 -227
- package/dist/src/memory/sona-optimizer.d.ts.map +0 -1
- package/dist/src/parser.d.ts +0 -41
- package/dist/src/parser.d.ts.map +0 -1
- package/dist/src/plugins/manager.d.ts +0 -133
- package/dist/src/plugins/manager.d.ts.map +0 -1
- package/dist/src/plugins/store/discovery.d.ts +0 -88
- package/dist/src/plugins/store/discovery.d.ts.map +0 -1
- package/dist/src/plugins/store/index.d.ts +0 -76
- package/dist/src/plugins/store/index.d.ts.map +0 -1
- package/dist/src/plugins/store/search.d.ts +0 -46
- package/dist/src/plugins/store/search.d.ts.map +0 -1
- package/dist/src/plugins/store/types.d.ts +0 -274
- package/dist/src/plugins/store/types.d.ts.map +0 -1
- package/dist/src/production/circuit-breaker.d.ts +0 -101
- package/dist/src/production/circuit-breaker.d.ts.map +0 -1
- package/dist/src/production/error-handler.d.ts +0 -92
- package/dist/src/production/error-handler.d.ts.map +0 -1
- package/dist/src/production/monitoring.d.ts +0 -161
- package/dist/src/production/monitoring.d.ts.map +0 -1
- package/dist/src/production/rate-limiter.d.ts +0 -80
- package/dist/src/production/rate-limiter.d.ts.map +0 -1
- package/dist/src/production/retry.d.ts +0 -48
- package/dist/src/production/retry.d.ts.map +0 -1
- package/dist/src/prompt.d.ts +0 -44
- package/dist/src/prompt.d.ts.map +0 -1
- package/dist/src/runtime/headless.d.ts +0 -60
- package/dist/src/runtime/headless.d.ts.map +0 -1
- package/dist/src/ruvector/ast-analyzer.d.ts +0 -67
- package/dist/src/ruvector/ast-analyzer.d.ts.map +0 -1
- package/dist/src/ruvector/coverage-router.d.ts +0 -160
- package/dist/src/ruvector/coverage-router.d.ts.map +0 -1
- package/dist/src/ruvector/diff-classifier.d.ts +0 -175
- package/dist/src/ruvector/diff-classifier.d.ts.map +0 -1
- package/dist/src/ruvector/enhanced-model-router.d.ts +0 -146
- package/dist/src/ruvector/enhanced-model-router.d.ts.map +0 -1
- package/dist/src/ruvector/flash-attention.d.ts +0 -195
- package/dist/src/ruvector/flash-attention.d.ts.map +0 -1
- package/dist/src/ruvector/graph-analyzer.d.ts +0 -187
- package/dist/src/ruvector/graph-analyzer.d.ts.map +0 -1
- package/dist/src/ruvector/index.d.ts +0 -34
- package/dist/src/ruvector/index.d.ts.map +0 -1
- package/dist/src/ruvector/lora-adapter.d.ts +0 -218
- package/dist/src/ruvector/lora-adapter.d.ts.map +0 -1
- package/dist/src/ruvector/model-router.d.ts +0 -220
- package/dist/src/ruvector/model-router.d.ts.map +0 -1
- package/dist/src/ruvector/moe-router.d.ts +0 -206
- package/dist/src/ruvector/moe-router.d.ts.map +0 -1
- package/dist/src/ruvector/q-learning-router.d.ts +0 -211
- package/dist/src/ruvector/q-learning-router.d.ts.map +0 -1
- package/dist/src/ruvector/semantic-router.d.ts +0 -77
- package/dist/src/ruvector/semantic-router.d.ts.map +0 -1
- package/dist/src/ruvector/vector-db.d.ts +0 -69
- package/dist/src/ruvector/vector-db.d.ts.map +0 -1
- package/dist/src/services/claim-service.d.ts +0 -204
- package/dist/src/services/claim-service.d.ts.map +0 -1
- package/dist/src/services/container-worker-pool.d.ts +0 -197
- package/dist/src/services/container-worker-pool.d.ts.map +0 -1
- package/dist/src/services/headless-worker-executor.d.ts +0 -304
- package/dist/src/services/headless-worker-executor.d.ts.map +0 -1
- package/dist/src/services/registry-api.d.ts +0 -58
- package/dist/src/services/registry-api.d.ts.map +0 -1
- package/dist/src/services/ruvector-training.d.ts +0 -213
- package/dist/src/services/ruvector-training.d.ts.map +0 -1
- package/dist/src/services/worker-daemon.d.ts +0 -203
- package/dist/src/services/worker-daemon.d.ts.map +0 -1
- package/dist/src/services/worker-queue.d.ts +0 -194
- package/dist/src/services/worker-queue.d.ts.map +0 -1
- package/dist/src/suggest.d.ts +0 -53
- package/dist/src/suggest.d.ts.map +0 -1
- package/dist/src/transfer/export.d.ts +0 -25
- package/dist/src/transfer/export.d.ts.map +0 -1
- package/dist/src/transfer/ipfs/client.d.ts +0 -109
- package/dist/src/transfer/ipfs/client.d.ts.map +0 -1
- package/dist/src/transfer/ipfs/upload.d.ts +0 -95
- package/dist/src/transfer/ipfs/upload.d.ts.map +0 -1
- package/dist/src/transfer/models/seraphine.d.ts +0 -72
- package/dist/src/transfer/models/seraphine.d.ts.map +0 -1
- package/dist/src/transfer/serialization/cfp.d.ts +0 -49
- package/dist/src/transfer/serialization/cfp.d.ts.map +0 -1
- package/dist/src/transfer/storage/gcs.d.ts +0 -82
- package/dist/src/transfer/storage/gcs.d.ts.map +0 -1
- package/dist/src/transfer/store/discovery.d.ts +0 -84
- package/dist/src/transfer/store/discovery.d.ts.map +0 -1
- package/dist/src/transfer/store/download.d.ts +0 -70
- package/dist/src/transfer/store/download.d.ts.map +0 -1
- package/dist/src/transfer/store/index.d.ts +0 -84
- package/dist/src/transfer/store/index.d.ts.map +0 -1
- package/dist/src/transfer/store/publish.d.ts +0 -76
- package/dist/src/transfer/store/publish.d.ts.map +0 -1
- package/dist/src/transfer/store/search.d.ts +0 -54
- package/dist/src/transfer/store/search.d.ts.map +0 -1
- package/dist/src/transfer/types.d.ts +0 -245
- package/dist/src/transfer/types.d.ts.map +0 -1
- package/dist/src/types.d.ts +0 -198
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/update/checker.d.ts +0 -34
- package/dist/src/update/checker.d.ts.map +0 -1
- package/dist/src/update/executor.d.ts +0 -32
- package/dist/src/update/executor.d.ts.map +0 -1
- package/dist/src/update/index.d.ts +0 -33
- package/dist/src/update/index.d.ts.map +0 -1
- package/dist/src/update/rate-limiter.d.ts +0 -20
- package/dist/src/update/rate-limiter.d.ts.map +0 -1
- package/dist/src/update/validator.d.ts +0 -17
- package/dist/src/update/validator.d.ts.map +0 -1
|
@@ -20,12 +20,59 @@
|
|
|
20
20
|
*
|
|
21
21
|
* @module v3/cli/memory/ewc-consolidation
|
|
22
22
|
*/
|
|
23
|
+
var __assign = (this && this.__assign) || function () {
|
|
24
|
+
__assign = Object.assign || function(t) {
|
|
25
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
26
|
+
s = arguments[i];
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
}
|
|
30
|
+
return t;
|
|
31
|
+
};
|
|
32
|
+
return __assign.apply(this, arguments);
|
|
33
|
+
};
|
|
34
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
35
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
36
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
37
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
38
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
39
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
40
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
44
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
45
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
46
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
47
|
+
function step(op) {
|
|
48
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
49
|
+
while (_) try {
|
|
50
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
51
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
52
|
+
switch (op[0]) {
|
|
53
|
+
case 0: case 1: t = op; break;
|
|
54
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
55
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
56
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
57
|
+
default:
|
|
58
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
59
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
60
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
61
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
62
|
+
if (t[2]) _.ops.pop();
|
|
63
|
+
_.trys.pop(); continue;
|
|
64
|
+
}
|
|
65
|
+
op = body.call(thisArg, _);
|
|
66
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
67
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
68
|
+
}
|
|
69
|
+
};
|
|
23
70
|
import * as fs from 'fs';
|
|
24
71
|
import * as path from 'path';
|
|
25
72
|
// ============================================================================
|
|
26
73
|
// Default Configuration
|
|
27
74
|
// ============================================================================
|
|
28
|
-
|
|
75
|
+
var DEFAULT_EWC_CONFIG = {
|
|
29
76
|
lambda: 0.4,
|
|
30
77
|
maxPatterns: 1000,
|
|
31
78
|
fisherDecayRate: 0.01,
|
|
@@ -42,34 +89,45 @@ const DEFAULT_EWC_CONFIG = {
|
|
|
42
89
|
* Implements Elastic Weight Consolidation with online updates
|
|
43
90
|
* for preventing catastrophic forgetting in continual learning
|
|
44
91
|
*/
|
|
45
|
-
|
|
46
|
-
config
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this.config = { ...DEFAULT_EWC_CONFIG, ...config };
|
|
92
|
+
var EWCConsolidator = /** @class */ (function () {
|
|
93
|
+
function EWCConsolidator(config) {
|
|
94
|
+
this.patterns = new Map();
|
|
95
|
+
this.gradientHistory = [];
|
|
96
|
+
this.globalFisher = [];
|
|
97
|
+
this.consolidationHistory = [];
|
|
98
|
+
this.initialized = false;
|
|
99
|
+
this.config = __assign(__assign({}, DEFAULT_EWC_CONFIG), config);
|
|
54
100
|
this.globalFisher = new Array(this.config.dimensions).fill(0);
|
|
55
101
|
}
|
|
56
102
|
/**
|
|
57
103
|
* Initialize the consolidator by loading persisted state
|
|
58
104
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
105
|
+
EWCConsolidator.prototype.initialize = function () {
|
|
106
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
107
|
+
var _a;
|
|
108
|
+
return __generator(this, function (_b) {
|
|
109
|
+
switch (_b.label) {
|
|
110
|
+
case 0:
|
|
111
|
+
if (this.initialized)
|
|
112
|
+
return [2 /*return*/, true];
|
|
113
|
+
_b.label = 1;
|
|
114
|
+
case 1:
|
|
115
|
+
_b.trys.push([1, 3, , 4]);
|
|
116
|
+
return [4 /*yield*/, this.loadFromDisk()];
|
|
117
|
+
case 2:
|
|
118
|
+
_b.sent();
|
|
119
|
+
this.initialized = true;
|
|
120
|
+
return [2 /*return*/, true];
|
|
121
|
+
case 3:
|
|
122
|
+
_a = _b.sent();
|
|
123
|
+
// Start fresh if no persisted state
|
|
124
|
+
this.initialized = true;
|
|
125
|
+
return [2 /*return*/, true];
|
|
126
|
+
case 4: return [2 /*return*/];
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
};
|
|
73
131
|
/**
|
|
74
132
|
* Compute Fisher Information Matrix from gradient history
|
|
75
133
|
* Uses diagonal approximation for efficiency: F_i = E[g_i^2]
|
|
@@ -77,10 +135,11 @@ export class EWCConsolidator {
|
|
|
77
135
|
* @param patterns - Array of patterns with their gradients/embeddings
|
|
78
136
|
* @returns Fisher information diagonal
|
|
79
137
|
*/
|
|
80
|
-
computeFisherMatrix(patterns) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
for (
|
|
138
|
+
EWCConsolidator.prototype.computeFisherMatrix = function (patterns) {
|
|
139
|
+
var fisher = new Array(this.config.dimensions).fill(0);
|
|
140
|
+
var sampleCount = 0;
|
|
141
|
+
for (var _i = 0, patterns_1 = patterns; _i < patterns_1.length; _i++) {
|
|
142
|
+
var pattern = patterns_1[_i];
|
|
84
143
|
if (!pattern.embedding || pattern.embedding.length === 0)
|
|
85
144
|
continue;
|
|
86
145
|
// Only use successful patterns for Fisher computation
|
|
@@ -90,27 +149,27 @@ export class EWCConsolidator {
|
|
|
90
149
|
sampleCount++;
|
|
91
150
|
// Fisher diagonal is expectation of squared gradients
|
|
92
151
|
// For embeddings, we use the embedding values as proxy for gradients
|
|
93
|
-
|
|
94
|
-
for (
|
|
152
|
+
var len = Math.min(pattern.embedding.length, this.config.dimensions);
|
|
153
|
+
for (var i = 0; i < len; i++) {
|
|
95
154
|
// Accumulate squared values (gradient proxy)
|
|
96
155
|
fisher[i] += pattern.embedding[i] * pattern.embedding[i];
|
|
97
156
|
}
|
|
98
157
|
}
|
|
99
158
|
// Normalize by sample count
|
|
100
159
|
if (sampleCount > 0) {
|
|
101
|
-
for (
|
|
160
|
+
for (var i = 0; i < this.config.dimensions; i++) {
|
|
102
161
|
fisher[i] /= sampleCount;
|
|
103
162
|
}
|
|
104
163
|
}
|
|
105
164
|
// Update global Fisher with exponential moving average (EWC++)
|
|
106
165
|
if (this.config.onlineMode) {
|
|
107
|
-
|
|
108
|
-
for (
|
|
166
|
+
var decay = this.config.fisherDecayRate;
|
|
167
|
+
for (var i = 0; i < this.config.dimensions; i++) {
|
|
109
168
|
this.globalFisher[i] = (1 - decay) * this.globalFisher[i] + decay * fisher[i];
|
|
110
169
|
}
|
|
111
170
|
}
|
|
112
171
|
return fisher;
|
|
113
|
-
}
|
|
172
|
+
};
|
|
114
173
|
/**
|
|
115
174
|
* Consolidate new patterns with old patterns without forgetting
|
|
116
175
|
* Applies EWC penalty to preserve important weights
|
|
@@ -119,9 +178,9 @@ export class EWCConsolidator {
|
|
|
119
178
|
* @param oldPatterns - Existing patterns to preserve
|
|
120
179
|
* @returns Consolidated patterns with modified weights
|
|
121
180
|
*/
|
|
122
|
-
consolidate(newPatterns, oldPatterns) {
|
|
123
|
-
|
|
124
|
-
|
|
181
|
+
EWCConsolidator.prototype.consolidate = function (newPatterns, oldPatterns) {
|
|
182
|
+
var startTime = performance.now();
|
|
183
|
+
var result = {
|
|
125
184
|
success: false,
|
|
126
185
|
patternsConsolidated: 0,
|
|
127
186
|
totalPenalty: 0,
|
|
@@ -131,32 +190,33 @@ export class EWCConsolidator {
|
|
|
131
190
|
};
|
|
132
191
|
try {
|
|
133
192
|
// Use stored patterns if no old patterns provided
|
|
134
|
-
|
|
193
|
+
var existingPatterns = oldPatterns || Array.from(this.patterns.values());
|
|
135
194
|
// Compute Fisher from successful existing patterns
|
|
136
|
-
|
|
137
|
-
.filter(p
|
|
138
|
-
.map(p
|
|
195
|
+
var fisherInput = existingPatterns
|
|
196
|
+
.filter(function (p) { return p.successCount > p.failureCount; })
|
|
197
|
+
.map(function (p) { return ({
|
|
139
198
|
id: p.id,
|
|
140
199
|
embedding: p.weights,
|
|
141
200
|
success: true
|
|
142
|
-
}));
|
|
143
|
-
|
|
201
|
+
}); });
|
|
202
|
+
var fisher = this.computeFisherMatrix(fisherInput);
|
|
144
203
|
// Process each new pattern
|
|
145
|
-
for (
|
|
204
|
+
for (var _i = 0, newPatterns_1 = newPatterns; _i < newPatterns_1.length; _i++) {
|
|
205
|
+
var newPattern = newPatterns_1[_i];
|
|
146
206
|
if (!newPattern.embedding || newPattern.embedding.length === 0)
|
|
147
207
|
continue;
|
|
148
|
-
|
|
208
|
+
var existingPattern = this.patterns.get(newPattern.id);
|
|
149
209
|
if (existingPattern) {
|
|
150
210
|
// Calculate EWC penalty for updating existing pattern
|
|
151
|
-
|
|
211
|
+
var penalty = this.getPenalty(existingPattern.weights, newPattern.embedding, fisher);
|
|
152
212
|
// Determine if update is allowed based on penalty
|
|
153
|
-
|
|
213
|
+
var importanceScore = this.calculateImportance(existingPattern);
|
|
154
214
|
if (importanceScore > this.config.importanceThreshold && penalty > this.config.lambda) {
|
|
155
215
|
// Protect high-importance patterns with high penalty
|
|
156
216
|
result.protectedPatterns.push(newPattern.id);
|
|
157
217
|
// Apply constrained update: blend old and new based on importance
|
|
158
|
-
|
|
159
|
-
|
|
218
|
+
var blendFactor = 1 - importanceScore;
|
|
219
|
+
var blendedWeights = this.blendWeights(existingPattern.weights, newPattern.embedding, blendFactor, fisher);
|
|
160
220
|
existingPattern.weights = blendedWeights;
|
|
161
221
|
existingPattern.lastUpdated = Date.now();
|
|
162
222
|
result.modifiedPatterns.push(newPattern.id);
|
|
@@ -173,7 +233,7 @@ export class EWCConsolidator {
|
|
|
173
233
|
}
|
|
174
234
|
else {
|
|
175
235
|
// New pattern: add directly
|
|
176
|
-
|
|
236
|
+
var weights = {
|
|
177
237
|
id: newPattern.id,
|
|
178
238
|
weights: newPattern.embedding.slice(0, this.config.dimensions),
|
|
179
239
|
fisherDiagonal: fisher,
|
|
@@ -210,7 +270,7 @@ export class EWCConsolidator {
|
|
|
210
270
|
result.duration = performance.now() - startTime;
|
|
211
271
|
return result;
|
|
212
272
|
}
|
|
213
|
-
}
|
|
273
|
+
};
|
|
214
274
|
/**
|
|
215
275
|
* Calculate EWC regularization penalty
|
|
216
276
|
*
|
|
@@ -221,47 +281,48 @@ export class EWCConsolidator {
|
|
|
221
281
|
* @param fisher - Fisher information diagonal (optional, uses global if not provided)
|
|
222
282
|
* @returns Regularization penalty value
|
|
223
283
|
*/
|
|
224
|
-
getPenalty(oldWeights, newWeights, fisher) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
for (
|
|
229
|
-
|
|
284
|
+
EWCConsolidator.prototype.getPenalty = function (oldWeights, newWeights, fisher) {
|
|
285
|
+
var fisherDiag = fisher || this.globalFisher;
|
|
286
|
+
var len = Math.min(oldWeights.length, newWeights.length, fisherDiag.length);
|
|
287
|
+
var penalty = 0;
|
|
288
|
+
for (var i = 0; i < len; i++) {
|
|
289
|
+
var diff = newWeights[i] - oldWeights[i];
|
|
230
290
|
penalty += fisherDiag[i] * diff * diff;
|
|
231
291
|
}
|
|
232
292
|
return (this.config.lambda / 2) * penalty;
|
|
233
|
-
}
|
|
293
|
+
};
|
|
234
294
|
/**
|
|
235
295
|
* Get consolidation statistics
|
|
236
296
|
*/
|
|
237
|
-
getConsolidationStats() {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
for (
|
|
297
|
+
EWCConsolidator.prototype.getConsolidationStats = function () {
|
|
298
|
+
var totalFisher = 0;
|
|
299
|
+
var maxFisher = 0;
|
|
300
|
+
var highImportance = 0;
|
|
301
|
+
for (var i = 0; i < this.globalFisher.length; i++) {
|
|
242
302
|
totalFisher += this.globalFisher[i];
|
|
243
303
|
if (this.globalFisher[i] > maxFisher) {
|
|
244
304
|
maxFisher = this.globalFisher[i];
|
|
245
305
|
}
|
|
246
306
|
}
|
|
247
|
-
for (
|
|
307
|
+
for (var _i = 0, _a = this.patterns.values(); _i < _a.length; _i++) {
|
|
308
|
+
var pattern = _a[_i];
|
|
248
309
|
if (this.calculateImportance(pattern) > this.config.importanceThreshold) {
|
|
249
310
|
highImportance++;
|
|
250
311
|
}
|
|
251
312
|
}
|
|
252
|
-
|
|
253
|
-
|
|
313
|
+
var totalPenalty = this.consolidationHistory.reduce(function (sum, h) { return sum + h.penalty; }, 0);
|
|
314
|
+
var avgPenalty = this.consolidationHistory.length > 0
|
|
254
315
|
? totalPenalty / this.consolidationHistory.length
|
|
255
316
|
: 0;
|
|
256
317
|
// Estimate storage size
|
|
257
|
-
|
|
318
|
+
var storageSizeBytes = 0;
|
|
258
319
|
try {
|
|
259
320
|
if (fs.existsSync(this.config.storagePath)) {
|
|
260
|
-
|
|
321
|
+
var stats = fs.statSync(this.config.storagePath);
|
|
261
322
|
storageSizeBytes = stats.size;
|
|
262
323
|
}
|
|
263
324
|
}
|
|
264
|
-
catch {
|
|
325
|
+
catch (_b) {
|
|
265
326
|
// Ignore stat errors
|
|
266
327
|
}
|
|
267
328
|
return {
|
|
@@ -273,27 +334,27 @@ export class EWCConsolidator {
|
|
|
273
334
|
lastConsolidation: this.consolidationHistory.length > 0
|
|
274
335
|
? this.consolidationHistory[this.consolidationHistory.length - 1].timestamp
|
|
275
336
|
: null,
|
|
276
|
-
avgPenalty,
|
|
277
|
-
storageSizeBytes
|
|
337
|
+
avgPenalty: avgPenalty,
|
|
338
|
+
storageSizeBytes: storageSizeBytes
|
|
278
339
|
};
|
|
279
|
-
}
|
|
340
|
+
};
|
|
280
341
|
/**
|
|
281
342
|
* Record a gradient sample for Fisher computation
|
|
282
343
|
*/
|
|
283
|
-
recordGradient(patternId, gradients, success) {
|
|
344
|
+
EWCConsolidator.prototype.recordGradient = function (patternId, gradients, success) {
|
|
284
345
|
this.gradientHistory.push({
|
|
285
|
-
patternId,
|
|
286
|
-
gradients,
|
|
346
|
+
patternId: patternId,
|
|
347
|
+
gradients: gradients,
|
|
287
348
|
timestamp: Date.now(),
|
|
288
|
-
success
|
|
349
|
+
success: success
|
|
289
350
|
});
|
|
290
351
|
// Keep only recent gradients
|
|
291
|
-
|
|
352
|
+
var maxGradients = this.config.maxPatterns * 2;
|
|
292
353
|
if (this.gradientHistory.length > maxGradients) {
|
|
293
354
|
this.gradientHistory = this.gradientHistory.slice(-maxGradients);
|
|
294
355
|
}
|
|
295
356
|
// Update pattern success/failure counts
|
|
296
|
-
|
|
357
|
+
var pattern = this.patterns.get(patternId);
|
|
297
358
|
if (pattern) {
|
|
298
359
|
if (success) {
|
|
299
360
|
pattern.successCount++;
|
|
@@ -305,47 +366,107 @@ export class EWCConsolidator {
|
|
|
305
366
|
}
|
|
306
367
|
// Online Fisher update from this gradient
|
|
307
368
|
if (this.config.onlineMode && success) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
for (
|
|
369
|
+
var decay = this.config.fisherDecayRate;
|
|
370
|
+
var len = Math.min(gradients.length, this.config.dimensions);
|
|
371
|
+
for (var i = 0; i < len; i++) {
|
|
311
372
|
this.globalFisher[i] = (1 - decay) * this.globalFisher[i] + decay * gradients[i] * gradients[i];
|
|
312
373
|
}
|
|
313
374
|
}
|
|
314
|
-
}
|
|
375
|
+
};
|
|
315
376
|
/**
|
|
316
377
|
* Get pattern weights by ID
|
|
317
378
|
*/
|
|
318
|
-
getPatternWeights(id) {
|
|
379
|
+
EWCConsolidator.prototype.getPatternWeights = function (id) {
|
|
319
380
|
return this.patterns.get(id);
|
|
320
|
-
}
|
|
381
|
+
};
|
|
321
382
|
/**
|
|
322
383
|
* Get all stored patterns
|
|
323
384
|
*/
|
|
324
|
-
getAllPatterns() {
|
|
385
|
+
EWCConsolidator.prototype.getAllPatterns = function () {
|
|
325
386
|
return Array.from(this.patterns.values());
|
|
326
|
-
}
|
|
387
|
+
};
|
|
327
388
|
/**
|
|
328
389
|
* Update EWC lambda (regularization strength)
|
|
329
390
|
*/
|
|
330
|
-
setLambda(lambda) {
|
|
391
|
+
EWCConsolidator.prototype.setLambda = function (lambda) {
|
|
331
392
|
this.config.lambda = lambda;
|
|
332
|
-
}
|
|
393
|
+
};
|
|
333
394
|
/**
|
|
334
395
|
* Get current lambda value
|
|
335
396
|
*/
|
|
336
|
-
getLambda() {
|
|
397
|
+
EWCConsolidator.prototype.getLambda = function () {
|
|
337
398
|
return this.config.lambda;
|
|
338
|
-
}
|
|
399
|
+
};
|
|
339
400
|
/**
|
|
340
401
|
* Reset Fisher matrix (use with caution - allows forgetting)
|
|
341
402
|
*/
|
|
342
|
-
resetFisher() {
|
|
403
|
+
EWCConsolidator.prototype.resetFisher = function () {
|
|
343
404
|
this.globalFisher = new Array(this.config.dimensions).fill(0);
|
|
344
|
-
}
|
|
405
|
+
};
|
|
406
|
+
/**
|
|
407
|
+
* Update Fisher matrix from pattern confidence changes.
|
|
408
|
+
* Called by SONA after distillLearning to track which patterns
|
|
409
|
+
* are important and should be protected from forgetting.
|
|
410
|
+
*
|
|
411
|
+
* Uses online averaging: F_new = alpha * F_old + (1-alpha) * F_current
|
|
412
|
+
*
|
|
413
|
+
* @param confidenceChanges - Array of {id, embedding, oldConf, newConf}
|
|
414
|
+
*/
|
|
415
|
+
EWCConsolidator.prototype.updateFisherFromConfidences = function (confidenceChanges) {
|
|
416
|
+
if (confidenceChanges.length === 0)
|
|
417
|
+
return;
|
|
418
|
+
var alpha = this.config.fisherDecayRate;
|
|
419
|
+
var currentFisher = new Array(this.config.dimensions).fill(0);
|
|
420
|
+
var sampleCount = 0;
|
|
421
|
+
for (var _i = 0, confidenceChanges_1 = confidenceChanges; _i < confidenceChanges_1.length; _i++) {
|
|
422
|
+
var change = confidenceChanges_1[_i];
|
|
423
|
+
if (!change.embedding || change.embedding.length === 0)
|
|
424
|
+
continue;
|
|
425
|
+
var confDelta = Math.abs(change.newConf - change.oldConf);
|
|
426
|
+
if (confDelta === 0)
|
|
427
|
+
continue;
|
|
428
|
+
sampleCount++;
|
|
429
|
+
var len = Math.min(change.embedding.length, this.config.dimensions);
|
|
430
|
+
// Squared gradient proxy: embedding scaled by confidence change magnitude
|
|
431
|
+
for (var i = 0; i < len; i++) {
|
|
432
|
+
var grad = change.embedding[i] * confDelta;
|
|
433
|
+
currentFisher[i] += grad * grad;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
if (sampleCount > 0) {
|
|
437
|
+
for (var i = 0; i < this.config.dimensions; i++) {
|
|
438
|
+
currentFisher[i] /= sampleCount;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
// Online EMA: F_new = alpha * F_old + (1-alpha) * F_current
|
|
442
|
+
for (var i = 0; i < this.config.dimensions; i++) {
|
|
443
|
+
this.globalFisher[i] = alpha * this.globalFisher[i] + (1 - alpha) * currentFisher[i];
|
|
444
|
+
}
|
|
445
|
+
this.saveToDisk();
|
|
446
|
+
};
|
|
447
|
+
/**
|
|
448
|
+
* Compute consolidation penalty for a proposed confidence update.
|
|
449
|
+
* Used by SONA to check whether a pattern update would cause forgetting.
|
|
450
|
+
*
|
|
451
|
+
* @param oldConfidence - Current confidence value
|
|
452
|
+
* @param newConfidence - Proposed new confidence value
|
|
453
|
+
* @returns Penalty value (higher = more forgetting risk)
|
|
454
|
+
*/
|
|
455
|
+
EWCConsolidator.prototype.computeConfidencePenalty = function (oldConfidence, newConfidence) {
|
|
456
|
+
// Use the global Fisher to estimate penalty for scalar confidence change
|
|
457
|
+
// Average Fisher value represents overall importance
|
|
458
|
+
var avgFisher = 0;
|
|
459
|
+
for (var i = 0; i < this.globalFisher.length; i++) {
|
|
460
|
+
avgFisher += this.globalFisher[i];
|
|
461
|
+
}
|
|
462
|
+
avgFisher = this.globalFisher.length > 0 ? avgFisher / this.globalFisher.length : 0;
|
|
463
|
+
var diff = newConfidence - oldConfidence;
|
|
464
|
+
return (this.config.lambda / 2) * avgFisher * diff * diff;
|
|
465
|
+
};
|
|
345
466
|
/**
|
|
346
467
|
* Clear all patterns and history (full reset)
|
|
347
468
|
*/
|
|
348
|
-
clear() {
|
|
469
|
+
EWCConsolidator.prototype.clear = function () {
|
|
349
470
|
this.patterns.clear();
|
|
350
471
|
this.gradientHistory = [];
|
|
351
472
|
this.globalFisher = new Array(this.config.dimensions).fill(0);
|
|
@@ -356,75 +477,79 @@ export class EWCConsolidator {
|
|
|
356
477
|
fs.unlinkSync(this.config.storagePath);
|
|
357
478
|
}
|
|
358
479
|
}
|
|
359
|
-
catch {
|
|
480
|
+
catch (_a) {
|
|
360
481
|
// Ignore deletion errors
|
|
361
482
|
}
|
|
362
|
-
}
|
|
483
|
+
};
|
|
363
484
|
// ============================================================================
|
|
364
485
|
// Private Methods
|
|
365
486
|
// ============================================================================
|
|
366
487
|
/**
|
|
367
488
|
* Calculate importance score for a pattern based on usage
|
|
368
489
|
*/
|
|
369
|
-
calculateImportance(pattern) {
|
|
370
|
-
|
|
490
|
+
EWCConsolidator.prototype.calculateImportance = function (pattern) {
|
|
491
|
+
var total = pattern.successCount + pattern.failureCount;
|
|
371
492
|
if (total === 0)
|
|
372
493
|
return 0.5;
|
|
373
494
|
// Success rate with Laplace smoothing
|
|
374
|
-
|
|
495
|
+
var successRate = (pattern.successCount + 1) / (total + 2);
|
|
375
496
|
// Recency factor: recent patterns are more important
|
|
376
|
-
|
|
377
|
-
|
|
497
|
+
var hoursSinceUpdate = (Date.now() - pattern.lastUpdated) / (1000 * 60 * 60);
|
|
498
|
+
var recencyFactor = Math.exp(-hoursSinceUpdate / 168); // 1 week half-life
|
|
378
499
|
// Combine factors
|
|
379
500
|
return successRate * 0.7 + recencyFactor * 0.3;
|
|
380
|
-
}
|
|
501
|
+
};
|
|
381
502
|
/**
|
|
382
503
|
* Blend old and new weights using Fisher-weighted interpolation
|
|
383
504
|
*/
|
|
384
|
-
blendWeights(oldWeights, newWeights, blendFactor, fisher) {
|
|
385
|
-
|
|
386
|
-
|
|
505
|
+
EWCConsolidator.prototype.blendWeights = function (oldWeights, newWeights, blendFactor, fisher) {
|
|
506
|
+
var len = Math.min(oldWeights.length, newWeights.length, this.config.dimensions);
|
|
507
|
+
var result = new Array(len);
|
|
387
508
|
// Normalize Fisher for per-weight blend factors
|
|
388
|
-
|
|
389
|
-
for (
|
|
509
|
+
var maxF = 0;
|
|
510
|
+
for (var i = 0; i < len; i++) {
|
|
390
511
|
if (fisher[i] > maxF)
|
|
391
512
|
maxF = fisher[i];
|
|
392
513
|
}
|
|
393
|
-
|
|
394
|
-
for (
|
|
514
|
+
var normFactor = maxF > 0 ? 1 / maxF : 1;
|
|
515
|
+
for (var i = 0; i < len; i++) {
|
|
395
516
|
// Higher Fisher = more weight on old value
|
|
396
|
-
|
|
397
|
-
|
|
517
|
+
var fisherWeight = fisher[i] * normFactor;
|
|
518
|
+
var adjustedBlend = blendFactor * (1 - fisherWeight * 0.5);
|
|
398
519
|
result[i] = oldWeights[i] * (1 - adjustedBlend) + newWeights[i] * adjustedBlend;
|
|
399
520
|
}
|
|
400
521
|
return result;
|
|
401
|
-
}
|
|
522
|
+
};
|
|
402
523
|
/**
|
|
403
524
|
* Prune old, low-importance patterns to stay within limit
|
|
404
525
|
*/
|
|
405
|
-
pruneOldPatterns() {
|
|
526
|
+
EWCConsolidator.prototype.pruneOldPatterns = function () {
|
|
527
|
+
var _this = this;
|
|
406
528
|
if (this.patterns.size <= this.config.maxPatterns)
|
|
407
529
|
return;
|
|
408
530
|
// Sort by importance (ascending)
|
|
409
|
-
|
|
410
|
-
.map((
|
|
411
|
-
|
|
531
|
+
var sortedPatterns = Array.from(this.patterns.entries())
|
|
532
|
+
.map(function (_a) {
|
|
533
|
+
var id = _a[0], pattern = _a[1];
|
|
534
|
+
return ({ id: id, importance: _this.calculateImportance(pattern) });
|
|
535
|
+
})
|
|
536
|
+
.sort(function (a, b) { return a.importance - b.importance; });
|
|
412
537
|
// Remove lowest importance patterns
|
|
413
|
-
|
|
414
|
-
for (
|
|
415
|
-
this.patterns
|
|
538
|
+
var toRemove = this.patterns.size - this.config.maxPatterns;
|
|
539
|
+
for (var i = 0; i < toRemove; i++) {
|
|
540
|
+
this.patterns["delete"](sortedPatterns[i].id);
|
|
416
541
|
}
|
|
417
|
-
}
|
|
542
|
+
};
|
|
418
543
|
/**
|
|
419
544
|
* Save state to disk
|
|
420
545
|
*/
|
|
421
|
-
saveToDisk() {
|
|
546
|
+
EWCConsolidator.prototype.saveToDisk = function () {
|
|
422
547
|
try {
|
|
423
|
-
|
|
548
|
+
var dir = path.dirname(this.config.storagePath);
|
|
424
549
|
if (!fs.existsSync(dir)) {
|
|
425
550
|
fs.mkdirSync(dir, { recursive: true });
|
|
426
551
|
}
|
|
427
|
-
|
|
552
|
+
var state = {
|
|
428
553
|
version: '1.0.0',
|
|
429
554
|
config: {
|
|
430
555
|
lambda: this.config.lambda,
|
|
@@ -438,56 +563,75 @@ export class EWCConsolidator {
|
|
|
438
563
|
};
|
|
439
564
|
fs.writeFileSync(this.config.storagePath, JSON.stringify(state, null, 2));
|
|
440
565
|
}
|
|
441
|
-
catch {
|
|
566
|
+
catch (_a) {
|
|
442
567
|
// Silently fail - persistence is best-effort
|
|
443
568
|
}
|
|
444
|
-
}
|
|
569
|
+
};
|
|
445
570
|
/**
|
|
446
571
|
* Load state from disk
|
|
447
572
|
*/
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
573
|
+
EWCConsolidator.prototype.loadFromDisk = function () {
|
|
574
|
+
var _a;
|
|
575
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
576
|
+
var content, state, _i, _b, _c, id, pattern;
|
|
577
|
+
return __generator(this, function (_d) {
|
|
578
|
+
if (!fs.existsSync(this.config.storagePath)) {
|
|
579
|
+
throw new Error('No persisted state found');
|
|
580
|
+
}
|
|
581
|
+
content = fs.readFileSync(this.config.storagePath, 'utf-8');
|
|
582
|
+
state = JSON.parse(content);
|
|
583
|
+
// Validate version
|
|
584
|
+
if (state.version !== '1.0.0') {
|
|
585
|
+
throw new Error("Unsupported state version: " + state.version);
|
|
586
|
+
}
|
|
587
|
+
// Restore state
|
|
588
|
+
this.globalFisher = state.globalFisher || new Array(this.config.dimensions).fill(0);
|
|
589
|
+
// Restore patterns
|
|
590
|
+
this.patterns.clear();
|
|
591
|
+
if (state.patterns) {
|
|
592
|
+
for (_i = 0, _b = state.patterns; _i < _b.length; _i++) {
|
|
593
|
+
_c = _b[_i], id = _c[0], pattern = _c[1];
|
|
594
|
+
this.patterns.set(id, pattern);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
// Restore history
|
|
598
|
+
this.consolidationHistory = state.consolidationHistory || [];
|
|
599
|
+
// Update config from persisted values
|
|
600
|
+
if (state.config) {
|
|
601
|
+
this.config.lambda = (_a = state.config.lambda) !== null && _a !== void 0 ? _a : this.config.lambda;
|
|
602
|
+
}
|
|
603
|
+
return [2 /*return*/];
|
|
604
|
+
});
|
|
605
|
+
});
|
|
606
|
+
};
|
|
607
|
+
return EWCConsolidator;
|
|
608
|
+
}());
|
|
609
|
+
export { EWCConsolidator };
|
|
475
610
|
// ============================================================================
|
|
476
611
|
// Singleton Instance
|
|
477
612
|
// ============================================================================
|
|
478
|
-
|
|
613
|
+
var ewcConsolidatorInstance = null;
|
|
479
614
|
/**
|
|
480
615
|
* Get the singleton EWC Consolidator instance
|
|
481
616
|
*
|
|
482
617
|
* @param config - Optional configuration overrides
|
|
483
618
|
* @returns EWC Consolidator instance
|
|
484
619
|
*/
|
|
485
|
-
export
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
620
|
+
export function getEWCConsolidator(config) {
|
|
621
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
622
|
+
return __generator(this, function (_a) {
|
|
623
|
+
switch (_a.label) {
|
|
624
|
+
case 0:
|
|
625
|
+
if (!!ewcConsolidatorInstance) return [3 /*break*/, 2];
|
|
626
|
+
ewcConsolidatorInstance = new EWCConsolidator(config);
|
|
627
|
+
return [4 /*yield*/, ewcConsolidatorInstance.initialize()];
|
|
628
|
+
case 1:
|
|
629
|
+
_a.sent();
|
|
630
|
+
_a.label = 2;
|
|
631
|
+
case 2: return [2 /*return*/, ewcConsolidatorInstance];
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
});
|
|
491
635
|
}
|
|
492
636
|
/**
|
|
493
637
|
* Reset the singleton instance (for testing)
|
|
@@ -508,9 +652,18 @@ export function resetEWCConsolidator() {
|
|
|
508
652
|
* @param newPatterns - New patterns to add
|
|
509
653
|
* @returns Consolidation result
|
|
510
654
|
*/
|
|
511
|
-
export
|
|
512
|
-
|
|
513
|
-
|
|
655
|
+
export function consolidatePatterns(newPatterns) {
|
|
656
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
657
|
+
var consolidator;
|
|
658
|
+
return __generator(this, function (_a) {
|
|
659
|
+
switch (_a.label) {
|
|
660
|
+
case 0: return [4 /*yield*/, getEWCConsolidator()];
|
|
661
|
+
case 1:
|
|
662
|
+
consolidator = _a.sent();
|
|
663
|
+
return [2 /*return*/, consolidator.consolidate(newPatterns)];
|
|
664
|
+
}
|
|
665
|
+
});
|
|
666
|
+
});
|
|
514
667
|
}
|
|
515
668
|
/**
|
|
516
669
|
* Record pattern usage outcome
|
|
@@ -520,23 +673,42 @@ export async function consolidatePatterns(newPatterns) {
|
|
|
520
673
|
* @param embedding - Pattern embedding (used as gradient proxy)
|
|
521
674
|
* @param success - Whether the pattern was successful
|
|
522
675
|
*/
|
|
523
|
-
export
|
|
524
|
-
|
|
525
|
-
|
|
676
|
+
export function recordPatternOutcome(patternId, embedding, success) {
|
|
677
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
678
|
+
var consolidator;
|
|
679
|
+
return __generator(this, function (_a) {
|
|
680
|
+
switch (_a.label) {
|
|
681
|
+
case 0: return [4 /*yield*/, getEWCConsolidator()];
|
|
682
|
+
case 1:
|
|
683
|
+
consolidator = _a.sent();
|
|
684
|
+
consolidator.recordGradient(patternId, embedding, success);
|
|
685
|
+
return [2 /*return*/];
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
});
|
|
526
689
|
}
|
|
527
690
|
/**
|
|
528
691
|
* Get EWC statistics
|
|
529
692
|
*/
|
|
530
|
-
export
|
|
531
|
-
|
|
532
|
-
|
|
693
|
+
export function getEWCStats() {
|
|
694
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
695
|
+
var consolidator;
|
|
696
|
+
return __generator(this, function (_a) {
|
|
697
|
+
switch (_a.label) {
|
|
698
|
+
case 0: return [4 /*yield*/, getEWCConsolidator()];
|
|
699
|
+
case 1:
|
|
700
|
+
consolidator = _a.sent();
|
|
701
|
+
return [2 /*return*/, consolidator.getConsolidationStats()];
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
});
|
|
533
705
|
}
|
|
534
706
|
export default {
|
|
535
|
-
EWCConsolidator,
|
|
536
|
-
getEWCConsolidator,
|
|
537
|
-
resetEWCConsolidator,
|
|
538
|
-
consolidatePatterns,
|
|
539
|
-
recordPatternOutcome,
|
|
540
|
-
getEWCStats
|
|
707
|
+
EWCConsolidator: EWCConsolidator,
|
|
708
|
+
getEWCConsolidator: getEWCConsolidator,
|
|
709
|
+
resetEWCConsolidator: resetEWCConsolidator,
|
|
710
|
+
consolidatePatterns: consolidatePatterns,
|
|
711
|
+
recordPatternOutcome: recordPatternOutcome,
|
|
712
|
+
getEWCStats: getEWCStats
|
|
541
713
|
};
|
|
542
714
|
//# sourceMappingURL=ewc-consolidation.js.map
|