Repository navigation
Enforce sparse source comments with Aontu policy controls #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/bin/sh | ||
| set -eu | ||
| cd "$(git rev-parse --show-toplevel)" | ||
| command -v node >/dev/null 2>&1 || { echo "pre-push: Node.js is required for the comment gate" >&2; exit 1; } | ||
| exec node tools/comment-gate.cjs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| name: Source comment policy | ||
| on: [push, pull_request] | ||
| permissions: | ||
| contents: read | ||
| jobs: | ||
| comments: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 | ||
| - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | ||
| with: | ||
| node-version: '24' | ||
| - run: make comments comments-test | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Implementation rationale | ||
|
|
||
| Host transitions are sequential and reconciliation reaches a fixed point eagerly. Reentrant lifecycle transitions are rejected. These properties allow the same lifecycle semantics in runtimes with different concurrency mechanisms. | ||
|
|
||
| Capability providers are ranked by descending version, ascending priority, then declaration position. Point-binding order bands do not rank capabilities: a provider may have several bindings or no bindings. | ||
|
|
||
| Rust drops RefCell borrows before invoking callbacks. Holding a borrow over plugin code can turn a lifecycle operation into a panic. | ||
|
|
||
| Sources: [host](typescript/src/Host.ts), [capability resolution](go/plugin/capability.go), [Rust guide](rust/AGENTS.md). | ||
|
|
||
| Corpus shape validation is separate from JSON generation so optional empty containers retain their assertion meaning. The runner checks cross-field relationships and nonempty test groups. Artifact validation checks that the corpus version marker exists; unification alone can fill an absent marker. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # Source code comment policy | ||
|
|
||
| Adapted from [Aontu ADR-032](https://github.com/aontu-lang/aontu/blob/main/ADR.md#adr-032--code-comments-are-sparse-and-terse-intent-lives-in-names-requirements-live-in-documents). | ||
|
|
||
| Comments are sparse and terse. Use them only for intricate or surprising code: | ||
| why an unobvious form is necessary, or what a maintainer could otherwise break. | ||
| Prefer a precise identifier, named constant, or extracted function to an | ||
| explanation of what the code does. Business rules and requirements belong in | ||
| documents. History belongs in commit messages and issues. | ||
|
|
||
| A line or two is the norm. Delete redundant or stale comments; move durable | ||
| explanations into a design document. A coverage exclusion still needs its short | ||
| justification. Paths, backticked symbols, and ADR numbers must resolve. Avoid | ||
| issue numbers, dates, versions, unverifiable counts, TODO narratives, and | ||
| commented-out code. These rules apply to authored code in every language. | ||
|
|
||
| ## Automated enforcement | ||
|
|
||
| `make comments` runs `tools/comment-gate.cjs`. `make comments-test` runs its | ||
| positive and negative tests, including the repository gate. CI runs both on | ||
| pushes and pull requests. `make hooks` installs the tracked pre-push hook; | ||
| Node.js and Git are required, and a missing Node.js fails the hook. | ||
|
|
||
| The automated scope covers `.ts`, `.go`, `.rs`, `.aon`, and `.aontu`, including | ||
| authored models, test corpora and generator templates. Other languages follow | ||
| the written policy through review. JavaScript build/release tooling is outside | ||
| the automated scope, as in Aontu. Tracked and unignored new files are checked; | ||
| symlinks, dependency directories, compiled output and Rust build artifacts are | ||
| not. `tools/comment-scope.json` lists any additional exclusions with reasons. | ||
| License notices and compiler, lint, formatting and coverage directives remain. | ||
| Generator slot and insertion markers (such as `<[SLOT]>`, `#SecretsImport`, and `EJECT-START`/`EJECT-END`) | ||
| are executable tooling directives and are exempt too. | ||
| Aontu models use `#` line comments; quoted strings and multiline backtick values | ||
| are preserved. Authored `model/target/` files are included. Generated model | ||
| goldens are excluded explicitly through `excludeModels` in the scope config; | ||
| this does not exclude implementation files in the same directories. | ||
|
|
||
| | Rule | Rejected content | | ||
| | --- | --- | | ||
| | `long-block` | More than 5 consecutive comment lines | | ||
| | `dense-file` | More than 12% comment/code lines, when comment lines exceed 8 | | ||
| | `narrative` | First person, change history, reviews, issues, commits, TODOs | | ||
| | `requirements` | Requirement and business-rule vocabulary | | ||
| | `commented-code` | Disabled source code | | ||
| | `count-claim`, `dated-claim`, `issue-ref`, `version-claim` | Unverifiable claims | | ||
| | `stale-path`, `stale-symbol`, `stale-adr` | Unresolved references | | ||
|
|
||
| The checker uses lexical heuristics; passing it does not establish the truth | ||
| of every sentence. Review still checks meaning and whether a comment is needed. | ||
| `node tools/comment-gate.cjs --json` emits findings with a failing exit status; | ||
| `--measure` prints statistics. There is no baseline that accepts existing debt. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit adds a workflow directly, but the repository requires workflow changes from agent sessions to arrive as a
git format-patchplus an applying README underpatch/, 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 👍 / 👎.