Lion Cipher Lab
Give three specialist subagents typed I/O contracts — a schema at every handoff, with repair, quarantine, and a rule about what repair may never invent — then measure the silent corruption free-form handoffs ship and the good work an over-strict schema throws away
- AI Security
- Intermediate
- ~95 min
- Free · no account required
Why it matters
Split a security-alert pipeline across three specialists — one triages, one enriches, one writes the incident up — and you have created two HANDOFFS, which are two places where the pipeline can quietly become wrong. Not break. Become wrong. That distinction is the whole lab. When a database connection fails you get a stack trace, a page, and somebody looking at it within ninety seconds. When your triage specialist writes 'Could be medium, but I would lean critical given the pattern' and the enrichment specialist's regular expression grabs the first severity word it sees, nothing fails. The…
What you'll learn
- defining a TYPED HANDOFF precisely and building one: a declared schema at the boundary between two specialist agents, a validator that returns a LIST of named violations rather than a bool, and a declared behaviour on violation — repair, or quarantine, with nothing in between
- writing a schema validator from scratch out of a plain Python dict — types, enums, patterns, lengths, ranges, nullability and an unknown-field policy — in about ninety lines of standard library, so you can say exactly what your validation layer did to a record instead of trusting a library you have never read
- naming SILENT CORRUPTION as a distinct failure class and measuring it: an unvalidated handoff does not crash, it produces a complete, confident, WRONG incident write-up, and in the measured run below 113 of 240 write-ups (47.1%) were wrong with nobody told and nothing logged
- building a repair stage that obeys one rule — information-preserving and unambiguous, or it is not a repair — and being able to say why lower-casing HIGH is a repair, why turning the string "0800" into 800 is not, and why a missing severity has no repair at all
- measuring the COST of a contract as carefully as the benefit: the FALSE-REJECT RATE, i.e. handoffs quarantined that would in fact have produced a correct write-up — 113 of them under a strict profile, 47.1% of the entire alert queue, thrown away to prevent 6 wrong write-ups
- finding the point on the strict-to-lenient dial with a measurement rather than a preference, and seeing that a lenient boundary does not remove the work but DEFERS it to the last gate, where there is no upstream left to re-ask
- knowing what a contract structurally cannot do: all 12 write-ups still wrong after validation were wrong because a specialist was confidently wrong in perfectly valid JSON, and a schema checks shape, never truth
- evolving a schema without an outage — additive-only changes, unknown-field policy, the deployment order an enum widening forces, and the specific afternoon a required field costs you later
- the judgment to say when a typed contract is overkill, and to distinguish it from the two cheaper things people reach for instead
Steps in this lab
- The words first: subagent, specialist, handoff, contract, schema, validation, coercion, quarantine, silent corruption, false reject
- Open a terminal and make a scratch folder (all three operating systems)
- Generate 240 security alerts and the answer key that makes 'wrong' a countable thing
- The three specialists are a DETERMINISTIC STUB — read this before you paste it
- The baseline: three specialists handing each other English sentences
- Write the schema and the validator yourself — and why not pydantic
- The repair rule: information-preserving and unambiguous, or it is a guess wearing a repair's clothes
- Run the typed pipeline: 0.0% malformed delivered, 55 loud failures — and 12 errors no contract can see
- One alert, both channels, every intermediate string printed
- The cost of the contract: strict throws away 47.1% of the queue to prevent 6 wrong write-ups
- Turn the rule off and count the bodies: what happens when repair is allowed to invent
- Versioned schemas and additive-only evolution — what a required field really costs you
- When a typed contract is overkill — and why this, not that
- The way a pro does it
- OPTIONAL appendix: swap the stub for a real local model