@vitest-agent/engine 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -0
  3. package/index.d.ts +2679 -0
  4. package/index.js +63 -0
  5. package/layers/ConfigLive.js +46 -0
  6. package/layers/DataReaderLive.js +1923 -0
  7. package/layers/DataStoreLive.js +1283 -0
  8. package/layers/DetailResolverLive.js +9 -0
  9. package/layers/DiscoveryRegistryLive.js +70 -0
  10. package/layers/EnvironmentDetectorLive.js +36 -0
  11. package/layers/EnvironmentDetectorTest.js +13 -0
  12. package/layers/ExecutorResolverLive.js +9 -0
  13. package/layers/FormatSelectorLive.js +20 -0
  14. package/layers/HistoryTrackerLive.js +49 -0
  15. package/layers/HistoryTrackerTest.js +25 -0
  16. package/layers/LoggerLive.js +70 -0
  17. package/layers/OutputPipelineLive.js +20 -0
  18. package/layers/OutputRendererLive.js +23 -0
  19. package/layers/PathResolutionLive.js +46 -0
  20. package/layers/PerClientSessionMapLive.js +145 -0
  21. package/layers/ProjectDiscoveryLive.js +67 -0
  22. package/layers/ProjectDiscoveryTest.js +12 -0
  23. package/layers/ProjectIdentityLive.js +95 -0
  24. package/layers/RunContextLive.js +82 -0
  25. package/lib/format-triage.js +103 -0
  26. package/lib/format-wrapup.js +67 -0
  27. package/migrations/0001_initial.js +824 -0
  28. package/migrations/0002_test_artifacts.js +30 -0
  29. package/migrations/index.js +27 -0
  30. package/migrations/registry_0001_initial.js +39 -0
  31. package/migrations/session_map_0001_initial.js +38 -0
  32. package/package.json +59 -0
  33. package/platform.js +58 -0
  34. package/programs/end-agent.js +19 -0
  35. package/programs/hook-paths.js +115 -0
  36. package/programs/platform-sidecar.js +37 -0
  37. package/programs/record-session.js +49 -0
  38. package/programs/record-tdd-artifact.js +119 -0
  39. package/programs/record-turn.js +61 -0
  40. package/programs/record-workspace-changes.js +57 -0
  41. package/programs/register-agent.js +85 -0
  42. package/programs/resolve-session-for-recording.js +44 -0
  43. package/programs/session-env.js +85 -0
  44. package/project-dir.js +32 -0
  45. package/services/Config.js +15 -0
  46. package/services/DataReader.js +8 -0
  47. package/services/DataStore.js +15 -0
  48. package/services/DetailResolver.js +8 -0
  49. package/services/DiscoveryRegistry.js +8 -0
  50. package/services/EnvironmentDetector.js +8 -0
  51. package/services/ExecutorResolver.js +8 -0
  52. package/services/FormatSelector.js +8 -0
  53. package/services/HistoryTracker.js +20 -0
  54. package/services/OutputRenderer.js +8 -0
  55. package/services/PerClientSessionMap.js +22 -0
  56. package/services/ProjectDiscovery.js +8 -0
  57. package/services/ProjectIdentity.js +62 -0
  58. package/services/RunContext.js +53 -0
  59. package/services/idempotency.js +58 -0
  60. package/sql/assemblers.js +69 -0
  61. package/testing/layers.js +16 -0
  62. package/testing.d.ts +1101 -0
  63. package/testing.js +243 -0
  64. package/tsdoc-metadata.json +11 -0
  65. package/utils/ensure-migrated.js +47 -0
  66. package/utils/failure-signature.js +34 -0
  67. package/utils/resolve-data-path.js +64 -0
  68. package/utils/resolve-project-key-from-cwd.js +52 -0
  69. package/utils/resolve-workspace-key.js +41 -0
  70. package/version.js +6 -0
package/testing.d.ts ADDED
@@ -0,0 +1,1101 @@
1
+ import { Agent, Agent as Agent$1, AgentId, AgentNotFoundError, AgentNotFoundError as AgentNotFoundError$1, AgentReport, AgentReport as AgentReport$1, ArtifactKind, ArtifactKind as ArtifactKind$1, ArtifactKind as ArtifactKind$2, ArtifactSuite, ArtifactSuite as ArtifactSuite$1, ArtifactSuite as ArtifactSuite$2, BehaviorDetail, BehaviorDetail as BehaviorDetail$1, BehaviorNotFoundError, BehaviorNotFoundError as BehaviorNotFoundError$1, BehaviorRow, BehaviorRow as BehaviorRow$1, BehaviorStatus, BehaviorStatus as BehaviorStatus$1, CacheManifest, CacheManifest as CacheManifest$1, ChatId, CitedArtifact, CitedArtifact as CitedArtifact$1, CoverageBaselines, CoverageBaselines as CoverageBaselines$1, CoverageReport, CoverageReport as CoverageReport$1, DataStoreError, DataStoreError as DataStoreError$1, FileCoverageReport, FileCoverageReport as FileCoverageReport$1, GoalDetail, GoalDetail as GoalDetail$1, GoalNotFoundError, GoalNotFoundError as GoalNotFoundError$1, GoalRow, GoalRow as GoalRow$1, GoalStatus, GoalStatus as GoalStatus$1, HistoryRecord, HistoryRecord as HistoryRecord$1, IdempotencyHit, IdempotencyHit as IdempotencyHit$1, IllegalStatusTransitionEntity, IllegalStatusTransitionError, IllegalStatusTransitionError as IllegalStatusTransitionError$1, Phase, Phase as Phase$1, RegistrationConflictError, RegistrationConflictError as RegistrationConflictError$1, ResolvedThresholds, ResolvedThresholds as ResolvedThresholds$1, TddTaskAlreadyEndedError, TddTaskAlreadyEndedError as TddTaskAlreadyEndedError$1, TddTaskEndOutcome, TddTaskNotFoundError, TddTaskNotFoundError as TddTaskNotFoundError$1, TrendEntry, TrendEntry as TrendEntry$1, TrendRecord, TrendRecord as TrendRecord$1 } from "@vitest-agent/sdk";
2
+ import { Context, Effect, Layer, Option } from "effect";
3
+ //#region src/services/DataStore.d.ts
4
+ /** @public */
5
+ interface CreateGoalInput {
6
+ readonly tddTaskId: number;
7
+ readonly goal: string;
8
+ }
9
+ /** @public */
10
+ interface UpdateGoalInput {
11
+ readonly id: number;
12
+ readonly goal?: string;
13
+ readonly status?: GoalStatus$1;
14
+ }
15
+ /** @public */
16
+ interface CreateBehaviorInput {
17
+ readonly goalId: number;
18
+ readonly behavior: string;
19
+ readonly suggestedTestName?: string;
20
+ readonly dependsOnBehaviorIds?: ReadonlyArray<number>;
21
+ }
22
+ /** @public */
23
+ interface UpdateBehaviorInput {
24
+ readonly id: number;
25
+ readonly behavior?: string;
26
+ readonly suggestedTestName?: string | null;
27
+ readonly status?: BehaviorStatus$1;
28
+ readonly dependsOnBehaviorIds?: ReadonlyArray<number>;
29
+ }
30
+ /** @public */
31
+ interface SettingsInput {
32
+ readonly vitestVersion: string;
33
+ readonly pool?: string;
34
+ readonly environment?: string;
35
+ readonly testTimeout?: number;
36
+ readonly hookTimeout?: number;
37
+ readonly slowTestThreshold?: number;
38
+ readonly maxConcurrency?: number;
39
+ readonly maxWorkers?: number;
40
+ readonly isolate?: boolean;
41
+ readonly bail?: number;
42
+ readonly globals?: boolean;
43
+ readonly fileParallelism?: boolean;
44
+ readonly sequenceSeed?: number;
45
+ readonly coverageProvider?: string;
46
+ }
47
+ /** @public */
48
+ interface TestRunInput {
49
+ readonly invocationId: string;
50
+ readonly project: string;
51
+ readonly settingsHash: string;
52
+ readonly timestamp: string;
53
+ readonly commitSha: string | null;
54
+ readonly branch: string | null;
55
+ readonly reason: "passed" | "failed" | "interrupted";
56
+ readonly duration: number;
57
+ readonly total: number;
58
+ readonly passed: number;
59
+ readonly failed: number;
60
+ readonly skipped: number;
61
+ readonly scoped: boolean;
62
+ readonly snapshotAdded?: number;
63
+ readonly snapshotMatched?: number;
64
+ readonly snapshotUnmatched?: number;
65
+ readonly snapshotUpdated?: number;
66
+ readonly snapshotUnchecked?: number;
67
+ readonly snapshotTotal?: number;
68
+ readonly snapshotFailure?: boolean;
69
+ readonly snapshotDidUpdate?: boolean;
70
+ readonly snapshotFilesAdded?: number;
71
+ readonly snapshotFilesRemoved?: number;
72
+ readonly snapshotFilesUnmatched?: number;
73
+ readonly snapshotFilesUpdated?: number;
74
+ /**
75
+ * Attribution columns added by the agent-agnostic taxonomy work. The
76
+ * reporter walks env vars / session map to populate these; un-attributed
77
+ * runs default to actor_type='system' and NULL agent/conversation ids.
78
+ */
79
+ readonly actorType?: "agent" | "user" | "system";
80
+ readonly agentId?: string | null;
81
+ readonly conversationId?: string | null;
82
+ /**
83
+ * Git context the run executed against. NULL for non-git workspaces.
84
+ */
85
+ readonly gitBranch?: string | null;
86
+ readonly gitCommitSha?: string | null;
87
+ readonly gitDirty?: boolean | null;
88
+ readonly gitUpstream?: string | null;
89
+ readonly gitWorktreeDir?: string | null;
90
+ /**
91
+ * Host metadata probe result (terminal pane, CI runner). NULL when no
92
+ * probe in the priority chain matched.
93
+ * @public
94
+ */
95
+ readonly hostSource?: string | null;
96
+ readonly hostValue?: string | null;
97
+ readonly hostMetadata?: Record<string, unknown> | null;
98
+ }
99
+ /** @public */
100
+ interface ModuleInput {
101
+ readonly fileId: number;
102
+ readonly relativeModuleId: string;
103
+ readonly state: string;
104
+ readonly duration?: number;
105
+ readonly environmentSetupDuration?: number;
106
+ readonly prepareDuration?: number;
107
+ readonly collectDuration?: number;
108
+ readonly setupDuration?: number;
109
+ readonly heap?: number;
110
+ }
111
+ /** @public */
112
+ interface TestCaseInput {
113
+ readonly suiteId?: number;
114
+ readonly vitestId?: string;
115
+ readonly name: string;
116
+ readonly fullName: string;
117
+ readonly state: string;
118
+ readonly classification?: string;
119
+ readonly duration?: number;
120
+ readonly startTime?: number;
121
+ readonly flaky?: boolean;
122
+ readonly slow?: boolean;
123
+ readonly retryCount?: number;
124
+ readonly repeatCount?: number;
125
+ readonly heap?: number;
126
+ readonly mode?: string;
127
+ readonly each?: boolean;
128
+ readonly fails?: boolean;
129
+ readonly concurrent?: boolean;
130
+ readonly shuffle?: boolean;
131
+ readonly timeout?: number;
132
+ readonly skipNote?: string;
133
+ readonly locationLine?: number;
134
+ readonly locationColumn?: number;
135
+ readonly tags?: readonly string[];
136
+ /**
137
+ * FK to `turns(id)`. Set by the reporter when the test case row was
138
+ * authored within a recorded turn (D2 binding rule 1).
139
+ * @public
140
+ */
141
+ readonly createdTurnId?: number;
142
+ }
143
+ /** @public */
144
+ interface StackFrameInput {
145
+ readonly ordinal: number;
146
+ readonly method: string | null;
147
+ readonly filePath: string;
148
+ readonly line: number;
149
+ readonly col: number;
150
+ readonly sourceMappedLine?: number;
151
+ readonly functionBoundaryLine?: number;
152
+ }
153
+ /** @public */
154
+ interface TestErrorInput {
155
+ readonly testCaseId?: number;
156
+ readonly testSuiteId?: number;
157
+ readonly moduleId?: number;
158
+ readonly scope: "test" | "suite" | "module" | "unhandled";
159
+ readonly name?: string;
160
+ readonly message: string;
161
+ readonly diff?: string;
162
+ readonly actual?: string;
163
+ readonly expected?: string;
164
+ readonly stack?: string;
165
+ readonly causeErrorId?: number;
166
+ readonly signatureHash?: string;
167
+ readonly frames?: ReadonlyArray<StackFrameInput>;
168
+ readonly ordinal?: number;
169
+ }
170
+ /** @public */
171
+ interface TestAttachmentInput {
172
+ readonly contentType?: string;
173
+ /** Post-resolution path under `.vitest/attachments/`, or an http(s) URL. */
174
+ readonly path?: string;
175
+ /** Inline body; persisted only when `byteSize` is under the 64 KiB cap. */
176
+ readonly body?: string;
177
+ /** How to read `body`. Vitest treats a string body as base64 unless `"utf-8"`. */
178
+ readonly bodyEncoding?: "base64" | "utf-8";
179
+ readonly byteSize: number;
180
+ }
181
+ /** @public */
182
+ interface TestAnnotationInput {
183
+ readonly testCaseId: number;
184
+ /** Arbitrary Vitest annotation type -- not an enum. */
185
+ readonly type: string;
186
+ readonly message: string;
187
+ readonly locationFile?: string;
188
+ readonly locationLine?: number;
189
+ readonly locationColumn?: number;
190
+ readonly attachments?: ReadonlyArray<TestAttachmentInput>;
191
+ }
192
+ /** @public */
193
+ interface TestArtifactInput {
194
+ readonly testCaseId: number;
195
+ /** `pkg:name`; `internal:` types are Vitest's own and are never written. */
196
+ readonly type: string;
197
+ readonly message?: string;
198
+ /** JSON of the artifact's custom fields, minus attachments and location. */
199
+ readonly data?: string;
200
+ readonly locationFile?: string;
201
+ readonly locationLine?: number;
202
+ readonly locationColumn?: number;
203
+ readonly attachments?: ReadonlyArray<TestAttachmentInput>;
204
+ }
205
+ /** @public */
206
+ interface FileCoverageInput {
207
+ readonly fileId: number;
208
+ readonly statements: number;
209
+ readonly branches: number;
210
+ readonly functions: number;
211
+ readonly lines: number;
212
+ readonly uncoveredLines?: string;
213
+ /**
214
+ * Coverage tier this row represents. `'below_threshold'` is the
215
+ * build-failing tier (file falls below the configured minimum
216
+ * coverage thresholds). `'below_target'` is the warning tier (file
217
+ * is above thresholds but below the aspirational target).
218
+ *
219
+ * Defaults to `'below_threshold'` when omitted, matching the only
220
+ * tier that existed before migration 0005.
221
+ * @public
222
+ */
223
+ readonly tier?: "below_threshold" | "below_target";
224
+ }
225
+ /** @public */
226
+ interface SuiteInput {
227
+ readonly parentSuiteId?: number;
228
+ readonly name: string;
229
+ readonly fullName: string;
230
+ readonly state: "pending" | "passed" | "failed" | "skipped";
231
+ readonly mode?: "run" | "only" | "skip" | "todo";
232
+ readonly concurrent?: boolean;
233
+ readonly shuffle?: boolean;
234
+ readonly retry?: number;
235
+ readonly repeats?: number;
236
+ readonly locationLine?: number;
237
+ readonly locationColumn?: number;
238
+ }
239
+ /** @public */
240
+ interface NoteInput {
241
+ readonly title: string;
242
+ readonly content: string;
243
+ readonly scope: "global" | "project" | "module" | "suite" | "test" | "note";
244
+ readonly project?: string;
245
+ readonly testFullName?: string;
246
+ readonly modulePath?: string;
247
+ readonly parentNoteId?: number;
248
+ readonly createdBy?: string;
249
+ readonly expiresAt?: string;
250
+ readonly pinned?: boolean;
251
+ }
252
+ /** @public */
253
+ interface SessionInput {
254
+ readonly chatId: string;
255
+ readonly project: string;
256
+ readonly cwd: string;
257
+ readonly agentKind: "main" | "subagent";
258
+ readonly agentType?: string;
259
+ readonly parentSessionId?: number;
260
+ readonly triageWasNonEmpty?: boolean;
261
+ readonly startedAt: string;
262
+ /**
263
+ * Canonical conversation UUID this session belongs to (issue #144).
264
+ * Set once at INSERT time — `sessions.conversation_id` is immutable
265
+ * thereafter (see the `trg_sessions_conv_id_immutable` trigger), so
266
+ * omit it here rather than trying to backfill via an update.
267
+ */
268
+ readonly conversationId?: string;
269
+ }
270
+ /** @public */
271
+ interface TurnInput {
272
+ readonly sessionId: number;
273
+ /** When omitted, writeTurn computes MAX(turnNo) + 1 for the session. */
274
+ readonly turnNo?: number;
275
+ readonly type: "user_prompt" | "tool_call" | "tool_result" | "file_edit" | "hook_fire" | "note" | "hypothesis";
276
+ readonly payload: string;
277
+ readonly occurredAt: string;
278
+ }
279
+ /** @public */
280
+ interface FailureSignatureWriteInput {
281
+ readonly signatureHash: string;
282
+ readonly runId: number;
283
+ readonly seenAt: string;
284
+ }
285
+ /** @public */
286
+ interface HypothesisInput {
287
+ readonly sessionId: number;
288
+ readonly content: string;
289
+ readonly createdTurnId?: number;
290
+ readonly citedTestErrorId?: number;
291
+ readonly citedStackFrameId?: number;
292
+ }
293
+ /** @public */
294
+ interface ValidateHypothesisInput {
295
+ readonly id: number;
296
+ readonly outcome: "confirmed" | "refuted" | "abandoned";
297
+ readonly validatedTurnId?: number;
298
+ readonly validatedAt: string;
299
+ }
300
+ /** @public */
301
+ interface IdempotentResponseInput {
302
+ readonly procedurePath: string;
303
+ readonly key: string;
304
+ readonly resultJson: string;
305
+ readonly createdAt: string;
306
+ }
307
+ /** @public */
308
+ interface TddTaskInput {
309
+ readonly sessionId: number;
310
+ readonly goal: string;
311
+ readonly startedAt: string;
312
+ readonly parentTddTaskId?: number;
313
+ readonly runId?: string;
314
+ }
315
+ /** @public */
316
+ interface EndTddTaskInput {
317
+ readonly id: number;
318
+ readonly endedAt: string;
319
+ readonly outcome: "succeeded" | "blocked" | "abandoned";
320
+ readonly summaryNoteId?: number;
321
+ }
322
+ /** @public */
323
+ interface WriteTddPhaseInput {
324
+ readonly tddTaskId: number;
325
+ readonly behaviorId?: number;
326
+ readonly phase: Phase$1;
327
+ readonly startedAt: string;
328
+ readonly transitionReason?: string;
329
+ readonly parentPhaseId?: number;
330
+ }
331
+ /** @public */
332
+ interface WriteTddPhaseOutput {
333
+ readonly id: number;
334
+ readonly previousPhaseId: number | null;
335
+ }
336
+ /** @public */
337
+ interface WriteTddArtifactInput {
338
+ readonly phaseId: number;
339
+ readonly artifactKind: ArtifactKind$2;
340
+ readonly fileId?: number;
341
+ readonly testCaseId?: number;
342
+ readonly testRunId?: number;
343
+ readonly testFirstFailureRunId?: number;
344
+ readonly diffExcerpt?: string;
345
+ readonly recordedAt: string;
346
+ /** Issue #363: explicit suite marker. Defaults to `"vitest"` when omitted. */
347
+ readonly suite?: ArtifactSuite$2;
348
+ }
349
+ /** @public */
350
+ interface WriteCommitInput {
351
+ readonly sha: string;
352
+ readonly parentSha?: string;
353
+ readonly message?: string;
354
+ readonly author?: string;
355
+ readonly committedAt?: string;
356
+ readonly branch?: string;
357
+ }
358
+ /** @public */
359
+ type ChangeKind = "added" | "modified" | "deleted" | "renamed" | "untracked-modified";
360
+ /** @public */
361
+ interface RunChangedFile {
362
+ readonly filePath: string;
363
+ readonly changeKind: ChangeKind;
364
+ readonly commitSha?: string;
365
+ }
366
+ /** @public */
367
+ interface WriteRunChangedFilesInput {
368
+ readonly runId: number;
369
+ readonly files: ReadonlyArray<RunChangedFile>;
370
+ }
371
+ /** @public */
372
+ type RunInvocationMethod = "bash" | "mcp" | "cli";
373
+ /**
374
+ * Input to `DataStore.registerAgent`.
375
+ *
376
+ * `sessionId` is the FK to `sessions.id` (integer PK), NOT the host's
377
+ * chat UUID string. Callers that hold only the chat UUID must resolve
378
+ * it through `getSessionByChatId` first.
379
+ *
380
+ * `idempotencyKey` is pre-derived by the caller via
381
+ * `deriveIdempotencyKey(...)` — both the sidecar CLI and the MCP
382
+ * server compute it the same way so a hook retry collapses to the
383
+ * same row.
384
+ * @public
385
+ */
386
+ interface RegisterAgentInput {
387
+ readonly sessionId: number;
388
+ readonly agentType: string;
389
+ readonly parentAgentId: string | null;
390
+ readonly conversationId: string | null;
391
+ readonly startedAt: number;
392
+ readonly startGitBranch?: string;
393
+ readonly startGitCommitSha?: string;
394
+ readonly startWorktreeDir?: string;
395
+ readonly idempotencyKey: string;
396
+ /**
397
+ * Pre-allocated `agents.agent_id` UUID. The sidecar passes
398
+ * `PerClientSessionMapWriter.mapSession()`'s `main_agent_id` here so
399
+ * the per-project `agents` row and the per-client session_map row
400
+ * agree on a single canonical id — the same value the SessionStart
401
+ * hook exports as `VITEST_AGENT_MAIN_AGENT_ID` / `_AGENT_ID`. When
402
+ * omitted, the implementation generates a fresh UUID (used by tests
403
+ * and any caller without a session map).
404
+ */
405
+ readonly agentId?: string;
406
+ }
407
+ /** @public */
408
+ interface AssociateRunSessionInput {
409
+ readonly chatId: string;
410
+ readonly invocationMethod: RunInvocationMethod;
411
+ }
412
+ declare const DataStore_base: Context.ServiceClass<DataStore, "vitest-agent/DataStore", {
413
+ readonly writeSettings: (hash: string, settings: SettingsInput, envVars: Record<string, string>) => Effect.Effect<void, DataStoreError$1>;
414
+ readonly writeRun: (input: TestRunInput) => Effect.Effect<number, DataStoreError$1>;
415
+ readonly writeModules: (runId: number, modules: ReadonlyArray<ModuleInput>) => Effect.Effect<ReadonlyArray<number>, DataStoreError$1>;
416
+ readonly writeSuites: (moduleId: number, suites: ReadonlyArray<SuiteInput>) => Effect.Effect<ReadonlyArray<number>, DataStoreError$1>;
417
+ readonly writeTestCases: (moduleId: number, tests: ReadonlyArray<TestCaseInput>) => Effect.Effect<ReadonlyArray<number>, DataStoreError$1>;
418
+ readonly writeErrors: (runId: number, errors: ReadonlyArray<TestErrorInput>) => Effect.Effect<void, DataStoreError$1>;
419
+ /**
420
+ * Persist `context.annotate` notes and their attachment descriptors.
421
+ * `runId` is carried for log correlation only -- `test_annotations`
422
+ * rows are reachable through `test_cases`.
423
+ */
424
+ readonly writeAnnotations: (runId: number, annotations: ReadonlyArray<TestAnnotationInput>) => Effect.Effect<void, DataStoreError$1>;
425
+ /**
426
+ * Persist `recordArtifact` payloads and their attachment
427
+ * descriptors. `runId` is carried for log correlation only.
428
+ */
429
+ readonly writeArtifacts: (runId: number, artifacts: ReadonlyArray<TestArtifactInput>) => Effect.Effect<void, DataStoreError$1>;
430
+ readonly writeCoverage: (runId: number, coverage: ReadonlyArray<FileCoverageInput>) => Effect.Effect<void, DataStoreError$1>;
431
+ readonly writeHistory: (project: string, fullName: string, modulePath: string, runId: number, timestamp: string, state: string, duration: number | null, flaky: boolean, retryCount: number, errorMessage: string | null) => Effect.Effect<void, DataStoreError$1>;
432
+ readonly writeBaselines: (baselines: CoverageBaselines$1) => Effect.Effect<void, DataStoreError$1>;
433
+ /**
434
+ * Persist the resolved (enforced) Vitest `coverage.thresholds` for the
435
+ * current run, distinct from the ratcheted `coverage_baselines` rows.
436
+ * Stored under `kind='threshold'`. See issue #237.
437
+ */
438
+ readonly writeThresholds: (thresholds: ResolvedThresholds$1) => Effect.Effect<void, DataStoreError$1>;
439
+ /**
440
+ * Persist the resolved aspirational `coverageTargets` for the current
441
+ * run, distinct from the ratcheted `coverage_baselines` rows. Stored
442
+ * under `kind='target'`. See issue #237.
443
+ */
444
+ readonly writeTargets: (targets: ResolvedThresholds$1) => Effect.Effect<void, DataStoreError$1>;
445
+ readonly writeTrends: (project: string, runId: number, entry: TrendEntry$1) => Effect.Effect<void, DataStoreError$1>;
446
+ readonly writeSourceMap: (sourceFilePath: string, testModuleId: number, mappingType: string) => Effect.Effect<void, DataStoreError$1>;
447
+ readonly ensureFile: (filePath: string) => Effect.Effect<number, DataStoreError$1>;
448
+ readonly writeNote: (note: NoteInput) => Effect.Effect<number, DataStoreError$1>;
449
+ readonly updateNote: (id: number, fields: Partial<NoteInput>) => Effect.Effect<void, DataStoreError$1>;
450
+ readonly deleteNote: (id: number) => Effect.Effect<void, DataStoreError$1>;
451
+ readonly writeSession: (input: SessionInput) => Effect.Effect<number, DataStoreError$1>;
452
+ /**
453
+ * Idempotent variant of `writeSession`: if a row with this
454
+ * `chat_id` already exists, return its id and leave the stored
455
+ * fields untouched; otherwise insert a new row. Used by
456
+ * hook-triggered recording paths (artifacts, turns) that fire
457
+ * for sessions whose original `SessionStart` may have missed —
458
+ * e.g. when Claude Code rotates `chat_id` mid-window after a
459
+ * continuation or compaction. Race-safe via
460
+ * `INSERT ... ON CONFLICT DO NOTHING`.
461
+ */
462
+ readonly upsertSession: (input: SessionInput) => Effect.Effect<number, DataStoreError$1>;
463
+ /**
464
+ * Backfill `sessions.conversation_id` for a row that was inserted
465
+ * before the canonical conversation id was known (issue #144) —
466
+ * `record session-start` always precedes `register-agent`, so the
467
+ * session row exists first. Race-safe and idempotent: the UPDATE's
468
+ * `WHERE conversation_id IS NULL` guard means a session that
469
+ * already carries a value is left untouched (zero rows affected),
470
+ * matching the trigger's null→value-only relaxation rather than
471
+ * risking an immutability-violation error on a redundant call.
472
+ */
473
+ readonly setSessionConversationIdIfNull: (input: {
474
+ readonly sessionId: number;
475
+ readonly conversationId: string;
476
+ }) => Effect.Effect<void, DataStoreError$1>;
477
+ readonly writeTurn: (input: TurnInput) => Effect.Effect<number, DataStoreError$1>;
478
+ readonly writeFailureSignature: (input: FailureSignatureWriteInput) => Effect.Effect<void, DataStoreError$1>;
479
+ readonly endSession: (chatId: string, endedAt: string, endReason: string | null) => Effect.Effect<void, DataStoreError$1>;
480
+ readonly writeHypothesis: (input: HypothesisInput) => Effect.Effect<number, DataStoreError$1>;
481
+ readonly validateHypothesis: (input: ValidateHypothesisInput) => Effect.Effect<void, DataStoreError$1>;
482
+ readonly writeTddTask: (input: TddTaskInput) => Effect.Effect<number, DataStoreError$1>;
483
+ readonly endTddTask: (input: EndTddTaskInput) => Effect.Effect<void, DataStoreError$1>;
484
+ readonly createGoal: (input: CreateGoalInput) => Effect.Effect<GoalRow$1, DataStoreError$1 | TddTaskNotFoundError$1 | TddTaskAlreadyEndedError$1>;
485
+ readonly getGoal: (id: number) => Effect.Effect<Option.Option<GoalRow$1>, DataStoreError$1>;
486
+ readonly updateGoal: (input: UpdateGoalInput) => Effect.Effect<GoalRow$1, DataStoreError$1 | GoalNotFoundError$1 | TddTaskAlreadyEndedError$1 | IllegalStatusTransitionError$1>;
487
+ readonly deleteGoal: (id: number) => Effect.Effect<void, DataStoreError$1 | GoalNotFoundError$1>;
488
+ readonly listGoalsByTddTask: (tddTaskId: number) => Effect.Effect<ReadonlyArray<GoalRow$1>, DataStoreError$1 | TddTaskNotFoundError$1>;
489
+ readonly createBehavior: (input: CreateBehaviorInput) => Effect.Effect<BehaviorRow$1, DataStoreError$1 | GoalNotFoundError$1 | BehaviorNotFoundError$1 | TddTaskAlreadyEndedError$1 | IllegalStatusTransitionError$1>;
490
+ readonly getBehavior: (id: number) => Effect.Effect<Option.Option<BehaviorRow$1>, DataStoreError$1>;
491
+ readonly updateBehavior: (input: UpdateBehaviorInput) => Effect.Effect<BehaviorRow$1, DataStoreError$1 | BehaviorNotFoundError$1 | TddTaskAlreadyEndedError$1 | IllegalStatusTransitionError$1>;
492
+ readonly deleteBehavior: (id: number) => Effect.Effect<void, DataStoreError$1 | BehaviorNotFoundError$1>;
493
+ readonly listBehaviorsByGoal: (goalId: number) => Effect.Effect<ReadonlyArray<BehaviorRow$1>, DataStoreError$1 | GoalNotFoundError$1>;
494
+ readonly listBehaviorsByTddTask: (tddTaskId: number) => Effect.Effect<ReadonlyArray<BehaviorRow$1>, DataStoreError$1 | TddTaskNotFoundError$1>;
495
+ readonly writeTddPhase: (input: WriteTddPhaseInput) => Effect.Effect<WriteTddPhaseOutput, DataStoreError$1>;
496
+ readonly writeTddArtifact: (input: WriteTddArtifactInput) => Effect.Effect<number, DataStoreError$1>;
497
+ readonly writeCommit: (input: WriteCommitInput) => Effect.Effect<void, DataStoreError$1>;
498
+ readonly writeRunChangedFiles: (input: WriteRunChangedFilesInput) => Effect.Effect<void, DataStoreError$1>;
499
+ readonly recordIdempotentResponse: (input: IdempotentResponseInput) => Effect.Effect<void, DataStoreError$1>;
500
+ readonly pruneSessions: (keepRecent: number) => Effect.Effect<{
501
+ readonly affectedSessions: number;
502
+ readonly prunedTurns: number;
503
+ }, DataStoreError$1>;
504
+ readonly associateLatestRunWithSession: (input: AssociateRunSessionInput) => Effect.Effect<void, DataStoreError$1>;
505
+ readonly backfillTestCaseTurns: (chatId: string) => Effect.Effect<number, DataStoreError$1>;
506
+ /**
507
+ * Idempotently insert an `agents` row.
508
+ *
509
+ * Returns `Agent` on a fresh insert, or `IdempotencyHit` carrying
510
+ * the existing `agentId` when the `(session_id, idempotency_key)`
511
+ * UNIQUE constraint already has a row. The caller treats the latter
512
+ * as a successful recovery (same logical agent), not an error.
513
+ *
514
+ * Fails with `RegistrationConflictError` when the supplied
515
+ * `parentAgentId` references an agent in a different session, or
516
+ * when no such agent exists. Surface to the caller for true
517
+ * mis-configuration cases; idempotency hits never produce this.
518
+ */
519
+ readonly registerAgent: (input: RegisterAgentInput) => Effect.Effect<Agent$1 | IdempotencyHit$1, RegistrationConflictError$1 | DataStoreError$1>;
520
+ /**
521
+ * Mark an agent as ended. Sets `agents.ended_at` to the supplied
522
+ * timestamp. Fails with `AgentNotFoundError` when no row exists.
523
+ */
524
+ readonly endAgent: (agentId: string, endedAt: number) => Effect.Effect<void, AgentNotFoundError$1 | DataStoreError$1>;
525
+ }>;
526
+ /** @public */
527
+ export declare class DataStore extends DataStore_base {}
528
+ //#endregion
529
+ //#region src/services/DataReader.d.ts
530
+ /** @public */
531
+ interface ProjectRunSummary {
532
+ readonly project: string;
533
+ readonly lastRun: string | null;
534
+ readonly lastResult: "passed" | "failed" | "interrupted" | null;
535
+ readonly total: number;
536
+ readonly passed: number;
537
+ readonly failed: number;
538
+ readonly skipped: number;
539
+ }
540
+ /** @public */
541
+ interface FlakyTest {
542
+ readonly fullName: string;
543
+ readonly modulePath: string;
544
+ readonly project: string;
545
+ readonly passCount: number;
546
+ readonly failCount: number;
547
+ readonly lastState: "passed" | "failed";
548
+ readonly lastTimestamp: string;
549
+ }
550
+ /** @public */
551
+ interface PersistentFailure {
552
+ readonly fullName: string;
553
+ readonly modulePath: string;
554
+ readonly project: string;
555
+ readonly consecutiveFailures: number;
556
+ readonly firstFailedAt: string;
557
+ readonly lastFailedAt: string;
558
+ readonly lastErrorMessage: string | null;
559
+ }
560
+ /** @public */
561
+ interface TestError {
562
+ /** `test_errors.id` — required by `hypothesis (action: record).citedTestErrorId`. */
563
+ readonly id: number;
564
+ /**
565
+ * `stack_frames.id` for the top frame of this error (ordinal 0), or
566
+ * `null` if no frames were captured. Required by
567
+ * `hypothesis (action: record).citedStackFrameId`.
568
+ */
569
+ readonly topStackFrameId: number | null;
570
+ readonly name: string | null;
571
+ readonly message: string;
572
+ readonly diff: string | null;
573
+ readonly actual: string | null;
574
+ readonly expected: string | null;
575
+ readonly stack: string | null;
576
+ readonly scope: "test" | "suite" | "module" | "unhandled";
577
+ readonly testFullName: string | null;
578
+ readonly moduleFile: string | null;
579
+ }
580
+ /** @public */
581
+ interface NoteRow {
582
+ readonly id: number;
583
+ readonly title: string;
584
+ readonly content: string;
585
+ readonly scope: "global" | "project" | "module" | "suite" | "test" | "note";
586
+ readonly project: string | null;
587
+ readonly testFullName: string | null;
588
+ readonly modulePath: string | null;
589
+ readonly parentNoteId: number | null;
590
+ readonly createdBy: string | null;
591
+ readonly expiresAt: string | null;
592
+ readonly pinned: boolean;
593
+ readonly createdAt: string;
594
+ readonly updatedAt: string;
595
+ }
596
+ /** @public */
597
+ interface SettingsRow {
598
+ readonly hash: string;
599
+ readonly reporters: string | null;
600
+ readonly coverageEnabled: boolean;
601
+ readonly coverageProvider: string | null;
602
+ readonly coverageThresholds: string | null;
603
+ readonly coverageTargets: string | null;
604
+ readonly pool: string | null;
605
+ readonly shard: string | null;
606
+ readonly project: string | null;
607
+ readonly environment: string | null;
608
+ readonly envVars: Record<string, string>;
609
+ readonly capturedAt: string;
610
+ }
611
+ /** @public */
612
+ interface TestListEntry {
613
+ readonly id: number;
614
+ readonly fullName: string;
615
+ readonly state: string;
616
+ readonly duration: number | null;
617
+ readonly module: string;
618
+ readonly classification: string | null;
619
+ }
620
+ /** @public */
621
+ interface ModuleListEntry {
622
+ readonly id: number;
623
+ readonly file: string;
624
+ readonly state: string;
625
+ readonly testCount: number;
626
+ readonly duration: number | null;
627
+ }
628
+ /** @public */
629
+ interface SuiteListEntry {
630
+ readonly id: number;
631
+ readonly name: string;
632
+ readonly module: string;
633
+ readonly state: string;
634
+ readonly testCount: number;
635
+ }
636
+ /** @public */
637
+ interface SettingsListEntry {
638
+ readonly hash: string;
639
+ readonly capturedAt: string;
640
+ }
641
+ /** @public */
642
+ interface SessionDetail {
643
+ readonly id: number;
644
+ readonly chatId: string;
645
+ readonly project: string;
646
+ readonly cwd: string;
647
+ readonly agentKind: "main" | "subagent";
648
+ readonly agentType: string | null;
649
+ readonly parentSessionId: number | null;
650
+ readonly triageWasNonEmpty: boolean;
651
+ readonly startedAt: string;
652
+ readonly endedAt: string | null;
653
+ readonly endReason: string | null;
654
+ /** Canonical conversation UUID this session belongs to (issue #144), null when unset. */
655
+ readonly conversationId: string | null;
656
+ }
657
+ /** @public */
658
+ interface TurnSummary {
659
+ readonly id: number;
660
+ readonly sessionId: number;
661
+ readonly turnNo: number;
662
+ readonly type: string;
663
+ readonly payload: string;
664
+ readonly occurredAt: string;
665
+ }
666
+ /** @public */
667
+ interface HistoryQueryOptions {
668
+ /** Exact `full_name` match — narrows to a single test's history. */
669
+ readonly testName?: string;
670
+ /** Exact `module_path` match — narrows to tests in one file. */
671
+ readonly modulePath?: string;
672
+ /** Max runs kept per (module_path, full_name) pair, most-recent-first. Default 20. */
673
+ readonly limit?: number;
674
+ }
675
+ /**
676
+ * Narrowing options shared by the classification reads
677
+ * (`DataReader.getFlaky` / `getPersistentFailures`). Mirrors the
678
+ * `testName` / `modulePath` half of {@link HistoryQueryOptions} so a
679
+ * caller that scoped `getHistory` to one test can scope the derived
680
+ * classifications to the same test instead of receiving the whole
681
+ * project's rows.
682
+ *
683
+ * @public
684
+ */
685
+ interface ClassificationQueryOptions {
686
+ /** Exact `full_name` match — narrows to a single test's classification. */
687
+ readonly testName?: string;
688
+ /** Exact `module_path` match — narrows to tests in one file. */
689
+ readonly modulePath?: string;
690
+ }
691
+ /**
692
+ * Narrowing options for `DataReader.getTestByFullName`. A
693
+ * `full_name` is not file-qualified (Decision D20), so the same name can
694
+ * exist in more than one module; `modulePath` disambiguates.
695
+ *
696
+ * @public
697
+ */
698
+ interface TestLookupOptions {
699
+ /** Exact `module_path` match — picks one variant of an ambiguous `full_name`. */
700
+ readonly modulePath?: string;
701
+ }
702
+ /** @public */
703
+ interface TurnSearchOptions {
704
+ readonly sessionId?: number;
705
+ readonly type?: string;
706
+ readonly since?: string;
707
+ readonly limit?: number;
708
+ }
709
+ /** @public */
710
+ interface AcceptanceMetrics {
711
+ readonly phaseEvidenceIntegrity: {
712
+ total: number;
713
+ compliant: number;
714
+ ratio: number;
715
+ };
716
+ readonly complianceHookResponsiveness: {
717
+ total: number;
718
+ withFollowup: number;
719
+ ratio: number;
720
+ };
721
+ readonly orientationUsefulness: {
722
+ total: number;
723
+ referencedCount: number;
724
+ ratio: number;
725
+ };
726
+ readonly antiPatternDetectionRate: {
727
+ total: number;
728
+ cleanSessions: number;
729
+ ratio: number;
730
+ };
731
+ }
732
+ /** @public */
733
+ interface FailureSignatureDetail {
734
+ readonly signatureHash: string;
735
+ readonly firstSeenRunId: number | null;
736
+ readonly firstSeenAt: string;
737
+ readonly lastSeenAt: string | null;
738
+ readonly occurrenceCount: number;
739
+ readonly recentErrors: ReadonlyArray<{
740
+ readonly runId: number;
741
+ readonly message: string;
742
+ readonly errorName: string | null;
743
+ }>;
744
+ }
745
+ /** @public */
746
+ interface TddPhaseDetail {
747
+ readonly id: number;
748
+ readonly behaviorId: number | null;
749
+ readonly phase: string;
750
+ readonly startedAt: string;
751
+ readonly endedAt: string | null;
752
+ readonly transitionReason: string | null;
753
+ }
754
+ /** @public */
755
+ interface TddArtifactDetail {
756
+ readonly id: number;
757
+ readonly phaseId: number;
758
+ readonly artifactKind: string;
759
+ readonly testCaseId: number | null;
760
+ readonly testRunId: number | null;
761
+ readonly recordedAt: string;
762
+ }
763
+ /** @public */
764
+ interface TddTaskDetail {
765
+ readonly id: number;
766
+ readonly sessionId: number;
767
+ readonly goal: string;
768
+ readonly startedAt: string;
769
+ readonly endedAt: string | null;
770
+ readonly outcome: string | null;
771
+ readonly runId: string | null;
772
+ readonly goals: ReadonlyArray<GoalDetail$1>;
773
+ readonly phases: ReadonlyArray<TddPhaseDetail>;
774
+ readonly artifacts: ReadonlyArray<TddArtifactDetail>;
775
+ }
776
+ /** @public */
777
+ interface CurrentTddPhase {
778
+ readonly id: number;
779
+ readonly phase: Phase$1;
780
+ readonly startedAt: string;
781
+ readonly behaviorId: number | null;
782
+ }
783
+ /** @public */
784
+ interface CitedArtifactRow extends CitedArtifact$1 {
785
+ readonly phase_id: number;
786
+ }
787
+ /** @public */
788
+ interface CommitChangesEntry {
789
+ readonly sha: string;
790
+ readonly parentSha: string | null;
791
+ readonly message: string | null;
792
+ readonly author: string | null;
793
+ readonly committedAt: string | null;
794
+ readonly branch: string | null;
795
+ readonly files: ReadonlyArray<{
796
+ readonly filePath: string;
797
+ readonly changeKind: ChangeKind;
798
+ }>;
799
+ }
800
+ /** @public */
801
+ interface HypothesisDetail {
802
+ readonly id: number;
803
+ readonly sessionId: number;
804
+ readonly content: string;
805
+ readonly citedTestErrorId: number | null;
806
+ readonly citedStackFrameId: number | null;
807
+ readonly validationOutcome: "confirmed" | "refuted" | "abandoned" | null;
808
+ readonly validatedAt: string | null;
809
+ }
810
+ /** @public */
811
+ interface TddTaskSummary {
812
+ readonly id: number;
813
+ readonly sessionId: number;
814
+ readonly goal: string;
815
+ readonly startedAt: string;
816
+ readonly endedAt: string | null;
817
+ readonly outcome: "succeeded" | "blocked" | "abandoned" | null;
818
+ }
819
+ /**
820
+ * Row shape returned by `listTddArtifactsForTask`. Carries every
821
+ * field an agent typically needs to cite an artifact in a subsequent
822
+ * `tdd_phase_transition_request` call without further lookups.
823
+ *
824
+ * @public
825
+ */
826
+ interface TddArtifactRow {
827
+ readonly id: number;
828
+ readonly tddTaskId: number;
829
+ readonly phaseId: number;
830
+ readonly phaseName: Phase$1;
831
+ readonly artifactKind: ArtifactKind$1;
832
+ readonly behaviorId: number | null;
833
+ readonly testCaseId: number | null;
834
+ readonly testRunId: number | null;
835
+ readonly testFirstFailureRunId: number | null;
836
+ readonly recordedAt: string;
837
+ readonly suite: ArtifactSuite$1;
838
+ }
839
+ /** @public */
840
+ interface TagInventoryRow {
841
+ /** The tag name (e.g. `"int"`, `"e2e"`, `"unit"`). */
842
+ readonly tag: string;
843
+ /** The Vitest project this tag was observed in. */
844
+ readonly project: string;
845
+ /**
846
+ * Number of distinct test modules in the project's latest run that contain
847
+ * at least one test case carrying this tag.
848
+ */
849
+ readonly moduleCount: number;
850
+ /**
851
+ * Number of test cases in the project's latest run that carry this tag.
852
+ */
853
+ readonly testCount: number;
854
+ }
855
+ /** @public */
856
+ interface TestArtifactQueryOptions {
857
+ /** Disambiguates a fullName that exists in more than one module. */
858
+ readonly modulePath?: string;
859
+ }
860
+ /** @public */
861
+ interface PersistedAttachment {
862
+ readonly contentType?: string;
863
+ readonly path?: string;
864
+ readonly body?: string;
865
+ /** How to read `body`. Absent when nothing was stored inline. */
866
+ readonly bodyEncoding?: "base64" | "utf-8";
867
+ readonly byteSize: number | null;
868
+ }
869
+ /** @public */
870
+ interface TestAnnotationRow {
871
+ readonly id: number;
872
+ readonly type: string;
873
+ readonly message: string;
874
+ readonly location?: {
875
+ readonly file: string;
876
+ readonly line: number;
877
+ readonly column: number;
878
+ };
879
+ readonly attachments: ReadonlyArray<PersistedAttachment>;
880
+ }
881
+ /** @public */
882
+ interface TestArtifactRow {
883
+ readonly id: number;
884
+ readonly type: string;
885
+ readonly message: string | null;
886
+ readonly data: string | null;
887
+ readonly location?: {
888
+ readonly file: string;
889
+ readonly line: number;
890
+ readonly column: number;
891
+ };
892
+ readonly attachments: ReadonlyArray<PersistedAttachment>;
893
+ }
894
+ declare const DataReader_base: Context.ServiceClass<DataReader, "vitest-agent/DataReader", {
895
+ readonly getLatestRun: (project: string) => Effect.Effect<Option.Option<AgentReport$1>, DataStoreError$1>;
896
+ readonly getRunsByProject: () => Effect.Effect<ReadonlyArray<ProjectRunSummary>, DataStoreError$1>;
897
+ readonly getHistory: (project: string, options?: HistoryQueryOptions) => Effect.Effect<HistoryRecord$1, DataStoreError$1>;
898
+ readonly getBaselines: (project: string) => Effect.Effect<Option.Option<CoverageBaselines$1>, DataStoreError$1>;
899
+ readonly getTrends: (project: string, limit?: number) => Effect.Effect<Option.Option<TrendRecord$1>, DataStoreError$1>;
900
+ readonly getFlaky: (project: string, options?: ClassificationQueryOptions) => Effect.Effect<ReadonlyArray<FlakyTest>, DataStoreError$1>;
901
+ readonly getPersistentFailures: (project: string, options?: ClassificationQueryOptions) => Effect.Effect<ReadonlyArray<PersistentFailure>, DataStoreError$1>;
902
+ readonly getFileCoverage: (runId: number) => Effect.Effect<ReadonlyArray<FileCoverageReport$1>, DataStoreError$1>;
903
+ readonly getCoverage: (project: string) => Effect.Effect<Option.Option<CoverageReport$1>, DataStoreError$1>;
904
+ readonly getTestsForFile: (filePath: string) => Effect.Effect<ReadonlyArray<string>, DataStoreError$1>;
905
+ readonly getErrors: (project: string, errorName?: string) => Effect.Effect<ReadonlyArray<TestError>, DataStoreError$1>;
906
+ /** Annotations recorded for a test in the project's latest run. */
907
+ readonly getAnnotationsForTest: (project: string, fullName: string, options?: TestArtifactQueryOptions) => Effect.Effect<ReadonlyArray<TestAnnotationRow>, DataStoreError$1>;
908
+ /** Artifacts recorded for a test in the project's latest run. */
909
+ readonly getArtifactsForTest: (project: string, fullName: string, options?: TestArtifactQueryOptions) => Effect.Effect<ReadonlyArray<TestArtifactRow>, DataStoreError$1>;
910
+ readonly getNotes: (scope?: string, project?: string, testFullName?: string) => Effect.Effect<ReadonlyArray<NoteRow>, DataStoreError$1>;
911
+ readonly getNoteById: (id: number) => Effect.Effect<Option.Option<NoteRow>, DataStoreError$1>;
912
+ readonly searchNotes: (query: string) => Effect.Effect<ReadonlyArray<NoteRow>, DataStoreError$1>;
913
+ readonly getManifest: () => Effect.Effect<Option.Option<CacheManifest$1>, DataStoreError$1>;
914
+ readonly getSettings: (hash: string) => Effect.Effect<Option.Option<SettingsRow>, DataStoreError$1>;
915
+ readonly getLatestSettings: () => Effect.Effect<Option.Option<SettingsRow>, DataStoreError$1>;
916
+ readonly getTestByFullName: (project: string, fullName: string, options?: TestLookupOptions) => Effect.Effect<Option.Option<TestListEntry>, DataStoreError$1>;
917
+ /**
918
+ * Every module path in the project's latest run that carries a test
919
+ * case with this exact `full_name`, ordered ascending. Length > 1
920
+ * means the name is ambiguous and callers must disambiguate with
921
+ * {@link TestLookupOptions.modulePath} rather than guess.
922
+ */
923
+ readonly getTestModulesByFullName: (project: string, fullName: string) => Effect.Effect<ReadonlyArray<string>, DataStoreError$1>;
924
+ readonly listTests: (project: string, options?: {
925
+ state?: string;
926
+ module?: string;
927
+ limit?: number;
928
+ }) => Effect.Effect<ReadonlyArray<TestListEntry>, DataStoreError$1>;
929
+ readonly listModules: (project: string) => Effect.Effect<ReadonlyArray<ModuleListEntry>, DataStoreError$1>;
930
+ readonly listSuites: (project: string, options?: {
931
+ module?: string;
932
+ }) => Effect.Effect<ReadonlyArray<SuiteListEntry>, DataStoreError$1>;
933
+ readonly listSettings: () => Effect.Effect<ReadonlyArray<SettingsListEntry>, DataStoreError$1>;
934
+ readonly getSessionById: (id: number) => Effect.Effect<Option.Option<SessionDetail>, DataStoreError$1>;
935
+ readonly getSessionByChatId: (chatId: string) => Effect.Effect<Option.Option<SessionDetail>, DataStoreError$1>;
936
+ /**
937
+ * Find every session row whose `chat_id` begins with `prefix`.
938
+ * Used to recover the synthetic subagent row created by the
939
+ * SubagentStart hook (`<parentChatId>-subagent-<ts>-<pid>`)
940
+ * when subsequent PostToolUse hooks fire under the bare
941
+ * parent chat_id. Returns most recent first.
942
+ */
943
+ readonly findSessionsByChatPrefix: (prefix: string) => Effect.Effect<ReadonlyArray<SessionDetail>, DataStoreError$1>;
944
+ /**
945
+ * Find the most-recently-started subagent session whose
946
+ * `parent_session_id` is `parentSessionId` and that has not ended
947
+ * (`ended_at IS NULL`). Used to attribute orchestrator (subagent)
948
+ * MCP writes — e.g. `hypothesis record` — to the running subagent's
949
+ * own session row instead of the parent main session, since the MCP
950
+ * server's recovered context only ever names the main agent.
951
+ */
952
+ readonly findActiveSubagentSession: (parentSessionId: number) => Effect.Effect<Option.Option<SessionDetail>, DataStoreError$1>;
953
+ /**
954
+ * Resolve the session a TDD task was opened under: the `sessions`
955
+ * row whose `id` equals `tdd_tasks.session_id` for `tddTaskId`.
956
+ * Returns `Option.none` when the task — or its session — does not
957
+ * exist. Lets `hypothesis (action: record)` bind a hypothesis
958
+ * deterministically from the orchestrator's unambiguous
959
+ * `tddTaskId` (returned by `tdd_task (action: start)`) instead of
960
+ * the fragile recovered host context or a caller-guessed
961
+ * `sessionId`.
962
+ */
963
+ readonly getSessionByTddTaskId: (tddTaskId: number) => Effect.Effect<Option.Option<SessionDetail>, DataStoreError$1>;
964
+ readonly listSessions: (options: {
965
+ readonly project?: string;
966
+ readonly agentKind?: "main" | "subagent";
967
+ readonly limit?: number;
968
+ }) => Effect.Effect<ReadonlyArray<SessionDetail>, DataStoreError$1>;
969
+ readonly searchTurns: (options: TurnSearchOptions) => Effect.Effect<ReadonlyArray<TurnSummary>, DataStoreError$1>;
970
+ readonly computeAcceptanceMetrics: () => Effect.Effect<AcceptanceMetrics, DataStoreError$1>;
971
+ readonly getFailureSignatureByHash: (hash: string) => Effect.Effect<Option.Option<FailureSignatureDetail>, DataStoreError$1>;
972
+ readonly getTddTaskById: (id: number) => Effect.Effect<Option.Option<TddTaskDetail>, DataStoreError$1>;
973
+ readonly getGoalById: (id: number) => Effect.Effect<Option.Option<GoalDetail$1>, DataStoreError$1>;
974
+ readonly getGoalsByTddTask: (tddTaskId: number) => Effect.Effect<ReadonlyArray<GoalDetail$1>, DataStoreError$1>;
975
+ readonly getBehaviorById: (id: number) => Effect.Effect<Option.Option<BehaviorDetail$1>, DataStoreError$1>;
976
+ readonly getBehaviorsByGoal: (goalId: number) => Effect.Effect<ReadonlyArray<BehaviorRow$1>, DataStoreError$1>;
977
+ readonly getBehaviorsByTddTask: (tddTaskId: number) => Effect.Effect<ReadonlyArray<BehaviorRow$1>, DataStoreError$1>;
978
+ readonly getBehaviorDependencies: (behaviorId: number) => Effect.Effect<ReadonlyArray<BehaviorRow$1>, DataStoreError$1>;
979
+ readonly resolveGoalIdForBehavior: (behaviorId: number) => Effect.Effect<Option.Option<number>, DataStoreError$1>;
980
+ readonly getCurrentTddPhase: (tddTaskId: number) => Effect.Effect<Option.Option<CurrentTddPhase>, DataStoreError$1>;
981
+ readonly getTddArtifactWithContext: (artifactId: number) => Effect.Effect<Option.Option<CitedArtifactRow>, DataStoreError$1>;
982
+ readonly getCommitChanges: (sha?: string) => Effect.Effect<ReadonlyArray<CommitChangesEntry>, DataStoreError$1>;
983
+ readonly listTddTasksForSession: (sessionId: number, options?: {
984
+ /**
985
+ * When true, also return tdd_tasks belonging to any
986
+ * ancestor of `sessionId` via `parent_session_id`. Used
987
+ * by hook-driven artifact recording where the
988
+ * orchestrator opened the tdd task under the parent
989
+ * main row but the subagent's own session row is the
990
+ * one carrying the calling chat_id. Default `false`
991
+ * preserves the prior single-session contract.
992
+ */
993
+ readonly walkParents?: boolean;
994
+ /**
995
+ * When true AND `sessionId`'s session has a non-null
996
+ * `conversation_id`, also return tdd_tasks belonging to
997
+ * any OTHER session sharing that `conversation_id` — the
998
+ * detached-session fallback (issue #144). A session with
999
+ * a null `conversation_id` never triggers this fallback.
1000
+ * Rows are ordered so a task owned by an `agent_kind =
1001
+ * 'main'` session sorts first, then by `started_at DESC`.
1002
+ * Default `false` preserves the prior contract.
1003
+ */
1004
+ readonly walkConversation?: boolean;
1005
+ }) => Effect.Effect<ReadonlyArray<TddTaskSummary>, DataStoreError$1>;
1006
+ /**
1007
+ * Diagnostic for the `missing_artifact_evidence` phase-transition
1008
+ * denial (issue #144): counts `tdd_artifacts` rows recorded at or
1009
+ * after `sinceIso` under sessions OTHER than the one that opened
1010
+ * `tddTaskId`, but sharing that session's `conversation_id`. Used
1011
+ * to tell an agent "your hooks may be attributing to a detached
1012
+ * session" rather than a bare "no artifact found". Returns 0 when
1013
+ * `tddTaskId` is unknown or its session's `conversation_id` is
1014
+ * null — the diagnostic never fabricates a signal it cannot back.
1015
+ */
1016
+ readonly countRecentArtifactsInOtherSessionsOfConversation: (input: {
1017
+ readonly tddTaskId: number;
1018
+ readonly sinceIso: string;
1019
+ }) => Effect.Effect<number, DataStoreError$1>;
1020
+ /**
1021
+ * List artifacts recorded for a TDD task, optionally filtered
1022
+ * by `artifactKind`, `phaseId`, or `behaviorId`. Returns rows in
1023
+ * recorded_at DESC order so the most recently captured artifact
1024
+ * (the typical citation target for a phase transition) appears
1025
+ * first. `limit` defaults to 50.
1026
+ */
1027
+ readonly listTddArtifactsForTask: (input: {
1028
+ readonly tddTaskId: number;
1029
+ readonly artifactKind?: ArtifactKind$1;
1030
+ readonly phaseId?: number;
1031
+ readonly behaviorId?: number;
1032
+ readonly limit?: number;
1033
+ }) => Effect.Effect<ReadonlyArray<TddArtifactRow>, DataStoreError$1>;
1034
+ readonly listHypotheses: (options: {
1035
+ readonly sessionId?: number;
1036
+ readonly outcome?: "confirmed" | "refuted" | "abandoned" | "open";
1037
+ readonly limit?: number;
1038
+ }) => Effect.Effect<ReadonlyArray<HypothesisDetail>, DataStoreError$1>;
1039
+ readonly findIdempotentResponse: (procedurePath: string, key: string) => Effect.Effect<Option.Option<string>, DataStoreError$1>;
1040
+ readonly getLatestTestCaseForSession: (chatId: string) => Effect.Effect<Option.Option<number>, DataStoreError$1>;
1041
+ /**
1042
+ * Returns one `TagInventoryRow` per `(tag, project)` pair observed in
1043
+ * each project's latest test run. When `project` is supplied, results
1044
+ * are restricted to that project's latest run.
1045
+ */
1046
+ readonly listTagInventory: (options?: {
1047
+ readonly project?: string;
1048
+ }) => Effect.Effect<ReadonlyArray<TagInventoryRow>, DataStoreError$1>;
1049
+ /**
1050
+ * Returns every `TestListEntry` from the latest run of each project
1051
+ * (or the specified project) whose test case carries `tag`.
1052
+ */
1053
+ readonly listTestsForTag: (tag: string, options?: {
1054
+ readonly project?: string;
1055
+ }) => Effect.Effect<ReadonlyArray<TestListEntry>, DataStoreError$1>;
1056
+ }>;
1057
+ /** @public */
1058
+ export declare class DataReader extends DataReader_base {}
1059
+ //#endregion
1060
+ //#region src/migrations/index.d.ts
1061
+ /**
1062
+ * Every migration that must run against a per-project `data.db`, keyed by
1063
+ * migration id in application order.
1064
+ *
1065
+ * This is the single source of truth for the project database's migration
1066
+ * set: `makeSqliteStack` (and through it `PlatformLive`, `ensureMigrated`,
1067
+ * the testing layers, `ReporterLive` and `SidecarLive`) defaults to it when
1068
+ * calling `SqliteMigrator.fromRecord`, so adding a migration file and
1069
+ * registering it here is enough to reach every process that opens a project
1070
+ * database.
1071
+ *
1072
+ * The session-map and discovery-registry databases are separate schemas with
1073
+ * their own migrations and are deliberately not listed here.
1074
+ *
1075
+ * @public
1076
+ */
1077
+ export declare const PROJECT_MIGRATIONS: {
1078
+ readonly "0001_initial": import("effect/Effect").Effect<void, import("effect/unstable/sql/SqlError").SqlError, import("effect/unstable/sql/SqlClient").SqlClient>;
1079
+ readonly "0002_test_artifacts": import("effect/Effect").Effect<void, import("effect/unstable/sql/SqlError").SqlError, import("effect/unstable/sql/SqlClient").SqlClient>;
1080
+ };
1081
+ //#endregion
1082
+ //#region src/testing/layers.d.ts
1083
+ /** @public */
1084
+ export declare function makeTestLayer(filename: string): Layer.Layer<DataReader | DataStore | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect/platform-node/NodeServices").NodeServices, import("@effect/sql-sqlite-node/SqliteMigrator").MigrationError | import("effect/unstable/sql/SqlError").SqlError, never>;
1085
+ /** @public */
1086
+ export declare const DataStoreTestLayer: Layer.Layer<DataReader | DataStore | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect/platform-node/NodeServices").NodeServices, import("@effect/sql-sqlite-node/SqliteMigrator").MigrationError | import("effect/unstable/sql/SqlError").SqlError, never>;
1087
+ //#endregion
1088
+ //#region src/testing/index.d.ts
1089
+ /** @public */
1090
+ export declare function empty(filename: string): Layer.Layer<DataReader | DataStore | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect/platform-node/NodeServices").NodeServices, import("@effect/sql-sqlite-node/SqliteMigrator").MigrationError | import("effect/unstable/sql/SqlError").SqlError, never>;
1091
+ /** @public */
1092
+ export declare function singlePassingRun(filename: string): Layer.Layer<DataReader | DataStore | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect/platform-node/NodeServices").NodeServices, import("@vitest-agent/sdk").DataStoreError | import("@effect/sql-sqlite-node/SqliteMigrator").MigrationError | import("effect/unstable/sql/SqlError").SqlError, never>;
1093
+ /** @public */
1094
+ export declare function withFailures(filename: string): Layer.Layer<DataReader | DataStore | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect/platform-node/NodeServices").NodeServices, import("@vitest-agent/sdk").DataStoreError | import("@effect/sql-sqlite-node/SqliteMigrator").MigrationError | import("effect/unstable/sql/SqlError").SqlError, never>;
1095
+ /** @public */
1096
+ export declare function flaky(filename: string): Layer.Layer<DataReader | DataStore | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect/platform-node/NodeServices").NodeServices, import("@vitest-agent/sdk").DataStoreError | import("@effect/sql-sqlite-node/SqliteMigrator").MigrationError | import("effect/unstable/sql/SqlError").SqlError, never>;
1097
+ /** @public */
1098
+ export declare function withTddTask(filename: string): Layer.Layer<DataReader | DataStore | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect/platform-node/NodeServices").NodeServices, import("@vitest-agent/sdk").BehaviorNotFoundError | import("@vitest-agent/sdk").DataStoreError | import("@vitest-agent/sdk").GoalNotFoundError | import("@vitest-agent/sdk").IllegalStatusTransitionError | import("@effect/sql-sqlite-node/SqliteMigrator").MigrationError | import("effect/unstable/sql/SqlError").SqlError | import("@vitest-agent/sdk").TddTaskAlreadyEndedError | import("@vitest-agent/sdk").TddTaskNotFoundError, never>;
1099
+ //#endregion
1100
+ export { type AcceptanceMetrics, Agent, AgentId, AgentNotFoundError, AgentReport, type ArtifactKind, type ArtifactSuite, type AssociateRunSessionInput, BehaviorDetail, BehaviorNotFoundError, BehaviorRow, BehaviorStatus, CacheManifest, type ChangeKind, ChatId, type CitedArtifact, type CitedArtifactRow, type ClassificationQueryOptions, type CommitChangesEntry, CoverageBaselines, CoverageReport, type CreateBehaviorInput, type CreateGoalInput, type CurrentTddPhase, DataStoreError, type EndTddTaskInput, type FailureSignatureDetail, type FailureSignatureWriteInput, type FileCoverageInput, FileCoverageReport, type FlakyTest, GoalDetail, GoalNotFoundError, GoalRow, GoalStatus, type HistoryQueryOptions, HistoryRecord, type HypothesisDetail, type HypothesisInput, IdempotencyHit, type IdempotentResponseInput, type IllegalStatusTransitionEntity, IllegalStatusTransitionError, type ModuleInput, type ModuleListEntry, type NoteInput, type NoteRow, type PersistedAttachment, type PersistentFailure, type Phase, type ProjectRunSummary, type RegisterAgentInput, RegistrationConflictError, type ResolvedThresholds, type RunChangedFile, type RunInvocationMethod, type SessionDetail, type SessionInput, type SettingsInput, type SettingsListEntry, type SettingsRow, type StackFrameInput, type SuiteInput, type SuiteListEntry, type TagInventoryRow, type TddArtifactDetail, type TddArtifactRow, type TddPhaseDetail, TddTaskAlreadyEndedError, type TddTaskDetail, type TddTaskEndOutcome, type TddTaskInput, TddTaskNotFoundError, type TddTaskSummary, type TestAnnotationInput, type TestAnnotationRow, type TestArtifactInput, type TestArtifactQueryOptions, type TestArtifactRow, type TestAttachmentInput, type TestCaseInput, type TestError, type TestErrorInput, type TestListEntry, type TestLookupOptions, type TestRunInput, TrendEntry, TrendRecord, type TurnInput, type TurnSearchOptions, type TurnSummary, type UpdateBehaviorInput, type UpdateGoalInput, type ValidateHypothesisInput, type WriteCommitInput, type WriteRunChangedFilesInput, type WriteTddArtifactInput, type WriteTddPhaseInput, type WriteTddPhaseOutput };
1101
+ //# sourceMappingURL=testing.d.ts.map