Skip to content

API Reference parrot_formdesigner.core.resolution

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

parrot_formdesigner.core.resolution

View source

Build-time rule-reference resolution (FEAT-393, Module 3).

Rules stay AUTHORED by field_id (humans, YAML, LLM) but are STORED as field_uid references — the stable, immutable identity introduced by Module 2 (core/schema.py). This module provides the shared resolution pass that rewrites authored field_id references to field_uid at every build boundary (extractors, CreateFormTool, blank-form and edit APIs), plus the canonical UID lookup helpers those and later modules consume.

Resolution is idempotent by construction: a reference that is already UID-shaped (and known) validates and passes through unchanged, so re-running resolve_rule_references on an already-resolved form is a no-op.

Alias DependencyRule

Re-exported from parrot_formdesigner.core.constraints.DependencyRule.

Alias FieldCondition

Re-exported from parrot_formdesigner.core.constraints.FieldCondition.

Alias FormField

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

Alias FormSchema

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

Alias FormSection

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

Function find_field_by_uid

Form-wide, subsection- and nesting-aware field lookup by UID.

The canonical replacement for api/operations.py's _field_index (which skips subsections) and tools/edit_toolkit.py's _find_field_and_section traversal (FEAT-393).

find_field_by_uid(form: FormSchema, field_uid: uuid.UUID) -> tuple[FormField, FormSection] | None

Parameter Type Default Description
form FormSchema The FormSchema to search.
field_uid uuid.UUID The field_uid to look up.

Returns: tuple[FormField, FormSection] | None — A (field, section) tuple for the first match, or None if no field with this field_uid exists anywhere in the form.

Function resolve_answer

Read an answer value for a UID-referenced field from a field_id-keyed answers dict.

resolve_answer(form: FormSchema, field_uid: uuid.UUID, answers: dict[str, Any]) -> Any

Parameter Type Default Description
form FormSchema The FormSchema the UID reference belongs to.
field_uid uuid.UUID The resolved field_uid to read an answer for.
answers dict[str, Any] The submission/answers mapping, keyed by field_id (unchanged wire shape — FEAT-393 only moves internal rule storage to UIDs, not the answers contract).

Returns: Any — The answer value for the field's current field_id, or None if the field is not found or has no answer.

Function resolve_rule_references

Rewrite authored field_id rule references to field_uid.

Walks every field in the form (via iter_fields_recursive()) and resolves depends_on conditions/operations and post_depends entries (including their nested operation) in place, then does the same for each FormSection.depends_on. Mutates and returns the same form instance.

Idempotent: a reference that already parses as a UUID is validated against the form's known UIDs and passed through unchanged — running this twice on the same form produces identical rule references.

resolve_rule_references(form: FormSchema) -> FormSchema

Parameter Type Default Description
form FormSchema The FormSchema whose rules should be resolved.

Returns: FormSchema — The same form instance, with rule references rewritten.

Raises:

  • ValueError — If a rule references a duplicate field_id (the form itself is ambiguous), or references an unknown/empty field_id/field_uid. The error names the owning field's field_id — or the owning section's section_id — and the offending reference.

Alias walk_fields

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

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