@duckcodeailabs/dql-agent 1.14.1 → 1.14.3-rc.1

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 (174) hide show
  1. package/dist/agent-run-engine.d.ts +71 -2
  2. package/dist/agent-run-engine.d.ts.map +1 -1
  3. package/dist/agent-run-engine.js +1048 -31
  4. package/dist/agent-run-engine.js.map +1 -1
  5. package/dist/agent-run-gates.d.ts.map +1 -1
  6. package/dist/agent-run-gates.js +12 -0
  7. package/dist/agent-run-gates.js.map +1 -1
  8. package/dist/agent-run-planner.d.ts +6 -0
  9. package/dist/agent-run-planner.d.ts.map +1 -1
  10. package/dist/agent-run-planner.js +2 -0
  11. package/dist/agent-run-planner.js.map +1 -1
  12. package/dist/agent-run-store.d.ts.map +1 -1
  13. package/dist/agent-run-store.js +48 -3
  14. package/dist/agent-run-store.js.map +1 -1
  15. package/dist/agentic/analyst-loop.d.ts +7 -1
  16. package/dist/agentic/analyst-loop.d.ts.map +1 -1
  17. package/dist/agentic/analyst-loop.js +211 -28
  18. package/dist/agentic/analyst-loop.js.map +1 -1
  19. package/dist/agentic/assumptions.d.ts +1 -1
  20. package/dist/agentic/assumptions.d.ts.map +1 -1
  21. package/dist/agentic/assumptions.js.map +1 -1
  22. package/dist/agentic/research/synthesis.d.ts +4 -0
  23. package/dist/agentic/research/synthesis.d.ts.map +1 -1
  24. package/dist/agentic/research/synthesis.js +23 -8
  25. package/dist/agentic/research/synthesis.js.map +1 -1
  26. package/dist/agentic/research-agent.d.ts.map +1 -1
  27. package/dist/agentic/research-agent.js +13 -3
  28. package/dist/agentic/research-agent.js.map +1 -1
  29. package/dist/agentic/sql-authorization.d.ts +8 -0
  30. package/dist/agentic/sql-authorization.d.ts.map +1 -1
  31. package/dist/agentic/sql-authorization.js +233 -2
  32. package/dist/agentic/sql-authorization.js.map +1 -1
  33. package/dist/analytical-compatibility.d.ts.map +1 -1
  34. package/dist/analytical-compatibility.js +8 -1
  35. package/dist/analytical-compatibility.js.map +1 -1
  36. package/dist/analytical-failure-repair.d.ts.map +1 -1
  37. package/dist/analytical-failure-repair.js +6 -2
  38. package/dist/analytical-failure-repair.js.map +1 -1
  39. package/dist/analytical-frame.d.ts +23 -1
  40. package/dist/analytical-frame.d.ts.map +1 -1
  41. package/dist/analytical-frame.js +332 -17
  42. package/dist/analytical-frame.js.map +1 -1
  43. package/dist/analytical-orchestration.d.ts +613 -0
  44. package/dist/analytical-orchestration.d.ts.map +1 -1
  45. package/dist/analytical-orchestration.js +1007 -0
  46. package/dist/analytical-orchestration.js.map +1 -1
  47. package/dist/answer-loop.d.ts +110 -6
  48. package/dist/answer-loop.d.ts.map +1 -1
  49. package/dist/answer-loop.js +1180 -125
  50. package/dist/answer-loop.js.map +1 -1
  51. package/dist/answer-shape.d.ts +32 -1
  52. package/dist/answer-shape.d.ts.map +1 -1
  53. package/dist/answer-shape.js +49 -3
  54. package/dist/answer-shape.js.map +1 -1
  55. package/dist/ask-observability/index.d.ts +11 -0
  56. package/dist/ask-observability/index.d.ts.map +1 -0
  57. package/dist/ask-observability/index.js +7 -0
  58. package/dist/ask-observability/index.js.map +1 -0
  59. package/dist/ask-observability/instrumentation.d.ts +35 -0
  60. package/dist/ask-observability/instrumentation.d.ts.map +1 -0
  61. package/dist/ask-observability/instrumentation.js +472 -0
  62. package/dist/ask-observability/instrumentation.js.map +1 -0
  63. package/dist/ask-observability/observer.d.ts +62 -0
  64. package/dist/ask-observability/observer.d.ts.map +1 -0
  65. package/dist/ask-observability/observer.js +537 -0
  66. package/dist/ask-observability/observer.js.map +1 -0
  67. package/dist/ask-observability/portable.d.ts +98 -0
  68. package/dist/ask-observability/portable.d.ts.map +1 -0
  69. package/dist/ask-observability/portable.js +527 -0
  70. package/dist/ask-observability/portable.js.map +1 -0
  71. package/dist/ask-observability/store.d.ts +130 -0
  72. package/dist/ask-observability/store.d.ts.map +1 -0
  73. package/dist/ask-observability/store.js +1114 -0
  74. package/dist/ask-observability/store.js.map +1 -0
  75. package/dist/ask-observability/types.d.ts +357 -0
  76. package/dist/ask-observability/types.d.ts.map +1 -0
  77. package/dist/ask-observability/types.js +2 -0
  78. package/dist/ask-observability/types.js.map +1 -0
  79. package/dist/ask-observability/utils.d.ts +21 -0
  80. package/dist/ask-observability/utils.d.ts.map +1 -0
  81. package/dist/ask-observability/utils.js +102 -0
  82. package/dist/ask-observability/utils.js.map +1 -0
  83. package/dist/conversation/snapshot.d.ts +20 -0
  84. package/dist/conversation/snapshot.d.ts.map +1 -1
  85. package/dist/conversation/snapshot.js +30 -1
  86. package/dist/conversation/snapshot.js.map +1 -1
  87. package/dist/fixtures/ask-ai-office-shaped.d.ts +153 -0
  88. package/dist/fixtures/ask-ai-office-shaped.d.ts.map +1 -0
  89. package/dist/fixtures/ask-ai-office-shaped.js +94 -0
  90. package/dist/fixtures/ask-ai-office-shaped.js.map +1 -0
  91. package/dist/generated-analytical-proposal.d.ts +37 -1
  92. package/dist/generated-analytical-proposal.d.ts.map +1 -1
  93. package/dist/generated-analytical-proposal.js +211 -3
  94. package/dist/generated-analytical-proposal.js.map +1 -1
  95. package/dist/governed-relational-compiler.d.ts +15 -0
  96. package/dist/governed-relational-compiler.d.ts.map +1 -1
  97. package/dist/governed-relational-compiler.js +99 -1
  98. package/dist/governed-relational-compiler.js.map +1 -1
  99. package/dist/index.d.ts +11 -9
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +7 -5
  102. package/dist/index.js.map +1 -1
  103. package/dist/intent-controller.d.ts +38 -0
  104. package/dist/intent-controller.d.ts.map +1 -1
  105. package/dist/intent-controller.js +31 -1
  106. package/dist/intent-controller.js.map +1 -1
  107. package/dist/meaning-resolution.d.ts +141 -2
  108. package/dist/meaning-resolution.d.ts.map +1 -1
  109. package/dist/meaning-resolution.js +444 -30
  110. package/dist/meaning-resolution.js.map +1 -1
  111. package/dist/metadata/analysis-planner.d.ts.map +1 -1
  112. package/dist/metadata/analysis-planner.js +144 -7
  113. package/dist/metadata/analysis-planner.js.map +1 -1
  114. package/dist/metadata/block-fit.d.ts +18 -0
  115. package/dist/metadata/block-fit.d.ts.map +1 -1
  116. package/dist/metadata/block-fit.js +250 -38
  117. package/dist/metadata/block-fit.js.map +1 -1
  118. package/dist/metadata/catalog.d.ts.map +1 -1
  119. package/dist/metadata/catalog.js +58 -12
  120. package/dist/metadata/catalog.js.map +1 -1
  121. package/dist/metadata/meaning-evidence.d.ts +19 -3
  122. package/dist/metadata/meaning-evidence.d.ts.map +1 -1
  123. package/dist/metadata/meaning-evidence.js +518 -54
  124. package/dist/metadata/meaning-evidence.js.map +1 -1
  125. package/dist/plan-execution-adapter.d.ts +9 -1
  126. package/dist/plan-execution-adapter.d.ts.map +1 -1
  127. package/dist/plan-execution-adapter.js +93 -13
  128. package/dist/plan-execution-adapter.js.map +1 -1
  129. package/dist/provider-egress.d.ts +24 -10
  130. package/dist/provider-egress.d.ts.map +1 -1
  131. package/dist/provider-egress.js +22 -17
  132. package/dist/provider-egress.js.map +1 -1
  133. package/dist/providers/claude.d.ts.map +1 -1
  134. package/dist/providers/claude.js +10 -9
  135. package/dist/providers/claude.js.map +1 -1
  136. package/dist/providers/dispatch.d.ts +27 -1
  137. package/dist/providers/dispatch.d.ts.map +1 -1
  138. package/dist/providers/dispatch.js +63 -1
  139. package/dist/providers/dispatch.js.map +1 -1
  140. package/dist/providers/gemini.js +10 -10
  141. package/dist/providers/gemini.js.map +1 -1
  142. package/dist/providers/index.d.ts +2 -2
  143. package/dist/providers/index.d.ts.map +1 -1
  144. package/dist/providers/index.js +1 -1
  145. package/dist/providers/index.js.map +1 -1
  146. package/dist/providers/ollama.js +15 -15
  147. package/dist/providers/ollama.js.map +1 -1
  148. package/dist/providers/openai.js +22 -22
  149. package/dist/providers/openai.js.map +1 -1
  150. package/dist/providers/types.d.ts +52 -0
  151. package/dist/providers/types.d.ts.map +1 -1
  152. package/dist/providers/types.js.map +1 -1
  153. package/dist/relationship-proof.d.ts +81 -0
  154. package/dist/relationship-proof.d.ts.map +1 -1
  155. package/dist/relationship-proof.js +228 -4
  156. package/dist/relationship-proof.js.map +1 -1
  157. package/dist/research-loop.d.ts.map +1 -1
  158. package/dist/research-loop.js +23 -1
  159. package/dist/research-loop.js.map +1 -1
  160. package/dist/resolved-analytical-plan.d.ts +22 -1
  161. package/dist/resolved-analytical-plan.d.ts.map +1 -1
  162. package/dist/resolved-analytical-plan.js +773 -49
  163. package/dist/resolved-analytical-plan.js.map +1 -1
  164. package/dist/router.d.ts +14 -4
  165. package/dist/router.d.ts.map +1 -1
  166. package/dist/router.js +3668 -425
  167. package/dist/router.js.map +1 -1
  168. package/dist/semantic-bridge/compose.d.ts.map +1 -1
  169. package/dist/semantic-bridge/compose.js +23 -4
  170. package/dist/semantic-bridge/compose.js.map +1 -1
  171. package/dist/semantic-bridge/member-select.d.ts.map +1 -1
  172. package/dist/semantic-bridge/member-select.js +39 -21
  173. package/dist/semantic-bridge/member-select.js.map +1 -1
  174. package/package.json +5 -5
@@ -95,6 +95,381 @@ export interface AnalyticalCoverageGapV1 {
95
95
  planFrozen: boolean;
96
96
  nextActions: string[];
97
97
  }
98
+ /**
99
+ * Roles are deliberately independent of a source's trust tier. A semantic
100
+ * dimension can be an entity label, a categorical breakdown, or a time axis;
101
+ * treating all members as interchangeable is what made an Account question
102
+ * offer owner e-mail and sentiment as substitutes for the account itself.
103
+ *
104
+ * Acceptance: CTX-005, CTX-007, AGT-009, AGT-010.
105
+ */
106
+ export type EvidenceCandidateRoleV1 = 'metric' | 'entity_key' | 'entity_label' | 'categorical_dimension' | 'time_dimension' | 'member' | 'relationship' | 'context';
107
+ /**
108
+ * A typed, content-safe reading of the analytical requirements in a question.
109
+ * It is advisory for retrieval/ranking only: the compatibility solver and the
110
+ * immutable resolved plan still own authorization and execution.
111
+ */
112
+ export interface AnalyticalRequirementSetV1 {
113
+ version: 1;
114
+ measures: string[];
115
+ dimensions: string[];
116
+ entityTerms: string[];
117
+ entityDisplayTerms: string[];
118
+ memberTerms: string[];
119
+ /** Explicit projection fields are requirements, not optional prompt hints. */
120
+ outputTerms?: string[];
121
+ /** `individual` requests a row-level relation rather than an aggregate. */
122
+ grain?: 'individual' | 'aggregate';
123
+ ranking?: {
124
+ metricTerms: string[];
125
+ entityTerms: string[];
126
+ direction: 'top' | 'bottom';
127
+ limit: number;
128
+ /** True means the reader did not specify a count and DQL assumed 10. */
129
+ defaultedLimit: boolean;
130
+ };
131
+ time?: {
132
+ role: 'time_axis' | 'time_filter';
133
+ grain?: 'day' | 'week' | 'month' | 'quarter' | 'year';
134
+ fiscalPeriod?: string;
135
+ /** A fiscal token is not executable until a declared calendar binds it. */
136
+ requiresDeclaredFiscalCalendar: boolean;
137
+ };
138
+ }
139
+ /**
140
+ * Host-owned analytical input to the one bounded meaning call. The seed is
141
+ * built before any provider response and is the only source of explicit user
142
+ * requirements downstream. The model may bind supplied candidate IDs and
143
+ * explain ambiguity; it may not erase, add, or replace the request tuple.
144
+ *
145
+ * This is deliberately not an execution plan. It contains business terms and
146
+ * parsed filters only; the compatibility solver and immutable resolved plan
147
+ * still own qualified identifiers, joins, SQL, trust, and route selection.
148
+ */
149
+ export interface AnalyticalRequirementSeedV1 {
150
+ version: 1;
151
+ sourceQuestion: string;
152
+ requirements: AnalyticalRequirementSetV1;
153
+ queryIntent: {
154
+ measures: string[];
155
+ dimensions: string[];
156
+ filters: Array<{
157
+ field: string;
158
+ value: string;
159
+ }>;
160
+ timeRange?: string;
161
+ timeGrain?: string;
162
+ order?: 'asc' | 'desc';
163
+ limit?: number;
164
+ fiscalCalendarId?: string;
165
+ fiscalDateRoleId?: string;
166
+ };
167
+ }
168
+ /** Build the immutable host request tuple before a meaning model can respond. */
169
+ export declare function buildAnalyticalRequirementSeedV1(input: {
170
+ question: string;
171
+ parsedIntent?: Partial<{
172
+ measures: string[];
173
+ dimensions: string[];
174
+ filters: Array<{
175
+ field: string;
176
+ value: string;
177
+ }>;
178
+ timeRange: string;
179
+ timeGrain: string;
180
+ order: 'asc' | 'desc';
181
+ limit: number;
182
+ fiscalCalendarId: string;
183
+ fiscalDateRoleId: string;
184
+ }>;
185
+ requirements?: AnalyticalRequirementSetV1;
186
+ fiscalCalendar?: {
187
+ id: string;
188
+ dateRoleId?: string;
189
+ fiscalPeriodFieldId?: string;
190
+ };
191
+ }): AnalyticalRequirementSeedV1;
192
+ type RetrievalParsedIntentRefinement = Partial<{
193
+ measures: string[];
194
+ dimensions: string[];
195
+ filters: Array<{
196
+ field: string;
197
+ value: string;
198
+ }>;
199
+ timeRange: string;
200
+ timeGrain: string;
201
+ order: 'asc' | 'desc';
202
+ limit: number;
203
+ fiscalCalendarId: string;
204
+ fiscalDateRoleId: string;
205
+ }>;
206
+ /**
207
+ * Return only parser refinements whose business words occur in the current
208
+ * source question. This deliberately does not try to recover previous turn
209
+ * context: continuation is represented by a server-issued structured choice
210
+ * and merged separately by the host. The helper is exported for regression
211
+ * tests and for router paths that construct a requirement set before a seed.
212
+ */
213
+ export declare function currentQuestionGroundedParsedIntent(question: string, parsedIntent: RetrievalParsedIntentRefinement | undefined): RetrievalParsedIntentRefinement | undefined;
214
+ export type ContextSourceCoverageStatusV1 = 'available' | 'empty' | 'stale' | 'unavailable' | 'errored' | 'skipped';
215
+ /** Source coverage is distinct from a missing capability. A bounded package
216
+ * may omit a relevant candidate; that is not proof that the source lacks it. */
217
+ export interface ContextSourceCoverageV1 {
218
+ version: 1;
219
+ source: 'certified' | 'semantic' | 'governed_relational' | 'exploratory' | 'dbt_manifest' | 'runtime_schema' | 'vector' | 'conversation';
220
+ status: ContextSourceCoverageStatusV1;
221
+ candidateIds: string[];
222
+ reason?: string;
223
+ }
224
+ export type AnalyticalCascadeTierV1 = 'certified' | 'semantic' | 'governed_relational' | 'exploratory_sql' | 'clarify_or_gap';
225
+ export type AnalyticalCascadeTierOutcomeV1 = 'executable' | 'ineligible' | 'unavailable' | 'ambiguous' | 'denied';
226
+ /** One immutable, inspectable decision per ordered authority tier. */
227
+ export interface CascadeTierAttemptV1 {
228
+ version: 1;
229
+ tier: AnalyticalCascadeTierV1;
230
+ outcome: AnalyticalCascadeTierOutcomeV1;
231
+ candidateIds: string[];
232
+ reason: string;
233
+ /** A denied or frozen tier must never silently fall through to another one. */
234
+ planFrozen: boolean;
235
+ }
236
+ /**
237
+ * A server-owned freeze made after a generated exploratory proposal has passed
238
+ * the selected snapshot's SQL/context checks and has been bound to one live
239
+ * execution target. It intentionally contains fingerprints and qualified
240
+ * candidate identities only: the opaque execution capability and SQL text
241
+ * never leave the in-memory host boundary.
242
+ */
243
+ export interface ExploratoryExecutionFreezeV1 {
244
+ version: 1;
245
+ selectedTier: 'exploratory_sql';
246
+ planId: string;
247
+ planFingerprint: string;
248
+ snapshotId: string;
249
+ targetFingerprint: string;
250
+ sqlFingerprint: string;
251
+ candidateIds: string[];
252
+ /** The host minted one single-use capability before connector execution. */
253
+ authorization: 'capability_minted';
254
+ /**
255
+ * Per-output proof emitted by the host SQL validator. When a frozen plan
256
+ * names explicit projected identifiers, a result is displayable only if the
257
+ * authorization receipt carries one exact physical source binding for each
258
+ * of them. Optional for pre-V4 persisted receipts; required for new
259
+ * exploratory execution with required outputs.
260
+ */
261
+ requiredOutputBindings?: ExploratoryRequiredOutputBindingProofV1[];
262
+ /**
263
+ * SQL authorization is distinct from the router plan freeze. Index zero is
264
+ * the first exact SQL handoff; index one is the only permitted same-plan
265
+ * correction after a retryable warehouse execution failure. Older receipts
266
+ * omit this additive field and are interpreted as the original handoff.
267
+ */
268
+ authorizationAttempt?: ExploratoryExecutionAuthorizationAttemptV1;
269
+ }
270
+ /**
271
+ * Host-owned proof that one output alias in the authorized SQL came from the
272
+ * exact physical source selected in the frozen analytical plan. The SQL text
273
+ * remains in the local execution boundary; this portable receipt carries only
274
+ * qualified identifiers and normalized relation/column names.
275
+ */
276
+ export interface ExploratoryRequiredOutputBindingProofV1 {
277
+ version: 1;
278
+ outputName: string;
279
+ qualifiedId: string;
280
+ relation: string;
281
+ column: string;
282
+ }
283
+ /**
284
+ * Server-owned lifecycle marker for an exploratory SQL capability. A repair
285
+ * does not reopen routing or meaning: it may only replace the SQL bytes while
286
+ * preserving the frozen plan, snapshot, target, candidate closure, and
287
+ * read-only validation proof.
288
+ */
289
+ export type ExploratoryExecutionAuthorizationAttemptV1 = {
290
+ version: 1;
291
+ index: 0;
292
+ parentSqlFingerprint?: never;
293
+ } | {
294
+ version: 1;
295
+ index: 1;
296
+ parentSqlFingerprint: string;
297
+ };
298
+ /**
299
+ * A host authorization attaches to a plan the router has already frozen. The
300
+ * plan freeze establishes the meaning, candidate closure, and source snapshot;
301
+ * this receipt establishes only the exact read-only SQL and live target. It
302
+ * is intentionally an alias of the existing wire shape so persisted V1/V3
303
+ * runs remain readable while callers stop treating authorization as the point
304
+ * at which a plan becomes frozen.
305
+ *
306
+ * Acceptance: AGT-029, AGT-031, AGT-034.
307
+ */
308
+ export type ExploratoryExecutionAuthorizationReceiptV1 = ExploratoryExecutionFreezeV1;
309
+ /** A content-safe, server-produced terminal incident for Ask observability. */
310
+ export interface AskTerminalIncidentV1 {
311
+ version: 1;
312
+ code: 'INTERNAL_EXPLORATORY_AUTHORIZATION_STATE_MISMATCH' | 'CONNECTION_NOT_CONFIGURED'
313
+ /** A frozen plan failed before any statement reached the warehouse. */
314
+ | 'COMPILATION_FAILED' | 'ANALYTICAL_EXECUTION_FAILED' | 'ANALYTICAL_COVERAGE_GAP' | 'PROVIDER_FAILURE'
315
+ /** Every admitted Research branch used its bounded window without a finding. */
316
+ | 'RESEARCH_BRANCH_TIMEOUT'
317
+ /** Explicit Research exhausted its root deadline before finalization. */
318
+ | 'RESEARCH_RUN_DEADLINE' | 'CANCELLED';
319
+ boundary: 'plan.compile' | 'semantic.compile' | 'sql.authorize' | 'sql.execute' | 'provider' | 'cascade' | 'run';
320
+ origin: 'internal_invariant' | 'governance_gate' | 'semantic_compiler' | 'plan_compiler' | 'provider' | 'warehouse' | 'unknown';
321
+ impact: 'execution_not_attempted' | 'execution_failed' | 'answer_not_produced' | 'run_cancelled';
322
+ safeAction: 'export_redacted_trace' | 'configure_connection' | 'change_authorized_connection' | 'inspect_failure' | 'retry_same_plan' | 'refresh_snapshot' | 'edit_dql' | 'open_sql_notebook' | 'request_access' | 'reapply_semantic_runtime' | 'review_analytical_failure' | 'inspect_research_failures' | 'none';
323
+ }
324
+ /**
325
+ * A compact, producer-owned account of a completed-but-limited Research run.
326
+ *
327
+ * This is deliberately distinct from `AskTerminalIncidentV1`: the root Ask
328
+ * can retain a receipt-backed finding and its selected trust state while one
329
+ * or more independently bounded Research children failed, timed out, or were
330
+ * skipped. The summary carries only typed counts, reason codes, and frozen
331
+ * child-plan evidence; it never retains branch prompts, result rows, SQL, or
332
+ * provider content.
333
+ */
334
+ export interface AskResearchBranchSummaryV1 {
335
+ version: 1;
336
+ totalBranches: number;
337
+ /** Children that completed their bounded lifecycle. */
338
+ completedBranches: number;
339
+ /** Completed children with a persisted execution receipt in the V2 ledger. */
340
+ receiptBackedBranches: number;
341
+ failedBranches: number;
342
+ timedOutBranches: number;
343
+ skippedBranches: number;
344
+ /** True only when a receipt-backed finding survived alongside a limited child. */
345
+ partialSuccess: boolean;
346
+ failureReasons: Array<{
347
+ code: 'execution_failed' | 'research_branch_timeout' | 'budget_exhausted' | 'run_deadline' | 'cancelled';
348
+ branchCount: number;
349
+ }>;
350
+ /** Frozen child plans actually persisted by the Research root. */
351
+ availableChildPlans: Array<{
352
+ tier: Exclude<AnalyticalCascadeTierV1, 'clarify_or_gap'>;
353
+ frozenPlanCount: number;
354
+ branchCount: number;
355
+ reviewRequired: boolean;
356
+ }>;
357
+ /** Distinct child run IDs carried by durable branch receipts. */
358
+ linkedChildRunCount: number;
359
+ safeAction: 'inspect_research_failures';
360
+ }
361
+ /** One compact canonical story used by both the inspector and full trace. */
362
+ export interface AskDecisionSummaryV1 {
363
+ version: 1;
364
+ summaryFingerprint: string;
365
+ understoodRequest: {
366
+ measures: number;
367
+ dimensions: number;
368
+ entityRequested: boolean;
369
+ outputCount: number;
370
+ ranking?: {
371
+ direction: 'top' | 'bottom';
372
+ limit: number;
373
+ defaultedLimit: boolean;
374
+ };
375
+ conversationBinding: 'none' | 'structured_clarification' | 'prior_result' | 'task_dependency';
376
+ };
377
+ evidenceByRole: Array<{
378
+ role: EvidenceCandidateRoleV1;
379
+ candidateCount: number;
380
+ }>;
381
+ tierDecisions: Array<{
382
+ tier: AnalyticalCascadeTierV1;
383
+ outcome: AnalyticalCascadeTierOutcomeV1;
384
+ planFrozen: boolean;
385
+ }>;
386
+ selectedPlan?: {
387
+ tier: Exclude<AnalyticalCascadeTierV1, 'clarify_or_gap'>;
388
+ planFrozen: boolean;
389
+ reviewRequired: boolean;
390
+ };
391
+ terminalIncident?: AskTerminalIncidentV1;
392
+ /** Present for persisted Research branch evidence; does not change root status. */
393
+ researchBranchSummary?: AskResearchBranchSummaryV1;
394
+ safeNextAction: AskTerminalIncidentV1['safeAction'] | 'none';
395
+ }
396
+ /**
397
+ * A narrow, producer-owned terminal relationship witness carried with the
398
+ * authoritative cascade. It is deliberately enumerated rather than a copy
399
+ * of router prose: durable Ask receipts must explain an allocation/relationship
400
+ * block without persisting a question, candidate label, or inferred join.
401
+ */
402
+ export interface AnalyticalCascadeTerminalGapV1 {
403
+ version: 1;
404
+ code: 'MISSING_RELATIONSHIP';
405
+ requirement: 'certified_relationship_or_allocation_proof';
406
+ /** Qualified evidence IDs only; presentation never infers new paths. */
407
+ witnessCandidateIds: string[];
408
+ }
409
+ /**
410
+ * The shared cascade receipt. This does not itself compile SQL; it prevents
411
+ * downstream presentation/execution layers from silently reinterpreting a
412
+ * question after route selection.
413
+ */
414
+ export interface AnalyticalCascadeDecisionV1 {
415
+ version: 1;
416
+ requirements: AnalyticalRequirementSetV1;
417
+ sourceCoverage: ContextSourceCoverageV1[];
418
+ attempts: CascadeTierAttemptV1[];
419
+ selectedTier?: Exclude<AnalyticalCascadeTierV1, 'clarify_or_gap'>;
420
+ planFrozen: boolean;
421
+ /** Present only after a selected exploratory proposal is host-authorized. */
422
+ exploratoryExecutionFreeze?: ExploratoryExecutionFreezeV1;
423
+ /**
424
+ * Present only when one retryable warehouse failure received the sole
425
+ * permitted same-plan exploratory SQL repair authorization. The original
426
+ * receipt remains above so persisted evidence proves parent-before-repair.
427
+ */
428
+ exploratoryRepairExecutionFreeze?: ExploratoryExecutionFreezeV1;
429
+ /** Present only when the router supplied a typed, relationship-safe gap. */
430
+ terminalGap?: AnalyticalCascadeTerminalGapV1;
431
+ stopReason: 'selected' | 'ambiguous' | 'coverage_gap' | 'denied' | 'post_freeze_failure';
432
+ }
433
+ export type ProviderFailureCauseV1 = 'authentication' | 'model_not_found' | 'rate_limited' | 'gateway' | 'network' | 'provider_timeout' | 'run_deadline' | 'admission_denied' | 'dispatch_budget' | 'cancelled' | 'unknown';
434
+ /** Content-free, redacted provider diagnostics safe to persist in a run. */
435
+ export interface ProviderFailureDiagnosticV1 {
436
+ version: 1;
437
+ cause: ProviderFailureCauseV1;
438
+ phase: 'preflight' | 'classification' | 'meaning_resolution' | 'planning' | 'generation' | 'repair' | 'narration' | 'unknown';
439
+ retryable: boolean;
440
+ safeAction: 'retry_same_provider' | 'fix_provider_configuration' | 'wait_and_retry' | 'inspect_run' | 'none';
441
+ httpStatusClass?: '4xx' | '5xx';
442
+ providerFingerprint?: string;
443
+ modelFingerprint?: string;
444
+ baseOriginFingerprint?: string;
445
+ }
446
+ /**
447
+ * Additive durable diagnostics. V1 and V2 intentionally remain the compact
448
+ * compatibility envelopes used by older persisted runs.
449
+ */
450
+ export interface AgentRunDiagnosticReceiptV3 {
451
+ version: 3;
452
+ runId: string;
453
+ sourceCoverage: ContextSourceCoverageV1[];
454
+ cascade?: AnalyticalCascadeDecisionV1;
455
+ /** Direct projection for run-detail consumers that do not traverse cascade. */
456
+ terminalGap?: AnalyticalCascadeTerminalGapV1;
457
+ planFrozen: boolean;
458
+ orchestrationMode?: 'legacy' | 'shadow' | 'agentic';
459
+ provider?: ProviderFailureDiagnosticV1;
460
+ finalStopReason: string;
461
+ }
462
+ /**
463
+ * Additive canonical Ask story. V1/V2/V3 remain readable; this receipt is
464
+ * deliberately JSON-only so no metadata/index migration is needed.
465
+ */
466
+ export interface AgentRunDiagnosticReceiptV4 {
467
+ version: 4;
468
+ runId: string;
469
+ summary: AskDecisionSummaryV1;
470
+ terminalIncident?: AskTerminalIncidentV1;
471
+ finalStopReason: string;
472
+ }
98
473
  export interface AnalyticalTurnPlanV1 {
99
474
  version: 1;
100
475
  turnId?: string;
@@ -139,6 +514,156 @@ export interface AnalyticalTurnAnswerV1 {
139
514
  * report partial success instead of collapsing the whole turn to one error.
140
515
  */
141
516
  export declare function inferAnalyticalTurnKind(question: string): AnalyticalTurnKind;
517
+ export type RoleBalancedEvidenceCandidate = {
518
+ id: string;
519
+ qualifiedId?: string;
520
+ kind?: string;
521
+ semanticObjectType?: string;
522
+ name?: string;
523
+ aliases?: string[];
524
+ dimensions?: string[];
525
+ timeGrains?: string[];
526
+ relationshipEvidence?: string[];
527
+ relevanceScore?: number;
528
+ exactMatch?: boolean;
529
+ compatibility?: string;
530
+ /**
531
+ * Snapshot-authored compatibility declarations. These are deliberately not
532
+ * folded into general lexical identity: only the categorical-dimension lane
533
+ * may use the narrowly typed declarations below.
534
+ */
535
+ compatibilityFacts?: string[];
536
+ /**
537
+ * A narrowly-scoped host extension derived from the same immutable semantic
538
+ * capability snapshot. It is not a lexical synonym or model assertion:
539
+ * the retriever may mint it only when one MetricFlow-capable grouping field
540
+ * is uniquely available for the requested business role. Keeping the
541
+ * source metric and exact dimension identity here lets routing record the
542
+ * assumption while the frozen capability still owns execution safety.
543
+ */
544
+ sameSnapshotRoleExtension?: SameSnapshotRoleExtensionV1;
545
+ analyticalCapability?: {
546
+ dimensions?: Array<{
547
+ dimensionId?: string;
548
+ }>;
549
+ timeDimensions?: Array<{
550
+ dimensionId?: string;
551
+ }>;
552
+ };
553
+ };
554
+ export interface SameSnapshotRoleExtensionV1 {
555
+ version: 1;
556
+ role: 'categorical_dimension';
557
+ requestedTerm: string;
558
+ metricId: string;
559
+ dimensionId: string;
560
+ /**
561
+ * `sole_metricflow_grouping_dimension` is the deliberately narrow
562
+ * geography recovery path. `exact_metricflow_grouping_dimension` is an
563
+ * equally snapshot-bound extension for a current-question categorical
564
+ * phrase whose exact, qualified dimension is declared by the admitted
565
+ * metric capability. Neither value permits lexical joins or a model-owned
566
+ * field identity.
567
+ */
568
+ basis: 'sole_metricflow_grouping_dimension' | 'exact_metricflow_grouping_dimension';
569
+ }
570
+ /**
571
+ * Entity/display terms are represented in the historical `dimensions` seed
572
+ * so ranking plans can retain their requested grain. They must not consume
573
+ * the separate categorical-dimension admission lane. For example, in "top
574
+ * customers by product category", `customer` is the entity/rank role while
575
+ * `product category` is the required categorical grouping role.
576
+ */
577
+ export declare function categoricalDimensionRequirementTerms(requirements: Pick<AnalyticalRequirementSetV1, 'dimensions' | 'entityTerms' | 'entityDisplayTerms'>): string[];
578
+ /**
579
+ * A small, typed vocabulary bridge for categorical field identities. It is
580
+ * intentionally not a general synonym engine: only the field-kind suffix is
581
+ * canonicalized, while the scoped business noun must still match. Thus
582
+ * `product category` can bind the snapshot-declared `product_type`, whereas
583
+ * `customer_type` cannot satisfy it. A bare `category` remains potentially
584
+ * ambiguous when more than one qualified `*_type` field exists.
585
+ */
586
+ export declare function categoricalDimensionTermsMatch(left: string, right: string): boolean;
587
+ /**
588
+ * Normalize grammatical aggregation wrappers before they become a plan
589
+ * requirement. Retrieval/parser output is allowed to retain useful search
590
+ * phrases, but an immutable plan must never treat "count for each customer"
591
+ * or "for each customer" as separate physical measures. The grouping entity
592
+ * is represented by the dimension/entity roles instead.
593
+ *
594
+ * `order count for each customer` is the common prose form for a count
595
+ * aggregation at customer grain. Keep the aggregation (`count`) and remove
596
+ * the object noun (`order`) only for that exact grouped construction; a named
597
+ * metric such as `order_value` remains untouched.
598
+ */
599
+ export declare function normalizeAnalyticalMeasureTerms(question: string, values: readonly string[], options?: {
600
+ preserveIdentity?: boolean;
601
+ }): string[];
602
+ /**
603
+ * Parse only stable analytical roles. This is purposefully narrower than an
604
+ * LLM interpretation: unknown business phrases remain available to the normal
605
+ * bounded meaning resolver instead of being guessed here.
606
+ */
607
+ export declare function buildAnalyticalRequirementSet(input: {
608
+ question: string;
609
+ parsedIntent?: Partial<{
610
+ measures: string[];
611
+ dimensions: string[];
612
+ filters: Array<{
613
+ field: string;
614
+ value: string;
615
+ }>;
616
+ timeGrain: string;
617
+ limit: number;
618
+ }>;
619
+ }): AnalyticalRequirementSetV1;
620
+ /**
621
+ * Keep account display-key selection separate from common account attributes.
622
+ * Candidate names originate in dbt/semantic identifiers, so underscores and
623
+ * dots must be normalized before testing (`account_sentiment_rating` is just
624
+ * as much an attribute as "Account Sentiment Rating").
625
+ */
626
+ export declare function hasEntityAttributeTerm(value: string): boolean;
627
+ export declare function isEntityAttributeCandidate(candidate: RoleBalancedEvidenceCandidate): boolean;
628
+ /** Classify the role an already-qualified candidate may fill. */
629
+ export declare function evidenceCandidateRoles(candidate: RoleBalancedEvidenceCandidate): EvidenceCandidateRoleV1[];
630
+ /**
631
+ * A direct ranking measure is authoritative for metric admission. Other
632
+ * retrieved metrics remain visible in the lifecycle receipt, but they cannot
633
+ * become a second metric choice merely because they are correlated with the
634
+ * entity phrase in the question.
635
+ */
636
+ export declare function candidateConflictsWithExplicitRankingMeasure(candidate: RoleBalancedEvidenceCandidate, requirements: AnalyticalRequirementSetV1): boolean;
637
+ /**
638
+ * A categorical dimension may satisfy a requested business role only through
639
+ * its own snapshot-authored declaration. In particular, `location_name` is
640
+ * not a synonym for `region`: it can fill a region lane only when metadata
641
+ * explicitly says `alternative-for:region`, or when the dimension itself is
642
+ * declared with the semantic geography role. This protects admission from
643
+ * broad lexical geography expansion while retaining role-balanced recall.
644
+ */
645
+ export declare function candidateMatchesCategoricalDimensionRequirement(candidate: Pick<RoleBalancedEvidenceCandidate, 'compatibilityFacts' | 'sameSnapshotRoleExtension'>, terms: readonly string[]): boolean;
646
+ /**
647
+ * Keep an internal retrieval result broad while making the provider package
648
+ * role-balanced. Exact/alias matches stay pinned; each requested role gets up
649
+ * to two candidates before relevance fills remaining cards.
650
+ */
651
+ export declare function selectRoleBalancedMeaningCandidates<T extends RoleBalancedEvidenceCandidate>(input: {
652
+ candidates: T[];
653
+ requirements: AnalyticalRequirementSetV1;
654
+ maxCandidates?: number;
655
+ /** Use before any kind cap to reserve exact/required-role cards. */
656
+ pinOnly?: boolean;
657
+ }): T[];
658
+ export declare function classifyProviderFailure(input: {
659
+ message?: string;
660
+ code?: string;
661
+ phase?: ProviderFailureDiagnosticV1['phase'];
662
+ providerFingerprint?: string;
663
+ modelFingerprint?: string;
664
+ baseOriginFingerprint?: string;
665
+ }): ProviderFailureDiagnosticV1;
666
+ export declare function buildAnalyticalCascadeDecision(input: Omit<AnalyticalCascadeDecisionV1, 'version'>): AnalyticalCascadeDecisionV1;
142
667
  export declare function splitAnalyticalTasks(question: string): string[];
143
668
  export declare function buildAnalyticalTaskGraph(input: {
144
669
  question: string;
@@ -317,6 +842,52 @@ export interface ResearchEvidenceLedgerV1 {
317
842
  factIds: string[];
318
843
  stoppingReason: 'completed' | 'budget' | 'insufficient_evidence' | 'blocked' | 'not_started';
319
844
  }
845
+ export type ResearchEvidenceVerdictV2 = 'supported' | 'contradicted' | 'inconclusive' | 'failed' | 'skipped';
846
+ /** Deterministic observation classes; none infer causality from returned rows. */
847
+ export type ResearchEvidenceValidatorKindV2 = 'trend' | 'comparison' | 'contributor' | 'anomaly' | 'freshness' | 'counter_evidence';
848
+ export interface ResearchEvidenceValidatorV2 {
849
+ version: 1;
850
+ kind: ResearchEvidenceValidatorKindV2;
851
+ /** True only when a deterministic, receipt-bound predicate was evaluated. */
852
+ evaluated: boolean;
853
+ /** Optional non-causal observation result. Absent means inconclusive. */
854
+ outcome?: 'supports_observation' | 'contradicts_observation';
855
+ receiptFingerprints: string[];
856
+ }
857
+ export interface ResearchHypothesisPlanEntryV2 {
858
+ id: string;
859
+ statement: string;
860
+ expectation: string;
861
+ targetId: string;
862
+ validatorKind: ResearchEvidenceValidatorKindV2;
863
+ }
864
+ export interface ResearchHypothesisPlanV2 {
865
+ version: 2;
866
+ hypotheses: ResearchHypothesisPlanEntryV2[];
867
+ limitedScope: boolean;
868
+ }
869
+ /**
870
+ * V2 makes the difference between a returned row and an evaluated hypothesis
871
+ * explicit. A branch may be observed yet inconclusive; it is never promoted to
872
+ * a causal claim merely because it executed.
873
+ */
874
+ export interface ResearchEvidenceLedgerEntryV2 extends ResearchLedgerEntryV1 {
875
+ verdict: ResearchEvidenceVerdictV2;
876
+ hypothesis?: string;
877
+ validator?: ResearchEvidenceValidatorV2;
878
+ counterEvidenceFactIds: string[];
879
+ }
880
+ export interface ResearchEvidenceLedgerV2 {
881
+ version: 2;
882
+ rootQuestion: string;
883
+ planId?: string;
884
+ snapshotId?: string;
885
+ entries: ResearchEvidenceLedgerEntryV2[];
886
+ factIds: string[];
887
+ groundableBranchCount: number;
888
+ limitedScope: boolean;
889
+ stoppingReason: ResearchEvidenceLedgerV1['stoppingReason'];
890
+ }
320
891
  export declare function capResearchBranches<T>(branches: T[], max?: number): T[];
321
892
  export declare function buildResearchEvidenceLedger(input: {
322
893
  rootQuestion: string;
@@ -325,6 +896,47 @@ export declare function buildResearchEvidenceLedger(input: {
325
896
  entries: ResearchLedgerEntryV1[];
326
897
  stoppingReason?: ResearchEvidenceLedgerV1['stoppingReason'];
327
898
  }): ResearchEvidenceLedgerV1;
899
+ export declare function buildResearchEvidenceLedgerV2(input: {
900
+ rootQuestion: string;
901
+ planId?: string;
902
+ snapshotId?: string;
903
+ /** Number of catalog-grounded branches admitted before execution. A runtime
904
+ * failure must not be misreported as if the catalog had fewer hypotheses. */
905
+ groundableBranchCount?: number;
906
+ entries: Array<ResearchLedgerEntryV1 & {
907
+ verdict?: ResearchEvidenceVerdictV2;
908
+ hypothesis?: string;
909
+ validator?: ResearchEvidenceValidatorV2;
910
+ counterEvidenceFactIds?: string[];
911
+ }>;
912
+ stoppingReason?: ResearchEvidenceLedgerV1['stoppingReason'];
913
+ }): ResearchEvidenceLedgerV2;
914
+ /**
915
+ * Normalise a hypothesis plan into the bounded research contract. The caller
916
+ * may supply fewer than three grounded hypotheses; that is retained honestly as
917
+ * limited scope rather than padded with invented joins or explanations.
918
+ */
919
+ export declare function buildResearchHypothesisPlanV2(input: {
920
+ hypotheses: Array<{
921
+ id?: string;
922
+ statement: string;
923
+ expectation: string;
924
+ targetId: string;
925
+ validatorKind?: ResearchEvidenceValidatorKindV2;
926
+ }>;
927
+ }): ResearchHypothesisPlanV2;
928
+ /** Map an action/expectation to a deterministic observation class only. */
929
+ export declare function inferResearchValidatorKind(statement: string, expectation?: string): ResearchEvidenceValidatorKindV2;
930
+ /**
931
+ * A verdict is promoted only from a validator that evaluated a deterministic
932
+ * observation against a branch receipt. Rows by themselves stay inconclusive;
933
+ * causal statements are never supported by this helper.
934
+ */
935
+ export declare function researchVerdictFromValidatedObservation(input: {
936
+ status: ResearchLedgerEntryV1['status'];
937
+ requestedVerdict?: ResearchEvidenceVerdictV2;
938
+ validator?: ResearchEvidenceValidatorV2;
939
+ }): ResearchEvidenceVerdictV2;
328
940
  /** The only accepted host-side execution identity is a SHA-256 fingerprint. */
329
941
  export declare function normalizeAnalyticalExecutionFingerprint(value: unknown): string | undefined;
330
942
  /**
@@ -333,4 +945,5 @@ export declare function normalizeAnalyticalExecutionFingerprint(value: unknown):
333
945
  */
334
946
  export declare function normalizeAnalyticalExecutionReceipt(value: unknown): DqlArtifactExecutionReceipt | undefined;
335
947
  export declare function buildCoverageGap(input: Omit<AnalyticalCoverageGapV1, 'version'>): AnalyticalCoverageGapV1;
948
+ export {};
336
949
  //# sourceMappingURL=analytical-orchestration.d.ts.map