Skip to content

API Reference parrot.squawk.blobs.filemanager

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

parrot.squawk.blobs.filemanager

View source

Squawk blob storage over the duck-typed file manager used by artifact storage.

Alias BlobMeta

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

Attribute CHUNK

Class FileManagerBlobStore

Store blobs using only the six file-manager methods in the duck contract.

The upstream file manager has no byte-range download operation. Reads therefore download the complete object, decrypt it when needed, and then yield the requested plaintext slice.

Parameter Type Default Description
file_manager Any Object implementing the six-method file-manager duck contract.
prefix str 'squawk/blobs' Object-name prefix reserved for Squawk blobs.
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 (when the manager reports a modification time).
max_bytes int 1024 * 1024 * 1024 Largest plaintext object accepted by put_stream (default 1 GiB).

Method FileManagerBlobStore.put_stream

Hash plaintext frames and publish the binary before its metadata, for owner.

Dedup is per owner: an unexpired record of the same owner and data class is reused (expiry extended to the later of the two); otherwise the record is republished. Other owners' records are never returned or modified. The duck contract only uploads from bytes, so the staged object is read into memory once for upload.

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 digest differs or publication cannot be verified.

Method FileManagerBlobStore.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 FileManagerBlobStore.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 FileManagerBlobStore.open_read

Download the authorized record's object and yield a plaintext byte range.

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 FileManagerBlobStore.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 metadata.

Raises:

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

Method FileManagerBlobStore.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 FileManagerBlobStore.sweep

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

A corrupt or concurrently deleted object is logged and skipped, never aborting the pass.

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 metadata records removed.

Alias HandleClaimError

Re-exported from parrot.interagent.HandleClaimError.

Alias HandleOwner

Re-exported from parrot.interagent.HandleOwner.

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