Skip to content

API Reference parrot.squawk.blobs.local

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.squawk.blobs.local

View source

Local-disk Squawk blob storage with temp publication and optional Fernet encryption.

Alias BlobMeta

Re-exported from parrot.squawk.blobs.store.BlobMeta.

Attribute CHUNK

Alias HandleClaimError

Re-exported from parrot.interagent.HandleClaimError.

Alias HandleOwner

Re-exported from parrot.interagent.HandleOwner.

Class LocalDiskBlobStore

Store content-addressed Squawk blobs on a local filesystem.

Parameter Type Default Description
root Path Directory that owns blob data and metadata.
encrypt_classes frozenset[str] frozenset({'hr', 'pii'}) Data classes encrypted before publication.
key_env str 'SQUAWK_BLOB_KEY' Environment variable containing the Fernet key.
orphan_grace_s int 3600 Age after which a .bin without metadata is swept.
max_bytes int 1024 * 1024 * 1024 Largest plaintext object accepted by put_stream (default 1 GiB).

Method LocalDiskBlobStore.put_stream

Hash plaintext frames into a temporary object and publish atomically for owner.

Dedup is per owner: an unexpired record of the same owner with the same data class is reused (its expiry extended to the later of the two); an expired one, or one with a different data class, is republished. Other owners' records are never returned or modified.

put_stream(frames: AsyncIterator[bytes], *, media_type: MediaType, owner: HandleOwner, ttl_s: int, expected_digest: str | None = None, data_class: str = 'internal') -> BlobMeta

Parameter Type Default Description
frames AsyncIterator[bytes] Plaintext byte chunks.
media_type MediaType Artifact media type.
owner HandleOwner Owner tuple authorized for the blob.
ttl_s int Lifetime in seconds.
expected_digest str | None None Optional expected sha256:<hex> key.
data_class str 'internal' Policy class controlling encryption at rest.

Returns: BlobMeta — Published or deduplicated metadata owned by owner.

Raises:

  • SquawkError — If the computed digest differs from the expected digest.

Method LocalDiskBlobStore.has

Return whether an unexpired record exists for the key.

has(key: str, *, owner: HandleOwner | None = None) -> bool

Parameter Type Default Description
key str Content-addressed blob key.
owner HandleOwner | None None Restrict the check to this owner's record when given.

Returns: bool — Whether a usable (unexpired) record exists.

Method LocalDiskBlobStore.meta

Load a record for a blob key.

meta(key: str, *, owner: HandleOwner | None = None) -> BlobMeta | None

Parameter Type Default Description
key str Content-addressed blob key.
owner HandleOwner | None None Return this owner's record (expired or not); when None, return any unexpired record.

Returns: BlobMeta | None — Parsed metadata, or None when absent.

Method LocalDiskBlobStore.open_read

Yield a plaintext byte range after ACL and expiry checks.

Plaintext objects are read with seek; encrypted objects must be decrypted in full before the range is sliced.

open_read(key: str, *, owner: HandleOwner, grantee: str | None = None, offset: int = 0, length: int | None = None) -> AsyncIterator[bytes]

Parameter Type Default Description
key str Content-addressed blob key.
owner HandleOwner Full owner tuple asserted by the caller.
grantee str | None None Agent identity used for explicit grant access.
offset int 0 First plaintext byte to return.
length int | None None Maximum plaintext bytes to return, or all remaining bytes.

Returns: AsyncIterator[bytes]

Raises:

  • HandleClaimError — If the blob is missing, expired, or unauthorized.
  • ValueError — If the range bounds are negative.

Method LocalDiskBlobStore.grant

Grant read access on the caller's own record (idempotent).

grant(key: str, *, owner: HandleOwner, grantee: str) -> BlobMeta

Parameter Type Default Description
key str Content-addressed blob key.
owner HandleOwner Full owner tuple asserted by the caller.
grantee str Agent identity to authorize.

Returns: BlobMeta — Updated immutable metadata.

Raises:

  • HandleClaimError — If the caller holds no record for the key.

Method LocalDiskBlobStore.delete

Delete the caller's own record for a key.

delete(key: str, *, owner: HandleOwner) -> bool

Parameter Type Default Description
key str Content-addressed blob key.
owner HandleOwner Full owner tuple asserted by the caller.

Returns: bool — Whether the caller had a record.

Method LocalDiskBlobStore.sweep

Delete every record expired at the cutoff and stale orphan binaries.

sweep(now: datetime | None = None) -> int

Parameter Type Default Description
now datetime | None None Optional expiry cutoff, defaulting to current UTC time.

Returns: int — Number of expired records removed.

Alias MediaType

Re-exported from parrot.interagent.MediaType.

Alias SquawkBlobStore

Re-exported from parrot.squawk.blobs.store.SquawkBlobStore.

Alias SquawkError

Re-exported from parrot.interagent.SquawkError.

Alias SquawkErrorCode

Re-exported from parrot.interagent.SquawkErrorCode.

Alias owner_slug

Re-exported from parrot.squawk.blobs.store.owner_slug.

Alias select_record

Re-exported from parrot.squawk.blobs.store.select_record.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally