Add hermetic template recording and replay - #2114
Open
martelogan wants to merge 3 commits into
Open
Conversation
(cherry picked from commit 3befa56)
Keep recorder hooks inert for host contexts without Liquid registers, capture only bytes produced by the template, and exclude memory-limited renders from the corpus. Strict replay now stubs application-only inline and block tags from the recorded sources. Assisted-By: devx/948e6cb4-458b-480b-8d99-d726473b381b
martelogan
force-pushed
the
martelogan/liquid-hermetic-recording
branch
from
September 3, 2026 03:45
394edbf to
2578979
Compare
The hooks sit on the hottest paths a host has - every drop read, filter call, tag and variable - and a host that never records should not pay for them. Storefront's verifier measured the ungated hooks at +1.59% allocations per request with recording switched off, against a 0.2% gate. HOOKS_ENABLED is deliberately boot-time: a constant is what makes the disabled path free. Recording is generated offline, so the processes that need it set LIQUID_TEMPLATE_RECORDER_HOOKS at boot and nothing else pays. TemplateRecorder.record now raises when the hooks are off, so a misconfigured host fails loudly instead of silently recording nothing. Assisted-By: devx/948e6cb4-458b-480b-8d99-d726473b381b
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
This carries forward the hermetic recording and deterministic replay work from #1975 while preserving its authorship lineage:
Branch ancestry
The PR head is intentionally rooted at
v5.13.0rather than the currentmain. The interveningmaincommit changes strict2 rendering independently of the recorder; excluding it keeps direct consumers of this immutable head recorder-only. The PR still targetsmain. Its single-file overlap inlib/liquid/template.rbcan be resolved when preparing the upstream merge, after consumers no longer depend on this exact head tree.Follow-up fixes
LIQUID_TEMPLATE_RECORDER_HOOKSgateThe boot-time gate addresses a Storefront verifier result of +1.59% allocations per request with the ungated hooks disabled at the feature level, versus a 0.2% gate. Offline recording processes explicitly enable the hooks; other hosts avoid recorder/session lookups on their render paths.
Current BLAKE3 for
lib/liquid/template_recorder.rb:fc979294a7523b48e9d8cf21aed3a4c1b9e944a6ee611406eb0c7cc2439be44f.Test plan
bundle exec rake(hooks-disabled lax, strict, and strict2 suites; hooks-enabled recorder tests; RuboCop)bundle exec ruby -Itest test/integration/template_recorder_disabled_test.rb(1 run, 3 assertions)LIQUID_TEMPLATE_RECORDER_HOOKS=1 bundle exec ruby -Itest test/integration/template_recorder_test.rb(24 runs, 57 assertions)