Skip to content

feat(core-engine): css io counts resource-fetching declarations (#2752) - #2775

Merged
squid-protocol merged 2 commits into
mainfrom
fix/2752-css-io
Sep 5, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
fix/2752-css-io

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #2752. Found by the #2669 pass over every non-green cell of the keyword-rosetta bias report.

The call

io was None. The in-code rationale — a url()/@import fetch "happens during browser paint and does NOT block a computational thread" — is true and is not the deciding factor: html's own io rule counts src= / href= / <img> / <iframe>, which are the same paint-time, non-blocking loads, and counts them as I/O. io measures a resource boundary. The corpus ledger (css-import-url-io-triple-overlap) had already recorded that comment as wrong on 2026-09-02.

So: wire the rule, and turn what the None was actually buying into explicit exclusions.

"io": re.compile(
    r"(?<=[-\w])[ \t]*:[^;{}@%<>]{0,200}?\burl\s*\((?!\s*['\"]?\s*(?:data:|#))",
    re.I,
),

The issue's numbers were wrong, in a way that matters

The issue claimed "all 117 crucible url() fetches are non-@import resource loads". A quote-aware pass over the same corpus says otherwise:

url( token count is it a fetch?
url(data:…) inline payload 59 no — nothing is fetched
url(#…) / url(%23…) inside those inlined SVG payloads 40 no — the payload's own internal refs
real external fetch 18 yes

18 fetches, in 14 declarations, in 5 of 38 files. That is what the rule counts, and it is why two of the three exclusions exist.

Exclusions

  1. @import is not counted. The rule is anchored on a declaration's :; an at-rule prelude has none, so @import url("a.css") keeps exactly the two hits it has today (import + _dependency_capture) rather than a third. @ is excluded from the value span so no earlier declaration's colon can bridge forward into a prelude either. This is the ledger's overlap objection, honoured exactly — keyword-rosetta's css shell scores io 0.
  2. url(data:…) is not counted. An inline payload, not a boundary. The majority construct in the wild.
  3. url(#fragment) is not counted. clip-path: url(#mask) references an element in the same document.

% and <> are excluded from the value span for exclusion 2's sake. A data:image/svg+xml value is an entire SVG document inlined as text, carrying its own url(#…) references and xmlns='http:-shaped colons; without the guard the scan walks into the payload and scores a fetch per embedded icon — 70 hits instead of 14 on the crucible corpus, 50 of them from one WordPress stylesheet. Both the percent-escaped (%3Csvg) and raw (<svg) inlining styles are covered. Cost: a value writing a percentage before its url (background: 50% 50% url(x.png)) is missed — zero occurrences in the sample below.

Oracle

how_to_add_a_language.md rule 17's hand-checkable oracle, built as a quote-and-paren-aware CSS declaration walker (the same shape as #2753's PyYAML oracle): every .css/.scss/.less file on the machine, deduped by content — 136 unique files spanning bootstrap, tailwind v4, WordPress, MediaWiki, Odoo, Element, reveal.js, three.js, Gutenberg CSS modules and a pile of unrelated app stylesheets.

185 fetching declarations, rule and oracle agreeing on every file, zero disagreement. Per-corpus: language-crucible css 14 (fonts-baseline 2, icons-baseline 1, style.css 1, about-rtl 2, deprecated-media-rtl.min 8); keyword-rosetta css 0.

The unit is the declaration, not the url() token: src: url(a.eot) format(…), url(a.ttf) format(…), url(a.woff) format(…) is one font, one boundary, one hit. That falls out of the anchor rather than being bolted on.

ReDoS

The property anchor is a fixed-width lookbehind, not a match, and that is load-bearing. Spelling it [-a-zA-Z_][-\w]*[ \t]*: puts an unbounded [-\w]* next to a required : (Rule 14), making every identifier character a start position that backtracks the whole run:

payload match-anchored lookbehind (shipped)
background: + 10k a 1340 ms 0.5 ms
20k 5487 ms 0.8 ms
40k 13525 ms 1.7 ms
80k 54005 ms 3.2 ms

Quadratic vs linear. Pinned by a scaling regression that detonates the bad spelling and asserts immunity for the shipped one.

Tests / docs

11 new strict cases in test_css_strict.py (85 total, was 74): the positive surface, the @import non-overlap with an import-still-fires sanity assertion, the data:/fragment exclusions, the SVG-payload walk-in in both inlining styles, and the ReDoS regression. docs/language_status/css.md sections 1/3/4/6/7 updated (31/48 keys wired, 17 explicit None).

Gauntlet

check result
pytest tests/ 7687 passed, 1 pre-existing failure (below)
audit_check.py (ruff / mypy / dead-key / ast-accuracy) all clear
tree_sitter_accuracy_audit.py --ci --all 30 languages, all OK
tri_comparison_chart.py --all --ci 3 languages, all OK
rosetta_audit.py 46 languages, 0 regressions
crucible_check.py 2 differences, blessed (see below)

Golden-master bless. Uncapped diff (regenerated and compared outside crucible_check's 50-difference / 4000-char caps): 2 differences, both css, both io — css/element/fonts-baseline.css 0→2 and css/odoo/icons-baseline.css 0→1. Zero off-target files and zero topological drift, since io feeds no node mass. The corpus's other fetching css files are minified/filtered out of the audit's parsed-file section.

Pre-existing, not this PR: test_committed_fidelity_table_is_fresh_against_the_corpus fails on main too — the committed table was generated at corpus 6377eb5 and keyword-rosetta has since merged the jcl and yaml waves. Regenerating it here produces a diff in jcl / makefile / the spec_exposure signal and the corpus SHA, and css: {} is unchanged; left alone as the separate housekeeping item it is (CI skips this test).

Corpus follow-up

css/io moves from n/a to a defined 0 against a median of 3, so keyword-rosetta needs a pairing PR after this merges (per the no-pins flow: engine first, corpus re-blesses against main). Screened plant: @keyframes probe-io { from { background-image: url("probe.png"); } } in main/a/b — io 0→3 (= the median), args 3→6 (a column already ledgered low for css under args-no-parameter-surface-morphology), func_start 13→16 (dev 0.23, still inside the ±25% band). The ledger's css-import-url-io-triple-overlap entry re-scopes from "io stays None correctly" to the @import line only.

🤖 Generated with Claude Code

squid-protocol and others added 2 commits September 5, 2026 16:13
`io` was wired to `None` under the rationale that a `url()`/`@import` fetch
"happens during browser paint and does not block a computational thread".
True, and not the deciding factor: html's own `io` rule counts `src=` /
`href=` / `<img>` / `<iframe>` -- the same paint-time, non-blocking loads --
and counts them as I/O. `io` measures a resource boundary, not blocking-ness.
Found by the #2669 pass over every non-green cell of the keyword-rosetta bias
report; the corpus ledger (`css-import-url-io-triple-overlap`) had already
recorded the in-code rationale as wrong.

The rule is anchored on a declaration's `:`, and carries three exclusions that
are what the old `None` was actually buying:

- `@import url("a.css")` is NOT counted. An at-rule prelude has no colon, so
  the import keeps exactly the two hits it has today (`import` +
  `_dependency_capture`) rather than a third; `@` is excluded from the value
  span so no earlier declaration's colon can bridge into a prelude either.
- `url(data:...)` is NOT counted -- an inline payload, nothing fetched. This
  is the majority construct: 59 of language-crucible's 117 `url(` tokens.
- `url(#fragment)` is NOT counted -- a same-document reference.

`%` and `<>` are excluded from the value span for the second exclusion's sake.
A `data:image/svg+xml` value is a whole SVG document inlined as text, carrying
its own `url(#...)` references and `xmlns='http:`-shaped colons; without the
guard the scan walks INTO the payload and scores a fetch per embedded icon (70
hits instead of 14 on the crucible corpus, 50 from one WordPress file).

Verified against a quote-aware oracle -- 136 real stylesheets on this machine,
185 fetching declarations, zero disagreement. language-crucible css: 14
declarations in 5 of 38 files. keyword-rosetta css: 0 (its only `url(` is the
`@import` chain, so the ledger's overlap objection is honoured exactly).

The property anchor is a fixed-width LOOKBEHIND, not a match: spelling it
`[-a-zA-Z_][-\w]*[ \t]*:` puts an unbounded `[-\w]*` next to a required `:` and
measures quadratic (1.3s / 5.5s / 13.5s / 54s over 10k-80k chars); the
lookbehind is linear on the same inputs (0.5 / 0.8 / 1.7 / 3.2 ms). Pinned by a
scaling regression.

11 new strict cases: the positive surface, the `@import` non-overlap, the
data:/fragment exclusions, the SVG-payload walk-in (both percent-escaped and
raw inlining), and the ReDoS regression. Docs: css status sections 1/3/4/6/7.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Both fixtures regenerated with crucible_check.py --update. The uncapped
zero-dependency diff (regenerated and compared outside crucible_check's
50-difference / 4000-char caps) is 2 differences, both css, both `io`:

  css/element/fonts-baseline.css      I/O and Network Boundaries  0 -> 2
  css/odoo/icons-baseline.css         I/O and Network Boundaries  0 -> 1

Zero off-target files and zero topological drift -- `io` feeds no node mass,
so nothing re-solved. Both counts match the standalone measurement:
fonts-baseline's two `@font-face src:` declarations (the second is a 4-format
list, counted once as one boundary) and icons-baseline's one.

The corpus's other css files with fetches (cytoscape style.css, the two
wordpress stylesheets) are minified or otherwise filtered out of the audit's
parsed-file section, so they do not appear.

The changed Absolute Project Path / Remote Origin URL / timestamp / duration
fields are the usual machine-to-machine churn (golden_diff sanitizes them);
they flip back and forth on every bless from a different checkout.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 362e272 into main Sep 5, 2026
31 checks passed
@squid-protocol
squid-protocol deleted the fix/2752-css-io branch September 5, 2026 20:54
squid-protocol added a commit to squid-protocol/keyword-rosetta that referenced this pull request Sep 5, 2026
…xy#2752) (#64)

gitgalaxy#2752 / engine PR #2775 (merged 362e2722) gave css an `io` rule. Under
AGENTS.md rule 8 that converts an honest n/a into a measured 0 against a median
of 3 unless the corpus plants the idiom, so this is the pairing.

**Plant.** `@keyframes probe-io` in main.css -- SPEC probe #2, which main holds
-- carrying its 3 hits as three keyframe steps in ONE function rather than one
per file, so the shell gains a single func_start instead of three. Screened
against the live rules: io 3, args +3, structural_boundaries +1 (ungated),
nothing else.

Deliberately NOT planted on the existing `@import url("a.css")` chain. #2775
anchors io on a declaration's colon precisely so an at-rule prelude cannot fire
it -- that is the ledger's `css-import-url-io-triple-overlap` objection honoured
in the engine, and a plant there would score nothing. The rule also excludes
`url(data:...)` (an inline payload) and `url(#id)` (a same-document reference),
so the plant uses real relative paths.

**Manifest.** main.css io 0 -> 3, args 1 -> 4, func_start 4 -> 5.
`verify_language.py css` PASS, 84 assertions across 4 files; engine-side
`rosetta_audit.py` 46 languages, 0 regressions; `na_check.py --ci` clean.

**Ledger.** `css-import-url-io-triple-overlap` re-scoped: its @import reasoning
is kept verbatim and still holds -- it simply never addressed the url() tokens
that are NOT imports, which on real stylesheets is all of them. The
blocking-vs-non-blocking framing it had already flagged as wrong was the entire
basis for `io: None`. `still_reproduces` false, upstream issue linked. The css
clause of `args-no-parameter-surface-morphology` keeps its verdict (CSS
functional notation is not a parameter surface; `calc()` still declined) and
updates its arithmetic: args 3 -> 6, still the same byproduct shape.

**Measured effect** (full-precision regen against engine main, artifacts not
committed per rule 6 -- bias-history.yml regenerates on push):
`bias_report.py --gate` exit 0, 0 unexplained (10 undefined / 170 ledgered /
116 derived), avg 87% across 49 metrics. Two css cells flip, both toward green:
`io` n/a -> 3 (= the median, dev 0.000) and `control_flow_ratio` RED -> GREEN
(0.125 -> 0.107 against a 0.094 median -- the probe body's declarations dilute
the at-rule-heavy ratio). `func_start` / `functions_found` 13 -> 14 (dev 0.077,
green; the manifest's "10 @Keyframes + 3 branch-duals = 13" becomes 11 + 3) and
`args` 3 -> 6, which stays out of band and stays ledgered. Nothing else moves
band. `language_deviations.py css`: 0 red / 0 amber unexplained across 44
comparable metrics.

**Cross-repo.** Companion to squid-protocol/gitgalaxy#2775 (MERGED as 362e2722),
which also re-blessed gitgalaxy's own golden masters for two real-world
stylesheets. Merge order is engine-then-corpus and the engine half is already
in, so this is green against engine main by construction (no pin either way,
gitgalaxy#2682). After merge: `bias-history.yml` regenerates the report, chart
and history here.

Co-authored-by: Joe Esquibel <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.

css: io is None, but every one of the 117 crucible url() fetches is a non-@import resource load that only args sees (design question)

1 participant