ErrFormat refusal path has no test at all
ErrFormat is raised in four places: a format-number mismatch and a page-size mismatch,
in each of the two readers — the plain one in pager.go and the encrypted one in
led.go. Every one now has a test, and every test asserts the same three things:
errors.Is(err, ErrFormat);
The encrypted tests build a real led store and reopen it with the correct key, so a
failure cannot be mistaken for a key-path failure. The plain-reader tests corrupt the field in
both meta copies, because loadMeta falls back to the other one and
corrupting a single copy measures the fallback instead.
Each test was run against a copy of the tree with its own check disabled — and every
one of them then failed on the checksum rather than on ErrFormat:
opening a led store with format 2 against a build that reads 1:
want ErrFormat, got sapedb/pager: page failed its checksum: page 0
That is not a broken proof; it is the proof. With the format check gone, the corrupted bytes travel
on into verify() and break there, for a different reason. So each test's pass on
the real tree depends on that one specific check and not on the checksum catching it incidentally
— which is exactly the Magic-versus-Format-versus-page-size confusion
this issue warned about. A test that corrupts the wrong bytes fails for the wrong reason and looks
identical to success.
A database file carries a layout version, const Format uint16 = 1, separate from the
eight-byte Magic and from the page size. When a build meets a file whose layout it does
not read, it must refuse politely and say what to do. That refusal was written and
shipped and had never been run.
grep -rn --include='*_test.go' -F "ErrFormat" . returned 0.ErrNotSapedb 3 files, ErrChecksum 2,
ErrNoMeta 3, ErrPageKind 1, ErrQuota 1,
ErrOutOfRange 1, ErrReadOnlyPage 1, ErrTruncated 1. Every one
non-zero. The search worked; the absence was real.Does it lose data, break a promise on a public surface, or stop somebody installing and running? Yes — the first one, on the path that matters most. This is the refusal that stands between a future build and a file it cannot read. If it does not fire, a build reads a file laid out under different rules as if it were its own: not "not found", not an error, just a database answering questions wrongly.
It was also load-bearing for SAPE-6. The upgrade rehearsal is "one build writes, the next reads it all back", and the negative half — the next build declining a file it should decline — is exactly this path. That blocker is now cleared.
The plain reader's format-number test landed first, and this page briefly carried Done on that alone. Its own closing paragraph asked for both readers: "for the plain reader and the encrypted one, since they are two copies of the same sentence." Two of six sites is not four of four. It was put back to In progress until the rest existed — the same correction SAPE-4 needed a few hours earlier, and for the same reason.
They prove the message and the file-integrity property for one value of each field
(Format+1, PageBytes+1); they do not fuzz. And they do not exercise a led
file with one corrupted field and a wrong key at once — the label checks run before
the key check, so that interaction is untested.