Skip to content

[renderer] Tree shape — discovery-map renderer (spike → keeper)#351

Closed
leeovery wants to merge 5 commits into
feat/render-core-signpostfrom
feat/render-tree
Closed

[renderer] Tree shape — discovery-map renderer (spike → keeper)#351
leeovery wants to merge 5 commits into
feat/render-core-signpostfrom
feat/render-tree

Conversation

@leeovery

@leeovery leeovery commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Summary

Stacked on #348. Adds renderTree — the first genuine continuous-gutter tree, on the shared wrapWithPrefix core. This was the go/no-go spike for the whole renderer; it came out clean, so the code is kept.

  • Branch glyphs ├─/└─ (hangs off the header, never ┌─), leading tier glyph, name [lifecycle], wrapped summary/provenance sub-lines under a continuous gutter (dropped on the last row).
  • Wrap budget subtracts the 9-char gutter → the 74-col gutter-orphan bug (the original motivation) is structurally impossible.
  • CLI tree reads a JSON node array on stdin (the data-owner builds it; Claude never assembles tree JSON); renderTree exported for in-process use.

Spike findings

  • GO. Structural rows reproduce the documented hand-drawn map byte-for-byte; every body line stays within width at 49/58/65.
  • Header-row overflow is inherent — a long label [lifecycle] row (e.g. 70 cols) can't wrap without breaking glyph alignment; the hand-drawn version overruns identically. Mitigation (truncation) is a separate decision.
  • Open: tree content width — 49 (consistent with the 49-wide dividers/markers) vs ~65 (current text density). Renderer is correct at any width; this is a visual-density call for the wiring step.

Test plan

  • node --test tests/scripts/test-render.cjs — 23 tests (6 new for the tree: byte-exact rows, hang-off-header, body-within-width across widths, continuous/dropped gutter, single-node └─).

🤖 Generated with Claude Code

leeovery and others added 5 commits June 4, 2026 21:01
Adds the first genuine tree shape on the shared wrapWithPrefix core:
branch glyphs (├─/└─, hangs off header, never ┌─), leading tier glyph,
name [lifecycle], and wrapped summary/provenance sub-lines under a
continuous │ gutter (dropped on the last row). Wrap budget subtracts the
9-char gutter, so the 74-col orphan bug is structurally impossible.

CLI `tree` reads a JSON node array on stdin (data-owner builds it);
renderTree exported for in-process use. Spike proven: structural rows
byte-exact vs the documented hand-drawn map; every body line within
width at 49/58/65. Header rows are single-line/data-determined (a long
label+tag is unwrappable — same as hand-drawn). 6 new tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Node shape now { glyph?, label, tag?, summary?, provenance? } (explicit
fields, was an opaque body[]). Provenance renders as a distinct
`· `-marked line with its first letter capitalised, so it reads as
metadata rather than a continuation of the summary. Default tree width
72 (configurable per call / --width).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Switch the provenance marker from · to ↳ so it reads as 'derived from'.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Split layout from content. renderTree node is now { title, body?,
children? } — pure layout (branch glyphs, continuous gutter, wrap,
recursion), knowing nothing about glyphs/tags/provenance. Adds children
recursion (arbitrary depth, e.g. the discussion map).

New conventions.cjs is the domain-aware composition layer: title()
(glyph+label+[tag]), tag(), derivedFrom() (↳, capitalised), and the
discovery-tier glyph vocabulary. Callers compose strings here, keeping
format normalised in one place while the renderer stays domain-free.

Flat discovery map renders byte-identically. 30 tests (incl. nesting +
conventions).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drop the residual 1-column gap between a node's wrapped body and its
branched children. Both now derive from childPrefix: children add a
branch glyph, body indents by the branch width to land at the same
content column. Simpler (one rule, derived not hardcoded) and tidier
(body text and child rows align). Discovery body shifts col 9 → 8.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@leeovery

Copy link
Copy Markdown
Owner Author

Consolidated into #380 (single branch off current main, same content, additive-only). Closing to keep one clean hand-off PR.

@leeovery leeovery closed this Jun 10, 2026
@leeovery leeovery deleted the feat/render-tree branch June 10, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant