Skip to content

feat(backend): phase2-export.v1 — one-call handoff envelope for asa-ableton + the rec-proof harness - #156

Merged
slittycode merged 1 commit into
mainfrom
claude/asa-ableton-audit-gy9xdh
Jun 10, 2026
Merged

feat(backend): phase2-export.v1 — one-call handoff envelope for asa-ableton + the rec-proof harness#156
slittycode merged 1 commit into
mainfrom
claude/asa-ableton-audit-gy9xdh

Conversation

@slittycode

Copy link
Copy Markdown
Owner

What

A versioned, one-call handoff for ASA's Phase 2 output — the file boundary between this repo and the sibling asa-ableton .als generator, and the input the recommendation-proof harness scores.

New route: GET /api/analysis-runs/{run_id}/export/phase2

Returns a single self-contained phase2-export.v1 envelope:

Field Contents
phase2 stored producer_summary interpretation result verbatim, incl. the frozen recommendations.v1 projection (ADR 0003)
phase1 the authoritative measurement payload — cited phase1Fields paths are verifiable offline (PURPOSE invariant #2)
validationWarnings the full warn-and-keep trail (citation / semantic / catalogue-gate) from attempt diagnostics
provenance interpretation schema version, profile, model, prompt version, grounding ids

Backed by new apps/backend/phase2_export.py (thin lookup-and-serve, same pattern as csv_export.py). 404 RUN_NOT_FOUND / PHASE2_EXPORT_NOT_AVAILABLE. Derived and read-only — exports stored state, rewrites nothing (invariant #1).

Why now

Until this PR the handoff was snapshot surgery: the interpretation result is embedded in the run snapshot, the warnings live in a different subtree, provenance in a third. asa-ableton's Gate α fixture was hand-saved, and the owner plan's fixture loop ("drop phase2.json in each fixture dir") has the same manual step. Now it's:

curl http://127.0.0.1:8100/api/analysis-runs/<run_id>/export/phase2 -o phase2.json

evaluate_recommendations.py --phase2 (and a fixture-dir phase2.json) accepts the envelope directly via the new recommendation_evaluation.coerce_phase2_payload (bare Phase2Result still works).

Boundary doc

docs/ASA_ABLETON_BOUNDARY.md records the cross-repo contract: file-coupled not code-coupled, consumer guidance (prefer the citation-gated recommendations.v1 entries; dedupe (device, parameter, value) tuples — the driver of Gate α's 60.7% raw vs ~50% deduped skip rate; flagged ≠ invalid), and the v1 freeze policy (key set frozen by test; additions bump the version).

Tests

  • +15: 10 builder tests (tests/test_phase2_export.py, incl. envelope-key freeze), 3 route tests (Phase2ExportRouteTests), 2 envelope-unwrap tests.
  • tests.test_server 227 OK; adjacent suites (test_phase2_export, test_recommendation_evaluation, test_recommendations_contract, test_csv_export) 110 OK; scorer --self-test PASS.
  • Full unittest discover: identical pass/fail fingerprint to the unmodified tree in this container (residual errors are missing matplotlib/torch in the minimal env, not this change). CI runs the complete suite.

https://claude.ai/code/session_01YB5QFBLL4nbqPSdtcnxrLy


Generated by Claude Code

…bleton + the rec-proof harness

The ASA -> asa-ableton boundary (and the GOAL.md fixture loop) ran on
hand-extracted interpretation JSON: the result lives embedded in the run
snapshot, the warn-and-keep validationWarnings in a different subtree
(attempt diagnostics), and provenance in a third. asa-ableton's Gate
alpha fixture and every per-fixture phase2.json in the owner plan were
produced by snapshot surgery — an unversioned, fragile handoff.

1. phase2_export.py + GET /api/analysis-runs/{run_id}/export/phase2:
   single self-contained phase2-export.v1 envelope — the stored
   producer_summary interpretation result verbatim (incl. the frozen
   recommendations.v1 projection), the authoritative Phase 1 payload its
   citations resolve against (invariant #2 verifiable offline), the full
   validationWarnings trail, and provenance. Thin lookup-and-serve,
   csv_export.py pattern; 404 RUN_NOT_FOUND / PHASE2_EXPORT_NOT_AVAILABLE.
   Derived and read-only — exports stored state, rewrites nothing.
2. recommendation_evaluation.coerce_phase2_payload: --phase2 (and a
   fixture-dir phase2.json) now accepts either a bare Phase2Result or
   the export envelope, so the downloaded file feeds the scorer as-is.
3. docs/ASA_ABLETON_BOUNDARY.md: the cross-repo contract — file-coupled
   not code-coupled, consumer guidance (prefer recommendations.v1
   entries; dedupe is a consumer concern — Gate alpha's 60.7%-vs-50%
   skip-rate accounting; flagged != invalid), and the v1 freeze policy.

Tests: +15 (10 builder incl. envelope-key freeze, 3 route, 2 unwrap).
tests.test_server 227 OK; adjacent suites 110 OK; full discover matches
the unmodified-tree baseline exactly (env-only matplotlib/torch gaps).

https://claude.ai/code/session_01YB5QFBLL4nbqPSdtcnxrLy
@slittycode
slittycode merged commit 41db6fb into main Jun 10, 2026
3 of 4 checks passed
@slittycode
slittycode deleted the claude/asa-ableton-audit-gy9xdh branch June 10, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants