Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 48 additions & 13 deletions implementation/core/src/re_frame/classification.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -445,16 +445,43 @@
`re-frame.resources` facade; core stays decoupled — the event peer of the
`:http/project-managed-fx-args` seam). Hook unbound (resources artefact
absent) ⇒ pass-through: without the artefact the event has no handler at
all, the documented fail-open. Identity-preserving when nothing applies."
[event]
all, the documented fail-open. `frame-id` reaches the payload's `:reply-to`
address, which may name a spawned actor. Identity-preserving when nothing
applies."
[event frame-id]
(if-let [project (rf.late-bind/get-fn :resources/project-execute-event-args)]
(if (>= (count event) 2)
(let [payload (nth event 1)
payload' (project payload)]
payload' (project payload frame-id)]
(if (identical? payload payload') event (assoc event 1 payload')))
event)
event))

(defn- project-reply-event-args
"Per-ARG DYNAMIC projection for a continuation reply map riding its
`:reply-to` target event, which `re-frame.reply/complete` appends as the
event's last argument. The reply's classification lives on the OWNER its
work ran for, named inside the reply, not on the target event's
registration, so the static registration layer cannot express it. Each
argument carrying `:rf.reply/work-kind` defers to the late-bound
`:resources/project-reply-event-arg` hook (published by `re-frame.resources`;
core stays decoupled), which resolves the owner in `frame-id`'s view. Hook
unbound ⇒ pass-through. Identity-preserving when nothing applies.
Spec 015 §Subsystem projection-relative classification."
[event frame-id]
(if-let [project (and (vector? event)
(> (count event) 1)
(rf.late-bind/get-fn :resources/project-reply-event-arg))]
(reduce (fn [event' i]
(let [arg (nth event' i)]
(if (and (map? arg) (contains? arg :rf.reply/work-kind))
(let [arg' (project arg frame-id)]
(if (identical? arg arg') event' (assoc event' i arg')))
event')))
event
(range 1 (count event)))
event))

(defn- project-navigation-event-arg
"Per-event-id DYNAMIC projection for a routing navigation event vector —
`[:rf.route/handle-url-change url …]` and `[:rf.route/navigate {request}]`.
Expand Down Expand Up @@ -536,13 +563,19 @@
on the ROUTE it names, so the
routing-published `:routing/project-url-change-event-args` hook projects
it (`project-navigation-event-arg`). Unbound ⇒ pass-through.
3. Per-argument DYNAMIC classification: a resource or mutation continuation
reply riding its `:reply-to` target event takes its OWNER's declaration,
through the resources-published `:resources/project-reply-event-arg` hook
(`project-reply-event-args`). Unbound ⇒ pass-through.

A spawn-error event — inner or routed to its parent — has its child-owned
payload summarized whatever the parent declares (`project-spawn-error-event`).

With `frame-id`, an event addressed to a spawned machine actor in that frame
takes its machine type's registration classification (`event-classification`);
without one, only `(first event)`'s own registration applies.
takes its machine type's registration classification (`event-classification`),
and every owner the dynamic layers name resolves in that frame's view; without
one, only `(first event)`'s own registration applies and owners resolve in the
ambient view.

A no-op when `event` is not a `[event-id arg-map …]` vector or nothing
applies.
Expand All @@ -563,12 +596,13 @@
(let [[sens large] (classification-paths class)]
(redact-event-vec event sens large))
event)
event' (project-spawn-error-event event')]
(case (when (vector? event') (first event'))
:rf.mutation/execute (project-execute-event-payload event')
(:rf.route/handle-url-change
:rf.route/navigate) (project-navigation-event-arg event')
event'))))
event' (project-spawn-error-event event')
event' (case (when (vector? event') (first event'))
:rf.mutation/execute (project-execute-event-payload event' frame-id)
(:rf.route/handle-url-change
:rf.route/navigate) (project-navigation-event-arg event')
event')]
(project-reply-event-args event' frame-id))))

(defn- project-event-tags
"Walk `:rf.event/dispatched` / `:rf.event/db-changed` / `:rf.fx/do-fx` tag
Expand Down Expand Up @@ -635,7 +669,8 @@
not a bug this closes).

`frame-id` is the frame the trace belongs to, which a `:dispatch` /
`:dispatch-later` target addressed to a spawned actor resolves its type in."
`:dispatch-later` target or a managed request's reply address addressed to
a spawned actor resolves its type in."
[fx-id args frame-id]
(let [args (if-let [class (classification-when :fx fx-id)]
(redact-by-classification args class)
Expand All @@ -644,7 +679,7 @@
:dispatch (redact-event-by-registration args frame-id)
:dispatch-later (project-dispatch-later-args args frame-id)
:rf.http/managed (if-let [project (rf.late-bind/get-fn :http/project-managed-fx-args)]
(project args)
(project args frame-id)
args)
args)))

Expand Down
9 changes: 6 additions & 3 deletions implementation/core/src/re_frame/late_bind/directory.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
:description "Emit-time chokepoint for trace bus — walks the assembled trace event's tags and substitutes sentinels at declared paths (Spec 015 §Egress projection). EP-0025: no value-match, no propagation — path-based redaction only."}
{:key :classification/redact-event-by-registration
:producer-ns 're-frame.classification
:description "ALWAYS-ON (NOT a DCE seam — the registration classification is populated in production too; only the emit-time TRACE projection is dev-gated): apply an event handler's REGISTRATION-OWNED :sensitive / :large classification to a [event-id arg-map] vector (EP-0015 — event args are registration-owned transient payloads). Consumed by re-frame.projection/project-event-slot — the one event projection the frame-owned sink route and the always-on re-frame.event-emit / re-frame.error-emit records share — and by the router's halted-epoch record, the managed-HTTP reply addresses (re-frame.http.privacy) and a mutation's :reply-to address (re-frame.resources.classification)."}
:description "ALWAYS-ON (NOT a DCE seam — the registration classification is populated in production too; only the emit-time TRACE projection is dev-gated): apply an event handler's REGISTRATION-OWNED :sensitive / :large classification to a [event-id arg-map] vector (EP-0015 — event args are registration-owned transient payloads), `(fn [event])` or `(fn [event frame-id])`: with the frame, an event addressed to a spawned machine actor takes its machine type's classification and every owner the dynamic arms name resolves in that frame's view. Consumed by re-frame.projection/project-event-slot — the one event projection the frame-owned sink route and the always-on re-frame.event-emit / re-frame.error-emit records share — and by the router's halted-epoch record, the managed-HTTP reply addresses (re-frame.http.privacy) and a mutation's :reply-to address (re-frame.resources.classification)."}

;; ---- re-frame.flows -------------------------------------------------------
{:key :flows/reg-flow
Expand Down Expand Up @@ -447,7 +447,10 @@
:description "OFF-BOX trace egress projector for the FX-ARGS tag slots (:rf.fx/args, :rf.event/fx) of ANY trace row — the SLOT-reached companion to :resources/project-resource-trace-egress, which is reached by OPERATION NAMESPACE and therefore never saw them. Resource events lower into effects that carry the family's data — a timer effect addresses an entry BY its scoped key ([:rf.resource/schedule-timers {:resource/key … :timers …}]), a mutation's transport payload carries its resolved :scope, and a read's :reply-to continuation carries its key, scope, params and value — and re-frame.fx stamps that payload verbatim under :rf.fx/args (on :rf.fx/handled, :rf.fx/skipped-on-platform and the always-on :rf.error/* fx-failure traces) plus the whole effect vector under :rf.event/fx — so without this projector a :sensitive? owner's resolved scope + canonical params would egress RAW on rows the resource family does not own, while the SAME payload's structured :effects[*].args slot reads :rf/redacted (a two-carrier shape). Given a row's :tags + the frame-id, walks the two slots by SHAPE and projects every embedded scoped key through the SAME resource OWNER classification the family rows' own :resource/key takes (:sensitive?/:large?/unregistered tokenizes scope+params to an opaque content-addressed {:rf/redacted <digest>}; a PLAIN owner rides verbatim, so attribution and per-key joins survive), stamping :sensitive? when a key redacted. Every OTHER tag on the row rides untouched whatever its shape — the row belongs to the fx family and this projector speaks only for the keys inside it. A tags map carrying neither slot rides through reference-preserved, so the epoch tool-pair (omit-off-box-fx-args-resource-keys) applies it to every row with no row predicate to keep in step with the emit sites. Gated on the off-box :rf.egress/include-sensitive? default (the trusted-local opt-in lifts it); no-op / nil when no resources artefact is loaded. Per Spec 015 §10 / Derivations §Tool redaction."}
{:key :resources/project-execute-event-args
:producer-ns 're-frame.resources
:description "Redact a [:rf.mutation/execute …] event's ARGS MAP per the mutation OWNER's projection-relative :sensitive / :large declaration (the SAME declaration surface the durable instance + continuation reply read): a :params-rooted decl redacts args [:params …], a :scope-rooted decl the sibling :scope; :data-rooted decls name the not-yet-existing RESULT projection and are skipped; a payload-carrying :reply-to address additionally rides its TARGET event registration's own classification (via :classification/redact-event-by-registration). Consulted by the core event-vector projection chokepoint (re-frame.classification/redact-event-by-registration) for every event-bearing trace slot (:rf.event/v, the bare :event error slot, the always-on :rf.observe/* records, the :dispatch / :dispatch-later fx-arg recursion) — the event peer of :http/project-managed-fx-args. Unbound (resources absent) ⇒ pass-through: without the artefact the event has no handler at all, the documented fail-open."}
:description "`(fn [args frame-id])` — redact a [:rf.mutation/execute …] event's ARGS MAP per the mutation OWNER's projection-relative :sensitive / :large declaration (the SAME declaration surface the durable instance + continuation reply read): a :params-rooted decl redacts args [:params …], a :scope-rooted decl the sibling :scope; :data-rooted decls name the not-yet-existing RESULT projection and are skipped; a payload-carrying :reply-to address additionally rides its TARGET event registration's own classification (via :classification/redact-event-by-registration, in frame-id, so a target addressed to a spawned actor takes its machine type's). Consulted by the core event-vector projection chokepoint (re-frame.classification/redact-event-by-registration) for every event-bearing trace slot (:rf.event/v, the bare :event error slot, the always-on :rf.observe/* records, the :dispatch / :dispatch-later fx-arg recursion) — the event peer of :http/project-managed-fx-args. Unbound (resources absent) ⇒ pass-through: without the artefact the event has no handler at all, the documented fail-open."}
{:key :resources/project-reply-event-arg
:producer-ns 're-frame.resources
:description "`(fn [arg frame-id])` — project one argument of an event vector when it is a resource or mutation continuation reply (a map whose :rf.reply/work-kind is :resource or :mutation) riding its :reply-to target event, which re-frame.reply/complete appends as the event's last argument: :params and :value tokenize when the reply's OWNER makes the coarse :sensitive? / :large? claim or is unregistered, and otherwise the owner's projection-relative :sensitive / :large declarations substitute (the same arms the reply's FX carrier takes under :resources/project-fx-args-egress); :error tokenizes unconditionally. The owner resolves in frame-id's registration view. Any other argument rides, identical when nothing applies. Consulted by the core event-vector projection chokepoint (re-frame.classification/redact-event-by-registration) for every event-bearing trace slot (:rf.event/v, the bare :event error slot, the always-on :rf.observe/* records, the epoch :trigger-event, the :dispatch / :dispatch-later fx-arg recursion); the app's own :reply-to handler still receives the raw reply. Unbound (resources absent) ⇒ pass-through: without the artefact no such reply exists."}
{:key :resources/project-resource-sub-egress
:producer-ns 're-frame.resources
:description "Project a resource or mutation read sub's value for egress — `(fn [query-v value opts]) -> projected-value`, where `opts` carries `:frame` — redacting the slots the OWNER's projection-relative :sensitive / :large declaration names (a coarse :sensitive? / :large? resource claim covering the whole data projection), re-rooted onto the sub's value: the entry's data under :data / :previous-data / :items / :pages or the whole value, a mutation instance's result under :result or the whole value, and the scoped keys the value carries (:previous-key, :affected-keys) by the same owner projection the family's trace rows use. The query vector names the owner: a resource sub's payload names its :resource, and a mutation sub's :instance is looked up in the frame's runtime-db. A five-argument arity `(fn [query-v value opts prior-inputs prior-policy])` projects a PRIOR value (:rf.sub/prev-value): `prior-inputs` are the inputs it was computed from, which carry a cleared mutation instance the live runtime-db no longer holds, and `prior-policy` is the classification policy it was computed under, whose claims on those inputs are unioned in. The declaration is read from the owner spec, not the live instances, so a prior value stays redacted after an evict or a clear removes the instance. A no-op pass-through for any other sub. Consumed by the trace chokepoint re-frame.classification/project-sub-tags for the :rf.sub/run :rf.sub/value / :rf.sub/prev-value slots. Unbound (resources absent) ⇒ pass-through: without the artefact these subs are not registered."}
Expand Down Expand Up @@ -508,7 +511,7 @@
:description "Register the machine-shape wrapper for managed HTTP requests."}
{:key :http/project-managed-fx-args
:producer-ns 're-frame.http.managed
:description "Redact a :rf.http/managed fx args map for the generic fx-arg-bearing trace slots (the :rf.event/fx aggregate on :rf.fx/do-fx + every [:rf.fx/id :rf.fx/args]-shaped slot). Honours the DYNAMIC per-call :sensitive? flag + the carrier denylists the dedicated :rf.http/* trace composers apply — a static registration :sensitive path cannot express them. Consumed by re-frame.classification/project-fx-args; unbound (http artefact absent) the entry passes through, matching the unregistered-fx fail-open."}
:description "`(fn [args frame-id])` — redact a :rf.http/managed fx args map for the generic fx-arg-bearing trace slots (the :rf.event/fx aggregate on :rf.fx/do-fx + every [:rf.fx/id :rf.fx/args]-shaped slot). Honours the DYNAMIC per-call :sensitive? flag + the carrier denylists the dedicated :rf.http/* trace composers apply — a static registration :sensitive path cannot express them — and redacts each reply address by its target event's classification in frame-id, so an address to a spawned actor takes its machine type's. Consumed by re-frame.classification/project-fx-args; unbound (http artefact absent) the entry passes through, matching the unregistered-fx fail-open."}

;; ---- re-frame.ssr ---------------------------------------------------------
{:key :ssr/current-hiccup-emitter
Expand Down
8 changes: 6 additions & 2 deletions implementation/core/src/re_frame/projection.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@
— would resolve the declaration in whatever universe happened to be bound
and ship a declared-sensitive payload RAW.

The owner is also handed to the hook, so an event addressed to a spawned
machine actor takes its machine type's classification and a continuation
reply's owner resolves in that same frame.

An explicit `nil` owner binds nothing: the ambient resolution is unchanged
and the subsequent frame-policy `walk-slot` still fails closed on the whole
slot. The seam is late-bound (`:live-frame/call-with-frame-resolution`) —
Expand All @@ -308,8 +312,8 @@
with-owner (when (some? owner)
(rf.late-bind/get-fn :live-frame/call-with-frame-resolution))]
(if with-owner
(with-owner owner #(redact event))
(redact event)))
(with-owner owner #(redact event owner))
(redact event owner)))
event))

(defn project-event-slot
Expand Down
4 changes: 2 additions & 2 deletions implementation/core/src/re_frame/router.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@
:classification/redact-event-by-registration)
trigger (if redact
(rf.live-frame/call-with-frame-resolution
frame-id #(redact halting-event))
frame-id #(redact halting-event frame-id))
halting-event)]
(commit-halt! frame-id fs-now halting-time-ms :halted-depth
halt-reason trigger)))))
Expand Down Expand Up @@ -1526,7 +1526,7 @@
redact (rf.late-bind/get-fn
:classification/redact-event-by-registration)]
(if (and redact event)
(rf.live-frame/call-with-frame-resolution frame-id #(redact event))
(rf.live-frame/call-with-frame-resolution frame-id #(redact event frame-id))
event)))

(defn- halt-at-pending-destroy!
Expand Down
Loading
Loading