Replay & verify
Verdicts & divergences
The rules are identical for every runtime, live in lib/src/core/verdict.dart, and are pinned by spec/fixtures/conformance/verdicts.json. They are deliberately strict: an attempt that didn't run as recorded is never evidence of a fix.
Attempts
| Attempt status | When |
|---|---|
| reproduced | The original failure assertion fired (same signature). |
| clean | It ran to the end as recorded: there is a failure assertion to check, every recorded input was dispatched, required restoration happened, no other failure fired, and nothing material diverged. |
| invalid | Anything else: errors, timeouts, crashes without a report, incompatible capsules, no assertion, material divergences. |
Batches (legacy verdict v1)
The table below describes the legacy rules. CLI 0.4.2 uses verdict v2 by default; use that section for current FIXED requirements.
bugcapsule run | bugcapsule verify | Rule | Exit |
|---|---|---|---|
| REPRODUCED | — | Every requested attempt reproduced | 0 |
| — | FIXED | Every requested attempt clean | 0 |
| NOT REPRODUCED | — | Every requested attempt clean | 1 |
| — | STILL FAILING | Reproduced, no clean attempt | 1 |
| FLAKY | FLAKY | Both reproduced and clean attempts | 2 |
| INCONCLUSIVE | INCONCLUSIVE | Anything else | 3 |
| INCOMPATIBLE | INCOMPATIBLE | Wrong runtime, state schema changed, or (spec v2) a required adapter is missing or a connection can't be restored | 3 |
Attempts that never ran count against the requested number. One clean attempt plus one error is INCONCLUSIVE, never FIXED. The verdict is recorded on your project with the number of valid attempts; a capsule moves to fixed only when every requested attempt was valid.
In regress run: FIXED → pass; STILL FAILING → fail; FLAKY → the test is quarantined (skipped unless --include-quarantined); INCOMPATIBLE → stale (schema changed without a migration); anything else → inconclusive, counted as a failure.
Verdict v2
Default in CLI 0.4.2. Install the current SDK releases to capture the evidence verdict v2 needs. The dashboard shows v2 results. See What's new.
Two clean attempts are not proof. A race that reproduces half the time also misses twice in a row on unchanged code. Under verdict v2 a candidate is never FIXED merely because the original failure didn't fire. verify reports FIXED only when all of these hold:
- The baseline reproduced. The capsule's own commit, built clean in a temporary worktree, reproduced the failure in every one of at least 3 attempts (
--baseline-runs, default 3). A baseline that reproduces only sometimes makes the result FLAKY. No baseline (no git SHA in the capsule, a commit missing from your repository, prebuilt artifacts) makes it INCONCLUSIVE. From CLI 0.4.2, a baseline whose attempts could not reach the replay server is reported unavailable (baseline.unavailable) and is never cached. - Enough candidate attempts ran, all clean. The number depends on the baseline (the Wilson 95% lower bound of its reproduction rate, at least 5 and at most 30). The CLI raises
--runsto it and says so. - Each clean attempt has positive evidence that the failing path ran (below).
- The capsule is eligible and nothing material diverged.
| Baseline | Clean candidate attempts needed |
|---|---|
| 3/3 | 8 |
| 5/5 | 6 |
| 10/10 | 5 |
| 11/20 | — (baseline is FLAKY: no FIXED) |
A baseline is cached under bugcapsule/.cache/baselines/ for 7 days, keyed by the capsule, the baseline revision and the harness (CLI version, runtime, strict network, settle timeout), so CI builds each old commit once.
Positive evidence
Each replay result from a v2 SDK carries evidence:
| Evidence | When | Best verdict |
|---|---|---|
| strong | The capsule's own BugCapsule.check(id, condition) ran during replay and held, or every postcondition you registered with BugCapsule.expect held | FIXED |
| weak | Only that every recorded input was dispatched and replay settled past the recorded failure point | FIXED (QUALIFIED) |
| none | No evidence (reports from older SDKs), or a postcondition didn't hold or threw | INCONCLUSIVE (STILL FAILING when a postcondition failed) |
Postconditions say what must hold after the scenario replays without its failure. They are evaluated once, after a clean replay settles, and do nothing outside replay. Capsules from exceptions reach FIXED only with a postcondition, because "the exception didn't fire" is not evidence.
BugCapsule.check('cart_total_non_negative', total >= 0);
BugCapsule.expect('cart_total_positive', () => cart.total > 0);
BugCapsule.check("cart.total", cart.total >= 0)
BugCapsule.expect("cart.total_positive") { cart.total > 0 }
BugCapsule.check("cart_total_non_negative", total >= 0)
BugCapsule.expect("cart_total_positive") { cart.total > 0 }
BugCapsule.check('cart_total_non_negative', total >= 0);
BugCapsule.expect('cart.total_positive', () => cart.total > 0);
New verdicts and exit codes
| Verdict | When | Exit |
|---|---|---|
| FIXED (QUALIFIED) | As FIXED, but the evidence is weak, or the capsule is partial or touched unsupported sources. The run lists its limitations. --accept-qualified exits 0 instead. | 4 |
| UNSAFE | Replay containment was broken: live traffic was allowed (--allow-live, or --lenient-network reaching a live dependency). Applies to run and verify, even when the failure reproduced. | 5 |
Neither counts as fixed: your project stores them as inconclusive, and the dashboard shows the precise verdict and the reason. run keeps its verdicts, adds UNSAFE, and REPRODUCED also needs evidence that the failure site was reached.
Per command
verifybuilds the baseline itself (above).regress runapplies the same rules per test and keeps each test's baseline in its entry underbugcapsule/regressions, so CI doesn't rebuild old commits. A test that can't be verified fails the run.gatetakes the baseline from the newest completebugcapsule runrecorded for the capsule, because CI gates a build of the release and can't rebuild the bug. A capsule without one stays INCONCLUSIVE, which blocks the gate only with--fail-on unverified(orerror). FIXED (QUALIFIED) and UNSAFE count as unverified too.--verdict-v1keeps the old rules on all three commands for one minor release. It is refused whenCI=trueunlessBUGCAPSULE_ALLOW_VERDICT_V1=1. Runs recorded before v2 keep their verdict and are never upgraded to a v2 FIXED.
Two divergences also become material under v2: screen.size when the attempt dispatched coordinate taps (semantic actions keep it informational), and network.unused when the unused response was served before the failure point in the baseline.
Divergence catalogue
Types not marked expected are material: an attempt with one can't count as clean. Unknown divergence types are material too.
| Type | Means | What to do | |
|---|---|---|---|
build.gitSha | expected | Replayed build is a different commit (normal for verify) | Nothing |
screen.size | expected | Different screen; pointer coordinates were scaled | Use the capture device, or add semantic actions |
network.unused | expected | A recorded response was never requested | Nothing |
network.unrecorded | material | The app sent a request the recording never saw | Add an endpoint rule for volatile fields; if a fix changed the requests, capture a new capsule on the fixed path |
network.reused | material | More requests with one key than recorded; the last fixture was served again | Check for retries or duplicate calls in the replayed build |
network.noBody | material | A fixture without a body was served | Keep body capture on for that endpoint; raise maxBodyBytes |
network.escaped | material | Web: a browser request bypassed the SDK to another origin. From the next web release, also any non-static request from the app's own origin (fetch/XHR the SDK didn't serve, beacons, EventSource, form posts, workers) and any real WebSocket | Init before code grabs fetch; add static origins to web.allowOrigins; replay a production-style build without a live-reload socket |
restore.disallowed | material | a storage key outside the capture's recorded storage policy (or the replayed build's allowlist) was not restored | Allow the key in both the capturing and the replayed build, then capture again |
replay.unsafe_live | material | Next web release: a request matched --allow-live and reached the real network. The run is UNSAFE | Use --allow-live only to debug the replay setup |
action.unregistered | material | A recorded action id isn't registered in the replayed build | Register it (renamed? registered late?) |
text.untracked | material | A recorded text id isn't tracked in the replayed build | Track it before the replay's input reaches it |
text.redacted, storage.redacted, state.redacted, route.redacted | material | A value was redacted on device and replayed as a placeholder | For QA builds, keep test-account tokens out of the deny list, or exclude that flow |
pointer.mismatch, selector.ambiguous, selector.missing | material | Web: the element at the recorded point isn't the recorded target | Add stable data-testid / data-bugcapsule-action attributes |
pointer.unsupported | material | iOS: the capsule needs pointer replay | Wrap the taps in BugCapsule.action |
lifecycle.unsupported | material | The runtime can't drive a recorded lifecycle state | Usually unavoidable (iOS hidden) |
restore.<integration> | material | A restorer threw | Fix the restore callback / serializer |
restore.missing, restore.missingIntegration, integration.missing | material | Captured data has no integration to restore it | Add the same integrations to the replayed build |
restore.late | material | A restorer registered after the first input, or storage was read before restoration | Init first; register state earlier |
bloc.unrestored, riverpod.unrestored, notifier.unrestored, getx.unrestored, mobx.unrestored | material | Flutter: state couldn't be injected from a periodic checkpoint | Register a serializer; avoid constructor-dispatched events |
capability.unsupported | material | The capsule needs a capability the replaying runtime lacks | See the feature matrix |
dispatch.error | material | Dispatching a recorded input threw | Read the attempt's details |
failure.other | material | A different failure fired | It may be a new bug; inspect it |
runtime.mismatch | incompatible | Capsule from another runtime | Replay in the right project (-p, --runtime) |
Interaction divergences and reason codes
Available in the stable releases (Flutter 0.4.2, Android 0.4.1, iOS 0.4.2 and web 0.4.0), for spec v2 capsules that recorded WebSockets, platform channels or native SDKs.
Replay serves recorded interactions offline and never contacts the real socket, plugin or SDK. Each family (ws, platform, native) reports the same divergences:
| Type | Means | What to do | |
|---|---|---|---|
*.unusedAfterFailure | expected | A recorded interaction after the failure time was never used | Nothing |
*.unrecorded | material | The app connected, sent, called or subscribed to something with no recorded match, also when the capsule has no recording for that adapter. The operation fails (connection error, bugcapsule.unrecorded) | As with network.unrecorded: if a fix changed the traffic, capture a capsule on the fixed path |
*.mismatch | material | Matched by order, but the payload or arguments differ from the recording | Mark volatile fields as ignored; check what the replayed build sends |
*.unused | material | A recorded interaction at or before the failure was never matched or delivered | The replayed build skipped a connection or call the recording made |
*.undelivered | material | A due delivery waited too long (5 s) for its handler | Listen to the stream or set the handler as the recording did |
*.noPayload | material | A delivery needed a value that wasn't recorded in full (size only, truncated, omitted, redacted) | Register a binary serializer, keep the payload under the limit, or allow redacted replay; capture again |
*.unrestored | material | A connection or subscription open at a periodic checkpoint couldn't be restored | Capture from launch |
dependency.live | material | A dependency was reached for real during replay (it escaped the adapter) | Route every use through the integration; web: open sockets after init, not in workers |
dependency.late | material | Flutter: the adapter was set up after the dependency (the binding existed before BugCapsule.init) | Make BugCapsule.init the first line of main |
Verdicts keep the same names. Runs add reason codes derived from these divergences; the CLI prints them under Why, and the dashboard explains them on the run:
| Reason code | From |
|---|---|
dependency.unsupported | Preflight: a required adapter is missing, doesn't support the recorded schema, or an open connection can't be restored (dependency.unsupported, dependency.schema, dependency.unrestorable). The attempt is INCOMPATIBLE and the app never starts. |
interaction.missing | *.unused, *.undelivered |
interaction.unexpected | *.unrecorded |
interaction.mismatch | *.mismatch |
interaction.incomplete | *.noPayload |
interaction.live | dependency.live, dependency.late |
interaction.unrestored | *.unrestored |
Why such a verify is never FIXED: a missing, unexpected or mismatched interaction, a value replay couldn't hand over, a real dependency reached, or a connection that wasn't restored means the attempt didn't run as recorded, so the failure not firing proves nothing. Those attempts are invalid, and BugCapsule never marks a capsule fixed by a run with interaction divergences. Only *.unusedAfterFailure is expected: after a fix, the app may not reach what was recorded after the failure.
Reading a result
$ bugcapsule verify 35f3c4ba-… -n 3 -p examples/shop
verify #1 PASS 9.6s pointer, 6 inputs, 6 responses (×3)
FIXED — failure gone in 3/3 valid runs
recorded: status fixed; runs: replay reproduced 3/3, verify not_reproduced 3/3 (validAttempts 3)
$ VITE_BUGCAPSULE_DEMO_FIX=discontinued bugcapsule verify 5200d4bc-… -n 2
verify #1 INVALID 8.3s … unexpected failure: …no recorded response for POST …/api/checkout
INCONCLUSIVE
The second one is correct: the fix makes the app send a request the recording never saw, so strict replay can't prove the bug is gone. Capture a capsule that covers the fixed path.
Login-gated flows
Tokens and OTPs are redacted on device, so replaying a flow behind a login often hits *.redacted and becomes inconclusive (a missing token can send the app down another path). For QA builds, use a test account whose token you deliberately leave out of the deny list, or start the failing flow after login so the token isn't part of it.