Repository navigation
Merged
Conversation
…urce=compact (#341, #342); pin the source extractor's first-occurrence scan (#344) At source=compact, SessionStart fires mid-session with an unchanged handoff fingerprint, so the delivery counter incremented as though a new session had seen the note -- a handoff delivered once could read as "already delivered 5 times" after four auto-compactions. The consolidation trigger had the same gap: it re-spawned run-consolidation.sh on every compact fire even though nothing about yesterday's staging files changed, measured firing 82 times across 50 sessions. Both are now gated on SESSION_START_SOURCE != "compact"; every other source (startup, resume, clear, fork, absent, unrecognised) behaves exactly as before. #344 adds a characterization test for _stdin_json_string's first-occurrence scan of "source" -- pinning that a top-level source wins over a nested one that follows it, and documenting (not fixing) the one direction that isn't covered: a nested source key appearing before the top-level one. No such payload shape exists today. Closes #341, Closes #342, Closes #344 Co-Authored-By: Max <noreply>
This was referenced Aug 28, 2026
This was referenced Aug 29, 2026
fdaviddpt
added a commit
that referenced
this pull request
Sep 1, 2026
…nd session_id (#493) * test: generalise the #344 top-level-wins pin to the extractor across source, cwd and session_id (#447) The #344/#379 pin only ever covered `source`, which #344 had bounded to a five-literal whitelist. Since #444 the same first-occurrence `_stdin_json_string`/`_stdin_cwd` extractor also resolves `cwd` (feeding REMEMBER_HOOK_CWD/PROJECT_DIR) and `session_id` on session-start, session-end and post-tool hooks -- none of which carry that whitelist. Adds the same two-test shape (nested-after wins, nested-before is the documented gap) for every (hook, key) pair the extractor actually reads, run directly against the extracted function bodies rather than through a full hook invocation. No JSON parser introduced and no extractor changed, per #340/#344's standing decision. Co-Authored-By: Max <noreply> * fix: narrow the new #447 extractor pin's win32 skip to "no bash found" (#432) The reviewer's audit flagged that the new test file copied the blanket `skipif(sys.platform == "win32")` shape #432 explicitly fixed in test_hook_cwd_leak_417.py and test_transcript_path_leak_424.py -- that pattern makes the windows-latest CI leg collect and skip every test while reporting the leg green, indistinguishable from a genuine pass. Switches to tests/_bash_runner.py's resolve_bash() (Git-Bash discovery), the same fix those two files already carry, so the 17 new tests actually run under Git Bash on Windows CI instead of being silently skipped for the whole platform. Co-Authored-By: Max <noreply>
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.
What
Three issues in
scripts/session-start-hook.sh, all aboutSessionStartfiring onsource=compact(auto-compaction) as though it were a new session.compactrefire, even though the same session was seeing the same content again. A handoff delivered once could read "already delivered 5 times" after four auto-compactions. Fixed by excludingsource=compactfrom the increment; every other source (startup,resume,clear,fork, absent, unrecognised) still increments as before.run-consolidation.shin the background on everySessionStart, includingcompact, whenever past-day staging files were pending. Measured on the session-start-hook.sh ignores thesourcefield, re-injecting the full memory recap on everycompact#339 report:compactfired 82 times across 50 sessions againststartup's 180 — the same redundant spawn repeated on a multiplier nobody had counted. Fixed the same way: gated onsource != compact._stdin_json_string's first-occurrence scan of"source"in raw stdin would extract a nestedsourcekey ahead of a top-level one, if such a payload shape ever existed. It does not today. Added a characterization test pinning the safe direction (top-level wins when a nested key follows it) and documenting, without fixing, the one untested direction. No production code changed for this issue, and no JSON parser was introduced (fix(session-start): stop re-injecting the whole recap at source=compact #340 avoided that dependency deliberately).Judgment call
Both #341 and #342 name
clear/resume/forkas needing an actual argument rather than a guess for whether they should also be excluded. I could not construct a reason to exclude any of them —resumeandforkare genuinely new entry points into a session, andclearexplicitly replaces context (the issue text leans the same way). So both gates exclude onlycompact, the one source that is provably still the same session. Full reasoning in the branch's own notes file.Cost of the #342 gate
A session that only ever sees
compactafter its initialstartupwill not re-trigger consolidation for staging that accumulates mid-session, until the process ends and a fresh entry point happens. Bounded: the trigger only ever acts on past-day staging (never same-day), and #342 is filed as "runs more often than it needs to," not as data loss — nothing is lost, consolidation just runs on the next real entry point instead of every mid-session fire.Tests
Three new files, each red before the fix (or, for #344, a passing characterization from the start since no fix was made):
tests/test_handoff_delivery_count_source_341.py— 3 tests, including a positive control (startuprefires must still inflate the count) paired with the negative (compactrefires must not).tests/test_consolidation_trigger_source_342.py— 3 tests, same positive/negative pairing, plus a characterization that the gate is staging-count AND source, not source alone.tests/test_stdin_source_top_level_wins_344.py— 2 tests pinning the extractor's current first-occurrence behaviour in both key orderings.All 8 pass locally (macOS, observed). Linux is reasoned via CI's existing matrix already exercising this file's POSIX
[syntax; Windows is skipped by an explicitskipifmarker on all three files, consistent with the repo's existing convention for this hook (test_session_start_compact_recap_339.pydoes the same).Review
Self-reviewed by an
Exploreagent (correctness, test vacuousness, stale prose) and anoss:auditoragent (silent-absence, guard-did-not-run, untrusted-input, platform band) against the committed diff — both returned NO FINDINGS.Docs
README.mdis held by a concurrent lane (#377) this tick, so not edited here. Two spots would benefit from a mention once that lane frees it: the line near "already delivered N times since" (README.md:296) could note that compact fires no longer inflate the count, and thesource=compactparagraph (README.md:128) could note the consolidation trigger is gated the same way. Left as text for the maintainer to fold in, not an edit.Closes #341
Closes #342
Closes #344