Skip to content

Fix #1006: wire SessionStart's consolidation launch to the hidden Windows launcher - #1065

Merged
fdaviddpt merged 3 commits into
mainfrom
fix/1006
Oct 31, 2026
Merged

fdaviddpt merged 3 commits into
mainfrom
fix/1006

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Closes #1006.

PR #1004 (#1002) routed three of the four detached launches through the hidden wscript.exe launcher; session-start-hook.sh's own consolidation launch was deferred because inlining lib-detach.sh directly would push that hook's compiled size over its 120 KiB release-tree budget (check_release_tree.py's HOOK_SCRIPT_MAX_BYTES), with no margin left to absorb it.

What changed

Adds scripts/consolidation-launch.sh, a separate, non-hook file that sources lib-detach.sh and decides Windows vs. the unchanged nohup fallback in its OWN process, invoked synchronously from session-start-hook.sh's staging-backlog branch. Since this file is not one of compile_hooks.py's four HOOK_SCRIPT_NAMES, lib-detach.sh's compiled body is never inlined into session-start-hook.sh's own output, so the call site there shrinks to one line and the hook's own byte budget stays comfortably under its 120 KiB cap (52-byte margin, measured against the real release-tree build).

tests/test_windows_hidden_detach_1002.py's own regression guard (test_every_nohup_detach_site_guards_with_the_shared_helper) now also names consolidation-launch.sh, the file that actually calls _remember_detach_windows. session-end-hook.sh's self-redetach and the Antigravity Stop hook's save remain out of scope, per the issue's own narrowing (comment on #1006, 2026-10-09) -- SessionEnd has a real stdin-inheritance regression blocking it, and Antigravity Stop is lower priority.

docs/windows.md and lib-detach.sh's own module comment are updated to reflect SessionStart's consolidation launch as wired.

A stale premise in the issue, corrected

The issue's byte-budget estimate (~1,518 bytes to inline the detach helper) was stale: lib-detach.sh has grown substantially since #1004 (TTL caching, slow-verdict throttling), and its real comment-stripped size is 4,236 bytes -- the true inlining cost is ~4,536 bytes, about 3x the issue's estimate. Rather than hunting that much removable code out of an already tight, heavily tested hook (candidates considered and rejected: extracting _remember_prune_stale_session_files or the promo-JSON-wrapping block, both of which still inline the same bytes via compile_hooks.py since they'd be sourced by the same hook), this PR satisfies the issue's own alternative phrasing ("a... separately compiled helper") by moving the dispatch to a file compile_hooks.py never inlines at all, rather than shrinking session-start-hook.sh's own existing code as the issue's first phrasing describes. Flagging this explicitly for review.

Below-bar finding (not filed, recorded here)

The new consolidation-launch.sh dispatch (hidden launcher vs. nohup) is REASONED, not OBSERVED, on real Windows: windows-latest CI exercises lib-detach.sh and post-tool-hook.sh's own call site against a real wscript.exe (tests/test_windows_real_wscript_1002.py), but not this new call path, and the new test (tests/test_session_start_windows_detach_1006.py) is stub-based and skipped on win32. This is the same REASONED-not-OBSERVED gap the whole Windows-hidden-detach feature already discloses for itself (lib-detach.sh's own module docstring and docs/windows.md both say so explicitly), now extended by one more call site -- not a new defect introduced by this diff. Adding a real-wscript.exe CI leg for this one path was judged too risky to attempt blind (no Windows box to verify against) within this change's scope.

Tests

Red: reverted session-start-hook.sh to its pre-fix state and removed scripts/consolidation-launch.sh; tests/test_session_start_windows_detach_1006.py went 1 failed (hidden-launcher test), 1 passed (non-Windows positive control, correctly still green).
Green: restored both files; 2 passed.
Also green: tests/test_strip_shell_comments_900.py, tests/test_release_branch_check_900.py (including the real check_release_tree.py run against this repo's own built tree), tests/test_windows_hidden_detach_1002.py (full file), tests/test_session_start_fd_leak_646.py (end-to-end through the new chain), tests/test_delivery_record_pruning_373.py -- 70 total passed. Full pytest not run locally, per this repo's own CI-is-the-gate policy; CI covers the full matrix.

🤖 Generated with Claude Code

[AI-generated]

fdaviddpt and others added 3 commits October 31, 2026 18:36
…dows launcher

PR #1004 (#1002) routed three of the four detached launches through the
hidden wscript.exe launcher; SessionStart's own consolidation launch was
deferred because inlining lib-detach.sh directly into session-start-hook.sh
would push that hook's compiled size over its 120 KiB release-tree budget
(check_release_tree.py's HOOK_SCRIPT_MAX_BYTES), with no margin left to
absorb it.

Adds scripts/consolidation-launch.sh, a separate, non-hook file that
sources lib-detach.sh and decides Windows vs. the unchanged nohup fallback
in its OWN process, invoked synchronously from session-start-hook.sh's
staging-backlog branch. Since this file is not one of compile_hooks.py's
four HOOK_SCRIPT_NAMES, lib-detach.sh's compiled body is never inlined
into session-start-hook.sh's own output, so the call site there shrinks
to one line and the hook's own byte budget stays comfortably under its
120 KiB cap (52-byte margin, measured against the real release-tree
build) instead of needing ~4.5 KB of unrelated code removed elsewhere --
lib-detach.sh has grown substantially since #1004 (TTL caching, slow-
verdict throttling), so the ~1,518-byte estimate in the issue is stale.

tests/test_windows_hidden_detach_1002.py's own regression guard
(test_every_nohup_detach_site_guards_with_the_shared_helper) now also
names consolidation-launch.sh, the file that actually calls
_remember_detach_windows. SessionEnd's self-redetach and the Antigravity
Stop hook's save remain out of scope, per the issue's own narrowing (a
real stdin-inheritance regression caught under review on PR #1004).

docs/windows.md and lib-detach.sh's own module comment updated to
reflect SessionStart's consolidation as wired.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
tests/test_windows_skip_triage_497.py failed on every ubuntu-latest leg of
PR #1065 (the fix/1006 branch): tests/test_session_start_windows_detach_1006.py
carries a module-level win32 blanket skip (its own fixture stubs wscript.exe,
which only exists conceptually on Windows CI -- the test is Linux/macOS-only
by design) but was never added to docs/windows-skip-triage.md, which this
repo's own convention (#497, #589) requires in the same commit that
introduces a new blanket skip.

Verdict: unclear -- same ambiguity as the table's templated majority. The
reason names the bash-subprocess dependency plus an unspecified "stub-based
simulation" claim; the stubs themselves are plain shell scripts, so whether
Git-Bash discovery alone would let this run on a real win32 runner, or
whether something else about the harness blocks it, is not settled by the
reason string alone.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
…launch

MEDIUM: scripts/session-start-hook.sh's staging-backlog branch invoked
consolidation-launch.sh synchronously. That file's Windows route
(_remember_detach_windows, lib-detach.sh) waits on wscript.exe up to a
15s watchdog cap, not "a few milliseconds" as the comments there and in
the changelog fragment claimed -- so this reintroduced the #646
SessionStart-stall class. Fixed by backgrounding the call (trailing `&`);
its exit status was already unused. Added a red-then-green test
(test_session_start_returns_promptly_even_when_windows_route_is_slow)
that stubs wscript.exe to sleep 5s and asserts the hook still returns
well under that, paired with the positive control that the hidden route
still actually runs in the background.

LOW: the existing Windows-route test asserted `not marker.exists()`
immediately after subprocess.run() returned, racing the backgrounded
nohup fallback -- a double launch could have passed undetected. Both
that assertion and the `captured.exists()` check now use a bounded
(up-to-5s) wait, matching the sibling nohup test's own poll.

Corrected the stale "a few milliseconds" / "SYNCHRONOUSLY" claims in
consolidation-launch.sh's header and session-start-hook.sh's call-site
comments, and updated the changelog fragment to describe the
backgrounded launch. session-start-hook.sh's compiled size grows by 2
bytes (the trailing ` &`) -- 122,830 bytes built, still under the
122,880-byte release-tree budget.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@fdaviddpt
fdaviddpt merged commit 4839eca into main Oct 31, 2026
19 checks passed
@fdaviddpt
fdaviddpt deleted the fix/1006 branch October 31, 2026 20:14
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.sh: consolidation launch still uses bare nohup on Windows (deferred from #1002), and the hook has 41 bytes of budget left

1 participant