Summary
Two claims in the rules files are wrong. Both were relied on while planning performance work, and both would mislead the next person the same way.
1. Subshells do not inherit the RANDOM state
.claude/rules/perf-fork-budget.md:257 and .claude/rules/architecture-map.md say a Bash 3 subshell inherits $$ and the RANDOM state, and give that as the reason a worker cannot mint a unique token.
Measured: three forked subshells printed three different $RANDOM values on 3.00.22, 3.2.57, 4.0.44, 5.2.37 and 5.3.15. Bash reseeds RANDOM per subshell.
The conclusion those files draw still holds, and the ordinal scheme (#851) should stay: an ordinal is guaranteed unique, a reseeded RANDOM is only probably unique, and $$ genuinely is inherited. So the fix is to the stated mechanism, not to the design. Worth correcting because "RANDOM is shared" is the kind of claim that gets reused as a premise.
2. shopt -u extdebug has a version-dependent side effect
shopt -s extdebug turns on errtrace and functrace on every supported build. Turning it back off does not behave the same everywhere:
| Build |
shopt -u extdebug leaves errtrace/functrace |
| 3.00.22, 3.2.57, 4.0.44 |
on |
| 5.2.37, 5.3.15 |
off, even if they were on beforehand |
So on Bash 5.2 and above, disabling extdebug silently clears set -E and set -T. That is the concrete shape of the hazard #808 works around, and it changes across the supported range, which the comments at src/runner/context.sh:84-88 and src/runner/discovery.sh:345-350 do not say.
This matters for anything that touches those paths, including #1346: a rewrite that stops using a subshell there has to save and restore errtrace/functrace on 5.2+, or it will turn off --strict error tracing as a side effect.
Expected behavior
Correct both claims where they are stated, and add the extdebug table to the comment at the two call sites, since that is where someone will read it. A test pinning the extdebug side effect per version would also stop it drifting.
Summary
Two claims in the rules files are wrong. Both were relied on while planning performance work, and both would mislead the next person the same way.
1. Subshells do not inherit the
RANDOMstate.claude/rules/perf-fork-budget.md:257and.claude/rules/architecture-map.mdsay a Bash 3 subshell inherits$$and theRANDOMstate, and give that as the reason a worker cannot mint a unique token.Measured: three forked subshells printed three different
$RANDOMvalues on 3.00.22, 3.2.57, 4.0.44, 5.2.37 and 5.3.15. Bash reseedsRANDOMper subshell.The conclusion those files draw still holds, and the ordinal scheme (#851) should stay: an ordinal is guaranteed unique, a reseeded
RANDOMis only probably unique, and$$genuinely is inherited. So the fix is to the stated mechanism, not to the design. Worth correcting because "RANDOM is shared" is the kind of claim that gets reused as a premise.2.
shopt -u extdebughas a version-dependent side effectshopt -s extdebugturns onerrtraceandfunctraceon every supported build. Turning it back off does not behave the same everywhere:shopt -u extdebugleaveserrtrace/functraceSo on Bash 5.2 and above, disabling
extdebugsilently clearsset -Eandset -T. That is the concrete shape of the hazard #808 works around, and it changes across the supported range, which the comments atsrc/runner/context.sh:84-88andsrc/runner/discovery.sh:345-350do not say.This matters for anything that touches those paths, including #1346: a rewrite that stops using a subshell there has to save and restore
errtrace/functraceon 5.2+, or it will turn off--stricterror tracing as a side effect.Expected behavior
Correct both claims where they are stated, and add the extdebug table to the comment at the two call sites, since that is where someone will read it. A test pinning the extdebug side effect per version would also stop it drifting.