Gunnar

nordisk/facett

.nornir/facett-deduplication-history.md

# facett de-duplication campaign — record

> **Class:** `history`. The running record of the `duplication-audit` (clusters
> A–L) consolidation: what was folded to a single home, and — just as important —
> what was **left deliberately** because a merge would ADD code, change output, or
> carry real regression risk for no true-dup gain. Descriptive "how the shared home
> works" lives in the relevant `*-design.md`; this file is the ledger + the honest
> "why not" for the clusters left standing.

The audit (`duplication-audit-2026-07-28`) ranked twelve true-dup clusters A–L
across facett's ~70 crates. Consolidation ran in passes; a later adversarial
verifier confirmed the work was real but that cluster J had two byte-identical
**survivors** and that A/D/E/G/H/I were still open. This is the settled state.

## FOLDED TO ONE HOME (true dups, done)

- **B — warm-red / amber literal (~24×)** → `facett_core::look::{RED, AMBER}`
  (`look/color.rs`). `facett_stat::Verdict::color` re-exports them, so there is one
  warm-red in the workspace. No `224,90,90` / `224,72,72` `Color32` literal remains
  outside core (the `facett-demo` widget-gallery `[224,90,90,255]` is a raw palette
  *swatch* array being displayed, not a use of the colour). Done in `eb28853`.
- **F — `lerp_color` (4×) + `heat_color` (2×)** → `facett_core::look::{lerp_color,
  heat_color}`. Done in `eb28853`.
- **C — terrain DEM (~340 LOC map3d ↔ flight)** → lives once in `facett-map3d`;
  flight `pub use`s it. Done in `1cd703f`.
- **J — serial FR step + box-fit** → `facett_core::barnes_hut::{fr_step_serial,
  normalize_box}` (`4fcf438`), plus the **two survivors** the verifier found
  (`197aab5`): the PRIMARY 3-D `facett-graph3d Layout3D::Force` inline loop now
  delegates `fr_step::<3>` / `fr_step_serial::<3>` (temp 0.04), and
  `facett-graphview::gpu_layout::normalize_box` deletes its byte-identical local
  copy for core's. See `force-layout-twolane-design.md` §f2b (incl. the
  coincident-node behavior note — left as-is, documented there).
- **L — Sutherland–Hodgman rect clip** → `facett_core::render::cpu::scissor`
  (`9c302b4`).
- **G — status chip (RichText form)** → `facett_core::look::chip`. `facett-deploykey`
  and `facett-buildthing::deck` had byte-identical local `fn chip`; both now delegate
  (`7c68d57`).
- **I — map fill-way paint recipe (4×)** → `facett_map::tessellate::paint_filled_way`
  (takes already-projected ring + holes; `fill: Option` so `MapFacet` strokes unfilled
  polygons; `outline_holes` flag). `facett-map` `MapView` + `MapFacet` and
  `facett-geomap` `GeoMap` + `osm2d` delegate; each keeps its own genuinely-different
  projection preamble (f32 `to_px` / f64 `cam.to_px` + S-H clip / tilt-fade). Byte-exact:
  the `rabbit_2d` / `real_map_2d` / `basemap` PNG goldens are unchanged (`7c68d57`).

## LEFT DELIBERATELY (would add code / change output / real regression risk)

- **A — camera / pan-zoom (~10 copies).** The single biggest *structural* item, and the
  one deliberately deferred. `facett-core` already carries the intended homes: the 2-D
  `nav::Navigable` and the 3-D `render::camera::Camera`/`V3`/`Projected`/`view_proj`,
  which is reproduced **bit-for-bit** from `facett-map3d`'s and **already goldened for
  equivalence** by the `camera_seam` test (2-D and 3-D). So the *seam exists and is
  proven*; what remains is a **typed migration**, not a byte-safe swap:
  - The 3-D finish would replace `facett-map3d::camera`'s own `V3`/`Projected`/`view_proj`
    (map3d adds `view_proj_mirrored` water + the flight floating-origin camera on top)
    with core's types, rippling through map3d **and** `facett-map3d-flight` (which
    re-exports map3d) and their 3-D render goldens.
  - The 2-D finish would move `graphpan`/`graphview`/`map`'s cameras onto `Navigable`,
    but those copies have **diverged by coordinate space and feature** (map carries
    `bearing_deg`+`tilt_deg` in f64; the graph cameras are f32 pan/zoom with a
    `clamp(0.25,4.0)`), so a single adopter is a behavioral rewrite across panes that
    all carry snapshot goldens.
  Verdict: **DEFERRED** — the duplication is intentional-and-goldened; completing it is
  a multi-crate typed/behavioral migration whose risk is not justified by dedup alone.
- **D — graphpan ≈ graphview (whole-component).** The `GraphNode`/`GraphEdge`/`GraphModel`
  dup is real, but this is a **crate merge**: `facett-graphpan` is a distinct `Facet`
  (`GraphPanView`) depended on by `facett-graphnav`, `facett-buildthing`, `facett-demo`,
  `facett-streamlit` and the umbrella; `graphview` is the "consolidated engine". Folding
  one into the other migrates 4+ dependents and reconciles two panes' goldens.
  Verdict: **DEFERRED** — pane merge, wide blast radius; not a byte-safe dedup.
- **E — facett-plot ⊂ facett-plotters.** `ChartKind` + `Series` are duplicated and
  plotters is a superset — but `facett-plot` has a real external consumer
  (`facett-warehousedeck`) and the two `ChartKind` enums differ (plot: Line/Bars;
  plotters: Line/Bar/Scatter/…). Merging is a **crate merge** that retypes warehousedeck.
  Verdict: **DEFERRED** — pane/crate merge with a live consumer; not byte-safe.
- **H — tiny format helpers.** JUSTIFIED SPECIALIZATION, not forced:
  - `human_bytes`/`human_size` (binview/pipeline/plandag/file) share the ÷1024 loop
    *skeleton* but each emits a **deliberately different string** — `"1.5 MB"` vs IEC
    `"1.5 MiB"` vs terse `"1.5M"` vs a 4-unit cap. One shared fn preserving every
    contract needs a units+separator parameter at every call site = **added surface**;
    one shared fn with a single convention **changes displayed text** in 3 of 4 crates.
  - `crate_color` (binview vs coderoom-view) share the FNV-1a hue hash but differ in
    **both** the Oklch L/C tuning (0.68/0.14 vs 0.62/0.13) **and** the return type
    (`Color32` vs coderoom's own `Color`); merging changes rendered colour (breaks the
    coderoom `hex()` robot golden) or needs a parameterised wrapper each site keeps.
  - `fmt_dur` (cicd, seconds) vs `fmt_elapsed` (jobview, ms + status-aware) are different
    signatures/inputs sharing only a ~1-line `"{}m {:02}s"` tail.
  Verdict: **JUSTIFIED** — the skeletons rhyme but the *contracts* diverge; the
  workspace already centralises the real primitives (`hash_color`, `look::lerp_color`).
- **K — gantt vs timeline time-axis.** Left at audit time (partial dup; a shared
  `TimeAxis` adopter would ADD an abstraction the two visuals don't otherwise share).

## Justified splits confirmed NOT dups
Per the audit's "looks-duplicated-but-correct" list: the `impl_facet_via_elm!` ELM
architecture (49 crates, not copy-paste), geomap/osm as well-behaved `facett-map`
consumers, the map3d ↔ map3d-flight layered split (only the terrain DEM, cluster C,
was a real copy), the `style.rs`/WKB/tessellation single owners, and the barnes-hut +
graphcloud + cpu-painter core homes.