Skip to content

doc: add a code review checklist for reviewers and coding agents - #15

Open
ppannuto-claude wants to merge 2 commits into
ppannuto:masterfrom
ppannuto-claude:tock-code-review-skill
Open

doc: add a code review checklist for reviewers and coding agents#15
ppannuto-claude wants to merge 2 commits into
ppannuto:masterfrom
ppannuto-claude:tock-code-review-skill

Conversation

@ppannuto-claude

Copy link
Copy Markdown

Staging branch for review comments. Adds doc/code-review/ — a review checklist for a Tock change set, aimed at both human reviewers and coding agents.

doc/CodeReview.md covers the process (who reviews, upkeep vs. significant, votes). This covers the content of a review, which was not written down anywhere.

File Contents
doc/code-review/README.md When to run it, the 7-step procedure, reporting rules
mechanical-checks.md The make targets, picking which board to build, license headers
subsystem-criteria.md Per-tree criteria (kernel/HIL/capsules/chips/boards/arch/libraries) + ripple checks
bug-patterns.md 20 recurring defect classes: signature, how to confirm, fix

Hooked into AGENTS.md (new "Reviewing Your Own Work" section) and indexed in doc/README.md.

Two commits on purpose: the first adds it under .claude/skills/, the second moves it to doc/ and de-Claude-ifies it. Squash on merge.

Things worth commenting on

  1. Placement. doc/code-review/ was chosen to match doc/wg, doc/reference, doc/syscalls. Easy to move.

  2. Safety comments. Written as "act as if missing_safety_doc / undocumented_unsafe_blocks were denied tree-wide," citing kernel: Deny clippy::missing_safety_doc for the kernel crate tock/tock#5003 for the kernel crate. Verified against clippy while writing: ### Safety does satisfy missing_safety_doc (any heading level), and // safety: satisfies undocumented_unsafe_blocks (case-insensitive). So the ~34 lowercase occurrences and the ### Safety wording in AGENTS.md / doc/CodeReview.md are style deviations, not lint failures. Separate PRs, per the note below.

  3. clippy.toml comment appears stale. It says missing_safety_doc is "allowed in Tock, except kernel", but the root Cargo.toml sets it to allow and kernel/Cargo.toml is workspace = true with no override — so it is allowed in the kernel too until kernel: Deny clippy::missing_safety_doc for the kernel crate tock/tock#5003 lands. Not touched here.

  4. static_init! exception. "Board crates only" has one standing exception in-tree: arch/x86/src/segmentation.rs and interrupts/idt.rs call it from unsafe fn init() where call-once is a documented precondition. Documented as the bar a non-board use must meet, rather than as a violation — worth confirming that is the intended reading.

  5. AI-policy paragraph in README.md cites .github/CONTRIBUTING.md as-is: disclosure + contributor review. It does not assume the stricter "no AI-written prose" wording, which is not currently in master.

  6. Scope. The bug-patterns.md list is 20 items drawn from the docs plus recurring failure modes. Additions and deletions both welcome — particularly whether anything there is too speculative to keep.

Checks run: make licensecheck, make format-check, tools/ci/check-for-readmes.sh. Markdown only, so clippy/syntax are unaffected. No <!-- toc --> markers, so ci-job-markdown-toc skips these files.

ppannuto-claude and others added 2 commits August 28, 2026 15:44
Adds `.claude/skills/tock-code-review/`, a repository-scoped skill that
performs a heavy-weight review of a change set against Tock's conventions
and its recurring defect classes.

The rules Tock cares about are largely invisible to rustc and clippy: they
are properties of the execution model (no allocation, no unwinding,
callbacks only from interrupts or deferred calls, static resource
ownership) rather than of the type system. Code that violates them compiles
cleanly and boots. This skill collects those rules, along with the
per-subsystem review criteria already written down in doc/CodeReview.md,
into a procedure an assistant can follow at a milestone or before a
submission.

  SKILL.md                         scope, procedure, and the requirement to
                                   verify a finding before reporting it
  references/mechanical-checks.md  the make targets, which boards a given
                                   change has to be built into, license
                                   headers
  references/subsystem-criteria.md kernel/HIL/capsules/chips/boards/arch/
                                   libraries criteria, plus the ripple
                                   checks a change fans out along
  references/bug-patterns.md       twenty recurring defect classes, each
                                   with how to spot it, how to confirm it,
                                   and the fix

The skill is deliberately scoped to run at milestones and before
submission, not on every edit.

Two points are documented from the tree rather than from the docs, since
they disagree: new code uses `/// # Safety` and `// SAFETY:` (the prose in
AGENTS.md and doc/CodeReview.md says `### Safety`, which appears nowhere in
the tree), and arch/x86 is the standing exception to "static_init! only in
board crates", where call-once is a documented safety precondition instead.

Per AGENTS.md, the skill instructs assistants to deliver findings as
technical points and not to draft PR or review prose for the contributor.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Two corrections to the checklist added in the previous commit.

**It was Claude-specific.** It lived in `.claude/skills/` and led with the
YAML frontmatter that Claude Code uses to discover and auto-trigger a
skill. Tock has an AGENTS.md and deliberately no CLAUDE.md, and nothing in
the checklist's content is tied to one assistant. Moved to
`doc/code-review/`, alongside the other subdirectories under `doc/`, with
README.md as the entry point and the frontmatter dropped. Discovery now
runs through AGENTS.md, which every agent reads, and through doc/README.md
for human reviewers -- who are as much the audience as any tool.

**The safety-comment rule was stated as a style preference.** It described
`/// # Safety` and `// SAFETY:` as "the in-tree convention" and noted that
AGENTS.md and doc/CodeReview.md say `### Safety` instead, advising readers
to match the tree. That framing is wrong in both directions:

- `### Safety` is not the error the previous commit implied. Verified
  against clippy: `missing_safety_doc` accepts a `Safety` heading at any
  level, and `undocumented_unsafe_blocks` matches the `SAFETY:` prefix
  case-insensitively, so `// safety:` passes as well. The prose in
  AGENTS.md is not describing a lint violation.
- More importantly, "match the tree" is the wrong instruction. Clippy's
  lints define the convention, and new code should be written as if they
  were denied tree-wide. That they are currently `allow` -- and that
  `undocumented_unsafe_blocks` sits in the `restriction` group -- is a
  transitional state rather than permission. tock#5003 makes
  `missing_safety_doc` a hard error for the kernel crate, headed tree-wide.

Both files now say that, and note the consequence for a reviewer: until
those lints land, nothing in CI checks that unsafe code is documented at
all, so review is the only thing that does.

Also corrected the AI-policy paragraph. It asserted that Tock's policy
forbids AI-written prose addressed to humans; the policy in
.github/CONTRIBUTING.md requires disclosure and contributor review, and
says nothing of the sort. It now cites what the policy actually says.

Added a step to the procedure: unrelated convention violations turned up
during a review belong in their own pull request, not folded into the
change under review.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant