Skip to content

API Reference parrot_formdesigner.services.snippets.conformance

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

parrot_formdesigner.services.snippets.conformance

View source

Tier conformance + equivalence gate for snippet bundles (FEAT-459 / M15).

Two checks: (a) Tier conformance — static ast analysis: no imports beyond declared stdlib_modules, no I/O at tiers PURE/HELPERS, no broker calls outside the manifest's BrokerAllowlist (best-effort — NOT a full sandbox; the runtime pools in services/sandbox/ are the actual safety boundary). (b) Semantic equivalence (OQ-8) — every bundle ships fixture cases; this gate executes the Python half and (via an injected JsRunnerFn — see NOT in scope) the compiled JS half against the same fixtures, failing on divergence or on zero fixtures.

Importable by services/snippets/approval.py (TASK-3166) so DB publishes run the SAME checks as git PRs (spec's explicit cross-source requirement).

Alias CapabilityTier

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

Class ConformanceResult

Satisfies TASK-3166's ConformanceResult Protocol (.passed, .errors).

Parameter Type Default Description
passed bool
errors list[str] list()

Fields:

Field Type Default Description
passed bool
errors list[str] field(default_factory=list)

Class EquivalenceFixture

One input/expected-output pair both halves of a bundle must agree on.

Parameter Type Default Description
name str
input_payload dict[str, Any]
expected_output dict[str, Any]

Fields:

Field Type Default Description
name str
input_payload dict[str, Any]
expected_output dict[str, Any]

Attribute JsRunnerFn

Alias SnippetBundle

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

Function check_equivalence

Execute both halves against fixtures, failing on divergence or zero fixtures.

check_equivalence(bundle: SnippetBundle, fixtures: list[EquivalenceFixture], *, run_js: JsRunnerFn | None = None) -> ConformanceResult

Parameter Type Default Description
bundle SnippetBundle
fixtures list[EquivalenceFixture]
run_js JsRunnerFn | None None Executes the compiled JS half. When None AND bundle.client_source is set, this is a FILL IN gap — the equivalence check for that bundle cannot be completed and MUST fail loudly (not silently pass) per OQ-8's "CI executes both halves... fails on divergent output" requirement.

Returns: ConformanceResult

Function check_tier_conformance

Static ast check: declared stdlib_modules only, no undeclared I/O.

Best-effort — see module docstring. Does not execute bundle.python_source.

check_tier_conformance(bundle: SnippetBundle) -> ConformanceResult

Parameter Type Default Description
bundle SnippetBundle

Returns: ConformanceResult

Attribute logger

Function run_gate

Combined tier-conformance + equivalence gate.

This is the function to wire into SnippetApprovalService's check_conformance parameter (TASK-3166) once this task lands.

run_gate(bundle: SnippetBundle, fixtures: list[EquivalenceFixture], *, run_js: JsRunnerFn | None = None) -> ConformanceResult

Parameter Type Default Description
bundle SnippetBundle
fixtures list[EquivalenceFixture]
run_js JsRunnerFn | None None

Returns: ConformanceResult

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