ruvnet-brain 3.9.134-dev → 4.0.2
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-plugin/marketplace.json +14 -0
- package/README.md +5 -5
- package/bin/install.mjs +382 -36
- package/console/CONTRACT.md +172 -0
- package/console/activity.js +753 -0
- package/console/app.js +4189 -0
- package/console/architecture.html +1221 -0
- package/console/assets/depth-1.webp +0 -0
- package/console/assets/depth-2.webp +0 -0
- package/console/assets/depth-3.webp +0 -0
- package/console/assets/harness-vs-plain.svg +259 -0
- package/console/assets/hero.webp +0 -0
- package/console/assets/memory.webp +0 -0
- package/console/assets/metaharness.svg +247 -0
- package/console/index.html +777 -0
- package/console/install-architecture.html +162 -0
- package/console/install-mockup.html +543 -0
- package/console/style.css +2144 -0
- package/console/tips.css +926 -0
- package/console/tips.html +858 -0
- package/console/tips.js +128 -0
- package/docs/RELEASE-NOTES-4.0.md +88 -0
- package/kb/model-requirements.mjs +37 -6
- package/kb/zip-extract.mjs +53 -14
- package/keys/ruvnet-brain-signing.pub.pem +3 -0
- package/package.json +14 -22
- package/plugin/.claude-plugin/marketplace.json +14 -0
- package/plugin/.claude-plugin/plugin.json +22 -0
- package/plugin/.codex-plugin/plugin.json +21 -0
- package/plugin/.mcp.json +8 -0
- package/plugin/commands/brain-console.md +16 -0
- package/plugin/commands/configure.md +33 -0
- package/plugin/commands/rvbc.md +79 -0
- package/plugin/commands/rvcb.md +16 -0
- package/plugin/commands/whats-new.md +57 -0
- package/plugin/hooks/codex-hooks.json +160 -0
- package/plugin/hooks/hook-contracts.json +77 -0
- package/plugin/hooks/hooks.json +202 -0
- package/plugin/mcp/managed-cli-interface.mjs +47 -4
- package/plugin/mcp/server.mjs +56 -6
- package/plugin/scripts/anticipate.sh +534 -0
- package/plugin/scripts/codex-hook-adapter.mjs +96 -0
- package/plugin/scripts/continuation-gate.mjs +267 -0
- package/plugin/scripts/design-wall.sh +137 -0
- package/plugin/scripts/detach.mjs +182 -0
- package/plugin/scripts/first-session-worker.mjs +38 -0
- package/plugin/scripts/gate-receipt.sh +35 -0
- package/plugin/scripts/ground-before-write.sh +199 -0
- package/plugin/scripts/ground-ruvnet.sh +517 -0
- package/plugin/scripts/grounding-stamp.sh +113 -0
- package/plugin/scripts/grounding-substance.mjs +595 -0
- package/plugin/scripts/hijack-ruvnet.sh +81 -0
- package/plugin/scripts/hook-input.mjs +558 -0
- package/plugin/scripts/hook-shim-bash.mjs +55 -0
- package/plugin/scripts/hook-shim.mjs +303 -0
- package/plugin/scripts/host-update.mjs +58 -0
- package/plugin/scripts/kling-preflight.sh +146 -0
- package/plugin/scripts/learn-capture.sh +173 -0
- package/plugin/scripts/learn-flush.mjs +155 -0
- package/plugin/scripts/lesson-hooks.sh +213 -0
- package/plugin/scripts/md-stamp.mjs +219 -0
- package/plugin/scripts/protect-brain-state.sh +84 -0
- package/plugin/scripts/route-dispatch.sh +147 -0
- package/plugin/scripts/routing-outcome-capture.mjs +89 -0
- package/plugin/scripts/runtime-preferences.mjs +269 -0
- package/plugin/scripts/session-start-core.mjs +477 -0
- package/plugin/scripts/session-start.sh +13 -0
- package/plugin/scripts/signal-watch.mjs +193 -0
- package/plugin/scripts/unprompted-runtime.mjs +377 -0
- package/plugin/scripts/update-apply.mjs +419 -0
- package/plugin/scripts/verify-interface.sh +53 -0
- package/plugin/scripts/version-bump-gate.sh +112 -0
- package/plugin/skills/brain-build/SKILL.md +123 -0
- package/plugin/skills/brain-console/SKILL.md +22 -0
- package/plugin/skills/brain-prompt/SKILL.md +83 -0
- package/plugin/skills/brain-score/SKILL.md +101 -0
- package/plugin/skills/release-proof/SKILL.md +81 -0
- package/plugin/skills/release-proof/agents/openai.yaml +4 -0
- package/plugin/skills/release-proof/references/receipt-contract.md +38 -0
- package/plugin/skills/release-proof/scripts/release-proof.mjs +210 -0
- package/plugin/skills/ruvnet-brain/PLAYBOOK.md +121 -0
- package/plugin/skills/ruvnet-brain/SKILL.md +234 -0
- package/plugin/skills/rvbc/SKILL.md +23 -0
- package/plugin/skills/savings/SKILL.md +46 -0
- package/plugin/skills/whats-new/SKILL.md +22 -0
- package/scripts/adr-backfill.mjs +107 -0
- package/scripts/advocacy-outcomes.mjs +808 -0
- package/scripts/agentdb-context.mjs +216 -0
- package/scripts/agentdb-fleet-doctor.mjs +101 -0
- package/scripts/ascii-drift.mjs +236 -0
- package/scripts/behavioral-l1-l4.mjs +210 -0
- package/scripts/brain-capability-check.mjs +72 -0
- package/scripts/brain-grade-groundtruth.mjs +100 -0
- package/scripts/brain-latency-50.mjs +227 -0
- package/scripts/brain-novice-50.mjs +189 -0
- package/scripts/brain-stamp.mjs +94 -0
- package/scripts/brain-state.mjs +212 -0
- package/scripts/build-bundle.mjs +522 -0
- package/scripts/build-concepts.mjs +132 -0
- package/scripts/build-l2.mjs +71 -0
- package/scripts/build-primer.mjs +73 -0
- package/scripts/build-symbols.mjs +68 -0
- package/scripts/calibrate-router.mjs +97 -0
- package/scripts/capability-audit.mjs +321 -0
- package/scripts/capability-registry.mjs +876 -0
- package/scripts/check-indexation.mjs +108 -0
- package/scripts/check-legibility.mjs +189 -0
- package/scripts/ci/build-fixture-kb.mjs +67 -0
- package/scripts/ci/learning-replay-codex-adapter.mjs +62 -0
- package/scripts/ci/learning-replay-recorder.mjs +59 -0
- package/scripts/ci/mutate-hook-timeout.mjs +70 -0
- package/scripts/ci/stranger-fixture-stage.mjs +17 -0
- package/scripts/ci/stranger-scenario.mjs +228 -0
- package/scripts/ci/stranger-timeout.mjs +25 -0
- package/scripts/ci-verdict.mjs +29 -0
- package/scripts/claims-verify.mjs +710 -0
- package/scripts/clear-claude-tmp.sh +31 -0
- package/scripts/console-engine.mjs +434 -0
- package/scripts/console-engine.test.mjs +125 -0
- package/scripts/corpus-qa.mjs +250 -0
- package/scripts/correction-detect-embed.mjs +346 -0
- package/scripts/correction-detect-measure.mjs +270 -0
- package/scripts/correction-detect.mjs +686 -0
- package/scripts/count-chunks.mjs +54 -0
- package/scripts/described-questions.json +30 -0
- package/scripts/design-grade.mjs +58 -0
- package/scripts/dev-plugin-link.sh +105 -0
- package/scripts/distill-project.mjs +200 -0
- package/scripts/doc-currency.mjs +801 -0
- package/scripts/eval-brain.mjs +244 -0
- package/scripts/fix-metaharness-memretrieve.mjs +121 -0
- package/scripts/full-hints.mjs +87 -0
- package/scripts/gate.sh +39 -0
- package/scripts/gates.mjs +146 -0
- package/scripts/gen-console-images.mjs +54 -0
- package/scripts/gen-images.mjs +47 -0
- package/scripts/git-clone-refresh.mjs +52 -0
- package/scripts/git-hooks/pre-push +126 -0
- package/scripts/goal-match.mjs +398 -0
- package/scripts/goldie-research.mjs +223 -0
- package/scripts/goldie-weekly.sh +67 -0
- package/scripts/health-repair.mjs +250 -0
- package/scripts/helix-scenario-questions.json +10 -0
- package/scripts/ingest-gists.mjs +230 -0
- package/scripts/ingest-meeting.mjs +115 -0
- package/scripts/ingest-repo.mjs +79 -0
- package/scripts/install-npx-witness.sh +49 -0
- package/scripts/issue-fix.mjs +639 -0
- package/scripts/issue-watch.mjs +276 -0
- package/scripts/issue4-close-note.md +31 -0
- package/scripts/key-canary.mjs +91 -0
- package/scripts/latency-to-surface.mjs +233 -0
- package/scripts/learning-enable.mjs +380 -0
- package/scripts/learning-replay.mjs +1570 -0
- package/scripts/learnings.mjs +62 -0
- package/scripts/lesson-gate.mjs +680 -0
- package/scripts/lesson-lifecycle.mjs +449 -0
- package/scripts/lesson-promote.mjs +262 -0
- package/scripts/lesson-ratify.mjs +98 -0
- package/scripts/lesson-seed.mjs +252 -0
- package/scripts/lesson-store.mjs +447 -0
- package/scripts/loop-checkpoint.mjs +86 -0
- package/scripts/memdb-health.sh +14 -0
- package/scripts/memory-doctor.mjs +271 -0
- package/scripts/model-catalog.mjs +79 -0
- package/scripts/nightly-controller.mjs +66 -0
- package/scripts/nightly-gists.sh +72 -0
- package/scripts/nightly-wrapper.sh +180 -0
- package/scripts/notify.sh +12 -0
- package/scripts/npx-witness.sh +56 -0
- package/scripts/onboarding-console.mjs +2749 -0
- package/scripts/private-fence.mjs +69 -0
- package/scripts/proactivity-metrics.mjs +118 -0
- package/scripts/proof-questions.json +56 -0
- package/scripts/prove.mjs +95 -0
- package/scripts/proxy/claude-proxied.sh +57 -0
- package/scripts/proxy/proxy-revert.sh +59 -0
- package/scripts/proxy/proxy-up.sh +60 -0
- package/scripts/proxy/proxy-verify.mjs +142 -0
- package/scripts/published-surface-probe.mjs +241 -0
- package/scripts/qe/card-lane-gate.mjs +162 -0
- package/scripts/qe/session-start-gate.mjs +229 -0
- package/scripts/qe/ux-suite.mjs +323 -0
- package/scripts/reconcile-project.mjs +0 -0
- package/scripts/record-lesson.mjs +113 -0
- package/scripts/refresh-model-catalog.mjs +99 -0
- package/scripts/release-proof.mjs +9 -0
- package/scripts/release-vector.mjs +281 -0
- package/scripts/release.mjs +395 -0
- package/scripts/remedy-registry.mjs +247 -0
- package/scripts/rerank-cap-eval.mjs +265 -0
- package/scripts/rerank-cap-warm-ab.mjs +129 -0
- package/scripts/route-cheap.mjs +20 -15
- package/scripts/router-utilization.mjs +182 -0
- package/scripts/routing-flywheel.mjs +596 -0
- package/scripts/rvf-generation.mjs +104 -0
- package/scripts/rvf-index-audit.mjs +138 -0
- package/scripts/self-update.mjs +508 -0
- package/scripts/selfcheck.mjs +7 -1
- package/scripts/sign-bundle.mjs +69 -0
- package/scripts/signal-watch.mjs +171 -0
- package/scripts/stack-sync.mjs +469 -0
- package/scripts/stamp-existing-rvf-generations.mjs +53 -0
- package/scripts/stamp-sweep.mjs +144 -0
- package/scripts/status-honesty.mjs +102 -0
- package/scripts/sync-version.mjs +217 -0
- package/scripts/token-report.mjs +102 -0
- package/scripts/top100-benchmark.mjs +479 -0
- package/scripts/top100-corpus.mjs +112 -0
- package/scripts/top100-semantic-assertions.mjs +449 -0
- package/scripts/update-apply.mjs +9 -0
- package/scripts/upgrade-notice.mjs +14 -0
- package/scripts/verify-bundle.mjs +51 -0
- package/scripts/verify-channels.mjs +184 -0
- package/scripts/verify-model-catalog.mjs +104 -0
- package/scripts/verify-nightly-close-issue4.sh +31 -0
- package/scripts/version.mjs +40 -0
- package/scripts/wired-check.mjs +864 -0
package/plugin/mcp/server.mjs
CHANGED
|
@@ -37,7 +37,7 @@ import { callManagedCli, MANAGED_CLI_TOOLS } from './managed-cli-interface.mjs';
|
|
|
37
37
|
|
|
38
38
|
const BRAIN_HOME = process.env.RUVNET_BRAIN_HOME || path.join(os.homedir(), '.cache', 'ruvnet-brain');
|
|
39
39
|
const KB = process.env.RUVNET_BRAIN_KB || path.join(BRAIN_HOME, 'kb');
|
|
40
|
-
const CHILD_MCP = path.join(KB, 'forge-mcp-all.mjs');
|
|
40
|
+
const CHILD_MCP = process.env.RUVNET_BRAIN_CHILD_MCP || path.join(KB, 'forge-mcp-all.mjs');
|
|
41
41
|
const ACTIVE = path.join(BRAIN_HOME, 'active.json');
|
|
42
42
|
const LEASES = path.join(BRAIN_HOME, 'leases');
|
|
43
43
|
const LEASE = path.join(LEASES, `mcp-${process.pid}.json`);
|
|
@@ -95,10 +95,33 @@ let child = null; // { proc, generation, nextId, pending: Map<childId
|
|
|
95
95
|
let pendingCount = 0; // client tools/call requests currently in flight (drain gate for swaps)
|
|
96
96
|
let childRetirement = Promise.resolve();
|
|
97
97
|
let childStartup = null;
|
|
98
|
+
let childIdleTimer = null;
|
|
98
99
|
const CHILD_TERM_GRACE_MS = 3_000;
|
|
99
100
|
const CHILD_INIT_TIMEOUT_MS = Number(process.env.RUVNET_BRAIN_INIT_TIMEOUT_MS) || 60_000;
|
|
101
|
+
const CHILD_IDLE_MS = Number(process.env.RUVNET_BRAIN_CHILD_IDLE_MS) || 30 * 60_000;
|
|
102
|
+
|
|
103
|
+
function clearChildIdleTimer() {
|
|
104
|
+
if (childIdleTimer) clearTimeout(childIdleTimer);
|
|
105
|
+
childIdleTimer = null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function armChildIdleTimer(c = child) {
|
|
109
|
+
clearChildIdleTimer();
|
|
110
|
+
if (!c || CHILD_IDLE_MS <= 0) return;
|
|
111
|
+
childIdleTimer = setTimeout(() => {
|
|
112
|
+
childIdleTimer = null;
|
|
113
|
+
if (child !== c) return;
|
|
114
|
+
if (pendingCount > 0 || c.pending.size > 0 || childStartup) {
|
|
115
|
+
armChildIdleTimer(c);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
void killChild(`idle for ${CHILD_IDLE_MS / 1000}s`);
|
|
119
|
+
}, CHILD_IDLE_MS);
|
|
120
|
+
childIdleTimer.unref?.();
|
|
121
|
+
}
|
|
100
122
|
|
|
101
123
|
function killChild(reason) {
|
|
124
|
+
clearChildIdleTimer();
|
|
102
125
|
if (!child) return childRetirement;
|
|
103
126
|
const c = child; child = null;
|
|
104
127
|
for (const [, p] of c.pending) p.reject(new Error(`brain worker ${reason}`));
|
|
@@ -124,6 +147,10 @@ function killChild(reason) {
|
|
|
124
147
|
async function ensureChild() {
|
|
125
148
|
const gen = currentGeneration();
|
|
126
149
|
if (child && child.generation !== gen && pendingCount === 0) await killChild('superseded by a newer generation');
|
|
150
|
+
// A concurrent initialize/tools-list/tools-call must join the same readiness promise. Returning
|
|
151
|
+
// `child` while its private initialize or model warmup is still running advertises a half-ready
|
|
152
|
+
// worker and charges cold-start to the first user call.
|
|
153
|
+
if (childStartup) return childStartup;
|
|
127
154
|
if (child) return child;
|
|
128
155
|
await childRetirement;
|
|
129
156
|
if (!fs.existsSync(CHILD_MCP)) return null;
|
|
@@ -154,10 +181,22 @@ async function ensureChild() {
|
|
|
154
181
|
capabilities: {},
|
|
155
182
|
clientInfo: { name: 'ruvnet-brain-shell', version: SERVER_INFO.version },
|
|
156
183
|
}, CHILD_INIT_TIMEOUT_MS);
|
|
184
|
+
const warmed = await childRequest(c, 'brain/warmup', {}, CHILD_INIT_TIMEOUT_MS);
|
|
185
|
+
// Rolling-upgrade compatibility: 4.0.1 workers predate the private warmup extension. The
|
|
186
|
+
// stable shell is installed before the 700MB KB swap completes, so rejecting -32601 here
|
|
187
|
+
// makes every query fail during the exact in-place upgrade window the shell exists to hide.
|
|
188
|
+
// An older initialized worker is usable (its first query may be cold); any other warmup
|
|
189
|
+
// failure still fails closed.
|
|
190
|
+
const warmupUnsupported = warmed.error?.code === -32601
|
|
191
|
+
|| /method not found/i.test(String(warmed.error?.message || ''));
|
|
192
|
+
if (!warmupUnsupported && (warmed.error || warmed.result?.ready !== true)) {
|
|
193
|
+
throw new Error(warmed.error?.message || 'brain worker did not confirm warm readiness');
|
|
194
|
+
}
|
|
157
195
|
} catch (e) {
|
|
158
196
|
await killChild('failed initialize');
|
|
159
197
|
throw new Error(`brain worker failed to initialize: ${e.message}`);
|
|
160
198
|
}
|
|
199
|
+
armChildIdleTimer(c);
|
|
161
200
|
return c;
|
|
162
201
|
})();
|
|
163
202
|
}
|
|
@@ -191,10 +230,11 @@ async function onChildTimeout(method, timeoutMs) {
|
|
|
191
230
|
}
|
|
192
231
|
}
|
|
193
232
|
|
|
194
|
-
// Overridable so the outage path above can actually be TESTED
|
|
195
|
-
//
|
|
196
|
-
//
|
|
197
|
-
|
|
233
|
+
// Overridable so the outage path above can actually be TESTED. The default matches the installer's
|
|
234
|
+
// real cold-start smoke budget: measured 153s after a cache repair on 2026-07-29. A 120s parent
|
|
235
|
+
// deadline killed the model just before it became usable and forced every retry to start cold.
|
|
236
|
+
// Steady-state latency remains a separate release gate; this budget prevents a permanent cold loop.
|
|
237
|
+
const CALL_TIMEOUT_MS = Number(process.env.RUVNET_BRAIN_CALL_TIMEOUT_MS) || 240_000;
|
|
198
238
|
|
|
199
239
|
function childRequest(c, method, params, timeoutMs = CALL_TIMEOUT_MS) {
|
|
200
240
|
return new Promise((resolve, reject) => {
|
|
@@ -216,6 +256,12 @@ async function handleClient(msg) {
|
|
|
216
256
|
if (id === undefined || id === null) return; // notifications need no answer
|
|
217
257
|
switch (method) {
|
|
218
258
|
case 'initialize':
|
|
259
|
+
// MCP initialize itself stays protocol-fast; normal clients request tools/list immediately
|
|
260
|
+
// afterwards, which joins this readiness promise and does not receive the tool declaration
|
|
261
|
+
// until the worker's query embedder and cross-encoder are warm.
|
|
262
|
+
void ensureChild().catch((e) => {
|
|
263
|
+
console.error(`[ruvnet-brain] worker warmup failed during initialize: ${e.message}`);
|
|
264
|
+
});
|
|
219
265
|
return clientOk(id, { protocolVersion: PROTOCOL_VERSION, capabilities: { tools: {} }, serverInfo: SERVER_INFO });
|
|
220
266
|
case 'ping':
|
|
221
267
|
return clientOk(id, {});
|
|
@@ -225,7 +271,10 @@ async function handleClient(msg) {
|
|
|
225
271
|
if (c) {
|
|
226
272
|
try {
|
|
227
273
|
const r = await childRequest(c, 'tools/list', {}, 15_000);
|
|
228
|
-
if (r.result?.tools?.length)
|
|
274
|
+
if (r.result?.tools?.length) {
|
|
275
|
+
armChildIdleTimer(c);
|
|
276
|
+
return clientOk(id, { ...r.result, tools: withLocalTools(r.result.tools) });
|
|
277
|
+
}
|
|
229
278
|
}
|
|
230
279
|
catch { /* fall through to the static declaration */ }
|
|
231
280
|
}
|
|
@@ -259,6 +308,7 @@ async function handleClient(msg) {
|
|
|
259
308
|
return clientOk(id, { content: [{ type: 'text', text: `search_ruvnet error: ${e.message}` }], isError: true });
|
|
260
309
|
} finally {
|
|
261
310
|
pendingCount--;
|
|
311
|
+
armChildIdleTimer(c);
|
|
262
312
|
}
|
|
263
313
|
}
|
|
264
314
|
default:
|