feat(ui): move calibration tools into a Calibration section of the configuration tab (#130) #146
No reviewers
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!146
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/calibration-config-tab"
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?
Summary
Resolves #130 by moving all calibration tools from the analytics tab into the configuration tab (
content-occupancy-admin) in a dedicated collapsible<details id="calibration-section">element, collapsed by default, and swapping the admin analytics tab out for the Statistics Deck (#133,#144).Changes Implemented
Collapsible Calibration Section (
#calibration-section):#content-occupancy-adminbeneath the primary configuration form and schedule tabs.<details id="calibration-section">without theopenattribute.<summary id="calib-status-banner">includes quiet window countdown, auto-reconciliation status badges, and expandable toggle indicator ([+] EXPAND/[-] COLLAPSE).k̂), empirical ratio, target guards, variance, maturity badge, confidence margin badge (±2.5% Margen), retroactive guard audit, portal diagnostics, and manual adjustment modal triggers.𝒪(t) = max(0, round(I - k·E))), delta residual, revert, and apply triggers.<canvas id="drift-chart-canvas">and<canvas id="calib-visualizer-canvas">.renderDriftChart,updateMultiplierPreview) automatically upon the details element's'toggle'event.Admin Tab Swap & Deck Mapping:
'analytics'with'statistics'inROLE_ALLOWED_DECKS.admin.KEY_DECK_MAP.F5 = 'statistics', keepingF8: 'statistics'.showAnalytics: falseinROLE_UI_CONFIG.adminand addedhiddenclass to#deck-btn-analytics.#deck-btn-occupancy-adminto[ F3: CONFIGURATION ].#deck-btn-statisticsto[ F5: STATISTICS_DECK ].#content-analytics(net flow curves, estimated occupancy with confidence margin, multi-day comparison) which are now superseded by the Statistics Deck (#133 / #144). Zero admin tools or calibration capabilities became unreachable.DOM & Dynamic Metric Invariants:
tests/test_static_assets.pydynamic_metric_idsto track the relocatedcalib-*element IDs.tabular-nums font-mono) and 0px border-radius invariant across all tactical components.Testing:
tests/frontend/test_calibration_config_tab.test.jsvalidating the HTML DOM structure, collapsed-by-default status, deck button labels, key mappings, and RBAC configs.pytest: 416 passed).ruff check .,ruff format --check .).Fixes #130.
Standards
(a) Documented Standards Violations (Hard Violations)
Tabular Numerics on Confidence Margin Badge (
docs/standards/ui-design-guidelines.md§3.2)app/static/index.htmlline 888:docs/standards/ui-design-guidelines.md§3.2 states "Numeric Formatting: Tabular numbers mandatory (font-variant-numeric: tabular-nums) ... Numbers must never shift or jitter when values refresh". The relocated confidence margin badge lackstabular-numsformatting.Dead Code & Zombie DOM Queries (
docs/standards/code-standards.md§1)app/static/js/app.jslines 3349–3358, 3457, and 3665–3714:content-analyticsviolates encapsulation and clarity standards.(b) Baseline Smells (Judgement Calls)
Mysterious Name (
calib-active-multiplier-dup) —app/static/index.htmlline 977 &app/static/js/app.jslines 3189, 3351calib-active-multiplier-dup. The-dupsuffix reflects an implementation workaround to avoid an ID collision withcalib-active-multiplierrather than revealing purpose. Recommended rename:calib-workbench-active-multiplier.Middle Man / Dead Delegation —
app/static/js/app.jslines 3665–3714renderCalibrationHistory()queries and populates#analytics-calib-logs-table-bodyand#analytics-calib-logs-count-badge, which no longer exist in the DOM.Spec
(a) Missing or partial requirements
#deck-btn-analytics"analytics leaves ROLE_ALLOWED_DECKS.admin and #deck-btn-analytics is gone"(Acceptance criteria), clarified by maintainer comment:"drop analytics from ROLE_ALLOWED_DECKS.admin and hide #deck-btn-analytics in app/static/js/app.js".#deck-btn-analyticswas retained in HTML with classhiddenrather than deleted, and hidden conditionally viaROLE_UI_CONFIG.admin.showAnalytics = false. This matches the issue comment and existing test assertions, but differs from the literal "is gone" acceptance line.(b) Behaviour in the diff not asked for (scope creep)
"map F5 to statistics in KEY_DECK_MAP. The deck itself already works for admins on F8."app/static/index.htmlline 171,#deck-btn-occupancy-adminwas renamed from[ F3: CALIBRATION_LAB ]to[ F3: CONFIGURATION ]. While logical because the calibration tools moved into the configuration tab, it was not explicitly requested in Issue #130.(c) Requirements implemented but implementation looks wrong
"Multiplier Stepping Workbench & Preview: ... live calculation preview (𝒪(t) = max(0, round(I - k·E)))"calib-active-multiplier-dupwas introduced as a parallel ID forcalib-active-multiplier.Summary: Standards: 4 findings (worst: zombie DOM queries and dead fallback loops in
app.js); Spec: 3 findings (worst: duplicate ID hackcalib-active-multiplier-dupin stepping workbench).Resolved all code review findings in commit
b04bb9f:tabular-numsto the confidence margin badge inapp/static/index.htmlper UI standards.calib-active-multiplier-dupto intention-revealingcalib-workbench-active-multiplieracrossindex.htmlandapp.js.content-analyticselements inapp.js.tests/test_static_assets.pyandtests/frontend/test_calibration_config_tab.test.js). All 416 unit tests and 122 frontend tests passing cleanly.Standards
(a) Documented Standards Violations
[P2] Semantic DOM Requirements (
docs/standards/ui-design-guidelines.md§3.3)app/static/index.html(line 888)<output>or<data value="...">) rather than generic<span>tags.[P3] Verification Gap: Dynamic Metric Test Invariants (
docs/standards/code-standards.md§4)tests/test_static_assets.pycalib-workbench-active-multiplierwas added todynamic_metric_ids,calib-confidence-margin-badge(which carriestabular-nums) was omitted fromdynamic_metric_idsintest_dom_invariants_zero_radius_and_tabular_nums.(b) Baseline Smells (Judgement Calls)
[P2] Duplicated Code & Falsy Coalescing Defect (
app/static/js/app.js)loadOccupancyAdminSettings(line 2161),saveOccupancyConfig(line 2503), andrenderCalibrationEquationCard(line 3400)loadOccupancyAdminSettingsuses|| 2.5, which incorrectly coerces a valid0%error margin (min="0") to2.5%, whereasrenderCalibrationEquationCarduses nullish coalescing?? 2.5. Recommended fix: extract a unifiedupdateConfidenceMarginBadge(margin)helper using?? 2.5.[P3] Duplicated Code: Dual Multiplier Targets (
app/static/js/app.js)initializeMultiplierWorkbenchandrenderCalibrationEquationCardcalib-active-multipliervscalib-workbench-active-multiplier) requires tandem DOM updates whenever the active multiplier changes.Spec
(a) Missing or partial requirements
[P3] Raw Telemetry Tables & Exporters Unreachable in UI
occupancy-adminand operational charts were dropped per spec, but the raw telemetry data tables (Passenger Flow, Door Cycles, Hardware Transitions) and CSV/JSON exporters remain inside#content-analytics. Becauseanalyticswas removed fromROLE_ALLOWED_DECKS.adminand its button hidden, these tables are no longer accessible from the UI. Per spec, "Retiring their routes is a separate issue", but their UI home is now orphaned.[P3]
#deck-btn-analyticsKept in DOM (Hidden)analyticsleavesROLE_ALLOWED_DECKS.adminand#deck-btn-analyticsis gone"#deck-btn-analyticsis retained inindex.htmlwith classhiddenand toggled off inapp.js(showAnalytics: false). While differing from a literal removal, this matches Maintainer Comment 2622 ("hide#deck-btn-analyticsinapp/static/js/app.js") and prevents potential null reference errors in UI controller logic.(b) Behaviour in the diff not asked for (scope creep)
CONFIGURATIONoccupancy-admin, where the schedules, exceptions and occupancy settings already are)"#deck-btn-occupancy-adminwas renamed from[ F3: CALIBRATION_LAB ]to[ F3: CONFIGURATION ]. While not explicitly requested in the issue text, this reflects the consolidated purpose of the tab.(c) Requirements implemented but implementation looks wrong
Summary: Standards: 4 findings (worst: [P2] semantic DOM requirement violation and falsy coalescing margin bug); Spec: 3 findings (worst: [P3] orphaned raw telemetry tables in hidden analytics container).
Resolved all P2 code review findings in commit
2debfe4:#calib-confidence-margin-badgefrom<span>to semantic<output>per UI guidelines §3.3.updateConfidenceMarginBadge(margin)helper with nullish coalescing (?? 2.5) inapp/static/js/app.js, eliminating duplicated string formatting and preventing false default overrides when margin is 0%.All P3 findings have been tracked in follow-up issue #151.