Experiment Architecture

The experiment pipeline combines deterministic program analysis with AI-generated code candidates. Each stage is independently verifiable, and the pipeline rejects candidates that fail any gate.

Deterministic Analysis → Evidence Packet → AI Coding Agent → Candidate Code → Correctness Validation → Sanitizer Checks → Native A/B Measurement → Accept / Reject

Stage Responsibilities

Deterministic Analysis Precedes analyzes the original source with Clang AST/CFG, profiles, and compiler evidence. No AI involvement.
Evidence Packet Original source, bounded profile/hotspot data, native LLVM/DWARF evidence, and contract restrictions are assembled for the model.
AI Coding Agent A single ephemeral, read-only sandbox invocation of OpenAI Codex receives the evidence and proposes a replacement function body. No historical solutions or recommended transformations are included.
Candidate Code The model's structured response is parsed, the replacement body is inserted at frozen byte offsets, and a zero-fuzz deterministic diff is generated and replayed.
Correctness Validation Authentic upstream references, independent numerical oracles, and differential checks verify functional equivalence on finite test inputs.
Sanitizer Checks Both original and candidate are compiled with ASan, UBSan, and LeakSanitizer. Unresolved undefined behavior excludes a candidate.
Native A/B Measurement Independent clean builds, CPU-pinned balanced rounds with warmups, paired wall-time ratios, and bootstrap confidence intervals.
Accept / Reject A candidate is accepted only if the confidence interval excludes 1.0 on the favorable side. Everything else is INCONCLUSIVE or rejected.

UTFCPP v4.0.6 — Primary Case Study

October 24, 2026 · Source revision b26a5f718f4f370af1852a0d5c6ae8fa031ba7d0

Measured Results

ProjectUTFCPP v4.0.6 (revision b26a5f7)
Model providerOpenAI Codex (codex exec, ephemeral, read-only sandbox)
Input tokens52,307
Output tokens930
Reasoning tokens233
Functional checks42 optimization tests pass
Benchmark measurements24 samples + 6 warmups
Performance ratio0.998909×
95% confidence interval[0.974, 1.052]
OutcomeINCONCLUSIVE
Total elapsed103.95 seconds

What Happened

The model proposed bypassing a redundant scalar-validity predicate after UTF-16 surrogate checking, using the same internal append implementation. The candidate passed all correctness, sanitizer, and reference checks. However, the measured performance showed no statistically supported improvement. The confidence interval spans both sides of 1.0, so neither a gain nor a regression can be established.

Validation Workload

Protected multilingual roundtrip workload (148,488 bytes, 32 full passes), independently generated Python-codec/FNV reference, 71 Unicode golden/boundary cases plus malformed UTF-8/UTF-16 checks, and the unmodified upstream negative-conformance program. Initial and final ASan/UBSan/LeakSanitizer checks were CLEAN for both original and candidate.

What This Demonstrates

The experiment demonstrated operational feasibility: the full pipeline from deterministic analysis through model invocation, strict validation, and independent native measurement completed without manual intervention. It did not demonstrate optimization efficiency. A technically valid candidate that passes all checks is not valuable unless it produces a proven improvement.

Salsa20 — End-to-End Pipeline Exercise

Phase 2.2 · Salsa20 from LLVM Test Suite (revision 624469628023)

Measured Results

ProjectSalsa20 (LLVM Test Suite)
ModelCodex (structured body, one-shot)
Input tokens26,064
Output tokens1,347
Measurements24 samples + 6 warmups
Performance ratio0.944× [0.919, 0.962]
OutcomeNO_SUPPORTED_GAIN

What Happened

The model independently proposed interleaving four disjoint quarter-rounds at each rotation stage of the Salsa20 cipher. The candidate passed strict validation including scope/replay checks, reference matching against Bernstein's published test vectors and 264 independent expectations, and CLEAN ASan/UBSan/LeakSanitizer results for both variants.

However, the candidate measured slower than the original: 0.944× with a confidence interval entirely below 1.0, indicating a detected local regression. The pipeline correctly classified this as NO_SUPPORTED_GAIN. No retry, repair, or retiming was performed.

Why This Matters

This demonstrates the complete pipeline working correctly, including correctly rejecting an unsupported optimization. A system that only reports wins would be unreliable. The ability to detect and refuse a plausible-sounding but actually harmful change is a necessary engineering property.

Earlier Experiment Phases

The autonomous optimization infrastructure was developed iteratively. Earlier phases exercised individual gates before the full pipeline was connected.

PhaseTargetModel OutcomeEngineering Significance
Phase 1 AlmaBench NONE Model identified possible repeated trigonometric work but declined to propose a change, citing rounding, errno, and alias obligations. Demonstrates honest termination when no safe optimization is found.
Phase 2 AlmaBench INCORRECT Model proposed a candidate, but the generated unified diff was malformed. GNU patch rejected it at zero fuzz. The harness terminated without repair or retry. Demonstrates fail-closed behavior.
Phase 2.1 Synthetic fixture INTERFACE TEST A deterministic synthetic replacement body exercised the structured edit adapter, zero-fuzz replay, and real validator with sanitizer checks. 27 tests pass. No model was invoked; this is an interface-engineering milestone.

Limitations and Conclusions

Observed Limitations

  • High inference and context consumption per candidate (52K+ input tokens for a single proposal)
  • Substantial validation infrastructure cost beyond the LLM call itself (compilation, sanitizer builds, measurement rounds)
  • No guaranteed relationship between token consumption and achieved speedup
  • A small code edit that passes all checks is not valuable unless it produces a proven runtime improvement
  • No demonstrated favorable cost-benefit ratio in any measured case to date
  • Model familiarity with public source code cannot be excluded; controlled novelty is not established

Conclusion

The agent integration was technically functional: the pipeline correctly invoked a model, received structured proposals, validated candidates through multiple independent gates, measured native performance, and accepted or rejected results based on evidence. But its measured optimization benefit did not justify broad adoption as the primary optimization engine.

The experiment establishes that the infrastructure works end-to-end. It does not establish that LLM-generated optimizations are generally effective, cost-efficient, or superior to deterministic analysis alone.

Important Distinction

Using an AI agent to develop the Precedes tool itself (as a programming assistant during implementation) is different from invoking an AI agent inside Precedes to optimize users' source code. This experiment tests the latter: can an AI agent, given deterministic analysis evidence, propose source-level C++ optimizations that survive independent validation and produce measurable runtime improvements?

Provenance

UTFCPP experiment October 24, 2026. Source revision b26a5f7. Evidence retained in work/consolidation/acceptance/utfcpp-host/
Salsa20 experiment Phase 2.2. Evidence retained in precedes-rea-lab/autonomous-optimizer-mvp-v2_2/runs/one-shot-salsa20/
Model OpenAI Codex via codex exec CLI. Host default model/settings inherited. Exact backend revision and temperature not exposed.
Compiler Clang/LLVM 21.1, GCC 15.2.0. -O3 -g -march=znver2 -fno-omit-frame-pointer, no fast-math.
Hardware AMD Ryzen 5 7520U (Zen 2). CPU-pinned measurement. Temperature, frequency, and outside load uncontrolled.
Statistical method Paired median ratios, 10,000-resample bootstrap with fixed seed, local unadjusted 95% intervals.