Skip to content

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:

# Simulated Fix
s = set(arr)
for x in arr:
    if x in s: # O(1) Lookup
        total += x

๐Ÿงญ 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.