Skip to content

Policy

How Jane turns events into decisions — cleanly, predictably, and without magic.

Policy is the decision‑making layer of Jane. It doesn’t validate, parse, normalize, or scan. It doesn’t touch values. It doesn’t mutate anything.

Policy looks at the events produced by the pipeline and decides what they mean. This is the layer that answers the question: "Given everything that happened, is this input acceptable?"

Policy is intentionally simple, explicit, and predictable.

It’s the part of Jane that lets you tune strictness without rewriting validators or changing your pipeline.

Why Policy Exists

Most validation libraries hard‑code their behavior:

  • Some errors are fatal.
  • Some warnings are ignored.
  • Some issues are treated inconsistently.
  • Some rules behave differently depending on context.

This leads to brittle systems where you can’t adjust strictness without rewriting code. Jane solves this by separating what happened (events) from what it means (policy).

Validators emit events. Policy interprets them. This separation is one of the reasons Jane feels predictable and safe.

What Policy Does

Policy controls four things:

  1. Mode

    The pipeline mode affects normalization and parsing behavior:

    • strict → no normalization, scan enabled, escalations
    • moderate → non‑lossy normalization, no scan
    • lax → full normalization, severity downgrades

    Mode is the personality of the pipeline.

  2. Severity transforms

    Policy can shift event severity up or down:

    • Override: error → warn, warn → info
    • Escalate: warn → error, error → fatal

    This lets you tune strictness without touching validators.

  3. Reject / Review patterns

    Policy can declare certain event codes as:

    • reject → automatic failure
    • review → requires human review

    These patterns use wildcards, so you can match entire categories:

    reject: ["number.*", "string.has.*"]

  4. Analysis toggles

Policy controls whether the pipeline produces:

  • Diff.
  • Explain.
  • Replay.
  • Telemetry.

These are optional and lazy. They don’t affect the decision.

What Policy Never Does

Policy is intentionally limited. It does not:

  • Validate
  • Parse
  • Normalize
  • Scan
  • Mutate values
  • Change events
  • Rewrite event codes
  • Coerce types

Policy only interprets events. It never changes what happened: Only what it means.

Default, Lax, and Strict Policies

Jane ships with three built‑in policies:

  • Default (moderate): Balanced, predictable, and safe.
  • No escalations.
  • No overrides.
  • No scan.
  • Lax: Developer‑friendly, forgiving, and permissive.
  • Downgrades severity
  • Allows bigint.
  • No scan.
  • Rejects nothing by default.
  • Great for prototyping or user‑facing forms.
  • Strict: Maximum scrutiny.
  • Scan enabled.
  • Escalates warnings.
  • Rejects many structural issues.
  • Enables all analysis features.
  • Great for compliance, auditing, and backend boundaries.

How Policy Affects Decisions

Policy looks at all events and determines:

  • Accept
  • Review
  • Reject

The logic is intentionally simple:

  • If any event is fatal → reject.
  • If any event matches a reject pattern → reject.
  • If any event matches a review pattern → review.
  • Otherwise → accept

Severity transforms happen before this step. This keeps the decision model clean and predictable.

Policy Overrides

You can override policy at the pipeline level:

jane(value)
  .strict()
  .withPolicy(customPolicy)
  .run();

At the boundary level you can:

  • Ignore events
  • Hide events
  • Override severity
  • Escalate severity
  • Change accept modes
  • Apply a reducer

Boundary‑level policy is the final authority.

Why Policy Matters

Policy is the layer that makes Jane adaptable:

  • strict for backend boundaries.
  • moderate for internal services.
  • lax for user‑facing forms.
  • custom for compliance or auditing.
  • Boundary‑level shaping for complex objects.

It lets you tune strictness without rewriting validators or changing your pipeline.