Skip to content

+ Stacker: fragmented clusters read, layout measured against dmsdos - #521

Open
Hawkynt wants to merge 4 commits into
mainfrom
feat/stacker-fragments
Open

Hawkynt wants to merge 4 commits into
mainfrom
feat/stacker-fragments

Conversation

@Hawkynt

@Hawkynt Hawkynt commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Stacks on #501: the first commit of this branch is #501's content (cherry-picked onto current main); review only the second commit. Merge after #501.

What changed

  • GenuineStackerReader reads fragmented Stacker clusters instead of refusing them. The AMAP run is the first piece; its first sector holds 0xED, the number n of further pieces, their summed sector count minus one (16-bit LE), and n 4-byte entries (16-bit sector, sectors − 1, a fourth byte). The compressed payload starts at byte 4 + 4·n and continues through the pieces in order.
  • An entry whose fourth byte is non-zero is refused (NotSupportedException), because no volume with that byte set was observed. A wrong piece total, a missing 0xED or a piece past the volume end is rejected (InvalidDataException).
  • The layout is written up in docs/CVF-CODECS-ON-DISK.md as measured. Stacker FORMAT-NOTES updated.
  • Still refused and documented: Stacker suballocated clusters and DriveSpace 3 fragmented clusters (no layout measured).

How the layout was established

There is no specification or sample volume. I built candidate volumes and ran dmsdos dcread on them in WSL, only as a black box (its source was not read). Six rounds of trial volumes narrowed the layout to the one above; dcread reads every accepted shape byte-exact and rejects a wrong piece total as "sector count mismash".

Verification

  • StackerFragmentedClusterTests: our reader and dmsdos both read six shapes byte-exact (SD-3/SD-4 payloads, two/three/four pieces, one- and two-sector first runs). dmsdos and our reader both refuse a wrong piece total. Malformed-list cases are covered.
  • Local filtered run Stacker + Compression.Tests.Cvf: 720 passed, 3 skipped (Windows + WSL dmsdos).

Hawkynt and others added 4 commits October 26, 2026 09:51
… back-references

* CvfLzCodec (DS-0-x, JM-0-x, SQ-0-0 and the Stacker dispatch) is replaced by an independent
  implementation (MsdblLzCodec + ClusterMatchFinder) written from docs/CVF-CODECS-ON-DISK.md and
  the dmsdos reference vectors. Public API unchanged; CvfLzMethod moves to its own file.
  Clean-room reimplementation from docs/CVF-CODECS-ON-DISK.md; the implementer did not read the
  previous code or dmsdos sources (rung 3/4 spec + black-box oracle).
* The DS/JM encoder now writes a sync after every 512 decoded bytes and never lets a match cross
  a 512-byte boundary - measured in all 16 dmsdos DS/JM reference streams and recorded in the spec.
  A sync followed only by zero padding ends a short cluster (tail reads zero).
* Auto in the codec keeps the smaller of DS and JM; GenuineDvr3Writer's Auto also tries SQ.
+ Sd4Codec rewritten from the spec: the encoder emits short/long matches with every length
  extension and run-coded code-length tables, codes built by package-merge (optimal, complete,
  15-bit limit). Within 10% of the dmsdos SD-4 encoder on the five reference samples; dmsdos reads
  our SD-4 volumes (and 15-bit-deep main codes) byte-exact.
+ BB_StackerSd4 building block.
# Stacker: a compressed run that needs every sector of its cluster reads as stored (AMAP has no
  flag for it), so ForceCompress wrote clusters dmsdos and our reader returned verbatim. Such a
  cluster is now stored raw; verified by dmsdos and our reader.
+ DmsdosOracle: the dmsdos gates run through WSL on Windows as well as natively on Linux; the
  existing Stacker/DriveSpace 3/DoubleSpace driver-proof tests use it.
+ Boundary tests for every CVF codec: empty/1-byte clusters, 512/8K/32K clusters, incompressible
  data, maximum match lengths and distances, malformed streams.
! Fragmented DriveSpace 3 clusters and fragmented/suballocated Stacker clusters are still refused;
  they follow in a separate change.
GenuineStackerReader refused every fragmented cluster (AMAP bit 7 set, run shorter than the
cluster). The layout is now read: the AMAP run is the first piece, its first sector carries 0xED, the
number of further pieces, their summed sector count minus one, and 4-byte entries (16-bit sector,
sectors - 1, a fourth byte); the compressed payload starts after the entries and continues through
the pieces. An entry whose fourth byte is non-zero is refused - its meaning was never observed.

Rung 4/5 by measurement: no specification or sample volume exists, so candidate layouts were built
and dmsdos (run only as a black box, its source not read) judged them through dcread. Six accepted
shapes (one to three further pieces, SD-3 and SD-4 payloads) are kept as DriverProof tests, and a
wrong piece total is refused by dmsdos and by us alike. Recorded in docs/CVF-CODECS-ON-DISK.md.
! Stacker suballocated clusters and DriveSpace 3 fragmented clusters stay refused: no layout measured.
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.

1 participant