deepline 0.2.14 → 0.2.15

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.
@@ -160,7 +160,7 @@ export const SDK_RELEASE = {
160
160
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
161
161
  // exposed storage-dependent synchronous access. This deliberate minor
162
162
  // release keeps lazy paging semantics independent of row residency.
163
- version: '0.2.14',
163
+ version: '0.2.15',
164
164
  contracts: {
165
165
  api: {
166
166
  name: 'sdk-http-api',
@@ -5844,17 +5844,21 @@ export async function heartbeatRuntimeWorkReceipts(
5844
5844
  JOIN unnest($3::text[]) WITH ORDINALITY AS lease_values(lease_id, ord)
5845
5845
  ON lease_values.ord = key_values.ord
5846
5846
  ),
5847
+ unique_inputs AS (
5848
+ SELECT DISTINCT key_hex, lease_id
5849
+ FROM input_keys
5850
+ ),
5847
5851
  renewed AS (
5848
5852
  UPDATE ${workReceiptTable(session)} AS target
5849
5853
  SET lease_expires_at = now() + ($4::double precision * interval '1 millisecond'),
5850
5854
  updated_at = now()
5851
- FROM input_keys
5852
- WHERE target.k = decode(input_keys.key_hex, 'hex')
5855
+ FROM unique_inputs
5856
+ WHERE target.k = decode(unique_inputs.key_hex, 'hex')
5853
5857
  AND ${workReceiptHeartbeatPredicateSql({
5854
5858
  receiptTable: 'target',
5855
5859
  ownerRunIdSql: '$2::text',
5856
5860
  ownerRunAttemptSql: '$5',
5857
- leaseIdSql: 'input_keys.lease_id',
5861
+ leaseIdSql: 'unique_inputs.lease_id',
5858
5862
  })}
5859
5863
  RETURNING target.k,
5860
5864
  target.status,
@@ -5867,8 +5871,7 @@ export async function heartbeatRuntimeWorkReceipts(
5867
5871
  target.lease_owner_run_id,
5868
5872
  target.lease_owner_attempt,
5869
5873
  target.lease_expires_at,
5870
- target.updated_at,
5871
- input_keys.ord
5874
+ target.updated_at
5872
5875
  ),
5873
5876
  returned AS (
5874
5877
  SELECT renewed.k,
@@ -5885,7 +5888,9 @@ export async function heartbeatRuntimeWorkReceipts(
5885
5888
  renewed.updated_at,
5886
5889
  input_keys.ord
5887
5890
  FROM input_keys
5888
- LEFT JOIN renewed ON renewed.ord = input_keys.ord
5891
+ LEFT JOIN renewed
5892
+ ON renewed.k = decode(input_keys.key_hex, 'hex')
5893
+ AND renewed.lease_id = input_keys.lease_id
5889
5894
  )
5890
5895
  SELECT convert_from(returned.k, 'UTF8') AS k,
5891
5896
  returned.status,
@@ -25,7 +25,10 @@ import {
25
25
  skipRuntimeStepReceiptViaAppRuntime,
26
26
  type WorkerRuntimeApiContext,
27
27
  } from './app-runtime-api';
28
- import { RuntimeReceiptWriter } from './runtime-receipt-writer';
28
+ import {
29
+ RuntimeReceiptWriter,
30
+ RuntimeReceiptWriterResultCountError,
31
+ } from './runtime-receipt-writer';
29
32
 
30
33
  type ReceiptOutput =
31
34
  | RuntimeStepReceipt
@@ -490,17 +493,43 @@ async function sendReceiptCommands(input: {
490
493
  ReceiptCommand,
491
494
  { kind: 'heartbeat' }
492
495
  >[];
493
- const leaseIds = commands.map((command) => command.input.leaseId);
496
+ const uniqueCommands: (typeof commands)[number][] = [];
497
+ const uniqueIndexByIdentity = new Map<string, number>();
498
+ const originalToUniqueIndex = commands.map((command) => {
499
+ const identity = JSON.stringify([
500
+ command.input.key,
501
+ command.input.leaseId,
502
+ ]);
503
+ const existingIndex = uniqueIndexByIdentity.get(identity);
504
+ if (existingIndex !== undefined) return existingIndex;
505
+ const uniqueIndex = uniqueCommands.length;
506
+ uniqueCommands.push(command);
507
+ uniqueIndexByIdentity.set(identity, uniqueIndex);
508
+ return uniqueIndex;
509
+ });
510
+ const leaseIds = uniqueCommands.map((command) => command.input.leaseId);
494
511
  const sharedLeaseId = leaseIds.every((leaseId) => leaseId === leaseIds[0])
495
512
  ? leaseIds[0]
496
513
  : undefined;
497
- return await heartbeatRuntimeStepReceiptsViaAppRuntime(input.context, {
498
- playName: input.playName,
499
- runId: first.input.runId,
500
- runAttempt: first.input.runAttempt,
501
- ...(sharedLeaseId ? { leaseId: sharedLeaseId } : { leaseIds }),
502
- keys: commands.map((command) => command.input.key),
503
- });
514
+ const uniqueResults = await heartbeatRuntimeStepReceiptsViaAppRuntime(
515
+ input.context,
516
+ {
517
+ playName: input.playName,
518
+ runId: first.input.runId,
519
+ runAttempt: first.input.runAttempt,
520
+ ...(sharedLeaseId ? { leaseId: sharedLeaseId } : { leaseIds }),
521
+ keys: uniqueCommands.map((command) => command.input.key),
522
+ },
523
+ );
524
+ if (uniqueResults.length !== uniqueCommands.length) {
525
+ throw new RuntimeReceiptWriterResultCountError(
526
+ uniqueCommands.length,
527
+ uniqueResults.length,
528
+ );
529
+ }
530
+ return originalToUniqueIndex.map(
531
+ (uniqueIndex) => uniqueResults[uniqueIndex]!,
532
+ );
504
533
  }
505
534
  case 'acquire_execution_lock':
506
535
  return [
package/dist/cli/index.js CHANGED
@@ -1044,7 +1044,7 @@ var SDK_RELEASE = {
1044
1044
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
1045
1045
  // exposed storage-dependent synchronous access. This deliberate minor
1046
1046
  // release keeps lazy paging semantics independent of row residency.
1047
- version: "0.2.14",
1047
+ version: "0.2.15",
1048
1048
  contracts: {
1049
1049
  api: {
1050
1050
  name: "sdk-http-api",
@@ -1030,7 +1030,7 @@ var SDK_RELEASE = {
1030
1030
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
1031
1031
  // exposed storage-dependent synchronous access. This deliberate minor
1032
1032
  // release keeps lazy paging semantics independent of row residency.
1033
- version: "0.2.14",
1033
+ version: "0.2.15",
1034
1034
  contracts: {
1035
1035
  api: {
1036
1036
  name: "sdk-http-api",
package/dist/index.js CHANGED
@@ -763,7 +763,7 @@ var SDK_RELEASE = {
763
763
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
764
764
  // exposed storage-dependent synchronous access. This deliberate minor
765
765
  // release keeps lazy paging semantics independent of row residency.
766
- version: "0.2.14",
766
+ version: "0.2.15",
767
767
  contracts: {
768
768
  api: {
769
769
  name: "sdk-http-api",
package/dist/index.mjs CHANGED
@@ -689,7 +689,7 @@ var SDK_RELEASE = {
689
689
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
690
690
  // exposed storage-dependent synchronous access. This deliberate minor
691
691
  // release keeps lazy paging semantics independent of row residency.
692
- version: "0.2.14",
692
+ version: "0.2.15",
693
693
  contracts: {
694
694
  api: {
695
695
  name: "sdk-http-api",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "description": "Deepline SDK + CLI — B2B data enrichment powered by durable cloud execution",
5
5
  "license": "MIT",
6
6
  "repository": {