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:
-
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/1ignoresdebug_infochunks. -
In
v0.2.11(#25), Mix gained--otp-app. In#27, passing an unavailable--otp-appsilently fell back to an empty table inprisma:resolve_lock_pplt/1instead of failing with an error.
-
In
-
Direct
elixir_v1AST Lowering (#28,#30,#31):-
#17separatedHelper.val()fromm.k.#28asked what happens when the module is in a variable (mod.version()with parentheses vsmap.versionwithno_parens: true). -
v0.2.11addedwithsupport.#30tested a two-generatorwith/elsewhere the first and second generators fail differently into a sharedelseclause—catching a falsedead_codecaused by duplicatingelsein each generator'scase. -
#22fixed valid<<x::size(eight())>>.#31flipped the width to:bad(<<x::size(invalid())>>) and caught that segment widths weren't type-checked againstinteger().
-
-
Always-Failing BIFs (
#34):-
hd([])passed even with OTP tables loaded because{improper_list, any, any}in Prisma's type lattice is consistent withnil.
-
-
Overloaded Specs, Missing Functions, and Stdlib Precision (
#29,#32,#33):-
#23caught overloaded@specreturns outside the union of all branches.#32swapped the returns between the two branches (:integerreturning<<7>>while:binaryreturned<<1>>). -
#33called a missing function in another analyzed Elixir module and passed cleanly becauseunknown_function_warnings/4skippedelixirmodules altogether. -
#29showedKeyword.split(opts, [:name])losing{:name, atom()}beforeGenServer.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
-
Anonymous
fn/funand captures (&Mod.fun/n,fun m:f/a):{'fun', ...}previously returnedany, sof.(1, :bad)or calling a 1-argfunwith 2 args produced zero warnings—and in Elixir,fn x, y when ... -> ... enddropped intermediate parameters (Pat = hd(ArgsAndGuard)). Nowinfer_fun_exprtypesfuns as{fun_type, Args, Ret}and validates call arity and arguments; remote captures register call sites so missing or private targets emitunknown_function. -
erlang:apply/3with static MFA and arg list: now resolves directly to the target call. -
Elixir binary patterns
<<x::8, rest::binary>>:translate_pattern({'<<>>', ...})previously returned an empty{bin, Anno, []}, typingrestasany. It now translates every segment and type specifier. -
Elixir
[a, b | tail]:translate_exprandtranslate_patternonly matched 1-element cons ([{'|', _, [H, T]}]), emitting phantom'|'/2calls on[1, 2 | t]and droppingtin patterns. Both now lower recursively. -
caseopaque deconstruction, BIFs, and comprehensions: addedopacity_violationchecks toinfer_case, caughtbinary_part/2,3,bnot, right-hand operands of--,length([1 | 2]),map_geton closed exact maps, and validated list/bitstring generators in comprehensions (for/lc/bc). -
otp_appswithoutproject_root:prisma:analyze_beams/2now resolvesotp_appseven whenproject_rootis omitted.
Round 2: Closures, named_fun, Exact Map Updates, for, and path: Deps
-
Closures and recursive
named_funs:infer_fun_exprnow preserves the enclosingEnv(X = :not_int, f = fn -> X end), andinfer_named_fun_exprruns a two-pass seed so recursivefun Loop(0) -> ok; Loop(X) -> Loop(X - 1) enddoesn't collapseok | anytoany. -
@opaquein function heads and structs:infer_clausenow checks opaque deconstruction on head patterns againstSeedArgs, andfind_opaque_deconstructiondescends into{map, _, Fields}. -
Exact map updates (
%{m | b: 2}/M#{b := 2}):exact_map_update_warnings/4flagsbadkeywhen updating a non-existent key on a closed non-struct map. -
forwithinto: %{}andreduce:: comprehensions now propagate element types (andnonempty_listwhen all generators are non-empty with irrefutable patterns and no filters),maps:from_list/1infers{map, ...}, andlists:foldl/3propagatesInitTypeand element types into the reducer. -
Mix
path:dependencies:discover_local_path_deps/3discovers and caches local dependencies in_build/<env>/lib/even when they have nomix.lockentry. -
Map.fetch!/2,Map.get/2,3,Keyword.get/2,3, andbinary:part/3bounds: specialized value lookup and out-of-bounds literal slice detection (including Elixir's nested<<"hi">>AST).
Round 3: Last Checks on the Endgame
By Round 3, zero critical issues remained, and five final medium/low gaps were closed cleanly:
-
Map.put/3,Map.merge/2,Map.delete/2,Keyword.fetch!/2, andAccess.get/2(m[:k]). -
try/rescue e in ExceptionMod:translate_try_catch_clause/2bindseto the exception struct withmessage :: binary(). -
iolist_to_binary/1(for <<...>>, into: <<>>),erlang:apply/2, andreceive ... after Timeoutvalidation (non_neg_integer() | infinity).
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:
-
rebar3 eunit: 314/314 tests passing -
rebar3 proper: 20/20 properties passing (100/100on both Elixir properties) -
rebar3 ex_doc: 0 warnings (after fixing EDoc`...'inline quotes and doc references) -
Self-check (
prisma check _build/default/lib/prisma/ebin): 0.398 s, 0 warnings
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!