Skip to content

feat(design-system): scan the SLM frontend for bare hex and name the replacement in every failure (#17567) - #21167

Merged
mrveiss merged 7 commits into
mainfrom
issue-17567
Nov 8, 2026
Merged

mrveiss merged 7 commits into
mainfrom
issue-17567

Conversation

@mrveiss

@mrveiss mrveiss commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Thinking Path

#17567 requires every design-system check to run over both frontends and every failure to name its replacement and link the issue. !important already sweeps both apps (_scan_important_all); the bare-colour check read autobot-frontend/src only. This PR extends that check through the same file filter, gives the control plane its own baseline, and rewrites the failure messages. Every assert against the real tree fails through one helper (_why) with the replacement and the issue link; the detector self-tests on a synthetic tree are controls and stay bare, because they test the detector, not a rule. The other open ACs (starting-number reconciliation, stylelint whole-tree switch) are untouched.

What Changed

  • repo_tests/_hardcoded_colour_detect.py: the file filter is one helper (_colour_candidates) used by _scan and by _colour_scanned_files; the reach population now covers both apps (SLM keys carry slm:, as the !important sweep's do). New _scan_slm runs the same _scan over autobot-slm-frontend/src. No parallel scanner.
  • repo_tests/_hardcoded_colour_baseline.py: SLM_HARDCODED_COLOUR_LITERALS, its own table, frozen at {}.
  • repo_tests/hardcoded_colour_ratchet_17560_test.py: TestTheControlPlaneColourSweep (control fixture, style-block exclusion, reach naming both apps, base ratchet, equality with the baseline); every failure message now names the replacement (var(--color-error) / getCssVar('--color-error', '#ef4444'), var(--text-on-primary), or specificity / kit primitive props for !important) and links Design-system enforcement: guard !important in component <style>, and switch the CSS gate from changed-files to whole-tree #17567.
  • repo_tests/_reach_policy_verdicts.py: the reach note for hardcoded-colour-scan now says both frontends.

Verification

Finding (not rebased): the issue table says 19 in 4 files for the SLM; the detector measures 0 script/template colour literals there.

python -I -c "from repo_tests._hardcoded_colour_detect import _scan_slm; ..."  ->  sum 0, 0 literals

Cross-check on a different question: every hex-shaped token outside <style> in autobot-slm-frontend/src (no context-keyword filter, .vue/.ts/.js) is 1, an issue-style colour mention inside an HTML comment (WebResearchSettings.vue). The other hex lines in those files sit inside <style> blocks, which color-no-hex owns; the 19-in-4 in the table plausibly counted those (not verified). 207 SLM source files are in the scanned population.

Control: test_the_detector_finds_a_literal_in_the_control_plane writes color: '#ef4444' into an SLM <script> and expects {"#ef4444": 1}; test_a_style_block_hex_is_left_to_stylelint expects {}.

Tests, in a scratch copy of the tree:

  • the three files below, in a scratch git repo: 1366 passed, 1 skipped (the base-ratchet test for the new table skips until the table exists at the base).
  • files: hardcoded_colour_ratchet_17560_test.py, reach_declarations_test.py, python_filter_covers_its_guards_test.py.
  • ruff check, flake8 (120) and black clean on the changed files.

Single-issue rationale: the remaining #17567 ACs (starting-number reconciliation, stylelint whole-tree switch) are gated on other work and cannot ride with these two.

Refs #17567 (other ACs remain open).

Model Used

Claude Sonnet 5.5

@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 55 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6b6e405 and 35034bd.

Files selected for processing: 4

  • repo_tests/_hardcoded_colour_baseline.py
  • repo_tests/_hardcoded_colour_detect.py
  • repo_tests/_reach_policy_verdicts.py
  • repo_tests/hardcoded_colour_ratchet_17560_test.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@mrveiss mrveiss added this to the M3 - Refined GUI complete milestone Nov 8, 2026
@mrveiss mrveiss added the phase:M3.1 Design docs, tokens and themes label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Notice: 29 open PRs — past the runaway threshold (25)

This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.

This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.

Currently open:

If the queue is draining normally, ignore this. Otherwise:

  1. Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
  2. Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
  3. Look for a loop opening near-identical PRs

Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.

@mrveiss

mrveiss commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

Code review (code-reviewer pass) follow-up at 30d36a7

Verdict: CHANGES (AC A is sound; AC B "every failure message" is not yet met on the real-tree guards, plus two small notes).

AC A, SLM scan. The scan reaches SLM files. _colour_scanned_files prefixes the SLM keys with slm:, and _scan_slm reads the SLM tree with the same detector. The zero is a real zero, not a parser zero:

  • At this head the SLM tree has 207 non-test, non-skipped .ts/.vue/.js files in the scan population.
  • Over those files I counted every hex match with the <style> blocks blanked and the resolved fallbacks blanked, and with no colour-keyword gate (stricter than the detector). That gave 567 matches.
  • 566 of the 567 are issue references (#741, #754, #779 and so on). The one real colour, #dc2626, is inside an HTML comment in WebResearchSettings.vue, so it is not a value.
  • Inside <style> blocks there are 14 colour hexes in 2 files (OrgTreeNode.vue 12, UpdateNotification.vue 2). autobot-slm-frontend/.stylelintrc.json enables color-no-hex, so the "stylelint owns it" explanation holds. The issue's "19 in 4 files" does not reproduce (I get 14 in 2). Say so in the PR body so the gap is on record.
  • The two controls prove the detector and the <style> blanking on a tmp_path/autobot-slm-frontend/src tree. They do not prove the live SLM tree is read. test_the_sweep_reads_the_control_plane_tree does, but only with any(...).

Main frontend population. Unchanged. _scan(root) was already given the frontend src root, and the _SKIP_FRAGMENTS check ran on a path relative to it, which is what _colour_candidates(frontend) does now. Skip logic and exemptions are the same, so nothing is silently dropped or added.

slm: prefix. Consistent with _important_scanned_files and SLM_KEY_PREFIX.

Reach policy. _reach_policy_verdicts.py keeps ABSOLUTE and SUBSET_DRIFTS and only rewords the reason, matching the important-declaration-sweep entry. The floor is derived from the base population, so it self-repins on the train.

600-line limit. _hardcoded_colour_detect.py is 398 lines, the ratchet test 541 and _reach_policy_verdicts.py 585. All are under the limit; the last has 15 lines of headroom.

Severity File:line Finding Fix
Medium repo_tests/hardcoded_colour_ratchet_17560_test.py:54, 235, 243, 247, 249, 328, 329, 475, 522 These real-tree guard asserts still fail with no message, or with a message that has no replacement and no #17567 link. That is 9 asserts, against "every failure message names the replacement and links #17567". The detector self-tests (about 35 asserts that are _scan(tmp_path) == ...) are controls and can stay bare. Add + _USE_TOKEN, _USE_CASCADE or See {_ISSUE} to these 9 asserts, and state in the PR body that controls are out of scope.
Low hardcoded_colour_ratchet_17560_test.py:~195 (test_the_sweep_reads_enough_files) _USE_TOKEN is appended to a reach-floor failure ("opened only N files"). Telling the reader to use a token is the wrong remedy for a shrunken sweep. Replace it with See {_ISSUE} plus a pointer to scripts/repin_reach_floors.py.
Low hardcoded_colour_ratchet_17560_test.py:~172 (test_each_exempt_basename_is_unique_in_the_tree) and _hardcoded_colour_detect.py _colour_candidates EXEMPT_BASENAMES is a basename filter shared by both apps, but the uniqueness check still searches only the main frontend. A same-named SLM file would be exempted unseen. Run the uniqueness check over both trees, or assert that no SLM file matches an exempt name.
Info _hardcoded_colour_baseline.py:93-100 The comment says "19 in 4 files" was counted from <style> hex. I measure 14 in 2. Correct the numbers, or say "about" and cite the stylelint rule.

@mrveiss

mrveiss commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

Code review (code-reviewer pass) follow-up at c154353

Finding Status
1 MEDIUM: real-tree asserts failed without a replacement or #17567 link Fixed in ecb4486 (merged into c154353). One helper _why(found, remedy=_USE_TOKEN) in repo_tests/hardcoded_colour_ratchet_17560_test.py now wraps the _FRONTEND moved check, the cacheManagement and useCssVars asserts, and the control-plane prefix and reach asserts. Detector self-tests stay bare as controls (stated in the PR body Thinking Path).
2 LOW: reach-floor failures carried the colour remedy Fixed. New _REACH_SHORT says the scan reached too few files (a scanner or path problem) and links #17567; used by the colour, !important and style-block reach floors.
3 LOW: exempt-basename uniqueness checked one tree Fixed. test_each_exempt_basename_is_unique_in_the_tree now covers both frontends (main exactly 1, control plane at most 1).
4 INFO: baseline comment "19 in 4 files" Fixed in repo_tests/_hardcoded_colour_baseline.py: 0 outside <style>; 14 <style> hex in 2 files (OrgTreeNode.vue 12, UpdateNotification.vue 2), owned by color-no-hex; the 14-vs-19 gap is stated as unreconciled and unknown.

Verification: the ratchet, reach-declarations and python-filter tests ran in a scratch git repo: 1366 passed, 1 skipped. flake8, black and ruff are clean, and the file-size guard exited 0. No CodeRabbit threads were open.

@mrveiss

mrveiss commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

Code review (code-reviewer pass) at c154353
Verdict: APPROVE (0 blocking)

Delta from the earlier CHANGES verdict (30d36a7) is fix commit ecb4486 plus one main merge. Head confirmed as c154353.

# Severity File:line Issue Fix
1 resolved repo_tests/hardcoded_colour_ratchet_17560_test.py:85 One _why(found, remedy=_USE_TOKEN) helper, not duplicated. All 9 flagged real-tree asserts now route through it or carry a remedy: :54, :254, :262, :266, :268, :347, :350, :547, plus :495/:498. Detector self-tests stay bare as controls, as agreed. The issue link is carried by _USE_TOKEN, _USE_CASCADE and _REACH_SHORT. none
2 resolved ...ratchet_17560_test.py:79, used at :215, :334, :434 _REACH_SHORT words the reach floors as a scanner or path problem, not a colour finding, and links #17567. The colour remedy is gone from all three floors. none
3 resolved ...ratchet_17560_test.py:197-207 Exempt-basename uniqueness now loops over both autobot-frontend (exactly 1) and autobot-slm-frontend (at most 1). The condition found <= 1 and (found == 1 or app != _FRONTEND) is correct. none
4 resolved repo_tests/_hardcoded_colour_baseline.py:93-100 Reads "0 outside <style>; 14 <style> hex in 2 files; 14-vs-19 gap unreconciled and unknown", which matches my earlier measurement of 14 in 2. none
5 info ...ratchet_17560_test.py 568 lines, under the 600 limit. _why is a plain concatenation, so it is tiny and has no logic to get wrong. No new problems found in the delta. none

CodeRabbit threads: 0 total (review-limit notice only); nothing to answer.
AC coverage (Refs PR, no Closes): not applicable.
Main-merge commits: clean. git show --cc c154353930 prints no combined diff, so there are no conflict hunks. The merge changes neither the ratchet test nor the baseline file against the first parent, and git diff ecb4486cdc c154353930 on those two files is empty.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No new hardcoded values of either class — ssot and other both block.

Known backlog in pipeline-scripts/hardcoded_values_baseline.txt is suppressed and tracked in #14371.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

phase:M3.1 Design docs, tokens and themes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant