Prisma Logo Prisma v0.2.12
Back to Blog & Benchmarks
Type Systems internals 2026-12-02 · Manuel Rubio

Reading the Board for v0.2.12: From Reactive Fixes to Adversarial Audits

How a second wave of nine sharp bug reports pushed us to anticipate the next moves with three internal soundness audits and a 37-scenario Elixir property suite

#erlang #elixir #prisma #type-systems #gradual-typing #proper #testing #diagnostics #security

Every codebase eventually meets a reviewer who tests it the way a strong chess player tests an opening: not with random moves, but with quiet, forcing questions that probe the exact boundary between what you claim to check and what you actually verify.

Shortly after publishing v0.2.11—which had already resolved an earlier wave of nine issues (#17–#25)—a second wave of nine issues (#26–#34) arrived from the same reviewer. Once again, we want to start by thanking our reviewer: every single report was minimal, reproducible, fair, and grounded in real Elixir and Erlang semantics. That kind of feedback is rare, and it makes Prisma meaningfully stronger with every round.

This time, though, fixing the nine issues one by one wasn't enough. Looking at both waves side by side, it was clear we had been playing reactively—responding to each move after it landed on the board. For v0.2.12, we decided to change our approach: read the pattern, step back, and try to see two or three moves ahead.


1. Reading the Pattern Behind #26–#34

When you line up #17–#25 next to #26–#34, the reviewer's strategy jumps off the page. Each issue tests a clean good vs bad pair across four pillars of Prisma's public contract:

  1. PPLT Cache & CLI Integrity (#26, #27):
    • In v0.2.11 (#20), recompiling a dependency's code invalidated its cached .pplt. In #26, the reviewer kept the function body identical and changed only @spec—exposing that :beam_lib.md5/1 ignores debug_info chunks.
    • In v0.2.11 (#25), Mix gained --otp-app. In #27, passing an unavailable --otp-app silently fell back to an empty table in prisma:resolve_lock_pplt/1 instead of failing with an error.
  2. Direct elixir_v1 AST Lowering (#28, #30, #31):
    • #17 separated Helper.val() from m.k. #28 asked what happens when the module is in a variable (mod.version() with parentheses vs map.version with no_parens: true).
    • v0.2.11 added with support. #30 tested a two-generator with/else where the first and second generators fail differently into a shared else clause—catching a false dead_code caused by duplicating else in each generator's case.
    • #22 fixed valid <<x::size(eight())>>. #31 flipped the width to :bad (<<x::size(invalid())>>) and caught that segment widths weren't type-checked against integer().
  3. Always-Failing BIFs (#34):
    • hd([]) passed even with OTP tables loaded because {improper_list, any, any} in Prisma's type lattice is consistent with nil.
  4. Overloaded Specs, Missing Functions, and Stdlib Precision (#29, #32, #33):
    • #23 caught overloaded @spec returns outside the union of all branches. #32 swapped the returns between the two branches (:integer returning <<7>> while :binary returned <<1>>).
    • #33 called a missing function in another analyzed Elixir module and passed cleanly because unknown_function_warnings/4 skipped elixir modules altogether.
    • #29 showed Keyword.split(opts, [:name]) losing {:name, atom()} before GenServer.start_link/3.

Fixing these nine was straightforward—beam_fingerprint/1 hashing full .beam bytes (#26), propagating resolve_project_pplts/2 errors (#27), checking no_parens + module-typed receivers (#28), routing with failures to a single shared else case (#30), checking bitstring segment sizes (#31), per-branch overload checking (#32), Elixir exports verification (#33), explicit hd([])/tl([]) checks (#34), and specializing Keyword.split/2 (#29).

The real question was: if we stop here, what would #35–#43 look like?


2. Turning the Tables: Three Rounds of Adversarial Audits

Instead of waiting for a third wave of reports, we turned the problem around. We ran three consecutive adversarial audit rounds, instructing a dedicated soundness-analyst pass to probe compiled prisma binaries with minimal Erlang and Elixir reproducers—specifically trying to break our own fixes and explore untouched corners of the AST and type engine.

At the same time, we expanded test/prop_prisma_elixir.erl from testing only valid/invalid @specs on 9 constructs into a 37-scenario negative and compound property suite (prop_elixir_negative_and_compound_cases/0) that compiles real Elixir modules with 'Elixir.Code':compile_string/1, runs them, and asserts the exact expected diagnostic (discrepancy, gradual_mismatch, unknown_function, opacity_violation, or zero dead_code).

Here is what the three audit rounds uncovered before shipping v0.2.12:

Round 1: Functions, Captures, Binary Patterns, and Multi-Element Cons

Round 2: Closures, named_fun, Exact Map Updates, for, and path: Deps

Round 3: Last Checks on the Endgame

By Round 3, zero critical issues remained, and five final medium/low gaps were closed cleanly:


3. Keeping the Clock Under Control: Verification & Benchmarks

Adding deeper inference (especially typing fun closures and lists:foldl/3) meant we also had to check the clock. After a first benchmark run showed extra overhead from double-passing fun bodies and doing an extra module lookup on every Erlang remote call, we unified infer_fun_expr into a single pass and restricted the private-export lookup to Elixir.* callees.

Measuring v0.2.12 against v0.2.11 with hyperfine --runs 5 --warmup 1:

Corpus v0.2.11 v0.2.12 Delta
prisma (17 modules, from_beams + check_pplt) 195 ms 192 ms ~0%
rabbit (234 modules, CLI prisma check) 1.722 s / 379.8 MiB 2.139 s / 353.5 MiB +24% time / -6.7% RAM

On the 234-module rabbit corpus, v0.2.12 uses 6.7% less peak memory than v0.2.11 and remains ~3.2× faster than Dialyzer (6.75 s), while catching an entire class of Elixir and Erlang bugs that previously slipped through silently.

And the test and documentation checks for v0.2.12:

Once again, thank you to our reviewer for pushing Prisma to become much sharper—this release is as much a product of that scrutiny as of our own audit loop. If you hit anything new on v0.2.12, keep the moves coming!