diff --git a/contracts/operator-surface.v1.md b/contracts/operator-surface.v1.md index b018efd..401e8f8 100644 --- a/contracts/operator-surface.v1.md +++ b/contracts/operator-surface.v1.md @@ -52,9 +52,9 @@ Every element carrying a state carries it in text as well as hue — a status ch ### Core 4: One source of visual truth -Literal colour, font, or size in an inline `style=` attribute is a violation; zero are tolerated. Computed geometry in an inline `style=` — a bar width, a chart offset — is permitted only for sites enumerated on the exemption register. The register lives in `ledger/`, not in this contract, so that shrinking it is a convergent change requiring no amendment. +Literal colour, font, or size in an inline `style=` attribute, or in a `", re.DOTALL) +#: An f-string placeholder naming a bare module-level constant -- the shape +#: `webtrust.py:374` (``) uses to embed its stylesheet. +_NAME_PLACEHOLDER = re.compile(r"\{([A-Za-z_][A-Za-z_0-9]*)\}") + + +def _module_str_constants(path: Path) -> dict[str, tuple[str, int]]: + """Module-level `NAME = "..."` string constants -> (value, line). + + Read by PARSING, never importing -- the same rule the rest of this kit + follows, so the census stays in-process and side-effect free. + """ + out: dict[str, tuple[str, int]] = {} + for node in ast.parse(read(path)).body: + if not isinstance(node, ast.Assign) or not isinstance(node.value, ast.Constant): + continue + if not isinstance(node.value.value, str): + continue + for target in node.targets: + if isinstance(target, ast.Name): + out[target.id] = (node.value.value, node.value.lineno) + return out + + +def style_blocks_outside_token_module() -> list[tuple[str, int, str]]: + """Every `` " + f"lives in a different string literal is INVISIBLE to this census, which " + f"would understate the violation -- fix the matcher, never the count." + ) + for tag in tags: + body = tag.group(1) + tag_line = text.count("\n", 0, tag.start()) + 1 + literal = _NAME_PLACEHOLDER.sub("", body) + if literal.strip(): + out.append((path.name, tag_line, literal)) + for name in _NAME_PLACEHOLDER.findall(body): + resolved = consts.get(name) + if resolved is None: + raise AssertionError( + f"`