Skip to content

fix: graph-buffer upsert contract + mem budget poisoning (4 red tests)#923

Merged
DeusData merged 2 commits into
mainfrom
fix/dry-run-test-regressions
Jul 6, 2026
Merged

fix: graph-buffer upsert contract + mem budget poisoning (4 red tests)#923
DeusData merged 2 commits into
mainfrom
fix/dry-run-test-regressions

Conversation

@DeusData

@DeusData DeusData commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Fixes the four cross-platform test failures blocking the dry run:

  • gbuf (3 tests): the deterministic same-QN collision rule inverted the documented upsert/merge refresh semantics. New rule = one mixed-direction total order (smallest file_path, largest start_line, then name/label) in both upsert and merge — order-independent (MT x4 fingerprint guard stays green) while restoring later-definition-wins within a file and refresh-on-tie.
  • mem (1 test): cbm_mem_init is init-once, so the backpressure test's setenv+re-init restore was a silent no-op, leaking a 1 MB budget process-wide. New test-only budget setter bypasses the guard; the test saves/restores explicitly, env dance removed.

Local gates: full suite 5922 passed / 0 failed; determinism repro green (only known deliberate REDs remain on the non-gating board); lint-ci clean.

DeusData added 2 commits July 7, 2026 00:58
The deterministic same-QN collision rule picked the lexicographically
smallest (label, file_path, start_line, name), which silently inverted
the documented upsert/merge semantics: re-upserting a QN with updated
fields kept the OLD content (gbuf_upsert_updates,
gbuf_upsert_same_qn_updates_all_fields, gbuf_merge_overlapping_qns all
red on every platform).

Replace it with a single mixed-direction total order applied in both
cbm_gbuf_upsert_node and merge_update_existing: smallest file_path,
then LARGEST start_line, then largest name/label. Still a pure content
function of the two candidates (commutative, associative,
scheduling-independent — multi-threaded runs stay byte-identical,
verified by the xfs MT x4 fingerprint guard), and line-descending
within a file restores the classic contract: a later definition in the
same file replaces the earlier one, and a full tie is the same entity
refreshed in place.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
cbm_mem_init is init-once (guarded by g_initialized), so the
backpressure test's setenv(CBM_MEM_BUDGET_MB=1) + re-init 'restore'
was a silent no-op: whichever init ran first fixed the budget for the
whole process. In the full runner this test's init won, locking a 1 MB
budget that leaked into every later budget consumer —
mem_over_budget_low_rss red on every platform, and all subsequent
pipeline tests silently running with backpressure permanently engaged.

Add cbm_mem_set_budget_for_tests(): writes the budget directly without
touching the init guard. The test now saves the caller-visible budget,
sets 1 MB via the hook, and restores before asserting. Env dance
removed.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
@DeusData DeusData merged commit 1c1b6df into main Jul 6, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant