Skip to main content

Unification and debloat baseline

Captured on 2026-08-20 for refactor/unification-debloat at fcd6ed9d41127cec0f40468672de081a1e8eff6c.

This document is the measured starting point for the behavior-preserving unification initiative described in the review plan. Counts are intentionally scoped and reproducible; they are not a claim that every similar implementation in the repository has been found.

Branch state

The source trees were identical before normalization even though dev had five merge-history commits to catch up. The prescribed fast-forward procedure was completed and pushed:

  • origin/main: fcd6ed9d41127cec0f40468672de081a1e8eff6c
  • normalized origin/dev: fcd6ed9d41127cec0f40468672de081a1e8eff6c
  • git diff origin/main...origin/dev: empty
  • implementation branch: refactor/unification-debloat

Verification baseline

CommandResultEvidence or limitation
pnpm install --frozen-lockfilePasspnpm 11.15.1; all eight workspace projects already up to date
pnpm verifyPre-existing failurelint, typecheck, docs, dependency policy, route security, dashboard sync, package tests, and script tests passed; API integration tests failed before application assertions because the test database pool timed out
pnpm buildPassWeb and documentation production builds completed; existing large-chunk warning remains
pnpm test:e2eEnvironment failurePlaywright startup stopped on Node Unknown file extension ".css" for uplot/dist/uPlot.min.css before any E2E test ran
pnpm docs:buildPassDocusaurus build and search-index validation completed
cargo fmt --manifest-path apps/api/Cargo.toml --all --checkPass
cargo clippy --manifest-path apps/api/Cargo.toml --all-targets --all-features -- -D warningsPassExisting future-incompatibility warning is emitted by a dependency, not clippy
cargo test --manifest-path apps/api/Cargo.toml --all --all-featuresPre-existing failure292 unit tests passed and 43 were ignored; 32 auth/integration tests failed at admin db connect: PoolTimedOut

The API failures are recorded as baseline limitations. They must not be attributed to later refactor changes without a working test database and a new comparison run.

Hotspot size baseline

The ratchet stores these values in config/architecture-budgets.json. A listed file may shrink but may not exceed its initial line or byte budget. Byte counts are normalized to LF before measurement so Windows checkout EOL conversion cannot reject unchanged source.

FileLinesBytes
apps/web/src/features/settings/SettingsPage.tsx1,86697,620
apps/web/src/components/settings/BackupSection.tsx1,70071,666
apps/web/src/components/layout/AppLayout.tsx43016,120
apps/web/src/components/dashboard/DashboardPageShell.tsx48518,178
apps/api/src/routes/vehicles.rs5,597198,198
apps/api/src/routes/charging.rs2,24283,776
apps/api/src/routes/trips.rs1,83365,504
apps/api/src/services/backups.rs2,67398,764
apps/api/src/services/charge_sessions.rs1,94973,563
packages/hooks/src/api/transport.ts2,25476,978

Duplicate-pattern inventory

Counts below exclude test and story files. A match count is reported separately from the file count where a file can contain multiple direct consumers.

PatternCountFilesScope
window.alert(...)00apps/web/src and shared frontend packages
window.confirm(...)63Settings and external-connection workflows
role="switch"33Settings and dashboard editor controls
createPortal(...)87Existing overlay and low-level tooltip/editor surfaces
queryKey: [...]11622App/package source; includes raw query and invalidation arrays
resolve_time_bounds definitions66apps/api/src/routes/{battery,efficiency,idle_drain,metrics,trips,charging}.rs

The initial guard configuration allowlists the current production locations and caps each pattern at its measured match count. Follow-up foundation and query-factory PRs must remove those allowlists and lower those caps as consumers migrate. The six Rust time-range definitions are likewise capped by the guard until A1 consolidates them.

Guard ownership

pnpm architecture:check is now the single named verification entry point for:

  • architecture-budget and duplicate-pattern ratchets;
  • raw transport ownership and source-cycle checks;
  • dashboard-default synchronization;
  • API route security inventory.

pnpm verify invokes this entry point once and no longer invokes the nested dashboard and route checks separately. PR 1 changes verification and documentation only; it does not change application runtime behavior.

Cleanup checkpoint

The temporary persisted custom-chart subsystem was removed from the application surface while the existing static dashboard chart catalog and specialized renderers were retained. Migration 0011_chart_definitions.sql remains immutable; migration 0012_remove_chart_definitions.sql removes its unused table for databases that applied the temporary feature.

The trips and efficiency routes now share one trip-tag search parser, normalizer, serializer, and route adapter. The route-local implementations fell from two to zero, with four focused contract tests covering canonical ordering, invalid input, untagged precedence, and identical serialization.