feat(conf): persist /config/ settings across pod restarts (migration v10)#63
Merged
Conversation
Adds coverage for functions that took no store/network/time-sensitive inputs and were previously untested (only healthstats and treadmill session detector had tests). - internal/web/colors_test.go: hslToHex anchors (red/green/blue/black/ white/grey) + always-well-formed sweep, nextExerciseColor determinism and small-N distinctness, needsColorBackfill/collectColors edges - internal/web/index_test.go: buildGroupList first-seen ordering (with empty-group edge case), sortExsByFrequency ordering + Place tiebreak + window respect - internal/api/health_test.go: parseHealthEnvelope metadata stripping, per-type counts, malformed root, dropped-untimeable records; healthRecordFromElement scalar mapping + Extra preservation + timestamp stripping from Extra + unmapped-type fallback via firstNumeric; firstTime priority, firstNumeric key order - internal/treadmill/parse_test.go: parseWatts envelope + raw + null- value + missing-value (both must NOT synthesise 0 W) + whitespace + garbage 45 tests pass across the three packages (~5 before this commit). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…v10) Every setting the /config/ page or PUT /api/config wrote was stored only in the process's atomic Conf holder, so a pod restart silently reset color / pagestep / frequency_days / display_days / autofill / cv_autolog back to the env-var defaults. The old on-disk YAML config path was a no-op even before I removed it in PR #45. Users who flipped CV auto-log on had it revert to off on every v0.0.102 rollout. Migration v10 adds a single-row app_config table (CHECK (id = 1)) with one column per persisted setting. Store gains GetAppConfig / SaveAppConfig. Startup path: env vars → overlay persisted row (when present) → conf.Set. Save handlers (web + api) UPSERT after conf.Set; persist failure is a soft-fail (server-side log) so a broken DB never makes the UI look broken. Not persisted: Pushover credentials (env-only per Layer 2 invariant on secrets), NodePath (environment-derived). Verified against a prod-dump preview: - Fresh DB → all 10 migrations apply, schema_version has 10 rows - v9 prod dump → only v10 applies; row counts unchanged; re-run reports "schema is up to date" - Round-trip: POST /config/ color=light pagestep=25 cvautolog=on; restart with the ORIGINAL env vars (COLOR=dark PAGESTEP=10 CVAUTOLOG=false); config still reads light/25/true; "loaded persisted config" logged on startup Bumps to pump-v0.0.103. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
# Conflicts: # internal/api/health_test.go # internal/web/colors_test.go # internal/web/index_test.go
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
Every setting the
/config/page orPUT /api/configwrote was stored only in the process's atomicConfholder, so a pod restart silently reset color / pagestep / frequency_days / display_days / autofill / cv_autolog back to the env-var defaults. Users who flipped CV auto-log on had it revert to off on everyv0.0.102rollout.app_configtable (CHECK (id = 1))GetAppConfig/SaveAppConfig(behindstore.Storeinterface)conf.Setconf.Set; persist failure is a soft-fail so a broken DB doesn't break the UIMigration checklist (per CLAUDE.md)
schema_versionhas 10 rows/config/color=light pagestep=25 cvautolog=on, restart with original env, config still reads light/25/true; startup logsloaded persisted configpump-vtag: bump to v0.0.103Test plan
go build && go vet && go test -race ./...— 47 tests pass across web/api/treadmill🤖 Generated with Claude Code