Skip to content

feat(0.2): renderer migration to uitokens — bracketed severity/verdict (Track 10.2)#161

Merged
pmclSF merged 1 commit intomainfrom
feat/0.2-track10-renderer-migration
May 5, 2026
Merged

feat(0.2): renderer migration to uitokens — bracketed severity/verdict (Track 10.2)#161
pmclSF merged 1 commit intomainfrom
feat/0.2-track10-renderer-migration

Conversation

@pmclSF
Copy link
Copy Markdown
Owner

@pmclSF pmclSF commented May 5, 2026

First in-tree consumer of uitokens. Migrates internal/changescope severity / verdict badges to uitokens.BracketedSeverity / uitokens.BracketedVerdict.

The PR-comment markdown's [HIGH] / [PASS] strings are now owned by one place; renaming a label would surface in two test files (uitokens + changescope golden) instead of being silently inconsistent.

Test plan

  • go build + go test ./...
  • make docs-verify / docs-linkcheck / truth-verify
  • 2 new uitokens tests + existing changescope goldens all pass

Plan tracker

Closes Track 10.2 (renderer migration foundation). Track 10.3
(PR-comment redesign through tokens) and 10.4 (HTML report
redesign) will follow on this base. The vet-style check that flags
raw color codes outside uitokens (the "V1 uniformity gate" from
the parity plan) remains 0.2.x work.

…t (Track 10.2)

Migrates internal/changescope to consume from internal/uitokens for
its bracketed severity and posture-verdict badges. First in-tree
consumer of uitokens — the foundation Track 10.1 shipped (#136) is
now live.

What changed

- New `uitokens.BracketedSeverity(severity)` and
  `uitokens.BracketedVerdict(band)` helpers. They encapsulate the
  exact bracketed strings (`[HIGH]`, `[CRIT]`, `[PASS]`, `[FAIL]`,
  etc.) that the unified-PR-comment visual contract requires —
  locked by the changescope golden tests shipped in #145.
- `internal/changescope/render.go` `severityIcon` and
  `postureBadge` are now thin wrappers that delegate to the
  uitokens helpers. The renderer call sites are unchanged; the
  vocabulary is now owned by one place.

Why this shape

The PR-comment markdown contract requires `[LABEL]` brackets
because GitHub-flavored markdown doesn't render ANSI color and the
brackets make badges scan reliably. The terminal-text severity
badge (uitokens.SeverityBadge) returns `Bold(Alert("HIGH"))`-style
colored tokens for direct terminal use. Both shapes are valid
design choices for their respective surfaces; locking each one in
uitokens prevents drift.

The wrapper-not-inline approach keeps the surgical: the changescope
helpers stay one-liners, the visual contract test (#145) keeps
asserting the same strings, and a future renderer joining the
party imports uitokens directly without changescope being in the
middle.

Coverage

- 2 new tests in uitokens_test.go: TestBracketedSeverity (locks
  every severity → bracket mapping) + TestBracketedVerdict (same
  for posture bands)
- Existing changescope golden tests (TestRenderPRSummaryMarkdown,
  TestRenderPRSummaryMarkdown_UnifiedShape, etc.) all still pass —
  proves the byte-identical rendering contract holds through the
  migration

Verification: full Go test suite green; `make docs-verify`,
`make docs-linkcheck`, `make truth-verify` clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pmclSF pmclSF merged commit 8190829 into main May 5, 2026
8 of 10 checks passed
@pmclSF pmclSF deleted the feat/0.2-track10-renderer-migration branch May 5, 2026 00:05
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

[RISK] Terrain — Merge with caution

High-severity gaps found in changed code.

Metric Value
Changed files 3 (2 source · 1 test)
Impacted units 28
Protection gaps 3
Tests selected 4 of 793 (0% of suite)

Coverage gaps in changed code

  • internal/uitokens/uitokens.go [MED] — Exported function BarChar has no observed test coverage.
    → Add unit tests for exported function BarChar — this is public API surface.
  • internal/uitokens/uitokens.go [MED] — Exported function BarEmpty has no observed test coverage.
    → Add unit tests for exported function BarEmpty — this is public API surface.
  • internal/uitokens/uitokens.go [MED] — Exported function Subheading has no observed test coverage.
    → Add unit tests for exported function Subheading — this is public API surface.
4 pre-existing issues on changed files
  • internal/changescope/render.go [HIGH] — [blastRadiusHotspot] Changes to this file propagate to 219 tests (50 direct, 169 indirect). High blast radius increases regression risk.
  • internal/uitokens/uitokens.go [HIGH] — [blastRadiusHotspot] Changes to this file propagate to 69 tests (19 direct, 50 indirect). High blast radius increases regression risk.
  • internal/uitokens/uitokens_test.go [MED] — [fixtureFragilityHotspot] Fixture 'runWithColor' is used by 17 tests across 1 files. A single change cascades widely.
  • internal/uitokens/uitokens_test.go [MED] — [fixtureFragilityHotspot] Fixture 'runWithoutColor' is used by 17 tests across 1 files. A single change cascades widely.

Recommended tests

4 test(s) with exact coverage of 25 impacted unit(s). 3 impacted unit(s) have no covering tests in the selected set.

Test Confidence Why
internal/changescope/changescope_test.go exact exact coverage of RenderCIAnnotation, RenderPRCommentConcise
internal/changescope/dedup_test.go exact exact coverage of RenderChangeScopedReport, RenderPRSummaryMarkdown
internal/changescope/unified_render_test.go exact exact coverage of RenderPRSummaryMarkdown
internal/uitokens/uitokens_test.go exact exact coverage of Accent, Alert, Bar + 18 more

Owners: PMCLSF

Limitations
  • No coverage artifacts provided; protection gaps reflect missing data, not measured absence. Provide --coverage to improve accuracy.
  • Mixed test cultures reduce cross-framework optimization confidence. Consider standardizing on fewer frameworks.

Generated by Terrain · terrain pr --json for machine-readable output

Targeted Test Results

Terrain selected 4 test(s) instead of the full suite.

  • Go tests: passed

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

Terrain AI Risk Review

Metric Value
AI surfaces 13
Eval scenarios 17
Impacted scenarios 0
Uncovered surfaces 13

Decision: PASS — AI surfaces are covered.

pmclSF added a commit that referenced this pull request May 9, 2026
…t (Track 10.2) (#161)

Migrates internal/changescope to consume from internal/uitokens for
its bracketed severity and posture-verdict badges. First in-tree
consumer of uitokens — the foundation Track 10.1 shipped (#136) is
now live.

What changed

- New `uitokens.BracketedSeverity(severity)` and
  `uitokens.BracketedVerdict(band)` helpers. They encapsulate the
  exact bracketed strings (`[HIGH]`, `[CRIT]`, `[PASS]`, `[FAIL]`,
  etc.) that the unified-PR-comment visual contract requires —
  locked by the changescope golden tests shipped in #145.
- `internal/changescope/render.go` `severityIcon` and
  `postureBadge` are now thin wrappers that delegate to the
  uitokens helpers. The renderer call sites are unchanged; the
  vocabulary is now owned by one place.

Why this shape

The PR-comment markdown contract requires `[LABEL]` brackets
because GitHub-flavored markdown doesn't render ANSI color and the
brackets make badges scan reliably. The terminal-text severity
badge (uitokens.SeverityBadge) returns `Bold(Alert("HIGH"))`-style
colored tokens for direct terminal use. Both shapes are valid
design choices for their respective surfaces; locking each one in
uitokens prevents drift.

The wrapper-not-inline approach keeps the surgical: the changescope
helpers stay one-liners, the visual contract test (#145) keeps
asserting the same strings, and a future renderer joining the
party imports uitokens directly without changescope being in the
middle.

Coverage

- 2 new tests in uitokens_test.go: TestBracketedSeverity (locks
  every severity → bracket mapping) + TestBracketedVerdict (same
  for posture bands)
- Existing changescope golden tests (TestRenderPRSummaryMarkdown,
  TestRenderPRSummaryMarkdown_UnifiedShape, etc.) all still pass —
  proves the byte-identical rendering contract holds through the
  migration

Verification: full Go test suite green; `make docs-verify`,
`make docs-linkcheck`, `make truth-verify` clean.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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