Module

contracts.rules_fragment_targets

Fragment target registry orphan check.

Fails loud at startup when the fragment target registry contains entries whosefragment_blockis not defined by any page leaf template. Such registrations are inert: boosted requests hitting that HX-Target resolve to a block that does not exist, producing a runtimeBlockNotFoundError (for required targets) or silently falling back to full-page composition (for optional targets).

Relation to sibling checks:

  • check_page_shell_contractsiterates each page template and reports missing required blocks per-template. High per-page fidelity but noisy when a registration is simply dead.
  • This check iterates each registration and reports orphans once per target — a single high-signal issue per registry typo. It is also the only check coveringrequired=Falsetargets.

Severity tiering:

  • required=True(contract-required or ad-hoc required): ERROR. Render-time would raiseBlockNotFoundErroron any boosted request matching the target id.
  • required=False: WARNING. Silent render fallback keeps requests working, but the registration is almost certainly a typo or stale.

Apps can demote globally via app.override_contract_severity("fragment_target_orphan", Severity.WARNING).

Functions

check_fragment_target_orphans 3 list[ContractIssue]
Emit ERROR/WARNING issues for targets whose block no template defines.
def check_fragment_target_orphans(fragment_target_registry: FragmentTargetRegistry, page_templates: set[str], kida_env: Environment | None) -> list[ContractIssue]
Parameters
Name Type Description
fragment_target_registry FragmentTargetRegistry
page_templates set[str]
kida_env Environment | None
Returns
list[ContractIssue]