Skip to content

API Reference parrot.knowledge.wiki.ledger.outbox

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

parrot.knowledge.wiki.ledger.outbox

View source

Durable ledger outbox: sealed batches of journal events awaiting delivery.

Class EventIdentityError

An event's id is not the hash of its own content.

Class LedgerBatch

Manifest of one sealed batch (spec §2 Data Models).

Fields:

Field Type Default Description
schema_version Literal[1] 1
batch_id str
source_ref str
source_head str
source_end_offset int
source_sha256 str
events_sha256 str
event_ids list[str]
remote str 'origin'
branch str 'dev'
prepared_at str

Class LedgerDeliveryConflict

One event that cannot be delivered without review.

Fields:

Field Type Default Description
event_id str
subject str
reason str

Class LedgerDeliveryReport

Typed outcome of one delivery attempt sequence (spec §2).

Fields:

Field Type Default Description
status Literal['delivered', 'already_delivered', 'pending', 'conflict', 'unsupported']
batch_id str
attempts int
remote_head str | None
commit_sha str | None
added int
remaining int
conflicts list[LedgerDeliveryConflict]
skipped list[str]
error_code str | None None
recovery_path str | None None

Alias LedgerEvent

Re-exported from parrot.knowledge.wiki.ledger.events.LedgerEvent.

Class LedgerOutbox

Own durable pending batches beside one resolved local event journal.

Parameter Type Default Description
ledger_dir Path Local ledger directory holding events.jsonl.
branch str 'dev' Remote branch that sealed batches are destined for (sdd/config.json).

Method LedgerOutbox.prepare

Seal complete shareable events absent from the fetched dev baseline; return None if empty.

prepare(*, repo_root: Path, source_ref: str, source_head: str, known_ids: set[str] | None = None) -> LedgerBatch | None

Parameter Type Default Description
repo_root Path
source_ref str
source_head str
known_ids set[str] | None None

Returns: LedgerBatch | None

Method LedgerOutbox.pending

Return validated unacknowledged batches in preparation order.

pending() -> list[LedgerBatch]

Returns: list[LedgerBatch]

Method LedgerOutbox.batch_events

Strictly read a sealed batch's events with its recorded identity and hash checks.

batch_events(batch: LedgerBatch) -> StrictRead

Parameter Type Default Description
batch LedgerBatch

Returns: StrictRead

Method LedgerOutbox.acknowledge

Persist a receipt only for the exact remotely verified batch.

acknowledge(batch: LedgerBatch, *, remote_head: str, verified_digest: str, skipped_event_ids: Sequence[str] = ()) -> None

Parameter Type Default Description
batch LedgerBatch The sealed batch that was verified on the remote.
remote_head str Remote commit the verification ran against.
verified_digest str Digest of the verified (delivered) events.
skipped_event_ids Sequence[str] () Redundant closes and unclaims of terminal issues, deliberately not delivered.

Method LedgerOutbox.receipt_for

Return the receipt for batch_id or None.

receipt_for(batch_id: str) -> LedgerReceipt | None

Parameter Type Default Description
batch_id str

Returns: LedgerReceipt | None

Method LedgerOutbox.status

Read-only counts for sealed and unsealed events without acquiring the preparation lock.

status(known_ids: set[str] | None = None) -> dict[str, int | bool]

Parameter Type Default Description
known_ids set[str] | None None

Returns: dict[str, int | bool]

Class LedgerReceipt

Audit record written only after remote content verification.

Fields:

Field Type Default Description
schema_version Literal[1] 1
batch_id str
manifest_sha256 str
remote str
branch str
remote_head str
verified_digest str
acknowledged_at str
skipped_event_ids list[str]

Attribute OUTBOX_DIRNAME

Class OutboxLockedError

Another preparer holds the outbox lock, or the filesystem cannot lock.

Class StrictLedgerReadError

A complete line is malformed, or an event id does not match its content.

Class StrictRead

Result of a strict read: raw lines and events up to the complete-line boundary.

Fields:

Field Type Default Description
raw_lines list[bytes]
events list[LedgerEvent]
end_offset int
truncated_tail bool

Alias canonical_json_dumps

Re-exported from parrot.knowledge.wiki.ledger.events.canonical_json_dumps.

Alias compute_event_id

Re-exported from parrot.knowledge.wiki.ledger.events.compute_event_id.

Alias is_shareable

Re-exported from parrot.knowledge.wiki.ledger.shared_log.is_shareable.

Attribute logger

Function read_strict_events

Strictly parse complete JSONL lines of path up to end_offset.

Missing files yield an empty result. A non-newline-terminated suffix is reported but deliberately not parsed.

read_strict_events(path: Path, *, end_offset: int | None = None) -> StrictRead

Parameter Type Default Description
path Path
end_offset int | None None

Returns: StrictRead

Function verify_event_identity

Raise when event.event_id is not the hash of its own content.

verify_event_identity(event: LedgerEvent) -> None

Parameter Type Default Description
event LedgerEvent

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