Skip to content

VIP-71: Experimental.Test: doubles, assertions and conformance for agentic programs

Status: accepted by Will, 2026-11-23 — standard library only (no compiler or language changes). Will: "58 I accept. I accept every other language proposal but ones that don't require a change to the language and are purely library functions that don't require compiler changes at all should be marked as such". Implemented in the runtime as Experimental.Test.

Will's words

Ok so give me a list of [the reference engine's] features. We need to figure out what the VIP should look like. Some of the features outside of durable execution likely should simply be in the standard library I'm guessing but we should enumerate all of them

Summary

One sentence. Experimental.Test is a module of layers and assertions that make an agentic program testable: a model that replays a recording, a host with fixed files, an engine that can crash on purpose, and assertions over a plan and a journal.

One paragraph. Vibe tests are @effect/vitest tests, and that does not change. What an agentic program adds is three things a unit test cannot hold still: a model, a machine and a crash. The testing package of the reference engine (an existing Effect durable-execution framework these built-ins are modelled on) has a double for each. A recorded model replays what a provider once answered, with no network. A test host serves files and commands from a record. A restartable engine kills a run between steps and resumes it, so a test proves replay. This VIP ports them as layers a test provides, and ports the assertions that read a plan and a journal as values. Conformance suites let a fork prove that its own engine or host behaves like the standard one.

 the program under test                  in production                         in a test
 ──────────────────────                  ─────────────                         ─────────
 LanguageModel.generateObject  ◄───────  Experimental.Model.use("anthropic:…")  Test.replay(recorded)     no network, no key
 FileSystem, ChildProcess      ◄───────  NodeServices.layer                     Test.host({ files })      fixed files
 workflow steps                ◄───────  Experimental.Durable.sqlite(…)         Test.restartable          crashes between steps
 time                          ◄───────  the clock                              TestClock (Effect)        moved by the test

Decision

// proposed
import { expect, it } from "@effect/vitest"
import recorded from "./fixtures/label.json" with { type: "json" }
 
schema Label { type: "bug" | "feature" | "question" | "chore" }
 
effect function label(title: string) {
  const reply = try LanguageModel.generateObject({ prompt: `Label this issue: ${title}`, schema: Label })
  return reply.value
}
 
it.effect("labels a crash as a bug", () => effect {
  provide Experimental.Test.replay(recorded) {
    const result = try label("Crash on start")
    try Effect.try(() => expect(result.type).toBe("bug"))
  }
})

Module

Experimental.Test, in scope with no import, as VIP-33 rules. Its code is vibelang-runtime/experimental/Test. It ports the reference engine's testing package. Effect's TestClock and TestConsole keep their names and are in scope today.

Doubles, each a layer:

LayerStands in forBehaviorReference engine
Test.replay(fixture)LanguageModelStrict. Each recorded call is claimed once; a request the fixture does not describe is a defect. It never calls a providerRecordedModel
Test.record(path, { live })LanguageModelReplays path; on a miss it calls the live layer and writes the answerCachedModel, FixtureStore.makeFile
Test.decisions(fixture), Test.recordDecisions(path, { live })DecisionModelThe same pair for decision modelsCachedEvaluator
Test.host({ files, commands? })FileSystem, Path, ChildProcessSpawnerA deterministic machine from a recordTestHost.layer
Test.durableThe durable engineIn memory, on a test clockTestLayers.unit, MemoryEngine
Test.restartableThe durable engineIn memory, with Test.crash to kill and resume a run between stepsRestartableEngine
Test.poisonedEvery serviceAny service read fails. Proves a workflow body is pure at plan timeTestLayers.poisoned

Assertions, each an Effect:

CallAssertsReference engine
Test.plan(W, ...args)Nodes, edges and keys of the plan, before anything runsPlanAssertions
Test.journal(run)Which steps ran, in what order, how many attemptsJournalAssertions
Test.divergence(runA, runB)The first attributable difference between two journalsDivergence

Conformance, for a fork:

SuiteCertifiesReference engine
Test.conformance.engine()An engine: nine black-box cases for identity, interruption, replay and raceConformance.coreSuite
Test.conformance.host()A host bundleHostSuite.hostSuite
Experimental.Sandbox.check(provider)A sandbox provider (std-sandbox)SandboxConformance.check

Rules

  1. The runner is @effect/vitest. it.effect runs on a test clock, it.live on real time, as today. it.effect.fuzz runs a property under std-fuzz.
  2. Replay never spends. Test.replay holds no live model. Recording is a different call, Test.record, that names its live layer. A missing recording is a failed test, never a silent network call.
  3. A fixture is executable state. An interrupted call is not recorded, because a truncated stream would replay as an aborted turn. A call the permission kernel refused is not recorded, because the provider never saw it.
  4. Matching ignores the model id. A recording made with one model replays under another, so a test does not break when a seat changes.
  5. A recording holds no key. The recorder reads a key from Config and never writes it.
  6. No environment variable decides. Whether a suite records or replays is the suite's own code. The library reads no process.env.
  7. A model in another process is served over HTTP: Test.modelServer({ fixture }) answers Chat Completions requests from a fixture, and a request it does not hold is a 501, as in the reference engine's model server.
  8. A memory engine is not a crash test. Test.durable proves a plan and a journal. Only Test.restartable, or a real store closed and reopened, proves recovery.
  9. Nine cases certify what they test. Test.conformance.engine() is the reference engine's nine pins. A promise this set adds, such as signal delivery, needs its own case before a fork may claim it.
  10. Assertions are Effects and conformance cases are values. They run under any runner.

Host needs

Test.replay, Test.host, Test.durable and every assertion need nothing and run in a browser. Test.record writes a file and needs FileSystem. Test.modelServer needs an HTTP server.

Maintainers' decisions

This record comes from the 2026-11-09 built-in set review. The Status line above records Will’s subsequent ruling.

  • Experimental.Test, in scope with no import, as VIP-33 rules. Design · Review.
  • Its code is vibelang-runtime/experimental/Test. Design · Review.
  • It ports the reference engine's testing package. Design · Review.
  • Effect's TestClock and TestConsole keep their names and are in scope today. Design · Review.
  • Doubles, each a layer: Design · Review.
  • Layer Test.replay(fixture): Stands in for: LanguageModel; Behavior: Strict. Each recorded call is claimed once; a request the fixture does not describe is a defect. It never calls a provider; Reference engine: RecordedModel. Design · Review.
  • Each recorded call is claimed once; a request the fixture does not describe is a defect. Design · Review.
  • It never calls a provider | RecordedModel | Design · Review.
  • Layer Test.record(path, { live }): Stands in for: LanguageModel; Behavior: Replays path; on a miss it calls the live layer and writes the answer; Reference engine: CachedModel, FixtureStore.makeFile. Design · Review.
  • Layer Test.decisions(fixture), Test.recordDecisions(path, { live }): Stands in for: DecisionModel; Behavior: The same pair for decision models; Reference engine: CachedEvaluator. Design · Review.
  • Layer Test.host({ files, commands? }): Stands in for: FileSystem, Path, ChildProcessSpawner; Behavior: A deterministic machine from a record; Reference engine: TestHost.layer. Design · Review.
  • Layer Test.durable: Stands in for: The durable engine; Behavior: In memory, on a test clock; Reference engine: TestLayers.unit, MemoryEngine. Design · Review.
  • Layer Test.restartable: Stands in for: The durable engine; Behavior: In memory, with Test.crash to kill and resume a run between steps; Reference engine: RestartableEngine. Design · Review.
  • Layer Test.poisoned: Stands in for: Every service; Behavior: Any service read fails. Proves a workflow body is pure at plan time; Reference engine: TestLayers.poisoned. Design · Review.
  • Proves a workflow body is pure at plan time | TestLayers.poisoned | Design · Review.
  • Assertions, each an Effect: Design · Review.
  • Call Test.plan(W, ...args): Asserts: Nodes, edges and keys of the plan, before anything runs; Reference engine: PlanAssertions. Design · Review.
  • Call Test.journal(run): Asserts: Which steps ran, in what order, how many attempts; Reference engine: JournalAssertions. Design · Review.
  • Call Test.divergence(runA, runB): Asserts: The first attributable difference between two journals; Reference engine: Divergence. Design · Review.
  • Conformance, for a fork: Design · Review.
  • Suite Test.conformance.engine(): Certifies: An engine: nine black-box cases for identity, interruption, replay and race; Reference engine: Conformance.coreSuite. Design · Review.
  • Suite Test.conformance.host(): Certifies: A host bundle; Reference engine: HostSuite.hostSuite. Design · Review.
  • Suite Experimental.Sandbox.check(provider): Certifies: A sandbox provider (std-sandbox); Reference engine: SandboxConformance.check. Design · Review.
  • The runner is @effect/vitest. it.effect runs on a test clock, it.live on real time, as today. Design · Review.
  • it.effect.fuzz runs a property under std-fuzz. Design · Review.
  • Replay never spends. Test.replay holds no live model. Design · Review.
  • Recording is a different call, Test.record, that names its live layer. Design · Review.
  • A missing recording is a failed test, never a silent network call. Design · Review.
  • A fixture is executable state. An interrupted call is not recorded, because a truncated stream would replay as an aborted turn. Design · Review.
  • A call the permission kernel refused is not recorded, because the provider never saw it. Design · Review.
  • Matching ignores the model id. A recording made with one model replays under another, so a test does not break when a seat changes. Design · Review.
  • A recording holds no key. The recorder reads a key from Config and never writes it. Design · Review.
  • No environment variable decides. Whether a suite records or replays is the suite's own code. Design · Review.
  • The library reads no process.env. Design · Review.
  • A model in another process is served over HTTP: Test.modelServer({ fixture }) answers Chat Completions requests from a fixture, and a request it does not hold is a 501, as in the reference engine's model server. Design · Review.
  • A memory engine is not a crash test. Test.durable proves a plan and a journal. Design · Review.
  • Only Test.restartable, or a real store closed and reopened, proves recovery. Design · Review.
  • Nine cases certify what they test. Test.conformance.engine() is the reference engine's nine pins. Design · Review.
  • A promise this set adds, such as signal delivery, needs its own case before a fork may claim it. Design · Review.
  • Assertions are Effects and conformance cases are values. They run under any runner. Design · Review.
  • Test.replay, Test.host, Test.durable and every assertion need nothing and run in a browser. Design · Review.
  • Test.record writes a file and needs FileSystem. Design · Review.
  • Test.modelServer needs an HTTP server. Design · Review.

Adopted review answers

  • Keep Experimental.X names under VIP-33. Promotion to a bare module name requires a later decision. Review question 1.

Compared

The same test in the reference engine 1.x: the label function from std-model's comparison, under a recorded model. It type-checks against the reference engine's testing and model packages at 1.0.0-rc.16.

import { Model } from "@smthrs/model"
import { CachedModel, FixtureStore } from "@smthrs/testing"
import { expect, it } from "@smthrs/testing/Vitest"
import { Effect, Layer } from "effect"
import { label, layer } from "./std-model.js"
 
const model = Layer.unwrap(
  Effect.gen(function*() {
    const live = yield* Model.Model
    const store = yield* Effect.acquireRelease(FixtureStore.makeFile("fixtures/label.json"), (store) => store.flush())
    return CachedModel.layer({ live, fixture: store })
  })
).pipe(Layer.provide(layer("")))
 
it.effect("labels a crash as a bug", () =>
  Effect.gen(function*() {
    const result = yield* label("Crash on start")
    expect(result.type).toBe("bug")
  }).pipe(Effect.provide(model)))
ProgramTokens (o200k_base)Lines
Vibe, proposed: the test and the 7-line function under test14216
Reference engine 1.x: the test alone; its function under test is 317 tokens more18519

The reference engine test records and replays through one file store. The Vibe test replays an imported fixture; the recording form is provide Experimental.Test.record("fixtures/label.json", { live: Experimental.Model.use(seat) }).

Checked. The Vibe example uses only existing syntax and compiles under vibelang 0.0.13 against a declaration of Experimental.Test.replay, including the JSON import attribute and it.effect from @effect/vitest 4.1.1. The reference engine program type-checks as shown.

Principles

  • TypeScript-first. Vitest, unchanged. A double is a layer.
  • Effect-second. @effect/vitest, TestClock and TestConsole are Effect's and stay. This module adds doubles for what Effect has no double of: a model, a durable engine, a guarded host.
  • Optimized for agentic programs. A test of an agent runs in CI with no key and no network, in milliseconds.
  • Highly forkable. Principle 4 asks that a fork be simple. Conformance suites are how a fork knows its engine or host still behaves.
  • Factory-first. The factory records its model calls. A recording is a public artifact that replays.

What this changes

  • Experimental.Test is new. No grammar changes.
  • vibelang eval (eval-declarations) provides Test.replay by default and Test.record under --live.

Alternatives

  • One call that records on a miss and replays on a hit, as the reference engine's CachedModel is. One name fewer. A deleted fixture then turns a free test run into a paid one with no change to the test. Two names keep the spend in the source.
  • Mock the model with a function. It tests the mock. A recording is the provider's real answer.
  • A test keyword. Vibe has none and needs none; see eval-declarations for the same decision about evals.
  • Record at the HTTP layer, with a generic cassette library. It records keys unless scrubbed, breaks on a header change, and cannot ignore the model id.
  • Fold it into Durable and Model as Durable.test and Model.recorded. Production modules would then carry test code into bundles.

Follow-up questions

  1. Where fixtures live. Beside the test, as fixtures/<name>.json? Recommendation: yes, and Test.record with a relative path resolves from the test file.
  2. A crash fuzzer. Test.restartable crashes where a test says. std-fuzz could choose where. Listed there as a follow-up.
  3. Node 26. The reference engine's testing package requires Node.js 26.4.0 or later; the rest of the reference engine requires 22.19.0. A standard-library module should not raise the floor. Recommendation: find and remove the Node 26 dependency in the port.

Depends on