Skip to content

Fix #1047: bound what SessionStart keeps from stdin, not just how it reads it - #1049

Closed
CNSeniorious000 wants to merge 3 commits into
Digital-Process-Tools:mainfrom
CNSeniorious000:fix/1047
Closed

CNSeniorious000 wants to merge 3 commits into
Digital-Process-Tools:mainfrom
CNSeniorious000:fix/1047

Conversation

@CNSeniorious000

@CNSeniorious000 CNSeniorious000 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1047.

What

session-start-hook.sh crops each side of the stdin join to 4 KB, so the payload its extractors see cannot exceed 8 KB whatever the host sends — and the four extractions over it (cwd, session_id, transcript_path, source) stay linear-size.

    while IFS= read -r -t 1 _line || [ -n "$_line" ]; do
        HOOK_STDIN="${HOOK_STDIN:0:4096}${_line:0:4096}"
        _line=""
    done

Why

_stdin_json_string_into opens with ${_sjsi_raw#*\"$_sjsi_key\"}, and a leading * makes bash retry the matcher at every offset — quadratic. Measured on bash 5.2.15: 0.28 s at 12.5 KB, 0.95 s at 25 KB, 3.55 s at 50 KB, 15.2 s at 100 KB, against 2-6 ms for the case one line below it on the same strings. Dropping the leading * is not an option: docs/releasing.md already records that both ${x#*P} and ${x%%P*} are quadratic on a miss.

The loop's own HOOK_STDIN="$HOOK_STDIN$_line" is the second quadratic, for many-line input rather than one huge line (6 MB across 5,000 lines: 63-91 s, against 0.4-0.7 s cropped). That is why the bound belongs in the read loop rather than only in the extractor: one 18-byte crop closes both.

The #1040 comment this sits under already says why the line loop itself is fine ("a few hundred bytes: milliseconds even at that rate"). That is a claim about a payload the host chooses, and nothing enforced it. Full numbers, and the 27 orphaned processes this was found on, are in #1047.

Red, then green

Red — with scripts/session-start-hook.sh reverted to main (tests, docs and fragment left in place), on Linux / bash 5.2.15, the same transcript-shaped payload the third test uses (1 MB over 64 lines):

pre-fix rc=124 elapsed=60s published=NONE      # timeout(1), never finished
post-fix rc=0  elapsed=605ms published=4096

and on macOS / bash 3.2, the deterministic test:

E   AssertionError: the hook published a 16419-byte payload; the bound is 8192
1 failed, 1 passed, 1 skipped

Green — this branch:

macOS, bash 3.2 (resolve_bash here):   2 passed, 1 skipped
macOS: tests/test_locale_ranges_695.py 5 passed
adjacent SessionStart modules:         123 passed, 13 skipped

The positive control is green in BOTH runs on purpose: a bound that cropped everything would pass the first assertion too.

The three tests

test what it is evidence of
..._a_16_kb_stdin_is_cropped_before_the_hook_publishes_it deterministic, counted by execution rather than by a clock: a hooks.d/ listener reports how many bytes the hook published in REMEMBER_HOOK_STDIN_FILE
..._a_real_payload_arrives_byte_for_byte the positive control, same fixture, same assertion surface (the trailing newline is stripped, as it always was — #1040)
..._a_transcript_sized_stdin_does_not_hang_the_hook the reported shape under a hang ceiling; 1 MB over 64 lines

Two fixture constraints came out of measuring bash 3.2, and both are in the module docstring:

  • 16 KB, not 64 KB+, for the deterministic test, because bash 3.2's read -r -t 1 returns EMPTY — not a partial line — once a payload needs more than its second to fetch (observed: a 16 KB single line arrives, a 64 KB one and an 8-line 131 KB one do not). A larger fixture would leave the hook with nothing to crop and the test green for the wrong reason.
  • The 1 MB case skips on bash 3.x rather than passing vacuously on it. On bash 5 that same payload is what produced the 605 ms / 60 s numbers above.

The listener is named 99-record-stdin.sh, not 50-git-restore.sh: a lone bundled listener is dispatched deferred (& disown, #660) and the published file is deleted on the way out, so a deferred copy would race that cleanup. An unknown script keeps the foreground dispatch, which is why nothing here polls.

Budget

built=122861 budget=122880 margin=19      # main: built=122843 margin=37
check_release_tree: OK -- 80 files, 704943 bytes

The comment block costs nothing (the build strips comments); the code change is the +18.

Not done here

  • /simplify findings that did not fit: an early break once the accumulator reaches the bound, or read -n, would cut the pathological loop from ~894 ms to ~4 ms — but costs 44-45 compiled bytes against a 19-byte margin, and would stop draining stdin (EPIPE for the writer). Left as a deliberate non-change.
  • The same ${raw#*...} operator lives in post-tool-hook.sh, session-end-hook.sh and user-prompt-hook.sh, whose payloads lib-stdin.sh also reads unbounded. Those are not affected by this fix and this PR does not touch them; noted on session-start-hook: a transcript-sized stdin makes field extraction quadratic — the hook spins for hours and ignores SIGTERM #1047 instead.

Observed, and reasoned

@fdaviddpt

fdaviddpt commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Thank you for this, and sorry it sat 11 days: GitHub holds CI on a first-time contributor's pull request until a maintainer approves it, and we missed it. We read the diff, it looks right, and CI has now run.

Linux and macOS are green. The three Windows pytest legs and the Windows compiled-hook leg fail in this PR's own new tests, and the cause is in the test, not the fix:

tests/test_session_start_stdin_bound_1047.py:111 writes the listener with listener.write_text(LISTENER, encoding="utf-8"). On Windows, Python translates \n to \r\n, so the shebang becomes #!/bin/bash\r, the listener never runs, and both the crop test and its positive control see no recorded payload (the hooks.d listener never recorded the published payload: rc=0). Passing newline="\n" fixes it:

listener.write_text(LISTENER, encoding="utf-8", newline="\n")

Two more things before it can merge:

  1. Please rebase on current main. The branch is from 20 October. Since then Fix #1040: read hook stdin in chunks, not one byte per syscall #1045 changed how hooks read stdin (scripts/lib-stdin.sh), so the fix should be re-checked against that code.
  2. The SessionStart hook is at its size limit. The built session-start-hook.sh is about 50 bytes under the 120 KiB release-tree budget (comments are stripped at build, code is not). If the release-tree budget test fails after the rebase, that is on us, not you: session-start-hook.sh is at its 120 KiB release-tree budget: shrink it before more SessionStart fixes can land #1067 shrinks the hook first, and this PR lands on top of it.

If you would rather we make these changes on your branch, say so and we will.

[AI-generated]

@fdaviddpt

Copy link
Copy Markdown
Contributor

CI is red on the Windows legs (pytest windows-latest 3.9/3.11/3.12, and hook tests (compiled) / windows-latest); all non-Windows legs pass. In the two new parametrized cases added by this PR (test_a_64_kb_stdin_is_cropped, test_a_real_payload_arrives_by... in tests/test_session_start_stdin_bound_1047.py), the hooks.d listener subprocess exits 0 with empty stdout and no hook-errors.log at all on windows-latest — total silence rather than a wrong value, which points at something in the dispatch-to-hooks.d path failing silently under bash-on-Windows for the modified read loop, rather than the cropping logic itself being wrong.

Could you take a look at why the listener never records the published payload on Windows? Once that's green, re-push and CI will pick it up automatically. Thanks for the detailed writeup in the issue and PR body — much appreciated.

fdaviddpt added a commit that referenced this pull request Nov 1, 2026
…ue, notice rewording, doctor.sh quote convention

#1047: the HOOK_STDIN accumulation loop in session-start-hook.sh was still
quadratic and unbounded (3.3 MB/2,500 lines measured at 68.8s on bash 3.2,
23.6s on bash 5.3) -- the earlier round only bounded _stdin_json_string_into's
own matched input. Now caps accumulation at a 32 KiB ceiling DURING the read
loop itself, matching the before_session_start/after_session_start listener-
publish block's own existing cap so every payload at or under it still
arrives byte-for-byte. Adopts the approach from external PR #1049
(CNSeniorious000/Muspi Merol); credited via Co-authored-by below. This
supersedes #1049 (its 4KB/4KB split-join approach would silently truncate a
legitimate 8-32KB payload before the listener-publish block ever saw it).
New end-to-end test drives the real hook with a 1MB transcript-shaped
payload. The capture-gap-check.sh copy of _stdin_json_string_into gets the
same LC_ALL=C, 4096-byte bound and fail-closed check, keeping the two copies
identical (pinned by test_entrypoint_sniff_bookkeeping_message_803.py's
parity test).

#1046: SessionStart now writes its own cheap "started under this store"
capture-alive.d marker (plain redirect, no fork) so a chat-only session (no
tool call, so post-tool-hook.sh's own marker never lands) is still rescuable
by recovery on its next startup -- new data loss the roster guard itself
introduced, not present before it. The pre-existing #200 "never captured"
notice is reworded when recovery's own log already says a candidate may
belong to a different store, rather than contradicting it with the flat
"not captured" wording. tests/test_jq_fallback_arg_667.py's fixture now
plants a roster marker for its PREV session, matching what a real previous
session's own SessionStart would have written. test_roster_skip_1046.py's
two direct subprocess calls use resolve_bash() rather than a bare "bash"
literal; docs/windows-skip-triage.md gains rows for it and for
test_doctor_dropped_summarizer_spans_1052.py.

#1052: doctor.sh's new "Dropped summarizer spans" WARN no longer claims the
dropped span itself is "kept, not lost" -- keep_rejected_text only saves the
model's own refusal text, never the span, and save-session.sh is unchanged
by this PR, so the span stays genuinely dropped. The escaped double-quote
in that WARN's message now uses this file's own printf -v _dq octal-042
convention instead of a backslash escape. Note for the maintainer: #1052
should stay OPEN after this merges (change "Closes #1052" to "Refs #1052"
in the PR body) -- save-session.sh's own position-advance-past-a-refused-
span behavior is unchanged, so the issue is not fully closed by this round.

Co-authored-by: CNSeniorious000 <[email protected]>
fdaviddpt added a commit that referenced this pull request Nov 1, 2026
…tion, dropped summarizer spans (#1084)

* Fix #1046, #1047, #1052: cross-store recovery, quadratic stdin extraction, dropped summarizer spans

#1046: SessionStart recovery no longer force-saves another store's live
session when several terminals pin different REMEMBER_DIRs at the same
project directory. Recovery now declines to force-save a candidate with no
marker under this store's own tmp/capture-alive.d roster -- gated at the
recovery call site only, not inside _find_previous_transcript, so the #200
capture-gap check (which shares that function's result and depends on the
same "no marker present" signal for a different purpose) stays unaffected.

#1047: session-start-hook.sh's field extractor bounded the raw payload it
matches against to 4096 bytes, eliminating the O(n^2) `${var#*pattern}`
blowup a multi-megabyte stdin payload (e.g. a whole transcript piped in)
triggered -- measured 16.8s before the fix on a 150KB payload with the
target field at the end, same shape as the issue's own 21-hour hang.
HOOK_STDIN's own full accumulation is untouched, so the before_session_start/
after_session_start listener-publish contract (#266) is unaffected.

#1052 (ask 1 only): /remember:doctor now counts [validate]/[haiku] REJECTED
lines across the daily logs present and WARNs -- a reject gate firing is a
successful summarizer call that drops a span of real work, invisible to
#870's own failure-marker counter since the call succeeded. Ask 2 (salvaging
a header refusal with a usable body, or changing the prompt wording) is left
for its own issue/PR.

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

* Self-review follow-up: #1046/#1047 hardening after two-reviewer pass

Explore and oss:auditor findings against 5a9998b, disposed as follows:

- #1046 recovery guard checked only one of capture_was_seen()'s three
  evidence sources (the capture-alive.d marker), missing the legacy
  single-slot file kept specifically for the upgrade-transition false
  positive capture_was_seen() already documents. Fixed: a new
  _remember_recovery_prev_id_vouched() checks both applicable sources
  (the third is excluded by construction, since recovery only reaches
  this guard when PREV_WAS_SAVED is already "no").
- Same function also sanitizes the session id before using it as a path
  component, matching capture_was_seen()'s own id allowlist -- defense in
  depth; empirically the dotglob-off default already makes a `.`/`..`
  id unreachable through _find_previous_transcript's own glob, confirmed
  by trying to reproduce it end to end, so this is tested directly
  against the function rather than through a (non-reproducing) hook
  fixture.
- #1046's functional narrowing of recovery (it can no longer rescue a
  session with literally no evidence anywhere, the original #200/#270
  no-marker case) is real and was under-documented -- changelog.d/1046
  now states it explicitly as the accepted trade-off the issue itself
  asked for, rather than leaving it to a test-file comment.
- #1047's _stdin_json_string_into gained two self-review fixes: LC_ALL=C
  (the 4096 bound was character-counted under a UTF-8 locale, not
  byte-counted, loosening the margin against the quadratic match), and a
  fail-closed check when a value's opening quote survives the bound but
  its closing quote does not -- previously returned success with a
  corrupted truncated value instead of the documented "missed" result.

Both reviewers' doctor.sh findings (unreadable-log-folds-into-zero,
pre-existing across every sibling section in that file) are left as-is
per their own non-blocking ranking.

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

* Fix #1046/#1047/#1052 review round 2: 32KiB stdin cap, chat-only rescue, notice rewording, doctor.sh quote convention

#1047: the HOOK_STDIN accumulation loop in session-start-hook.sh was still
quadratic and unbounded (3.3 MB/2,500 lines measured at 68.8s on bash 3.2,
23.6s on bash 5.3) -- the earlier round only bounded _stdin_json_string_into's
own matched input. Now caps accumulation at a 32 KiB ceiling DURING the read
loop itself, matching the before_session_start/after_session_start listener-
publish block's own existing cap so every payload at or under it still
arrives byte-for-byte. Adopts the approach from external PR #1049
(CNSeniorious000/Muspi Merol); credited via Co-authored-by below. This
supersedes #1049 (its 4KB/4KB split-join approach would silently truncate a
legitimate 8-32KB payload before the listener-publish block ever saw it).
New end-to-end test drives the real hook with a 1MB transcript-shaped
payload. The capture-gap-check.sh copy of _stdin_json_string_into gets the
same LC_ALL=C, 4096-byte bound and fail-closed check, keeping the two copies
identical (pinned by test_entrypoint_sniff_bookkeeping_message_803.py's
parity test).

#1046: SessionStart now writes its own cheap "started under this store"
capture-alive.d marker (plain redirect, no fork) so a chat-only session (no
tool call, so post-tool-hook.sh's own marker never lands) is still rescuable
by recovery on its next startup -- new data loss the roster guard itself
introduced, not present before it. The pre-existing #200 "never captured"
notice is reworded when recovery's own log already says a candidate may
belong to a different store, rather than contradicting it with the flat
"not captured" wording. tests/test_jq_fallback_arg_667.py's fixture now
plants a roster marker for its PREV session, matching what a real previous
session's own SessionStart would have written. test_roster_skip_1046.py's
two direct subprocess calls use resolve_bash() rather than a bare "bash"
literal; docs/windows-skip-triage.md gains rows for it and for
test_doctor_dropped_summarizer_spans_1052.py.

#1052: doctor.sh's new "Dropped summarizer spans" WARN no longer claims the
dropped span itself is "kept, not lost" -- keep_rejected_text only saves the
model's own refusal text, never the span, and save-session.sh is unchanged
by this PR, so the span stays genuinely dropped. The escaped double-quote
in that WARN's message now uses this file's own printf -v _dq octal-042
convention instead of a backslash escape. Note for the maintainer: #1052
should stay OPEN after this merges (change "Closes #1052" to "Refs #1052"
in the PR body) -- save-session.sh's own position-advance-past-a-refused-
span behavior is unchanged, so the issue is not fully closed by this round.

Co-authored-by: CNSeniorious000 <[email protected]>

* Self-review follow-up: #1047 round 3 -- byte-cap the top-level read loop under UTF-8 locales

Explore + oss:auditor review of commit 32682fb both flagged the same gap
independently: the new HOOK_STDIN read loop counts and slices by CHARACTER
under any UTF-8 locale (the common CI default), the exact defect class
_stdin_json_string_into's own comment already names -- but that function's
`local LC_ALL=C` fix is unavailable here since this block is top-level
script code, not a function. A multi-byte-heavy payload could therefore
grow HOOK_STDIN up to ~4x past the documented 32 KiB byte ceiling before
the loop's own character-count check tripped. The quadratic growth this
whole round exists to bound stays bounded either way (it is a looser
ceiling, not an unbounded one), but the ceiling itself was not the number
the comments and changelog claimed.

Fixed by saving/restoring LC_ALL explicitly around the loop (bash has no
`local` outside a function, so a bare assignment would otherwise leak into
this hook's own later user-facing output). New test
(test_the_cap_is_a_byte_cap_not_a_character_cap_under_utf8) drives a
payload built from a 4-byte UTF-8 character under an explicit UTF-8
locale and asserts the cap holds in bytes, not characters.

Explore's other finding (the hooks.d/ publish FILE's own "holds it,
complete" promise is now unreachable above the 32 KiB cap, not merely
truncated-with-warning) is a real, unavoidable consequence of killing the
quadratic join at the source -- there is no cost-free alternative without
reintroducing the hang this round exists to fix. Left as a documented
tradeoff (the updated comment block already states it honestly); noted for
the maintainer in the handback rather than changed further here.

oss:auditor's other finding (doctor.sh's grep -c folds "zero matches" and
"grep itself failed" into the same WARN-does-not-fire outcome) is
pre-existing across the whole file and was already identified and left
as-is in this PR's own first review round (see PR #1084's own description:
"doctor.sh's unreadable-log pattern folds to a zero count the same way
every pre-existing section in that file already does -- pre-existing
across the whole file, not introduced by this diff, ranked non-blocking by
the auditor itself"). Not re-fixed here for the same reason.

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

* Fix CI: #1040's read-site locator + Windows cp1252 UnicodeEncodeError in the new #1047 test

tests/test_hook_stdin_chunked_read_1040.py's _read_site() located
session-start-hook.sh's stdin block by the literal text `HOOK_STDIN=""`
immediately followed by `if [ ! -t 0 ]; then` on the next line -- this
round's 32KiB-cap rewrite (and the LC_ALL save/restore added for the
byte-vs-character self-review fix) inserted code between those two lines,
so the locator's text.index() raised before any assertion ran, failing 4
session-start parametrized cases on the "hook tests (compiled) / windows-
latest" CI leg. Considered switching session-start-hook.sh onto the shared
_remember_read_stdin_into (scripts/lib-stdin.sh) the other three hooks
already use, per the review's own suggestion -- not done: that helper's own
accumulation (both its chunked and line-loop-fallback paths) is equally
unbounded, so moving session-start-hook.sh onto it without ALSO capping
lib-stdin.sh itself would not fully close #1047 on bash < 4.1 (the exact
case the issue's own worst numbers were measured against), and capping
lib-stdin.sh is a larger change touching three other hooks -- out of scope
for a CI-fix commit. Fixed the locator instead: it now starts at
_REMEMBER_HOOK_STDIN_CAP=32768 (the real start of the block, needed because
that constant is now referenced inside the loop) and ends at the stable
`unset _hook_stdin_lc_all_was_set ...` line that closes the whole block,
rather than the first `fi` reached -- the block now contains three `fi`
lines of its own. The #1040 field-parity assertions this test exists for
are unchanged; all previously-passing cases still pass, and the bug the
locator failure was masking (whatever it would have caught) was never
triggered in this run either way, since LINE_LOOP_MAX_PAYLOAD (16 KiB)
already keeps every payload these session-start cases exercise well under
the new 32 KiB cap.

Did not confirm whether the SAME locator bug also fails on non-compiled,
non-Windows legs (it should, being a pure text-match issue independent of
platform or compilation) -- only the one CI leg named in the report was
investigated; the fix is leg-independent, so it should resolve on every
leg this affects, not only the one that was reported.

tests/test_session_start_stdin_cap_1047.py's new UTF-8-byte-cap test fed a
multi-byte payload through subprocess.run with text=True and no explicit
encoding, which on Windows decodes/encodes via the platform's preferred
codepage (cp1252) rather than UTF-8 -- raising UnicodeEncodeError on the
`input=` argument before the subprocess even started, since cp1252 cannot
represent the payload's own 4-byte UTF-8 character at all. Fixed by pinning
encoding="utf-8" explicitly on that one subprocess.run call.

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

* Fix CI on PR #1084: #1046 guard fixtures, prune-count assertion

Three tests failed in CI against the #1046/#1047/#1052 branch, all in
test fixtures/assertions that predate or were invalidated by round 2's
new SessionStart roster marker -- not bugs in the guard itself.

tests/test_recovery_transcript_leak_407.py's _startup_project fixture
gives PREV five real tool_use lines in its transcript but never plants
the capture-alive.d/PREV marker those tool calls would themselves have
produced under post-tool-hook.sh (pre-existing since #206, unrelated to
this PR). #1046's recovery guard reads that exact marker to tell "ran
under this store" from "may belong to a different store sharing this
project's transcript directory" -- so the fixture's omission is not a
realistic "never captured" case, it is a hole the guard correctly
declines on. Planted the marker in the fixture instead of weakening the
guard; this also fixes test_detached_spawn_fd_hygiene_648.py's
test_session_start_recovery_spawn, which imports the same fixture.
tests/test_roster_skip_1046.py's own test_a_chat_only_previous_session_is_still_rescued
already pins the marker staying in capture-alive.d (not moved
elsewhere), so this is the fixture-side fix, not a guard change.

tests/test_session_start_promo_spawn_budget_660.py's
test_capture_seen_prune_is_gated_on_the_threshold asserted an
under-threshold capture-alive.d directory is left with exactly its 2
seeded entries. Round 2 (already shipped on this branch) has
session-start-hook.sh write its own cheap roster marker for every
SessionStart's own session id into that same directory,
unconditionally -- intentional, so a chat-only session still earns
roster evidence. That legitimately adds one entry regardless of the
prune threshold, so the assertion now checks the 2 seeded entries
survive unpruned, plus exactly the new run's own SESSION marker.

Reran the full targeted set plus test_roster_skip_1046,
test_jq_fallback_arg_667, test_locale_ranges_695, test_capture_gap_notice,
test_session_start_prev_session_270, test_previous_transcript_no_sort_691
and the release-tree/branch suites: 557 passed, 1 skipped (case-insensitive
filesystem).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Fix #1047 round 4: Windows CI timeout from the read loop's own per-line cost

CI self-review after pushing the #1046 guard-fixture fix: every Windows
leg (3.9-3.12) failed test_session_start_stdin_cap_1047.py's
test_a_1mb_transcript_sized_stdin_does_not_hang_the_real_hook with a
subprocess.TimeoutExpired at the 30s budget -- consistently, across
every Windows job including the compiled-hooks leg, while every
Ubuntu/macOS leg stayed well under it.

The #1047 round-3 fix correctly caps HOOK_STDIN's own growth at 32KiB
during accumulation, closing the quadratic string-concat cost. But the
`while IFS= read -r -t 1 _line` loop around it kept iterating once per
line for the REST of an oversized payload even after the cap was hit,
with nothing left to do once HOOK_STDIN is already capped. That is
O(lines) of pure per-`read`-call overhead, not O(bytes) -- cheap enough
on Linux/macOS bash to go unnoticed, but Windows runners (git-bash/MSYS
syscall overhead per shell builtin call) paid enough per iteration that
2,500 lines alone pushed this test past its budget.

Fixed by breaking out of the line loop the instant the cap is hit and
draining whatever is left of stdin with a single bulk `cat <&0
>/dev/null`, copying bytes without ever growing a string or forking a
process per line. HOOK_STDIN's own contract (byte-identical up to the
32KiB cap) is unchanged; only the work done AFTER the cap is reached is
removed.

tests/test_locale_ranges_695.py's hardcoded allowlist entry for
scripts/session-start-hook.sh's CURRENT_SESSION_ID bracket range
(line 380) updated to its new line (399) -- this diff inserts 15 lines
above it.

Verified locally (fast on this platform by construction -- the bug is
Windows-specific) plus the full #1046/#1047 targeted set, the release-
tree/branch byte-budget suites, and test_locale_ranges_695: 565 passed,
1 skipped (case-insensitive filesystem, pre-existing).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Fix final-review findings on #1046, #1047, #1052

- #1052: doctor's dropped-summarizer-spans check now matches #1085's
  renamed [summarizer] tag (was validate|haiku only), confirmed [ndc]
  REJECTED is retried rather than dropped and left out of the count.
- #1047: the post-cap stdin drain now runs detached, so a writer holding
  its end of stdin open past the cap can no longer hang the hook.
- #1046: SessionStart's own roster marker moved out of capture-alive.d
  into its own tmp/session-started.d/, so the #200 capture-gap check can
  no longer read a chat-only session's own marker as proof PostToolUse
  ran; only the recovery guard accepts either folder. Added a one-time
  upgrade grace (tmp/roster-epoch) so a pre-existing unmarked session from
  before this landed is still rescued once, not silently abandoned.
- Reworded the #1046 changelog fragment in plain language and corrected
  its claim that the #200 check is unaffected.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Fix CI: widen windows-latest flake in the new stdin-drain test

3.16s observed on windows-latest against the 3.0s bound, from process
spawn overhead alone -- the fix (backgrounded drain) was correctly in
place. Widened to 5s, matching this file's other must-fire test.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Harden the #1047 drain test margin; state the #1046 upgrade-grace trade-off

The writer now holds stdin for 15 s against a 5 s bound, so a later widening for a
slow runner cannot reach the hold and stop catching a blocking drain. The changelog
now says plainly that the one-time grace can still save one other window's
conversation into the wrong store per store, once, after the update.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
Co-authored-by: CNSeniorious000 <[email protected]>
@CNSeniorious000

Copy link
Copy Markdown
Contributor Author

Closed as superseded by #1084. Thanks for incorporating the fix and preserving the co-author credit!

@fdaviddpt

Copy link
Copy Markdown
Contributor

Thank you @CNSeniorious000, both for the fix and for closing this yourself. Your measurements and the idea of capping what is kept, not just how it is read, are what #1084 is built on, and the 1 MB end-to-end test is yours. It ships in the next release.

[AI-generated]

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.

session-start-hook: a transcript-sized stdin makes field extraction quadratic — the hook spins for hours and ignores SIGTERM

2 participants