deepline 0.1.298 → 0.1.299

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.
@@ -93,6 +93,7 @@ import {
93
93
  normalizePlayRuntimeSelection,
94
94
  type PlayRuntimeSelection,
95
95
  } from '../../shared_libs/play-runtime/runtime-environment.js';
96
+ import { decodePlayRunPublicStatus } from '../../shared_libs/play-runtime/run-lifecycle-policy.js';
96
97
 
97
98
  const TERMINAL_PLAY_STATUSES = new Set(['completed', 'failed', 'cancelled']);
98
99
  const INCLUDE_TOOL_METADATA_HEADER = 'x-deepline-include-tool-metadata';
@@ -991,12 +992,18 @@ function normalizePlayStatus(raw: Record<string, unknown>): PlayStatus {
991
992
  ? raw.package
992
993
  : null;
993
994
  const packageRun = runPackage?.run;
994
- const status =
995
+ const rawStatus =
995
996
  typeof raw.status === 'string'
996
997
  ? raw.status
997
998
  : typeof packageRun?.status === 'string'
998
999
  ? packageRun.status
999
- : 'running';
1000
+ : null;
1001
+ const status = decodePlayRunPublicStatus(rawStatus);
1002
+ if (!status) {
1003
+ throw new Error(
1004
+ `Invalid play run lifecycle status in API response: ${JSON.stringify(rawStatus)}.`,
1005
+ );
1006
+ }
1000
1007
  const runId =
1001
1008
  typeof raw.runId === 'string'
1002
1009
  ? raw.runId
@@ -1007,7 +1014,7 @@ function normalizePlayStatus(raw: Record<string, unknown>): PlayStatus {
1007
1014
  ...(raw as unknown as Omit<PlayStatus, 'runId' | 'status'>),
1008
1015
  runId,
1009
1016
  ...(runPackage ? { package: runPackage, outputs: runPackage.outputs } : {}),
1010
- status: status as PlayStatus['status'],
1017
+ status,
1011
1018
  };
1012
1019
  }
1013
1020
 
@@ -155,7 +155,7 @@ export const SDK_RELEASE = {
155
155
  // 0.1.253 makes play-page browser opening opt-in and retires --no-open.
156
156
  // 0.1.254 removes the internal operations tree from the published SDK CLI.
157
157
  // Operators use the checkout-local deepline-admin binary instead.
158
- version: '0.1.298',
158
+ version: '0.1.299',
159
159
  contracts: {
160
160
  api: {
161
161
  name: 'sdk-http-api',
@@ -3,7 +3,6 @@ import {
3
3
  PLATFORM_DEPLOY_INTERRUPTED_MESSAGE,
4
4
  } from './run-failure';
5
5
  import {
6
- isAuthoritativePlayRunTerminalSource,
7
6
  nextPlayRunLedgerTerminalSource,
8
7
  normalizePlayRunLedgerTerminalSource,
9
8
  } from './run-terminal-source';
@@ -643,16 +642,6 @@ function nextTerminalSource(
643
642
  });
644
643
  }
645
644
 
646
- function shouldUpgradeFromCoordinatorTerminal(
647
- base: PlayRunLedgerSnapshot,
648
- eventSource: PlayRunLedgerEventSource,
649
- ): boolean {
650
- return (
651
- base.terminalSource === 'coordinator' &&
652
- isAuthoritativePlayRunTerminalSource(eventSource)
653
- );
654
- }
655
-
656
645
  function shouldIgnoreNonTerminalAfterStickyTerminal(
657
646
  base: PlayRunLedgerSnapshot,
658
647
  ): boolean {
@@ -908,13 +897,10 @@ function appendLogLines(
908
897
  }
909
898
 
910
899
  /**
911
- * Terminal-status precedence. Conflicting terminal events use
912
- * newest-terminal-wins by event time: older events are ignored and logged,
913
- * newer events reconcile the snapshot. Same-status terminal events continue to
914
- * the reducer so recovery/transport paths can fill in canonical payloads after
915
- * an earlier partial terminal snapshot. Retryable platform-deploy failures are
916
- * the narrow exception: they are never allowed to replace a real terminal
917
- * result from the runtime.
900
+ * Terminal-status precedence. The first accepted run terminal is immutable:
901
+ * later events may enrich the same terminal payload, but may never change its
902
+ * outcome. Attempt retries are not authority to rewrite a terminal run, and
903
+ * producer timestamps are telemetry rather than an ordering mechanism.
918
904
  */
919
905
  function conflictingTerminalSnapshot(
920
906
  base: PlayRunLedgerSnapshot,
@@ -923,26 +909,12 @@ function conflictingTerminalSnapshot(
923
909
  eventError?: string | null,
924
910
  options?: {
925
911
  allowStaleSameStatusPayloadMerge?: boolean;
926
- allowCoordinatorTerminalUpgrade?: boolean;
927
912
  },
928
913
  ): PlayRunLedgerSnapshot | null {
929
914
  if (!isTerminalPlayRunLedgerStatus(base.status)) {
930
915
  return null;
931
916
  }
932
917
  const terminalAt = base.finishedAt ?? base.updatedAt ?? 0;
933
- if (base.status === 'cancelled' && eventType !== 'run.cancelled') {
934
- if (occurredAt <= terminalAt) {
935
- return withTiming(
936
- appendLogLines(base, [
937
- `[ledger] stale conflicting terminal event ${eventType} ignored; status already ${base.status}`,
938
- ]),
939
- );
940
- }
941
- return withTiming(base);
942
- }
943
- if (options?.allowCoordinatorTerminalUpgrade === true) {
944
- return null;
945
- }
946
918
  if (
947
919
  base.status === 'completed' &&
948
920
  eventType === 'run.failed' &&
@@ -970,12 +942,6 @@ function conflictingTerminalSnapshot(
970
942
  }
971
943
  return null;
972
944
  }
973
- if (occurredAt > terminalAt) {
974
- // Newer terminal evidence reconciles the run. This covers replay/receipt
975
- // races where an earlier attempt failed but a later attempt recovered and
976
- // completed with the durable result.
977
- return null;
978
- }
979
945
  return withTiming(
980
946
  appendLogLines(base, [
981
947
  `[ledger] stale conflicting terminal event ${eventType} ignored; status already ${base.status}`,
@@ -1205,12 +1171,7 @@ export function reducePlayRunLedgerEvent(
1205
1171
  case 'run.completed':
1206
1172
  return (
1207
1173
  conflictingTerminalSnapshot(base, event.type, occurredAt, null, {
1208
- allowCoordinatorTerminalUpgrade: shouldUpgradeFromCoordinatorTerminal(
1209
- base,
1210
- event.source,
1211
- ),
1212
1174
  allowStaleSameStatusPayloadMerge:
1213
- shouldUpgradeFromCoordinatorTerminal(base, event.source) ||
1214
1175
  (base.result === undefined && event.result !== undefined) ||
1215
1176
  (base.resultSummary === undefined &&
1216
1177
  event.resultSummary !== undefined),
@@ -1234,7 +1195,6 @@ export function reducePlayRunLedgerEvent(
1234
1195
  retryablePlatformDeployFailureSnapshot(base, event.error) ??
1235
1196
  conflictingTerminalSnapshot(base, event.type, occurredAt, event.error, {
1236
1197
  allowStaleSameStatusPayloadMerge:
1237
- shouldUpgradeFromCoordinatorTerminal(base, event.source) ||
1238
1198
  (base.error == null && event.error != null) ||
1239
1199
  (base.result === undefined && event.result !== undefined),
1240
1200
  }) ??
@@ -1258,7 +1218,6 @@ export function reducePlayRunLedgerEvent(
1258
1218
  return (
1259
1219
  conflictingTerminalSnapshot(base, event.type, occurredAt, event.error, {
1260
1220
  allowStaleSameStatusPayloadMerge:
1261
- shouldUpgradeFromCoordinatorTerminal(base, event.source) ||
1262
1221
  (base.error == null && event.error != null) ||
1263
1222
  (base.result === undefined && event.result !== undefined),
1264
1223
  }) ??
@@ -9,6 +9,15 @@ export type PlayRunLifecycleStatus =
9
9
  | 'timed_out'
10
10
  | 'unknown';
11
11
 
12
+ /** The only lifecycle states exposed by the API, SDK, CLI, and UI. */
13
+ export type PlayRunPublicStatus =
14
+ | 'queued'
15
+ | 'running'
16
+ | 'waiting'
17
+ | 'completed'
18
+ | 'failed'
19
+ | 'cancelled';
20
+
12
21
  const TERMINAL_PLAY_RUN_STATUSES = new Set<PlayRunLifecycleStatus>([
13
22
  'completed',
14
23
  'failed',
@@ -33,7 +42,7 @@ export function normalizePlayRunLifecycleStatus(
33
42
  switch (normalized) {
34
43
  case 'queued':
35
44
  case 'pending':
36
- return 'running';
45
+ return 'queued';
37
46
  case 'running':
38
47
  case 'started':
39
48
  return 'running';
@@ -60,12 +69,43 @@ export function normalizePlayRunLifecycleStatus(
60
69
  }
61
70
 
62
71
  export function isTerminalPlayRunLifecycleStatus(status: unknown): boolean {
63
- return TERMINAL_PLAY_RUN_STATUSES.has(normalizePlayRunLifecycleStatus(status));
72
+ return TERMINAL_PLAY_RUN_STATUSES.has(
73
+ normalizePlayRunLifecycleStatus(status),
74
+ );
64
75
  }
65
76
 
66
77
  export function isActivePlayRunLifecycleStatus(status: unknown): boolean {
67
78
  const normalized = normalizePlayRunLifecycleStatus(status);
68
- return normalized === 'running' || normalized === 'waiting';
79
+ return (
80
+ normalized === 'queued' ||
81
+ normalized === 'running' ||
82
+ normalized === 'waiting'
83
+ );
84
+ }
85
+
86
+ /**
87
+ * Decode a public lifecycle value without inventing progress. Internal
88
+ * termination reasons intentionally collapse to the one public cancellation
89
+ * outcome at this Adapter boundary. Unknown/missing values are invalid.
90
+ */
91
+ export function decodePlayRunPublicStatus(
92
+ value: unknown,
93
+ ): PlayRunPublicStatus | null {
94
+ const status = normalizePlayRunLifecycleStatus(value);
95
+ switch (status) {
96
+ case 'queued':
97
+ case 'running':
98
+ case 'waiting':
99
+ case 'completed':
100
+ case 'failed':
101
+ case 'cancelled':
102
+ return status;
103
+ case 'terminated':
104
+ case 'timed_out':
105
+ return 'cancelled';
106
+ case 'unknown':
107
+ return null;
108
+ }
69
109
  }
70
110
 
71
111
  export function isRecoverableDatasetRowStatus(status: unknown): boolean {
package/dist/cli/index.js CHANGED
@@ -718,7 +718,7 @@ var SDK_RELEASE = {
718
718
  // 0.1.253 makes play-page browser opening opt-in and retires --no-open.
719
719
  // 0.1.254 removes the internal operations tree from the published SDK CLI.
720
720
  // Operators use the checkout-local deepline-admin binary instead.
721
- version: "0.1.298",
721
+ version: "0.1.299",
722
722
  contracts: {
723
723
  api: {
724
724
  name: "sdk-http-api",
@@ -2113,7 +2113,7 @@ function normalizePlayRunLifecycleStatus(value) {
2113
2113
  switch (normalized) {
2114
2114
  case "queued":
2115
2115
  case "pending":
2116
- return "running";
2116
+ return "queued";
2117
2117
  case "running":
2118
2118
  case "started":
2119
2119
  return "running";
@@ -2139,7 +2139,26 @@ function normalizePlayRunLifecycleStatus(value) {
2139
2139
  }
2140
2140
  }
2141
2141
  function isTerminalPlayRunLifecycleStatus(status) {
2142
- return TERMINAL_PLAY_RUN_STATUSES.has(normalizePlayRunLifecycleStatus(status));
2142
+ return TERMINAL_PLAY_RUN_STATUSES.has(
2143
+ normalizePlayRunLifecycleStatus(status)
2144
+ );
2145
+ }
2146
+ function decodePlayRunPublicStatus(value) {
2147
+ const status = normalizePlayRunLifecycleStatus(value);
2148
+ switch (status) {
2149
+ case "queued":
2150
+ case "running":
2151
+ case "waiting":
2152
+ case "completed":
2153
+ case "failed":
2154
+ case "cancelled":
2155
+ return status;
2156
+ case "terminated":
2157
+ case "timed_out":
2158
+ return "cancelled";
2159
+ case "unknown":
2160
+ return null;
2161
+ }
2143
2162
  }
2144
2163
 
2145
2164
  // ../shared_libs/play-runtime/run-snapshot-stream.ts
@@ -3080,7 +3099,13 @@ function isPlayRunPackage(value) {
3080
3099
  function normalizePlayStatus(raw) {
3081
3100
  const runPackage = isPlayRunPackage(raw) ? raw : isPlayRunPackage(raw.package) ? raw.package : null;
3082
3101
  const packageRun = runPackage?.run;
3083
- const status = typeof raw.status === "string" ? raw.status : typeof packageRun?.status === "string" ? packageRun.status : "running";
3102
+ const rawStatus = typeof raw.status === "string" ? raw.status : typeof packageRun?.status === "string" ? packageRun.status : null;
3103
+ const status = decodePlayRunPublicStatus(rawStatus);
3104
+ if (!status) {
3105
+ throw new Error(
3106
+ `Invalid play run lifecycle status in API response: ${JSON.stringify(rawStatus)}.`
3107
+ );
3108
+ }
3084
3109
  const runId = typeof raw.runId === "string" ? raw.runId : typeof raw.workflowId === "string" ? raw.workflowId : packageRun?.id ?? "";
3085
3110
  return {
3086
3111
  ...raw,
@@ -703,7 +703,7 @@ var SDK_RELEASE = {
703
703
  // 0.1.253 makes play-page browser opening opt-in and retires --no-open.
704
704
  // 0.1.254 removes the internal operations tree from the published SDK CLI.
705
705
  // Operators use the checkout-local deepline-admin binary instead.
706
- version: "0.1.298",
706
+ version: "0.1.299",
707
707
  contracts: {
708
708
  api: {
709
709
  name: "sdk-http-api",
@@ -2098,7 +2098,7 @@ function normalizePlayRunLifecycleStatus(value) {
2098
2098
  switch (normalized) {
2099
2099
  case "queued":
2100
2100
  case "pending":
2101
- return "running";
2101
+ return "queued";
2102
2102
  case "running":
2103
2103
  case "started":
2104
2104
  return "running";
@@ -2124,7 +2124,26 @@ function normalizePlayRunLifecycleStatus(value) {
2124
2124
  }
2125
2125
  }
2126
2126
  function isTerminalPlayRunLifecycleStatus(status) {
2127
- return TERMINAL_PLAY_RUN_STATUSES.has(normalizePlayRunLifecycleStatus(status));
2127
+ return TERMINAL_PLAY_RUN_STATUSES.has(
2128
+ normalizePlayRunLifecycleStatus(status)
2129
+ );
2130
+ }
2131
+ function decodePlayRunPublicStatus(value) {
2132
+ const status = normalizePlayRunLifecycleStatus(value);
2133
+ switch (status) {
2134
+ case "queued":
2135
+ case "running":
2136
+ case "waiting":
2137
+ case "completed":
2138
+ case "failed":
2139
+ case "cancelled":
2140
+ return status;
2141
+ case "terminated":
2142
+ case "timed_out":
2143
+ return "cancelled";
2144
+ case "unknown":
2145
+ return null;
2146
+ }
2128
2147
  }
2129
2148
 
2130
2149
  // ../shared_libs/play-runtime/run-snapshot-stream.ts
@@ -3065,7 +3084,13 @@ function isPlayRunPackage(value) {
3065
3084
  function normalizePlayStatus(raw) {
3066
3085
  const runPackage = isPlayRunPackage(raw) ? raw : isPlayRunPackage(raw.package) ? raw.package : null;
3067
3086
  const packageRun = runPackage?.run;
3068
- const status = typeof raw.status === "string" ? raw.status : typeof packageRun?.status === "string" ? packageRun.status : "running";
3087
+ const rawStatus = typeof raw.status === "string" ? raw.status : typeof packageRun?.status === "string" ? packageRun.status : null;
3088
+ const status = decodePlayRunPublicStatus(rawStatus);
3089
+ if (!status) {
3090
+ throw new Error(
3091
+ `Invalid play run lifecycle status in API response: ${JSON.stringify(rawStatus)}.`
3092
+ );
3093
+ }
3069
3094
  const runId = typeof raw.runId === "string" ? raw.runId : typeof raw.workflowId === "string" ? raw.workflowId : packageRun?.id ?? "";
3070
3095
  return {
3071
3096
  ...raw,
package/dist/index.js CHANGED
@@ -438,7 +438,7 @@ var SDK_RELEASE = {
438
438
  // 0.1.253 makes play-page browser opening opt-in and retires --no-open.
439
439
  // 0.1.254 removes the internal operations tree from the published SDK CLI.
440
440
  // Operators use the checkout-local deepline-admin binary instead.
441
- version: "0.1.298",
441
+ version: "0.1.299",
442
442
  contracts: {
443
443
  api: {
444
444
  name: "sdk-http-api",
@@ -1833,7 +1833,7 @@ function normalizePlayRunLifecycleStatus(value) {
1833
1833
  switch (normalized) {
1834
1834
  case "queued":
1835
1835
  case "pending":
1836
- return "running";
1836
+ return "queued";
1837
1837
  case "running":
1838
1838
  case "started":
1839
1839
  return "running";
@@ -1859,7 +1859,26 @@ function normalizePlayRunLifecycleStatus(value) {
1859
1859
  }
1860
1860
  }
1861
1861
  function isTerminalPlayRunLifecycleStatus(status) {
1862
- return TERMINAL_PLAY_RUN_STATUSES.has(normalizePlayRunLifecycleStatus(status));
1862
+ return TERMINAL_PLAY_RUN_STATUSES.has(
1863
+ normalizePlayRunLifecycleStatus(status)
1864
+ );
1865
+ }
1866
+ function decodePlayRunPublicStatus(value) {
1867
+ const status = normalizePlayRunLifecycleStatus(value);
1868
+ switch (status) {
1869
+ case "queued":
1870
+ case "running":
1871
+ case "waiting":
1872
+ case "completed":
1873
+ case "failed":
1874
+ case "cancelled":
1875
+ return status;
1876
+ case "terminated":
1877
+ case "timed_out":
1878
+ return "cancelled";
1879
+ case "unknown":
1880
+ return null;
1881
+ }
1863
1882
  }
1864
1883
 
1865
1884
  // ../shared_libs/play-runtime/run-snapshot-stream.ts
@@ -2800,7 +2819,13 @@ function isPlayRunPackage(value) {
2800
2819
  function normalizePlayStatus(raw) {
2801
2820
  const runPackage = isPlayRunPackage(raw) ? raw : isPlayRunPackage(raw.package) ? raw.package : null;
2802
2821
  const packageRun = runPackage?.run;
2803
- const status = typeof raw.status === "string" ? raw.status : typeof packageRun?.status === "string" ? packageRun.status : "running";
2822
+ const rawStatus = typeof raw.status === "string" ? raw.status : typeof packageRun?.status === "string" ? packageRun.status : null;
2823
+ const status = decodePlayRunPublicStatus(rawStatus);
2824
+ if (!status) {
2825
+ throw new Error(
2826
+ `Invalid play run lifecycle status in API response: ${JSON.stringify(rawStatus)}.`
2827
+ );
2828
+ }
2804
2829
  const runId = typeof raw.runId === "string" ? raw.runId : typeof raw.workflowId === "string" ? raw.workflowId : packageRun?.id ?? "";
2805
2830
  return {
2806
2831
  ...raw,
package/dist/index.mjs CHANGED
@@ -367,7 +367,7 @@ var SDK_RELEASE = {
367
367
  // 0.1.253 makes play-page browser opening opt-in and retires --no-open.
368
368
  // 0.1.254 removes the internal operations tree from the published SDK CLI.
369
369
  // Operators use the checkout-local deepline-admin binary instead.
370
- version: "0.1.298",
370
+ version: "0.1.299",
371
371
  contracts: {
372
372
  api: {
373
373
  name: "sdk-http-api",
@@ -1762,7 +1762,7 @@ function normalizePlayRunLifecycleStatus(value) {
1762
1762
  switch (normalized) {
1763
1763
  case "queued":
1764
1764
  case "pending":
1765
- return "running";
1765
+ return "queued";
1766
1766
  case "running":
1767
1767
  case "started":
1768
1768
  return "running";
@@ -1788,7 +1788,26 @@ function normalizePlayRunLifecycleStatus(value) {
1788
1788
  }
1789
1789
  }
1790
1790
  function isTerminalPlayRunLifecycleStatus(status) {
1791
- return TERMINAL_PLAY_RUN_STATUSES.has(normalizePlayRunLifecycleStatus(status));
1791
+ return TERMINAL_PLAY_RUN_STATUSES.has(
1792
+ normalizePlayRunLifecycleStatus(status)
1793
+ );
1794
+ }
1795
+ function decodePlayRunPublicStatus(value) {
1796
+ const status = normalizePlayRunLifecycleStatus(value);
1797
+ switch (status) {
1798
+ case "queued":
1799
+ case "running":
1800
+ case "waiting":
1801
+ case "completed":
1802
+ case "failed":
1803
+ case "cancelled":
1804
+ return status;
1805
+ case "terminated":
1806
+ case "timed_out":
1807
+ return "cancelled";
1808
+ case "unknown":
1809
+ return null;
1810
+ }
1792
1811
  }
1793
1812
 
1794
1813
  // ../shared_libs/play-runtime/run-snapshot-stream.ts
@@ -2729,7 +2748,13 @@ function isPlayRunPackage(value) {
2729
2748
  function normalizePlayStatus(raw) {
2730
2749
  const runPackage = isPlayRunPackage(raw) ? raw : isPlayRunPackage(raw.package) ? raw.package : null;
2731
2750
  const packageRun = runPackage?.run;
2732
- const status = typeof raw.status === "string" ? raw.status : typeof packageRun?.status === "string" ? packageRun.status : "running";
2751
+ const rawStatus = typeof raw.status === "string" ? raw.status : typeof packageRun?.status === "string" ? packageRun.status : null;
2752
+ const status = decodePlayRunPublicStatus(rawStatus);
2753
+ if (!status) {
2754
+ throw new Error(
2755
+ `Invalid play run lifecycle status in API response: ${JSON.stringify(rawStatus)}.`
2756
+ );
2757
+ }
2733
2758
  const runId = typeof raw.runId === "string" ? raw.runId : typeof raw.workflowId === "string" ? raw.workflowId : packageRun?.id ?? "";
2734
2759
  return {
2735
2760
  ...raw,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.1.298",
3
+ "version": "0.1.299",
4
4
  "description": "Deepline SDK + CLI — B2B data enrichment powered by durable cloud execution",
5
5
  "license": "MIT",
6
6
  "repository": {