Coding Guideline Review
Purpose
Provide a consistent, evidence-based review process for coding guideline PRs, aligned with repository style rules, validation checks, and authoritative Rust documentation. Reviews must hold a high bar for correctness because these guidelines are used in safety-critical software.
Inputs
- •Required:
PR_URL: <url>
Steps
- •Fetch PR context and changes.
- •Use
gh pr viewto capture title, body, labels, reviewers, and status checks. - •Use
gh pr diffto identify the guideline files and any non-guideline changes. - •Confirm the PR body includes
closes #<id>when applicable.
- •Use
- •Verify CI and status checks.
- •Ensure
buildandcheck_typosare successful. - •Note Netlify and header/redirect checks (informational unless policy says otherwise).
- •If anything fails, record the failure reason and classify it (spec lock diff, rust-example issues, inline URLs, bibliography problems, invalid FLS IDs).
- •Ensure
- •Validate placement and file structure.
- •Guidelines belong under
src/coding-guidelines/<chapter>/gui_<id>.rst.incwith the chapter index updated. - •The chapter should align with the FLS section for the guideline.
- •If a guideline replaces an existing one, the old guideline should be retained as
status: retiredor a migration rationale must be provided.
- •Guidelines belong under
- •Check guideline structure and required fields.
- •Required fields are present:
category,status,release,fls,decidability,scope,tags. - •Field values are valid:
- •
category: mandatory, required, advisory, disapplied - •
status: draft, approved, retired - •
decidability: decidable, undecidable - •
scope: module, crate, system
- •
- •Validate field choices against
src/process/style-guideline.rstand.github/ISSUE_TEMPLATE/CODING-GUIDELINE.yml. - •Every field choice must have a justification or citation in
claims.md. - •Title and amplification are normative and use RFC 2119 language (MUST, SHOULD, MAY) when appropriate.
- •Exceptions are explicit and only used when needed.
- •Required fields are present:
- •Verify FLS linkage and scope alignment.
- •
:fls:uses a valid FLS paragraph ID and matches the guideline scope. - •The guideline content maps to the referenced FLS paragraph without going beyond it.
- •If multiple FLS paragraphs are needed, split into multiple guidelines.
- •
- •Enforce citations and bibliography rules.
- •No inline URLs in guideline text.
- •Use
:std:for standard library, core, and alloc references. - •Use
:cite:and:bibentry:for external sources (Rust Reference, CERT, MISRA, etc.). - •Citation keys are UPPERCASE-WITH-HYPHENS, 50 characters max, and consistent for identical URLs across guidelines.
- •Validate technical correctness against authoritative sources.
- •Validate all claims against the Rust Reference, Unsafe Code Guidelines, and std/core/alloc docs.
- •Use additional authoritative sources as needed (Rustonomicon, RFCs, edition guide, rustc dev guide, compiler behavior notes).
- •Claims include guideline text, rationale, example prose, and inline code comments.
- •If a claim cannot be verified or appears incorrect, treat it as a blocking issue.
- •Map claims to sources in
claims.md.- •Record every claim with its location, text, type, and supporting source.
- •Use normative sources when available; otherwise use authoritative non-normative sources (FLS, UCG, rustc dev guide) or referenced standards (CERT, MISRA, etc.).
- •Include every field choice (category, status, release, fls, decidability, scope, tags) as a claim with justification.
- •Any unverified claim is a blocking issue.
- •Review rust-example usage and correctness.
- •Each guideline includes at least one non-compliant and one compliant example.
- •Examples use
.. rust-example::(notcode-block). - •Non-compliant examples only violate the current guideline; compliant examples adhere to all guidelines.
- •Directive options match expected behavior:
- •
:compile_fail:for compile errors - •
:should_panic:for runtime panics - •
:no_run:for compile-only examples
- •
- •Avoid warnings or add
:warn: allowwith rationale. - •Unsafe code must include
:miri:(useexpect_uborskipwith justification as needed).
- •Check cross-guideline consistency.
- •If overlapping with existing rules, link to them and describe the relationship (stronger, weaker, subset).
- •If the guideline is intended as a replacement, ensure cross-references are updated accordingly.
- •Validate external standard coverage claims.
- •If the PR claims to cover CERT, MISRA, or similar standards, verify the guideline text actually covers those requirements.
- •Include citations and note any limitations or partial coverage explicitly.
- •Determine verdict (approve, comment, or request changes).
- •Approve only if CI is green and correctness is verified with no blocking issues.
- •Request changes if any blocking issue exists or correctness cannot be verified.
- •Comment only when issues are non-blocking or CI failures are clearly infra-related.
- •Deliver review artifacts under
$OPENCODE_CONFIG_DIR/reviews.
- •
Create
pr-<number>-<short-slug>/summary.mdfor the final verdict and rationale. - •
Create
comment-001.md,comment-002.md, etc., for each review comment. - •
If there are zero issues, only create
summary.md. - •
Each comment file uses this template and includes GitHub suggestion blocks for edits:
md### Location File: <path> Line: <line-number> Snippet: `<leading text from the line>` ### Type Blocking | Non-blocking | Question ### Comment <comment text, with references> ```suggestion <replacement or insertion text> ```
- •
Use GitHub suggestion blocks whenever text should be added or replaced.
- •
Create
claims.mdwith a claims-to-sources map and summary table:md# Claims Map PR: <number> Guideline IDs: <gui_...> Reviewer: <name> Date: <yyyy-mm-dd> ## Summary Table | ID | Status | Type | Location | Source Kind | Notes | | --- | --- | --- | --- | --- | --- | | C-001 | Verified | Normative | <path>:<line> | Reference | <short note> | ## Legend - Type: Normative | Rationale | Example-prose | Example-comment | Field-choice - Source kind: Reference | FLS | UCG | Rustc-dev-guide | Standard (CERT/MISRA/...) | Other - Status: Verified | Unverified | Disputed ## Claims ### C-001 Location: - File: <path> - Line: <line> - Snippet: `<leading text>` Claim: - Text: "<verbatim claim>" - Type: Normative Source: - Kind: Reference - Citation: <link or :cite: key> - Notes: <short explanation mapping claim to source> Status: - Verified
Output
- •
summary.mdwith verdict, CI status, blocking issues, and correctness evidence. - •One
comment-###.mdper review comment using the required template and suggestion blocks. - •
claims.mdwith a claims-to-sources map and summary table.