feat(core): add baseline/rhythm rule - #207
Conversation
Add the `baseline/rhythm` rule that flags text elements whose typographic baselines miss the configured vertical-rhythm grid. The rule computes an approximate baseline position from font-size, line-height, and the bounding rect, then checks distance to the nearest multiple of `rhythm.base_line_px`. Violations fire when the distance exceeds `rhythm.tolerance_px`. Includes golden snapshot test, determinism test, rule docs, SUMMARY and CHANGELOG entries. Closes #73 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
I have all the information needed. Let me write the review. PR #207 Review —
|
| # | File:line | Issue | Class |
|---|---|---|---|
| 1 | crates/plumb-core/src/rules/baseline/rhythm.rs:341-393 |
Loop emits N violations per node; one-per-node invariant violated | BLOCKER |
| 2 | crates/plumb-core/src/snapshot.rs:505-518 |
text_box_index silently wrong if text_boxes unsorted at deserialize time |
BLOCKER |
| 3 | crates/plumb-core/tests/golden_baseline_rhythm.rs |
Missing double-off-grid multiline test | Warning |
Verdict: REQUEST_CHANGES
Remove philosophical phrasing ("consistent cadence that readers perceive
as orderly even without consciously noticing") and tighten the rationale
to plain, direct language.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add TextBox type to PlumbSnapshot and extract per-line text fragments from CDP's document.textBoxes. The baseline/rhythm rule now checks each rendered line independently instead of approximating from the element bounding rect, giving accurate results for multi-line and mixed-font text. Includes golden tests for multi-line and multi-font scenarios. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Addresses three review items on PR #207: 1. Collect all off-grid lines per node and emit a single aggregated violation using the worst-distance line as primary metadata. Multi-line nodes get a summary message format. 2. Add debug_assert in text_box_index to catch unsorted text_boxes in test builds. 3. Add baseline_rhythm_multiline_both_off_grid test asserting exactly one violation when both lines are off-grid. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…292) * fix(ci): unstick Preflight + tolerate Dogfood warnings/nextjs flake PR #287 deleted docs/src/ci/release-prep.md and removed the matching guard in tests/install-smoke-validate.sh, but missed the parallel guard in tests/release-security-validate.sh. The validator has been failing on every CI run since 2026-05-07, skipping every downstream job (MSRV, deny, Test, Size, Coverage, Determinism, Docs). Drop the stale RELEASE_PREP_DOC declaration and the corresponding sentinel-grep block. The Homebrew + npm contracts are still validated authoritatively against dist-workspace.toml and install-smoke.yml in sections 5 and 6 of the same script. Two follow-on dogfood fixes since the daily run has been red since 2026-05-02 (after the Phase 7 rule additions in #202/#204/#207): - lint-canonical-docs now tolerates exit 3 (warnings/info only) alongside exit 0, mirroring the test-sites leg in the same workflow. Errors still fail. The 318-violation steady state on the live docs site is a separate content/theme cleanup, not a CI bug. - nextjs leg gets continue-on-error on both plumb invocations to mirror the e2e-sites stance on the upstream chromiumoxide WebSocket flake tracked in #233. Also drops the dead docs/src/ci/release-prep.md reference from the install-smoke.yml header comment. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * test(cdp): gate macos_candidate ordering test to unix The `macos_candidate_order_lists_system_apps_then_user_apps` test in crates/plumb-cdp/src/chrome_path.rs asserts that paths returned by `macos_candidates` start with `/Users/example/Applications/...` — forward slashes against `Path::display()`. On Windows, `Path::join` uses `\`, so display[3] becomes `/Users/example\Applications\Google Chrome.app\...` and the starts_with check fails. `detect_with` short-circuits to `None` on non-macOS targets, so the function is never reached in production on Windows. Gate the test to `#[cfg(unix)]` to keep the existing Linux coverage and drop the unreachable Windows leg. This test was previously masked because Preflight has been failing on every CI run since 2026-05-07, which skipped Test (windows-latest) entirely. Surfacing now as a side effect of the validator fix in this same PR. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(cdp): gate macos_candidates import to unix in tests Follow-up to 890b14c. Gating the test to `#[cfg(unix)]` left `macos_candidates` as an unused import on Windows, breaking the `Test (windows-latest)` build with `error: unused import: \`macos_candidates\``. Mirror the gate on the import. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
baseline/rhythmrule that flags text elements whose typographic baselines miss the configured vertical-rhythm grid (rhythm.base_line_px).rhythm.tolerance_px.Closes #73
Validations
register_builtin(alphabetical order)golden_baseline_rhythm_golden) with on-grid, off-grid, and non-text nodesbaseline_rhythm_run_is_deterministic) — 3-run byte-identical checkdocs/src/rules/baseline-rhythm.mdwith all required sectionsdocs/src/SUMMARY.mdupdated with alphabetically placed entry[Unreleased]entry addedgit diff --check— no whitespace issuesunwrap/expect/todo!/dbg!/println!in library code(snapshot, config)— no I/O, no wall-clock, no HashMapIndexMapfor metadata,parse_pxfromrules::utilTest plan
cargo nextest run -p plumb-core --test golden_baseline_rhythmpasses both golden and determinism testsjust validatepasses (fmt + clippy + full test suite)🤖 Generated with Claude Code