Sponsio
CLAUDE.md440 starsChanged 7 months agoApache-2.0View on GitHub
This file is for LLM coding agents and repo-reading assistants. It is meant to help you answer questions about Sponsio accurately and make code changes without breaking the architecture. Sponsio is a runtime contract layer for LLM apps and agents. Its core job is pre-execution enforcement for LLM tool/action behavior: before a model-driven system calls a tool, edits a file, hits an API, writes to a database, issues a refund, approves a loan, or triggers any side effect, Sponsio checks…
- Installs packages
In this repository2 other files it gives its agents.
- llms-full.txtllms.txt
- llms.txtllms.txt
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
16 rules. About 0 are common, 5 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 24
When explaining Sponsio, emphasize:
- Very specific: line 31
Do not describe Sponsio as only an output assertion library, only a prompt guardrail, or primarily a drift/reliability scoring framework.
- Very specific: line 152
Add a factory to sponsio/patterns/library.py.
- Very specific: line 153
If it needs a new observable, add atom extraction in sponsio/tracer/grounding.py.
- Very specific: line 154
Add DSL parsing in sponsio/generation/dsl_to_contract.py.
- Distinctive: line 155
Add tests for pattern behavior and NL parsing.
- Distinctive: line 156
Update README/docs if the pattern is public.
- Distinctive: line 157
Check TypeScript parity if the pattern belongs in the TS det core.
- Very specific: line 163
Only implement framework interception/wrapping.
- Very specific: line 165
Add optional dependencies in pyproject.toml.
- Very specific: line 166
Add examples/tests/docs.
- Very specific: line 171
Prefer the framework-specific factory for new examples — e.g.
- Distinctive: line 173
Do not claim OTEL ingestion can block actions.
- Very specific: line 174
Do not claim prompt engineering is unnecessary.
- Distinctive: line 175
Do not invent benchmark numbers.
- Very specific: line 176
Do not rely on internal files such as STATUS.md or PLAN.md.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent Guide for Sponsio
This file is for LLM coding agents and repo-reading assistants. It is meant to help you answer questions about Sponsio accurately and make code changes without breaking the architecture.
What Sponsio Is
Sponsio is a runtime contract layer for LLM apps and agents.
Its core job is pre-execution enforcement for LLM tool/action behavior: before a model-driven system calls a tool, edits a file, hits an API, writes to a database, issues a refund, approves a loan, or triggers any side effect, Sponsio checks the current trace against contracts.
The main public entrypoint is:
import sponsio
guard = sponsio.Sponsio(...)Sponsio ships only deterministic contracts: pure-Python checks over the trace, with no LLM in the runtime hot path. Patterns covering syntactic PII / response length / response keyword bans (no_pii, max_length, no_keywords) are regex-against-llm_said and need no judge.
Positioning
When explaining Sponsio, emphasize:
- Action-boundary enforcement: Sponsio checks tool/action calls before side effects happen.
- Temporal trace contracts: Rules can express ordering and history, such as "A before B", "never B after A", "at most N calls", or "after AML check, loan files are immutable".
- Deterministic hot path: Det checks are pure Python and do not call an LLM at runtime.
- Framework optionality: Users do not need an agent framework. Custom function-calling loops can use
guard.guard_before()/guard.guard_after()directly.
Do not describe Sponsio as only an output assertion library, only a prompt guardrail, or primarily a drift/reliability scoring framework. A concise distinction:
Sponsio focuses on the action boundary: checking tool calls before they execute, not only auditing outputs after the fact.
What To Read First
For product-level questions:
README.md— public positioning, quick start, demos, benchmarksQUICKSTART.md— install and first integration (repo root)docs/reference/cli.md—sponsio scan,validate,check,demo,reportdocs/integrations/index.md— framework-specific wiring
For architecture and contract questions:
docs/concepts/architecture.md— conceptual model, atoms, patterns, grounding, observation boundariesdocs/concepts/contracts.md— deterministic constraints and atom vocabulary
For implementation:
sponsio/core.py—sponsio.Sponsio()factory and framework resolutionsponsio/integrations/base.py—BaseGuard, contract compilation, enforcement hookssponsio/runtime/monitor.py— det dispatch and enforcement routingsponsio/runtime/verifier.py— trace-aware contract verificationsponsio/patterns/library.py— deterministic pattern factoriessponsio/generation/dsl_to_contract.py— text DSL → pattern-library calls (rule-based; LLM extractor is a separate, opt-in stage inparse_contract)sponsio/tracer/grounding.py— event-to-atom groundingsponsio/formulas/formula.pyandsponsio/formulas/evaluator.py— formula AST and finite-trace evaluator
Repository Map
sponsio/
├── core.py public entrypoint: sponsio.Sponsio()
├── cli.py CLI: scan, validate, check, demo, patterns, report
├── config.py YAML config loader
├── demos/ packaged mock demos used by `sponsio demo`
├── discovery/ code/docs/traces -> proposed contracts
├── formulas/ LTL/propositional/arithmetic AST + evaluators
├── generation/ text DSL -> contract parsing and optional LLM extractor for free-form NL
├── integrations/ framework adapters; all contract logic lives in BaseGuard
├── models/ Agent, Contract, System, Trace, Event, spans
├── patterns/ deterministic pattern library
├── reporting/ shadow-mode report aggregation/rendering
├── runtime/ monitor, verifier, strategies, feedback, session logging
└── tracer/ event collection and grounding
ts/ TypeScript workspace (npm workspaces)
└── packages/sdk/ @sponsio/sdk: det engine, framework integrations, and AST static scanner CLI
docs/ user-facing documentation
scripts/ one-off maintenance utilities (e.g. plugin sync)
tests/ pytest suiteThe api/ and web/ directories are not part of this repo. Local
single-user observability uses sponsio host trace --follow / sponsio
report / sponsio replay <session> / sponsio explain <contract> /
sponsio.tracer.exporters.OtlpHttpExporter.
Core Invariants
sponsio/core should avoid hard dependencies on framework packages. Framework deps belong in[project.optional-dependencies].- Framework adapters should inherit from
BaseGuardand keep framework-specific code thin. - Det violations route through det strategies such as
DetBlockorEscalateToHuman. - The trace is append-only during a session. In enforce mode, a hard-blocked event may be rolled back so later checks are not poisoned.
- Grounding produces one valuation dict per timestep; formula evaluators consume valuations, not raw events.
What Deterministic Contracts Cover
Deterministic contracts handle properties that are structurally observable:
- tool ordering
- rate limits
- retries/loops
- destructive action gates
- path/argument blacklists
- exact PII regexes, length, format
- permissions and allowlists
These are exactly checkable with regexes, counters, paths, or ordering, with no LLM judge in the loop.
Python / TypeScript Parity
Python and TypeScript share the deterministic core. When changing these Python files, check the matching TS files:
| Python | TypeScript (ts/packages/sdk/src/) |
sponsio/formulas/formula.py | core/formula.ts |
sponsio/formulas/evaluator.py | core/evaluator.ts |
sponsio/tracer/grounding.py | core/grounding.ts |
sponsio/patterns/library.py | core/patterns.ts |
sponsio/generation/dsl_to_contract.py | core/nl-parser.ts |
sponsio/integrations/base.py (CheckResult) | index.ts (CheckResult) |
The verdict shape is part of the parity surface, not just the formulas.
Both runtimes derive blocked / escalated / redirected / redirectedTo
/ stopOriginal from a per-violation action, and both treat
{blocked, redirected} as the stopping set. stopOriginal is the field
an adapter gates on: a redirect leaves blocked false and allowed true
because the flow continues down the safe path, so a caller reading
blocked runs the exact call the contract forbade.
A pattern whose behaviour depends on a strategy has to carry it on the
compiled formula (DetFormula.strategy / safeName). redirect_to_safe
compiles to G(!called(unsafe)), which is indistinguishable from a plain
ban, so a runtime reading only the formula turns every redirect into a
block. Anything that rebuilds a DetFormula field by field has to copy
those two along.
Cross-language scenarios live in tests/cross_language/scenarios.json,
whose contracts are inline NL strings. A pattern with no plain-English
form cannot go in there: redirect_to_safe has its own rulebook and
shared answer key (redirect_parity.yaml, redirect_expected.json) read
by a test on each side.
The TS SDK covers deterministic runtime enforcement. Python currently has the broader surface: DFA/verifier work, YAML config, discovery, OTEL, and reporting.
Common Tasks
Add a deterministic pattern
- Add a factory to
sponsio/patterns/library.py. - If it needs a new observable, add atom extraction in
sponsio/tracer/grounding.py. - Add DSL parsing in
sponsio/generation/dsl_to_contract.py. - Add tests for pattern behavior and NL parsing.
- Update README/docs if the pattern is public.
- Check TypeScript parity if the pattern belongs in the TS det core.
Add an integration
- Create
sponsio/integrations/<framework>.py. - Inherit from
BaseGuard. - Only implement framework interception/wrapping; keep contract logic in
BaseGuard. - Register the framework in
sponsio/core.py. - Add optional dependencies in
pyproject.toml. - Add examples/tests/docs.
Common Pitfalls for AI Assistants
- The import path is
sponsio, notSponsio. - Prefer the framework-specific factory for new examples — e.g.
from sponsio.langgraph import Sponsiothenguard = Sponsio(...). The genericsponsio.Sponsio(framework="langgraph", ...)works too but is less idiomatic. DetFormulawraps a raw formula plus metadata. Use.formulafor the AST and.descfor the human-readable description.- Do not claim OTEL ingestion can block actions. OTEL-based observation is post-hoc unless combined with framework hooks.
- Do not claim prompt engineering is unnecessary. Prompting still defines intent; Sponsio enforces action boundaries.
- Do not invent benchmark numbers. Cite the root
README.md§ Benchmarks table if present, or internal eval notes — detailed benchmark tables are not maintained in the public documentation tree. - Do not rely on internal files such as
STATUS.mdorPLAN.md; they are not part of the public guide.
Useful Commands
pip install -e ".[all]"
pytest -v
ruff check sponsio/ tests/ scripts/
ruff format sponsio/ tests/ scripts/
sponsio demo --scenario freeze --fast
sponsio validate "tool `check_policy` must precede `issue_refund`"Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

