Skip to content

build: the native macOS build stamps through scripts/env.sh (ADR 0032); close ADR 0037's open items - #328

Merged
glennneuber merged 2 commits into
mainfrom
fix/adr0032-metal-stamp
Sep 19, 2026
Merged

glennneuber merged 2 commits into
mainfrom
fix/adr0032-metal-stamp

Conversation

@glennneuber

Copy link
Copy Markdown

Resolves the two open consequences ADR 0037 recorded, and the ADR 0032 non-conformance behind one of them.

What went wrong

The v0.34.1 fold shipped one commit under two identities:

time (2026-09-18)
fold merge lands 8a7ba949 11:56:44
Metal binary built from it 12:00:24
v0.34.1-dynres cut on it 12:49:45

The CUDA image, stamped by scripts/env.sh, reports 0.34.1-dynres-0-g8a7ba94. The Metal binary reports 0.34.0-maxusai-8a7ba949 — build-macos.sh never adopted ADR 0032. It stamped its own <base>-maxusai-<sha>, taking <base> from the newest release tag at build time, still v0.34.0-dynres for those 49 minutes. So the release matrix couldn't render both surfaces from one --version, and nothing refused a fold build made before its tag.

Fix

  • build-macos.sh stamps through scripts/env.sh, sourced in a subshell so only VERSION crosses over (env.sh's release GOFLAGS would change the build). STAMP_ONLY=1 prints the stamp and builds nothing; inert when unset (H4).
  • mlx-metal-0-34-0 admits both stamps of the deployed build plus interim builds on the 0.34.1 lineage, and refuses 0.34.0-dynres-* — a fold build made before its tag — along with point tags and -dirty. The original mistake now stops at preflight.
  • release_matrix.py --version is repeatable. One prefix still drops a foreign build's run.
  • ADR 0032 amendment records 0.34.0-maxusai-8a7ba949 ≡ 0.34.1-dynres-0-g8a7ba94 as one build. No rebuild to restamp, per the ADR's own 0.33.0 precedent.
  • ADR 0037 closes: stamp → resolved here; OLLAMA_MLX_DRAFT_UNDER_GRAMMAR=0 → now in the Metal launchd env (verified in the running process's environment); global scale + mlx: opt-in dense GEMM for nvfp4 prefill (dequantise to bf16 above a row threshold) #287 → parked.
  • README deploy line, matrix comment (now a one-command regeneration once the CUDA run is committed), BINARIES.md, and spec/apple-silicon-build.md, which told readers to hand-assemble the stamp.

Tests — written first, watched fail for the right reasons

  • TestMetalStampFollowsADR0032 — admits/refuses the right stamps, resolves through preflight.resolve_profile (not just the regex), and build-macos.sh == env.sh.
  • TestReleaseMatrixEquivalentStamps — repeatable --version, in-process and via the CLI.

One thing worth knowing about the stamp test. Its first draft ran build-macos.sh for real, and in the red state — before STAMP_ONLY existed — that launched cmake and an MLX compile (inside a worktree, stopped immediately, production untouched). It now runs with PATH=/usr/bin:/bin: git, but no cmake and no go. It cannot start a build even if STAMP_ONLY regresses; its red state exits 127.

preflight 114/114 (module and script mode — both collect the new classes, per the file's own warning about classes appended after __main__); vision-suite client 38, quant_dims 8, rescore 24, summarizers 134.

🤖 Generated with Claude Code

glennneuber and others added 2 commits September 19, 2026 17:58
… amendment); close ADR 0037's open items

The v0.34.1 fold shipped one commit under two identities. The fold merge
landed 8a7ba94 at 11:56:44 on 2026-09-18, the Metal binary was built from it
at 12:00:24, and v0.34.1-dynres was cut on it at 12:49:45. The CUDA image,
stamped by scripts/env.sh, reports 0.34.1-dynres-0-g8a7ba94; the Metal binary
reports 0.34.0-maxusai-8a7ba949, because build-macos.sh never adopted ADR 0032
— it stamped <base>-maxusai-<sha> with <base> taken from the newest release tag
at BUILD time, which for those 49 minutes was still v0.34.0-dynres.

build-macos.sh now sources scripts/env.sh in a subshell and takes only VERSION
(env.sh's release GOFLAGS would change what it builds). STAMP_ONLY=1 prints the
stamp and builds nothing; inert when unset (SPEC H4).

mlx-metal-0-34-0 admits both stamps of the deployed build and interim builds
on the 0.34.1 lineage, and refuses 0.34.0-dynres-* — a fold build made before
its tag — along with point tags and -dirty. The mistake now stops at preflight.

release_matrix.py --version is repeatable, so a release whose surfaces carry
equivalent stamps names each; one prefix still drops a foreign build's run.

ADR 0032 records 0.34.0-maxusai-8a7ba949 = 0.34.1-dynres-0-g8a7ba94 as one
build, and does not rebuild the deployed binary to restamp it, following its
own 0.33.0 precedent. ADR 0037's consequences are closed: the stamp is
resolved by that amendment; OLLAMA_MLX_DRAFT_UNDER_GRAMMAR=0 is now in the
Metal launchd environment (re-bootstrapped 17:44:40, verified in the running
process's env); the nvfp4 global-scale question and #287 are parked.

Tests (test_verdicts.py), written first and watched fail for the right
reasons:
  TestMetalStampFollowsADR0032        admits/refuses, resolves through
                                      preflight.resolve_profile, and
                                      build-macos.sh == env.sh
  TestReleaseMatrixEquivalentStamps   repeatable --version, in-process and CLI

The stamp test runs build-macos.sh with PATH cut to /usr/bin:/bin — git, no
cmake, no go — so it CANNOT start a real build even if STAMP_ONLY regresses.
Its first draft could, and did: run red before STAMP_ONLY existed, it launched
cmake and an MLX compile (inside the worktree, stopped at once). A test whose
red state builds the product is a hazard; this one's red state now exits 127.

preflight 114/114 (module and script mode, the new classes collected in
both); vision-suite client 38, quant_dims 8, rescore 24, summarizers 134.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…lds only git/sed/dirname

CI's "Verify the tests pass on a tree carrying preflight/ alone" step copies
preflight/ to a temp tree and runs the suite there, to prove the gate ships
self-contained. test_build_macos_stamps_exactly_what_env_sh_stamps reaches
outside it for build-macos.sh and scripts/env.sh, so it failed there with
"cannot open ... build-macos.sh". It now skips when either is absent, the
same way the suite's other out-of-tree tests do. The class's other three
tests need only expectations.toml and preflight.py and still run.

Fixing it showed the "cannot start a real build" claim leaned on
/usr/bin:/bin holding no cmake — true on this Mac, not something to rely on
for a Linux runner. PATH is now a temp dir holding only git, sed and dirname,
everything the script touches before STAMP_ONLY exits, invoked through
/bin/sh. Checked by running the script WITHOUT STAMP_ONLY under that PATH:
rc=127 at the first build tool, no build/ created.

Local, both CI modes: full tree 114 OK (skipped=6, the stamp test runs);
simulated preflight/-alone tree 114 OK (skipped=10, the stamp test skipped
with its reason).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@glennneuber
glennneuber merged commit d7f6dea into main Sep 19, 2026
1 check passed
@glennneuber
glennneuber deleted the fix/adr0032-metal-stamp branch September 19, 2026 08:10
glennneuber pushed a commit that referenced this pull request Sep 19, 2026
…line

#328 amended the Apple Silicon sentence — the stamp equivalence under ADR 0032,
and the launchd environment does set OLLAMA_MLX_DRAFT_UNDER_GRAMMAR=0 after all.
That correction is kept verbatim; this branch contributes only the CUDA line,
which moves to the ADR 0036 rebuild stamp.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
glennneuber added a commit that referenced this pull request Sep 19, 2026
Closes the ADR 0036 record: the deployed stamp on the CUDA host, the production verification, and the retirement-register row. Main merged in twice to keep both deployment lines after #324 and #328 edited the same block.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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