@claude-flow/cli 3.21.0 → 3.22.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/helpers/auto-memory-hook.mjs +35 -3
- package/.claude/helpers/helpers.manifest.json +12 -0
- package/.claude/helpers/hook-handler.cjs +26 -5
- package/.claude/helpers/intelligence.cjs +4 -1
- package/dist/src/commands/daemon.js +23 -2
- package/dist/src/commands/doctor.js +56 -0
- package/dist/src/commands/memory-distill.d.ts +27 -0
- package/dist/src/commands/memory-distill.js +374 -0
- package/dist/src/commands/memory.js +4 -2
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +22 -1
- package/dist/src/init/executor.js +37 -0
- package/dist/src/init/helper-refresh.d.ts +19 -0
- package/dist/src/init/helper-refresh.js +175 -0
- package/dist/src/init/helper-signing.d.ts +30 -0
- package/dist/src/init/helper-signing.js +60 -0
- package/dist/src/init/helpers-generator.d.ts +16 -0
- package/dist/src/init/helpers-generator.js +89 -8
- package/dist/src/init/memory-package-resolver.d.ts +53 -0
- package/dist/src/init/memory-package-resolver.js +118 -0
- package/dist/src/init/statusline-generator.js +18 -7
- package/dist/src/mcp-client.js +13 -0
- package/dist/src/mcp-tools/agenticow-speculate-tools.js +9 -2
- package/dist/src/mcp-tools/browser-intent-tools.d.ts +162 -0
- package/dist/src/mcp-tools/browser-intent-tools.js +548 -0
- package/dist/src/mcp-tools/browser-tools.d.ts +9 -1
- package/dist/src/mcp-tools/browser-tools.js +4 -1
- package/dist/src/memory/memory-bridge.js +115 -54
- package/dist/src/memory/memory-initializer.d.ts +71 -0
- package/dist/src/memory/memory-initializer.js +330 -2
- package/dist/src/services/distill-tuning.d.ts +111 -0
- package/dist/src/services/distill-tuning.js +510 -0
- package/dist/src/services/memory-distillation.d.ts +41 -0
- package/dist/src/services/memory-distillation.js +277 -0
- package/dist/src/services/worker-daemon.d.ts +22 -1
- package/dist/src/services/worker-daemon.js +117 -6
- package/package.json +5 -2
- package/dist/src/agenticow/speculative-exploration.d.ts.map +0 -1
- package/dist/src/agenticow/speculative-exploration.js.map +0 -1
- package/dist/src/appliance/gguf-engine.d.ts.map +0 -1
- package/dist/src/appliance/gguf-engine.js.map +0 -1
- package/dist/src/appliance/ruvllm-bridge.d.ts.map +0 -1
- package/dist/src/appliance/ruvllm-bridge.js.map +0 -1
- package/dist/src/appliance/rvfa-builder.d.ts.map +0 -1
- package/dist/src/appliance/rvfa-builder.js.map +0 -1
- package/dist/src/appliance/rvfa-distribution.d.ts.map +0 -1
- package/dist/src/appliance/rvfa-distribution.js.map +0 -1
- package/dist/src/appliance/rvfa-format.d.ts.map +0 -1
- package/dist/src/appliance/rvfa-format.js.map +0 -1
- package/dist/src/appliance/rvfa-runner.d.ts.map +0 -1
- package/dist/src/appliance/rvfa-runner.js.map +0 -1
- package/dist/src/appliance/rvfa-signing.d.ts.map +0 -1
- package/dist/src/appliance/rvfa-signing.js.map +0 -1
- package/dist/src/autopilot-state.d.ts.map +0 -1
- package/dist/src/autopilot-state.js.map +0 -1
- package/dist/src/benchmarks/gaia-agent-planning.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-agent-planning.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-agent.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-agent.js.map +0 -1
- package/dist/src/benchmarks/gaia-causal-memory.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-causal-memory.js.map +0 -1
- package/dist/src/benchmarks/gaia-causal-memory.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-causal-memory.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-convergence.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-convergence.js.map +0 -1
- package/dist/src/benchmarks/gaia-convergence.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-convergence.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-critic.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-critic.js.map +0 -1
- package/dist/src/benchmarks/gaia-critic.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-critic.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-decomposer.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-decomposer.js.map +0 -1
- package/dist/src/benchmarks/gaia-decomposer.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-decomposer.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-e2e-smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-e2e-smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-extract.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-extract.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-hardness/features.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-hardness/features.js.map +0 -1
- package/dist/src/benchmarks/gaia-hardness/predictor.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-hardness/predictor.js.map +0 -1
- package/dist/src/benchmarks/gaia-hardness/predictor.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-hardness/predictor.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-hardness/train-data-loader.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-hardness/train-data-loader.js.map +0 -1
- package/dist/src/benchmarks/gaia-judge.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-judge.js.map +0 -1
- package/dist/src/benchmarks/gaia-loader.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-loader.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/file_read.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/file_read.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/grounded_query.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/grounded_query.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/index.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/index.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/types.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/types.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/web_search.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/web_search.js.map +0 -1
- package/dist/src/benchmarks/gaia-voting.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-voting.js.map +0 -1
- package/dist/src/benchmarks/gaia-voting.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-voting.smoke.js.map +0 -1
- package/dist/src/benchmarks/pretrain/index.d.ts.map +0 -1
- package/dist/src/benchmarks/pretrain/index.js.map +0 -1
- package/dist/src/business-pods/bbs-budget-tracker.d.ts.map +0 -1
- package/dist/src/business-pods/bbs-budget-tracker.js.map +0 -1
- package/dist/src/business-pods/domain-affinity-policy.d.ts.map +0 -1
- package/dist/src/business-pods/domain-affinity-policy.js.map +0 -1
- package/dist/src/business-pods/pod-schema.d.ts.map +0 -1
- package/dist/src/business-pods/pod-schema.js.map +0 -1
- package/dist/src/commands/agent-wasm.d.ts.map +0 -1
- package/dist/src/commands/agent-wasm.js.map +0 -1
- package/dist/src/commands/agent.d.ts.map +0 -1
- package/dist/src/commands/agent.js.map +0 -1
- package/dist/src/commands/analyze.d.ts.map +0 -1
- package/dist/src/commands/analyze.js.map +0 -1
- package/dist/src/commands/appliance-advanced.d.ts.map +0 -1
- package/dist/src/commands/appliance-advanced.js.map +0 -1
- package/dist/src/commands/appliance.d.ts.map +0 -1
- package/dist/src/commands/appliance.js.map +0 -1
- package/dist/src/commands/autopilot.d.ts.map +0 -1
- package/dist/src/commands/autopilot.js.map +0 -1
- package/dist/src/commands/benchmark.d.ts.map +0 -1
- package/dist/src/commands/benchmark.js.map +0 -1
- package/dist/src/commands/claims.d.ts.map +0 -1
- package/dist/src/commands/claims.js.map +0 -1
- package/dist/src/commands/cleanup.d.ts.map +0 -1
- package/dist/src/commands/cleanup.js.map +0 -1
- package/dist/src/commands/completions.d.ts.map +0 -1
- package/dist/src/commands/completions.js.map +0 -1
- package/dist/src/commands/config.d.ts.map +0 -1
- package/dist/src/commands/config.js.map +0 -1
- package/dist/src/commands/daemon.d.ts.map +0 -1
- package/dist/src/commands/daemon.js.map +0 -1
- package/dist/src/commands/deployment.d.ts.map +0 -1
- package/dist/src/commands/deployment.js.map +0 -1
- package/dist/src/commands/doctor.d.ts.map +0 -1
- package/dist/src/commands/doctor.js.map +0 -1
- package/dist/src/commands/eject.d.ts.map +0 -1
- package/dist/src/commands/eject.js.map +0 -1
- package/dist/src/commands/embeddings.d.ts.map +0 -1
- package/dist/src/commands/embeddings.js.map +0 -1
- package/dist/src/commands/gaia-bench.d.ts.map +0 -1
- package/dist/src/commands/gaia-bench.js.map +0 -1
- package/dist/src/commands/guidance.d.ts.map +0 -1
- package/dist/src/commands/guidance.js.map +0 -1
- package/dist/src/commands/hive-mind.d.ts.map +0 -1
- package/dist/src/commands/hive-mind.js.map +0 -1
- package/dist/src/commands/hooks.d.ts.map +0 -1
- package/dist/src/commands/hooks.js.map +0 -1
- package/dist/src/commands/index.d.ts.map +0 -1
- package/dist/src/commands/index.js.map +0 -1
- package/dist/src/commands/init.d.ts.map +0 -1
- package/dist/src/commands/init.js.map +0 -1
- package/dist/src/commands/issues.d.ts.map +0 -1
- package/dist/src/commands/issues.js.map +0 -1
- package/dist/src/commands/mcp.d.ts.map +0 -1
- package/dist/src/commands/mcp.js.map +0 -1
- package/dist/src/commands/memory.d.ts.map +0 -1
- package/dist/src/commands/memory.js.map +0 -1
- package/dist/src/commands/metaharness.d.ts.map +0 -1
- package/dist/src/commands/metaharness.js.map +0 -1
- package/dist/src/commands/migrate.d.ts.map +0 -1
- package/dist/src/commands/migrate.js.map +0 -1
- package/dist/src/commands/neural.d.ts.map +0 -1
- package/dist/src/commands/neural.js.map +0 -1
- package/dist/src/commands/performance.d.ts.map +0 -1
- package/dist/src/commands/performance.js.map +0 -1
- package/dist/src/commands/plugins.d.ts.map +0 -1
- package/dist/src/commands/plugins.js.map +0 -1
- package/dist/src/commands/process.d.ts.map +0 -1
- package/dist/src/commands/process.js.map +0 -1
- package/dist/src/commands/progress.d.ts.map +0 -1
- package/dist/src/commands/progress.js.map +0 -1
- package/dist/src/commands/providers.d.ts.map +0 -1
- package/dist/src/commands/providers.js.map +0 -1
- package/dist/src/commands/route.d.ts.map +0 -1
- package/dist/src/commands/route.js.map +0 -1
- package/dist/src/commands/ruvector/backup.d.ts.map +0 -1
- package/dist/src/commands/ruvector/backup.js.map +0 -1
- package/dist/src/commands/ruvector/benchmark.d.ts.map +0 -1
- package/dist/src/commands/ruvector/benchmark.js.map +0 -1
- package/dist/src/commands/ruvector/import.d.ts.map +0 -1
- package/dist/src/commands/ruvector/import.js.map +0 -1
- package/dist/src/commands/ruvector/index.d.ts.map +0 -1
- package/dist/src/commands/ruvector/index.js.map +0 -1
- package/dist/src/commands/ruvector/init.d.ts.map +0 -1
- package/dist/src/commands/ruvector/init.js.map +0 -1
- package/dist/src/commands/ruvector/migrate.d.ts.map +0 -1
- package/dist/src/commands/ruvector/migrate.js.map +0 -1
- package/dist/src/commands/ruvector/optimize.d.ts.map +0 -1
- package/dist/src/commands/ruvector/optimize.js.map +0 -1
- package/dist/src/commands/ruvector/pg-utils.d.ts.map +0 -1
- package/dist/src/commands/ruvector/pg-utils.js.map +0 -1
- package/dist/src/commands/ruvector/setup.d.ts.map +0 -1
- package/dist/src/commands/ruvector/setup.js.map +0 -1
- package/dist/src/commands/ruvector/status.d.ts.map +0 -1
- package/dist/src/commands/ruvector/status.js.map +0 -1
- package/dist/src/commands/security.d.ts.map +0 -1
- package/dist/src/commands/security.js.map +0 -1
- package/dist/src/commands/session.d.ts.map +0 -1
- package/dist/src/commands/session.js.map +0 -1
- package/dist/src/commands/start.d.ts.map +0 -1
- package/dist/src/commands/start.js.map +0 -1
- package/dist/src/commands/status.d.ts.map +0 -1
- package/dist/src/commands/status.js.map +0 -1
- package/dist/src/commands/swarm.d.ts.map +0 -1
- package/dist/src/commands/swarm.js.map +0 -1
- package/dist/src/commands/task.d.ts.map +0 -1
- package/dist/src/commands/task.js.map +0 -1
- package/dist/src/commands/transfer-store.d.ts.map +0 -1
- package/dist/src/commands/transfer-store.js.map +0 -1
- package/dist/src/commands/update.d.ts.map +0 -1
- package/dist/src/commands/update.js.map +0 -1
- package/dist/src/commands/verify.d.ts.map +0 -1
- package/dist/src/commands/verify.js.map +0 -1
- package/dist/src/commands/workflow.d.ts.map +0 -1
- package/dist/src/commands/workflow.js.map +0 -1
- package/dist/src/config-adapter.d.ts.map +0 -1
- package/dist/src/config-adapter.js.map +0 -1
- package/dist/src/encryption/vault.d.ts.map +0 -1
- package/dist/src/encryption/vault.js.map +0 -1
- package/dist/src/fs-secure.d.ts.map +0 -1
- package/dist/src/fs-secure.js.map +0 -1
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/infrastructure/in-memory-repositories.d.ts.map +0 -1
- package/dist/src/infrastructure/in-memory-repositories.js.map +0 -1
- package/dist/src/init/claudemd-generator.d.ts.map +0 -1
- package/dist/src/init/claudemd-generator.js.map +0 -1
- package/dist/src/init/executor.d.ts.map +0 -1
- package/dist/src/init/executor.js.map +0 -1
- package/dist/src/init/helpers-generator.d.ts.map +0 -1
- package/dist/src/init/helpers-generator.js.map +0 -1
- package/dist/src/init/index.d.ts.map +0 -1
- package/dist/src/init/index.js.map +0 -1
- package/dist/src/init/mcp-generator.d.ts.map +0 -1
- package/dist/src/init/mcp-generator.js.map +0 -1
- package/dist/src/init/settings-generator.d.ts.map +0 -1
- package/dist/src/init/settings-generator.js.map +0 -1
- package/dist/src/init/statusline-generator.d.ts.map +0 -1
- package/dist/src/init/statusline-generator.js.map +0 -1
- package/dist/src/init/types.d.ts.map +0 -1
- package/dist/src/init/types.js.map +0 -1
- package/dist/src/log-filters.d.ts.map +0 -1
- package/dist/src/log-filters.js.map +0 -1
- package/dist/src/mcp-client.d.ts.map +0 -1
- package/dist/src/mcp-client.js.map +0 -1
- package/dist/src/mcp-server.d.ts.map +0 -1
- package/dist/src/mcp-server.js.map +0 -1
- package/dist/src/mcp-tools/agent-execute-core.d.ts.map +0 -1
- package/dist/src/mcp-tools/agent-execute-core.js.map +0 -1
- package/dist/src/mcp-tools/agent-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/agent-tools.js.map +0 -1
- package/dist/src/mcp-tools/agentbbs-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/agentbbs-tools.js.map +0 -1
- package/dist/src/mcp-tools/agentdb-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/agentdb-tools.js.map +0 -1
- package/dist/src/mcp-tools/agenticow-loader.d.ts.map +0 -1
- package/dist/src/mcp-tools/agenticow-loader.js.map +0 -1
- package/dist/src/mcp-tools/agenticow-speculate-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/agenticow-speculate-tools.js.map +0 -1
- package/dist/src/mcp-tools/agenticow-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/agenticow-tools.js.map +0 -1
- package/dist/src/mcp-tools/analyze-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/analyze-tools.js.map +0 -1
- package/dist/src/mcp-tools/auto-install.d.ts.map +0 -1
- package/dist/src/mcp-tools/auto-install.js.map +0 -1
- package/dist/src/mcp-tools/autopilot-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/autopilot-tools.js.map +0 -1
- package/dist/src/mcp-tools/browser-session-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/browser-session-tools.js.map +0 -1
- package/dist/src/mcp-tools/browser-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/browser-tools.js.map +0 -1
- package/dist/src/mcp-tools/business-pod-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/business-pod-tools.js.map +0 -1
- package/dist/src/mcp-tools/claims-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/claims-tools.js.map +0 -1
- package/dist/src/mcp-tools/config-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/config-tools.js.map +0 -1
- package/dist/src/mcp-tools/coordination-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/coordination-tools.js.map +0 -1
- package/dist/src/mcp-tools/daa-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/daa-tools.js.map +0 -1
- package/dist/src/mcp-tools/embeddings-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/embeddings-tools.js.map +0 -1
- package/dist/src/mcp-tools/github-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/github-tools.js.map +0 -1
- package/dist/src/mcp-tools/guidance-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/guidance-tools.js.map +0 -1
- package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/hive-mind-tools.js.map +0 -1
- package/dist/src/mcp-tools/hooks-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/hooks-tools.js.map +0 -1
- package/dist/src/mcp-tools/http-fetch-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/http-fetch-tools.js.map +0 -1
- package/dist/src/mcp-tools/index.d.ts.map +0 -1
- package/dist/src/mcp-tools/index.js.map +0 -1
- package/dist/src/mcp-tools/managed-agent-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/managed-agent-tools.js.map +0 -1
- package/dist/src/mcp-tools/memory-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/memory-tools.js.map +0 -1
- package/dist/src/mcp-tools/metaharness-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/metaharness-tools.js.map +0 -1
- package/dist/src/mcp-tools/neural-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/neural-tools.js.map +0 -1
- package/dist/src/mcp-tools/performance-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/performance-tools.js.map +0 -1
- package/dist/src/mcp-tools/progress-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/progress-tools.js.map +0 -1
- package/dist/src/mcp-tools/request-tracker.d.ts.map +0 -1
- package/dist/src/mcp-tools/request-tracker.js.map +0 -1
- package/dist/src/mcp-tools/ruvllm-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/ruvllm-tools.js.map +0 -1
- package/dist/src/mcp-tools/security-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/security-tools.js.map +0 -1
- package/dist/src/mcp-tools/session-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/session-tools.js.map +0 -1
- package/dist/src/mcp-tools/swarm-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/swarm-tools.js.map +0 -1
- package/dist/src/mcp-tools/system-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/system-tools.js.map +0 -1
- package/dist/src/mcp-tools/task-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/task-tools.js.map +0 -1
- package/dist/src/mcp-tools/terminal-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/terminal-tools.js.map +0 -1
- package/dist/src/mcp-tools/testgen-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/testgen-tools.js.map +0 -1
- package/dist/src/mcp-tools/tool-loop-guardrail.d.ts.map +0 -1
- package/dist/src/mcp-tools/tool-loop-guardrail.js.map +0 -1
- package/dist/src/mcp-tools/transfer-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/transfer-tools.js.map +0 -1
- package/dist/src/mcp-tools/types.d.ts.map +0 -1
- package/dist/src/mcp-tools/types.js.map +0 -1
- package/dist/src/mcp-tools/validate-input.d.ts.map +0 -1
- package/dist/src/mcp-tools/validate-input.js.map +0 -1
- package/dist/src/mcp-tools/wasm-agent-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/wasm-agent-tools.js.map +0 -1
- package/dist/src/mcp-tools/workflow-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/workflow-tools.js.map +0 -1
- package/dist/src/memory/bge-embedder.d.ts.map +0 -1
- package/dist/src/memory/bge-embedder.js.map +0 -1
- package/dist/src/memory/cross-encoder-rerank.d.ts.map +0 -1
- package/dist/src/memory/cross-encoder-rerank.js.map +0 -1
- package/dist/src/memory/embedding-quantization.d.ts.map +0 -1
- package/dist/src/memory/embedding-quantization.js.map +0 -1
- package/dist/src/memory/ewc-consolidation.d.ts.map +0 -1
- package/dist/src/memory/ewc-consolidation.js.map +0 -1
- package/dist/src/memory/graph-edge-writer.d.ts.map +0 -1
- package/dist/src/memory/graph-edge-writer.js.map +0 -1
- package/dist/src/memory/hybrid-retrieval.d.ts.map +0 -1
- package/dist/src/memory/hybrid-retrieval.js.map +0 -1
- package/dist/src/memory/intelligence.d.ts.map +0 -1
- package/dist/src/memory/intelligence.js.map +0 -1
- package/dist/src/memory/lucene-bm25.d.ts.map +0 -1
- package/dist/src/memory/lucene-bm25.js.map +0 -1
- package/dist/src/memory/memory-bridge.d.ts.map +0 -1
- package/dist/src/memory/memory-bridge.js.map +0 -1
- package/dist/src/memory/memory-initializer.d.ts.map +0 -1
- package/dist/src/memory/memory-initializer.js.map +0 -1
- package/dist/src/memory/neural-package-bridge.d.ts.map +0 -1
- package/dist/src/memory/neural-package-bridge.js.map +0 -1
- package/dist/src/memory/rabitq-index.d.ts.map +0 -1
- package/dist/src/memory/rabitq-index.js.map +0 -1
- package/dist/src/memory/sona-optimizer.d.ts.map +0 -1
- package/dist/src/memory/sona-optimizer.js.map +0 -1
- package/dist/src/memory/structured-distill.d.ts.map +0 -1
- package/dist/src/memory/structured-distill.js.map +0 -1
- package/dist/src/output.d.ts.map +0 -1
- package/dist/src/output.js.map +0 -1
- package/dist/src/parser.d.ts.map +0 -1
- package/dist/src/parser.js.map +0 -1
- package/dist/src/plugins/manager.d.ts.map +0 -1
- package/dist/src/plugins/manager.js.map +0 -1
- package/dist/src/plugins/store/discovery.d.ts.map +0 -1
- package/dist/src/plugins/store/discovery.js.map +0 -1
- package/dist/src/plugins/store/index.d.ts.map +0 -1
- package/dist/src/plugins/store/index.js.map +0 -1
- package/dist/src/plugins/store/search.d.ts.map +0 -1
- package/dist/src/plugins/store/search.js.map +0 -1
- package/dist/src/plugins/store/types.d.ts.map +0 -1
- package/dist/src/plugins/store/types.js.map +0 -1
- package/dist/src/plugins/tests/demo-plugin-store.d.ts.map +0 -1
- package/dist/src/plugins/tests/demo-plugin-store.js.map +0 -1
- package/dist/src/plugins/tests/standalone-test.d.ts.map +0 -1
- package/dist/src/plugins/tests/standalone-test.js.map +0 -1
- package/dist/src/plugins/tests/test-plugin-store.d.ts.map +0 -1
- package/dist/src/plugins/tests/test-plugin-store.js.map +0 -1
- package/dist/src/production/circuit-breaker.d.ts.map +0 -1
- package/dist/src/production/circuit-breaker.js.map +0 -1
- package/dist/src/production/error-handler.d.ts.map +0 -1
- package/dist/src/production/error-handler.js.map +0 -1
- package/dist/src/production/index.d.ts.map +0 -1
- package/dist/src/production/index.js.map +0 -1
- package/dist/src/production/monitoring.d.ts.map +0 -1
- package/dist/src/production/monitoring.js.map +0 -1
- package/dist/src/production/rate-limiter.d.ts.map +0 -1
- package/dist/src/production/rate-limiter.js.map +0 -1
- package/dist/src/production/retry.d.ts.map +0 -1
- package/dist/src/production/retry.js.map +0 -1
- package/dist/src/prompt.d.ts.map +0 -1
- package/dist/src/prompt.js.map +0 -1
- package/dist/src/runtime/headless.d.ts.map +0 -1
- package/dist/src/runtime/headless.js.map +0 -1
- package/dist/src/runtime/parent-death-watchdog.d.ts.map +0 -1
- package/dist/src/runtime/parent-death-watchdog.js.map +0 -1
- package/dist/src/ruvector/agent-wasm.d.ts.map +0 -1
- package/dist/src/ruvector/agent-wasm.js.map +0 -1
- package/dist/src/ruvector/ast-analyzer.d.ts.map +0 -1
- package/dist/src/ruvector/ast-analyzer.js.map +0 -1
- package/dist/src/ruvector/codemods/engine.d.ts.map +0 -1
- package/dist/src/ruvector/codemods/engine.js.map +0 -1
- package/dist/src/ruvector/codemods/scope-analysis.d.ts.map +0 -1
- package/dist/src/ruvector/codemods/scope-analysis.js.map +0 -1
- package/dist/src/ruvector/coverage-router.d.ts.map +0 -1
- package/dist/src/ruvector/coverage-router.js.map +0 -1
- package/dist/src/ruvector/coverage-tools.d.ts.map +0 -1
- package/dist/src/ruvector/coverage-tools.js.map +0 -1
- package/dist/src/ruvector/diff-classifier.d.ts.map +0 -1
- package/dist/src/ruvector/diff-classifier.js.map +0 -1
- package/dist/src/ruvector/diskann-backend.d.ts.map +0 -1
- package/dist/src/ruvector/diskann-backend.js.map +0 -1
- package/dist/src/ruvector/enhanced-model-router.d.ts.map +0 -1
- package/dist/src/ruvector/enhanced-model-router.js.map +0 -1
- package/dist/src/ruvector/graph-analyzer.d.ts.map +0 -1
- package/dist/src/ruvector/graph-analyzer.js.map +0 -1
- package/dist/src/ruvector/graph-backend.d.ts.map +0 -1
- package/dist/src/ruvector/graph-backend.js.map +0 -1
- package/dist/src/ruvector/index.d.ts.map +0 -1
- package/dist/src/ruvector/index.js.map +0 -1
- package/dist/src/ruvector/lora-adapter.d.ts.map +0 -1
- package/dist/src/ruvector/lora-adapter.js.map +0 -1
- package/dist/src/ruvector/model-prices.d.ts.map +0 -1
- package/dist/src/ruvector/model-prices.js.map +0 -1
- package/dist/src/ruvector/model-router.d.ts.map +0 -1
- package/dist/src/ruvector/model-router.js.map +0 -1
- package/dist/src/ruvector/neural-router.d.ts.map +0 -1
- package/dist/src/ruvector/neural-router.js.map +0 -1
- package/dist/src/ruvector/output-verifier.d.ts.map +0 -1
- package/dist/src/ruvector/output-verifier.js.map +0 -1
- package/dist/src/ruvector/q-learning-router.d.ts.map +0 -1
- package/dist/src/ruvector/q-learning-router.js.map +0 -1
- package/dist/src/ruvector/router-calibrator.d.ts.map +0 -1
- package/dist/src/ruvector/router-calibrator.js.map +0 -1
- package/dist/src/ruvector/router-parallel-recorder.d.ts.map +0 -1
- package/dist/src/ruvector/router-parallel-recorder.js.map +0 -1
- package/dist/src/ruvector/router-trajectory.d.ts.map +0 -1
- package/dist/src/ruvector/router-trajectory.js.map +0 -1
- package/dist/src/ruvector/run-transcript-recorder.d.ts.map +0 -1
- package/dist/src/ruvector/run-transcript-recorder.js.map +0 -1
- package/dist/src/ruvector/ruvllm-wasm.d.ts.map +0 -1
- package/dist/src/ruvector/ruvllm-wasm.js.map +0 -1
- package/dist/src/ruvector/semantic-router.d.ts.map +0 -1
- package/dist/src/ruvector/semantic-router.js.map +0 -1
- package/dist/src/ruvector/task-embedder.d.ts.map +0 -1
- package/dist/src/ruvector/task-embedder.js.map +0 -1
- package/dist/src/ruvector/trajectory-tree.d.ts.map +0 -1
- package/dist/src/ruvector/trajectory-tree.js.map +0 -1
- package/dist/src/ruvector/vector-db.d.ts.map +0 -1
- package/dist/src/ruvector/vector-db.js.map +0 -1
- package/dist/src/services/agentic-flow-bridge.d.ts.map +0 -1
- package/dist/src/services/agentic-flow-bridge.js.map +0 -1
- package/dist/src/services/checkpoint-gate.d.ts.map +0 -1
- package/dist/src/services/checkpoint-gate.js.map +0 -1
- package/dist/src/services/claim-service.d.ts.map +0 -1
- package/dist/src/services/claim-service.js.map +0 -1
- package/dist/src/services/config-file-manager.d.ts.map +0 -1
- package/dist/src/services/config-file-manager.js.map +0 -1
- package/dist/src/services/container-worker-pool.d.ts.map +0 -1
- package/dist/src/services/container-worker-pool.js.map +0 -1
- package/dist/src/services/distill-oracle.d.ts.map +0 -1
- package/dist/src/services/distill-oracle.js.map +0 -1
- package/dist/src/services/fable-harness.d.ts.map +0 -1
- package/dist/src/services/fable-harness.js.map +0 -1
- package/dist/src/services/headless-worker-executor.d.ts.map +0 -1
- package/dist/src/services/headless-worker-executor.js.map +0 -1
- package/dist/src/services/index.d.ts.map +0 -1
- package/dist/src/services/index.js.map +0 -1
- package/dist/src/services/native-training.d.ts.map +0 -1
- package/dist/src/services/native-training.js.map +0 -1
- package/dist/src/services/registry-api.d.ts.map +0 -1
- package/dist/src/services/registry-api.js.map +0 -1
- package/dist/src/services/ruvector-training.d.ts.map +0 -1
- package/dist/src/services/ruvector-training.js.map +0 -1
- package/dist/src/services/swarm-memory-branches.d.ts.map +0 -1
- package/dist/src/services/swarm-memory-branches.js.map +0 -1
- package/dist/src/services/weight-eft.d.ts.map +0 -1
- package/dist/src/services/weight-eft.js.map +0 -1
- package/dist/src/services/worker-daemon.d.ts.map +0 -1
- package/dist/src/services/worker-daemon.js.map +0 -1
- package/dist/src/services/worker-queue.d.ts.map +0 -1
- package/dist/src/services/worker-queue.js.map +0 -1
- package/dist/src/suggest.d.ts.map +0 -1
- package/dist/src/suggest.js.map +0 -1
- package/dist/src/transfer/anonymization/index.d.ts.map +0 -1
- package/dist/src/transfer/anonymization/index.js.map +0 -1
- package/dist/src/transfer/deploy-seraphine.d.ts.map +0 -1
- package/dist/src/transfer/deploy-seraphine.js.map +0 -1
- package/dist/src/transfer/export.d.ts.map +0 -1
- package/dist/src/transfer/export.js.map +0 -1
- package/dist/src/transfer/index.d.ts.map +0 -1
- package/dist/src/transfer/index.js.map +0 -1
- package/dist/src/transfer/ipfs/client.d.ts.map +0 -1
- package/dist/src/transfer/ipfs/client.js.map +0 -1
- package/dist/src/transfer/ipfs/upload.d.ts.map +0 -1
- package/dist/src/transfer/ipfs/upload.js.map +0 -1
- package/dist/src/transfer/models/seraphine.d.ts.map +0 -1
- package/dist/src/transfer/models/seraphine.js.map +0 -1
- package/dist/src/transfer/serialization/cfp.d.ts.map +0 -1
- package/dist/src/transfer/serialization/cfp.js.map +0 -1
- package/dist/src/transfer/storage/gcs.d.ts.map +0 -1
- package/dist/src/transfer/storage/gcs.js.map +0 -1
- package/dist/src/transfer/storage/index.d.ts.map +0 -1
- package/dist/src/transfer/storage/index.js.map +0 -1
- package/dist/src/transfer/store/discovery.d.ts.map +0 -1
- package/dist/src/transfer/store/discovery.js.map +0 -1
- package/dist/src/transfer/store/download.d.ts.map +0 -1
- package/dist/src/transfer/store/download.js.map +0 -1
- package/dist/src/transfer/store/index.d.ts.map +0 -1
- package/dist/src/transfer/store/index.js.map +0 -1
- package/dist/src/transfer/store/publish.d.ts.map +0 -1
- package/dist/src/transfer/store/publish.js.map +0 -1
- package/dist/src/transfer/store/registry.d.ts.map +0 -1
- package/dist/src/transfer/store/registry.js.map +0 -1
- package/dist/src/transfer/store/search.d.ts.map +0 -1
- package/dist/src/transfer/store/search.js.map +0 -1
- package/dist/src/transfer/store/tests/standalone-test.d.ts.map +0 -1
- package/dist/src/transfer/store/tests/standalone-test.js.map +0 -1
- package/dist/src/transfer/store/types.d.ts.map +0 -1
- package/dist/src/transfer/store/types.js.map +0 -1
- package/dist/src/transfer/test-seraphine.d.ts.map +0 -1
- package/dist/src/transfer/test-seraphine.js.map +0 -1
- package/dist/src/transfer/tests/test-store.d.ts.map +0 -1
- package/dist/src/transfer/tests/test-store.js.map +0 -1
- package/dist/src/transfer/types.d.ts.map +0 -1
- package/dist/src/transfer/types.js.map +0 -1
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js.map +0 -1
- package/dist/src/update/checker.d.ts.map +0 -1
- package/dist/src/update/checker.js.map +0 -1
- package/dist/src/update/executor.d.ts.map +0 -1
- package/dist/src/update/executor.js.map +0 -1
- package/dist/src/update/index.d.ts.map +0 -1
- package/dist/src/update/index.js.map +0 -1
- package/dist/src/update/rate-limiter.d.ts.map +0 -1
- package/dist/src/update/rate-limiter.js.map +0 -1
- package/dist/src/update/validator.d.ts.map +0 -1
- package/dist/src/update/validator.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/scripts/beir-bootstrap-significance.mjs +0 -162
- package/scripts/bench-rvagent.mjs +0 -312
- package/scripts/benchmark-codemods.mjs +0 -127
- package/scripts/benchmark-cross-repo.mjs +0 -206
- package/scripts/benchmark-pretrained-retrieval.mjs +0 -305
- package/scripts/benchmark-self-learning.mjs +0 -241
- package/scripts/benchmark-trajectory-mrr.mjs +0 -191
- package/scripts/deploy-ipfs-node.sh +0 -153
- package/scripts/grid-search-retrieval.mjs +0 -216
- package/scripts/pretrain-from-github.mjs +0 -358
- package/scripts/publish-registry.ts +0 -345
- package/scripts/publish.sh +0 -57
- package/scripts/run-beir-bge.mjs +0 -324
- package/scripts/run-beir-hybrid.mjs +0 -284
- package/scripts/run-beir-lucene-bm25.mjs +0 -154
- package/scripts/run-beir-nfcorpus.mjs +0 -231
- package/scripts/run-beir-rrf-ablation.mjs +0 -221
- package/scripts/setup-ipfs-registry.md +0 -366
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// beir-bootstrap-significance.mjs — paired bootstrap significance test for
|
|
3
|
-
// BEIR retrieval results (ADR-086).
|
|
4
|
-
//
|
|
5
|
-
// Given a run JSON with per-query nDCG@10 and a baseline mean nDCG@10,
|
|
6
|
-
// estimates whether our result is significantly above the baseline.
|
|
7
|
-
//
|
|
8
|
-
// Method: paired bootstrap — resample N=10000 with replacement from our
|
|
9
|
-
// per-query nDCG scores, compute mean each time, take 2.5%-97.5% percentile
|
|
10
|
-
// for 95% CI. Compare baseline to our CI: if baseline < CI lower bound,
|
|
11
|
-
// the difference is significant at p < 0.05.
|
|
12
|
-
//
|
|
13
|
-
// For a paired test against ANOTHER per-query run (e.g. our pure-BM25 vs
|
|
14
|
-
// our BGE-base), resample paired DIFFERENCES instead. Pass --paired
|
|
15
|
-
// path/to/baseline-run.json.
|
|
16
|
-
//
|
|
17
|
-
// Usage:
|
|
18
|
-
// node scripts/beir-bootstrap-significance.mjs <run-json-path>
|
|
19
|
-
// node scripts/beir-bootstrap-significance.mjs <ours> --paired <baseline>
|
|
20
|
-
//
|
|
21
|
-
// Example:
|
|
22
|
-
// node scripts/beir-bootstrap-significance.mjs \
|
|
23
|
-
// docs/benchmarks/runs/beir-nfcorpus-bge-latest.json
|
|
24
|
-
|
|
25
|
-
import { readFileSync } from 'node:fs';
|
|
26
|
-
import { performance } from 'node:perf_hooks';
|
|
27
|
-
|
|
28
|
-
const args = process.argv.slice(2);
|
|
29
|
-
if (args.length === 0) {
|
|
30
|
-
console.error('Usage: node beir-bootstrap-significance.mjs <run-json> [--paired <baseline-run-json>]');
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
33
|
-
const RUN_PATH = args[0];
|
|
34
|
-
const PAIRED_IDX = args.indexOf('--paired');
|
|
35
|
-
const PAIRED_PATH = PAIRED_IDX > 0 ? args[PAIRED_IDX + 1] : null;
|
|
36
|
-
const ITERATIONS = Number(process.env.BOOTSTRAP_ITERATIONS) || 10000;
|
|
37
|
-
|
|
38
|
-
// Deterministic PRNG (Mulberry32) — so re-runs are reproducible.
|
|
39
|
-
const SEED = Number(process.env.BOOTSTRAP_SEED) || 42;
|
|
40
|
-
function mulberry32(a) {
|
|
41
|
-
return function () {
|
|
42
|
-
a |= 0; a = (a + 0x6D2B79F5) | 0;
|
|
43
|
-
let t = a;
|
|
44
|
-
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
45
|
-
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
46
|
-
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function mean(arr) { let s = 0; for (const v of arr) s += v; return s / arr.length; }
|
|
51
|
-
|
|
52
|
-
function percentile(sortedArr, p) {
|
|
53
|
-
const idx = Math.max(0, Math.min(sortedArr.length - 1, Math.floor(p * sortedArr.length)));
|
|
54
|
-
return sortedArr[idx];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function pointEstimate(scores) {
|
|
58
|
-
return {
|
|
59
|
-
mean: mean(scores),
|
|
60
|
-
n: scores.length,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function bootstrapCI(scores, iterations, rng, percentiles = [0.025, 0.975]) {
|
|
65
|
-
const means = new Float64Array(iterations);
|
|
66
|
-
const n = scores.length;
|
|
67
|
-
for (let i = 0; i < iterations; i++) {
|
|
68
|
-
let s = 0;
|
|
69
|
-
for (let j = 0; j < n; j++) s += scores[Math.floor(rng() * n)];
|
|
70
|
-
means[i] = s / n;
|
|
71
|
-
}
|
|
72
|
-
const sorted = Array.from(means).sort((a, b) => a - b);
|
|
73
|
-
return {
|
|
74
|
-
point: mean(scores),
|
|
75
|
-
lower: percentile(sorted, percentiles[0]),
|
|
76
|
-
upper: percentile(sorted, percentiles[1]),
|
|
77
|
-
p_value_vs_baseline_zero: null,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Paired bootstrap: compare our per-query scores to a baseline's per-query
|
|
82
|
-
// scores. Resample (idx) and average paired differences. The 95% CI on the
|
|
83
|
-
// mean difference tells us if it's significantly non-zero.
|
|
84
|
-
function pairedBootstrap(oursByQid, baselineByQid, iterations, rng) {
|
|
85
|
-
const sharedIds = [...oursByQid.keys()].filter((id) => baselineByQid.has(id));
|
|
86
|
-
const diffs = sharedIds.map((id) => oursByQid.get(id) - baselineByQid.get(id));
|
|
87
|
-
const n = diffs.length;
|
|
88
|
-
const means = new Float64Array(iterations);
|
|
89
|
-
for (let i = 0; i < iterations; i++) {
|
|
90
|
-
let s = 0;
|
|
91
|
-
for (let j = 0; j < n; j++) s += diffs[Math.floor(rng() * n)];
|
|
92
|
-
means[i] = s / n;
|
|
93
|
-
}
|
|
94
|
-
const sorted = Array.from(means).sort((a, b) => a - b);
|
|
95
|
-
// One-sided p ≈ fraction of resamples where mean diff ≤ 0
|
|
96
|
-
let negCount = 0;
|
|
97
|
-
for (const m of means) if (m <= 0) negCount++;
|
|
98
|
-
return {
|
|
99
|
-
n_paired: n,
|
|
100
|
-
point_diff: mean(diffs),
|
|
101
|
-
lower_95: percentile(sorted, 0.025),
|
|
102
|
-
upper_95: percentile(sorted, 0.975),
|
|
103
|
-
p_one_sided: negCount / iterations,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function loadRun(path) {
|
|
108
|
-
const data = JSON.parse(readFileSync(path, 'utf-8'));
|
|
109
|
-
if (!data.perQuery || !Array.isArray(data.perQuery)) {
|
|
110
|
-
console.error(`Run JSON at ${path} has no perQuery array — re-run the bench with the updated harness.`);
|
|
111
|
-
process.exit(2);
|
|
112
|
-
}
|
|
113
|
-
return data;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const ours = loadRun(RUN_PATH);
|
|
117
|
-
console.log(`# BEIR significance test (ADR-086)`);
|
|
118
|
-
console.log(`Run: ${RUN_PATH}`);
|
|
119
|
-
console.log(`Dataset: ${ours.dataset ?? '?'} Model: ${ours.model ?? '?'} Queries: ${ours.perQuery.length}`);
|
|
120
|
-
console.log(`Bootstrap: ${ITERATIONS} iterations, seed=${SEED}`);
|
|
121
|
-
|
|
122
|
-
const rng = mulberry32(SEED);
|
|
123
|
-
const ourScores = ours.perQuery.map((q) => q.ndcg10);
|
|
124
|
-
|
|
125
|
-
const t0 = performance.now();
|
|
126
|
-
const oursCI = bootstrapCI(ourScores, ITERATIONS, rng);
|
|
127
|
-
console.log(`\n=== Our nDCG@10 (1-sample bootstrap CI) ===`);
|
|
128
|
-
console.log(` point: ${oursCI.point.toFixed(4)}`);
|
|
129
|
-
console.log(` 95% CI: [${oursCI.lower.toFixed(4)}, ${oursCI.upper.toFixed(4)}]`);
|
|
130
|
-
|
|
131
|
-
if (ours.baselines) {
|
|
132
|
-
console.log(`\n=== vs each published baseline (CI overlap) ===`);
|
|
133
|
-
for (const [name, score] of Object.entries(ours.baselines)) {
|
|
134
|
-
const ciDiff = oursCI.point - score;
|
|
135
|
-
const lowerDiff = oursCI.lower - score;
|
|
136
|
-
const upperDiff = oursCI.upper - score;
|
|
137
|
-
const direction = ciDiff > 0 ? '↑ above' : '↓ below';
|
|
138
|
-
const sig = (lowerDiff > 0 && upperDiff > 0) ? 'p<0.05 (95% CI excludes baseline)'
|
|
139
|
-
: (lowerDiff < 0 && upperDiff < 0) ? 'p<0.05 (95% CI below baseline)'
|
|
140
|
-
: 'n.s. (95% CI overlaps baseline)';
|
|
141
|
-
console.log(` ${score.toFixed(3)} ${name.padEnd(28)} Δ=${ciDiff >= 0 ? '+' : ''}${ciDiff.toFixed(4)} ${direction} [${sig}]`);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (PAIRED_PATH) {
|
|
146
|
-
const baseline = loadRun(PAIRED_PATH);
|
|
147
|
-
console.log(`\n=== Paired bootstrap vs ${PAIRED_PATH} ===`);
|
|
148
|
-
const oursByQid = new Map(ours.perQuery.map((q) => [q.qid, q.ndcg10]));
|
|
149
|
-
const baseByQid = new Map(baseline.perQuery.map((q) => [q.qid, q.ndcg10]));
|
|
150
|
-
const rng2 = mulberry32(SEED + 1);
|
|
151
|
-
const paired = pairedBootstrap(oursByQid, baseByQid, ITERATIONS, rng2);
|
|
152
|
-
console.log(` paired queries: ${paired.n_paired}`);
|
|
153
|
-
console.log(` Δ (ours - baseline): ${paired.point_diff >= 0 ? '+' : ''}${paired.point_diff.toFixed(4)}`);
|
|
154
|
-
console.log(` 95% CI: [${paired.lower_95.toFixed(4)}, ${paired.upper_95.toFixed(4)}]`);
|
|
155
|
-
console.log(` one-sided p (Δ ≤ 0): ${paired.p_one_sided.toFixed(4)}`);
|
|
156
|
-
const sig = paired.lower_95 > 0 ? 'SIGNIFICANT improvement (p<0.025 one-sided)' :
|
|
157
|
-
paired.upper_95 < 0 ? 'SIGNIFICANT regression (p<0.025 one-sided)' :
|
|
158
|
-
'NOT SIGNIFICANT — CI overlaps zero';
|
|
159
|
-
console.log(` verdict: ${sig}`);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
console.log(`\nBootstrap took ${((performance.now() - t0) / 1000).toFixed(1)}s.`);
|
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* ADR-129 rvagent benchmark suite.
|
|
4
|
-
*
|
|
5
|
-
* Measures the four performance wins introduced by ADR-129 Phases 1–4:
|
|
6
|
-
*
|
|
7
|
-
* P1 — Provider routing latency (JsModelProvider wiring).
|
|
8
|
-
* Compares echo-stub round-trip (keyless baseline) against provider
|
|
9
|
-
* attachment overhead (measured with a fake key that will 401 — we
|
|
10
|
-
* capture the latency to the WASM call boundary, not the network hop).
|
|
11
|
-
*
|
|
12
|
-
* P2 — wasm_agent_compose throughput with N=10/50/100 MCP tools.
|
|
13
|
-
* Shows cost of allowlist validation + descriptor building at scale.
|
|
14
|
-
*
|
|
15
|
-
* P3 — Gallery CRUD throughput: add → list → import → export → remove.
|
|
16
|
-
* Validates that the 10 new gallery operations land in <1 ms each.
|
|
17
|
-
*
|
|
18
|
-
* P4 — Plugin enumeration overhead: wasm_agent_compose with/without
|
|
19
|
-
* includePlugins. Measures manifest-lookup cost when the plugin
|
|
20
|
-
* directory does not exist (graceful no-op path).
|
|
21
|
-
*
|
|
22
|
-
* Output: docs/benchmarks/rvagent-baseline.json
|
|
23
|
-
*
|
|
24
|
-
* Usage:
|
|
25
|
-
* node v3/@claude-flow/cli/scripts/bench-rvagent.mjs [--tag=baseline] [--trials=5]
|
|
26
|
-
*
|
|
27
|
-
* Pattern: mirrors v3/@claude-flow/guidance/scripts/bench-phase-1.mjs.
|
|
28
|
-
* Standalone — does NOT require the test runner, only Node ≥20 + the WASM
|
|
29
|
-
* package (@ruvector/rvagent-wasm must be installed for realistic numbers;
|
|
30
|
-
* the bench gracefully degrades to timing the WASM-unavailable error path).
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
import { performance } from 'node:perf_hooks';
|
|
34
|
-
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
35
|
-
import { fileURLToPath } from 'node:url';
|
|
36
|
-
import { dirname, resolve } from 'node:path';
|
|
37
|
-
|
|
38
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
39
|
-
const REPO_ROOT = resolve(__dirname, '../../../..');
|
|
40
|
-
const OUT_DIR = resolve(REPO_ROOT, 'docs', 'benchmarks');
|
|
41
|
-
|
|
42
|
-
const args = Object.fromEntries(
|
|
43
|
-
process.argv.slice(2).map(a => {
|
|
44
|
-
const [k, v] = a.replace(/^--/, '').split('=');
|
|
45
|
-
return [k, v ?? true];
|
|
46
|
-
}),
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
const TAG = args.tag || 'baseline';
|
|
50
|
-
const TRIALS = Math.max(3, parseInt(args.trials || '5', 10));
|
|
51
|
-
|
|
52
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
53
|
-
// Timing harness — 5-trial median, same as bench-phase-1.mjs
|
|
54
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Time N async calls (or sync if fn returns non-Promise), return median ms.
|
|
58
|
-
*/
|
|
59
|
-
async function bench(name, fn, reps = 20) {
|
|
60
|
-
// Warmup — trigger any lazy init so it doesn't inflate the first trial.
|
|
61
|
-
for (let i = 0; i < Math.min(3, reps); i++) {
|
|
62
|
-
try { await fn(); } catch { /* ignore warmup errors */ }
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const latencies = [];
|
|
66
|
-
for (let t = 0; t < TRIALS; t++) {
|
|
67
|
-
const start = performance.now();
|
|
68
|
-
for (let i = 0; i < reps; i++) {
|
|
69
|
-
try { await fn(); } catch { /* measure call overhead, not success */ }
|
|
70
|
-
}
|
|
71
|
-
latencies.push((performance.now() - start) / reps);
|
|
72
|
-
}
|
|
73
|
-
latencies.sort((a, b) => a - b);
|
|
74
|
-
const median = latencies[Math.floor(TRIALS / 2)];
|
|
75
|
-
const min = latencies[0];
|
|
76
|
-
const max = latencies[TRIALS - 1];
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
name,
|
|
80
|
-
trials: TRIALS,
|
|
81
|
-
reps,
|
|
82
|
-
medianMs: Math.round(median * 1000) / 1000,
|
|
83
|
-
minMs: Math.round(min * 1000) / 1000,
|
|
84
|
-
maxMs: Math.round(max * 1000) / 1000,
|
|
85
|
-
variance: Math.round(((max - min) / (median || 1)) * 1000) / 1000,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
90
|
-
// Load the live agent-wasm module (dist preferred, src fallback)
|
|
91
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
92
|
-
|
|
93
|
-
// dist layout: dist/src/**/*.js (tsc rootDir=.)
|
|
94
|
-
const DIST_SRC = resolve(__dirname, '../dist/src');
|
|
95
|
-
let wasmMod;
|
|
96
|
-
try {
|
|
97
|
-
wasmMod = await import(resolve(DIST_SRC, 'ruvector/agent-wasm.js'));
|
|
98
|
-
} catch {
|
|
99
|
-
console.warn('[bench] Could not load agent-wasm dist — using stub metrics only.');
|
|
100
|
-
wasmMod = null;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Load the wasm tools module to bench wasm_agent_compose handler directly
|
|
104
|
-
let composeHandler;
|
|
105
|
-
let galleryHandlers = {};
|
|
106
|
-
try {
|
|
107
|
-
const toolsMod = await import(resolve(DIST_SRC, 'mcp-tools/wasm-agent-tools.js'));
|
|
108
|
-
const tools = toolsMod.wasmAgentTools ?? toolsMod.default ?? [];
|
|
109
|
-
const findHandler = (name) => tools.find(t => t.name === name)?.handler;
|
|
110
|
-
composeHandler = findHandler('wasm_agent_compose');
|
|
111
|
-
galleryHandlers = {
|
|
112
|
-
add: findHandler('wasm_gallery_add_custom'),
|
|
113
|
-
list: findHandler('wasm_gallery_list'),
|
|
114
|
-
importFn: findHandler('wasm_gallery_import'),
|
|
115
|
-
exportFn: findHandler('wasm_gallery_export'),
|
|
116
|
-
remove: findHandler('wasm_gallery_remove_custom'),
|
|
117
|
-
categories: findHandler('wasm_gallery_categories'),
|
|
118
|
-
listByCategory: findHandler('wasm_gallery_list_by_category'),
|
|
119
|
-
loadRvf: findHandler('wasm_gallery_load_rvf'),
|
|
120
|
-
active: findHandler('wasm_gallery_active'),
|
|
121
|
-
config: findHandler('wasm_gallery_config'),
|
|
122
|
-
};
|
|
123
|
-
} catch {
|
|
124
|
-
// Handlers unavailable — bench will time the missing-module error path.
|
|
125
|
-
composeHandler = null;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
129
|
-
// P1 — Provider routing latency
|
|
130
|
-
//
|
|
131
|
-
// Baseline: echo-stub path (no keys set) — measures raw WASM call overhead.
|
|
132
|
-
// Provider: createWasmAgent with a fake ANTHROPIC_API_KEY. The key is 401'd
|
|
133
|
-
// by the Anthropic API before any tokens are billed, but the routing
|
|
134
|
-
// logic (attachJsModelProvider, JsModelProvider instantiation, provider
|
|
135
|
-
// lookup) runs synchronously before the network call. We measure the
|
|
136
|
-
// in-process portion only by timing createWasmAgent + promptWasmAgent
|
|
137
|
-
// with a deliberately short input and catching the 401 network error.
|
|
138
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
139
|
-
|
|
140
|
-
const originalKey = process.env.ANTHROPIC_API_KEY;
|
|
141
|
-
|
|
142
|
-
console.log('\nADR-129 rvagent benchmark suite');
|
|
143
|
-
console.log('================================');
|
|
144
|
-
console.log(`tag=${TAG} trials=${TRIALS} node=${process.version}`);
|
|
145
|
-
console.log('');
|
|
146
|
-
|
|
147
|
-
// P1a — echo-stub baseline (no key)
|
|
148
|
-
console.log('P1a: provider routing — echo-stub baseline (keyless)...');
|
|
149
|
-
delete process.env.ANTHROPIC_API_KEY;
|
|
150
|
-
delete process.env.OPENROUTER_API_KEY;
|
|
151
|
-
delete process.env.OLLAMA_API_KEY;
|
|
152
|
-
|
|
153
|
-
const r_p1_echo = await bench('P1-echo-stub: createWasmAgent (keyless)', async () => {
|
|
154
|
-
if (!wasmMod) return; // module unavailable — timing the absence
|
|
155
|
-
try {
|
|
156
|
-
const info = await wasmMod.createWasmAgent({ maxTurns: 1 });
|
|
157
|
-
wasmMod.terminateWasmAgent(info.id);
|
|
158
|
-
} catch { /* WASM unavailable is expected in keyless CI */ }
|
|
159
|
-
}, 5);
|
|
160
|
-
|
|
161
|
-
// P1b — provider-path: fake key triggers attachJsModelProvider logic
|
|
162
|
-
console.log('P1b: provider routing — with fake key (measures attach overhead)...');
|
|
163
|
-
process.env.ANTHROPIC_API_KEY = 'sk-ant-bench-fake-key-00000000000000000000000000';
|
|
164
|
-
|
|
165
|
-
const r_p1_provider = await bench('P1-provider-path: createWasmAgent (fake key)', async () => {
|
|
166
|
-
if (!wasmMod) return;
|
|
167
|
-
try {
|
|
168
|
-
const info = await wasmMod.createWasmAgent({ maxTurns: 1 });
|
|
169
|
-
wasmMod.terminateWasmAgent(info.id);
|
|
170
|
-
} catch { /* 401 expected */ }
|
|
171
|
-
}, 5);
|
|
172
|
-
|
|
173
|
-
// Restore original key state
|
|
174
|
-
if (originalKey !== undefined) {
|
|
175
|
-
process.env.ANTHROPIC_API_KEY = originalKey;
|
|
176
|
-
} else {
|
|
177
|
-
delete process.env.ANTHROPIC_API_KEY;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
181
|
-
// P2 — wasm_agent_compose throughput with N=10/50/100 MCP tools
|
|
182
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
183
|
-
|
|
184
|
-
console.log('P2: compose throughput — N=10/50/100 MCP tools...');
|
|
185
|
-
|
|
186
|
-
function makeMcpToolList(n) {
|
|
187
|
-
return Array.from({ length: n }, (_, i) => `memory_search_${i % 30 === 0 ? i : 'search'}`);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
async function timeCompose(toolCount) {
|
|
191
|
-
if (!composeHandler) return null;
|
|
192
|
-
const tools = makeMcpToolList(toolCount);
|
|
193
|
-
return bench(`P2-compose: ${toolCount} MCP tools`, async () => {
|
|
194
|
-
await composeHandler({ mcpTools: tools, skills: [], prompts: [], tools: [] });
|
|
195
|
-
}, 10);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const r_p2_10 = await timeCompose(10);
|
|
199
|
-
const r_p2_50 = await timeCompose(50);
|
|
200
|
-
const r_p2_100 = await timeCompose(100);
|
|
201
|
-
|
|
202
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
203
|
-
// P3 — Gallery CRUD throughput: full add → list → import → export → remove cycle
|
|
204
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
205
|
-
|
|
206
|
-
console.log('P3: gallery CRUD — add/list/import/export/remove cycle...');
|
|
207
|
-
|
|
208
|
-
const CUSTOM_TEMPLATE = JSON.stringify({
|
|
209
|
-
id: 'bench-custom-1',
|
|
210
|
-
name: 'bench-template',
|
|
211
|
-
description: 'Benchmark custom template',
|
|
212
|
-
category: 'testing',
|
|
213
|
-
tags: ['bench'],
|
|
214
|
-
version: '0.1.0',
|
|
215
|
-
author: 'bench',
|
|
216
|
-
builtin: false,
|
|
217
|
-
tools: [],
|
|
218
|
-
prompts: [],
|
|
219
|
-
skills: [],
|
|
220
|
-
mcp_tools: [],
|
|
221
|
-
capabilities: [],
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
const r_p3_cycle = await bench('P3-gallery-crud: add→list→import→export→remove', async () => {
|
|
225
|
-
const fns = galleryHandlers;
|
|
226
|
-
if (fns.add) await fns.add({ template: JSON.parse(CUSTOM_TEMPLATE) }).catch(() => {});
|
|
227
|
-
if (fns.list) await fns.list({}).catch(() => {});
|
|
228
|
-
if (fns.importFn) await fns.importFn({ templatesJson: `[${CUSTOM_TEMPLATE}]` }).catch(() => {});
|
|
229
|
-
if (fns.exportFn) await fns.exportFn({}).catch(() => {});
|
|
230
|
-
if (fns.remove) await fns.remove({ id: 'bench-custom-1' }).catch(() => {});
|
|
231
|
-
}, 5);
|
|
232
|
-
|
|
233
|
-
const r_p3_categories = await bench('P3-gallery-categories: getCategories', async () => {
|
|
234
|
-
if (galleryHandlers.categories) await galleryHandlers.categories({}).catch(() => {});
|
|
235
|
-
}, 10);
|
|
236
|
-
|
|
237
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
238
|
-
// P4 — Plugin enumeration: compose with/without includePlugins
|
|
239
|
-
//
|
|
240
|
-
// Tests the manifest-lookup path for plugins that don't exist on disk
|
|
241
|
-
// (graceful no-op / warning). This measures that skipping absent plugins
|
|
242
|
-
// doesn't add significant overhead.
|
|
243
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
244
|
-
|
|
245
|
-
console.log('P4: plugin enumeration — compose with/without includePlugins...');
|
|
246
|
-
|
|
247
|
-
const r_p4_without = await bench('P4-plugin-enum: compose WITHOUT includePlugins', async () => {
|
|
248
|
-
if (!composeHandler) return;
|
|
249
|
-
await composeHandler({ mcpTools: ['memory_search'], skills: [], prompts: [], tools: [] });
|
|
250
|
-
}, 10);
|
|
251
|
-
|
|
252
|
-
const r_p4_with = await bench('P4-plugin-enum: compose WITH includePlugins (absent plugins)', async () => {
|
|
253
|
-
if (!composeHandler) return;
|
|
254
|
-
await composeHandler({
|
|
255
|
-
mcpTools: ['memory_search'],
|
|
256
|
-
includePlugins: ['nonexistent-plugin-a', 'nonexistent-plugin-b'],
|
|
257
|
-
skills: [],
|
|
258
|
-
prompts: [],
|
|
259
|
-
tools: [],
|
|
260
|
-
});
|
|
261
|
-
}, 10);
|
|
262
|
-
|
|
263
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
264
|
-
// Emit results
|
|
265
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
266
|
-
|
|
267
|
-
const results = [
|
|
268
|
-
r_p1_echo,
|
|
269
|
-
r_p1_provider,
|
|
270
|
-
r_p2_10,
|
|
271
|
-
r_p2_50,
|
|
272
|
-
r_p2_100,
|
|
273
|
-
r_p3_cycle,
|
|
274
|
-
r_p3_categories,
|
|
275
|
-
r_p4_without,
|
|
276
|
-
r_p4_with,
|
|
277
|
-
].filter(Boolean);
|
|
278
|
-
|
|
279
|
-
const out = {
|
|
280
|
-
tag: TAG,
|
|
281
|
-
trials: TRIALS,
|
|
282
|
-
node: process.version,
|
|
283
|
-
platform: `${process.platform}-${process.arch}`,
|
|
284
|
-
capturedAt: new Date().toISOString(),
|
|
285
|
-
adr: 'ADR-129',
|
|
286
|
-
phases: ['P1-provider-routing', 'P2-compose-throughput', 'P3-gallery-crud', 'P4-plugin-enum'],
|
|
287
|
-
results,
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
mkdirSync(OUT_DIR, { recursive: true });
|
|
291
|
-
const outPath = resolve(OUT_DIR, `rvagent-${TAG}.json`);
|
|
292
|
-
writeFileSync(outPath, JSON.stringify(out, null, 2));
|
|
293
|
-
|
|
294
|
-
console.log(`\nWrote ${outPath}\n`);
|
|
295
|
-
|
|
296
|
-
const COL_NAME = 52;
|
|
297
|
-
const COL_MS = 10;
|
|
298
|
-
const COL_VAR = 8;
|
|
299
|
-
|
|
300
|
-
console.log(`| ${'Benchmark'.padEnd(COL_NAME)} | ${'Median ms'.padStart(COL_MS)} | ${'Variance'.padStart(COL_VAR)} |`);
|
|
301
|
-
console.log(`|${'-'.repeat(COL_NAME + 2)}|${'-'.repeat(COL_MS + 2)}|${'-'.repeat(COL_VAR + 2)}|`);
|
|
302
|
-
|
|
303
|
-
for (const r of results) {
|
|
304
|
-
const name = r.name.padEnd(COL_NAME).slice(0, COL_NAME);
|
|
305
|
-
const ms = String(r.medianMs).padStart(COL_MS);
|
|
306
|
-
const vari = String(r.variance).padStart(COL_VAR);
|
|
307
|
-
console.log(`| ${name} | ${ms} | ${vari} |`);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
console.log('');
|
|
311
|
-
console.log('Note: ms values measure in-process overhead including WASM unavailable error path.');
|
|
312
|
-
console.log('When @ruvector/rvagent-wasm is not installed, timings reflect the import error cost only.');
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// benchmark-codemods.mjs — measured benchmark for deterministic Tier-1 codemods (ADR-143).
|
|
3
|
-
//
|
|
4
|
-
// Runs every case in bench/codemod-corpus.json through applyCodemod() and records:
|
|
5
|
-
// - correctness vs the golden `expected` output
|
|
6
|
-
// - latency (avg / p50 / p99 / max)
|
|
7
|
-
// - cost: $0 measured (no API call) + estimated savings vs an LLM edit
|
|
8
|
-
//
|
|
9
|
-
// Writes a run JSON (tagged summary.benchmark="codemod-tier1") into the
|
|
10
|
-
// cost-tracker plugin's runs dir, which is exactly what `cost-trend` reads:
|
|
11
|
-
// plugins/ruflo-cost-tracker/docs/benchmarks/runs/codemod-<timestamp>.json
|
|
12
|
-
// View the series with: BENCH_NAME=codemod-tier1 node scripts/trend.mjs
|
|
13
|
-
//
|
|
14
|
-
// Usage:
|
|
15
|
-
// node scripts/benchmark-codemods.mjs # build dist first (npm run build)
|
|
16
|
-
// BENCH_JSON=1 node scripts/benchmark-codemods.mjs # machine-readable JSON to stdout
|
|
17
|
-
// BENCH_NO_WRITE=1 node scripts/benchmark-codemods.mjs # don't write a run file
|
|
18
|
-
|
|
19
|
-
import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
20
|
-
import { fileURLToPath } from 'node:url';
|
|
21
|
-
import { dirname, join, resolve } from 'node:path';
|
|
22
|
-
import { performance } from 'node:perf_hooks';
|
|
23
|
-
|
|
24
|
-
const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
|
|
25
|
-
const CLI_ROOT = resolve(SCRIPT_DIR, '..');
|
|
26
|
-
const REPO_ROOT = resolve(SCRIPT_DIR, '../../../..');
|
|
27
|
-
// Write to the cost-tracker plugin's runs dir — the exact path `cost-trend` reads.
|
|
28
|
-
const RUNS_DIR = join(REPO_ROOT, 'plugins', 'ruflo-cost-tracker', 'docs', 'benchmarks', 'runs');
|
|
29
|
-
|
|
30
|
-
// Estimated per-edit LLM cost (USD). Documented estimates, NOT a live call —
|
|
31
|
-
// used only to express the savings of a $0 deterministic codemod.
|
|
32
|
-
const LLM_EDIT_COST = { haiku: 0.0002, sonnet: 0.003, opus: 0.015 };
|
|
33
|
-
|
|
34
|
-
function percentile(sorted, p) {
|
|
35
|
-
if (sorted.length === 0) return 0;
|
|
36
|
-
const idx = Math.min(sorted.length - 1, Math.floor((p / 100) * sorted.length));
|
|
37
|
-
return sorted[idx];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function main() {
|
|
41
|
-
const { applyCodemod } = await import('../dist/src/ruvector/codemods/engine.js');
|
|
42
|
-
const corpus = JSON.parse(readFileSync(join(CLI_ROOT, 'bench', 'codemod-corpus.json'), 'utf-8'));
|
|
43
|
-
const cases = corpus.cases;
|
|
44
|
-
|
|
45
|
-
const results = [];
|
|
46
|
-
const latencies = [];
|
|
47
|
-
let correct = 0;
|
|
48
|
-
|
|
49
|
-
for (const c of cases) {
|
|
50
|
-
const t0 = performance.now();
|
|
51
|
-
const r = applyCodemod(c.intent, c.code, { language: c.language });
|
|
52
|
-
const latencyMs = performance.now() - t0;
|
|
53
|
-
latencies.push(latencyMs);
|
|
54
|
-
const ok = r.success && r.output === c.expected;
|
|
55
|
-
if (ok) correct++;
|
|
56
|
-
results.push({
|
|
57
|
-
id: c.id, intent: c.intent, correct: ok, changed: r.changed,
|
|
58
|
-
edits: r.edits, latencyMs: Number(latencyMs.toFixed(4)),
|
|
59
|
-
...(ok ? {} : { gotPrefix: (r.output ?? '').slice(0, 80), reason: r.reason }),
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const sorted = [...latencies].sort((a, b) => a - b);
|
|
64
|
-
const avg = latencies.reduce((s, x) => s + x, 0) / latencies.length;
|
|
65
|
-
const winRate = correct / cases.length;
|
|
66
|
-
const estSavings = {
|
|
67
|
-
vsHaiku: Number((LLM_EDIT_COST.haiku * cases.length).toFixed(6)),
|
|
68
|
-
vsSonnet: Number((LLM_EDIT_COST.sonnet * cases.length).toFixed(6)),
|
|
69
|
-
vsOpus: Number((LLM_EDIT_COST.opus * cases.length).toFixed(6)),
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const summary = {
|
|
73
|
-
runAt: new Date().toISOString(),
|
|
74
|
-
benchmark: 'codemod-tier1',
|
|
75
|
-
corpusVersion: corpus.version,
|
|
76
|
-
corpusSize: cases.length,
|
|
77
|
-
winRate,
|
|
78
|
-
winRatePct: `${(winRate * 100).toFixed(1)}%`,
|
|
79
|
-
successCount: correct,
|
|
80
|
-
avgLatencyMs: Number(avg.toFixed(4)),
|
|
81
|
-
p50LatencyMs: Number(percentile(sorted, 50).toFixed(4)),
|
|
82
|
-
p99LatencyMs: Number(percentile(sorted, 99).toFixed(4)),
|
|
83
|
-
maxLatencyMs: Number(Math.max(...latencies).toFixed(4)),
|
|
84
|
-
structuralCostUsd: 0,
|
|
85
|
-
llmBaseline: 'estimated',
|
|
86
|
-
estimatedSavingsUsd: estSavings,
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const run = { summary, results };
|
|
90
|
-
|
|
91
|
-
if (process.env.BENCH_JSON) {
|
|
92
|
-
console.log(JSON.stringify(run, null, 2));
|
|
93
|
-
} else {
|
|
94
|
-
console.log(`# Codemod Tier-1 benchmark (${cases.length} cases, corpus v${corpus.version})`);
|
|
95
|
-
console.log('');
|
|
96
|
-
console.log('| Metric | Value |');
|
|
97
|
-
console.log('|---|---:|');
|
|
98
|
-
console.log(`| Win rate (correct vs golden) | ${summary.winRatePct} (${correct}/${cases.length}) |`);
|
|
99
|
-
console.log(`| Avg latency | ${summary.avgLatencyMs} ms |`);
|
|
100
|
-
console.log(`| p50 / p99 / max latency | ${summary.p50LatencyMs} / ${summary.p99LatencyMs} / ${summary.maxLatencyMs} ms |`);
|
|
101
|
-
console.log(`| Measured cost | $0 (no API call) |`);
|
|
102
|
-
console.log(`| Est. savings vs Haiku/Sonnet/Opus | $${estSavings.vsHaiku} / $${estSavings.vsSonnet} / $${estSavings.vsOpus} |`);
|
|
103
|
-
console.log('');
|
|
104
|
-
const failed = results.filter((r) => !r.correct);
|
|
105
|
-
if (failed.length) {
|
|
106
|
-
console.log('## Failures');
|
|
107
|
-
for (const f of failed) console.log(`- \`${f.id}\` (${f.intent}): ${f.reason ?? `got "${f.gotPrefix}"`}`);
|
|
108
|
-
console.log('');
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (!process.env.BENCH_NO_WRITE) {
|
|
113
|
-
mkdirSync(RUNS_DIR, { recursive: true });
|
|
114
|
-
const stamp = summary.runAt.replace(/[:.]/g, '-');
|
|
115
|
-
writeFileSync(join(RUNS_DIR, `codemod-${stamp}.json`), JSON.stringify(run, null, 2));
|
|
116
|
-
writeFileSync(join(RUNS_DIR, 'codemod-latest.json'), JSON.stringify(run, null, 2));
|
|
117
|
-
if (!process.env.BENCH_JSON) console.log(`Wrote run to ${join(RUNS_DIR, `codemod-${stamp}.json`)}`);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Non-zero exit if any case regressed — usable as a CI guardrail.
|
|
121
|
-
if (correct !== cases.length) process.exit(1);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
main().catch((err) => {
|
|
125
|
-
console.error('benchmark failed:', err);
|
|
126
|
-
process.exit(1);
|
|
127
|
-
});
|