Module

middleware.layout_debug

Layout chain and route contract debug middleware.

When config.debug is True, adds X-Chirp-Layout-* and X-Chirp-Route-* headers to help diagnose layout resolution and route contract metadata.

Also emitsX-Chirp-Render-Planwith a base64-encoded compact JSON snapshot of the render plan for consumption by the HTMX debug tray.

Classes

LayoutDebugMiddleware 1
Middleware that adds X-Chirp-Layout-* and X-Chirp-Route-* headers when config.debug.

Middleware that adds X-Chirp-Layout-* and X-Chirp-Route-* headers when config.debug.

Methods

Internal Methods 1
__call__ 2 AnyResponse
async
async def __call__(self, request: Request, next: Next) -> AnyResponse
Parameters
Name Type Description
request
next
Returns
AnyResponse

Functions

set_layout_debug_metadata 4 None
Store layout chain metadata on the request for the layout debug middleware.
def set_layout_debug_metadata(request: Request | None, chain: str, match: str, mode: str) -> None
Parameters
Name Type Description
request Request | None
chain str
match str
mode str
_build_render_plan_payload 1 dict | None
Build a rich render plan payload from the stashed RenderPlan. Uses the public …
def _build_render_plan_payload(request: Request) -> dict | None

Build a rich render plan payload from the stashed RenderPlan.

Uses the publicget_render_plan()API to access the frozen RenderPlan object, producing a richer payload than the old compact snapshot (which was capped at 20 context keys and ~2 KB).

Parameters
Name Type Description
request Request
Returns
dict | None
_compact_render_plan 1 dict
Trim a render plan snapshot to header-safe size (~2 KB). Fallback used when th…
def _compact_render_plan(plan: dict) -> dict

Trim a render plan snapshot to header-safe size (~2 KB).

Fallback used when the frozen RenderPlan is not available.

Parameters
Name Type Description
plan dict
Returns
dict