Skip to content

API Reference parrot.outputs.a2ui.recipes.store

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

parrot.outputs.a2ui.recipes.store

View source

Recipe stores — AbstractRecipeStore + File + DB backends (Module 4, FEAT-324).

Two backends, both core ai-parrot (resolved brainstorm decision): a plain YAML-per-file directory (:class:FileRecipeStore, for hand-authoring) and a Redis-backed store (:class:DBRecipeStore), whose connection/config shape mirrors :class:parrot.skills.store.SkillRegistry — a lazy, try/except redis.asyncio import behind a REDIS_AVAILABLE flag, an idempotent configure(), and an in-memory dict fallback when Redis is absent or unreachable. (SkillRegistry does NOT use asyncdb/a SQL table anywhere — grep-verified — so this mirrors what actually exists, not a relational pattern that would need to be invented.)

Versioning is simple overwrite + updated_at bump (spec G5); save() is the single source of truth for updated_at (the TASK-1865 models do not auto-set it). Owner scoping isolates recipes across all operations.

Core-side, dependency-free (spec G8): Redis is optional and imported lazily; FileRecipeStore works with zero DB extras installed.

Class AbstractRecipeStore

Persistence contract shared by :class:FileRecipeStore and :class:DBRecipeStore.

All operations accept an optional owner for scoping; recipes owned by different owners (including None, the unscoped/shared owner) never collide even if they share a name.

Method AbstractRecipeStore.save

Persist recipe, overwriting any existing recipe with the same (name, owner) and bumping updated_at to now (UTC).

save(recipe: InfographicRecipe) -> None

Parameter Type Default Description
recipe InfographicRecipe

Method AbstractRecipeStore.get

Load a recipe by name (and owner scope).

get(name: str, owner: Optional[str] = None) -> InfographicRecipe

Parameter Type Default Description
name str
owner Optional[str] None

Returns: InfographicRecipe

Raises:

  • RecipeNotFoundError — If no such recipe exists.
  • RecipeSchemaVersionError — If the stored schema_version is unsupported.

Method AbstractRecipeStore.list

List lightweight summaries (name/title/description/owner/updated_at) for every recipe in owner's scope.

list(owner: Optional[str] = None) -> list[dict[str, Any]]

Parameter Type Default Description
owner Optional[str] None

Returns: list[dict[str, Any]]

Method AbstractRecipeStore.delete

Delete a recipe by name (and owner scope).

delete(name: str, owner: Optional[str] = None) -> None

Parameter Type Default Description
name str
owner Optional[str] None

Raises:

  • RecipeNotFoundError — If no such recipe exists.

Class DBRecipeStore

Redis-backed recipe store (falls back to in-memory when Redis is unavailable).

Mirrors :class:parrot.skills.store.SkillRegistry's connection shape: a lazy, try/except redis.asyncio import, an idempotent configure() that connects (or degrades gracefully), and per-namespace key isolation. There is no relational table here — SkillRegistry itself has none to copy.

Parameter Type Default Description
redis_url Optional[str] None
namespace str 'default'

Method DBRecipeStore.configure

Idempotently connect to Redis, falling back to in-memory on failure.

Takes self._lock for the whole check-then-set so two concurrent first-callers cannot both attempt a Redis connection (the previous, lock-free double-checked version had exactly that race).

configure() -> None

Method DBRecipeStore.save

save(recipe: InfographicRecipe) -> None

Parameter Type Default Description
recipe InfographicRecipe

Method DBRecipeStore.get

get(name: str, owner: Optional[str] = None) -> InfographicRecipe

Parameter Type Default Description
name str
owner Optional[str] None

Returns: InfographicRecipe

Method DBRecipeStore.list

list(owner: Optional[str] = None) -> list[dict[str, Any]]

Parameter Type Default Description
owner Optional[str] None

Returns: list[dict[str, Any]]

Method DBRecipeStore.delete

delete(name: str, owner: Optional[str] = None) -> None

Parameter Type Default Description
name str
owner Optional[str] None

Class FileRecipeStore

One YAML file per recipe under directory (hand-authoring backend).

Layout: <directory>/<name>.yaml for unscoped recipes, or <directory>/<owner>/<name>.yaml when owner is set. Writes are atomic (write-to-temp + os.replace) so concurrent same-name saves never leave a partially-written file.

Parameter Type Default Description
directory Path | str

Method FileRecipeStore.save

save(recipe: InfographicRecipe) -> None

Parameter Type Default Description
recipe InfographicRecipe

Method FileRecipeStore.get

get(name: str, owner: Optional[str] = None) -> InfographicRecipe

Parameter Type Default Description
name str
owner Optional[str] None

Returns: InfographicRecipe

Method FileRecipeStore.list

list(owner: Optional[str] = None) -> list[dict[str, Any]]

Parameter Type Default Description
owner Optional[str] None

Returns: list[dict[str, Any]]

Method FileRecipeStore.delete

delete(name: str, owner: Optional[str] = None) -> None

Parameter Type Default Description
name str
owner Optional[str] None

Class RecipeNotFoundError

Raised when a requested recipe does not exist in the store.

Parameter Type Default Description
name str
available list[str]

Attributes:

Attribute Type Description
name The recipe name that was not found.
available Names of recipes actually present (same owner scope).

Class RecipeSchemaVersionError

Raised when a stored recipe's schema_version is outside the supported range.

A schema_version of 1 or SUPPORTED_SCHEMA_VERSION (2) both load fine (1 is auto-migrated in memory on read, per FEAT-470 TASK-2542) — this error is only for versions < 1 or > SUPPORTED_SCHEMA_VERSION.

Parameter Type Default Description
name str
found_version int

Attribute SUPPORTED_SCHEMA_VERSION

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