@senpi/runtime 3.0.132 → 3.0.138
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 -12
- package/dist/actions/action-events.d.ts +7 -21
- package/dist/actions/action-events.d.ts.map +1 -1
- package/dist/actions/action-events.js +26 -54
- package/dist/actions/action-events.js.map +1 -1
- package/dist/actions/action-runtime-module.d.ts.map +1 -1
- package/dist/actions/action-runtime-module.js +7 -38
- package/dist/actions/action-runtime-module.js.map +1 -1
- package/dist/actions/close-position/close-position.action.d.ts.map +1 -1
- package/dist/actions/close-position/close-position.action.js +15 -122
- package/dist/actions/close-position/close-position.action.js.map +1 -1
- package/dist/actions/decision-engine.d.ts.map +1 -1
- package/dist/actions/decision-engine.js +2 -15
- package/dist/actions/decision-engine.js.map +1 -1
- package/dist/actions/event-derivation.d.ts +2 -71
- package/dist/actions/event-derivation.d.ts.map +1 -1
- package/dist/actions/event-derivation.js +8 -251
- package/dist/actions/event-derivation.js.map +1 -1
- package/dist/actions/open-position/open-position.action.d.ts +2 -12
- package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
- package/dist/actions/open-position/open-position.action.js +41 -144
- package/dist/actions/open-position/open-position.action.js.map +1 -1
- package/dist/actions/position-tracker/position-tracker.action.d.ts +1 -2
- package/dist/actions/position-tracker/position-tracker.action.d.ts.map +1 -1
- package/dist/actions/position-tracker/position-tracker.action.js +17 -62
- package/dist/actions/position-tracker/position-tracker.action.js.map +1 -1
- package/dist/actions/store/types.d.ts +2 -9
- package/dist/actions/store/types.d.ts.map +1 -1
- package/dist/actions/store/types.js.map +1 -1
- package/dist/actions/types.d.ts +0 -13
- package/dist/actions/types.d.ts.map +1 -1
- package/dist/actions/types.js +0 -13
- package/dist/actions/types.js.map +1 -1
- package/dist/cli/guide-commands.d.ts.map +1 -1
- package/dist/cli/guide-commands.js +13 -8
- package/dist/cli/guide-commands.js.map +1 -1
- package/dist/cli/senpi-commands.d.ts.map +1 -1
- package/dist/cli/senpi-commands.js +11 -4
- package/dist/cli/senpi-commands.js.map +1 -1
- package/dist/constants/dsl/index.d.ts +0 -6
- package/dist/constants/dsl/index.d.ts.map +1 -1
- package/dist/constants/dsl/index.js +0 -6
- package/dist/constants/dsl/index.js.map +1 -1
- package/dist/dsl/engine-client/event-mapping.d.ts.map +1 -1
- package/dist/dsl/engine-client/event-mapping.js +0 -14
- package/dist/dsl/engine-client/event-mapping.js.map +1 -1
- package/dist/dsl/events/build-closed-event.d.ts +1 -16
- package/dist/dsl/events/build-closed-event.d.ts.map +1 -1
- package/dist/dsl/events/build-closed-event.js +0 -6
- package/dist/dsl/events/build-closed-event.js.map +1 -1
- package/dist/dsl/events/handlers.d.ts +0 -7
- package/dist/dsl/events/handlers.d.ts.map +1 -1
- package/dist/dsl/events/handlers.js +7 -37
- package/dist/dsl/events/handlers.js.map +1 -1
- package/dist/dsl/monitor/create-monitor.d.ts +2 -6
- package/dist/dsl/monitor/create-monitor.d.ts.map +1 -1
- package/dist/dsl/monitor/create-monitor.js +9 -82
- package/dist/dsl/monitor/create-monitor.js.map +1 -1
- package/dist/dsl/monitor/dsl-failure-events.d.ts +2 -45
- package/dist/dsl/monitor/dsl-failure-events.d.ts.map +1 -1
- package/dist/dsl/monitor/dsl-failure-events.js +3 -52
- package/dist/dsl/monitor/dsl-failure-events.js.map +1 -1
- package/dist/dsl/monitor/process-one-position.d.ts +0 -1
- package/dist/dsl/monitor/process-one-position.d.ts.map +1 -1
- package/dist/dsl/monitor/process-one-position.js +36 -159
- package/dist/dsl/monitor/process-one-position.js.map +1 -1
- package/dist/dsl/plugin/index.d.ts +2 -8
- package/dist/dsl/plugin/index.d.ts.map +1 -1
- package/dist/dsl/plugin/index.js +6 -8
- package/dist/dsl/plugin/index.js.map +1 -1
- package/dist/health/types.d.ts +0 -13
- package/dist/health/types.d.ts.map +1 -1
- package/dist/health/types.js +0 -12
- package/dist/health/types.js.map +1 -1
- package/dist/index.d.ts +4 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -271
- package/dist/index.js.map +1 -1
- package/dist/runtime/action-registry.d.ts.map +1 -1
- package/dist/runtime/action-registry.js +3 -4
- package/dist/runtime/action-registry.js.map +1 -1
- package/dist/runtime/auto-update/coordinator.d.ts +6 -13
- package/dist/runtime/auto-update/coordinator.d.ts.map +1 -1
- package/dist/runtime/auto-update/coordinator.js +18 -86
- package/dist/runtime/auto-update/coordinator.js.map +1 -1
- package/dist/runtime/auto-update/run-update-command.d.ts.map +1 -1
- package/dist/runtime/auto-update/run-update-command.js +3 -4
- package/dist/runtime/auto-update/run-update-command.js.map +1 -1
- package/dist/runtime/auto-update/types.d.ts +5 -11
- package/dist/runtime/auto-update/types.d.ts.map +1 -1
- package/dist/runtime/auto-update/types.js +0 -11
- package/dist/runtime/auto-update/types.js.map +1 -1
- package/dist/runtime/domain-events.d.ts.map +1 -1
- package/dist/runtime/domain-events.js +0 -7
- package/dist/runtime/domain-events.js.map +1 -1
- package/dist/runtime/lifecycle-events.d.ts +3 -15
- package/dist/runtime/lifecycle-events.d.ts.map +1 -1
- package/dist/runtime/lifecycle-events.js +3 -17
- package/dist/runtime/lifecycle-events.js.map +1 -1
- package/dist/runtime/lifecycle-reaper.d.ts +6 -4
- package/dist/runtime/lifecycle-reaper.d.ts.map +1 -1
- package/dist/runtime/lifecycle-reaper.js +6 -4
- package/dist/runtime/lifecycle-reaper.js.map +1 -1
- package/dist/runtime/reconcile-run.d.ts +3 -13
- package/dist/runtime/reconcile-run.d.ts.map +1 -1
- package/dist/runtime/reconcile-run.js +3 -4
- package/dist/runtime/reconcile-run.js.map +1 -1
- package/dist/runtime/reconcile-state.d.ts +0 -8
- package/dist/runtime/reconcile-state.d.ts.map +1 -1
- package/dist/runtime/reconcile-state.js +1 -4
- package/dist/runtime/reconcile-state.js.map +1 -1
- package/dist/runtime/risk-guard.d.ts +20 -1
- package/dist/runtime/risk-guard.d.ts.map +1 -1
- package/dist/runtime/risk-guard.js +47 -6
- package/dist/runtime/risk-guard.js.map +1 -1
- package/dist/runtime/run.d.ts +0 -1
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js.map +1 -1
- package/dist/runtime/runtime-schema.js +3 -3
- package/dist/runtime/runtime-schema.js.map +1 -1
- package/dist/runtime/runtime.d.ts +3 -2
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +30 -37
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/strategy-lifecycle.d.ts +108 -2
- package/dist/runtime/strategy-lifecycle.d.ts.map +1 -1
- package/dist/runtime/strategy-lifecycle.js +325 -4
- package/dist/runtime/strategy-lifecycle.js.map +1 -1
- package/dist/runtime/supervisor/long-running-supervisor.d.ts +0 -13
- package/dist/runtime/supervisor/long-running-supervisor.d.ts.map +1 -1
- package/dist/runtime/supervisor/long-running-supervisor.js +0 -1
- package/dist/runtime/supervisor/long-running-supervisor.js.map +1 -1
- package/dist/runtime/validate-dsl-position-tracking.d.ts.map +1 -1
- package/dist/runtime/validate-dsl-position-tracking.js +1 -2
- package/dist/runtime/validate-dsl-position-tracking.js.map +1 -1
- package/dist/runtime-api/handlers/ingest-signals.d.ts.map +1 -1
- package/dist/runtime-api/handlers/ingest-signals.js +0 -1
- package/dist/runtime-api/handlers/ingest-signals.js.map +1 -1
- package/dist/runtime-api/handlers/types.d.ts +0 -5
- package/dist/runtime-api/handlers/types.d.ts.map +1 -1
- package/dist/runtime-api/intake/intake-events.d.ts +1 -1
- package/dist/runtime-api/intake/intake-events.d.ts.map +1 -1
- package/dist/runtime-api/intake/intake-events.js +3 -9
- package/dist/runtime-api/intake/intake-events.js.map +1 -1
- package/dist/runtime-api/intake/intake-mount.d.ts.map +1 -1
- package/dist/runtime-api/intake/intake-mount.js +19 -4
- package/dist/runtime-api/intake/intake-mount.js.map +1 -1
- package/dist/runtime-api/intake/process-error-post.d.ts +1 -6
- package/dist/runtime-api/intake/process-error-post.d.ts.map +1 -1
- package/dist/runtime-api/intake/process-error-post.js +1 -5
- package/dist/runtime-api/intake/process-error-post.js.map +1 -1
- package/dist/runtime-api/intake/process-signal-post.d.ts +1 -7
- package/dist/runtime-api/intake/process-signal-post.d.ts.map +1 -1
- package/dist/runtime-api/intake/process-signal-post.js +0 -5
- package/dist/runtime-api/intake/process-signal-post.js.map +1 -1
- package/dist/runtime-api/intake/scaffold-error-router.js.map +1 -1
- package/dist/runtime-api/intake/scanner-launcher.d.ts.map +1 -1
- package/dist/runtime-api/intake/scanner-launcher.js +0 -15
- package/dist/runtime-api/intake/scanner-launcher.js.map +1 -1
- package/dist/runtime-api/intake/types.d.ts +0 -55
- package/dist/runtime-api/intake/types.d.ts.map +1 -1
- package/dist/runtime-api/routes/signals.d.ts +0 -2
- package/dist/runtime-api/routes/signals.d.ts.map +1 -1
- package/dist/runtime-api/routes/signals.js +1 -5
- package/dist/runtime-api/routes/signals.js.map +1 -1
- package/dist/runtime-api/routes/signals.schema.d.ts +0 -43
- package/dist/runtime-api/routes/signals.schema.d.ts.map +1 -1
- package/dist/runtime-api/routes/signals.schema.js +0 -43
- package/dist/runtime-api/routes/signals.schema.js.map +1 -1
- package/dist/runtime-api/server.d.ts +1 -7
- package/dist/runtime-api/server.d.ts.map +1 -1
- package/dist/runtime-api/server.js +0 -1
- package/dist/runtime-api/server.js.map +1 -1
- package/dist/scanners/engine/engine.d.ts +1 -22
- package/dist/scanners/engine/engine.d.ts.map +1 -1
- package/dist/scanners/engine/engine.js +11 -78
- package/dist/scanners/engine/engine.js.map +1 -1
- package/dist/scanners/engine/lifecycle.d.ts +1 -7
- package/dist/scanners/engine/lifecycle.d.ts.map +1 -1
- package/dist/scanners/events.d.ts +0 -4
- package/dist/scanners/events.d.ts.map +1 -1
- package/dist/scanners/events.js +0 -2
- package/dist/scanners/events.js.map +1 -1
- package/dist/scanners/external/scaffold/delivery.py +25 -194
- package/dist/scanners/external/scaffold/scaffold.py +31 -172
- package/dist/scanners/external/scaffold/senpi_mcp.py +8 -150
- package/dist/scanners/external-scanner-receiver.d.ts +0 -17
- package/dist/scanners/external-scanner-receiver.d.ts.map +1 -1
- package/dist/scanners/external-scanner-receiver.js +0 -8
- package/dist/scanners/external-scanner-receiver.js.map +1 -1
- package/dist/scanners/runtime-module.d.ts +0 -1
- package/dist/scanners/runtime-module.d.ts.map +1 -1
- package/dist/scanners/runtime-module.js +9 -66
- package/dist/scanners/runtime-module.js.map +1 -1
- package/dist/telemetry/attributes.d.ts +0 -20
- package/dist/telemetry/attributes.d.ts.map +1 -1
- package/dist/telemetry/attributes.js +0 -24
- package/dist/telemetry/attributes.js.map +1 -1
- package/dist/telemetry/event-builders.d.ts +6 -81
- package/dist/telemetry/event-builders.d.ts.map +1 -1
- package/dist/telemetry/event-builders.js +17 -141
- package/dist/telemetry/event-builders.js.map +1 -1
- package/dist/telemetry/event-store.d.ts +0 -6
- package/dist/telemetry/event-store.d.ts.map +1 -1
- package/dist/telemetry/event-store.js +8 -12
- package/dist/telemetry/event-store.js.map +1 -1
- package/dist/telemetry/metrics.d.ts +2 -14
- package/dist/telemetry/metrics.d.ts.map +1 -1
- package/dist/telemetry/metrics.js +4 -19
- package/dist/telemetry/metrics.js.map +1 -1
- package/dist/telemetry/spans/redact-pii.d.ts.map +1 -1
- package/dist/telemetry/spans/redact-pii.js +2 -18
- package/dist/telemetry/spans/redact-pii.js.map +1 -1
- package/dist/telemetry/tracing.d.ts +0 -9
- package/dist/telemetry/tracing.d.ts.map +1 -1
- package/dist/telemetry/tracing.js +0 -36
- package/dist/telemetry/tracing.js.map +1 -1
- package/dist/types/dsl/index.d.ts +0 -48
- package/dist/types/dsl/index.d.ts.map +1 -1
- package/dist/types/scanner.d.ts +0 -15
- package/dist/types/scanner.d.ts.map +1 -1
- package/dist/utils/event-catalog.d.ts +0 -202
- package/dist/utils/event-catalog.d.ts.map +1 -1
- package/dist/utils/event-catalog.js +0 -26
- package/dist/utils/event-catalog.js.map +1 -1
- package/dist/utils/logger.d.ts +1 -4
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/validate/recipe-checks.d.ts.map +1 -1
- package/dist/validate/recipe-checks.js +2 -2
- package/dist/validate/recipe-checks.js.map +1 -1
- package/openclaw.plugin.json +4 -8
- package/package.json +1 -1
- package/dist/actions/skipped-signal-results.d.ts +0 -25
- package/dist/actions/skipped-signal-results.d.ts.map +0 -1
- package/dist/actions/skipped-signal-results.js +0 -71
- package/dist/actions/skipped-signal-results.js.map +0 -1
- package/dist/runtime-api/intake/ingest-request.d.ts +0 -17
- package/dist/runtime-api/intake/ingest-request.d.ts.map +0 -1
- package/dist/runtime-api/intake/ingest-request.js +0 -34
- package/dist/runtime-api/intake/ingest-request.js.map +0 -1
- package/dist/runtime-api/intake/scaffold-tick-router.d.ts +0 -39
- package/dist/runtime-api/intake/scaffold-tick-router.d.ts.map +0 -1
- package/dist/runtime-api/intake/scaffold-tick-router.js +0 -122
- package/dist/runtime-api/intake/scaffold-tick-router.js.map +0 -1
- package/dist/scanners/external/scaffold/tick_facts.py +0 -130
- package/dist/scanners/external/scaffold/ulid.py +0 -58
- package/dist/telemetry/dsl-positions.d.ts +0 -111
- package/dist/telemetry/dsl-positions.d.ts.map +0 -1
- package/dist/telemetry/dsl-positions.js +0 -118
- package/dist/telemetry/dsl-positions.js.map +0 -1
- package/dist/telemetry/live-telemetry.d.ts +0 -257
- package/dist/telemetry/live-telemetry.d.ts.map +0 -1
- package/dist/telemetry/live-telemetry.js +0 -959
- package/dist/telemetry/live-telemetry.js.map +0 -1
- package/dist/telemetry/scanner-stats.d.ts +0 -143
- package/dist/telemetry/scanner-stats.d.ts.map +0 -1
- package/dist/telemetry/scanner-stats.js +0 -426
- package/dist/telemetry/scanner-stats.js.map +0 -1
- package/dist/telemetry/scanner-tick-feed.d.ts +0 -87
- package/dist/telemetry/scanner-tick-feed.d.ts.map +0 -1
- package/dist/telemetry/scanner-tick-feed.js +0 -48
- package/dist/telemetry/scanner-tick-feed.js.map +0 -1
- package/dist/telemetry/strategy-topology.d.ts +0 -99
- package/dist/telemetry/strategy-topology.d.ts.map +0 -1
- package/dist/telemetry/strategy-topology.js +0 -93
- package/dist/telemetry/strategy-topology.js.map +0 -1
- package/dist/telemetry/telemetry-publisher.d.ts +0 -83
- package/dist/telemetry/telemetry-publisher.d.ts.map +0 -1
- package/dist/telemetry/telemetry-publisher.js +0 -256
- package/dist/telemetry/telemetry-publisher.js.map +0 -1
- package/dist/telemetry/tick-frame.d.ts +0 -212
- package/dist/telemetry/tick-frame.d.ts.map +0 -1
- package/dist/telemetry/tick-frame.js +0 -421
- package/dist/telemetry/tick-frame.js.map +0 -1
- package/dist/telemetry/timeline-buffer.d.ts +0 -95
- package/dist/telemetry/timeline-buffer.d.ts.map +0 -1
- package/dist/telemetry/timeline-buffer.js +0 -237
- package/dist/telemetry/timeline-buffer.js.map +0 -1
- package/dist/utils/telemetry-required-log.d.ts +0 -60
- package/dist/utils/telemetry-required-log.d.ts.map +0 -1
- package/dist/utils/telemetry-required-log.js +0 -105
- package/dist/utils/telemetry-required-log.js.map +0 -1
- package/dist/utils/ulid.d.ts +0 -9
- package/dist/utils/ulid.d.ts.map +0 -1
- package/dist/utils/ulid.js +0 -43
- package/dist/utils/ulid.js.map +0 -1
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The compact `plugin.senpi.tick` frame: the wire shape, the two detail dials that gate it, and the
|
|
3
|
-
* byte budget it is built under.
|
|
4
|
-
*
|
|
5
|
-
* Shape, and why it is compact. A frame carries the latest finished run of every scanner on the box,
|
|
6
|
-
* so the same 42-character wallet, the same scanner name and the same handful of tool names repeat on
|
|
7
|
-
* every entry. A per-frame dictionary interns them once and each entry references them by index; the
|
|
8
|
-
* timestamps are deltas from one frame-level `t0`; and the keys are one or two characters. Two hundred
|
|
9
|
-
* runtimes at full detail land under a tenth of the frame budget this way, where the long-key shape
|
|
10
|
-
* would not.
|
|
11
|
-
*
|
|
12
|
-
* Short keys stop at this boundary. A client's store expands them once at the reducer and its
|
|
13
|
-
* components keep reading `scannedCount`, never `n`.
|
|
14
|
-
*
|
|
15
|
-
* Two dials, not one. `mcp` gates what the MCP boundary reports (`sw`, `mms`, `c`, `cms`) and `state`
|
|
16
|
-
* gates the author's own state projection (`stc`, `st`), because the two cost very different numbers
|
|
17
|
-
* of bytes and an operator watching a slow venue does not also want every author key on the wire. The
|
|
18
|
-
* tick's own summary facts (`q`, `lag`, `jp`, `cm`) belong to neither, so they ride whenever either
|
|
19
|
-
* dial is up: with both off the frame is the always-keys only, which is the shape a box publishes when
|
|
20
|
-
* it wants nothing but proof of life.
|
|
21
|
-
*
|
|
22
|
-
* Nothing here reaches `logger.event` or `appendDomainEvent`. A tick is a LEVEL — see
|
|
23
|
-
* {@link ../utils/telemetry-required-log.js} for why these facts must not become catalogued events.
|
|
24
|
-
*/
|
|
25
|
-
import { capValue } from "./attributes.js";
|
|
26
|
-
import { sanitizeFields as sanitizeScalarFields, sanitizeFieldsWithScalarLists as sanitizeScalarListFields, } from "../utils/telemetry-required-log.js";
|
|
27
|
-
/**
|
|
28
|
-
* The level a source takes when the configuration does not name it.
|
|
29
|
-
*
|
|
30
|
-
* Verbose, not summary: a box is watched by exactly one client over that client's own socket, the
|
|
31
|
-
* frame budget holds two hundred runtimes at this level, and an operator who has to change a setting
|
|
32
|
-
* before the screen can answer why a scanner is slow will not have changed it yet when it matters.
|
|
33
|
-
*/
|
|
34
|
-
export const DEFAULT_TICK_DETAIL = "verbose";
|
|
35
|
-
/** The levels a configured value may name; anything else falls back to the default. */
|
|
36
|
-
const TICK_DETAILS = ["off", "summary", "verbose"];
|
|
37
|
-
/**
|
|
38
|
-
* Character ceiling for one scanner-authored string inside a tick — an outcome, a state value, a
|
|
39
|
-
* tool argument. Matches the cap the stats payload's free text takes, for the same reason: these
|
|
40
|
-
* carry a stringified throwable or an author's own value, and nothing upstream bounds either.
|
|
41
|
-
*/
|
|
42
|
-
export const MAX_TICK_TEXT_CHARS = 1_024;
|
|
43
|
-
/**
|
|
44
|
-
* Calls recorded for one tick. A scanner that calls a tool in a loop would otherwise put an unbounded
|
|
45
|
-
* list on the wire; past this many the tally still counts them (`c` at summary and `cms` stay whole,
|
|
46
|
-
* because they are read off the scaffold's own totals), and only the per-call detail is cut.
|
|
47
|
-
*/
|
|
48
|
-
export const MAX_TICK_CALLS = 64;
|
|
49
|
-
/**
|
|
50
|
-
* Bounds for one list-valued argument, mirroring the producer's own per-list bounds: at most this
|
|
51
|
-
* many elements, and no more characters across the whole list than a single string argument is
|
|
52
|
-
* allowed. The frame is a second, independent gate on values the scaffold already bounded, so it
|
|
53
|
-
* must not admit a longer list than the scaffold can send — and a list from any other producer is
|
|
54
|
-
* held to the same terms here.
|
|
55
|
-
*
|
|
56
|
-
* The frame's byte budget is not a substitute. That budget drops a whole ENTRY that does not fit,
|
|
57
|
-
* so without these one scanner's long list would cost that scanner's entire tick rather than the
|
|
58
|
-
* tail of the list. The character bound is counted AFTER the scrub, for the reason `scrubText`
|
|
59
|
-
* gives: a redaction can be longer than the text it replaced, so a bound taken first would bound
|
|
60
|
-
* the input and not what leaves.
|
|
61
|
-
*/
|
|
62
|
-
export const MAX_TICK_CALL_ARG_LIST_ITEMS = 16;
|
|
63
|
-
export const MAX_TICK_CALL_ARG_LIST_CHARS = 1_024;
|
|
64
|
-
/**
|
|
65
|
-
* `cm` — the state commit outcome, as a RAW STRING and not a dictionary index. Only `a` `s` `m` `o`
|
|
66
|
-
* `x` are interned; these are a small closed set a client reads directly.
|
|
67
|
-
*
|
|
68
|
-
* A tick that committed normally sends nothing at all: the key exists to make the abnormal endings
|
|
69
|
-
* visible, and the common case is not one of them.
|
|
70
|
-
*
|
|
71
|
-
* - `rolled_back` — the tick was not `ok`, so the scaffold discarded the tick's state mutations.
|
|
72
|
-
* - `persist_failed` — the commit was attempted, the write failed, and the tick was rolled back;
|
|
73
|
-
* state did not advance, which is the stall this key exists to make visible.
|
|
74
|
-
*/
|
|
75
|
-
export const COMMIT_ROLLED_BACK = "rolled_back";
|
|
76
|
-
export const COMMIT_PERSIST_FAILED = "persist_failed";
|
|
77
|
-
/** 128 KiB, the same ceiling the timeline and stats frames are split against. */
|
|
78
|
-
const DEFAULT_MAX_FRAME_BYTES = 128 * 1024;
|
|
79
|
-
/** One comma between two members of the same JSON array. */
|
|
80
|
-
const SEPARATOR_BYTES = 1;
|
|
81
|
-
function isTickDetail(value) {
|
|
82
|
-
return typeof value === "string" && TICK_DETAILS.includes(value);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Read the `tickTelemetry` plugin-config value.
|
|
86
|
-
*
|
|
87
|
-
* Never throws and never leaves the caller without settings: an unusable value falls back to the
|
|
88
|
-
* default and is reported in `invalid` so the caller can warn about it once, at startup, the way an
|
|
89
|
-
* unusable `logLevel` is. A configuration mistake must not be the reason a box publishes nothing.
|
|
90
|
-
*/
|
|
91
|
-
export function resolveTickTelemetry(value) {
|
|
92
|
-
const fallback = {
|
|
93
|
-
enabled: true,
|
|
94
|
-
mcp: DEFAULT_TICK_DETAIL,
|
|
95
|
-
state: DEFAULT_TICK_DETAIL,
|
|
96
|
-
};
|
|
97
|
-
if (value === undefined || value === null)
|
|
98
|
-
return { settings: fallback, invalid: undefined };
|
|
99
|
-
if (typeof value === "string") {
|
|
100
|
-
if (!isTickDetail(value)) {
|
|
101
|
-
return { settings: fallback, invalid: `tickTelemetry="${value}"` };
|
|
102
|
-
}
|
|
103
|
-
// A bare level applies to both sources; a bare `off` is the one value that stops the frames
|
|
104
|
-
// themselves, rather than emptying them of everything but the always-keys.
|
|
105
|
-
return { settings: { enabled: value !== "off", mcp: value, state: value } };
|
|
106
|
-
}
|
|
107
|
-
if (typeof value !== "object" || Array.isArray(value)) {
|
|
108
|
-
return { settings: fallback, invalid: `tickTelemetry=${JSON.stringify(value) ?? typeof value}` };
|
|
109
|
-
}
|
|
110
|
-
const raw = value;
|
|
111
|
-
const bad = [];
|
|
112
|
-
const read = (key) => {
|
|
113
|
-
const level = raw[key];
|
|
114
|
-
if (level === undefined)
|
|
115
|
-
return DEFAULT_TICK_DETAIL;
|
|
116
|
-
if (isTickDetail(level))
|
|
117
|
-
return level;
|
|
118
|
-
bad.push(`tickTelemetry.${key}="${String(level)}"`);
|
|
119
|
-
return DEFAULT_TICK_DETAIL;
|
|
120
|
-
};
|
|
121
|
-
const mcp = read("mcp");
|
|
122
|
-
const state = read("state");
|
|
123
|
-
return {
|
|
124
|
-
// The object form never turns the frames off: `{mcp:"off",state:"off"}` is an operator asking
|
|
125
|
-
// for proof of life and nothing else, which is a frame of always-keys — not silence.
|
|
126
|
-
settings: { enabled: true, mcp, state },
|
|
127
|
-
...(bad.length > 0 ? { invalid: bad.join(", ") } : {}),
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
/** Whether a source is at `summary` or better. */
|
|
131
|
-
function atLeastSummary(level) {
|
|
132
|
-
return level !== "off";
|
|
133
|
-
}
|
|
134
|
-
/** A finite, non-negative count, or `undefined` for a value that means nothing. */
|
|
135
|
-
function count(value) {
|
|
136
|
-
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : undefined;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Scrub, then cap, one scanner-authored string. The cap is taken AFTER the scrub because a redaction
|
|
140
|
-
* can be longer than the text it replaced, so a cut taken first would bound the input and not what
|
|
141
|
-
* leaves. A string the scrub could not vouch for is dropped rather than passed through.
|
|
142
|
-
*/
|
|
143
|
-
async function scrubText(text, scrub) {
|
|
144
|
-
if (text === "")
|
|
145
|
-
return "";
|
|
146
|
-
try {
|
|
147
|
-
const scrubbed = await scrub(text);
|
|
148
|
-
return scrubbed === null ? null : capValue(scrubbed, MAX_TICK_TEXT_CHARS);
|
|
149
|
-
}
|
|
150
|
-
catch {
|
|
151
|
-
// The caller's scrub already reports its own failures; a throw here costs the one string.
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
/** Every scalar in a bag, scrubbed. Non-scalars are dropped exactly as the required log drops them. */
|
|
156
|
-
async function scrubScalarBag(bag, scrub) {
|
|
157
|
-
const { attributes } = sanitizeScalarFields(bag);
|
|
158
|
-
const out = {};
|
|
159
|
-
for (const key of Object.keys(attributes)) {
|
|
160
|
-
const value = attributes[key];
|
|
161
|
-
if (typeof value !== "string") {
|
|
162
|
-
out[key] = value;
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
const scrubbed = await scrubText(value, scrub);
|
|
166
|
-
if (scrubbed !== null)
|
|
167
|
-
out[key] = scrubbed;
|
|
168
|
-
}
|
|
169
|
-
return out;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* One list argument, scrubbed and bounded — or `null` when the list is not carried at all.
|
|
173
|
-
*
|
|
174
|
-
* Every string element goes through the same scrub a bare string value does, because a list that
|
|
175
|
-
* bypassed redaction would put on the wire exactly what the scrub exists to keep off it. An element
|
|
176
|
-
* the scrub could not vouch for refuses the whole list: at bag level an unvouchable value costs its
|
|
177
|
-
* key, and this list IS one key's value.
|
|
178
|
-
*
|
|
179
|
-
* Elements cut by either bound are replaced by a trailing count, so a shortened list reads as
|
|
180
|
-
* shortened rather than as a shorter call. The marker is a plain string element because a consumer
|
|
181
|
-
* expands dictionary indexes and scalars, and a nested object would not survive that.
|
|
182
|
-
*/
|
|
183
|
-
async function scrubScalarList(items, scrub) {
|
|
184
|
-
const kept = [];
|
|
185
|
-
let chars = 0;
|
|
186
|
-
for (const item of items.slice(0, MAX_TICK_CALL_ARG_LIST_ITEMS)) {
|
|
187
|
-
const rendered = typeof item === "string" ? await scrubText(item, scrub) : String(item);
|
|
188
|
-
if (rendered === null)
|
|
189
|
-
return null;
|
|
190
|
-
if (chars + rendered.length > MAX_TICK_CALL_ARG_LIST_CHARS)
|
|
191
|
-
break;
|
|
192
|
-
chars += rendered.length;
|
|
193
|
-
kept.push(typeof item === "string" ? rendered : item);
|
|
194
|
-
}
|
|
195
|
-
if (kept.length < items.length)
|
|
196
|
-
kept.push(`+${items.length - kept.length} more`);
|
|
197
|
-
return kept;
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* One call's arguments: every scalar as the state projection keeps them, and additionally a list
|
|
201
|
-
* whose every element is a scalar.
|
|
202
|
-
*
|
|
203
|
-
* Which assets a scanner priced is the argument an operator reads first, and it arrives as a list —
|
|
204
|
-
* so an argument bag is the one bag on this frame that needs the wider rule. It is asked for HERE
|
|
205
|
-
* and not in the shared sanitiser: the narrow rule is a contract the required log's consumer and the
|
|
206
|
-
* author's state projection both depend on, and neither may gain lists because an argument bag
|
|
207
|
-
* wanted them.
|
|
208
|
-
*/
|
|
209
|
-
async function scrubCallArgs(bag, scrub) {
|
|
210
|
-
const { attributes } = sanitizeScalarListFields(bag);
|
|
211
|
-
const out = {};
|
|
212
|
-
for (const key of Object.keys(attributes)) {
|
|
213
|
-
const value = attributes[key];
|
|
214
|
-
if (Array.isArray(value)) {
|
|
215
|
-
const list = await scrubScalarList(value, scrub);
|
|
216
|
-
if (list !== null)
|
|
217
|
-
out[key] = list;
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
if (typeof value !== "string") {
|
|
221
|
-
out[key] = value;
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
const scrubbed = await scrubText(value, scrub);
|
|
225
|
-
if (scrubbed !== null)
|
|
226
|
-
out[key] = scrubbed;
|
|
227
|
-
}
|
|
228
|
-
return out;
|
|
229
|
-
}
|
|
230
|
-
export function createTickFrameBuilder(options) {
|
|
231
|
-
const { epoch, t0, settings } = options;
|
|
232
|
-
const maxBytes = options.maxBytes ?? DEFAULT_MAX_FRAME_BYTES;
|
|
233
|
-
const dictionary = { a: [], s: [], m: [], o: [], x: [] };
|
|
234
|
-
const entries = [];
|
|
235
|
-
// What the frame costs before it holds anything. Counted rather than estimated, so the running
|
|
236
|
-
// total below is the size of the frame that goes out and not a sum of approximations.
|
|
237
|
-
let bytes = Buffer.byteLength(JSON.stringify({ v: 1, e: epoch, t0, d: dictionary, k: [] }));
|
|
238
|
-
/**
|
|
239
|
-
* The index of `text` in a dictionary slot, interning it when it is new.
|
|
240
|
-
*
|
|
241
|
-
* `added` accumulates what the new strings cost, so an entry that turns out not to fit can have
|
|
242
|
-
* them taken back out again: a dropped entry must not leave its wallet in the dictionary of a
|
|
243
|
-
* frame that never mentions it.
|
|
244
|
-
*/
|
|
245
|
-
function intern(slot, text, added) {
|
|
246
|
-
const list = dictionary[slot];
|
|
247
|
-
const found = list.indexOf(text);
|
|
248
|
-
if (found !== -1)
|
|
249
|
-
return found;
|
|
250
|
-
added.bytes += Buffer.byteLength(JSON.stringify(text)) + (list.length > 0 ? SEPARATOR_BYTES : 0);
|
|
251
|
-
list.push(text);
|
|
252
|
-
return list.length - 1;
|
|
253
|
-
}
|
|
254
|
-
/** Every slot's length, so interning can be undone wholesale. */
|
|
255
|
-
function marks() {
|
|
256
|
-
return {
|
|
257
|
-
a: dictionary.a.length,
|
|
258
|
-
s: dictionary.s.length,
|
|
259
|
-
m: dictionary.m.length,
|
|
260
|
-
o: dictionary.o.length,
|
|
261
|
-
x: dictionary.x.length,
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
function restore(mark) {
|
|
265
|
-
dictionary.a.length = mark.a;
|
|
266
|
-
dictionary.s.length = mark.s;
|
|
267
|
-
dictionary.m.length = mark.m;
|
|
268
|
-
dictionary.o.length = mark.o;
|
|
269
|
-
dictionary.x.length = mark.x;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* `c` and its two companions, in whichever of the two shapes the MCP dial asks for.
|
|
273
|
-
*
|
|
274
|
-
* Summary is a count per tool: what the scanner did, in the fewest bytes that can say it. Verbose
|
|
275
|
-
* is one element per call with its duration and its arguments, which is what answers where the time
|
|
276
|
-
* went — and `cms` is dropped there because the per-call durations already carry the total.
|
|
277
|
-
*/
|
|
278
|
-
async function mcpKeys(tick, scrub, added) {
|
|
279
|
-
if (settings.mcp === "off")
|
|
280
|
-
return {};
|
|
281
|
-
const out = {};
|
|
282
|
-
// A producer that reported no call information at all — an in-process scanner — is not a
|
|
283
|
-
// producer that made no calls. The first leaves `c` off entirely; the second sends it empty.
|
|
284
|
-
const calls = tick.mcpCalls;
|
|
285
|
-
if (calls === undefined) {
|
|
286
|
-
const swallowedOnly = count(tick.mcpFailures);
|
|
287
|
-
if (swallowedOnly !== undefined && swallowedOnly > 0)
|
|
288
|
-
out.sw = swallowedOnly;
|
|
289
|
-
return out;
|
|
290
|
-
}
|
|
291
|
-
// The time split rides with the MCP source and is absent when the tick called no tool at all —
|
|
292
|
-
// a zero would read as "MCP was instant" rather than "MCP was not used".
|
|
293
|
-
const mcpMs = count(tick.mcpMs);
|
|
294
|
-
if (mcpMs !== undefined && calls.length > 0)
|
|
295
|
-
out.mms = mcpMs;
|
|
296
|
-
const swallowed = count(tick.mcpFailures);
|
|
297
|
-
if (swallowed !== undefined && swallowed > 0)
|
|
298
|
-
out.sw = swallowed;
|
|
299
|
-
if (settings.mcp === "summary") {
|
|
300
|
-
const counts = {};
|
|
301
|
-
for (const call of calls) {
|
|
302
|
-
const index = intern("m", capValue(call.tool, MAX_TICK_TEXT_CHARS), added);
|
|
303
|
-
counts[index] = (counts[index] ?? 0) + 1;
|
|
304
|
-
}
|
|
305
|
-
out.c = counts;
|
|
306
|
-
return out;
|
|
307
|
-
}
|
|
308
|
-
const detail = [];
|
|
309
|
-
for (const call of calls.slice(0, MAX_TICK_CALLS)) {
|
|
310
|
-
const tool = intern("m", capValue(call.tool, MAX_TICK_TEXT_CHARS), added);
|
|
311
|
-
const ms = count(call.ms) ?? 0;
|
|
312
|
-
const args = call.args === undefined ? {} : await scrubCallArgs(call.args, scrub);
|
|
313
|
-
if (call.errorType === undefined) {
|
|
314
|
-
detail.push([tool, ms, args]);
|
|
315
|
-
continue;
|
|
316
|
-
}
|
|
317
|
-
const err = intern("x", capValue(call.errorType, MAX_TICK_TEXT_CHARS), added);
|
|
318
|
-
detail.push([tool, ms, args, err]);
|
|
319
|
-
}
|
|
320
|
-
out.c = detail;
|
|
321
|
-
return out;
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* `cms` rides at BOTH levels, the one number the frame repeats. A client could sum the per-call
|
|
325
|
-
* durations at verbose, but two implementations of the same total disagree eventually, so the box
|
|
326
|
-
* states it and neither side derives it.
|
|
327
|
-
*/
|
|
328
|
-
function totalCallMs(tick) {
|
|
329
|
-
return settings.mcp === "off" ? undefined : count(tick.mcpMs);
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* `stc` at summary, `st` at verbose, nothing at off — exactly one of the two, never both.
|
|
333
|
-
*
|
|
334
|
-
* The projection is the last COMMITTED row, so it is stale by one tick whenever the current tick
|
|
335
|
-
* failed. That is the point: a tick that could not commit is precisely when an operator wants to
|
|
336
|
-
* see what the scanner last agreed on.
|
|
337
|
-
*/
|
|
338
|
-
async function stateKeys(tick, scrub) {
|
|
339
|
-
if (settings.state === "off")
|
|
340
|
-
return {};
|
|
341
|
-
if (settings.state === "summary") {
|
|
342
|
-
const changed = count(tick.stateChangedCount);
|
|
343
|
-
const total = count(tick.stateFieldCount);
|
|
344
|
-
if (changed === undefined || total === undefined)
|
|
345
|
-
return {};
|
|
346
|
-
return { stc: [changed, total] };
|
|
347
|
-
}
|
|
348
|
-
if (tick.state === undefined)
|
|
349
|
-
return {};
|
|
350
|
-
return { st: await scrubScalarBag(tick.state, scrub) };
|
|
351
|
-
}
|
|
352
|
-
async function add(tick, scrub) {
|
|
353
|
-
if (!settings.enabled)
|
|
354
|
-
return false;
|
|
355
|
-
const mark = marks();
|
|
356
|
-
const added = { bytes: 0 };
|
|
357
|
-
try {
|
|
358
|
-
const outcome = (await scrubText(tick.outcome, scrub)) ?? "";
|
|
359
|
-
const scanned = count(tick.scannedCount);
|
|
360
|
-
const duration = count(tick.durationMs);
|
|
361
|
-
const summary = atLeastSummary(settings.mcp) || atLeastSummary(settings.state);
|
|
362
|
-
const quiet = summary ? count(tick.quietTicks) : undefined;
|
|
363
|
-
const lag = summary ? count(tick.lagMs) : undefined;
|
|
364
|
-
const journal = summary ? count(tick.journalPending) : undefined;
|
|
365
|
-
const commit = summary && tick.commit !== undefined && tick.commit !== "committed"
|
|
366
|
-
? tick.commit
|
|
367
|
-
: undefined;
|
|
368
|
-
// The two indexes are taken before the spread below so the dictionary is interned in a fixed
|
|
369
|
-
// order, then the entry is assembled in the CONTRACT's own key order: a frame then reads the
|
|
370
|
-
// way its table does, and two frames of the same shape serialise to the same bytes.
|
|
371
|
-
const a = intern("a", tick.address, added);
|
|
372
|
-
const s = intern("s", tick.scannerId, added);
|
|
373
|
-
const o = intern("o", outcome, added);
|
|
374
|
-
const mcp = await mcpKeys(tick, scrub, added);
|
|
375
|
-
const cms = totalCallMs(tick);
|
|
376
|
-
const state = await stateKeys(tick, scrub);
|
|
377
|
-
const entry = {
|
|
378
|
-
a,
|
|
379
|
-
s,
|
|
380
|
-
t: tick.finishedAt - t0,
|
|
381
|
-
o,
|
|
382
|
-
...(scanned === undefined ? {} : { n: scanned }),
|
|
383
|
-
g: count(tick.signalCount) ?? 0,
|
|
384
|
-
...(duration === undefined ? {} : { ms: duration }),
|
|
385
|
-
...(mcp.mms === undefined ? {} : { mms: mcp.mms }),
|
|
386
|
-
...(quiet !== undefined && quiet > 0 ? { q: quiet } : {}),
|
|
387
|
-
...(lag !== undefined && lag > 0 ? { lag } : {}),
|
|
388
|
-
...(mcp.sw === undefined ? {} : { sw: mcp.sw }),
|
|
389
|
-
...(journal !== undefined && journal > 0 ? { jp: journal } : {}),
|
|
390
|
-
...(commit === undefined ? {} : { cm: commit }),
|
|
391
|
-
...(mcp.c === undefined ? {} : { c: mcp.c }),
|
|
392
|
-
...(cms === undefined ? {} : { cms }),
|
|
393
|
-
...(state.stc === undefined ? {} : { stc: state.stc }),
|
|
394
|
-
...(state.st === undefined ? {} : { st: state.st }),
|
|
395
|
-
};
|
|
396
|
-
// Bytes, not entry count: one non-ASCII character in a scanner-authored string costs up to
|
|
397
|
-
// three of them, and the read limit at the far end counts bytes. The separator is counted with
|
|
398
|
-
// the member it precedes, so the running total is the frame's own size and not a sum under it.
|
|
399
|
-
const cost = added.bytes +
|
|
400
|
-
Buffer.byteLength(JSON.stringify(entry)) +
|
|
401
|
-
(entries.length > 0 ? SEPARATOR_BYTES : 0);
|
|
402
|
-
if (bytes + cost > maxBytes) {
|
|
403
|
-
restore(mark);
|
|
404
|
-
return false;
|
|
405
|
-
}
|
|
406
|
-
entries.push(entry);
|
|
407
|
-
bytes += cost;
|
|
408
|
-
return true;
|
|
409
|
-
}
|
|
410
|
-
catch {
|
|
411
|
-
// A malformed producer value must cost its own tick and nothing else.
|
|
412
|
-
restore(mark);
|
|
413
|
-
return false;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
return {
|
|
417
|
-
add,
|
|
418
|
-
build: () => entries.length === 0 ? null : { v: 1, e: epoch, t0, d: dictionary, k: entries },
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
//# sourceMappingURL=tick-frame.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tick-frame.js","sourceRoot":"","sources":["../../src/telemetry/tick-frame.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EACL,cAAc,IAAI,oBAAoB,EACtC,6BAA6B,IAAI,wBAAwB,GAE1D,MAAM,oCAAoC,CAAC;AAe5C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAe,SAAS,CAAC;AAEzD,uFAAuF;AACvF,MAAM,YAAY,GAA0B,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAEzC;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE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EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;gBACtD,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;aACpD,CAAC;YAEF,2FAA2F;YAC3F,+FAA+F;YAC/F,+FAA+F;YAC/F,MAAM,IAAI,GACR,KAAK,CAAC,KAAK;gBACX,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;gBACxC,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7C,IAAI,KAAK,GAAG,IAAI,GAAG,QAAQ,EAAE,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,CAAC;gBACd,OAAO,KAAK,CAAC;YACf,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpB,KAAK,IAAI,IAAI,CAAC;YACd,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,sEAAsE;YACtE,OAAO,CAAC,IAAI,CAAC,CAAC;YACd,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO;QACL,GAAG;QACH,KAAK,EAAE,GAAG,EAAE,CACV,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE;KAClF,CAAC;AACJ,CAAC"}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-memory recent-window buffer for the live telemetry stream: the records a client replays on
|
|
3
|
-
* subscribe and the records the stats view is computed from. One buffer per process, partitioned by
|
|
4
|
-
* strategy address — the same shape as the disk ring's process-global sink map, because the tap that
|
|
5
|
-
* feeds it (`appendDomainEvent`) is process-global too.
|
|
6
|
-
*
|
|
7
|
-
* Three things make a client's state recoverable across a reconnect:
|
|
8
|
-
* - `epoch`, a ULID minted when the buffer is created. A change means the plugin restarted, not that
|
|
9
|
-
* frames were lost.
|
|
10
|
-
* - `seq`, monotonic per epoch across every address, so `(epoch, seq)` is a dedupe and resume key and
|
|
11
|
-
* a single `afterSeq` cursor is unambiguous. It never rewinds while the epoch holds — not on
|
|
12
|
-
* teardown, not on eviction.
|
|
13
|
-
* - {@link TimelineBuffer.oldestTs}, the stamp of the oldest record still held. A client whose cursor
|
|
14
|
-
* predates it knows it has a gap that no replay can fill.
|
|
15
|
-
*
|
|
16
|
-
* The write path is on the serial trading path: it takes one bounded slot write and returns. It does
|
|
17
|
-
* no I/O, awaits nothing, computes nothing, and never throws.
|
|
18
|
-
*/
|
|
19
|
-
import type { AttrValue } from "../utils/event-catalog.js";
|
|
20
|
-
import { type LogLevel } from "../utils/logger.js";
|
|
21
|
-
/**
|
|
22
|
-
* Records held per address before the oldest is overwritten. The bound is a record COUNT, per
|
|
23
|
-
* address: a fixed-size ring makes eviction a single slot write (no scan, no shift) and makes the
|
|
24
|
-
* oldest stamp an O(1) read, both of which a byte or age bound would cost the write path. Per address
|
|
25
|
-
* rather than process-wide so one chatty strategy cannot evict a quiet one's window.
|
|
26
|
-
*
|
|
27
|
-
* This is the number to change when the retention window is measured — see also the
|
|
28
|
-
* `maxRecordsPerAddress` option, which overrides it per buffer.
|
|
29
|
-
*/
|
|
30
|
-
export declare const DEFAULT_MAX_RECORDS_PER_ADDRESS = 2000;
|
|
31
|
-
/** The seq of the first record of an epoch. Records start at 1, so `afterSeq: 0` means "everything". */
|
|
32
|
-
export declare const FIRST_SEQ = 1;
|
|
33
|
-
/** One record as the tap hands it over, before the buffer stamps a seq. */
|
|
34
|
-
export interface TimelineRecordInput {
|
|
35
|
-
/** Call-time epoch ms, stamped by `logger.event`. */
|
|
36
|
-
ts: number;
|
|
37
|
-
name: string;
|
|
38
|
-
level: LogLevel;
|
|
39
|
-
address: string;
|
|
40
|
-
/** The engine scanner id. Absent — never empty — on a record that has no scanner. */
|
|
41
|
-
scannerId?: string;
|
|
42
|
-
body: string;
|
|
43
|
-
attrs: Record<string, AttrValue>;
|
|
44
|
-
}
|
|
45
|
-
/** A buffered record: the tap's input plus its position in the epoch. */
|
|
46
|
-
export interface TimelineRecord extends TimelineRecordInput {
|
|
47
|
-
seq: number;
|
|
48
|
-
}
|
|
49
|
-
/** Filters for {@link TimelineBuffer.read}; all optional, all combinable. Time bounds are inclusive. */
|
|
50
|
-
export interface TimelineQuery {
|
|
51
|
-
/** Exclusive lower bound on seq — the client's resume cursor. */
|
|
52
|
-
afterSeq?: number;
|
|
53
|
-
address?: string;
|
|
54
|
-
scannerId?: string;
|
|
55
|
-
sinceMs?: number;
|
|
56
|
-
untilMs?: number;
|
|
57
|
-
/** Keep the last N after filtering (newest tail). */
|
|
58
|
-
limit?: number;
|
|
59
|
-
}
|
|
60
|
-
export interface TimelineBufferOptions {
|
|
61
|
-
/** Overrides {@link DEFAULT_MAX_RECORDS_PER_ADDRESS}. Clamped to at least one record. */
|
|
62
|
-
maxRecordsPerAddress?: number;
|
|
63
|
-
}
|
|
64
|
-
export interface TimelineBuffer {
|
|
65
|
-
/** ULID minted with this buffer. Rides every published payload. */
|
|
66
|
-
readonly epoch: string;
|
|
67
|
-
/** Copy one record in and return. Never blocks, never throws. */
|
|
68
|
-
append(input: TimelineRecordInput): void;
|
|
69
|
-
/** Records matching `query`, oldest first. */
|
|
70
|
-
read(query?: TimelineQuery): TimelineRecord[];
|
|
71
|
-
/** Stamp of the oldest record still held across every address; undefined when nothing is held. */
|
|
72
|
-
oldestTs(): number | undefined;
|
|
73
|
-
/**
|
|
74
|
-
* The largest seq this buffer has thrown away, or zero when it has thrown away nothing. A client
|
|
75
|
-
* resuming from a cursor BELOW this lost at least one record; a cursor at or above it lost none.
|
|
76
|
-
*
|
|
77
|
-
* It is not the oldest seq still held. The rings are per address, so a quiet strategy keeps a low
|
|
78
|
-
* seq alive long after a chatty one has evicted everything above it, and the oldest record held
|
|
79
|
-
* then says nothing about what a resuming client is missing.
|
|
80
|
-
*/
|
|
81
|
-
highestDroppedSeq(): number;
|
|
82
|
-
/** Records appended since the last drain, oldest first. Reads the publish frontier — does not evict. */
|
|
83
|
-
drain(): TimelineRecord[];
|
|
84
|
-
/** Drop every record. The seq counter is deliberately not rewound. */
|
|
85
|
-
teardown(): void;
|
|
86
|
-
}
|
|
87
|
-
export declare function createTimelineBuffer(options?: TimelineBufferOptions): TimelineBuffer;
|
|
88
|
-
/** The process's telemetry buffer, minted (with its epoch) on first use. */
|
|
89
|
-
export declare function getTimelineBuffer(): TimelineBuffer;
|
|
90
|
-
/**
|
|
91
|
-
* Drop the process buffer on plugin reload or shutdown. The next {@link getTimelineBuffer} mints a
|
|
92
|
-
* fresh epoch, so the restarted seq run cannot collide with the one a client already holds.
|
|
93
|
-
*/
|
|
94
|
-
export declare function teardownTimelineBuffer(): void;
|
|
95
|
-
//# sourceMappingURL=timeline-buffer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timeline-buffer.d.ts","sourceRoot":"","sources":["../../src/telemetry/timeline-buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAKjE;;;;;;;;GAQG;AACH,eAAO,MAAM,+BAA+B,OAAO,CAAC;AAEpD,wGAAwG;AACxG,eAAO,MAAM,SAAS,IAAI,CAAC;AAE3B,2EAA2E;AAC3E,MAAM,WAAW,mBAAmB;IAClC,qDAAqD;IACrD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ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