contracts.template_scan

Page actions AI-ready formats and sharing
Open LLM text
Share with AI
Ask Claude Ask ChatGPT Ask Gemini Ask Copilot

Template source scanners used by contracts checker.

Template source scanners used by contracts checker.

contracts.template_scan

Name Type Default Description
type
qualified_name
element_type
description
source_file
line_number
is_autodoc
autodoc_element
_autodoc_template
_autodoc_url_path
_autodoc_page_type
title
doc_content_hash

Symbols on this page

class QueryClientReference

One statically knowable programmatic HTTP QUERY client call.

Jump to symbol
class _LoadedTemplateSource Jump to symbol class CanonicalTemplateSources

Private scan mapping that iterates canonical names and resolves aliases.

Jump to symbol
class CanonicalTemplateScan

Canonical built-in scan inputs derived from logical loader names.

Jump to symbol
class TemplateSourceInventory

Loaded logical sources with private loader provenance.

Jump to symbol
function _javascript_call_suffix

Return the remainder of one call, stopping at its balanced).

Jump to symbol
function get_form_method

Return POST only when form has method='post', otherwise GET.

Jump to symbol
function extract_targets_from_source

Extract (attr_name, url, method_override) from template source.

Jump to symbol
function extract_query_client_references

Extract literal, browser-proven QUERY calls from template scripts.

Chirp does not publish a declarativehx-queryattribute. This scanner intentionally recognizes only the programmatic Fetch…

Jump to symbol
function extract_href_references

Extract URL paths from href= attributes and macro keyword arguments.

Used for orphan-route detection: catches<a href="/team">, macro calls likesidebar_link("/team", ...),…

Jump to symbol
function extract_legacy_action_contracts

Extract legacy action= contract names from template call arguments.

Jump to symbol
function extract_hx_target_selectors

Extract static hx-target selector values from source.

Jump to symbol
function extract_static_ids

Extract static id= values from source.

Jump to symbol
function extract_template_references

Extract static template references from Kida template tags.

Jump to symbol
function resolve_template_reference

Resolve a Kida cross-template reference for contract bookkeeping.

Kida 0.8 lets templates use./ and ../references relative to the caller, plus@alias/namespace…

Jump to symbol
function extract_fragment_island_ids

Extract id values from fragment_island() macro calls.

Jump to symbol
function extract_wizard_form_ids

Extract id values from wizard_form() macro calls.

Jump to symbol
function extract_ids_with_disinherit

Extract id values from elements that have hx-disinherit.

Jump to symbol
function extract_mutation_target_ids

Extract #id values from hx-target when element is mutating.

Jump to symbol
function extract_htmx_partial_sources

Extractsrc= attribute values from <htmx-partial>elements.

Values are normalized to URL paths suitable for route matching:

query strings and fragments are stripped, and…

Jump to symbol
function _load_one

Load one logical template while retaining loader provenance.

Jump to symbol
function load_template_inventory

Load logical template sources and their private provenance.

Jump to symbol
function load_template_sources

Load all logical template sources for the public contract snapshot.

Jump to symbol
QueryClientReference
class

One statically knowable programmatic HTTP QUERY client call.

_LoadedTemplateSource
class
CanonicalTemplateSources
class

Private scan mapping that iterates canonical names and resolves aliases.

CanonicalTemplateScan
class

Canonical built-in scan inputs derived from logical loader names.

TemplateSourceInventory
class

Loaded logical sources with private loader provenance.

_javascript_call_suffix
function
def _javascript_call_suffix(source: str, start: int) -> str

Return the remainder of one call, stopping at its balanced).

Parameters

Name Type Default Description
source str
start int
get_form_method
function
def get_form_method(source: str, action_pos: int) -> str | None

Return POST only when form has method='post', otherwise GET.

Parameters

Name Type Default Description
source str
action_pos int
extract_targets_from_source
function
def extract_targets_from_source(source: str) -> list[tuple[str, str, str | None]]

Extract (attr_name, url, method_override) from template source.

Parameters

Name Type Default Description
source str
extract_query_client_references
function
def extract_query_client_references(source: str) -> tuple[QueryClientReference, ...]

Extract literal, browser-proven QUERY calls from template scripts.

Chirp does not publish a declarativehx-queryattribute. This scanner intentionally recognizes only the programmatic Fetch andhtmx.ajax forms covered by the QUERY browser contract, and only when the URL and method are literal. Dynamic headers remain unknown instead of becoming a false-positive media-type diagnostic.

Parameters

Name Type Default Description
source str
extract_href_references
function
def extract_href_references(source: str) -> set[str]

Extract URL paths from href= attributes and macro keyword arguments.

Used for orphan-route detection: catches<a href="/team">, macro calls likesidebar_link("/team", ...), and keyword args like href="/login". Returns base paths (query strings and fragments stripped).

Parameters

Name Type Default Description
source str
extract_legacy_action_contracts
function
def extract_legacy_action_contracts(source: str) -> set[str]

Extract legacy action= contract names from template call arguments.

Parameters

Name Type Default Description
source str
extract_hx_target_selectors
function
def extract_hx_target_selectors(source: str) -> list[str]

Extract static hx-target selector values from source.

Parameters

Name Type Default Description
source str
extract_static_ids
function
def extract_static_ids(source: str) -> set[str]

Extract static id= values from source.

Parameters

Name Type Default Description
source str
extract_template_references
function
def extract_template_references(source: str) -> set[str]

Extract static template references from Kida template tags.

Parameters

Name Type Default Description
source str
resolve_template_reference
function
def resolve_template_reference(reference: str, caller: str, template_aliases: Mapping[str, str] | None = None) -> str

Resolve a Kida cross-template reference for contract bookkeeping.

Kida 0.8 lets templates use./ and ../references relative to the caller, plus@alias/namespace prefixes. Chirp's contract rules compare references against the root-relative names returned by loaders, so keep the same canonicalization here.

Parameters

Name Type Default Description
reference str
caller str
template_aliases Mapping[str, str] | None None
extract_fragment_island_ids
function
def extract_fragment_island_ids(source: str) -> set[str]

Extract id values from fragment_island() macro calls.

Parameters

Name Type Default Description
source str
extract_wizard_form_ids
function
def extract_wizard_form_ids(source: str) -> set[str]

Extract id values from wizard_form() macro calls.

Parameters

Name Type Default Description
source str
extract_ids_with_disinherit
function
def extract_ids_with_disinherit(source: str) -> set[str]

Extract id values from elements that have hx-disinherit.

Parameters

Name Type Default Description
source str
extract_mutation_target_ids
function
def extract_mutation_target_ids(source: str) -> set[str]

Extract #id values from hx-target when element is mutating.

Parameters

Name Type Default Description
source str
extract_htmx_partial_sources
function
def extract_htmx_partial_sources(source: str) -> list[str]

Extractsrc= attribute values from <htmx-partial>elements.

Values are normalized to URL paths suitable for route matching:

query strings and fragments are stripped, and only leading-/paths are kept. Results are deduplicated while preserving order.

Parameters

Name Type Default Description
source str
_load_one
function
def _load_one(loader: Any, name: str) -> _LoadedTemplateSource | None

Load one logical template while retaining loader provenance.

Parameters

Name Type Default Description
loader Any
name str
load_template_inventory
function
def load_template_inventory(kida_env: Any) -> TemplateSourceInventory

Load logical template sources and their private provenance.

Parameters

Name Type Default Description
kida_env Any
load_template_sources
function
def load_template_sources(kida_env: Any) -> dict[str, str]

Load all logical template sources for the public contract snapshot.

Parameters

Name Type Default Description
kida_env Any

View source · /home/runner/work/chirp/chirp/site/../src/chirp/contracts/template_scan.py:1