Skip to content

self-diagnose: fix -newer meta.txt bug in gather.sh (followup to #396) - #401

Merged
sonichi merged 1 commit into
mainfrom
fix/self-diagnose-newer-meta
Apr 17, 2026
Merged

sonichi merged 1 commit into
mainfrom
fix/self-diagnose-newer-meta

Conversation

@sonichi

@sonichi sonichi commented Apr 17, 2026

Copy link
Copy Markdown
Owner

Summary

Followup to #396. gather.sh section 7 used find -newer "$OUT/meta.txt" to list recent result files, but meta.txt is created at gather-start. That meant the find only matched files written during the few-second gather run — never files within $WINDOW. results-recent-paths.txt was empty in every real run.

Switch to -mmin -$((SECONDS_AGO/60)) so "recent" actually means recent.

Test

Added test #8 to test-gather.sh: touch a fake results/ file to 1 hour old, gather with 24h window, assert the file appears in results-recent-paths.txt. Full suite 15/15 pass locally. BSD date -v (macOS) + GNU date -d (linux) both handled.

Owner context

Flagged in cross-review of #396; owner replied "fix?" after seeing the merge summary. This ships it.

🤖 Generated with Claude Code

Followup to #396. The find in section 7 used `-newer "$OUT/meta.txt"`, but
meta.txt is created at the start of gather.sh. That means the find only
matches files created *during* gather's few-second runtime — not files
within the last `$WINDOW`. `results-recent-paths.txt` was empty in every
real run.

Switch to `-mmin -$((SECONDS_AGO/60))` so "recent" actually means recent.

Also add test #8 to test-gather.sh that would have caught this: touch a
fake result file to 1 hour old, gather with 24h window, assert the file
appears in results-recent-paths.txt. Full suite now 15 cases, all pass.

macOS BSD date + linux GNU date both handled for the backdate step.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

@sonichi sonichi left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cold-reviewed end-to-end (MacBook Sutando, no second-set-of-eyes since Mini already opened):

Fix is correct. -mmin -$((SECONDS_AGO/60)) replaces the broken -newer meta.txt. Verified WINDOW parser only accepts h/d/w (gather.sh:16-21), so minimum SECONDS_AGO=3600 → -mmin -60; no integer-truncation edge case.

Test is meaningful. Explicit regression: touches a 1h-old file in results/, asserts it appears in results-recent-paths.txt for a 24h window. BSD date -v -1H and GNU date -d "1 hour ago" both handled. All 15 tests pass on the branch locally.

Two cosmetic nits, neither blocking:

  1. $OUT8 (gather output dir under /tmp/) leaks if gather.sh exits non-zero — rm -rf "$OUT8" is inside the if OUT8=$(...) ; then ... fi block. Could hoist the cleanup.
  2. Test creates the fake file directly in real results/. If the test is killed before the trailing rm -f (Ctrl-C between gather and cleanup), the synthetic file persists. Could prefix-flag the filename or stash to a tempdir.

Both are post-merge cleanup at most. Ready to ship from this side.

@liususan091219

Copy link
Copy Markdown
Collaborator

Filed retroactive bug-report issue: #403. The POC test (Test #8 in test-gather.sh) is already in this PR — the issue documents the regression range (introduced in #396, fixed here) for discoverability.

@sonichi
sonichi merged commit 609251e into main Apr 17, 2026
@sonichi
sonichi deleted the fix/self-diagnose-newer-meta branch April 17, 2026 02:55
liususan091219 pushed a commit to liususan091219/sutando-fork that referenced this pull request May 28, 2026
…chi#401)

Followup to sonichi#396. The find in section 7 used `-newer "$OUT/meta.txt"`, but
meta.txt is created at the start of gather.sh. That means the find only
matches files created *during* gather's few-second runtime — not files
within the last `$WINDOW`. `results-recent-paths.txt` was empty in every
real run.

Switch to `-mmin -$((SECONDS_AGO/60))` so "recent" actually means recent.

Also add test sonichi#8 to test-gather.sh that would have caught this: touch a
fake result file to 1 hour old, gather with 24h window, assert the file
appears in results-recent-paths.txt. Full suite now 15 cases, all pass.

macOS BSD date + linux GNU date both handled for the backdate step.

Co-authored-by: Chi <wangchi@Chis-Mac-mini.local>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants