Repository navigation
GH-1453: Add AGENTS.md with rules for AI coding agents #1470
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
Open
krickert
wants to merge
2
commits into
main
Choose a base branch
from
feat/GH-1453-agents-md
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+110
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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,110 @@ | ||
| <!-- | ||
| Licensed to the Apache Software Foundation (ASF) under one or more | ||
| contributor license agreements. See the NOTICE file distributed with | ||
| this work for additional information regarding copyright ownership. | ||
| The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| (the "License"); you may not use this file except in compliance with | ||
| the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| --> | ||
|
|
||
| # Notes for AI coding agents | ||
|
|
||
| Short rules for agents working on Apache OpenNLP. Human contributors follow | ||
| the same rules. | ||
|
|
||
| ## Layout | ||
|
|
||
| - `opennlp-api`: the public interfaces and shared types such as `ParamChecks`. | ||
| - `opennlp-core`: `opennlp-runtime` (the components), `opennlp-ml` (the shared | ||
| `opennlp-ml-commons` plus the maxent, perceptron, naive Bayes and libsvm | ||
| implementations, and `opennlp-dl` and `opennlp-dl-gpu` for ONNX models), | ||
| `opennlp-formats`, `opennlp-cli` and `opennlp-model-resolver`. | ||
| - `opennlp-tools`: the end-user toolkit that bundles the core modules. | ||
| - `opennlp-extensions`: Morfologik, spell checking and UIMA. | ||
| - `opennlp-docs`: the manual in DocBook (`src/docbkx`). | ||
| - `opennlp-eval-tests`: evaluations on reference corpora (see Tests). | ||
| - `opennlp-distr`: the binary and source distributions. | ||
|
|
||
| ## Policy | ||
|
|
||
| - AI tools may help write code. The committer reviews every line, can explain | ||
| it, and is responsible for it. | ||
| - When AI contributed to a commit that a human authored and edited, disclose it | ||
| with a `Co-authored-by:` trailer naming the tool and its version and the model | ||
| and its version, following the | ||
| [ASF generative tooling guidance](https://www.apache.org/legal/generative-tooling.html). | ||
| The human is the author and signs off the commit (`git commit -s`). | ||
| - Agents do not open pull requests, post comments, file issues or reply to | ||
| reviewers on their own. A human writes each message. Quoted AI output is | ||
| marked as such and accompanied by the human's comment. | ||
| - Contributors who need AI translation, because English is not their first | ||
| language or for accessibility, quote and attribute the AI text and include | ||
| the original wording when possible. | ||
| - Never include third-party code or data without a compatible license. | ||
| - When in doubt, ask on GitHub Discussions or dev@opennlp.apache.org. | ||
|
|
||
| ## Build | ||
|
|
||
| - JDK 21 and `./mvnw`. With `-pl`, add `-am`. | ||
| - Run `./mvnw verify` on the touched modules before proposing a change; | ||
| checkstyle and forbiddenapis run there. | ||
| - Do not introduce new dependencies without a discussion and approval. | ||
|
|
||
| ## Code | ||
|
|
||
| - No regular expressions in production code: no `java.util.regex`, | ||
| `String.split`, `matches`, `replaceAll`. Scan with an index or code points. | ||
| - Unicode character sets by default, not ASCII unless a standard feature requires it. | ||
| - Use existing helpers before writing new ones. Check the JDK, then | ||
| `ParamChecks`, `StringUtil`, `UnicodeWhitespace` and the helpers of the | ||
| package you work in. A second copy of a helper is a bug. | ||
| - Case mapping and trimming go through `StringUtil` | ||
| (`toLowerCase`, `toUpperCase`, `trimUnicodeWhitespace`), never the | ||
| locale-sensitive `String` methods. | ||
| - Whitespace: define what counts (ASCII, Unicode, a single space) and use the | ||
| matching helper or constant. Do not hard-code `' '` or `"\\s+"`. | ||
| - Formatting: two-space indents in Java, no tabs, no trailing whitespace, | ||
| files end with a newline. Match the indentation of the surrounding docbkx. | ||
| - Reject bad arguments at the public API with `IllegalArgumentException` via | ||
| `ParamChecks`; never NPE from `Objects.requireNonNull`. | ||
| - Malformed input data throws `InvalidFormatException`. | ||
| - Name repeated literals as constants. Do not allocate in hot loops. | ||
| - Serializable singletons need `readResolve()`; changed Serializable classes | ||
| need a new `serialVersionUID`. | ||
|
|
||
| ## Javadoc and comments | ||
|
|
||
| - Every new or changed method gets short, accurate Javadoc. Overrides use | ||
| `{@inheritDoc}`. Write `@throws X Thrown if ...`. New public types get | ||
| `@since`. | ||
| - Describe the contract, not the history. No "replaces the old regex", | ||
| issue numbers, or design narrative in source; that goes in the issue. | ||
| - No em dashes. | ||
| - Use the terms the code and the manual already use; do not invent new ones. | ||
|
|
||
| ## Tests | ||
|
|
||
| - Test first for behavior changes: the test fails before the fix. | ||
| - Many inputs go in a `@ParameterizedTest`, not a loop. | ||
| - Reuse shared fixtures instead of copying helpers into each test class. | ||
| - Assert exception type and message. Do not reimplement the code under test | ||
| as the expected value. | ||
| - Do not add tests that repeat a case another test already covers. | ||
| - Changes to models, training or default behavior need an eval build: the | ||
| `eval-tests` profile of `opennlp-eval-tests`, run on the ASF Jenkins job | ||
| `OpenNLP/eval-tests-configurable`. Ask a committer to trigger it and link the | ||
| run in the pull request. | ||
|
|
||
| ## Commits | ||
|
|
||
| - Title: `GH-<issue>: <what changes for users>`. Body: a few plain sentences | ||
| on the change, not the history. | ||
| - Update `opennlp-docs` when user-visible behavior changes. | ||
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.
Uh oh!
There was an error while loading. Please reload this page.