Skip to content

Commit 126c14d

Browse files
committed
docs: add AI agent guidelines and security model reference
1 parent 5f65b78 commit 126c14d

3 files changed

Lines changed: 618 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
# Apache Camel Spring Boot - AI Agent Guidelines
2+
3+
Guidelines for AI agents working on this codebase.
4+
5+
## Project Info
6+
7+
Apache Camel Spring Boot provides Spring Boot auto-configuration and starter modules for Apache Camel components.
8+
9+
- Version: 4.21.0-SNAPSHOT
10+
- Java: 17+
11+
- Build: Maven (use `./mvnw` wrapper)
12+
- Issue tracker: [JIRA (CAMEL project)](https://issues.apache.org/jira/browse/CAMEL)
13+
- Related repository: [apache/camel](https://github.com/apache/camel) — Camel core
14+
15+
## AI Agent Rules of Engagement
16+
17+
These rules apply to ALL AI agents working on this codebase.
18+
19+
### Attribution
20+
21+
- All AI-generated content (GitHub PR descriptions, review comments, JIRA comments) MUST clearly
22+
identify itself as AI-generated and mention the human operator.
23+
Example: "_Claude Code on behalf of [Human Name]_"
24+
25+
### PR Volume
26+
27+
- An agent MUST NOT open more than 10 PRs per day per operator to ensure human reviewers can keep up.
28+
- Prioritize quality over quantity — fewer well-tested PRs are better than many shallow ones.
29+
30+
### Git branch
31+
32+
- An agent MUST NEVER push commits to a branch it did not create.
33+
- If a contributor's PR needs changes, the agent may suggest changes via review comments,
34+
but must not push to their branch without explicit permission.
35+
- An agent should prefer to use his own fork to push branches instead of the main
36+
apache/camel-spring-boot repository. It avoids filling the main repository with a long list
37+
of uncleaned branches.
38+
- An agent must provide a useful name for the git branch. It should contain the global topic
39+
and issue number if possible.
40+
- After a Pull Request is merged or rejected, the branch should be deleted.
41+
42+
### JIRA Ticket Ownership
43+
44+
- An agent MUST ONLY pick up **Unassigned** JIRA tickets.
45+
- If a ticket is already assigned to a human, the agent must not reassign it or work on it.
46+
- Before starting work, the agent must assign the ticket to its operator and transition it to
47+
"In Progress".
48+
- Before closing a ticket, always set the correct `fixVersions` field.
49+
Note: `fixVersions` cannot be set on an already-closed issue — set it before closing,
50+
or reopen/set/close if needed.
51+
52+
### PR Description Maintenance
53+
54+
When pushing new commits to a PR, **always update the PR description** (and title if needed) to
55+
reflect the current state of the changeset. PRs evolve across commits — the description must stay
56+
accurate and complete. Use `gh pr edit --title "..." --body "..."` after each push.
57+
58+
### PR Reviewers
59+
60+
When creating a PR, **always identify and request reviews** from the most relevant committers:
61+
62+
- Run `git log --format='%an' --since='1 year' -- <affected-files> | sort | uniq -c | sort -rn | head -10`
63+
to find who has been most active on the affected files.
64+
- Use `git blame` on key modified files to identify who wrote the code being changed.
65+
- Cross-reference with the [committer list](https://home.apache.org/committers-by-project.html#camel)
66+
to ensure you request reviews from active committers (not just contributors).
67+
- For component-specific changes, prefer reviewers who have recently worked on that component.
68+
- For cross-cutting changes (core, auto-configuration), include committers with broader project
69+
knowledge.
70+
- Request review from **at least 2 relevant committers** using `gh pr edit --add-reviewer`.
71+
- When all comments on the Pull Request are addressed (by providing a fix or providing more
72+
explanation) and the PR checks are green, re-request review on existing reviewers so that they
73+
are aware that the new changeset is ready to be reviewed.
74+
75+
### Merge Requirements
76+
77+
- An agent MUST NOT merge a PR if there are any **unresolved review conversations**.
78+
- An agent MUST NOT merge a PR without at least **one human approval**.
79+
- An agent MUST NOT approve its own PRs — human review is always required.
80+
81+
### Code Quality
82+
83+
- Every PR must include tests for new functionality or bug fixes.
84+
- Every PR must include documentation updates where applicable.
85+
- All generated files must be regenerated and committed (CI checks for uncommitted changes).
86+
87+
### Asynchronous Testing: Use Awaitility Instead of Thread.sleep
88+
89+
Do **NOT** use `Thread.sleep()` in test code. It leads to flaky, slow, and non-deterministic tests.
90+
Use the [Awaitility](https://github.com/awaitility/awaitility) library instead, which is already
91+
available as a test dependency in the project.
92+
93+
**Example — waiting for a route to be registered:**
94+
95+
```java
96+
import static org.awaitility.Awaitility.await;
97+
98+
await().atMost(20, TimeUnit.SECONDS)
99+
.untilAsserted(() -> assertEquals(1, context.getRoutes().size()));
100+
```
101+
102+
**Rules:**
103+
104+
- New test code MUST NOT introduce `Thread.sleep()` calls.
105+
- When modifying existing test code that contains `Thread.sleep()`, migrate it to Awaitility.
106+
- Always set an explicit `atMost` timeout to avoid hanging builds.
107+
- Use `untilAsserted` or `until` with a clear predicate — do not replace a sleep with a
108+
busy-wait loop.
109+
110+
### Issue Investigation (Before Implementation)
111+
112+
Before implementing a fix for a JIRA issue, **thoroughly investigate** the issue's validity and
113+
context. Camel is a large, long-lived project — code often looks "wrong" but exists for good
114+
reasons. Do NOT jump straight to implementation after reading the issue description and the
115+
current code.
116+
117+
**Required investigation steps:**
118+
119+
1. **Validate the issue**: Confirm the reported problem is real and reproducible. Question
120+
assumptions in the issue description — they may be incomplete or based on misunderstanding.
121+
2. **Check git history**: Run `git log --oneline <file>` and `git blame <file>` on the affected
122+
code. Read the commit messages and linked JIRA tickets for prior changes to understand *why*
123+
the code is written the way it is.
124+
3. **Search for related issues**: Search JIRA for related tickets (same component, similar
125+
keywords) to find prior discussions, rejected approaches, or intentional design decisions.
126+
4. **Understand the broader context**: If the issue involves a module that replaced or deprecated
127+
another, understand *why* the replacement was made and what was intentionally changed vs.
128+
accidentally omitted. Check the [apache/camel](https://github.com/apache/camel) repository
129+
for design documents in `proposals/` if the affected area touches core Camel behaviour.
130+
5. **Check if the "fix" reverts prior work**: If your proposed change effectively reverts a prior
131+
intentional commit, stop and reconsider. If the revert is still justified, explicitly
132+
acknowledge it in the PR description and explain why despite the original rationale.
133+
134+
**Present your findings** to the operator before implementing. Flag any risks, ambiguities, or
135+
cases where the issue may be invalid or the proposed approach may conflict with prior decisions.
136+
137+
### Knowledge Cutoff Awareness
138+
139+
AI agents have a training data cutoff and may not know about recent releases, API changes, or
140+
deprecations in external projects. **Never make authoritative claims about external project state
141+
based solely on training knowledge.**
142+
143+
- When a JIRA issue, PR, or code references a specific version of an external dependency (e.g.,
144+
Spring Boot 4.0, JUnit 6, Jakarta EE 11), **verify it exists** by checking official sources
145+
(web search, Maven Central, release notes) before questioning or relying on it.
146+
- When implementing or reviewing changes that depend on external project behavior, verify the
147+
current state rather than assuming training data is up to date.
148+
- If uncertain about whether something exists or has changed, say so and verify — do not
149+
confidently assert something is wrong based on potentially stale knowledge.
150+
151+
### Git History Review (When Reviewing PRs)
152+
153+
When reviewing PRs, apply the same investigative rigor:
154+
155+
- Check `git log` and `git blame` on modified files to see if the change conflicts with prior
156+
intentional decisions.
157+
- Verify that "fixes" don't revert deliberate behavior without justification.
158+
- Search for related JIRA tickets that provide context on why the code was written that way.
159+
160+
## Security Model
161+
162+
This project shares the same security model as [Apache Camel core](https://github.com/apache/camel).
163+
The canonical security model document is maintained in the `apache/camel` repository at
164+
[`docs/user-manual/modules/ROOT/pages/security-model.adoc`](https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/security-model.adoc).
165+
166+
camel-spring-boot is an auto-configuration layer — it wraps Camel components with
167+
`@ConfigurationProperties` and Spring Boot lifecycle integration but does not define its own
168+
trust boundaries, consumers, producers, header filtering, or deserialization paths. The Camel
169+
core security model's trust assumptions, in-scope vulnerability classes, and out-of-scope
170+
categories apply directly.
171+
172+
When triaging security reports or reviewing security-sensitive PRs in this repository, refer to
173+
the Camel core security model for:
174+
175+
- **Trust assumptions**: Route authors and deployment operators are fully trusted; external
176+
message senders are untrusted.
177+
- **In-scope classes**: Unsafe deserialization, XXE, expression injection, path traversal, SSRF,
178+
header/bean-dispatch abuse, auth bypass, information disclosure, insecure defaults,
179+
query injection.
180+
- **Out-of-scope**: Route-author code, explicit opt-ins, DoS via unthrottled routes, deployer
181+
misconfiguration of management surfaces, unreachable transitive CVEs, scanner reports
182+
without PoC.
183+
184+
For reporting vulnerabilities, see [`SECURITY.md`](SECURITY.md).
185+
186+
## Structure
187+
188+
```
189+
camel-spring-boot/
190+
├── core/ # Core auto-configuration (CamelAutoConfiguration, actuator, vault)
191+
│ ├── camel-spring-boot/ # Main auto-configuration module
192+
│ └── camel-spring-boot-xml/ # XML (JAXB) route loading variant
193+
├── components-starter/ # ~425 generated starter modules, one per Camel component
194+
├── core-starter/ # Starters for core Camel modules
195+
├── dsl-starter/ # Starters for Camel DSL modules (YAML, Groovy, Kotlin, etc.)
196+
├── tooling/ # Maven plugins for code generation (starters, BOMs, catalog)
197+
├── catalog/ # Spring Boot runtime provider for Camel catalog
198+
├── tests/ # Integration tests and fat-jar tests
199+
└── archetypes/ # Maven archetype for new Camel Spring Boot projects
200+
```
201+
202+
## Build
203+
204+
```bash
205+
# Build a specific starter (preferred — always build in the module directory)
206+
cd components-starter/camel-aws2-s3-starter && mvn verify
207+
208+
# Build core module
209+
cd core/camel-spring-boot && mvn verify
210+
211+
# Fast install (skip tests)
212+
mvn install -Dfastinstall
213+
214+
# Run a single test
215+
cd components-starter/camel-aws2-s3-starter && mvn verify -Dtest=S3ComponentTest
216+
217+
# Format/install without tests
218+
cd <module> && mvn -DskipTests install
219+
```
220+
221+
Do NOT parallelize Maven jobs — builds are resource-intensive.
222+
223+
## Code Generation
224+
225+
Most code in `components-starter/` is **generated** by the Maven plugins in `tooling/`. For each
226+
Camel component, the generator produces:
227+
- `*ComponentAutoConfiguration.java` — Spring Boot `@AutoConfiguration` that registers the
228+
component bean
229+
- `*ComponentConfiguration.java``@ConfigurationProperties` class exposing component options
230+
as `camel.component.<name>.*`
231+
- `*ComponentConverter.java` — Type converter for complex property types
232+
- `META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports` — Registers
233+
auto-configuration classes
234+
235+
Generated code blocks are delimited by `<!--START OF GENERATED CODE-->` / `<!--END OF GENERATED CODE-->`
236+
in POM files. Do not manually edit generated sections.
237+
238+
### Auto-Configuration Pattern
239+
240+
Each starter's auto-configuration class follows a consistent pattern:
241+
1. `@AutoConfiguration(after = CamelAutoConfiguration.class)` — ensures CamelContext is available
242+
2. `@ConditionalOnHierarchicalProperties` — enables/disables via `camel.component.<name>.enabled`
243+
3. `ComponentCustomizer` bean copies Spring Boot properties onto the Camel component
244+
245+
The core `CamelAutoConfiguration` in `core/camel-spring-boot` is the central configuration that
246+
all starters depend on.
247+
248+
### Creating/Deleting Starters
249+
250+
```sh
251+
./starter-create <component-name> # Create a new starter
252+
./starter-delete <component-name> # Delete a starter
253+
```
254+
255+
These invoke the `camel-spring-boot-generator-maven-plugin` under `tooling/`.
256+
257+
### Relationship with Camel Core
258+
259+
This project depends on `apache/camel` for component implementations. The `camel-version` property
260+
must match the target Camel release. When Camel core adds/removes/changes a component, the starters
261+
here must be regenerated.
262+
263+
## Conventions
264+
265+
Code style:
266+
- Do NOT use Records or Lombok (unless already present in the file)
267+
- Do NOT change public API signatures without justification
268+
- Do NOT add new dependencies without justification
269+
- Maintain backwards compatibility for public APIs
270+
271+
Import style:
272+
- Do NOT use fully qualified class names (FQCNs) in Java code. Always add an `import` statement
273+
and use the simple class name.
274+
- Exception: when two classes share the same simple name, import the most-used one and qualify
275+
the other.
276+
277+
Tests: `*Test.java` (JUnit 5)
278+
279+
## Commits
280+
281+
```
282+
CAMEL-XXXX: Brief description
283+
```
284+
285+
Reference JIRA when applicable.
286+
287+
## Links
288+
289+
- https://camel.apache.org/camel-spring-boot/latest/
290+
- https://github.com/apache/camel-spring-boot
291+
- https://github.com/apache/camel
292+
- https://issues.apache.org/jira/browse/CAMEL
293+
- dev@camel.apache.org
294+
- https://camel.zulipchat.com/

0 commit comments

Comments
 (0)