End-to-End Governance Runs (benchmarks/end_to_end.md)
An End-to-End (E2E) Run is the gold standard for performance governance. It proves that the engine can move from raw code to a mathematical verdict without human intervention. This page documents the workflow and output of a full governance audit.
๐๏ธ 1. The Audit Workflow
In a standard E2E run, Alnoms executes the following sequence:
1. Static Sweep: The HeuristicsEngine scans the AST for structural anti-patterns.
2. Profiling: cProfile identifies the "slowest function" during a baseline run.
3. Scaling Proof: The Profiler runs a doubling test to verify asymptotic behavior (\(O(N^2)\) vs. \(O(N)\)).
4. Remediation: The DecisionEngine provides a specific fix from the Sovereign DSA library.
๐งช 2. Case Study: The Membership Trap
To demonstrate the engine's precision, we analyze a common "Silent Trap": checking membership inside a loop using a list instead of a hash-based structure.
The Target Script
def slow_membership_sum(arr):
total = 0
for x in arr:
# Intentional O(N^2) membership trap
if x in arr:
total += x
return total
โ๏ธ 3. The Performance Report (Raw Output)
The following report is generated entirely by the Alnoms PerformanceCLI. It represents the "Ground Truth" for the code above.
==================================================
โ๏ธ PERFORMANCE REPORT
==================================================
File: scripts/slow_script.py
Timestamp (UTC): 2026-04-21T16:52:37Z
Total Execution Time: 0.0344s
๐จ STATIC ANALYSIS
--------------------------------------------------
1. โ ๏ธ ISSUE: Membership test ('in arr') inside loop
๐ Explanation: Membership checks on lists inside loops are O(N).
๐ RECOMMENDED OPTIMIZATION: O(N) lookup replacement.
๐๏ธ IMPLEMENTATION: alnoms.dsa.structures.separate_chaining_hash_st
๐ ACCESS TIER: OSS
โฑ๏ธ Complexity Shift: O(N*M) โ O(N + M)
๐ EMPIRICAL SCALING ANALYSIS: slow_membership_sum()
--------------------------------------------------
N | Time (s) | Ratio | Est. Complexity
--------------------------------------------------
50 | 0.00001 | - | Initial Round
100 | 0.00002 | 3.59 | O(N^2)
200 | 0.00008 | 3.31 | O(N^2)
400 | 0.00030 | 3.79 | O(N^2)
โ๏ธ VERDICT:
โ ๏ธ WARNING: Function operates at O(N^2). May not scale efficiently.
๐ EXPECTED IMPACT (N = 10,000)
--------------------------------------------------
โข Current: ~100,000,000 operations
โข Optimized: ~10,000 operations
Estimated improvement: 100รโ1000ร.
๐ค CONFIDENCE: High โ static and empirical signals agree.
==================================================
โ๏ธ 4. Key Takeaways
The "Double-Check" Logic
The engine doesn't just guess that the code is slow because of the in keyword (Static Analysis). It validates the diagnosis by doubling the data (\(N=100\) to \(N=200\)) and seeing the time quadruple (Ratio \(\approx 4.0\)). This Empirical Grounding ensures no false positives by verifying that the scaling ratio matches the predicted complexity.
Prescriptive Remediation
The report provides a Simulated After-Optimization view, showing exactly how to reduce the "cognitive tax" on the system by converting the list to a set:
๐งญ 5. Design Principles Applied
- Transparency: All timing data, scaling ratios, and AST findings are visible to the auditor, ensuring the report is fully observable and verifiable.
- Actionability: The report doesn't just diagnose bottlenecks; it prescribes the exact module from the DSA Pharmacy needed for the cure, including implementation paths.
- Determinism: Running this audit on any machine will produce the same \(O(N^2)\) verdict, providing a stable, reproducible foundation for industrial Performance Governance.
๐ Next Step: Explore the Case Studies to see how Alnoms handles complex, real-world algorithmic challenges.