Repository navigation
feat: bump the substrate to integration-2026-10-14 for embeddinggemma-2 (#234) - #237
Conversation
…-2 (#234) Pin mlx-swift-lm at integration-2026-10-14 (29dcb353) and raise the mlx-swift floor to 0.32.3. Refuse kv_compression=triattention with a named reason (not in this tag; ADR 028 amendment), keep the serve and guided prefill at 512-token .remainder chunks, flush rejected tool calls as content, classify embedding_gemma2 as an embedder, give the forced tool-call grammars fixed separators, and add the embedding parity script. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UYFBxGGeqv3otX74mHcj4n
Cap EmbeddingGemma 2 input at its context length (#235 tracks the BERT-family case), fail a truncated rejected-tool-call preview instead of returning it as content, keep Qwen3.5 MTP inert at this pin (its iterator prefills unchunked; #92), pin the serve-path prefill through a testable seam, skip the TriAttention heavy test with its named reason, harden the parity script against NaN/empty references, and correct the substrate-behaviour wording in the ADR, tests and scripts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UYFBxGGeqv3otX74mHcj4n
… rejection (#234) Throwing inside the stream loop left the inference gate while the substrate producer could still be decoding. Record the rejection, let the stream finish as on any normal completion, then fail the request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UYFBxGGeqv3otX74mHcj4n
There was a problem hiding this comment.
Verdict: COMMENT — deferring to @GoodOlClint. No blockers found; 8 in-scope follow-ups below.
@GoodOlClint — this is a substrate pin bump plus an mlx-swift minor bump (0.31.6 → 0.32.3) and an ADR 028 amendment that removes a config value operators can set today. All three are explicitly operator calls, so I'm not approving or requesting changes. Four things specifically want your judgment:
- TriAttention withdrawal vs. ADR 033. This PR enacts most of ADR 033 §3 ("collapse
kv_compressiontonone-only") — but ADR 033 is still Proposed — awaiting operator approval, and it specified a different mechanism (triattentionbecomes an unrecognized value, like theturboquantretirement). This PR instead keeps the enum case and refuses it with a distinctUnavailableError. The new ADR 028 amendment never mentions ADR 033, even though ADR 028's own tripwire paragraph says "Superseded if ADR 033 lands". Please rule on whether the amendment supersedes, narrows, or defers ADR 033 — the ledger currently leaves two live ADRs disagreeing about the same knob. - The embedding input cap is deliberately asymmetric. EmbeddingGemma 2 now 400s over 8,192 tokens; BERT-family models (512 positions) keep silently truncating, left as #235. That's a client-visible inconsistency by design, not by oversight — your call.
- Disclosed-but-unmeasured gaps that touch accepted ADRs: disconnect-cancel under the substrate's new dedicated generation thread was not re-measured and
deploy/e2e-disconnect-cancel.shwas not run (ADR 029's 2026-09-24 addendum); the ADR 044 xgrammar tripwire came back inconclusive. Both are honestly stated in the PR body — whether they gate the merge is yours. - Minor, but public-repo-shaped: the reference file is correctly not committed, but the parity-corpus queries are quoted verbatim in the PR body, and they read like a private consumer corpus (DV/legal-domain phrasings). Nothing in a tracked file; flagging per the no-private-references rule and leaving it to you.
Scope
One coherent change (the pin bump) that fuses eight sub-changes — 340+/101- across 26 files. Four of them stand alone and are not strictly pin-driven: the x-guidance forced-tool-call grammar fix, the EmbeddingGemma 2 input cap, the ModelClass ordering fix, and the new parity script. The pin is what exposes each of them, and splitting would leave a tree that can't build, so one PR is defensible — but it is the upper end of what one review can carry.
Verification
CI: unit tier pending at review time. Lint (swift-format), Resolve pins with no cache, and Classify diff all pass. Heavy gates (845 unit tests, 7/7 tool-choice, 6/6 parity, MTP #64) are host-only and not reproducible here. What I did verify independently against the substrate at 29dcb353:
- Pin chain is sound: tag
integration-2026-10-14→ annotated tage9c7ae64→ commit29dcb353, matchingPackage.resolved. PrefillParameters.Chunkingdefault did become.balanced, and.remainderreturns exactlyresolvedStepSize— soGuidedSubstrate.prefilldoes keep hard 512-token boundaries, andPrefillWindowPinTests' third assertion (.balancedon 1000 → 500 ≠ 512) genuinely fails under mutation. Claim holds.BatchGenerator'sprefillStepSize: Int = 2048is unchanged at this pin — the "predates the bump" disclosure is accurate, andBatchScheduler.enabledis still default-off, so the serve-path prefill claim holds for the shipped posture.EmbeddingGemma2Configuration.contextLength == 8_192, and the model really doesmin(tokens.dim(1), 8192)— the silent-prefix-embedding the cap prevents is real.embedding_gemma2/embedding_gemma2_textare both inEmbedderTypeRegistry, so theembedderOnlyTypesaddition is correct.RejectedToolCall/RejectedToolCallErrorshapes match the new handler, includingdefaultPreviewByteLimit = 32_768.- The drain-then-throw ordering is correct:
for await event in begun.streamruns to stream termination before the throw escapeswithExclusiveExecution, so the producer has stopped before the gate opens. The "a truncated preview is never returned" claim holds — the client only ever seese.message, which is detail-free (NE7). See follow-up 1 for the latent half of that guarantee.
Hard constraints: no new egress; no route added/removed/changed (so no OpenAPISpec.swift edit owed); errors stay in the envelope; appVersion untouched at 0.11.0; ADR 028 amended with its LEDGER line in the same PR.
Follow-ups
Sources/AthenaLLM/MLXLLMModule.swift:938— the new failure path lands in the generic error bucket, and carries the preview with it.RejectedToolCallErrorisn't anAthenaError, soAthenaError.classifyfalls through to.moduleLoadFailed(.llm, reason: String(describing: error)): the client gets a 500module_load_failed/ "Module llm failed to load." for a model-output anomaly after a successful load — the opposite of cause-naming. Separately,RejectedToolCallErroris a plain struct (noCustomStringConvertible), soString(describing:)reflects over it and embeds the fullrawTextPreview— up to 32 KiB of model output, possibly argument values — intoAthenaError.serverDetail. Nothing leaks today (both chat paths catchAthenaErrordirectly and return onlye.message;AthenaServer.classified, which logsserverDetail, is unreachable from any generation route), but it quietly defeats the stated "the log line carries the reason only" property for any future caller that does reach it. A dedicatedAthenaErrorcase carrying onlyreason+rawTextByteCountfixes the code name and the latent leak in one edit.Sources/AthenaLLM/MLXLLMModule.swift:940— a rejected-tool-call failure escapes token metering. The throw skipscontinuation.yield(.usage(u)), andAthenaServer+ChatOpenAI.swift:353returns beforemeter(principal:usage:). This is the first failure path reachable after a complete decode —.infohas already populatedu— so a request that burned up tomax_tokensof GPU time is recorded as 0 tokens against its ADR 041 budget and the metrics counter. Skipping metering on error is pre-existing for every other path, but those all fail before decode.Sources/AthenaLLM/SupportedModels.swift:58—athena showstill advertises both capabilities this PR disables. For anyqwen3_5*model it prints "Qwen3.5 (vendored): MTP speculative, TriAttention eviction, guided structured output".loadMTPDrafterIfEligiblenow returns early forqwen3_5*, andkv_compression = triattentionrefuses at start — so two of the three advertised features are gone. This is user-visible CLI output, not a comment, and the "stale triattention prose" sweep (athena.toml, DefaultConfig, RUNBOOK I5, studio-setup, ConfigEditor) missed it.Sources/AthenaDeploy/AthenaConfig.swift:56's doc comment still says "none(default) ortriattention" too.Sources/AthenaLLM/MLXLLMModule.swift:693—loadQwen35MTPDrafternow has no callers. ~25 lines of unreachable code (Swift won't warn for aprivatemethod). Presumably retained as the #92 restore point, the same way theservesArchwarning inLoad.swiftwas deliberately kept — but unlike that one, nothing in the diff or the ADR says so. Add a one-line marker or delete it.Sources/AthenaEmbedding/MLXEmbeddingModule.swift:250— new limit logic the unit tier can't reach.inputCeiling(for:)is a client-visible 400 boundary that dispatches on the substrate typeEmbeddingGemma2inside an MLX-linked target, so its only evidence is a live curl log; nothing pins it underswift test. The decidable part is small — something likeinputCeiling(maxPositions: Int?, isPositionLimited: Bool)in AthenaCore, withMLXEmbeddingModulesupplying the two facts — and would satisfy ADR 008/009. This is the closest thing in the diff to a hard-constraint item; I'm flagging rather than blocking because the extracted algebra is a singlemin().docs/substrate-bump-runbook.md— the new gate isn't in the gate battery.deploy/e2e-embedding-parity.shis a reusable, permanent gate (it takes a reference file and a model id), but §5's table gained no row for it, so the next bump won't run it. While in that table: the Unit-tier row still reads "787 tests" against the 845 this PR reports.Sources/AthenaLLM/MLXLLMModule.swift:901— the one newlog.noticeomitsmetadata: ["function": …], unlike every other log site in the file (including the Qwen3.5 notice added 260 lines above it).deploy/e2e-embedding-parity.sh— two inputs still fail as a Python traceback rather than a named error. A reference file with noquerieskey raisesKeyError, and an all-zero reference vector divides by zero incosine. The Codex round'sisfiniteand non-empty guards cover the other two shapes; these two are oneifeach.
🤖 Generated with Claude Code
Prerelease cut for embeddinggemma-2 on /v1/embeddings (substrate integration-2026-10-14, #237) and the embedder load-failure fix (#240). - Athena.appVersion 0.11.0 -> 0.12.0-dev1 (ADR 040 S8 release commit). - release.yml publishes a tag containing a hyphen as a GitHub prerelease, so a dev tag never becomes Latest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WD2bc4rWu67xtvnZ7uba6H
Prerelease cut for embeddinggemma-2 on /v1/embeddings (substrate integration-2026-10-14, #237) and the embedder load-failure fix (#240). - Athena.appVersion 0.11.0 -> 0.12.0-dev1 (ADR 040 S8 release commit). - release.yml publishes a tag containing a hyphen as a GitHub prerelease, so a dev tag never becomes Latest. Claude-Session: https://claude.ai/code/session_01WD2bc4rWu67xtvnZ7uba6H Co-authored-by: goodolclint-claude[bot] <323206664+goodolclint-claude[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Closes #234.
Moves the MLX substrate from
integration-2026-07-31(5b892140) tointegration-2026-10-14(29dcb353) so thatgoogle/embeddinggemma-2serves on/v1/embeddings.mlx-swiftmoves 0.31.6 → 0.32.3 (a minor; the substrate's manifest now requires it). The full blast-radius inventory is in #234.What this changes
Package.swiftpoints at tagintegration-2026-10-14. Themlx-swiftfloor is.upToNextMinor(from: "0.32.3")in the manifestkvScheme(unsupportedLegacyScheme). Sokv_compression = triattentionis refused with a named reason at daemon start (env and TOML) and atathena config set. The enum case is kept, so its return is a one-line diff. Recorded as an ADR 028 amendment plus its LEDGER lineKVCompressionTests.testTriattentionRefusedWithNamedReason(4 failures with the refusal removed; log below);ConfigEditorTests.testRefusesUnavailableTriattention;e2e-rbac.shphase 12.balanced. The serve path (MLXLLMModule.serveParameters) and the guided path (TokenIterator) shareGuidedSubstrate.prefill = (stepSize: 512, chunking: .remainder), which keeps ADR 030's per-512-chunk reasoning (#88)PrefillWindowPinTestscovers the constant and the serve seam (a mutation to.balancedfails it). The guided call site is pinned only by its use of the shared constant, becauseTokenIteratorneeds a model-mtpcheckpoints (#92). Its MTP iterator, however, prefills the whole prompt in one unchunked forward with full-vocab logits, outside the 512 window and ADR 030. It is kept inert at this pin with a logged reason. This matches pre-bump behaviour, where it never paired. No local checkpoint can exercise itinput_too_longinstead of a vector that embeds only the prefix. The BERT-family analogue (512 positions, silently accepted on main today) is #235, left for an operator decisionembeddinggemma2-overlength.log)Generation.rejectedToolCallrawTextPreviewkeeps that. Behaviour change: a call to an undeclared tool used to pass through astool_calls; the substrate now rejects it, and it arrives as content. A truncated (>32 KiB) preview is never returned: the stream is drained first, so the producer stops before the inference gate opens, and then the request fails. The log line carries only the reasongoogle/embeddinggemma-2config carriesvision_config/audio_config, soModelClassrouted it to the VLM path and the store did not offer it as an embedder. Embedder-onlymodel_types (now includingembedding_gemma2/_text) are checked before the vision ruleModelClassTests.testEmbeddingGemma2BeatsItsVisionTowertool_choice: requiredproduced{"arguments":{…}followed by whitespace up tomax_tokens. llguidance's default flexible whitespace allowed that loop, because the grammar still needed,"name". The forced tool-call schemas (single andoneOf) now carry"x-guidance": {"whitespace_flexible": false}at the root, which gives compact,/:separatorsStructuredSchemaTests; e2e tool-choice was 5/7 before the fix (checks 3 and 6 failed withfinish=length) and 7/7 after. Main's v0.11.0 binary is also 7/7MLXArray's non-Sendability through@preconcurrency import MLX(7 new warnings).DiarizationOutput/StreamingStateare now@unchecked Sendableunder a single-owner hand-off invariant, justified in the warnings audit §4. The first-party warning set is back to the audited baseline (the 3setErrorHandlersites)swift build --build-testswith all sources toucheddeploy/e2e-embedding-parity.sh <reference.json> [model]. It POSTs eachprefixed_input, prints a cosine per query, and exits non-zero below 0.99 (PARITY_MIN), on NaN, or on an empty reference. The reference file is not committedNo
appVersionbump. No SPM salt bump:Package.resolvedchanged, so the cache key rotates; the dependency shape (traits) is unchanged; and neither runbook §4 case applies. The toolchain floor is unchanged (mlx-swift's tools version is still 6.3).Test evidence
./deploy/test.shpasses (unit tier): 845 run, 0 failurese2e-tool-choice-auto7/7,e2e-count-tokensALL PASSED,e2e-rbac455/0,e2e-embedding-parity6/6.balanced), x-guidance schema and the classifier reorder (both caught under mutation by the house reviewer)Design / ADR discipline
/v1/embeddingsgains a model, not a route)input_too_long,module_load_failed, the classified rejection)Gates (runbook §5)
Each gate has a log on the build host; the file names are below.
./deploy/test.shunit.log./deploy/build.sh Releaseverify-hardening: OK; the pin guard printsmlx-swift-lm 29dcb353… (integration-2026-10-14)andmlx-swift 19601207… (0.32.3)release-build.log--cache-path/--scratch-path, copied manifest)resolved at integration-2026-10-14 (29dcb35)cold-resolve.loge2e-tool-choice-auto.log(baseline on main's binary:e2e-tool-choice-auto.MAIN-v0.11.0-binary.log)e2e-count-tokens.log'Red', 284 prompt tokens (283 at the previous pin)vision-smoke.loggemma4_assistantdrafter, proposed=21 accepted=21 passthrough=none. ADR 028 re-stampedmtp-parity-gate.loge2e-rbac.loge2e-embedding-parity.logkeyNotFound, recorded on the issue)paraphrase-ranking.logmutation-triattention.logPer-query cosines against the reference (query text withheld; the reference set is not public):
Notes for the reviewer
Known gaps
deploy/e2e-disconnect-cancel.shwas not run.nm -gU athena | grep -c xgrammarreads 0 at Xcode 27.0, but the Release binary exports only 547 global symbols, so the count does not show whether the dead code is gone. ADR 044 is left unchanged.BatchGeneratorstill prefills at its own 2048 default. This predates the bump.embeddinggemma-300mstill fails to load (embeddinggemma-300m (sentence-transformers export) fails to load: loader expectsmodel.embed_tokens.weight, file hasembed_tokens.weight#205). A failing configured embedder also wedges/v1/embeddingsfor every model until restart; this reproduces on main's v0.11.0 binary and is filed as One embedder that fails to load wedges /v1/embeddings for every model (500 module_load_failed until restart) #236.Review record
House pre-submit reviewer (athena-pre-reviewer). It mutation-checked every test-pinning claim, and all the refusal, schema and classifier tests caught their mutations. Fixed:
serveParametersseam);testTriattentionInertOnNonQwenStillGenerates(now skips with the named reason);kvScheme(it throws per request; corrected in the ADR, the comments and e2e-rbac);triattentionprose (athena.toml, DefaultConfig, RUNBOOK I5, studio-setup, the ConfigEditor option list).Accepted as is:
Load.swift'sservesArchwarning, which is unreachable while TriAttention is refused but is kept for its return.Codex adversarial review, round 1, all fixed:
isfiniteand a non-empty check.Codex round 2. [high] Throwing mid-stream released the inference gate while the producer could still run. Fixed by draining the stream before failing.
🤖 Generated with Claude Code
https://claude.ai/code/session_01UYFBxGGeqv3otX74mHcj4n