Skip to content

fix(core-engine): yaml args reads declared inputs: and counts parameters, not blocks (#2753) - #2759

Merged
squid-protocol merged 1 commit into
mainfrom
fix/2753-yaml-args
Sep 5, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/2753-yaml-args

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Sep 5, 2026 •

Copy link
Copy Markdown
Owner

Closes #2753

yaml/args read 0 against a rosetta median of 13. The rule was narrower than the language on both axes the issue names.

1. with: is the call site; inputs: is the declaration

The old rule matched only

r"^[ \t]*with:[ \t]*(?:#.*)?\n(?:[ \t]*(?:#.*)?\n){0,10}[ \t]+[a-zA-Z0-9_-]+:[ \t]*.*"

with: supplies arguments to an action (it binds to uses:). The parameter surface a YAML file declares — what every other language's args reads off a def/function/sub line — is inputs:: on: workflow_dispatch: / workflow_call: inputs (the latter being the signature of the reusable-workflow API #2743 added to the api trigger set), and action.yml's top-level inputs:. None matched, so a composite action declaring 24 inputs read 0.

2. It counted blocks, not parameters

The regex consumed the header through its first key as one match, so a with: carrying five inputs read args 1. Every other language records one hit per parameter.

The shape

Both are fixed by inverting the rule. A YAML key line means "parameter" or "ordinary config key" purely by what it is nested under — fetch-depth: 0 is an argument beneath with: and a plain setting anywhere else — and that is the enclosing form, which no flat pattern can see. So args now matches every indented mapping key

"args": re.compile(r"^[ \t]+(?:-[ \t]+)*([a-zA-Z0-9_.-]{1,64}):(?=[ \t]|$)", re.M),
"_scope_filters": {"args": "yaml_parameter_block"},

and #2674's registry-declared scope-filter mechanism keeps only the keys whose immediate parent is a valueless with: / inputs: / args: header. Direct children only: under inputs: the direct children are the parameter names, and their own description: / required: / default: keys are that parameter's attributes, not further parameters.

_yaml_parameter_child_offsets is one indentation walk, O(lines). It skips block-scalar bodies, so a run: | heredoc that itself contains with: and key: value lines cannot forge a parameter block out of shell text — the single most dangerous false positive this shape invites. It strips a trailing comment before deciding whether a header carries a value, which preserves epic #813/#843's with: # inputs for this action fix, and it has no {0,10} cap on the comment/blank run before the first key.

The other consumer of the rule

A rule with a declared scope filter matches a superset on purpose, so _calculate_block_metrics' generic single-.search() args derivation would have read that superset: every - run: step would have "declared" one argument off its own run: key, a pure measurement artefact (the shape #2722 hit for shell). For any rule with a declared scope filter the per-function count now comes off the already-filtered spatial map (hit_vector["args"]) instead. Only yaml declares one for args, so nothing else changes.

Measured against a real YAML parser

Not just corpus counts: a PyYAML oracle counts the direct children of every with: / inputs: / args: mapping, and the engine is compared to it file by file.

pool files (unique by content) oracle keys engine keys disagreements
every .yml/.yaml on the dev box — GitHub Actions workflows, action.yml composite actions, compose/k8s/openapi/ansible 196 868 868 0

Plus 18 adversarial shapes pinned as tests (block scalars, tabs, dash-introduced keys, flow-style with: {…}, commented-out blocks, sequence-form args:, empty blocks, a with: nested inside a with: value).

Cost

Matching every indented key sounds expensive; measured, it isn't — the old with: regex was itself scanning the whole file, and the filter is one pass over the lines. coding_analysis on the largest YAML to hand, a 361 KB swagger.yaml: 1169 ms → 1135 ms (0.97x). A 21 KB mkdocs.yml: 19.0 → 19.7 ms. A 4 KB workflow: 2.8 → 2.9 ms. The walk itself is pinned linear by a test on three pathological shapes (one enormous parameter block, 20k indentation changes, one enormous block scalar).

Deliberately out of scope

  • Ansible's module-parameter surface (the mapping under a bare module name, fail: → msg:) — its key vocabulary is unbounded (every module in every collection), so recognising it would mean treating any nested mapping as a parameter block, which is the over-claim this rule already had in the other direction.
  • vars: — Ansible's variable block, the analogue of yaml's own env: (which state_mutation claims). vars: on include_role/include_tasks really does pass parameters, but nothing on the block itself distinguishes the two uses. Both are recorded in the code comment.

Verification

gate result
pytest tests/ 7674 passed, 4 skipped, 9 xfailed, 3 xpassed
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, 0 pre-existing, 0 broken
crucible_check.py full_precision PASS, zero_dependency PASS

No golden-master bless is owed. Neither corpus contains a with: / inputs: / args: block — the language-crucible yaml sample is 7 Ansible task files, and the rosetta shell is run: steps — so both read args 0 before and after. That is also why the old rule was unexercised by the golden master (the caveat recorded as language-crucible#23).

Cross-repo

The rosetta cell needs its paired corpus plant: squid-protocol/keyword-rosetta#59 (pairing table row for #2753). Engine merges first, then the corpus PR re-blesses against engine main (docs/GATING.md "Cross-repo flow"; gitgalaxy#2682 — no pins). The corpus plant declares one inputs: key per function definition in each file (main 4, a/b/c 3 each = 13, exactly SPEC's "13 function definitions, each taking one argument"), which needs no uses: line and so adds no fake edge to the planted main→a→b→c DAG — the objection that made the original ledger entry decline the with: plant.

Docs: how_to_add_a_language.md rule 17 gains the yaml filter as the worked example of a scope filter used in the widening direction, with the warning to check every other consumer of a rule before letting it match a superset.

🤖 Generated with Claude Code

…ers, not blocks (#2753)

`yaml/args` read 0 against a rosetta median of 13. The rule was narrower than
the language on two axes:

1. It matched only `with:` -- the CALL-SITE argument block, which binds to
   `uses:`. The parameter surface a YAML file DECLARES (what every other
   language's `args` reads off a def/function/sub line) is `inputs:`:
   `on: workflow_dispatch:`/`workflow_call:` inputs, and action.yml's top-level
   `inputs:`. A composite action declaring 24 inputs read 0.
2. It counted BLOCKS, not parameters: the regex consumed the header through its
   first key as one match, so a `with:` carrying five inputs read 1.

A YAML key line means "parameter" or "ordinary config key" purely by what it is
nested under (`fetch-depth: 0` is an argument beneath `with:` and a plain
setting anywhere else) -- the enclosing form, which no flat pattern can see.
So the rule now matches every indented mapping key and a registry-declared
`yaml_parameter_block` scope filter (#2674's mechanism) keeps only the keys
whose immediate parent is a valueless `with:` / `inputs:` / `args:` header.
Direct children only: under `inputs:` the direct children are the parameter
names, and their own `description:`/`required:`/`default:` keys are that
parameter's attributes.

The walk skips block-scalar bodies, so a `run: |` heredoc that itself contains
`with:` / `key: value` lines cannot forge a parameter block out of text. It
also strips a trailing comment before deciding whether a header carries a
value, preserving epic #813/#843's `with: # inputs for this action` fix, and
has no {0,10} cap on the comment/blank run before the first key.

Because a filtered rule matches a superset on purpose, `_calculate_block_metrics`'
per-function args count is re-pointed at the already-filtered spatial map for
any rule with a declared scope filter -- otherwise every `- run:` step would
have "declared" one argument off its own `run:` key.

Ansible's module-parameter surface (the mapping under a bare module name) is
deliberately out of scope: its key vocabulary is unbounded, so recognising it
would mean treating any nested mapping as a parameter block. `vars:` is left
out for the same reason it is not `state_mutation`'s job to guess -- nothing on
the block distinguishes Ansible's variable block from the parameter-passing use
on `include_role`/`include_tasks`.

Measured: against a PyYAML oracle over 196 unique real .yml/.yaml files
(GitHub Actions workflows, action.yml composite actions, compose/k8s/openapi),
868 parameter keys, engine and oracle agree exactly on every file. Both
corpora (keyword-rosetta and language-crucible) still read 0 -- neither
contains a `with:`/`inputs:`/`args:` block -- so no golden master moves; the
rosetta cell needs its paired corpus plant (keyword-rosetta#59).

Closes #2753

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 69a5c0e into main Sep 5, 2026
31 checks passed
@squid-protocol
squid-protocol deleted the fix/2753-yaml-args branch September 5, 2026 19:36
squid-protocol added a commit that referenced this pull request Sep 5, 2026
Conflict was the two golden-master fixtures again, both auto-generated: #2755
(jcl api/cleanup/globals) and #2759 (yaml args) re-blessed them on main while
this branch was in flight. `gitgalaxy/core/detector.py` merged cleanly -- their
changes are in the rules, this one is in the Mode D slicer.

Resolved per .agents/skills/ci-push-checklist section 6: took origin/main's
version of both fixtures to clear the markers, then re-ran
`crucible_check.py --update --yes` so they are recalculated from the merged
code rather than stitched together.

Verified rather than trusted: re-attributed the regenerated fixture against
origin/main and got the same profile as before the merge, exactly -- 20
differences, 0 topology movement, `Start Line` the only field changed inside
`5. Function Analysis`, and all 17 per-file diffs on `.sh` files. #2755's and
#2759's own contributions are in the base and untouched.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WfeHRWra1d6Z5uSReFajSq
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.

yaml: args matches only a with: block — inputs: declarations are invisible and a block counts as one argument

1 participant