@teamscala/service-boot 0.23.356 → 0.23.358

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/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "name": "@teamscala/service-boot",
8
8
  "type": "module",
9
- "version": "0.23.356",
9
+ "version": "0.23.358",
10
10
  "sideEffects": false,
11
11
  "imports": {
12
12
  "#service-boot/*": "./src/*",
@@ -36,7 +36,6 @@
36
36
  "@teamscala/object-storage": "*",
37
37
  "@teamscala/orpc": "*",
38
38
  "@teamscala/os": "*",
39
- "@teamscala/proc-walker": "*",
40
39
  "@teamscala/realtime-utils": "*",
41
40
  "@teamscala/resolver-engine": "*",
42
41
  "@teamscala/timing": "*",
@@ -402,6 +401,14 @@
402
401
  "types": "./src/handlers/bun-stable-watch.d.ts",
403
402
  "default": "./src/handlers/bun-stable-watch.ts"
404
403
  },
404
+ "./handlers/lane-attention-sweep": {
405
+ "types": "./src/handlers/lane-attention-sweep.d.ts",
406
+ "default": "./src/handlers/lane-attention-sweep.ts"
407
+ },
408
+ "./handlers/lane-attention-sweep.ts": {
409
+ "types": "./src/handlers/lane-attention-sweep.d.ts",
410
+ "default": "./src/handlers/lane-attention-sweep.ts"
411
+ },
405
412
  "./handlers/pane-outbox-drain": {
406
413
  "types": "./src/handlers/pane-outbox-drain.d.ts",
407
414
  "default": "./src/handlers/pane-outbox-drain.ts"
@@ -898,22 +905,6 @@
898
905
  "types": "./src/security-headers.d.ts",
899
906
  "default": "./src/security-headers.ts"
900
907
  },
901
- "./serve/serve": {
902
- "types": "./src/serve/serve.d.ts",
903
- "default": "./src/serve/serve.ts"
904
- },
905
- "./serve/serve.ts": {
906
- "types": "./src/serve/serve.d.ts",
907
- "default": "./src/serve/serve.ts"
908
- },
909
- "./serve/stamp-transport-identity": {
910
- "types": "./src/serve/stamp-transport-identity.d.ts",
911
- "default": "./src/serve/stamp-transport-identity.ts"
912
- },
913
- "./serve/stamp-transport-identity.ts": {
914
- "types": "./src/serve/stamp-transport-identity.d.ts",
915
- "default": "./src/serve/stamp-transport-identity.ts"
916
- },
917
908
  "./server-error-page": {
918
909
  "types": "./src/server-error-page.d.ts",
919
910
  "default": "./src/server-error-page.ts"
@@ -0,0 +1,81 @@
1
+ /**
2
+ * @system server-boot
3
+ * @status handwritten
4
+ * @edit edit directly
5
+ *
6
+ * The `lane-attention-sweep` pg-boss handler. Calls the database function that
7
+ * reminds an orchestrator about lanes waiting on it, and records the outcome.
8
+ *
9
+ * This handler holds NO POLICY. Which lanes are waiting, how long counts as
10
+ * waiting, who is told, what the message says, and how often it may repeat are
11
+ * all in `lane_needs_attention` and `sweep_lanes_needing_attention` — so
12
+ * changing any of them is a migration, not a rebuild and redeploy of this
13
+ * service. All this file supplies is the tick and the telemetry.
14
+ *
15
+ * WHY A TICK EXISTS AT ALL, given `observability-is-passive` and
16
+ * `no-polling-for-pushable-state`. Both forbid polling for state a source CAN
17
+ * push. Here the trigger is the PASSAGE OF TIME against a threshold: a lane
18
+ * going silent emits nothing, because emitting is exactly what it stopped
19
+ * doing. There is no state transition to react to, so nothing could push it.
20
+ * The same justification `registry-stale-inactive-sweep` carries, recorded on
21
+ * the row as `poll_justification`.
22
+ *
23
+ * Registered under slug `@teamscala/service-boot:lane-attention-sweep`.
24
+ */
25
+ import type { ScheduledJobConfig } from "@teamscala/db-validation/registry-schemas/scheduled-job";
26
+ import { getPrisma } from "@teamscala/db/prisma-registry";
27
+ import { recordEvent } from "@teamscala/event-log/record-event";
28
+ import { getAppLogger } from "@teamscala/logger/app-loggers";
29
+ import { pgBossHandlerRegistry } from "../pg-boss-handler-registry.ts";
30
+
31
+ interface RemindedLane {
32
+ task_id: string;
33
+ window_name: string | null;
34
+ reason: string;
35
+ orchestrator_project_id: string;
36
+ }
37
+
38
+ async function laneAttentionSweep(ctx: { config: ScheduledJobConfig }): Promise<void> {
39
+ const log = getAppLogger();
40
+ const prisma = getPrisma();
41
+
42
+ // The repeat window is the row's, so silencing a chatty reminder is a
43
+ // registry edit. The default lives in the SQL function's signature, which is
44
+ // the one place it is defined.
45
+ const repeatAfter = (ctx.config as { repeat_after?: string }).repeat_after;
46
+
47
+ const reminded = repeatAfter
48
+ ? await prisma.$queryRawUnsafe<RemindedLane[]>(
49
+ "SELECT * FROM sweep_lanes_needing_attention($1::interval)",
50
+ repeatAfter,
51
+ )
52
+ : await prisma.$queryRawUnsafe<RemindedLane[]>("SELECT * FROM sweep_lanes_needing_attention()");
53
+
54
+ // Emitted even when nothing was due. A sweep that only reports on the runs
55
+ // where it found something is indistinguishable from a sweep that stopped
56
+ // running, and this exists precisely to notice silence.
57
+ recordEvent({
58
+ kind: "fleet.lane-attention.swept",
59
+ payload: {
60
+ remindedCount: reminded.length,
61
+ lanes: reminded.map((lane) => ({
62
+ task: lane.task_id,
63
+ window: lane.window_name,
64
+ reason: lane.reason,
65
+ toldOrchestrator: lane.orchestrator_project_id,
66
+ })),
67
+ },
68
+ });
69
+
70
+ if (reminded.length > 0) {
71
+ log.info(
72
+ `[lane-attention-sweep] reminded ${reminded.length} orchestrator(s) about waiting lanes`,
73
+ { lanes: reminded.map((lane) => `${lane.window_name}: ${lane.reason}`) },
74
+ );
75
+ }
76
+ }
77
+
78
+ pgBossHandlerRegistry.register(
79
+ "@teamscala/service-boot:lane-attention-sweep",
80
+ laneAttentionSweep as (ctx: { config: ScheduledJobConfig }) => Promise<void>,
81
+ );
@@ -34,6 +34,7 @@ import "./handlers/scala-tools-currency-watch.ts";
34
34
  import "./handlers/singleton-tools-currency-watch.ts";
35
35
  import "./handlers/registry-stale-inactive-sweep.ts";
36
36
  import "./handlers/pane-outbox-drain.ts";
37
+ import "./handlers/lane-attention-sweep.ts";
37
38
 
38
39
  /**
39
40
  * Module-level reference to the mounted PgBoss instance — set by mountPgBoss on