@duckcodeailabs/dql-cli 1.14.5 → 1.14.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"dql-agent-provider.d.ts","sourceRoot":"","sources":["../../../src/llm/providers/dql-agent-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,2BAA2B,EACjC,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAoBL,KAAK,WAAW,EAEhB,KAAK,wBAAwB,EAE7B,KAAK,oBAAoB,EAIzB,KAAK,aAAa,EAGlB,KAAK,oBAAoB,EAEzB,KAAK,gBAAgB,EAoCrB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EAIpB,KAAK,6BAA6B,EAIlC,KAAK,+BAA+B,EACpC,KAAK,sBAAsB,EAE3B,KAAK,eAAe,EAErB,MAAM,2BAA2B,CAAC;AAkBnC,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAA4B,UAAU,EAAE,MAAM,aAAa,CAAC;AACtG,OAAO,EAAE,oBAAoB,EAAkC,MAAM,yBAAyB,CAAC;AAQ/F;;;;GAIG;AACH,KAAK,gBAAgB,GACjB,OAAO,CAAC,UAAU,EAAE,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,eAAe,CAAC,GACnF,aAAa,GACb,OAAO,CAAC;AAoFZ;;;;GAIG;AACH,iBAAS,0BAA0B,CAAC,KAAK,EAAE;IACzC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,2BAA2B,CAAC,OAAO,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,2BAA2B,CA0B9B;AA2cD,KAAK,wBAAwB,GAAG,QAAQ,GAAG,WAAW,GAAG,gBAAgB,GAAG,kBAAkB,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CESSION. The progression rule exists to stop a
1452
+ // model from finishing without trying the executable tiers — but a
1453
+ // model that has inspected them and TWICE chosen to finish rather
1454
+ // than write exploratory SQL it cannot ground has made an honest
1455
+ // judgment (observed live: certified empty + semantic unavailable
1456
+ // on a 3,373-model repo; sonnet declined to invent Snowflake SQL
1457
+ // and the kernel burned the whole dispatch budget re-denying).
1458
+ // Concede on the SECOND identical denial: close the turn as a
1459
+ // typed gap. No SQL runs, no prose is trusted; the reader gets an
1460
+ // honest refusal in 3 dispatches instead of a timeout in 6.
1461
+ if (name === 'finish_answer'
1462
+ && allowed.reasonCode === 'ASK_V2_TOOL_PROGRESSION_REQUIRED'
1463
+ && !completed
1464
+ && state.observations.some((observation) => observation.tool === 'finish_answer'
1465
+ && observation.reasonCode === 'ASK_V2_TOOL_PROGRESSION_REQUIRED')) {
1466
+ observe('finish_answer', 'ineligible', 'ASK_V2_REMAINING_TIERS_DECLINED', {
1467
+ origin: 'agent_control',
1468
+ ...(allowed.safeNextTools?.length ? { safeAction: `use:${allowed.safeNextTools.join(',')}` } : {}),
1469
+ });
1470
+ finishAskAgentV2Turn(state, {
1471
+ version: 2,
1472
+ kind: 'gap',
1473
+ reasonCode: 'ASK_V2_REMAINING_TIERS_DECLINED',
1474
+ origin: 'agent_control',
1475
+ });
1476
+ return { finished: true, conceded: true, reasonCode: 'ASK_V2_REMAINING_TIERS_DECLINED' };
1477
+ }
1451
1478
  const clarificationPreFreeze = name === 'request_clarification'
1452
1479
  && (allowed.reasonCode === 'ASK_V2_CLARIFICATION_NOT_MATERIALLY_AMBIGUOUS'
1453
1480
  || allowed.reasonCode === 'ASK_V2_TOOL_PROGRESSION_REQUIRED');
@@ -2705,7 +2732,22 @@ function createAskV2LaneHandler(state, limits) {
2705
2732
  ? 'GOVERNED_RELATIONAL_IDENTIFIER_OR_PATH_NOT_ADMITTED'
2706
2733
  : 'GOVERNED_RELATIONAL_EXECUTION_UNAVAILABLE';
2707
2734
  observe('compile_and_run_dql', 'ineligible', reason, { tier: 'governed_relational', candidateIds: selectedCandidateIds, origin: 'validation' });
2708
- return denied('compile_and_run_dql', reason);
2735
+ // A bare "not admitted" is unactionable — the model guessed wrong
2736
+ // IDs once and will guess again until the budget dies. Name the
2737
+ // admitted relational identifiers and path handles verbatim, the
2738
+ // same teaching contract the semantic tier's refusals carry.
2739
+ const admittedRelational = visibleCandidates()
2740
+ .filter(relationLike)
2741
+ .slice(0, 16)
2742
+ .map((candidate) => v2CandidateId(candidate));
2743
+ return {
2744
+ ...denied('compile_and_run_dql', reason),
2745
+ ...(reason === 'GOVERNED_RELATIONAL_IDENTIFIER_OR_PATH_NOT_ADMITTED' ? {
2746
+ admittedRelationalIds: admittedRelational,
2747
+ admittedRelationshipPathIds: state.relationshipPathHandles.slice(0, 8).map((path) => path.id),
2748
+ usage: 'Re-send compile_and_run_dql using measureIds/dimensionIds/expectedOutputIds from admittedRelationalIds verbatim and relationshipPathIds from admittedRelationshipPathIds. Invented identifiers are never admitted.',
2749
+ } : {}),
2750
+ };
2709
2751
  }
2710
2752
  // The local host mints a V2-only authorization before compiling the
2711
2753
  // DQL program. This is the frozen boundary: the compiler and
@@ -2819,7 +2861,22 @@ function createAskV2LaneHandler(state, limits) {
2819
2861
  if (!outputs || !validation.ok || (!v2Prepare && !legacyPrepare) || !input.executeAgenticGeneratedSql) {
2820
2862
  const reason = !outputs ? 'EXPLORATORY_OUTPUT_IDENTIFIER_NOT_ADMITTED' : validation.ok ? 'EXPLORATORY_EXECUTION_CAPABILITY_UNAVAILABLE' : 'EXPLORATORY_SQL_VALIDATION_FAILED';
2821
2863
  observe('validate_and_run_sql', 'ineligible', reason, { tier: 'exploratory_sql', candidateIds: outputIds, origin: 'validation' });
2822
- return denied('validate_and_run_sql', reason);
2864
+ // Same teaching contract as the semantic/relational refusals: a
2865
+ // model told only "not admitted" guesses identifiers until the
2866
+ // budget dies. Name the admitted output IDs verbatim.
2867
+ const admittedOutputs = reason === 'EXPLORATORY_OUTPUT_IDENTIFIER_NOT_ADMITTED'
2868
+ ? visibleCandidates().slice(0, 24).map((candidate) => v2CandidateId(candidate))
2869
+ : [];
2870
+ return {
2871
+ ...denied('validate_and_run_sql', reason),
2872
+ ...(admittedOutputs.length ? {
2873
+ admittedOutputIds: admittedOutputs,
2874
+ usage: 'Re-send validate_and_run_sql with expectedOutputIds drawn from admittedOutputIds verbatim; each must name a card your SQL actually selects.',
2875
+ } : {}),
2876
+ ...(reason === 'EXPLORATORY_SQL_VALIDATION_FAILED' && !validation.ok && 'reason' in validation && validation.reason ? {
2877
+ usage: String(validation.reason).slice(0, 400),
2878
+ } : {}),
2879
+ };
2823
2880
  }
2824
2881
  try {
2825
2882
  const selectedCandidateIds = [...new Set(outputIds)];
@@ -2999,7 +3056,7 @@ function createAskV2LaneHandler(state, limits) {
2999
3056
  // simply that the user asked for a field this project has never modeled.
3000
3057
  // "Not enough context" for an unmodeled term reads as a system failure;
3001
3058
  // the truthful answer names the term and the governed alternatives.
3002
- const requestedUnmodeledTerm = () => {
3059
+ const requestedUnmodeledTerm = async () => {
3003
3060
  const plan = buildAnalysisQuestionPlan(input.question);
3004
3061
  const requirements = buildAnalyticalRequirementSet({ question: input.question });
3005
3062
  // A "dimension term" can actually be a member VALUE ("beverage
@@ -3051,10 +3108,31 @@ function createAskV2LaneHandler(state, limits) {
3051
3108
  });
3052
3109
  if (unresolved.length === 0)
3053
3110
  return undefined;
3111
+ // Retention is a ranking, not the model: a term absent from the 80
3112
+ // retained cards can still be modeled a thousand times over in a large
3113
+ // catalog. Only the HOST's whole-catalog lookup may authorize a
3114
+ // "not modeled" claim; without that proof, no refusal.
3115
+ const catalogCheck = input.catalogTermMentioned;
3116
+ if (!catalogCheck)
3117
+ return undefined;
3118
+ let confirmed;
3119
+ for (const term of unresolved) {
3120
+ try {
3121
+ if (!(await catalogCheck(term))) {
3122
+ confirmed = term;
3123
+ break;
3124
+ }
3125
+ }
3126
+ catch {
3127
+ return undefined;
3128
+ }
3129
+ }
3130
+ if (!confirmed)
3131
+ return undefined;
3054
3132
  const admitted = [...new Set(all
3055
3133
  .filter((candidate) => v2SemanticCandidateMatchesRole(candidate, 'dimension'))
3056
3134
  .map((candidate) => candidate.semanticRuntimeName ?? candidate.name))].slice(0, 6);
3057
- return { term: unresolved[0], admitted };
3135
+ return { term: confirmed, admitted };
3058
3136
  };
3059
3137
  const hostFirst = !state.exactCertifiedCandidateId
3060
3138
  && state.tierStates?.certified?.status !== 'complete'
@@ -3104,7 +3182,7 @@ function createAskV2LaneHandler(state, limits) {
3104
3182
  // needed the term to resolve.
3105
3183
  if (!state.terminalOutcome
3106
3184
  && (state.turnClass === 'analytics' || state.turnClass === 'prior_result' || state.turnClass === 'clarification_response')) {
3107
- const unmodeled = requestedUnmodeledTerm();
3185
+ const unmodeled = await requestedUnmodeledTerm();
3108
3186
  if (unmodeled) {
3109
3187
  observeAskAgentV2Tool(state, {
3110
3188
  version: 1,
@@ -3148,7 +3226,14 @@ function createAskV2LaneHandler(state, limits) {
3148
3226
  // was shown "stopped at its own orchestration budget" instead of the
3149
3227
  // rows DQL was holding. Ten matches the run-level ceiling so the two
3150
3228
  // budgets cannot disagree about how much room the analyst really has.
3151
- maxProviderDispatches: limits?.maxProviderDispatches ?? (state.turnClass === 'research' ? 12 : state.turnClass === 'analytics' || state.turnClass === 'prior_result' ? 10 : 2),
3229
+ // PHYSICAL sends, not logical round trips: a wrapper provider (the
3230
+ // claude-code/codex passthrough) spends TWO physical sends per
3231
+ // logical turn, so a cap of 10 gave those providers only five turns —
3232
+ // the cold big-repo discovery ladder alone costs five, leaving zero
3233
+ // room to apply a taught refusal. Sixteen restores eight logical
3234
+ // turns for wrappers; 1:1 text providers are still bounded by the
3235
+ // tool-call ceiling and the run deadline long before this guard.
3236
+ maxProviderDispatches: limits?.maxProviderDispatches ?? (state.turnClass === 'research' ? 12 : state.turnClass === 'analytics' || state.turnClass === 'prior_result' ? 24 : 4),
3152
3237
  // The kernel owns current availability. Native transports evaluate it
3153
3238
  // before each API tool declaration; text transports receive the same
3154
3239
  // update after every observation. This reserves a final *LLM action*
@@ -3378,6 +3463,9 @@ function createAskV2LaneHandler(state, limits) {
3378
3463
  askAgentV2Outcome: { version: 2, kind: 'finish_answer', reasonCode: contextualEvidenceBound ? 'ASK_V2_CONTEXTUAL_ANSWER' : 'ASK_V2_GENERAL_UNGROUNDED_ANSWER', origin: 'narration' },
3379
3464
  };
3380
3465
  }
3466
+ if (state.terminalOutcome?.reasonCode === 'ASK_V2_REMAINING_TIERS_DECLINED') {
3467
+ return askV2NoAnswer(input, 'gap', 'ASK_V2_REMAINING_TIERS_DECLINED', 'agent_control');
3468
+ }
3381
3469
  const progress = kernel.toolPolicy();
3382
3470
  if (progress.terminalActionToolNames?.length) {
3383
3471
  observe('finish_answer', 'ineligible', 'ASK_V2_TOOL_PROGRESSION_REQUIRED', {
@@ -3386,7 +3474,7 @@ function createAskV2LaneHandler(state, limits) {
3386
3474
  });
3387
3475
  return askV2NoAnswer(input, 'gap', 'ASK_V2_TOOL_PROGRESSION_REQUIRED', 'agent_control');
3388
3476
  }
3389
- return askV2NoAnswer(input, 'gap', 'ASK_V2_NO_EXECUTABLE_TOOL_RESULT', 'tool', undefined, requestedUnmodeledTerm());
3477
+ return askV2NoAnswer(input, 'gap', 'ASK_V2_NO_EXECUTABLE_TOOL_RESULT', 'tool', undefined, await requestedUnmodeledTerm());
3390
3478
  };
3391
3479
  }
3392
3480
  /**
@@ -3863,7 +3951,9 @@ function askV2NoAnswer(input, kind, reasonCode, origin, safeActionOverride, mode
3863
3951
  : 'The selected governed query did not complete on the current connection. Review the connection and trace, then retry.'
3864
3952
  : modelingGap
3865
3953
  ? `"${modelingGap.term}" is not modeled in this project's governed data, so no query can compute it.${modelingGap.admitted.length ? ` Governed groupings available: ${modelingGap.admitted.join(', ')}.` : ''} Ask with one of those instead, or model "${modelingGap.term}" and re-sync.`
3866
- : 'DQL could not complete a safe analytical tool path from the current metadata snapshot.';
3954
+ : reasonCode === 'ASK_V2_REMAINING_TIERS_DECLINED'
3955
+ ? 'No certified block or semantic metric covers this question, and the analyst declined to run unverified exploratory SQL against this snapshot. No query was executed. Use Research for a deeper investigation, certify a block for this question, or name the exact model/columns to query.'
3956
+ : 'DQL could not complete a safe analytical tool path from the current metadata snapshot.';
3867
3957
  return {
3868
3958
  kind: 'no_answer',
3869
3959
  sourceTier: 'no_answer',
@@ -5730,6 +5820,7 @@ export function createDqlAgentProviderRunner(id, providerOverride) {
5730
5820
  // SQL-boundary guard is needed because it can never execute a
5731
5821
  // provider-authored query.
5732
5822
  ...(req.probeAllowlistedLiteral ? { probeAllowlistedLiteral: req.probeAllowlistedLiteral } : {}),
5823
+ ...(req.catalogTermMentioned ? { catalogTermMentioned: req.catalogTermMentioned } : {}),
5733
5824
  prepareExploratorySqlExecution: req.prepareExploratorySqlExecution
5734
5825
  ? async (sql, ...args) => {
5735
5826
  guardSnapshot();