Agentic Loop Build Matrix#
The agentic loop cycles through a build matrix — a set of build configurations that each define a preset, a sanitizer, a build directory, and an optional test command. This ensures the loop doesn’t only test one build type but regularly exercises ASAN, TSan, profile, and release builds across both Windows (Stevedore) and Linux (Rancher Desktop).
Configuration#
The build matrix is defined in the project’s AgenticLoop.config.json under
the buildMatrix key. Each platform (windows, linux) has an array of
entries:
{
"buildMatrix": {
"windows": [
{
"name": "clangcl-debug",
"sanitizer": "asan",
"buildDir": "build-clangcl-debug",
"buildType": "Debug",
"testCommand": "ctest --test-dir build-clangcl-debug --output-on-failure -C Debug"
},
{
"name": "clangcl-profile",
"sanitizer": "none",
"buildDir": "build-clangcl-profile",
"buildType": "RelWithDebInfo",
"testCommand": "ctest --test-dir build-clangcl-profile --output-on-failure -C RelWithDebInfo"
},
{
"name": "clangcl-release",
"sanitizer": "none",
"buildDir": "build-clangcl-release",
"buildType": "Release",
"testCommand": null
}
],
"linux": [
{
"name": "linux-debug-asan-clang",
"sanitizer": "asan",
"buildDir": "build-asan-clang",
"buildType": "Debug",
"testCommand": "ctest --test-dir build-asan-clang --output-on-failure -C Debug"
},
{
"name": "linux-debug-tsan-clang",
"sanitizer": "tsan",
"buildDir": "build-tsan-clang",
"buildType": "Debug",
"testCommand": "ctest --test-dir build-tsan-clang --output-on-failure -C Debug"
},
{
"name": "linux-profile-clang",
"sanitizer": "none",
"buildDir": "build-profile-clang",
"buildType": "RelWithDebInfo",
"testCommand": "ctest --test-dir build-profile-clang --output-on-failure -C RelWithDebInfo"
},
{
"name": "linux-release-clang",
"sanitizer": "none",
"buildDir": "build-release-clang",
"buildType": "Release",
"testCommand": null
}
]
}
}
Entry Fields#
Field |
Type |
Description |
|---|---|---|
|
|
Build configuration name (maps to a CMake preset or |
|
|
|
|
|
Build directory (used for Linux |
|
|
CMake build type ( |
|
|
Shell command for tests, or |
Backward Compatibility#
The module also accepts the legacy buildConfigurations format (arrays of
strings). Strings are normalized to entries with sanitizer: "none" and no
per-config test command. This means existing configs keep working without
changes.
Sanitizer-Aware Test Execution#
When a matrix entry has sanitizer: "asan" or sanitizer: "tsan", the
module automatically sets the appropriate environment variables before
running the test command, then restores the original environment:
Sanitizer |
Env Var |
Value |
|---|---|---|
|
|
|
|
|
|
|
— |
No env vars set |
This ensures sanitizer-instrumented tests actually catch memory errors and data races, rather than silently passing because the sanitizer was not configured to halt on error.
Windows ASAN Note#
On Windows, the ASAN debug binary needs clang_rt.asan_dynamic-x86_64.dll
next to the executable. The build copies it automatically. The
ASAN_OPTIONS env var must use a relative log_path — an absolute
C:\... path breaks ASAN option parsing at the drive-letter colon. The
module’s default ASAN_OPTIONS does not set log_path, avoiding this
issue.
Full Matrix Sweep#
In addition to cycling one config per build trigger, the loop supports a full matrix sweep — every N iterations, it runs ALL configs in sequence instead of just one. This ensures all configs are exercised regularly, not just the one that happens to be next in the cycle.
Enable it in the config:
{
"intervals": {
"fullMatrixEveryNIterations": 5
}
}
0= disabled (cycle one config per build trigger, the default)5= every 5th iteration, run all configs in sequence
Build Matrix Cycling#
Without a full sweep, the loop cycles through the matrix entries one at a
time. After every buildEveryNTasks completed tasks, the next entry in the
matrix is used:
Build # |
Windows |
Linux |
|---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
This ensures that over multiple build triggers, every config is exercised.
Cross-Platform Support#
The same config file works on both Windows and Linux. The loop
automatically selects the windows or linux matrix based on the
platform it’s running on:
Windows: builds go through
Build-Windows-Container.ps1(Stevedore container). The config name maps to a preset viaBuild-Windows.config.psd1.Linux: builds go through
cmake-configure-build.sh(Rancher Desktop container or native). The config name is the CMake preset, and thebuildDirfield overrides the preset’sbinaryDirto ensure each config has its own build directory.
Module API#
PowerShell (WindowsAgenticLoop.Common.psm1)#
The PowerShell functions implementing this behaviour
(Resolve-BuildMatrixEntry, Get-SanitizerEnvVars,
Invoke-SanitizerTestCommand, and the high-level Invoke-AgenticLoop)
are documented in the module API reference,
windows-agentic-loop.md.
Bash (agentic-loop.sh)#
Function |
Purpose |
|---|---|
|
Echo env var assignment string for the sanitizer |
|
Set env vars, run tests, restore env |
|
Parse a matrix entry to globals |
|
Count matrix entries for a platform |
|
Get entry name by index (backward-compatible) |
|
Full loop with build matrix, sanitizer tests, quality gates |