Help us improve
Share bugs, ideas, or general feedback.
Share bugs, ideas, or general feedback.
Share bugs, ideas, or general feedback.
By pyrex41
Enforce formal backpressure in AI coding by generating compile-time guard types from Shen sequent-calculus specifications, then running a verification loop that catches invariant violations during build and tests handwritten implementations against formal specs.
npx claudepluginhub pyrex41/shen-backpressure --plugin sbBuild a shengen codegen tool that compiles Shen sequent-calculus specs into guard types for any target language. Provides the complete algorithm, grammar, symbol table schema, accessor resolution rules, and per-language enforcement strategies. Use when bootstrapping shengen for a new target language (Go, Rust, Python, TypeScript, Java, etc.) or when extending an existing shengen to support new Shen patterns.
Configure and run the optional shen-derive spec-equivalence gate. Use when the project has Shen `(define ...)` functions that should act as an oracle for handwritten Go implementations, or when `sb.toml` already contains `[[derive.specs]]` entries and the user wants to run, regenerate, or debug the derive gate.
Show all Shen Backpressure commands, what they do, and when to use each one.
Add Shen backpressure to any project. Generates formal type specs from domain description, builds shengen, produces guard types in your target language, sets up verification gates. Works with any workflow — Ralph loops, CI pipelines, manual dev, or custom orchestrators.
Configure and launch a Ralph loop — a headless LLM harness in a bash loop with Shen backpressure, using the core five gates plus optional shen-derive verification when configured. Requires /sb:init first.
Runs pre-commands
Contains inline bash commands via ! syntax
Bash prerequisite issue
Uses bash pre-commands but Bash not in allowed tools
Share bugs, ideas, or general feedback.
Own this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge.
Sign in to claimOwn this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge.
Sign in to claimBased on adoption, maintenance, documentation, and repository signals. Not a security audit or endorsement.
Verified Coherence Spec-Driven Development — adversarial quality gates for AI-assisted development
Specification-first AI harness: 11 structural gates, 11 Ouroboros commands, 11 agent personas, and 3-tier architecture enforcement. v2.1: Pair Mode (Navigator-Driver + independent test design + /review command).
Verify code, architecture, and bug fixes through factored multi-agent verification
Enforce mandatory pre-action verification checkpoints to prevent pattern-matching from overriding explicit reasoning. Use this skill when about to execute implementation actions (Bash, Write, Edit) to verify hypothesis-action alignment. Blocks execution when hypothesis unverified or action targets different system than hypothesis identified. Critical for preventing cognitive dissonance where correct diagnosis leads to wrong implementation.
Verifiable AI-Augmented Engineering framework with traceable requirements, independent verification, and compliance-ready artifacts
Evidence-driven development pipeline with multi-model code review
Formal verification gates for AI coding loops, in the language you're already using.
AI coding loops use tests as the only gate. Tests are empirical: they check the cases you remembered to write. Specs are deductive: they hold for every case the type system can construct. An LLM that produces code which slips past your tests but contradicts an invariant has produced a regression that won't surface until production.
Shen-Backpressure adds spec-level gates to the loop. The agent must pass the structural check (your invariants compile) and the behavioral check (your pure functions match a spec on sampled inputs) on top of the regular tests and build. When a gate fails, the failure feeds back into the next prompt as backpressure.
You write a Shen sequent-calculus spec describing your domain's
invariants and pure functions. The spec lives in your repo as
specs/core.shen and is the human-edited source of truth.
shengen lowers the spec into opaque guard types in your target
language. Today: Go and TypeScript are production-wired through
sb gen; Python and Rust exist as reference emitters. The guard
types have unexported fields and validated constructors, so the
language compiler enforces every invariant the spec declares.
shen-derive turns (define …) spec blocks into table-driven tests
that pin a hand-written implementation against the spec on sampled
inputs.
Production ships your normal target-language binary. Shen runs at
build time, not at runtime — but the two guarantees are different in
kind. Structural guarantees (shen-guard) are compile-time: the
target-language compiler rejects any Amount that wasn't built
through NewAmount. Behavioral evidence (shen-derive) is
sampled: a deterministic boundary pool plus optional seeded random
draws asserts pointwise equality between the spec and the impl. The
former is a proof-for-all-inputs; the latter is high-confidence
evidence on a designed sample.
Every iteration of the Ralph loop must pass all five gates (plus a
sixth when shen-derive is configured):
| Gate | Command | What it catches |
|---|---|---|
| 1. shengen | sb gen | Regenerates guard types from spec. Catches stale types. |
| 2. test | go test ./... (or npm test) | Tests against regenerated types. Catches runtime invariant violations. |
| 3. build | go build ./... (or npx tsc --noEmit) | Compiles against regenerated types. Catches type signature mismatches. |
| 4. shen tc+ | bin/shen-check.sh | Verifies spec internal consistency. Catches contradictory rules. |
| 5. tcb audit | bin/shenguard-audit.sh | Re-runs shengen, diffs output, rejects unexpected files in shenguard/. |
| 6. shen-derive | sb derive | Regenerates committed spec-equivalence tests, fails on drift, then runs them. Active when [[derive.specs]] is configured. |
Gate topology is declared in sb.toml. The legacy fixed five-gate
shape still works; the new [[gates]] array of tables lets you
declare a custom gate list with optional parallel groups.
Every successful gate run also writes .sb/discharge_report.json, a
structured artifact that distinguishes how each premise of each Shen
rule was discharged: statically by the guard types, by runtime
sampling against the Shen oracle, or unproven. Failed premises ship
with concrete counter-examples — case ID, spec output, impl output,
and a ready-to-paste go test -run … reproduction command.
The artifact is dual-purpose:
sb context injects a five-second
Markdown summary into the harness prompt. Failed cases steer the
next iteration without scraping log output.sb audit-report renders a
long-form Markdown document a security reviewer or compliance
auditor can read end-to-end without prior knowledge of
Shen-Backpressure: spec hash, git commit, tool versions, per-rule
premise tables, history, and a "How to read this report"
appendix.The schema is locked at schema_version: 1
(design memo)
and time-stamped copies accumulate under .sb/history/ so claims
like "this invariant has been verified at every commit since X" have
evidence on disk, not memory.
What this does not mean: not signed, not third-party verified,
not SOC-2 certified. The artifact is the foundation that audit and
compliance workflows can build on — not certification itself. The
schema reserves room for signature fields; v0 always emits
signature: null.
# In your project (sb binary on $PATH)
sb init # scaffold specs/core.shen, sb.toml, prompts/, plans/
# and install /sb:* commands into .claude/
sb loop # run the Ralph loop