πŸ† Flagsmith Γ— WeMakeDevs Hackathon β€’ Track 02: AI Agents & Feature Flags

Don't sample your flags.
Prove them.

The first formal verifier for Flagsmith targeting rules. Encodes segments, overrides, priorities, and percentage splits into Z3 mathematical logic. Detects subtle regression overlaps in 24 milliseconds where random sampling of 2,000 users finds nothing.

102 / 102
Flagsmith engine conformance tests green (0 mismatches)
250 Passed
Zero test failures across unit, e2e, and mutation suites
Dual-Solver
Independent Z3 and cvc5 proof certificates agree 100%
0 False Positives
Every violation replayed & confirmed by real Flagsmith engine
🎲 Conventional Monte Carlo Testing
SAMPLING

Teams typically write unit tests or sample 2,000 synthetic users to check if any retired EU user gets the forbidden new_pricing flag.

// Invariant I-001 Check
assert not (region == "EU" && signup_year < 2022 && new_pricing == true)
Ready. Click button above to simulate 2,000 random users against targeting rules.
πŸ›‘οΈ FlagProof Formal Verifier
Z3 + cvc5 PROVER

FlagProof models every segment, override priority, and percentage split as symbolic first-order logic and asks Z3 if any possible user violates the rule.

βˆƒ user: EU(user) ∧ Retired(user) ∧ BetaPro(user) β‡’ new_pricing = True
Ready. Click button above to mathematically prove all 3 invariants.
πŸ›‘οΈ Claude Code Agent Interlock (`PreToolUse` Hook)
ZERO-LEAK SAFETY GUARD

When an AI agent (like Claude Code) tries to modify feature flags via the official Flagsmith MCP server, FlagProof Interlock intercepts the tool call, constructs the draft environment diff, and verifies invariants before anything touches Flagsmith.

1
Agent Proposes Edit
Claude calls create_segment_override(feature="new_pricing", segment="beta_pro").
2
Interlock Intercepts
Hook captures tool call; translates draft to symbolic Flagsmith AST.
3
Z3 Computes Proof
Z3 finds that beta_pro overrides eu_legacy_retired for EU Pro users.
4
DENIED With Witness
Tool execution is halted. Witness user is returned so Claude can auto-synthesize a safe fix.
[INTERLOCK] DENIED Flagsmith tool execution:
Invariant I-001 violated: "Retired EU users must never receive new pricing"
Concrete Witness User:
  Identifier: usr_c9e2b104
  Traits: {"region": "EU", "plan": "pro", "signup_year": 2021, "app_build": 430}
Flagsmith Engine Oracle Replay: CONFIRMED (Served state: new_pricing=True)
Action Required: Proposed modification blocked. Write rejected.
Self-Contained Offline Report β€” out/report.html Open Full Screen β†—
Feature Cohort Reachability Atlas β€” out/atlas.html Open Full Screen β†—

60-Second Clean-Clone Quickstart

FlagProof runs 100% offline without needing a Flagsmith account or LLM API keys.

$ git clone https://github.com/Monolithic-Dev/FlagProof.git && cd FlagProof
$ make install # Installs dependencies via uv and pulls Flagsmith engine conformance submodule
$ NO_BROWSER=1 make demo # Runs formal verification against demo environment
$ make demo-interlock # Simulates Claude Code AI Agent PreToolUse hook interception
$ make corpus # Runs verifier across 102 official Flagsmith test environments (0 crashes)

Or Install as a Python Package:

$ pip install flagproof
$ flagproof verify --environment prod --invariants invariants.yaml

Why FlagProof Wins Over Testing

Mathematical proof replaces guesswork when deploying feature flags with AI agents.

πŸ”¬

Zero-False-Positive Replay

Every violation found by the solver is immediately replayed through the real flagsmith-flag-engine. If the engine doesn't agree, it is never reported as a violation.

🀝

Dual-Solver Cross-Check

Invariants are checked across two independent mathematical theorem provers: Microsoft Z3 and Stanford cvc5. Both must agree before a proof certificate is stamped.

πŸ›‘οΈ

Claude Code Interlock

A native PreToolUse hook that protects production. AI agents can propose changes, but cannot apply unsafe overrides that violate organizational policy.

πŸ”§

Automated Sound Fixes

When an invariant is violated, flagproof fix synthesizes candidate fixes, mathematically proves they resolve the violation without breaking existing rules, and presents them for human review.

πŸ§ͺ

Pre-Flight Experiment Guard

Proves that multivariate A/B experiment arms obey invariants across all user cohorts before traffic is allocated, detecting cohort collisions before rollout.

πŸ“¦

Zero External Infrastructure

Ships as a standalone CLI, GitHub Action, and 9-tool MCP server. No databases, no external servers, no cloud data leaks.