Skip to main content

Examples

Every example runs against the real engine, is self-contained, and needs no server and no signup. Clone watchlight-de or copy a single file. Run one in a terminal and watchlight dev in another to watch the decisions land.

Start here​

ExampleWhat it shows
agent.pyThe DENY line — one allowed tool, one denied, refused before it runs.
governed_research_agent.pyFive tools, only research and read permitted; email, transfer and delete are blocked.
context_governance.pyThe same call allowed or denied by runtime context; missing context fails closed.
governed_subagents.pyScope attenuation — a child can only ever narrow; widening is refused.

Govern something you already have​

ExampleInstall
governed_langgraph_agent.pywatchlight[langgraph]
governed_pydantic_ai_agent.pywatchlight[pydantic-ai]
governed_claude_agent.pywatchlight[claude-agent]
governed_deepagents.pywatchlight[deepagents] — runs without an API key
governed_mcp_server.pywatchlight-mcp — a denied tools/call never reaches the server

The how is in Govern an agent you already have and Govern an MCP server.

Policy recipes​

These are copy-paste patterns for the decisions people reach for the Developer Edition to make. Each one is a policy, the code that governs the tool, and the tests that prove the verdicts — all run through the real engine on every commit.

RecipeThe question it answers
Money-bounded agentMay this agent spend this much, on this, now — or does a human decide?
Destructive actionsDelete, drop, deploy: require a human, and make some things undeletable.
External messagingMay the agent message outside, and only allowlisted destinations?
Data egressMay this classification of data cross this boundary?
Allow, but redactSay "yes, but…" in the policy — obligations that ride on the Allow.
Kill switch / quarantineStop a suspect agent cold, with a boundary that beats every grant.
Per-user attributionAttribute the decision to the acting end-user, and scope policy to them.
PII before readStrip PII from a document before the agent ever sees it.
Screen before modelCatch prompt-injection shapes in what a read returns.
Sub-agent confinementA spawned agent can only ever do less than its parent.
Audit sinkShip the value-free trail to a store you already run.
QuotasAllow this many reads per hour, folded from the trail into Cedar context.

→ All of them

Showcases​

These are complete pipelines that run in both lanes and exit non-zero if what happened contradicts the verdict.

ShowcaseWhat it proves
denied-before-executeA stub bank's call counter is 0 after the denied transfer, 1 after a permitted one.
identityOne engine and one policy set: the agent alone, the agent for a person, a sub-agent under it.
human-in-the-loopA NeedsApproval hold, a separate approver, the action running exactly once. Replay is refused.
policy-tests-ciA suite, a workflow, and a deliberately widened policy that turns the run red.
audit-forensicsThe questions an incident review asks, answered from value-free records alone.
poisoned-ragA retrieved document hiding an injection and personal data — withheld, then redacted.
red-teamAn adversarial corpus, per-family counts, red if any prompt reaches the model unscreened.
web-backendFastAPI and Express: the authenticated user becomes the principal on the decision record.