Skip to content

args contract: css is a stated absence, not an approximate fallback (count contract corollary 3) #2893

Closed

Description

@squid-protocol

Summary

args is a stated contract — "The parameters a callable declares" (signal_contracts.py, #2773, docs/args_rule_contract.md). Every language now satisfies it except css, whose rule matches value-function calls:

"args": re.compile(
    r"\b(?:calc|clamp|min|max|var|env|url|rgba?|hsla?|lch|oklch|color-mix|light-dark)"
    r"\s*\((?:[^()]|\((?:[^()]|\((?:[^()]|\([^()]*\))*\))*\))*\)",
    re.I,
),

docs/args_rule_contract.md:194-200 names this as the exception in as many words — "It is the one place in this document where the contract is deliberately not met" — and keeps it because "CSS has no callable of any kind, so the honest alternatives are this approximation or 0 forever, and 0 says a stylesheet full of computed values has no coupling at all."

Both halves of that justification are now false. This issue proposes css args become a stated absence (None), the answer the count contract already mandates.

1. The sheet already decided this

signal_contracts.py, COUNT_CONTRACT corollary 3:

Where the language makes the property the default, say which side counts. Either the declaration itself is the marker (api corollary 3: public-by-default languages count def), or the language records a contract-level absence (None rule + a ledgered intended-morphology entry) rather than a manufactured construct. The two answers cannot coexist inside one signal.

docs/io_rule_contract.md C3 applies it, and names css in the same breath:

solidity is the stated absence: the EVM cannot reach outside itself, io: None with manifest 0 … the absence answer and the rule answer cannot coexist in one language (count contract corollary 3).

css args is a manufactured construct living inside a stated contract. The third alternative is None, not 0 — and None is not scored at all.

2. The counter-argument has expired — measured, not asserted

Composition of all 3,857 css args hits over the 38 crucible css files (live compiled rule, finditer):

head hits share is it coupling?
var( 2,522 65.4% yes — the real residual
rgba( rgb( oklch( color-mix( 932 24.2% no — a colour written longhand
calc( 321 8.3% partly — 226 of them already contain a var(), i.e. double-counted
url( 77 2.0% io owns it since #2752
clamp( min( 5 0.1% safety owns clamp()

Nearly a quarter of the signal was never coupling. Meanwhile, on those same 38 files, css coupling is measured — by the rules that own it:

signal hits what it is
api 3,618 3,597 are --custom-property: declarations (+21 :root) — the definitions of the very tokens var() reads. Larger than the read side.
safety 516 513 are var(x, fallback) (+2 clamp, +1 @supports) — the guarded read, already counted
io 14 the real external fetches (#2752)
reflection_metaprogramming 24 nested calc( — computation depth
import 9 the @import DAG

So "0 says a stylesheet has no coupling at all" was true when written, and is not true now: three of those five rules postdate it.

The named residual, stated plainly: the unguarded var(--x) read — 2,522 − 513 = 2,009 occurrences — becomes unmeasured. Nothing else counts it and nothing should be stretched to: the globals contract's C2 explicitly excludes an ordinary read of a binding by name. If it ever earns measurement it earns its own signal; smuggling it into a signal that means something else is the failure mode this change exists to end.

3. It is a live measurement defect, not only a mislabel

css does not receive args_search_text (only objective-c, c, cpp, dart do), so _calculate_block_metrics searches the whole block body and takes the first match. Six css at-rule blocks therefore carry a parameter count borrowed from their own body — the exact failure args_rule_contract.md:38-53 describes:

  • tailwind/preflight.css:291 — an @supports whose prelude is (not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px) reads arity 3, off a color-mix(in oklab, currentcolor 50%, transparent) three lines inside the block.
  • threejs/editor_main.css:720 @media → arity 4; a second @media → 3; three gutenberg/*.module.css @layer → 1 each.

tree-sitter reads 0 for every one. args_exact_match for css is 19 of 25; a stated absence takes it to 25 of 25 — higher_is_better, so this is an accuracy improvement.

Separately: tests/tools/tree_sitter_accuracy_audit.py (~L299-312) documents this defect as a non-defect. It tells the next reviewer the gap is fine because "GitGalaxy assigns them a param count read from the at-rule prelude tokens". That mechanism does not exist — the count comes from the block body. That docstring is wrong on main today regardless of what is decided here.

4. Scope caveat — the doc must not repeat "CSS has no callable of any kind"

css.py:24 claims [".css", ".scss", ".sass", ".less", ".styl", ".pcss"], and Sass genuinely declares parameters: @mixin button($size, $color), @function foo($a, $b); Less has .mixin(@a; @b). So the sweeping sentence in the contract doc is wrong at the scope this definition claims.

The route of narrowing the rule to those declaration forms — which would satisfy the contract rather than except it — was considered and rejected on measurability: there are 0 .scss/.sass/.less files in the language-crucible, 0 in keyword-rosetta, and 0 anywhere on the build box. A rule that cannot be measured on either corpus is not one this project ships.

So: None today, with an explicit reopen condition recorded in both the rule comment and the contract doc — if .scss/.less enters the crucible, @function/@mixin/.mixin(@a; @b) is a real declared parameter surface and this absence must be revisited.

5. Corpus consequence (keyword-rosetta)

args/css reads 6 vs median 13 (−54%) and avg_func_args/css 0.05 vs 1. No plant targets either — all 6 hits are byproducts of other plants (3 @import url() + 3 @keyframes probe-io url() steps). It is the only open-defect cell left in the whole args family ("args — 1 of 45").

Two ledger edits are owed, and one of them is a trap:

6. Expected movement

before after
struct_args css (crucible) 3,857 0
args/css (rosetta) 6, red (extraction) n/a
avg_func_args/css 0.05 0.0, ledgered (inherency)
args_exact_match css 19 / 25 25 / 25
open-defect share 13 of ~2636 12 of ~2635
"metrics carrying the most open defect" args — 1 of 45 args row gone

No risk_* formula consumes args, so no risk leaf may move — that is the go/no-go on the golden-master bless. Expected leaves: Function Parameters (6), Structural Magnitude (~5), Directory Group Magnitude (4), composition.css.impact, and the corpus-wide X/Y/Z topological ripple.

Out of scope

Roadmap: #2812 Phase 3, corollary follow-up on an already-stated contract (beside #2824, #2817, #2832, #2827).

Activity

  1. added
    metrics
    core-engine
    on Sep 8, 2026
  2. squid-protocol commented on Sep 8, 2026

    @squid-protocol
    OwnerAuthor

    Correction to the composition table above: measure the code stream, not the raw file.

    The tables in the issue body were measured over raw file text and read 3857 total. The engine hands rules the Prism code stream (comments blanked), and rule_probe.py confirms css args at 3855 — the figure docs/args_rule_contract.md already carried. Two hits sat inside comments.

    Re-measured on the code stream, which is what the PR and the rule comment use:

    head hits share
    var( 2521 65.4%
    rgba( rgb( oklch( color-mix( 931 24.2%
    calc( 321 8.3% (226 containing a var())
    url( 77 2.0%
    clamp( min( 5 0.1%
    total 3855

    And the owners: api 3618 (3597 --custom-property: declarations), safety 515 (of which 512 are the guarded var(x, fallback) read), io 14, reflection_metaprogramming 24, import 9.

    The named residual is unchanged either way: 2521 − 512 = 2009 unguarded var() reads. No part of the argument moves; recording it so the numbers in the issue, the rule comment and the contract doc all agree.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    core-enginedata-qualitymetrics

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions