[data-veracity] Calibration log dedup destroys audit history and backfills the multiplier it later reports #34
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#34
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?
Problem
quarantine_and_deduplicate_calibration_logs_async(app/db/occupancy_repository.py:1410) performs three destructive or fabricating writes on the table that backs the deck's Nocturnal Calibration Ledger and the k̂ drift chart.1. Hard delete of all but the newest log per cycle
Only the highest
idpercycle_datesurvives. An earlierMANUAL_OVERRIDErecorded by an operator is silently destroyed by a later automatic run on the same cycle.CONTEXT.md§3 listsMANUAL_OVERRIDEas a first-class trust status, andperformed_by/reasonexist precisely to record who intervened — those rows are being deleted.The deck presents this table as an audit trail. An audit trail that is pruned to one row per day, keeping whichever write happened last, is not one.
2. Cycle dates backfilled by blind subtraction
This assumes every log was written roughly 24 h after the cycle it describes. True for the 04:15 nocturnal run; false for a manual calibration executed at 23:00, which gets attributed to the wrong cycle — and then, per (1), can delete that cycle's real log. It also uses SQLite
'localtime', i.e. server timezone (see the separate timezone issue).3. The multiplier is invented where it was not recorded
Two problems:
1.000is indistinguishable from an unset one, and gets overwritten with the rawI/Eratio.compute_ewma_multiplierandcompute_multiplier_varianceas though it were a measurement.The deck plots this column as "Exit multiplier k̂ drift — nightly convergence". Some of those points are not convergence results; they are ratios backfilled by a maintenance job.
KPIs corrupted
Nocturnal Calibration Ledger (Month) · k̂ drift chart and its σ band ·
multiplier_varianceand therefore the width of the 95% CI on the Day occupancy envelope · Trust Index.Suggested fix
DELETEwith asuperseded_by/is_currentcolumn; keep every row. Retention already prunes at 365 days (prune_retention_data_async), which is the right place for deletion.MANUAL_OVERRIDE. If dedup must collapse rows, it must skip operator-authored ones.cycle_datethrough the real business-cycle boundary function, nottimestamp - 86400.1.0: makecomputed_exit_multipliernullable and stop backfilling. If a ratio is wanted, store it in its own column (raw_io_ratio) so the drift chart plots only genuine convergence results.MANUAL_OVERRIDErow survives a dedup pass.Being addressed in draft PR #71, one of four [data-veracity] drafts declared on 2026-09-23 (#68, #69, #70, #71). Each will be triaged, reviewed and implemented in order; the PR description lists the open design points to settle first.
gabogg referenced this issue2026-09-24 13:13:53 +00:00