refactor(config): replace inline production values with named config keys and constants #74
Labels
No labels
blocked
bug
enhancement
high-priority
low-priority
needs-info
needs-triage
ready-for-agent
ready-for-human
referenced
research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gabogg/hikcentral#74
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Principle
A value that belongs to the deployment (a site's calibration, schedule, thresholds) lives in
occupancy_config/ settings and is read by name. A value that is a unit or protocol constant (seconds per hour) gets a named constant, defined once. Literals repeated as fallbacks (cfg.get("x", <production value>)) should take their default from one place.Evidence from a first scan (
masterat42891fa; occurrences inapp/Python and JS)1.1162k0.0002"04:00""03:30"/"04:30"8640036005000/400000.35,0.80,1.30static/js/src/ui/calibration_desk.js,app.js0.90,1.35telemetry_engine.js900.0Contradiction already visible: commit
3c0c519changed thedaily_reset_timeconfig default to"00:00"(HikCentral's reported time), but code still falls back to"04:00"in 17 places. Any path that reaches the fallback resets at the wrong hour.Duplicated across the stack: the frontend hardcodes backend thresholds (
calibration_desk.js:0.35,0.80,1.30;telemetry_engine.js:0.90). They should come from the API (config) so the two can't drift.Scope (to be settled in triage)
occupancy_configdefaults), never a repeated literal.SECONDS_PER_HOUR, …) in one module; cycle length follows #27's decision.Open questions for triage
occupancy_configcolumn defaults, a Pydantic settings model, or a constants module?"04:00"vs"00:00"contradiction need a fix before this sweep, as a data-veracity bug of its own?app/only, or tests andprototype_*files too (prototype_occupancy_math.pycarries many of these)?Related: #27, #33, #36.
Triage decisions (2026-09-24)
app/config_defaults.py; unit constants (SECONDS_PER_HOUR, …) inapp/units.py. DDL, schemas and services all import from these; no value is written twice."04:00"for fresh deployments (safe for venues open past midnight; matches production). The HikCentral-reported time is a hint shown to the operator, not the default. Resolves #76 item 2.app/Python plus frontend JS, as a CI test. Tests are excluded;prototype_*files are excluded and, if nothing imports them, deleted in a separate chore.Triage note (2026-09-24): the
"04:00"vs"00:00"reset-time contradiction is latent, not urgent.Production stores
daily_reset_time = 04:00explicitly (confirmed by the maintainer), so the 17 inline"04:00"fallbacks currently agree with production. A fresh deployment gets the"00:00"column default from the database, so the key is present there too. The literal fallback only takes effect if the config row is missing or incomplete.Decision: no fix in the open
[data-veracity]PRs (#68–#71). They are expected to add more inline values; this sweep runs after them and catches everything. During their reviews, any newly introduced inline production value is flagged as P3 and routed here instead of being fixed in the PR.Additions from the round-3 reviews of the
[data-veracity]PRs (2026-09-24), per the routing rule in comment 1622:now - 900and/ 15.0inline inget_group_recent_rate_async(not tied to each other); one morecfg.get("daily_reset_time", "04:00")fallback in the stall path; the"%I:%M:%S %p"format string now also in the repository (presentation formatting in the persistence layer)."04:00"default arguments acrossapp/facility_time.pyand three repository call sites; the"AUTOMATIC_NOCTURNAL"string compare in the repository.14in three places (service maturity check, trusted-history limit,app.jsbadge text).index.htmlcarryvalue="…"defaults: a fourth copy of the trust defaults (with DDL, repository and schema). TheTrustSettingsgrouping is in the PR #71 follow-up issue; do both together.