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,158 @@
|
|
|
1
|
+
export type HatchetColdExecutionPhaseId =
|
|
2
|
+
| 'submit'
|
|
3
|
+
| 'hatchet_dispatch_claim'
|
|
4
|
+
| 'daytona_create'
|
|
5
|
+
| 'daytona_upload'
|
|
6
|
+
| 'daytona_execute'
|
|
7
|
+
| 'terminal_observation';
|
|
8
|
+
|
|
9
|
+
export type HatchetColdExecutionPhaseDefinition = {
|
|
10
|
+
id: HatchetColdExecutionPhaseId;
|
|
11
|
+
header: string;
|
|
12
|
+
phase: string;
|
|
13
|
+
budgetMs: number;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type HatchetColdExecutionSample = Partial<
|
|
18
|
+
Record<HatchetColdExecutionPhaseId, number | null>
|
|
19
|
+
>;
|
|
20
|
+
|
|
21
|
+
export type HatchetColdExecutionPhaseSummary = {
|
|
22
|
+
phase: string;
|
|
23
|
+
id: HatchetColdExecutionPhaseId;
|
|
24
|
+
budgetMs: number;
|
|
25
|
+
p50: number | null;
|
|
26
|
+
p95: number | null;
|
|
27
|
+
max: number | null;
|
|
28
|
+
observed: number;
|
|
29
|
+
ok: boolean | null;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const HATCHET_COLD_EXECUTION_TARGET = {
|
|
33
|
+
name: 'hatchet-cold-execution-under-2s',
|
|
34
|
+
description:
|
|
35
|
+
'Customer-observed cold execution from submit through terminal observation on the real Hatchet + Daytona path.',
|
|
36
|
+
thresholdMs: 2_000,
|
|
37
|
+
percentile: 95,
|
|
38
|
+
} as const;
|
|
39
|
+
|
|
40
|
+
export const HATCHET_COLD_EXECUTION_PHASES = [
|
|
41
|
+
{
|
|
42
|
+
id: 'submit',
|
|
43
|
+
header: 'hc_submit',
|
|
44
|
+
phase: 'hatchet_cold.submit',
|
|
45
|
+
budgetMs: 300,
|
|
46
|
+
description:
|
|
47
|
+
'Customer submit route response, including app validation, authority minting, scheduler row creation, and Hatchet dispatch.',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: 'hatchet_dispatch_claim',
|
|
51
|
+
header: 'hc_hatchet',
|
|
52
|
+
phase: 'hatchet_cold.hatchet_dispatch_claim',
|
|
53
|
+
budgetMs: 250,
|
|
54
|
+
description:
|
|
55
|
+
'Hatchet dispatch and worker claim time from persisted scheduler row to claimed execution.',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: 'daytona_create',
|
|
59
|
+
header: 'hc_create',
|
|
60
|
+
phase: 'hatchet_cold.daytona_create',
|
|
61
|
+
budgetMs: 300,
|
|
62
|
+
description: 'Fresh Daytona sandbox creation for the claimed run.',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 'daytona_upload',
|
|
66
|
+
header: 'hc_upload',
|
|
67
|
+
phase: 'hatchet_cold.daytona_upload',
|
|
68
|
+
budgetMs: 350,
|
|
69
|
+
description:
|
|
70
|
+
'Runner bundle, play artifact, config, and staged-file upload into the Daytona sandbox.',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: 'daytona_execute',
|
|
74
|
+
header: 'hc_execute',
|
|
75
|
+
phase: 'hatchet_cold.daytona_execute',
|
|
76
|
+
budgetMs: 650,
|
|
77
|
+
description:
|
|
78
|
+
'Daytona command execution until the play runner returns its terminal result.',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 'terminal_observation',
|
|
82
|
+
header: 'hc_observe',
|
|
83
|
+
phase: 'hatchet_cold.terminal_observation',
|
|
84
|
+
budgetMs: 150,
|
|
85
|
+
description:
|
|
86
|
+
'Lag between scheduler terminal persistence and the customer-visible observer noticing terminal state.',
|
|
87
|
+
},
|
|
88
|
+
] as const satisfies readonly HatchetColdExecutionPhaseDefinition[];
|
|
89
|
+
|
|
90
|
+
export const HATCHET_COLD_EXECUTION_PHASE_DEFINITIONS =
|
|
91
|
+
HATCHET_COLD_EXECUTION_PHASES.map((definition) => ({
|
|
92
|
+
header: definition.header,
|
|
93
|
+
phase: definition.phase,
|
|
94
|
+
source: 'hatchet_cold',
|
|
95
|
+
description: `${definition.description} Budget: ${definition.budgetMs}ms.`,
|
|
96
|
+
}));
|
|
97
|
+
|
|
98
|
+
export function validateHatchetColdExecutionTarget(): string[] {
|
|
99
|
+
const errors: string[] = [];
|
|
100
|
+
const phaseIds = new Set<string>();
|
|
101
|
+
const phaseNames = new Set<string>();
|
|
102
|
+
let budgetTotal = 0;
|
|
103
|
+
for (const phase of HATCHET_COLD_EXECUTION_PHASES) {
|
|
104
|
+
if (phaseIds.has(phase.id)) {
|
|
105
|
+
errors.push(`Duplicate phase id: ${phase.id}`);
|
|
106
|
+
}
|
|
107
|
+
phaseIds.add(phase.id);
|
|
108
|
+
if (phaseNames.has(phase.phase)) {
|
|
109
|
+
errors.push(`Duplicate phase name: ${phase.phase}`);
|
|
110
|
+
}
|
|
111
|
+
phaseNames.add(phase.phase);
|
|
112
|
+
if (!Number.isFinite(phase.budgetMs) || phase.budgetMs <= 0) {
|
|
113
|
+
errors.push(`Phase ${phase.id} must have a positive budget.`);
|
|
114
|
+
}
|
|
115
|
+
budgetTotal += phase.budgetMs;
|
|
116
|
+
}
|
|
117
|
+
if (budgetTotal !== HATCHET_COLD_EXECUTION_TARGET.thresholdMs) {
|
|
118
|
+
errors.push(
|
|
119
|
+
`Phase budgets sum to ${budgetTotal}ms, expected ${HATCHET_COLD_EXECUTION_TARGET.thresholdMs}ms.`,
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
return errors;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function summarizeHatchetColdExecutionPhases(
|
|
126
|
+
samples: readonly HatchetColdExecutionSample[],
|
|
127
|
+
): HatchetColdExecutionPhaseSummary[] {
|
|
128
|
+
return HATCHET_COLD_EXECUTION_PHASES.map((definition) => {
|
|
129
|
+
const values = samples
|
|
130
|
+
.map((sample) => sample[definition.id])
|
|
131
|
+
.filter(
|
|
132
|
+
(value): value is number =>
|
|
133
|
+
typeof value === 'number' && Number.isFinite(value),
|
|
134
|
+
)
|
|
135
|
+
.sort((left, right) => left - right);
|
|
136
|
+
const p50 = percentile(values, 50);
|
|
137
|
+
const p95 = percentile(values, HATCHET_COLD_EXECUTION_TARGET.percentile);
|
|
138
|
+
return {
|
|
139
|
+
phase: definition.phase,
|
|
140
|
+
id: definition.id,
|
|
141
|
+
budgetMs: definition.budgetMs,
|
|
142
|
+
p50,
|
|
143
|
+
p95,
|
|
144
|
+
max: values.at(-1) ?? null,
|
|
145
|
+
observed: values.length,
|
|
146
|
+
ok: p95 === null ? null : p95 <= definition.budgetMs,
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function percentile(sortedValues: readonly number[], p: number): number | null {
|
|
152
|
+
if (sortedValues.length === 0) return null;
|
|
153
|
+
const index = Math.min(
|
|
154
|
+
sortedValues.length - 1,
|
|
155
|
+
Math.max(0, Math.ceil((p / 100) * sortedValues.length) - 1),
|
|
156
|
+
);
|
|
157
|
+
return sortedValues[index] ?? null;
|
|
158
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal Step Id Contract.
|
|
3
|
+
*
|
|
4
|
+
* Static analysis turns top-level play statements it cannot attribute to a
|
|
5
|
+
* structured step into `run_javascript` glue substeps whose alias is a
|
|
6
|
+
* machine-generated source line range (`lines_<startLine>_<endLine>`, built in
|
|
7
|
+
* `src/lib/plays/static-analysis.ts` → `createCodeStageForStatements`). The
|
|
8
|
+
* execution plan / runtime node ids namespace every substep by its type
|
|
9
|
+
* (`getStaticSubstepNodeId` in `src/lib/plays/step-progress.ts` and
|
|
10
|
+
* `apps/play-runner-workers/src/entry.ts`), so glue nodes are ALWAYS
|
|
11
|
+
* `run_javascript:<alias>` on the wire (ledger stepsById, snapshot
|
|
12
|
+
* nodeStates, `play.step.*` stream events).
|
|
13
|
+
*
|
|
14
|
+
* These nodes are internal bookkeeping, not user-level play steps: surfacing
|
|
15
|
+
* them produced the `step lines_687_687: completed` garbage in the CLI run
|
|
16
|
+
* summary (SDK 0.1.93 regression). This module is the single structural
|
|
17
|
+
* marker both the app package builder and the SDK CLI renderer use to keep
|
|
18
|
+
* them out of user-facing output. Do NOT re-implement this check with ad-hoc
|
|
19
|
+
* string matching elsewhere — import the predicate.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** Node-id namespace stamped on machine-generated glue-code substeps. */
|
|
23
|
+
export const INTERNAL_GLUE_NODE_ID_PREFIX = 'run_javascript:';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* True when a ledger/snapshot/stream step id refers to an internal
|
|
27
|
+
* glue-code node rather than a user-level play step.
|
|
28
|
+
*/
|
|
29
|
+
export function isInternalGlueStepId(stepId: unknown): boolean {
|
|
30
|
+
return (
|
|
31
|
+
typeof stepId === 'string' &&
|
|
32
|
+
stepId.startsWith(INTERNAL_GLUE_NODE_ID_PREFIX)
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createSecretRedactionContext } from './secret-redaction';
|
|
2
|
+
|
|
3
|
+
export const MAX_LEDGER_RESULT_PAYLOAD_BYTES = 2_500_000;
|
|
4
|
+
export const MAX_LEDGER_LOG_LINES_PER_EVENT = 500;
|
|
5
|
+
export const MAX_LEDGER_LOG_LINE_LENGTH = 2_000;
|
|
6
|
+
|
|
7
|
+
const ledgerIngressRedactor = createSecretRedactionContext();
|
|
8
|
+
|
|
9
|
+
export function redactLedgerString(value: unknown): string | null {
|
|
10
|
+
if (typeof value !== 'string' || !value.trim()) return null;
|
|
11
|
+
return ledgerIngressRedactor.redactString(value.trim());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function sanitizeLedgerPayload(value: unknown): unknown {
|
|
15
|
+
if (value === undefined) return undefined;
|
|
16
|
+
const serialized = JSON.stringify(value);
|
|
17
|
+
if (serialized && serialized.length > MAX_LEDGER_RESULT_PAYLOAD_BYTES) {
|
|
18
|
+
throw new Error('run event result payload is too large');
|
|
19
|
+
}
|
|
20
|
+
return ledgerIngressRedactor.redact(value);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function sanitizeLedgerLogLines(value: unknown): string[] {
|
|
24
|
+
if (!Array.isArray(value)) return [];
|
|
25
|
+
return value
|
|
26
|
+
.filter((line): line is string => typeof line === 'string')
|
|
27
|
+
.slice(0, MAX_LEDGER_LOG_LINES_PER_EVENT)
|
|
28
|
+
.map((line) =>
|
|
29
|
+
ledgerIngressRedactor
|
|
30
|
+
.redactString(line.trim())
|
|
31
|
+
.slice(0, MAX_LEDGER_LOG_LINE_LENGTH),
|
|
32
|
+
)
|
|
33
|
+
.filter(Boolean);
|
|
34
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type PlayRunLiveStatus =
|
|
2
|
+
| 'queued'
|
|
3
|
+
| 'running'
|
|
4
|
+
| 'completed'
|
|
5
|
+
| 'failed'
|
|
6
|
+
| 'cancelled'
|
|
7
|
+
| 'terminated'
|
|
8
|
+
| 'timed_out'
|
|
9
|
+
| 'unknown';
|
|
10
|
+
|
|
11
|
+
export type PlayVisualNodeStatus =
|
|
12
|
+
| 'idle'
|
|
13
|
+
| 'running'
|
|
14
|
+
| 'completed'
|
|
15
|
+
| 'failed'
|
|
16
|
+
| 'skipped';
|
|
17
|
+
|
|
18
|
+
export type PlayStepLiveStatus = Exclude<PlayVisualNodeStatus, 'idle'>;
|
|
19
|
+
|
|
20
|
+
export type PlayVisualNodeProgressSnapshot = {
|
|
21
|
+
completed?: number;
|
|
22
|
+
total?: number;
|
|
23
|
+
failed?: number;
|
|
24
|
+
message?: string;
|
|
25
|
+
updatedAt?: number | null;
|
|
26
|
+
startedAt?: number | null;
|
|
27
|
+
completedAt?: number | null;
|
|
28
|
+
artifactTableNamespace?: string | null;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type PlayVisualNodeStateSnapshot = {
|
|
32
|
+
nodeId: string;
|
|
33
|
+
status: PlayVisualNodeStatus;
|
|
34
|
+
artifactTableNamespace?: string | null;
|
|
35
|
+
progress?: PlayVisualNodeProgressSnapshot | null;
|
|
36
|
+
startedAt?: number | null;
|
|
37
|
+
completedAt?: number | null;
|
|
38
|
+
updatedAt?: number | null;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type PlayRunLiveSnapshot = {
|
|
42
|
+
runId: string;
|
|
43
|
+
status: PlayRunLiveStatus;
|
|
44
|
+
updatedAt: number | null;
|
|
45
|
+
logs: string[];
|
|
46
|
+
activeArtifactTableNamespace: string | null;
|
|
47
|
+
resultTableNamespace: string | null;
|
|
48
|
+
nodeStates: PlayVisualNodeStateSnapshot[];
|
|
49
|
+
activeNodeId: string | null;
|
|
50
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
MapExecutionFrame,
|
|
3
|
+
MapExecutionScope,
|
|
4
|
+
PlayCheckpoint,
|
|
5
|
+
PlayExecutionEvent,
|
|
6
|
+
} from './ctx-types';
|
|
7
|
+
|
|
8
|
+
export function cloneMapFrame(frame: MapExecutionFrame): MapExecutionFrame {
|
|
9
|
+
return {
|
|
10
|
+
...frame,
|
|
11
|
+
completedRowKeys: [...frame.completedRowKeys],
|
|
12
|
+
pendingRowKeys: [...frame.pendingRowKeys],
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class MapExecutionFrameStore {
|
|
17
|
+
constructor(
|
|
18
|
+
private readonly checkpoint: PlayCheckpoint,
|
|
19
|
+
private readonly emitExecutionEvent: (event: PlayExecutionEvent) => void,
|
|
20
|
+
) {}
|
|
21
|
+
|
|
22
|
+
set(frame: MapExecutionFrame): void {
|
|
23
|
+
this.checkpoint.mapFrames = {
|
|
24
|
+
...(this.checkpoint.mapFrames ?? {}),
|
|
25
|
+
[frame.mapInvocationId]: cloneMapFrame(frame),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
start(input: {
|
|
30
|
+
scope: MapExecutionScope;
|
|
31
|
+
totalRows: number;
|
|
32
|
+
completedRowKeys: readonly string[];
|
|
33
|
+
pendingRowKeys: readonly string[];
|
|
34
|
+
}): void {
|
|
35
|
+
const now = Date.now();
|
|
36
|
+
this.set({
|
|
37
|
+
mapInvocationId: input.scope.mapInvocationId,
|
|
38
|
+
mapNodeId: input.scope.mapNodeId ?? null,
|
|
39
|
+
logicalNamespace: input.scope.logicalNamespace,
|
|
40
|
+
artifactTableNamespace: input.scope.artifactTableNamespace,
|
|
41
|
+
status: 'running',
|
|
42
|
+
totalRows: input.totalRows,
|
|
43
|
+
completedRowKeys: [...input.completedRowKeys],
|
|
44
|
+
pendingRowKeys: [...input.pendingRowKeys],
|
|
45
|
+
startedAt: now,
|
|
46
|
+
updatedAt: now,
|
|
47
|
+
});
|
|
48
|
+
this.emitExecutionEvent({
|
|
49
|
+
type: 'map.started',
|
|
50
|
+
mapInvocationId: input.scope.mapInvocationId,
|
|
51
|
+
mapNodeId: input.scope.mapNodeId ?? null,
|
|
52
|
+
logicalNamespace: input.scope.logicalNamespace,
|
|
53
|
+
artifactTableNamespace: input.scope.artifactTableNamespace,
|
|
54
|
+
totalRows: input.totalRows,
|
|
55
|
+
completedRows: input.completedRowKeys.length,
|
|
56
|
+
pendingRows: input.pendingRowKeys.length,
|
|
57
|
+
at: Date.now(),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
updateProgress(input: {
|
|
62
|
+
scope: MapExecutionScope;
|
|
63
|
+
totalRows: number;
|
|
64
|
+
status?: MapExecutionFrame['status'];
|
|
65
|
+
completedRowKey?: string | null;
|
|
66
|
+
pendingRowKey?: string | null;
|
|
67
|
+
activeBoundaryId?: string | null;
|
|
68
|
+
emitEventType?: PlayExecutionEvent['type'];
|
|
69
|
+
}): void {
|
|
70
|
+
const existing =
|
|
71
|
+
this.checkpoint.mapFrames?.[input.scope.mapInvocationId] ?? null;
|
|
72
|
+
if (!existing) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const completedRowKeys = new Set(existing.completedRowKeys);
|
|
76
|
+
const pendingRowKeys = new Set(existing.pendingRowKeys);
|
|
77
|
+
const completedBefore = completedRowKeys.size;
|
|
78
|
+
if (input.completedRowKey?.trim()) {
|
|
79
|
+
const completedRowKey = input.completedRowKey.trim();
|
|
80
|
+
completedRowKeys.add(completedRowKey);
|
|
81
|
+
pendingRowKeys.delete(completedRowKey);
|
|
82
|
+
}
|
|
83
|
+
if (input.pendingRowKey?.trim()) {
|
|
84
|
+
pendingRowKeys.add(input.pendingRowKey.trim());
|
|
85
|
+
}
|
|
86
|
+
const nextFrame: MapExecutionFrame = {
|
|
87
|
+
...existing,
|
|
88
|
+
status: input.status ?? existing.status,
|
|
89
|
+
completedRowKeys: [...completedRowKeys],
|
|
90
|
+
pendingRowKeys: [...pendingRowKeys],
|
|
91
|
+
...(input.activeBoundaryId !== undefined
|
|
92
|
+
? { activeBoundaryId: input.activeBoundaryId }
|
|
93
|
+
: {}),
|
|
94
|
+
updatedAt: Date.now(),
|
|
95
|
+
};
|
|
96
|
+
this.set(nextFrame);
|
|
97
|
+
const progressEventType =
|
|
98
|
+
input.emitEventType ??
|
|
99
|
+
(completedRowKeys.size > completedBefore ? 'map.progress' : null);
|
|
100
|
+
if (progressEventType) {
|
|
101
|
+
this.emitExecutionEvent({
|
|
102
|
+
type: progressEventType,
|
|
103
|
+
mapInvocationId: input.scope.mapInvocationId,
|
|
104
|
+
mapNodeId: input.scope.mapNodeId ?? null,
|
|
105
|
+
logicalNamespace: input.scope.logicalNamespace,
|
|
106
|
+
artifactTableNamespace: input.scope.artifactTableNamespace,
|
|
107
|
+
completedRows: nextFrame.completedRowKeys.length,
|
|
108
|
+
failedRows: Math.max(
|
|
109
|
+
0,
|
|
110
|
+
input.totalRows -
|
|
111
|
+
nextFrame.completedRowKeys.length -
|
|
112
|
+
nextFrame.pendingRowKeys.length,
|
|
113
|
+
),
|
|
114
|
+
totalRows: input.totalRows,
|
|
115
|
+
at: Date.now(),
|
|
116
|
+
} as PlayExecutionEvent);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
derivePlayRowIdentity,
|
|
3
3
|
derivePlayRowIdentityFromKey,
|
|
4
4
|
// Relative (not '@shared_libs/...') because this file ships inside the
|
|
5
|
-
// packed SDK's dist/
|
|
5
|
+
// packed SDK's dist/bundling-sources graph (reachable from the
|
|
6
6
|
// apps/play-runner-workers entry), where only relative imports resolve.
|
|
7
7
|
} from '../plays/row-identity';
|
|
8
8
|
import type { MapExecutionScope } from './ctx-types';
|