Google Workspace — all cases¶
Every case file under src/clauz3/stdlib/google_workspace/tests/cases/, inlined.
_pass cases must prove; _fail cases must not.
See the curated walk-through for the trusted module and contract vocabulary.
src/clauz3/stdlib/google_workspace/tests/cases/campaign_pass.py¶
# ruff: noqa: F821
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
# A realistic agent-driven send campaign with full safety stack:
# - dry_run_only() — never actually fires
# - only_recipients allowlist — small explicit set
# - unique_recipients — no double-sends
# - emails_at_most cap — bounded volume
# - subject_must_contain "[DRAFT]" — visible machine-authored marker
# - no_body_contains "BEGIN PRIVATE KEY" — secrets exfil guard
@clauz3.guarantee(email.dry_run_only())
@clauz3.guarantee(email.only_recipients(["alice@example.com", "bob@example.com"]))
@clauz3.guarantee(email.unique_recipients())
@clauz3.guarantee(email.emails_at_most(2))
@clauz3.guarantee(email.subject_must_contain("[DRAFT]"))
@clauz3.guarantee(email.no_body_contains("BEGIN PRIVATE KEY"))
def main() -> None:
send_email(
"alice@example.com",
"[DRAFT] status update",
"all clear",
dry_run=True,
)
send_email(
"bob@example.com",
"[DRAFT] status update",
"all clear",
dry_run=True,
)
src/clauz3/stdlib/google_workspace/tests/cases/draft_body_fail.py¶
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import create_draft
import clauz3
@clauz3.guarantee(email.no_body_contains("secret"))
def main() -> None:
create_draft("alice@example.com", "hello", "secret")
src/clauz3/stdlib/google_workspace/tests/cases/draft_count_fail.py¶
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import create_draft
import clauz3
@clauz3.guarantee(email.emails_at_most(1))
def main() -> None:
create_draft("alice@example.com", "hello", "hi")
create_draft("bob@example.com", "hello", "hi")
src/clauz3/stdlib/google_workspace/tests/cases/draft_invalid_recipient_fail.py¶
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import create_draft
import clauz3
@clauz3.guarantee(email.drafts_only())
def main() -> None:
create_draft("alice", "hello", "hi")
src/clauz3/stdlib/google_workspace/tests/cases/draft_pass.py¶
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import create_draft
import clauz3
@clauz3.guarantee(email.drafts_only())
@clauz3.guarantee(email.only_recipients(["alice@example.com"]))
@clauz3.guarantee(email.emails_at_most(1))
@clauz3.guarantee(email.unique_recipients())
@clauz3.guarantee(email.subject_must_contain("hello"))
@clauz3.guarantee(email.subject_length_at_most(20))
@clauz3.guarantee(email.body_length_at_most(20))
@clauz3.guarantee(email.no_body_contains("secret"))
@clauz3.guarantee(email.no_subject_contains("secret"))
def main() -> None:
create_draft("alice@example.com", "hello", "hello from clauz3")
src/clauz3/stdlib/google_workspace/tests/cases/draft_recipients_fail.py¶
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import create_draft
import clauz3
@clauz3.guarantee(email.only_recipients(["alice@example.com"]))
def main() -> None:
create_draft("bob@example.com", "hello", "hi")
src/clauz3/stdlib/google_workspace/tests/cases/draft_subject_fail.py¶
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import create_draft
import clauz3
@clauz3.guarantee(email.subject_must_contain("hello"))
def main() -> None:
create_draft("alice@example.com", "bye", "hi")
src/clauz3/stdlib/google_workspace/tests/cases/drafts_only_preview_fail.py¶
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
@clauz3.guarantee(email.drafts_only())
def main() -> None:
send_email("alice@example.com", "hello", "hi", dry_run=True)
src/clauz3/stdlib/google_workspace/tests/cases/drafts_only_send_fail.py¶
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import create_draft, send_email
import clauz3
@clauz3.guarantee(email.drafts_only())
def main() -> None:
create_draft("alice@example.com", "hello", "hi")
send_email("alice@example.com", "hello", "hi", dry_run=False)
src/clauz3/stdlib/google_workspace/tests/cases/dry_run_only_default_fail.py¶
# ruff: noqa: F821
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
# Relies on the runtime default dry_run=True but does NOT pass it
# explicitly. The contract `dry_run_only()` queries `e.dry_run` which is
# not in the recorded fact (default kwargs aren't reflected), so the
# prover fails closed. This is the load-bearing safety property: agents
# can't earn approval without intentionally stating dry_run.
@clauz3.guarantee(email.dry_run_only())
def main() -> None:
send_email("alice@example.com", "[DRAFT] hello", "hi")
src/clauz3/stdlib/google_workspace/tests/cases/dry_run_only_explicit_false_fail.py¶
# ruff: noqa: F821
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
# Explicit dry_run=False with dry_run_only() guarantee is correctly
# rejected. This is the "intentional real send under a dry-run-only
# campaign" failure mode — caught at prove time.
@clauz3.guarantee(email.dry_run_only())
def main() -> None:
send_email("alice@example.com", "[DRAFT] hello", "hi", dry_run=False)
src/clauz3/stdlib/google_workspace/tests/cases/dry_run_only_pass.py¶
# ruff: noqa: F821
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
@clauz3.guarantee(email.dry_run_only())
def main() -> None:
send_email("alice@example.com", "[DRAFT] hello", "hi", dry_run=True)
src/clauz3/stdlib/google_workspace/tests/cases/email_no_guarantees_pass.py¶
# ruff: noqa: F821
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
# Explicit null contract: agent asks for no guarantees. The trusted
# preconditions still hold (addr has "@", subject non-empty), so the
# call is well-formed, but the contract surface makes no claims about
# behaviour. This is the "I know what I'm doing, document that I'm
# claiming nothing" pattern.
@clauz3.guarantee(email.no_guarantees())
def main() -> None:
send_email("anyone@example.com", "anything", "anything")
src/clauz3/stdlib/google_workspace/tests/cases/emails_at_most_fail.py¶
# ruff: noqa: F821
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
@clauz3.guarantee(email.emails_at_most(1))
@clauz3.guarantee(email.dry_run_only())
def main() -> None:
send_email("alice@example.com", "[DRAFT] a", "x", dry_run=True)
send_email("bob@example.com", "[DRAFT] b", "x", dry_run=True)
src/clauz3/stdlib/google_workspace/tests/cases/emails_at_most_pass.py¶
# ruff: noqa: F821
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
@clauz3.guarantee(email.emails_at_most(2))
@clauz3.guarantee(email.dry_run_only())
def main() -> None:
send_email("alice@example.com", "[DRAFT] a", "x", dry_run=True)
send_email("bob@example.com", "[DRAFT] b", "x", dry_run=True)
src/clauz3/stdlib/google_workspace/tests/cases/mixed_count_fail.py¶
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import create_draft, send_email
import clauz3
@clauz3.guarantee(email.emails_at_most(1))
def main() -> None:
create_draft("alice@example.com", "hello", "hi")
send_email("alice@example.com", "hello", "hi", dry_run=True)
src/clauz3/stdlib/google_workspace/tests/cases/no_body_contains_fail.py¶
# ruff: noqa: F821
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
@clauz3.guarantee(email.no_body_contains("BEGIN PRIVATE KEY"))
@clauz3.guarantee(email.dry_run_only())
def main() -> None:
send_email(
"alice@example.com",
"[DRAFT] notes",
"BEGIN PRIVATE KEY\n...\n",
dry_run=True,
)
src/clauz3/stdlib/google_workspace/tests/cases/no_body_contains_pass.py¶
# ruff: noqa: F821
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
@clauz3.guarantee(email.no_body_contains("BEGIN PRIVATE KEY"))
@clauz3.guarantee(email.dry_run_only())
def main() -> None:
send_email(
"alice@example.com",
"[DRAFT] notes",
"no secrets here",
dry_run=True,
)
src/clauz3/stdlib/google_workspace/tests/cases/no_drafts_fail.py¶
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import create_draft
import clauz3
@clauz3.guarantee(email.no_drafts())
def main() -> None:
create_draft("alice@example.com", "hello", "hi")
src/clauz3/stdlib/google_workspace/tests/cases/no_emails_fail.py¶
# ruff: noqa: F821
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
@clauz3.guarantee(email.no_emails())
def main() -> None:
send_email("alice@example.com", "[DRAFT] hi", "hi", dry_run=True)
src/clauz3/stdlib/google_workspace/tests/cases/no_emails_pass.py¶
# ruff: noqa: F821
from tools.google_workspace.gmail.trusted import contracts as email
import clauz3
@clauz3.guarantee(email.no_emails())
def main() -> None:
pass
src/clauz3/stdlib/google_workspace/tests/cases/only_recipients_fail.py¶
# ruff: noqa: F821
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
@clauz3.guarantee(email.only_recipients(["alice@example.com"]))
@clauz3.guarantee(email.dry_run_only())
def main() -> None:
send_email("alice@example.com", "[DRAFT] hi", "hi", dry_run=True)
send_email("eve@example.com", "[DRAFT] hi", "hi", dry_run=True)
src/clauz3/stdlib/google_workspace/tests/cases/only_recipients_pass.py¶
# ruff: noqa: F821
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
@clauz3.guarantee(email.only_recipients(["alice@example.com", "bob@example.com"]))
@clauz3.guarantee(email.dry_run_only())
def main() -> None:
send_email("alice@example.com", "[DRAFT] hi alice", "hi", dry_run=True)
send_email("bob@example.com", "[DRAFT] hi bob", "hi", dry_run=True)
src/clauz3/stdlib/google_workspace/tests/cases/preview_pass.py¶
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
@clauz3.guarantee(email.dry_run_only())
@clauz3.guarantee(email.no_drafts())
def main() -> None:
send_email("alice@example.com", "hello", "hi", dry_run=True)
src/clauz3/stdlib/google_workspace/tests/cases/send_empty_subject_fail.py¶
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
@clauz3.guarantee(email.dry_run_only())
def main() -> None:
send_email("alice@example.com", "", "hi", dry_run=True)
src/clauz3/stdlib/google_workspace/tests/cases/send_invalid_recipient_fail.py¶
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
@clauz3.guarantee(email.dry_run_only())
def main() -> None:
send_email("alice", "hello", "hi", dry_run=True)
src/clauz3/stdlib/google_workspace/tests/cases/subject_must_contain_fail.py¶
# ruff: noqa: F821
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
@clauz3.guarantee(email.subject_must_contain("[DRAFT]"))
@clauz3.guarantee(email.dry_run_only())
def main() -> None:
send_email("alice@example.com", "hello", "hi", dry_run=True)
src/clauz3/stdlib/google_workspace/tests/cases/subject_must_contain_pass.py¶
# ruff: noqa: F821
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
@clauz3.guarantee(email.subject_must_contain("[DRAFT]"))
@clauz3.guarantee(email.dry_run_only())
def main() -> None:
send_email("alice@example.com", "[DRAFT] hello", "hi", dry_run=True)
src/clauz3/stdlib/google_workspace/tests/cases/unique_recipients_fail.py¶
# ruff: noqa: F821
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
@clauz3.guarantee(email.unique_recipients())
@clauz3.guarantee(email.dry_run_only())
def main() -> None:
send_email("alice@example.com", "[DRAFT] hi", "hi", dry_run=True)
send_email("alice@example.com", "[DRAFT] again", "hi again", dry_run=True)
src/clauz3/stdlib/google_workspace/tests/cases/unique_recipients_pass.py¶
# ruff: noqa: F821
from tools.google_workspace.gmail.trusted import contracts as email
from tools.google_workspace.gmail.trusted.effects import send_email
import clauz3
@clauz3.guarantee(email.unique_recipients())
@clauz3.guarantee(email.dry_run_only())
def main() -> None:
send_email("alice@example.com", "[DRAFT] hi", "hi", dry_run=True)
send_email("bob@example.com", "[DRAFT] hi", "hi", dry_run=True)