diff --git a/.github/workflows/phase6c-historical-it-private.yml b/.github/workflows/phase6c-historical-it-private.yml index e30dbf19..b07a4ced 100644 --- a/.github/workflows/phase6c-historical-it-private.yml +++ b/.github/workflows/phase6c-historical-it-private.yml @@ -183,6 +183,15 @@ jobs: qmake CONFIG-=shared CONFIG+=release psycle-player.pro make -j2 + - name: Attest frozen historical candidate player + shell: bash + run: | + set -euo pipefail + mkdir -p phase6c-historical-public + python3 scripts/phase6c-midi-corpus.py attest-candidate-player \ + psycle-cpp-r12005-sanitized/psycle-player/++qmake/psycle-player \ + phase6c-historical-public/candidate-player-attestation.json + - name: Observe candidate historical direct-import boundary shell: bash run: | @@ -199,7 +208,8 @@ jobs: python3 scripts/phase6c-historical-it.py candidate \ "$RUNROOT/d-503_-_sickmaate.it" \ "$RUNROOT/candidate-psycle-player" \ - phase6c-historical-public/candidate-historical-it.json + phase6c-historical-public/candidate-historical-it.json \ + --attestation phase6c-historical-public/candidate-player-attestation.json rm -rf -- "$RUNROOT" rm -f -- "$HISTORICAL_IT" ! find phase6c-historical-public -type f -iname '*.it' -print -quit | grep -q . diff --git a/.github/workflows/phase6c-legacy-playback-import.yml b/.github/workflows/phase6c-legacy-playback-import.yml index 79ba3282..15c8dacf 100644 --- a/.github/workflows/phase6c-legacy-playback-import.yml +++ b/.github/workflows/phase6c-legacy-playback-import.yml @@ -6,6 +6,14 @@ on: - main - 'phase-6c/**' paths: + - 'phase6c/legacy-closeout.json' + - 'phase6c/LEGACY_CLOSEOUT.md' + - 'phase6c/compatibility-matrix.json' + - 'phase6c/SAMPLER_PS1.md' + - 'phase6c/DELAYED_RETRIGGER.md' + - 'phase6c/evidence/sampler-ps1/pitch-hosted/**' + - 'scripts/phase6c-legacy-closeout.py' + - 'tests/phase6c_legacy_closeout.py' - 'phase6c/LEGACY_PLAYBACK_IMPORT.md' - 'phase6c/evidence/legacy-module-import/**' - 'phase6c/reference-corpus/**' @@ -39,6 +47,14 @@ on: - 'README.md' pull_request: paths: + - 'phase6c/legacy-closeout.json' + - 'phase6c/LEGACY_CLOSEOUT.md' + - 'phase6c/compatibility-matrix.json' + - 'phase6c/SAMPLER_PS1.md' + - 'phase6c/DELAYED_RETRIGGER.md' + - 'phase6c/evidence/sampler-ps1/pitch-hosted/**' + - 'scripts/phase6c-legacy-closeout.py' + - 'tests/phase6c_legacy_closeout.py' - 'phase6c/LEGACY_PLAYBACK_IMPORT.md' - 'phase6c/evidence/legacy-module-import/**' - 'phase6c/reference-corpus/**' @@ -92,6 +108,19 @@ jobs: python3 tests/phase6c_legacy_module_import.py python3 tests/phase6c_historical_it.py python3 tests/phase6c_midi_corpus.py + python3 tests/phase6c_legacy_closeout.py + + - name: Validate legacy implementation closeout and pending gates + run: | + python3 scripts/phase6c-legacy-closeout.py \ + --output phase6c-generated/legacy-closeout.json + + - name: Upload legacy closeout handoff + uses: actions/upload-artifact@v4 + with: + name: phase6c-legacy-lane-closeout + path: phase6c-generated/legacy-closeout.json + if-no-files-found: error - name: Generate canonical IT fixture run: | diff --git a/PSYCLE_CORE_PARITY.md b/PSYCLE_CORE_PARITY.md index f8889f6d..a3877e2b 100644 --- a/PSYCLE_CORE_PARITY.md +++ b/PSYCLE_CORE_PARITY.md @@ -149,6 +149,10 @@ Phase 6 separates engine gaps from UI gaps. The absence of a full tracker UI in - C-Psycle platform UI bridge implementation details; - C-Psycle's newer event-sequencer internals when they differ from original Psycle. +## Legacy detour handoff + +The [legacy-lane closeout](phase6c/LEGACY_CLOSEOUT.md) records the IT/MIDI donor repairs and named follow-ups for unresolved import/translation/runtime boundaries. Its implementation is complete; historical and MIDI private observations remain pending. No matrix row is added or promoted, and the return point after observation review is the pending Sampler PS1 E-D3/E-C3 paired witness. + ## Current implementation backlog Phase 6C now justifies this evidence backlog: diff --git a/README.md b/README.md index c1a0357f..cc369cda 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ That distinction changes the implementation strategy. **C-Psycle is no longer treated as the literal implementation base for the final Linux Psycle.** The extensive work already completed against `cpsycle/` remains valuable as a preservation corpus, compatibility laboratory, behavioural oracle, Linux-port reference, and regression suite. -Phase 6B is complete: the provenance-cleared SourceForge SVN r12005 C++ candidate has been imported as `psycle-cpp-r12005-sanitized/`, frozen by a reproducible baseline identity, and its historical Linux `psycle-player` build is maintained in CI. Phase 6C is collecting evidence against the pinned Psycle 1.12.0 x86 reference, while Phase 6D keeps the human parity report mechanically synchronized with the canonical compatibility matrix. **The immediate Phase 6C priority is now the legacy playback/import evidence lane**: a generated redistributable Impulse Tracker fixture, a hash-bound historical `.it` witness, and a contributor-supplied MIDI reference corpus are being used to expose shared song-I/O, timing, sampler, command and routing failures before expanding the remaining isolated contracts. See [`phase6c/LEGACY_PLAYBACK_IMPORT.md`](phase6c/LEGACY_PLAYBACK_IMPORT.md). The current 20-contract matrix itself is unchanged: three scoped `PASS` results, one scoped serialization/save `MISSING` result, one scoped BPM/LPB/tick `DIFFERENT` result, and 15 `UNKNOWN` contracts. +Phase 6B is complete: the provenance-cleared SourceForge SVN r12005 C++ candidate has been imported as `psycle-cpp-r12005-sanitized/`, frozen by a reproducible baseline identity, and its historical Linux `psycle-player` build is maintained in CI. Phase 6C is collecting evidence against the pinned Psycle 1.12.0 x86 reference, while Phase 6D keeps the human parity report mechanically synchronized with the canonical compatibility matrix. **The legacy playback/import detour implementation is now closed out, with private observation gates still pending**: a generated redistributable Impulse Tracker fixture, a hash-bound historical `.it` witness, and a contributor-supplied MIDI reference corpus are being used to expose shared song-I/O, timing, sampler, command and routing failures before expanding the remaining isolated contracts. See the [closeout and return plan](phase6c/LEGACY_CLOSEOUT.md) and [`phase6c/LEGACY_PLAYBACK_IMPORT.md`](phase6c/LEGACY_PLAYBACK_IMPORT.md). After private observation review, the return point is the pending Sampler PS1 E-D3/E-C3 paired witness. The current 20-contract matrix itself is unchanged: three scoped `PASS` results, one scoped serialization/save `MISSING` result, one scoped BPM/LPB/tick `DIFFERENT` result, and 15 `UNKNOWN` contracts. ## Dedication diff --git a/ROADMAP.md b/ROADMAP.md index 80e82f34..a0f05f15 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -270,7 +270,9 @@ At the start of Phase 6A the repository did **not** import the C++ engine family ### 6C — build a three-way compatibility matrix -> **Current priority hold — legacy playback/import evidence.** After the Sampler PS1 E-D3/E-C3 lane, new Phase 6C expansion is temporarily deferred while the project establishes a legacy module import/playback baseline. Historical module import crosses song I/O, sequence construction, tracker-command translation, samples, loops, sampler state, timing and routing in one path, making it a high-value diagnostic for shared playback defects. The first lane uses a generated redistributable IT fixture plus the hash-bound external `SickMaate` historical witness and the contributor-supplied MIDI reference corpus. Existing receipts and matrix verdicts remain frozen. See [`phase6c/LEGACY_PLAYBACK_IMPORT.md`](phase6c/LEGACY_PLAYBACK_IMPORT.md). +**Legacy implementation closeout:** the IT/MIDI donor repairs and remaining boundaries now have a checked [handoff ledger](phase6c/LEGACY_CLOSEOUT.md), forming the intended v0.2.0 checkpoint. The historical and real-corpus observation/review gates remain pending; the priority hold below is not automatically cleared. After those outcomes are recorded and reviewed, resume the pending Sampler PS1 E-D3/E-C3 paired witness, then the existing narrow PS1 ladder. + +> **Current priority hold — legacy playback/import evidence.** The Sampler PS1 E-D3/E-C3 collector is implemented, but its pending paired observation and new Phase 6C expansion are temporarily deferred while the legacy module import/playback lane completes its private observation gates. Historical module import crosses song I/O, sequence construction, tracker-command translation, samples, loops, sampler state, timing and routing in one path, making it a high-value diagnostic for shared playback defects. The lane uses a generated redistributable IT fixture plus the hash-bound external `SickMaate` historical witness and the contributor-supplied MIDI reference corpus. Existing receipts and matrix verdicts remain frozen. See [`phase6c/LEGACY_PLAYBACK_IMPORT.md`](phase6c/LEGACY_PLAYBACK_IMPORT.md). Compare: diff --git a/phase6c/LEGACY_CLOSEOUT.md b/phase6c/LEGACY_CLOSEOUT.md new file mode 100644 index 00000000..ae087cf0 --- /dev/null +++ b/phase6c/LEGACY_CLOSEOUT.md @@ -0,0 +1,96 @@ +# Phase 6C — Legacy-lane closeout + +The IT/MIDI detour has an **implementation closeout**, recorded in +[`legacy-closeout.json`](legacy-closeout.json). The repaired donor paths and +remaining capability/translation boundaries have explicit dispositions and +follow-up actions. **Private observation closeout remains pending.** This is +the intended v0.2.0 implementation checkpoint, not a new parity verdict. + +## Repair and handoff ledger + +| Boundary | Disposition | Retained scope / follow-up | +| --- | --- | --- | +| IT sample-mode instruments and routes | Repaired in C-Psycle | Canonical fixture, two identical non-silent 512-frame renders | +| Disabled/dormant SMF import path | Repaired in C-Psycle | Existing loader restored; pre-projection event graph recorded | +| MIDI releases and voice allocation | Repaired in C-Psycle | Equal-tick/terminal releases, channel matching, high notes and 64-voice reuse | +| MIDI timing/event semantics | Repaired in C-Psycle | Exact ticks, tempo maps, initial BPM, SysEx, running status, note/CC digests | +| Ended Sampulse foreground voice | Repaired in C-Psycle | Avoid period recalculation without a live sample controller | +| Frozen candidate direct IT/SMF loading | Handed off | Narrow host/song-I/O capability lane; establish original requirements first | +| IT note-cut → release compromise | Handed off | Pin original note-cut behavior before translation changes | +| Native MIDI instrument selection | Handed off | Deterministic Sampler projection proves execution; instrument choice remains separate | +| Original Sampler startup / render attribution | Handed off | Continue paired PS1 and delayed/retrigger evidence; donor fixes do not settle original behavior | + +The ledger's `references` point to the retained source, procedures and regression +probes. `REPAIRED_DONOR_ONLY` describes the scoped donor repair, never original +Psycle compatibility. `HANDED_OFF` means the boundary has a named next action; +it does not mean the capability is implemented or verified. + +The compatibility matrix, historical-input manifest and six-set corpus manifest +remain byte-identical to the PR #89 checkpoint. The closeout validator checks +their SHA-256 identities. Future changes must explicitly revise the closeout +snapshot rather than presenting changed inputs as this checkpoint. + +## Validate the checkpoint + +```bash +python3 tests/phase6c_legacy_closeout.py +python3 scripts/phase6c-legacy-closeout.py --output /tmp/legacy-closeout.json +``` + +Ordinary PR CI runs the new controls alongside the existing IT, historical and +MIDI contracts and the native donor execution probes. Its new +`phase6c-legacy-lane-closeout` artifact reports the implementation handoff with +both private observation gates pending. A successful validator exit means the +encoded closeout contract passed; it does not mean the private corpus ran. + +## Outstanding private observations + +| Lane | Masked repository secret | Combined artifact | +| --- | --- | --- | +| Historical `SickMaate` | `PSYCLE_PHASE6C_HISTORICAL_IT_URL` | `phase6c-historical-sickmaate-three-way-summary` | +| Six MIDI stem sets | `PSYCLE_PHASE6C_MIDI_CORPUS_URL` | `phase6c-midi-real-world-corpus-summary` | + +Dispatch the existing manual workflows documented in +[`LEGACY_PLAYBACK_IMPORT.md`](LEGACY_PLAYBACK_IMPORT.md), then download and +extract each **combined** artifact. Raw IT/MIDI/ZIP/WAV bytes stay outside the +public evidence roots. Recheck the summary against its complete component files: + +```bash +python3 scripts/phase6c-legacy-closeout.py \ + --historical-artifact /path/to/historical-summary \ + --midi-artifact /path/to/midi-summary \ + --output /tmp/legacy-closeout-observations.json +``` + +The tool reruns the existing summary/component validators, checks the recreated +summary matches, rejects missing or changed support files, and audits the roots +for private payloads and symlinks. Both lanes require the frozen candidate's +clean-rebuild attestation, retained executable, dependency identities and exact +workflow repository revision. Use a checkout of the exact workflow head to +revalidate downloaded artifacts, rather than relabeling old evidence as a new +run. Historical artifacts produced before this attestation was added cannot +satisfy the closeout gate; repeat the private observation with the attested +workflow instead of retroactively issuing identity claims for an old run. + +`COMPONENTS_REVALIDATED` means summary integrity under those existing contracts. +It is narrower than an independent execution replay or a new original-reference +behavioral verdict. Missing artifacts stay `PENDING_PRIVATE_DISPATCH`; malformed +supplied evidence fails validation. Neither a self-reported success flag nor an +inconclusive original observation clears the priority hold automatically. + +## Return to the main evidence ladder + +Once the private outcomes have been reviewed against the existing priority-hold +exit criteria and any new defect has been isolated or handed off, record the +observation identities and update the working roadmap. The return point is the +pending **Sampler PS1 E-D3/E-C3 paired runtime witness**, then the narrow +envelope/loop/panning/offset/volume/retrigger/state ladder in +[`SAMPLER_PS1.md`](SAMPLER_PS1.md). XMSampler and routing follow under normal +Phase 6C evidence rules. The confirmed Phase 7 serializer and TPB/extra-tick +backlog remains separate. + +This implementation checkpoint leaves all existing matrix verdicts untouched: +three scoped `PASS`, one `MISSING`, one `DIFFERENT` and fifteen `UNKNOWN`. +The closeout report itself always retains `parity_status: UNKNOWN` and +`priority_hold: AWAITING_OBSERVATION_REVIEW`; it cannot authorize engine +convergence or deferred evidence expansion by itself. diff --git a/phase6c/LEGACY_PLAYBACK_IMPORT.md b/phase6c/LEGACY_PLAYBACK_IMPORT.md index a147ac24..40869fa4 100644 --- a/phase6c/LEGACY_PLAYBACK_IMPORT.md +++ b/phase6c/LEGACY_PLAYBACK_IMPORT.md @@ -15,8 +15,8 @@ While the legacy lane is active, **this document is the working roadmap**. The b 1. [x] **Import/translation baseline** — canonical generated IT identity, donor import/decoder coverage, pinned-original acceptance observation, and frozen-candidate direct-import boundary. 2. [x] **Sample-mode playback witness** — C-Psycle sample-mode instrument/virtual-generator mapping is restored and the canonical generated fixture has a deterministic non-silent donor playback witness. 3. [ ] **Historical `SickMaate` three-way summary — private observation pending** — the privacy-preserving original/candidate/donor workflow is implemented; the three-way observation remains pending manual dispatch with the private historical input. -4. [ ] **MIDI real-world playback corpus — current phase** — exercise the contributor-supplied SMF corpus from gentle baseline through dense timing/polyphony/routing stress, keeping native MIDI import separate from the deterministic audibility projection. -5. [ ] **Legacy-lane closeout** — isolate or hand off any remaining shared playback defects, then resume the deferred Phase 6C contract ladder. +4. [ ] **MIDI real-world playback corpus — implementation complete, private observation pending** — exercise the contributor-supplied SMF corpus from gentle baseline through dense timing/polyphony/routing stress, keeping native MIDI import separate from the deterministic audibility projection. +5. [x] **Legacy-lane implementation closeout** — repaired donor defects and remaining boundaries are recorded in the checked [closeout ledger](LEGACY_CLOSEOUT.md). Private observation/review gates remain pending before the deferred Phase 6C contract ladder resumes. No item in this temporary roadmap may promote original-Psycle parity without the normal paired/versioned evidence requirements. @@ -227,6 +227,12 @@ This gives the project two complementary layers: 1. **minimal generated fixtures** that continuously isolate and exercise the execution path; 2. **real musical corpora** that reveal interactions and audible regressions under private, identity-bound observation. +## Implementation closeout + +The final implementation step is recorded in [`LEGACY_CLOSEOUT.md`](LEGACY_CLOSEOUT.md) and `legacy-closeout.json`. The closeout validator preserves the matrix and private-input manifest identities, checks all repair/handoff dispositions, and can revalidate downloaded combined observation artifacts through the existing lane validators. This is the intended v0.2.0 checkpoint. It does not turn implemented workflows into completed private observations or clear the priority hold by itself. + +After the outstanding private observations are reviewed, resume the pending Sampler PS1 E-D3/E-C3 paired runtime witness before widening the remaining PS1, XMSampler and routing contracts. + ## Exit criteria for the temporary priority hold Resume the previously deferred Phase 6C expansion after all of the following are true: @@ -238,6 +244,6 @@ Resume the previously deferred Phase 6C expansion after all of the following are - [x] C-Psycle sample-mode import has a deterministic non-silent playback witness from the unchanged canonical fixture; - [ ] the historical `SickMaate` witness has a hash-bound original/candidate/C-Psycle observation summary without redistributing its samples; - [ ] the contributor-supplied MIDI corpus has begun real-world playback observations after the minimal IT witness is stable; -- [ ] any discovered shared playback defect has either been isolated or explicitly handed off to a narrow fix/evidence PR. +- [x] shared playback defects discovered in the implemented detour have been repaired in the donor or explicitly handed off with a scoped next action in [`legacy-closeout.json`](legacy-closeout.json); new private-run findings must receive the same treatment. Only then return to the remaining Sampler PS1, XMSampler, routing and other Phase 6C rows. diff --git a/phase6c/legacy-closeout.json b/phase6c/legacy-closeout.json new file mode 100644 index 00000000..c313e876 --- /dev/null +++ b/phase6c/legacy-closeout.json @@ -0,0 +1,122 @@ +{ + "schema_version": 1, + "phase": "6C", + "contract": "legacy-playback-import-closeout", + "implementation_status": "COMPLETE", + "parity_status": "UNKNOWN", + "resume_contract": "sampler-ps1-extended-timing", + "preserved_inputs": { + "phase6c/compatibility-matrix.json": "70e9321d9b5cb5960d2bf15f7ee2c3b71824a7780cf9602395bc4f79c7f7f1c6", + "phase6c/reference-corpus/manifest.json": "e5ade0893e9b1f00861120a3f6f216e03a4328a83ee0ce9224d52592c865d949", + "phase6c/evidence/legacy-module-import/historical-sickmaate.json": "07099abd15c028d8be5a27d76a4990f2b51fb4cecd2b1e09b5727356891c318d" + }, + "dispositions": [ + { + "id": "it-sample-mode-route", + "status": "REPAIRED_DONOR_ONLY", + "scope": "IT sample-mode imports now materialize Sampulse instruments and virtual-generator routes. The canonical fixture produces two identical non-silent 512-frame donor renders.", + "next_action": "Keep this donor regression; measure original/candidate sample and command semantics independently.", + "references": [ + "cpsycle/audio/src/itmodule2.c", + "tests/phase6c_legacy_it_playback.c" + ] + }, + { + "id": "midi-import-execution", + "status": "REPAIRED_DONOR_ONLY", + "scope": "Restore the existing SMF feature gate and initialize imported PatternEntry objects. Freeze native import before attaching the project-owned classic Sampler for a bounded execution projection.", + "next_action": "Keep native import distinct from instrument selection and audibility.", + "references": [ + "cpsycle/detail/psyconf.h", + "cpsycle/audio/src/midiloader.c", + "tests/phase6c_midi_corpus_probe.c" + ] + }, + { + "id": "midi-release-polyphony", + "status": "REPAIRED_DONOR_ONLY", + "scope": "Preserve equal-tick and terminal releases, channel-aware matching, all 128 MIDI note slots, and 64 simultaneous voices with reuse.", + "next_action": "Retain zero-duration, equal-tick, multichannel, high-note, repeated-chord and 64-note regression fixtures.", + "references": [ + "cpsycle/audio/src/midiloader.c", + "scripts/phase6c-midi-corpus.py", + "tests/phase6c_midi_corpus.py" + ] + }, + { + "id": "midi-tempo-event-semantics", + "status": "REPAIRED_DONOR_ONLY", + "scope": "Preserve exact cumulative ticks, tempo maps and tick-zero BPM, SysEx parsing and channel running status across meta events. Independently compare note, controller and tempo semantics with imported graph digests.", + "next_action": "Keep the synthetic semantic comparisons in the native donor CI lane; run the six-set private corpus separately.", + "references": [ + "cpsycle/audio/src/midiloader.c", + "tests/phase6c_midi_corpus_probe.c", + "scripts/phase6c-midi-corpus.py" + ] + }, + { + "id": "sampulse-ended-voice", + "status": "REPAIRED_DONOR_ONLY", + "scope": "Do not recalculate the period of an ended foreground voice whose wave controller lacks a sample. This repair was exposed by the earlier Sampulse MIDI projection.", + "next_action": "Keep the sample-mode IT playback witness; the MIDI lane now deliberately uses classic Sampler.", + "references": [ + "cpsycle/audio/src/xmsampler.c", + "tests/phase6c_legacy_it_playback.c", + "tests/phase6c_historical_it_probe.c" + ] + }, + { + "id": "candidate-legacy-file-loaders", + "status": "HANDED_OFF", + "scope": "Frozen C++ direct IT/SMF load rejection is a scoped host/song-I/O boundary. Internal sampler and MIDI machinery are not classified as absent.", + "next_action": "A later narrow loader capability/evidence PR must pin original requirements before candidate convergence.", + "references": [ + "phase6c/LEGACY_PLAYBACK_IMPORT.md", + "scripts/phase6c-historical-it.py", + "scripts/phase6c-midi-corpus.py" + ] + }, + { + "id": "it-note-cut-translation", + "status": "HANDED_OFF", + "scope": "The retained donor maps IT note cut 254 to Psycle release; this is an explicit translation compromise, not an original-Psycle equivalence claim.", + "next_action": "Observe pinned-original note-cut versus release behavior with a minimal fixture before changing the translation.", + "references": [ + "cpsycle/audio/src/itmodule2.c", + "tests/phase6c_legacy_it_loader.c", + "phase6c/LEGACY_PLAYBACK_IMPORT.md" + ] + }, + { + "id": "midi-native-instrument-selection", + "status": "HANDED_OFF", + "scope": "SMF import creates no sound-generating machines. Deterministic classic-Sampler projection supplies audibility while preserving the pre-projection imported graph.", + "next_action": "Keep native MIDI instrument choice, external MIDI output and original-reference MIDI parity in separate observation/implementation lanes.", + "references": [ + "tests/phase6c_midi_corpus_probe.c", + "phase6c/reference-corpus/manifest.json" + ] + }, + { + "id": "original-runtime-sampler", + "status": "HANDED_OFF", + "scope": "Original-reference sample startup and ambiguous render attribution remain unresolved in existing lanes; donor repairs do not resolve these boundaries.", + "next_action": "Resume the pending PS1 E-D3/E-C3 paired witness after observation closeout, then narrow envelope/loop/panning/offset/volume/retrigger and state witnesses.", + "references": [ + "phase6c/SAMPLER_PS1.md", + "phase6c/DELAYED_RETRIGGER.md", + "phase6c/evidence/sampler-ps1/pitch-hosted/observation.json" + ] + } + ], + "pending_observations": { + "historical-sickmaate": { + "status": "PENDING_PRIVATE_DISPATCH", + "workflow": ".github/workflows/phase6c-historical-it-private.yml" + }, + "midi-real-world-corpus": { + "status": "PENDING_PRIVATE_DISPATCH", + "workflow": ".github/workflows/phase6c-midi-corpus-private.yml" + } + } +} diff --git a/scripts/phase6c-historical-it.py b/scripts/phase6c-historical-it.py index bce0496c..562d561a 100644 --- a/scripts/phase6c-historical-it.py +++ b/scripts/phase6c-historical-it.py @@ -4,6 +4,7 @@ import argparse import hashlib +import importlib.util import json import pathlib import shutil @@ -24,6 +25,28 @@ EXPECTED_REFERENCE_EXECUTABLE_SHA256 = ( "fdb130d2465d5b4a4acfbfe0bfb2368926380fe07a383c4774f0951591b6d6b6" ) +BUILD_IDENTITY_FIELDS = ( + "candidate_baseline_sha256", "source_revision", "repository_commit", + "build_target", "plugin_interface_git_blob", "diversalis_revision", + "diversalis_file_count", "diversalis_manifest_sha256", "clean_rebuild_sha256", +) + + +def candidate_build_identity(player: pathlib.Path, attestation: pathlib.Path) -> dict[str, Any]: + """Reuse the exact frozen-player attestation contract from the MIDI lane.""" + spec = importlib.util.spec_from_file_location( + "historical_candidate_build", ROOT / "scripts/phase6c-midi-corpus.py" + ) + helper = importlib.util.module_from_spec(spec) + assert spec.loader is not None + spec.loader.exec_module(helper) + with player.open("rb") as handle: + if handle.read(4) != b"\x7fELF": + die("historical candidate player is not an ELF executable") + verified = helper.validate_candidate_attestation( + attestation, player, helper.repository_commit() + ) + return {field: verified[field] for field in BUILD_IDENTITY_FIELDS} def die(message: str) -> "NoReturn": @@ -154,6 +177,10 @@ def command_candidate(args: argparse.Namespace) -> None: identity = validate_historical_file(input_path) if not player.is_file(): die(f"candidate player is missing: {player}") + attestation = args.attestation.resolve() + if attestation.parent != args.output.resolve().parent: + die("historical candidate attestation must be retained beside its receipt") + build_identity = candidate_build_identity(player, attestation) player_sha = sha256_file(player) if input_path.parent != player.parent: die("candidate replay requires the private IT beside the candidate player") @@ -183,6 +210,9 @@ def command_candidate(args: argparse.Namespace) -> None: "source_size_bytes": identity["size_bytes"], "player": "candidate-psycle-player", "player_sha256": player_sha, + **build_identity, + "build_attestation": attestation.name, + "build_attestation_sha256": sha256_file(attestation), "command": [ "./candidate-psycle-player", "--output-driver", @@ -346,6 +376,18 @@ def validate_summary_components( candidate.get("player_sha256"), "candidate player", ) + require_public_support_file( + candidate_path, + candidate.get("build_attestation"), + candidate.get("build_attestation_sha256"), + "candidate build attestation", + ) + build_identity = candidate_build_identity( + candidate_path.parent / candidate["player"], + candidate_path.parent / candidate["build_attestation"], + ) + if any(candidate.get(field) != value for field, value in build_identity.items()): + die("historical candidate receipt differs from its frozen build identity") require_hash(candidate.get("raw_output_sha256"), "candidate raw_output_sha256") require_common_receipt( @@ -473,6 +515,7 @@ def build_parser() -> argparse.ArgumentParser: candidate.add_argument("input", type=pathlib.Path) candidate.add_argument("player", type=pathlib.Path) candidate.add_argument("output", type=pathlib.Path) + candidate.add_argument("--attestation", type=pathlib.Path, required=True) candidate.set_defaults(func=command_candidate) summary = sub.add_parser("summary", help="build a public-safe three-way summary") diff --git a/scripts/phase6c-legacy-closeout.py b/scripts/phase6c-legacy-closeout.py new file mode 100644 index 00000000..181e7245 --- /dev/null +++ b/scripts/phase6c-legacy-closeout.py @@ -0,0 +1,233 @@ +#!/usr/bin/env python3 +"""Validate the legacy detour handoff and recheck sanitized observation summaries. + +A valid implementation ledger is not proof that private observations ran. The +report keeps those gates pending unless their complete component artifacts pass +the existing lane validators. No compatibility row is written or classified. +""" +from __future__ import annotations + +import argparse +import contextlib +import hashlib +import importlib.util +import io +import json +import pathlib +import tempfile +from typing import Any + +ROOT = pathlib.Path(__file__).resolve().parents[1] +LEDGER = ROOT / "phase6c/legacy-closeout.json" +CONTRACT = "legacy-playback-import-closeout" +PINS = { + "phase6c/compatibility-matrix.json": "70e9321d9b5cb5960d2bf15f7ee2c3b71824a7780cf9602395bc4f79c7f7f1c6", + "phase6c/reference-corpus/manifest.json": "e5ade0893e9b1f00861120a3f6f216e03a4328a83ee0ce9224d52592c865d949", + "phase6c/evidence/legacy-module-import/historical-sickmaate.json": "07099abd15c028d8be5a27d76a4990f2b51fb4cecd2b1e09b5727356891c318d", +} +DISPOSITIONS = { + "it-sample-mode-route": "REPAIRED_DONOR_ONLY", + "midi-import-execution": "REPAIRED_DONOR_ONLY", + "midi-release-polyphony": "REPAIRED_DONOR_ONLY", + "midi-tempo-event-semantics": "REPAIRED_DONOR_ONLY", + "sampulse-ended-voice": "REPAIRED_DONOR_ONLY", + "candidate-legacy-file-loaders": "HANDED_OFF", + "it-note-cut-translation": "HANDED_OFF", + "midi-native-instrument-selection": "HANDED_OFF", + "original-runtime-sampler": "HANDED_OFF", +} +OBSERVATIONS = { + "historical-sickmaate": ".github/workflows/phase6c-historical-it-private.yml", + "midi-real-world-corpus": ".github/workflows/phase6c-midi-corpus-private.yml", +} + + +def fail(message: str) -> None: + raise ValueError(message) + + +def reject_duplicate_keys(pairs): + result = {} + for key, value in pairs: + if key in result: + fail(f"duplicate JSON key: {key}") + result[key] = value + return result + + +def read_json(path: pathlib.Path) -> dict[str, Any]: + data = json.loads(path.read_text(encoding="utf-8"), object_pairs_hook=reject_duplicate_keys) + if not isinstance(data, dict): + fail(f"JSON root must be an object: {path.name}") + return data + + +def digest(path: pathlib.Path) -> str: + return hashlib.sha256(path.read_bytes()).hexdigest() + + +def local_file(root: pathlib.Path, name: Any) -> pathlib.Path: + if not isinstance(name, str) or not name or "\\" in name: + fail("artifact/repository path must be a nonempty POSIX path") + relative = pathlib.PurePosixPath(name) + if relative.is_absolute() or ".." in relative.parts: + fail(f"path escapes root: {name}") + path = root / name + if not path.resolve().is_relative_to(root.resolve()) or not path.is_file(): + fail(f"missing or escaping file: {name}") + return path + + +def load_helper(filename: str): + spec = importlib.util.spec_from_file_location(filename.replace("-", "_"), ROOT / "scripts" / filename) + module = importlib.util.module_from_spec(spec) + assert spec.loader is not None + spec.loader.exec_module(module) + return module + + +def validate_ledger(ledger: dict[str, Any]) -> None: + required = { + "schema_version": 1, + "phase": "6C", + "contract": CONTRACT, + "implementation_status": "COMPLETE", + "parity_status": "UNKNOWN", + "resume_contract": "sampler-ps1-extended-timing", + } + for key, expected in required.items(): + if type(ledger.get(key)) is not type(expected) or ledger[key] != expected: + fail(f"closeout {key} changed") + if ledger.get("preserved_inputs") != PINS: + fail("closeout preserved input identities changed") + for path, expected in PINS.items(): + if digest(local_file(ROOT, path)) != expected: + fail(f"preserved input hash mismatch: {path}") + items = ledger.get("dispositions") + if not isinstance(items, list) or len(items) != len(DISPOSITIONS): + fail("closeout disposition set is incomplete") + seen = set() + for item in items: + if not isinstance(item, dict): + fail("disposition must be an object") + identifier = item.get("id") + if not isinstance(identifier, str) or identifier in seen or identifier not in DISPOSITIONS: + fail("unknown or duplicate disposition") + seen.add(identifier) + if item.get("status") != DISPOSITIONS[identifier]: + fail(f"{identifier}: invalid disposition status") + for field in ("scope", "next_action"): + if not isinstance(item.get(field), str) or not item[field].strip(): + fail(f"{identifier}: {field} is required") + references = item.get("references") + if not isinstance(references, list) or not references: + fail(f"{identifier}: references are required") + for reference in references: + local_file(ROOT, reference) + observations = ledger.get("pending_observations") + if not isinstance(observations, dict) or set(observations) != set(OBSERVATIONS): + fail("closeout pending observation set changed") + for identifier, workflow in OBSERVATIONS.items(): + item = observations[identifier] + if not isinstance(item, dict) or item.get("status") != "PENDING_PRIVATE_DISPATCH" or item.get("workflow") != workflow: + fail(f"{identifier}: pending observation boundary changed") + local_file(ROOT, workflow) + local_file(ROOT, "phase6c/SAMPLER_PS1.md") + + +def audit_artifact(root: pathlib.Path) -> None: + if not root.is_dir(): + fail("observation artifact root is missing") + # Reject links before the lane validators read any support file. + if root.is_symlink() or any(path.is_symlink() for path in root.rglob("*")): + fail("observation artifacts must not contain symlinks") + load_helper("phase6c-midi-corpus.py").audit_public_tree(root) + for path in root.rglob("*"): + if path.is_file(): + prefix = path.read_bytes()[:12] + wave = prefix[:4] in {b"RIFF", b"RIFX", b"RF64"} and prefix[8:12] == b"WAVE" + if path.suffix.lower() in {".it", ".wav"} or prefix.startswith(b"IMPM") or wave: + fail("observation artifact contains raw IT/audio payload") + + +def revalidate_summary(root: pathlib.Path, lane: str) -> dict[str, Any]: + audit_artifact(root) + # Recreate the complete summary from its component files. Reading a top-level + # success flag or hash alone would admit an incomplete/edited observation. + with tempfile.TemporaryDirectory() as temporary: + output = pathlib.Path(temporary) / "summary.json" + if lane == "historical-sickmaate": + helper = load_helper("phase6c-historical-it.py") + summary = local_file(root, "historical-sickmaate-three-way.json") + with contextlib.redirect_stdout(io.StringIO()): + helper.command_summary(argparse.Namespace( + donor=local_file(root, "donor/cpsycle-historical-it.json"), + candidate=local_file(root, "candidate/candidate-historical-it.json"), + original=local_file(root, "original/original-historical-legacy-it.json"), + output=output, + )) + elif lane == "midi-real-world-corpus": + helper = load_helper("phase6c-midi-corpus.py") + summary = local_file(root, "midi-real-world-corpus-summary.json") + helper.corpus_summary( + local_file(root, "donor/donor-midi-corpus.json"), + local_file(root, "candidate/candidate-midi-boundary.json"), output, + ) + else: + fail("unknown observation lane") + if read_json(summary) != read_json(output): + fail(f"{lane}: summary differs from validated components") + return {"status": "COMPONENTS_REVALIDATED", "summary_sha256": digest(summary)} + + +def closeout_report(ledger: dict[str, Any], artifacts: dict[str, pathlib.Path]) -> dict[str, Any]: + validate_ledger(ledger) + if set(artifacts) - set(OBSERVATIONS): + fail("unknown observation artifact") + observations = { + lane: revalidate_summary(artifacts[lane], lane) if lane in artifacts + else {"status": "PENDING_PRIVATE_DISPATCH"} + for lane in OBSERVATIONS + } + return { + "schema_version": 1, "phase": "6C", "contract": CONTRACT, + "evidence_role": "implementation-closeout-and-observation-handoff", + "implementation_status": "COMPLETE", + "observations": observations, + "observation_summaries_revalidated": all(item["status"] == "COMPONENTS_REVALIDATED" for item in observations.values()), + # Summary integrity is narrower than independent execution/behavioural + # verification. The maintainer must review the observed outcomes against + # the priority-hold exit criteria; this tool does not authorize expansion. + "priority_hold": "AWAITING_OBSERVATION_REVIEW", + "resume_contract": ledger["resume_contract"], + "parity_status": "UNKNOWN", + "matrix_sha256": PINS["phase6c/compatibility-matrix.json"], + } + + +def main() -> int: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--historical-artifact", type=pathlib.Path) + parser.add_argument("--midi-artifact", type=pathlib.Path) + parser.add_argument("--output", type=pathlib.Path) + args = parser.parse_args() + artifacts = { + lane: path for lane, path in ( + ("historical-sickmaate", args.historical_artifact), + ("midi-real-world-corpus", args.midi_artifact), + ) if path is not None + } + try: + report = closeout_report(read_json(LEDGER), artifacts) + except (OSError, ValueError, TypeError, KeyError) as exc: + parser.exit(2, f"phase6c-legacy-closeout: {exc}\n") + rendered = json.dumps(report, indent=2, sort_keys=True) + "\n" + if args.output: + args.output.parent.mkdir(parents=True, exist_ok=True) + args.output.write_text(rendered, encoding="utf-8") + print(rendered, end="") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tests/phase6c_historical_it.py b/tests/phase6c_historical_it.py index a2218747..39e1890f 100644 --- a/tests/phase6c_historical_it.py +++ b/tests/phase6c_historical_it.py @@ -266,6 +266,10 @@ assert "phase6c-historical-summary/candidate/" in workflow assert "phase6c-historical-summary/original/" in workflow assert "historical module bytes leaked into combined artifact" in workflow +assert "Attest frozen historical candidate player" in workflow +assert "phase6c-midi-corpus.py attest-candidate-player" in workflow +assert "--attestation phase6c-historical-public/candidate-player-attestation.json" in workflow +assert "candidate_build_identity" in HELPER.read_text(encoding="utf-8") for upload_block in workflow.split("uses: actions/upload-artifact@v4")[1:]: block = upload_block.split("\n - name:", 1)[0] assert ".it" not in block.lower(), block diff --git a/tests/phase6c_legacy_closeout.py b/tests/phase6c_legacy_closeout.py new file mode 100644 index 00000000..5a9ab9bb --- /dev/null +++ b/tests/phase6c_legacy_closeout.py @@ -0,0 +1,185 @@ +#!/usr/bin/env python3 +"""Closeout cannot erase pending observations or promote donor evidence to parity.""" +from __future__ import annotations + +import argparse +import copy +import importlib.util +import json +import tempfile +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +spec = importlib.util.spec_from_file_location("closeout_test", ROOT / "scripts/phase6c-legacy-closeout.py") +helper = importlib.util.module_from_spec(spec) +assert spec.loader is not None +spec.loader.exec_module(helper) +ledger = helper.read_json(helper.LEDGER) + + +def rejected(operation, message): + try: + operation() + except (ValueError, SystemExit) as exc: + assert message in str(exc), str(exc) + else: + raise AssertionError(f"expected rejection: {message}") + + +matrix = (ROOT / "phase6c/compatibility-matrix.json").read_bytes() +report = helper.closeout_report(ledger, {}) +assert report["implementation_status"] == "COMPLETE" +assert report["observation_summaries_revalidated"] is False +assert report["priority_hold"] == "AWAITING_OBSERVATION_REVIEW" +assert report["parity_status"] == "UNKNOWN" +assert all(item["status"] == "PENDING_PRIVATE_DISPATCH" for item in report["observations"].values()) + +for field, value, message in ( + ("schema_version", True, "schema_version"), + ("parity_status", "PASS", "parity_status"), + ("preserved_inputs", {}, "identities"), + ("dispositions", ledger["dispositions"][:-1], "incomplete"), + ("pending_observations", {}, "observation set"), + ("resume_contract", "phase-7", "resume_contract"), +): + altered = copy.deepcopy(ledger) + altered[field] = value + rejected(lambda: helper.validate_ledger(altered), message) + +for mutation, message in ( + (lambda data: data["dispositions"][0].update(status="PASS"), "invalid disposition"), + (lambda data: data["dispositions"][1].update(id=data["dispositions"][0]["id"]), "duplicate"), + (lambda data: data["dispositions"][0].update(references=["../outside"]), "escapes root"), + (lambda data: data["dispositions"][0].update(references=["missing-source"]), "missing"), + (lambda data: data["pending_observations"]["historical-sickmaate"].update(status="OBSERVED"), "boundary"), +): + altered = copy.deepcopy(ledger) + mutation(altered) + rejected(lambda: helper.validate_ledger(altered), message) + +with tempfile.TemporaryDirectory() as temporary: + root = Path(temporary) + duplicate = root / "duplicate.json" + duplicate.write_text('{"parity_status":"UNKNOWN","parity_status":"PASS"}') + rejected(lambda: helper.read_json(duplicate), "duplicate JSON") + duplicate.unlink() + + # A plausible summary without component evidence must not count as dispatch. + (root / "historical-sickmaate-three-way.json").write_text('{"parity_status":"UNKNOWN"}') + rejected(lambda: helper.revalidate_summary(root, "historical-sickmaate"), "missing") + (root / "midi-real-world-corpus-summary.json").write_text('{"parity_status":"UNKNOWN"}') + rejected(lambda: helper.revalidate_summary(root, "midi-real-world-corpus"), "missing") + (root / "link").symlink_to(ROOT / "README.md") + rejected(lambda: helper.audit_artifact(root), "symlinks") + (root / "link").unlink() + for name, payload in ( + ("renamed.log", b"IMPMprivate module"), + ("audio.wav", b"audio"), + ("renamed-audio.log", b"RIFF\x04\x00\x00\x00WAVE"), + ): + path = root / name + path.write_bytes(payload) + rejected(lambda: helper.audit_artifact(root), "raw IT/audio") + path.unlink() + midi = helper.load_helper("phase6c-midi-corpus.py") + midi.write_synthetic_fixture(root / "renamed.log") + rejected(lambda: helper.audit_artifact(root), "raw corpus") + +# Positive summary validation uses project-owned metadata/support bytes only. +# It proves the component validator is invoked, not original execution. +with tempfile.TemporaryDirectory() as temporary: + root = Path(temporary) + historical = helper.load_helper("phase6c-historical-it.py") + source = historical.manifest_source() + for name in ("donor", "candidate", "original"): + (root / name).mkdir() + common = {"schema_version": 1, "phase": "6C", "contract": historical.EXPECTED_CONTRACT, "parity_status": "UNKNOWN"} + + def support(directory, name): + path = root / directory / name + path.write_text("project-owned support fixture\n") + return name, helper.digest(path) + + donor_source, donor_sha = support("donor", "source.c") + probe, probe_sha = support("donor", "probe") + player, player_sha = support("candidate", "player") + player_path = root / "candidate" / player + player_path.write_bytes(b"\x7fELFproject-owned candidate fixture") + player_sha = helper.digest(player_path) + midi = helper.load_helper("phase6c-midi-corpus.py") + identity = { + "candidate_baseline_sha256": midi.EXPECTED_CANDIDATE_BASELINE, + "source_revision": midi.EXPECTED_CANDIDATE_SOURCE_REVISION, + "repository_commit": midi.repository_commit(), + "build_target": "psycle-player", + "plugin_interface_git_blob": midi.EXPECTED_CANDIDATE_PLUGIN_BLOB, + "diversalis_revision": f"SourceForge SVN r{midi.DIVERSALIS_REVISION}", + "diversalis_file_count": midi.EXPECTED_DIVERSALIS_FILE_COUNT, + "diversalis_manifest_sha256": midi.EXPECTED_DIVERSALIS_MANIFEST_SHA256, + "clean_rebuild_sha256": player_sha, + } + attestation_path = root / "candidate/candidate-player-attestation.json" + attestation = midi.candidate_attestation_document(identity, player_sha) + attestation_path.write_text(json.dumps(attestation)) + donor = dict(common, evidence_role="cpsycle-donor-observation", source_sha256=source["sha256"], source_size_bytes=source["size_bytes"], load_result="accepted", non_silent_playback=True, fixture_redistributed=False, private_input_required=True, source_file=donor_source, source_file_sha256=donor_sha, probe_executable=probe, probe_executable_sha256=probe_sha, raw_output_sha256="1" * 64) + candidate = dict(common, evidence_role="candidate-observation", source_sha256=source["sha256"], source_size_bytes=source["size_bytes"], direct_it_load="rejected", diagnostic_could_not_load_song_file=True, exit_code=2, private_input_required=True, player=player, player_sha256=player_sha, raw_output_sha256="2" * 64) + candidate.update(identity, build_attestation=attestation_path.name, build_attestation_sha256=helper.digest(attestation_path)) + original = dict(common, evidence_role="original", fixture_sha256=source["sha256"], fixture_distribution="external-hash-bound", fixture_redistributed=False, original_psycle_observed=True, reference_build=historical.EXPECTED_REFERENCE_BUILD, reference_file=historical.EXPECTED_REFERENCE_FILE, reference_installer_sha256=historical.EXPECTED_REFERENCE_INSTALLER_SHA256, reference_installer_size_bytes=historical.EXPECTED_REFERENCE_INSTALLER_SIZE, reference_executable_sha256=historical.EXPECTED_REFERENCE_EXECUTABLE_SHA256, load_result="inconclusive", observation="project-owned summary validation fixture") + for field in ("stdout", "stderr", "ui_evidence", "loaded_vc90_runtime", "machine_plugin_inventory"): + name, sha = support("original", field + ".json") + mapping = {"path": name, "sha256": sha} + if field in ("loaded_vc90_runtime", "machine_plugin_inventory"): + original.setdefault("environment", {})[field] = mapping + else: + original[field] = mapping + donor_path = root / "donor/cpsycle-historical-it.json" + candidate_path = root / "candidate/candidate-historical-it.json" + original_path = root / "original/original-historical-legacy-it.json" + for path, data in ((donor_path, donor), (candidate_path, candidate), (original_path, original)): + path.write_text(json.dumps(data)) + summary = root / "historical-sickmaate-three-way.json" + historical.command_summary(argparse.Namespace(donor=donor_path, candidate=candidate_path, original=original_path, output=summary)) + one_lane = helper.closeout_report(ledger, {"historical-sickmaate": root}) + assert one_lane["observations"]["historical-sickmaate"]["status"] == "COMPONENTS_REVALIDATED" + assert one_lane["observation_summaries_revalidated"] is False + assert one_lane["priority_hold"] == "AWAITING_OBSERVATION_REVIEW" + + for field, bad in ( + ("repository_commit", "0" * 40), + ("candidate_baseline_sha256", "0" * 64), + ("clean_rebuild_sha256", "0" * 64), + ("plugin_interface_git_blob", "0" * 40), + ): + changed_attestation = dict(attestation) + changed_attestation[field] = bad + attestation_path.write_text(json.dumps(changed_attestation)) + changed_candidate = dict(candidate, **{field: bad}) + changed_candidate["build_attestation_sha256"] = helper.digest(attestation_path) + candidate_path.write_text(json.dumps(changed_candidate)) + rejected(lambda: helper.revalidate_summary(root, "historical-sickmaate"), "attestation is incomplete or invalid") + attestation_path.write_text(json.dumps(attestation)) + candidate_path.write_text(json.dumps(candidate)) + changed_candidate = dict(candidate, repository_commit="0" * 40) + candidate_path.write_text(json.dumps(changed_candidate)) + rejected(lambda: helper.revalidate_summary(root, "historical-sickmaate"), "differs from its frozen build identity") + candidate_path.write_text(json.dumps(candidate)) + original_player = player_path.read_bytes() + player_path.write_bytes(b"\x7fELFsubstituted candidate") + changed_candidate = dict(candidate, player_sha256=helper.digest(player_path)) + candidate_path.write_text(json.dumps(changed_candidate)) + rejected(lambda: helper.revalidate_summary(root, "historical-sickmaate"), "attestation is incomplete or invalid") + player_path.write_bytes(original_player) + candidate_path.write_text(json.dumps(candidate)) + attestation_path.unlink() + rejected(lambda: helper.revalidate_summary(root, "historical-sickmaate"), "support file is missing") + attestation_path.write_text(json.dumps(attestation)) + changed = helper.read_json(summary) + changed["observations"]["candidate"]["direct_it_load"] = "accepted" + summary.write_text(json.dumps(changed)) + rejected(lambda: helper.revalidate_summary(root, "historical-sickmaate"), "differs") + historical.command_summary(argparse.Namespace(donor=donor_path, candidate=candidate_path, original=original_path, output=summary)) + (root / "donor/source.c").write_text("tampered support") + rejected(lambda: helper.revalidate_summary(root, "historical-sickmaate"), "hash mismatch") + +assert (ROOT / "phase6c/compatibility-matrix.json").read_bytes() == matrix +print("phase6c-legacy-closeout: PASS") diff --git a/tests/phase6c_midi_corpus.py b/tests/phase6c_midi_corpus.py index f73837c4..26222efd 100644 --- a/tests/phase6c_midi_corpus.py +++ b/tests/phase6c_midi_corpus.py @@ -816,7 +816,27 @@ def canonical_analysis(root: Path): helper.corpus_summary(donor_path, candidate_path, root / "summary.json") assert (root / "summary.json").exists() + # The closeout must validate the full native corpus component contract too. + closeout_spec = importlib.util.spec_from_file_location( + "phase6c_closeout_midi_test", ROOT / "scripts/phase6c-legacy-closeout.py" + ) + closeout = importlib.util.module_from_spec(closeout_spec) + assert closeout_spec.loader is not None + closeout_spec.loader.exec_module(closeout) + helper.write_json( + root / "midi-real-world-corpus-summary.json", + helper.load_json(root / "summary.json"), + ) + checked = closeout.revalidate_summary(root, "midi-real-world-corpus") + assert checked["status"] == "COMPONENTS_REVALIDATED" + candidate_attestation_path.unlink() + try: + closeout.revalidate_summary(root, "midi-real-world-corpus") + except SystemExit as exc: + assert "candidate build attestation support file is missing" in str(exc) + else: + raise AssertionError("closeout must reject missing candidate attestation") try: helper.corpus_summary( donor_path, candidate_path, root / "missing-attestation.json"