---
slug: "InvariantFilter"
name: "InvariantFilter"
type: "Protocols"
layer: "Society"
ref: "InvariantFilter#212b"
sema_id: "sema:InvariantFilter#mh:SHA-256:212b8b7a75ea69b22561e19191aa5cb630aaf75f4e4229e03db798338ab00a8e"
tags: ["Society","Protocols"]
updated: 2026-11-11
mindscape: "bootstrap"
index_url: https://mindscape.pages.dev/bootstrap/index.json
url: https://mindscape.pages.dev/bootstrap/InvariantFilter/
related: ["Message","RuleSet","Check","Stream"]
---

# InvariantFilter

Rule-based message filtering

Layer: Society · Category: Protocols

## Mechanism

A strict communication firewall that intercepts [Message](https://mindscape.pages.dev/bootstrap/Message.md)s (incoming or outgoing) and evaluates them against an explicit set of [RuleSet](https://mindscape.pages.dev/bootstrap/RuleSet.md) (Invariants). If a [Message](https://mindscape.pages.dev/bootstrap/Message.md) satisfies all predicates, it is permitted to pass. If it fails even one, it is blocked, dropped, or flagged for review. This enforces 'Contractual Safety' on the communication channel. It inspects every [Message](https://mindscape.pages.dev/bootstrap/Message.md) via a rigorous [Check](https://mindscape.pages.dev/bootstrap/Check.md) against defined predicates before allowing transit.

## Invariants

- Atomic Blocking: If Predicate(M) is False, M is NOT forwarded.
- Fail-Closed: If evaluation errors (e.g. timeout), default to BLOCK.
- Isolation: The protected agent state is not mutated by evaluation.

## Preconditions

- A defined Invariant Set (Predicates)
- A [Message](https://mindscape.pages.dev/bootstrap/Message.md) or [Stream](https://mindscape.pages.dev/bootstrap/Stream.md) to evaluate

## Postconditions

- Only compliant messages reach the destination
- Blocked messages are logged (optional)

## Failure modes

- Incomplete Invariants: If the filter does not catch a specific edge case, bad data leaks through.
- False Positives: Overly strict invariants blocking legitimate messages.
- Latency: Complex predicate evaluation slowing down high-throughput streams.

## Parameters

- `action_on_fail` (Enum, [DROP, REJECT, FLAG]): What happens when a message violates a predicate

## Builds on

- [Message](https://mindscape.pages.dev/bootstrap/Message.md) (Infrastructure; Accepts)
- [RuleSet](https://mindscape.pages.dev/bootstrap/RuleSet.md) (Infrastructure; Accepts)
- [Check](https://mindscape.pages.dev/bootstrap/Check.md) (Infrastructure; References)
- [Stream](https://mindscape.pages.dev/bootstrap/Stream.md) (Infrastructure; References)

## Used by

—

## Identity

- Sema ID: `sema:InvariantFilter#mh:SHA-256:212b8b7a75ea69b22561e19191aa5cb630aaf75f4e4229e03db798338ab00a8e`
- Ref: `InvariantFilter#212b`
- Supersedes:
  - `sema:InvariantFilter#mh:SHA-256:a541049098acbba01ebe35ee9c23ebbdaf9d34e252b1b69f97daa87b3e96eea2`
  - `sema:InvariantFilter#mh:SHA-256:cc3794d06d91be2bd2371c18fcdddc379e5001aa4864f6f3fea1fb3b037bd2b2`
  - `sema:InvariantFilter#mh:SHA-256:5e4da90216dd412c9acc3258da818ffe31965d54ba79cbd966a193563e9c2329`

## Links

- [Pattern page](https://mindscape.pages.dev/bootstrap/InvariantFilter/)
- [View in the interactive graph](https://mindscape.pages.dev/bootstrap/#InvariantFilter)
- [JSON](https://mindscape.pages.dev/bootstrap/InvariantFilter.json)
- [Index of all patterns](https://mindscape.pages.dev/bootstrap/index.json)
