Repository navigation
fix(cli): keep cron's state inside --cache-dir and quiet its first run - #39
Merged
Merged
Conversation
cron ran analysis without its cache dir, so the inner --since path read and
overwrote ~/.wikihistory/observations/<page>.json and printed a
"Re-observation delta" against it — outside --cache-dir, and counting prior
events outside the lookback window as resolved, which cron's own count does
not. Cron now passes its cache dir through and asks analysis not to record an
observation (runAnalyze's new { recordObservation: false }); cron keeps the
only one.
A page's first run logged the not-yet-written report with its ENOENT and full
stack; analyze --since did the same for its first observation. readPriorJson
is silent on a missing file and reports any other read or parse failure in
one line, path and reason.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
packages/cli/src/commands/analyze.ts conflicted on runAnalyze's signature: #38 widened its return type with `coverage`, this branch added the `{ recordObservation }` option. Kept both. CHANGELOG.md had two "## Unreleased" headings on main, from #38's section merging beside the existing one without a conflict. Folded them into one, entries unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Two
refract cronbugs, confirmed against@refract-org/cli@0.5.17from npm and present onmain.1.
--cache-dirdid not isolate cronCron called
runAnalyzewithout its cache dir. The analysis's--sincepath then read and overwrote~/.wikihistory/observations/<page>.jsonand printed a "Re-observation delta" against that file. On a first run into an empty--cache-dir, it reported e.g. "New events: 66, Resolved: 8, Unchanged: 87" from an unrelated earlier run. That delta also counted prior events outside the lookback window as resolved, which cron's own count does not, so the two numbers could disagree.Cron now passes its cache dir through and asks analysis not to record an observation, via a new optional trailing argument to
runAnalyze:{ recordObservation: false }. Cron keeps the only observation, under its cache dir.refract analyze --sinceis unchanged.2. A page's first run printed a stack trace
reports/<page>.jsondoes not exist until the first run finishes, and reading it was logged as a failure with the ENOENT and its full stack.refract analyze --sincedid the same for its first observation file. A newreadPriorJsonhelper is silent on a missing file. It reports any other read or parse failure in one line, naming the path and the reason. All three readers use it.Tests
cron.test.ts:{ recordObservation: false }cron-cache-dir.test.tsruns cron twice over the real analysis pipeline againstfake-mediawiki, withhomedir()mocked to an empty temp dir. It asserts:analyze-helpers.test.ts:analyze --since's first observation is silentWith the original
cron.tsswapped back in, all four new or changed cron tests fail. The real-pipeline test fails because.wikihistoryappears in the fake home.Verification
bun run build,typecheck,biome ci packages/,check:boundariesandbun run testpass: 380 passed, 9 skipped. The skips are theREFRACT_TEST_LIVEcontract tests;mediawiki-client.tsis untouched.refract cron pages.txt --interval 720 --cache-dir <scratch>withEarth.~/.wikihistory/observationsdid not change.observations/Earth.jsonandreports/Earth.jsonwere written in the cache dir.Not changed
analyze --since --cache-dir Dstores its observation atD/<page>.json, notD/observations/<page>.json.🤖 Generated with Claude Code