Skip to content

API Reference parrot.knowledge.wiki.decisions.repository

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

parrot.knowledge.wiki.decisions.repository

View source

Store-facing persistence for ADR records (FEAT-578 Module 2).

The only module in decisions/ that touches a :class:BaseWikiStore, and the only place the store's raw failures become typed :class:DecisionError codes. Every ADR mutation in the feature goes through :meth:save.

Alias ADR_CATEGORY

Re-exported from parrot.knowledge.wiki.decisions.models.ADR_CATEGORY.

Alias ADR_INVENTORY_LIMIT

Re-exported from parrot.knowledge.wiki.decisions.models.ADR_INVENTORY_LIMIT.

Alias ADR_READ_ONLY

Re-exported from parrot.knowledge.wiki.decisions.models.ADR_READ_ONLY.

Alias ADR_REVISION_CONFLICT

Re-exported from parrot.knowledge.wiki.decisions.models.ADR_REVISION_CONFLICT.

Alias ADR_WRITE_UNSUPPORTED

Re-exported from parrot.knowledge.wiki.decisions.models.ADR_WRITE_UNSUPPORTED.

Alias BaseWikiStore

Re-exported from parrot.knowledge.wiki.store.BaseWikiStore.

Alias DecisionDiagnostic

Re-exported from parrot.knowledge.wiki.decisions.models.DecisionDiagnostic.

Alias DecisionError

Re-exported from parrot.knowledge.wiki.decisions.models.DecisionError.

Alias DecisionRecord

Re-exported from parrot.knowledge.wiki.decisions.models.DecisionRecord.

Class DecisionRepository

Bounded ADR inventory reads and compare-and-swap writes.

Parameter Type Default Description
store BaseWikiStore Any wiki backend. A read-only or CAS-less store is accepted here and refused at write time, so reads keep working on a foreign or archived plane.
max_records int 10000 Inventory bound from DecisionConfig.max_records.

Attributes:

Attribute Type Description
last_diagnostics list[DecisionDiagnostic]

Method DecisionRepository.get

Load one record together with the page hash to CAS against.

get(decision_id: str) -> tuple[DecisionRecord, str | None] | None

Parameter Type Default Description
decision_id str

Returns: tuple[DecisionRecord, str | None] | None — (record, content_hash), or None when no such page exists. Pass the returned hash straight back to :meth:save as expected_content_hash — reading it from anywhere else reopens the race this class exists to close.

Raises:

  • DecisionError — ADR_SCHEMA_UNSUPPORTED when the page exists but is not a decodable managed record.

Method DecisionRepository.inventory_with_hashes

Load the complete bounded ADR inventory with each page's stored content_hash.

Reads limit=max_records + 1 so an overflow is detectable rather than silently truncated into a wrong "no decisions" answer. The hash is the one the store holds for the page the record was decoded from — compare against it, never against a re-encoded record.

inventory_with_hashes() -> list[tuple[DecisionRecord, str | None]]

Returns: list[tuple[DecisionRecord, str | None]]

Raises:

  • DecisionError — ADR_INVENTORY_LIMIT when the plane holds more than max_records ADR pages.

Method DecisionRepository.inventory

Load the complete bounded ADR inventory.

inventory() -> list[DecisionRecord]

Returns: list[DecisionRecord]

Raises:

  • DecisionError — ADR_INVENTORY_LIMIT when the plane holds more than max_records ADR pages.

Method DecisionRepository.save

CAS one full record and its audit history.

save(record: DecisionRecord, expected_content_hash: str | None) -> DecisionRecord

Parameter Type Default Description
record DecisionRecord The complete replacement record, audit history included. Partial writes do not exist — the page body is the record.
expected_content_hash str | None The hash returned by :meth:get, or None to insert a record that must not already exist.

Returns: DecisionRecord — The record as written.

Raises:

  • DecisionError — ADR_REVISION_CONFLICT when the precondition did not hold, ADR_WRITE_UNSUPPORTED on a backend without a conditional write, ADR_READ_ONLY on a read-only plane, ADR_RECORD_TOO_LARGE from the codec.

Alias decision_from_page

Re-exported from parrot.knowledge.wiki.decisions.codec.decision_from_page.

Alias decision_to_page

Re-exported from parrot.knowledge.wiki.decisions.codec.decision_to_page.

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