# Handover: deps-cube implementation in progress ## What you are picking up The package `package/dev-script/deps-cube/` is being built per the approved plan at `/home/user/.claude/plans/make-a-new-workspace-serialized-puppy.md`. Read that plan first; it has the full design, the dimension mapping, the deck. gl scene composition, the UI/UX spec, the data-acquisition pipeline, the library-audit rationale (deck. gl approved at 72.7% TS as an explicit user-confirmed exception), and the verification checklist. Tool premise: scatter-plot every catalog entry in the `pnpm-workspace.yaml` in 3D feature space (6 dims = 3 spatial + color + shape + size), with deck. gl WebGL rendering and a custom HTML control panel for dim swapping, 3-state boolean filtering, range sliders, name search, display toggles, and URL-hash bookmarking. Output: `/dist/deps-cube-.html` (filename carries ISO 8601 UTC down to seconds with `:`→`-`, so each run produces a distinct artifact; the package directory is located via `findPackageRoot` walking up from `import.meta.dirname`). Stdout: exactly `Saved to `. **Status (2026-05-12, ninth handover; visual-fix iteration)**: tasks 1 through 12 done; task 13 still partial (headless verification done; manual Firefox interaction checks pending). The eighth handover described three Task-13 bugs that were fixed. THIS handover covers a second round of visual fixes (Tasks 14 to 22) addressing six visual issues found when actually opening the HTML in Firefox: stretched ellipses (flat 2D `ScatterplotLayer` glyphs foreshortened at 30° camera tilt), invisible wireframe, fragmented overlapping axis labels, indistinguishable leaf vs non-leaf, double scrollbar, single-handle range sliders. The user also pivoted the backdrop visual: scene should resemble a classic 3D coordinate-system diagram (three green coordinate planes + arrowed axes with tick marks + `X`/`Y`/`Z` capital labels + origin `O`), not a wireframe box with threshold planes. Implemented: - New deps `@deck.gl/mesh-layers` + `@luma.gl/engine` (catalog + `package.json` + pnpm install). - New `src/deck-geometries.ts`: `sphereGeometry`, `octahedronGeometry` (flat-shaded with 24 duplicated vertices), `coneGeometryX`/`Y`/`Z` (pre-rotated per axis via luma. gl's `verticalAxis` prop). - Rewrote `src/deck-scatter.ts` to use `SimpleMeshLayer` with the sphere/octahedron geometries instead of `ScatterplotLayer`. Glyphs are now true 3D solids (spheres for leaf, octahedra for non-leaf) round/diamond-silhouetted from every camera angle. - New `probeRadiusWorld({probe, state, bounds})` accessor in `src/deck-accessors.ts` returning world-space radius scaled to 0.5 to 3% of the bounds diagonal (`Math.hypot(dx, dy, dz)`). - Rewrote `src/deck-layers.ts`: replaced wireframe-box + threshold-planes with `buildAxisShaftLayer` (3 thick PathLayer segments from min-corner to tip), `buildAxisArrowheadLayers` (3 cone `SimpleMeshLayer`s at tips), `buildAxisTickLayer` (5 ticks per axis). - New `src/deck-planes.ts`: `buildCoordinatePlaneLayers` (3 pale-green `PolygonLayer`s at floor/back/side walls intersecting at the data box's min corner) + `buildThresholdLineLayer` (thin guide lines on the planes at the threshold values; replaces the previous opaque threshold-plane fills while preserving the heuristic meaning). - Rewrote `src/deck-labels.ts`: split into four layer factories: `buildAxisCapitalsLayer` (bold `X`/`Y`/`Z` at arrow tips, 24px), `buildAxisSubtitlesLayer` (small dim-name labels alongside), `buildOriginLabelLayer` (single `O` at the min corner), `buildNameLabelsLayer` (per-glyph names, unchanged behaviour). - Rewired `src/deck-config.ts` `buildLayers` to call the new factories in the right back-to-front order; the `showWireframe` display toggle now controls the coordinate planes (the wireframe-box layer is gone). - `src/styles.css`: `html, body { block-size: 100vh; overflow: hidden }` and `#canvas-host { block-size: 100vh; overflow: hidden }` to remove the page-level scrollbar (now only the controls panel scrolls). Added `.range-track` rules: two `` stacked on a single track via `position: absolute`; only the `::-webkit-slider-thumb` / `::-moz-range-thumb` accept pointer events so both can be dragged independently. No `background-color` override on the canvas; green is forgiving of dark backdrops, so the OS dark/light scheme is respected. - `src/render-controls.ts` `renderRangeRow`: wraps the two inputs in `
` so the dual-thumb CSS applies. - Test fix: `test/render-controls.unit.test.ts` updated for the new HTML structure (asserts `class="range-track"` × 6, twelve range inputs, six `range-row` classes via prefix match). Lint, types, and tests all clean (0 errors; ~454 stylistic warnings, all non-blocking). 9 PASS / 0 FAIL / 1 SKIP across the eight test files. The CLI runs end-to-end and produces a fresh `dist/deps-cube-*.html` (~826KB; slight uptick from the previous 803KB driven by the mesh-layers + luma. gl/engine additions in the inlined controller bundle). **Status (2026-05-12, tenth handover; coordinate-system backdrop iteration 2)**: when the user opened the iteration-1 HTML in Firefox they could see only ONE green coordinate plane (back wall): the floor and side wall were missing entirely. Diagnosis via reading deck. gl source: `SolidPolygonLayer`'s default tessellator runs earcut on the XY projection of the polygon. For our floor (constant `y`) and side wall (constant `x`) the XY projection collapses to a line, earcut produces zero triangles, and the layer renders nothing. The fix is `_full3d: true`, which permutes the largest-area plane onto XY before earcut and back after; that prop is exposed only by `SolidPolygonLayer`, not the high-level `PolygonLayer` wrapper. Implemented: - `src/deck-planes.ts`: swapped `PolygonLayer` for `SolidPolygonLayer` and passed `_full3d: true` on each of the three plane layers. Bumped `COORDINATE_PLANE_COLOR` alpha from 30 to 60 so the planes read clearly without dominating the data. - `src/script/state.ts`: `DEFAULT_DISPLAY_TOGGLES.showThresholdPlanes` flipped from `true` to `false`. The brown threshold guide lines were confusing default-on chrome; they're an opt-in heuristic overlay now. - New `src/script/scheme.ts`: exports `ChromeColors` type and `detectScheme()` that branches on `globalThis.matchMedia('(prefers-color-scheme: dark)').matches` to return either a light-on-dark or dark-on-light palette for the chrome (axes / ticks / capitals / origin / name labels). - `src/script/controller.ts`: `createSession` calls `detectScheme()` once and stores the palette on the session; passed through to every `buildLayers` call via the existing render path. New `chrome: ChromeColors` field on the `Session` type. - `src/deck-config.ts` `buildLayers`: accepts `chrome: ChromeColors`, forwards to every chrome-coloured factory (`buildAxisShaftLayer`, `buildAxisArrowheadLayers`, `buildAxisTickLayer`, `buildOriginLabelLayer`, `buildAxisCapitalsLayer`, `buildAxisSubtitlesLayer`, `buildNameLabelsLayer`). Coordinate planes still use the static `COORDINATE_PLANE_COLOR` (green works on either backdrop). - `src/deck-labels.ts`: dropped the opaque-white label backgrounds (they dominated the dark scene); colours now come from `chrome`. Subtitles moved from the arrow-tip neighbourhood to the axis midpoint so they don't compete with the capitals. `SUBTITLE_LABEL_SIZE_PX` 12 → 10, `TIP_LABEL_OFFSET_FRACTION` 0.18 → 0.22, `ORIGIN_OFFSET_FRACTION` 0.04 → 0.08. Deleted the now-unused `LABEL_BACKGROUND_COLOR` / `AXIS_LABEL_COLOR` / `ORIGIN_LABEL_COLOR` / `NAME_LABEL_COLOR` constants. - `src/deck-layers.ts`: accepts `chrome` and reads `axis` and `axisTick` colours from it; deleted the `AXIS_SHAFT_COLOR` / `AXIS_TICK_COLOR` constants. - Test fix: `test/state.unit.test.ts` updated the `defaultState` display-toggle assertion to expect `showThresholdPlanes: false` (it was the only test referencing the flipped default). Lint, types, and tests all clean (0 errors; ~471 stylistic warnings, all non-blocking). 8 PASS / 0 FAIL / 1 SKIP across the eight test files. The CLI runs end-to-end and produces a fresh `dist/deps-cube-2026-05-13T02-18-53Z.html` (~822KB). Pending: manual Firefox interaction verification; open the new HTML and confirm all three green planes render at every camera angle (drag-rotate to test); no brown threshold-guide lines by default; axes + capitals + origin in light gray on dark mode (or dark gray on light mode); subtitles in 10px at axis midpoints; no white-rectangle label backgrounds. **Status (2026-05-12, eleventh handover; glyph-scale + per-glyph name labels)**: with iteration-2's coordinate-system backdrop reading correctly, the user asked for two further tweaks: shrink the spheres / octahedra by 0.5× so they no longer obscure each other in dense regions, and label every glyph (including the unknown-cluster spheres) with its npm name by default. Implemented: - `src/deck-accessors.ts`: `RADIUS_MIN_WORLD_FRACTION` 0.005 → 0.0025 and `RADIUS_MAX_WORLD_FRACTION` 0.03 → 0.015; halved diagonal fractions used by `probeRadiusWorld` so every mesh-layer glyph renders at half its previous world-space size. - `src/script/state.ts`: `DEFAULT_DISPLAY_TOGGLES.nameLabels` flipped from `'none'` to `'all'`. The radio control still offers `none` / `topN` / `all`; the default is just no longer hidden. - `src/deck-labels.ts`: `buildNameLabelsLayer` no longer filters out probes with `unknownReason !== null` or null `probePosition`. For those, the per-glyph label position is sourced from `unknownClusterPosition` (the same accessor `buildUnknownClusterLayer` uses), so the upper-right unknown bucket also gets its names painted alongside the spheres. New import: `unknownClusterPosition` from `./deck-accessors.ts`. - Test fix: `test/state.unit.test.ts` assertion updated to expect `nameLabels: 'all'` and the test name extended to mention name labels. Lint, types, and tests all clean (0 errors; 471 stylistic warnings; 8 PASS / 0 FAIL / 1 SKIP). Fresh HTML at `dist/deps-cube-2026-05-13T02-28-46Z.html` (~822KB; no size delta from iteration-2 since the bundle contents are unchanged). **Status (2026-05-12, fifteenth handover; both orientations per texture)**: iteration-6 added a single canvas-Y flip on the assumption that luma. gl would upload with `flipY: false`. luma. gl's source does default to `flipY: false`, but the empirical result on the sphere was still inverted text; likely because the equirectangular UV mapping combines with the orientation of the canvas in a way the single flip didn't undo. Instead of chasing the math, the user proposed a guaranteed-correct workaround: print BOTH an upright and a rotated-180° copy on the same texture, so at least one is readable from any rotation. That is now the implementation in `src/deck-textures.ts`: - Sphere textures get two stripes at `v = 0.35` (upright) and `v = 0.65` (rotated 180°), each with two horizontal repetitions at `u = 0.25 / 0.75`. Four text instances per texture; the viewer sees at least one right-side-up copy on the visible hemisphere regardless of camera angle. - Octahedron textures get two stripes inside the UV face triangle at `v = 1/4` (upright) and `v = 1/2` (rotated 180°). Each of the 8 faces shows both orientations, so a glance at any face yields a readable name. - `paintFlippedName` (the previous `scale(1, -1)` helper) replaced by paired `paintUpright` (no transform) and `paintRotated180` (`translate / rotate(PI)`); the rotation keeps the glyph centred under its anchor point without the Y-mirror artefacts that `scale(1, -1)` introduces on some glyph features. - Constants renamed: `SPHERE_EQUATOR_V` → `SPHERE_UPRIGHT_V` + `SPHERE_FLIPPED_V`; `OCTAHEDRON_CENTROID_V` → `OCTAHEDRON_UPRIGHT_V` + `OCTAHEDRON_FLIPPED_V`. Lint, types, and tests all clean (0 errors; 8 PASS / 0 FAIL / 1 SKIP). Fresh HTML at `dist/deps-cube-2026-05-13T03-02-47Z.html`. **Status (2026-05-12, fourteenth handover; texture fixes: vertical flip + auto-shrink + 2-repeat)**: iteration-6 added a single canvas-Y flip on the assumption that luma. gl would upload with `flipY: false`. luma. gl's source does default to `flipY: false`, but the empirical result on the sphere was still inverted text; likely because the equirectangular UV mapping combines with the orientation of the canvas in a way the single flip didn't undo. The previous attempt's contents follow. **Status (2026-05-12, fourteenth handover; texture fixes: vertical flip + auto-shrink + 2-repeat)**: iteration-5 baked the names but two artefacts showed up: text rendered upside-down on the camera-facing side of every sphere, and at 4 repetitions on a 512 px texture long names like `happy-rusty` overflowed their 128 px slot and overlapped. Both fixed in `src/deck-textures.ts`: - Vertical flip: text is drawn with a `ctx.save() / translate / scale(1, -1) / draw / restore()` wrapper. Reason: luma. gl's `SphereGeometry` writes `texCoord_v = 1 - latitude` (north pole at v=1, south pole at v=0) while WebGL's default canvas upload puts canvas-top at v=0. Without the flip, text drawn at canvas-middle ends up with its top half south-of-equator on the sphere, reading upside-down to anyone looking at the equator from outside. With the flip, the text renders right-side-up. Applies to the octahedron path too (faces are orientation-symmetric, so the flip never makes things worse). - 2 repetitions instead of 4; slot width 256 px, room for a wider type. - Auto-shrink: a `pickFontSize` helper calls `ctx.measureText` once at the max font size and rescales proportionally to fit `slot * 0.85`, clamped to `[MIN_FONT_SIZE_PX, FONT_SIZE_PX] = [22, 56]`. The line width of the outline is scaled to match (`OUTLINE_WIDTH_PX * fontSize / FONT_SIZE_PX`) so the rim stays visually consistent. - Cache key already includes the name so the auto-shrink result is captured automatically; nothing to change there. Lint, types, and tests all clean (0 errors; 500 stylistic warnings; 8 PASS / 0 FAIL / 1 SKIP). Fresh HTML at `dist/deps-cube-2026-05-13T02-54-15Z.html`. **Status (2026-05-12, thirteenth handover; names baked into the mesh textures)**: iteration-4's painted labels still used a billboard `TextLayer` with `depthCompare: 'always'`, so back-glyph labels rendered on top of nearer glyphs (clearly visible in a Firefox screenshot where a back-octahedron's name appeared larger than the front octahedron occluding it). The user identified the fix: "If you made the text part of mesh this would not happen. Are you able to bake text into mesh? " Yes; and that is now the implementation. The floating `TextLayer` is gone; each probe gets its own `SimpleMeshLayer` with a per-probe canvas texture that has the colour and the npm name baked in. Depth testing then handles occlusion the same way it does for any other mesh surface; a sphere behind a sphere shows only the parts not occluded. - New `src/deck-textures.ts`: `makeProbeTexture({ probe, fillColor, shape, withName })` renders a 512×512 canvas: fill background with the probe's data-derived colour, then (when `withName`) draw the npm name in bold sans-serif 56 px white with a black 6 px outline. Two UV layouts: - `'sphere'`: name repeated 4× along the equator (`v = 0.5`) so the equirectangular wrap shows the label from any longitude. - `'octahedron'`: name once at the face triangle's centroid (`v = 1/3` under the UV layout `(0,0),(1,0),(0.5,1)` that every face shares). Textures cached by `(catalogKey, rgba, shape, withName)` so repeated renders reuse the same canvas (and the same GPU upload). - `src/deck-geometries.ts`: octahedron now writes a UV triangle `(0,0),(1,0),(0.5,1)` per face (was all-zero `TEXCOORD_0`). The same UV patch on every face means the baked-name texture appears identically on each octahedron facet. - `src/deck-scatter.ts` rewritten; each factory now returns `readonly Layer[]` with one `SimpleMeshLayer` per probe rather than a single layer holding the whole bucket. Per-layer `opacity` (0.05 vs 1) supplies the filter-fade effect (since `texture` overrides `getColor` in deck. gl's SimpleMeshLayer, per-instance alpha is no longer available). Lighting stays on by default so the meshes keep their 3D shading. - New `src/deck-scatter-helpers.ts`: `partitionProbes` (leaf / non-leaf / unknown bucketing) and `computeNameBakeSet` (which `originalIndex` values get a baked name under the current `nameLabels` toggle) extracted so the main scatter file stays under the 300-line cap. - `src/deck-labels.ts`: `buildNameLabelsLayer` removed entirely (the corresponding visual is now baked into the textures); module docstring updated; unused `nameLabel` / `probePosition` / `unknownClusterPosition` / `PackageProbe` / `AppState` imports + the `TOP_N_NAMES` / `NAME_LABEL_SIZE_PX` / `NAME_LABEL_OFFSET_FRACTION` constants + the painted-label fill / outline constants are all gone. - `src/deck-config.ts` `buildLayers`: drops the `nameLabels === 'none'` branch (no separate name-label layer to gate); flattens the three scatter factories' `readonly Layer[]` returns directly into the layer groups. Per-probe layers (≈ 117 at the current catalog size) trade extra draw calls for correct depth-of-text rendering. A texture-atlas + per-instance UV transform extension would consolidate back to three draw calls but is not worth the complexity at this scale. Lint, types, and tests all clean (0 errors; 495 stylistic warnings; 8 PASS / 0 FAIL / 1 SKIP). Fresh HTML at `dist/deps-cube-2026-05-13T02-48-13Z.html` (~824KB). **Status (2026-05-12, twelfth handover; names painted on the balls)**: iteration-3 floated the names just above each glyph as a HUD label; the user asked for them to feel painted onto the balls themselves (basketball-with-team-logo metaphor). Implemented in a single file: - `src/deck-labels.ts` `buildNameLabelsLayer`: - Position is the glyph center directly (no `+ nameOffset`). The `NAME_LABEL_OFFSET_FRACTION` constant is gone. - `getColor` hardcoded to white `[255, 255, 255, 255]` instead of `chrome.nameLabel`; the SDF outline supplies contrast on any ball colour, so OS-scheme adaptation is no longer needed for this specific layer. Other label layers (capitals, subtitles, origin) still draw from `chrome` since they sit against the scene backdrop, not on opaque glyphs. - `chrome` param dropped from the function signature; `deck-config.ts` `buildLayers` no longer forwards it for name labels (other factories untouched). - Painted-letter look: `fontFamily: 'sans-serif'`, `fontWeight: 700`, `fontSettings: { sdf: true }`, `outlineColor` pure black, `outlineWidth: 3` (deck. gl-relative units; produces a ~10 to 15 % rim around the white fill at 11 px). - Depth override: `parameters: { depthCompare: 'always' }` so the billboard text sits on top of the opaque sphere/octahedron rather than being half-occluded by the mesh's front face. Verified via cloned deck. gl source at `modules/extensions/src/terrain/terrain-pass.ts:90` and `modules/core/src/passes/screen-pass.ts:36` that `depthCompare: 'always'` is the WebGPU-style key deck. gl 9 / luma. gl v9 layers accept on `parameters`. `src/deck-config.ts` `buildLayers` updated call site (one less prop on `buildNameLabelsLayer`). Lint, types, and tests all clean (0 errors; 473 stylistic warnings; two more than the iteration-3 baseline, from the new SDF/outline declarations). 8 PASS / 0 FAIL / 1 SKIP. Fresh HTML at `dist/deps-cube-2026-05-13T02-35-01Z.html` (~823KB). **Last commits** (most recent first): - `c2a2079a feat(dev-script/deps-cube): interpolate probe colour in OKLCH` - `80a5f175 feat(dev-script/deps-cube): pin camera-controls guide to top of sidebar` - `677af470 fix(dev-script/deps-cube): paint upright AND rotated-180° copies per texture` (iteration 7) - `bd6e6049 fix(dev-script/deps-cube): flip texture Y + auto-shrink long names + 2 reps` (iteration 6) - `62d80159 feat(dev-script/deps-cube): bake names into per-probe mesh textures` (iteration 5) - `059201f2 feat(dev-script/deps-cube): paint name labels onto each ball/octahedron` (iteration 4) - `217ffab5 feat(dev-script/deps-cube): halve glyph size and label every glyph by default` (iteration 3) - `21b62437 feat(dev-script/deps-cube): all 3 coordinate planes via SolidPolygonLayer + scheme-aware chrome` (iteration 2) - `220818cb feat(dev-script/deps-cube): 3D mesh glyphs + coordinate-system backdrop + dual-thumb sliders` (iteration 1) - `5d552cdf fix(dev-script/deps-cube): use ISO 8601 UTC down to seconds in output filename` - `dbd34c10 feat(dev-script/deps-cube): tsdown build with bin pointing to dist/final/node/cli.mjs` - `594ce226 fix(dev-script/deps-cube): walk up to package.json instead of hardcoded`..`for dist resolution` - `b0364026 fix(dev-script/deps-cube): deep-clone defaults in defaultState to prevent shared-reference corruption` (task 13 fix 3) - `775efcf1 fix(dev-script/deps-cube): pass partial-unknowns through range filter by default` (task 13 fix 2) - `9376aff8 fix(dev-script/deps-cube): anchor output to /dist/ via import.meta.dirname` (task 13 fix 1) - `77656a03 test(dev-script/deps-cube): add eight unit-test files for task 12` (task 12) - `cfa2d156 docs(dev-script/deps-cube): add depth-matched library audit for deck.gl` (task 11) - `c37ee14c feat(dev-script/deps-cube): add HTML composer + CLI entry` (task 10) - `a496f91c feat(dev-script/deps-cube): add browser-side scene controller` (task 9) - `d8142cba feat(dev-script/deps-cube): add HTML control panel renderer` (task 8) - `df8f7fb3 docs(dev-script/deps-cube): handover update; tasks 6 to 7 done, 8 to 13 pending` (second handover) - `c2ce8e45 feat(dev-script/deps-cube): add deck.gl config + layer factories` (task 7) - `a0609584 feat(dev-script/deps-cube): add browser-side filter + state modules` (task 6) - `d6d1aae6 docs(dev-script/deps-cube): handover doc covering tasks 1-5 done, 6-13 pending` (first handover) - `7c57662e feat(dev-script/deps-cube): scaffold package and probe pipeline` (tasks 1 to 5) ## Task tracker (matches TaskList IDs 1 to 13) Done: - ~~Task 1 (scaffold)~~: `package.json` (bin `deps-cube` → `src/cli.ts`, deps on `@deck.gl/core`, `@deck.gl/layers`, `string-dedent`, `@monochromatic-dev/module-es`, `@monochromatic-dev/module-pnpm-workspace-catalog`, `nano-spawn`, `p-limit`), `mise.toml`, `tsconfig.json`, `README.md`. - ~~Task 2 (catalog entry)~~: `pnpm-workspace.yaml` carries `@deck.gl/core: '>=9.3.2'` and `@deck.gl/layers: '>=9.3.2'`. - ~~Task 3 (catalog parser)~~: `package/module/pnpm-workspace-catalog` owns YAML parsing, validation, prototype-safe maps, and located-file discovery. `src/catalog.ts` adapts its raw default-plus-named entries into the resolved `CatalogEntry` shape; alias decoder remains exported as `decodeAlias`. - ~~Task 4 (cache)~~: `src/cache.ts` exports `createCache({ rootDir? })`. JSON file per (name, version) at `~/.cache/monochromatic/deps-cube//.json`; per-field `{ value, fetchedAt }`; atomic tmp+rename writes. - ~~Task 5 (probe)~~: `src/probe.ts` (orchestrator) + `src/probe-fields.ts` (per-field probes + helpers) + `src/probe-transitive.ts` (depth-bounded dep walk). Failed entries return a stub via `failedProbe` with `unknownReason: 'private-or-404'`. - ~~Task 6 (filter + state)~~: `src/script/filter.ts` exports `computeVisibleIndices`, `extractDim`, `derivedBool`, `searchMatches`, plus the type vocabulary (`ToggleKey`, `ToggleValue`, `ToggleState`, `DataDimKey`, `ChannelKey`, `DimMapping`, `RangeState`). `src/script/state.ts` exports `defaultState({ probes })`, `encodeState`/`decodeState` (URL-encoded JSON, no base64), `readStateFromHash`/`writeStateToHash`, plus the `AppState`/`ViewState`/`DisplayToggleState` types. Both files are pure functions, no DOM, browser-bundle-safe. - ~~Task 8 (HTML control panel)~~: `src/render-controls.ts` exports `renderControls({ probes, state })` returning the full `