Skip to content

Pins pre-Back compile bytes at v0.45.0 - #782

Merged
johnnyt merged 1 commit into
mainfrom
sb-7622-hash-ratchet
Nov 20, 2026
Merged

johnnyt merged 1 commit into
mainfrom
sb-7622-hash-ratchet

Conversation

@johnnyt

@johnnyt johnnyt commented Nov 20, 2026

Copy link
Copy Markdown
Member

What

A ratchet test that holds documents with no returnable step to the bytes and chart identity they compiled to at the v0.45.0 release, the last release before returnable steps, Back and core.checkpoint. ADR-0004's Amendment of 2026-11-20, L8, is the rule: a document with no returnable step compiles byte-identically. The test enumerates; the record does not.

The operator's ruling it carries: "No switch: Back exists exactly where a returnable step exists; upgrading moves no hash; a host opts in by declaring its type returnable, and those documents move once" (ruled by the operator, 2026-11-19).

Re-running the ratchet

One command, on any checkout of this branch or of main after it merges:

mix test test/statifier_blocks/compiler/compile_ratchet_test.exs

The pieces

  • test/support/compile_ratchet.ex (StatifierBlocks.CompileRatchet): the enumeration, the pin shape and capture/1, which writes the pins file. Its moduledoc says what the enumeration covers, what it leaves out and why, and how to re-derive the pins.
  • test/fixtures/compile_ratchet/v0.45.0.json: the pins. Each key is a document name and a compile mode (plain, terminate: true, child_use: true); each value is the SHA-256 of the compiled bytes and the chart identity (or, for a compile that is refused, the sorted finding codes), plus the document's own content hash, so a fixture whose input changed is told apart from a compiler whose output did.
  • test/statifier_blocks/compiler/compile_ratchet_test.exs: one test per document and mode against its pin; a test that the pins and the enumeration name the same documents in both directions; a test that no enumerated document has a returnable step; and the moving case.
  • changelog.d/sb-7622.md, under Changed, for the release's upgrading note: a document with no returnable step keeps its bytes and chart identity, and a host that declares a block type returnable moves the bytes and chart identity of every document using it, once.

What the enumeration covers

  • Every stored block document under test/fixtures/ that decodes and whose block types the shared fixture palette resolves.
  • The migration guide's document and composite declaration combinations: before with the old declaration, before with the new one, and after with the new one.
  • The byte corpus entries, each under its own palette.
  • The editor fixture documents and the map fixtures' deeper library loans.

What it leaves out, each with its reason in the moduledoc: stored documents whose host types are defined inside one test file, the insert probe and the assignability worked example (their host types are stubs that refuse to emit), JSON files that are not block documents, the run-time sub-path document added after v0.45.0, the document generator (fresh block ids on every call), and the card and live run fixtures (they need statifier-ui, and the ratchet also runs in the headless job).

The literal core.subchart fixtures are not pinned a second time: they keep their existing pins. capture/1 recomputes every one of those pins under the tree it runs on and raises if any differs, so the capture at v0.45.0 also proves those pins were already true at v0.45.0.

How the pins were captured, and how to trust them

The pins were written by capture/1 in a detached checkout of the v0.45.0 tag (1a6af24), with compile_ratchet.ex and subchart_byte_fixtures.ex copied into its test/support/. Neither file existed there, but every fixture module they call did, and none of those modules has changed since. The same capture run on this branch's base (a016c7b) produced a byte-equal file. The moduledoc gives the commands to re-derive it.

The moving case

The byte corpus's signup wizard is compiled twice. Under the shared palette it matches its pin. With its host step type swapped for one that declares returnable?/1 true, it compiles to other bytes and another chart identity, with the document trail root in the datamodel. A second compile gives the same moved bytes and identity.

Sabotage

  • Make Trail's survey count every block as a returnable step: every pin test whose document compiles goes red on its assertion, and so does the moving case's unchanged-palette check. The pins for refused compiles stay green, as they should.
  • Make BlockType.returnable?/2 answer false for every type: the moving case goes red on its first refute.

Both mutations were restored byte-equal and the build was forced before the next run.

Gate

Full mix quality green on the committed tree.

A document with no returnable step compiles to the bytes and chart
identity it compiled to at v0.45.0, as ADR-0004's Amendment of
2026-11-20 says in L8. A new ratchet test holds every stored fixture
document the shared fixture palette resolves, the migration guide's
composite pair, the byte corpus and the editor and map fixture
documents to SHA-256 and chart identity pins captured in a checkout of
the v0.45.0 tag, under the plain, terminate and child use modes. The
capture also confirms the literal subchart pins hold at v0.45.0.

The moving case is pinned beside it: the signup wizard with its host
step type declaring returnable?/1 compiles to other bytes and another
chart identity, the same ones on every compile. A changelog fragment
names the move for the upgrading note: no switch, ruled by the
operator, 2026-11-19.

Refs: sb-7622
@johnnyt
johnnyt merged commit b71247e into main Nov 20, 2026
2 checks passed
@johnnyt
johnnyt deleted the sb-7622-hash-ratchet branch November 20, 2026 16:37
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