## Why
The architecture audit found several business rules maintained separatel…y by the terminal and web interfaces. Some had already diverged: mutable quota labels could collide, a missing primary allowance could pass scheduled-recovery coverage checks, an optional statusline could report `INPUT NEEDED` while working, and fractional Usage bars had different scales between renderers.
This PR consolidates those rules at their source, removes redundant state and handwritten browser contracts, and keeps rendering and browser security boundaries separate. It introduces no runtime dependency, service, persistence, or new browser write capability.
## Shared identity and session accounting
- Define quota identity once: backend limit ID, primary/secondary slot and meter kind. Definition keys additionally include duration, not mutable names or future reset timestamps.
- Reuse that identity in graph history, Sessions quota comparisons, scheduled quota recovery and API-EQ learning. Identical labels or durations no longer conflate distinct allowances, missing/changed windows are detected, and renamed labels refresh without rebasing accounting.
- Share observed session-state classification and attention/active predicates. No attention signal is no longer interpreted as an input request in the optional statusline.
- Share bounded token-interval sampling while preserving each interface's existing baseline, cadence and history limits.
## Interface-independent calculations
- Extract the existing process-local API-EQ learning engine into `internal/quotaestimate`; the TUI retains formatting, localisation, diagnostics and benchmark coordination. Remove its unused issues map. This does not add API-EQ estimates to the browser or change the estimator's confidence policy.
- Share elapsed-cycle calculations between quota health, reset gauges and graph geometry. Use the existing Go quota-graph regression, coverage and clipping code for browser Pace geometry; remove the JavaScript implementation. Geometry now uses the quota observation timestamp, rather than a separately advancing browser clock; countdown labels continue advancing normally.
- Share Usage dimension aggregation, ordering, units and bar scaling. Fix fractional totals, preserve signed corrections without turning negative values into positive bar fills, retain missing-versus-zero semantics, and compute browser report projections when reports are fetched rather than on every quota refresh.
## Contracts and maintenance
- Generate TypeScript types, the local slash-command catalogue and Usage dimensions from explicitly browser-safe Go projections. Daily normalisation uses the same dimension catalogue; historical 80%/100% warning classification is owned in Go and projected to the browser. Keep browser-specific help text and security/transport lifecycle code in their adapters.
- Replace hardcoded browser input-review command paths with Go-produced metadata; handle nullable wire fields explicitly.
- Add `make web-contracts` and freshness tests. Numerical browser fixtures are generated by the actual Go projectors, so browser tests do not maintain another copy of the maths.
- Document these ownership boundaries and the generation workflow. Rebuild embedded frontend assets; refresh the screenshot source fingerprint without changing the seven PNGs.
## Size measurements
Re-measured after successful CI, comparing final PR commit `9609afb` with default-branch baseline `93b3fb9`:
| Measurement | Before | Final | Difference |
| --- | ---: | ---: | ---: |
| Maintained production Go/Svelte/TypeScript lines | 41,878 | 41,696 | -182 (-0.43%) |
| Embedded production JavaScript, uncompressed | 151,565 B | 150,289 B | -1,276 B (-0.84%) |
| Embedded production CSS, uncompressed | 18,819 B | 18,819 B | Unchanged |
| Stripped Linux amd64 standalone binary | 16,875,680 B | 16,883,872 B | +8,192 B (+0.05%) |
Source counts now cover all tracked non-test Go files, including the root entrypoints, plus maintained Svelte/TypeScript under `web/src`. They exclude generated contracts, tests and embedded bundles. This corrects the earlier narrower source-count scope: both totals now include 750 unchanged root-level Go lines; the net reduction remains 182 lines.
Both binaries were freshly built with Go 1.27.3, `CGO_ENABLED=0`, `GOOS=linux`, `GOARCH=amd64`, `GOAMD64=v1`, `-buildvcs=false`, `-trimpath`, `-s -w` and the same injected version `0.27.1`. This removes development/VCS metadata differences from the comparison.
**There is no standalone binary-size win.** The measurable savings are in maintained source and browser JavaScript; the principal benefit is fewer independently maintained business rules. Generated contracts, numerical fixtures and additional regression tests make the overall diff larger despite the production-source reduction.
## Validation
- Final commit `9609afb`: [CI](https://github.com/merefield/codexometer/actions/runs/42067972864) and [Security](https://github.com/merefield/codexometer/actions/runs/42068349530) completed successfully, including Linux, macOS, Windows, browser tests and both vulnerability scans.
- Go race and coverage suite across all packages, with the locale subprocess matrix run separately.
- All 17 terminal locale cases under the race detector; English presentation snapshot unchanged.
- Direct tests for the extracted estimator: 91.7% statement coverage, including account/plan/window changes, tainted intervals, evidence validation and confidence bounds. Existing TUI accounting integration tests retained.
- Targeted identity, session-status, sampling, schedule-coverage, fractional/signed Usage, elapsed-cycle boundaries, reset rounding and historical warning-level regressions.
- All 111 Playwright browser tests, including Go-produced Pace fixtures and fractional-bar scaling and signed corrections.
- Frontend type/Svelte checks, formatting and production build; `go vet ./...`; generated-contract and fixture freshness checks.
- `make screenshots-check`: all seven README terminal screenshots verified for v0.27.1.
- Controlled standalone builds and `git diff --check`.
## Deliberately retained boundaries
Terminal/SVG geometry, colours, localisation, selection, transport lifecycles and browser-origin/write-authority protections remain interface-specific. No common abstraction is introduced for code that has genuinely different responsibilities.