deepline 0.1.119 → 0.1.121
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/README.md +4 -0
- package/dist/bundling-sources/apps/play-runner-workers/src/runtime/README.md +21 -0
- package/dist/bundling-sources/apps/play-runner-workers/src/runtime/batching.ts +185 -0
- package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-batch.ts +107 -0
- package/dist/{repo → bundling-sources}/sdk/src/client.ts +116 -12
- package/dist/bundling-sources/sdk/src/compat.ts +191 -0
- package/dist/bundling-sources/sdk/src/gtm.ts +146 -0
- package/dist/bundling-sources/sdk/src/helpers.ts +12 -0
- package/dist/{repo → bundling-sources}/sdk/src/index.ts +2 -1
- package/dist/{repo → bundling-sources}/sdk/src/play.ts +3 -1
- package/dist/{repo → bundling-sources}/sdk/src/plays/bundle-play-file.ts +17 -5
- package/dist/{repo → bundling-sources}/sdk/src/release.ts +2 -2
- package/dist/{repo → bundling-sources}/sdk/src/runs/observe-transport.ts +2 -3
- package/dist/bundling-sources/shared_libs/play-data-plane/index.ts +3 -0
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +838 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +5510 -0
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-contract.ts +261 -0
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +828 -0
- package/dist/bundling-sources/shared_libs/play-runtime/dataset-id.ts +10 -0
- package/dist/bundling-sources/shared_libs/play-runtime/daytona-runtime-config.ts +50 -0
- package/dist/bundling-sources/shared_libs/play-runtime/durability-store.ts +20 -0
- package/dist/bundling-sources/shared_libs/play-runtime/event-wait-tools.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-runtime/governor/in-memory-rate-state-backend.ts +171 -0
- package/dist/bundling-sources/shared_libs/play-runtime/hatchet-cold-execution-diagnosis.ts +321 -0
- package/dist/bundling-sources/shared_libs/play-runtime/hatchet-cold-execution-target.ts +158 -0
- package/dist/bundling-sources/shared_libs/play-runtime/internal-step-ids.ts +34 -0
- package/dist/bundling-sources/shared_libs/play-runtime/ledger-safe-payload.ts +34 -0
- package/dist/bundling-sources/shared_libs/play-runtime/live-state-contract.ts +50 -0
- package/dist/bundling-sources/shared_libs/play-runtime/map-execution-frame.ts +119 -0
- package/dist/{repo → bundling-sources}/shared_libs/play-runtime/map-row-identity.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/play-latency-trace.ts +636 -0
- package/dist/bundling-sources/shared_libs/play-runtime/postgres-json.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-runtime/progress-emitter.ts +197 -0
- package/dist/bundling-sources/shared_libs/play-runtime/projection.ts +262 -0
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +143 -0
- package/dist/bundling-sources/shared_libs/play-runtime/public-play-contract.ts +42 -0
- package/dist/bundling-sources/shared_libs/play-runtime/receipt-status.ts +40 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-actions.ts +178 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +4015 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-constraints.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-pg-driver-neon-serverless.ts +238 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-pg-driver-pg.ts +53 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-pg-driver.ts +149 -0
- package/dist/bundling-sources/shared_libs/play-runtime/suspension.ts +68 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-batch-executor.ts +149 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result-types.ts +159 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tracing.ts +33 -0
- package/dist/bundling-sources/shared_libs/play-runtime/waterfall-replay.ts +79 -0
- package/dist/bundling-sources/shared_libs/play-runtime/worker-api-types.ts +139 -0
- package/dist/bundling-sources/shared_libs/plays/artifact-transport.ts +14 -0
- package/dist/bundling-sources/shared_libs/plays/artifact-types.ts +49 -0
- package/dist/bundling-sources/shared_libs/plays/compiler-manifest.ts +41 -0
- package/dist/bundling-sources/shared_libs/plays/dataset-summary.ts +163 -0
- package/dist/bundling-sources/shared_libs/plays/definition.ts +267 -0
- package/dist/bundling-sources/shared_libs/plays/file-refs.ts +11 -0
- package/dist/bundling-sources/shared_libs/plays/input-contract.ts +146 -0
- package/dist/bundling-sources/shared_libs/plays/resolve-static-pipeline.ts +190 -0
- package/dist/bundling-sources/shared_libs/plays/runtime-validation.ts +417 -0
- package/dist/bundling-sources/shared_libs/plays/tool-codegen.ts +142 -0
- package/dist/bundling-sources/shared_libs/security/safe-outbound-fetch.ts +274 -0
- package/dist/bundling-sources/shared_libs/temporal/preview-config.ts +150 -0
- package/dist/cli/index.js +811 -2207
- package/dist/cli/index.mjs +847 -2258
- package/dist/compiler-manifest-BjoRENv9.d.mts +227 -0
- package/dist/compiler-manifest-BjoRENv9.d.ts +227 -0
- package/dist/index.d.mts +8 -231
- package/dist/index.d.ts +8 -231
- package/dist/index.js +101 -15
- package/dist/index.mjs +101 -15
- package/dist/plays/bundle-play-file.d.mts +120 -0
- package/dist/plays/bundle-play-file.d.ts +120 -0
- package/dist/plays/bundle-play-file.mjs +1830 -0
- package/package.json +4 -9
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/child-play-await.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/child-play-submit.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/coordinator-entry.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/dedup-do.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/entry.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/runtime/csv-rows.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/runtime/dataset-handles.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/runtime/harness-receipt-store.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/runtime/live-progress.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/runtime/map-chunk-plan.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/runtime/receipts.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/runtime/row-isolation.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/runtime/tool-http-errors.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/workflow-instance-create.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/workflow-retry-state.ts +0 -0
- /package/dist/{repo → bundling-sources}/apps/play-runner-workers/src/workflow-retry.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/agent-runtime.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/config.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/errors.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/http.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/plays/harness-stub.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/plays/local-file-discovery.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/stream-reconnect.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/tool-output.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/types.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/version.ts +0 -0
- /package/dist/{repo → bundling-sources}/sdk/src/worker-play-entry.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-data-plane/cell-policy.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-data-plane/column-names.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-data-plane/sheet-contract.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/backend.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/batch-runtime.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/batching-types.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/cell-staleness.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/coordinator-headers.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/csv-rename.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/db-session-crypto.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/db-session-plan.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/db-session.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/dedup-backend.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/default-batch-strategies.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/email-status.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/execution-plan.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/extractor-targets.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/fullenrich-batching.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/governor/coordinator-rate-state-backend.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/governor/governor.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/governor/policy.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/governor/rate-state-backend.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/live-events.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/play-runtime-batching-registry.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/profiles.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/providers.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/run-failure.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/run-ledger.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/run-snapshot-stream.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/scheduler-backend.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/secret-capability.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/secret-redaction.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/step-lifecycle-tracker.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/step-program-dataset-builder.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/submit-limits.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/tool-result.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/play-runtime/work-receipts.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/plays/bootstrap-routes.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/plays/bundling/index.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/plays/bundling/limits.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/plays/contracts.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/plays/dataset.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/plays/row-identity.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/plays/secret-guardrails.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/plays/static-pipeline.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/security/outbound-url-policy.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/security/safe-fetch.ts +0 -0
- /package/dist/{repo → bundling-sources}/shared_libs/temporal/constants.ts +0 -0
|
@@ -0,0 +1,636 @@
|
|
|
1
|
+
import { HATCHET_COLD_EXECUTION_PHASE_DEFINITIONS } from './hatchet-cold-execution-target';
|
|
2
|
+
|
|
3
|
+
export type PlayLatencyPhaseDefinition = {
|
|
4
|
+
header: string;
|
|
5
|
+
phase: string;
|
|
6
|
+
source?: string;
|
|
7
|
+
description: string;
|
|
8
|
+
includeInDominantPhase?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type PlayLatencyObservation = {
|
|
12
|
+
ts?: number | null;
|
|
13
|
+
source: string;
|
|
14
|
+
runId?: string | null;
|
|
15
|
+
playLabel?: string | null;
|
|
16
|
+
phase: string;
|
|
17
|
+
ms?: number | null;
|
|
18
|
+
ok?: boolean | null;
|
|
19
|
+
status?: string | null;
|
|
20
|
+
graphHash?: string | null;
|
|
21
|
+
extra?: Record<string, unknown>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type PlayLatencyPhase = PlayLatencyPhaseDefinition & {
|
|
25
|
+
ms: number | null;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type PlayLatencyTrace = {
|
|
29
|
+
runId: string | null;
|
|
30
|
+
playLabel: string | null;
|
|
31
|
+
status: string | null;
|
|
32
|
+
ok: boolean | null;
|
|
33
|
+
phaseMs: Record<string, number>;
|
|
34
|
+
phases: PlayLatencyPhase[];
|
|
35
|
+
dominantPhase: PlayLatencyPhase | null;
|
|
36
|
+
observations: PlayLatencyObservation[];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const PLAY_LATENCY_SUMMARY_COLUMNS: PlayLatencyPhaseDefinition[] = [
|
|
40
|
+
{
|
|
41
|
+
header: 'wall',
|
|
42
|
+
phase: 'runner.wall',
|
|
43
|
+
source: 'runner',
|
|
44
|
+
description:
|
|
45
|
+
'Measured play execution window only: CLI invoke, stream/tail, and assertions. Pre-run setup is excluded.',
|
|
46
|
+
includeInDominantPhase: false,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
header: 'setup_reset',
|
|
50
|
+
phase: 'setup.reset',
|
|
51
|
+
source: 'setup',
|
|
52
|
+
description:
|
|
53
|
+
'Pre-run history/table cleanup. This is setup time, not play execution time.',
|
|
54
|
+
includeInDominantPhase: false,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
header: 'command',
|
|
58
|
+
phase: 'runner.command',
|
|
59
|
+
source: 'runner',
|
|
60
|
+
description: 'Runner-side CLI command wall time.',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
header: 'assert_status',
|
|
64
|
+
phase: 'runner.fetchAssertionStatus',
|
|
65
|
+
source: 'runner',
|
|
66
|
+
description:
|
|
67
|
+
'Runner-side post-run status fetch used by completed-run assertions.',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
header: 'assertions',
|
|
71
|
+
phase: 'runner.completedAssertions',
|
|
72
|
+
source: 'runner',
|
|
73
|
+
description: 'Runner-side completed-run assertion checks.',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
header: 'submit',
|
|
77
|
+
phase: 'server.total',
|
|
78
|
+
source: 'server',
|
|
79
|
+
description: 'POST /api/v2/plays/run end-to-end on the app server.',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
header: 'start_stream',
|
|
83
|
+
phase: 'server.start_stream_start_run',
|
|
84
|
+
source: 'server',
|
|
85
|
+
description:
|
|
86
|
+
'Streamed start route from request handling through startPlayRunForAuth.',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
header: 'fast_terminal',
|
|
90
|
+
phase: 'server.start_stream_fast_terminal',
|
|
91
|
+
source: 'server',
|
|
92
|
+
description:
|
|
93
|
+
'Streamed start route emitting terminal status without scheduler attach.',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
header: 'route_inputs',
|
|
97
|
+
phase: 'server.start_route_prepare_inputs',
|
|
98
|
+
source: 'server',
|
|
99
|
+
description:
|
|
100
|
+
'Start route artifact preparation, preflight, and input file staging.',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
header: 'route_resolve',
|
|
104
|
+
phase: 'server.start_route_resolve_named_play',
|
|
105
|
+
source: 'server',
|
|
106
|
+
description: 'Start route named play revision resolution.',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
header: 'route_child',
|
|
110
|
+
phase: 'server.start_route_resolve_child_manifests',
|
|
111
|
+
source: 'server',
|
|
112
|
+
description: 'Start route child play manifest resolution for workers_edge.',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
header: 'route_active',
|
|
116
|
+
phase: 'server.start_route_active_run_check',
|
|
117
|
+
source: 'server',
|
|
118
|
+
description: 'Start route active-run checks for guarded child play calls.',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
header: 'route_exec',
|
|
122
|
+
phase: 'server.start_route_start_execution',
|
|
123
|
+
source: 'server',
|
|
124
|
+
description:
|
|
125
|
+
'Start route call into startPlayRunExecution, including validation, persistence, and scheduler submit.',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
header: 'route_ready',
|
|
129
|
+
phase: 'server.start_route_runtime_data_plane_ready',
|
|
130
|
+
source: 'server',
|
|
131
|
+
description:
|
|
132
|
+
'Start route Runtime Sheet Data Plane readiness check; active tenants use the cached or record fast path, new tenants may provision here.',
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
header: 'route_wait',
|
|
136
|
+
phase: 'server.start_route_wait_completion',
|
|
137
|
+
source: 'server',
|
|
138
|
+
description: 'Start route bounded wait for a terminal result.',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
header: 'route_total',
|
|
142
|
+
phase: 'server.start_route_total',
|
|
143
|
+
source: 'server',
|
|
144
|
+
description:
|
|
145
|
+
'Start route total time from auth/body normalization to outcome.',
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
header: 'validate',
|
|
149
|
+
phase: 'server.validate_before_run_total',
|
|
150
|
+
source: 'server',
|
|
151
|
+
description: 'Server-side play validation and artifact preflight.',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
header: 'exec_validate',
|
|
155
|
+
phase: 'server.start_execution_validate',
|
|
156
|
+
source: 'server',
|
|
157
|
+
description: 'startPlayRunExecution validation phase.',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
header: 'callback',
|
|
161
|
+
phase: 'server.start_execution_callback_health',
|
|
162
|
+
source: 'server',
|
|
163
|
+
description: 'Callback URL health check before launching remote runtime.',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
header: 'authority',
|
|
167
|
+
phase: 'server.start_execution_mint_authority',
|
|
168
|
+
source: 'server',
|
|
169
|
+
description: 'Executor token and runtime authority minting.',
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
header: 'session_preload',
|
|
173
|
+
phase: 'server.preload_runtime_sheet_sessions',
|
|
174
|
+
source: 'server',
|
|
175
|
+
description: 'Scoped runtime DB session mint/encrypt preload.',
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
header: 'preload_wait',
|
|
179
|
+
phase: 'server.start_execution_preload_wait',
|
|
180
|
+
source: 'server',
|
|
181
|
+
description: 'Wait for runtime DB session preload before run persistence.',
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
header: 'persist',
|
|
185
|
+
phase: 'server.persist',
|
|
186
|
+
source: 'server',
|
|
187
|
+
description: 'Initial durable run persistence.',
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
header: 'sched_submit',
|
|
191
|
+
phase: 'server.scheduler_submit',
|
|
192
|
+
source: 'server',
|
|
193
|
+
description: 'Server to coordinator submit round trip.',
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
header: 'stream_attach',
|
|
197
|
+
phase: 'server.stream_scheduler_attach',
|
|
198
|
+
source: 'server',
|
|
199
|
+
description: 'Server attach to scheduler observer after start.',
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
header: 'stream_term',
|
|
203
|
+
phase: 'server.stream_scheduler_terminal_event',
|
|
204
|
+
source: 'server',
|
|
205
|
+
description: 'Scheduler observer wait until terminal coordinator event.',
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
header: 'term_snapshot',
|
|
209
|
+
phase: 'server.stream_terminal_snapshot_query',
|
|
210
|
+
source: 'server',
|
|
211
|
+
description: 'Canonical terminal snapshot lookup after scheduler terminal.',
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
header: 'term_append',
|
|
215
|
+
phase: 'server.stream_terminal_append_transport',
|
|
216
|
+
source: 'server',
|
|
217
|
+
description:
|
|
218
|
+
'Transport terminal event append when Convex has not converged.',
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
header: 'coord_submit',
|
|
222
|
+
phase: 'coordinator.submit_total',
|
|
223
|
+
source: 'coordinator',
|
|
224
|
+
description: 'Coordinator submit route total.',
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
header: 'dispatch_entry',
|
|
228
|
+
phase: 'coordinator.dispatch_get_entrypoint',
|
|
229
|
+
source: 'coordinator',
|
|
230
|
+
description:
|
|
231
|
+
'Coordinator Durable Object entrypoint lookup before dynamic start.',
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
header: 'dynamic_start',
|
|
235
|
+
phase: 'coordinator.dynamic_start_fetch',
|
|
236
|
+
source: 'coordinator',
|
|
237
|
+
description: 'Coordinator fetch to dynamic worker /start.',
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
header: 'workflow_create',
|
|
241
|
+
phase: 'coordinator.workflow_create',
|
|
242
|
+
source: 'coordinator',
|
|
243
|
+
description: 'Coordinator call that creates the Cloudflare Workflow run.',
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
header: 'start_gap',
|
|
247
|
+
phase: 'coordinator.workflow_start_gap',
|
|
248
|
+
source: 'coordinator',
|
|
249
|
+
description:
|
|
250
|
+
'Delay after coordinator submit begins before Cloudflare enters the Workflow run.',
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
header: 'post_create_gap',
|
|
254
|
+
phase: 'coordinator.workflow_post_create_start_gap',
|
|
255
|
+
source: 'coordinator',
|
|
256
|
+
description:
|
|
257
|
+
'Delay after Cloudflare Workflow create returns before Workflow user code starts.',
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
header: 'start_drain',
|
|
261
|
+
phase: 'coordinator.dynamic_start_response_drain',
|
|
262
|
+
source: 'coordinator',
|
|
263
|
+
description:
|
|
264
|
+
'Coordinator time spent reading the dynamic worker /start response body.',
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
header: 'coord_dispatch',
|
|
268
|
+
phase: 'coordinator.dispatch_workflow',
|
|
269
|
+
source: 'coordinator',
|
|
270
|
+
description: 'Coordinator dispatch to workflow start.',
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
header: 'status_read',
|
|
274
|
+
phase: 'coordinator.submit_status_read',
|
|
275
|
+
source: 'coordinator',
|
|
276
|
+
description: 'Coordinator Workflow status read after submit.',
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
header: 'loader_compile',
|
|
280
|
+
phase: 'coordinator.loader_compile',
|
|
281
|
+
source: 'coordinator',
|
|
282
|
+
description: 'Worker Loader bundle compile or cache-hit span.',
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
header: 'runner_run',
|
|
286
|
+
phase: 'coordinator.runner_run',
|
|
287
|
+
source: 'coordinator',
|
|
288
|
+
description: 'Inner play runner execution on the dynamic Worker.',
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
header: 'wall_minus_runner',
|
|
292
|
+
phase: 'derived.wall_minus_coordinator_runner_run',
|
|
293
|
+
source: 'derived',
|
|
294
|
+
description:
|
|
295
|
+
'Runner wall time not explained by inner coordinator.runner_run.',
|
|
296
|
+
},
|
|
297
|
+
...HATCHET_COLD_EXECUTION_PHASE_DEFINITIONS,
|
|
298
|
+
];
|
|
299
|
+
|
|
300
|
+
const PHASE_DEFINITION_BY_KEY = new Map(
|
|
301
|
+
PLAY_LATENCY_SUMMARY_COLUMNS.map((definition) => [
|
|
302
|
+
definition.phase,
|
|
303
|
+
definition,
|
|
304
|
+
]),
|
|
305
|
+
);
|
|
306
|
+
|
|
307
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
308
|
+
return Boolean(value && typeof value === 'object' && !Array.isArray(value));
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function finiteNumber(value: unknown): number | null {
|
|
312
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : null;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function nullableString(value: unknown): string | null {
|
|
316
|
+
return typeof value === 'string' && value.trim() ? value.trim() : null;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function sourceForPhase(phase: string): string {
|
|
320
|
+
const definition = PHASE_DEFINITION_BY_KEY.get(phase);
|
|
321
|
+
if (definition?.source) {
|
|
322
|
+
return definition.source;
|
|
323
|
+
}
|
|
324
|
+
const prefix = phase.split('.')[0]?.trim();
|
|
325
|
+
return prefix || 'unknown';
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export function formatPlayLatencyMs(value: number | null | undefined): string {
|
|
329
|
+
if (value === null || value === undefined || !Number.isFinite(value)) {
|
|
330
|
+
return 'n/a';
|
|
331
|
+
}
|
|
332
|
+
return `${Math.round(value)}ms`;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export function normalizePlayLatencyObservation(
|
|
336
|
+
value: unknown,
|
|
337
|
+
): PlayLatencyObservation | null {
|
|
338
|
+
if (!isRecord(value)) {
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
const phase = nullableString(value.phase);
|
|
342
|
+
if (!phase) {
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
const source = nullableString(value.source) ?? sourceForPhase(phase);
|
|
346
|
+
return {
|
|
347
|
+
ts: finiteNumber(value.ts),
|
|
348
|
+
source,
|
|
349
|
+
runId: nullableString(value.runId),
|
|
350
|
+
playLabel: nullableString(value.playLabel),
|
|
351
|
+
phase,
|
|
352
|
+
ms: finiteNumber(value.ms),
|
|
353
|
+
ok: typeof value.ok === 'boolean' ? value.ok : null,
|
|
354
|
+
status: nullableString(value.status),
|
|
355
|
+
graphHash: nullableString(value.graphHash),
|
|
356
|
+
extra: Object.fromEntries(
|
|
357
|
+
Object.entries(value).filter(
|
|
358
|
+
([key]) =>
|
|
359
|
+
![
|
|
360
|
+
'ts',
|
|
361
|
+
'source',
|
|
362
|
+
'runId',
|
|
363
|
+
'playLabel',
|
|
364
|
+
'phase',
|
|
365
|
+
'ms',
|
|
366
|
+
'ok',
|
|
367
|
+
'status',
|
|
368
|
+
'graphHash',
|
|
369
|
+
].includes(key),
|
|
370
|
+
),
|
|
371
|
+
),
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export function parseCliTraceTimings(output: string): Record<string, number> {
|
|
376
|
+
const timings: Record<string, number> = {};
|
|
377
|
+
for (const line of output.split(/\r?\n/)) {
|
|
378
|
+
const observation = parseMarkerJsonObservation(line, '[cli-trace] ');
|
|
379
|
+
if (
|
|
380
|
+
observation?.phase.startsWith('cli.') &&
|
|
381
|
+
observation.ms !== null &&
|
|
382
|
+
observation.ms !== undefined
|
|
383
|
+
) {
|
|
384
|
+
timings[observation.phase] = observation.ms;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return timings;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
export function parsePlayPerfTraceLine(
|
|
391
|
+
line: string,
|
|
392
|
+
): PlayLatencyObservation | null {
|
|
393
|
+
return parseMarkerJsonObservation(line, '[perf-trace] ');
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
export function parsePlayPerfTraceJsonLine(
|
|
397
|
+
line: string,
|
|
398
|
+
): PlayLatencyObservation | null {
|
|
399
|
+
const trimmed = line.trim();
|
|
400
|
+
if (!trimmed) {
|
|
401
|
+
return null;
|
|
402
|
+
}
|
|
403
|
+
try {
|
|
404
|
+
return normalizePlayLatencyObservation(JSON.parse(trimmed));
|
|
405
|
+
} catch {
|
|
406
|
+
return null;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export function parsePlayPerfTraceLines(
|
|
411
|
+
lines: Iterable<string>,
|
|
412
|
+
): PlayLatencyObservation[] {
|
|
413
|
+
const observations: PlayLatencyObservation[] = [];
|
|
414
|
+
for (const line of lines) {
|
|
415
|
+
const observation = parsePlayPerfTraceLine(line);
|
|
416
|
+
if (observation) {
|
|
417
|
+
observations.push(observation);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return observations.sort((left, right) => (left.ts ?? 0) - (right.ts ?? 0));
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export function parsePlayPerfTraceJsonLines(
|
|
424
|
+
lines: Iterable<string>,
|
|
425
|
+
): PlayLatencyObservation[] {
|
|
426
|
+
const observations: PlayLatencyObservation[] = [];
|
|
427
|
+
for (const line of lines) {
|
|
428
|
+
const observation = parsePlayPerfTraceJsonLine(line);
|
|
429
|
+
if (observation) {
|
|
430
|
+
observations.push(observation);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
return observations.sort((left, right) => (left.ts ?? 0) - (right.ts ?? 0));
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export function buildPlayLatencyTrace(input: {
|
|
437
|
+
runId?: string | null;
|
|
438
|
+
playLabel?: string | null;
|
|
439
|
+
status?: string | null;
|
|
440
|
+
ok?: boolean | null;
|
|
441
|
+
wallMs?: number | null;
|
|
442
|
+
observations: readonly PlayLatencyObservation[];
|
|
443
|
+
}): PlayLatencyTrace {
|
|
444
|
+
const normalizedRunId = input.runId ?? null;
|
|
445
|
+
const normalizedPlayLabel = input.playLabel ?? null;
|
|
446
|
+
const relevant = input.observations.filter((observation) => {
|
|
447
|
+
const matchesRun =
|
|
448
|
+
normalizedRunId !== null &&
|
|
449
|
+
observation.runId !== null &&
|
|
450
|
+
observation.runId !== undefined &&
|
|
451
|
+
observation.runId === normalizedRunId;
|
|
452
|
+
const matchesLabel =
|
|
453
|
+
normalizedPlayLabel !== null &&
|
|
454
|
+
observation.playLabel !== null &&
|
|
455
|
+
observation.playLabel !== undefined &&
|
|
456
|
+
observation.playLabel === normalizedPlayLabel;
|
|
457
|
+
return (
|
|
458
|
+
matchesRun ||
|
|
459
|
+
matchesLabel ||
|
|
460
|
+
(normalizedRunId === null && normalizedPlayLabel === null)
|
|
461
|
+
);
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
const phaseMs = new Map<string, number>();
|
|
465
|
+
const setMax = (phase: string, ms: number | null | undefined) => {
|
|
466
|
+
if (ms === null || ms === undefined || !Number.isFinite(ms)) {
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
phaseMs.set(phase, Math.max(phaseMs.get(phase) ?? 0, ms));
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
for (const observation of relevant) {
|
|
473
|
+
setMax(observation.phase, observation.ms);
|
|
474
|
+
}
|
|
475
|
+
setMax('runner.wall', input.wallMs);
|
|
476
|
+
|
|
477
|
+
const wallMs = phaseMs.get('runner.wall') ?? null;
|
|
478
|
+
const runnerRunMs = phaseMs.get('coordinator.runner_run') ?? null;
|
|
479
|
+
if (wallMs !== null && runnerRunMs !== null) {
|
|
480
|
+
phaseMs.set(
|
|
481
|
+
'derived.wall_minus_coordinator_runner_run',
|
|
482
|
+
Math.max(0, wallMs - runnerRunMs),
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
const workflowStartGapMs =
|
|
486
|
+
phaseMs.get('coordinator.workflow_start_gap') ?? null;
|
|
487
|
+
const workflowCreateMs = phaseMs.get('coordinator.workflow_create') ?? null;
|
|
488
|
+
if (
|
|
489
|
+
!phaseMs.has('coordinator.workflow_post_create_start_gap') &&
|
|
490
|
+
workflowStartGapMs !== null &&
|
|
491
|
+
workflowCreateMs !== null
|
|
492
|
+
) {
|
|
493
|
+
phaseMs.set(
|
|
494
|
+
'coordinator.workflow_post_create_start_gap',
|
|
495
|
+
Math.max(0, workflowStartGapMs - workflowCreateMs),
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
const definedPhaseKeys = new Set(
|
|
500
|
+
PLAY_LATENCY_SUMMARY_COLUMNS.map((definition) => definition.phase),
|
|
501
|
+
);
|
|
502
|
+
const unknownDefinitions: PlayLatencyPhaseDefinition[] = [...phaseMs.keys()]
|
|
503
|
+
.filter((phase) => !definedPhaseKeys.has(phase))
|
|
504
|
+
.sort()
|
|
505
|
+
.map((phase) => ({
|
|
506
|
+
header: phase,
|
|
507
|
+
phase,
|
|
508
|
+
source: sourceForPhase(phase),
|
|
509
|
+
description: `Uncatalogued latency phase ${phase}.`,
|
|
510
|
+
}));
|
|
511
|
+
|
|
512
|
+
const phases = [...PLAY_LATENCY_SUMMARY_COLUMNS, ...unknownDefinitions].map(
|
|
513
|
+
(definition): PlayLatencyPhase => ({
|
|
514
|
+
...definition,
|
|
515
|
+
ms: phaseMs.get(definition.phase) ?? null,
|
|
516
|
+
}),
|
|
517
|
+
);
|
|
518
|
+
const dominantPhase =
|
|
519
|
+
phases
|
|
520
|
+
.filter(
|
|
521
|
+
(phase) =>
|
|
522
|
+
phase.ms !== null &&
|
|
523
|
+
phase.ms !== undefined &&
|
|
524
|
+
(phase.includeInDominantPhase ?? true),
|
|
525
|
+
)
|
|
526
|
+
.sort((left, right) => (right.ms ?? 0) - (left.ms ?? 0))[0] ?? null;
|
|
527
|
+
|
|
528
|
+
return {
|
|
529
|
+
runId: normalizedRunId,
|
|
530
|
+
playLabel: normalizedPlayLabel,
|
|
531
|
+
status: input.status ?? null,
|
|
532
|
+
ok: input.ok ?? null,
|
|
533
|
+
phaseMs: Object.fromEntries(phaseMs.entries()),
|
|
534
|
+
phases,
|
|
535
|
+
dominantPhase,
|
|
536
|
+
observations: relevant,
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
export function formatPlayLatencyBreakdownLines(
|
|
541
|
+
trace: PlayLatencyTrace,
|
|
542
|
+
options: { prefix?: string; includeHeader?: boolean } = {},
|
|
543
|
+
): string[] {
|
|
544
|
+
const prefix = options.prefix ?? '';
|
|
545
|
+
const lines: string[] = [];
|
|
546
|
+
if (options.includeHeader ?? true) {
|
|
547
|
+
lines.push(
|
|
548
|
+
`${prefix}latency breakdown ${trace.playLabel ?? trace.runId ?? 'unknown'}`,
|
|
549
|
+
);
|
|
550
|
+
lines.push(`${prefix} run: ${trace.runId ?? 'n/a'}`);
|
|
551
|
+
}
|
|
552
|
+
for (const phase of trace.phases) {
|
|
553
|
+
if (phase.ms === null || phase.ms === undefined) {
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
lines.push(`${prefix} ${phase.phase}: ${formatPlayLatencyMs(phase.ms)}`);
|
|
557
|
+
}
|
|
558
|
+
if (
|
|
559
|
+
trace.dominantPhase?.ms !== null &&
|
|
560
|
+
trace.dominantPhase?.ms !== undefined
|
|
561
|
+
) {
|
|
562
|
+
lines.push(
|
|
563
|
+
`${prefix} dominant: ${trace.dominantPhase.phase} ${formatPlayLatencyMs(
|
|
564
|
+
trace.dominantPhase.ms,
|
|
565
|
+
)}`,
|
|
566
|
+
);
|
|
567
|
+
}
|
|
568
|
+
return lines;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
export function phaseLegendLines(): string[] {
|
|
572
|
+
return PLAY_LATENCY_SUMMARY_COLUMNS.map(
|
|
573
|
+
(phase) => `- **${phase.header}** - ${phase.description}`,
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
function parseMarkerJsonObservation(
|
|
578
|
+
line: string,
|
|
579
|
+
marker: string,
|
|
580
|
+
): PlayLatencyObservation | null {
|
|
581
|
+
const markerIndex = line.indexOf(marker);
|
|
582
|
+
if (markerIndex < 0) {
|
|
583
|
+
return null;
|
|
584
|
+
}
|
|
585
|
+
const jsonText = extractFirstJsonObject(line, markerIndex + marker.length);
|
|
586
|
+
if (!jsonText) {
|
|
587
|
+
return null;
|
|
588
|
+
}
|
|
589
|
+
try {
|
|
590
|
+
return normalizePlayLatencyObservation(JSON.parse(jsonText));
|
|
591
|
+
} catch {
|
|
592
|
+
return null;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
function extractFirstJsonObject(
|
|
597
|
+
line: string,
|
|
598
|
+
startIndex: number,
|
|
599
|
+
): string | null {
|
|
600
|
+
const start = line.indexOf('{', startIndex);
|
|
601
|
+
if (start < 0) {
|
|
602
|
+
return null;
|
|
603
|
+
}
|
|
604
|
+
let depth = 0;
|
|
605
|
+
let inString = false;
|
|
606
|
+
let escaped = false;
|
|
607
|
+
for (let index = start; index < line.length; index += 1) {
|
|
608
|
+
const char = line[index]!;
|
|
609
|
+
if (escaped) {
|
|
610
|
+
escaped = false;
|
|
611
|
+
continue;
|
|
612
|
+
}
|
|
613
|
+
if (char === '\\') {
|
|
614
|
+
escaped = true;
|
|
615
|
+
continue;
|
|
616
|
+
}
|
|
617
|
+
if (char === '"') {
|
|
618
|
+
inString = !inString;
|
|
619
|
+
continue;
|
|
620
|
+
}
|
|
621
|
+
if (inString) {
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
624
|
+
if (char === '{') {
|
|
625
|
+
depth += 1;
|
|
626
|
+
continue;
|
|
627
|
+
}
|
|
628
|
+
if (char === '}') {
|
|
629
|
+
depth -= 1;
|
|
630
|
+
if (depth === 0) {
|
|
631
|
+
return line.slice(start, index + 1);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
return null;
|
|
636
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const POSTGRES_UNSUPPORTED_NUL_RE = /\u0000/g;
|
|
2
|
+
|
|
3
|
+
export function stringifyPostgresJson(value: unknown): string | undefined {
|
|
4
|
+
return JSON.stringify(value, (_key, nestedValue) =>
|
|
5
|
+
typeof nestedValue === 'string'
|
|
6
|
+
? nestedValue.replace(POSTGRES_UNSUPPORTED_NUL_RE, '')
|
|
7
|
+
: nestedValue,
|
|
8
|
+
);
|
|
9
|
+
}
|