feat: document GenerationConfig hint/guarantee rule + add EmbeddingBackend capabilities (#1834)#1887
Merged
Merged
Conversation
…ckend capabilities (#1834) Three non-breaking polish items deferred from #1834: - Type-level doc on GenerationConfig stating the throw-vs-silently-ignore rule once: capability-gated guarantees (grammar) MUST throw; advisory hints (seed, minP, jsonMode, penalties, vendor knobs) are best-effort. - Additive EmbeddingCapabilities value type + EmbeddingBackend.capabilities protocol requirement with a protocol-extension default (.default), so existing conformers don't break. Tightened dimensions/embed(_:) contract docs. - Non-DocC comment by the llama* vendor sampler fields noting the deferred relocation into the companion package (tracked in #1834). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Small, additive, non-breaking polish addressing three deferred items from #1834. Source-only stability (no
-enable-library-evolution), so all three arefeat:, notfeat!:.Changes
Item #1 — GenerationConfig throw-vs-silent-ignore rule (doc). Added a type-level DocC block on
GenerationConfigstating the rule once: capability-gated guarantees (e.g.grammar) MUST throwInferenceError.unsupportedGrammarrather than silently degrade; advisory hints (seed,minP,jsonMode, sampler penalties, vendor knobs) are best-effort and silently ignored by backends that don't support them. No field changed.Item #15 — EmbeddingBackend capabilities (additive). New public
EmbeddingCapabilitiesvalue type (Sendable/Codable/Equatable/Hashable) withmaxBatchSize,maxInputLength,producesNormalizedVectors, a memberwise init with safe defaults, andEmbeddingCapabilities.default. Addedvar capabilitiesto theEmbeddingBackendprotocol with a protocol-extension default (.default) — the same non-breaking pattern asInferenceBackend.manifest/secureWipe, so existing conformers don't break. Tightened thedimensionsandembed(_:)contract docs (load-time meaning ofdimensions; one-vector-per-input postcondition onembed).Item #2 — vendor-knob cleanup note (docs-only). Added a plain
//comment by thellama*sampler fields noting they're backend-specific knobs on the shared type, accepted as tech debt, with relocation deferred and tracked in #1834. Fields unchanged.Non-breaking
All additive: new type + a protocol requirement satisfied by a protocol-extension default. No vendor field removed or relocated, no
backendSpecificcontainer added, noPackage.swift/Package.resolvedchange. Source-only stability means this does not break ABI.Why not more
The relocate+remove of the
llama*vendor fields into the companion package was deliberately deferred — cross-repo blast radius. An adversarial review concluded these items are not freeze-blocking, so this PR ships the docs + the additive capabilities surface only.Tests
Tests/ManifoldInferenceTests/EmbeddingBackendProtocolTests.swift:capabilitiesreturnsEmbeddingCapabilities.default(proves the non-breaking default);EmbeddingCapabilitiesCodable round-trips.Scoped suite:
swift test --filter EmbeddingBackendProtocolTests→ 7/7 pass. Sabotage-verified the default test fails when the protocol-extension default is broken, then reverted.🤖 Generated with Claude Code