Skip to content

API Reference parrot_formdesigner.services.snippets.approval

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

parrot_formdesigner.services.snippets.approval

View source

Tenant snippet approval service (FEAT-459 / M6).

Draft -> published -> revoked lifecycle for DB-sourced snippets, mirroring FormVersionService.publish()/.get_published()/.list_versions() (services/form_version.py:306,431,480) adapted onto the form_snippets table (migrations/008_snippet_store.sql, TASK-3165).

This is the C4 human-approval gate for the DB source: publish() refuses any bundle that fails the conformance gate (TASK-3175, injected as ConformanceCheckFn to avoid a hard dependency on that module's exact API while it is still being written — spec's Worktree Strategy prefers a minimal M15 stub landing early over blocking this task).

Alias CapabilityManifest

Re-exported from parrot_formdesigner.core.snippets.CapabilityManifest.

Attribute ConformanceCheckFn

Class ConformanceResult

Shape TASK-3175's gate result must satisfy — duck-typed, not imported.

Attributes:

Attribute Type Description
passed bool
errors list[str]

Alias DbSnippetStore

Re-exported from parrot_formdesigner.services.snippets.db_store.DbSnippetStore.

Class SnippetApprovalService

Draft/publish/revoke lifecycle for DB-sourced tenant snippets.

Parameter Type Default Description
store DbSnippetStore The DbSnippetStore owning form_snippets reads/cache.
check_conformance ConformanceCheckFn Runs TASK-3175's tier-conformance + equivalence gate against a bundle. Injected so this service has no import-time dependency on services/snippets/conformance.py.

Method SnippetApprovalService.draft

Insert a new DRAFT version for (tenant, bundle.handler_ref).

Does NOT run the conformance gate — a draft is allowed to be broken; only publish() enforces conformance (an author should be able to save work-in-progress).

draft(bundle: SnippetBundle, *, tenant: str) -> SnippetBundle

Parameter Type Default Description
bundle SnippetBundle
tenant str

Returns: SnippetBundle — The bundle as stored, with status=DRAFT and its assigned version (current max version for this key, plus one).

Raises:

  • ValueError — bundle.tenant != tenant, or bundle.source is not DB (a GIT bundle has no draft concept).

Method SnippetApprovalService.publish

Promote a DRAFT version to PUBLISHED. The C4 human-approval gate.

Order of checks (all must pass before ANY row mutation):

  1. The (tenant, handler_ref, version) row exists and is DRAFT.
  2. check_conformance(bundle) passes.
  3. store.check_tier_cap(tenant, bundle.manifest) does not raise.

Steps after checks pass: 4. UPDATE the row: status='published', approved_by, approved_at=now(). 5. store.invalidate(tenant=tenant, handler_ref=handler_ref) so the NEXT resolve_current() call re-reads storage instead of serving a stale cached (possibly-absent) entry.

publish(*, tenant: str, handler_ref: str, version: int, approved_by: str) -> SnippetBundle

Parameter Type Default Description
tenant str
handler_ref str
version int
approved_by str

Returns: SnippetBundle

Raises:

  • ValueError — row not found, not DRAFT, fails conformance, or fails the tier cap. The error message MUST name which check failed (approvers and CI logs both depend on this).

Method SnippetApprovalService.revoke

Set a PUBLISHED (or DRAFT) row to REVOKED and invalidate the cache.

After revocation, get_form_event()'s existing tenant -> global fallback (event_registry.py:149) restores the platform git snippet for this tenant with NO code change here — that is the existing registry's job, not this service's.

revoke(*, tenant: str, handler_ref: str, version: int) -> None

Parameter Type Default Description
tenant str
handler_ref str
version int

Method SnippetApprovalService.get_published

Convenience passthrough to the store's read-through cache.

get_published(*, tenant: str, handler_ref: str) -> SnippetBundle | None

Parameter Type Default Description
tenant str
handler_ref str

Returns: SnippetBundle | None

Method SnippetApprovalService.list_versions

All versions (any status) for (tenant, handler_ref), newest first.

list_versions(*, tenant: str, handler_ref: str) -> list[SnippetBundle]

Parameter Type Default Description
tenant str
handler_ref str

Returns: list[SnippetBundle]

Alias SnippetBundle

Re-exported from parrot_formdesigner.core.snippets.SnippetBundle.

Alias SnippetSource

Re-exported from parrot_formdesigner.core.snippets.SnippetSource.

Alias SnippetStatus

Re-exported from parrot_formdesigner.core.snippets.SnippetStatus.

Attribute logger

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