#!/usr/bin/env python3 """Structural-path full-corpus harness (render48k, 48000/4096 internal grid). Mirrors scripts/corpus.py but drives dsp/build/render48k (structural FUN_180529fe0 chain on the internal grid) instead of framed_test (bridge). Purpose: honest per-group comparison of the structural chain against the committed bridge baseline (BITEXACT_PLAN step-1 criterion: structural must not regress below bridge on single-band groups). Usage: python3 scripts/corpus_structural.py [--out results.json] python3 scripts/corpus_structural.py --vs-bridge scripts/baseline_bridge.json """ import json, sys sys.path.insert(0, 'scripts') import corpus corpus.RB = '/home/m/re-tools/dsp/build/render48k' _orig_build_cases = corpus.build_cases def build_cases_structural(): cases = [] for name, inp, args, ref, f in _orig_build_cases(): # render48k parses only comma-form band args; join split dual args. joined = [','.join(args)] if len(args) == 3 else args cases.append((name, inp, joined, ref, f)) return cases corpus.build_cases = build_cases_structural if __name__ == '__main__': a = sys.argv[1:] if a and a[0] == '--vs-bridge': base = json.load(open(a[1])) res, _ = corpus.run_all() bs, cs = corpus.group_stats(base), corpus.group_stats(res) print(f'{"group":>12} {"n":>3} {"bridge":>8} {"struct":>8} {"d":>8} {"max":>7}') for g in ['t1kq', 't1k', 'al', 'res', 'dual', 'comb', 'TOTAL']: if g not in cs: continue b = bs.get(g, {'mean_abs': float('nan')})['mean_abs'] s = cs[g] print(f'{g:>12} {s["n"]:>3} {b:>8.3f} {s["mean_abs"]:>8.3f} ' f'{s["mean_abs"] - b:>+8.3f} {s["max_abs"]:>7.3f}') sys.exit(0) sys.exit(corpus.main())