You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
session-start-hook.sh cannot be profiled with bash -x: bootstrap-dirs.sh:364 redirects fd 2 mid-run and the trace stops silently #690
cohort-12Open at the v0.33.0 tag, 2026-09-15 (6 issues). Frozen: nothing joins a cohort.lane-capturein-session hooks and the summarizer — post-tool, prompt, session-start/end, haiku.py, prompts/priority:mediumRecurring cost; compounds if unfixed
From that line on, everything written to fd 2 goes to the hook's own error log -- including an xtrace stream, if the profiler put one there. bash -x scripts/session-start-hook.sh therefore produces a trace that covers only the part of the run before bootstrap-dirs.sh is sourced, and nothing anywhere says the rest was lost.
Measured while building the #660 diagnostic, on macOS, one run:
wall 0.71s | traced span 0.07s | 238 traced lines
90% of the run was missing. With BASH_XTRACEFD pointed at a dedicated fd, the same run gives wall 0.71s | traced span 0.66s | 1372 traced lines.
Why it matters
A truncated trace does not look truncated. It looks like a complete profile of a fast hook, and every number derived from it -- fork counts, per-step attributions, "the largest gap is X" -- describes a fraction of the run while reading as though it describes all of it. This is the repo's own cardinal failure shape (a thing that ran, produced a clean result, and silently covered a fraction of what it claimed) sitting inside a diagnostic aid.
It is also not hypothetical: #660 has been reasoned about for days using PS4='+$EPOCHREALTIME ' bash -x measurements from a reporter, and unless their trace was on a non-default fd it stopped at this same line.
Not a proposal to remove the redirect
The redirect exists for a reason -- a hook's stderr must not leak into the host's transcript (#643 and the stderr-leak lane). The ask is that it stop being invisible:
leave the redirect alone when BASH_XTRACEFD is already set to something other than 2, or when an explicit opt-out (REMEMBER_TRACE=1) is present; and/or
document it at the redirect and in docs/diagnostics.md, so the next person to profile this hook is told where their trace went rather than discovering it by arithmetic.
A positive control belongs in whichever shape lands: a traced run whose span is within some margin of its wall clock, so a future redirect that swallows the trace again fails a test rather than a person.
Two platform floors the fix in PR #708 does not yet clear. Recording them here rather than
only on the pull request, so they survive if that branch stalls. Both are read out of run
#35091652526 (16 legs, 8 failed: every macOS leg and every Windows leg; all Linux legs green).
macOS, bash 3.2 -- a real defect in the fix, not a test artifact. tests/test_trace_not_swallowed_690.py:164 fails with assert 'echo MARKER-690-ON-FD-2' in '':
the trace file is empty. GitHub's macOS runners resolve bash to stock /bin/bash 3.2, the same
floor tests/test_session_start_fork_tax_665.py already names in its $BASHPID skip reasons. BASH_XTRACEFD was added in bash 4.1, so on 3.2 export BASH_XTRACEFD=9 is ignored and xtrace
stays on fd 2 -- while the new guard at scripts/bootstrap-dirs.sh:384 reads [ "${BASH_XTRACEFD:-2}" = "2" ], sees 9, concludes the trace is safely elsewhere, and
redirects fd 2 into hook-errors.log anyway. That is the #690 symptom itself, reproduced by the
fix, on the platform the original measurement was taken on.
The guard needs a version test alongside the fd test: below bash 4.1 (BASH_VERSINFO[0] < 4, or
4 with BASH_VERSINFO[1] < 1), BASH_XTRACEFD is not honoured, so xtrace is on fd 2 regardless
of what the variable says and the redirect must stand down.
Windows, Git Bash -- not yet diagnosed. tests/test_trace_not_swallowed_690.py:242 fails with assert 'NOW-BODY-690' in '': running bash -x scripts/session-start-hook.sh exits 0 and produces zero bytes on stdout. The preceding
six tests in the same file pass on Windows, so bash resolution and path handling are not the
cause. The hook's stdout goes through the _REMEMBER_CTX_FILE buffer flushed by the cat calls
at scripts/session-start-hook.sh:2003 and :2006; under trace on Git Bash that flush yields
nothing. Whether the buffer redirect never engages, or engages and the flush branch is not
reached, has not been established -- it needs a Windows runner to answer, and no claim is made
here beyond what the log shows.
Reopening. PR #708 merged and fixed the macOS bash-3.2 regression, but the issue's own
end-to-end promise (the real hook's bash -x trace surviving past the bootstrap) is still
unverified on Windows -- test_the_real_hook_traces_past_the_bootstrap is xfail'd there,
not passing, tracked separately as #712.
I edited PR #708's body before merging to change "Closes #690" to "Part of #690" for exactly
this reason, but GitHub's merge auto-close used the issue link established at PR creation time
rather than the edited body text, and closed this anyway. Reopening to correct that.
This will close for real once #712 is fixed and the xfail marker on
test_the_real_hook_traces_past_the_bootstrap is removed.
cohort-12Open at the v0.33.0 tag, 2026-09-15 (6 issues). Frozen: nothing joins a cohort.lane-capturein-session hooks and the summarizer — post-tool, prompt, session-start/end, haiku.py, prompts/priority:mediumRecurring cost; compounds if unfixed
Activity
fdaviddpt commentedon Sep 16, 2026
Two platform floors the fix in PR #708 does not yet clear. Recording them here rather than
only on the pull request, so they survive if that branch stalls. Both are read out of run
#35091652526 (16 legs, 8 failed: every macOS leg and every Windows leg; all Linux legs green).
macOS, bash 3.2 -- a real defect in the fix, not a test artifact.
tests/test_trace_not_swallowed_690.py:164fails withassert 'echo MARKER-690-ON-FD-2' in '':the trace file is empty. GitHub's macOS runners resolve
bashto stock/bin/bash3.2, the samefloor
tests/test_session_start_fork_tax_665.pyalready names in its$BASHPIDskip reasons.BASH_XTRACEFDwas added in bash 4.1, so on 3.2export BASH_XTRACEFD=9is ignored and xtracestays on fd 2 -- while the new guard at
scripts/bootstrap-dirs.sh:384reads[ "${BASH_XTRACEFD:-2}" = "2" ], sees9, concludes the trace is safely elsewhere, andredirects fd 2 into
hook-errors.loganyway. That is the #690 symptom itself, reproduced by thefix, on the platform the original measurement was taken on.
The guard needs a version test alongside the fd test: below bash 4.1 (
BASH_VERSINFO[0]< 4, or4 with
BASH_VERSINFO[1]< 1),BASH_XTRACEFDis not honoured, so xtrace is on fd 2 regardlessof what the variable says and the redirect must stand down.
Windows, Git Bash -- not yet diagnosed.
tests/test_trace_not_swallowed_690.py:242fails withassert 'NOW-BODY-690' in '': runningbash -x scripts/session-start-hook.shexits 0 and produces zero bytes on stdout. The precedingsix tests in the same file pass on Windows, so bash resolution and path handling are not the
cause. The hook's stdout goes through the
_REMEMBER_CTX_FILEbuffer flushed by thecatcallsat
scripts/session-start-hook.sh:2003and:2006; under trace on Git Bash that flush yieldsnothing. Whether the buffer redirect never engages, or engages and the flush branch is not
reached, has not been established -- it needs a Windows runner to answer, and no claim is made
here beyond what the log shows.
[AI-generated]
fix(#690): the fd-2 guard also needs a bash version, not just a variable
fix(#690): unset the new version-check scratch var; scope the win xfail
fix(#690): stop the fd-2 redirect swallowing a deliberate trace (#708)
fdaviddpt commentedon Sep 16, 2026
Reopening. PR #708 merged and fixed the macOS bash-3.2 regression, but the issue's own
end-to-end promise (the real hook's bash -x trace surviving past the bootstrap) is still
unverified on Windows -- test_the_real_hook_traces_past_the_bootstrap is xfail'd there,
not passing, tracked separately as #712.
I edited PR #708's body before merging to change "Closes #690" to "Part of #690" for exactly
this reason, but GitHub's merge auto-close used the issue link established at PR creation time
rather than the edited body text, and closed this anyway. Reopening to correct that.
This will close for real once #712 is fixed and the xfail marker on
test_the_real_hook_traces_past_the_bootstrap is removed.
[AI-generated]
fix(#720,#721): stop /remember parsing its Write target from the tran…
fix(#712): skip session-start-hook.sh's stdout buffer under an active…
fix(Digital-Process-Tools#736): remove the strict=False xfail marker …
refactor(#898): build the log line once; shorter trace and debug notes