Repository navigation
Conversation
Define an artifact for state that a runtime builds while running a model, such as a prompt cache or a saved conversation. Its manifest references the model artifact through subject, and its config records the state's format, the tokens it was built from and, optionally, its precision. Refs modelpack#239 Signed-off-by: João Galego <jgalego1990@gmail.com>
Add the artifact, config and layer media types for model state artifacts, a State type for the config, and a JSON schema registered under ValidatorMediaTypeModelStateConfig. As with model configs, the validator decodes a state config into its Go type before validating it against the schema. Refs modelpack#239 Signed-off-by: João Galego <jgalego1990@gmail.com>
1435155 to
dc063a4
Compare
aftersnow
left a comment
There was a problem hiding this comment.
Please align the Go state validator with the published schema and clarify how runtimes establish trust in a state before loading it.
| func validateState(buf []byte) error { | ||
| state := v1.State{} | ||
|
|
||
| err := json.Unmarshal(buf, &state) |
There was a problem hiding this comment.
I ran ValidatorMediaTypeModelStateConfig.Validate on {"format":"example/v1","tokens":[1.0]}. Both 1.0 and 1e0 fail to decode into []int, while 1 succeeds. All three represent the same integer under the declared JSON Schema. Please validate the numeric value exactly, retaining the existing regression case for 1.0000000000000001, and add passing cases for both integral spellings. JSON Schema integer semantics
There was a problem hiding this comment.
Fixed. validateState now checks each token ID's exact value: 1.0 and 1e0 pass, 1.0000000000000001 still fails. Added passing cases for both spellings.
|
|
||
| A state MUST NOT be loaded for a model other than the one its `subject` references. A runtime MUST NOT load a state whose `format` it does not support. | ||
|
|
||
| A runtime cannot check that a state's layers match its `tokens` without processing the tokens, which is the work the state saves. Runtimes SHOULD load only states they trust, for example states with a verified signature or states referenced by digest, and SHOULD NOT load a state only because it is listed as a referrer of the model. |
There was a problem hiding this comment.
Every descriptor returned by the referrers API already carries a digest. Reusing that digest to check the downloaded blob establishes integrity, but gives the runtime no independent evidence of who produced the state or whether it corresponds to the stated tokens. Please qualify the example as a digest pinned through a trusted channel, or a signature verified against an authorized producer. OCI referrers API
There was a problem hiding this comment.
Reworded: "a state pinned by a digest obtained through a trusted channel, or one whose signature was verified against an authorized producer".
…onent Check each token ID's exact value instead of decoding into []int, so 1.0 and 1e0 pass as the schema allows, while 1.0000000000000001 still fails. Refs modelpack#239 Signed-off-by: João Galego <jgalego1990@gmail.com>
A digest from the referrers listing proves integrity, not who produced the state. Name a digest pinned through a trusted channel or a signature verified against an authorized producer instead. Refs modelpack#239 Signed-off-by: João Galego <jgalego1990@gmail.com>
|
Both addressed: the validator now accepts any integral spelling, and the trust example names the trusted channel or the authorized signer. |
Description
Adds OCI artifacts for runtime state, such as prompt caches and saved conversations.
application/vnd.cncf.model.state.manifest.v1+jsonwith a requiredsubjectreferencing the model artifact's manifest.application/vnd.cncf.model.state.config.v1+jsonwith requiredformat(encoding and version) andtokens, and optionalprecision.application/vnd.cncf.model.state.v1.raw,.tar,.tar+gzip, and.tar+zstd.Adds Go types and constants, a JSON schema, typed config validation, and tests for invalid configs and the documentation example.
State encoding is runtime-specific and identified by
format. Loading rules:subjectreferences, or by a runtime that does not support itsformat.States built from images, audio or other non-token input, or with an adapter applied, are out of scope. Existing media types and the model config schema are unchanged.
Related Issue
Closes #239
Motivation and Context
ModelPack does not currently define how to package reusable runtime state. This supports two use cases:
Linking through
subjectleaves the model artifact unchanged and lets multiple states be published independently. As discussed on #60, the doc notes that this link is advisory.This PR proposes defining state artifacts in ModelPack rather than a separate spec.