deepline 0.3.92 → 0.3.93

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.
@@ -200,7 +200,7 @@ export const SDK_RELEASE = {
200
200
  // getters keep their established compatibility behavior.
201
201
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
202
202
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
203
- version: '0.3.92',
203
+ version: '0.3.93',
204
204
  updateSummary:
205
205
  'Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.',
206
206
  packageCapabilities: {
@@ -5,6 +5,7 @@ import {
5
5
  type WorkerRuntimeApiContext,
6
6
  } from '../app-runtime-api';
7
7
  import {
8
+ DEFAULT_ADVISORY_PROVIDER_MAX_RPS,
8
9
  noopPacingPermit,
9
10
  type PacingPermit,
10
11
  type PacingRule,
@@ -445,8 +446,8 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
445
446
  const response = await this.port.acquire({
446
447
  bucketId,
447
448
  rateScopeToken,
448
- // Stamp adaptiveMaxRps on default-pacing rules so the DB row's ceiling
449
- // matches the old in-memory AIMD range.
449
+ // Stamp the advisory ceiling so the durable DB row uses the same
450
+ // catalogued-rate AIMD range as this in-memory controller.
450
451
  rules: withAdaptiveMaxRps(ordered),
451
452
  requested: this.requestedForBucket(laneKey, ordered),
452
453
  observedSuccesses,
@@ -823,41 +824,21 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
823
824
  }
824
825
 
825
826
  /**
826
- * Multiplier applied to an undeclared default-pacing rule's
827
- * `requestsPerWindow` to derive its `adaptiveMaxRps` ceiling. Declared rules
828
- * carry either their explicit advisory ceiling or their hard base rate.
829
- */
830
- const DEFAULT_PACING_ADAPTIVE_MAX_RPS_MULTIPLIER = 25;
831
-
832
- /**
833
- * A rule id shaped `default:<toolId>` is the undeclared-tool default-pacing rule
834
- * minted by `defaultPacingForTool` in governor.ts.
835
- */
836
- function isDefaultPacingRuleId(ruleId: string): boolean {
837
- return ruleId.startsWith('default:');
838
- }
839
-
840
- /**
841
- * Preserve explicit advisory ceilings, stamp the legacy base * 25 ceiling onto
842
- * undeclared default-pacing rules, and stamp declared rules with their base
843
- * rate. Sending the hard base explicitly also repairs bucket rows widened by a
844
- * previous runtime version on their next acquire.
827
+ * Catalogued provider rates seed AIMD. In the absence of an explicit
828
+ * provider-specific ceiling, let the controller probe to the shared bounded
829
+ * advisory maximum instead of treating a recommendation as a hard ceiling.
845
830
  */
846
831
  function withAdaptiveMaxRps(rules: readonly PacingRule[]): PacingRule[] {
847
832
  return rules.map((rule) =>
848
833
  rule.adaptiveMaxRps != null
849
834
  ? rule
850
- : isDefaultPacingRuleId(rule.ruleId)
851
- ? ({
852
- ...rule,
853
- adaptiveMaxRps:
854
- rule.requestsPerWindow *
855
- DEFAULT_PACING_ADAPTIVE_MAX_RPS_MULTIPLIER,
856
- } as PacingRule)
857
- : ({
858
- ...rule,
859
- adaptiveMaxRps: (rule.requestsPerWindow / rule.windowMs) * 1_000,
860
- } as PacingRule),
835
+ : ({
836
+ ...rule,
837
+ adaptiveMaxRps: Math.max(
838
+ (rule.requestsPerWindow / rule.windowMs) * 1_000,
839
+ DEFAULT_ADVISORY_PROVIDER_MAX_RPS,
840
+ ),
841
+ } as PacingRule),
861
842
  );
862
843
  }
863
844
 
@@ -6,6 +6,14 @@
6
6
  * down the lineage via the snapshot. See ADR 0007 and CONTEXT.md.
7
7
  */
8
8
 
9
+ /**
10
+ * A catalogued provider rate is a starting recommendation, not a throughput
11
+ * ceiling. The shared controller probes from that seed to this bounded rate
12
+ * until upstream backpressure teaches it otherwise. A provider can still set a
13
+ * different explicit `adaptiveMaxRps` in its queue hint.
14
+ */
15
+ export const DEFAULT_ADVISORY_PROVIDER_MAX_RPS = 100;
16
+
9
17
  /** A single resolved rate rule for a bucket (from rate-limit-definitions). */
10
18
  export interface PacingRule {
11
19
  readonly ruleId: string;
@@ -4,7 +4,10 @@ import type {
4
4
  PlayRunnerRateStatePenalizeInput,
5
5
  PlayRunnerRateStateReleaseInput,
6
6
  } from '../protocol';
7
- import type { PacingRule } from '../governor/rate-state-backend';
7
+ import {
8
+ DEFAULT_ADVISORY_PROVIDER_MAX_RPS,
9
+ type PacingRule,
10
+ } from '../governor/rate-state-backend';
8
11
  import type { PostgresSchedulerQueryClient } from './postgres';
9
12
  import { resolveRuntimeSchedulerSchemaEnv } from './runtime-scheduler-schema';
10
13
  import { stringifyPostgresJson } from '../postgres-json';
@@ -25,23 +28,6 @@ const MIN_ADAPTIVE_RPS_FLOOR = 0.01;
25
28
  */
26
29
  const MAX_INTERNAL_COOLDOWN_MS = 45 * 60 * 1000;
27
30
 
28
- /**
29
- * Additive-ramp multiplier applied to undeclared default-pacing buckets.
30
- * Declared rules stay pinned at base unless they carry an explicit adaptive
31
- * ceiling.
32
- */
33
- const DEFAULT_PACING_MAX_RPS_MULTIPLIER = 25;
34
-
35
- /**
36
- * Low-rate provider requests cross the sandbox -> gateway -> app boundary after
37
- * their permit wakes. Small network-latency differences can compress two
38
- * otherwise exact 100ms/200ms intervals at the provider and turn a mathematically
39
- * valid edge into a rolling-window 429. Keep a 20% arrival margin below 100
40
- * RPS. High-rate providers retain their microburst schedule and full rate.
41
- */
42
- const LOW_RATE_DISPATCH_HEADROOM_FACTOR = 0.8;
43
- const LOW_RATE_DISPATCH_HEADROOM_THRESHOLD_RPS = 100;
44
-
45
31
  function quoteIdent(value: string): string {
46
32
  return `"${value.replace(/"/g, '""')}"`;
47
33
  }
@@ -74,8 +60,9 @@ function concurrencyLeaseTableName(options?: {
74
60
 
75
61
  /**
76
62
  * Acquire input rules may carry an optional `adaptiveMaxRps` the client can send
77
- * to widen a bucket's recovery ceiling above its declared base rate. When
78
- * absent, `default:*` rules get base * 25 and declared providers pin at base.
63
+ * to override a bucket's recovery ceiling. When absent, a catalogued provider
64
+ * rate is an advisory seed and the controller may probe to the shared bounded
65
+ * maximum.
79
66
  */
80
67
  type AcquirePacingRule = PacingRule & {
81
68
  adaptiveMaxRps?: number | null;
@@ -120,12 +107,11 @@ function normalizeRules(
120
107
  * Seed parameters for a rule row. `base_refill` is the declared rate in tokens
121
108
  * per second; `capacity` is one window of burst. The adaptive `[min,max]` range
122
109
  * is derived value-first so the same wire shape drives both declared and
123
- * default-pacing buckets:
110
+ * catalogued-rate buckets:
124
111
  * - min_rps = min(base, max(0.01, base/8))
125
112
  * (low-RPM rules must still be able to back down below their base)
126
- * - max_rps = base (declared: recovery climbs back TO base only)
127
- * - max_rps = base * 25 (undeclared default:* buckets, or explicit
128
- * adaptiveMaxRps override)
113
+ * - max_rps = max(base, 100) (catalogued-rate recommendation)
114
+ * - max_rps = explicit adaptiveMaxRps when supplied
129
115
  */
130
116
  function seedForRule(rule: AcquirePacingRule): {
131
117
  rule_id: string;
@@ -140,13 +126,10 @@ function seedForRule(rule: AcquirePacingRule): {
140
126
  const capacity = Math.max(1, rule.requestsPerWindow);
141
127
  const base = (rule.requestsPerWindow / rule.windowMs) * 1000;
142
128
  const minRps = Math.min(base, Math.max(MIN_ADAPTIVE_RPS_FLOOR, base / 8));
143
- const isDefaultPacing = rule.ruleId.startsWith('default:');
144
129
  const maxRps =
145
- rule.adaptiveMaxRps != null && rule.adaptiveMaxRps > base
146
- ? rule.adaptiveMaxRps
147
- : isDefaultPacing
148
- ? base * DEFAULT_PACING_MAX_RPS_MULTIPLIER
149
- : base;
130
+ rule.adaptiveMaxRps != null && rule.adaptiveMaxRps > 0
131
+ ? Math.max(rule.adaptiveMaxRps, base)
132
+ : Math.max(base, DEFAULT_ADVISORY_PROVIDER_MAX_RPS);
150
133
  return {
151
134
  rule_id: rule.ruleId,
152
135
  capacity,
@@ -385,16 +368,7 @@ async function acquirePureRate(
385
368
  MAX(cool_until_ms),
386
369
  MAX(next_dispatch_at_ms)
387
370
  )::bigint AS first_at_ms,
388
- CEIL(MAX(
389
- 1000.0 / GREATEST(
390
- refill_per_sec * CASE
391
- WHEN refill_per_sec < ${LOW_RATE_DISPATCH_HEADROOM_THRESHOLD_RPS}
392
- THEN ${LOW_RATE_DISPATCH_HEADROOM_FACTOR}
393
- ELSE 1.0
394
- END,
395
- 0.0001
396
- )
397
- ))::bigint AS spacing_ms,
371
+ CEIL(MAX(1000.0 / GREATEST(refill_per_sec, 0.0001)))::bigint AS spacing_ms,
398
372
  GREATEST(1, FLOOR(MIN(refill_per_sec) / 100.0))::bigint AS burst_size
399
373
  FROM refreshed
400
374
  ),
@@ -661,16 +635,7 @@ async function acquireWithConcurrency(
661
635
  MAX(cool_until_ms),
662
636
  MAX(next_dispatch_at_ms)
663
637
  )::bigint AS first_at_ms,
664
- CEIL(MAX(
665
- 1000.0 / GREATEST(
666
- refill_per_sec * CASE
667
- WHEN refill_per_sec < ${LOW_RATE_DISPATCH_HEADROOM_THRESHOLD_RPS}
668
- THEN ${LOW_RATE_DISPATCH_HEADROOM_FACTOR}
669
- ELSE 1.0
670
- END,
671
- 0.0001
672
- )
673
- ))::bigint AS spacing_ms,
638
+ CEIL(MAX(1000.0 / GREATEST(refill_per_sec, 0.0001)))::bigint AS spacing_ms,
674
639
  GREATEST(1, FLOOR(MIN(refill_per_sec) / 100.0))::bigint AS burst_size
675
640
  FROM refreshed
676
641
  ),
package/dist/cli/index.js CHANGED
@@ -1298,7 +1298,7 @@ var SDK_RELEASE = {
1298
1298
  // getters keep their established compatibility behavior.
1299
1299
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
1300
1300
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
1301
- version: "0.3.92",
1301
+ version: "0.3.93",
1302
1302
  updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
1303
1303
  packageCapabilities: {
1304
1304
  updatePreferences: 1
@@ -21484,6 +21484,9 @@ function exportableSheetRow(row) {
21484
21484
  }
21485
21485
  return fallback;
21486
21486
  }
21487
+ function acceptsSettledRowsAsCompleteExport(status) {
21488
+ return status.status === "failed" || status.status === "cancelled";
21489
+ }
21487
21490
  function mergeExportColumns(preferredColumns, rows) {
21488
21491
  const columns = [];
21489
21492
  const seen = /* @__PURE__ */ new Set();
@@ -21524,6 +21527,7 @@ async function fetchBackingDatasetRows(input2) {
21524
21527
  }
21525
21528
  const sheetRows = [];
21526
21529
  let offset = 0;
21530
+ let settledTotal = null;
21527
21531
  while (true) {
21528
21532
  const page = await input2.client.runs.exportDatasetRows({
21529
21533
  playName,
@@ -21534,13 +21538,18 @@ async function fetchBackingDatasetRows(input2) {
21534
21538
  rowMode: "all"
21535
21539
  });
21536
21540
  sheetRows.push(...page.rows);
21541
+ const summaryTotal = page.summary?.stats?.total;
21542
+ if (typeof summaryTotal === "number" && Number.isFinite(summaryTotal)) {
21543
+ settledTotal = Math.max(settledTotal ?? 0, Math.trunc(summaryTotal));
21544
+ }
21537
21545
  if (page.rows.length < RUN_EXPORT_PAGE_SIZE) {
21538
21546
  break;
21539
21547
  }
21540
21548
  offset += page.rows.length;
21541
21549
  }
21542
21550
  const rows = sheetRows.map(exportableSheetRow).filter((row) => Boolean(row));
21543
- if (!currentTable && rows.length < input2.rowsInfo.totalRows || currentTable && rows.length === 0 && input2.rowsInfo.totalRows > 0) {
21551
+ const hasCompleteSettledPrefix = !currentTable && acceptsSettledRowsAsCompleteExport(input2.status) && settledTotal !== null && rows.length >= settledTotal;
21552
+ if (!currentTable && rows.length < input2.rowsInfo.totalRows && !hasCompleteSettledPrefix || currentTable && rows.length === 0 && input2.rowsInfo.totalRows > 0) {
21544
21553
  return null;
21545
21554
  }
21546
21555
  const columns = mergeExportColumns(
@@ -1271,7 +1271,7 @@ var SDK_RELEASE = {
1271
1271
  // getters keep their established compatibility behavior.
1272
1272
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
1273
1273
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
1274
- version: "0.3.92",
1274
+ version: "0.3.93",
1275
1275
  updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
1276
1276
  packageCapabilities: {
1277
1277
  updatePreferences: 1
@@ -21534,6 +21534,9 @@ function exportableSheetRow(row) {
21534
21534
  }
21535
21535
  return fallback;
21536
21536
  }
21537
+ function acceptsSettledRowsAsCompleteExport(status) {
21538
+ return status.status === "failed" || status.status === "cancelled";
21539
+ }
21537
21540
  function mergeExportColumns(preferredColumns, rows) {
21538
21541
  const columns = [];
21539
21542
  const seen = /* @__PURE__ */ new Set();
@@ -21574,6 +21577,7 @@ async function fetchBackingDatasetRows(input2) {
21574
21577
  }
21575
21578
  const sheetRows = [];
21576
21579
  let offset = 0;
21580
+ let settledTotal = null;
21577
21581
  while (true) {
21578
21582
  const page = await input2.client.runs.exportDatasetRows({
21579
21583
  playName,
@@ -21584,13 +21588,18 @@ async function fetchBackingDatasetRows(input2) {
21584
21588
  rowMode: "all"
21585
21589
  });
21586
21590
  sheetRows.push(...page.rows);
21591
+ const summaryTotal = page.summary?.stats?.total;
21592
+ if (typeof summaryTotal === "number" && Number.isFinite(summaryTotal)) {
21593
+ settledTotal = Math.max(settledTotal ?? 0, Math.trunc(summaryTotal));
21594
+ }
21587
21595
  if (page.rows.length < RUN_EXPORT_PAGE_SIZE) {
21588
21596
  break;
21589
21597
  }
21590
21598
  offset += page.rows.length;
21591
21599
  }
21592
21600
  const rows = sheetRows.map(exportableSheetRow).filter((row) => Boolean(row));
21593
- if (!currentTable && rows.length < input2.rowsInfo.totalRows || currentTable && rows.length === 0 && input2.rowsInfo.totalRows > 0) {
21601
+ const hasCompleteSettledPrefix = !currentTable && acceptsSettledRowsAsCompleteExport(input2.status) && settledTotal !== null && rows.length >= settledTotal;
21602
+ if (!currentTable && rows.length < input2.rowsInfo.totalRows && !hasCompleteSettledPrefix || currentTable && rows.length === 0 && input2.rowsInfo.totalRows > 0) {
21594
21603
  return null;
21595
21604
  }
21596
21605
  const columns = mergeExportColumns(
package/dist/index.js CHANGED
@@ -856,7 +856,7 @@ var SDK_RELEASE = {
856
856
  // getters keep their established compatibility behavior.
857
857
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
858
858
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
859
- version: "0.3.92",
859
+ version: "0.3.93",
860
860
  updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
861
861
  packageCapabilities: {
862
862
  updatePreferences: 1
package/dist/index.mjs CHANGED
@@ -768,7 +768,7 @@ var SDK_RELEASE = {
768
768
  // getters keep their established compatibility behavior.
769
769
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
770
770
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
771
- version: "0.3.92",
771
+ version: "0.3.93",
772
772
  updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
773
773
  packageCapabilities: {
774
774
  updatePreferences: 1
@@ -149,7 +149,7 @@ type SdkRelease = {
149
149
  supportPolicy: SdkSupportPolicy;
150
150
  };
151
151
  declare const SDK_RELEASE: {
152
- readonly version: "0.3.92";
152
+ readonly version: "0.3.93";
153
153
  readonly updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.";
154
154
  readonly packageCapabilities: {
155
155
  readonly updatePreferences: 1;
package/dist/release.d.ts CHANGED
@@ -149,7 +149,7 @@ type SdkRelease = {
149
149
  supportPolicy: SdkSupportPolicy;
150
150
  };
151
151
  declare const SDK_RELEASE: {
152
- readonly version: "0.3.92";
152
+ readonly version: "0.3.93";
153
153
  readonly updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.";
154
154
  readonly packageCapabilities: {
155
155
  readonly updatePreferences: 1;
package/dist/release.js CHANGED
@@ -74,7 +74,7 @@ var SDK_RELEASE = {
74
74
  // getters keep their established compatibility behavior.
75
75
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
76
76
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
77
- version: "0.3.92",
77
+ version: "0.3.93",
78
78
  updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
79
79
  packageCapabilities: {
80
80
  updatePreferences: 1
package/dist/release.mjs CHANGED
@@ -48,7 +48,7 @@ var SDK_RELEASE = {
48
48
  // getters keep their established compatibility behavior.
49
49
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
50
50
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
51
- version: "0.3.92",
51
+ version: "0.3.93",
52
52
  updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
53
53
  packageCapabilities: {
54
54
  updatePreferences: 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.3.92",
3
+ "version": "0.3.93",
4
4
  "description": "GTM data CLI and TypeScript SDK for coding agents",
5
5
  "license": "MIT",
6
6
  "homepage": "https://code.deepline.com",