Skip to content

Add hermetic template recording and replay - #2114

Open
martelogan wants to merge 4 commits into
Shopify:mainfrom
martelogan:martelogan/liquid-hermetic-recording
Open

martelogan wants to merge 4 commits into
Shopify:mainfrom
martelogan:martelogan/liquid-hermetic-recording

Conversation

@martelogan

@martelogan martelogan commented Sep 3, 2026 •

Copy link
Copy Markdown
Member

Summary

Carries forward the hermetic recording and deterministic replay work from #1975 while preserving commit authorship. Tobi’s recorder commit and the two Logan-authored integration/performance follow-ups remain unchanged in history. The new merge commit is authored by Logan Martel.

Branch ancestry

Refreshed by merging main at 4e39ae4, preserving existing commit identities. This head now includes Liquid 5.14.0, including the upstream strict2 and range-resource-limit changes. Consumers moving from the previous v5.13-based recording head must validate that runtime upgrade; this is no longer a recorder-only delta against stock 5.13.

The Template#render conflict preserves both recorder output/lifecycle handling and upstream error-mode register restoration. Added coverage for recording with strict2 and restoring the caller’s error mode.

Recording behavior

  • Hooks remain disabled unless LIQUID_TEMPLATE_RECORDER_HOOKS is set before loading Liquid.
  • Recording without enabled hooks fails loudly.
  • Records contain only the template’s own output bytes, excluding existing buffer prefixes and later mutations.
  • Memory-limited partial renders are not recorded as successful.
  • Strict replay supports captured application-only tags; compute/verify replay recomputes from captured inputs.
  • Host contexts without Liquid registers remain unaffected.

The boot-time gate was introduced after an earlier ungated Storefront verifier allocation regression. No claim is made that the old measurement establishes performance for this refreshed head.

Validation

Run locally on Ruby 4.0.7:

  • bundle exec rake: hooks-disabled lax/strict/strict2 suites, isolated hooks-enabled recorder tests, RuboCop
  • LIQUID_TEMPLATE_RECORDER_HOOKS=1 bundle exec rake: full hooks-enabled lax/strict/strict2 suites and RuboCop (the disabled-hooks-only test skips as intended)
  • bundle exec rake spec: all four maintained adapters, each 2,845 passes and zero failures; 216 unsupported-feature cases skipped

No new mandatory tooling or source-refresh requirement is introduced for downstream saved tests.

Hosted check blocker

At refreshed head 7eb9c7c, the CLA workflow fails while fetching commits because the Shopify organization IP allowlist rejects its GitHub-hosted runner. It does not reach contributor/signature validation. Local tests above pass; this PR is not being reported as CI-green.

tobi and others added 2 commits September 2, 2026 23:45
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
martelogan force-pushed the martelogan/liquid-hermetic-recording branch from 394edbf to 2578979 Compare September 3, 2026 03:45
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 branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants