@utaba/deep-memory-storage-cosmosdb 0.12.1 → 0.14.0

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/index.d.cts CHANGED
@@ -147,7 +147,7 @@ declare class CosmosDbProvider implements StorageProvider, GraphTraversalProvide
147
147
  * For agent-facing graph queries use {@link traverse}, which enforces the
148
148
  * repositoryId partition predicate.
149
149
  */
150
- executeNativeQuery(_repositoryId: string, query: string, params?: Record<string, unknown>): Promise<TraversalResult>;
150
+ executeNativeQuery(_repositoryId: string, query: string, params?: Record<string, unknown>): Promise<unknown[]>;
151
151
  private executeNativeQueryImpl;
152
152
  }
153
153
 
package/dist/index.d.ts CHANGED
@@ -147,7 +147,7 @@ declare class CosmosDbProvider implements StorageProvider, GraphTraversalProvide
147
147
  * For agent-facing graph queries use {@link traverse}, which enforces the
148
148
  * repositoryId partition predicate.
149
149
  */
150
- executeNativeQuery(_repositoryId: string, query: string, params?: Record<string, unknown>): Promise<TraversalResult>;
150
+ executeNativeQuery(_repositoryId: string, query: string, params?: Record<string, unknown>): Promise<unknown[]>;
151
151
  private executeNativeQueryImpl;
152
152
  }
153
153
 
package/dist/index.js CHANGED
@@ -1095,6 +1095,7 @@ var DEFAULT_START = 5;
1095
1095
  var DEFAULT_MAX = 32;
1096
1096
  var DEFAULT_INCREASE_AFTER = 50;
1097
1097
  var DEFAULT_COOLDOWN_MS = 1e3;
1098
+ var DEFAULT_RAMP_UP_COOLDOWN_MS = 5e3;
1098
1099
  var DEFAULT_MAX_CONSECUTIVE_THROTTLES_AT_MIN = 10;
1099
1100
  var DEFAULT_THROTTLE_CEILING_MULTIPLIER = 3;
1100
1101
  var NO_SOFT_CEILING = Number.POSITIVE_INFINITY;
@@ -1104,6 +1105,7 @@ function resolveOptions(opts) {
1104
1105
  const start = Math.min(max, Math.max(min, opts?.start ?? DEFAULT_START));
1105
1106
  const increaseAfter = Math.max(1, opts?.increaseAfter ?? DEFAULT_INCREASE_AFTER);
1106
1107
  const cooldownMs = Math.max(0, opts?.cooldownMs ?? DEFAULT_COOLDOWN_MS);
1108
+ const rampUpCooldownMs = Math.max(0, opts?.rampUpCooldownMs ?? DEFAULT_RAMP_UP_COOLDOWN_MS);
1107
1109
  const maxConsecutiveThrottlesAtMin = Math.max(
1108
1110
  1,
1109
1111
  opts?.maxConsecutiveThrottlesAtMin ?? DEFAULT_MAX_CONSECUTIVE_THROTTLES_AT_MIN
@@ -1118,6 +1120,7 @@ function resolveOptions(opts) {
1118
1120
  max,
1119
1121
  increaseAfter,
1120
1122
  cooldownMs,
1123
+ rampUpCooldownMs,
1121
1124
  maxConsecutiveThrottlesAtMin,
1122
1125
  throttleCeilingMultiplier,
1123
1126
  onAdjust: opts?.onAdjust
@@ -1138,6 +1141,7 @@ var AdaptiveConcurrencyController = class {
1138
1141
  current;
1139
1142
  streak = 0;
1140
1143
  cooldownUntil = 0;
1144
+ rampFrozenUntil = 0;
1141
1145
  completed = 0;
1142
1146
  throttled = 0;
1143
1147
  startEmitted = false;
@@ -1188,10 +1192,11 @@ var AdaptiveConcurrencyController = class {
1188
1192
  this.notify("start", this.current);
1189
1193
  }
1190
1194
  /** Record a throttle-free task completion. May trigger ramp-up. */
1191
- noteSuccess() {
1195
+ noteSuccess(now = Date.now()) {
1192
1196
  this.completed++;
1193
- this.streak++;
1194
1197
  this.consecutiveThrottlesAtMin = 0;
1198
+ if (now < this.rampFrozenUntil) return;
1199
+ this.streak++;
1195
1200
  if (this.current >= this.opts.max) return;
1196
1201
  const target = this.current + 1;
1197
1202
  const needed = target >= this.softCeiling ? this.opts.increaseAfter * this.opts.throttleCeilingMultiplier : this.opts.increaseAfter;
@@ -1213,6 +1218,7 @@ var AdaptiveConcurrencyController = class {
1213
1218
  const previous = this.current;
1214
1219
  const next = Math.max(this.opts.min, Math.floor(this.current / 2));
1215
1220
  this.cooldownUntil = now + this.opts.cooldownMs;
1221
+ this.rampFrozenUntil = now + this.opts.rampUpCooldownMs;
1216
1222
  if (next !== previous) {
1217
1223
  this.current = next;
1218
1224
  this.softCeiling = previous;
@@ -2178,35 +2184,9 @@ var CosmosDbProvider = class {
2178
2184
  return this.track("executeNativeQuery", void 0, () => this.executeNativeQueryImpl(query, params));
2179
2185
  }
2180
2186
  async executeNativeQueryImpl(query, params) {
2181
- const startTime = Date.now();
2182
2187
  try {
2183
2188
  const result = await this.conn.submit(query, params);
2184
- const executionTimeMs = Date.now() - startTime;
2185
- const entities = [];
2186
- for (const item of result.items) {
2187
- try {
2188
- const entity = entityFromGremlin(item);
2189
- if (entity.id) {
2190
- entities.push(entity);
2191
- }
2192
- } catch {
2193
- }
2194
- }
2195
- const queryMetadata = {
2196
- executionTimeMs,
2197
- resourceCost: result.requestCharge != null ? { units: "RU", value: result.requestCharge } : void 0,
2198
- compiledQuery: query,
2199
- compiledQueryLanguage: "gremlin",
2200
- appliedLimits: { maxResults: entities.length },
2201
- truncated: false
2202
- };
2203
- return {
2204
- entities,
2205
- total: entities.length,
2206
- returned: entities.length,
2207
- hasMore: false,
2208
- queryMetadata
2209
- };
2189
+ return result.items;
2210
2190
  } catch (err) {
2211
2191
  throw new ProviderError(
2212
2192
  `Native Gremlin query failed: ${err instanceof Error ? err.message : String(err)}`,