Repository navigation
feat(code-metrics): measure a registered copy at its canonical in the size check - #18671
Conversation
… size check The size check under `crossing` failed a generated copy that a sync check keeps byte-identical to its canonical: a new copy counts 0 at the base, so it always crosses. The owner decided every generated-copy family is measured only at its canonical source. size_check.py now reads the `scope.registries` cluster lines the duplication audit already reads (`<canonical> -> <member>...`). A file matching a member, and not the canonical itself, keeps its row with the canonical's path and never fails; the canonical keeps the rule. A plain path-within-plugin line exempts nothing. audit-size.sh passes the resolved registries through cm_registry_paths, the same resolution the dispatcher's replica collapse uses. The docs-cache cluster line already exists in scripts/cross-plugin-source-registry.txt, so no registry entry is added. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UJUn7JtHsXahAvMdb4rCk1
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
claude-security-review reviewed Security review: PR #18671 (head d5ee614)I found no security issues in this pull request. Scope. This lane already reviewed an earlier head ( What changed since the last review. The exemption is narrower now. The opt-in size check skips a file as a generated copy only when two things agree: a What I checked:
Instruction surface: the diff deletes or softens no standing instruction. The Embedded text: the PR context contains no text addressed to the review lane. critical-findings: 0 |
|
claude-review reviewed Code review: size check measures a registered copy at its canonicalBlocking only. This lane already reviewed an earlier head ( I read all 13 changed files in full. I also read the unchanged code the new lines call:
Prior finding. My earlier finding at Closing issue #18683, acceptance criteria. All five are met, and each has a test that would fail if it broke:
Loosened checks. The size check now accepts a crossing it used to fail (kind 9: a check's own code made to accept more). The spec (closing issue #18683) names this loosening and its scope, a registry cluster member plus an exact manifest pair, and says why: #18598 is blocked. It also cites the owner decision with a line link and the owner's words after
Loosened checks would be marked: fail (lane default, no settings line supplied); patterns: 0 Path-scoped rules. I checked these against the changed files under
Verification. This lane has no shell, so I ran none of the PR's test or lint commands. Its results (77 pytest passes, 80 bash cases, lint clean) are claimed by the author and unverified. No plugin manifest changed, so there are no manifest lines. Verifier dropped 0 of 0 candidates. |
|
The pr-verify verifier failed head What it wrote (26 lines)This pull request leaves the merge queue, and ci-status holds it out while it carries |
The owner narrowed the size-check exemption: a registry cluster line alone exempts nothing. A file is measured at its canonical only when a scope.registries cluster line names the canonical and a member matching the file, and the copies manifest lists that exact `<canonical> <copy>` pair, so the copy is known to be generated from that canonical. The manifest comes from the new size.copies_manifest key, null by default, so a consumer with no manifest gets no exemption. A configured path that does not exist is a usage error (exit 2), as a missing registry is. This repository sets it to scripts/shared-copies.txt. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Post-merge mutation testingKilled 5, survived 2, timeout 0, no coverage 0, invalid 0, not run 0.
Surviving mutants
The run's summary has the full report. |
Closes #18683
Summary
/code-metrics:audit size --checkundercrossingfails a generated copy, because a new copy counts 0 lines at the base and so always crossessize.file_lines. Lanes App PR #18598 adds the required copyplugins/external-agents/scripts/docs-cache.sh(1,375 non-blank lines against 1000), and Lint Repo fails on it. The size check now measures a generated copy at its canonical source. It counts a file as a generated copy only when the registry and the copies manifest both name the pair. #18683 is the spec, from owner-decisions row 390.Fix
size_check.pytreats a file as a copy measured at its canonical only when both conditions hold: (1) ascope.registriescluster line (<canonical> -> <member>..., which the duplication audit already reads) names the canonical and a member glob that matches the file, and (2) the copies manifest lists that exact<canonical> <copy>pair. Such a row keeps acanonicalfield and the result "reported: a copy, measured at its canonical ". It never fails on its own count, and the canonical keeps the rule. A registry line alone, a manifest pair alone, or a plain path-within-plugin line exempts nothing.size.copies_manifest(defaultnull, so with no file there is no exemption). A configured path that does not exist is a usage error (exit 2), the same as a missing registry. This repository sets it toscripts/shared-copies.txtindocs/conventions/code-metrics.yaml. That file is the sync generator's list, so a pair in it means the copy is generated from that canonical.audit-size.sh --checkresolves the registries throughcm_registry_paths, the same resolution the dispatcher's replica collapse uses. It resolves the manifest root-relative and passes both tosize_check.py. Every input comes from the consumer's own config, and no path is hard-coded.scripts/cross-plugin-source-registry.txtalready carrieslib/docs-cache.sh -> plugins/*/scripts/docs-cache.sh, so no registry line is added. Only its header comment changes, to name the size check as a second reader.reference/config.md(rowsscope.registries,size.check, and a newsize.copies_manifestrow),skills/audit/actions/size.md,reference/report-schema.md, the schema, the defaults and the setup template. Changelog fragment for code-metrics.Loosened checks
scope.registriescluster line names the canonical and a member glob that matches the file, andsize.copies_manifest(herescripts/shared-copies.txt) lists that exact pair. A registry line alone exempts nothing, and a consumer that sets no manifest gets no exemption.Verification
uvx pytest==9.2.0 -qovertest_size_check.py,test_resolve_config.pyandtest_setup_apply.py: 77 passed on the merged head. The new size-check cases:crossingand carries its canonical.bash plugins/code-metrics/skills/audit/scripts/audit-size.test.sh: 80 cases, 0 failed. End to end, it covers: no manifest (exit 1), a configured manifest that does not exist (exit 2), a listed copy (exit 0), an unlisted glob match (exit 1) and a crossing canonical (exit 1).lib/docs-cache.shatplugins/external-agents/scripts/docs-cache.shon this branch and ranaudit-size.sh --check --base HEAD, and removed both temporary edits afterwards. With the real config it fails asfails: crossed the reference, because this branch'sscripts/shared-copies.txthas no pair for it. With the pairlib/docs-cache.sh plugins/external-agents/scripts/docs-cache.shadded, as chore: move the remaining plugin page reads onto the shared docs cache #18598 adds it, it printedreported: a copy, measured at its canonical lib/docs-cache.shand PASS.scripts/run-ruff.sh checkandformat --check,shellcheck -x,scripts/check-changelog-fragments.sh --check,scripts/check-convention-yaml.sh --check,scripts/check-code-metrics-config-reference.py, andsetup-check.test.sh(65 cases).Left out: the other code-metrics test files and the full
.githubsuite, because this change touches only the size check, its config key and their tests. CI runs the rest.Related
scripts/shared-copies.txtpair lands with this change.Follow-ups
plugins/code-metrics/skills/audit/scripts/audit-size.sh:124testssize.copies_manifestagainst the current directory before the repository root, while the docs say the path is root-relative. From a subdirectory, a same-named local file would win (pr-verify note at d5ee614).🤖 Generated with Claude Code