Skip to content

Understanding Oracles

Oracles brings powerful and sophisticated testing and specification ideas into the everyday work of developing software with coding agents.

Note

Outline draft for review. One conceptual overview will connect the ideas; deeper sources remain linked rather than becoming a prerequisite course.

Start with one rule

The header must never cover the page content.

  • Start with Headroom: change the header’s content and size, then check that its wrapper reserves enough space.
  • Show the historical bug: the header grew while its wrapper kept the old height.
  • Some laws need only a simple constraint. Others need a reference calculation or a small simulation. Start with the simplest model that captures the behavior you want to check.

Before and after a Headroom fix: the wrapper grows with the header so the header does not cover the page content.

A historical Headroom bug, reproduced against an earlier version.

Decide what you want, then check it

  • The design loop works out what the software should do: behavior, priorities, performance budgets and tradeoffs.
  • The enforcement loop checks whether the implementation does that, and whether the oracle notices when it does not.
  • Agents help explore alternatives and their consequences. You make the design decisions, such as how tasks with equal priority should be ordered.

From examples to promises

  • An example test records an answer for one case.
  • A property states a rule over a domain; generated inputs explore it.
  • A test oracle supplies a judgment about correct behavior.
  • Introduce the running example: maintaining the highest-priority open tasks as records change.

Simulate the behavior simply

  • Keep tasks in a plain collection, apply each batch of edits, then filter, sort and take the top ten.
  • Production may use indexes, caches and incremental updates. The independent model can recompute the result after each batch.
  • Compare exactly the promised result: an empty answer can satisfy filtering, ordering and size constraints without satisfying the query.
  • Explain why an independent model can still be mistaken and needs scrutiny.

Observe behavior where the promise applies

  • Law, history, model, driver, observation and check, connected through one example.
  • Include intermediate publications or messages when final state alone can hide a defect.
  • A disagreement can reveal a bug, a model mistake or an unresolved design question.

Challenge the oracle too

  • Constructed histories ask whether execution reached the important situation. Deliberately create a tie at the tenth slot: add nine higher-priority tasks, then equal-priority B followed by A. Check that A takes the slot, completing A admits B and reopening A restores A.
  • Calibrations ask whether the check would recognize a failure. In a separate history where both tied tasks fit, replace [A, B] with [B, A] and require the ordering check to reject it. A check that compares only length would miss the swap.
  • Gap investigations change copies of production code and check whether the oracle notices. An unnoticed fault starts an investigation: improve the histories, model, observations or comparison and run again. Enforcement gaps are not waived.
  • Generated exploration, shrinking and replay; what finite testing does and does not establish.

Make the next change easier

  • Follow an optimization that accidentally changes the order of equal-priority tasks. Show the failure and the design decision it points back to.
  • Explain how a later human or agent can use that decision when it becomes relevant to their work.
  • When a bug slips through, improve the part of the oracle that missed it. More random inputs will not repair a comparison that ignores the relevant result.
  • Use the subscriber-message story from Kyle’s DB post: checking message semantics exposed bugs that comparing final maps had hidden.

Where these ideas come from

  • Property-based testing: QuickCheck and generators.
  • Model-based testing: fast-check’s conceptual overview and independent state/behavior judgments.
  • Mutation testing: Stryker’s introduction and testing whether tests notice changes.
  • Formal methods: TLA+ and specifying designs as models with properties to verify.
  • These ideas apply across languages. The current JavaScript/TypeScript tooling is one integration of the method.

Connect formal verification to production code

  • Formal verification establishes properties of a model; an implementation oracle checks those same properties against production code across generated histories.
  • Explain how Lean proofs and TLA+/TLC model checking can strengthen the models used to judge production behavior.
  • Show the shared model connecting the two: formal verification ↔ model ↔ production code.

Why coding agents change the economics

  • Agents make demanding model, generator and investigation work more practical.
  • Better checks make it practical to attempt more ambitious algorithms, richer behavior and larger changes.
  • Preserve what each investigation teaches, so later work starts with better feedback and a clearer design.
  • Read Kyle’s DB/Oracles post and the existing introduction.