Skip to content

docs(review-rules): list every built-in rule mapping in all five locales - #1785

Merged
lizhengfeng101 merged 2 commits into
alibaba:mainfrom
SU-AN-coder:docs/review-rules-pattern-table
Nov 10, 2026
Merged

lizhengfeng101 merged 2 commits into
alibaba:mainfrom
SU-AN-coder:docs/review-rules-pattern-table

Conversation

@SU-AN-coder

@SU-AN-coder SU-AN-coder commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

The review-rules guide publishes the embedded system_rules.json path_rule_map as a pattern → rule-document table (Rule resolution per file), and says it is shown in relative matching order. That table is hand-maintained in five locales and had fallen behind: 8 of the 57 patterns are missing from every locale (en, zh, ja, ko, ru), so the guide never tells a reader that these languages resolve to a dedicated rule document instead of default.md:

glob rule doc
**/*.pug pug.md
**/*.nix nix.md
**/*.{hs,lhs} haskell.md
**/*.{nim,nims,nimble} nim.md
**/*.swift swift.md
**/*.zig zig.md
**/*.{ml,mli} ocaml.md
**/*.{re,rei} ocaml.md

Every one of those 8 extensions is already in internal/config/allowlist/supported_file_types.json, mapped in internal/config/rules/system_rules.json, and backed by an embedded rule document — the existing integrity tests in internal/config/rules/system_rules_test.go check that direction (referenced doc exists, no orphan doc, mapped extension is allowlisted). Only the guide was out of step with the mapping it documents.

This PR adds the missing rows in all five locales (in the same relative order the rows already follow) and drops the Selected wording from the sentence above the table, which is now exhaustive.

TestReviewRulesGuideListsEverySystemRulePattern is the guard that stops this recurring. It reads the embedded system_rules.json and the five pages/src/content/docs/<locale>/review-rules.md pages, and reports three kinds of drift per locale:

  • a glob in the embedded map with no row on the page;
  • a row naming a rule document other than the one the map points at (a translated row can name the wrong document just as easily as it can go missing);
  • a row whose glob is not in the embedded map at all.

Relative row order is deliberately not asserted: the patterns are disjoint, so a reordered row cannot change which rule a file resolves to.

Enumerating the gap

A script comparing the two sources before the change:

system_rules.json path_rule_map: 57 patterns
en rows: 49   zh rows: 49   ja rows: 49   ko rows: 49   ru rows: 49
glob in the map with no row in any locale: 8 (listed above)
row in a locale whose glob is not in the map: 0
row naming a rule doc other than the map's value: 0

Not changed here

Two rows sit in a different relative order than system_rules.json in all five locales: **/*.{glsl,hlsl,wgsl,metal} is listed before **/*.{v,sv,vh}, and **/*.R before **/*.{cpp,cc,cxx,hpp,hxx}. The patterns are disjoint and matching is first-match-wins, so resolution is unaffected; I left the page's grouping alone rather than reorder rows in a documentation-only change. Say the word and I will line them up and assert order in the same guard.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

No Go production code changes: the system_rules.json mapping, the resolver and the file filter are untouched. The added file is a test.

How Has This Been Tested?

  • make test passes locally
  • Manual testing (describe below)

The new guard fails on the pre-change docs, one failure per missing glob per locale (40 in total):

$ go test ./internal/config/rules -run TestReviewRulesGuideListsEverySystemRulePattern -count=1
--- FAIL: TestReviewRulesGuideListsEverySystemRulePattern (0.00s)
    --- FAIL: TestReviewRulesGuideListsEverySystemRulePattern/en (0.00s)
        rule_docs_table_test.go:94: ../../../pages/src/content/docs/en/review-rules.md does not list "**/*.{ml,mli}" (ocaml.md)
        ... 7 more for en, and 8 each for zh, ja, ko, ru
FAIL	github.com/alibaba/open-code-review/internal/config/rules	0.005s

and passes after the change:

$ go test ./internal/config/rules -run TestReviewRulesGuideListsEverySystemRulePattern -count=1 -v
--- PASS: TestReviewRulesGuideListsEverySystemRulePattern (0.00s)
    --- PASS: TestReviewRulesGuideListsEverySystemRulePattern/en (0.00s)
    --- PASS: TestReviewRulesGuideListsEverySystemRulePattern/zh (0.00s)
    --- PASS: TestReviewRulesGuideListsEverySystemRulePattern/ja (0.00s)
    --- PASS: TestReviewRulesGuideListsEverySystemRulePattern/ko (0.00s)
    --- PASS: TestReviewRulesGuideListsEverySystemRulePattern/ru (0.00s)
ok  	github.com/alibaba/open-code-review/internal/config/rules	0.004s

Each assertion was checked by breaking the page and watching it fire, one direction at a time, then restoring:

row for `**/*.pug` deleted from en/review-rules.md:
    en/review-rules.md does not list "**/*.pug" (pug.md)

that row repointed at `zig.md`:
    en/review-rules.md lists "**/*.pug" as "`zig.md` — Pug templates.", want pug.md

a row added for `**/*.txt`:
    en/review-rules.md lists "**/*.txt", which is not in system_rules.json

After restoring the page, the guard is green again.

Gates on the final commit:

$ make check
All source files have valid license headers.
No unapproved non-English text in 795 scanned source files.
...
check passed

$ go test -race -count=1 ./...
ok  github.com/alibaba/open-code-review/cmd/opencodereview  17.170s
ok  github.com/alibaba/open-code-review/internal/config/rules  1.525s
... (all 25 packages ok)

The translation-sync guardrail was run as well (node scripts/github-actions/check-translation-sync.test.js, and check-translation-sync.js readmes), both green; all five locales are edited symmetrically in this PR.

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA
  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

AI/LLM disclosure: the change and the guard test were drafted by an AI coding assistant (Hermes Agent, model deepseek-v4-flash). The account owner read the entire diff line by line, independently re-ran the enumeration, the three broken-page checks and the gates quoted above, and is responsible for the content. Commits are not attributed to the tool.

CLA: the license/cla check reports it as signed for this account.

Related Issues

No issue: the gap was found by comparing the guide against the embedded mapping rather than from a report. I will file a documentation issue if you would rather have this tracked that way before merge.

Relative to the open #1541 (docs(review): correct the default exclude list and test it against the json), which does the same thing for the default_exclude_patterns.json list on the same page: this PR touches only the pattern → rule table, so the two do not overlap.

Eight patterns of the embedded system_rules.json path_rule_map had no row in
the review-rules guide's pattern table: pug, nix, Haskell, Nim, Swift, Zig and
the two OCaml/ReasonML patterns. The table is the published form of the mapping
and the page claims to show it in matching order, so a reader could not tell
that those languages resolve to a dedicated rule document instead of default.md.

Add the missing rows to en, zh, ja, ko and ru, and drop the "Selected" wording
above the table, which is now exhaustive.

TestReviewRulesGuideListsEverySystemRulePattern keeps the table and the embedded
map in step: every mapped glob must be listed, the rule document named on the
row must be the one the map points at, and a row for a glob absent from the map
is an error as well.
@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review skipped: no items were selected.

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

2 participants