Module

contracts.rules_boundary

Error boundary coverage check for OOB template blocks.

Scans template sources for blocks inside elements withhx-swap-oob attributes and suggests wrapping them in{% try %}...{% fallback %} for graceful error handling.

This only catches templates that embedhx-swap-oobin their source. Templates used withSuspense don't contain hx-swap-oob— the OOB wrappers are generated at render time by chirp's Suspense pipeline, which already has its own per-block error handling (seesuspense.py).

Kida 0.4.0 introduced error boundaries —{% try %}blocks that catch render errors and fall back to safe defaults.

This check emits INFO-level issues (not errors or warnings) since server-side error handling already prevents page-level failures.

Scope limitations — the check uses regex-based HTML parsing, so it:

  • Only sees blocks in the literal template source (not inherited/included blocks)
  • May miss OOB regions split across template conditionals These are acceptable trade-offs for an INFO-level advisory check.

Functions

_extract_oob_regions 1 list[str]
Extract the inner content of each OOB element by tracking tag nesting. Limitat…
def _extract_oob_regions(source: str) -> list[str]

Extract the inner content of each OOB element by tracking tag nesting.

Limitations (regex-based HTML parsing):

  • Cannot see blocks inherited via{% extends %}or pulled in via {% include %}— only the literal source of each template is scanned.
  • HTML comments or template conditionals that split tags may confuse the nesting tracker, though this is rare in practice.
Parameters
Name Type Description
source str
Returns
list[str]
check_boundary_coverage 1 list[ContractIssue]
Suggest error boundaries for blocks inside OOB elements. Only inspects blocks …
def check_boundary_coverage(template_sources: dict[str, str]) -> list[ContractIssue]

Suggest error boundaries for blocks inside OOB elements.

Only inspects blocks that are inside elements withhx-swap-oob attributes (explicit OOB swap targets). Blocks outside OOB regions in the same template are not flagged. Does not cover Suspense-rendered OOB (those wrappers are generated at render time, not in the source).

Parameters
Name Type Description
template_sources dict[str, str]
Returns
list[ContractIssue]