Skip to content

fix(#905): check_release_tree needle for a one-line positional delegate - #911

Merged
fdaviddpt merged 3 commits into
mainfrom
fix/905
Oct 5, 2026
Merged

fdaviddpt merged 3 commits into
mainfrom
fix/905

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Adds a FAIL-grade needle to .github/scripts/check_release_tree.py that catches a shell function whose whole body is a single call to another function with a positional parameter ($1..$9, ${1}..) spliced into a string argument -- the shape that held scripts/log.sh's three dispatch reporters at the Anthropic directory as COMMAND_SCRIPT_NOT_FOLLOWED until #899 r40.

Closes #905.

Also folds in #904 parts 1 and 2 (NOT part 3, the session-start structural redesign, which stays open and unaddressed here):

  • a new jit-context paths-layer warning (hook-script-size-budget.md) naming the 128 KiB scanner limit, the 120 KiB release budget, "shrink real code, never minify", and the known scanner triggers;
  • confirmation, documented in docs/releasing.md, that the existing pytest job (test_strip_shell_comments_900.py::test_this_repository_built_tree_has_no_check_failures) already gates hook size pre-merge across the full 3-OS/4-interpreter matrix, so part 2 needed no new CI job.

Refs #904.

Self-review (an Explore-type reviewer plus oss:auditor, both spawned read-only against the first commit) found four real coverage gaps, all addressed: the jit-context match pattern under-covered hooks.d/*.sh (fixed), the needle missed an unquoted positional splice (fixed), the function keyword declaration form was invisible to the regex (fixed), and two misreports-class gaps -- a single-physical-line function body and CRLF line endings, both independently reproduced as red against the pre-fix committed source before being fixed. One related shape (msg=$(other_func "text $1"), a command-substitution assignment rather than a bare delegating call) was deliberately left out of scope, recorded as a reasoned decision in the commit message rather than filed separately.

44 targeted tests green across the touched suite; full repository suite left to CI per this repo's own test_command discipline.

[AI-generated]

fdaviddpt and others added 3 commits October 5, 2026 22:51
Refs #904

check_release_tree.py now FAILs any shipped shell function whose whole
body is a single call to another function with a positional parameter
($1..$9, ${1}..) spliced into a string argument. This is the shape that
held three of scripts/log.sh's dispatch reporters at the Anthropic
directory as COMMAND_SCRIPT_NOT_FOLLOWED until #899 r40 restored them
to self-contained bodies; tests/test_dispatch_reporter_shape_898.py
pinned it only for those three named functions, this generalizes the
needle to any shipped function. Red test first
(tests/test_single_line_delegate_positional_905.py), paired
must-fire/must-not-fire controls, and confirmed today's log.sh and the
real built release tree do not trip it.

Also closes #904 parts 1 and 2 (not part 3, the session-start
redesign):
- part 1: a .claude/jit-context entry
  (paths/00-manual/hook-script-size-budget.md) fires on any edit under
  scripts/*.sh, stating the 128 KiB scanner limit, the 120 KiB release
  budget, and the scanner's known triggers (case, typed <<, naming
  another script by path, and this issue's positional-delegate shape).
  Proven to fire on scripts/log.sh and scripts/session-start-hook.sh
  edits and to stay silent on README.md.
- part 2: confirmed the ordinary pytest job already gates this on every
  pull request via
  test_strip_shell_comments_900.py::test_this_repository_built_tree_has_no_check_failures,
  which builds the release tree and asserts zero check_release_tree.py
  offenders. No new CI job was needed; documented the gap in
  docs/releasing.md instead.

Closes #905

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Refs #904

Self-review (Explore + oss:auditor spawned against the committed diff)
found that _check_single_line_delegate_positional missed real instances
of its own target shape:

- a function declared with the `function` keyword, not only bare
  `name()` -- _FUNC_DEF_MULTI/_FUNC_DEF_SINGLE now accept an optional
  `function` prefix.
- an unquoted positional splice (`other_func msg:$1`) -- the check now
  also scans bareword arguments after stripping quoted segments, not
  only double-quoted strings, while still exempting a bare `$1`
  standing alone as its own argument.
- the hook-script-size-budget.md jit-context entry's `match:
  scripts/.*\.sh$` under-covered what check_release_tree.py's own
  _SCRIPT_DIRS actually scans (hooks/ and hooks.d/ ship real tracked
  .sh files too, e.g. hooks.d/after_save/50-git-backup.sh) -- widened
  to (scripts|hooks|hooks\.d)/.*\.sh$ and proven to fire on a
  hooks.d/*.sh edit.

Also fixed, found independently while verifying the auditor's CRLF/
single-line-body report: a single physical-line function body
(`name() { stmt; }`, the actual r38/r39 on-disk shape) and a CRLF-
encoded .sh (this repo ships no .gitattributes, so nothing forces LF)
both silently evaded the multi-line-only regex. Confirmed red against
the prior committed version before fixing, via a direct re-exec of
that version's check_tree over both fixtures.

Six new paired must-fire/must-not-fire tests; full targeted suite
(44 tests across this file + test_dispatch_reporter_shape_898.py +
test_strip_shell_comments_900.py + test_release_branch_check_900.py)
green.

Not fixed, judged out of the needle's literal scope (whole body is a
single CALL, not an assignment): `msg=$(other_func "text $1")` -- a
variable assignment whose RHS is a command substitution calling
another function is a related but distinct shape from "the function's
whole body delegates," and extending to it risks new false
positives/negatives without a second held-shape data point to pin
against. Noted in the PR body rather than filed, since it is this
diff's own code and not blocking.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Refs #904

Auditor review noted _check_single_line_delegate_positional had no
try/except around data.decode("utf-8"), unlike its neighbor
_check_shell_comments, which reports a non-UTF-8 file as an offender
rather than letting the decode raise and crash the whole check_tree
run. Mirrors that sibling's handling (one line, same message shape).
Not a general fix: _check_launchers has the same gap and is out of
this diff's scope.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@fdaviddpt
fdaviddpt merged commit 950a703 into main Oct 5, 2026
31 of 34 checks passed
fdaviddpt added a commit that referenced this pull request Oct 6, 2026
* docs(trap.d): log round-1 v0.41.0 release-audit findings

Gate 3's oss:release-auditor found two non-blocking (misreports) findings in
the v0.40.0..HEAD delta (#911/#912): the #902 FATAL refusal is unreadable
because log()'s own stderr fallback never fires once MEMORY_LOG_FILE is
/dev/null, and the #902 changelog fragment overclaims mkdir-guard coverage
since bootstrap-dirs.sh builds the same tree ahead of the guard on the slow
path. Logged rather than filed per findings.md's misreports routing; /oss:curate
decides later whether either becomes a rule.

Co-Authored-By: Max <noreply>

* docs(trap.d): clarify misreports routing note

Co-Authored-By: Max <noreply>
@fdaviddpt
fdaviddpt deleted the fix/905 branch October 31, 2026 17:18
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.

Release check: fail on a one-line reporter that calls another function with positional parameters in the message (directory trigger)

1 participant