Skip to content

Enforce sparse source comments with Aontu policy controls - #44

Merged
rjrodger merged 1 commit into
mainfrom
chore/comment-policy
Sep 18, 2026
Merged

rjrodger merged 1 commit into
mainfrom
chore/comment-policy

Conversation

@rjrodger

Copy link
Copy Markdown
Contributor

Adds Aontu ADR-032's sparse-comment policy and removes prohibited prose, stale references and commented-out code. Durable rationale lives in Markdown; license notices, coverage/compiler directives and executable generator markers are preserved.

The standalone checker covers TypeScript, Go, Rust, .aon and .aontu, including authored models, test corpora and generator templates. It runs through Make, applicable npm test commands, a tracked pre-push hook and a GitHub Actions workflow with pinned actions. Generated goldens and vendored snapshots have explicit exclusions. Regression tests exercise both acceptance and rejection, including CLI and hook failures for new files.

Validation:

  • make comments comments-test: passed, including all 9 control tests.
  • git diff --check: passed.
  • TypeScript build/test, Go tests and Rust tests.
  • Shared corpus freshness and shape checks, including negative probes.

Adopt Aontu ADR-032, clean existing source comments, and enforce the policy through tests, CI and pre-push hooks. Preserve executable directives and move durable rationale into Markdown.

Validation: make comments comments-test (9 tests); git diff --check. Package and corpus validation is recorded in the PR description.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-18T11:46:25.449423Z ea9d635 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@rjrodger
rjrodger merged commit 43acbf2 into main Sep 18, 2026
30 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea9d6350b4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -0,0 +1,13 @@
name: Source comment policy

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Deliver the workflow through patch/

This commit adds a workflow directly, but the repository requires workflow changes from agent sessions to arrive as a git format-patch plus an applying README under patch/, because the supported credentials cannot push .github/workflows/. Move this addition to that delivery mechanism; otherwise the changeset cannot be delivered through the supported path.

AGENTS.md reference: AGENTS.md:L231-L238

Useful? React with 👍 / 👎.

Comment thread tools/comment-gate.cjs
]

const PATH_RE = /\b((?:[\w.-]+\/)+[\w.-]+\.(?:ts|go|md|tsv|cjs|mjs|js|json|aontu|aon|abnf|yml|sh))\b/g
const ADR_RE = /\bADR-(\d{3})\b/g

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Recognize the repository's actual ADR identifiers

When a source comment cites this repository's ADR-1 through ADR-4 form, this three-digit-only regex ignores it completely. In addition, adrs() indexes a nonexistent root ADR.md rather than docs/ADR.md, so merely widening this regex would mark every valid citation stale. As a result, the new stale-adr rule cannot validate any actual repository ADR citation; accept unpadded IDs and index the real ADR file.

AGENTS.md reference: AGENTS.md:L344-L348

Useful? React with 👍 / 👎.

Comment thread tools/comment-gate.cjs
Comment on lines +157 to +159
const regexStart = lang === 'ts' && (!/[\w$)\]]/.test(prev) ||
/\b(?:return|throw|yield|case)\s*$/.test(text.slice(Math.max(0,i-30),i)))
if (c === '/' && regexStart) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Handle postfix division before regex literals

For valid TypeScript such as const z = x++ / y // TODO: fix this, prev is +, so the division slash is classified as the start of a regex and the first slash of the real line comment is consumed as its closing delimiter. The lexer consequently reports no comment and the prohibited TODO passes the gate; distinguish postfix ++/-- expressions from regex-start contexts.

AGENTS.md reference: AGENTS.md:L344-L348

Useful? React with 👍 / 👎.

Comment thread tools/comment-gate.cjs
Comment on lines +21 to +22
const DIRECTIVE_RE =
/^(#!|\/\/\s*(EJECT-(?:START|END)|<\[|#[A-Z][\w-]*\b|go:|nolint|@ts-|eslint|prettier|c8 |istanbul|coverage:ignore|covergate:allow|\/\s*<reference)|\/\*\s*([@#]__PURE__|[@#]__NO_SIDE_EFFECTS__|node:coverage|eslint|c8|istanbul|prettier))/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restrict exemptions to known insertion markers

The generic #[A-Z][\w-]* alternative exempts every comment beginning with an uppercase hash token, not just executable markers such as #SecretsImport. Consequently ordinary violations such as // #TODO: fix this or // #NARRATIVE We fixed the old code bypass every rule and do not count toward density; enumerate the supported markers or otherwise validate that the token is an actual tooling directive.

AGENTS.md reference: AGENTS.md:L344-L348

Useful? React with 👍 / 👎.

Comment thread tools/comment-gate.cjs
},
]

const PATH_RE = /\b((?:[\w.-]+\/)+[\w.-]+\.(?:ts|go|md|tsv|cjs|mjs|js|json|aontu|aon|abnf|yml|sh))\b/g

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate paths to every port's source files

The path matcher omits extensions used by most ports, including .py, .rb, .php, .java, .cs, and others. A checked comment such as // See python/voxgig_plugin/no_such_file.py therefore produces no stale-path finding, while an equivalent missing .go path does, allowing stale cross-port references to remain green; path validation should not depend on this partial target-extension allowlist.

AGENTS.md reference: AGENTS.md:L344-L348

Useful? React with 👍 / 👎.

Comment thread tools/comment-gate.cjs
Comment on lines +65 to +67
const model = /\.(aon|aontu)$/.test(rel)
return SOURCE_EXTS.some((ext) => rel.endsWith(ext)) &&
!rel.split('/').some((part) => SKIP_DIRS.has(part) && !(model && part === 'target' && /(^|\/)model\/target\//.test(rel))) &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include implementation files under model/target

For an authored file such as model/target/implementation.ts, model is false because it is based on the extension, so the target directory exclusion drops the file even though .ts is otherwise in scope. The same happens to .go and .rs implementation helpers placed beside generated models, leaving their comments completely unchecked; make the model/target/ exception depend on the path and reserve excludeModels for generated model files.

AGENTS.md reference: AGENTS.md:L344-L348

Useful? React with 👍 / 👎.

Comment thread tools/comment-gate.cjs
Comment on lines +358 to +359
const density = scan.codeLines === 0 ? 0 : commentLines / scan.codeLines
if (commentLines > DENSITY_FLOOR_LINES && density > MAX_DENSITY) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Treat comment-only source files as maximally dense

When a source file has no code lines, this assigns density zero regardless of how many comments it contains. A file with nine or more one-line comments separated by blank lines therefore avoids both long-block and dense-file and can grow as arbitrary prose while the gate remains green; once the comment floor is exceeded, zero code lines should be treated as a density violation rather than 0%.

AGENTS.md reference: AGENTS.md:L344-L348

Useful? React with 👍 / 👎.

Comment thread tools/comment-gate.cjs
Comment on lines +58 to +59
const CODE_SHAPED_RE =
/^\s*(?:(?:const|let|var|func|function|type|class|interface|import|export|package|return|if|for|while|switch|case|await|throw|new|await)\b(?=[^\n]*[;{}()=[\]])|[\w$.[\]]+\s*(?::=|\+=|=[^=])|[\w$.]+\([^)]*\)\s*[;{]?\s*$|[})\]];?\s*$)/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Detect commented-out Rust declarations

The shared code-shaped pattern includes TypeScript and Go declaration keywords but omits ordinary Rust forms. As a result, comments such as // fn disabled() {}, // pub fn disabled() {}, // struct Disabled {}, and // use crate::foo; produce no commented-code finding even though .rs files are explicitly scanned; add Rust declaration and import forms to the language-aware check.

AGENTS.md reference: AGENTS.md:L344-L348

Useful? React with 👍 / 👎.

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