fix(devex): stop the raw-colour scanner counting issue references - #2732
Merged
Merged
Conversation
A '#' followed by three or six hex digits is a colour, and it is also what an issue reference looks like in rendered copy, so '(ent#184)', '(Abilityai#526)' and '>Abilityai#847</a>' were counted as hardcoded colours. Nine of them sat in the baseline, and since Abilityai#2605 made the ratchet bite that turned load-bearing: adding a second reference to a file grew its entry and failed the build for prose. No lexical rule separates the two, so the rule is positional: code is scanned, rendered copy is not. Tags, attribute values and {{ }} interpolations stay in, the text between them is blanked before matching, offsets preserved so sample lines still point at the source. The hex pattern also refuses a '#' glued to a word, which catches the 'ent#206' shape inside a prose attribute. hardcoded_colors drops 456 to 447 across 8 files, all of it phantom; raw_nongray, raw_gray and semantic_tokens do not move and no surviving sample changes line. The baseline is hand-edited rather than regenerated, so the refrozen provenance block survives. Fixes Abilityai#2718
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
scan-raw-colors.mjsmatched a#followed by three or six hex digits anywhere inside a<template>or<style>block. A three-digit hex is also what an issue reference looks like in rendered copy, so(ent#184),Opt-in per agent (#526).and<a …>#847</a>were counted as hardcoded colours. Nine of them sat inraw-color-baseline.json, and since #2605 made the ratchet actually bite, that turned load-bearing: adding a second reference to a file grows its entry and fails the build for prose.No lexical rule separates the two, since
#190is both. The rule here is positional, and it is the one the file already implies: code is scanned, rendered copy is not.HEX_RErefuses a#glued to a word,(?<![\w&]), which catches theent#206shape even inside a prose attribute such astitle="quality (ent#206)". A hex literal is never preceded by a word character, so1px solid #374151andbg-[#1e1e1e]are unaffected.<template>is blanked before matching, offsets preserved so sample line numbers still point at the source. Tags, attribute values and{{ }}interpolations stay in, sostroke="#10b981"and{{ ok ? '#10b981' : '#ef4444' }}are still counted.<style>blocks are never blanked.v-if="nowX >= 0"would otherwise end the tag early and blank the colour that follows it.ReplayTimeline.vuehas exactly that shape.The prescription in the issue, the
\wlookbehind alone, removes only theent#NNNhalf:#190,(#526)and>#847<are not preceded by a word character. Both halves are needed, and the spec fails if either is reverted.Measured on this branch, nothing else moves:
The nine are
ExecutionsPanel:54,OverviewPanel:359,ReliabilityPanel:7and:74,ScheduleAnalyticsCard:46,settings/OperatorIntakePanel:9,settings/TelemetrySharingPanel:9,views/Settings:1251,views/enterprise/Index:118. No surviving sample changes line.The baseline is hand-edited, 8 entries plus the total, rather than regenerated:
--baselinerewrites the file and would drop the hand-writtenrefrozenprovenance. A_2718_noteis added there in the style of the existing ones.Related Issue
Fixes #2718
Journey Impact
Journey Impact: none: a scanner accuracy fix in the devex tooling; it changes no user-facing behaviour and no promise in tests/journeys/catalog.yaml.
Type of Change
Testing
countHardcodedColors(source, onSample)is exported so the spec can drive it with literal snippets, the wayloadingGateRatchet.spec.jsdrivescountBareLoadingGates. Seven cases intests/unit/rawColorRatchet.spec.jsunder#2718: issue references in copy, in an attribute and as link text, an HTML entity, hex in an attribute, in an arbitrary class, in a<style>block,rgba(), a hex behind an attribute containing>, and a hex inside an interpolation.The one failure is
tests/unit/canvasUtils.spec.js > a date axis keeps the default spacing, which fails the same way ondevwithout this branch.Checklist
One documentation note left deliberately:
docs/memory/learnings.mdstill records the durable scanner fix as open debt. Happy to update it here if you would rather it land together.