Skip to content

Commit ca8a637

Browse files
oscerdclaude
andauthored
chore: add AGENTS.md, CLAUDE.md and SECURITY.md (#6635)
* chore: add AGENTS.md, CLAUDE.md and SECURITY.md Adds repository-root AGENTS.md (AI agent guidelines), CLAUDE.md (identical content, mirroring apache/camel's layout), and SECURITY.md (the entry point GitHub and security tooling expect), modeled on apache/camel but adapted for Camel K: - Go/Make toolchain and real targets (make build/test/lint/generate/ update-docs), not Maven. - GitHub Issues workflow and the project's branch/commit conventions, not JIRA. - Go async-testing guidance (Gomega Eventually, no time.Sleep). - Security Model section wired to docs/threat-model.md as the additive Camel-K sub-project expansion of the umbrella Apache Camel Security Model; SECURITY.md points to it for scope and to the ASF process for private disclosure. Note: SECURITY.md and AGENTS.md reference docs/threat-model.md, added by PR #6634; those repo-relative links resolve once #6634 merges. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: address review feedback on AGENTS.md squakez: don't hardcode the Camel K version and Go version in the agent guidelines (they go stale). Instruct the agent to read them from the authoritative sources instead: version from pkg/util/defaults/defaults.go (or 'make get-version'), Go from the go directive in go.mod. Applied identically to CLAUDE.md to keep the two files in sync. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 035ca9b commit ca8a637

3 files changed

Lines changed: 749 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 357 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,357 @@
1+
# Apache Camel K - AI Agent Guidelines
2+
3+
Guidelines for AI agents working on this codebase.
4+
5+
## Project Info
6+
7+
Apache Camel K is a Kubernetes-native integration platform built on Apache Camel. It is a
8+
Go **operator** plus the `kamel` **CLI** that turn user-supplied Camel route Custom Resources
9+
(`Integration`, `Pipe`, `Kamelet`, …) into built container images and running workloads on
10+
Kubernetes/OpenShift.
11+
12+
- Version: not hardcoded — read it from `pkg/util/defaults/defaults.go`
13+
(`Version = "…"`), or run `make get-version`.
14+
- Go: not hardcoded — read the `go` directive in `go.mod`.
15+
- Build: `make` (Go toolchain, not Maven)
16+
- Module: `github.com/apache/camel-k/v2` (see `go.mod`)
17+
- Issue tracker: **GitHub Issues** (not JIRA)
18+
19+
## AI Agent Rules of Engagement
20+
21+
These rules apply to ALL AI agents working on this codebase.
22+
23+
### Attribution
24+
25+
- All AI-generated content (GitHub PR descriptions, review comments, issue comments) MUST clearly
26+
identify itself as AI-generated and mention the human operator.
27+
Example: "_Claude Code on behalf of [Human Name]_"
28+
29+
### PR Volume
30+
31+
- An agent MUST NOT open more than 10 PRs per day per operator to ensure human reviewers can keep up.
32+
- Prioritize quality over quantity — fewer well-tested PRs are better than many shallow ones.
33+
34+
### Git branch
35+
36+
- An agent MUST NEVER push commits to a branch it did not create.
37+
- If a contributor's PR needs changes, the agent may suggest changes via review comments,
38+
but must not push to their branch without explicit permission.
39+
- An agent should prefer to use its own fork to push branches instead of the main
40+
`apache/camel-k` repository. It avoids filling the main repository with a long list of
41+
uncleaned branches.
42+
- An agent must provide a useful branch name following the project conventions:
43+
`fix/<ISSUE_NUMBER>`, `feature/<ISSUE_NUMBER>-<short-slug>`, `bugfix/<ISSUE_NUMBER>`,
44+
`quick-fix/<short-slug>`, or `ci-issue/<short-slug>`.
45+
- After a Pull Request is merged or rejected, the branch should be deleted.
46+
47+
### GitHub Issue Ownership
48+
49+
- An agent MUST ONLY pick up **unassigned** GitHub issues.
50+
- If an issue is already assigned to a human, the agent must not reassign it or work on it.
51+
- Before starting work, the agent must assign the issue to its operator.
52+
- Link the PR to the issue (`Fixes #<ISSUE_NUMBER>`) so it is closed on merge, and apply the
53+
relevant labels/milestone before closing where the project uses them.
54+
55+
### PR Description Maintenance
56+
57+
When pushing new commits to a PR, **always update the PR description** (and title if needed) to
58+
reflect the current state of the changeset. PRs evolve across commits — the description must stay
59+
accurate and complete. Use `gh pr edit --title "..." --body "..."` after each push.
60+
61+
### PR Reviewers
62+
63+
When creating a PR, **always identify and request reviews** from the most relevant committers:
64+
65+
- Run `git log --format='%an' --since='1 year' -- <affected-files> | sort | uniq -c | sort -rn | head -10`
66+
to find who has been most active on the affected files.
67+
- Use `git blame` on key modified files to identify who wrote the code being changed.
68+
- Cross-reference with the [committer list](https://home.apache.org/committers-by-project.html#camel)
69+
to ensure you request reviews from active committers (not just contributors).
70+
- For controller/trait/builder changes, prefer reviewers who recently worked on that area.
71+
- For cross-cutting changes (apis, controller, platform), include committers with broader
72+
project knowledge.
73+
- Request review from **at least 2 relevant committers** using `gh pr edit --add-reviewer`.
74+
- When all comments on the Pull Request are addressed (by providing a fix or more explanation)
75+
and the PR checks are green, re-request review so reviewers know the new changeset is ready.
76+
77+
### Merge Requirements
78+
79+
- An agent MUST NOT merge a PR if there are any **unresolved review conversations**.
80+
- An agent MUST NOT merge a PR without at least **one human approval**.
81+
- An agent MUST NOT approve its own PRs — human review is always required.
82+
83+
### Code Quality
84+
85+
- Every PR must include tests for new functionality or bug fixes.
86+
- Every PR must include documentation updates where applicable.
87+
- All code must be formatted (`make fmt` and `make goimport`) and pass `make lint`
88+
(golangci-lint) before pushing.
89+
- All generated artifacts must be regenerated and committed — run `make generate` (codegen,
90+
CRDs, deepcopy, RBAC) and `make update-docs` (autogenerated trait docs). CI fails if there
91+
are uncommitted changes after a build.
92+
93+
### Asynchronous Testing: Use `Eventually`, not `time.Sleep`
94+
95+
Do **NOT** use `time.Sleep()` to wait for asynchronous state in tests. It leads to flaky, slow,
96+
and non-deterministic tests. Use polling with a timeout instead — Gomega's `Eventually` in the
97+
e2e suites, or a bounded poll helper in unit tests.
98+
99+
**Example — waiting for an Integration to reach the running phase (e2e):**
100+
101+
```go
102+
import (
103+
. "github.com/onsi/gomega"
104+
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
105+
)
106+
107+
Eventually(IntegrationPhase(t, ctx, ns, "my-it"), TestTimeoutMedium).
108+
Should(Equal(v1.IntegrationPhaseRunning))
109+
```
110+
111+
**Rules:**
112+
113+
- New test code MUST NOT introduce `time.Sleep()` to await state.
114+
- When modifying existing test code that sleeps to await state, migrate it to `Eventually`.
115+
- Always set an explicit timeout to avoid hanging builds.
116+
- Use a clear assertion/predicate — do not replace a sleep with a busy-wait loop.
117+
118+
### Issue Investigation (Before Implementation)
119+
120+
Before implementing a fix for a GitHub issue, **thoroughly investigate** the issue's validity
121+
and context. Camel K coordinates many moving parts (operator, builds, traits, CRDs, the
122+
Camel runtime); code often looks "wrong" but exists for good reasons. Do NOT jump straight to
123+
implementation after reading the issue description and the current code.
124+
125+
**Required investigation steps:**
126+
127+
1. **Validate the issue**: Confirm the reported problem is real and reproducible. Question
128+
assumptions in the issue description — they may be incomplete or based on misunderstanding.
129+
2. **Check git history**: Run `git log --oneline <file>` and `git blame <file>` on the affected
130+
code. Read commit messages and linked issues/PRs to understand *why* the code is the way it is.
131+
3. **Search for related issues**: Search GitHub for related issues/PRs (same area, similar
132+
keywords) to find prior discussions, rejected approaches, or intentional design decisions.
133+
4. **Look for design documents**: Check the `proposals/` directory for design docs (`.adoc`)
134+
that may explain architectural decisions. Key proposals by area:
135+
- **Security / monitoring** (RBAC, metrics endpoint hardening, multi-tenancy):
136+
[`proposals/monitoring-security.adoc`](proposals/monitoring-security.adoc)
137+
- **Kamelets** (provided kamelet catalog): [`proposals/provided-kamelets.adoc`](proposals/provided-kamelets.adoc)
138+
- **Service binding**: [`proposals/service-binding.adoc`](proposals/service-binding.adoc)
139+
- **Threat model** (trust boundaries, what is a vulnerability): [`docs/threat-model.md`](docs/threat-model.md)
140+
5. **Understand the broader context**: If the issue involves a feature that replaced or
141+
deprecated another (e.g. `pod` trait, synthetic Integrations, multi-operator), understand
142+
*why* the change was made and what was intentionally changed vs. accidentally omitted.
143+
6. **Check if the "fix" reverts prior work**: If your proposed change effectively reverts a
144+
prior intentional commit, stop and reconsider. If the revert is still justified, explicitly
145+
acknowledge it in the PR description and explain why despite the original rationale.
146+
147+
**Present your findings** to the operator before implementing. Flag any risks, ambiguities, or
148+
cases where the issue may be invalid or the proposed approach may conflict with prior decisions.
149+
150+
### Knowledge Cutoff Awareness
151+
152+
AI agents have a training data cutoff and may not know about recent releases, API changes, or
153+
deprecations in external projects (Kubernetes, Knative, Quarkus, the Camel runtime). **Never
154+
make authoritative claims about external project state based solely on training knowledge.**
155+
156+
- When an issue, PR, or code references a specific version of an external dependency, **verify
157+
it exists** via official sources before questioning or relying on it.
158+
- When implementing or reviewing changes that depend on external project behavior, verify the
159+
current state rather than assuming training data is up to date.
160+
- If uncertain whether something exists or has changed, say so and verify — do not confidently
161+
assert something is wrong based on potentially stale knowledge.
162+
163+
### Git History Review (When Reviewing PRs)
164+
165+
When reviewing PRs, apply the same investigative rigor:
166+
167+
- Check `git log` and `git blame` on modified files to see if the change conflicts with prior
168+
intentional decisions.
169+
- Verify that "fixes" don't revert deliberate behavior without justification.
170+
- Check for design proposals (`proposals/*.adoc`) and the threat model
171+
(`docs/threat-model.md`) related to the affected area.
172+
- Search for related GitHub issues that provide context on why the code was written that way.
173+
174+
### Documentation Conventions
175+
176+
When writing or modifying `.adoc` documentation under `docs/modules/`:
177+
178+
- **Use `xref:` for internal links**, never external `https://camel.apache.org/camel-k/...`
179+
URLs.
180+
- Trait reference pages and parts of the docs are **autogenerated** (see `cmd/util/doc-gen`
181+
and the `// Start of autogenerated code - DO NOT EDIT!` markers). Do not hand-edit
182+
autogenerated blocks; change the Go source and run `make update-docs`.
183+
- When reviewing doc PRs, check that `xref:` links and the Antora nav resolve correctly.
184+
185+
## Security Model
186+
187+
Camel K has a documented threat model that defines who is trusted, where the trust boundaries
188+
sit, what counts as a Camel K vulnerability, and what is operator/deployer responsibility. The
189+
canonical document is [`docs/threat-model.md`](docs/threat-model.md). It is the **additive
190+
Camel-K sub-project expansion** of the umbrella
191+
[Apache Camel Security Model](https://camel.apache.org/manual/security-model.html), which
192+
explicitly scopes itself to "Camel embedded in someone else's application, **not a multi-tenant
193+
managed service**" — the Kubernetes operator / Custom Resource / cluster layer is Camel K's to
194+
model. Use `docs/threat-model.md` (and its `docs/threat-model.yaml` triage sidecar) when
195+
triaging security reports, deciding whether a finding warrants a CVE, or reviewing a
196+
security-sensitive PR.
197+
198+
For the vulnerability **reporting** convention, [`SECURITY.md`](SECURITY.md) at the repository
199+
root is the entry point GitHub and security tooling expect. It points to the threat model for
200+
scope and to the ASF process for private disclosure. An agent that discovers or is handed a
201+
suspected vulnerability MUST NOT open a public issue, PR, or mailing-list post about it —
202+
follow the private process in `SECURITY.md` and stop.
203+
204+
### Trust assumptions (Camel K layer)
205+
206+
- **Platform admins / operator-deployers** are **fully trusted**. They install the operator,
207+
set its RBAC, and edit `IntegrationPlatform` / `IntegrationProfile` (registry, base image,
208+
Maven settings, build strategy). Compromise here is total and out of model.
209+
- **CR authors** (whoever can create/patch `Integration`, `Pipe`, `Kamelet`,
210+
`IntegrationKit`, `Build`, `IntegrationProfile`) are trusted **only at the target
211+
namespace's level**. Submitting such a CR is, by design, arbitrary code and container
212+
execution in that namespace; the only gate is Kubernetes RBAC.
213+
- **Cluster tenants without Camel K CR RBAC** are **untrusted** and in scope as adversaries.
214+
- **Network clients of the deployed integration** are **untrusted**; the running route's own
215+
attack surface is **Apache Camel core's** threat model, not Camel K's.
216+
217+
### What is in scope (concise summary)
218+
219+
- A principal **without** Camel K CR RBAC causing builds/workloads, or reading another
220+
tenant's secrets/artifacts through the operator.
221+
- **Cross-namespace / cross-trust escalation** via the operator (it can create
222+
`roles`/`rolebindings`/`clusterrolebindings`, `serviceaccounts`, and `pods/exec`): any path
223+
by which creating a CR in namespace A yields rights in namespace B / cluster-scope the
224+
author lacked is `VALID`.
225+
- Camel K weakening or bypassing Kubernetes RBAC as the authorization gate.
226+
- Insecure defaults the operator ships that expose the above with zero extra configuration.
227+
228+
### What is out of scope
229+
230+
- A CR author running arbitrary code/containers in their own namespace (trusted at that
231+
level — by design, not a vulnerability), incl. `builder.tasks`, `container.image`, the
232+
`pod` trait, `spec.template`.
233+
- Platform-admin / `IntegrationPlatform` editor actions; a hostile Maven repo / registry /
234+
base image / remote Kamelet catalog the deployer chose to trust (supply chain is the
235+
deployer's).
236+
- The deployed route's own runtime behavior (Apache Camel core's model).
237+
- Behavior reachable only under a non-default, discouraged knob (`registry.insecure`,
238+
Maven `InsecureSkipVerify`, `routine` build strategy with untrusted CR authors).
239+
- Shipped-but-unsupported code (`examples/`, `e2e/`, `proposals/`, samples, deprecated
240+
Buildah/Kaniko/Spectrum tasks, `pod` trait, synthetic Integrations, multi-operator).
241+
- Automated scanner reports without a PoC demonstrating an actual trust-boundary breach.
242+
243+
### Operator hardening checklist
244+
245+
When reviewing or recommending a deployment, surface the following:
246+
247+
- Treat "create/patch `Integration` / `Pipe` / `Kamelet` / `IntegrationKit` / `Build` /
248+
`IntegrationProfile` in namespace N" as equivalent to "run arbitrary code in N" — grant
249+
that RBAC only to principals trusted at that level.
250+
- Lock down `IntegrationPlatform` / `IntegrationProfile` and the install namespace.
251+
- For untrusted or multi-tenant CR authors, use the **`pod` build strategy**, not `routine`
252+
(which runs the Maven build inside the operator pod). This is required, not advisory.
253+
- Provide a trusted Maven proxy/mirror and a controlled registry; never enable
254+
`insecure` / `InsecureSkipVerify` in production.
255+
- Apply Kubernetes-native isolation: namespaces, Pod Security Admission,
256+
ResourceQuota/LimitRange, NetworkPolicies (Camel K ships none).
257+
- Set `runAsNonRoot` / `runAsUser` explicitly — the default does not.
258+
259+
### Committer review checklist (for security-sensitive PRs)
260+
261+
When reviewing a PR that touches the operator, a controller, a trait, the builder, RBAC
262+
manifests, or a CRD:
263+
264+
- Does a new CR field or trait give a CR author new control over images, commands, mounts,
265+
the raw pod spec, or the build? If so it must be covered by `docs/threat-model.md` §4.6.
266+
- Does the change widen the operator's RBAC (`secrets`, `rolebindings`,
267+
`clusterrolebindings`, `pods/exec`, cross-namespace)? Cross-namespace/cross-trust
268+
escalation is `VALID` — justify and minimize.
269+
- Does the change add a new external fetch (Maven repo, registry, remote Kamelet catalog,
270+
git, HTTP source)? Note it as a supply-chain edge.
271+
- Does it relax a security-relevant default (build strategy, `runAsNonRoot`, TLS verify)?
272+
New defaults err toward the safer value; a relaxation needs an upgrade note and PMC
273+
sign-off, and a matching update to `docs/threat-model.md` (§4.5a / §4.12).
274+
- Does it ship or change an admission webhook? Today there is none by design — adding one
275+
moves the §4.4 trust boundary and must be reflected in the threat model.
276+
277+
## Structure
278+
279+
```
280+
camel-k/
281+
├── cmd/kamel/ # kamel CLI entrypoint
282+
├── pkg/
283+
│ ├── apis/ # CRD Go types (camel.apache.org/v1)
284+
│ ├── controller/ # reconcilers (integration, integrationkit, build, …)
285+
│ ├── trait/ # traits (how a CR maps to Kubernetes resources)
286+
│ ├── builder/ # build subsystem (Maven, Jib, S2I)
287+
│ ├── cmd/ # CLI + operator command implementations
288+
│ ├── platform/ # IntegrationPlatform defaults & helpers
289+
│ ├── client/ # generated Kubernetes client
290+
│ └── resources/ # embedded manifests (CRDs, RBAC, samples)
291+
├── e2e/ # end-to-end test suites
292+
├── helm/ , install/ # install assets (Helm chart, Kustomize overlays)
293+
├── proposals/ # design proposals (.adoc)
294+
├── docs/ # Antora AsciiDoc docs + threat-model.md / .yaml
295+
└── script/ # Makefile and build scripts
296+
```
297+
298+
## Build
299+
300+
```bash
301+
make build # codegen + resources + unit tests + kamel + e2e compile (full)
302+
make build-kamel # build just the kamel CLI binary
303+
make generate # regenerate codegen, CRDs, deepcopy, RBAC
304+
make update-docs # regenerate autogenerated documentation (e.g. trait pages)
305+
make fmt goimport # format Go code and imports
306+
make lint # golangci-lint
307+
make check # lint + vulnerability scan (govulncheck)
308+
```
309+
310+
Do NOT parallelize resource-intensive build/test jobs.
311+
312+
## Testing
313+
314+
```bash
315+
make test # unit tests
316+
make test-common # common e2e suite (requires a cluster)
317+
make test-smoke # smoke e2e suite
318+
# other suites: test-advanced, test-knative, test-kafka, test-gateway,
319+
# test-telemetry, test-install, test-quarkus-native, …
320+
```
321+
322+
E2E suites need a reachable Kubernetes cluster and use Gomega `Eventually` for asynchronous
323+
assertions (see the async-testing rule above).
324+
325+
## Conventions
326+
327+
- Standard Go conventions: `gofmt`/`make fmt`, `go vet`, and `make lint` (golangci-lint,
328+
see `.golangci.yml`) must pass.
329+
- Follow the existing **trait** pattern in `pkg/trait` and the **Action/state-machine**
330+
controller pattern in `pkg/controller` rather than inventing new shapes.
331+
- Keep CRD Go types in `pkg/apis/camel/v1` in sync with generated CRDs/RBAC — run
332+
`make generate` and commit the result.
333+
- Maintain backwards compatibility for public Go APIs and CRD fields; do not change CRD
334+
field semantics without a justification and an upgrade note.
335+
- Deprecation: mark Go fields/traits with a `// Deprecated:` comment, reflect it in the CRD
336+
schema/catalog, and document it in the upgrade notes. Deprecated surface is in *limited*
337+
scope for security (documented migration is the primary remediation); removed surface is
338+
out of scope.
339+
340+
## Commits
341+
342+
```
343+
Fix #<ISSUE_NUMBER>: Brief description # bug/feature tied to a GitHub issue
344+
chore: Brief description # quick-fix / no issue
345+
ci: Brief description # CI-only change
346+
```
347+
348+
Reference the GitHub issue (`Fixes #<n>`) when applicable so it closes on merge.
349+
350+
## Links
351+
352+
- https://camel.apache.org/camel-k/
353+
- https://github.com/apache/camel-k
354+
- https://github.com/apache/camel-k/issues
355+
- https://camel.apache.org/manual/security-model.html (umbrella Apache Camel Security Model)
356+
- dev@camel.apache.org
357+
- https://camel.zulipchat.com/

0 commit comments

Comments
 (0)