Introducing a new way to review your PRs.

Read the announcement

helixdb / helix-db

HelixDB is an OLTP graph database with native vector and full-text search built in Rust on Object Storage.

View on GitHub

27 documents · Updated Nov 23, 2026

docs / database-testkit-verification

Database testkit verification

The database testkit is a reusable validation system for database, planner, and transport behavior. It describes work as typed actions, compares observed results with independent models, records complete request histories, and turns failures into repeatable inputs. It is a validation foundation beside telemetry collection under telemetry and validation.

Validation model

The testkit keeps the workload description separate from the system under test. A workload adapter executes the same action against an embedded database, a service, or another boundary. The testkit then checks the result, the state transition, and the resources that the action should own.

Validation flow

The flow turns a typed workload into an observed result and a reusable failure artifact.

flowchart LR
    A[Typed actions] --> B[Independent model]
    A --> C[Database or service adapter]
    B --> D[Expected state and result]
    C --> E[Observed result and trace]
    D --> F[Semantic comparison]
    E --> F
    F --> G[Replayable regression case]

The independent model is the reference for meaning. The adapter is the reference for actual behavior. This split helps the testkit find errors in storage, transaction, index, planner, and transport paths without copying their internal choices.

References: crates/…/lib.rs• L1-6 crates/…/fixtures.rs• L21-63 crates/…/replay.rs• L19-24

Modeled actions

The action language is the common input format for all execution adapters. It covers the behavior that needs to remain stable across graph reads, graph writes, index work, background work, faults, and runtime changes.

Action domains

Each action has a clear purpose and a matching result or state effect.

DomainValidation purpose
ReadsCheck point and range reads, traversal, projection, aggregates, index search, catalog state, and generation visibility.
WritesCheck node and edge creation, property changes, deletion, atomic transactions, and explicit write conflicts.
Index actionsCheck creation, build, publication, retirement, retry, abort, and recreation of a generation.
Background actionsCheck worker drain, reconciliation, compaction, reclaim, and reader topology changes.
Fault actionsCheck failpoints, corrupt durable input, cancellation, timeout, panic, disconnect, and restart.
Runtime actionsCheck writer and reader open, close, reopen, replica progress, and replica delay.

The values in an action also carry the semantic rules needed for comparison. For example, a vector has a non-zero dimension, a range has ordered bounds, and a property patch cannot be empty. Invalid workload states are rejected before they can become misleading database failures.

References: crates/…/action.rs• L431-516 crates/…/action.rs• L590-637 crates/…/action.rs• L639-841

Lifecycle states

Index lifecycle actions use state-specific transitions. An index moves from absent to building, then to active or retired. A blocked build can retry or abort. Only an active generation can be dropped, and recreation uses a new generation identity.

This model makes illegal action order visible at workload creation time and during trace validation. It also gives search checks a precise rule: pending and retired generations must not be publicly searchable.

References: crates/…/lifecycle.rs• L152-184 crates/…/lifecycle.rs• L237-404 crates/…/model.rs• L419-552

Lifecycle workloads

Lifecycle workloads test index change while normal database traffic continues. They combine seeded choice with fixed coverage so a short run reaches the important states and a longer run explores their order.

Seeded workload stages

The lifecycle runner opens the writer and readers, creates each index family, applies foreground writes, runs build work, exercises blocked and retry paths, publishes and reads generations, injects failures, and drains all resources. It validates invariants after each step. The result contains both coverage counters and a replay trace.

sequenceDiagram
    participant W as Workload
    participant O as Oracle
    participant S as System adapter
    participant T as Trace

    W->>O: Apply modeled action
    W->>S: Execute same action
    S-->>T: Record outcome and commit
    O-->>W: Expected state
    W->>W: Compare visibility and resources
    W->>T: Keep validated request history

The runner checks more than whether an action returns success. It checks atomic publication, mutation catch-up for live generations, duplicate work behavior, shared text resource references, fail-closed corruption handling, and eventual cleanup.

References: crates/…/lifecycle_workload.rs• L122-155 crates/…/lifecycle_workload.rs• L278-344 crates/…/lifecycle_workload.rs• L905-1016

Workload profiles

The same lifecycle behavior is available at different bounded sizes. Pull-request runs favor fast feedback. Nightly runs use longer histories and more competing indexes. Pre-launch runs use the broadest deterministic history.

The profile is part of the test plan rather than an accidental test-run setting. Coverage counters show whether a run reached blocked builds, retries, aborts, restarts, failpoints, reader changes, reclamation, and fail-closed errors.

References: crates/…/lifecycle_workload.rs• L29-90 crates/…/lifecycle_workload.rs• L93-120

Histories and traces

The testkit treats time, snapshots, request ownership, and outcomes as test data. This makes concurrent behavior checkable without depending on wall-clock order or a particular scheduler.

Isolation histories

An isolation history gives every open read or write a fixed committed snapshot. A read observation is valid only when its result matches that snapshot. A write exposes all staged actions at one commit or exposes none of them.

The normalized history domain covers stable reads during writes, read-after-write, failed-write atomicity, overlapping writers, generation races, and cleanup after abnormal exits. Resource accounting then checks that snapshots and transactions are released when requests finish, fail, or stop early.

References: crates/…/history.rs• L36-186 crates/…/history.rs• L270-399 crates/…/model.rs• L1245-1373

Trace records

Each request trace stores its request identity, logical start and finish times, snapshot, runtime, tenant, action, selected generation, commit sequence, and typed outcome. A typed outcome is either an observed value or a known error class.

Trace validation checks schema version, unique request identities, clock order, commit order, snapshot order, and lifecycle order. Valid traces can be written as JSON and read back without changing their meaning. This gives every failure a durable description that can move between adapters and test runs.

References: crates/…/trace.rs• L43-175 crates/…/trace.rs• L177-287 crates/…/trace.rs• L304-389

Replay and shrinking

Replay and shrinking turn a detected mismatch into a small, stable reproducer. They separate failure diagnosis from the workload that first found the problem.

Adapter replay

The replay engine sends each validated request to a workload adapter in recorded completion order. It compares the adapter's typed outcome and commit sequence with the trace. A report states how many requests ran and lists each exact mismatch.

The adapter boundary supports embedded, service, and transport execution without changing the trace format. A mismatch therefore points to a behavior difference at the selected boundary instead of to a change in test harness rules.

References: crates/…/replay.rs• L10-23 crates/…/replay.rs• L26-91 crates/…/fixtures.rs• L52-63

Trace shrinking

The shrinker removes request ranges while a caller-provided failure condition remains true. It keeps only candidates that still pass trace validation, so it cannot create an illegal lifecycle history while minimizing a failure.

Minimized traces can be stored in a file regression corpus. The filename uses the seed and content digest. Repeated saves of the same trace are stable, which makes minimized cases suitable for long-term regression use.

References: crates/…/shrink.rs• L11-97 crates/…/shrink.rs• L100-144

Fuzzing and semantic oracles

Fuzzing explores malformed input and unusual valid combinations. Semantic oracles decide whether the resulting behavior is correct without relying on the implementation that is being tested.

Fuzzing boundaries

The fuzz targets cover public query JSON, planner context and AST pairs, planner-to-interpreter execution, and stateful replay traces. The stateful target accepts only traces that deserialize and satisfy the lifecycle contract. It then checks that validated traces survive JSON round trips.

Checked-in corpora preserve minimized failures as deterministic regression seeds. Bounded corpus runs can be used before publishing planner or executor contract changes.

References: crates/…/README.md• L1-32 crates/…/stateful_action_trace.rs• L5-21

Semantic oracles

The graph oracle models nodes, edges, properties, traversal, projection, and aggregate results. The combined oracle also models secondary equality and range search, text matching, vector distance, index catalog visibility, and generation state. Its snapshots let a request read the exact committed state it owns.

The oracle uses explicit semantic rules rather than storage encoding. Numeric equality and ordering remain typed, missing values and null remain distinct where required, and search results have stable ordering and limits. A planner semantic check uses the independent graph model to compare database results with expected counts and traversal results. This protects meaning across planning and execution, not only the final response shape.

References: crates/…/model.rs• L21-165 crates/…/model.rs• L554-835 crates/…/planner_semantic_oracle.rs• L17-138

Sustained workloads

Sustained workloads extend single-history checks into concurrency and launch readiness. They describe read, write, maintenance, restart, recovery, backfill, lifecycle churn, and multi-tenant contention as named workload classes.

Each class has an explicit reader, writer, worker, and tenant topology. Replica convergence is measured by committed sequence lag as well as elapsed time. This keeps the acceptance rule tied to database progress instead of to an ungrounded timing guess.

References: crates/…/sustained.rs• L11-45 crates/…/sustained.rs• L47-140 crates/…/sustained.rs• L142-221

Launch acceptance

The launch gate compares fixed-size baseline and candidate run sets. It checks throughput, latency, memory, cache use, correctness violations, replica lag, and resource quiescence. A candidate fails when any reviewed dimension crosses its limit.

This gate joins performance evidence with correctness evidence. A fast run cannot pass if it leaves a request, worker, file, memory, or object-store resource active after shutdown.

References: crates/…/launch_gate.rs• L15-25 crates/…/launch_gate.rs• L90-245 crates/…/launch_gate.rs• L267-329

Change checklist

When these files or sections are changed, remember to consider these:

  • Update action serialization and trace validation together. A new action or outcome must remain valid for every adapter and replay reader.
  • Keep lifecycle state rules aligned with public generation visibility. A transition that changes one contract must also update the oracle and workload invariant checks.
  • Preserve snapshot and commit sequence meaning when changing transaction or read behavior. History checks compare both the result and the state version that produced it.
  • Keep minimized regression traces valid after lifecycle changes. The shrinker drops candidates that no longer satisfy trace rules, which can hide a changed failure contract if the corpus is not reviewed.
  • Update sustained workload classes and launch-gate observations together when adding a new acceptance dimension. The workload must produce evidence that the gate can evaluate.

Important failure modes

TriggerConsequenceGuard
An index action arrives in an illegal stateThe model rejects the transition and the trace cannot validateState-specific lifecycle transitions and ReplayTrace::validate
A read returns data from a newer commit than its owned snapshotThe history reports a snapshot violationSnapshot-bound observations in IsolationHistory
One action in a multi-action write failsStaged changes become visible or the model and MVCC sequences divergeAtomic write staging and commit checks
A pending or retired generation becomes searchableLifecycle visibility no longer matches the public catalogPer-step lifecycle invariant checks
A minimized candidate breaks lifecycle orderThe candidate is discarded instead of becoming a false reproducerTrace validation during shrinking
Shutdown leaves an owned resource activeThe run fails quiescence and the launch gate reports a resource leakResource accounting and post-shutdown checks
Durable input is corruptRecovery changes state instead of returning a typed fail-closed errorCorruption actions and fail-closed workload assertions

Key files

FileWhy to read it
crates/…/action.rsDefines the shared workload language and its semantic boundaries.
crates/…/model.rsDefines the independent graph, search, lifecycle, MVCC, and resource oracles.
crates/…/lifecycle_workload.rsShows how seeded lifecycle traffic, faults, traces, and invariant checks form one workload.
crates/…/history.rsShows how snapshots, atomic writes, observations, and cleanup are validated.
crates/…/trace.rsDefines the durable request trace and its validation rules.
crates/…/replay.rsDefines the adapter boundary and exact replay comparison.
crates/…/shrink.rsDefines valid trace minimization and regression corpus storage.
crates/…/README.mdMaps fuzz targets to the semantic boundaries they explore.
crates/…/sustained.rsDefines sustained workload classes and sequence-based lag checks.
crates/…/launch_gate.rsDefines the combined correctness, performance, lag, and resource acceptance gate.