refactor: move the deep-analysis last-run record out of the cache - #534
Merged
Conversation
The deep-analysis safety net now keeps its last-run record in a dedicated file, /config/.plex-language-sync-last-run, instead of a last_scheduler_run field in state.json. The restart behavior is unchanged: a startup pass runs only when no record exists or the last completed pass is older than DEEP_SCAN_INTERVAL, and the replay look-back window still extends from the previous completed pass, capped at 30 days. state.json no longer carries the last_scheduler_run key. Files written by earlier versions still load; the retired key is ignored on read. On the first start after this upgrade the record file does not exist yet, so one initial deep-analysis pass runs even if the previous version completed one recently, and that pass uses the 24-hour look-back floor. The pass records its completion and the schedule is back to normal from then on. One boundary detail changed: a record aged exactly DEEP_SCAN_INTERVAL now counts as due, where it previously had to be strictly older.
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.
Moves the deep-analysis pass's last-run record out of the persisted JSON cache and into the shared restart-surviving record from scheduler v4.1.0, at
/config/.plex-language-sync-last-run. The startup gate keeps its exact semantics (CountFailed: any completed pass holds its slot, the interval ticker owns the retry), and the replay lookback window now reads the same record, 24h floor and 30-day clamp unchanged. Thelast_scheduler_runcache field is deleted from the schema, the legacy migrations, the contract, and the test fake; old cache files still load (unknown JSON keys are ignored, pinned by a test).Migration effect, one-time: on the first boot after this upgrade the record does not exist yet, so one initial deep-analysis pass runs even if the previous version ran recently, with the 24h lookback floor. Self-heals after that pass. The alerting example is unchanged; its window already derives from the conditional startup behavior this preserves.
Tested: startup-gate matrix ported to the record file, lookback floor/extend/cap, watermark set, retired-key cache load, record-write failure tolerance; full suite, lint, and markdownlint green; the race detector runs in CI.