Skip to content

feat: document GenerationConfig hint/guarantee rule + add EmbeddingBackend capabilities (#1834)#1887

Merged
roryford merged 1 commit into
mainfrom
feat/contract-1834-polish
Jun 15, 2026
Merged

feat: document GenerationConfig hint/guarantee rule + add EmbeddingBackend capabilities (#1834)#1887
roryford merged 1 commit into
mainfrom
feat/contract-1834-polish

Conversation

@roryford

Copy link
Copy Markdown
Owner

Small, additive, non-breaking polish addressing three deferred items from #1834. Source-only stability (no -enable-library-evolution), so all three are feat:, not feat!:.

Changes

Item #1 — GenerationConfig throw-vs-silent-ignore rule (doc). Added a type-level DocC block on GenerationConfig stating the rule once: capability-gated guarantees (e.g. grammar) MUST throw InferenceError.unsupportedGrammar rather 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 EmbeddingCapabilities value type (Sendable/Codable/Equatable/Hashable) with maxBatchSize, maxInputLength, producesNormalizedVectors, a memberwise init with safe defaults, and EmbeddingCapabilities.default. Added var capabilities to the EmbeddingBackend protocol with a protocol-extension default (.default) — the same non-breaking pattern as InferenceBackend.manifest/secureWipe, so existing conformers don't break. Tightened the dimensions and embed(_:) contract docs (load-time meaning of dimensions; one-vector-per-input postcondition on embed).

Item #2 — vendor-knob cleanup note (docs-only). Added a plain // comment by the llama* 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 backendSpecific container added, no Package.swift/Package.resolved change. 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:

  • a conformer that does not override capabilities returns EmbeddingCapabilities.default (proves the non-breaking default);
  • EmbeddingCapabilities Codable 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

…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>
@roryford roryford merged commit 7a48515 into main Jun 15, 2026
10 checks passed
@roryford roryford deleted the feat/contract-1834-polish branch June 15, 2026 11:24
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