@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.
- 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 -17
- package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
- package/dist/actions/open-position/open-position.action.js +47 -162
- 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 +0 -3
- package/dist/cli/guide-commands.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 -15
- package/dist/dsl/monitor/create-monitor.js.map +1 -1
- package/dist/dsl/monitor/dsl-failure-events.d.ts +0 -2
- package/dist/dsl/monitor/dsl-failure-events.d.ts.map +1 -1
- package/dist/dsl/monitor/dsl-failure-events.js +1 -2
- 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 +25 -59
- 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 +42 -254
- 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/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 +1 -9
- package/dist/runtime/lifecycle-events.d.ts.map +1 -1
- package/dist/runtime/lifecycle-events.js +2 -11
- package/dist/runtime/lifecycle-events.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/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 +0 -1
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +3 -27
- package/dist/runtime/runtime.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 -11
- 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 -166
- package/dist/utils/event-catalog.d.ts.map +1 -1
- package/dist/utils/event-catalog.js +0 -18
- 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 +1 -1
- 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/live-telemetry.d.ts +0 -238
- package/dist/telemetry/live-telemetry.d.ts.map +0 -1
- package/dist/telemetry/live-telemetry.js +0 -853
- 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 -63
- package/dist/telemetry/telemetry-publisher.d.ts.map +0 -1
- package/dist/telemetry/telemetry-publisher.js +0 -229
- 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 +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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E,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,MAA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K,IAAI,cAAc,EAAE,CAAC;IAC1B,sEAAsE;IACtE,QAAQ,IAAI,IAAI,CAAC;CAClB;AAkDD,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,qBAA0B,GAAG,cAAc,CA8IxF;AAMD,4EAA4E;AAC5E,wBAAgB,iBAAiB,IAAI,cAAc,CAGlD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAG7C"}
|
|
@@ -1,237 +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 { newUlid } from "../utils/ulid.js";
|
|
20
|
-
import { createLogger } from "../utils/logger.js";
|
|
21
|
-
import { normalizeStrategyAddress } from "./event-store.js";
|
|
22
|
-
const logger = createLogger("[senpi-core][timeline-buffer]");
|
|
23
|
-
/**
|
|
24
|
-
* Records held per address before the oldest is overwritten. The bound is a record COUNT, per
|
|
25
|
-
* address: a fixed-size ring makes eviction a single slot write (no scan, no shift) and makes the
|
|
26
|
-
* oldest stamp an O(1) read, both of which a byte or age bound would cost the write path. Per address
|
|
27
|
-
* rather than process-wide so one chatty strategy cannot evict a quiet one's window.
|
|
28
|
-
*
|
|
29
|
-
* This is the number to change when the retention window is measured — see also the
|
|
30
|
-
* `maxRecordsPerAddress` option, which overrides it per buffer.
|
|
31
|
-
*/
|
|
32
|
-
export const DEFAULT_MAX_RECORDS_PER_ADDRESS = 2000;
|
|
33
|
-
/** The seq of the first record of an epoch. Records start at 1, so `afterSeq: 0` means "everything". */
|
|
34
|
-
export const FIRST_SEQ = 1;
|
|
35
|
-
/**
|
|
36
|
-
* A fixed-size ring of one address's records. Appending past capacity overwrites the oldest slot, so
|
|
37
|
-
* a write is one index assignment regardless of how full the ring is.
|
|
38
|
-
*/
|
|
39
|
-
class RecordRing {
|
|
40
|
-
capacity;
|
|
41
|
-
slots;
|
|
42
|
-
head = 0;
|
|
43
|
-
count = 0;
|
|
44
|
-
constructor(capacity) {
|
|
45
|
-
this.capacity = capacity;
|
|
46
|
-
this.slots = new Array(capacity);
|
|
47
|
-
}
|
|
48
|
-
/** The seq of the record this write overwrote, or undefined while the ring still has room. */
|
|
49
|
-
push(record) {
|
|
50
|
-
const evicted = this.count === this.capacity ? this.slots[this.head]?.seq : undefined;
|
|
51
|
-
this.slots[(this.head + this.count) % this.capacity] = record;
|
|
52
|
-
if (this.count === this.capacity) {
|
|
53
|
-
this.head = (this.head + 1) % this.capacity;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
this.count++;
|
|
57
|
-
}
|
|
58
|
-
return evicted;
|
|
59
|
-
}
|
|
60
|
-
oldest() {
|
|
61
|
-
return this.count === 0 ? undefined : this.slots[this.head];
|
|
62
|
-
}
|
|
63
|
-
/** Every held record, oldest first. */
|
|
64
|
-
toArray() {
|
|
65
|
-
const out = [];
|
|
66
|
-
for (let i = 0; i < this.count; i++) {
|
|
67
|
-
const record = this.slots[(this.head + i) % this.capacity];
|
|
68
|
-
if (record !== undefined)
|
|
69
|
-
out.push(record);
|
|
70
|
-
}
|
|
71
|
-
return out;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function matches(record, query) {
|
|
75
|
-
if (query.afterSeq !== undefined && record.seq <= query.afterSeq)
|
|
76
|
-
return false;
|
|
77
|
-
if (query.scannerId !== undefined && record.scannerId !== query.scannerId)
|
|
78
|
-
return false;
|
|
79
|
-
if (query.sinceMs !== undefined && record.ts < query.sinceMs)
|
|
80
|
-
return false;
|
|
81
|
-
if (query.untilMs !== undefined && record.ts > query.untilMs)
|
|
82
|
-
return false;
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
export function createTimelineBuffer(options = {}) {
|
|
86
|
-
const requested = options.maxRecordsPerAddress ?? DEFAULT_MAX_RECORDS_PER_ADDRESS;
|
|
87
|
-
// A ring of zero slots would divide by zero on every write; a caller asking for less than one
|
|
88
|
-
// record gets the smallest ring that still works rather than a wedged buffer.
|
|
89
|
-
const capacity = Number.isFinite(requested) ? Math.max(1, Math.floor(requested)) : DEFAULT_MAX_RECORDS_PER_ADDRESS;
|
|
90
|
-
const epoch = newUlid();
|
|
91
|
-
const rings = new Map();
|
|
92
|
-
let nextSeq = FIRST_SEQ;
|
|
93
|
-
let drainCursor = FIRST_SEQ - 1;
|
|
94
|
-
// The eviction frontier, tracked on the write path because it cannot be recovered on the read
|
|
95
|
-
// path: once a record is overwritten, nothing left in the buffer records that it existed.
|
|
96
|
-
let highestDropped = 0;
|
|
97
|
-
// One-shot per buffer, not reset on a later success: bad and good records interleave on this path,
|
|
98
|
-
// so resetting on success would turn the guard into a warn-per-record on a hot loop. Warning once
|
|
99
|
-
// is enough to make the upstream bug findable.
|
|
100
|
-
let warnedNoAddress = false;
|
|
101
|
-
let warnedBadTimestamp = false;
|
|
102
|
-
let warnedAppendFailure = false;
|
|
103
|
-
function ringFor(address) {
|
|
104
|
-
let ring = rings.get(address);
|
|
105
|
-
if (ring === undefined) {
|
|
106
|
-
ring = new RecordRing(capacity);
|
|
107
|
-
rings.set(address, ring);
|
|
108
|
-
}
|
|
109
|
-
return ring;
|
|
110
|
-
}
|
|
111
|
-
function collect(query) {
|
|
112
|
-
const address = query.address === undefined ? undefined : normalizeStrategyAddress(query.address);
|
|
113
|
-
// An address filter selects the partition rather than filtering records, so one address's read
|
|
114
|
-
// cannot reach another's ring at all.
|
|
115
|
-
const searched = address === undefined ? [...rings.values()] : [rings.get(address)];
|
|
116
|
-
const out = [];
|
|
117
|
-
for (const ring of searched) {
|
|
118
|
-
if (ring === undefined)
|
|
119
|
-
continue;
|
|
120
|
-
for (const record of ring.toArray()) {
|
|
121
|
-
if (matches(record, query))
|
|
122
|
-
out.push(record);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
// Each ring is already in seq order; the sort merges partitions into the one order a client
|
|
126
|
-
// resumes on. Read side only — the write path never sorts.
|
|
127
|
-
out.sort((a, b) => a.seq - b.seq);
|
|
128
|
-
return query.limit !== undefined && query.limit > 0 ? out.slice(-query.limit) : out;
|
|
129
|
-
}
|
|
130
|
-
return {
|
|
131
|
-
epoch,
|
|
132
|
-
append(input) {
|
|
133
|
-
try {
|
|
134
|
-
const raw = input?.address;
|
|
135
|
-
const address = typeof raw === "string" ? normalizeStrategyAddress(raw) : "";
|
|
136
|
-
if (address === "") {
|
|
137
|
-
// The tap resolves the address and early-returns without one, so a record arriving here
|
|
138
|
-
// unattributed is an upstream break — it cannot be filed under any strategy.
|
|
139
|
-
if (!warnedNoAddress) {
|
|
140
|
-
warnedNoAddress = true;
|
|
141
|
-
logger.warn("timeline buffer dropped a record with no strategy address", {
|
|
142
|
-
"senpi.event.name": typeof input?.name === "string" ? input.name : "unknown",
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
// `since` is load-bearing — a client reads it to decide whether it has an unfillable gap — so
|
|
148
|
-
// an unusable stamp is replaced with the arrival time rather than poisoning the window.
|
|
149
|
-
let ts = input.ts;
|
|
150
|
-
if (typeof ts !== "number" || !Number.isFinite(ts)) {
|
|
151
|
-
ts = Date.now();
|
|
152
|
-
if (!warnedBadTimestamp) {
|
|
153
|
-
warnedBadTimestamp = true;
|
|
154
|
-
logger.warn("timeline record carried an unusable timestamp; stamping arrival time", {
|
|
155
|
-
"senpi.event.name": typeof input.name === "string" ? input.name : "unknown",
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
const evicted = ringFor(address).push({
|
|
160
|
-
seq: nextSeq++,
|
|
161
|
-
ts,
|
|
162
|
-
name: input.name,
|
|
163
|
-
level: input.level,
|
|
164
|
-
address,
|
|
165
|
-
// Omitted, not present-and-undefined: absent is the wire's own statement about a record
|
|
166
|
-
// with no scanner, and a held record that spells it differently is a second answer to
|
|
167
|
-
// the same question.
|
|
168
|
-
...(input.scannerId === undefined ? {} : { scannerId: input.scannerId }),
|
|
169
|
-
body: input.body,
|
|
170
|
-
// The caller builds a fresh attribute bag per event and does not mutate it afterwards, so
|
|
171
|
-
// the reference is carried as-is — copying it would be work on the trading path.
|
|
172
|
-
attrs: input.attrs ?? {},
|
|
173
|
-
});
|
|
174
|
-
if (evicted !== undefined && evicted > highestDropped)
|
|
175
|
-
highestDropped = evicted;
|
|
176
|
-
}
|
|
177
|
-
catch (err) {
|
|
178
|
-
// The buffer sits on the serial trading path and must never disturb its caller. A wedged
|
|
179
|
-
// buffer must not be silent either.
|
|
180
|
-
if (!warnedAppendFailure) {
|
|
181
|
-
warnedAppendFailure = true;
|
|
182
|
-
logger.warn("timeline buffer append failed; the live stream may be incomplete", {
|
|
183
|
-
err: err instanceof Error ? err.message : String(err),
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
read(query = {}) {
|
|
189
|
-
return collect(query);
|
|
190
|
-
},
|
|
191
|
-
oldestTs() {
|
|
192
|
-
let oldest;
|
|
193
|
-
for (const ring of rings.values()) {
|
|
194
|
-
const record = ring.oldest();
|
|
195
|
-
if (record === undefined)
|
|
196
|
-
continue;
|
|
197
|
-
if (oldest === undefined || record.ts < oldest)
|
|
198
|
-
oldest = record.ts;
|
|
199
|
-
}
|
|
200
|
-
return oldest;
|
|
201
|
-
},
|
|
202
|
-
highestDroppedSeq() {
|
|
203
|
-
return highestDropped;
|
|
204
|
-
},
|
|
205
|
-
drain() {
|
|
206
|
-
const batch = collect({ afterSeq: drainCursor });
|
|
207
|
-
const last = batch[batch.length - 1];
|
|
208
|
-
// Advance only to what was actually returned: records evicted before this drain are gone, and
|
|
209
|
-
// anything newer than the cursor still comes back on the next tick.
|
|
210
|
-
if (last !== undefined)
|
|
211
|
-
drainCursor = last.seq;
|
|
212
|
-
return batch;
|
|
213
|
-
},
|
|
214
|
-
teardown() {
|
|
215
|
-
// Everything held is now gone, so the frontier moves to the last seq issued: a client holding
|
|
216
|
-
// any cursor from this run lost whatever it had not already read.
|
|
217
|
-
highestDropped = nextSeq - 1;
|
|
218
|
-
rings.clear();
|
|
219
|
-
},
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
// ─── The process buffer: one instance, shared by every runtime in this plugin process ───
|
|
223
|
-
let processBuffer = null;
|
|
224
|
-
/** The process's telemetry buffer, minted (with its epoch) on first use. */
|
|
225
|
-
export function getTimelineBuffer() {
|
|
226
|
-
processBuffer ??= createTimelineBuffer();
|
|
227
|
-
return processBuffer;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Drop the process buffer on plugin reload or shutdown. The next {@link getTimelineBuffer} mints a
|
|
231
|
-
* fresh epoch, so the restarted seq run cannot collide with the one a client already holds.
|
|
232
|
-
*/
|
|
233
|
-
export function teardownTimelineBuffer() {
|
|
234
|
-
processBuffer?.teardown();
|
|
235
|
-
processBuffer = null;
|
|
236
|
-
}
|
|
237
|
-
//# sourceMappingURL=timeline-buffer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timeline-bu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G,CAAC;YAC/C,OAAO,KAAK,CAAC;QACf,CAAC;QAED,QAAQ;YACN,8FAA8F;YAC9F,kEAAkE;YAClE,cAAc,GAAG,OAAO,GAAG,CAAC,CAAC;YAC7B,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC;AAED,2FAA2F;AAE3F,IAAI,aAAa,GAA0B,IAAI,CAAC;AAEhD,4EAA4E;AAC5E,MAAM,UAAU,iBAAiB;IAC/B,aAAa,KAAK,oBAAoB,EAAE,CAAC;IACzC,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB;IACpC,aAAa,EAAE,QAAQ,EAAE,CAAC;IAC1B,aAAa,GAAG,IAAI,CAAC;AACvB,CAAC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A structured log that telemetry reads. It is a LOG on purpose — not an event — and it must stay one.
|
|
3
|
-
*
|
|
4
|
-
* Do NOT "promote" a call site here to `logger.event()`, and do not delete or downgrade one as noise:
|
|
5
|
-
* a telemetry consumer parses these records by their field names.
|
|
6
|
-
*
|
|
7
|
-
* Why a log and not an event: `logger.event()` is unconditional (the trade narrative may never go
|
|
8
|
-
* dark) and every event also reaches `appendDomainEvent`, which feeds the per-strategy on-disk ring
|
|
9
|
-
* and the live-telemetry publisher's bounded in-memory buffer. These facts are per-tick and
|
|
10
|
-
* high-frequency, so catalogued they would evict real decision records from that buffer. Routed
|
|
11
|
-
* through the plain log path they stay level-gated — silenceable by configuration, no code change —
|
|
12
|
-
* and nothing taps them, so nothing is evicted.
|
|
13
|
-
*
|
|
14
|
-
* The level is fixed at `info`: the default minimum level, so these records are present in a stock
|
|
15
|
-
* deployment, while `SENPI_LOG_LEVEL=warn` still silences them. `debug` would be off by default and
|
|
16
|
-
* telemetry would go dark without anyone noticing.
|
|
17
|
-
*/
|
|
18
|
-
import type { Logger } from "./logger.js";
|
|
19
|
-
/** A value a consumer can parse on sight: no shape to walk, no encoding to agree on. */
|
|
20
|
-
export type TelemetryScalar = string | number | boolean;
|
|
21
|
-
/** Named structured fields — scalars only. A consumer reads keys, never a formatted sentence. */
|
|
22
|
-
export type TelemetryLogFields = Record<string, TelemetryScalar>;
|
|
23
|
-
/** Named structured fields, widened by one shape: a list whose every element is a scalar. */
|
|
24
|
-
export type TelemetryListFields = Record<string, TelemetryScalar | TelemetryScalar[]>;
|
|
25
|
-
/**
|
|
26
|
-
* Keep the values a consumer can actually parse: strings, finite numbers, booleans. Everything else —
|
|
27
|
-
* objects, arrays, `null`/`undefined`, `NaN`/`Infinity`, functions — is dropped and counted.
|
|
28
|
-
*
|
|
29
|
-
* Exported because the tick frame's state projection has to apply the SAME rule to an author's own
|
|
30
|
-
* state row. Sharing the implementation is what makes "sanitised exactly as the required log does"
|
|
31
|
-
* true rather than intended.
|
|
32
|
-
*/
|
|
33
|
-
export declare function sanitizeFields(fields: unknown): {
|
|
34
|
-
attributes: TelemetryLogFields;
|
|
35
|
-
dropped: number;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* `sanitizeFields`, widened by exactly one shape: a list whose every element is a scalar.
|
|
39
|
-
*
|
|
40
|
-
* A SECOND entry point rather than a flag on the first, because the two rules belong to different
|
|
41
|
-
* consumers and the narrow one is a contract two call sites depend on. The required log's consumer
|
|
42
|
-
* reads flat named fields, and the tick frame's state projection promises to carry what that log
|
|
43
|
-
* would have written; neither may gain lists as a side effect of a caller that wants them.
|
|
44
|
-
*
|
|
45
|
-
* A single non-scalar element refuses the WHOLE list rather than filtering it down. Filtering would
|
|
46
|
-
* let an author's unbounded nested value decide how much of itself gets rendered, and scalars-only
|
|
47
|
-
* is the rule that keeps a nested payload off the wire. The kept list is a new array, so the
|
|
48
|
-
* caller's own can still be mutated without changing what was recorded.
|
|
49
|
-
*/
|
|
50
|
-
export declare function sanitizeFieldsWithScalarLists(fields: unknown): {
|
|
51
|
-
attributes: TelemetryListFields;
|
|
52
|
-
dropped: number;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Write one telemetry-required log. `name` is a stable machine identifier and becomes the whole
|
|
56
|
-
* body — the facts live in `fields`, never interpolated into a sentence. The wrapper's own keys are
|
|
57
|
-
* applied last, so a caller field can never shadow them. Never throws into the caller.
|
|
58
|
-
*/
|
|
59
|
-
export declare function logRequiredByTelemetry(logger: Logger, name: string, fields: TelemetryLogFields): void;
|
|
60
|
-
//# sourceMappingURL=telemetry-required-log.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-required-log.d.ts","sourceRoot":"","sources":["../../src/utils/telemetry-required-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,wFAAwF;AACxF,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAExD,iGAAiG;AACjG,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAEjE,6FAA6F;AAC7F,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,EAAE,CAAC,CAAC;AA6CtF;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG;IAAE,UAAU,EAAE,kBAAkB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAInG;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,OAAO,GACd;IAAE,UAAU,EAAE,mBAAmB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAMtD;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,kBAAkB,GACzB,IAAI,CAON"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A structured log that telemetry reads. It is a LOG on purpose — not an event — and it must stay one.
|
|
3
|
-
*
|
|
4
|
-
* Do NOT "promote" a call site here to `logger.event()`, and do not delete or downgrade one as noise:
|
|
5
|
-
* a telemetry consumer parses these records by their field names.
|
|
6
|
-
*
|
|
7
|
-
* Why a log and not an event: `logger.event()` is unconditional (the trade narrative may never go
|
|
8
|
-
* dark) and every event also reaches `appendDomainEvent`, which feeds the per-strategy on-disk ring
|
|
9
|
-
* and the live-telemetry publisher's bounded in-memory buffer. These facts are per-tick and
|
|
10
|
-
* high-frequency, so catalogued they would evict real decision records from that buffer. Routed
|
|
11
|
-
* through the plain log path they stay level-gated — silenceable by configuration, no code change —
|
|
12
|
-
* and nothing taps them, so nothing is evicted.
|
|
13
|
-
*
|
|
14
|
-
* The level is fixed at `info`: the default minimum level, so these records are present in a stock
|
|
15
|
-
* deployment, while `SENPI_LOG_LEVEL=warn` still silences them. `debug` would be off by default and
|
|
16
|
-
* telemetry would go dark without anyone noticing.
|
|
17
|
-
*/
|
|
18
|
-
/** Marks the record as a telemetry input, so a consumer can select these without matching prose. */
|
|
19
|
-
const REQUIRED_MARKER_KEY = "log.telemetry.required";
|
|
20
|
-
/** Count of caller fields that failed the scalar contract, so a silent drop stays visible. */
|
|
21
|
-
const DROPPED_COUNT_KEY = "log.fields.dropped";
|
|
22
|
-
/** Whether one value is a scalar a consumer can parse: a string, a boolean, a finite number. */
|
|
23
|
-
function isTelemetryScalar(value) {
|
|
24
|
-
if (typeof value === "string" || typeof value === "boolean")
|
|
25
|
-
return true;
|
|
26
|
-
return typeof value === "number" && Number.isFinite(value);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Walk a bag once, keeping what `keep` vouches for and counting every other key as dropped, so a
|
|
30
|
-
* silent drop stays visible. `keep` returns `undefined` to refuse a value; that is unambiguous
|
|
31
|
-
* because an `undefined` is itself never a value any of these bags carries.
|
|
32
|
-
*
|
|
33
|
-
* Each property is read inside the guard so a throwing getter costs one field, not the record.
|
|
34
|
-
*/
|
|
35
|
-
function sanitizeBag(fields, keep) {
|
|
36
|
-
const attributes = {};
|
|
37
|
-
let dropped = 0;
|
|
38
|
-
if (typeof fields !== "object" || fields === null || Array.isArray(fields)) {
|
|
39
|
-
return { attributes, dropped };
|
|
40
|
-
}
|
|
41
|
-
for (const key of Object.keys(fields)) {
|
|
42
|
-
let value;
|
|
43
|
-
try {
|
|
44
|
-
value = fields[key];
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
dropped++;
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
const kept = keep(value);
|
|
51
|
-
if (kept === undefined)
|
|
52
|
-
dropped++;
|
|
53
|
-
else
|
|
54
|
-
attributes[key] = kept;
|
|
55
|
-
}
|
|
56
|
-
return { attributes, dropped };
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Keep the values a consumer can actually parse: strings, finite numbers, booleans. Everything else —
|
|
60
|
-
* objects, arrays, `null`/`undefined`, `NaN`/`Infinity`, functions — is dropped and counted.
|
|
61
|
-
*
|
|
62
|
-
* Exported because the tick frame's state projection has to apply the SAME rule to an author's own
|
|
63
|
-
* state row. Sharing the implementation is what makes "sanitised exactly as the required log does"
|
|
64
|
-
* true rather than intended.
|
|
65
|
-
*/
|
|
66
|
-
export function sanitizeFields(fields) {
|
|
67
|
-
return sanitizeBag(fields, (value) => isTelemetryScalar(value) ? value : undefined);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* `sanitizeFields`, widened by exactly one shape: a list whose every element is a scalar.
|
|
71
|
-
*
|
|
72
|
-
* A SECOND entry point rather than a flag on the first, because the two rules belong to different
|
|
73
|
-
* consumers and the narrow one is a contract two call sites depend on. The required log's consumer
|
|
74
|
-
* reads flat named fields, and the tick frame's state projection promises to carry what that log
|
|
75
|
-
* would have written; neither may gain lists as a side effect of a caller that wants them.
|
|
76
|
-
*
|
|
77
|
-
* A single non-scalar element refuses the WHOLE list rather than filtering it down. Filtering would
|
|
78
|
-
* let an author's unbounded nested value decide how much of itself gets rendered, and scalars-only
|
|
79
|
-
* is the rule that keeps a nested payload off the wire. The kept list is a new array, so the
|
|
80
|
-
* caller's own can still be mutated without changing what was recorded.
|
|
81
|
-
*/
|
|
82
|
-
export function sanitizeFieldsWithScalarLists(fields) {
|
|
83
|
-
return sanitizeBag(fields, (value) => {
|
|
84
|
-
if (isTelemetryScalar(value))
|
|
85
|
-
return value;
|
|
86
|
-
if (Array.isArray(value) && value.every(isTelemetryScalar))
|
|
87
|
-
return [...value];
|
|
88
|
-
return undefined;
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Write one telemetry-required log. `name` is a stable machine identifier and becomes the whole
|
|
93
|
-
* body — the facts live in `fields`, never interpolated into a sentence. The wrapper's own keys are
|
|
94
|
-
* applied last, so a caller field can never shadow them. Never throws into the caller.
|
|
95
|
-
*/
|
|
96
|
-
export function logRequiredByTelemetry(logger, name, fields) {
|
|
97
|
-
try {
|
|
98
|
-
const { attributes, dropped } = sanitizeFields(fields);
|
|
99
|
-
logger.info(name, { ...attributes, [REQUIRED_MARKER_KEY]: true, [DROPPED_COUNT_KEY]: dropped });
|
|
100
|
-
}
|
|
101
|
-
catch {
|
|
102
|
-
// A telemetry-side failure must never disturb the caller.
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
//# sourceMappingURL=telemetry-required-log.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-required-log.js","sourceRoot":"","sources":["../../src/utils/telemetry-required-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAaH,oGAAoG;AACpG,MAAM,mBAAmB,GAAG,wBAAwB,CAAC;AAErD,8FAA8F;AAC9F,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAE/C,gGAAgG;AAChG,SAAS,iBAAiB,CAAC,KA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UAAU,6BAA6B,CAC3C,MAAe;IAEf,OAAO,WAAW,CAAsC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;QACxE,IAAI,iBAAiB,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC;YAAE,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;QAC9E,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAc,EACd,IAAY,EACZ,MAA0B;IAE1B,IAAI,CAAC;QACH,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;QACvD,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,UAAU,EAAE,CAAC,mBAAmB,CAAC,EAAE,IAAI,EAAE,CAAC,iBAAiB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAClG,CAAC;IAAC,MAAM,CAAC;QACP,0DAA0D;IAC5D,CAAC;AACH,CAAC"}
|
package/dist/utils/ulid.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ULID minting: a 26-character, lexicographically sortable id — 48 bits of millisecond timestamp
|
|
3
|
-
* followed by 80 bits of randomness, rendered in Crockford's base32. Sortable ids are what make an
|
|
4
|
-
* `epoch` comparable ("which boot came first") without carrying a second field, and 80 random bits
|
|
5
|
-
* make a collision between two boots of the same millisecond unreachable.
|
|
6
|
-
*/
|
|
7
|
-
/** Mint a ULID. `now` is injectable so a caller can pin the time half in a test. */
|
|
8
|
-
export declare function newUlid(now?: number): string;
|
|
9
|
-
//# sourceMappingURL=ulid.d.ts.map
|
package/dist/utils/ulid.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ulid.d.ts","sourceRoot":"","sources":["../../src/utils/ulid.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuCH,oFAAoF;AACpF,wBAAgB,OAAO,CAAC,GAAG,GAAE,MAAmB,GAAG,MAAM,CAExD"}
|
package/dist/utils/ulid.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ULID minting: a 26-character, lexicographically sortable id — 48 bits of millisecond timestamp
|
|
3
|
-
* followed by 80 bits of randomness, rendered in Crockford's base32. Sortable ids are what make an
|
|
4
|
-
* `epoch` comparable ("which boot came first") without carrying a second field, and 80 random bits
|
|
5
|
-
* make a collision between two boots of the same millisecond unreachable.
|
|
6
|
-
*/
|
|
7
|
-
import { randomBytes } from "node:crypto";
|
|
8
|
-
/** Crockford's base32: no I, L, O or U, so a transcribed id cannot be misread. */
|
|
9
|
-
const CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
10
|
-
const TIME_CHARS = 10;
|
|
11
|
-
const RANDOM_BYTES = 10;
|
|
12
|
-
const MAX_TIME = 2 ** 48 - 1;
|
|
13
|
-
/** Render `ms` as the 10-character time prefix. Clamped: a broken clock must still yield a valid id. */
|
|
14
|
-
function encodeTime(ms) {
|
|
15
|
-
let remaining = Number.isFinite(ms) ? Math.min(Math.max(Math.floor(ms), 0), MAX_TIME) : 0;
|
|
16
|
-
let out = "";
|
|
17
|
-
for (let i = 0; i < TIME_CHARS; i++) {
|
|
18
|
-
out = CROCKFORD[remaining % 32] + out;
|
|
19
|
-
remaining = Math.floor(remaining / 32);
|
|
20
|
-
}
|
|
21
|
-
return out;
|
|
22
|
-
}
|
|
23
|
-
/** Render 80 random bits as the 16-character suffix, five bits at a time. */
|
|
24
|
-
function encodeRandom() {
|
|
25
|
-
const bytes = randomBytes(RANDOM_BYTES);
|
|
26
|
-
let acc = 0;
|
|
27
|
-
let bits = 0;
|
|
28
|
-
let out = "";
|
|
29
|
-
for (const byte of bytes) {
|
|
30
|
-
acc = (acc << 8) | byte;
|
|
31
|
-
bits += 8;
|
|
32
|
-
while (bits >= 5) {
|
|
33
|
-
bits -= 5;
|
|
34
|
-
out += CROCKFORD[(acc >> bits) & 31];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return out;
|
|
38
|
-
}
|
|
39
|
-
/** Mint a ULID. `now` is injectable so a caller can pin the time half in a test. */
|
|
40
|
-
export function newUlid(now = Date.now()) {
|
|
41
|
-
return encodeTime(now) + encodeRandom();
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=ulid.js.map
|
package/dist/utils/ulid.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ulid.js","sourceRoot":"","sources":["../../src/utils/ulid.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,kFAAkF;AAClF,MAAM,SAAS,GAAG,kCAAkC,CAAC;AAErD,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAE7B,wGAAwG;AACxG,SAAS,UAAU,CAAC,EAAU;IAC5B,IAAI,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1F,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,GAAG,GAAG,SAAS,CAAC,SAAS,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC;QACtC,SAAS,GAAG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