Thanks to visit codestin.com
Credit goes to github.com

Skip to content

docs(review-rules): document the merge_system_rule field - #1136

Open
A1oha666 wants to merge 9 commits into
alibaba:mainfrom
A1oha666:docs/document-merge-system-rule
Open

docs(review-rules): document the merge_system_rule field#1136
A1oha666 wants to merge 9 commits into
alibaba:mainfrom
A1oha666:docs/document-merge-system-rule

Conversation

@A1oha666

@A1oha666 A1oha666 commented Sep 2, 2026

Copy link
Copy Markdown

Closes #1133

Summary

The merge_system_rule field has been implemented for a while (ProjectRuleEntry.MergeSystemRule
mergeWithSystemRule in internal/config/rules/system_rules.go), but the review rules guide never mentioned it —
in any of the five locales. The only place it appeared in the repo was skills/open-code-review/SKILL.md, which
most users never read.

This PR documents the field in all five locales of the review rules guide.

Changes

In pages/src/content/docs/{en,zh,ja,ko,ru}/review-rules.md:

  1. Field list — the rules entry now documents {path, rule, merge_system_rule?}, noting the field is
    optional and defaults to false (replace).

  2. New "Merging with the system rule" section — a worked example showing the JSON plus the resulting ocr rules check output, so the ## System-Specific Rules (Mandatory) / ## User-Specific Rules (Mandatory)
    structure is visible. It states that:

    • the system half is resolved per file, so one catch-all **/* entry yields java.md for .java,
      python.md for .py, and default.md for unrecognized extensions;
    • it works in all three user layers (--rule, <repo>/.opencodereview/rule.json, and
      ~/.opencodereview/rule.json);
    • it merges the system layer only — multiple user entries matching the same file still resolve
      first-match-wins, and a matching layer still shadows lower user layers.
  3. New recipe — "Global security rules on top of the built-in per-language rules", covering the common case
    users search for.

Non-English locales are written in their own language (pages/src/content/docs/** is exempt from the
English-only scan per AGENTS.md).

Verification

  • make test passes
  • make check passes (license-check, english-check, go vet)

No Go code changed — docs only.

@CLAassistant

CLAassistant commented Sep 2, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

OpenCodeReview: Review skipped: no items were selected.


The system half is resolved **per file**, from the same embedded table above —
one catch-all `**/*` entry yields `java.md` for a `.java` file, `python.md` for
a `.py` file, and `default.md` for an unrecognized extension.

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.

Suggested change
a `.py` file, and `default.md` for an unrecognized extension.
a `.py` file or a `.ipynb` file, and `default.md` for an unrecognized extension.

Have you actually referenced system_rules.json before submission?

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.

After applying this suggestion, you have to sync it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sorry about that, and thanks for catching it. I've confirmed , applied your suggestion, and synced the fix to all five locales.

@wu21-web wu21-web 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.

When AI is not sure about a word, it just skips entirely.

Since I am a native Chinese speaker, here are my suggestions. Please batch and commit if there is no issues.

Comment thread pages/src/content/docs/zh/review-rules.md Outdated
Comment thread pages/src/content/docs/zh/review-rules.md Outdated
Comment thread pages/src/content/docs/zh/review-rules.md Outdated

@wu21-web wu21-web 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

@NriotHrreion NriotHrreion left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@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.

Nice catch on the gap — the field-level details all match system_rules.go. Three fixes:

1. Sample output is missing its File: line (all 5 locales). rules_cmd.go:70 prints it before Source:, and the two existing samples in the same doc already show it (en 215/226, zh 194/205, ja 175/186, ko 204/215, ru 219/230):

$ ocr rules check src/main/java/com/example/UserService.java
File: src/main/java/com/example/UserService.java
Source: Project (.opencodereview/rule.json)

2. "the same embedded table above" points the wrong way (all 5 locales). The new section sits in ## Rule file format (en ~59); the table is at 161, below it. A link survives future reordering: the same embedded table in [Rule resolution per file](#rule-resolution-per-file).

3. ko: the recipe heading's {#...} is on its own line, so it renders as visible body text. headingId.ts:7 only matches a trailing {#id} on the heading line — otherwise the heading falls back to generateHeadingId(), which strips Hangul entirely and leaves an empty id. That's why all 14 existing ko headings anchor on the same line. Your other new ko heading gets this right.

@lizhengfeng101

Copy link
Copy Markdown
Contributor

and rebase main @A1oha666

@A1oha666
A1oha666 force-pushed the docs/document-merge-system-rule branch from c0d835d to 0424234 Compare September 12, 2026 06:27
A1oha666 and others added 7 commits September 12, 2026 14:51
Polish the zh/ja/ru localizations of the review rules guide:
- zh: reword the five-gate filter as five checks and localize remaining
  English terms (per-file, default-path gate, fallback), fix a heading
  grammar slip, tighten verbs, and normalize dashes/punctuation
- ja: localize the fallback table label
- ru: fix a garbled translation of the per-file filter note and localize
  the fallback label (switching to half-width parentheses for Russian)

Docs only; no code changes.
…ction

Address review feedback:
- Add the missing File: line to the ocr rules check sample output in
  all five locales (rules_cmd.go prints it before Source:)
- Point 'the same embedded table' at the actual location via a link to
  the Rule resolution per file section instead of the wrong 'above'
- Fold the ko recipe heading's {#...} anchor onto the heading line so
  headingId.ts can parse it (a standalone line renders as body text
  and generateHeadingId() strips Hangul, yielding an empty id)

Docs only; no code changes.
@A1oha666
A1oha666 force-pushed the docs/document-merge-system-rule branch from 0424234 to d0ca2b4 Compare September 12, 2026 06:55
The cross-references added in the previous commit broke in ja/ko/ru:
generateHeadingId() only keeps ASCII + Han, so the raw heading text
anchor (#ファイルごとのルール解決, #파일별-규칙-해석,
#разрешение-правила-для-файла) never matches the generated id
(stripped to 解決 or empty).

Add explicit {#rule-resolution-per-file} markers to the ja/ru headings
(following the ko doc's existing convention of explicit anchors on
every heading) and point all three locales' links at it. zh keeps the
auto-generated Han anchor, which survives generateHeadingId().

Docs only; no code changes.
The new ja heading 'システムルールとのマージ' is pure kana, which
generateHeadingId() strips to an empty id — colliding with the two
pre-existing empty ids in the same doc and making the TOC link
unaddressable. Give it an explicit {#merging-with-the-system-rule}
marker, matching the id used by the ko/ru translations of the same
heading. en/zh auto-generate usable ids and are unchanged.

The two remaining ja empty ids and eight ru empty ids pre-date this PR
(upstream/main has the same counts); fixing them is out of scope here.

Docs only; no code changes.
@A1oha666

Copy link
Copy Markdown
Author

@lizhengfeng101 Thanks for the review! I’ve applied all 3 requested fixes (added the missing File: lines across all 5 locales, resolved the localized heading anchors, and fixed the ko inline formatting), along with an extra ja anchor fix caught during the audit—rebased onto main, please take another look whenever you have time!

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.

docs(review-rules): document merge_system_rule in the review rules guide

6 participants