Persist UX insights weekly gate across restarts - #39
Open
silas-dsc wants to merge 1 commit into
Open
Conversation
The weekly gate's nextRunAt clock was in-memory only, so a restart reset it to 0. Combined with the day-of-week anchor, that still let the report re-post on any restart that happened on the report day (e.g. Monday). Persist nextRunAt to .symphony-ux-insights-state.json (mirroring the orchestrator's existing Slack-queue persistence) via a new injectable UxStateStore, defaulting to a disk-backed FileUxStateStore. The watcher restores the clock on construction and rewrites it after each successful run. Both load and save are best-effort: a missing, corrupt, or unwritable file degrades to the previous in-memory behaviour instead of crashing. The report now goes out at most once per run_interval_ms even across repeated restarts, and always on the configured weekday. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aJhv8L2YPc8TaJE6SXeXM
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.
Summary
Follow-up to #38. That PR anchored the UX insights report to a weekday (Monday), which stopped it re-posting on Tue–Sun restarts — but the weekly-gate clock (
nextRunAt) was still in-memory only, so a restart reset it to0. On a restart that happened on the report day (Monday), both gates were open and the report re-posted. It could re-post on every Monday restart.This closes that gap by persisting the clock across restarts.
Change
UxStateStore(load()/save()) onUxInsightsWatcher, defaulting to a disk-backedFileUxStateStorethat reads/writes.symphony-ux-insights-state.json— mirroring the orchestrator's existing.symphony-slack-queue.jsonpersistence pattern.nextRunAton construction and rewrites it after each successful run.loadandsaveare best-effort: a missing, corrupt, or unwritable file logs a warning and degrades to the previous in-memory behaviour rather than crashing the watcher.Net effect: the report goes out at most once per
run_interval_mseven across repeated restarts, and always on the configured weekday.The
symphony-ux-insightsCLI /--dry-runpath is unchanged — it still bypasses the gate and doesn't touch the state store.Files
src/ux-insights.ts—UxSchedulerState/UxStateStoretypes, load-on-construct + save-on-advance,FileUxStateStore.src/orchestrator.ts— wire aFileUxStateStore(undersymphonyRoot) into the watcher..gitignore— ignore.symphony-ux-insights-state.json.WORKFLOW.md— updated the scheduling note to reflect persistence.src/__tests__/ux-insights.test.ts— tests for persist-on-success, no-persist-on-failure, restore-blocks-restart, andFileUxStateStoreround-trip / missing / corrupt / bad-value handling.Testing
pnpm build— clean.pnpm test— 260 passed (16 files), including 7 new tests for the persistence behaviour.🤖 Generated with Claude Code
https://claude.ai/code/session_014aJhv8L2YPc8TaJE6SXeXM
Generated by Claude Code