deepline 0.3.270 → 0.3.272
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/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/activity-observation.ts +3 -2
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +11 -9
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +5 -4
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +2 -1
- package/dist/bundling-sources/shared_libs/play-runtime/run-event-catalog.ts +610 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-event-transport.ts +3 -1
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-projection-diagnostics.ts +3 -2
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +80 -67
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +5 -4
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +59 -20
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +3 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +19 -9
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +205 -107
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +125 -81
- package/dist/cli/getting-started.d.mts +13 -9
- package/dist/cli/getting-started.d.ts +13 -9
- package/dist/cli/getting-started.js +15 -3
- package/dist/cli/getting-started.mjs +13 -3
- package/dist/cli/index.js +447 -11
- package/dist/cli/index.mjs +447 -11
- package/dist/index.js +420 -1
- package/dist/index.mjs +420 -1
- package/dist/install-integrity.json +1 -0
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +1 -1
- package/dist/release.mjs +1 -1
- package/package.json +1 -1
package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts
CHANGED
|
@@ -7,6 +7,16 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { normalizeRuntimeSchedulerSchema } from '../runtime-scheduler-topology';
|
|
9
9
|
import type { PostgresSchedulerQueryClient } from './postgres';
|
|
10
|
+
import {
|
|
11
|
+
RUN_EVENT_CONVEX_INTERNAL_KIND_SQL_LITERAL,
|
|
12
|
+
RUN_EVENT_KIND_SQL_LITERAL,
|
|
13
|
+
RUN_EVENT_KNOWN_KIND_SQL_LIST,
|
|
14
|
+
RUN_EVENT_LIFECYCLE_KIND_SQL_LIST,
|
|
15
|
+
RUN_EVENT_SNAPSHOT_KIND_SQL_LIST,
|
|
16
|
+
RUN_EVENT_SEARCH_FALLBACK_KIND_SQL_LITERAL,
|
|
17
|
+
RUN_EVENT_TERMINAL_LOG_CARRIER_SQL_LIST,
|
|
18
|
+
RUN_SCHEDULER_OUTBOX_EVENT_TYPE_SQL_LITERAL,
|
|
19
|
+
} from '../run-event-catalog';
|
|
10
20
|
|
|
11
21
|
const EVENTS_TABLE = 'runtime_observability.events';
|
|
12
22
|
const RUNTIME_EVENT_LOG_DEDUPE_INDEX = 'runtime_events_log_attempt_digest_idx';
|
|
@@ -15,18 +25,18 @@ const RUNTIME_EVENT_LOG_POSITION_INDEX =
|
|
|
15
25
|
const RUNTIME_EVENT_LOG_LEGACY_INDEX =
|
|
16
26
|
'runtime_events_legacy_log_normalize_idx';
|
|
17
27
|
const RUNTIME_EVENT_LOG_BODY_PAGE_INDEX = 'runtime_events_run_log_body_seq_idx';
|
|
18
|
-
const RUNTIME_EVENT_LOG_LEGACY_PREDICATE = `kind =
|
|
28
|
+
const RUNTIME_EVENT_LOG_LEGACY_PREDICATE = `kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}
|
|
19
29
|
AND source_digest IS NOT NULL
|
|
20
30
|
AND NOT (search_doc ? 'logContentDigest')
|
|
21
31
|
AND (search_doc->>'producerAttempt') ~ '^[1-9][0-9]{0,5}$'`;
|
|
22
|
-
const RUNTIME_EVENT_LOG_BODY_PAGE_PREDICATE = `kind =
|
|
32
|
+
const RUNTIME_EVENT_LOG_BODY_PAGE_PREDICATE = `kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}
|
|
23
33
|
AND log_seq IS NOT NULL
|
|
24
34
|
AND (log_body IS NOT NULL OR message IS NOT NULL)`;
|
|
25
|
-
const RUNTIME_EVENT_LOG_DEDUPE_PREDICATE = `kind =
|
|
35
|
+
const RUNTIME_EVENT_LOG_DEDUPE_PREDICATE = `kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}
|
|
26
36
|
AND source_digest IS NOT NULL
|
|
27
37
|
AND search_doc ? 'producerAttempt'
|
|
28
38
|
AND search_doc ? 'logContentDigest'`;
|
|
29
|
-
const RUNTIME_EVENT_LOG_POSITION_PREDICATE = `kind =
|
|
39
|
+
const RUNTIME_EVENT_LOG_POSITION_PREDICATE = `kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}
|
|
30
40
|
AND search_doc ? 'producerAttempt'
|
|
31
41
|
AND search_doc ? 'logPositions'`;
|
|
32
42
|
const RUNTIME_EVENT_LOG_POSITION_EXPRESSION = `jsonb_set(
|
|
@@ -41,7 +51,7 @@ const RUNTIME_EVENT_LOG_POSITION_EXPRESSION = `jsonb_set(
|
|
|
41
51
|
// Migration readiness tracks this projection body independently of scheduler
|
|
42
52
|
// wire and schema versions. Bump when a changed trigger must be reinstalled.
|
|
43
53
|
export const RUNTIME_EVENT_SEARCH_OUTBOX_PROJECTION_MARKER =
|
|
44
|
-
'runtime-event-search-log-context-
|
|
54
|
+
'runtime-event-search-log-context-v12-scheduler-wait-logs';
|
|
45
55
|
export const RUNTIME_EVENT_CANONICAL_RETENTION_INDEX_READY_MARKER =
|
|
46
56
|
'runtime-event-canonical-retention-v1';
|
|
47
57
|
export const RUNTIME_EVENTS_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;
|
|
@@ -369,7 +379,7 @@ export async function searchRuntimeEvents(
|
|
|
369
379
|
params.push(input.includePayloads === true);
|
|
370
380
|
const result = await client.query<EventRow>(
|
|
371
381
|
`SELECT event_id, occurred_at, ingested_at, run_id, play_name, kind, level,
|
|
372
|
-
coalesce(message, CASE WHEN kind =
|
|
382
|
+
coalesce(message, CASE WHEN kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended} THEN
|
|
373
383
|
left(CASE WHEN search_doc->>'source' = 'terminal' THEN
|
|
374
384
|
regexp_replace(log_body,
|
|
375
385
|
'^' || chr(1) || 'prov:[^' || chr(1) || ']*' || chr(1), '')
|
|
@@ -515,14 +525,14 @@ export async function getRuntimeRunLogPage(
|
|
|
515
525
|
(SELECT log_seq
|
|
516
526
|
FROM runtime_observability.events
|
|
517
527
|
WHERE runtime_scope = $1 AND org_id = $2 AND run_id = $3
|
|
518
|
-
AND kind =
|
|
528
|
+
AND kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended} AND log_seq IS NOT NULL
|
|
519
529
|
AND (log_body IS NOT NULL OR message IS NOT NULL)
|
|
520
530
|
AND ingested_at >= clock_timestamp() - interval '7 days'
|
|
521
531
|
ORDER BY log_seq ASC LIMIT 1) AS first_seq,
|
|
522
532
|
(SELECT log_seq
|
|
523
533
|
FROM runtime_observability.events
|
|
524
534
|
WHERE runtime_scope = $1 AND org_id = $2 AND run_id = $3
|
|
525
|
-
AND kind =
|
|
535
|
+
AND kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended} AND log_seq IS NOT NULL
|
|
526
536
|
AND (log_body IS NOT NULL OR message IS NOT NULL)
|
|
527
537
|
AND ingested_at >= clock_timestamp() - interval '7 days'
|
|
528
538
|
ORDER BY log_seq DESC LIMIT 1) AS last_seq
|
|
@@ -534,7 +544,7 @@ export async function getRuntimeRunLogPage(
|
|
|
534
544
|
SELECT log_seq AS seq, coalesce(log_body, message) AS line
|
|
535
545
|
FROM runtime_observability.events
|
|
536
546
|
WHERE runtime_scope = $1 AND org_id = $2 AND run_id = $3
|
|
537
|
-
AND kind =
|
|
547
|
+
AND kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended} AND log_seq IS NOT NULL
|
|
538
548
|
AND (log_body IS NOT NULL OR message IS NOT NULL)
|
|
539
549
|
AND ingested_at >= clock_timestamp() - interval '7 days'
|
|
540
550
|
${pageWhere}
|
|
@@ -806,7 +816,7 @@ export async function ensureRuntimeEventSearchSchema(
|
|
|
806
816
|
);
|
|
807
817
|
await client.query(`CREATE INDEX IF NOT EXISTS runtime_events_run_log_seq_idx
|
|
808
818
|
ON runtime_observability.events (runtime_scope, org_id, run_id, log_seq)
|
|
809
|
-
WHERE kind =
|
|
819
|
+
WHERE kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended} AND log_seq IS NOT NULL`);
|
|
810
820
|
await client.query(
|
|
811
821
|
`DROP INDEX IF EXISTS runtime_observability.runtime_run_log_cursors_retention_idx`,
|
|
812
822
|
);
|
|
@@ -1027,7 +1037,7 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1027
1037
|
IF run_org IS NULL OR play IS NULL THEN
|
|
1028
1038
|
RAISE EXCEPTION 'Outbox search projection has no matching run';
|
|
1029
1039
|
END IF;
|
|
1030
|
-
IF observation.event_type =
|
|
1040
|
+
IF observation.event_type = ${RUN_SCHEDULER_OUTBOX_EVENT_TYPE_SQL_LITERAL.runEvents} THEN
|
|
1031
1041
|
event_batch := observation.payload_json->'events';
|
|
1032
1042
|
IF jsonb_typeof(event_batch) IS DISTINCT FROM 'array' THEN
|
|
1033
1043
|
RAISE EXCEPTION 'Search projection requires run.events array';
|
|
@@ -1036,7 +1046,7 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1036
1046
|
AND observation.payload_json->>'logBodyStore' IS DISTINCT FROM 'planet_scale' THEN
|
|
1037
1047
|
RAISE EXCEPTION 'Search projection requires nonempty run.events array';
|
|
1038
1048
|
END IF;
|
|
1039
|
-
ELSIF observation.event_type IN (
|
|
1049
|
+
ELSIF observation.event_type IN (${RUN_EVENT_TERMINAL_LOG_CARRIER_SQL_LIST})
|
|
1040
1050
|
AND observation.payload_json ? 'terminalProgressEvents' THEN
|
|
1041
1051
|
event_batch := observation.payload_json->'terminalProgressEvents';
|
|
1042
1052
|
IF jsonb_typeof(event_batch) IS DISTINCT FROM 'array' THEN
|
|
@@ -1049,24 +1059,65 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1049
1059
|
observation.payload_json->'terminalWorkCounterSegment'->'attempt');
|
|
1050
1060
|
-- The retained envelope has its own position space: it can contain
|
|
1051
1061
|
-- diagnostics absent from both live delivery and ctx-only replay.
|
|
1052
|
-
IF observation.event_type IN (
|
|
1062
|
+
IF observation.event_type IN (${RUN_EVENT_TERMINAL_LOG_CARRIER_SQL_LIST})
|
|
1053
1063
|
AND observation.payload_json ? 'terminalLogLines'
|
|
1054
1064
|
AND (envelope_attempt #>> '{}') ~ '^[1-9][0-9]{0,5}$' THEN
|
|
1055
1065
|
event_batch := coalesce(event_batch, '[]'::jsonb) || jsonb_build_array(
|
|
1056
1066
|
jsonb_strip_nulls(jsonb_build_object(
|
|
1057
|
-
'type',
|
|
1067
|
+
'type', ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}, 'runId', observation.run_id, 'source', 'terminal',
|
|
1058
1068
|
'producerAttempt', envelope_attempt, 'channelOffset', 0,
|
|
1059
1069
|
'lines', observation.payload_json->'terminalLogLines',
|
|
1060
1070
|
'lineContexts', observation.payload_json->'terminalLogContexts'
|
|
1061
1071
|
))
|
|
1062
1072
|
);
|
|
1063
1073
|
END IF;
|
|
1074
|
+
IF observation.event_type = ${RUN_SCHEDULER_OUTBOX_EVENT_TYPE_SQL_LITERAL.runWaitTimeout} THEN
|
|
1075
|
+
event_batch := jsonb_build_array(jsonb_build_object(
|
|
1076
|
+
'type', ${RUN_EVENT_KIND_SQL_LITERAL.logAppended},
|
|
1077
|
+
'runId', observation.run_id,
|
|
1078
|
+
'occurredAt', floor(extract(epoch FROM observation.created_at) * 1000)::bigint,
|
|
1079
|
+
'source', 'system',
|
|
1080
|
+
'lines', jsonb_build_array(
|
|
1081
|
+
'Timed out waiting for integration_event:' ||
|
|
1082
|
+
CASE WHEN jsonb_typeof(observation.payload_json->'eventKey') = 'string'
|
|
1083
|
+
THEN observation.payload_json->>'eventKey' ELSE 'event' END || '.'
|
|
1084
|
+
)
|
|
1085
|
+
));
|
|
1086
|
+
ELSIF observation.event_type IN (
|
|
1087
|
+
${RUN_EVENT_KIND_SQL_LITERAL.runWaiting},
|
|
1088
|
+
${RUN_EVENT_KIND_SQL_LITERAL.runResumed}
|
|
1089
|
+
)
|
|
1090
|
+
AND (
|
|
1091
|
+
jsonb_typeof(observation.payload_json->'kind') IS DISTINCT FROM 'string'
|
|
1092
|
+
OR observation.payload_json->>'kind' IN ('integration_event', 'integration_event_batch')
|
|
1093
|
+
)
|
|
1094
|
+
AND (
|
|
1095
|
+
jsonb_typeof(observation.payload_json->'kind') IS DISTINCT FROM 'string'
|
|
1096
|
+
OR (
|
|
1097
|
+
jsonb_typeof(observation.payload_json->'eventKey') = 'string'
|
|
1098
|
+
AND observation.payload_json->>'eventKey' <> ''
|
|
1099
|
+
)
|
|
1100
|
+
) THEN
|
|
1101
|
+
event_batch := jsonb_build_array(jsonb_build_object(
|
|
1102
|
+
'type', ${RUN_EVENT_KIND_SQL_LITERAL.logAppended},
|
|
1103
|
+
'runId', observation.run_id,
|
|
1104
|
+
'occurredAt', floor(extract(epoch FROM observation.created_at) * 1000)::bigint,
|
|
1105
|
+
'source', 'system',
|
|
1106
|
+
'lines', jsonb_build_array(
|
|
1107
|
+
CASE WHEN observation.event_type = ${RUN_EVENT_KIND_SQL_LITERAL.runWaiting}
|
|
1108
|
+
THEN 'Waiting for integration_event:'
|
|
1109
|
+
ELSE 'Resumed integration_event:' END ||
|
|
1110
|
+
CASE WHEN jsonb_typeof(observation.payload_json->'eventKey') = 'string'
|
|
1111
|
+
THEN observation.payload_json->>'eventKey' ELSE 'event' END || '.'
|
|
1112
|
+
)
|
|
1113
|
+
));
|
|
1114
|
+
END IF;
|
|
1064
1115
|
IF event_batch IS NOT NULL THEN
|
|
1065
1116
|
-- Normalize old positional writers once per batch under the run mutex.
|
|
1066
1117
|
-- Per-line lookups must remain digest-selective: an OR fallback for
|
|
1067
1118
|
-- unmarked rows otherwise scans the whole attempt for every new line.
|
|
1068
1119
|
IF EXISTS (SELECT 1 FROM jsonb_array_elements(event_batch) AS entry
|
|
1069
|
-
WHERE entry->>'type' =
|
|
1120
|
+
WHERE entry->>'type' = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}) THEN
|
|
1070
1121
|
UPDATE runtime_observability.events AS event SET search_doc = event.search_doc ||
|
|
1071
1122
|
jsonb_build_object('logContentDigest', event.source_digest) ||
|
|
1072
1123
|
CASE WHEN NOT (event.search_doc ? 'logPositions')
|
|
@@ -1078,7 +1129,7 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1078
1129
|
substring(event.event_id FROM length('log:' || observation.run_id || ':' || (event.search_doc->>'producerAttempt') || ':') + 1)::bigint))
|
|
1079
1130
|
ELSE '{}'::jsonb END
|
|
1080
1131
|
WHERE event.runtime_scope = ${quoteLiteral(scope)} AND event.org_id = run_org
|
|
1081
|
-
AND event.run_id = observation.run_id AND event.kind =
|
|
1132
|
+
AND event.run_id = observation.run_id AND event.kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}
|
|
1082
1133
|
AND event.source_digest IS NOT NULL AND NOT (event.search_doc ? 'logContentDigest')
|
|
1083
1134
|
AND (event.search_doc->>'producerAttempt') ~ '^[1-9][0-9]{0,5}$';
|
|
1084
1135
|
END IF;
|
|
@@ -1088,14 +1139,8 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1088
1139
|
RAISE EXCEPTION 'Search projection event has invalid run identity';
|
|
1089
1140
|
END IF;
|
|
1090
1141
|
kind := coalesce(item->>'type', item->>'key');
|
|
1091
|
-
IF kind NOT IN (
|
|
1092
|
-
|
|
1093
|
-
'run.completed', 'run.failed', 'run.cancelled',
|
|
1094
|
-
'step.started', 'step.progress', 'step.completed',
|
|
1095
|
-
'step.failed', 'step.skipped', 'log.appended',
|
|
1096
|
-
'dataset.lifecycle', 'activity.observed', 'work.counters'
|
|
1097
|
-
) THEN
|
|
1098
|
-
kind := 'runtime.event';
|
|
1142
|
+
IF kind NOT IN (${RUN_EVENT_KNOWN_KIND_SQL_LIST}) THEN
|
|
1143
|
+
kind := ${RUN_EVENT_SEARCH_FALLBACK_KIND_SQL_LITERAL};
|
|
1099
1144
|
END IF;
|
|
1100
1145
|
at_time := CASE WHEN (item->>'occurredAt') ~ '^[0-9]{12,14}$'
|
|
1101
1146
|
THEN to_timestamp((item->>'occurredAt')::double precision / 1000)
|
|
@@ -1115,15 +1160,15 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1115
1160
|
'operation', CASE WHEN item->'observation'->'target'->>'kind' = 'provider'
|
|
1116
1161
|
THEN left(item->'observation'->'target'->>'operation', 256) END
|
|
1117
1162
|
));
|
|
1118
|
-
IF kind =
|
|
1163
|
+
IF kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended} AND jsonb_typeof(item->'lines') IS DISTINCT FROM 'array' THEN
|
|
1119
1164
|
RAISE EXCEPTION 'Search projection requires log.appended lines';
|
|
1120
1165
|
END IF;
|
|
1121
|
-
IF kind =
|
|
1166
|
+
IF kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended} AND item ? 'lineContexts'
|
|
1122
1167
|
AND (jsonb_typeof(item->'lineContexts') IS DISTINCT FROM 'array'
|
|
1123
1168
|
OR jsonb_array_length(item->'lineContexts') <> jsonb_array_length(item->'lines')) THEN
|
|
1124
1169
|
RAISE EXCEPTION 'Search projection requires lineContexts aligned to log lines';
|
|
1125
1170
|
END IF;
|
|
1126
|
-
IF kind =
|
|
1171
|
+
IF kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended} THEN
|
|
1127
1172
|
FOR line, line_ordinal IN SELECT value, ordinality FROM jsonb_array_elements(item->'lines') WITH ORDINALITY LOOP
|
|
1128
1173
|
IF jsonb_typeof(line) IS DISTINCT FROM 'string' THEN
|
|
1129
1174
|
RAISE EXCEPTION 'Search projection requires log line strings';
|
|
@@ -1137,7 +1182,7 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1137
1182
|
SELECT coalesce(event.log_text_digest, encode(sha256(convert_to(btrim(event.log_body), 'UTF8')), 'hex')) AS dedupe_key
|
|
1138
1183
|
FROM runtime_observability.events AS event
|
|
1139
1184
|
WHERE event.runtime_scope = ${quoteLiteral(scope)} AND event.org_id = run_org
|
|
1140
|
-
AND event.run_id = observation.run_id AND event.kind =
|
|
1185
|
+
AND event.run_id = observation.run_id AND event.kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}
|
|
1141
1186
|
AND event.log_seq IS NOT NULL AND (event.log_text_digest IS NOT NULL OR event.log_body IS NOT NULL)
|
|
1142
1187
|
AND (item->>'producerAttempt' IS NULL
|
|
1143
1188
|
OR event.search_doc->>'producerAttempt' = item->>'producerAttempt')
|
|
@@ -1237,7 +1282,7 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1237
1282
|
INTO matched_event_id, existing_digest, matched_doc
|
|
1238
1283
|
FROM runtime_observability.events AS event
|
|
1239
1284
|
WHERE event.runtime_scope = ${quoteLiteral(scope)} AND event.org_id = run_org
|
|
1240
|
-
AND event.run_id = observation.run_id AND event.kind =
|
|
1285
|
+
AND event.run_id = observation.run_id AND event.kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}
|
|
1241
1286
|
AND event.event_id = ANY(position_event_ids)
|
|
1242
1287
|
AND (
|
|
1243
1288
|
event.search_doc->'logPositions'->>log_channel = log_position::text
|
|
@@ -1262,7 +1307,7 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1262
1307
|
INTO matched_event_id, existing_digest, matched_doc
|
|
1263
1308
|
FROM runtime_observability.events AS event
|
|
1264
1309
|
WHERE event.runtime_scope = ${quoteLiteral(scope)} AND event.org_id = run_org
|
|
1265
|
-
AND event.run_id = observation.run_id AND event.kind =
|
|
1310
|
+
AND event.run_id = observation.run_id AND event.kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}
|
|
1266
1311
|
AND event.search_doc ? 'producerAttempt'
|
|
1267
1312
|
AND event.search_doc ? 'logPositions'
|
|
1268
1313
|
AND (${RUNTIME_EVENT_LOG_POSITION_EXPRESSION.replaceAll('search_doc', 'event.search_doc')}) @> position_alias
|
|
@@ -1283,7 +1328,7 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1283
1328
|
INTO matched_event_id, matched_doc
|
|
1284
1329
|
FROM runtime_observability.events AS event
|
|
1285
1330
|
WHERE event.runtime_scope = ${quoteLiteral(scope)} AND event.org_id = run_org
|
|
1286
|
-
AND event.run_id = observation.run_id AND event.kind =
|
|
1331
|
+
AND event.run_id = observation.run_id AND event.kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}
|
|
1287
1332
|
AND event.source_digest IS NOT NULL
|
|
1288
1333
|
AND event.search_doc ? 'producerAttempt'
|
|
1289
1334
|
AND event.search_doc ? 'logContentDigest'
|
|
@@ -1306,7 +1351,7 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1306
1351
|
-- Serialize with terminal acceptance on the log mutex. A late
|
|
1307
1352
|
-- retry of an accepted position is harmless; a new position
|
|
1308
1353
|
-- after terminal closure must never recreate expired history.
|
|
1309
|
-
IF compact_logs AND observation.event_type =
|
|
1354
|
+
IF compact_logs AND observation.event_type = ${RUN_SCHEDULER_OUTBOX_EVENT_TYPE_SQL_LITERAL.runEvents}
|
|
1310
1355
|
AND run_status IN ('completed', 'failed', 'cancelled')
|
|
1311
1356
|
AND NOT EXISTS (SELECT 1 FROM runtime_observability.events
|
|
1312
1357
|
WHERE runtime_scope = ${quoteLiteral(scope)} AND org_id = run_org
|
|
@@ -1322,13 +1367,13 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1322
1367
|
CASE WHEN canonical_events THEN nextval('runtime_observability.runtime_event_order_seq') END,
|
|
1323
1368
|
CASE WHEN canonical_events THEN jsonb_strip_nulls(
|
|
1324
1369
|
(item - 'lines' - 'lineContexts') || jsonb_build_object(
|
|
1325
|
-
'type',
|
|
1370
|
+
'type', ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}, 'runId', observation.run_id,
|
|
1326
1371
|
'occurredAt', floor(extract(epoch FROM at_time) * 1000)::bigint,
|
|
1327
1372
|
'lineOrdinal', line_ordinal,
|
|
1328
1373
|
'context', line_context
|
|
1329
1374
|
)) END,
|
|
1330
1375
|
at_time, observation.run_id, play,
|
|
1331
|
-
|
|
1376
|
+
${RUN_EVENT_KIND_SQL_LITERAL.logAppended}, NULL, CASE WHEN compact_logs THEN NULL ELSE left(line #>> '{}', 2048) END,
|
|
1332
1377
|
line #>> '{}', digest,
|
|
1333
1378
|
encode(sha256(convert_to(btrim(line #>> '{}'), 'UTF8')), 'hex'), line_doc
|
|
1334
1379
|
) ON CONFLICT DO NOTHING;
|
|
@@ -1346,7 +1391,7 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1346
1391
|
ELSE
|
|
1347
1392
|
-- Final progress may arrive in the first terminal receipt and
|
|
1348
1393
|
-- again in completion. One attempt/ordinal owns one immutable fact.
|
|
1349
|
-
terminal_progress_identity := observation.event_type IN (
|
|
1394
|
+
terminal_progress_identity := observation.event_type IN (${RUN_EVENT_TERMINAL_LOG_CARRIER_SQL_LIST})
|
|
1350
1395
|
AND coalesce((observation.payload_json->>'producerAttempt') ~ '^[1-9][0-9]{0,5}$', false);
|
|
1351
1396
|
eid := CASE WHEN terminal_progress_identity
|
|
1352
1397
|
THEN 'terminal-progress:' || observation.run_id || ':' ||
|
|
@@ -1374,10 +1419,11 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1374
1419
|
END IF;
|
|
1375
1420
|
END LOOP;
|
|
1376
1421
|
END IF;
|
|
1377
|
-
IF observation.event_type IN (
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1422
|
+
IF observation.event_type IN (${RUN_EVENT_LIFECYCLE_KIND_SQL_LIST})
|
|
1423
|
+
AND NOT (observation.event_type IN (
|
|
1424
|
+
${RUN_EVENT_KIND_SQL_LITERAL.runWaiting},
|
|
1425
|
+
${RUN_EVENT_KIND_SQL_LITERAL.runResumed}
|
|
1426
|
+
)
|
|
1381
1427
|
AND observation.payload_json->>'kind' = 'detached_runner') THEN
|
|
1382
1428
|
INSERT INTO runtime_observability.events (
|
|
1383
1429
|
runtime_scope, org_id, event_id, event_seq, event_payload,
|
|
@@ -1399,7 +1445,7 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1399
1445
|
observation.run_id, play, observation.event_type, jsonb_build_object('kind', observation.event_type, 'source', 'system')
|
|
1400
1446
|
) ON CONFLICT DO NOTHING;
|
|
1401
1447
|
END IF;
|
|
1402
|
-
IF observation.event_type IN (
|
|
1448
|
+
IF observation.event_type IN (${RUN_EVENT_TERMINAL_LOG_CARRIER_SQL_LIST}) THEN
|
|
1403
1449
|
-- Detached runners deliver their retained ctx.log tail in the terminal
|
|
1404
1450
|
-- outbox fact rather than a run.events batch. Project it from that
|
|
1405
1451
|
-- authoritative write so search and the existing log stream agree.
|
|
@@ -1407,7 +1453,7 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1407
1453
|
AND NOT (observation.payload_json ? 'terminalLogLines') THEN
|
|
1408
1454
|
RAISE EXCEPTION 'Search projection requires terminalLogLines for terminalLogContexts';
|
|
1409
1455
|
END IF;
|
|
1410
|
-
IF observation.event_type IN (
|
|
1456
|
+
IF observation.event_type IN (${RUN_EVENT_TERMINAL_LOG_CARRIER_SQL_LIST})
|
|
1411
1457
|
AND observation.payload_json ? 'terminalLogLines'
|
|
1412
1458
|
AND NOT coalesce((envelope_attempt #>> '{}') ~ '^[1-9][0-9]{0,5}$', false) THEN
|
|
1413
1459
|
IF jsonb_typeof(observation.payload_json->'terminalLogLines') IS DISTINCT FROM 'array' THEN
|
|
@@ -1436,7 +1482,7 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1436
1482
|
FROM runtime_observability.events AS event
|
|
1437
1483
|
WHERE event.runtime_scope = ${quoteLiteral(scope)}
|
|
1438
1484
|
AND event.org_id = run_org AND event.run_id = observation.run_id
|
|
1439
|
-
AND event.kind =
|
|
1485
|
+
AND event.kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}
|
|
1440
1486
|
AND (observation.payload_json->>'producerAttempt' IS NULL
|
|
1441
1487
|
OR event.search_doc->>'producerAttempt' = observation.payload_json->>'producerAttempt')
|
|
1442
1488
|
AND event.log_seq IS NOT NULL AND (event.log_text_digest IS NOT NULL OR event.log_body IS NOT NULL)
|
|
@@ -1448,7 +1494,7 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1448
1494
|
FROM runtime_observability.events AS event
|
|
1449
1495
|
WHERE event.runtime_scope = ${quoteLiteral(scope)}
|
|
1450
1496
|
AND event.org_id = run_org AND event.run_id = observation.run_id
|
|
1451
|
-
AND event.kind =
|
|
1497
|
+
AND event.kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended} AND (event.log_text_digest IS NOT NULL OR event.log_body IS NOT NULL)
|
|
1452
1498
|
AND event.event_id = ANY(fresh_event_ids)
|
|
1453
1499
|
AND (observation.payload_json->>'producerAttempt' IS NULL
|
|
1454
1500
|
OR event.search_doc->>'producerAttempt' = observation.payload_json->>'producerAttempt')
|
|
@@ -1499,7 +1545,7 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1499
1545
|
END IF;
|
|
1500
1546
|
END IF;
|
|
1501
1547
|
line_doc := jsonb_strip_nulls(jsonb_build_object(
|
|
1502
|
-
'kind',
|
|
1548
|
+
'kind', ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}, 'source', 'terminal',
|
|
1503
1549
|
'producerAttempt', observation.payload_json->'producerAttempt'
|
|
1504
1550
|
));
|
|
1505
1551
|
IF line_context IS NOT NULL THEN
|
|
@@ -1513,12 +1559,12 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1513
1559
|
${quoteLiteral(scope)}, run_org, observation.event_id || ':log:' || line_ordinal,
|
|
1514
1560
|
CASE WHEN canonical_events THEN nextval('runtime_observability.runtime_event_order_seq') END,
|
|
1515
1561
|
CASE WHEN canonical_events THEN jsonb_strip_nulls(jsonb_build_object(
|
|
1516
|
-
'type',
|
|
1562
|
+
'type', ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}, 'runId', observation.run_id,
|
|
1517
1563
|
'occurredAt', floor(extract(epoch FROM observation.created_at) * 1000)::bigint,
|
|
1518
1564
|
'source', 'terminal', 'producerAttempt', observation.payload_json->'producerAttempt',
|
|
1519
1565
|
'lineOrdinal', line_ordinal, 'context', line_context
|
|
1520
1566
|
)) END,
|
|
1521
|
-
observation.created_at, observation.run_id, play,
|
|
1567
|
+
observation.created_at, observation.run_id, play, ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}, NULL,
|
|
1522
1568
|
CASE WHEN compact_logs THEN NULL ELSE left(regexp_replace(line #>> '{}',
|
|
1523
1569
|
'^' || chr(1) || 'prov:[^' || chr(1) || ']*' || chr(1), ''), 2048) END,
|
|
1524
1570
|
line #>> '{}',
|
|
@@ -1562,7 +1608,7 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1562
1608
|
LANGUAGE sql IMMUTABLE SET search_path = pg_catalog AS $function$
|
|
1563
1609
|
SELECT coalesce(jsonb_agg(item.value ORDER BY item.ordinality), '[]'::jsonb)
|
|
1564
1610
|
FROM jsonb_array_elements(batch) WITH ORDINALITY AS item(value, ordinality)
|
|
1565
|
-
WHERE coalesce(item.value->>'type', item.value->>'key') IS DISTINCT FROM
|
|
1611
|
+
WHERE coalesce(item.value->>'type', item.value->>'key') IS DISTINCT FROM ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}
|
|
1566
1612
|
$function$
|
|
1567
1613
|
`);
|
|
1568
1614
|
await client.query(`
|
|
@@ -1572,61 +1618,59 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1572
1618
|
SELECT coalesce(value->>'type', value->>'key') AS kind
|
|
1573
1619
|
)
|
|
1574
1620
|
SELECT CASE
|
|
1575
|
-
WHEN event.kind IN (
|
|
1621
|
+
WHEN event.kind IN (
|
|
1622
|
+
${RUN_EVENT_CONVEX_INTERNAL_KIND_SQL_LITERAL.rollupMembershipAdded},
|
|
1623
|
+
${RUN_EVENT_CONVEX_INTERNAL_KIND_SQL_LITERAL.rollupMembershipRemoved}
|
|
1624
|
+
)
|
|
1576
1625
|
AND value->>'opaque' = 'true' THEN jsonb_strip_nulls(jsonb_build_object(
|
|
1577
1626
|
'type', event.kind, 'runId', value->'runId',
|
|
1578
1627
|
'occurredAt', value->'occurredAt', 'source', value->'source',
|
|
1579
1628
|
'opaque', true, 'payload', value->'payload'))
|
|
1580
|
-
WHEN event.kind IN (
|
|
1581
|
-
|
|
1582
|
-
'run.completed', 'run.failed', 'run.cancelled',
|
|
1583
|
-
'step.started', 'step.progress', 'step.completed',
|
|
1584
|
-
'step.failed', 'step.skipped', 'dataset.lifecycle',
|
|
1585
|
-
'activity.observed', 'work.counters'
|
|
1586
|
-
) THEN jsonb_strip_nulls(jsonb_build_object(
|
|
1629
|
+
WHEN event.kind IN (${RUN_EVENT_SNAPSHOT_KIND_SQL_LIST})
|
|
1630
|
+
THEN jsonb_strip_nulls(jsonb_build_object(
|
|
1587
1631
|
'type', event.kind, 'runId', value->'runId',
|
|
1588
1632
|
'occurredAt', value->'occurredAt', 'source', value->'source'
|
|
1589
1633
|
) || CASE event.kind
|
|
1590
|
-
WHEN
|
|
1634
|
+
WHEN ${RUN_EVENT_KIND_SQL_LITERAL.runCreated} THEN jsonb_build_object(
|
|
1591
1635
|
'playName', value->'playName', 'status', value->'status',
|
|
1592
1636
|
'runtimeBackend', value->'runtimeBackend')
|
|
1593
|
-
WHEN
|
|
1637
|
+
WHEN ${RUN_EVENT_KIND_SQL_LITERAL.runStarted} THEN jsonb_build_object(
|
|
1594
1638
|
'playName', value->'playName', 'runtimeBackend', value->'runtimeBackend')
|
|
1595
|
-
WHEN
|
|
1639
|
+
WHEN ${RUN_EVENT_KIND_SQL_LITERAL.runWaiting} THEN jsonb_build_object(
|
|
1596
1640
|
'waitKind', value->'waitKind', 'waitUntil', value->'waitUntil')
|
|
1597
|
-
WHEN
|
|
1641
|
+
WHEN ${RUN_EVENT_KIND_SQL_LITERAL.runCompleted} THEN jsonb_build_object(
|
|
1598
1642
|
'result', value->'result', 'resultSummary', value->'resultSummary',
|
|
1599
1643
|
'terminalWorkCounterSegment', value->'terminalWorkCounterSegment')
|
|
1600
|
-
WHEN
|
|
1644
|
+
WHEN ${RUN_EVENT_KIND_SQL_LITERAL.runFailed} THEN jsonb_build_object(
|
|
1601
1645
|
'error', value->'error', 'result', value->'result',
|
|
1602
1646
|
'resultSummary', value->'resultSummary',
|
|
1603
1647
|
'terminalWorkCounterSegment', value->'terminalWorkCounterSegment')
|
|
1604
|
-
WHEN
|
|
1648
|
+
WHEN ${RUN_EVENT_KIND_SQL_LITERAL.runCancelled} THEN jsonb_build_object(
|
|
1605
1649
|
'error', value->'error', 'result', value->'result')
|
|
1606
|
-
WHEN
|
|
1650
|
+
WHEN ${RUN_EVENT_KIND_SQL_LITERAL.stepStarted} THEN jsonb_build_object(
|
|
1607
1651
|
'stepId', value->'stepId', 'label', value->'label',
|
|
1608
1652
|
'kind', value->'kind', 'artifactTableNamespace', value->'artifactTableNamespace')
|
|
1609
|
-
WHEN
|
|
1653
|
+
WHEN ${RUN_EVENT_KIND_SQL_LITERAL.stepProgress} THEN jsonb_build_object(
|
|
1610
1654
|
'stepId', value->'stepId', 'label', value->'label',
|
|
1611
1655
|
'kind', value->'kind', 'status', value->'status', 'progress', value->'progress')
|
|
1612
|
-
WHEN
|
|
1656
|
+
WHEN ${RUN_EVENT_KIND_SQL_LITERAL.stepCompleted} THEN jsonb_build_object(
|
|
1613
1657
|
'stepId', value->'stepId', 'label', value->'label',
|
|
1614
1658
|
'kind', value->'kind', 'artifactTableNamespace', value->'artifactTableNamespace')
|
|
1615
|
-
WHEN
|
|
1659
|
+
WHEN ${RUN_EVENT_KIND_SQL_LITERAL.stepFailed} THEN jsonb_build_object(
|
|
1616
1660
|
'stepId', value->'stepId', 'label', value->'label', 'kind', value->'kind',
|
|
1617
1661
|
'error', value->'error', 'artifactTableNamespace', value->'artifactTableNamespace')
|
|
1618
|
-
WHEN
|
|
1662
|
+
WHEN ${RUN_EVENT_KIND_SQL_LITERAL.stepSkipped} THEN jsonb_build_object(
|
|
1619
1663
|
'stepId', value->'stepId', 'label', value->'label',
|
|
1620
1664
|
'kind', value->'kind', 'artifactTableNamespace', value->'artifactTableNamespace')
|
|
1621
|
-
WHEN
|
|
1665
|
+
WHEN ${RUN_EVENT_KIND_SQL_LITERAL.datasetLifecycle} THEN jsonb_build_object(
|
|
1622
1666
|
'datasetId', value->'datasetId', 'path', value->'path',
|
|
1623
1667
|
'tableNamespace', value->'tableNamespace', 'phase', value->'phase',
|
|
1624
1668
|
'persistedRows', value->'persistedRows', 'succeededRows', value->'succeededRows',
|
|
1625
1669
|
'failedRows', value->'failedRows', 'complete', value->'complete',
|
|
1626
1670
|
'bornFrom', value->'bornFrom')
|
|
1627
|
-
WHEN
|
|
1671
|
+
WHEN ${RUN_EVENT_KIND_SQL_LITERAL.activityObserved} THEN jsonb_build_object(
|
|
1628
1672
|
'observation', value->'observation')
|
|
1629
|
-
WHEN
|
|
1673
|
+
WHEN ${RUN_EVENT_KIND_SQL_LITERAL.workCounters} THEN jsonb_build_object(
|
|
1630
1674
|
'attempt', value->'attempt', 'invocationSeq', value->'invocationSeq',
|
|
1631
1675
|
'segmentId', value->'segmentId', 'logicalCalls', value->'logicalCalls',
|
|
1632
1676
|
'providerRequests', value->'providerRequests', 'provider429s', value->'provider429s',
|
|
@@ -1689,7 +1733,7 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1689
1733
|
FROM ${schema}.runs WHERE run_id = NEW.run_id;
|
|
1690
1734
|
IF compact_logs OR canonical_events THEN
|
|
1691
1735
|
NEW.payload_json := NEW.payload_json - 'terminalLogLines' - 'terminalLogContexts';
|
|
1692
|
-
IF NEW.event_type =
|
|
1736
|
+
IF NEW.event_type = ${RUN_SCHEDULER_OUTBOX_EVENT_TYPE_SQL_LITERAL.runEvents} THEN
|
|
1693
1737
|
NEW.payload_json := jsonb_set(NEW.payload_json, '{events}',
|
|
1694
1738
|
${schema}.without_log_events(NEW.payload_json->'events'))
|
|
1695
1739
|
|| jsonb_build_object('logBodyStore', 'planet_scale');
|
|
@@ -1698,17 +1742,17 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1698
1742
|
NEW.payload_json := jsonb_set(NEW.payload_json, '{terminalProgressEvents}',
|
|
1699
1743
|
${schema}.without_log_events(NEW.payload_json->'terminalProgressEvents'));
|
|
1700
1744
|
END IF;
|
|
1701
|
-
IF NEW.event_type =
|
|
1745
|
+
IF NEW.event_type = ${RUN_EVENT_KIND_SQL_LITERAL.runFailed} AND NEW.payload_json ? 'result' THEN
|
|
1702
1746
|
NEW.payload_json := jsonb_set(NEW.payload_json, '{result}',
|
|
1703
1747
|
${schema}.compact_runner_log_envelope(NEW.payload_json->'result'));
|
|
1704
1748
|
END IF;
|
|
1705
|
-
IF NEW.event_type =
|
|
1749
|
+
IF NEW.event_type = ${RUN_EVENT_KIND_SQL_LITERAL.runCompleted} AND NEW.payload_json ? 'output' THEN
|
|
1706
1750
|
NEW.payload_json := jsonb_set(NEW.payload_json, '{output}',
|
|
1707
1751
|
${schema}.without_runtime_log_tail(NEW.payload_json->'output'));
|
|
1708
1752
|
END IF;
|
|
1709
1753
|
END IF;
|
|
1710
1754
|
IF canonical_events THEN
|
|
1711
|
-
IF NEW.event_type =
|
|
1755
|
+
IF NEW.event_type = ${RUN_SCHEDULER_OUTBOX_EVENT_TYPE_SQL_LITERAL.runEvents} THEN
|
|
1712
1756
|
NEW.payload_json := jsonb_set(NEW.payload_json, '{events}',
|
|
1713
1757
|
${schema}.convex_projection_events(NEW.payload_json->'events'));
|
|
1714
1758
|
END IF;
|
|
@@ -1737,12 +1781,12 @@ export async function attachRuntimeEventSearchTriggers(
|
|
|
1737
1781
|
sha256(convert_to(NEW.runner_result_json::text, 'UTF8')), 'hex');
|
|
1738
1782
|
observation.event_id := 'runner-terminal-logs:' || NEW.run_id || ':' || NEW.attempt;
|
|
1739
1783
|
observation.run_id := NEW.run_id;
|
|
1740
|
-
observation.event_type :=
|
|
1784
|
+
observation.event_type := ${RUN_SCHEDULER_OUTBOX_EVENT_TYPE_SQL_LITERAL.runnerLogs};
|
|
1741
1785
|
observation.created_at := coalesce(NEW.runner_terminal_received_at, clock_timestamp());
|
|
1742
1786
|
observation.payload_json := jsonb_set(NEW.runner_log_payload_json,
|
|
1743
1787
|
'{terminalProgressEvents}', (
|
|
1744
1788
|
SELECT coalesce(jsonb_agg(
|
|
1745
|
-
CASE WHEN event->>'type' =
|
|
1789
|
+
CASE WHEN event->>'type' = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended} THEN event
|
|
1746
1790
|
ELSE event || jsonb_build_object('_runtimeProgressOrdinal', position) END
|
|
1747
1791
|
ORDER BY position), '[]'::jsonb)
|
|
1748
1792
|
FROM jsonb_array_elements(CASE
|
|
@@ -1894,12 +1938,12 @@ export async function hasRuntimeEventSearchShape(
|
|
|
1894
1938
|
return result.rows[0]?.ready === true;
|
|
1895
1939
|
}
|
|
1896
1940
|
|
|
1897
|
-
const RUNTIME_EVENT_BODY_RETENTION_PREDICATE = `kind <>
|
|
1941
|
+
const RUNTIME_EVENT_BODY_RETENTION_PREDICATE = `kind <> ${RUN_EVENT_KIND_SQL_LITERAL.logAppended} OR log_body IS NOT NULL
|
|
1898
1942
|
OR message IS NOT NULL OR search_doc ? 'context'`;
|
|
1899
|
-
const RUNTIME_EVENT_CANONICAL_RETENTION_PREDICATE = `(kind <>
|
|
1943
|
+
const RUNTIME_EVENT_CANONICAL_RETENTION_PREDICATE = `(kind <> ${RUN_EVENT_KIND_SQL_LITERAL.logAppended} AND event_payload IS NULL)
|
|
1900
1944
|
OR (substr(kind, 1, 8) = 'receipt.' AND event_payload IS NOT NULL
|
|
1901
1945
|
AND (receipt_ref IS NOT NULL OR receipt_key IS NOT NULL))
|
|
1902
|
-
OR (kind =
|
|
1946
|
+
OR (kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended} AND (log_body IS NOT NULL OR message IS NOT NULL OR search_doc ? 'context'))`;
|
|
1903
1947
|
|
|
1904
1948
|
// pg_get_expr adds grouping and text casts. Preserve quoted literals exactly;
|
|
1905
1949
|
// this known OR-only predicate rejects other operators, keys and literal values.
|
|
@@ -2230,11 +2274,11 @@ export async function pruneRuntimeEvents(
|
|
|
2230
2274
|
event_payload = CASE WHEN event.event_payload IS NULL THEN NULL
|
|
2231
2275
|
ELSE event.event_payload - 'context' END,
|
|
2232
2276
|
search_doc = jsonb_strip_nulls(jsonb_build_object(
|
|
2233
|
-
'kind',
|
|
2277
|
+
'kind', ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}, 'source', event.search_doc->'source',
|
|
2234
2278
|
'producerAttempt', event.search_doc->'producerAttempt',
|
|
2235
2279
|
'logPositions', event.search_doc->'logPositions',
|
|
2236
2280
|
'logContentDigest', event.search_doc->'logContentDigest'))
|
|
2237
|
-
FROM candidates WHERE event.ctid = candidates.ctid AND event.kind =
|
|
2281
|
+
FROM candidates WHERE event.ctid = candidates.ctid AND event.kind = ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}
|
|
2238
2282
|
RETURNING event.event_id
|
|
2239
2283
|
), scrubbed_receipts AS (
|
|
2240
2284
|
UPDATE runtime_observability.events AS event
|
|
@@ -2247,7 +2291,7 @@ export async function pruneRuntimeEvents(
|
|
|
2247
2291
|
RETURNING event.event_id
|
|
2248
2292
|
), deleted AS (
|
|
2249
2293
|
DELETE FROM runtime_observability.events AS event USING candidates
|
|
2250
|
-
WHERE event.ctid = candidates.ctid AND event.kind <>
|
|
2294
|
+
WHERE event.ctid = candidates.ctid AND event.kind <> ${RUN_EVENT_KIND_SQL_LITERAL.logAppended}
|
|
2251
2295
|
AND event.event_payload IS NULL
|
|
2252
2296
|
RETURNING event.event_id
|
|
2253
2297
|
)
|
|
@@ -10,9 +10,9 @@ declare const DEEPLINE_GTM_SKILL = "/deepline-gtm";
|
|
|
10
10
|
* promise of "the same starter workflows offered after setup" was false for
|
|
11
11
|
* anyone who landed on the dashboard first.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* `scripts/check-starter-prompts.ts
|
|
13
|
+
* Mintlify starter blocks are generated from this list by
|
|
14
|
+
* `bun scripts/regen.ts starter-prompts` (also run by the commit hook).
|
|
15
|
+
* `scripts/check-starter-prompts.ts` rejects generated-document drift.
|
|
16
16
|
*/
|
|
17
17
|
declare const DEEPLINE_GTM_STARTER_PROMPTS: readonly [{
|
|
18
18
|
readonly id: "competitor-tracking";
|
|
@@ -24,12 +24,15 @@ declare const DEEPLINE_GTM_STARTER_PROMPTS: readonly [{
|
|
|
24
24
|
readonly prompt: "/deepline-gtm Find 10 CTOs at B2B SaaS companies and enrich them with email addresses.";
|
|
25
25
|
}, {
|
|
26
26
|
readonly id: "decision-maker-discovery";
|
|
27
|
-
readonly title: "
|
|
28
|
-
readonly prompt: "/deepline-gtm Find
|
|
27
|
+
readonly title: "Fintech hiring and growth";
|
|
28
|
+
readonly prompt: "/deepline-gtm Find five fintech companies with live SDR openings and six-month headcount growth. Show dated evidence for both.";
|
|
29
29
|
}];
|
|
30
30
|
/** The first starter prompt, for surfaces that show exactly one example. */
|
|
31
31
|
declare const DEEPLINE_GTM_PRIMARY_STARTER_PROMPT: "/deepline-gtm Track competitors of my company. Use my business email domain when available; otherwise ask for my company name.";
|
|
32
|
-
declare const DEEPLINE_GTM_HANDOFF_QUESTION = "
|
|
32
|
+
declare const DEEPLINE_GTM_HANDOFF_QUESTION = "What would you like to do with Deepline?";
|
|
33
|
+
declare const DEEPLINE_GTM_CUSTOM_OPTION = "Tell me what you want to accomplish and I'll help you build it";
|
|
34
|
+
/** Three executable examples followed by the custom-task choice. */
|
|
35
|
+
declare const DEEPLINE_GTM_STARTER_OPTIONS: readonly [...("/deepline-gtm Track competitors of my company. Use my business email domain when available; otherwise ask for my company name." | "/deepline-gtm Find 10 CTOs at B2B SaaS companies and enrich them with email addresses." | "/deepline-gtm Find five fintech companies with live SDR openings and six-month headcount growth. Show dated evidence for both.")[], "Tell me what you want to accomplish and I'll help you build it"];
|
|
33
36
|
declare function deeplineGtmGettingStartedPayload(): {
|
|
34
37
|
skill: string;
|
|
35
38
|
examples: readonly [{
|
|
@@ -42,11 +45,12 @@ declare function deeplineGtmGettingStartedPayload(): {
|
|
|
42
45
|
readonly prompt: "/deepline-gtm Find 10 CTOs at B2B SaaS companies and enrich them with email addresses.";
|
|
43
46
|
}, {
|
|
44
47
|
readonly id: "decision-maker-discovery";
|
|
45
|
-
readonly title: "
|
|
46
|
-
readonly prompt: "/deepline-gtm Find
|
|
48
|
+
readonly title: "Fintech hiring and growth";
|
|
49
|
+
readonly prompt: "/deepline-gtm Find five fintech companies with live SDR openings and six-month headcount growth. Show dated evidence for both.";
|
|
47
50
|
}];
|
|
48
51
|
question: string;
|
|
52
|
+
customOption: string;
|
|
49
53
|
customProblemBehavior: string;
|
|
50
54
|
};
|
|
51
55
|
|
|
52
|
-
export { DEEPLINE_GTM_HANDOFF_QUESTION, DEEPLINE_GTM_PRIMARY_STARTER_PROMPT, DEEPLINE_GTM_SKILL, DEEPLINE_GTM_STARTER_PROMPTS, deeplineGtmGettingStartedPayload };
|
|
56
|
+
export { DEEPLINE_GTM_CUSTOM_OPTION, DEEPLINE_GTM_HANDOFF_QUESTION, DEEPLINE_GTM_PRIMARY_STARTER_PROMPT, DEEPLINE_GTM_SKILL, DEEPLINE_GTM_STARTER_OPTIONS, DEEPLINE_GTM_STARTER_PROMPTS, deeplineGtmGettingStartedPayload };
|