Automated Type Contracts Generation for Ruby
summary
Runtime traces collected with tracepoint plus occasional YARV disassembly turn method calls into input→output tuples which are compressed into contracts like (String, T) -> T. Rules become NFAs that the system determinizes and minimizes (NFA→DFA minimization) and can merge across runs and projects; proto tooling includes arc_scanner gem, a server for merging, and an IDE plugin. Tests run much slower under tracing (tens×), so collection is intended as a one‑time or CI job.
AI-written summary · about
chapters (13)
- 0:00Introduction and motivation
- 3:35Why Ruby needs types
- 7:46Limitations of testing and static analysis
- 10:59Collecting type data with TracePoint
- 17:29Handling corner cases in data collection
- 18:12Transforming raw data into type contracts
- 23:13Improving contract generation with bit masks
- 24:50Merging automatons for consistency
- 27:04Demo: Generating type annotations
- 29:30Building a global type database
- 31:16Project architecture and tools
- 33:49Future possibilities and impact
- 34:34Q&A session
related talks
28mA Plan towards Ruby 3 Types
36mA Static Type Analyzer of Untyped Ruby Code for Ruby 3
24mJust-in-Time Compiling Ruby Regexps on TruffleRuby
30mGarnet.js: Implementing the YARV Virtual Machine
39mGradual typing of Ruby at Scale
33mRuby the Hard Way: Writing Bytecode to Optimize Plain Ruby
36mCould a Machine ever write tests for our code
34mHijacking Ruby Syntax in Ruby
