Browse the documentation
Contract: provider adapter
Status: specified
; validation and normalization areimplemented in src/provider.mjs, and model
profiles are implemented in src/model-profile.mjs.
The seam
A provider is any backend that can complete text. Seed and Bloom agree on one call shape:
generate({ system, prompt, model, signal, ...providerConfig })
returning
{ text, complete, model, usage }
| Field | Contract |
|---|---|
system |
stable instruction text, sent before the changing prompt body |
prompt |
the per-call task body |
model |
the model identifier the caller selected, or null for the default |
signal |
abort support; a stopped run must stop the call |
text |
the generated body (string; may be empty when complete is true) |
complete |
true only when the provider reports a finished structured response |
model |
the model that actually served, for the ledger |
usage |
{ input, output, total, cacheRead, cacheWrite } or null |
Rules
- Missing metrics are
null, never zero, never invented. A provider that cannot report usage returnsnull; the run records “unreported”, the same discipline Bloom documents for its own usage lines. - No silent model substitution. If the requested model is unavailable, the adapter errors; it never substitutes another model without the caller deciding.
- Stops propagate.
signalaborts the call; the adapter resolves without recording a fabricated completion. completeis earned. Streaming adapters returncomplete: falseuntil their backend reports a finished structured response. Nocomplete: trueon truncated text.- One provider process, one responsibility. A provider never mutates run state, memory, or artifacts; those facts belong to the run engine and the stores.
Model names
implemented in src/model-alias.mjs. A caller asks for a model by alias. An alias
table, held by the caller, maps each alias to a backend model name:
modelAlias({ alias, backendModel, workload, deprecated?, replacedBy? })
modelAliasTable([alias records])
resolveModel(table, requested)
→ { resolved: true, requested, backendModel, deprecated, replacedBy }
| { resolved: false, requested, reason: 'unknown-alias' }
- The two names stay distinct. An alias is lowercase words joined by hyphens, with
no wildcard. A record whose alias equals its backend model name is refused. The result
carries both
requestedandbackendModel. - Only an alias resolves. A backend model name that no alias names is
unknown-alias, and nothing is chosen in its place (rule 2 above). - Deprecated is a label, not a swap. A deprecated alias resolves to its own backend
model with
deprecated: true. It may namereplacedBy, which the table checks is a registered alias that is not itself deprecated. Resolution never follows it; the caller decides. - The table is local. Resolution reads only the table it is given. It makes no
network call and asks no backend which models exist. No seed module opens a listener
or calls the network, and a test reads every module in
src/to hold that.
Serving these names over a local endpoint is stage 2, and stays specified.
Model profiles
implemented in src/model-profile.mjs. A model profile says what a configured model can
do, and where each answer came from:
checkModelProfile(record) -> { ok, errors }
modelProfile(record) -> frozen copy, or throws ModelProfileError
PROFILE_SLOTS = ['model', 'contextLength', 'toolCalling', 'constrainedOutput', 'streaming']
PROFILE_SOURCES = ['reported', 'probed', 'unknown']
Every slot is { value, source }:
| Slot | Known value |
|---|---|
model |
a non-empty string, the model that answers |
contextLength |
a positive safe integer |
toolCalling |
a boolean |
constrainedOutput |
a boolean |
streaming |
a boolean |
- Provenance is required.
reportedmeans a backend declared the value,probedmeans a probe observed it, andunknownmeans neither. No other source is accepted. - Unknown is not a guess. An
unknownslot carriesvalue: null. Anunknownslot with a value is refused, so no default context window or optimistictruepasses as known. - Known means known. A
reportedorprobedslot needs a value of the slot’s type. A probedfalseis a known answer. - The record is closed. Only the five slots, and only
valueandsourceinside each. A profile holds no endpoint address, host, or credential, and error text names the slot and the expectation without repeating a supplied value. - Seed checks truth, not capability. Seed builds no profile from a backend. Probing is the consumer’s job; seed only refuses a record that claims more than it knows.
Recorded conformance fixtures
test/fixtures/provider-conformance.json holds recorded request and response cases with
synthetic values. test/provider-conformance.test.mjs replays each case through a recorded
adapter, validateProvider, and normalizeGeneration with fetch disabled, and checks:
- valid completions with full, partial, and unreported usage (
null, never0); - malformed records (missing
text, non-booleancomplete, unknown usage field, negative or fractional counts, non-stringmodel) fail closed with the named violation; - truncated completions keep
complete: false; - a slow stream aborted by
signalresolves with the partial text,complete: false, andusage: null, and the same stream left to finish earnscomplete: true; - an unavailable model fails closed, and no other model is named in its place.
The fixtures name no address, host, or credential, and a test holds that.
The OpenAI-compatible tier
Hosted and local services that already speak the chat-completions HTTP surface
(POST {base}/v1/chat/completions) are the first adapter class, because Bloom accepts
such a service today via its --api-base provider mode. The Stage 2 endpoint (see
roadmap) puts that HTTP shape — speaking to any configured backend —
inside seed, so workspaces point at one local address while backends remain swappable.
src/provider.mjs implements validateProvider (checks a candidate adapter against the
seam) and normalizeGeneration (accepts a raw provider result and either returns a
conforming record or names every contract violation).
Changes
0.10.0addscheckModelProfile,modelProfile,ModelProfileError,PROFILE_SLOTS, andPROFILE_SOURCESinsrc/model-profile.mjs, with recorded offline conformance fixtures. Additive; no existing export changed.0.4.0— model names (modelAlias,modelAliasTable,resolveModel,ModelAliasError) are new exports insrc/model-alias.mjs. Additive; no existing export changed. Stage 2 staysspecified.