@noego/telemetry 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +130 -0
  2. package/dist/browser/index.cjs +1346 -0
  3. package/dist/browser/index.cjs.map +1 -0
  4. package/dist/browser/index.d.cts +5 -0
  5. package/dist/browser/index.d.ts +5 -0
  6. package/dist/browser/index.js +1318 -0
  7. package/dist/browser/index.js.map +1 -0
  8. package/dist/browser_telemetry_client-BzBPQm4m.d.cts +29 -0
  9. package/dist/browser_telemetry_client-Ch_VzwEa.d.ts +29 -0
  10. package/dist/cli/telemetry_bin.cjs +5531 -0
  11. package/dist/cli/telemetry_bin.cjs.map +1 -0
  12. package/dist/cli/telemetry_bin.d.cts +1 -0
  13. package/dist/cli/telemetry_bin.d.ts +1 -0
  14. package/dist/cli/telemetry_bin.js +5517 -0
  15. package/dist/cli/telemetry_bin.js.map +1 -0
  16. package/dist/cli/telemetry_cli.cjs +5523 -0
  17. package/dist/cli/telemetry_cli.cjs.map +1 -0
  18. package/dist/cli/telemetry_cli.d.cts +92 -0
  19. package/dist/cli/telemetry_cli.d.ts +92 -0
  20. package/dist/cli/telemetry_cli.js +5497 -0
  21. package/dist/cli/telemetry_cli.js.map +1 -0
  22. package/dist/client_defaults-B5tC-TgG.d.ts +8 -0
  23. package/dist/client_defaults-C9LnSX4j.d.cts +8 -0
  24. package/dist/core/index.cjs +2354 -0
  25. package/dist/core/index.cjs.map +1 -0
  26. package/dist/core/index.d.cts +168 -0
  27. package/dist/core/index.d.ts +168 -0
  28. package/dist/core/index.js +2318 -0
  29. package/dist/core/index.js.map +1 -0
  30. package/dist/electron/index.cjs +1379 -0
  31. package/dist/electron/index.cjs.map +1 -0
  32. package/dist/electron/index.d.cts +31 -0
  33. package/dist/electron/index.d.ts +31 -0
  34. package/dist/electron/index.js +1353 -0
  35. package/dist/electron/index.js.map +1 -0
  36. package/dist/envelope.types-rOLpWXRC.d.cts +42 -0
  37. package/dist/envelope.types-rOLpWXRC.d.ts +42 -0
  38. package/dist/in_memory_batch_transport-DKW9EZnU.d.cts +16 -0
  39. package/dist/in_memory_batch_transport-oOwNxXnA.d.ts +16 -0
  40. package/dist/index.cjs +3325 -0
  41. package/dist/index.cjs.map +1 -0
  42. package/dist/index.d.cts +66 -0
  43. package/dist/index.d.ts +66 -0
  44. package/dist/index.js +3285 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/maintenance_coordinator.types-B-bZUNvw.d.cts +127 -0
  47. package/dist/maintenance_coordinator.types-CBA5y74b.d.ts +127 -0
  48. package/dist/metric_definition_contract-BR6a_GzF.d.cts +12 -0
  49. package/dist/metric_definition_contract-l4i4SaAp.d.ts +12 -0
  50. package/dist/node/index.cjs +7157 -0
  51. package/dist/node/index.cjs.map +1 -0
  52. package/dist/node/index.d.cts +74 -0
  53. package/dist/node/index.d.ts +74 -0
  54. package/dist/node/index.js +7122 -0
  55. package/dist/node/index.js.map +1 -0
  56. package/dist/node/producer/index.cjs +1322 -0
  57. package/dist/node/producer/index.cjs.map +1 -0
  58. package/dist/node/producer/index.d.cts +21 -0
  59. package/dist/node/producer/index.d.ts +21 -0
  60. package/dist/node/producer/index.js +1294 -0
  61. package/dist/node/producer/index.js.map +1 -0
  62. package/dist/query.types-Bntwh6KF.d.cts +186 -0
  63. package/dist/query.types-DySoqYop.d.ts +186 -0
  64. package/dist/result.types-171Huujb.d.cts +9 -0
  65. package/dist/result.types-171Huujb.d.ts +9 -0
  66. package/dist/sqlite/index.cjs +3409 -0
  67. package/dist/sqlite/index.cjs.map +1 -0
  68. package/dist/sqlite/index.d.cts +77 -0
  69. package/dist/sqlite/index.d.ts +77 -0
  70. package/dist/sqlite/index.js +3382 -0
  71. package/dist/sqlite/index.js.map +1 -0
  72. package/dist/storage.types-BTCGVxOM.d.ts +76 -0
  73. package/dist/storage.types-DjuUMinz.d.cts +76 -0
  74. package/dist/telemetry_client-BXw8WH_F.d.ts +141 -0
  75. package/dist/telemetry_client-CYaPYfOl.d.cts +141 -0
  76. package/dist/telemetry_configuration_parser-C7Et_gwG.d.ts +39 -0
  77. package/dist/telemetry_configuration_parser-R-niZQRZ.d.cts +39 -0
  78. package/dist/testing/index.cjs +215 -0
  79. package/dist/testing/index.cjs.map +1 -0
  80. package/dist/testing/index.d.cts +32 -0
  81. package/dist/testing/index.d.ts +32 -0
  82. package/dist/testing/index.js +187 -0
  83. package/dist/testing/index.js.map +1 -0
  84. package/dist/trace-adapter/index.cjs +1034 -0
  85. package/dist/trace-adapter/index.cjs.map +1 -0
  86. package/dist/trace-adapter/index.d.cts +72 -0
  87. package/dist/trace-adapter/index.d.ts +72 -0
  88. package/dist/trace-adapter/index.js +1007 -0
  89. package/dist/trace-adapter/index.js.map +1 -0
  90. package/dist/transport.types-BAl_TRtU.d.cts +99 -0
  91. package/dist/transport.types-DDnZoKWi.d.ts +99 -0
  92. package/migrations/1783695629569_raw_events.down.sql +1 -0
  93. package/migrations/1783695629569_raw_events.up.sql +30 -0
  94. package/migrations/1783695630053_batch_acknowledgements.down.sql +1 -0
  95. package/migrations/1783695630053_batch_acknowledgements.up.sql +13 -0
  96. package/migrations/1783695630960_ingest_watermarks.down.sql +1 -0
  97. package/migrations/1783695630960_ingest_watermarks.up.sql +9 -0
  98. package/migrations/1783695631522_metric_definitions.down.sql +1 -0
  99. package/migrations/1783695631522_metric_definitions.up.sql +10 -0
  100. package/migrations/1783695631966_metric_samples.down.sql +1 -0
  101. package/migrations/1783695631966_metric_samples.up.sql +15 -0
  102. package/migrations/1783695632417_metric_rollups.down.sql +1 -0
  103. package/migrations/1783695632417_metric_rollups.up.sql +22 -0
  104. package/migrations/1783695632860_rollup_completions.down.sql +1 -0
  105. package/migrations/1783695632860_rollup_completions.up.sql +17 -0
  106. package/migrations/1783695633302_extraction_failures.down.sql +1 -0
  107. package/migrations/1783695633302_extraction_failures.up.sql +10 -0
  108. package/migrations/1783695633748_maintenance_runs.down.sql +1 -0
  109. package/migrations/1783695633748_maintenance_runs.up.sql +12 -0
  110. package/migrations/1783695634221_reader_leases.down.sql +1 -0
  111. package/migrations/1783695634221_reader_leases.up.sql +9 -0
  112. package/migrations/1783702703104_committed_drop_counters.down.sql +1 -0
  113. package/migrations/1783702703104_committed_drop_counters.up.sql +11 -0
  114. package/migrations/1783705542684_rollup_completion_state.down.sql +2 -0
  115. package/migrations/1783705542684_rollup_completion_state.up.sql +6 -0
  116. package/migrations/1784309799539_metric_samples_event_index.down.sql +1 -0
  117. package/migrations/1784309799539_metric_samples_event_index.up.sql +2 -0
  118. package/native/noego_telemetry_native.node +0 -0
  119. package/package.json +137 -0
  120. package/proper.json +8 -0
package/README.md ADDED
@@ -0,0 +1,130 @@
1
+ # `@noego/telemetry`
2
+
3
+ Bounded structured telemetry for Node, browsers, and Electron. The core package owns envelope normalization, batching, transport contracts, routing, and collector semantics. SQLite is an explicit Node-only storage terminal.
4
+
5
+ ```ts
6
+ import {
7
+ DEFAULT_METADATA_SNAPSHOT_LIMITS,
8
+ DEFAULT_TELEMETRY_ADMISSION_POLICY,
9
+ NodeTelemetryProducerHost,
10
+ } from '@noego/telemetry/node/producer';
11
+
12
+ const host = new NodeTelemetryProducerHost({
13
+ source: 'api',
14
+ processKind: 'server',
15
+ transport, // Any TelemetryBatchTransport implementation.
16
+ admission: DEFAULT_TELEMETRY_ADMISSION_POLICY,
17
+ metadata: DEFAULT_METADATA_SNAPSHOT_LIMITS,
18
+ producerId: null,
19
+ });
20
+
21
+ host.client.info('tool.set.resolve.started', {
22
+ conversationId: 169,
23
+ toolCount: 8,
24
+ });
25
+ ```
26
+
27
+ Producer calls only take a bounded metadata snapshot and enqueue it. Encoding, checksums, transport work, metric extraction, persistence, and maintenance run asynchronously downstream.
28
+
29
+ Producer-only Node applications should import `@noego/telemetry/node/producer`.
30
+ That entry contains no SQLite, Proper, SQLStack, filesystem, or native-addon
31
+ dependency. The existing `@noego/telemetry/node` entry remains the compatible
32
+ collector/combined composition surface and therefore includes SQLite support.
33
+
34
+ Node supports producer, collector, and combined roles. Browser code injects a
35
+ browser-safe transport through `@noego/telemetry/browser`; Electron renderers
36
+ use the browser client while the main or utility process composes the Node
37
+ collector. Custom batch transports and custom storage terminals implement the
38
+ public core contracts, so pipes and durable targets can be chained or fanned
39
+ out without changing event producers.
40
+
41
+ ## Rust N-API collector
42
+
43
+ Electron applications should use `NativeTelemetryHost.combined(...)` from
44
+ `@noego/telemetry/node` when collector work must not run on Electron's event
45
+ loop. The N-API boundary validates its constructor configuration, starts one
46
+ named `noego-telemetry-collector` Rust thread, and sends it commands through a
47
+ bounded channel. Batch validation, metric extraction, SQLite transactions,
48
+ rollups, retention, lease heartbeats, checkpoints, incremental reclaim, and
49
+ shutdown execute on that thread. JavaScript receives promises backed by N-API
50
+ tasks; no SQLite statement executes in the calling JavaScript thread.
51
+
52
+ Build the native addon with `npm run build:native`, or use `npm run build` to
53
+ build the addon and TypeScript package together. The build requires a Rust
54
+ toolchain with Cargo. The resulting N-API 9 addon is loaded by package-relative
55
+ path and works under both supported Node and Electron runtimes. There is no
56
+ fallback from `NativeTelemetryHost` to synchronous JavaScript SQLite.
57
+
58
+ Collector and combined Node hosts can create same-process producers with
59
+ `host.createLocalProducer({ source, processKind, admission, metadata,
60
+ producerId })`. Each producer receives its own in-memory durable pipe and
61
+ sequence identity; the host owns and drains all of them before collector
62
+ shutdown.
63
+
64
+ SQLite owns its schema and runs bundled Proper migrations through its sole
65
+ writer connection. Table names are predefined; a validated prefix or logical
66
+ table override map is available as an initialization escape hatch. Metric
67
+ definitions write generic versioned rows and never create application tables.
68
+
69
+ SQLite idempotency is deliberately time-bounded. Exact duplicate
70
+ acknowledgements are retained for `raw + lateArrival`; after that window, the
71
+ durable per-producer watermark rejects reused or overlapping sequence ranges.
72
+ The ingestion horizon is the longest configured raw/sample/rollup retention
73
+ window. Batches containing events older than that horizon are rejected, which
74
+ allows inactive producer watermarks to be removed after their acknowledgements,
75
+ raw rows, samples, and extraction failures have expired without letting an old
76
+ retry resurrect a retained aggregate. Retention catches up in 500-row
77
+ transactions until its work deadline, and also bounds completed maintenance
78
+ runs, released/expired reader leases, extraction failures, and unreferenced
79
+ inactive metric definitions. Committed producer drop counters are accumulated
80
+ transactionally in a fixed target/reason/priority table and exposed in the
81
+ SQLite target status; duplicate batches never increment them twice.
82
+
83
+ Node collector hosts run maintenance once at startup and once, within the same
84
+ absolute shutdown deadline, after producers drain. Regular scheduling remains
85
+ collector-owned. A cardinality `reject` marks only that metric/version/
86
+ resolution/bucket as durably rejected: it is not query coverage and cannot
87
+ authorize raw/sample deletion, but it also cannot block other rollups or later
88
+ retention stages. Unchanged rejections are not recomputed; a late sample
89
+ invalidates the marker and retries the bucket. Retention keyset-scans beyond
90
+ protected rows, and due-bucket selection filters current markers before its
91
+ page limit, so old or rejected buckets cannot starve newer work.
92
+
93
+ Metric query ranges are half-open and return only buckets fully contained in
94
+ the requested interval. An unaligned leading or trailing bucket is represented
95
+ as a `partial-bucket` coverage gap instead of returning data from outside the
96
+ range. Historical definition versions are never merged implicitly: overlapping
97
+ versions are returned as parallel, version-labelled segments, and graph output
98
+ uses separate version/resolution series.
99
+
100
+ The Node CLI uses the same bounded query contracts:
101
+
102
+ ```bash
103
+ telemetry timeline query --config telemetry.config.yml \
104
+ --storage-base /path/to/app-data \
105
+ --label tool.set.resolve.started \
106
+ --from 2026-07-10T10:00:00Z \
107
+ --to 2026-07-10T12:00:00Z
108
+
109
+ telemetry metrics graph --config telemetry.config.yml \
110
+ --storage-base /path/to/app-data \
111
+ --metric tool_set_resolve_by_conversation \
112
+ --where conversationId=169 \
113
+ --measurement count \
114
+ --resolution 15m \
115
+ --from 2026-07-10T10:00:00Z \
116
+ --to 2026-07-10T12:00:00Z \
117
+ --type line --format svg --output tool-resolves.svg
118
+ ```
119
+
120
+ `--where` values use JSON primitive typing: `169`, `true`, `false`, and `null`
121
+ remain typed values, while ordinary text remains text. Quote a numeric-looking
122
+ string as JSON (for example `--where 'conversationId="169"'`). Repeating a
123
+ dimension or passing a non-empty JSON array creates a bounded `in` filter.
124
+
125
+ Read-only timeline, metric, graph, and guarded SQL commands can query a live
126
+ SQLite collector through a concurrent WAL reader. Migration and maintenance
127
+ commands acquire the exclusive telemetry lease and refuse a live collector.
128
+ See the `@noego/telemetry/core`, `/node/producer`, `/node`,
129
+ `/browser`, `/electron`, `/sqlite`, `/trace-adapter`, `/cli`, and `/testing`
130
+ exports for composition.