@senpi/runtime 3.0.123 → 3.0.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/dist/actions/action-events.d.ts +7 -21
  2. package/dist/actions/action-events.d.ts.map +1 -1
  3. package/dist/actions/action-events.js +26 -54
  4. package/dist/actions/action-events.js.map +1 -1
  5. package/dist/actions/action-runtime-module.d.ts.map +1 -1
  6. package/dist/actions/action-runtime-module.js +7 -38
  7. package/dist/actions/action-runtime-module.js.map +1 -1
  8. package/dist/actions/close-position/close-position.action.d.ts.map +1 -1
  9. package/dist/actions/close-position/close-position.action.js +15 -122
  10. package/dist/actions/close-position/close-position.action.js.map +1 -1
  11. package/dist/actions/decision-engine.d.ts.map +1 -1
  12. package/dist/actions/decision-engine.js +2 -15
  13. package/dist/actions/decision-engine.js.map +1 -1
  14. package/dist/actions/event-derivation.d.ts +2 -71
  15. package/dist/actions/event-derivation.d.ts.map +1 -1
  16. package/dist/actions/event-derivation.js +8 -251
  17. package/dist/actions/event-derivation.js.map +1 -1
  18. package/dist/actions/open-position/open-position.action.d.ts +2 -17
  19. package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
  20. package/dist/actions/open-position/open-position.action.js +47 -162
  21. package/dist/actions/open-position/open-position.action.js.map +1 -1
  22. package/dist/actions/position-tracker/position-tracker.action.d.ts +1 -2
  23. package/dist/actions/position-tracker/position-tracker.action.d.ts.map +1 -1
  24. package/dist/actions/position-tracker/position-tracker.action.js +17 -62
  25. package/dist/actions/position-tracker/position-tracker.action.js.map +1 -1
  26. package/dist/actions/store/types.d.ts +2 -9
  27. package/dist/actions/store/types.d.ts.map +1 -1
  28. package/dist/actions/store/types.js.map +1 -1
  29. package/dist/actions/types.d.ts +0 -13
  30. package/dist/actions/types.d.ts.map +1 -1
  31. package/dist/actions/types.js +0 -13
  32. package/dist/actions/types.js.map +1 -1
  33. package/dist/cli/guide-commands.d.ts.map +1 -1
  34. package/dist/cli/guide-commands.js +0 -3
  35. package/dist/cli/guide-commands.js.map +1 -1
  36. package/dist/dsl/engine-client/event-mapping.d.ts.map +1 -1
  37. package/dist/dsl/engine-client/event-mapping.js +0 -14
  38. package/dist/dsl/engine-client/event-mapping.js.map +1 -1
  39. package/dist/dsl/events/build-closed-event.d.ts +1 -16
  40. package/dist/dsl/events/build-closed-event.d.ts.map +1 -1
  41. package/dist/dsl/events/build-closed-event.js +0 -6
  42. package/dist/dsl/events/build-closed-event.js.map +1 -1
  43. package/dist/dsl/events/handlers.d.ts +0 -7
  44. package/dist/dsl/events/handlers.d.ts.map +1 -1
  45. package/dist/dsl/events/handlers.js +7 -37
  46. package/dist/dsl/events/handlers.js.map +1 -1
  47. package/dist/dsl/monitor/create-monitor.d.ts +2 -6
  48. package/dist/dsl/monitor/create-monitor.d.ts.map +1 -1
  49. package/dist/dsl/monitor/create-monitor.js +9 -15
  50. package/dist/dsl/monitor/create-monitor.js.map +1 -1
  51. package/dist/dsl/monitor/dsl-failure-events.d.ts +0 -2
  52. package/dist/dsl/monitor/dsl-failure-events.d.ts.map +1 -1
  53. package/dist/dsl/monitor/dsl-failure-events.js +1 -2
  54. package/dist/dsl/monitor/dsl-failure-events.js.map +1 -1
  55. package/dist/dsl/monitor/process-one-position.d.ts +0 -1
  56. package/dist/dsl/monitor/process-one-position.d.ts.map +1 -1
  57. package/dist/dsl/monitor/process-one-position.js +25 -59
  58. package/dist/dsl/monitor/process-one-position.js.map +1 -1
  59. package/dist/dsl/plugin/index.d.ts +2 -8
  60. package/dist/dsl/plugin/index.d.ts.map +1 -1
  61. package/dist/dsl/plugin/index.js +6 -8
  62. package/dist/dsl/plugin/index.js.map +1 -1
  63. package/dist/health/types.d.ts +0 -13
  64. package/dist/health/types.d.ts.map +1 -1
  65. package/dist/health/types.js +0 -12
  66. package/dist/health/types.js.map +1 -1
  67. package/dist/index.d.ts +4 -27
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +42 -254
  70. package/dist/index.js.map +1 -1
  71. package/dist/runtime/action-registry.d.ts.map +1 -1
  72. package/dist/runtime/action-registry.js +3 -4
  73. package/dist/runtime/action-registry.js.map +1 -1
  74. package/dist/runtime/domain-events.d.ts.map +1 -1
  75. package/dist/runtime/domain-events.js +0 -7
  76. package/dist/runtime/domain-events.js.map +1 -1
  77. package/dist/runtime/lifecycle-events.d.ts +1 -9
  78. package/dist/runtime/lifecycle-events.d.ts.map +1 -1
  79. package/dist/runtime/lifecycle-events.js +2 -11
  80. package/dist/runtime/lifecycle-events.js.map +1 -1
  81. package/dist/runtime/reconcile-run.d.ts +3 -13
  82. package/dist/runtime/reconcile-run.d.ts.map +1 -1
  83. package/dist/runtime/reconcile-run.js +3 -4
  84. package/dist/runtime/reconcile-run.js.map +1 -1
  85. package/dist/runtime/reconcile-state.d.ts +0 -8
  86. package/dist/runtime/reconcile-state.d.ts.map +1 -1
  87. package/dist/runtime/reconcile-state.js +1 -4
  88. package/dist/runtime/reconcile-state.js.map +1 -1
  89. package/dist/runtime/run.d.ts +0 -1
  90. package/dist/runtime/run.d.ts.map +1 -1
  91. package/dist/runtime/run.js.map +1 -1
  92. package/dist/runtime/runtime-schema.js +3 -3
  93. package/dist/runtime/runtime-schema.js.map +1 -1
  94. package/dist/runtime/runtime.d.ts +0 -1
  95. package/dist/runtime/runtime.d.ts.map +1 -1
  96. package/dist/runtime/runtime.js +3 -27
  97. package/dist/runtime/runtime.js.map +1 -1
  98. package/dist/runtime/supervisor/long-running-supervisor.d.ts +0 -13
  99. package/dist/runtime/supervisor/long-running-supervisor.d.ts.map +1 -1
  100. package/dist/runtime/supervisor/long-running-supervisor.js +0 -1
  101. package/dist/runtime/supervisor/long-running-supervisor.js.map +1 -1
  102. package/dist/runtime/validate-dsl-position-tracking.d.ts.map +1 -1
  103. package/dist/runtime/validate-dsl-position-tracking.js +1 -2
  104. package/dist/runtime/validate-dsl-position-tracking.js.map +1 -1
  105. package/dist/runtime-api/handlers/ingest-signals.d.ts.map +1 -1
  106. package/dist/runtime-api/handlers/ingest-signals.js +0 -1
  107. package/dist/runtime-api/handlers/ingest-signals.js.map +1 -1
  108. package/dist/runtime-api/handlers/types.d.ts +0 -5
  109. package/dist/runtime-api/handlers/types.d.ts.map +1 -1
  110. package/dist/runtime-api/intake/intake-events.d.ts +1 -1
  111. package/dist/runtime-api/intake/intake-events.d.ts.map +1 -1
  112. package/dist/runtime-api/intake/intake-events.js +3 -9
  113. package/dist/runtime-api/intake/intake-events.js.map +1 -1
  114. package/dist/runtime-api/intake/intake-mount.d.ts.map +1 -1
  115. package/dist/runtime-api/intake/intake-mount.js +19 -4
  116. package/dist/runtime-api/intake/intake-mount.js.map +1 -1
  117. package/dist/runtime-api/intake/process-error-post.d.ts +1 -6
  118. package/dist/runtime-api/intake/process-error-post.d.ts.map +1 -1
  119. package/dist/runtime-api/intake/process-error-post.js +1 -5
  120. package/dist/runtime-api/intake/process-error-post.js.map +1 -1
  121. package/dist/runtime-api/intake/process-signal-post.d.ts +1 -7
  122. package/dist/runtime-api/intake/process-signal-post.d.ts.map +1 -1
  123. package/dist/runtime-api/intake/process-signal-post.js +0 -5
  124. package/dist/runtime-api/intake/process-signal-post.js.map +1 -1
  125. package/dist/runtime-api/intake/scaffold-error-router.js.map +1 -1
  126. package/dist/runtime-api/intake/scanner-launcher.d.ts.map +1 -1
  127. package/dist/runtime-api/intake/scanner-launcher.js +0 -15
  128. package/dist/runtime-api/intake/scanner-launcher.js.map +1 -1
  129. package/dist/runtime-api/intake/types.d.ts +0 -55
  130. package/dist/runtime-api/intake/types.d.ts.map +1 -1
  131. package/dist/runtime-api/routes/signals.d.ts +0 -2
  132. package/dist/runtime-api/routes/signals.d.ts.map +1 -1
  133. package/dist/runtime-api/routes/signals.js +1 -5
  134. package/dist/runtime-api/routes/signals.js.map +1 -1
  135. package/dist/runtime-api/routes/signals.schema.d.ts +0 -43
  136. package/dist/runtime-api/routes/signals.schema.d.ts.map +1 -1
  137. package/dist/runtime-api/routes/signals.schema.js +0 -43
  138. package/dist/runtime-api/routes/signals.schema.js.map +1 -1
  139. package/dist/runtime-api/server.d.ts +1 -7
  140. package/dist/runtime-api/server.d.ts.map +1 -1
  141. package/dist/runtime-api/server.js +0 -1
  142. package/dist/runtime-api/server.js.map +1 -1
  143. package/dist/scanners/engine/engine.d.ts +1 -22
  144. package/dist/scanners/engine/engine.d.ts.map +1 -1
  145. package/dist/scanners/engine/engine.js +11 -78
  146. package/dist/scanners/engine/engine.js.map +1 -1
  147. package/dist/scanners/engine/lifecycle.d.ts +1 -7
  148. package/dist/scanners/engine/lifecycle.d.ts.map +1 -1
  149. package/dist/scanners/events.d.ts +0 -4
  150. package/dist/scanners/events.d.ts.map +1 -1
  151. package/dist/scanners/events.js +0 -2
  152. package/dist/scanners/events.js.map +1 -1
  153. package/dist/scanners/external/scaffold/delivery.py +25 -194
  154. package/dist/scanners/external/scaffold/scaffold.py +31 -172
  155. package/dist/scanners/external/scaffold/senpi_mcp.py +8 -150
  156. package/dist/scanners/external-scanner-receiver.d.ts +0 -17
  157. package/dist/scanners/external-scanner-receiver.d.ts.map +1 -1
  158. package/dist/scanners/external-scanner-receiver.js +0 -8
  159. package/dist/scanners/external-scanner-receiver.js.map +1 -1
  160. package/dist/scanners/runtime-module.d.ts +0 -1
  161. package/dist/scanners/runtime-module.d.ts.map +1 -1
  162. package/dist/scanners/runtime-module.js +9 -66
  163. package/dist/scanners/runtime-module.js.map +1 -1
  164. package/dist/telemetry/attributes.d.ts +0 -20
  165. package/dist/telemetry/attributes.d.ts.map +1 -1
  166. package/dist/telemetry/attributes.js +0 -24
  167. package/dist/telemetry/attributes.js.map +1 -1
  168. package/dist/telemetry/event-builders.d.ts +6 -81
  169. package/dist/telemetry/event-builders.d.ts.map +1 -1
  170. package/dist/telemetry/event-builders.js +17 -141
  171. package/dist/telemetry/event-builders.js.map +1 -1
  172. package/dist/telemetry/event-store.d.ts +0 -6
  173. package/dist/telemetry/event-store.d.ts.map +1 -1
  174. package/dist/telemetry/event-store.js +8 -12
  175. package/dist/telemetry/event-store.js.map +1 -1
  176. package/dist/telemetry/metrics.d.ts +2 -14
  177. package/dist/telemetry/metrics.d.ts.map +1 -1
  178. package/dist/telemetry/metrics.js +4 -19
  179. package/dist/telemetry/metrics.js.map +1 -1
  180. package/dist/telemetry/spans/redact-pii.d.ts.map +1 -1
  181. package/dist/telemetry/spans/redact-pii.js +2 -18
  182. package/dist/telemetry/spans/redact-pii.js.map +1 -1
  183. package/dist/telemetry/tracing.d.ts +0 -9
  184. package/dist/telemetry/tracing.d.ts.map +1 -1
  185. package/dist/telemetry/tracing.js +0 -36
  186. package/dist/telemetry/tracing.js.map +1 -1
  187. package/dist/types/dsl/index.d.ts +0 -11
  188. package/dist/types/dsl/index.d.ts.map +1 -1
  189. package/dist/types/scanner.d.ts +0 -15
  190. package/dist/types/scanner.d.ts.map +1 -1
  191. package/dist/utils/event-catalog.d.ts +0 -166
  192. package/dist/utils/event-catalog.d.ts.map +1 -1
  193. package/dist/utils/event-catalog.js +0 -18
  194. package/dist/utils/event-catalog.js.map +1 -1
  195. package/dist/utils/logger.d.ts +1 -4
  196. package/dist/utils/logger.d.ts.map +1 -1
  197. package/dist/utils/logger.js.map +1 -1
  198. package/dist/validate/recipe-checks.d.ts.map +1 -1
  199. package/dist/validate/recipe-checks.js +2 -2
  200. package/dist/validate/recipe-checks.js.map +1 -1
  201. package/openclaw.plugin.json +1 -1
  202. package/package.json +1 -1
  203. package/dist/actions/skipped-signal-results.d.ts +0 -25
  204. package/dist/actions/skipped-signal-results.d.ts.map +0 -1
  205. package/dist/actions/skipped-signal-results.js +0 -71
  206. package/dist/actions/skipped-signal-results.js.map +0 -1
  207. package/dist/runtime-api/intake/ingest-request.d.ts +0 -17
  208. package/dist/runtime-api/intake/ingest-request.d.ts.map +0 -1
  209. package/dist/runtime-api/intake/ingest-request.js +0 -34
  210. package/dist/runtime-api/intake/ingest-request.js.map +0 -1
  211. package/dist/runtime-api/intake/scaffold-tick-router.d.ts +0 -39
  212. package/dist/runtime-api/intake/scaffold-tick-router.d.ts.map +0 -1
  213. package/dist/runtime-api/intake/scaffold-tick-router.js +0 -122
  214. package/dist/runtime-api/intake/scaffold-tick-router.js.map +0 -1
  215. package/dist/scanners/external/scaffold/tick_facts.py +0 -130
  216. package/dist/scanners/external/scaffold/ulid.py +0 -58
  217. package/dist/telemetry/live-telemetry.d.ts +0 -238
  218. package/dist/telemetry/live-telemetry.d.ts.map +0 -1
  219. package/dist/telemetry/live-telemetry.js +0 -853
  220. package/dist/telemetry/live-telemetry.js.map +0 -1
  221. package/dist/telemetry/scanner-stats.d.ts +0 -143
  222. package/dist/telemetry/scanner-stats.d.ts.map +0 -1
  223. package/dist/telemetry/scanner-stats.js +0 -426
  224. package/dist/telemetry/scanner-stats.js.map +0 -1
  225. package/dist/telemetry/scanner-tick-feed.d.ts +0 -87
  226. package/dist/telemetry/scanner-tick-feed.d.ts.map +0 -1
  227. package/dist/telemetry/scanner-tick-feed.js +0 -48
  228. package/dist/telemetry/scanner-tick-feed.js.map +0 -1
  229. package/dist/telemetry/strategy-topology.d.ts +0 -99
  230. package/dist/telemetry/strategy-topology.d.ts.map +0 -1
  231. package/dist/telemetry/strategy-topology.js +0 -93
  232. package/dist/telemetry/strategy-topology.js.map +0 -1
  233. package/dist/telemetry/telemetry-publisher.d.ts +0 -63
  234. package/dist/telemetry/telemetry-publisher.d.ts.map +0 -1
  235. package/dist/telemetry/telemetry-publisher.js +0 -229
  236. package/dist/telemetry/telemetry-publisher.js.map +0 -1
  237. package/dist/telemetry/tick-frame.d.ts +0 -212
  238. package/dist/telemetry/tick-frame.d.ts.map +0 -1
  239. package/dist/telemetry/tick-frame.js +0 -421
  240. package/dist/telemetry/tick-frame.js.map +0 -1
  241. package/dist/telemetry/timeline-buffer.d.ts +0 -95
  242. package/dist/telemetry/timeline-buffer.d.ts.map +0 -1
  243. package/dist/telemetry/timeline-buffer.js +0 -237
  244. package/dist/telemetry/timeline-buffer.js.map +0 -1
  245. package/dist/utils/telemetry-required-log.d.ts +0 -60
  246. package/dist/utils/telemetry-required-log.d.ts.map +0 -1
  247. package/dist/utils/telemetry-required-log.js +0 -105
  248. package/dist/utils/telemetry-required-log.js.map +0 -1
  249. package/dist/utils/ulid.d.ts +0 -9
  250. package/dist/utils/ulid.d.ts.map +0 -1
  251. package/dist/utils/ulid.js +0 -43
  252. package/dist/utils/ulid.js.map +0 -1
@@ -1,238 +0,0 @@
1
- /**
2
- * The publisher: the piece that turns the buffer and the three builders into frames on the gateway
3
- * websocket, plus the snapshot a client reads when it connects.
4
- *
5
- * Two things about the transport shape the whole module:
6
- * - The only route to the websocket is a captured `context.broadcast`, and `context` exists only
7
- * inside a gateway RPC handler — the plugin api object has no push surface at all. So the handle is
8
- * captured from the FIRST request of ANY kind, not only from the subscribe method: a box whose
9
- * client never calls subscribe would otherwise hold nothing to publish through, silently.
10
- * - The gateway drops any event name that does not start with `plugin.`, and closes the socket with
11
- * 1008 for a slow client unless the call passes `dropIfSlow`. Both are enforced here rather than at
12
- * each call site, because either mistake is invisible until a client is missing frames.
13
- *
14
- * Three cadences, because the three payloads cost different things to build:
15
- * - timeline, on the flush tick — a drain plus a filter, cheap, and the one a live screen feels.
16
- * - stats, on the sample tick — a scan of the whole held window and an async read of every runtime's
17
- * health and system state, so it runs an order of magnitude less often.
18
- * - topology, on the sample tick but published only when it changes — it rides the same gather as
19
- * stats, and nothing in the plugin signals a topology change, so "on change" means polled and
20
- * diffed rather than pushed.
21
- *
22
- * The snapshot is what stops a client that joins mid-life from seeing an empty screen: it is read
23
- * from the buffer's held window, which the flush drain never evicts.
24
- *
25
- * A fourth broadcast sits outside all of that. The tick frame is a LEVEL — the latest finished run of
26
- * each scanner, most of which produce nothing and so leave no record anywhere — and it is published
27
- * on a window of its own, driven by the runs themselves rather than by a timer that is always
28
- * running. It carries no seq, is never buffered, is not in the snapshot and is not replayed, because
29
- * a client that misses one is made whole by the next one. Keeping it off the buffer is the point: the
30
- * buffer is where decision records live, and per-tick facts would evict them.
31
- *
32
- * Everything that leaves the box is scrubbed here. `logger.event` redacts its `redact` slot and not
33
- * its `attributes`, which is sound for the disk ring — that never leaves — but not for a stream a
34
- * browser reads. There are four ways out — the timeline frame, the stats frame, the tick frame and
35
- * the snapshot that carries one of the first three — and two kinds of free text between them, so the
36
- * scrub sits in two places:
37
- * - {@link toWireRecord} for a timeline record's attributes. It is what makes the flush tick
38
- * asynchronous and gives it an in-flight guard.
39
- * - {@link scrubScannerText} for text a scanner process authored: the scanner state's three
40
- * free-text fields, via {@link scrubStatsPayload}, which reach both the stats frame and the
41
- * snapshot; and a tick's `outcome`. Their content is a stringified throwable or status from a
42
- * scanner process, so they are the strings on the wire with no bound of their own and they are
43
- * capped as well as scrubbed.
44
- *
45
- * The topology payload carries no captured text: its `name` and `scannerId` are operator-authored
46
- * config keys the client joins on, and the scanner `config` that could hold a resolved secret is
47
- * never copied onto it.
48
- */
49
- import type { EventName } from "../utils/event-catalog.js";
50
- import { type TimelineBuffer } from "./timeline-buffer.js";
51
- import { type ScannerRunFacts } from "./scanner-tick-feed.js";
52
- import { type TickFramePayload, type TickTelemetryConfig } from "./tick-frame.js";
53
- import { type ScannerStateSnapshot, type ScannerStatsPayload } from "./scanner-stats.js";
54
- import { type IdMembership, type RuntimeHealthLike, type StrategyTopologyPayload, type TopologyStrategySource } from "./strategy-topology.js";
55
- /** The gateway drops any broadcast whose name does not carry this prefix, with no error. */
56
- export declare const EVENT_TIMELINE = "plugin.senpi.timeline";
57
- export declare const EVENT_STATS = "plugin.senpi.scanner.stats";
58
- export declare const EVENT_TOPOLOGY = "plugin.senpi.strategies";
59
- export declare const EVENT_TICK = "plugin.senpi.tick";
60
- /**
61
- * Byte ceiling for one frame. A frame published here travels southbound — gateway to bridge — and
62
- * meets the bridge's southbound read limit, 1 MiB unless a deployment sets its own; a frame past it
63
- * takes the whole connection down rather than costing the one frame. The budget is set far inside
64
- * that: the payload envelope the gateway wraps around ours, and the growth of a single record's
65
- * attribute bag, both have to fit in the margin, and neither is measured here.
66
- */
67
- export declare const MAX_FRAME_BYTES: number;
68
- /**
69
- * Character ceiling for one of the scanner state's free-text fields on the wire — `lastRunReason`,
70
- * `lastRunStatus` and `degradedReason`.
71
- *
72
- * These carry a stringified throwable from a scanner process, which nothing upstream bounds: an HTTP
73
- * client's error message alone runs to a few hundred characters and a stack-bearing one to
74
- * kilobytes, once per scanner per sample. 1024 holds the sentence that says what failed — the error
75
- * type, the operation and the endpoint. It is also what keeps the payload bounded at all: this frame
76
- * is published whole, with no splitting of the kind the timeline does, so two hundred scanners each
77
- * reporting a 4 KiB error in every one of the three fields serialise to about 1.7 MB — past the read
78
- * limit that ends the connection — and at this cap the same box lands under half of it.
79
- */
80
- export declare const MAX_SCANNER_TEXT_CHARS = 1024;
81
- /**
82
- * What one of those fields reads as when its text could not be scrubbed — no redactor registered, or
83
- * a redactor that threw.
84
- *
85
- * Not `null` and not an absent key: the producer reporting no reason and this box withholding one it
86
- * cannot vouch for are different facts, and a summary screen is read as if they were the same.
87
- */
88
- export declare const SCANNER_TEXT_WITHHELD = "[withheld: not scrubbed]";
89
- /** Flush cadence for the timeline. A live screen feels this number. */
90
- export declare const DEFAULT_FLUSH_INTERVAL_MS = 1000;
91
- /**
92
- * Sample cadence for stats and topology. Both are built from one async read of every runtime's health
93
- * and system state, so they share a tick. Five seconds is roughly a third of the default bucket width
94
- * — fast enough that a counter visibly moves and a hung scan is seen while it is still running, slow
95
- * enough that the per-scanner store read behind the system state is not a poll loop.
96
- */
97
- export declare const DEFAULT_SAMPLE_INTERVAL_MS = 5000;
98
- /**
99
- * How long the first tick of a frame waits for the ticks that land beside it.
100
- *
101
- * Scanners on a box share cadences — a recipe gives several of them the same interval, and every
102
- * runtime starts them within the same boot — so their terminal callbacks arrive in clumps. A frame per
103
- * callback would put one websocket write per scanner per cadence on the wire for a payload of seven
104
- * scalars; one window collapses a clump into a single write. It is short enough that the level a
105
- * dashboard shows is still the current one, and it is not the timeline's flush tick because a tick
106
- * frame must not wait behind a scrub of hundreds of records.
107
- */
108
- export declare const TICK_COALESCE_MS = 250;
109
- /**
110
- * The PUBLICATION list: what leaves on the timeline event. A name being on this list AND on the
111
- * admission list is the normal case, not a duplication — `signal.outcome` is the decision row the feed
112
- * is built around and the source of `opens`/`closes`/`skips`, and the two `scaffold.tick_*` names are
113
- * the source of `errors` and the rows behind the Errors filter. A failing external scanner has to
114
- * leave a visible line, not only a number that silently goes up.
115
- *
116
- * The two lists are separate so admission can be widened for a counter the feed does not display,
117
- * which is the direction that has to stay open: the display filter belongs here at publish time,
118
- * where it is still recoverable, never at append time, where it is not. Today nothing is admitted for
119
- * counting alone, so the sets are equal — the seam is what matters, not the difference.
120
- */
121
- export declare const PUBLISHED_EVENT_NAMES: ReadonlySet<EventName>;
122
- /**
123
- * The share of its own interval a tick may take before it is warned about. A fraction rather than a
124
- * constant, so a deployment that changes a cadence gets a proportional threshold: 250ms on the
125
- * one-second timeline flush, 1.25s on the five-second sample.
126
- *
127
- * A quarter, not a whole interval. Both ticks share an event loop with the serial trading path, so a
128
- * tick holding it for a quarter of its own period is already adding latency to trading; and a tick
129
- * that fills its interval has already started stacking on the next one, which is too late to be told.
130
- */
131
- export declare const SLOW_TICK_FRACTION = 0.25;
132
- /**
133
- * How often the timing summary is logged, and the floor between two slow-tick warns of the same kind.
134
- * The flush tick runs every second, so a line per tick would be tens of thousands a day for numbers
135
- * that only mean anything aggregated — and a repeating tick that is slow is slow every time.
136
- */
137
- export declare const TIMING_REPORT_INTERVAL_MS = 60000;
138
- export interface GatewayBroadcastOpts {
139
- dropIfSlow?: boolean;
140
- stateVersion?: number;
141
- }
142
- export type GatewayBroadcastFn = (event: string, payload: unknown, opts?: GatewayBroadcastOpts) => void;
143
- /** One record as it goes on the wire. */
144
- export interface TimelineWireRecord {
145
- seq: number;
146
- ts: number;
147
- name: string;
148
- level: string;
149
- address: string;
150
- scannerId?: string;
151
- body: string;
152
- attrs: Record<string, string | number | boolean>;
153
- }
154
- export interface TimelinePayload {
155
- v: 1;
156
- epoch: string;
157
- batchSeq: number;
158
- records: TimelineWireRecord[];
159
- }
160
- /**
161
- * A tick frame, in the compact wire shape {@link ./tick-frame.js} builds: a per-frame string
162
- * dictionary, index references into it, times as offsets from one `t0`, and short keys.
163
- *
164
- * It carries no `batchSeq` and its entries carry no `seq`, because there is nothing to resume: this
165
- * is the current state of a set of scanners, and a client that misses a frame is made whole by the
166
- * next one rather than by a replay.
167
- */
168
- export type ScannerTickPayload = TickFramePayload;
169
- export interface TelemetrySnapshot {
170
- epoch: string;
171
- topology: StrategyTopologyPayload;
172
- stats: ScannerStatsPayload;
173
- recent: TimelinePayload;
174
- /**
175
- * The client asked to resume from a cursor inside THIS epoch whose successor is no longer held, or
176
- * the window it is owed did not fit one frame. Either way there is a gap this response cannot fill,
177
- * and only the box knows it: `recent.records` alone looks like a normal short window.
178
- *
179
- * A cursor from another epoch is not truncation. It buys nothing, so the whole retained window is
180
- * served — which is the most this box could ever serve, and so nothing was withheld.
181
- */
182
- truncated: boolean;
183
- }
184
- /** Everything the two builders need that the buffer cannot supply, gathered once per tick. */
185
- export interface TelemetryFacts {
186
- strategies: TopologyStrategySource[];
187
- runningRuntimeIds: IdMembership;
188
- unwiredRuntimeIds: IdMembership;
189
- readHealth?: (runtimeId: string) => RuntimeHealthLike | undefined;
190
- scannerState: ScannerStateSnapshot[];
191
- }
192
- export interface LiveTelemetryOptions {
193
- /** Defaults to the process buffer — one per process, shared by every address. */
194
- buffer?: TimelineBuffer;
195
- collectFacts: () => Promise<TelemetryFacts>;
196
- flushIntervalMs?: number;
197
- sampleIntervalMs?: number;
198
- now?: () => number;
199
- /**
200
- * Monotonic millisecond reader for tick durations. Defaults to `performance.now`; `now` is wall
201
- * clock and can step backwards under NTP, which would report a negative tick.
202
- */
203
- monotonicMs?: () => number;
204
- /**
205
- * How much detail a tick frame carries, as the plugin config states it. Plugin config and not an
206
- * env var on purpose: `register()` re-reads plugin config on a config reload, while a service
207
- * variable change restarts the container. An unusable value warns and falls back rather than
208
- * throwing — a configuration mistake must not be why a box goes dark.
209
- */
210
- tickTelemetry?: TickTelemetryConfig;
211
- }
212
- export interface LiveTelemetry {
213
- readonly epoch: string;
214
- /** Take the broadcast handle off a gateway request context if we do not hold one yet. */
215
- captureBroadcast(ctx: unknown, methodName: string): void;
216
- /** `afterSeq` counts only when `afterEpoch` is the epoch this box is running. */
217
- snapshot(params?: {
218
- afterEpoch?: unknown;
219
- afterSeq?: unknown;
220
- }): Promise<TelemetrySnapshot>;
221
- /** One flush tick: drain, filter to the publication list, scrub, frame, broadcast. */
222
- flushTimeline(): Promise<void>;
223
- /** One sample tick: stats always, topology when it changed. */
224
- sample(): Promise<void>;
225
- /**
226
- * Take one finished scanner run for the next tick frame. Synchronous, never throws, and returns
227
- * without building anything when no client has ever connected. `start` registers this as the
228
- * process tick sink; it is on the interface so a caller holding the publisher can drive it directly.
229
- */
230
- recordTick(run: ScannerRunFacts, startedAt: number | undefined, finishedAt: number): void;
231
- /** Publish whatever the current coalescing window holds, now. */
232
- flushTicks(): Promise<void>;
233
- start(): void;
234
- /** Clear every timer, release the tick sink, drop the captured handle, and empty the timelineBuffer(). */
235
- stop(): void;
236
- }
237
- export declare function createLiveTelemetry(options: LiveTelemetryOptions): LiveTelemetry;
238
- //# sourceMappingURL=live-telemetry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"live-telemetry.d.ts","sourceRoot":"","sources":["../../src/telemetry/live-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAKtE,OAAO,EAGL,KAAK,cAAc,EAEpB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,mBAAmB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