Repository navigation
fix(#758): guard REMEMBER_EMIT_READ_MAX like every sibling numeric knob - #772
Merged
Merged
Conversation
`_remember_emit_file` read `${REMEMBER_EMIT_READ_MAX:-16384}` straight off
the environment and fed it unguarded into `[ "$2" -gt "$_remember_emit_max" ]`,
unlike MEMORY_INJECT_MAX_BYTES in the same file and log.sh's _budget/_grace.
A non-numeric value made the comparison print "integer expression expected"
to stderr and fall through (an if condition suppresses set -e) to the read
arm -- sending the file down the quadratic path the 16 KB threshold exists
to keep it off.
Add the same `case (''|*[!0-9]*) ... ;; esac` guard used by the file's other
numeric knobs, falling back to the documented default of 16384 on garbage.
Adds tests/test_emit_read_max_guard_758.py (red before the fix, green after),
a changelog.d/758.fixed.md fragment, and a windows-skip-triage.md row for the
new bash-subprocess test module.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Self-review (Explore reviewer) found `.claude/jit-context/paths/00-manual/ 00-README.md`'s declined-trap entry for `695.emit-read-max-is-an-unvalidated- knob` still asserted "still true, not fixed" about the exact guard #758's previous commit just added -- stale prose adjacent to the diff, contradicting the code it describes. Updates the entry to say the knob was fixed in #758. Co-Authored-By: Claude Sonnet 5 <[email protected]>
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.
Fixes the one numeric env knob in
scripts/lib-memory-context.shthat lacked thecase (''|*[!0-9]*) ... ;; esacguard every sibling knob in the same file already carries(
MEMORY_INJECT_MAX_BYTES,log.sh's_budget/_grace)._remember_emit_filereadREMEMBER_EMIT_READ_MAXstraight off the environment and used itunguarded in
[ "$2" -gt "$_remember_emit_max" ]. A non-numeric value made that comparison print"integer expression expected" (GNU bash) or "integer expected" (macOS bash) to stderr and, because
the test sits inside an
ifcondition, fell through to the wrong branch -- sending the file downthe quadratic
readpath the 16 KB threshold exists to keep it off. Low severity (undocumented,developer-only knob), but the same easy fix as its siblings.
Closes #758
Fix
Added the same guard convention already used by this file's other numeric knobs, falling back to
the documented default of 16384 on garbage input.
Tests
Red (pre-fix):
test_a_non_numeric_threshold_does_not_print_to_stderrfailed with the actualmacOS-bash message reproduced:
[: notanumber: integer expected.Green (post-fix):
python3 -m pytest tests/test_emit_read_max_guard_758.py tests/test_unknown_size_695.py tests/test_render_is_byte_identical_660.py tests/test_locale_ranges_695.py tests/test_windows_skip_triage_497.py -q --no-cov-> 42 passed.Full
pytest(whole suite) not run locally, per this repo's own policy that CI is the gate forthe 3-OS x 4-interpreter matrix.
Follow-up commit
A second commit in this branch fixes stale prose in
.claude/jit-context/paths/00-manual/00-README.mdthat a self-review reviewer caught: thedeclined-trap entry for
695.emit-read-max-is-an-unvalidated-knobstill said the knob was "stilltrue, not fixed" after this PR's own fix landed. Updated to say fixed in #758.
Below-bar finding (not fixed here, on purpose)
A second self-review reviewer (oss:auditor) found that the new guard silently substitutes the
default (16384) on garbage input, with no stderr note distinguishing "garbage, defaulted" from
"never set, default applied on purpose". This mirrors an existing, unchanged sibling pattern
(MEMORY_INJECT_MAX_BYTES at line ~712) rather than introducing a new one; below-bar for this
diff, not a defect this fix created.
Docs:
README.mdchecked, no change needed (this is an undocumented, dev-only knob, neverdocumented there).
docs/windows-skip-triage.mdupdated with a row for the new bash-subprocesstest module.
🤖 Generated with Claude Code
[AI-generated]