Skip to content

ci: guard the code-comments rule with a grep in the build job - #202

Merged
mmcky merged 2 commits into
mainfrom
claude/busy-dijkstra-oy40fc
Sep 11, 2026
Merged

ci: guard the code-comments rule with a grep in the build job#202
mmcky merged 2 commits into
mainfrom
claude/busy-dijkstra-oy40fc

Conversation

@quantecon-services

@quantecon-services quantecon-services commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #200, which is now merged. This targets main; the diff is one commit, 16 added lines in .github/workflows/ci.yml, and nothing else changes.

Rebuilt on main after #200 was squash-merged. The original branch carried #200's pre-squash commits, whose content is in main under a different SHA, so it was recreated from 6ff8bf5 with only the guard commit re-applied.

Why

#200 added a Code comments section to CONTRIBUTING.md and cleaned the tree to match it. Nothing stops the next contributor reintroducing what it removed, and the point of the rewrite is that this kind of comment goes stale silently. This fails the existing Build & Typecheck job on the framing vocabulary instead.

What it matches, and what it deliberately does not

Phase [0-9] | PLAN.md | parity milestone | open question [0-9]

over app styles plugins scripts tests template.yml tailwind.config.js playwright.config.ts .github/workflows.

  • Bare #NNN is not matched. chore(comments): code comments explain the code, not its history #200's rule permits issue links where the thread carries detail the comment cannot — QuantEcon/mystmd#50, #126, #130, #172, #117 are all kept on purpose. The pattern would also hit every hex colour in styles/quantecon.css, so it would be noise rather than a guard.
  • Prose docs are exempt by path. README.md, docs/, PLAN.md and tests/visual/README.md are written for a reader who wants the project's history and keep it — the scope CONTRIBUTING now states.
  • One letter of each alternative is bracketed (Phas[e], PLA[N]) so this workflow file, which contains the pattern, is not itself a match. The scan covers .github/workflows, so without that the guard fails on itself — it did on the first attempt.

Verification

  • Passes on main as merged.
  • Catches a planted /* Phase 8 */ in styles/rtl.css, and previously a planted // see PLAN.md item 3 in app/revalidate.ts.
  • Does not self-match.
  • ci.yml still parses as YAML, and the step is purely additive — no existing line changed.

Unlike the earlier stacked version of this PR, CI now runs against it: ci.yml triggers on pull_request: branches: [main], so while this targeted chore/code-comments the guard could not exercise itself.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QAy8brFG9x8fXet3AV9dJE

@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-09-11 04:41 UTC

Base automatically changed from chore/code-comments to main September 11, 2026 04:10
@mmcky
mmcky requested a balanced review from Copilot September 11, 2026 04:10
CONTRIBUTING.md's "Code comments" section relies on review to hold. This
fails the build job on the framing vocabulary instead.

Only that vocabulary is matched. Bare `#NNN` is deliberately not matched:
issue links are allowed where the thread carries detail the comment cannot,
and the pattern would hit every hex colour. Prose docs are exempt by path.
One letter of each alternative is bracketed so the workflow file, which holds
the pattern, does not match itself.

Verified: passes on the tree, catches a planted `Phase 7` and a planted
`PLAN.md` reference, does not self-match, and ci.yml still parses. The step
is purely additive.

Split out of the comment PR so that one stays comment- and docs-only, which
is the property its mechanical verification rests on.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QAy8brFG9x8fXet3AV9dJE
@quantecon-services
quantecon-services force-pushed the claude/busy-dijkstra-oy40fc branch from 4f38cf4 to 4db1fea Compare September 11, 2026 04:11
@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

🎭 Visual regression results

passed  41 passed
skipped  12 skipped

Details

stats  53 tests across 2 suites
duration  1 minute, 23 seconds
commit  07d53b2

Skipped tests

mobile-chrome › theme.spec.ts › QuantEcon theme — visual regression › without JavaScript › drawer-opens-without-javascript
mobile-chrome › theme.spec.ts › QuantEcon theme — visual regression › drawer-closes-when-search-opens
mobile-chrome › theme.spec.ts › QuantEcon theme — visual regression › launch-colab
mobile-chrome › theme.spec.ts › QuantEcon theme — visual regression › live-compute-toggle
mobile-chrome › theme.spec.ts › QuantEcon theme — visual regression › live-compute-toggle-absent-without-thebe
mobile-chrome › theme.spec.ts › On this page outline › outline-pinned-and-nested
mobile-chrome › theme.spec.ts › On this page outline › outline-tracks-scroll
mobile-chrome › theme.spec.ts › On this page outline › outline-unnumbered
mobile-chrome › theme.spec.ts › On this page outline › outline-within-viewport
mobile-chrome › theme.spec.ts › Meta/SEO and notebook output › social-meta
mobile-chrome › theme.spec.ts › Meta/SEO and notebook output › stderr-collapsed
mobile-chrome › theme.spec.ts › Site options reach the theme › site-options

Copilot AI 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.

🟡 Changes recommended

The guard scans tests/visual/README.md even though its own comment and CONTRIBUTING.md declare that file exempt, so permitted history in it would trigger a false CI failure (fixable with --exclude=README.md, plus -I to skip binary snapshots).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adds a lightweight CI guard that enforces the "Code comments" rule introduced in its base PR (#200): comments should describe what the code does, not narrate project history. A new Build & Typecheck step greps the code tree for framing vocabulary (Phase N, PLAN.md, parity milestone, open question N) and fails the build if any is found. Because this PR is stacked on chore/code-comments, the diff against main also carries all of #200's comment-only rewrites; the sole substantive delta of this PR is the 16-line ci.yml step.

I verified the guard passes on the current tree, the bracket trick prevents the workflow file from matching itself, and the planted-example behavior works as described. The one concrete issue is that the scan does not actually exempt tests/visual/README.md, contradicting both its own comment and CONTRIBUTING.md.

Changes:

  • New ci.yml step "No project framing in code comments" that greps a fixed set of paths for framing vocabulary and fails on a match.
  • Inherited from #200: comment/doc rewrites across app/, styles/, tests/, workflows, and root config to drop project-history framing.
  • CONTRIBUTING.md gains the "Code comments" rule (also inherited context) that this guard enforces.
File summaries
File Description
.github/workflows/ci.yml The PR's substantive change: adds the grep guard step; also renames the FOUC step. Guard does not exempt tests/visual/README.md despite claiming to.
CONTRIBUTING.md Documents the "Code comments" rule and the "exempt by path" scope the guard is meant to implement.
styles/quantecon.css, styles/rtl.css, styles/mpl-widget.css, styles/app.css Comment rewrites removing Sphinx/phase framing and correcting px/contrast figures (from #200).
app/* (root.tsx, seo.ts, types.ts, i18n.ts, links.ts, renderers.tsx, revalidate.ts, routes, components) Comment-only rewrites dropping phase/issue framing (from #200).
tests/** (specs, fixtures, unit tests) Comment/title/fixture-string rewrites dropping framing; tests/visual/README.md remains prose history (relevant to the guard's exemption gap).
template.yml, tailwind.config.js, playwright.config.ts, Makefile, .npmrc, plugins/git-metadata.mjs, scripts/relative-css-asset-urls.mjs, workflows Comment rewrites removing history framing (from #200).
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/ci.yml Outdated
The guard contradicted the rule it enforces. CONTRIBUTING.md exempts prose
docs by name, "the test suite's own README.md" included, and the step's own
comment repeats that -- but the scan recurses through `tests`, so
tests/visual/README.md was scanned like any source file. Confirmed by
appending a permitted history line to it: the step failed. It carries eight
issue references today, so it is exactly the file the exemption is for.

--exclude=README.md is scoped to READMEs, not all Markdown: the fixture
`.md` files under tests/visual/fixture are still scanned, verified with a
planted `<!-- Phase 9 -->`.

-I skips the 29 binary PNG snapshots under tests/visual/__snapshots__.
Nothing matches this pattern in them today, but grep reports "Binary file
... matches" and exits 0 on a stray byte hit, which would fail the step for
no reason -- a pattern earlier in this work did match those PNGs.

Verified: passes clean, exempts the README, still catches a planted
`Phase 8` in styles/rtl.css and `Phase 9` in a fixture, does not self-match,
and ci.yml still parses.

Reported by the Copilot reviewer on #202.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QAy8brFG9x8fXet3AV9dJE
@mmcky
mmcky merged commit d7ec6cd into main Sep 11, 2026
4 checks passed
@mmcky
mmcky deleted the claude/busy-dijkstra-oy40fc branch September 11, 2026 04:41
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.

4 participants