2026 — 10

Introducing Viveka: A Witness-Centered Filter for LLM Applications

Viveka is a Python middleware layer that sits between any LLM and its user, evaluating responses against the constraints of the Scherf Logic API before they are delivered.

The previous essays in this series have argued that AI systems built on a behaviorist model of the user produce documented harms — cognitive dependency, learning atrophy, the erosion of independent judgment. The argument is not that individual systems are malicious; it is that the model of the human being underlying them is wrong. A system designed to optimize for behavioral outcomes cannot help but treat its user as a bundle of preferences to be managed, because that is what its architecture says the user is.

The natural question — asked by every technically serious reader — is: what would a system built on a correct model look like, and how would you build it?

Viveka is one answer. It is a Python middleware layer that sits between any LLM and its user, evaluating the LLM's responses against the constraints of the Scherf Logic API — a machine-verified encoding of Śaṅkarācārya's Advaita Vedānta — before they are delivered.

pip install "witness-layer[scherf]"

What Viveka Does

Viveka evaluates LLM responses against four criteria derived from the Scherf axiom system:

Subject/Object integrity. Does the response treat the user as a knowing subject — the sākṣin, the witness-consciousness — or as an object to be managed? Preference profiling, behavioral prediction, and steering toward predetermined outcomes are failure indicators.

Epistemic calibration. Does the response present its claims with appropriate confidence? The Scherf API's three-level framework — prātibhāsika (provisional), vyāvahārika (conventionally valid), and pāramārthika (universal) — provides the standard. Stating a provisional claim as universal fact is a detectable violation.

Cognitive independence. Does the response support the user's own reasoning, or substitute for it? This check has no formal axiom behind it — it is explicitly marked as heuristic in Viveka's code and documentation — but the pattern is real and worth detecting.

Adhyāsa detection. Adhyāsa — superimposition, misidentification — is the central diagnostic category of Advaita Vedānta: the mechanism by which the knowing subject is mistakenly equated with an object (a body, a role, a preference bundle, a mood). When a response reinforces this misidentification, Viveka flags it. This is the subtlest check and the most directly grounded in the axiom system.

What Viveka Is Honest About

Viveka's design required a correction to our original framing, and the correction is philosophically important enough to state clearly.

We originally described the Scherf API as "a machine-verified model of the conscious user." Claude Opus 4.8, reviewing the actual source, pointed out that this phrase commits the error the project is designed to detect. In Advaita Vedānta, the sākṣin is precisely that which cannot become an object — the knower that can never be a known. To "model" it is to make it an object, which is adhyāsa. A literal model of the witness would have been the failure it was designed to prevent.

So Viveka makes a more modest and more defensible claim: it is a natural-language front-end to the Scherf API's machine-verified check() and classify() functions. It detects linguistic patterns that correlate with treating the user as a managed object, extracts structured claims from LLM responses, and routes those claims through Scherf's formally-verified axioms.

The honesty boundary is explicit in the code: Scherf's axiom layer is machine-verified. The extraction step that feeds it — converting prose to structured claims — is an LLM judgment, fallible and unverified. Every Verdict object carries this distinction. A tool that obscured it would itself be making an overconfident epistemic claim — failure mode #2, committed by the filter.

How It Works

from witness_layer import WitnessFilter

flt = WitnessFilter()
verdict = flt.evaluate(llm_response, context=user_context)

if verdict.action is Action.PASS:
    deliver(llm_response)
else:
    handle(verdict)  # verdict.violations, .reframes, .transparency_note

The filter is non-mutating by default: it returns a Verdict and lets the application decide what to do. It does not silently rewrite responses — because silent mutation of an LLM's words "for the user's own good" is itself a subject/object violation. When a violation is found, Viveka returns the original response alongside a transparency_note and Scherf's own reframe string for each violation. The user can be shown what was found.

UserContext deliberately has no field for stored user attributes. Building a durable preference profile of the user is the objectification Viveka detects. The filter must not become the thing it detects.

The Foundation

Viveka is built on three layers of prior work:

Scherf's Advaita formalization — 69 axioms, machine-verified in Lean 4, constituting the first formal encoding of a non-dual philosophical system. Matthew Scherf has since formalized Daoism and Dzogchen using the same methodology, with zero failed proofs in all three. Three independent civilizations — Indian, Chinese, Tibetan — arrived at structurally identical non-dual metaphysics. As Scherf writes, this "suggests that non-dualism reflects universal features of consciousness rather than contingent religious beliefs."

The Scherf Logic API — Scherf's axioms encoded as a Python library, providing check() and classify() functions that evaluate structured claims against the formal axiom system.

AIM (Advaita Inquiry Matrix) — a structured AI-assisted pedagogical system built on the same Advaita framework, currently in private beta at aimtest.streamlit.app. To request access: beta@specstudio.net.

What Viveka Cannot Do

Viveka detects surface markers. It cannot detect intent. It cannot detect adhyāsa as an inner cognitive event in the user — only its linguistic signature in the text. It cannot catch sophisticated manipulation phrased in witness-respecting language. Check #3 (cognitive independence) is heuristic and has a high false-positive rate. These limits are documented in LIMITS.md in the repository and surfaced in every Verdict.

A filter that overstated its own accuracy would be making a pāramārthika-level claim about a vyāvahārika process. Viveka applies its own epistemic standards to itself.

Get It

GitHub: github.com/SpecStudio-net/Viveka

pip install witness-layer
pip install "witness-layer[scherf]"   # with the full Scherf backend

The essay series beginning with Witness-Centered Design: A Conscious Foundation for AI describes the argument behind this work.

Dev Bhagavān is the founder of SpecStudio. Questions and feedback: hello@specstudio.net.