Skip to content

The ABI vocabulary gates — build-time floor derivation + publish-time continuity (the darwin-24 drift window) - #399

Merged
ronaldtse merged 1 commit into
mainfrom
feat/abi-continuity-gate
Nov 27, 2026
Merged

ronaldtse merged 1 commit into
mainfrom
feat/abi-continuity-gate

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

What

Two fail-closed gates for the ABI vocabulary (abi segment of a platform triplet — resolution truth for native-extension payloads per spec 05 §5, mirrored verbatim into tpkg-registry.yaml since registry MINOR 11 / tebako#1047):

  1. Build time (derivation): Builder#write_abi_sidecar now asserts each darwin shard's abi equals the contract floor's derivation — Contract#darwin_kernel_major (the macOS N ↔ darwin N+9 SSOT, now owned by the contract and flowed into configure_triplet) against macos_deployment_target. A host-kernel leak fails the leg with a named error (exit 134) naming got / want / floor before anything publishes.
  2. Publish time (continuity): publish.yml gains a gate step running tools/registry_abi_gate.rb, which compares the rendered registry's darwin rows against the newest non-withdrawn same-(line × platform) row on origin/main. Any move fails closed naming every (line, platform, old → new) tuple (::error:: prefixed) — unless the run carries the deliberate abi_bump workflow_dispatch input, whose text is then recorded into the registry bot PR body alongside one bump acknowledged: line per tuple. The publish step itself additionally requires the gate step's success.

Why

The darwin-24 drift window: 0.17.14 / 0.17.15 shards published *-darwin-24 abis — the macos-15 fleet's kernel release baked in by config.guess after the fleet move in 1cca8848 — an abi the contract never spelled. The 0.17.16 triplet pin (e21ac53) restored the contract floor's darwin-23 spelling (#317), and that deliberate patch-line move silently broke every darwin-24-pressed native payload: the packed-metanorma smoke failed with "Could not find 'ox' (>= 0) among 316 total gem(s)" (tebako-packages/packed-metanorma#313; payload-side fix at tebako-packages/metanorma#176).

Nothing between the shard and the registry mirror ever asserted the vocabulary, so a fleet move could leak a host kernel into a published abi, and a vocabulary restoration could ship as a silent patch. A vocabulary move is legitimate only as a deliberate act — the same treatment an era boundary gets. These gates make both classes impossible to miss.

Scope rules (MECE — the gates own what they own, nothing else)

  • Darwin rows only participate in the continuity gate: the floor's derivation gate and the fleet-move class are darwin-shaped; linux/windows abi strings carry no kernel segment to drift.
  • A (line × platform) pair absent from main is an introduction (new ruby line or new platform row), never a bump — pass.
  • A previous row carrying no abi (pre-MINOR-11) declares no vocabulary to continue — pass.
  • status: withdrawn rows are dead vocabulary: newest means newest non-withdrawn on both sides.
  • The version grammar (<ruby>-<tebako>, dotted) is enforced upstream by the product reader's registry validate in the same job; rows outside it do not participate here.
  • The derivation gate runs in the shard's own leg (write_abi_sidecar), so a leak fails the build before any artifact exists.

The knob

abi_bump (string, workflow_dispatch only, default ''). When a deliberate vocabulary move is intended (e.g. a fleet move adopting a newer darwin), dispatch with a reason; the gate then passes and the publish step records the bump acknowledged: tuples plus the knob text into the registry bot PR body under a dedicated heading, so the deliberate act is visible in the merge record. Without the knob, any move is an error; with an empty registry diff (no move), the knob is inert.

Evidence

  • Full suite: 453 examples, 0 failures, 50 pending (pendings are the opt-in published-pair network acceptance).
  • New coverage: spec/builder_spec.rb — 5 #write_abi_sidecar tests (bump-proof: floor derived from the repo's contract.yml, off-floor failure asserts the rewrapped named message); spec/registry_abi_gate_spec.rb — 8 tests (stable pass, fail-closed tuple naming, knob acknowledgment recording, new-line introduction, new-platform introduction, withdrawn-newest continuity, grammar-outside skip, both-arch ordering); spec/build_workflow_spec.rb — structural locks for the knob declaration, gate step wiring/ordering, publish if requiring steps.abi-gate.outcome == 'success', and the PR-body recording.
  • Live simulation: ruby tools/registry_abi_gate.rb tpkg-registry.yaml tpkg-registry.yaml → abi continuity gate: 10 darwin row(s) stable vs the previous line — no bump, exit 0. Against a fixture with main's 0.17.16 macos rows flipped to darwin-24: fail-closed exit 1 naming both (4.0.9 × {aarch64,x86_64}-macos, darwin-24 → darwin-23) tuples; with the knob → exit 0 with bump acknowledged: lines and the knob echoed. Missing-file input fails cleanly (message + exit 1, no stack trace).
  • Rubocop: diff-clean — 4 offenses remain, all pre-existing on pristine files (contract.rb:65 LineLength; builder.rb:58 redundant disable; builder.rb:63 AbcSize/MethodLength on run_stages); this change adds none.

Notes

  • Docs: docs/build-chain.md gains "The abi gates" section and the macOS N ↔ darwin N+9 SSOT entry.
  • Contract#darwin_kernel_major also deduplicates the previously inline split.to_i + 9 in configure_triplet (SSOT law: one owner, everything else flows).
  • Draft per the standing rule — merge only with the owner's go-ahead.

…+ publish-time continuity

The registry's `abi` segment is resolution truth for native-extension
payloads (spec 05 §5; mirrored verbatim by tools/registry_update.rb
since registry MINOR 11, tebako#1047), yet nothing asserted the
vocabulary's continuity or its derivation:

- The 0.17.14/0.17.15 darwin-24 drift window (the macos-15 fleet's
  kernel release baked in by config.guess since the fleet move in
  1cca8848) let a shard publish an abi the contract never spelled.
- The 0.17.16 triplet pin (e21ac53) restored the contract floor's
  darwin-23 spelling (#317) — a patch line that silently broke every
  darwin-24-pressed native payload (the metanorma smoke's
  "Could not find 'ox' (>= 0) among 316 total gem(s)",
  tebako-packages/packed-metanorma#313).

This change closes the window with two fail-closed layers:

1. Build time — Builder#write_abi_sidecar now asserts the shard's abi
   equals the contract floor's derivation: Contract#darwin_kernel_major
   (the macOS N ↔ darwin N+9 SSOT, owned here and flowed into
   configure_triplet) against macos_deployment_target. A host-kernel
   leak fails the leg with exit 134 naming got/want/floor before any
   publish.

2. Publish time — publish.yml gains a gate step
   (tools/registry_abi_gate.rb) comparing the render's darwin rows
   against the previous line's rows on origin/main, failing closed
   naming every (line, platform, old → new) tuple unless the run
   carries the deliberate abi_bump dispatch input, whose text is
   recorded into the registry bot PR body. Scope is MECE: darwin rows
   only, introductions pass, withdrawn rows are dead vocabulary,
   pre-MINOR-11 rows declare no vocabulary.

Evidence: 453 examples / 0 failures (50 pending = the opt-in
published-pair network acceptance); the gate simulated live against
main's registry (10 darwin rows stable, exit 0) and against a flipped
fixture (fail-closed without the knob naming both macos tuples;
acknowledged with it, exit 0). Rubocop diff-clean (the 4 remaining
offenses pre-date this change).
@ronaldtse
ronaldtse marked this pull request as ready for review November 27, 2026 11:36
@ronaldtse
ronaldtse merged commit 5e7a487 into main Nov 27, 2026
68 of 70 checks passed

This branch was previously deployed

1 inactive deployment
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.

2 participants