Repository navigation
Merged
Conversation
… hook-errors.log writers (#620, #621, #618) - #620: post-tool-hook.sh's basename-derived SESSION_ID (used whenever stdin does not supply a trusted session_id) reached save-session.sh's argv unguarded. Applies the same leading-dash guard #610 already gives the stdin route, at the point the basename id is derived, and corrects the comment that claimed both routes already shared it. - #621: log() forked printf|tr on every call to flatten control bytes (#599), even for the large majority of messages that carry none. A cheap in-shell case match now gates the fork on whether one is actually present. - #618: #599's control-byte flatten never reached hook-errors.log's four raw writers (_dispatch_report_failure, _dispatch_report_skip, report_error, _dispatch_report_timeout), which write a second, raw copy of the same message outside log(). All four now flatten before either write. Corrects #599's own coverage claim in scripts/log.sh's comment (the already-released CHANGELOG.md entry is left as historical record). Each fix is paired with a red-then-green test carrying a positive control. See the PR body for the #620 impact analysis (narrower than filed, because save-session.sh's own session-id-shape check independently closes the gap for this specific route) and the #621 judgment call record. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c
…uilds CI on fix/620 (PR #627) reported a genuine, deterministic red on all 4 windows-latest legs (Python 3.9-3.12): the #621 pre-check in log() -- `case "$message" in *[[:cntrl:]]*)` -- never matched a message carrying a real embedded newline under Git Bash's MSYS2-built bash, so `tr` was never invoked and the flatten silently never ran. Every ubuntu-latest and macos-latest leg passed, and so did this repo's own macOS dev machine, on an old bash 3.2.57. `[[:cntrl:]]` is a POSIX bracket CLASS -- a ctype/locale table lookup a shell build can implement however it likes. Replaced with a literal byte-value range test via ANSI-C quoting (the C0 range plus DEL), which performs a straight ordinal comparison with no ctype table and nothing left for a different bash build to classify differently. Could not reproduce directly on Windows (no such machine available here); this fix is reasoned from the failure signature (deterministic, all 4 interpreters, only that platform, only that one assertion) rather than observed against the actual CI failure. Broadened tests/test_log_hot_path_tr_spawn_621.py with an explicit parametrized case per control-byte class (tab, CR, DEL, unit separator) so more than one single byte value pins the range this fix claims to cover. All 6 tests in that file plus the full adjacent suite (83 tests) pass locally on macOS. Asking for another Windows CI run to confirm. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c
Second CI round-trip on fix/620 (PR #627) showed the real symptom: every control-byte class added in the previous commit failed identically on windows-latest/3.11, with the same signature -- the message came out CORRECTLY FLATTENED (e.g. a tab became a space), but the test's own "did tr get invoked" ledger was never created. That rules out the control-byte pre-check as the cause: log() was flattening correctly the whole time. The REAL system tr was running in the stub's place. Root cause: tests/test_log_hot_path_tr_spawn_621.py's `_run()` prepended the stub's directory onto $PATH via subprocess's `env=` dict, joined with `os.pathsep` -- `;` on Windows. Git Bash's bash.exe is a POSIX shell and always wants $PATH colon-separated internally, regardless of host OS, so the semicolon-joined value the test constructed could not be parsed the way the test intended, and PATH resolution silently fell through to the real system tr instead of the stub. Fixed by prepending the stub's directory to $PATH from INSIDE the bash script itself (`export PATH="$BINDIR:$PATH"`, a literal colon, extending bash's own already-POSIX $PATH) rather than through the Python-constructed env dict -- this sidesteps the ambiguity entirely rather than depending on how MSYS2 converts an externally-injected PATH value. Also corrected the previous commit's changelog claim: whether the earlier `[[:cntrl:]]` bracket-class pre-check ever genuinely failed to match a control byte on Windows is, on this evidence, no longer established -- the harness bug fully explains both observed failures (the original single-case one and this one), so the byte-range change in scripts/log.sh remains a reasonable portability improvement but is not confirmed to have fixed anything real. Left in place rather than reverted: it is not worse, and reverting now is pure churn. Could not verify on an actual Windows machine (none available here); reasoned from the failure signature across two CI round-trips rather than observed directly. All 83 tests in the adjacent suite still pass locally on macOS. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c
…ional flatten Three portability attempts at gating log()'s printf|tr flatten behind a cheap in-shell pre-check each broke a different CI platform in ways this repo could not reproduce locally (multiple bash builds, multiple locales, an emptied environment): a POSIX [[:cntrl:]] bracket-class version missed control bytes under windows-latest Git Bash, and a follow-up ANSI-C byte-value range meant to sidestep exactly that ctype/locale dependency then did the identical thing on every macos-latest leg instead (PR #627, run 34086759256). #621 itself calls this a cost optimization, optional ("if judged worth it"), not a correctness fix, and #618/#620 -- correctness fixes landing in the same pull request -- should not keep failing CI because of it. log() now forks the flatten unconditionally again, exactly as it did before #621. Removed tests/test_log_hot_path_tr_spawn_621.py, which existed solely to verify the now-abandoned pre-check (its Windows leg was itself unreliable: a separate PATH/stub-interception artifact, not a log.sh bug). tests/test_log_newline_sanitization_599.py remains the correctness regression guard and needs no change. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c
Self-review (Explore) caught: fc84430 (bracket-class pre-check) and ec41c8d (ANSI-C byte-range pre-check) are the only two portability attempts at #621's control-byte pre-check before it was abandoned in 8875f17 -- not three. changelog.d/621.fixed.md already had the count right; only the in-source comment in scripts/log.sh repeated the miscount. Corrected there. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c
This was referenced Sep 7, 2026
fdaviddpt
added a commit
that referenced
this pull request
Sep 7, 2026
PR #628's CI was systematically red on all four macos-latest legs (3.9-3.12, Windows and Ubuntu all green) -- every failure was the same four tests in tests/test_save_session_marker_unreadable_625.py, same symptom: "bash: ts_marker_read: command not found". The helper extracted ts_marker_read()'s definition via `source <(sed -n '/^ts_marker_read()/,/^}/p' FILE)`. That process substitution worked on every macOS bash tried locally (3.2.57 and Homebrew 5.x) but was observed failing, consistently, only on macos-latest GitHub Actions runners -- the same shape of macOS-CI-only shell-substitution flakiness this session had already hit once this session (#621/#627) with a different fragile trick, and equally unreproducible locally. Per the maintainer's steer after reporting the CI failure (verified via gh-pr:628:status and gh-job:*:fail before making this change, matching the report exactly): dropped process substitution rather than continuing to chase an unreproducible CI-only mechanism. `_extract_ts_marker_read_source()` now pulls the function's source with a plain Python regex (byte-identical range to the old `sed` selection) instead of shelling out to `sed`, and `_call_ts_marker_read()` writes it to a real temp file and `source`s that, removing the `<(...)` construct from this path entirely. Verified locally: all 9 tests in the file still pass, including the FIFO hang regression test (confirmed it still fails fast rather than trivially passing). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c
fdaviddpt
added a commit
that referenced
this pull request
Sep 7, 2026
… recovery hint (#626) (#628) * Fix absent-vs-unreadable collapse at two more markers (#625), add NDC recovery hint (#626) #619 fixed `cat FILE 2>/dev/null || echo 0` collapsing "never created" and "exists but a read failed" into the same 0, at NDC_GEN_FILE. The identical pattern was still present, unfixed, at COOLDOWN_MARKER (tmp/last-save-ts) and NDC_MARKER (tmp/last-ndc.ts). A durably unreadable marker there silently defeats its cooldown on every invocation, forever, with nothing in the log to say so -- lower stakes than NDC_GEN_FILE (an extra Haiku call, not lost data), but the same silent failure mode. Both now go through a shared ts_marker_read() helper, the same shape as #619's ndc_read_gen(), and log a WARNING naming the marker when a read fails instead of proceeding in silence. Fixing this surfaced an adjacent defect: the unconditional `date +%s > "$MARKER"` write below each read was unguarded, so a durably unwritable marker (a directory reproduces this without depending on a uid ever being denied a permission bit) crashed the WHOLE script under `set -e` -- a harder failure than the documented "fails open" behaviour. Both writes are now guarded the same way the existing self-heal write already is. #626: the SKIPPED-commit log line #619 added for a durably unreadable NDC_GEN_FILE now also names the remedy -- delete it to reset generation tracking to 0 -- instead of leaving every future round to land on the same line with no hint of the way out. Two doc rows added to docs/windows-skip-triage.md for the two new blanket win32-skip test modules, per repo convention. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c * Self-review fixes: FIFO hang, stale comments, misleading wording (#625) Two spawned reviewers (Explore + oss:auditor) found three issues in the #625/#626 commit: 1. Widening the marker-existence test from `-f` to `-e || -L` (needed so a directory-in-place-of-marker reaches the read guard instead of silently skipping it) also let a FIFO reach `ts_marker_read`'s unconditional `cat`. `cat` on a FIFO with no writer present blocks forever -- no O_NONBLOCK, no timeout anywhere in this script -- which is a HARDER failure than the "fails open" behaviour this fix exists to guarantee. Fixed: ts_marker_read now rejects any non-regular file before ever calling `cat` on it. Reproduced the hang against a scratch copy with the guard removed (TimeoutExpired), confirmed the fix returns "unreadable" in milliseconds, and pinned both with three new tests (FIFO, a plain regular-file control, an absent-marker control) that call the function in isolation via process substitution rather than through the full script, so a regression fails fast instead of hanging the suite. 2. The downstream `case "$LAST_MOD"/"$NDC_MOD" in ''|*[!0-9]*) ...=0 ;; esac` at both marker sites is now unreachable through this read path -- ts_marker_read already intercepts anything that would have hit it, and converts its own "unreadable" sentinel to 0 first. The ~30-line comment block explaining #326/#258's arithmetic-parse-failure self-heal is still accurate history but no longer describes this path's live behaviour. Added one clarifying paragraph at each site rather than rewriting the history away. 3. The new WARNING wording ("exists but could not be read") was specific to read failures, but ts_marker_read's "unreadable" sentinel also covers a read that SUCCEEDED and returned unparseable content (corrupted by an interrupted write, stray whitespace) -- a case where the marker plainly WAS read. Reworded both WARNINGs to "its value could not be used (a read failure, or content that is not a plain timestamp)", accurate for both. Updated the test constant and assertions to match. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c * Fix stale dangling-symlink claim in ts_marker_read's own comment (#625) A re-audit round (spawned after the classifier flagged the first oss:auditor return as referred-not-stated, per the developer brief's review-return protocol) found one real finding: the module-level comment above ts_marker_read claimed a dangling symlink "echoes 0" the same as a marker that was never created. It does not -- `-L` is true for a dangling symlink, so `[ ! -e ] && [ ! -L ]` is false and the function falls through to "unreadable" instead, the same as ndc_read_gen's own (correct) comment already describes for the identical case. Verified by extracting the function and calling it directly against a real dangling symlink, before and after this fix. Corrected the comment to point at ndc_read_gen's own accurate description instead of restating it wrong, and added a test pinning the actual behaviour (unreadable, not 0) so this claim has a red/green check rather than resting on prose alone. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c * Fix macOS-CI-only ts_marker_read isolation helper (PR #628 CI failure) PR #628's CI was systematically red on all four macos-latest legs (3.9-3.12, Windows and Ubuntu all green) -- every failure was the same four tests in tests/test_save_session_marker_unreadable_625.py, same symptom: "bash: ts_marker_read: command not found". The helper extracted ts_marker_read()'s definition via `source <(sed -n '/^ts_marker_read()/,/^}/p' FILE)`. That process substitution worked on every macOS bash tried locally (3.2.57 and Homebrew 5.x) but was observed failing, consistently, only on macos-latest GitHub Actions runners -- the same shape of macOS-CI-only shell-substitution flakiness this session had already hit once this session (#621/#627) with a different fragile trick, and equally unreproducible locally. Per the maintainer's steer after reporting the CI failure (verified via gh-pr:628:status and gh-job:*:fail before making this change, matching the report exactly): dropped process substitution rather than continuing to chase an unreproducible CI-only mechanism. `_extract_ts_marker_read_source()` now pulls the function's source with a plain Python regex (byte-identical range to the old `sed` selection) instead of shelling out to `sed`, and `_call_ts_marker_read()` writes it to a real temp file and `source`s that, removing the `<(...)` construct from this path entirely. Verified locally: all 9 tests in the file still pass, including the FIFO hang regression test (confirmed it still fails fast rather than trivially passing). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c * Fix pep604_floor_guard false-positive on the new extraction helper The previous commit (6e6f29c) fixed the macOS-CI-only process-substitution failure but introduced a new one: this repo's own test_the_repo_has_nothing_the_discriminator_could_not_decide gate flags any module-level `|` expression it cannot classify as bitwise vs. type-union, and `_TS_MARKER_READ_RANGE = re.compile(pattern, re.MULTILINE | re.DOTALL)` at module level tripped it -- observed on ALL SIXTEEN legs uniformly (this gate is a static AST walk, not platform-conditional), unlike the prior macOS-only failure. Per pep604_floor.py's own documented scope, a function-local `|` is out of scope for this guard entirely (it only runs at call time, so it cannot take out a 3.9 leg at import). Moved the regex out of the module-level assignment and inlined it as an re.search(...) call inside _extract_ts_marker_read_source() instead of pre-compiling it at module scope -- no behavior change, same regex, same bytes extracted. Verified locally: test_the_repo_has_nothing_the_discriminator_could_not_decide passes, ruff clean, and the file's own 9 tests still pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
fdaviddpt
added a commit
that referenced
this pull request
Sep 10, 2026
…he macOS case/glob landmine (#644) * Document that #621's hot-path pre-check was abandoned, not shipped (#629), and record the macOS case/glob byte-range landmine (#630) Both issues are record-keeping follow-ups to #627 (issues #618/#620/#621). No behavioural code changes: `log()` already forks its `printf | tr` control-byte flatten unconditionally (the pre-#621 shape #627 restored), and #621's own closed-issue comment plus CHANGELOG.md's 0.30.0 entry already state accurately that the optimization was abandoned rather than shipped. Verified both are correct against the actual git history (git log on fix/620, gh-issue:621:full, gh-pr:627) before concluding no code change was warranted for #629. #630 asks that the specific failure mode -- a case/glob byte-range pattern silently failing to match a real control byte on macos-latest CI, mechanism unknown, not reproducible locally -- be made discoverable beyond a closed PR's history, since the pattern shape is a plausible thing to reach for again anywhere in this codebase. Logged as trap.d/630.macos-case-byte-range-silent-mismatch.md for the curation pass to weigh as a jit-context rule. changelog.d/629.changed.md and changelog.d/630.changed.md fragment both. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c * Fix #629 fragment: the test-harness PATH-injection fix targeted windows-latest, not macOS Self-review (Explore reviewer against commit 157e3d5) caught that changelog.d/629.changed.md's third pre-check attempt was described as "aimed at the still-red macOS leg." The actual commit (7a9069f, "fix(#621 test harness): stop injecting PATH via os.pathsep for Git Bash") diagnoses and resolves a windows-latest/3.11-specific PATH separator bug and says nothing about macOS; the macOS failure mode stayed unexplained through that commit and into the next one. That wording was inherited near-verbatim from #629's own issue body rather than re-derived from git log, despite the previous commit message claiming the history was verified. Corrected to say what the commit actually targeted and that the macOS mechanism was left unexplained -- the distinction #630 exists specifically to keep from being blurred. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c * Fix #629 fragment: match the authoritative "two attempts, third round" framing exactly Re-review (fresh Explore spawn against f4cbdab) caught that changelog.d/629.changed.md said "three attempts on that branch," counting the test-harness PATH-injection fix (commit 7a9069f, a fix to test infrastructure, not to the pre-check logic) as a third attempt at the pre-check itself. scripts/log.sh's own comment on log() ("tried twice... a two-attempt failure record") and CHANGELOG.md's 0.30.0 entry for #621 ("two portability attempts... a third round of unreproducible platform fragility") both already draw this line correctly and were the exact record this fragment claimed to be consistent with. Reworded to match that framing precisely, quoting both sources, rather than leave a contradicting count sitting beside the record it cites as authoritative. Also cleans up an unrewrapped short line left by the previous fixup. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c --------- Co-authored-by: Claude Opus 5 (1M context) <[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.
Closes #620, closes #621, closes #618.
Three issues from the same release-3-audit lane against
scripts/log.sh/scripts/post-tool-hook.sh.#620 -- basename-derived SESSION_ID reached save-session.sh's argv unguarded
post-tool-hook.shderivesSESSION_IDfrom the TRANSCRIPT basename whenever stdin does not supply a trustedsession_id. That value reachednohup "$SAVE_SCRIPT" "$SESSION_ID" ...with no guard, unlike the stdin-derived id, which #610 already guards against a leading dash. The fix applies the identical case-statement guard (''|.|..|-*|*[!A-Za-z0-9._-]*) at the point the basename id is computed, and corrects a nearby comment that incorrectly claimed both routes already shared it.Pushback / impact correction: the audit's own reproduction of #620 was not run. I verified the code shape is real, but empirically the described impact ("silently turns a real delta-triggered save into a no-op --dry preview") does NOT reproduce for this specific route. Tracing it: whatever value post-tool-hook.sh hands
save-session.shas argv[1],save-session.sh's own arg loop reads--dry/--forceas a FLAG rather than a positional id, leaving its ownSESSION_IDempty, which triggers its own auto-detect (if [ -z "$SESSION_ID" ], same "newest .jsonl in this directory" rule) -- and because the basename-derived id and the transcript that auto-detect independently re-discovers are always the SAME file, it re-derives the identical--dry/--forcestring and rejects it via its own session-id-shape check (^[a-f0-9][a-f0-9-]*$) before DRY_RUN is ever consulted. I reproduced this directly (manual runs withbash -x, quoted in the commit history of this branch) and confirmed the end-to-end outcome is byte-identical whether or not the new guard is present: anERROR: invalid session IDline in the daily log, no dry-run banner, no corruption. This is unlike #610's own exploit, which decouples a crafted stdin id from a real, unrelated transcript path -- that decoupling is what lets a REAL session get silently dry-run'd, and it cannot happen via the basename route because the id IS the transcript name there.Given that, I still implemented the fix, for three reasons stated rather than assumed: (1) it is cheap, correct, and requested explicitly; (2) it is genuine defense-in-depth against a future change to
save-session.sh's own validation or auto-detect logic silently reopening this route; (3) it fixes a real, separate defect -- the code comment claiming both routes already shared the guard was simply false before this diff. The new test (tests/test_post_tool_basename_dry_flag_injection_620.py) is scoped accordingly: rather than asserting onsave-session.sh's end-to-end DRY RUN output (which cannot distinguish fixed from unfixed for this route, as shown above), it stubssave-session.shvia a fake plugin root and asserts directly on the argvpost-tool-hook.shhands it -- the guard under test, isolated from the downstream validation that happens to also close the gap.#621 -- log() forked printf|tr unconditionally on the hot path
log()forks aprintf | trpipeline on every call to flatten control bytes (#599), even though the large majority of messages this codebase logs carry none.log()runs on the per-tool-call hot path. Fixed with a cheap in-shellcase "$message" in *[[:cntrl:]]*) ... ;; esacpre-check (no subprocess) that only pays for the fork when a control byte is actually present;local LC_ALL=Cscopes the character-class match to the C locale (function-local, restored on return) for the same byte-level correctness reason #599 forced on the tr pipeline itself.Judgment call, recorded as requested: yes, worth fixing. The cost is small per call but log() fires multiple times per tool invocation across post-tool-hook.sh's various WARNING branches, and this repository already treats hot-path spawn count as a costed invariant elsewhere in the same file (the
[ -d ]-before-mkdir -pguard, the_LIB_MEMORY_DIR_LOADEDre-source guard). The fix is a few lines, has no behavioral change for messages that do carry control bytes (verified: same tr pipeline, same LC_ALL=C), and is covered by a red-then-green test with a positive control.#618 -- #599's flatten never reached hook-errors.log's four raw writers
#599's control-byte flatten only ever covered
$MEMORY_LOG_FILE(log()'s own daily narrative file). Four functions inscripts/log.sh--_dispatch_report_failure,_dispatch_report_skip,report_error,_dispatch_report_timeout-- each write a SECOND, raw, unflattened copy of the same message straight tohook-errors.logvia their ownprintf, entirely outsidelog().hook-errors.logis the file/remember:doctortails under "Recent errors" and the one maintainers ask reporters to paste -- exactly the file #599's own rationale names as the one that matters, anddoctor.shreads it viatail -n 5, treating each line as one entry, so a forged embedded newline could both masquerade as a second attacker-shaped entry and push a genuine one out of the tail window. All four writers now flatten before either write. This also corrects #599's own coverage claim ("the class is closed everywherelog()is used") -- true oflog()callers, never true ofhook-errors.log's own raw writers, which #599 never reached. The already-releasedCHANGELOG.mdentry under 0.29.0 is left as historical record rather than hand-edited;changelog.d/618.fixed.mdis the correction, sincechangelog.d/599.fixed.mdno longer exists (it was already folded intoCHANGELOG.mdat release 0.29.0/0.29.1, before this lane started).Verification
All three fixes follow TDD: a new test written first, run and shown red for the stated reason, then the fix, then green. Positive controls pair every "must not fire" assertion. Full commit history on this branch shows the red/green transitions.
Targeted run at HEAD (this commit):
python3 -m pytest tests/test_post_tool_basename_dry_flag_injection_620.py tests/test_log_hot_path_tr_spawn_621.py tests/test_hook_errors_log_control_byte_618.py tests/test_log_newline_sanitization_599.py tests/test_log_sh.py tests/test_log.py tests/test_post_tool_session_id.py tests/test_post_tool_dry_flag_injection_610.py tests/test_codex_stdin_session_id_468.py tests/test_post_tool_cooldown.py tests/test_post_tool_save_log_swept_527.py tests/test_transcript_path_trust_431.py -q --no-cov->92 passed. The repo's wholetest_command(pytest) was deliberately NOT run locally; CI is the gate for the full matrix.python3 .oss/assemble_changelog.py --check->ok (3 fragments ... all names parse ...).docs/windows-skip-triage.mdgained one row for the new blanket win32-skip test module (tests/test_post_tool_basename_dry_flag_injection_620.py), verified againsttests/test_windows_skip_triage_497.py(2 passed).Self-review: two spawns (Explore + oss:auditor) against the committed diff, both returned NO FINDINGS (classified via
scripts/review_return.pyasno-findingsin both cases, not inferred from tone). Tree snapshot before/after both spawns: clean, no mutation.README.md (this repo's only
docs_targetsentry) does not mention any of these three internal script details (hook-errors.log,SESSION_ID,DRY_RUN, argv) -- checked, no change needed.🤖 Generated with Claude Code
[AI-generated]