deepline 0.1.227 → 0.1.229

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.
Files changed (46) hide show
  1. package/dist/bundling-sources/apps/play-runner-workers/src/coordinator-entry.ts +76 -1842
  2. package/dist/bundling-sources/apps/play-runner-workers/src/dedup-do.ts +0 -113
  3. package/dist/bundling-sources/apps/play-runner-workers/src/entry.ts +144 -1000
  4. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/ledger-event-batches.ts +81 -0
  5. package/dist/bundling-sources/apps/play-runner-workers/src/workflow-retry-state.ts +1 -50
  6. package/dist/bundling-sources/sdk/src/client.ts +24 -2
  7. package/dist/bundling-sources/sdk/src/play.ts +2 -2
  8. package/dist/bundling-sources/sdk/src/release.ts +2 -2
  9. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +382 -31
  10. package/dist/bundling-sources/shared_libs/play-runtime/child-execution-strategy.ts +84 -79
  11. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +201 -705
  12. package/dist/bundling-sources/shared_libs/play-runtime/coordinator-headers.ts +3 -10
  13. package/dist/bundling-sources/shared_libs/play-runtime/ctx-contract.ts +2 -2
  14. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +12 -47
  15. package/dist/bundling-sources/shared_libs/play-runtime/governor/block-reserving-budget-state-backend.ts +0 -2
  16. package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +12 -200
  17. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +2 -17
  18. package/dist/bundling-sources/shared_libs/play-runtime/live-state-contract.ts +3 -9
  19. package/dist/bundling-sources/shared_libs/play-runtime/play-call-execution.ts +6 -1
  20. package/dist/bundling-sources/shared_libs/play-runtime/play-latency-trace.ts +28 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/run-execution-scope.ts +16 -64
  22. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +26 -0
  23. package/dist/bundling-sources/shared_libs/play-runtime/run-lifecycle-policy.ts +5 -2
  24. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-paths.ts +0 -4
  25. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +81 -18
  26. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +0 -36
  27. package/dist/bundling-sources/shared_libs/play-runtime/suspension.ts +3 -21
  28. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +9 -1
  29. package/dist/bundling-sources/shared_libs/play-runtime/transport-error-diagnostics.ts +63 -0
  30. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +2 -0
  31. package/dist/cli/index.js +78 -11
  32. package/dist/cli/index.mjs +78 -11
  33. package/dist/{compiler-manifest-BhgZ23A4.d.ts → compiler-manifest-CYcwzSOJ.d.mts} +2 -0
  34. package/dist/{compiler-manifest-BhgZ23A4.d.mts → compiler-manifest-CYcwzSOJ.d.ts} +2 -0
  35. package/dist/index.d.mts +3 -3
  36. package/dist/index.d.ts +3 -3
  37. package/dist/index.js +14 -5
  38. package/dist/index.mjs +14 -5
  39. package/dist/plays/bundle-play-file.d.mts +2 -2
  40. package/dist/plays/bundle-play-file.d.ts +2 -2
  41. package/package.json +1 -1
  42. package/dist/bundling-sources/apps/play-runner-workers/src/child-manifest-resolver.ts +0 -108
  43. package/dist/bundling-sources/apps/play-runner-workers/src/child-play-await.ts +0 -374
  44. package/dist/bundling-sources/apps/play-runner-workers/src/child-play-submit.ts +0 -203
  45. package/dist/bundling-sources/shared_libs/play-runtime/child-execution-placement.ts +0 -14
  46. package/dist/bundling-sources/shared_libs/play-runtime/child-run-id.ts +0 -121
@@ -3,101 +3,106 @@ import {
3
3
  type PlayStaticPipeline,
4
4
  } from '../plays/static-pipeline';
5
5
  import type { PlayCallExecution } from './play-call-execution';
6
- import { resolveChildExecutionPlacement } from './child-execution-placement';
7
6
 
8
- export type ChildExecutionStrategy = 'inline' | 'scheduled';
7
+ /**
8
+ * `ctx.runPlay` is function composition. It has exactly one execution
9
+ * placement: inline in the caller's run. Do not add a scheduler fallback
10
+ * here: children that need their own run lifecycle must be top-level plays.
11
+ */
12
+ export type ChildExecutionStrategy = 'inline';
9
13
 
10
14
  export type ChildExecutionDecision = {
11
15
  strategy: ChildExecutionStrategy;
12
- reason:
13
- | 'scalar_child'
14
- | 'missing_static_contract'
15
- | 'dataset_child'
16
- | 'event_wait_child'
17
- | 'explicit_timeout'
18
- | 'explicit_inline'
19
- | 'explicit_child_workflow';
16
+ reason: 'scalar_child' | 'explicit_inline';
20
17
  };
21
18
 
19
+ export type CtxRunPlayInlineOnlyReason =
20
+ | 'missing_static_contract'
21
+ | 'dataset_child'
22
+ | 'event_wait_child'
23
+ | 'suspending_child'
24
+ | 'explicit_timeout'
25
+ | 'explicit_child_workflow';
26
+
27
+ /** Stable machine-readable prefix for every rejected ctx.runPlay shape. */
28
+ export const CTX_RUN_PLAY_INLINE_ONLY = 'CTX_RUN_PLAY_INLINE_ONLY';
29
+
30
+ /**
31
+ * One public error for every unsupported child contract. The checker and
32
+ * runtime deliberately call this same helper so a dynamic child fails with
33
+ * the same actionable error as a statically known child.
34
+ */
35
+ export function ctxRunPlayInlineOnlyMessage(
36
+ childPlayName: string,
37
+ reason: CtxRunPlayInlineOnlyReason,
38
+ ): string {
39
+ const detail: Record<CtxRunPlayInlineOnlyReason, string> = {
40
+ missing_static_contract: 'its static contract could not be resolved',
41
+ dataset_child: 'it uses ctx.dataset(), ctx.csv(), or a Runtime Sheet',
42
+ event_wait_child: 'it waits for an event',
43
+ suspending_child: 'it attempted to suspend the parent execution',
44
+ explicit_timeout: 'it sets an explicit timeout',
45
+ explicit_child_workflow: 'it requests execution: "child-workflow"',
46
+ };
47
+ return (
48
+ `${CTX_RUN_PLAY_INLINE_ONLY}: ctx.runPlay("${childPlayName}") only composes a resolved scalar child; ` +
49
+ `${detail[reason]}. Move that work to a top-level play and compose only the scalar result.`
50
+ );
51
+ }
52
+
22
53
  /**
23
- * Choose execution placement from the child's authored contract. Scalar child
24
- * plays are ordinary function composition. Dataset and event-wait children own
25
- * independent durable state, so they remain scheduler jobs.
54
+ * Resolve an authored child contract. Any shape that would need a second run,
55
+ * durable scheduler state, or a suspension is rejected before invocation.
26
56
  */
27
57
  export function resolveChildExecutionStrategy(input: {
28
58
  pipeline: PlayStaticPipeline | null | undefined;
29
59
  timeoutMs?: number | null;
30
- execution?: PlayCallExecution | null;
60
+ hasExplicitTimeout?: boolean;
61
+ /** `child-workflow` remains accepted as parsed legacy source solely to emit
62
+ * the canonical migration error rather than silently scheduling it. */
63
+ execution?: PlayCallExecution | 'child-workflow' | null;
31
64
  childPlayName?: string | null;
32
65
  }): ChildExecutionDecision {
66
+ const childPlayName = input.childPlayName?.trim() || 'child';
33
67
  if (input.execution === 'child-workflow') {
34
- return { strategy: 'scheduled', reason: 'explicit_child_workflow' };
68
+ throw new Error(
69
+ ctxRunPlayInlineOnlyMessage(childPlayName, 'explicit_child_workflow'),
70
+ );
35
71
  }
36
- const steps = input.pipeline ? flattenStaticPipeline(input.pipeline) : [];
37
- const authoredDecision: ChildExecutionDecision =
38
- input.timeoutMs != null
39
- ? { strategy: 'scheduled', reason: 'explicit_timeout' }
40
- : !input.pipeline
41
- ? { strategy: 'scheduled', reason: 'missing_static_contract' }
42
- : input.pipeline.tableNamespace ||
43
- input.pipeline.sheetContract ||
44
- steps.some((step) => step.type === 'dataset' || step.type === 'csv')
45
- ? { strategy: 'scheduled', reason: 'dataset_child' }
46
- : steps.some(
47
- (step) =>
48
- step.type === 'tool' &&
49
- (step.isEventWait || step.toolId === 'test_wait_for_event'),
50
- )
51
- ? { strategy: 'scheduled', reason: 'event_wait_child' }
52
- : { strategy: 'inline', reason: 'scalar_child' };
53
- if (input.execution === 'inline') {
54
- if (
55
- authoredDecision.strategy === 'scheduled' &&
56
- authoredDecision.reason !== 'missing_static_contract'
57
- ) {
58
- throw new Error(
59
- inlineExecutionRequiresScalarChildMessage(
60
- input.childPlayName?.trim() || 'child',
61
- authoredDecision.reason,
62
- ),
63
- );
64
- }
65
- return { strategy: 'inline', reason: 'explicit_inline' };
72
+ if (!input.pipeline) {
73
+ throw new Error(
74
+ ctxRunPlayInlineOnlyMessage(childPlayName, 'missing_static_contract'),
75
+ );
66
76
  }
67
- const placement = resolveChildExecutionPlacement({
68
- requiresWorkflow: authoredDecision.strategy === 'scheduled',
69
- execution: input.execution,
70
- });
71
- if (placement.strategy === 'inline') {
72
- return { strategy: 'inline', reason: 'scalar_child' };
77
+ if (input.hasExplicitTimeout === true || input.timeoutMs != null) {
78
+ throw new Error(
79
+ ctxRunPlayInlineOnlyMessage(childPlayName, 'explicit_timeout'),
80
+ );
73
81
  }
74
- return authoredDecision;
75
- }
76
82
 
77
- export function inlineExecutionRequiresScalarChildMessage(
78
- childPlayName: string,
79
- reason: ChildExecutionDecision['reason'],
80
- ): string {
81
- return (
82
- `ctx.runPlay("${childPlayName}") requested execution: "inline", but the child requires a child workflow ` +
83
- `(${reason}). Remove the explicit execution option or use execution: "child-workflow".`
84
- );
85
- }
86
-
87
- /**
88
- * Verbatim rejection message for a scheduling-required child invoked per row.
89
- * Shared by the static preflight (`plays check`/publish gate) and the runtime
90
- * launch guard so a dynamically-named child fails with the EXACT same text as a
91
- * statically-provable one. See ADR 0013.
92
- */
93
- export function inlineChildScheduledInRowMessage(
94
- childPlayName: string,
95
- rowContextField: string,
96
- ): string {
97
- return (
98
- `ctx.runPlay("${childPlayName}") runs per row in the "${rowContextField}" batch, ` +
99
- 'but it is a scheduling-required child (it uses ctx.dataset()/ctx.csv(), waits on an ' +
100
- 'event, sets an explicit timeout, or explicitly requests a child workflow). Row-scoped children must be scalar. ' +
101
- 'Give the batch ONE dataset child at play level instead of fanning a scheduled run out per row.'
102
- );
83
+ const steps = flattenStaticPipeline(input.pipeline);
84
+ if (
85
+ input.pipeline.tableNamespace ||
86
+ input.pipeline.sheetContract ||
87
+ steps.some((step) => step.type === 'dataset' || step.type === 'csv')
88
+ ) {
89
+ throw new Error(
90
+ ctxRunPlayInlineOnlyMessage(childPlayName, 'dataset_child'),
91
+ );
92
+ }
93
+ if (
94
+ steps.some(
95
+ (step) =>
96
+ step.type === 'tool' &&
97
+ (step.isEventWait || step.toolId === 'test_wait_for_event'),
98
+ )
99
+ ) {
100
+ throw new Error(
101
+ ctxRunPlayInlineOnlyMessage(childPlayName, 'event_wait_child'),
102
+ );
103
+ }
104
+ return {
105
+ strategy: 'inline',
106
+ reason: input.execution === 'inline' ? 'explicit_inline' : 'scalar_child',
107
+ };
103
108
  }