contracts.rules_htmx_provisioned

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

Page-level htmx provisioning contract (#185).

A template can be authored withhx-* / sse-*attributes -- the whole point of a hypermedia app -- but those attributes are inert unless the htmx…

Page-level htmx provisioning contract (#185).

A template can be authored withhx-* / sse-*attributes -- the whole point of a hypermedia app -- but those attributes are inert unless the htmx runtime is actually loaded on the page. Chirp can provision htmx in two ways:

  • AppConfig(htmx=True) -- Chirp injects the htmx core <script>before </body> (dedup on data-chirp="htmx"), or
  • the layout chain ships its own htmx<script> (a data-chirp="htmx" marker, or asrcpointing at an htmx build).

When neither is true, everyhx-*attribute silently does nothing: clicks fall through to default browser navigation (or nothing), and the developer only notices in the browser. This rule promotes that to a startupapp.check() WARNING.

It fires once per NON-framework template that emits anhx-*/sse-* attribute when htmx is not provisioned. Framework templates (chirp//chirpui/) are skipped. Severity is WARNINGand can be promoted viaapp.override_contract_severity("htmx_provisioned", Severity.ERROR).

contracts.rules_htmx_provisioned

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

_htmx_runtime_present
function
def _htmx_runtime_present(template_sources: Mapping[str, str]) -> bool

True when a NON-framework template carries an htmx<script>marker.

Framework templates (chirp//chirpui/shell + boost layouts) always ship an htmx marker, but they are only rendered when the app opts into the chirp-ui shell. Provisioning must therefore be proven by the app's own layout chain, not by the bundled framework sources.

Parameters

Name Type Default Description
template_sources Mapping[str, str]
check_htmx_provisioned
function
def check_htmx_provisioned(template_sources: Mapping[str, str], *, htmx_config_enabled: bool) -> list[ContractIssue]

Flag templates emittinghx-*/sse-*when htmx is not provisioned.

htmx counts as provisioned whenhtmx_config_enabled is True (AppConfig(htmx=True)) or an htmx <script>marker is present in any scanned template source. When provisioned the rule stays silent.

Parameters

Name Type Default Description
template_sources Mapping[str, str]
htmx_config_enabled bool

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