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/. End-to-end tests are in tests/, especially tests/gold_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 autests during configuration:
cmake -B build -DENABLE_AUTEST=ON cmake --build build cmake --install build
Run all autests:
cmake --build build -t autest
Run specific test(s):
cd build/tests ./autest.sh --sandbox /tmp/sbcodex --clean=none -f <test_name_without_test_py>
For example, to run cache-auth.test.py:
./autest.sh --sandbox /tmp/sbcursor --clean=none -f cache-auth
To run multiple tests efficiently, pass the -j option.
cd build/tests ./autest.sh -j4 --sandbox /tmp/sbcodex --clean=none -f 'header_rewrite*'
Most end-to-end test coverage is in tests/gold_tests/. The CI system uses the Docker image ci.trafficserver.apache.org/ats/fedora:43 (Fedora version updated regularly).
New tests should use the Test.ATSReplayTest() approach, which references a replay.yaml file that describes the test configuration and traffic patterns using the Proxy Verifier format. This is simpler, more maintainable, and parseable by tools.
If ATSReplayTest is not a good fit (say, the test needs a custom client), then organize the test around a test class with member functions that configure any servers, the ATS process, and the client. See tests/gold_tests/ats_probe/ats_probe.test.py for an example of a test organized around a test class.
In autests, launch Python helpers with {sys.executable} rather than a hardcoded python3, so the test runs under the same interpreter the harness uses.
For complete details on writing autests, see:
doc/developer-guide/testing/autests.en.rst - Comprehensive guide to autestAlways 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 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));
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.