@duckcodeailabs/dql-agent 1.14.3-rc.1 → 1.14.5
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.
- package/dist/agent-run-engine.d.ts +177 -3
- package/dist/agent-run-engine.d.ts.map +1 -1
- package/dist/agent-run-engine.js +2067 -57
- package/dist/agent-run-engine.js.map +1 -1
- package/dist/agent-run-gates.d.ts.map +1 -1
- package/dist/agent-run-gates.js +51 -3
- package/dist/agent-run-gates.js.map +1 -1
- package/dist/agent-run-store.d.ts.map +1 -1
- package/dist/agent-run-store.js +544 -9
- package/dist/agent-run-store.js.map +1 -1
- package/dist/agentic/analyst-loop.d.ts +2 -0
- package/dist/agentic/analyst-loop.d.ts.map +1 -1
- package/dist/agentic/analyst-loop.js +41 -4
- package/dist/agentic/analyst-loop.js.map +1 -1
- package/dist/agentic/ledger-tools.d.ts.map +1 -1
- package/dist/agentic/ledger-tools.js +8 -1
- package/dist/agentic/ledger-tools.js.map +1 -1
- package/dist/agentic/orchestrator-policy.d.ts +3 -1
- package/dist/agentic/orchestrator-policy.d.ts.map +1 -1
- package/dist/agentic/orchestrator-policy.js +1 -1
- package/dist/agentic/orchestrator-policy.js.map +1 -1
- package/dist/agentic/tool-loop.d.ts +13 -1
- package/dist/agentic/tool-loop.d.ts.map +1 -1
- package/dist/agentic/tool-loop.js +441 -32
- package/dist/agentic/tool-loop.js.map +1 -1
- package/dist/analytical-frame.d.ts +19 -0
- package/dist/analytical-frame.d.ts.map +1 -1
- package/dist/analytical-frame.js +170 -12
- package/dist/analytical-frame.js.map +1 -1
- package/dist/analytical-orchestration.d.ts +949 -10
- package/dist/analytical-orchestration.d.ts.map +1 -1
- package/dist/analytical-orchestration.js +499 -56
- package/dist/analytical-orchestration.js.map +1 -1
- package/dist/answer-loop.d.ts +166 -2
- package/dist/answer-loop.d.ts.map +1 -1
- package/dist/answer-loop.js +654 -18
- package/dist/answer-loop.js.map +1 -1
- package/dist/answer-shape.d.ts +27 -0
- package/dist/answer-shape.d.ts.map +1 -1
- package/dist/answer-shape.js +55 -0
- package/dist/answer-shape.js.map +1 -1
- package/dist/ask-observability/instrumentation.d.ts.map +1 -1
- package/dist/ask-observability/instrumentation.js +52 -1
- package/dist/ask-observability/instrumentation.js.map +1 -1
- package/dist/ask-observability/portable.js +562 -0
- package/dist/ask-observability/portable.js.map +1 -1
- package/dist/ask-observability/types.d.ts +26 -3
- package/dist/ask-observability/types.d.ts.map +1 -1
- package/dist/ask-observability/types.js.map +1 -1
- package/dist/ask-runtime/ask-agent-runtime-v2.d.ts +850 -0
- package/dist/ask-runtime/ask-agent-runtime-v2.d.ts.map +1 -0
- package/dist/ask-runtime/ask-agent-runtime-v2.js +1716 -0
- package/dist/ask-runtime/ask-agent-runtime-v2.js.map +1 -0
- package/dist/ask-runtime/ask-analyst-runtime.d.ts +95 -0
- package/dist/ask-runtime/ask-analyst-runtime.d.ts.map +1 -0
- package/dist/ask-runtime/ask-analyst-runtime.js +8280 -0
- package/dist/ask-runtime/ask-analyst-runtime.js.map +1 -0
- package/dist/conversation/session-store.d.ts +31 -0
- package/dist/conversation/session-store.d.ts.map +1 -1
- package/dist/conversation/session-store.js +38 -0
- package/dist/conversation/session-store.js.map +1 -1
- package/dist/conversation/snapshot.d.ts +4 -1
- package/dist/conversation/snapshot.d.ts.map +1 -1
- package/dist/conversation/snapshot.js +85 -3
- package/dist/conversation/snapshot.js.map +1 -1
- package/dist/conversation/turn-trust.d.ts.map +1 -1
- package/dist/conversation/turn-trust.js +2 -0
- package/dist/conversation/turn-trust.js.map +1 -1
- package/dist/embeddings/provider.d.ts +1 -0
- package/dist/embeddings/provider.d.ts.map +1 -1
- package/dist/embeddings/provider.js +18 -0
- package/dist/embeddings/provider.js.map +1 -1
- package/dist/generated-analytical-proposal.js +37 -2
- package/dist/generated-analytical-proposal.js.map +1 -1
- package/dist/index.d.ts +15 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/intent-controller.d.ts +77 -1
- package/dist/intent-controller.d.ts.map +1 -1
- package/dist/intent-controller.js +1 -1
- package/dist/intent-controller.js.map +1 -1
- package/dist/kg/build.js +32 -2
- package/dist/kg/build.js.map +1 -1
- package/dist/meaning-resolution.d.ts +129 -0
- package/dist/meaning-resolution.d.ts.map +1 -1
- package/dist/meaning-resolution.js +108 -15
- package/dist/meaning-resolution.js.map +1 -1
- package/dist/metadata/analysis-planner.js +57 -6
- package/dist/metadata/analysis-planner.js.map +1 -1
- package/dist/metadata/catalog.d.ts +14 -0
- package/dist/metadata/catalog.d.ts.map +1 -1
- package/dist/metadata/catalog.js +28 -1
- package/dist/metadata/catalog.js.map +1 -1
- package/dist/metadata/meaning-evidence.d.ts +19 -0
- package/dist/metadata/meaning-evidence.d.ts.map +1 -1
- package/dist/metadata/meaning-evidence.js +113 -6
- package/dist/metadata/meaning-evidence.js.map +1 -1
- package/dist/provider-egress.d.ts +4 -1
- package/dist/provider-egress.d.ts.map +1 -1
- package/dist/provider-egress.js +50 -5
- package/dist/provider-egress.js.map +1 -1
- package/dist/providers/claude.d.ts +2 -2
- package/dist/providers/claude.d.ts.map +1 -1
- package/dist/providers/claude.js +191 -28
- package/dist/providers/claude.js.map +1 -1
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/openai.d.ts +2 -2
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +191 -21
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/types.d.ts +79 -1
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/providers/types.js.map +1 -1
- package/dist/requirement-clauses.d.ts +23 -0
- package/dist/requirement-clauses.d.ts.map +1 -0
- package/dist/requirement-clauses.js +70 -0
- package/dist/requirement-clauses.js.map +1 -0
- package/dist/resolved-analytical-plan.d.ts.map +1 -1
- package/dist/resolved-analytical-plan.js +201 -15
- package/dist/resolved-analytical-plan.js.map +1 -1
- package/dist/router.d.ts +109 -2
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +753 -76
- package/dist/router.js.map +1 -1
- package/package.json +4 -4
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Acceptance: AGT-027..033, CTX-007, PERF-003, E2E-022.
|
|
13
13
|
*/
|
|
14
|
-
import type { DqlArtifactExecutionReceipt } from '@duckcodeailabs/dql-core';
|
|
14
|
+
import type { AgentRunTelemetryV1, DqlArtifactExecutionReceipt } from '@duckcodeailabs/dql-core';
|
|
15
15
|
export declare const ANALYTICAL_ORCHESTRATION_CONTRACT_VERSION: 1;
|
|
16
16
|
export type AnalyticalTurnKind = 'conversation' | 'definition' | 'lookup' | 'ranking' | 'breakdown' | 'comparison' | 'drilldown' | 'diagnosis' | 'research' | 'compound' | 'clarification' | 'aggregation';
|
|
17
17
|
export type AnalyticalTaskKind = 'definition' | 'aggregation' | 'ranking' | 'attribute_lookup' | 'breakdown' | 'comparison' | 'drilldown' | 'diagnosis' | 'research_branch';
|
|
@@ -74,14 +74,53 @@ export interface AnalyticalTaskV1 {
|
|
|
74
74
|
source: 'conversation' | 'result' | 'user';
|
|
75
75
|
}>;
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Trust projected for one task outcome. This is intentionally the same
|
|
79
|
+
* local-first vocabulary used by the canonical answer, but it is declared
|
|
80
|
+
* independently so task receipts remain readable without importing the run
|
|
81
|
+
* engine (and old JSON records remain valid).
|
|
82
|
+
*/
|
|
83
|
+
export type AnalyticalTaskOutcomeTrustStateV1 = 'certified' | 'governed' | 'review_required' | 'blocked' | 'not_applicable';
|
|
84
|
+
/** Finalized state for one bounded Ask clause or Research branch. */
|
|
85
|
+
export type AnalyticalTaskOutcomeStatusV1 = 'completed' | 'partial' | 'gap' | 'blocked'
|
|
86
|
+
/** A child was deliberately not executed because its required parent failed. */
|
|
87
|
+
| 'dependency_blocked';
|
|
88
|
+
/** Typed, content-safe failure retained per task rather than collapsed into the root. */
|
|
89
|
+
export interface AnalyticalTaskFailureV1 {
|
|
90
|
+
version: 1;
|
|
91
|
+
code: string;
|
|
92
|
+
message: string;
|
|
93
|
+
phase: 'planning' | 'execution' | 'dependency';
|
|
94
|
+
}
|
|
77
95
|
/** Durable, content-only outcome for one independent clause/branch. */
|
|
78
96
|
export interface AnalyticalTaskOutcomeV1 {
|
|
79
97
|
version: 1;
|
|
80
98
|
taskId: string;
|
|
81
|
-
status:
|
|
99
|
+
status: AnalyticalTaskOutcomeStatusV1;
|
|
100
|
+
/** Present once a compiler or executor established task-local provenance. */
|
|
101
|
+
trustState?: AnalyticalTaskOutcomeTrustStateV1;
|
|
82
102
|
summary?: string;
|
|
83
103
|
resultFingerprint?: string;
|
|
84
104
|
gap?: AnalyticalCoverageGapV1;
|
|
105
|
+
/** Typed cause when the task did not produce an independent result. */
|
|
106
|
+
failure?: AnalyticalTaskFailureV1;
|
|
107
|
+
/** Parent task IDs that prevented this child from executing. */
|
|
108
|
+
dependencyTaskIds?: string[];
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Additive turn-level task receipt for ordinary Ask. The run's historical
|
|
112
|
+
* terminal status stays wire-compatible; this summary distinguishes a
|
|
113
|
+
* completed, partial, or fully blocked multi-task answer without hiding any
|
|
114
|
+
* independently validated sibling result.
|
|
115
|
+
*/
|
|
116
|
+
export interface AnalyticalTaskOutcomeSummaryV1 {
|
|
117
|
+
version: 1;
|
|
118
|
+
status: 'completed' | 'partial' | 'blocked';
|
|
119
|
+
trustState: AnalyticalTaskOutcomeTrustStateV1;
|
|
120
|
+
taskCount: number;
|
|
121
|
+
successfulTaskIds: string[];
|
|
122
|
+
failedTaskIds: string[];
|
|
123
|
+
dependencyBlockedTaskIds: string[];
|
|
85
124
|
}
|
|
86
125
|
export interface AnalyticalCoverageGapV1 {
|
|
87
126
|
version: 1;
|
|
@@ -104,6 +143,13 @@ export interface AnalyticalCoverageGapV1 {
|
|
|
104
143
|
* Acceptance: CTX-005, CTX-007, AGT-009, AGT-010.
|
|
105
144
|
*/
|
|
106
145
|
export type EvidenceCandidateRoleV1 = 'metric' | 'entity_key' | 'entity_label' | 'categorical_dimension' | 'time_dimension' | 'member' | 'relationship' | 'context';
|
|
146
|
+
/**
|
|
147
|
+
* Content-safe statement of what the bounded planner package established for
|
|
148
|
+
* one requested role. `alternatives` deliberately means that qualified cards
|
|
149
|
+
* were retained for a user choice; it never claims the business meaning was
|
|
150
|
+
* proven merely because retrieval found related fields.
|
|
151
|
+
*/
|
|
152
|
+
export type EvidenceRoleCoverageStateV1 = 'proven' | 'alternatives';
|
|
107
153
|
/**
|
|
108
154
|
* A typed, content-safe reading of the analytical requirements in a question.
|
|
109
155
|
* It is advisory for retrieval/ranking only: the compatibility solver and the
|
|
@@ -116,6 +162,13 @@ export interface AnalyticalRequirementSetV1 {
|
|
|
116
162
|
entityTerms: string[];
|
|
117
163
|
entityDisplayTerms: string[];
|
|
118
164
|
memberTerms: string[];
|
|
165
|
+
/**
|
|
166
|
+
* A host-validated predicate reconstructed from one stable prior result
|
|
167
|
+
* selection. This is execution context, not an LLM-selected meaning: the
|
|
168
|
+
* runtime keeps it through retrieval/planning so a deictic follow-up cannot
|
|
169
|
+
* widen back to the full warehouse after reload.
|
|
170
|
+
*/
|
|
171
|
+
priorResultMemberBinding?: AnalyticalPriorResultMemberBindingV1;
|
|
119
172
|
/** Explicit projection fields are requirements, not optional prompt hints. */
|
|
120
173
|
outputTerms?: string[];
|
|
121
174
|
/** `individual` requests a row-level relation rather than an aggregate. */
|
|
@@ -127,15 +180,77 @@ export interface AnalyticalRequirementSetV1 {
|
|
|
127
180
|
limit: number;
|
|
128
181
|
/** True means the reader did not specify a count and DQL assumed 10. */
|
|
129
182
|
defaultedLimit: boolean;
|
|
183
|
+
/** Per-group top-N ("top 2 per month") vs one overall ranking. */
|
|
184
|
+
scope?: 'overall' | 'per_group';
|
|
130
185
|
};
|
|
131
186
|
time?: {
|
|
132
187
|
role: 'time_axis' | 'time_filter';
|
|
133
188
|
grain?: 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
189
|
+
/**
|
|
190
|
+
* A bounded period the answer must be restricted to. This clause was
|
|
191
|
+
* previously UNREPRESENTABLE: "last two months" had no slot anywhere in
|
|
192
|
+
* the requirement layer, so it degraded into a grouping dimension while
|
|
193
|
+
* its count was misread as a row limit. A window is a restriction on
|
|
194
|
+
* WHEN, independent of whether the answer also groups by a grain.
|
|
195
|
+
*/
|
|
196
|
+
window?: AnalyticalTimeWindowV1;
|
|
134
197
|
fiscalPeriod?: string;
|
|
135
198
|
/** A fiscal token is not executable until a declared calendar binds it. */
|
|
136
199
|
requiresDeclaredFiscalCalendar: boolean;
|
|
137
200
|
};
|
|
201
|
+
/**
|
|
202
|
+
* Where each clause came from, so runtime re-derivation can refresh a
|
|
203
|
+
* clause read from the current question without silently deleting one the
|
|
204
|
+
* user established earlier in the conversation or via a clarification.
|
|
205
|
+
*/
|
|
206
|
+
clauseMeta?: {
|
|
207
|
+
time?: RequirementClauseMetaV1;
|
|
208
|
+
ranking?: RequirementClauseMetaV1;
|
|
209
|
+
};
|
|
138
210
|
}
|
|
211
|
+
/** A typed time restriction; `expression` is the canonical resolver input. */
|
|
212
|
+
export interface AnalyticalTimeWindowV1 {
|
|
213
|
+
version: 1;
|
|
214
|
+
kind: 'relative' | 'absolute' | 'named_period';
|
|
215
|
+
/** Canonical digits form accepted by `resolvePlanTimeRange`, e.g. "last 2 months". */
|
|
216
|
+
expression: string;
|
|
217
|
+
relative?: {
|
|
218
|
+
count: number;
|
|
219
|
+
unit: 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
220
|
+
/** True = complete calendar periods; false = trailing from now. */
|
|
221
|
+
complete: boolean;
|
|
222
|
+
};
|
|
223
|
+
absolute?: {
|
|
224
|
+
startInclusive: string;
|
|
225
|
+
endExclusive: string;
|
|
226
|
+
};
|
|
227
|
+
namedPeriod?: string;
|
|
228
|
+
}
|
|
229
|
+
export type RequirementClauseProvenance = 'question' | 'inherited' | 'clarification' | 'defaulted';
|
|
230
|
+
export interface RequirementClauseMetaV1 {
|
|
231
|
+
provenance: RequirementClauseProvenance;
|
|
232
|
+
required: boolean;
|
|
233
|
+
sourceTurnId?: string;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Additive, host-owned representation of a selected value from a prior
|
|
237
|
+
* canonical result. It intentionally mirrors the engine boundary without
|
|
238
|
+
* importing that module, so analytical framing remains cycle-free.
|
|
239
|
+
*/
|
|
240
|
+
export interface AnalyticalPriorResultMemberBindingV1 {
|
|
241
|
+
version: 1;
|
|
242
|
+
displayDimension: string;
|
|
243
|
+
values: string[];
|
|
244
|
+
sourceTurnId?: string;
|
|
245
|
+
resultFingerprint?: string;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Preserve a validated prior-result predicate as typed analytical context.
|
|
249
|
+
* The selected display key supplies the entity/display requirements needed to
|
|
250
|
+
* retrieve relationship closure; the literal values remain an immutable host
|
|
251
|
+
* filter and are never treated as a provider-selected member meaning.
|
|
252
|
+
*/
|
|
253
|
+
export declare function withAnalyticalPriorResultMemberBinding(requirements: AnalyticalRequirementSetV1, binding: AnalyticalPriorResultMemberBindingV1 | undefined): AnalyticalRequirementSetV1;
|
|
139
254
|
/**
|
|
140
255
|
* Host-owned analytical input to the one bounded meaning call. The seed is
|
|
141
256
|
* built before any provider response and is the only source of explicit user
|
|
@@ -183,6 +298,7 @@ export declare function buildAnalyticalRequirementSeedV1(input: {
|
|
|
183
298
|
fiscalDateRoleId: string;
|
|
184
299
|
}>;
|
|
185
300
|
requirements?: AnalyticalRequirementSetV1;
|
|
301
|
+
priorResultMemberBinding?: AnalyticalPriorResultMemberBindingV1;
|
|
186
302
|
fiscalCalendar?: {
|
|
187
303
|
id: string;
|
|
188
304
|
dateRoleId?: string;
|
|
@@ -211,6 +327,18 @@ type RetrievalParsedIntentRefinement = Partial<{
|
|
|
211
327
|
* tests and for router paths that construct a requirement set before a seed.
|
|
212
328
|
*/
|
|
213
329
|
export declare function currentQuestionGroundedParsedIntent(question: string, parsedIntent: RetrievalParsedIntentRefinement | undefined): RetrievalParsedIntentRefinement | undefined;
|
|
330
|
+
/**
|
|
331
|
+
* Preserve a small set of explicit current-question literals even when a
|
|
332
|
+
* retriever did not emit a parser filter. This is deliberately not a value
|
|
333
|
+
* search or synonym engine: it records only quoted values, capitalized proper
|
|
334
|
+
* names, and values introduced by an explicit predicate phrase. The planner
|
|
335
|
+
* must still bind each term to an admitted, qualified member/dimension card
|
|
336
|
+
* before it can become an executable filter.
|
|
337
|
+
*
|
|
338
|
+
* Without this host-owned atom, "customers in Philadelphia" could reach a
|
|
339
|
+
* broad certified fit after retrieval silently omitted the parser filter.
|
|
340
|
+
*/
|
|
341
|
+
export declare function currentQuestionLiteralMemberTerms(question: string): string[];
|
|
214
342
|
export type ContextSourceCoverageStatusV1 = 'available' | 'empty' | 'stale' | 'unavailable' | 'errored' | 'skipped';
|
|
215
343
|
/** Source coverage is distinct from a missing capability. A bounded package
|
|
216
344
|
* may omit a relevant candidate; that is not proof that the source lacks it. */
|
|
@@ -311,13 +439,15 @@ export interface AskTerminalIncidentV1 {
|
|
|
311
439
|
version: 1;
|
|
312
440
|
code: 'INTERNAL_EXPLORATORY_AUTHORIZATION_STATE_MISMATCH' | 'CONNECTION_NOT_CONFIGURED'
|
|
313
441
|
/** A frozen plan failed before any statement reached the warehouse. */
|
|
314
|
-
| 'COMPILATION_FAILED'
|
|
442
|
+
| 'COMPILATION_FAILED'
|
|
443
|
+
/** The executed rows did not satisfy the immutable frozen result contract. */
|
|
444
|
+
| 'RESULT_CONTRACT_MISMATCH' | 'ANALYTICAL_EXECUTION_FAILED' | 'ANALYTICAL_COVERAGE_GAP' | 'PROVIDER_FAILURE'
|
|
315
445
|
/** Every admitted Research branch used its bounded window without a finding. */
|
|
316
446
|
| 'RESEARCH_BRANCH_TIMEOUT'
|
|
317
447
|
/** Explicit Research exhausted its root deadline before finalization. */
|
|
318
448
|
| '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';
|
|
449
|
+
boundary: 'plan.compile' | 'semantic.compile' | 'sql.authorize' | 'sql.execute' | 'result.validate' | 'provider' | 'cascade' | 'run';
|
|
450
|
+
origin: 'internal_invariant' | 'governance_gate' | 'semantic_compiler' | 'plan_compiler' | 'result_validator' | 'provider' | 'warehouse' | 'unknown';
|
|
321
451
|
impact: 'execution_not_attempted' | 'execution_failed' | 'answer_not_produced' | 'run_cancelled';
|
|
322
452
|
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
453
|
}
|
|
@@ -435,7 +565,7 @@ export type ProviderFailureCauseV1 = 'authentication' | 'model_not_found' | 'rat
|
|
|
435
565
|
export interface ProviderFailureDiagnosticV1 {
|
|
436
566
|
version: 1;
|
|
437
567
|
cause: ProviderFailureCauseV1;
|
|
438
|
-
phase: 'preflight' | 'classification' | 'meaning_resolution' | 'planning' | 'generation' | 'repair' | 'narration' | 'unknown';
|
|
568
|
+
phase: 'preflight' | 'classification' | 'meaning_resolution' | 'planning' | 'generation' | 'repair' | 'narration' | 'agent_control' | 'tool_followup' | 'unknown';
|
|
439
569
|
retryable: boolean;
|
|
440
570
|
safeAction: 'retry_same_provider' | 'fix_provider_configuration' | 'wait_and_retry' | 'inspect_run' | 'none';
|
|
441
571
|
httpStatusClass?: '4xx' | '5xx';
|
|
@@ -470,6 +600,664 @@ export interface AgentRunDiagnosticReceiptV4 {
|
|
|
470
600
|
terminalIncident?: AskTerminalIncidentV1;
|
|
471
601
|
finalStopReason: string;
|
|
472
602
|
}
|
|
603
|
+
/**
|
|
604
|
+
* Ask Analyst Runtime V1 contracts.
|
|
605
|
+
*
|
|
606
|
+
* These records deliberately separate an agent's business interpretation from
|
|
607
|
+
* the deterministic compiler/execution authority. They contain typed intent,
|
|
608
|
+
* stable candidate identities, and receipts — never prompts, provider
|
|
609
|
+
* responses, SQL text, result rows, credentials, or hidden reasoning.
|
|
610
|
+
*
|
|
611
|
+
* Acceptance: AGT-035..040, API-015, OBS-015, E2E-023.
|
|
612
|
+
*/
|
|
613
|
+
export type AskAnalystRuntimeModeV1 = 'legacy' | 'shadow' | 'authoritative';
|
|
614
|
+
export interface BusinessQuestionFrameV3 {
|
|
615
|
+
version: 3;
|
|
616
|
+
/** Stable only within the persisted run; raw question text stays on AgentRun. */
|
|
617
|
+
questionFingerprint: string;
|
|
618
|
+
kind: AnalyticalTurnKind;
|
|
619
|
+
requirements: AnalyticalRequirementSetV1;
|
|
620
|
+
/** A source question supplied a top-N default; presentation must disclose it. */
|
|
621
|
+
defaultedTop?: {
|
|
622
|
+
limit: number;
|
|
623
|
+
};
|
|
624
|
+
conversation: {
|
|
625
|
+
binding: 'none' | 'structured_clarification' | 'prior_result' | 'task_dependency';
|
|
626
|
+
sourceTurnId?: string;
|
|
627
|
+
selectedStableId?: string;
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
export type AnalyticalHypothesisKindV1 = 'direct_answer' | 'trend' | 'comparison' | 'contributor' | 'anomaly' | 'freshness' | 'counter_evidence';
|
|
631
|
+
/** Agent-proposed question to test; deterministic execution validates it. */
|
|
632
|
+
export interface AnalyticalHypothesisV1 {
|
|
633
|
+
version: 1;
|
|
634
|
+
id: string;
|
|
635
|
+
kind: AnalyticalHypothesisKindV1;
|
|
636
|
+
taskId: string;
|
|
637
|
+
status: 'planned' | 'supported' | 'contradicted' | 'inconclusive' | 'failed' | 'skipped';
|
|
638
|
+
requiredRoles: EvidenceCandidateRoleV1[];
|
|
639
|
+
}
|
|
640
|
+
/** Bounded mission owned by the Ask runtime before a compiler is selected. */
|
|
641
|
+
export interface AnalyticalMissionV1 {
|
|
642
|
+
version: 1;
|
|
643
|
+
mode: 'ask' | 'research';
|
|
644
|
+
taskLimit: number;
|
|
645
|
+
planningContinuationLimit: number;
|
|
646
|
+
/**
|
|
647
|
+
* The ingress task graph exceeded this mission's bounded capacity. This is
|
|
648
|
+
* separate from `deferredTasks`: ordinary Ask must present a scope outcome
|
|
649
|
+
* before planning/execution rather than silently dropping clauses.
|
|
650
|
+
*/
|
|
651
|
+
scopeOverflow?: boolean;
|
|
652
|
+
tasks: AnalyticalTaskV1[];
|
|
653
|
+
/**
|
|
654
|
+
* Ordinary Ask currently freezes one route-neutral executable program per
|
|
655
|
+
* turn. When ingress splits a compound request, retain the unexecuted
|
|
656
|
+
* clauses explicitly instead of silently running task-1 and losing the
|
|
657
|
+
* rest. Research owns the multi-branch execution contract.
|
|
658
|
+
*/
|
|
659
|
+
deferredTasks?: Array<Pick<AnalyticalTaskV1, 'id' | 'kind'>>;
|
|
660
|
+
hypotheses: AnalyticalHypothesisV1[];
|
|
661
|
+
}
|
|
662
|
+
export interface EvidenceWorkspaceToolReceiptV1 {
|
|
663
|
+
version: 1;
|
|
664
|
+
id: string;
|
|
665
|
+
kind: 'retrieve_snapshot' | 'candidate_extension' | 'compiler_broker' | 'provider_meaning' | 'execute' | 'repair';
|
|
666
|
+
status: 'completed' | 'skipped' | 'failed';
|
|
667
|
+
candidateIds: string[];
|
|
668
|
+
reasonCode: string;
|
|
669
|
+
}
|
|
670
|
+
/** Same-snapshot evidence admission; excluded is never interpreted as absent. */
|
|
671
|
+
export interface EvidenceWorkspaceV1 {
|
|
672
|
+
version: 1;
|
|
673
|
+
snapshotId?: string;
|
|
674
|
+
sourceFingerprint?: string;
|
|
675
|
+
sourceCoverage: ContextSourceCoverageV1[];
|
|
676
|
+
/**
|
|
677
|
+
* Additive V2 admission projection. Legacy readers use
|
|
678
|
+
* `admittedCandidateIds`; new Ask runs retain the qualified 32-card
|
|
679
|
+
* execution workspace separately from the 16 cards released to the
|
|
680
|
+
* planner. Both are stable IDs from one immutable snapshot.
|
|
681
|
+
*/
|
|
682
|
+
workspaceCandidateIds?: string[];
|
|
683
|
+
plannerCandidateIds?: string[];
|
|
684
|
+
admittedCandidateIds: string[];
|
|
685
|
+
excludedCandidates: Array<{
|
|
686
|
+
id: string;
|
|
687
|
+
reasonCode: 'role_cap' | 'incompatible' | 'ranking_conflict' | 'duplicate' | 'not_admitted';
|
|
688
|
+
}>;
|
|
689
|
+
tools: EvidenceWorkspaceToolReceiptV1[];
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Route-neutral analytical intent. Certified, MetricFlow, governed
|
|
693
|
+
* relational, and exploratory SQL are all compilers of this one program.
|
|
694
|
+
*/
|
|
695
|
+
export interface AnalyticalProgramV1 {
|
|
696
|
+
version: 1;
|
|
697
|
+
id: string;
|
|
698
|
+
frameFingerprint: string;
|
|
699
|
+
taskIds: string[];
|
|
700
|
+
/** Immutable selected evidence identities. Compilers may only consume these. */
|
|
701
|
+
candidateIds: string[];
|
|
702
|
+
/**
|
|
703
|
+
* Same-snapshot compiler context. This is deliberately separate from the
|
|
704
|
+
* bounded meaning cards: a physical relation/column closure may be needed
|
|
705
|
+
* for a pre-freeze fallback even when it was not sent to the meaning model.
|
|
706
|
+
* It is still immutable, target-scoped by the compiler, and never a license
|
|
707
|
+
* to retrieve or nominate a new business meaning.
|
|
708
|
+
*/
|
|
709
|
+
executionCandidateIds?: string[];
|
|
710
|
+
requiredRoles: EvidenceCandidateRoleV1[];
|
|
711
|
+
/** Route-neutral predicate/member contract; never inferred by a compiler. */
|
|
712
|
+
filters: Array<{
|
|
713
|
+
fieldTerms: string[];
|
|
714
|
+
memberIds: string[];
|
|
715
|
+
/** Literal/member binding owned by the program, never guessed by a compiler. */
|
|
716
|
+
value: string;
|
|
717
|
+
operator: 'equals' | 'in' | 'between' | 'contains' | 'unknown';
|
|
718
|
+
}>;
|
|
719
|
+
ranking?: {
|
|
720
|
+
metricTerms: string[];
|
|
721
|
+
direction: 'asc' | 'desc';
|
|
722
|
+
limit: number;
|
|
723
|
+
defaultedLimit?: boolean;
|
|
724
|
+
};
|
|
725
|
+
time?: {
|
|
726
|
+
roleTerms: string[];
|
|
727
|
+
calendarId?: string;
|
|
728
|
+
fiscalPeriodTerms: string[];
|
|
729
|
+
grain?: NonNullable<AnalyticalRequirementSetV1['time']>['grain'];
|
|
730
|
+
};
|
|
731
|
+
comparison?: {
|
|
732
|
+
kind: 'none' | 'period_over_period' | 'segment' | 'baseline';
|
|
733
|
+
terms: string[];
|
|
734
|
+
};
|
|
735
|
+
/** Stable relationship evidence IDs required to combine selected objects. */
|
|
736
|
+
relationshipRequirements: string[];
|
|
737
|
+
outputs: {
|
|
738
|
+
measures: string[];
|
|
739
|
+
dimensions: string[];
|
|
740
|
+
entityDisplayTerms: string[];
|
|
741
|
+
timeGrain?: NonNullable<AnalyticalRequirementSetV1['time']>['grain'];
|
|
742
|
+
limit?: number;
|
|
743
|
+
assertions: Array<'all_requested_measures' | 'all_requested_dimensions' | 'safe_relationship_closure' | 'result_contract'>;
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
/** Runtime-owned selection receipt around the existing immutable RAP. */
|
|
747
|
+
export interface ResolvedAnalyticalPlanV2 {
|
|
748
|
+
version: 2;
|
|
749
|
+
programId: string;
|
|
750
|
+
compiler: 'certified' | 'metricflow' | 'governed_relational' | 'exploratory_sql' | 'none';
|
|
751
|
+
selectedTier?: Exclude<AnalyticalCascadeTierV1, 'clarify_or_gap'>;
|
|
752
|
+
planFrozen: boolean;
|
|
753
|
+
reviewRequired: boolean;
|
|
754
|
+
planFingerprint?: string;
|
|
755
|
+
}
|
|
756
|
+
/** Typed continuation material that survives reload without reparsing prose. */
|
|
757
|
+
export interface AskAnalystConversationDeltaV1 {
|
|
758
|
+
version: 1;
|
|
759
|
+
sourceQuestionFingerprint: string;
|
|
760
|
+
selectedStableId?: string;
|
|
761
|
+
selectedResultBindingId?: string;
|
|
762
|
+
partialFrame: Pick<BusinessQuestionFrameV3, 'kind' | 'requirements'>;
|
|
763
|
+
}
|
|
764
|
+
export interface AskAnalystStateV1 {
|
|
765
|
+
version: 1;
|
|
766
|
+
mode: AskAnalystRuntimeModeV1;
|
|
767
|
+
phase: 'framed' | 'evidence_ready' | 'program_ready' | 'compiled' | 'executed' | 'clarify' | 'blocked';
|
|
768
|
+
frame: BusinessQuestionFrameV3;
|
|
769
|
+
mission: AnalyticalMissionV1;
|
|
770
|
+
workspace: EvidenceWorkspaceV1;
|
|
771
|
+
program: AnalyticalProgramV1;
|
|
772
|
+
resolvedPlan?: ResolvedAnalyticalPlanV2;
|
|
773
|
+
conversationDelta: AskAnalystConversationDeltaV1;
|
|
774
|
+
planningContinuations: number;
|
|
775
|
+
toolCalls: number;
|
|
776
|
+
executionAttempts: number;
|
|
777
|
+
repairAttempts: number;
|
|
778
|
+
}
|
|
779
|
+
/** A fact-bound answer envelope. Narrative can only summarize these receipts. */
|
|
780
|
+
export interface BusinessAnswerV1 {
|
|
781
|
+
version: 1;
|
|
782
|
+
mode: 'facts_only' | 'deterministic_fallback';
|
|
783
|
+
trustState: 'certified' | 'governed' | 'review_required' | 'blocked' | 'not_applicable';
|
|
784
|
+
factIds: string[];
|
|
785
|
+
resultFingerprint?: string;
|
|
786
|
+
/** The accepted answer text, already visible in the corresponding artifact. */
|
|
787
|
+
answer?: string;
|
|
788
|
+
limitations: string[];
|
|
789
|
+
/** Additive per-task aggregate; omitted by legacy/single-task records. */
|
|
790
|
+
taskOutcomeSummary?: AnalyticalTaskOutcomeSummaryV1;
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Content-free runtime projection for diagnostics/trace export. The durable
|
|
794
|
+
* local run retains typed continuation state; this projection intentionally
|
|
795
|
+
* omits raw question, requirement/member values, answer text, SQL, and rows.
|
|
796
|
+
*/
|
|
797
|
+
export interface AskAnalystDiagnosticStateV1 {
|
|
798
|
+
version: 1;
|
|
799
|
+
mode: AskAnalystRuntimeModeV1;
|
|
800
|
+
phase: AskAnalystStateV1['phase'];
|
|
801
|
+
questionFingerprint: string;
|
|
802
|
+
kind: AnalyticalTurnKind;
|
|
803
|
+
requirementCounts: {
|
|
804
|
+
measures: number;
|
|
805
|
+
dimensions: number;
|
|
806
|
+
entityTerms: number;
|
|
807
|
+
members: number;
|
|
808
|
+
filters: number;
|
|
809
|
+
};
|
|
810
|
+
mission: {
|
|
811
|
+
mode: AnalyticalMissionV1['mode'];
|
|
812
|
+
taskCount: number;
|
|
813
|
+
deferredTaskCount: number;
|
|
814
|
+
hypothesisCount: number;
|
|
815
|
+
};
|
|
816
|
+
workspace: {
|
|
817
|
+
snapshotId?: string;
|
|
818
|
+
sourceFingerprint?: string;
|
|
819
|
+
admittedCandidateCount: number;
|
|
820
|
+
excludedCandidateCount: number;
|
|
821
|
+
sourceCoverage: Array<{
|
|
822
|
+
source: ContextSourceCoverageV1['source'];
|
|
823
|
+
status: ContextSourceCoverageV1['status'];
|
|
824
|
+
candidateCount: number;
|
|
825
|
+
}>;
|
|
826
|
+
tools: Array<Pick<EvidenceWorkspaceToolReceiptV1, 'id' | 'kind' | 'status' | 'reasonCode'>>;
|
|
827
|
+
};
|
|
828
|
+
program: {
|
|
829
|
+
id: string;
|
|
830
|
+
taskCount: number;
|
|
831
|
+
candidateCount: number;
|
|
832
|
+
requiredRoles: EvidenceCandidateRoleV1[];
|
|
833
|
+
outputAssertionCount: number;
|
|
834
|
+
};
|
|
835
|
+
resolvedPlan?: ResolvedAnalyticalPlanV2;
|
|
836
|
+
counters: {
|
|
837
|
+
planningContinuations: number;
|
|
838
|
+
toolCalls: number;
|
|
839
|
+
executionAttempts: number;
|
|
840
|
+
repairAttempts: number;
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
export interface BusinessAnswerDiagnosticProjectionV1 {
|
|
844
|
+
version: 1;
|
|
845
|
+
mode: BusinessAnswerV1['mode'];
|
|
846
|
+
trustState: BusinessAnswerV1['trustState'];
|
|
847
|
+
factIds: string[];
|
|
848
|
+
resultFingerprint?: string;
|
|
849
|
+
limitationCount: number;
|
|
850
|
+
}
|
|
851
|
+
/** Compact default trace story; advanced spans remain in local observability. */
|
|
852
|
+
export interface AskDecisionSummaryV2 {
|
|
853
|
+
version: 2;
|
|
854
|
+
summaryFingerprint: string;
|
|
855
|
+
runtimeMode: AskAnalystRuntimeModeV1;
|
|
856
|
+
whatHappened: string;
|
|
857
|
+
why: string;
|
|
858
|
+
impact: string;
|
|
859
|
+
nextAction: AskTerminalIncidentV1['safeAction'] | 'none';
|
|
860
|
+
selectedCompiler?: ResolvedAnalyticalPlanV2['compiler'];
|
|
861
|
+
programTaskCount: number;
|
|
862
|
+
admittedCandidateCount: number;
|
|
863
|
+
toolCallCount: number;
|
|
864
|
+
executionAttempts: number;
|
|
865
|
+
}
|
|
866
|
+
/** Additive V5 receipt; V1-V4 remain readable JSON records. */
|
|
867
|
+
export interface AgentRunDiagnosticReceiptV5 {
|
|
868
|
+
version: 5;
|
|
869
|
+
runId: string;
|
|
870
|
+
state: AskAnalystDiagnosticStateV1;
|
|
871
|
+
summary: AskDecisionSummaryV2;
|
|
872
|
+
businessAnswer?: BusinessAnswerDiagnosticProjectionV1;
|
|
873
|
+
/** Typed terminal provider evidence from the physical provider boundary. */
|
|
874
|
+
provider?: ProviderFailureDiagnosticV1;
|
|
875
|
+
finalStopReason: string;
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Additive retrieval-first Ask contracts. V1 records remain the persisted
|
|
879
|
+
* compatibility shape; V2 is the authoritative runtime shape for new turns.
|
|
880
|
+
* The planner gets qualified cards only and cannot turn a raw retrieval term
|
|
881
|
+
* into an execution identity.
|
|
882
|
+
*/
|
|
883
|
+
export type AskPlanningModeV1 = 'exact_fast_path' | 'initial_planner' | 'targeted_revision' | 'deterministic_binding';
|
|
884
|
+
export interface AnalyticalPlannerCandidateCardV1 {
|
|
885
|
+
version: 1;
|
|
886
|
+
id: string;
|
|
887
|
+
qualifiedId?: string;
|
|
888
|
+
/** Compact retrieval label/aliases; never a raw definition dump or row data. */
|
|
889
|
+
label?: string;
|
|
890
|
+
aliases?: string[];
|
|
891
|
+
roles: EvidenceCandidateRoleV1[];
|
|
892
|
+
source: ContextSourceCoverageV1['source'];
|
|
893
|
+
trustTier: 'certified' | 'semantic' | 'governed' | 'exploratory';
|
|
894
|
+
exactMatch: boolean;
|
|
895
|
+
/**
|
|
896
|
+
* The card was retained so the planner can resolve one otherwise-unmet
|
|
897
|
+
* business role. This is admission context only: it is not a declared
|
|
898
|
+
* alias, selected meaning, or execution authorization. The verifier must
|
|
899
|
+
* still prove an exact declaration or one unique inferred substitution.
|
|
900
|
+
*/
|
|
901
|
+
admissionReasonCode?: 'candidate_for_unresolved_role';
|
|
902
|
+
unresolvedRoles?: EvidenceCandidateRoleV1[];
|
|
903
|
+
relationHints?: string[];
|
|
904
|
+
/** Present only for a host-authored relationship-path card; exploratory never implies governed authority. */
|
|
905
|
+
relationshipProofClass?: 'governed' | 'exploratory';
|
|
906
|
+
}
|
|
907
|
+
export interface AnalyticalPlannerRequestV1 {
|
|
908
|
+
version: 1;
|
|
909
|
+
planningMode: AskPlanningModeV1;
|
|
910
|
+
/** Raw business question is intentionally available only at the bounded planner boundary. */
|
|
911
|
+
question: string;
|
|
912
|
+
questionFingerprint: string;
|
|
913
|
+
/**
|
|
914
|
+
* Advisory frame for the planner. It is deliberately not an immutable
|
|
915
|
+
* execution tuple: parser-derived metric/entity/dimension guesses can be
|
|
916
|
+
* corrected only by selecting locally-qualified cards. Explicit user
|
|
917
|
+
* predicates, time, ranking and output constraints remain host verified.
|
|
918
|
+
*/
|
|
919
|
+
frame: Pick<BusinessQuestionFrameV4, 'kind' | 'requirements' | 'conversation' | 'planningMode'>;
|
|
920
|
+
/** Host-owned, content-safe hints; they are advisory and never execution authority. */
|
|
921
|
+
advisoryHints: string[];
|
|
922
|
+
sourceCoverage: Array<Pick<ContextSourceCoverageV1, 'source' | 'status'>>;
|
|
923
|
+
/**
|
|
924
|
+
* Bounded server-derived task options. They are not an execution plan: the
|
|
925
|
+
* planner may select one compatible option or two/three independent options,
|
|
926
|
+
* and the verifier later requires every selected ID to freeze and execute.
|
|
927
|
+
*/
|
|
928
|
+
taskOptions: Array<{
|
|
929
|
+
id: string;
|
|
930
|
+
kind: AnalyticalTaskV1['kind'];
|
|
931
|
+
question: string;
|
|
932
|
+
}>;
|
|
933
|
+
/**
|
|
934
|
+
* Present only for the one verifier-directed revision. Prior selected
|
|
935
|
+
* bindings are immutable context; only a card in `targetedCandidates` may
|
|
936
|
+
* fill the verifier-proven missing role.
|
|
937
|
+
*/
|
|
938
|
+
priorProposal?: Pick<AnalyticalPlannerProposalV1, 'version' | 'selectedConceptIds' | 'tasks'>;
|
|
939
|
+
priorSelectedConceptIds?: string[];
|
|
940
|
+
verificationFeedback?: ProgramVerificationFeedbackV1;
|
|
941
|
+
/** At most four verifier-admitted cards released for a targeted revision. */
|
|
942
|
+
targetedCandidates?: AnalyticalPlannerCandidateCardV1[];
|
|
943
|
+
candidates: AnalyticalPlannerCandidateCardV1[];
|
|
944
|
+
deadlineMs: number;
|
|
945
|
+
}
|
|
946
|
+
export type AnalyticalPlannerOperationV1 = 'aggregate' | 'rank' | 'group' | 'filter' | 'trend' | 'compare' | 'project';
|
|
947
|
+
export interface AnalyticalPlannerTaskProposalV1 {
|
|
948
|
+
version: 1;
|
|
949
|
+
taskId: string;
|
|
950
|
+
/**
|
|
951
|
+
* Server task options this one program deliberately covers. Omitted means
|
|
952
|
+
* only `taskId`. The verifier must prove complete coverage before a
|
|
953
|
+
* compatible multi-clause Ask may collapse to one execution.
|
|
954
|
+
*/
|
|
955
|
+
coveredTaskIds?: string[];
|
|
956
|
+
selectedConceptIds: string[];
|
|
957
|
+
/** Candidate-ID role bindings only; the verifier owns role compatibility. */
|
|
958
|
+
roleBindings: Partial<Record<EvidenceCandidateRoleV1, string[]>>;
|
|
959
|
+
/** Typed analytical intent, never SQL/DQL or a compiler authorization. */
|
|
960
|
+
operations: AnalyticalPlannerOperationV1[];
|
|
961
|
+
preferredCompiler?: 'certified' | 'metricflow' | 'governed_relational' | 'exploratory_sql';
|
|
962
|
+
assumptions?: string[];
|
|
963
|
+
}
|
|
964
|
+
export interface TargetedContextRequestV1 {
|
|
965
|
+
version: 1;
|
|
966
|
+
/** Exactly one verifier-proven role may be recovered per Ask turn. */
|
|
967
|
+
missingRoles: EvidenceCandidateRoleV1[];
|
|
968
|
+
/**
|
|
969
|
+
* Normalized business terms used to search the existing immutable 32-card
|
|
970
|
+
* workspace. The planner never receives or mints hidden workspace IDs.
|
|
971
|
+
*/
|
|
972
|
+
searchTerms?: string[];
|
|
973
|
+
/** Optional references to cards already in the supplied 16-card package. */
|
|
974
|
+
relatedCandidateIds?: string[];
|
|
975
|
+
/**
|
|
976
|
+
* Legacy compatibility carrier. New planner JSON must not use this to name
|
|
977
|
+
* an unadmitted card; the verifier rejects anything outside the planner
|
|
978
|
+
* package before it can be treated as a recovery hint.
|
|
979
|
+
*/
|
|
980
|
+
candidateIds?: string[];
|
|
981
|
+
/** Existing same-snapshot relationship paths, bounded to three. */
|
|
982
|
+
relationshipPathIds?: string[];
|
|
983
|
+
}
|
|
984
|
+
export interface TargetedContextResultV1 {
|
|
985
|
+
version: 1;
|
|
986
|
+
status: 'admitted' | 'unavailable' | 'denied';
|
|
987
|
+
candidateIds: string[];
|
|
988
|
+
relationshipPathIds: string[];
|
|
989
|
+
reasonCode: string;
|
|
990
|
+
}
|
|
991
|
+
export interface AnalyticalPlannerProposalV1 {
|
|
992
|
+
version: 1;
|
|
993
|
+
tasks: AnalyticalPlannerTaskProposalV1[];
|
|
994
|
+
selectedConceptIds: string[];
|
|
995
|
+
confidence?: 'high' | 'medium' | 'low';
|
|
996
|
+
missingInformation?: string[];
|
|
997
|
+
recovery?: TargetedContextRequestV1;
|
|
998
|
+
}
|
|
999
|
+
export interface ProgramVerificationFeedbackV1 {
|
|
1000
|
+
version: 1;
|
|
1001
|
+
status: 'valid' | 'needs_targeted_context' | 'ambiguous' | 'denied' | 'invalid';
|
|
1002
|
+
missingRoles: EvidenceCandidateRoleV1[];
|
|
1003
|
+
candidateIds: string[];
|
|
1004
|
+
reasonCode: string;
|
|
1005
|
+
}
|
|
1006
|
+
export interface EvidenceWorkspaceV2 extends Omit<EvidenceWorkspaceV1, 'version' | 'admittedCandidateIds'> {
|
|
1007
|
+
version: 2;
|
|
1008
|
+
/** The qualified immutable closure; never exceeds 32 candidates. */
|
|
1009
|
+
workspaceCandidateIds: string[];
|
|
1010
|
+
/** Cards released to the one planner call; never exceeds 16. */
|
|
1011
|
+
plannerCandidateIds: string[];
|
|
1012
|
+
/** V1 consumers read this as the planner admission. */
|
|
1013
|
+
admittedCandidateIds: string[];
|
|
1014
|
+
/**
|
|
1015
|
+
* Content-safe role admission counters. These are captured at the runtime
|
|
1016
|
+
* boundary, rather than reconstructed later from raw retrieval cards, so a
|
|
1017
|
+
* V7 trace can distinguish a missing requested role from a role-cap
|
|
1018
|
+
* exclusion after reload without retaining business labels or values.
|
|
1019
|
+
*/
|
|
1020
|
+
roleCoverage?: Array<{
|
|
1021
|
+
role: EvidenceCandidateRoleV1;
|
|
1022
|
+
candidateCount: number;
|
|
1023
|
+
state?: EvidenceRoleCoverageStateV1;
|
|
1024
|
+
}>;
|
|
1025
|
+
targetedContext?: TargetedContextResultV1;
|
|
1026
|
+
}
|
|
1027
|
+
export interface BusinessQuestionFrameV4 extends Omit<BusinessQuestionFrameV3, 'version'> {
|
|
1028
|
+
version: 4;
|
|
1029
|
+
planningMode: AskPlanningModeV1;
|
|
1030
|
+
}
|
|
1031
|
+
export interface AnalyticalProgramV2 extends Omit<AnalyticalProgramV1, 'version' | 'candidateIds' | 'executionCandidateIds'> {
|
|
1032
|
+
version: 2;
|
|
1033
|
+
/** Validated meaning cards selected by the planner. */
|
|
1034
|
+
candidateIds: string[];
|
|
1035
|
+
/** Full immutable qualified workspace consumed by compilers. */
|
|
1036
|
+
executionCandidateIds: string[];
|
|
1037
|
+
plannerCandidateIds: string[];
|
|
1038
|
+
workspaceCandidateIds: string[];
|
|
1039
|
+
/**
|
|
1040
|
+
* Provider-neutral business interpretation accepted by the deterministic
|
|
1041
|
+
* verifier. IDs remain canonicalized below; the planner never gains join,
|
|
1042
|
+
* grain, additivity, trust, or compiler authority.
|
|
1043
|
+
*/
|
|
1044
|
+
planner: {
|
|
1045
|
+
version: 1;
|
|
1046
|
+
tasks: Array<{
|
|
1047
|
+
taskId: string;
|
|
1048
|
+
coveredTaskIds?: string[];
|
|
1049
|
+
selectedConceptIds: string[];
|
|
1050
|
+
roleBindings: Partial<Record<EvidenceCandidateRoleV1, string[]>>;
|
|
1051
|
+
operations: AnalyticalPlannerOperationV1[];
|
|
1052
|
+
preferredCompiler?: AnalyticalPlannerTaskProposalV1['preferredCompiler'];
|
|
1053
|
+
assumptions: string[];
|
|
1054
|
+
}>;
|
|
1055
|
+
confidence?: AnalyticalPlannerProposalV1['confidence'];
|
|
1056
|
+
missingInformation: string[];
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* Planner V2 is the post-verification business interpretation. The provider
|
|
1061
|
+
* V1 wire format remains readable during rollout, but a frozen program does
|
|
1062
|
+
* not preserve a provider-selected relationship/join binding: relationship
|
|
1063
|
+
* closure is compiler-owned evidence, not business meaning.
|
|
1064
|
+
*/
|
|
1065
|
+
export type AnalyticalPlannerBusinessRoleV2 = Exclude<EvidenceCandidateRoleV1, 'relationship'>;
|
|
1066
|
+
export interface AnalyticalPlannerTaskV2 {
|
|
1067
|
+
taskId: string;
|
|
1068
|
+
coveredTaskIds?: string[];
|
|
1069
|
+
selectedConceptIds: string[];
|
|
1070
|
+
roleBindings: Partial<Record<AnalyticalPlannerBusinessRoleV2, string[]>>;
|
|
1071
|
+
operations: AnalyticalPlannerOperationV1[];
|
|
1072
|
+
preferredCompiler?: AnalyticalPlannerTaskProposalV1['preferredCompiler'];
|
|
1073
|
+
assumptions: string[];
|
|
1074
|
+
}
|
|
1075
|
+
export interface AnalyticalPlannerInterpretationV2 {
|
|
1076
|
+
version: 2;
|
|
1077
|
+
/** The source is diagnostic only; it cannot change authority after verify. */
|
|
1078
|
+
source: 'provider' | 'deterministic' | 'legacy_adapter';
|
|
1079
|
+
tasks: AnalyticalPlannerTaskV2[];
|
|
1080
|
+
confidence?: AnalyticalPlannerProposalV1['confidence'];
|
|
1081
|
+
missingInformation: string[];
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* One host-derived safe relationship closure. `candidateId` refers to the
|
|
1085
|
+
* compact same-snapshot path card; `relationshipEvidence` contains only its
|
|
1086
|
+
* canonical proof IDs. A planner never selects either value.
|
|
1087
|
+
*/
|
|
1088
|
+
export interface CanonicalRelationshipPathReceiptV1 {
|
|
1089
|
+
version: 1;
|
|
1090
|
+
candidateId: string;
|
|
1091
|
+
proofClass: 'governed' | 'exploratory';
|
|
1092
|
+
relationshipEvidence: string[];
|
|
1093
|
+
}
|
|
1094
|
+
/**
|
|
1095
|
+
* Lossless typed inputs that survive planner/legacy adapter conversions. The
|
|
1096
|
+
* words remain local program data; diagnostic projections expose counts only.
|
|
1097
|
+
*/
|
|
1098
|
+
export interface AnalyticalInputAtomV1 {
|
|
1099
|
+
version: 1;
|
|
1100
|
+
source: 'current_question' | 'trusted_successful_task';
|
|
1101
|
+
role: Exclude<EvidenceCandidateRoleV1, 'relationship' | 'context'> | 'filter';
|
|
1102
|
+
term: string;
|
|
1103
|
+
required: true;
|
|
1104
|
+
}
|
|
1105
|
+
/** A host-validated anchor from a successful prior task/result. */
|
|
1106
|
+
export interface TrustedAnalyticalTaskAnchorV1 {
|
|
1107
|
+
version: 1;
|
|
1108
|
+
/**
|
|
1109
|
+
* `member_binding` retains a validated selected result value.
|
|
1110
|
+
* `analytical_shape` retains only a successful task's metric/projection
|
|
1111
|
+
* shape for an explicit additive follow-up such as "add region here".
|
|
1112
|
+
* Neither form is provider supplied.
|
|
1113
|
+
*/
|
|
1114
|
+
kind?: 'member_binding' | 'analytical_shape';
|
|
1115
|
+
displayDimension?: string;
|
|
1116
|
+
values: string[];
|
|
1117
|
+
/** Existing successful-task shape; no rows or free-form prior answer. */
|
|
1118
|
+
measures?: string[];
|
|
1119
|
+
dimensions?: string[];
|
|
1120
|
+
sourceTurnId?: string;
|
|
1121
|
+
resultFingerprint?: string;
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* The authoritative frozen Ask contract. V1/V2 remain valid persisted JSON
|
|
1125
|
+
* readers; all new authoritative turns construct V3 before compiler entry.
|
|
1126
|
+
*/
|
|
1127
|
+
export interface AnalyticalProgramV3 extends Omit<AnalyticalProgramV2, 'version' | 'planner'> {
|
|
1128
|
+
version: 3;
|
|
1129
|
+
planner: AnalyticalPlannerInterpretationV2;
|
|
1130
|
+
/** Compiler-owned path receipts; never provider-selected join instructions. */
|
|
1131
|
+
relationshipPaths: CanonicalRelationshipPathReceiptV1[];
|
|
1132
|
+
/** Current-turn atoms cannot be erased by a compatibility MeaningResolution. */
|
|
1133
|
+
inputAtoms: AnalyticalInputAtomV1[];
|
|
1134
|
+
/** Validated prior-result anchors are distinct from free-text member guesses. */
|
|
1135
|
+
trustedTaskAnchors: TrustedAnalyticalTaskAnchorV1[];
|
|
1136
|
+
}
|
|
1137
|
+
export interface AskAnalystConversationDeltaV2 extends Omit<AskAnalystConversationDeltaV1, 'version' | 'partialFrame'> {
|
|
1138
|
+
version: 2;
|
|
1139
|
+
partialFrame: Pick<BusinessQuestionFrameV4, 'kind' | 'requirements' | 'planningMode'>;
|
|
1140
|
+
programId?: string;
|
|
1141
|
+
}
|
|
1142
|
+
export interface AskAnalystStateV2 extends Omit<AskAnalystStateV1, 'version' | 'frame' | 'workspace' | 'program' | 'conversationDelta'> {
|
|
1143
|
+
version: 2;
|
|
1144
|
+
frame: BusinessQuestionFrameV4;
|
|
1145
|
+
workspace: EvidenceWorkspaceV2;
|
|
1146
|
+
program: AnalyticalProgramV2;
|
|
1147
|
+
conversationDelta: AskAnalystConversationDeltaV2;
|
|
1148
|
+
planningMode: AskPlanningModeV1;
|
|
1149
|
+
plannerRevisionCount: number;
|
|
1150
|
+
planningReceipt?: AskAnalystPlanningReceiptV1;
|
|
1151
|
+
}
|
|
1152
|
+
/** New authoritative state; V2 remains readable for interrupted old runs. */
|
|
1153
|
+
export interface AskAnalystStateV3 extends Omit<AskAnalystStateV2, 'version' | 'program'> {
|
|
1154
|
+
version: 3;
|
|
1155
|
+
program: AnalyticalProgramV3;
|
|
1156
|
+
}
|
|
1157
|
+
export interface AskAnalystPlanningReceiptV1 {
|
|
1158
|
+
version: 1;
|
|
1159
|
+
mode: AskPlanningModeV1;
|
|
1160
|
+
plannerCalls: number;
|
|
1161
|
+
revisionCalls: number;
|
|
1162
|
+
verification: ProgramVerificationFeedbackV1;
|
|
1163
|
+
}
|
|
1164
|
+
export interface BusinessAnswerV2 extends Omit<BusinessAnswerV1, 'version'> {
|
|
1165
|
+
version: 2;
|
|
1166
|
+
/** Facts and result fingerprint are the only authoritative narrative source. */
|
|
1167
|
+
factBinding: 'validated_result_facts' | 'deterministic_fallback';
|
|
1168
|
+
}
|
|
1169
|
+
export interface AgentRunDiagnosticReceiptV6 extends Omit<AgentRunDiagnosticReceiptV5, 'version'> {
|
|
1170
|
+
version: 6;
|
|
1171
|
+
planning?: AskAnalystPlanningReceiptV1;
|
|
1172
|
+
/** Role coverage is count-only: raw terms and candidate labels stay Advanced-only. */
|
|
1173
|
+
roleCoverage: Array<{
|
|
1174
|
+
role: EvidenceCandidateRoleV1;
|
|
1175
|
+
candidateCount: number;
|
|
1176
|
+
/** `alternatives` is a clarification state, not a proof of business meaning. */
|
|
1177
|
+
state?: EvidenceRoleCoverageStateV1;
|
|
1178
|
+
}>;
|
|
1179
|
+
/** The exact pre-execution cascade record behind the selected compiler. */
|
|
1180
|
+
cascade: {
|
|
1181
|
+
attempts: Array<Pick<CascadeTierAttemptV1, 'tier' | 'outcome' | 'planFrozen'>>;
|
|
1182
|
+
selectedTier?: AnalyticalCascadeDecisionV1['selectedTier'];
|
|
1183
|
+
stopReason?: string;
|
|
1184
|
+
planFrozen: boolean;
|
|
1185
|
+
};
|
|
1186
|
+
/** Present only for a typed terminal incident; never inferred from prose. */
|
|
1187
|
+
origin?: Pick<AskTerminalIncidentV1, 'boundary' | 'origin' | 'impact'>;
|
|
1188
|
+
connection: {
|
|
1189
|
+
attempted: boolean;
|
|
1190
|
+
};
|
|
1191
|
+
execution: {
|
|
1192
|
+
attempts: number;
|
|
1193
|
+
};
|
|
1194
|
+
/**
|
|
1195
|
+
* Content-safe physical counters. Research roots aggregate server-owned
|
|
1196
|
+
* child execution counters (with durable receipt fallback for older child
|
|
1197
|
+
* records); the root dispatch ledger remains the authority for provider
|
|
1198
|
+
* egress so child spans are never double-counted.
|
|
1199
|
+
*/
|
|
1200
|
+
telemetry?: AgentRunTelemetryV1;
|
|
1201
|
+
facts: {
|
|
1202
|
+
factCount: number;
|
|
1203
|
+
resultFingerprint?: string;
|
|
1204
|
+
};
|
|
1205
|
+
safeNextAction: AskDecisionSummaryV2['nextAction'];
|
|
1206
|
+
/** Compact default story; raw spans and candidate lifecycle remain Advanced-only. */
|
|
1207
|
+
story: Array<{
|
|
1208
|
+
stage: 'retrieval' | 'role_coverage' | 'planner' | 'verification' | 'targeted_recovery' | 'cascade' | 'freeze' | 'connection' | 'execution' | 'facts';
|
|
1209
|
+
status: 'completed' | 'skipped' | 'blocked' | 'unavailable';
|
|
1210
|
+
reasonCode: string;
|
|
1211
|
+
}>;
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* Additive V7 reader receipt. V6 remains the detailed, content-free trace
|
|
1215
|
+
* record; V7 projects it into the few decisions an analyst needs first:
|
|
1216
|
+
* whether the question was understood, whether evidence was sufficient, what
|
|
1217
|
+
* the planner/cascade decided, and whether a result was actually narrated.
|
|
1218
|
+
* It deliberately carries counts and enum outcomes only—never prompt text,
|
|
1219
|
+
* SQL, result rows, provider payloads, candidate labels, or member values.
|
|
1220
|
+
*/
|
|
1221
|
+
export interface AgentRunDiagnosticReceiptV7 extends Omit<AgentRunDiagnosticReceiptV6, 'version'> {
|
|
1222
|
+
version: 7;
|
|
1223
|
+
inspector: {
|
|
1224
|
+
understood: {
|
|
1225
|
+
questionKind: BusinessQuestionFrameV4['kind'];
|
|
1226
|
+
conversationBinding: BusinessQuestionFrameV4['conversation']['binding'];
|
|
1227
|
+
measureCount: number;
|
|
1228
|
+
dimensionCount: number;
|
|
1229
|
+
entityRequested: boolean;
|
|
1230
|
+
hasBoundFilter: boolean;
|
|
1231
|
+
};
|
|
1232
|
+
evidence: {
|
|
1233
|
+
admittedCandidateCount: number;
|
|
1234
|
+
roleCount: number;
|
|
1235
|
+
recoveryAttempted: boolean;
|
|
1236
|
+
};
|
|
1237
|
+
planning: {
|
|
1238
|
+
mode: AskPlanningModeV1;
|
|
1239
|
+
plannerCalls: number;
|
|
1240
|
+
verification: ProgramVerificationFeedbackV1['status'];
|
|
1241
|
+
};
|
|
1242
|
+
route: {
|
|
1243
|
+
selectedTier?: AnalyticalCascadeDecisionV1['selectedTier'];
|
|
1244
|
+
tierAttemptCount: number;
|
|
1245
|
+
planFrozen: boolean;
|
|
1246
|
+
reviewRequired: boolean;
|
|
1247
|
+
};
|
|
1248
|
+
outcome: {
|
|
1249
|
+
connectionAttempted: boolean;
|
|
1250
|
+
executionAttempts: number;
|
|
1251
|
+
factCount: number;
|
|
1252
|
+
narration: 'fact_bound' | 'result_without_facts' | 'not_applicable';
|
|
1253
|
+
};
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
/** New runtime values are V2; V1 values remain readable from old JSON runs. */
|
|
1257
|
+
export type AskAnalystState = AskAnalystStateV1 | AskAnalystStateV2 | AskAnalystStateV3;
|
|
1258
|
+
export type AnalyticalProgram = AnalyticalProgramV1 | AnalyticalProgramV2 | AnalyticalProgramV3;
|
|
1259
|
+
export type BusinessQuestionFrame = BusinessQuestionFrameV3 | BusinessQuestionFrameV4;
|
|
1260
|
+
export type BusinessAnswer = BusinessAnswerV1 | BusinessAnswerV2;
|
|
473
1261
|
export interface AnalyticalTurnPlanV1 {
|
|
474
1262
|
version: 1;
|
|
475
1263
|
turnId?: string;
|
|
@@ -521,9 +1309,20 @@ export type RoleBalancedEvidenceCandidate = {
|
|
|
521
1309
|
semanticObjectType?: string;
|
|
522
1310
|
name?: string;
|
|
523
1311
|
aliases?: string[];
|
|
1312
|
+
/** Source-authored semantic or physical value type when the snapshot has it. */
|
|
1313
|
+
dataType?: string;
|
|
524
1314
|
dimensions?: string[];
|
|
525
1315
|
timeGrains?: string[];
|
|
526
1316
|
relationshipEvidence?: string[];
|
|
1317
|
+
/**
|
|
1318
|
+
* Host-only runtime-value proof attached to one qualified physical column.
|
|
1319
|
+
* It is intentionally structural here so the retrieval selector can reserve
|
|
1320
|
+
* the field for a current literal without exposing values to a provider.
|
|
1321
|
+
*/
|
|
1322
|
+
safeValueEvidence?: Array<{
|
|
1323
|
+
normalizedValue?: string;
|
|
1324
|
+
value?: string;
|
|
1325
|
+
}>;
|
|
527
1326
|
relevanceScore?: number;
|
|
528
1327
|
exactMatch?: boolean;
|
|
529
1328
|
compatibility?: string;
|
|
@@ -591,10 +1390,13 @@ export declare function categoricalDimensionTermsMatch(left: string, right: stri
|
|
|
591
1390
|
* or "for each customer" as separate physical measures. The grouping entity
|
|
592
1391
|
* is represented by the dimension/entity roles instead.
|
|
593
1392
|
*
|
|
594
|
-
* `order count for each customer` is the common prose form for
|
|
595
|
-
*
|
|
596
|
-
*
|
|
597
|
-
* metric
|
|
1393
|
+
* `order count for each customer` is the common prose form for the authored
|
|
1394
|
+
* `order_count` semantic measure at customer grain. Keep that compound
|
|
1395
|
+
* identity intact: reducing it to the generic aggregation `count` makes the
|
|
1396
|
+
* unfiltered `Orders` MetricFlow metric indistinguishable from scoped metrics
|
|
1397
|
+
* such as `Drink Orders` and `Food Orders`. The grouping entity is still
|
|
1398
|
+
* represented by the dimension/entity roles rather than becoming another
|
|
1399
|
+
* measure.
|
|
598
1400
|
*/
|
|
599
1401
|
export declare function normalizeAnalyticalMeasureTerms(question: string, values: readonly string[], options?: {
|
|
600
1402
|
preserveIdentity?: boolean;
|
|
@@ -655,6 +1457,16 @@ export declare function selectRoleBalancedMeaningCandidates<T extends RoleBalanc
|
|
|
655
1457
|
/** Use before any kind cap to reserve exact/required-role cards. */
|
|
656
1458
|
pinOnly?: boolean;
|
|
657
1459
|
}): T[];
|
|
1460
|
+
/**
|
|
1461
|
+
* Build the Ask execution workspace before planner admission. It is the
|
|
1462
|
+
* only helper that may create the 32-card closure; all later compiler paths
|
|
1463
|
+
* must intersect with this immutable result rather than reaching back into a
|
|
1464
|
+
* broad snapshot.
|
|
1465
|
+
*/
|
|
1466
|
+
export declare function selectRoleBalancedWorkspaceCandidates<T extends RoleBalancedEvidenceCandidate>(input: {
|
|
1467
|
+
candidates: T[];
|
|
1468
|
+
requirements: AnalyticalRequirementSetV1;
|
|
1469
|
+
}): T[];
|
|
658
1470
|
export declare function classifyProviderFailure(input: {
|
|
659
1471
|
message?: string;
|
|
660
1472
|
code?: string;
|
|
@@ -888,6 +1700,133 @@ export interface ResearchEvidenceLedgerV2 {
|
|
|
888
1700
|
limitedScope: boolean;
|
|
889
1701
|
stoppingReason: ResearchEvidenceLedgerV1['stoppingReason'];
|
|
890
1702
|
}
|
|
1703
|
+
/**
|
|
1704
|
+
* A local structural lineage observation is not a query result. This receipt
|
|
1705
|
+
* deliberately carries only bounded counts, opaque fingerprints, and
|
|
1706
|
+
* allowlisted status values: it must never become a place where prompts, SQL,
|
|
1707
|
+
* rows, graph labels, paths, or provider output are persisted.
|
|
1708
|
+
*/
|
|
1709
|
+
export type ResearchLineageEvidenceStatusV1 = 'completed' | 'missing' | 'ambiguous' | 'stale' | 'truncated' | 'unavailable';
|
|
1710
|
+
export type ResearchLineageResolutionV1 = 'exact_id' | 'exact_name' | 'canonical_alias' | 'missing' | 'ambiguous' | 'stale' | 'unavailable';
|
|
1711
|
+
export type ResearchLineageNodeTypeV1 = 'source_table' | 'dbt_model' | 'dbt_source' | 'term' | 'block' | 'business_view' | 'metric' | 'dimension' | 'domain' | 'chart' | 'notebook' | 'dashboard' | 'app';
|
|
1712
|
+
export interface ResearchLineageEvidenceReceiptV1 {
|
|
1713
|
+
version: 1;
|
|
1714
|
+
evidenceKind: 'lineage_graph';
|
|
1715
|
+
/** Opaque local identity only; no source path or graph content is retained. */
|
|
1716
|
+
snapshotId?: string;
|
|
1717
|
+
snapshotFingerprint?: string;
|
|
1718
|
+
graphFingerprint: string;
|
|
1719
|
+
targetFingerprint: string;
|
|
1720
|
+
status: ResearchLineageEvidenceStatusV1;
|
|
1721
|
+
resolution: ResearchLineageResolutionV1;
|
|
1722
|
+
candidateCount: number;
|
|
1723
|
+
targetType?: ResearchLineageNodeTypeV1;
|
|
1724
|
+
upstreamNodeCount: number;
|
|
1725
|
+
downstreamNodeCount: number;
|
|
1726
|
+
upstreamPathCount: number;
|
|
1727
|
+
downstreamPathCount: number;
|
|
1728
|
+
traversedNodeCount: number;
|
|
1729
|
+
traversedEdgeCount: number;
|
|
1730
|
+
maxDepth: number;
|
|
1731
|
+
maxPaths: number;
|
|
1732
|
+
maxNodes: number;
|
|
1733
|
+
maxEdges: number;
|
|
1734
|
+
truncated: boolean;
|
|
1735
|
+
/** One-way digest of the bounded structural program, never a result digest. */
|
|
1736
|
+
structuralFingerprint?: string;
|
|
1737
|
+
validator: {
|
|
1738
|
+
version: 1;
|
|
1739
|
+
kind: 'structural_dependency';
|
|
1740
|
+
evaluated: boolean;
|
|
1741
|
+
outcome: 'dependency_observed' | 'inconclusive';
|
|
1742
|
+
/** A lineage edge is structural evidence only, never a causal conclusion. */
|
|
1743
|
+
nonCausal: true;
|
|
1744
|
+
};
|
|
1745
|
+
/** This program must not dispatch AI, SQL, warehouse, or repair work. */
|
|
1746
|
+
zeroCallCounters: {
|
|
1747
|
+
providerCalls: 0;
|
|
1748
|
+
sqlExecutions: 0;
|
|
1749
|
+
warehouseExecutions: 0;
|
|
1750
|
+
repairAttempts: 0;
|
|
1751
|
+
};
|
|
1752
|
+
}
|
|
1753
|
+
export type ResearchEvidenceKindV3 = 'analytical_result' | 'lineage_graph';
|
|
1754
|
+
/**
|
|
1755
|
+
* V3 is additive and content-safe. V1/V2 remain available to old readers,
|
|
1756
|
+
* while V3 distinguishes a receipt-bound analytical result from a bounded
|
|
1757
|
+
* structural lineage observation. In particular, the lineage variant has no
|
|
1758
|
+
* result fingerprint, execution receipt, row count, SQL, or provider payload.
|
|
1759
|
+
*/
|
|
1760
|
+
export interface ResearchEvidenceLedgerAnalyticalEntryV3 {
|
|
1761
|
+
version: 3;
|
|
1762
|
+
id: string;
|
|
1763
|
+
branchId: string;
|
|
1764
|
+
evidenceKind: 'analytical_result';
|
|
1765
|
+
status: ResearchLedgerEntryV1['status'];
|
|
1766
|
+
verdict: ResearchEvidenceVerdictV2;
|
|
1767
|
+
hypothesisFingerprint?: string;
|
|
1768
|
+
factIds: string[];
|
|
1769
|
+
counterEvidenceFactIds: string[];
|
|
1770
|
+
receiptFingerprints: string[];
|
|
1771
|
+
resultFingerprint?: string;
|
|
1772
|
+
}
|
|
1773
|
+
export interface ResearchEvidenceLedgerLineageEntryV3 {
|
|
1774
|
+
version: 3;
|
|
1775
|
+
id: string;
|
|
1776
|
+
branchId: string;
|
|
1777
|
+
evidenceKind: 'lineage_graph';
|
|
1778
|
+
/** The structural program completed even when a target is missing/stale. */
|
|
1779
|
+
status: 'observed' | 'failed' | 'skipped';
|
|
1780
|
+
verdict: ResearchEvidenceVerdictV2;
|
|
1781
|
+
hypothesisFingerprint?: string;
|
|
1782
|
+
factIds: string[];
|
|
1783
|
+
counterEvidenceFactIds: string[];
|
|
1784
|
+
receiptFingerprints: string[];
|
|
1785
|
+
lineageReceipt: ResearchLineageEvidenceReceiptV1;
|
|
1786
|
+
}
|
|
1787
|
+
export type ResearchEvidenceLedgerEntryV3 = ResearchEvidenceLedgerAnalyticalEntryV3 | ResearchEvidenceLedgerLineageEntryV3;
|
|
1788
|
+
export interface ResearchEvidenceLedgerV3 {
|
|
1789
|
+
version: 3;
|
|
1790
|
+
/** One-way root-question identity; V3 does not retain research prose. */
|
|
1791
|
+
rootQuestionFingerprint: string;
|
|
1792
|
+
planId?: string;
|
|
1793
|
+
snapshotId?: string;
|
|
1794
|
+
entries: ResearchEvidenceLedgerEntryV3[];
|
|
1795
|
+
factIds: string[];
|
|
1796
|
+
groundableBranchCount: number;
|
|
1797
|
+
limitedScope: boolean;
|
|
1798
|
+
stoppingReason: ResearchEvidenceLedgerV1['stoppingReason'];
|
|
1799
|
+
}
|
|
1800
|
+
export interface ResearchEvidenceLedgerAnalyticalInputV3 {
|
|
1801
|
+
kind: 'analytical_result';
|
|
1802
|
+
index: number;
|
|
1803
|
+
entry: ResearchEvidenceLedgerEntryV2;
|
|
1804
|
+
hypothesisFingerprint?: string;
|
|
1805
|
+
}
|
|
1806
|
+
export interface ResearchEvidenceLedgerLineageInputV3 {
|
|
1807
|
+
kind: 'lineage_graph';
|
|
1808
|
+
index: number;
|
|
1809
|
+
id: string;
|
|
1810
|
+
branchId: string;
|
|
1811
|
+
receipt: ResearchLineageEvidenceReceiptV1;
|
|
1812
|
+
hypothesisFingerprint?: string;
|
|
1813
|
+
/** Omitted means the direct structural program completed normally. */
|
|
1814
|
+
status?: 'observed' | 'failed' | 'skipped';
|
|
1815
|
+
}
|
|
1816
|
+
/**
|
|
1817
|
+
* Build a mixed V3 ledger without reinterpreting V1/V2. The legacy ledgers
|
|
1818
|
+
* continue to contain analytical branches only, because their `observed`
|
|
1819
|
+
* state requires an execution/result receipt and would otherwise falsely
|
|
1820
|
+
* represent a graph walk as query execution.
|
|
1821
|
+
*/
|
|
1822
|
+
export declare function buildResearchEvidenceLedgerV3(input: {
|
|
1823
|
+
rootQuestionFingerprint: string;
|
|
1824
|
+
planId?: string;
|
|
1825
|
+
snapshotId?: string;
|
|
1826
|
+
groundableBranchCount?: number;
|
|
1827
|
+
entries: Array<ResearchEvidenceLedgerAnalyticalInputV3 | ResearchEvidenceLedgerLineageInputV3>;
|
|
1828
|
+
stoppingReason?: ResearchEvidenceLedgerV1['stoppingReason'];
|
|
1829
|
+
}): ResearchEvidenceLedgerV3;
|
|
891
1830
|
export declare function capResearchBranches<T>(branches: T[], max?: number): T[];
|
|
892
1831
|
export declare function buildResearchEvidenceLedger(input: {
|
|
893
1832
|
rootQuestion: string;
|