Repository navigation
docs(review-pr): add the A rule family for code shape, and the AGENTS.md principles it rests on - #1815
Open
zoroyihan7 wants to merge 6 commits into
Open
docs(review-pr): add the A rule family for code shape, and the AGENTS.md principles it rests on#1815zoroyihan7 wants to merge 6 commits into
zoroyihan7 wants to merge 6 commits into
Conversation
zoroyihan7
requested review from
a team,
Ahmedhasssan-aig,
chao-xu-spec,
devalshahamd,
iraj465,
tsrikris and
yueliu14
as code owners
October 10, 2026 13:51
Contributor
Author
|
The earlier ruff-rules content of this branch now lives in #1812. This PR was reopened and reused for the code-shape review rules (A family) and the AGENTS.md Code shape block. |
Add a Code shape bullet beside Clean design, Trust the caller and Simplify by removing a mechanism. It states, as principles, what the repository owner asks of new code: modules are used through the names their owner exports, business-agnostic helpers live in hyperloom.common, logic sits beside the state it reads, per-framework facts are fields on the owner's spec, closed vocabularies are typed where they enter, signatures and results have one named shape, a query-named function changes nothing, an abstraction waits for its second implementation (unless a lower layer declares it for a higher one, or out-of-tree code implements it), and an alias or a shared role such as log keeps the meaning its package gives it. No existing text changes. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: zoroyihan7 <Yihan.Wang@amd.com>
…d shape Fourteen rules (A1-A14) clustered from the review history of #1611, #1642, #1650, #1655, #1658, #1660, #1662, #1665, #1703, #1705, #1707, #1739 and #1794, each with at least one Seen in example re-read on the merge base. Each rule is the concrete check for one sentence of AGENTS.md (Code shape, Clean design, Trust the caller, Simplify by removing a mechanism), and its Severity names that sentence; the parts no AGENTS.md sentence states (data clumps, module-level mutable state, renaming locals, re-raise-only handlers) stay advisory. Three items fold into existing rules instead of becoming new ones: X2 treats a refactor title as a claim that nothing observable changed, with a refactor commit subject alone advisory (#1297); D1 covers a second code shape for one concern (#1658); D10 names the hyperloom.common helpers whose private copies fire it (#1348, #1408). The index gains rows for the A rules, SKILL.md's rule count follows (69 rules, 10 families), and copilot-instructions.md points at the Code shape principles. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: zoroyihan7 <Yihan.Wang@amd.com>
A1, A2 and A8's flag-with-dummies case stay blocking: their triggers are mechanical and each rests on an AGENTS.md sentence that states it outright. Every other A rule, and D1's new code-shape half, is advisory until its trigger has been calibrated on real PRs. A1 no longer fires on attributes hung on another object or on dunder names, and A8 cites PR #893, where kill_only was introduced. Co-Authored-By: Claude <noreply@anthropic.com>
zoroyihan7
force-pushed
the
ci/ruff-principle-rules
branch
from
October 10, 2026 20:04
e7bf720 to
f7e7afe
Compare
A1-A14 were replayed on 30 recent merged PRs and every fire was judged by an independent adversarial judge. Severity now follows the measured precision: a rule or delimited sub-case is blocking at precision >= 0.8 on at least two real findings with an AGENTS.md sentence behind it. - A1: demoted to advisory as a whole (5/10); the added non-test import sub-case stays blocking (5/5). Tests and unchanged lines are carved out. - A2 stays blocking (2/2); A8(a) keeps blocking (no fire). - A12 pure forwarder (2/2) and A13 redundant re-check (2/2) promoted. - A4, A5, A9, A10, A11 get Not-a-finding clauses for each replayed false positive; every Severity line records its count. - Rules whose shape the code-metrics job (#1812) mechanizes say so. Co-Authored-By: Claude <noreply@anthropic.com>
…lause to V1 The code-metrics job in #1812 (head 0962cff) checks none of the A shapes, so the Mechanized notes cited a gate that does not exist. The A11 clause no longer exempts an in-place resolve_* by convention; it covers only a write that moved unchanged from the parent (V1). Co-Authored-By: Claude <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description: what and why
This PR reuses docs(review-pr): add the A rule family for code shape, and the AGENTS.md principles it rests on #1815 and replaces the content of branch
ci/ruff-principle-rules. The earlier ruff-rules content of docs(review-pr): add the A rule family for code shape, and the AGENTS.md principles it rests on #1815 now lives in ci: code-metrics gate on touched files with baseline-free checks; fold in import-linter, PR hygiene and ruff principle rules #1812; nothing from it remains on this branch.Reviews of this repository keep returning to the same code-shape questions -- private names used across packages, per-framework switches repeated at each consumer, flag arguments, positional tuples and dict bags as results, query-named functions with side effects, single-implementation abstractions, forwarding layers. Until now those findings had no rule to point at, and most could not be blocking because no
AGENTS.mdsentence stated them. This PR writes them down in two places:AGENTS.mdgains a Code shape bullet (16 lines) beside Clean design, Trust the caller and Simplify by removing a mechanism. It states the principles; it does not change any existing text, including the Size is a design signal complexity paragraph. Where a principle has a legitimate exception the rules rely on, the sentence says so: a query-named function changes nothing while a command may return its outcome, and an abstraction waits for its second implementation unless a lower layer declares it for a higher one to implement or out-of-tree code implements it..claude/skills/review-pr/rules.mdgains the A -- Abstraction, boundaries and shape family, A1-A14, in the house format, with index rows so a reviewer reaches them from the diff. Every rule keeps at least oneSeen inre-read on the merge base (880c167); citations that did not hold were corrected or dropped. Each rule's Severity names theAGENTS.mdsentence it rests on. Severity follows a calibration replay (see Calibration below): a rule or a clearly delimited sub-case is blocking when it measured precision >= 0.8 on at least two real findings and rests on anAGENTS.mdsentence that states it outright; everything else is advisory:_-name or through an_module segment (5/5; Code shape: "an_-name or an_internalpackage is not an interface"); demoted to advisory otherwisedef(Simplify by removing a mechanism: "a forwarding layer with no job of its own"); advisory for single-implementation abstractions (no fire)except: raise(no fire)No A shape is mechanized yet: the code-metrics job in ci: code-metrics gate on touched files with baseline-free checks; fold in import-linter, PR hygiene and ruff principle rules #1812 (head 0962cff) checks none of them, so every A rule stays a review-time check.
Wrong behaviour that a shape defect causes stays blocking under the C or S rule it breaks.
Three items fold into existing rules rather than becoming A rules: X2 now treats a
refactortitle as a claim that nothing observable changed, with arefactorcommit subject alone under an accurate title and description advisory (feat(keep): --max-latency-ms as a constraint on every promotion #1297); D1 covers a second code shape for one concern ([Bad smell] refactor: give misleading names the meaning their code has #1658), resting on Finish the replacement and advisory like the A rules; D10 names thehyperloom.commonhelpers whose private copies fire it (GEMM lane: connect the three unwired shape inputs, and fix the five defects behind them #1348, Move kernel selection from Hyperloom into KernelForge #1408).SKILL.md's rule count follows (69 rules, 10 families; the file stays at its 350-line budget), and.github/copilot-instructions.mdgains a Code shape review bullet pointing at the new principles.Overlaps are assigned rather than reported twice: a private copy of a
hyperloom.commonhelper is D10's, an empty base class or pure forwarder is A12's, a per-framework/backend/arch branch is A7's, a query name on a function with an effect is A11's (unless the effect is a second result channel, which is A9's), and a business rule in a utility module is A3's. A2 states the layer direction from the imports the tree already has and does not depend on any import-linter configuration, so it reads the same before and after the gates in ci: code-metrics gate on touched files with baseline-free checks; fold in import-linter, PR hygiene and ruff principle rules #1812 land.No new gate is added here; the rules are review-time checks.
Calibration
A1-A14 were replayed on 30 recent merged PRs (fix(orchestrator): bound the prompt sections that grow with the session #1735-fix(orchestrator): keep a PRELUDE skip_to_kernel hint from ending FRAMEWORK_AGENT #1808, in 10 batches of 3) and every fire was judged by an independent adversarial judge; contested cases defaulted to false. 26 fires, 15 real (precision 0.58 overall). The per-rule counts are in the severity table above. Every false positive got a precise Not a finding when clause (or a narrower Fires when) so the replayed false positives no longer fire, without dropping any real finding:
tests/dir (own, layer-level, or a sibling layer's dir hosting the owner's unit tests) that import, call, assert on or monkeypatch the private name under test (fix(agentx): derive explore winner axes, park baseline aiter drops off NFS, sandbox aiter in tests #1806 x3, fix(gemm-tune): keep the TunableOp recording envs in the vLLM shape capture #1772); an unchanged_access whose module load alone changed fromsys.pathto a package import ([Relocate] Kernel agent: move the kernel tools to their owner packages and retire HYPERLOOM_KERNEL_AGENT_ROOT #1787, V1)..get()for older records (fix(prelude): keep PRELUDE open until the initial roofline books #1779).str(fix(orchestrator): keep a PRELUDE skip_to_kernel hint from ending FRAMEWORK_AGENT #1808, fix(prelude): keep PRELUDE open until the initial roofline books #1779); a raw literal compared where the owner exports the constant still fires.resolve_*slice split out of a function that already wrote the sameargs.<field>in place on the merge base, the write moving unchanged (V1, fix(cli): export every --extra-env pin so all readers resolve it alike #1797); a new write still fires.Linked issue(s): none
Tests: docs only. Ran codespell 2.4.1 on the changed files (only the two pre-existing
unparseablehits in S-family text, unchanged by this PR),reuse lint(compliant),python scripts/check_cli_references.py(pass),git diff --check(clean), and a script confirming everyAGENTS.mdsentence quoted in an A rule's Severity is present verbatim inAGENTS.mdand every A rule is on an index row.Size/complexity triggers crossed: none (no code).
If this simplifies or refactors: n/a.
Observable effect: none for operators -- docs and review instructions only. Authors and reviewers now have an
AGENTS.mdprinciple and a numbered rule (A1-A14) to cite for code-shape findings, and the review skill marks blocking the calibrated cases in the table above (A1 added non-test import, A2, A8(a), A12 pure forwarder, A13 redundant re-check); the rest are adjudicated but not published.Breaking changes: no
PR addresses single concern: yes -- the code-shape principle and the review rules that check it.
Root cause is upstream (Magpie/TraceLens/GEAK/IntelliKit/AgentKernelArena), ticket filed: n/a
🤖 Generated with Claude Code