feat(backend): phase2-export.v1 — one-call handoff envelope for asa-ableton + the rec-proof harness - #156
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A versioned, one-call handoff for ASA's Phase 2 output — the file boundary between this repo and the sibling
asa-ableton.alsgenerator, and the input the recommendation-proof harness scores.New route:
GET /api/analysis-runs/{run_id}/export/phase2Returns a single self-contained
phase2-export.v1envelope:phase2producer_summaryinterpretation result verbatim, incl. the frozenrecommendations.v1projection (ADR 0003)phase1phase1Fieldspaths are verifiable offline (PURPOSE invariant #2)validationWarningsprovenanceBacked by new
apps/backend/phase2_export.py(thin lookup-and-serve, same pattern ascsv_export.py). 404RUN_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.jsonin each fixture dir") has the same manual step. Now it's:evaluate_recommendations.py --phase2(and a fixture-dirphase2.json) accepts the envelope directly via the newrecommendation_evaluation.coerce_phase2_payload(barePhase2Resultstill works).Boundary doc
docs/ASA_ABLETON_BOUNDARY.mdrecords the cross-repo contract: file-coupled not code-coupled, consumer guidance (prefer the citation-gatedrecommendations.v1entries; 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
tests/test_phase2_export.py, incl. envelope-key freeze), 3 route tests (Phase2ExportRouteTests), 2 envelope-unwrap tests.tests.test_server227 OK; adjacent suites (test_phase2_export,test_recommendation_evaluation,test_recommendations_contract,test_csv_export) 110 OK; scorer--self-testPASS.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