SPipe
steerability.spipe
.spipe: a portable serialization format for SteeringPipeline.
One format holds both the recipe (model reference plus controls-as-constructed) and, when
frozen, the resolution (fingerprints, resolved bindings, per-fit digests, and a
content-addressed artifact store). See docs/concepts/spipe.md for the model and the
sharing guidance.
DataRef
dataclass
A reference to a dataset, resolved at pipeline construction.
Attributes:
| Name | Type | Description |
|---|---|---|
kind |
str
|
|
repo_id |
str | None
|
Hub dataset id ( |
revision |
str | None
|
Hub revision ( |
split |
str | None
|
Dataset split ( |
subset |
str | None
|
Dataset configuration name ( |
path |
str | None
|
Local file path ( |
sha256 |
str | None
|
Hex digest the file must match ( |
type |
str | None
|
Type qualname of the recorded object ( |
fingerprint |
str | None
|
Content fingerprint of the recorded object ( |
Source code in steerability/spipe/codec.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
fingerprint = None
class-attribute
instance-attribute
kind
instance-attribute
path = None
class-attribute
instance-attribute
repo_id = None
class-attribute
instance-attribute
revision = None
class-attribute
instance-attribute
sha256 = None
class-attribute
instance-attribute
split = None
class-attribute
instance-attribute
subset = None
class-attribute
instance-attribute
type = None
class-attribute
instance-attribute
load()
Materialize the reference.
Returns:
| Type | Description |
|---|---|
Any
|
The loaded dataset for |
Raises:
| Type | Description |
|---|---|
SpipeFormatError
|
If the kind is |
SpipeIntegrityError
|
If a |
Source code in steerability/spipe/codec.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
NotFreezableError
Bases: RuntimeError
A control produces steer-time state but declares no frozen form.
Raised by BaseControl.frozen_form when a control's steer step produces fits or exported
state and the control does not override frozen_form to name a constructor-valid frozen
form. Re-exported from steerability.spipe.errors alongside the other spipe exceptions.
Source code in steerability/algorithms/core/base_control.py
12 13 14 15 16 17 18 | |
SPipe
A serialized steering pipeline: recipe, optional lock, and artifact store.
Instances come from SteeringPipeline.to_spipe() (backed by a temporary store until
saved) or SPipe.load() (backed by the loaded bundle). The manifest is data; controls
are instantiated only by pipeline().
Source code in steerability/spipe/spipe.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 | |
code_dependent
property
Whether loading this spipe needs matching code and allow_code=True.
config_id
property
The configuration identity digest over the recipe entries, 12 hex characters.
is_frozen
property
True iff every enabled entry with steer-time products carries a resolution.
Entries with resolved: null have nothing to pin (their recipe is their frozen
form), which makes a manifest with a lock section frozen.
manifest
property
A deep copy of the manifest.
recipe_id
property
The recipe identity digest (model reference plus controls), 12 hex characters.
describe()
A human-readable table of entries, frozen state, and artifact sizes.
Source code in steerability/spipe/spipe.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
load(path, *, allow_code=False, allow_stale=False, artifact_store=None)
classmethod
Load a .spipe file or directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
A |
required |
allow_code
|
bool
|
Permit |
False
|
allow_stale
|
bool
|
Skip the staleness check. |
False
|
artifact_store
|
str | Path | Callable[[str], Path] | None
|
External artifact source for thin bundles: a store directory, or a callable mapping an artifact id to the directory holding it. |
None
|
Returns:
| Type | Description |
|---|---|
'SPipe'
|
The loaded |
Raises:
| Type | Description |
|---|---|
SpipeFormatError
|
On format-version, schema, or archive violations. |
SpipeIntegrityError
|
If a present artifact fails content verification. |
SpipeStaleError
|
If a frozen entry is stale and |
Source code in steerability/spipe/spipe.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
pipeline(*, backend=None, prefer='frozen', verify='strict', **pipeline_kwargs)
Instantiate a SteeringPipeline from this spipe.
Frozen entries instantiate from their resolution by default; prefer="recipe"
instantiates every entry from its recipe args (forcing re-fits at steer()). The
spipe supplies the model reference and the controls only; backend, device, dtype, and
hf_model_kwargs are the caller's. The caller runs pipeline.check() /
pipeline.steer() as normal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
BackendSpec | str | None
|
Forwarded to the |
None
|
prefer
|
str
|
|
'frozen'
|
verify
|
str
|
Verification policy for frozen steering artifacts ( |
'strict'
|
Returns:
| Type | Description |
|---|---|
SteeringPipeline
|
The constructed (unsteered) |
Raises:
| Type | Description |
|---|---|
SpipeFormatError
|
If a method key resolves to no registered method. |
SpipeCodeRefError
|
If decoding requires code and the spipe was loaded without
|
SpipeStaleError
|
If a deferred staleness check fails (thin bundles). |
Source code in steerability/spipe/spipe.py
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 | |
save(path, *, artifacts='fat')
Write the spipe to path.
A path ending in .spipe produces a zip file; any other path produces (or replaces)
a directory. artifacts="fat" (default) embeds every referenced artifact;
artifacts="thin" writes the manifest only, leaving artifact ids resolvable at load
via artifact_store=. A recipe-only spipe with no artifact references writes no
artifacts/ directory either way.
Saving onto the bundle's own backing directory rewrites the manifest in place. A fat
save there also embeds any referenced artifact the store resolves externally, and a
thin save there raises SpipeSaveError when the directory embeds artifacts, since a
thin export would have to delete them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Destination file or directory. |
required |
artifacts
|
str
|
|
'fat'
|
Returns:
| Type | Description |
|---|---|
Path
|
The written path. |
Raises:
| Type | Description |
|---|---|
SpipeSaveError
|
If a directory target exists and is neither empty nor a spipe directory, a referenced artifact is unavailable for a fat export, or a thin export targets the bundle's own directory while it embeds artifacts. |
Source code in steerability/spipe/spipe.py
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | |
thaw()
A recipe-only copy: every resolved section and the lock are dropped.
Source code in steerability/spipe/spipe.py
207 208 209 210 211 212 213 214 215 216 | |
verify()
The model-free report: format, integrity, staleness, versions, code dependence.
Never loads a model or instantiates a backend. Referenced artifacts that are not present are reported in one warning (a thin bundle); the present ones are verified against their content ids.
Returns:
| Type | Description |
|---|---|
SpipeReport
|
The report. |
Source code in steerability/spipe/spipe.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
SpipeCodeRefError
Bases: SpipeError
Decoding requires importing code and allow_code was not granted.
Raised when a manifest contains a $ref callable reference, a $dc class outside the
steerability. namespace, or a pickle-backed memory artifact, and load() was called
without allow_code=True.
Source code in steerability/spipe/errors.py
49 50 51 52 53 54 55 | |
SpipeError
Bases: Exception
Base class for .spipe errors.
Source code in steerability/spipe/errors.py
15 16 | |
SpipeFormatError
Bases: SpipeError
The manifest or archive violates the spipe/1 format.
Raised for unsupported format versions, schema violations (missing, mistyped, or unknown fields), unknown method keys, and malformed archives.
Source code in steerability/spipe/errors.py
19 20 21 22 23 24 | |
SpipeIntegrityError
Bases: SpipeError
Stored artifact bytes do not match their content-addressed id.
Source code in steerability/spipe/errors.py
36 37 | |
SpipeReport
dataclass
The result of a model-free SPipe.verify().
Attributes:
| Name | Type | Description |
|---|---|---|
ok |
bool
|
True when no errors were found. |
errors |
list[str]
|
Findings that make the bundle unusable as-is. |
warnings |
list[str]
|
Findings worth knowing that do not block loading. |
Source code in steerability/spipe/spipe.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
errors = field(default_factory=list)
class-attribute
instance-attribute
ok
instance-attribute
warnings = field(default_factory=list)
class-attribute
instance-attribute
render()
A human-readable summary.
Source code in steerability/spipe/spipe.py
56 57 58 59 60 61 | |
SpipeSaveError
Bases: SpipeError
A pipeline or value cannot be serialized.
Raised for unresolvable model references, unregistered control classes, live model or
tokenizer objects inside args, lambdas and other unnameable callables, reserved $-prefixed
mapping keys, values over the inline size limit, and controls that cannot freeze.
Source code in steerability/spipe/errors.py
27 28 29 30 31 32 33 | |
SpipeStaleError
Bases: SpipeError
A frozen artifact's recorded fit digest does not match the current recipe.
The recipe's fit-relevant fields were edited after freezing and the pinned artifacts no
longer correspond to the recipe. Call thaw() and re-steer(), or pass
allow_stale=True to load anyway.
Source code in steerability/spipe/errors.py
40 41 42 43 44 45 46 | |
codec
The .spipe value codec: round-tripping between constructor values and manifest JSON.
Plain JSON values pass through; everything else encodes as a single-key tagged object:
$artifact: tensor-bearing or on-disk state, stored content-addressed (store.py).$dc: pure-data dataclasses and enums, decoded by importing the class and calling it.$component: state-control components (transforms, gates, selectors) and routing objects, decoded throughCOMPONENT_KINDS.$ref: module-level callables, decoded by import only underallow_code=True.$data: dataset references (DataRef), materialized at pipeline construction.$map: mappings with non-string scalar keys, kept as[key, value]pairs sorted by key so key types are retained through the JSON round trip and the encoding is independent of insertion order.
The codec round-trips; identity.canonical_value remains the separate, hash-only
canonicalizer. Digest computation for fit identities goes through encode in digest mode
(EncodeContext(store=None)), where tensors reduce to content ids without being written and
unhandled objects reduce to their type name.
COMPONENT_KINDS = _component_kinds
module-attribute
TAGS = ('$artifact', '$dc', '$component', '$ref', '$data', '$map')
module-attribute
TRUSTED_DC_PREFIX = 'steerability.'
module-attribute
logger = logging.getLogger(__name__)
module-attribute
AsPath
Marker wrapping an artifact value whose decoded form is the payload path.
Used by frozen_form implementations whose constructor field takes a path rather than the
reconstructed object (e.g. sasa's wv_path, load_lora's path).
Source code in steerability/spipe/codec.py
138 139 140 141 142 143 144 145 146 | |
value = value
instance-attribute
CodeRef
dataclass
Inert stand-in for a $ref callable, used by internal digest decoding.
Encodes back to the same $ref; calling it raises.
Attributes:
| Name | Type | Description |
|---|---|---|
target |
str
|
The |
Source code in steerability/spipe/codec.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
target
instance-attribute
DataRef
dataclass
A reference to a dataset, resolved at pipeline construction.
Attributes:
| Name | Type | Description |
|---|---|---|
kind |
str
|
|
repo_id |
str | None
|
Hub dataset id ( |
revision |
str | None
|
Hub revision ( |
split |
str | None
|
Dataset split ( |
subset |
str | None
|
Dataset configuration name ( |
path |
str | None
|
Local file path ( |
sha256 |
str | None
|
Hex digest the file must match ( |
type |
str | None
|
Type qualname of the recorded object ( |
fingerprint |
str | None
|
Content fingerprint of the recorded object ( |
Source code in steerability/spipe/codec.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
fingerprint = None
class-attribute
instance-attribute
kind
instance-attribute
path = None
class-attribute
instance-attribute
repo_id = None
class-attribute
instance-attribute
revision = None
class-attribute
instance-attribute
sha256 = None
class-attribute
instance-attribute
split = None
class-attribute
instance-attribute
subset = None
class-attribute
instance-attribute
type = None
class-attribute
instance-attribute
load()
Materialize the reference.
Returns:
| Type | Description |
|---|---|
Any
|
The loaded dataset for |
Raises:
| Type | Description |
|---|---|
SpipeFormatError
|
If the kind is |
SpipeIntegrityError
|
If a |
Source code in steerability/spipe/codec.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
DecodeContext
dataclass
State threaded through one decoding pass.
Attributes:
| Name | Type | Description |
|---|---|---|
store |
ArtifactStore | None
|
Source artifact store, or None when artifacts are unavailable (thin bundle without an external store). |
allow_code |
bool
|
Whether |
code_mode |
str
|
|
verify |
str
|
Verification policy applied to frozen steering artifacts ( |
data_mode |
str
|
|
manifest_records |
Mapping[str, ArtifactRecord]
|
Artifact records from the manifest's resolved entries, keyed by
artifact id. When an artifact has one, its |
Source code in steerability/spipe/codec.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
allow_code = False
class-attribute
instance-attribute
code_mode = 'strict'
class-attribute
instance-attribute
data_mode = 'load'
class-attribute
instance-attribute
manifest_records = field(default_factory=dict)
class-attribute
instance-attribute
store = None
class-attribute
instance-attribute
verify = 'strict'
class-attribute
instance-attribute
EncodeContext
dataclass
State threaded through one encoding pass.
Attributes:
| Name | Type | Description |
|---|---|---|
store |
ArtifactStore | None
|
Destination artifact store, or None for digest mode (tensor ids are computed without writing, unhandled objects reduce to their type name, and callables never raise). |
records |
dict[str, ArtifactRecord]
|
Artifact records produced during the pass, keyed by artifact id. |
code_refs |
list[str]
|
|
provenance |
dict
|
Provenance mapping stamped onto artifact records. |
default_model_type |
str | None
|
|
Source code in steerability/spipe/codec.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
artifact_fields = field(default_factory=dict)
class-attribute
instance-attribute
code_refs = field(default_factory=list)
class-attribute
instance-attribute
default_model_type = None
class-attribute
instance-attribute
digest_mode
property
provenance = field(default_factory=dict)
class-attribute
instance-attribute
records = field(default_factory=dict)
class-attribute
instance-attribute
store = None
class-attribute
instance-attribute
decode(value, ctx, path='$')
Decode one manifest JSON value back to its constructor form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The encoded value. |
required |
ctx
|
DecodeContext
|
The decoding context (store, code and data policies, verification policy). |
required |
path
|
str
|
Breadcrumb naming the position of |
'$'
|
Returns:
| Type | Description |
|---|---|
Any
|
The decoded value. |
Raises:
| Type | Description |
|---|---|
SpipeFormatError
|
If a tagged object is malformed or names an unknown kind or type. |
SpipeCodeRefError
|
If decoding requires code and |
SpipeIntegrityError
|
If a referenced artifact is unavailable or fails verification. |
Source code in steerability/spipe/codec.py
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 | |
digest_of(value)
12-hex-character digest of a value's encoded form, in digest mode.
Tensors reduce to content-addressed ids (float32 form), callables to their qualified names, and unhandled objects to their type names, which keeps the digest stable across a save and load round trip.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The value to digest. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The digest. |
Source code in steerability/spipe/codec.py
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 | |
encode(value, ctx, path='$')
Encode one constructor value to its manifest JSON form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The value to encode. |
required |
ctx
|
EncodeContext
|
The encoding context; artifacts land in |
required |
path
|
str
|
Breadcrumb naming the position of |
'$'
|
Returns:
| Type | Description |
|---|---|
Any
|
A JSON-serializable form of |
Raises:
| Type | Description |
|---|---|
SpipeSaveError
|
If |
Source code in steerability/spipe/codec.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | |
encoded_size(encoded)
Byte length of the canonical JSON form of an encoded value.
Source code in steerability/spipe/codec.py
510 511 512 | |
errors
Exception types for the .spipe serialization format.
NotFreezableError
Bases: RuntimeError
A control produces steer-time state but declares no frozen form.
Raised by BaseControl.frozen_form when a control's steer step produces fits or exported
state and the control does not override frozen_form to name a constructor-valid frozen
form. Re-exported from steerability.spipe.errors alongside the other spipe exceptions.
Source code in steerability/algorithms/core/base_control.py
12 13 14 15 16 17 18 | |
SpipeCodeRefError
Bases: SpipeError
Decoding requires importing code and allow_code was not granted.
Raised when a manifest contains a $ref callable reference, a $dc class outside the
steerability. namespace, or a pickle-backed memory artifact, and load() was called
without allow_code=True.
Source code in steerability/spipe/errors.py
49 50 51 52 53 54 55 | |
SpipeError
Bases: Exception
Base class for .spipe errors.
Source code in steerability/spipe/errors.py
15 16 | |
SpipeFormatError
Bases: SpipeError
The manifest or archive violates the spipe/1 format.
Raised for unsupported format versions, schema violations (missing, mistyped, or unknown fields), unknown method keys, and malformed archives.
Source code in steerability/spipe/errors.py
19 20 21 22 23 24 | |
SpipeIntegrityError
Bases: SpipeError
Stored artifact bytes do not match their content-addressed id.
Source code in steerability/spipe/errors.py
36 37 | |
SpipeSaveError
Bases: SpipeError
A pipeline or value cannot be serialized.
Raised for unresolvable model references, unregistered control classes, live model or
tokenizer objects inside args, lambdas and other unnameable callables, reserved $-prefixed
mapping keys, values over the inline size limit, and controls that cannot freeze.
Source code in steerability/spipe/errors.py
27 28 29 30 31 32 33 | |
SpipeStaleError
Bases: SpipeError
A frozen artifact's recorded fit digest does not match the current recipe.
The recipe's fit-relevant fields were edited after freezing and the pinned artifacts no
longer correspond to the recipe. Call thaw() and re-steer(), or pass
allow_stale=True to load anyway.
Source code in steerability/spipe/errors.py
40 41 42 43 44 45 46 | |
format
The spipe/1 manifest schema and archive packing.
The canonical form of a .spipe is a directory holding spipe.json and an optional
artifacts/ store; a .spipe file is a zip of that directory. Zips are written
deterministically (sorted member names, stored uncompressed, fixed timestamps) and unpacked
with a zip-slip guard, symlink rejection, and a decompressed-size cap.
ARTIFACTS_DIR = 'artifacts'
module-attribute
FORMAT_VERSION = 'spipe/1'
module-attribute
MANIFEST_NAME = 'spipe.json'
module-attribute
SIZE_CAP_BYTES = 20 * 1024 ** 3
module-attribute
logger = logging.getLogger(__name__)
module-attribute
pack_zip(directory, target)
Write directory as a deterministic zip at target.
Members are written in sorted arcname order, stored uncompressed, with a fixed
(1980, 1, 1, 0, 0, 0) timestamp and no extra fields. Equal directories therefore
produce byte-equal files.
Raises:
| Type | Description |
|---|---|
SpipeFormatError
|
If |
Source code in steerability/spipe/format.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
read_manifest(directory)
Read and validate spipe.json from directory.
Raises:
| Type | Description |
|---|---|
SpipeFormatError
|
If the manifest is absent, is not valid JSON, or violates the schema. |
Source code in steerability/spipe/format.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
unpack_zip(archive_path, dest)
Extract a .spipe zip into dest with the format's safety guards.
Every member name is normalized and rejected if absolute, containing .., or resolving
outside dest; symlink members are rejected; the total decompressed size is capped at
20 GB.
Raises:
| Type | Description |
|---|---|
SpipeFormatError
|
If the archive is not a zip, a member violates the guards, or the size cap is exceeded. |
Source code in steerability/spipe/format.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
validate_manifest(manifest)
Validate a parsed spipe.json against the spipe/1 schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifest
|
Any
|
The parsed manifest. |
required |
Raises:
| Type | Description |
|---|---|
SpipeFormatError
|
On any schema violation; the message names the offending field.
An unsupported |
Source code in steerability/spipe/format.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
write_manifest(manifest, directory)
Write spipe.json into directory (sorted keys, two-space indent, UTF-8).
Source code in steerability/spipe/format.py
130 131 132 133 134 135 | |
freeze
Building an SPipe from a live SteeringPipeline (to_spipe orchestration).
The recipe section is the codec encoding of each control's constructor args, in pipeline
order. Freezing additionally walks each enabled control's export_state() and
frozen_form(), writes the exported artifacts into the bundle's store with provenance and
fit digests, and assembles the lock. The freeze walk over every enabled control runs before
any recipe encoding, so a recipe value with the same content as an exported artifact reuses
the artifact's record.
INLINE_LIMIT_BYTES = 1000000
module-attribute
logger = logging.getLogger(__name__)
module-attribute
build_spipe(pipeline, *, freeze=None, model_ref=None)
Build an SPipe from a pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pipeline
|
SteeringPipeline
|
The |
required |
freeze
|
bool | None
|
Freeze the resolution (default: the pipeline's steered state). |
None
|
model_ref
|
str | None
|
Explicit model reference, overriding the pipeline's. |
None
|
Returns:
| Type | Description |
|---|---|
'SPipe'
|
The built |
Raises:
| Type | Description |
|---|---|
SpipeSaveError
|
If the model reference is unresolvable, a control is unregistered or cannot serialize, freezing is requested on an unsteered pipeline, or a control cannot freeze. |
Source code in steerability/spipe/freeze.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
spipe
SPipe: a portable serialization of a SteeringPipeline.
One format holds both the recipe and the frozen resolution. A recipe-only spipe carries the
model reference and the controls as constructed; loading it and calling steer() re-runs
fits. A frozen spipe additionally pins what the resolution produced (fingerprints, resolved
bindings, per-fit digests) in a lock section and stores the products content-addressed. The
loaded controls therefore steer cheaply and model-free. The frozen form is itself a valid
recipe, since every resolved entry is constructor-valid for its method and loading takes the
ordinary construction and steer() path.
logger = logging.getLogger(__name__)
module-attribute
SPipe
A serialized steering pipeline: recipe, optional lock, and artifact store.
Instances come from SteeringPipeline.to_spipe() (backed by a temporary store until
saved) or SPipe.load() (backed by the loaded bundle). The manifest is data; controls
are instantiated only by pipeline().
Source code in steerability/spipe/spipe.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 | |
code_dependent
property
Whether loading this spipe needs matching code and allow_code=True.
config_id
property
The configuration identity digest over the recipe entries, 12 hex characters.
is_frozen
property
True iff every enabled entry with steer-time products carries a resolution.
Entries with resolved: null have nothing to pin (their recipe is their frozen
form), which makes a manifest with a lock section frozen.
manifest
property
A deep copy of the manifest.
recipe_id
property
The recipe identity digest (model reference plus controls), 12 hex characters.
describe()
A human-readable table of entries, frozen state, and artifact sizes.
Source code in steerability/spipe/spipe.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
load(path, *, allow_code=False, allow_stale=False, artifact_store=None)
classmethod
Load a .spipe file or directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
A |
required |
allow_code
|
bool
|
Permit |
False
|
allow_stale
|
bool
|
Skip the staleness check. |
False
|
artifact_store
|
str | Path | Callable[[str], Path] | None
|
External artifact source for thin bundles: a store directory, or a callable mapping an artifact id to the directory holding it. |
None
|
Returns:
| Type | Description |
|---|---|
'SPipe'
|
The loaded |
Raises:
| Type | Description |
|---|---|
SpipeFormatError
|
On format-version, schema, or archive violations. |
SpipeIntegrityError
|
If a present artifact fails content verification. |
SpipeStaleError
|
If a frozen entry is stale and |
Source code in steerability/spipe/spipe.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
pipeline(*, backend=None, prefer='frozen', verify='strict', **pipeline_kwargs)
Instantiate a SteeringPipeline from this spipe.
Frozen entries instantiate from their resolution by default; prefer="recipe"
instantiates every entry from its recipe args (forcing re-fits at steer()). The
spipe supplies the model reference and the controls only; backend, device, dtype, and
hf_model_kwargs are the caller's. The caller runs pipeline.check() /
pipeline.steer() as normal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
BackendSpec | str | None
|
Forwarded to the |
None
|
prefer
|
str
|
|
'frozen'
|
verify
|
str
|
Verification policy for frozen steering artifacts ( |
'strict'
|
Returns:
| Type | Description |
|---|---|
SteeringPipeline
|
The constructed (unsteered) |
Raises:
| Type | Description |
|---|---|
SpipeFormatError
|
If a method key resolves to no registered method. |
SpipeCodeRefError
|
If decoding requires code and the spipe was loaded without
|
SpipeStaleError
|
If a deferred staleness check fails (thin bundles). |
Source code in steerability/spipe/spipe.py
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 | |
save(path, *, artifacts='fat')
Write the spipe to path.
A path ending in .spipe produces a zip file; any other path produces (or replaces)
a directory. artifacts="fat" (default) embeds every referenced artifact;
artifacts="thin" writes the manifest only, leaving artifact ids resolvable at load
via artifact_store=. A recipe-only spipe with no artifact references writes no
artifacts/ directory either way.
Saving onto the bundle's own backing directory rewrites the manifest in place. A fat
save there also embeds any referenced artifact the store resolves externally, and a
thin save there raises SpipeSaveError when the directory embeds artifacts, since a
thin export would have to delete them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Destination file or directory. |
required |
artifacts
|
str
|
|
'fat'
|
Returns:
| Type | Description |
|---|---|
Path
|
The written path. |
Raises:
| Type | Description |
|---|---|
SpipeSaveError
|
If a directory target exists and is neither empty nor a spipe directory, a referenced artifact is unavailable for a fat export, or a thin export targets the bundle's own directory while it embeds artifacts. |
Source code in steerability/spipe/spipe.py
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | |
thaw()
A recipe-only copy: every resolved section and the lock are dropped.
Source code in steerability/spipe/spipe.py
207 208 209 210 211 212 213 214 215 216 | |
verify()
The model-free report: format, integrity, staleness, versions, code dependence.
Never loads a model or instantiates a backend. Referenced artifacts that are not present are reported in one warning (a thin bundle); the present ones are verified against their content ids.
Returns:
| Type | Description |
|---|---|
SpipeReport
|
The report. |
Source code in steerability/spipe/spipe.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
SpipeReport
dataclass
The result of a model-free SPipe.verify().
Attributes:
| Name | Type | Description |
|---|---|---|
ok |
bool
|
True when no errors were found. |
errors |
list[str]
|
Findings that make the bundle unusable as-is. |
warnings |
list[str]
|
Findings worth knowing that do not block loading. |
Source code in steerability/spipe/spipe.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
errors = field(default_factory=list)
class-attribute
instance-attribute
ok
instance-attribute
warnings = field(default_factory=list)
class-attribute
instance-attribute
render()
A human-readable summary.
Source code in steerability/spipe/spipe.py
56 57 58 59 60 61 | |
store
Content-addressed artifact store backing frozen .spipe bundles.
The store is a directory of artifact directories, each named by its content id. Two encodings
exist: "tensors" (a single artifact.safetensors, id and bytes produced by artifact_id_for
from state_control/common/lowering.py, byte-compatible with the vLLM-Hook plugin registry)
and "tree" (a directory copied verbatim under payload/, id a SHA-256 over the sorted
relative paths and per-file digests). Every artifact directory carries an artifact.json
sidecar duplicating its manifest record plus type-specific reconstruction metadata, which
keeps a detached artifact directory self-describing. Writes are idempotent and reads verify the
content hash.
PAYLOAD_DIR = 'payload'
module-attribute
SIDECAR_FILE = 'artifact.json'
module-attribute
TENSOR_FILE = 'artifact.safetensors'
module-attribute
logger = logging.getLogger(__name__)
module-attribute
ArtifactRecord
dataclass
One artifact's manifest record.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Content-addressed artifact id ( |
encoding |
str
|
|
type |
str
|
Name of the producing class (e.g. |
artifact_class |
str
|
|
source |
str | None
|
Fit-source class name, or None for recipe-supplied artifacts. |
fit_digest |
str | None
|
12-hex-character digest of the producing fit identity, or None. |
provenance |
dict
|
Producing-side fingerprints ( |
type_meta |
dict
|
Type-specific reconstruction metadata (sidecar only, excluded from the manifest record). |
Source code in steerability/spipe/store.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
artifact_class = 'opaque'
class-attribute
instance-attribute
encoding
instance-attribute
fit_digest = None
class-attribute
instance-attribute
id
instance-attribute
provenance = field(default_factory=dict)
class-attribute
instance-attribute
source = None
class-attribute
instance-attribute
type
instance-attribute
type_meta = field(default_factory=dict)
class-attribute
instance-attribute
from_mapping(data)
classmethod
Source code in steerability/spipe/store.py
152 153 154 155 156 157 158 159 160 161 162 163 | |
manifest_entry()
The record as it appears in spipe.json (without type_meta).
Source code in steerability/spipe/store.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
sidecar_entry()
The record as written to the artifact's artifact.json sidecar.
Source code in steerability/spipe/store.py
148 149 150 | |
ArtifactStore
Directory-backed store of content-addressed artifacts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
str | Path
|
The store directory ( |
required |
resolver
|
Callable[[str], Path] | None
|
Optional callable mapping an artifact id to the directory holding that
artifact, used when artifacts live outside |
None
|
Source code in steerability/spipe/store.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
root = Path(root)
instance-attribute
copy_into(dest_root, artifact_ids)
Copy the named artifacts into another store directory (fat export).
Source code in steerability/spipe/store.py
318 319 320 321 322 323 324 325 326 | |
has(artifact_id)
Whether the store holds artifact_id.
Source code in steerability/spipe/store.py
188 189 190 | |
ids()
Sorted ids of every artifact under root.
Source code in steerability/spipe/store.py
192 193 194 195 196 197 198 199 200 | |
load_tensors(artifact_id)
Load and verify a "tensors" artifact.
Returns:
| Type | Description |
|---|---|
dict[str, Tensor]
|
Mapping from tensor name to float32 CPU tensor. |
Source code in steerability/spipe/store.py
293 294 295 296 297 298 299 300 301 302 303 | |
payload_path(artifact_id)
The verified payload/ path of a "tree" artifact.
Source code in steerability/spipe/store.py
305 306 307 308 | |
put_tensors(tensors, record_fields)
Write a tensor payload as a "tensors" artifact, idempotently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tensors
|
Mapping[str, Tensor]
|
Mapping from tensor name to tensor. |
required |
record_fields
|
dict
|
Record fields other than |
required |
Returns:
| Type | Description |
|---|---|
ArtifactRecord
|
The artifact record. |
Source code in steerability/spipe/store.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
put_tree(source, record_fields)
Copy a directory as a "tree" artifact, idempotently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str | Path
|
Directory whose contents become |
required |
record_fields
|
dict
|
Record fields other than |
required |
Returns:
| Type | Description |
|---|---|
ArtifactRecord
|
The artifact record. |
Raises:
| Type | Description |
|---|---|
SpipeSaveError
|
If |
Source code in steerability/spipe/store.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
record_for(artifact_id)
The sidecar record of a stored artifact.
Raises:
| Type | Description |
|---|---|
SpipeIntegrityError
|
If the artifact is absent or the sidecar's |
Source code in steerability/spipe/store.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
size_of(artifact_id)
Total on-disk bytes of an artifact's content (sidecar excluded).
Source code in steerability/spipe/store.py
310 311 312 313 314 315 316 | |
verify(artifact_id)
Verify a stored artifact's bytes against its content id.
Raises:
| Type | Description |
|---|---|
SpipeIntegrityError
|
If the artifact is absent, the sidecar id mismatches, or the
recomputed content hash differs from |
Source code in steerability/spipe/store.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
save_object_tree(save_fn, store, record_fields)
Save an object into the store as a "tree" artifact via its own save(path) method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
save_fn
|
Callable[[Path], Any]
|
Callable writing the object into a directory (or file inside it). |
required |
store
|
ArtifactStore
|
The destination store. |
required |
record_fields
|
dict
|
Record fields other than |
required |
Returns:
| Type | Description |
|---|---|
ArtifactRecord
|
The artifact record. |
Source code in steerability/spipe/store.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | |
tensors_payload(tensors)
The content id and serialized safetensors bytes of a tensor payload.
Uses the id algorithm of artifact_id_for (float32, contiguous, CPU, sorted names,
SHA-256 over the safetensors serialization), which makes tensor artifact directories
byte-compatible with the vLLM-Hook plugin registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tensors
|
Mapping[str, Tensor]
|
Mapping from tensor name to tensor. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, bytes]
|
The |
Source code in steerability/spipe/store.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
tree_id_for(root)
The content id of a directory tree.
The id is "sha256:" + sha256 over the concatenation of
f"{posix_relpath}\n{sha256_of_file_hex}\n" for every file, sorted by posix relative
path. Symlinks are rejected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
Directory to hash. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The |
Raises:
| Type | Description |
|---|---|
SpipeSaveError
|
If |
Source code in steerability/spipe/store.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |