Repository navigation
Merged
Conversation
…u failure detail to hook-errors.log #691: previous_transcript() (and its no-CURRENT_SESSION_ID sibling) forked `ls -t` over the whole session directory on every start just to read one line off the top, throwing the sort away -- the only per-session cost that grows with how long a project has been used (0.104s at 500 past transcripts, 0.41s at 2000, per #660's own diagnostic). Both call sites are now a single pass over the glob that compares mtimes with bash's own `-nt` test builtin, so the cost no longer scales with transcript count at all. #694: a failed background save reported only `exited 1` in hook-errors.log while the nested Haiku CLI's own failure detail -- already computed and already length-capped -- went only to the daily narrative log nobody reads while diagnosing a live outage (#693: 12 occurrences over several days before anyone found it in the second file). save-session.sh's two internal failure sites (a failed call, an empty response) now call report_error() instead of log() alone, so the same detail reaches the file /remember:doctor tails and a reporter is asked to paste. Propagation only, no new diagnosis. New tests for both, each with a real red-before-fix run; guard set checked via scripts/lane_setup.py (no cross-cutting guards apply in this repo). Changelog fragments for both issues, verified against .oss/assemble_changelog.py --check. A new module-level win32 skip gets its docs/windows-skip-triage.md row in this same commit, per CLAUDE.md's own convention. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…b output Self-review finding (oss:auditor) on e0357f6: three assertions in tests/test_previous_transcript_no_sort_691.py compared bash's own glob output (always joined with a literal forward slash, verbatim on whatever $dir it was handed) against Python's str(Path) (all-backslash on Windows), so a passing local run would still fail on windows-latest CI -- a correct fix reported as broken by its own test. Folds every occurrence of the platform separator byte to a forward slash on both sides before comparing. Re-ran the file after the fix: all 5 tests still pass. 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.
Two independent fixes, both filed against the #660 diagnostic and its follow-on reports.
#691 -- previous_transcript() sorted every transcript in SESSIONS_DIR
previous_transcript()in scripts/session-start-hook.sh forkedls -tover the whole session-transcripts directory on every session start, read one line off the top, and threw the sort away. Measured on windows-latest (the #660 diagnostic): 0.104s at 500 past transcripts, 0.41s at 2000 -- the only per-session cost in the hook that grows with how long a project has been used. A sibling call site (the no-CURRENT_SESSION_ID fallback) had the identical shape.Both call sites are rewritten to a single pass over the glob comparing mtimes with bash's own
-nttest operator (a builtin, not a fork).previous_transcript()tracks the newest file excluding the current session id; a new_second_newest_jsonl()helper tracks the second-newest overall for the fallback site, setting a global rather than being captured via$(...)so it costs no subshell either. Both functions now spawn zero external processes at any transcript count.Closes #691
#694 -- a failed background save reported only "exited 1" in hook-errors.log
scripts/save-session.sh's Haiku-call failure path called
log()only, which writes solely to the daily narrative log. The real cause -- already dug out of the CLI's stdout JSON by pipeline/haiku.py's_failure_detail()and printed to stderr bypipeline.shell call-haiku's own exception handler -- never reached hook-errors.log, the file/remember:doctortails and a reporter is asked to paste. One installation (#693) failed every background save for days with hook-errors.log saying only "exited 1" the whole time, while the real cause (an ANTHROPIC_API_KEY precedence issue) sat in the daily log on all 12 occurrences.This call site, and a sibling with the identical shape for an empty Haiku response, both switch from
log()toreport_error(), which writes to both the daily log AND hook-errors.log. Propagation only --_failure_detail()itself is untouched.Closes #694
Testing
Both fixes are test-first (red confirmed against the unmodified code, reapplied and green). See the two new test files for the exact assertions: tests/test_previous_transcript_no_sort_691.py (5 tests, including a spawn-count assertion at a realistic 500-transcript count) and tests/test_haiku_failure_reaches_hook_errors_694.py (3 tests, a must-fire, a must-not-fire negative control, and the empty-response sibling). Related existing test files were re-run and show no regression.
Self-review (Explore + oss:auditor spawned together) found one Windows-only test-portability defect in the new #691 test file (bash's forward-slash-joined glob paths vs Python's backslash
str(Path)on Windows) and it was fixed in a follow-up commit on this branch.Not included: #690
#690 was already fixed and merged before this branch existed (PR #708, commit 9bdcde4, now on main). It was reopened because its own end-to-end promise -- a bash -x trace surviving past bootstrap, on Windows -- is unverified:
test_the_real_hook_traces_past_the_bootstrapisxfail'd on Windows, tracked separately as #712, which needs a real Windows runner to diagnose. Nothing actionable for #690 remains in this branch; no code here touches it.[AI-generated]