Skip to content

API Reference parrot_formdesigner.services.snippets.git_loader

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

parrot_formdesigner.services.snippets.git_loader

View source

Git-backed snippet loader (FEAT-459 / M4).

Bundle directory layout (one directory per snippet, under the configured root)::

<root>/<bundle-name>/
    manifest.json   # {"handler_ref": str, "event": FormEventName,
                     #  "manifest": CapabilityManifest-shaped dict}
    run.py           # Python source; sha256 verified against
                      #  manifest.json's "python_sha256" (which the
                      #  author/CI computes and commits alongside)
    client.js         # OPTIONAL — compiled JS, produced by
                      #  scripts/build_snippet_bundles.py (TASK-3174).
                      #  Read verbatim if present; never compiled here.

Approval for this source IS the merged PR: a bundle present on disk with a matching hash is, by construction, approved (spec §2 point 2).

Attribute CLIENT_SOURCE_FILENAME

Alias CapabilityManifest

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

Alias CapabilityTier

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

Alias ContextProjectorFn

Re-exported from parrot_formdesigner.services.snippets.base.ContextProjectorFn.

Class GitSnippetLoader

Discovers git-backed snippet bundles under root and registers them.

Parameter Type Default Description
root Path Directory containing one subdirectory per snippet bundle.
strict bool True When True (default), any parse/hash failure aborts discover() entirely. When False, a failing bundle is logged and skipped rather than aborting the whole boot — deliberately rare/ops-only: G4/G5 treat an unverified source as unsafe to run at all, so strict=False should only be used to keep an otherwise-healthy platform snippet set booting while a single broken bundle is fixed out-of-band, never as a routine operating mode.

Method GitSnippetLoader.discover

Walk root, parse and hash-verify every bundle directory.

discover() -> list[SnippetBundle]

Returns: list[SnippetBundle] — All discovered bundles, in sorted directory-name order.

Raises:

  • SnippetIntegrityError — propagated from a failing bundle when strict=True.

Method GitSnippetLoader.resolve_current

SnippetSourceProtocol implementation — plain dict lookup.

Git bundles never change without a redeploy (which re-runs discover() at process boot), so no cache invalidation is needed.

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

Parameter Type Default Description
tenant str | None
handler_ref str

Returns: SnippetBundle | None

Method GitSnippetLoader.register_all

Register every discovered bundle via register_resolver().

register_all(*, project_context: ContextProjectorFn, execute: SandboxExecutorFn, gvisor_available: Callable[[], bool] = lambda: False) -> int

Parameter Type Default Description
project_context ContextProjectorFn Passed through to register_resolver() — TASK-3167's ContextProjector.project, injected.
execute SandboxExecutorFn Passed through to register_resolver() — TASK-3172's TierRouter.execute, injected.
gvisor_available Callable[[], bool] lambda: False Returns True when the gVisor runtime is usable. Defaults to a fail-safe False so a caller that forgets to wire TASK-3170's real probe gets tier-3/4 bundles refused rather than silently allowed to load without isolation (OQ-4: no silent degradation).

Returns: int — Count of registered snippets.

Raises:

  • SnippetIntegrityError — source hash mismatch (from discover()).
  • SnippetTierUnavailableError — bundle declares tier 3/4 but gVisor is unavailable.
  • ValueError — propagated from register_form_event() on a duplicate (tenant, handler_ref).

Attribute MANIFEST_FILENAME

Attribute PYTHON_SOURCE_FILENAME

Alias SandboxExecutorFn

Re-exported from parrot_formdesigner.services.snippets.base.SandboxExecutorFn.

Alias SnippetBundle

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

Alias SnippetIntegrityError

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

Alias SnippetSource

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

Alias SnippetStatus

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

Alias SnippetTierUnavailableError

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

Attribute logger

Alias register_resolver

Re-exported from parrot_formdesigner.services.snippets.base.register_resolver.

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