Parc.RequestPreparer behaviour (parc v0.1.0)

Copy Markdown View Source

A preprocessing step in a Parc.Pipeline. A preparer reads a Parc.Request and either continues with a (possibly transformed) request or aborts the whole evaluation with an error. It runs before the decider and cannot decide; only Parc.PolicyDecider returns a verdict.

A preparer may add context facts, emit telemetry, validate inputs, or trace: anything that prepares (or observes) the request ahead of the decision. Steps run in declaration order; declare them with prepare (see Parc.Pipeline).

Return values:

  • {:cont, request}: continue with this request. Fail-soft belongs here. A preparer that cannot resolve a fact leaves the key absent and continues, so the decider denies on the missing fact.
  • {:error, reason}: abort, fail-hard. The preparer was unable to complete its security-required processing. The pipeline short-circuits, the decider is never consulted, and reason surfaces a genuine failure, distinct from a deny.

Summary

Types

result()

@type result() :: {:cont, Parc.Request.t()} | {:error, term()}

Callbacks

call(request, opts)

@callback call(request :: Parc.Request.t(), opts :: keyword()) :: result()