context-graph: dedicated finite projection heap budget (HYP_GRAPH_PROJECTION_MAX_HEAP_MB) - step 1 of #376#378
Open
philcunliffe wants to merge 1 commit into
Open
context-graph: dedicated finite projection heap budget (HYP_GRAPH_PROJECTION_MAX_HEAP_MB) - step 1 of #376#378philcunliffe wants to merge 1 commit into
philcunliffe wants to merge 1 commit into
Conversation
Graph projection ran its three executeQuerySql scans (the shared per-contract scan, the raw-SQL rule scans, and the dedup id read) without a maxHeapBytes override, so they inherited the 1 GiB user-query heap budget added in #295 (LLP 0097). The shared scan fully materializes the source table before the rule loop sees a row, so on the ~1.66M-row prod table it trips that budget every sweep, logs graph_projection.scope_failed, and freezes the fleet graph. Step 1 (immediate unblock): resolve a DEDICATED projection budget from a new knob HYP_GRAPH_PROJECTION_MAX_HEAP_MB (default 3 GiB) in one helper, resolveProjectionMaxHeapBytes, and pass it as maxHeapBytes at all three scan sites. Never 0: a blank, zero, non-positive, or non-numeric knob falls back to the default rather than disabling executeQuerySql's watchdog (0 risks a daemon OOM crash-loop, strictly worse than a stale graph). This leaves the 1 GiB user-query guard untouched and preserves the fail-clean property: when the table outgrows the dedicated budget, projection refuses cleanly instead of crashing the daemon. The durable incremental + chunked projection (step 2) is deferred to #377. Adds a regression test asserting the finite knob-derived budget reaches every scan site (default 3 GiB, override propagates, unset != 0), captured through an injectable query-exec seam. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
Neutral review - PR #378 (step 1 of #376): dedicated finite projection heap budgetVerdict: clean. No actionable findings. CI green. Reviewed Focus points
Step 2 (durable incremental + chunked) is correctly out of scope, deferred to #377. No changes pushed - the PR stands as reviewed. |
philcunliffe
marked this pull request as ready for review
July 22, 2026 23:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 1 of #376: immediate prod unblock
projectGraphran its threeexecuteQuerySqlscans without amaxHeapBytesoverride, so they inherited the 1 GiB user-query heap budget added in #295 (LLP 0097). The shared per-contract scan fully materializes the whole source table before the rule loop sees a row, so on the ~1.66M-row prod table it trips that budget every sweep, logsgraph_projection.scope_failed, re-marks the scope dirty, and freezes the fleet graph.The fix
resolveProjectionMaxHeapBytes()reads a dedicated knobHYP_GRAPH_PROJECTION_MAX_HEAP_MB(default 3 GiB = 3221225472 bytes), MB -> bytes, mirroring the existingHYP_QUERY_MAX_HEAP_MBblank-var handling.maxHeapBytesat all three projection call sites: the shared per-contract scan, the raw-SQL rule scans, and the dedup id read.executeQuerySql's watchdog.maxHeapBytes: 0would remove the guard entirely and risk a daemon OOM crash-loop, which is strictly worse than a stale graph.Properties preserved
POST /v1/querytraffic is unchanged.QueryExecutionBudgetError(surfaced by the scheduler asgraph_projection.scope_failed) instead of crashing the daemon. Acknowledged treadmill; it buys time for step 2.Testing
test/plugins/context-graph-projection-budget.test.jscaptures the query-exec seam and asserts the finite knob-derived budget reaches every scan site: default 3 GiB when unset, the knob override propagates, and the unset/blank/zero/negative cases resolve to the default (never 0). Verified it fails when themaxHeapBytesadditions are reverted and passes with them. Fullnpm testgreen apart from the known pre-existing sandbox failures (hyparquet/icebirdmodule-resolution,vector-search, ~7leave/join).Deferred
The durable incremental + chunked projection (step 2) is tracked in #377.
Fixes #376