{"owner":"apache","repo":"kafka","hasSkills":true,"hasMcp":false,"mcpConfig":null,"found":["AGENTS.md"],"files":{"AGENTS.md":"<!--\n Licensed to the Apache Software Foundation (ASF) under one or more\n contributor license agreements.  See the NOTICE file distributed with\n this work for additional information regarding copyright ownership.\n The ASF licenses this file to You under the Apache License, Version 2.0\n (the \"License\"); you may not use this file except in compliance with\n the License.  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n-->\n\n# Agent Guide for Apache Kafka\n\nThis file is read by automated agents (security scanners, code analyzers,\nAI assistants) operating on this repository.\n\n## Project overview\n\nApache Kafka is a distributed event streaming platform. This repo is a **Gradle**\nbuild in **Java** and **Scala 2.13**.\n\n- **Supported JDK**: 11+ for `clients`, `generator`, and `streams`; 17+ for other modules.\n- **Build/test JDK**: Java 17 and 25.\n- **Build tool**: Gradle, wrapper `./gradlew` is recommended.\n\n## Repository layout (high level)\n\n| Path                                                                                          | Purpose                                                                                            |\n|-----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|\n| `clients/`                                                                                    | Producer, consumer, admin client APIs and protocol messages                                        |\n| `core/`                                                                                       | Broker runtime, log, replication, request handling (gradually being removed along with Scala code) |\n| `server/`, `server-common/`                                                                   | Broker/server components and shared server code                                                    |\n| `metadata/`, `raft/`                                                                          | KRaft metadata layer and Raft implementation                                                       |\n| `storage/`, `storage/api/`                                                                    | Log segments, checkpoints, tiered storage APIs                                                     |\n| `group-coordinator/`, `share-coordinator/`, `transaction-coordinator/`, `coordinator-common/` | Coordinators                                                                                       |\n| `connect/`                                                                                    | Kafka Connect (api, runtime, plugins, transforms)                                                  |\n| `streams/`                                                                                    | Kafka Streams (+ Scala, examples, upgrade system tests)                                            |\n| `generator/`                                                                                  | RPC/message code generation                                                                        |\n| `tools/`, `shell/`                                                                            | CLI tools and kafka metadata shell                                                                 |\n| `examples/`                                                                                   | Kafka producer and consumer examples                                                               |\n| `jmh-benchmarks/`                                                                             | Kafka benchmarks tests                                                                             |\n| `trogdor/`                                                                                    | test framework                                                                                     |\n| `tests/`                                                                                      | System test harness (see `tests/README.md`)                                                        |\n| `config/`                                                                                     | Sample broker/controller configuration                                                             |\n| `checkstyle/`                                                                                 | Checkstyle rules and import-control XML                                                            |\n| `docs/`                                                                                       | Documentation sources                                                                              |\n| `docker/`                                                                                     | Docker images, build/test scripts, and examples for JVM and native Kafka           |\n\n\n## Build commands\n\n```bash\n# Compile jars\n./gradlew jar\n\n# Release tarball (output under core/build/distributions/)\n./gradlew clean releaseTarGz\n\n# Publish to local Maven (skip signing for local dev)\n./gradlew -PskipSigning=true publishToMavenLocal\n\n# Regenerate RPC/message classes after branch switches\n./gradlew processMessages processTestMessages\n\n# List tasks\n./gradlew tasks\n```\n\nModule-scoped build:\n\n```bash\n./gradlew core:jar\n./gradlew clients:jar\n./gradlew :streams:testAll\n```\n\n## Test commands\n\n```bash\n# All unit + integration tests\n./gradlew test\n\n# Split suites\n./gradlew unitTest\n./gradlew integrationTest\n\n# Include flaky tests (marked @Flaky)\n./gradlew test -Pkafka.test.run.flaky=true\n\n# Re-run without considering up-to-date\n./gradlew test --rerun-tasks\n\n# Single test class\n./gradlew clients:test --tests RequestResponseTest\n\n# Single test method\n./gradlew clients:clients-integration-tests:test --tests org.apache.kafka.clients.producer.ProducerFailureHandlingTest.testCannotSendToInternalTopic\n\n# Coverage (whole project or one module)\n./gradlew reportCoverage -PenableTestCoverage=true -Dorg.gradle.parallel=false\n./gradlew clients:reportCoverage -PenableTestCoverage=true -Dorg.gradle.parallel=false\n```\n\n**Test retries** (optional): `-PmaxTestRetries=1 -PmaxTestRetryFailures=3`\n\n**Logging**: adjust `log4j2.yaml` under `<module>/src/test/resources/` for verbose test logs.\n\n**System tests**: see [tests/README.md](tests/README.md).\n\n## Code quality\n\nRun before submitting Java changes:\n\n```bash\n./gradlew spotlessApply          # fix import order / formatting\n./gradlew checkstyleMain checkstyleTest spotlessCheck\n./gradlew spotbugsMain spotbugsTest -x test   # optional static analysis\n```\n\nCheckstyle reports: `<module>/build/reports/checkstyle/`.\n\n## Coding conventions\n\n- **Commits / PR titles**: Start with `KAFKA-XXXXX`, `MINOR`, or `HOTFIX`. Use `KAFKA-XXXXX` only when there is a valid Jira ticket for the change.\n- **AI-generated contributions**: Follow the [AI-Generated Contributions](CONTRIBUTING.md#ai-generated-contributions) section in `CONTRIBUTING.md` — add a `Co-Authored-By` or `Generated-by` commit trailer for AI-assisted changes.\n- **Public API / KIP**: Changes to public interfaces, wire protocol, configurations, or metrics generally require a [KIP](https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Improvement+Proposals). See the `javadoc` `include` list in [build.gradle](build.gradle) for packages treated as public API.\n- **License header**: New source files need the standard ASF license header (see existing files in the same module).\n- **Checkstyle**: Enforced on main and test sources; rules in `checkstyle/`. Import order is checked via Spotless.\n- **Generated code**: Do not hand-edit generated RPC/message sources. Regenerate with `processMessages` / `processTestMessages`. See [clients/src/main/resources/common/message/README.md](clients/src/main/resources/common/message/README.md).\n- **Scope**: Prefer targeted unit tests in the module you change; integration/system tests for cross-component behavior.\n- **Compatibility**: clients, generator, and streams modules support Java 11+; all other modules require Java 17+. Avoid APIs that break those release levels.\n\n## Security\n\nSee [SECURITY.md](./SECURITY.md) for how to report a vulnerability and for links\nto the Apache Kafka security model under [docs/security/](./docs/security/).\n\nAgents that scan this repository should consult `SECURITY.md` and the linked\nsecurity model before reporting issues. In particular, the core model defines\nwhat is in and out of scope, how reports are classified, and a list of known\nnon-findings; each component page adds its own known non-findings.\n\n## Reference docs\n\n| Topic                          | Location |\n|--------------------------------|----------|\n| Build, test, broker quickstart | [README.md](README.md) |\n| Contributing                   | [CONTRIBUTING.md](CONTRIBUTING.md), https://kafka.apache.org/contributing.html |\n| Message protocol / codegen     | [clients/src/main/resources/common/message/README.md](clients/src/main/resources/common/message/README.md) |\n| System tests                   | [tests/README.md](tests/README.md) |\n| JMH benchmarks                 | [jmh-benchmarks/README.md](jmh-benchmarks/README.md) |\n| Client examples                | [examples/README.md](examples/README.md) |\n| Security                       | [SECURITY.md](SECURITY.md) |\n"}}