259 lines
17 KiB
Markdown
259 lines
17 KiB
Markdown
```
|
|
STEP 5 REPORT — Standard MIDI builders and safe single-file writer
|
|
Date: 2026-10-20
|
|
|
|
STEP 5 FORMAT-WRITER STATUS: PASS; ready for orchestrator review.
|
|
REAL PRODUCTION MAPPING / FULL STEP 4 STATUS: FALSE / BLOCKED.
|
|
NATIVE-FORMAT / REAL PLUGIN / CUBASE ACCEPTANCE: NOT VERIFIED.
|
|
NEXT NATIVE STEP: still requires its authorized evidence; not started.
|
|
|
|
IMPLEMENTED
|
|
- Added Generation.Midi.MidiEventBuilder.Build, MidiFileBuilder.Build,
|
|
MidiFileWriter.Write and MidiFileWriter.WriteFile, with CancellationToken.
|
|
Only the existing pinned DryWetMIDI 8.0.3 constructs/reads/writes MIDI.
|
|
Core, production mappings, server source and production registry are unchanged.
|
|
- Preflight validates the composition, matching selected roles and bar extent,
|
|
shared lead-in/end, possible event count, supported event types and ranges,
|
|
stable order, checked timing/deltas, track/channel independence, positive
|
|
complete note pairing and played-note timing/count/pitched-note agreement.
|
|
Drum pitches and output velocities come from the event plan, not guesses.
|
|
Invalid/unrepresentable input throws rather than emitting partial success.
|
|
- Actual output is SMF type 1, 960 PPQ, named Conductor then selected Lead,
|
|
Bass, Drums tracks. No absent-role tracks are added.
|
|
Tempo/meter remain at tick zero despite shared lead-in.
|
|
- Preserves absolute pitches, transformed output velocities, configured
|
|
zero-based channels, CC values, keyswitches and explicit NoteOffEvent
|
|
messages (release velocity zero). Direct event insertion preserves the
|
|
plan's stable note-off/reset/new-state/musical-on ordering and equal-priority
|
|
insertion order; no high-level note/control reordering helper is used.
|
|
- Exactly one retained End-of-Track per track is set to the global EndTick.
|
|
Declared rests, lead-in and later release/reset tails are preserved.
|
|
- Borrowed writable streams, including non-seekable streams, remain open.
|
|
Invalid/read-only/disposed streams fail explicitly. I/O failure propagates.
|
|
Stream output is not transactional; failure/cancellation can leave bytes.
|
|
- Explicit fully qualified file paths require an existing parent and valid
|
|
non-reserved filename. A request-owned uniquely named .riffgroove-*.stage
|
|
file is created in that SAME directory with CreateNew and exclusive access.
|
|
It is fully written and closed before File.Move(..., overwrite: false).
|
|
Early File.Exists checks are not the collision-safety mechanism.
|
|
- Failure/cancellation deletes only that request's staging file. Late file
|
|
and directory collisions preserve the other owner's destination.
|
|
Deletion failure reports AggregateException containing original error,
|
|
cleanup error and remaining stage path. Simultaneous serialization/
|
|
cancellation and stage-close errors also retain both original exceptions.
|
|
- Cancellation is checked during event translation, before/after synchronous
|
|
library serialization and before publication. The synchronous library call
|
|
has no cancellation-token API and is not interruptible. Observed cancellation
|
|
prevents publication; cancellation after the final check/during a successful
|
|
move does not undo that completed publication. This is not multi-file
|
|
publication, crash-durability, fallback orchestration or Step 8.
|
|
- Extracted the existing integration Example/Profiles/Pitched setup into
|
|
Support\SyntheticPipelineProfiles.cs. Both old articulation and new file
|
|
pipeline tests use that one factory. Unit MIDI tests reuse SyntheticProfiles.
|
|
- Updated README and the three directly related existing contracts/inventory.
|
|
No new package/project/interface framework, Core dependency, raw MIDI
|
|
encoder, native writer, production profile or MCP tool was added.
|
|
|
|
PINNED LIBRARY FINDINGS AND LIMITS
|
|
- Inspected existing package XML and reflected existing 8.0.3 assemblies;
|
|
no package restore/install was used merely for API inspection.
|
|
Package XML/reflection path:
|
|
C:\Users\g3\.nuget\packages\melanchall.drywetmidi\8.0.3\lib\net45\
|
|
Actual .NET 10 tests exercise the project's resolved library, and assert
|
|
assembly version 8.0.3.0 plus the relevant public API shapes.
|
|
- SetTempoEvent(Int64) carries integer microseconds per quarter.
|
|
Conversion is Math.Round(60000000d / BPM, MidpointRounding.AwayFromZero).
|
|
Read-back verifies 120 -> 500000; 123 -> 487805; 512 -> 117188
|
|
(the last quotient is exactly 117187.5), and exact bounds 1/16777215.
|
|
Core's UNROUNDED quotient range 1..16777215 remains enforced; quotients
|
|
0.75 and 16777215.25 fail even though rounding could land inside that range.
|
|
Nonpositive/nonfinite BPM and out-of-range tempos also fail.
|
|
- TimeSignatureEvent(Byte numerator, Byte denominator) takes the ACTUAL
|
|
denominator, not its encoded SMF exponent. /128 round-trips correctly.
|
|
The Denominator property/constructor parameter are Byte: Core-valid /256
|
|
cannot be represented through this pinned API. The writer throws a clear
|
|
NotSupportedException naming /256 and writer powers-of-two range 1..128.
|
|
Core still accepts /256; there is no byte wrap, changed meter or silent
|
|
narrowing of Core. The SMF representation itself is not claimed to forbid 256.
|
|
- MidiEvent.DeltaTime is Int64. Direct pinned-library serialization ACCEPTS
|
|
delta 0x10000000; it does not enforce the standard four-byte VLQ maximum.
|
|
The builder therefore uses checked subtraction and accepts only
|
|
0..0x0FFFFFFF (268435455) per gap. Exactly the maximum is serialized and
|
|
read back; maximum+1 is rejected before any destination bytes/staging.
|
|
Backward delta and checked Int64 subtraction overflow are tested.
|
|
Because the conductor has metadata only at zero before its end marker,
|
|
its end delta also bounds GLOBAL EndTick to 268435455. No filler events
|
|
are inserted to conceal a longer arrangement.
|
|
- EndOfTrackEvent has NO public constructor. The library writes EOT
|
|
automatically and its normal reader omits it unless
|
|
ReadingSettings.EndOfTrackStoringPolicy = Store.
|
|
EventsCollection documentation also cautions against adding EOT directly.
|
|
The builder obtains each track from a library-generated empty-file read
|
|
with Store, inserts ordinary events BEFORE the retained EOT and sets that
|
|
marker's delta. No reflection construction or handwritten byte fixture is
|
|
used in production. Actual read-back proves one EOT at the intended end,
|
|
not a duplicate/default zero-time replacement.
|
|
- MidiFile.Write(Stream, MidiFileFormat.MultiTrack, WritingSettings) is the
|
|
pinned serialization API. NoteOffAsSilentNoteOn is a BOOLEAN setting,
|
|
explicitly false; default-tempo/meter deletion and running status are
|
|
explicitly false. Both 120-BPM/4-4 metadata and explicit note-offs survive.
|
|
- Early exploratory reflection exposed the nonpublic EOT constructor and
|
|
/256 byte conversion failure. One mixed exploratory probe exited 1 after
|
|
asking for a nonexistent NoteOffAs enum; the actual boolean API above was
|
|
then verified. No guessed enum/API remains in implementation.
|
|
|
|
ACTUAL FILE WRITE / READ-BACK EVIDENCE
|
|
- New integration pipeline runs description -> parse -> composition -> validate
|
|
-> extracted SYNTHETIC profiles -> event plan -> actual staged .mid file ->
|
|
DryWetMIDI.Read(path, Store + MissedEndOfTrackPolicy.Abort).
|
|
All channel events are compared in sequence against the complete event plan:
|
|
absolute tick, event type, channel, pitch/CC number and velocity/CC value.
|
|
Complete note-off pairing, names, resolution, format and every EOT are checked.
|
|
- Full documented four-bar example was written using an explicit path while
|
|
Environment.CurrentDirectory was the unrelated existing Windows system
|
|
directory. Owned output directories are beneath the checkout's test output.
|
|
No files were written in the system directory.
|
|
- Captured actual output: 886 bytes.
|
|
SHA256:
|
|
B7DC2F2F9944ACA22D32A2D5224E3BAF88194AF4B902C3EE60AB0B496EA6A780
|
|
Read-back: type 1, 960 PPQ, Conductor/Lead/Bass/Drums, 175 channel events,
|
|
32 played lead notes + 4 played bass notes + 48 mapped drum hits,
|
|
2 complete switch pairs, 4 EOTs at tick 15600.
|
|
Unshifted musical extent 15360; shared lead-in 240; musical/global end 15600.
|
|
- Invented test lead: pitch 64, output velocity 110, channel 0, starts
|
|
240 + 480*i (32 notes); switch 11/91 at tick 0, off at 30.
|
|
Invented test bass: pitch 40, velocity 96, channel 1, starts
|
|
240 + 3840*i (4 notes); switch 12/92 at 120, off at 140.
|
|
Invented test drums: pitches 50/51/52, channel 9, source hit velocities and
|
|
exact shifted starts/ends; CC21 = 0@0, 100@240, 0@15600.
|
|
These are NOT Ample/SD3 numbers or application compatibility evidence.
|
|
- Reversed profile enumeration produces byte-identical repeated file output;
|
|
source composition/event plan JSON remains unchanged.
|
|
- Additional actual files cover selected roles (including Lead+Bass), 3/8 at
|
|
123 BPM, 1000 repeated 7/8 bars (14000 sixteenth notes, exact 240-tick
|
|
spacing, 3360000 unshifted ticks + 240 lead-in), declared trailing rests,
|
|
final reset pulse tail to 4110 and momentary switch release to 20000.
|
|
Every track in each file has the same global end.
|
|
Unit read-back also covers exact rational triplets at 320-tick spacing.
|
|
- File tests cover pre-existing and late-collision no-overwrite behavior,
|
|
real staged files, injected serialization error/cancellation, unrelated-file
|
|
preservation and explicit cleanup/close failure aggregation. Locked owned
|
|
file deletion failure is exercised directly through the cleanup helper.
|
|
Borrowed-stream tests exercise actual library writes into failing streams
|
|
and cancellation signalled by a write callback at the synchronous boundary.
|
|
No disk-full/power-loss or application import scenario is claimed.
|
|
- Generated .mid files/test directories are deleted by their owning tests.
|
|
Final audits found zero .mid/.midi/.agp/.sdp/.stage files and zero owned
|
|
midi-writer-/midi-pipeline- directories under src/tests.
|
|
|
|
CHANGED FILES (14 deliverables including this report)
|
|
src\GAJ3T.MusicGen.RiffGrooveBuilder.Generation\Midi\MidiEventBuilder.cs
|
|
src\GAJ3T.MusicGen.RiffGrooveBuilder.Generation\Midi\MidiFileBuilder.cs
|
|
src\GAJ3T.MusicGen.RiffGrooveBuilder.Generation\Midi\MidiFileWriter.cs
|
|
tests\GAJ3T.MusicGen.RiffGrooveBuilder.UnitTests\Midi\MidiEventBuilderTests.cs
|
|
tests\GAJ3T.MusicGen.RiffGrooveBuilder.UnitTests\Midi\MidiFileBuilderTests.cs
|
|
tests\GAJ3T.MusicGen.RiffGrooveBuilder.UnitTests\Midi\MidiFileWriterTests.cs
|
|
tests\GAJ3T.MusicGen.RiffGrooveBuilder.IntegrationTests\Midi\MidiGenerationPipelineTests.cs
|
|
tests\GAJ3T.MusicGen.RiffGrooveBuilder.IntegrationTests\Articulations\ArticulationPipelineTests.cs
|
|
tests\GAJ3T.MusicGen.RiffGrooveBuilder.IntegrationTests\Support\SyntheticPipelineProfiles.cs
|
|
README.md
|
|
docs\articulation-mappings.md
|
|
docs\format-compatibility.md
|
|
docs\text-description-contract.md
|
|
prompts\report_5.md
|
|
|
|
EXACT VALIDATION COMMANDS AND RESULTS
|
|
All dotnet commands ran from the repository root with process-local settings:
|
|
$env:PATH = 'C:\Program Files\dotnet;' + $env:PATH
|
|
$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1'
|
|
$env:DOTNET_NOLOGO = '1'
|
|
Executable: C:\Program Files\dotnet\dotnet.exe.
|
|
|
|
FINAL FOCUSED VALIDATION
|
|
1. dotnet test .\GAJ3T.MusicGen.RiffGrooveBuilder.slnx -c Release --no-restore --filter FullyQualifiedName~.Midi. --verbosity quiet
|
|
PASS, exit 0: 86 unit + 11 integration = 97 passed, 0 failed/skipped.
|
|
|
|
FINAL REQUIRED ACCEPTANCE (rerun after the last code/test changes)
|
|
2. dotnet build .\GAJ3T.MusicGen.RiffGrooveBuilder.slnx -c Release --no-restore
|
|
PASS, exit 0; all five projects; 0 warnings, 0 errors (0.63 s).
|
|
3. dotnet test .\GAJ3T.MusicGen.RiffGrooveBuilder.slnx -c Release --no-build
|
|
PASS, exit 0:
|
|
UnitTests: 618 passed, 0 failed, 0 skipped (667 ms).
|
|
IntegrationTests: 45 passed, 0 failed, 0 skipped (1 s).
|
|
TOTAL: 663 passed, 0 failed, 0 skipped.
|
|
All 566 accepted baseline cases retained; 97 new Step 5 cases.
|
|
4. dotnet restore .\GAJ3T.MusicGen.RiffGrooveBuilder.slnx --locked-mode
|
|
PASS, exit 0; all five projects up to date against unchanged locks.
|
|
|
|
FILE EVIDENCE COMMAND
|
|
5. dotnet test .\tests\GAJ3T.MusicGen.RiffGrooveBuilder.IntegrationTests\GAJ3T.MusicGen.RiffGrooveBuilder.IntegrationTests.csproj -c Release --no-build --filter FullyQualifiedName~FullExampleWritesActualTypeOneFileFromUnrelatedCwdAndReadsEveryEventBack --logger 'console;verbosity=detailed'
|
|
PASS, exit 0: 1 passed, 0 failed/skipped. Printed the 886-byte hash and
|
|
read-back facts above. Subsequent final full run also passed this case.
|
|
|
|
DEVELOPMENT HISTORY / CORRECTIONS
|
|
6. dotnet build .\src\GAJ3T.MusicGen.RiffGrooveBuilder.Generation\GAJ3T.MusicGen.RiffGrooveBuilder.Generation.csproj -c Release --no-restore --verbosity quiet
|
|
PASS, exit 0; 0 warnings/errors.
|
|
7. dotnet test .\tests\GAJ3T.MusicGen.RiffGrooveBuilder.UnitTests\GAJ3T.MusicGen.RiffGrooveBuilder.UnitTests.csproj -c Release --no-restore --filter FullyQualifiedName~.Midi. --verbosity quiet
|
|
Initial: exit 1; 76 passed, 2 failed, 0 skipped.
|
|
Corrected test expectations/setup: stable same-priority switch off precedes
|
|
musical off in the existing plan; a failing buffered stream must itself
|
|
simulate partial write before throwing to test retained partial bytes.
|
|
Retry: exit 0; 78 passed, 0 failed/skipped.
|
|
8. dotnet test .\GAJ3T.MusicGen.RiffGrooveBuilder.slnx -c Release --no-restore --filter 'FullyQualifiedName~.Midi.|FullyQualifiedName~.Articulations.ArticulationPipelineTests' --verbosity quiet
|
|
Initial: exit 1; unit 78 passed; integration 18 passed/2 failed.
|
|
Next: exit 1; unit 78 passed; integration 19 passed/1 failed.
|
|
Corrected new assertions, not existing musical/planner behavior:
|
|
7/8 contains 14, not 28, sixteenth notes per bar; selected sustain rules
|
|
still contribute their configured shared 240 lead-in; drum final CC reset
|
|
consumes the trailing-rest delta, leaving a zero-delta EOT at the same end.
|
|
Final retry: exit 0; unit 78 + integration 20 passed, 0 failed/skipped.
|
|
The integration selector includes 9 retained articulation cases.
|
|
9. The exact focused command in (1) also passed during test expansion:
|
|
82 unit + 11 integration; then 83 unit + 11 integration; finally 86 + 11.
|
|
An earlier full build/test/locked restore passed 615 unit + 45 integration
|
|
before the three final stage-close error cases were added; final (2)-(4)
|
|
supersede that count.
|
|
|
|
Diagnostic no-build commands (all exited 1 on the known failing assertions):
|
|
dotnet test .\tests\GAJ3T.MusicGen.RiffGrooveBuilder.UnitTests\GAJ3T.MusicGen.RiffGrooveBuilder.UnitTests.csproj -c Release --no-build --filter 'FullyQualifiedName~InvalidReadOnlyDisposedAndFailingStreamsAreTruthful|FullyQualifiedName~SameTickMomentaryReleaseResetNewStateAndNotesKeepStableOrder' --logger 'console;verbosity=normal'
|
|
0 passed, 2 failed, 0 skipped.
|
|
dotnet test .\tests\GAJ3T.MusicGen.RiffGrooveBuilder.IntegrationTests\GAJ3T.MusicGen.RiffGrooveBuilder.IntegrationTests.csproj -c Release --no-build --filter 'FullyQualifiedName~RestsKeepFullDeclaredBarsEvenAfterLastNoteOff|FullyQualifiedName~LongRepeatedPatternUsesExactTicksWithoutAccumulatedDrift' --logger 'console;verbosity=normal'
|
|
0 passed, 2 failed, 0 skipped.
|
|
dotnet test .\tests\GAJ3T.MusicGen.RiffGrooveBuilder.IntegrationTests\GAJ3T.MusicGen.RiffGrooveBuilder.IntegrationTests.csproj -c Release --no-build --filter FullyQualifiedName~LongRepeatedPatternUsesExactTicksWithoutAccumulatedDrift --logger 'console;verbosity=normal'
|
|
0 passed, 1 failed, 0 skipped.
|
|
All development failures above are resolved; final focused/full runs pass.
|
|
|
|
ADDITIONAL CHECKS / PRESERVATION / UNRUN CHECKS
|
|
- Editor runTests over the three initial MIDI unit files: "No tests found".
|
|
Used the prescribed CLI fallback; editor nondiscovery is not a test pass.
|
|
- Editor problems over src/tests and final changed source: no errors found.
|
|
- git --no-pager diff --check: PASS, exit 0. In-memory whitespace audit of
|
|
new source/test files: PASS. No scratch source/log files were retained.
|
|
- Core project audit: zero PackageReference/ProjectReference elements.
|
|
Embedded production profile JSON remains exactly []; server still constructs
|
|
new McpToolRegistry() with no production tools. Full protocol/catalog
|
|
regressions pass. No dependency manifests or lock files were changed.
|
|
- Entry-state modified prompts\plan.md and untracked prompts\step_5.md were
|
|
preserved, not edited/reset. Existing reports/prompts were not modified.
|
|
No new later prompt, commit, delegation, native writer or public tool.
|
|
- No real Ample/SD3/Cubase imports, installed-plugin scanning, audio/device
|
|
work, Riffer-specific single-track export, AGP/SDP serialization, publication
|
|
or runtime-free deployment check was performed. These are not Step 5 passes.
|
|
|
|
READINESS AND STOP
|
|
- No unresolved generic builder/writer build/test blocker remains.
|
|
/256 and four-byte-delta limits are explicit tested writer limitations,
|
|
not silently changed compositions or fabricated success.
|
|
- Format-writer readiness is PASS for the supported limits, subject to
|
|
orchestrator review of this report and changes.
|
|
- Real mapping admission remains BLOCKED for ABJ/AGLP/AGM/AGT/AME/AMR/SD3:
|
|
exact installed versions/settings, complete authorized numeric/timing/
|
|
velocity/channel/state maps and actual application verification are missing.
|
|
Synthetic format tests do not establish real plugin compatibility.
|
|
- Native schemas, lawful fixtures/template rights, AGP/SDP entity/extension/
|
|
load semantics and plugin/Cubase acceptance remain separate open gates.
|
|
The combined type-1 arrangement is not automatically a single-track
|
|
Riffer-import file, and MIDI is not a renamed native container.
|
|
- Stopping after Step 5 for report review. No Step 6 or profile work started.
|
|
```
|