Files
ruvnet__ruflo/v3/@claude-flow/cli/__tests__/system-uptime-2235.test.ts
ruv 455152da03 fix(intelligence): 4-issue bug cluster — Opus 4.8 + uptime + MCP orphan + Q-encoder
Fixes four user-reported bugs from the same triage round, each with a
regression test and the minimal honest fix:

#2232 (Opus 4.8 / silent-downgrade): bump `opus` alias to claude-opus-4-8
(keep `opus-4.7` reachable), and route `executeAgentTask` through the
existing `resolveAnthropicModel` so literal claude-* ids stop silently
collapsing to Sonnet 4.6 via the bare MODEL_MAP||DEFAULT fold. Widens the
agent-tools alias whitelist, JSON-schema enum, and updates the statusline /
settings defaults.

#2235(B) (stale system_status.uptime): read live `process.uptime()` instead
of the persisted metrics.startTime, which was the file's creation timestamp
and reported ~8.8-day uptime on a freshly-spawned server. (Note: part A —
agentdb db-unified legacy SQLite never engaging better-sqlite3 — is in the
bundled agentdb package and is upstream-only.)

#2234 (MCP server orphan / ~1 GB leak): add a parent-death watchdog to
`ruflo mcp start` that exits cleanly when the process is reparented to
launchd/init (ppid===1) — i.e. Claude Code has exited. Stops ~50 MB
orphans accumulating across restarts and a stale orphan winning the stdio
handshake.

#2239 (Q-state encoder discards keyword block): replace the 31-bit
truncating fold (which silently dropped features 0–31, collapsing
keyword-distinct tasks to one Q-state) with a 32-bit FNV-1a fold over the
full quantized vector. Bump encoder version to 2 in the persisted model;
loadModel resets the Q-table on a v1→v2 mismatch (keeps stats/epsilon).

Tests: 17 new regression tests across all four issues; full CLI suite
62 files / 2104 passed / 46 skipped / 0 failed.

Closes #2232, #2234, #2239. Closes #2235 (B); #2235 (A) tracked upstream.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-29 18:30:28 -04:00

28 lines
1.4 KiB
TypeScript

// Regression test for #2235(B) — system_status.uptime was reading a persisted
// metrics.startTime (the file's creation timestamp) instead of the live process
// uptime, so a freshly-spawned MCP server reported ~8.8 days of uptime.
import { describe, it, expect } from 'vitest';
import { systemTools } from '../src/mcp-tools/system-tools.js';
const statusTool = systemTools.find((t) => t.name === 'system_status')!;
describe('system_status.uptime (#2235 B)', () => {
it('reports the live process uptime, not a persisted/stale value', async () => {
const r = (await statusTool.handler({ verbose: false })) as { uptime: number; uptimeFormatted: string };
// The vitest process itself has been running for at most a few minutes;
// a stale persisted-startTime bug would yield values in the millions of
// ms (hours/days). Cap generously to allow CI slowness.
expect(r.uptime).toBeGreaterThanOrEqual(0);
expect(r.uptime).toBeLessThan(60 * 60 * 1000); // < 1 hour
expect(typeof r.uptimeFormatted).toBe('string');
});
it('produces a non-decreasing uptime across two reads (live counter, not file mtime)', async () => {
const a = (await statusTool.handler({})) as { uptime: number };
await new Promise((res) => setTimeout(res, 25));
const b = (await statusTool.handler({})) as { uptime: number };
expect(b.uptime).toBeGreaterThanOrEqual(a.uptime);
});
});