feat: RenderCapture — block-level capture, search indexing, freeze cache#99
Merged
feat: RenderCapture — block-level capture, search indexing, freeze cache#99
Conversation
…ering Introduces a new render-time data capture system parallel to the existing RenderAccumulator (profiling). Templates compiled with enable_capture=True inject capture hooks at block call sites. When a captured_render() context manager is active, block content, content hashes, context snapshots, and template names are recorded into a RenderCapture object. - New module: kida/render_capture.py (Fragment, RenderCapture, captured_render) - New Environment flag: enable_capture (default False, zero overhead when off) - Compiler: include_cap parameter in preamble, capture hooks at block call sites - Template: context snapshot + template_name in _render_scaffold - 28 new tests covering unit, integration, profiling co-existence, and edge cases Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…fing Bridges BlockMetadata (role, depends_on) into captured Fragments at render time. The _render_scaffold populates block metadata from template analysis, so captured blocks carry semantic roles (content, navigation, etc.) and dependency information automatically. - RenderCapture._record() now pulls role/depends_on from BlockMetadata - _render_scaffold bridges block_metadata() into active capture - RenderCapture.changed_from() enables semantic block-level diffing - 7 new tests for metadata bridging and diffing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Introduces RenderManifest for accumulating captures across batch renders (e.g., static site freeze), SearchManifestBuilder for auto-deriving search indexes from block roles, and ManifestDiff for semantic deploy-level diffing. - RenderManifest: batch accumulation, all_fragments(), unique_content_hashes() - SearchManifestBuilder: auto-classifies blocks by role, extracts facets from context, produces Chirp-compatible search manifest format - ManifestDiff: added/removed/changed URLs with block-level granularity - 14 new tests covering manifest ops, diffing, and search generation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- `kida manifest <dir>` renders templates and outputs a capture manifest as JSON with block roles, content hashes, and dependency metadata. Supports --data for context injection and --search for auto-derived search index output. - `kida diff <old> <new>` computes semantic diff between two manifests, reporting added/removed/changed URLs with block-level granularity. Exit code 1 when changes detected, 0 when identical. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
SearchManifestBuilder now uses raw context values (doc.body) instead of rendered HTML for search indexing, with a FieldExtractor protocol for framework-agnostic field mapping. FreezeCache auto-caches site-scoped blocks during batch renders, targeting the 59% redundant render opportunity. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
template.render(), using the same ContextVar + compile-time flag pattern as profiling. Zero overhead when disabled (enable_capture=Falseelides all capture AST).content_hash(SHA256[:16]),role,depends_on, andcache_scopebridged from BlockMetadata at render time.FieldExtractorprotocol enables framework-agnostic field mapping; default extractor reads raw context (doc.body) instead of stripping rendered HTML.kida manifestrenders templates with capture and outputs JSON;kida diffcomputes semantic block-level diffs between manifests.Test plan
ty checkon changed files only (109 pre-existing diagnostics incompiler/expressions.pycause full-src hook to fail)🤖 Generated with Claude Code