Skip to content

feat: add min-wait-loop, expensive-loop-check, and nested-binder-lambda - #2

Merged
e54-bot merged 2 commits into
mainfrom
feat/migrate-native-rules
Nov 11, 2026
Merged

e54-bot merged 2 commits into
mainfrom
feat/migrate-native-rules

Conversation

@e54-bot

@e54-bot e54-bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #1

Adds min-wait-loop, expensive-loop-check, and nested-binder-lambda with their native bare IDs, native metadata, evidence, and default severity. The matchers are the parity rules from wrightkit/wright crates/wright-analyzer/tests/yaml_contract.rs (#970 there). Also adds fixtures, a CI job, and the maintenance contract in AGENTS.md.

Verification

Independent reference: the native rules in Wright 0.41.8. For each rule, I ran wright lint -f json --all --rule-id <id> once with the native rule and once with this package pinned by SHA. I compared the sorted {location, severity, evidence} sets:

Input min-wait-loop expensive-loop-check nested-binder-lambda
wright tests/fixtures/workshop/real-world/reproducer-bastion-prophet.ws same (0) same (0) same (16)
this PR's three fixtures same (3) same (2) same (2)

tests/run.sh passes against Wright 0.41.8. It fails when a matcher changes (checked by setting the Wait threshold to 0.001). It also fails when a finding does not come from this package, because the native message format has no (matched N nodes) suffix.

Deviations from the issue

  • CI tracks the latest Wright release instead of a pinned one. .github/docs/rust-ci.md item 8 says to follow the latest release of a fast-moving upstream rather than an old pin. AGENTS.md says the same.
  • The expensive-loop-check documentation names distance and isInLoS only. The native text also names raycast, which matches no canonical element, so the native rule never reported it. Behavior is unchanged.
  • tests/run.sh checks each fixture rule by name. The previous harness allowed only one finding per fixture file. Now every rule named flagged… must report exactly one finding and every rule named clean… none, so one fixture covers all three loop scopes and the documented exclusions.

Not covered

  • The previous behavior's finding text differs. Migrated rules report <summary> (matched N nodes); the owner approved this in wrightkit/wright#970.
  • On Wright 0.39.2 the whole package fails to load (unknown field evidence). One unsupported field refuses the package, not one rule. This is input for wrightkit/wright#1080.
  • The four rules on the unpushed local branch feat/initial-rules are not part of this PR.

Move the three built-in Wright rules that the SPEC-309 matcher can express into this package, with fixtures, a CI job, and the package maintenance contract in AGENTS.md.

Fixes #1
@Teakowa

Teakowa commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Verdict: CHANGES REQUESTED

Reviewed head 1dba2b786a5d57d6c03780fe5f8864292eea6fe8. Both findings are documentation only. The rules, fixtures, harness, and CI pass every falsification attempt below.

Findings

1. README.md:28-35 and AGENTS.md:38-43: no minimum Wright version is stated, and older releases fail to load the whole package.

Failure scenario: a contributor or user on Wright 0.39.x follows the README (tests/run.sh, or a packages pin). Every rule fails to load, and wright lint exits 2 with no findings. The first published release that loads the package is 0.41.0 (0.40.0 is an unpublished draft). Issue #1 scope item 4 asks the docs to state the Wright release that CI uses and how to raise it. The PR switched CI to latest, so the docs now name no version at all.

Evidence (verified release archives, .sha256 checked):

$ WRIGHT=<0.39.3> tests/run.sh
wright: lint package 'wrightkit/lint-rules' at 132a40…: …/rules/expensive-loop-check.yaml: invalid rule YAML: metadata: unknown field `evidence`, expected one of `summary`, `rationale`, `documentation`, `known-limits`, `tags` at line 14 column 3
$ wright --version && WRIGHT=wright tests/run.sh; echo rc=$?
wright 0.39.2 (wright-driver 0.39.2)
wright: lint package … unknown field `evidence` …
rc=2
$ WRIGHT=<0.41.0> tests/run.sh
ok   expensive-loop-check
ok   min-wait-loop
ok   nested-binder-lambda

Fix: state "Wright 0.41.0 or later" in the README Use and Test sections, and say in AGENTS.md that the floor rises when a rule uses a newer matcher feature.

2. README.md:15-26: the README says a Wright release already embeds this package. No release does yet.

README.md:15 says "a newer revision than your Wright release embeds", and README.md:25 says "The pinned revision replaces the embedded rules." On Wright 0.41.8 and on wrightkit/wright main, nothing is embedded: docs/cli/lint.md:248-249 says "The first-party package currently ships no rules", and wrightkit/wright#1081 (the embedding) is open. Today a pin replaces Wright's native rules with the same bare IDs. AGENTS.md:44-47 has the same present tense but adds the "Until wrightkit/wright#1081 lands" caveat. The README has no caveat, so a reader concludes that the current release ships a recorded SHA of this repository.

Fix: in the README, say that a pin replaces Wright's built-in rules with the same IDs, and that Wright embeds this package from wrightkit/wright#1081 on. No policy rule covers this beyond Issue #1 acceptance criterion 3.

Decision for the orchestrator (not a finding)

Issue #1 scope item 3 and acceptance criterion 1 say CI runs "against one pinned Wright release". The PR uses version: latest and cites .github/docs/rust-ci.md item 8 ("While an upstream is changing quickly, follow its latest release"). The PR body records the deviation, and AGENTS.md:43 documents it. I did not treat this as a defect, because the org policy supports it. The Issue owner should confirm it. If the owner keeps the pin, finding 1 is resolved by naming the pinned release instead.

Verification

Independent reference: native rules in Wright 0.41.8 (wright-0.41.8-aarch64-apple-darwin.tar.gz, SHA-256 eff9c802…828c5 matches the release .sha256), plus crates/wright-analyzer/src/registry.rs and tests/yaml_contract.rs on wrightkit/wright main ddf991f4.

  • AC1. CI run 42898139152 ("Rule fixtures") is green on the head commit, with Wright 0.41.8 in the log. Locally tests/run.sh passes on 0.41.8 and 0.41.0.
  • AC2, parity. For each rule I ran wright lint -f json --all --rule-id <id> natively and with the package pinned by the head SHA in a package store. I compared sorted {code, location, severity, evidence} sets. All equal (SAME) on:
    • the three PR fixtures, each crossed with all three rules;
    • reproducer-bastion-prophet.ws from Wright main: 16 / 0 / 0 findings;
    • three adversarial files (34 rules). Inputs: nested loops (both loop levels report), a disabled Wait, a disabled rule, Wait(0.017), Wait(0.0160), Wait(Add(0.008, 0.008)), Wait(-1), Wait Until, a Wait in If inside a loop, two waits in one body, the Loop action, and a Wait after End. Also distance in a For header, in If / Else If conditions inside a loop, and in a While condition. Also Ray Cast Hit Position, nested distance, and a rule condition. Also triple binder nesting, a binder at index 0 inside index 1, a binder deep under a non-binder, and sibling binders. Totals: 8 min-wait, 8 expensive, and 10 binder findings, each equal on both sides.
    • Every package finding carries the (matched N nodes) suffix; the native one does not. The code is the bare ID.
  • Metadata. summary, rationale, documentation, known-limits, and tags equal the registry text exactly, with two exceptions: the documented raycast removal, and wright issue #713 rewritten as `wrightkit/wright#713`. The rewrite is correct outside the wright repo. Matchers are byte-equal to MIN_WAIT_RULE_YAML, EXPENSIVE_RULE_YAML, and BINDER_RULE_YAML. Severity and evidence equal native: warning/static-indicator, info/heuristic, and warning/static-indicator.
  • Harness. tests/run.sh exits 1 on each of 9 mutations: from: 0, threshold 0.015, a scope without for-player-variable, an unknown metadata field, severity: error with heuristic, a dropped --lint-config (native findings leak; reports "3 findings did not come from this package"), a mismatched id, and an unparseable fixture. It exits 0 unmutated.
  • CI. actions/checkout@3d3c42e5… resolves to tag v7.0.1. wrightkit/setup-wright@v1 is a WrightKit action, so .github/docs/ci-platform.md does not require a SHA pin. Concurrency matches the documented pattern.
  • Non-goals. No native rule changes, no new rules, and no change to what expensive-loop-check matches.

Limitations: the JSON envelope exposes only the start line:col, so I did not compare span ends or the WIR action node. yaml_contract.rs covers both.

@e54-bot

e54-bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review in ea82ef8. Please re-review.

  1. README.md states Wright 0.41.0 or later in Use and Test, and that older releases refuse the whole package. AGENTS.md says to raise that minimum in the same PR when a rule uses a newer matcher feature.
  2. README.md now says a pin replaces Wright's default rules with the same IDs, that those defaults are native rules today, and that Wright embeds this package from wrightkit/wright#1081 on.

CI pin vs. latest: kept latest per .github/docs/rust-ci.md item 8; the stated minimum covers the floor.

@Teakowa

Teakowa commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Verdict: LGTM

Re-reviewed head ea82ef80c6a9f0f0fe484f7a17bf06393955b7f5 against the two findings from round 1.

  1. Minimum Wright version: fixed. README.md now states "Wright 0.41.0 or later" in Use and Test. AGENTS.md says to raise the floor in the same PR when a rule uses a newer matcher feature. This matches the round-1 measurements: 0.39.2 and 0.39.3 refuse the package (unknown field evidence), and 0.41.0 passes tests/run.sh.
  2. Embedding tense: fixed. README.md now says a pin replaces Wright's default rules with the same IDs, that these are native rules today, and that embedding starts with wrightkit/wright#1081. This matches Wright main docs/cli/lint.md:248-249.

The fix commit ea82ef8 changes only AGENTS.md (+3) and README.md (+11/−7): git diff --stat 1dba2b7 ea82ef8. Rules, fixtures, tests/run.sh, and CI are unchanged, so the round-1 parity and harness results still apply. CI run 42950104501 ("Rule fixtures") is green on ea82ef8 with Wright 0.41.8.

The CI latest vs Issue #1 "pinned release" question stays with the Issue owner, as noted in round 1.

@e54-bot
e54-bot merged commit 08cb2c8 into main Nov 11, 2026
1 check passed
@e54-bot
e54-bot deleted the feat/migrate-native-rules branch November 11, 2026 03:04
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.

Ship min-wait-loop, expensive-loop-check, and nested-binder-lambda with the package maintenance contract

2 participants