testing library
Public testing-support library for grid_engine.
The reusable, engine-only Fakes (not mocks) the offline suite drives the reactive kernel with — a controllable FakeRuntimeProvider, the recording bd-write chokepoint (RecordingBdRunner/GatedCreateBdRunner), the land ops (RecordingGitRunner/FakePrOpener), the observable FakeSnapshotSource, the buildFakes/bead/sessionBead builders, and the reentrant inflater fakes (RecordingCapabilityRegistry/FakeCapabilityHost). Promoted to a public library so downstream asset packages (grid_assets) reuse the SAME fakes — the cross-package enabler for the opinion extraction (ADR-0007 §1).
The code-asset-specific helpers (kCodeResolver, the code circuit) are NOT
here — they reference the moved opinions and live in grid_assets's test
support. Pure-Dart: no live tg/gc/claude/git/network.
Classes
- EmptyBeadProbeReader
- Empty lifecycle reader for mutation-only fixtures.
- FakeCapabilityHost
-
A recording fake leaf (NOT the real
CapabilityHost): records its mount / unmount with its capabilityId, session, and path, and is a pureIdleleaf. - FakePrOpener
-
A recording
PrOpener: records everyopencall and returns a settablePullRequestResult(success with a configurable url, or a failure). Never touches real GitHub. - FakeRuntimeProvider
- Records start/stop calls and exposes a controllable events stream so a test emits SessionStarted/Exited/Died on demand. Only the members the effect touches are meaningful; the rest are honest no-ops over an empty surface.
- FakeSnapshotSource
-
A fake SnapshotSource: a broadcast StreamController the test pushes
through, plus a settable current (mirroring the real runtime's
last-emitted accessor).
pushupdatescurrentAND emits, 1:1, like the change-gated runtime. - FakeTreeContext
-
A fake
TreeContextfor driving an Allocation/Capability bare — no mounted tree. Ambient values resolve fromvaluesby EXACT type (mirroring genesis's exact-type inherited lookup). Flip mounted to false to exercise the loud async-gap protection (getInheritedSeedOfExactType then throws, like the real handle). - FixedRouteCapability
- A RouteCapability that returns a FIXED verdict — the offline route stand-in every routing test drives the router with.
- GatedCreateBdRunner
-
A
BdRunnerwhosecreateparks until releaseCreate is called, so a test can drive a dispose into the middle of the async mint. - RecordingBdRunner
-
A recording
BdRunner(the grid_runtime fake shape): records full argv + stdin so a test asserts the EXACT bd commands, andcreatereturns a caller-controlled synthetic id so the mint+stamp is exercised with no realbd. - RecordingCapabilityRegistry
-
A recording CapabilityRegistry:
hostmounts a fake leaf that recordsSTART/STOP <capabilityId>(<sessionId>/<nodePath>)so a test asserts the inflation frontier AND the disjoint per-session routing;circuitresolves fromcircuits;nowis a fixedclock. - RecordingDeliveryMethod
- A recording DeliveryMethod: records every request and returns a settable StepOutcome. Set throwNext to prove the throwing-delivery → supervision path. Delivers nothing anywhere.
- RecordingEscalationHandler
- A recording EscalationHandler: records every escalation and returns a settable EscalationDecision (default: park, like HumanGate).
- RecordingExplorationTransport
- Records ExplorationTransport.flare calls for offline tests.
- RecordingGitRunner
-
A recording
GitRunner: records everygitargv (with its cwd) in order, and returns a configurable result so commit/push readok. Wrap it in the realGitOpsso the land step's realadd -A/commit -m/push -uargv is what gets recorded (Fakes, not mocks).
Constants
- stateSubstation → const String
- The_grid's owned state substation in the offline fakes.
Functions
-
advancingClock(
{DateTime? from, Duration step = const Duration(seconds: 1)}) → DateTime Function() -
A monotonically ADVANCING clock (FT-1, tg-pez) — each call returns the next
instant
stepapart, starting atfrom(default DateTime(2026)). Feed to RecordingCapabilityRegistry.new'snowFnso the host's kick and terminal read DISTINCT instants, provingstartedAt < finishedAtand a deterministicdurationMs(the first twonow()calls of a clean transition arestepapart). -
bead(
String id) → Bead -
An open task bead with
id. -
buildFakes(
{String createdId = 'tgdog-sess1', WorkSignalProbe? workSignal}) → Fakes - Builds an StationServices over the fakes (the chokepoint writes through a recording bd runner; the transport is a controllable provider; land is wired to the recording git/PR ops) and returns it with the recorders.
-
sessionBead(
{required String id, required String workBeadId, bool closed = false, bool outcomeComplete = false, bool escalated = false, Map< String, String> metadata = const {}}) → Bead -
A
type=sessionstate bead linkingworkBeadId— the row the join bridge projects + keys bywork_bead, carrying the OWNED substation marker (the persistedmetadata.rigkey — codec law; so the chokepoint's ownership re-check passes) + the I-10 closed-session shapes (the engine's own DONE evidence viaoutcomeComplete, a HUMAN marker viaescalated). -
stepArgs(
String nodePath, {Map< String, String> params = const {}, CancelToken? cancel}) → StepArgs - StepArgs for a bare-driven capability/allocation (a fresh CancelToken unless one is injected).
-
testWorkspace(
String beadId, {String? workspaceDir, String branch = '', String baseBranch = 'main'}) → Workspace -
A Workspace for a bare-driven test (the synthetic offline shape
SessionScopemounts when no source control is wired).
Typedefs
- Fakes = ({StationServices ctx, RecordingGitRunner git, FakePrOpener pr, FakeRuntimeProvider provider, RecordingBdRunner runner})
- A bundle of an StationServices over the fakes plus the recording collaborators the test asserts against.