fix(elision): elide ungated dev-only prose + :doc non-literal + directory sentinel#4959
Merged
Merged
Conversation
…c opts, directory corpus
Three production-bundle-elision fixes on the shared elision-probe surface
(check-elision.cjs sentinels + elision_probe.cljs probe roots).
1. Ungated dev-only diagnostic emits (rf2-7czrms / rf2-tfiutq) — STEP-0 empirical
re-evaluation. The ~18 app-facing warning/diagnostic emits (resources /
routing / machines / ssr-client) call trace/emit! / emit-error! DIRECTLY on a
runtime data branch with no call-site interop/debug-enabled? gate. Rooting a
representative site in the :advanced probe proved the (str ...) / literal-
string prose is ALREADY elided in production (control build DEBUG=true keeps
it; production DEBUG=false drops it): a directly-called emit fn folds its body
to nil under goog.DEBUG=false, Closure inlines the no-op call, and the pure
prose args drop as dead. The bead's premise (emit identity escaping into a
late-bind registry) applies to the framework's OWN emit machinery (already
gated), not these direct-call sites. So no mass-gating — instead close the
systemic probe gap: the probe previously pinned prose absence only inside
already-gated branches, never at an ungated direct-emit site. Add two
DEV_ONLY sentinels + a touch rooting one emit! and one emit-error! direct
site, pinning the fold-path elision against a future regression that captures
emit! into a var.
2. :doc opts-map DCE gap on reg-machine (rf2-7xz70g / rf2-tfiutq). expand-reg-
machine forwarded its opts-form verbatim, bypassing gate-doc-args, so a
literal (reg-machine :id {:doc "..."} spec) left its :doc string bytes in the
:advanced bundle. Route the opts-form through gate-doc-arg when it is a
literal map (the idiomatic shape), emitting the same
(if interop/debug-enabled? <full> <stripped>) gate Closure folds. Pin via a
new DEV_ONLY sentinel + probe touch, a JVM handler-meta-strip parity test in
the machines artefact, and a cross-reference note in the core doc-elision
suite.
3. Reachability sentinel for the late-bind directory :description corpus
(rf2-7czrms / rf2-tfiutq). The ~150 paragraph :description strings in
re-frame.late-bind.directory/hooks are plain ungated CLJC data kept out of
production solely by reachability DCE (no production src namespace requires
the directory). No sentinel guarded that absence; add a PROD_ABSENT_WHEN_
UNUSED sentinel mirroring the EP-0023 image-assembly guard so an accidental
future production require is caught by CI.
Gates: npm run test:elision PASS (production 45/45 absent, control 45/45
present); npm run test:cljs 7999 tests / 36798 assertions 0 failures; machines
JVM 845 tests 0 failures; core doc-elision JVM 5 tests 0 failures.
mike-thompson-day8
added a commit
that referenced
this pull request
Jun 25, 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
Three production-bundle-elision fixes on the shared elision-probe surface (
implementation/scripts/check-elision.cjssentinels +implementation/core/test/re_frame/elision_probe.cljsprobe roots). One worker on one branch because all three share the two coupling files. Refs rf2-7czrms, rf2-7xz70g, rf2-tfiutq.1. Ungated dev-only diagnostic emits — STEP-0 empirical re-evaluation
The ~18 app-facing warning/diagnostic emits (resources / routing / machines / ssr-client) call
trace/emit!/trace/emit-error!directly on a runtime data branch (when-some/when (seq …)/doseq/ acatch), building(str …)or literal-string prose, with no call-siteinterop/debug-enabled?gate.STEP-0 finding (the load-bearing surprise): I rooted a representative site (routing
advise-query-promotion!—emit!+(str …):advice; machinesemit-destroy-exit-failure!—emit-error!+ literal string) in the:advancedprobe and grepped both builds. The prose is already elided in production:stays a STRING in the route sliceAn :exit action threw during destroy-time cascadeA directly-called
emit!/emit-error!folds its body tonilundergoog.DEBUG=false; Closure inlines the now-no-op call and drops the pure prose args as dead. The bead's stated root cause —emit!'s identity escaping into a late-bind registry — applies to the framework's own emit machinery (storage.cljc,registrar.cljc, which captureemit!via(late-bind/get-fn :trace/emit!)and are already gated), not to these direct-call sites.Per the bead's own STEP-0 escape hatch ("if it does NOT survive — already DCE'd — re-evaluate, do not blindly gate"), no mass-gating was applied — gating 18 already-elided sites would add redundant noise implying a leak that does not exist (ELEGANCE / CLARITY). Instead I closed the systemic probe gap the bead correctly identifies: the probe previously pinned dev-only prose absence only inside already-gated branches and via the require boundary — it never rooted an ungated direct-emit site, so the fold-path's production absence was unverified. Added two
DEV_ONLY_SENTINELS+ atouch-direct-emit-diagnostics!root so the control build exercises the path and a future regression (e.g. capturingemit!into a var, escaping its identity like the framework machinery) is caught.2.
:docmacro-DCE gap onreg-machineopts mapexpand-reg-machineforwarded itsopts-formverbatim, bypassinggate-doc-args— so a literal(reg-machine :id {:doc "…"} spec)left its:docstring bytes in the:advancedbundle (the splice-throughdefreg-macro/defreg-event-macrosurfaces gate every literal doc-bearing arg;reg-machinedid not). Fix: routeopts-formthroughgate-doc-argwhen it is a literal map (the idiomatic shape), emitting the same(if interop/debug-enabled? <full> <stripped>)gate Closure folds. A non-literal opts expression (symbol / computed map /merge) passes through unchanged — its:docstill strips from stored handler-meta via the runtimeregister!strip, but its bytes are outside the macro's reach.Pinned by: a new
DEV_ONLYsentinel + probe touch (rf2-tfiutq-machine-opts-doc-sentinel— prod absent, control present, confirmed); a JVM handler-meta-strip parity test in the machines artefact (re-frame.machine-doc-opts-prod-elision-test); a cross-reference note in the core doc-elision suite (the core:testclasspath lacksday8/re-frame2-machines, so the machine surface's semantic strip test lives in the machines artefact).3. Reachability sentinel for the late-bind directory
:descriptioncorpusre-frame.late-bind.directory/hookscarries ~150 paragraph-length:descriptionstrings — plain ungated CLJC data, kept out of production solely by reachability DCE (verified: zero production src namespace:requires the directory; only test files and one docstring mention it). No leak today, but no sentinel guarded that absence. Added aPROD_ABSENT_WHEN_UNUSED_SENTINELSentry (Enqueue an event for processing by the drain loop, the:router/dispatch!row's:description, unique across tracked source) mirroring the EP-0023 image-assembly reachability guard, so an accidental future production:requireis caught by CI. Pure test-guard addition — no source change.Gate results
npm run test:elision— PASS: production 45/45 absent (was 42), control 45/45 present, EP-0023 1/1 provenance-survives + 2/2 assembly-DCE.npm run test:cljs— 7999 tests / 36798 assertions, 0 failures, 0 errors.clojure -M:test) — 845 tests / 2743 assertions, 0 failures, 0 errors.Files changed
implementation/core/src/re_frame/core_reg_macros.cljc— routereg-machineliteral opts throughgate-doc-arg(only production-source change).implementation/scripts/check-elision.cjs— +2 direct-emitDEV_ONLYsentinels, +1 reg-machine opts-:docDEV_ONLYsentinel, +1 directory-corpusPROD_ABSENT_WHEN_UNUSEDsentinel.implementation/core/test/re_frame/elision_probe.cljs—touch-direct-emit-diagnostics!+ reg-machine literal-opts:doctouch.implementation/machines/test/re_frame/machine_doc_opts_prod_elision_test.clj— new JVM parity test for the reg-machine opts:docstrip.implementation/core/test/re_frame/doc_metadata_prod_elision_test.clj— cross-reference note pointing at the machines-artefact parity test.