Repository navigation
Merged
Conversation
… recovery hint (#626) #619 fixed `cat FILE 2>/dev/null || echo 0` collapsing "never created" and "exists but a read failed" into the same 0, at NDC_GEN_FILE. The identical pattern was still present, unfixed, at COOLDOWN_MARKER (tmp/last-save-ts) and NDC_MARKER (tmp/last-ndc.ts). A durably unreadable marker there silently defeats its cooldown on every invocation, forever, with nothing in the log to say so -- lower stakes than NDC_GEN_FILE (an extra Haiku call, not lost data), but the same silent failure mode. Both now go through a shared ts_marker_read() helper, the same shape as #619's ndc_read_gen(), and log a WARNING naming the marker when a read fails instead of proceeding in silence. Fixing this surfaced an adjacent defect: the unconditional `date +%s > "$MARKER"` write below each read was unguarded, so a durably unwritable marker (a directory reproduces this without depending on a uid ever being denied a permission bit) crashed the WHOLE script under `set -e` -- a harder failure than the documented "fails open" behaviour. Both writes are now guarded the same way the existing self-heal write already is. #626: the SKIPPED-commit log line #619 added for a durably unreadable NDC_GEN_FILE now also names the remedy -- delete it to reset generation tracking to 0 -- instead of leaving every future round to land on the same line with no hint of the way out. Two doc rows added to docs/windows-skip-triage.md for the two new blanket win32-skip test modules, per repo convention. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c
Two spawned reviewers (Explore + oss:auditor) found three issues in the #625/#626 commit: 1. Widening the marker-existence test from `-f` to `-e || -L` (needed so a directory-in-place-of-marker reaches the read guard instead of silently skipping it) also let a FIFO reach `ts_marker_read`'s unconditional `cat`. `cat` on a FIFO with no writer present blocks forever -- no O_NONBLOCK, no timeout anywhere in this script -- which is a HARDER failure than the "fails open" behaviour this fix exists to guarantee. Fixed: ts_marker_read now rejects any non-regular file before ever calling `cat` on it. Reproduced the hang against a scratch copy with the guard removed (TimeoutExpired), confirmed the fix returns "unreadable" in milliseconds, and pinned both with three new tests (FIFO, a plain regular-file control, an absent-marker control) that call the function in isolation via process substitution rather than through the full script, so a regression fails fast instead of hanging the suite. 2. The downstream `case "$LAST_MOD"/"$NDC_MOD" in ''|*[!0-9]*) ...=0 ;; esac` at both marker sites is now unreachable through this read path -- ts_marker_read already intercepts anything that would have hit it, and converts its own "unreadable" sentinel to 0 first. The ~30-line comment block explaining #326/#258's arithmetic-parse-failure self-heal is still accurate history but no longer describes this path's live behaviour. Added one clarifying paragraph at each site rather than rewriting the history away. 3. The new WARNING wording ("exists but could not be read") was specific to read failures, but ts_marker_read's "unreadable" sentinel also covers a read that SUCCEEDED and returned unparseable content (corrupted by an interrupted write, stray whitespace) -- a case where the marker plainly WAS read. Reworded both WARNINGs to "its value could not be used (a read failure, or content that is not a plain timestamp)", accurate for both. Updated the test constant and assertions to match. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c
A re-audit round (spawned after the classifier flagged the first oss:auditor return as referred-not-stated, per the developer brief's review-return protocol) found one real finding: the module-level comment above ts_marker_read claimed a dangling symlink "echoes 0" the same as a marker that was never created. It does not -- `-L` is true for a dangling symlink, so `[ ! -e ] && [ ! -L ]` is false and the function falls through to "unreadable" instead, the same as ndc_read_gen's own (correct) comment already describes for the identical case. Verified by extracting the function and calling it directly against a real dangling symlink, before and after this fix. Corrected the comment to point at ndc_read_gen's own accurate description instead of restating it wrong, and added a test pinning the actual behaviour (unreadable, not 0) so this claim has a red/green check rather than resting on prose alone. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c
PR #628's CI was systematically red on all four macos-latest legs (3.9-3.12, Windows and Ubuntu all green) -- every failure was the same four tests in tests/test_save_session_marker_unreadable_625.py, same symptom: "bash: ts_marker_read: command not found". The helper extracted ts_marker_read()'s definition via `source <(sed -n '/^ts_marker_read()/,/^}/p' FILE)`. That process substitution worked on every macOS bash tried locally (3.2.57 and Homebrew 5.x) but was observed failing, consistently, only on macos-latest GitHub Actions runners -- the same shape of macOS-CI-only shell-substitution flakiness this session had already hit once this session (#621/#627) with a different fragile trick, and equally unreproducible locally. Per the maintainer's steer after reporting the CI failure (verified via gh-pr:628:status and gh-job:*:fail before making this change, matching the report exactly): dropped process substitution rather than continuing to chase an unreproducible CI-only mechanism. `_extract_ts_marker_read_source()` now pulls the function's source with a plain Python regex (byte-identical range to the old `sed` selection) instead of shelling out to `sed`, and `_call_ts_marker_read()` writes it to a real temp file and `source`s that, removing the `<(...)` construct from this path entirely. Verified locally: all 9 tests in the file still pass, including the FIFO hang regression test (confirmed it still fails fast rather than trivially passing). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c
The previous commit (6e6f29c) fixed the macOS-CI-only process-substitution failure but introduced a new one: this repo's own test_the_repo_has_nothing_the_discriminator_could_not_decide gate flags any module-level `|` expression it cannot classify as bitwise vs. type-union, and `_TS_MARKER_READ_RANGE = re.compile(pattern, re.MULTILINE | re.DOTALL)` at module level tripped it -- observed on ALL SIXTEEN legs uniformly (this gate is a static AST walk, not platform-conditional), unlike the prior macOS-only failure. Per pep604_floor.py's own documented scope, a function-local `|` is out of scope for this guard entirely (it only runs at call time, so it cannot take out a 3.9 leg at import). Moved the regex out of the module-level assignment and inlined it as an re.search(...) call inside _extract_ts_marker_read_source() instead of pre-compiling it at module scope -- no behavior change, same regex, same bytes extracted. Verified locally: test_the_repo_has_nothing_the_discriminator_could_not_decide passes, ruff clean, and the file's own 9 tests still pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c
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
#619 fixed
cat FILE 2>/dev/null || echo 0collapsing "marker never created" (legitimately 0) with "marker exists but a read of it failed" (a permission or I/O error, or a directory in its place) into the identical fallback 0, at NDC_GEN_FILE. The identical pattern was still present, unfixed, at two more timestamp markers in the same file -- COOLDOWN_MARKER (tmp/last-save-ts) and NDC_MARKER (tmp/last-ndc.ts). A durably unreadable marker there silently defeats its cooldown on every invocation, forever, with nothing in the log to say so -- lower stakes than NDC_GEN_FILE (an extra Haiku call, not lost data), but the same silent-failure shape.Closes #625.
Also in this PR: #626
The SKIPPED-commit log line #619 added for a durably unreadable NDC_GEN_FILE now also names the remedy -- delete it to reset generation tracking to 0 -- instead of leaving every future round to land on the same line with no hint of the way out.
Closes #626.
What changed
ts_marker_read(), the same shape as save-session.sh NDC generation guard (#614) collapses "file absent" and "read failed" to the same value #619'sndc_read_gen(), reused at both COOLDOWN_MARKER and NDC_MARKER. Logs a WARNING naming the marker when a read fails instead of proceeding in silence.date +%s > "$MARKER"write below each read was unguarded, so a durably unwritable marker (a directory, most reachably) crashed the WHOLE script underset -e-- harder than the documented "fails open" behaviour. Both writes now guarded the same way an existing self-heal write already was.Self-review (two rounds)
Spawned Explore + oss:auditor against the first commit. Explore found three real issues, all fixed in a follow-up commit:
-fto-e || -L(needed to catch a directory in a marker's place) let a FIFO reachts_marker_read's unconditionalcat, which blocks forever on a FIFO with no writer -- a harder failure than the "fails open" this fix exists to guarantee. Fixed:ts_marker_readnow rejects any non-regular file before ever callingcaton it. Reproduced the hang against a scratch copy with the guard removed (TimeoutExpired), confirmed the fix returns fast, pinned with three new tests calling the function in isolation via process substitution.case ... in ''|*[!0-9]*)...fallback at both marker sites is now unreachable through the ts_marker_read path -- added a clarifying comment rather than rewriting the pre-existing The cooldown guards validate syntax but not range: a digits-only marker ahead of now sticks the throttle ON permanently, with no diagnostic #326/Cooldown and lock robustness in 50-git-backup.sh: a corrupt marker bypasses the throttle, and the marker is only written on success #258 history away.oss:auditor's first return classified as
referred-not-statedby the review-return protocol's classifier (a "finding, see above" phrase inside its own per-class checklist, even though the one real finding -- missing write-guard-specific test assertions -- was fully stated once). Per protocol, re-spawned once with a stricter format request. The re-spawn's clean return (states-findings) found one more real issue: a stale comment claiming a dangling symlink reads as0(it does not ---Lis true for it, so it falls through tounreadable, same asndc_read_gen's own correct comment already says). Fixed, with a new test pinning the actual behaviour.Tests
Red confirmed for every new assertion before its fix (the two marker-unreadable read/write cases, the #626 log-line wording, the FIFO hang via TimeoutExpired against a scratch copy, the dangling-symlink case against a scratch copy). All new and pre-existing related tests green: 151 tests across
test_save_session*,test_ndc_*,test_post_tool_cooldown*,test_windows_skip_triage_497pass. Fullpytestsuite not run locally, per this repo's own CLAUDE.md and the developer brief -- CI is the gate for the whole matrix.🤖 Generated with Claude Code
[AI-generated]