* Add formatting conventions * Add a fmt lint check * rely on defaults --------- Co-authored-by: Julius Marminge <[email protected]>
3.7 KiB
3.7 KiB
ProviderService Integration Test Plan
Goal:
- Validate end-to-end
ProviderServicebehavior with real layers:ProviderServiceLiveCheckpointServiceLiveCheckpointStoreLiveCheckpointRepositoryLive(sqlite in-memory)ProviderSessionDirectoryLive
- Only fake the adapter event source (deterministic Codex-like stream).
- Avoid mocking checkpointing/persistence orchestration logic.
Test Harness
Build a deterministic TestProviderAdapterLive in apps/server/src/provider/Layers/TestProviderAdapter.integration.ts:
- Service contract:
ProviderAdapterShape<ProviderAdapterError>. - Internal state:
- session registry (session + cwd + threadId)
- thread snapshot store (
threadId,turns) - event subscribers
- Behavior:
startSession: creates session with threadId.sendTurn: appends a deterministic turn snapshot and emits ordered events:turn/starteditem/started/item/completed(tool + approval variants depending on scenario)item/agentMessage/deltachunksturn/completed
- optional "mutator" callback per turn to change workspace files before completion.
readThread,rollbackThread,stopSession,stopAll.
Use real git-backed temporary workspaces in integration tests:
- initialize repo with baseline commit
- run provider turn in workspace
- assert checkpoint diffs against real git refs
Core Integration Specs
startSessioninitializes checkpoint root exactly once
- Arrange:
- start provider session in git repo.
- Assert:
provider_checkpointscontains root row (turn 0).- checkpoint ref exists in git.
- second
startSessionfor new session creates a new independent root.
- Turn without filesystem change
- Arrange:
- emit normal turn events, no file mutation.
- Assert:
- provider subscribers receive:
turn/startedturn/completed- synthetic
checkpoint/captured
listCheckpointsreturns root + turn 1.getCheckpointDiff(0 -> 1)returns empty/no-op diff.
- provider subscribers receive:
- Turn with filesystem change
- Arrange:
- mutate
README.mdduring turn.
- mutate
- Assert:
listCheckpointsreturns root + turn 1.getCheckpointDiff(0 -> 1)contains file path and hunk.- persisted checkpoint metadata includes non-empty
checkpointRef.
- Multi-turn sequencing and checkpoint monotonicity
- Arrange:
- turn 1: no file change
- turn 2: file change
- turn 3: file change
- Assert:
- turn counts are monotonic and contiguous in DB (0,1,2,3).
- latest checkpoint is marked current.
- diffs for adjacent turns map to expected filesystem deltas.
- Revert to checkpoint
- Arrange:
- execute 3 turns with at least one file-changing turn.
- call
revertToCheckpoint(turnCount=1).
- Assert:
- workspace content matches turn 1 state.
- adapter
rollbackThreadcalled withnumTurns=2. - DB rows for turns >1 are removed.
- later refs are deleted from git.
- Capture failure surface
- Arrange:
- adapter emits
turn/completed, but file mutation leaves invalid repo state or store capture fails.
- adapter emits
- Assert:
ProviderServiceemitscheckpoint/captureError.- no partial metadata/ref divergence is left behind.
WebSocket Coverage (Thin Integration)
Add one ws server integration spec:
- Subscribe to
providers.event. - Run a deterministic provider turn through ws methods.
- Assert push stream includes:
turn/started, tool events,turn/completed,checkpoint/captured.
- Assert orchestration projection still updates assistant message and turn diff summary.
Proposed PR Split
PR A:
- Test adapter harness + shared integration fixtures (repo setup, runtime/layer setup).
PR B:
- Core ProviderService integration specs (cases 1-4).
PR C:
- Revert + failure-path specs (cases 5-6) + ws thin integration spec.