Skip to content

auto_trace_glossary_1

github-actions[bot] edited this page Nov 14, 2025 · 1 revision

Snippet from Trace-Glossary.md

# Audit Trace: Parse Key Fields
import json
from typing import Dict

def decode_trace(trace_path: str) -> Dict:
    with open(trace_path, 'r') as f:
        cert = json.load(f)
    
    # Extractors
    model = cert['model']
    U = cert['utility']
    components = cert['utility_components']
    feas = cert['constraints']['feasible']
    shadows = cert['constraints']['shadow_prices']
    gap = cert['boundary']['utility_gap']
    entropy = cert['boundary']['entropy']
    r_t = cert['drift']['trust_radius']
    
    # Insights
    insights = []
    if not feas:
        insights.append("Infeas: Loosen b via shadows.")
    if gap < 0.05 or entropy > 1.0:
        insights.append(f"Boundary: g={gap:.3f}, H={entropy:.2f}—explore.")
    if r_t < 0.5:
        insights.append("Tight r_t—check EMA drift.")
    
    return {
        "summary": {"model": model, "U": U},
        "components": components,
        "insights": insights,
        "sig": cert['pgd_signature'][:8]  # Prefix for quick ID
    }

# Example: Load Verbose
print(decode_trace('examples/trace.example.json'))

Clone this wiki locally