Skip to content

API Reference parrot_formdesigner.services.sinks.base

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

parrot_formdesigner.services.sinks.base

View source

Submission sink ABC, capability enforcement and error taxonomy.

Structured after :class:parrot_formdesigner.services.blob_storage. AbstractBlobStorage — an ABC with a small mandatory surface (capability declaration, provisioning, write) plus optional operations (read, list) whose defaults raise so a write-only backend needs no stub overrides.

The error taxonomy defined here is the contract the submit-path integration (TASK-2428) maps onto HTTP status codes:

  • :class:SinkUnavailableError -> 503
  • :class:SinkNotCapableError -> 501
  • :class:SinkTargetMismatchError -> 422

Class AbstractSubmissionSink

Destination for a single form's submissions.

Concrete backends implement :attr:capabilities, :meth:ensure_target and :meth:write. read and list_revisions default to raising :class:SinkNotCapableError, so a write-only backend (e.g. CSV, Google Sheets) is fully instantiable without overriding them.

Parameter Type Default Description
target Any None
alias_registry Any None
tenant str ''
**kwargs Any {}

Attributes:

Attribute Type Description
capabilities frozenset[SinkCapability] Return the frozenset of operations this sink supports.
family str Data family for the submission mapper: "tabular" or "document". Tabular sinks (Postgres, CSV, Google Sheets, and the bigquery asyncdb driver) receive :func:~parrot_formdesigner.services.sinks.mapper. flatten_submission's output; document sinks (the mongo/ arango asyncdb drivers) receive :func:~parrot_formdesigner.services.sinks.mapper.nest_submission's output instead (FEAT-457, TASK-2428's submit-path branch decides which mapper to call based on this property). Defaults to "tabular" — the common case; AsyncDBSink overrides this per its configured driver.

Method AbstractSubmissionSink.ensure_target

Idempotently create/extend the destination. Additive only.

ensure_target(form: FormSchema) -> None

Parameter Type Default Description
form FormSchema The form whose destination must exist and be up to date.

Method AbstractSubmissionSink.write

Persist one submission.

write(submission: FormSubmission, payload: Any) -> str

Parameter Type Default Description
submission FormSubmission The submission record being persisted.
payload Any The mapped payload to write (tabular row or nested document — see the submission mapper).

Returns: str — The persisted submission's submission_id.

Method AbstractSubmissionSink.read

Retrieve a single submission by id.

read(submission_id: str) -> FormSubmission | None

Parameter Type Default Description
submission_id str The submission id to look up.

Returns: FormSubmission | None — The matching submission, or None if not found.

Raises:

  • SinkNotCapableError — If this sink does not declare READ.

Method AbstractSubmissionSink.list_revisions

List all revisions of a submission.

list_revisions(root_submission_id: str) -> list[FormSubmission]

Parameter Type Default Description
root_submission_id str The root submission id whose revisions to list.

Returns: list[FormSubmission] — The list of revisions, most recent first.

Raises:

  • SinkNotCapableError — If this sink does not declare LIST.

Method AbstractSubmissionSink.close

Release any resources held by this sink. No-op by default.

close() -> None

Method AbstractSubmissionSink.require

Raise unless capability is in this sink's capability set.

Shared enforcement path for both backends and the HTTP handler.

require(capability: SinkCapability) -> None

Parameter Type Default Description
capability SinkCapability The capability the caller intends to invoke.

Raises:

  • SinkNotCapableError — If capability is not declared.

Alias FormSchema

Re-exported from parrot_formdesigner.core.schema.FormSchema.

Alias FormSubmission

Re-exported from parrot_formdesigner.services.submissions.FormSubmission.

Alias SinkCapability

Re-exported from parrot_formdesigner.core.persistence.SinkCapability.

Class SinkError

Base class for all submission-sink errors.

Class SinkNotCapableError

Operation not in the sink's declared capability set.

HTTP mapping: 501 Not Implemented. The response should name the sink type and its declared capabilities so the caller can tell a genuine gap from a bug.

Class SinkTargetMismatchError

Existing target incompatible with the form (e.g. a changed destination or an incompatible existing column type).

HTTP mapping: 422 Unprocessable Entity.

Class SinkUnavailableError

Destination unreachable or rate-limited.

HTTP mapping: 503 Service Unavailable. The submit path fails the request with no fallback and persists nothing anywhere (spec section 1, Goal 8).

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