Skip to content

Commit 25d2fa8

Browse files
committed
test(repro): honest-RED DeusData#581, honest safety-net DeusData#431 (false-guard audit)
repro_issue581 was a FALSE GUARD. A 3-node fixture over 150 search_graph calls cannot move process RSS (observed factor=1.00), so rss_end <= 3.0x rss_warmup passed even on the leaking build, and an explicit PASS() escape fired when RSS read 0. DeusData#581 is OPEN: there is no SQLITE_CHECKPOINT_TRUNCATE anywhere and cbm_mem_collect is never called in the query path (only after index/delete). The green was a lie. Replace the vacuous assertion with an honest FAIL that documents the leak is unfixed and not reproducible in this tier (needs a real WAL/committed-pages reproduction tier plus the fix). repro_issue431 is actually FIXED: install_vscode_profile_configs (cli.c:3211) scans Code/User/profiles/ and plans a per-profile mcp.json, and the test passes via the real assertion. Its detection-unmet branch returned a VACUOUS PASS that would hide a future regression; change it to SKIP_PLATFORM so a host where detection cannot fire is honestly inconclusive, not falsely green. Repro board: 311 passed, 1 failed (the honest DeusData#581 RED). Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 006ea01 commit 25d2fa8

2 files changed

Lines changed: 34 additions & 42 deletions

File tree

‎tests/repro/repro_issue431.c‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,17 @@ TEST(repro_issue431_vscode_profile_inherits_mcp_json) {
109109
/* --- Precondition: VSCode is detected --- */
110110
cbm_detected_agents_t agents = cbm_detect_agents(tmpdir);
111111
if (!agents.vscode) {
112-
/* Detection failed in the temp tree — adjust path derivation.
113-
* On non-Apple Linux the detection reads cbm_app_config_dir() which
114-
* is process-global (not home-relative), so detection may return false
115-
* for a synthetic tmpdir home. The bug still exists, but we cannot
116-
* demonstrate it via the plan-based oracle without detection firing.
117-
* Mark the test as an expected skip on this platform/config. */
112+
/* #431 IS FIXED: install_vscode_profile_configs() (cli.c:3211) scans
113+
* Code/User/profiles/ and plans a per-profile mcp.json, so the assertion
114+
* below passes as a genuine regression guard whenever detection fires
115+
* (which it does for this fixture). This branch is only reached if
116+
* cbm_detect_agents() cannot see the fixture home on some platform — in
117+
* which case the fix cannot be VERIFIED here. Skip honestly rather than
118+
* vacuously PASS (would hide a future regression) or FAIL (would red a
119+
* fixed bug). */
118120
th_rmtree(tmpdir);
119-
PASS(); /* precondition unmet — non-blocking; bug still open */
121+
SKIP_PLATFORM("VSCode detection did not fire for the synthetic fixture "
122+
"home; cannot verify the #431 per-profile install here");
120123
}
121124

122125
/* --- Run the install plan oracle (dry-run, no mutations) --- */

‎tests/repro/repro_issue581.c‎

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -245,46 +245,35 @@ TEST(repro_issue581_query_rss_stable) {
245245
free(args);
246246
rh_cleanup(&lp, store);
247247

248-
// If RSS is not measurable (cbm_mem_rss() returns 0 and no Linux fallback),
249-
// skip the growth assertion -- an unmeasurable RSS cannot produce a
250-
// meaningful signal. This avoids a false PASS masking a real leak on
251-
// platforms where our RSS API is unavailable.
252-
if (rss_warmup == 0 || rss_end == 0) {
253-
printf(" NOTE: RSS not measurable on this platform/build; "
254-
"growth assertion skipped (inconclusive, not a pass)\n");
255-
PASS();
248+
if (rss_warmup > 0 && rss_end > 0) {
249+
printf(" rss_warmup_kb=%zu rss_end_kb=%zu factor=%.2f threshold=%.1f\n", rss_warmup / 1024,
250+
rss_end / 1024, (double)rss_end / (double)rss_warmup, LEAK_FACTOR);
251+
} else {
252+
printf(" NOTE: RSS not measurable on this platform/build\n");
256253
}
257254

258-
printf(" rss_warmup_kb=%zu rss_end_kb=%zu factor=%.2f threshold=%.1f\n",
259-
rss_warmup / 1024, rss_end / 1024,
260-
(double)rss_end / (double)rss_warmup,
261-
LEAK_FACTOR);
262-
263-
// PRIMARY assertion: end RSS must not exceed LEAK_FACTOR x warmup RSS.
255+
// HONEST RED — this guard is currently VACUOUS and #581 is OPEN.
264256
//
265-
// RED condition (current code):
266-
// SQLite WAL + mimalloc retained pages grow each iteration.
267-
// Over 150 iterations the cumulative growth pushes rss_end above
268-
// LEAK_FACTOR * rss_warmup.
269-
// ASSERT fires -> RED.
257+
// This fixture CANNOT reproduce the leak: a 3-node graph over 150
258+
// search_graph calls allocates far too little to move process RSS (observed
259+
// factor=1.00), so the old "rss_end <= 3.0 x rss_warmup" assertion passed
260+
// even on the leaking build. A green here would mean "leak fixed" while the
261+
// leak is unfixed — a false guard that violates the tests-are-guards rule
262+
// (green <=> fixed). So it stays RED.
270263
//
271-
// GREEN condition (after fix):
272-
// Periodic compaction (cbm_mem_collect + WAL TRUNCATE checkpoint) keeps
273-
// rss_end near rss_warmup. factor stays <1.5 comfortably.
264+
// Turning this GREEN legitimately requires BOTH:
265+
// (a) a real reproduction tier — a long-running MCP session issuing
266+
// thousands of ops against a LARGE graph, measuring the SQLite WAL
267+
// file size and mimalloc committed pages DIRECTLY (not process-RSS
268+
// jitter) so the monotonic growth is actually observable; AND
269+
// (b) the fix — periodic SQLITE_CHECKPOINT_TRUNCATE + cbm_mem_collect() in
270+
// the MCP query loop / idle eviction (see the header + #581).
274271
//
275-
// We report the ratio in the failure message so the fixer can see the
276-
// growth slope without needing a profiler.
277-
size_t rss_limit = (size_t)(rss_warmup * LEAK_FACTOR);
278-
if (rss_end > rss_limit) {
279-
printf(" BUG #581 reproduced: RSS grew %.2fx after %d search_graph calls "
280-
"(warmup=%zu kB end=%zu kB limit=%zu kB)\n",
281-
(double)rss_end / (double)rss_warmup,
282-
ITER_TOTAL - ITER_WARMUP,
283-
rss_warmup / 1024, rss_end / 1024, rss_limit / 1024);
284-
}
285-
ASSERT(rss_end <= rss_limit);
286-
287-
PASS();
272+
// Until both land this is an honest "not fixed / not provable here" RED, not
273+
// a false green.
274+
FAIL("bug #581 (query-path memory leak) is OPEN and cannot be reproduced in "
275+
"this fixture (RSS factor ~1.0 even when leaking) — needs a real "
276+
"WAL/committed-pages reproduction tier plus the fix");
288277
}
289278

290279
// -- Suite ------------------------------------------------------------------

0 commit comments

Comments
 (0)