Hardened and shared the on-disk Handlebars template compile cache across users - refs #1362 - #1377
Merged
philayres merged 1 commit intoAug 25, 2026
Conversation
This was referenced Aug 27, 2026
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
Stage 1 of issue #1362: hardens and shares the existing on-disk Handlebars template compile cache, without adding any new pre-warmer/scheduled job (that remains a future Stage 2, out of scope here). The compile-on-demand pipeline (compile at request time, cache to disk, serve to the browser) is made safer, disk-bounded, and shareable across users.
What changed
HandlebarsPrecompiler::FileLock: a flock-based, fail-open mutual-exclusion primitive used purely as a work-duplication optimisation (correctness already comes from atomic writes + deterministic filenames), wired into the compile step and multi-bundle assembly to avoid redundant CLI invocations under concurrent requests._search_results_resources_panel.html.erb(and the analogousactivity_logs_controller#apply_perspectivecall site) by restricting aFormatter::Substitutioncall to only exposerole_name, not the fullcurrent_user.public/intotmp/— only the final multi-bundle JS actually served to the browser remains web-servable; individual compiled templates/partials are server-side-only.gen-<key>/) with a count-based sweeper and an opportunistic (no cron) trigger, bounding disk usage across dynamic-definition/config rotations instead of accumulating indefinitely.rails console/rails runner) no longer wipes the web server's compiled templates or invalidates its cache on its own restart, since they share disk on Elastic Beanstalk.Review process
This branch went through two full independent reviews (via a separate model instance) plus targeted fault-injection testing (deliberately breaking isolation/sharing in the implementation to confirm the new specs catch the regression, then reverting). All blocking and should-fix findings from both reviews have been resolved.
Testing
rubocopclean on every file touched by this branch (verified against the pre-existing baseline — no new offenses introduced).Refs #1362 (Stage 1 only — pre-warming itself is a separate future Stage 2).