fix(consolidate): floor NULL demote target instead of nulling importance (#188)#191
Merged
Merged
Conversation
…nce (#188) The child re-clamp used MAX(1, MIN(importance, CAST(? AS INTEGER))), which writes NULL when the payload importance is NULL (CAST(NULL)->NULL, MIN/MAX with NULL->NULL) — so the comment's claimed floor-of-1 'regardless of the supplied value' did not actually hold for NULL. Wrap the bind in COALESCE(?, importance) so a NULL payload no-ops to the current value and MAX(1, ...) re-pins the floor for every input. Tighten the comment to match the real guarantee. Tests: prove a NULL newImportance no-ops (never nulls the column), and add the missing end-to-end spawn -> stderr -> parseConsolidateProgress link (child emits a progress marker then hangs past a short timeout; the parser recovers the committed counts from the killed child's captured stderr). Closes #188
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.
Summary
Hardens the consolidate child re-clamp to deliver the floor-of-1 invariant its comment advertised, from the RedTeam gate on PR #184 (issue #145).
The demote re-clamp used
MAX(1, MIN(importance, CAST(? AS INTEGER))). ANULLimportance payload wroteNULL(CAST(NULL)→NULL,MIN/MAXwith NULL→NULL), so the comment's claim that the floor of 1 is re-pinned "regardless of the supplied value" was overstated. Not reachable on the legit path (the planner always supplies an integer) and not a regression (pre-PRSET importance = ?nulled identically) — but it didn't fully deliver the asterisked invariant.Changes
COALESCE(?, importance):MAX(1, MIN(CAST(COALESCE(?, importance) AS INTEGER), importance)). ANULLpayload now no-ops to the current value andMAX(1, …)re-pins the floor for every input, NULL included. The "can only LOWER, never raise" guarantee is unchanged.NULLnewImportanceno-ops to the current value and never nulls the column (tests/hooks/consolidate-core.test.ts).spawn → err.stderr → parselink (the LOW from the same gate): a child emits aRECALL_CONSOLIDATE_PROGRESSmarker then hangs past a shortexecSynctimeout; the SIGTERM'd child's captured stderr is recovered byparseConsolidateProgress(tests/lib/consolidate.test.ts). Prior coverage proved the parser and the apply separately but never the live link.Verification
bun run lintclean.bun test— full suite 1191 pass / 0 fail (in-worktree, withnode_modulesresolvable). The 19 consolidate tests (incl. the two new ones) pass.risk:low — defense-in-depth hardening on a non-reachable path; the legit planner path is unaffected.
Closes #188