@@ -31,16 +31,31 @@ import { Commit } from '../../schema/models/types/Commit'
3131import { DocumentVersion } from '../../schema/models/types/DocumentVersion'
3232import { Workspace } from '../../schema/models/types/Workspace'
3333import { Cursor } from '../../schema/types'
34- import { isFeatureEnabledByName } from '../../services/workspaceFeatures/isFeatureEnabledByName '
34+ import { isClickHouseSpansReadEnabled } from '../../services/workspaceFeatures/isClickHouseSpansReadEnabled '
3535import {
3636 getSpansWithoutIssues as chGetSpansWithoutIssues ,
3737 getSpansWithActiveIssues as chGetSpansWithActiveIssues ,
3838 getSpansWithFailedResults as chGetSpansWithFailedResults ,
3939 getSpansWithPassedResults as chGetSpansWithPassedResults ,
4040} from '../../queries/clickhouse/spans/getSpansWithoutIssues'
4141
42- const CLICKHOUSE_SPANS_READ_FLAG = 'clickhouse-spans-read'
43-
42+ /**
43+ * Fetches spans that have no issues associated through evaluation results,
44+ * filtered by document and commit history.
45+ *
46+ * Automatically excludes optimization-related spans:
47+ * - Spans with source 'optimization'
48+ * - Spans with source 'experiment' where the experiment is linked
49+ * to an optimization (via baselineExperimentId or optimizedExperimentId)
50+ *
51+ * @param excludeFailedResults - When true, excludes spans with failed or errored evaluation results.
52+ * @param requirePassedResults - When true, only returns spans with at least one
53+ * evaluation result where hasPassed IS TRUE.
54+ * @param requirePassedAnnotations - When true, implies requirePassedResults and
55+ * only returns spans with at least one human evaluation result where hasPassed IS TRUE.
56+ * @param spanTypes - Array of span types to include. Defaults to all main span types.
57+ * Pass [SpanType.Prompt] for optimizer use cases.
58+ */
4459export async function getSpansWithoutIssues (
4560 {
4661 workspace,
@@ -77,13 +92,10 @@ export async function getSpansWithoutIssues(
7792 } )
7893 }
7994
80- const clickhouseEnabledResult = await isFeatureEnabledByName (
95+ const shouldUseClickHouse = await isClickHouseSpansReadEnabled (
8196 workspace . id ,
82- CLICKHOUSE_SPANS_READ_FLAG ,
8397 db ,
8498 )
85- const shouldUseClickHouse =
86- clickhouseEnabledResult . ok && clickhouseEnabledResult . value
8799
88100 // Get optimization experiment UUIDs (still from PostgreSQL)
89101 const optimizationExperimentUuids = await db
0 commit comments