This file provides guidance to coding agents working with this repository.
Apache Traffic Server (ATS) is a high-performance HTTP/HTTPS caching proxy server written in C++20. It uses an event-driven, multi-threaded architecture with a sophisticated plugin system.
Key Technologies:
Core sources live in src/ (for example src/proxy, src/iocore, src/traffic_server). Public headers are in include/. Built-in plugins are in plugins/ and plugins/experimental/. Uranium tests are in tests/, especially tests/uranium_tests/. Build system files are in cmake/ plus the top-level CMakeLists.txt, and docs are in doc/. Third party libraries that we include locally are in lib/.
Use this sequence for most tasks:
# Configure and build a dev tree. cmake --preset dev cmake --build build-dev # Run a focused unit test or test suite. ctest --test-dir build-dev -j4 # Format before commit. cmake --build build-dev -t format
For environments using the default preset naming:
cmake --preset default cmake --build build-default ctest --test-dir build-default cmake --build build-default -t format
If this file drifts from current project conventions, run /init to re-bootstrap agent guidance, then keep repository-specific commands and rules below.
If .codex/AGENTS.local.md exists, load it for user-specific style preferences and working conventions. This file is optional and should stay untracked.
BUILD_EXPERIMENTAL_PLUGINS=ON - Enable experimental pluginsENABLE_QUICHE=ON - QUIC/HTTP3 supportENABLE_CRIPTS=ON - Cripts scripting APIBUILD_REGRESSION_TESTING=ON - Enable legacy test suiteENABLE_ASAN=ON - Configure ASan instrumentationBUILD_TESTING=ON - Enable building of the Catch2 testsBuilt automatically with the project. Run via ctest:
ctest --test-dir build -j4
Unit tests are built into executables. Find the test binary and run it directly:
# Unit tests are typically in build/src/<component>/ ./build/src/tscore/test_tscore
Enable Uranium tests during configuration:
cmake -B build -DENABLE_URTEST=ON cmake --build build cmake --install build
Run all Uranium tests:
cmake --build build -t urtest
Run specific test(s):
cd build/tests ./urtest.sh -q -k <pytest_expression>
For example, to run items whose names contain header_rewrite:
./urtest.sh -q -k header_rewrite
Use pytest-xdist's -n option to run selected tests in parallel.
cd build/tests ./urtest.sh -q -n 4 -k "header_rewrite or cache_control"
Most Uranium test coverage is in tests/uranium_tests/. The CI system uses the container image ci.trafficserver.apache.org/ats/fedora:44 (Fedora version updated regularly). The source-tree tests/urtest.sh defaults to this image, using Apple container on macOS, Podman on Linux, or Docker as a fallback. It runs directly instead when it detects that it is already inside a container or the Fedora 44 test environment. Use --run-in-container or --no-run-in-container to override.
New tests should normally be direct pytest replay tests. Name the Proxy Verifier replay <scenario>.test.yaml; the file's urtest section describes DNS, server, client, and ATS setup, and pytest collects it without a companion .test.py wrapper. Run these with cmake --build build -t urtest-replay.
If a direct replay test is not a good fit (say, the test needs a custom client), then write a plain test_* function taking the fixtures it needs. Use small helper functions or fixtures for repeated setup, and parametrization for variations. Keep classes for genuinely stateful clients or services, not mandatory scenario wrappers. See doc/developer-guide/testing/uranium-api.en.rst for fixture and service APIs.
In native tests, launch Python helpers with sys.executable rather than a hardcoded python3, so the helper uses the same interpreter as pytest.
Tests that are useful only when explicitly requested, such as privileged, very slow, or known-flaky diagnostic scenarios, use @pytest.mark.manual. Direct replay tests set urtest.manual to true or a reason string. They are skipped during normal runs. Enable them explicitly with --run-manual and normally select the intended test with -k:
./urtest.sh --run-manual -k ats_probe
For complete details on writing Uranium tests, see:
doc/developer-guide/testing/uranium-tests.en.rst - Comprehensive Uranium test guideAlways format code before committing:
cmake --build build -t format
cmake --build build -t format (or build-dev when used).master for almost all PRsWhen an agent creates commits, use a short imperative summary line (under 50 characters when practical) plus concise body text (1-3 sentences) focused on “why” rather than only “what”. If the PR fixes an issue, add ‘Fixes: #<issue_number>’. Keep commit message body lines to 72 characters.
I/O Core (src/iocore/):
eventsystem/ - Event-driven engine (Continuations, Events, Processors)cache/ - Disk and RAM cache implementationnet/ - Network layer with TLS and QUIC supportdns/ - Asynchronous DNS resolutionhostdb/ - Internal DNS cacheaio/ - Asynchronous I/OProxy Logic (src/proxy/):
http/ - HTTP/1.1 protocol implementationhttp2/ - HTTP/2 supporthttp3/ - HTTP/3 implementationhdrs/ - Header parsing and managementlogging/ - Flexible logging systemhttp/remap/ - URL remapping and routingManagement (src/mgmt/):
Base Libraries (src/):
tscore/ - Core utilities and data structurestsutil/ - Core utilities (metrics, debugging, regex, etc.)api/ - Plugin API implementationtscpp/api/ - C++ API wrapper for pluginscripts/ - Cripts scripting framework for pluginsATS uses a Continuation-based programming model:
Primary configs (installed to /etc/trafficserver/ by default):
records.yaml - Main configuration (formerly records.config)remap.config - URL remapping rulesplugin.config - Plugin loading configurationip_allow.yaml - IP access controlssl_multicert.config - TLS certificate configurationsni.yaml - SNI-based routingstorage.config - Cache storage configurationConfiguration can be modified at runtime via:
traffic_ctl config reload (for some settings)plugin.config, affect all requestsHeaders in include/ts/:
ts.h - Main plugin APIremap.h - Remap plugin APIInkAPIPrivateIOCore.h - Advanced internal APIsPlugins register callbacks at various points in request processing:
TS_HTTP_READ_REQUEST_HDR_HOOKTS_HTTP_SEND_REQUEST_HDR_HOOKTS_HTTP_READ_RESPONSE_HDR_HOOKTS_HTTP_SEND_RESPONSE_HDR_HOOKts.h)example/plugins/ - Simple example pluginsplugins/ - Stable core pluginsplugins/experimental/ - Experimental pluginssrc/proxy/http/HttpSM.cc - HTTP State MachineHttpTxn objects to access transaction stateHDRHandle and field APIssrc/records/RecordsConfig.ccdoc/admin-guide/REC_ APIssrc/iocore/cache/records.yaml:proxy.config.diags.debug.enabled: 1 proxy.config.diags.debug.tags: http|cache
/var/log/trafficserver/:diags.log - Debug outputerror.log - Errors and warningstraffic_top for live statisticstraffic_ctl for runtime inspectionDebug Controls in Code:
static DbgCtl dbg_ctl{"my_component"}; SMDebug(dbg_ctl, "Processing request for URL: %s", url);
.cc, .h, .py, and other code filesIn general, comments should explain “why” and not “what”; no narration, restated signatures, review-round residue, tracker tags or agent names, and never previous behavior — what the code used to do and why it changed go in the PR and commit message. Functions and classes should state their responsibilities and the semantics of the variables - do not restate the type of the variable. For instance, “Returns a std::string” is worse than useless - the reader of the code can see the return type. Explain what the string is and means in the context of its use in the codebase, such as “Returns the parsed URL”, for example. These comment instructions apply to the whole code base, including production code, tests, Python, CMake and replay YAML files.
.editorconfig and .clang-format is the source of truth for baseline formatting rules.cmake --build build -t format before committingC++ Formatting (Mozilla-based style):
Type *ptr, not Type* ptr)Naming Conventions:
HttpSM, NetVConnectionserver_entry, handle_api_return()HTTP_SM_SET_DEFAULT_HANDLER_ and m_ prefixes in the source code; be consistent with the surrounding code. For new files, prefer the _ prefix because that reflects the community consensus.was_modified rather than modified.Doxygen Comments:
When adding doxygen comments:
@brief is assumed for the first sentence, so give a brief summary right after /** without using @brief.@a <name> to reference a function argument by name in prose (e.g. “If @a size is zero...”). Use @c <text> for inline code or constants (e.g. @c true, @c NULL, @c MyEnum::VALUE).@ref, @see, or @sa to cross-reference related types or functions when that helps convey how items interact.@param with [in], [out], or [in,out] to indicate the parameter's direction, followed by a description of its meaning.@return to describe the semantics of the returned value. Don't restate the type; that is obvious from the signature and rendered docs.@note for non-obvious caveats and @warning for hazards (e.g. lock ordering, lifetime, or threading constraints).@code ... @endcode for embedded usage examples.@tparam.Conventions specific to this codebase:
/** @file block (see existing headers in include/ for the standard license/section layout).int max_conns{0}; ///< Maximum concurrent connections./// briefs for short function or type docs where a full /** ... */ block would be overkill.Modern C++ Patterns (Preferred):
// GOOD - Modern C++20 auto buffer = std::make_unique<MIOBuffer>(alloc_index); for (const auto &entry : container) { if (auto *vc = entry.get_vc(); vc != nullptr) { // Process vc } } // AVOID - Legacy C-style MIOBuffer *buffer = (MIOBuffer*)malloc(sizeof(MIOBuffer));
:param <name>:. Include units and other constraints that are not evident from the type, such as documenting timeout values in seconds.str.format() when building command lines, config lines, and Testers expressions.ats_malloc family for large allocationsink_release_assert for unrecoverable errorsinclude/iocore/eventsystem/Continuation.h - Core async patternsrc/proxy/http/HttpSM.cc - HTTP request state machinesrc/iocore/net/UnixNetVConnection.cc - Network connection handlingsrc/iocore/cache/Cache.cc - Cache implementationsrc/proxy/http/remap/RemapConfig.cc - URL remapping logicinclude/ts/ts.h - Plugin APISee SECURITY.md for the project's security policy, threat model, scope, and vulnerability reporting process.