Skip to content

API Reference parrot_formdesigner.tools.snippet_authoring

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

parrot_formdesigner.tools.snippet_authoring

View source

LLM authoring surface for snippet bundles (FEAT-459 / M16).

Generates conformant bundles (Python + TS + manifest + OQ-8 equivalence fixtures) from a natural-language rule description, gates every draft through TASK-3175's run_gate() BEFORE returning it, and produces a plain-language capability summary for whoever approves it (PR reviewer for git snippets, tenant admin for DB snippets via TASK-3166).

C4 (human approval, always) is enforced structurally here: no method in this toolkit ever calls SnippetApprovalService.publish() or otherwise causes generated code to become executable. Only draft()-ing (DB) or returning files ready to be PR'd (git) are in scope.

Codebase-contract note: unlike the task blueprint's draft, methods here are NOT decorated with @tool — that decorator (parrot.tools.tool) marks a standalone function as a tool; AbstractToolkit instead auto-converts every public async method into a tool (see tools/edit_toolkit.py for the verified convention in this package).

Attribute BundleGeneratorFn

Alias CapabilityManifest

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

Alias CapabilityTier

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

Alias EquivalenceFixture

Re-exported from parrot_formdesigner.services.snippets.conformance.EquivalenceFixture.

Class GeneratedBundle

One LLM-generation attempt: a candidate bundle plus its fixtures.

Parameter Type Default Description
bundle Any
fixtures list[EquivalenceFixture]

Fields:

Field Type Default Description
bundle Any
fixtures list[EquivalenceFixture]

Alias SnippetApprovalService

Re-exported from parrot_formdesigner.services.snippets.approval.SnippetApprovalService.

Class SnippetAuthoringToolkit

Generates, gates, and summarizes snippet bundles. NEVER approves or executes one.

Parameter Type Default Description
generate_bundle BundleGeneratorFn Calls an LLM to produce a GeneratedBundle from a natural-language rule description. Injected — see module docstring.
**kwargs Any {} Forwarded to AbstractToolkit.init.

Method SnippetAuthoringToolkit.draft_from_description

Generate a conformant snippet bundle from a natural-language rule.

Runs the bundle through the tier-conformance and equivalence gate BEFORE returning it. Never approves or publishes the result — approval is always a separate human action (C4).

draft_from_description(rule_description: str) -> dict

Parameter Type Default Description
rule_description str Plain-language description of the desired behavior, e.g. "if total > 5000, require approver_email".

Returns: dict — A dict with keys: ready (bool — True only if the gate passed), bundle (the generated SnippetBundle, always returned even on failure so a caller can retry generation with the error context), gate_errors (list[str], empty if ready), capability_summary (str, plain language).

Method SnippetAuthoringToolkit.summarize_capabilities

Translate a CapabilityManifest into a plain-language summary for an approver.

summarize_capabilities(manifest: CapabilityManifest) -> str

Parameter Type Default Description
manifest CapabilityManifest The manifest to summarize.

Returns: str — A short paragraph, never a JSON/field dump.

Method SnippetAuthoringToolkit.propose_for_tenant

Generate a bundle and insert it as a DB draft (NOT published — C4).

propose_for_tenant(rule_description: str, *, tenant: str, approval_service: SnippetApprovalService) -> dict

Parameter Type Default Description
rule_description str See draft_from_description.
tenant str The tenant this draft belongs to.
approval_service SnippetApprovalService TASK-3166's service — draft() only, never publish().

Returns: dict — Same shape as draft_from_description()'s return, plus a draft_version key when ready is True (the version number SnippetApprovalService.draft() assigned).

Alias SnippetSource

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

Attribute logger

Alias run_gate

Re-exported from parrot_formdesigner.services.snippets.conformance.run_gate.

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