@smoothbricks/lmao 0.1.0
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 +269 -0
- package/dist/allocator.wasm +0 -0
- package/dist/bun/preload.d.ts +11 -0
- package/dist/bun/preload.d.ts.map +1 -0
- package/dist/bun/preload.js +10 -0
- package/dist/bun/trace-preload.d.ts +8 -0
- package/dist/bun/trace-preload.d.ts.map +1 -0
- package/dist/bun/trace-preload.js +12 -0
- package/dist/es.d.ts +8 -0
- package/dist/es.d.ts.map +1 -0
- package/dist/es.js +9 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +84 -0
- package/dist/lib/JsBufferStrategy.d.ts +49 -0
- package/dist/lib/JsBufferStrategy.d.ts.map +1 -0
- package/dist/lib/JsBufferStrategy.js +60 -0
- package/dist/lib/archive/chunkCompaction.d.ts +15 -0
- package/dist/lib/archive/chunkCompaction.d.ts.map +1 -0
- package/dist/lib/archive/chunkCompaction.js +24 -0
- package/dist/lib/archive/chunkEnvelope.d.ts +21 -0
- package/dist/lib/archive/chunkEnvelope.d.ts.map +1 -0
- package/dist/lib/archive/chunkEnvelope.js +55 -0
- package/dist/lib/archive/chunkRouting.d.ts +10 -0
- package/dist/lib/archive/chunkRouting.d.ts.map +1 -0
- package/dist/lib/archive/chunkRouting.js +47 -0
- package/dist/lib/archive/chunkStats.d.ts +12 -0
- package/dist/lib/archive/chunkStats.d.ts.map +1 -0
- package/dist/lib/archive/chunkStats.js +10 -0
- package/dist/lib/archive/index.d.ts +5 -0
- package/dist/lib/archive/index.d.ts.map +1 -0
- package/dist/lib/archive/index.js +4 -0
- package/dist/lib/arrow/capacityStats.d.ts +9 -0
- package/dist/lib/arrow/capacityStats.d.ts.map +1 -0
- package/dist/lib/arrow/capacityStats.js +231 -0
- package/dist/lib/arrow/dictionaries.d.ts +27 -0
- package/dist/lib/arrow/dictionaries.d.ts.map +1 -0
- package/dist/lib/arrow/dictionaries.js +135 -0
- package/dist/lib/arrow/flechette.d.ts +40 -0
- package/dist/lib/arrow/flechette.d.ts.map +1 -0
- package/dist/lib/arrow/flechette.js +67 -0
- package/dist/lib/arrow/utils.d.ts +38 -0
- package/dist/lib/arrow/utils.d.ts.map +1 -0
- package/dist/lib/arrow/utils.js +112 -0
- package/dist/lib/buffer/Nanoseconds.d.ts +109 -0
- package/dist/lib/buffer/Nanoseconds.d.ts.map +1 -0
- package/dist/lib/buffer/Nanoseconds.js +86 -0
- package/dist/lib/bufferStrategy.d.ts +95 -0
- package/dist/lib/bufferStrategy.d.ts.map +1 -0
- package/dist/lib/bufferStrategy.js +1 -0
- package/dist/lib/capacityTuning.d.ts +50 -0
- package/dist/lib/capacityTuning.d.ts.map +1 -0
- package/dist/lib/capacityTuning.js +65 -0
- package/dist/lib/codegen/evaluatorGenerator.d.ts +35 -0
- package/dist/lib/codegen/evaluatorGenerator.d.ts.map +1 -0
- package/dist/lib/codegen/evaluatorGenerator.js +199 -0
- package/dist/lib/codegen/fixedPositionWriterGenerator.d.ts +139 -0
- package/dist/lib/codegen/fixedPositionWriterGenerator.d.ts.map +1 -0
- package/dist/lib/codegen/fixedPositionWriterGenerator.js +289 -0
- package/dist/lib/codegen/spanLoggerGenerator.d.ts +115 -0
- package/dist/lib/codegen/spanLoggerGenerator.d.ts.map +1 -0
- package/dist/lib/codegen/spanLoggerGenerator.js +575 -0
- package/dist/lib/convertToArrow.d.ts +40 -0
- package/dist/lib/convertToArrow.d.ts.map +1 -0
- package/dist/lib/convertToArrow.js +1467 -0
- package/dist/lib/defineOpContext.d.ts +96 -0
- package/dist/lib/defineOpContext.d.ts.map +1 -0
- package/dist/lib/defineOpContext.js +227 -0
- package/dist/lib/errors/Blocked.d.ts +113 -0
- package/dist/lib/errors/Blocked.d.ts.map +1 -0
- package/dist/lib/errors/Blocked.js +68 -0
- package/dist/lib/errors/CodeError.d.ts +101 -0
- package/dist/lib/errors/CodeError.d.ts.map +1 -0
- package/dist/lib/errors/CodeError.js +42 -0
- package/dist/lib/errors/RetriesExhausted.d.ts +67 -0
- package/dist/lib/errors/RetriesExhausted.d.ts.map +1 -0
- package/dist/lib/errors/RetriesExhausted.js +31 -0
- package/dist/lib/errors/Transient.d.ts +115 -0
- package/dist/lib/errors/Transient.d.ts.map +1 -0
- package/dist/lib/errors/Transient.js +54 -0
- package/dist/lib/errors/index.d.ts +14 -0
- package/dist/lib/errors/index.d.ts.map +1 -0
- package/dist/lib/errors/index.js +16 -0
- package/dist/lib/errors/retry-policy.d.ts +60 -0
- package/dist/lib/errors/retry-policy.d.ts.map +1 -0
- package/dist/lib/errors/retry-policy.js +54 -0
- package/dist/lib/flushScheduler.d.ts +162 -0
- package/dist/lib/flushScheduler.d.ts.map +1 -0
- package/dist/lib/flushScheduler.js +388 -0
- package/dist/lib/library.d.ts +149 -0
- package/dist/lib/library.d.ts.map +1 -0
- package/dist/lib/library.js +588 -0
- package/dist/lib/logApi.d.ts +61 -0
- package/dist/lib/logApi.d.ts.map +1 -0
- package/dist/lib/logApi.js +12 -0
- package/dist/lib/logBinding.d.ts +63 -0
- package/dist/lib/logBinding.d.ts.map +1 -0
- package/dist/lib/logBinding.js +1 -0
- package/dist/lib/op.d.ts +105 -0
- package/dist/lib/op.d.ts.map +1 -0
- package/dist/lib/op.js +59 -0
- package/dist/lib/opContext/contextTypes.d.ts +88 -0
- package/dist/lib/opContext/contextTypes.d.ts.map +1 -0
- package/dist/lib/opContext/contextTypes.js +34 -0
- package/dist/lib/opContext/createOpGroup.d.ts +57 -0
- package/dist/lib/opContext/createOpGroup.d.ts.map +1 -0
- package/dist/lib/opContext/createOpGroup.js +341 -0
- package/dist/lib/opContext/defineOp.d.ts +83 -0
- package/dist/lib/opContext/defineOp.d.ts.map +1 -0
- package/dist/lib/opContext/defineOp.js +197 -0
- package/dist/lib/opContext/featureFlagTypes.d.ts +58 -0
- package/dist/lib/opContext/featureFlagTypes.d.ts.map +1 -0
- package/dist/lib/opContext/featureFlagTypes.js +1 -0
- package/dist/lib/opContext/index.d.ts +13 -0
- package/dist/lib/opContext/index.d.ts.map +1 -0
- package/dist/lib/opContext/index.js +15 -0
- package/dist/lib/opContext/opGroupTypes.d.ts +250 -0
- package/dist/lib/opContext/opGroupTypes.d.ts.map +1 -0
- package/dist/lib/opContext/opGroupTypes.js +31 -0
- package/dist/lib/opContext/opTypes.d.ts +48 -0
- package/dist/lib/opContext/opTypes.d.ts.map +1 -0
- package/dist/lib/opContext/opTypes.js +7 -0
- package/dist/lib/opContext/spanContextTypes.d.ts +347 -0
- package/dist/lib/opContext/spanContextTypes.d.ts.map +1 -0
- package/dist/lib/opContext/spanContextTypes.js +1 -0
- package/dist/lib/opContext/types.d.ts +297 -0
- package/dist/lib/opContext/types.d.ts.map +1 -0
- package/dist/lib/opContext/types.js +16 -0
- package/dist/lib/result.d.ts +308 -0
- package/dist/lib/result.d.ts.map +1 -0
- package/dist/lib/result.js +359 -0
- package/dist/lib/schema/LogSchema.d.ts +62 -0
- package/dist/lib/schema/LogSchema.d.ts.map +1 -0
- package/dist/lib/schema/LogSchema.js +134 -0
- package/dist/lib/schema/builder.d.ts +12 -0
- package/dist/lib/schema/builder.d.ts.map +1 -0
- package/dist/lib/schema/builder.js +169 -0
- package/dist/lib/schema/defineFeatureFlags.d.ts +60 -0
- package/dist/lib/schema/defineFeatureFlags.d.ts.map +1 -0
- package/dist/lib/schema/defineFeatureFlags.js +29 -0
- package/dist/lib/schema/defineLogSchema.d.ts +87 -0
- package/dist/lib/schema/defineLogSchema.d.ts.map +1 -0
- package/dist/lib/schema/defineLogSchema.js +171 -0
- package/dist/lib/schema/evaluator.d.ts +267 -0
- package/dist/lib/schema/evaluator.d.ts.map +1 -0
- package/dist/lib/schema/evaluator.js +169 -0
- package/dist/lib/schema/extend.d.ts +14 -0
- package/dist/lib/schema/extend.d.ts.map +1 -0
- package/dist/lib/schema/extend.js +51 -0
- package/dist/lib/schema/systemSchema.d.ts +112 -0
- package/dist/lib/schema/systemSchema.d.ts.map +1 -0
- package/dist/lib/schema/systemSchema.js +260 -0
- package/dist/lib/schema/typeGuards.d.ts +52 -0
- package/dist/lib/schema/typeGuards.d.ts.map +1 -0
- package/dist/lib/schema/typeGuards.js +127 -0
- package/dist/lib/schema/types.d.ts +156 -0
- package/dist/lib/schema/types.d.ts.map +1 -0
- package/dist/lib/schema/types.js +4 -0
- package/dist/lib/spanBuffer.d.ts +133 -0
- package/dist/lib/spanBuffer.d.ts.map +1 -0
- package/dist/lib/spanBuffer.js +442 -0
- package/dist/lib/spanBufferHelpers.d.ts +53 -0
- package/dist/lib/spanBufferHelpers.d.ts.map +1 -0
- package/dist/lib/spanBufferHelpers.js +65 -0
- package/dist/lib/spanBufferStats.d.ts +38 -0
- package/dist/lib/spanBufferStats.d.ts.map +1 -0
- package/dist/lib/spanBufferStats.js +1 -0
- package/dist/lib/spanContext.d.ts +141 -0
- package/dist/lib/spanContext.d.ts.map +1 -0
- package/dist/lib/spanContext.js +763 -0
- package/dist/lib/sqlite/index.d.ts +14 -0
- package/dist/lib/sqlite/index.d.ts.map +1 -0
- package/dist/lib/sqlite/index.js +12 -0
- package/dist/lib/sqlite/sqlite-async-writer.d.ts +24 -0
- package/dist/lib/sqlite/sqlite-async-writer.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-async-writer.js +65 -0
- package/dist/lib/sqlite/sqlite-common.d.ts +37 -0
- package/dist/lib/sqlite/sqlite-common.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-common.js +207 -0
- package/dist/lib/sqlite/sqlite-d1.d.ts +25 -0
- package/dist/lib/sqlite/sqlite-d1.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-d1.js +67 -0
- package/dist/lib/sqlite/sqlite-db.d.ts +29 -0
- package/dist/lib/sqlite/sqlite-db.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-db.js +1 -0
- package/dist/lib/sqlite/sqlite-node.d.ts +16 -0
- package/dist/lib/sqlite/sqlite-node.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-node.js +68 -0
- package/dist/lib/sqlite/sqlite-writer.d.ts +39 -0
- package/dist/lib/sqlite/sqlite-writer.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-writer.js +78 -0
- package/dist/lib/testing/bun-harness.d.ts +150 -0
- package/dist/lib/testing/bun-harness.d.ts.map +1 -0
- package/dist/lib/testing/bun-harness.js +729 -0
- package/dist/lib/testing/extractFacts.d.ts +73 -0
- package/dist/lib/testing/extractFacts.d.ts.map +1 -0
- package/dist/lib/testing/extractFacts.js +237 -0
- package/dist/lib/testing/facts.d.ts +235 -0
- package/dist/lib/testing/facts.d.ts.map +1 -0
- package/dist/lib/testing/facts.js +209 -0
- package/dist/lib/testing/index.d.ts +58 -0
- package/dist/lib/testing/index.d.ts.map +1 -0
- package/dist/lib/testing/index.js +74 -0
- package/dist/lib/testing/queryable-span.d.ts +39 -0
- package/dist/lib/testing/queryable-span.d.ts.map +1 -0
- package/dist/lib/testing/queryable-span.js +58 -0
- package/dist/lib/testing/span-query.d.ts +21 -0
- package/dist/lib/testing/span-query.d.ts.map +1 -0
- package/dist/lib/testing/span-query.js +47 -0
- package/dist/lib/testing/stdio-replay.d.ts +4 -0
- package/dist/lib/testing/stdio-replay.d.ts.map +1 -0
- package/dist/lib/testing/stdio-replay.js +42 -0
- package/dist/lib/testing/trace-query.d.ts +59 -0
- package/dist/lib/testing/trace-query.d.ts.map +1 -0
- package/dist/lib/testing/trace-query.js +462 -0
- package/dist/lib/testing/vitest-harness.d.ts +135 -0
- package/dist/lib/testing/vitest-harness.d.ts.map +1 -0
- package/dist/lib/testing/vitest-harness.js +486 -0
- package/dist/lib/threadId.d.ts +58 -0
- package/dist/lib/threadId.d.ts.map +1 -0
- package/dist/lib/threadId.js +123 -0
- package/dist/lib/traceContext.d.ts +116 -0
- package/dist/lib/traceContext.d.ts.map +1 -0
- package/dist/lib/traceContext.js +37 -0
- package/dist/lib/traceId.d.ts +78 -0
- package/dist/lib/traceId.d.ts.map +1 -0
- package/dist/lib/traceId.js +87 -0
- package/dist/lib/traceRoot.d.ts +133 -0
- package/dist/lib/traceRoot.d.ts.map +1 -0
- package/dist/lib/traceRoot.es.d.ts +75 -0
- package/dist/lib/traceRoot.es.d.ts.map +1 -0
- package/dist/lib/traceRoot.es.js +129 -0
- package/dist/lib/traceRoot.js +19 -0
- package/dist/lib/traceRoot.node.d.ts +77 -0
- package/dist/lib/traceRoot.node.d.ts.map +1 -0
- package/dist/lib/traceRoot.node.js +133 -0
- package/dist/lib/traceRoot.universal.d.ts +3 -0
- package/dist/lib/traceRoot.universal.d.ts.map +1 -0
- package/dist/lib/traceRoot.universal.js +17 -0
- package/dist/lib/tracer.d.ts +296 -0
- package/dist/lib/tracer.d.ts.map +1 -0
- package/dist/lib/tracer.js +346 -0
- package/dist/lib/tracers/ArrayQueueTracer.d.ts +56 -0
- package/dist/lib/tracers/ArrayQueueTracer.d.ts.map +1 -0
- package/dist/lib/tracers/ArrayQueueTracer.js +67 -0
- package/dist/lib/tracers/CompositeTracer.d.ts +24 -0
- package/dist/lib/tracers/CompositeTracer.d.ts.map +1 -0
- package/dist/lib/tracers/CompositeTracer.js +57 -0
- package/dist/lib/tracers/NoOpTracer.d.ts +58 -0
- package/dist/lib/tracers/NoOpTracer.d.ts.map +1 -0
- package/dist/lib/tracers/NoOpTracer.js +41 -0
- package/dist/lib/tracers/SQLiteTracer.d.ts +42 -0
- package/dist/lib/tracers/SQLiteTracer.d.ts.map +1 -0
- package/dist/lib/tracers/SQLiteTracer.js +84 -0
- package/dist/lib/tracers/StdioTracer.d.ts +83 -0
- package/dist/lib/tracers/StdioTracer.d.ts.map +1 -0
- package/dist/lib/tracers/StdioTracer.js +270 -0
- package/dist/lib/tracers/TestTracer.d.ts +95 -0
- package/dist/lib/tracers/TestTracer.d.ts.map +1 -0
- package/dist/lib/tracers/TestTracer.js +87 -0
- package/dist/lib/tracers/index.d.ts +12 -0
- package/dist/lib/tracers/index.d.ts.map +1 -0
- package/dist/lib/tracers/index.js +11 -0
- package/dist/lib/types.d.ts +366 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +1 -0
- package/dist/lib/utf8Cache.d.ts +111 -0
- package/dist/lib/utf8Cache.d.ts.map +1 -0
- package/dist/lib/utf8Cache.js +177 -0
- package/dist/lib/wasm/WasmBufferStrategy.d.ts +88 -0
- package/dist/lib/wasm/WasmBufferStrategy.d.ts.map +1 -0
- package/dist/lib/wasm/WasmBufferStrategy.js +138 -0
- package/dist/lib/wasm/wasmAllocator.d.ts +109 -0
- package/dist/lib/wasm/wasmAllocator.d.ts.map +1 -0
- package/dist/lib/wasm/wasmAllocator.js +227 -0
- package/dist/lib/wasm/wasmSpanBuffer.d.ts +123 -0
- package/dist/lib/wasm/wasmSpanBuffer.d.ts.map +1 -0
- package/dist/lib/wasm/wasmSpanBuffer.js +772 -0
- package/dist/lib/wasm/wasmTraceRoot.d.ts +167 -0
- package/dist/lib/wasm/wasmTraceRoot.d.ts.map +1 -0
- package/dist/lib/wasm/wasmTraceRoot.js +264 -0
- package/dist/node.d.ts +7 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +8 -0
- package/dist/testing.d.ts +18 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +17 -0
- package/package.json +193 -0
- package/src/bun/preload.ts +11 -0
- package/src/bun/trace-preload.ts +14 -0
- package/src/es.ts +11 -0
- package/src/index.ts +194 -0
- package/src/lib/JsBufferStrategy.ts +102 -0
- package/src/lib/__tests__/arrow-builder-integration/arrow-conversion.test.ts +485 -0
- package/src/lib/__tests__/arrow-builder-integration/binary-arrow-conversion.test.ts +390 -0
- package/src/lib/__tests__/arrow-builder-integration/binary-comparison.test.ts +647 -0
- package/src/lib/__tests__/arrow-builder-integration/binary-format-compliance.test.ts +292 -0
- package/src/lib/__tests__/arrow-builder-integration/buffer-chaining.test.ts +354 -0
- package/src/lib/__tests__/arrow-builder-integration/foundation.test.ts +127 -0
- package/src/lib/__tests__/arrow-builder-integration/integration.test.ts +392 -0
- package/src/lib/__tests__/arrow-builder-integration/lazy-columns.test.ts +389 -0
- package/src/lib/__tests__/arrow-conversion-algorithms.test.ts +54 -0
- package/src/lib/__tests__/arrow-test-helpers.ts +71 -0
- package/src/lib/__tests__/binary-e2e.test.ts +203 -0
- package/src/lib/__tests__/buffer-overflow-op-api.test.ts +608 -0
- package/src/lib/__tests__/buffer-overflow.test.ts +612 -0
- package/src/lib/__tests__/capacity-tuning.test.ts +544 -0
- package/src/lib/__tests__/effective-schema.test.ts +439 -0
- package/src/lib/__tests__/flechette.test.ts +42 -0
- package/src/lib/__tests__/flushScheduler.test.ts +537 -0
- package/src/lib/__tests__/integration.test.ts +600 -0
- package/src/lib/__tests__/library.test.ts +934 -0
- package/src/lib/__tests__/nested-library-tasks.test.ts +849 -0
- package/src/lib/__tests__/op-context-binding.test.ts +135 -0
- package/src/lib/__tests__/op-metadata.test.ts +198 -0
- package/src/lib/__tests__/op-type-safety.test.ts +71 -0
- package/src/lib/__tests__/package-exports.test.ts +57 -0
- package/src/lib/__tests__/remapped-buffer-view-integration.test.ts +319 -0
- package/src/lib/__tests__/remapped-buffer-view.test.ts +635 -0
- package/src/lib/__tests__/scope-attributes.test.ts +348 -0
- package/src/lib/__tests__/span-lifecycle.test.ts +680 -0
- package/src/lib/__tests__/sync-async-trace.test.ts +435 -0
- package/src/lib/__tests__/test-helpers.ts +318 -0
- package/src/lib/__tests__/timestamp.test.ts +259 -0
- package/src/lib/__tests__/trace-archive-primitives.test.ts +98 -0
- package/src/lib/__tests__/traceContext-type-enforcement.test.ts +271 -0
- package/src/lib/__tests__/tracer.test.ts +211 -0
- package/src/lib/__tests__/type-narrowing.test.ts +137 -0
- package/src/lib/archive/chunkCompaction.ts +44 -0
- package/src/lib/archive/chunkEnvelope.ts +79 -0
- package/src/lib/archive/chunkRouting.ts +70 -0
- package/src/lib/archive/chunkStats.ts +25 -0
- package/src/lib/archive/index.ts +4 -0
- package/src/lib/arrow/capacityStats.ts +340 -0
- package/src/lib/arrow/dictionaries.ts +159 -0
- package/src/lib/arrow/flechette.ts +114 -0
- package/src/lib/arrow/utils.ts +126 -0
- package/src/lib/buffer/Nanoseconds.ts +131 -0
- package/src/lib/bufferStrategy.ts +106 -0
- package/src/lib/capacityTuning.ts +102 -0
- package/src/lib/codegen/__tests__/__snapshots__/evaluatorGenerator.test.ts.snap +160 -0
- package/src/lib/codegen/__tests__/__snapshots__/scopeGenerator.test.ts.snap +196 -0
- package/src/lib/codegen/__tests__/__snapshots__/spanLoggerGenerator.test.ts.snap +1965 -0
- package/src/lib/codegen/__tests__/evaluatorGenerator.test.ts +516 -0
- package/src/lib/codegen/__tests__/nullBitmap.test.ts +207 -0
- package/src/lib/codegen/__tests__/spanLoggerGenerator.test.ts +237 -0
- package/src/lib/codegen/evaluatorGenerator.ts +309 -0
- package/src/lib/codegen/fixedPositionWriterGenerator.ts +444 -0
- package/src/lib/codegen/spanLoggerGenerator.ts +715 -0
- package/src/lib/convertToArrow.ts +1805 -0
- package/src/lib/defineOpContext.ts +398 -0
- package/src/lib/errors/Blocked.ts +165 -0
- package/src/lib/errors/CodeError.ts +132 -0
- package/src/lib/errors/RetriesExhausted.ts +78 -0
- package/src/lib/errors/Transient.ts +168 -0
- package/src/lib/errors/__tests__/Blocked-config.test.ts +152 -0
- package/src/lib/errors/__tests__/Transient.test.ts +129 -0
- package/src/lib/errors/__tests__/retry-policy.test.ts +85 -0
- package/src/lib/errors/index.ts +24 -0
- package/src/lib/errors/retry-policy.ts +87 -0
- package/src/lib/flushScheduler.ts +509 -0
- package/src/lib/library.ts +682 -0
- package/src/lib/logApi.ts +70 -0
- package/src/lib/logBinding.ts +67 -0
- package/src/lib/op.ts +103 -0
- package/src/lib/opContext/__tests__/retry.test.ts +764 -0
- package/src/lib/opContext/contextTypes.ts +130 -0
- package/src/lib/opContext/createOpGroup.ts +456 -0
- package/src/lib/opContext/defineOp.ts +281 -0
- package/src/lib/opContext/featureFlagTypes.ts +54 -0
- package/src/lib/opContext/index.ts +16 -0
- package/src/lib/opContext/opGroupTypes.ts +342 -0
- package/src/lib/opContext/opTypes.ts +80 -0
- package/src/lib/opContext/spanContextTypes.ts +398 -0
- package/src/lib/opContext/types.ts +403 -0
- package/src/lib/result.ts +550 -0
- package/src/lib/schema/LogSchema.ts +153 -0
- package/src/lib/schema/__tests__/defineLogSchema.test.ts +342 -0
- package/src/lib/schema/__tests__/featureFlags.test.ts +443 -0
- package/src/lib/schema/builder.ts +201 -0
- package/src/lib/schema/defineFeatureFlags.ts +91 -0
- package/src/lib/schema/defineLogSchema.ts +291 -0
- package/src/lib/schema/evaluator.ts +404 -0
- package/src/lib/schema/extend.ts +69 -0
- package/src/lib/schema/systemSchema.ts +339 -0
- package/src/lib/schema/typeGuards.ts +163 -0
- package/src/lib/schema/types.ts +265 -0
- package/src/lib/spanBuffer.ts +571 -0
- package/src/lib/spanBufferHelpers.ts +73 -0
- package/src/lib/spanBufferStats.ts +40 -0
- package/src/lib/spanContext.ts +1566 -0
- package/src/lib/sqlite/__tests__/sqlite-common.test.ts +89 -0
- package/src/lib/sqlite/index.ts +26 -0
- package/src/lib/sqlite/sqlite-async-writer.ts +101 -0
- package/src/lib/sqlite/sqlite-common.ts +309 -0
- package/src/lib/sqlite/sqlite-d1.ts +104 -0
- package/src/lib/sqlite/sqlite-db.ts +32 -0
- package/src/lib/sqlite/sqlite-node.ts +83 -0
- package/src/lib/sqlite/sqlite-writer.ts +128 -0
- package/src/lib/testing/TRACE-TESTING.md +100 -0
- package/src/lib/testing/__tests__/bun-harness.test.ts +108 -0
- package/src/lib/testing/__tests__/extractFacts.test.ts +279 -0
- package/src/lib/testing/__tests__/facts.test.ts +324 -0
- package/src/lib/testing/__tests__/vitest-harness.test.ts +32 -0
- package/src/lib/testing/bun-harness.ts +990 -0
- package/src/lib/testing/extractFacts.ts +362 -0
- package/src/lib/testing/facts.ts +470 -0
- package/src/lib/testing/index.ts +141 -0
- package/src/lib/testing/queryable-span.ts +108 -0
- package/src/lib/testing/span-query.ts +65 -0
- package/src/lib/testing/stdio-replay.ts +50 -0
- package/src/lib/testing/trace-query.ts +329 -0
- package/src/lib/testing/vitest-harness.ts +691 -0
- package/src/lib/threadId.ts +135 -0
- package/src/lib/traceContext.ts +182 -0
- package/src/lib/traceId.ts +142 -0
- package/src/lib/traceRoot.es.ts +157 -0
- package/src/lib/traceRoot.node.ts +170 -0
- package/src/lib/traceRoot.ts +154 -0
- package/src/lib/traceRoot.universal.ts +22 -0
- package/src/lib/tracer.ts +896 -0
- package/src/lib/tracers/ArrayQueueTracer.ts +76 -0
- package/src/lib/tracers/CompositeTracer.ts +76 -0
- package/src/lib/tracers/NoOpTracer.ts +73 -0
- package/src/lib/tracers/SQLiteTracer.ts +115 -0
- package/src/lib/tracers/StdioTracer.ts +380 -0
- package/src/lib/tracers/TestTracer.ts +146 -0
- package/src/lib/tracers/__tests__/ArrayQueueTracer.test.ts +184 -0
- package/src/lib/tracers/__tests__/NoOpTracer.test.ts +204 -0
- package/src/lib/tracers/__tests__/StdioTracer.test.ts +313 -0
- package/src/lib/tracers/__tests__/TestTracer.test.ts +200 -0
- package/src/lib/tracers/index.ts +12 -0
- package/src/lib/types.ts +498 -0
- package/src/lib/utf8Cache.ts +201 -0
- package/src/lib/wasm/WasmBufferStrategy.ts +219 -0
- package/src/lib/wasm/__tests__/WasmBufferStrategy.test.ts +256 -0
- package/src/lib/wasm/__tests__/wasm-integration.test.ts +476 -0
- package/src/lib/wasm/__tests__/wasmAllocator.test.ts +699 -0
- package/src/lib/wasm/__tests__/wasmSpanBuffer.test.ts +449 -0
- package/src/lib/wasm/__tests__/wasmTraceRoot.test.ts +390 -0
- package/src/lib/wasm/__tests__/wasmTracer.test.ts.disabled +444 -0
- package/src/lib/wasm/allocator.zig +945 -0
- package/src/lib/wasm/wasmAllocator.ts +469 -0
- package/src/lib/wasm/wasmSpanBuffer.ts +1014 -0
- package/src/lib/wasm/wasmTraceRoot.ts +315 -0
- package/src/node.ts +10 -0
- package/src/testing.ts +18 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
import { DEFAULT_BUFFER_CAPACITY } from '@smoothbricks/arrow-builder';
|
|
3
|
+
import { DEFAULT_METADATA } from '../../opContext/defineOp.js';
|
|
4
|
+
import { S } from '../../schema/builder.js';
|
|
5
|
+
import { createSpanBuffer, getSpanBufferClass } from '../../spanBuffer.js';
|
|
6
|
+
|
|
7
|
+
import { createBuffer, createTestSchema, createTestTraceRoot, createTraceId } from '../test-helpers.js';
|
|
8
|
+
|
|
9
|
+
describe('Buffer Foundation', () => {
|
|
10
|
+
it('creates SpanBuffer with TypedArrays', () => {
|
|
11
|
+
const schema = createTestSchema({
|
|
12
|
+
userId: S.category(), // Category: user IDs repeat
|
|
13
|
+
count: S.number(),
|
|
14
|
+
});
|
|
15
|
+
const buf = createSpanBuffer(schema, createTestTraceRoot('trace-123'), DEFAULT_METADATA); // Uses DEFAULT_BUFFER_CAPACITY
|
|
16
|
+
|
|
17
|
+
// Span identity assertions (unified memory layout)
|
|
18
|
+
expect(typeof buf.span_id).toBe('number');
|
|
19
|
+
expect(buf.span_id).toBeGreaterThan(0);
|
|
20
|
+
expect(buf._hasParent).toBe(false);
|
|
21
|
+
expect(buf.trace_id).toBe(createTraceId('trace-123'));
|
|
22
|
+
|
|
23
|
+
// Check TypedArrays are created
|
|
24
|
+
expect(buf.timestamp).toBeInstanceOf(BigInt64Array);
|
|
25
|
+
expect(buf.entry_type).toBeInstanceOf(Uint8Array);
|
|
26
|
+
|
|
27
|
+
// Check null bitmaps exist for each attribute (Arrow format: 1 Uint8Array per column)
|
|
28
|
+
expect(buf.userId_nulls).toBeInstanceOf(Uint8Array);
|
|
29
|
+
expect(buf.count_nulls).toBeInstanceOf(Uint8Array);
|
|
30
|
+
|
|
31
|
+
// Check attribute columns exist for each schema field (using _values suffix)
|
|
32
|
+
// category columns now use string[] arrays for zero-cost hot path writes
|
|
33
|
+
expect(Array.isArray(buf.userId_values)).toBe(true); // category → string[]
|
|
34
|
+
expect(buf.count_values).toBeInstanceOf(Float64Array); // number → Float64Array
|
|
35
|
+
|
|
36
|
+
// Metadata
|
|
37
|
+
expect(buf._children).toBeInstanceOf(Array);
|
|
38
|
+
expect(buf._writeIndex).toBe(0);
|
|
39
|
+
expect(buf._capacity).toBe(DEFAULT_BUFFER_CAPACITY);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('creates root SpanBuffer with createSpanBuffer', () => {
|
|
43
|
+
const schema = createTestSchema({
|
|
44
|
+
userId: S.category(),
|
|
45
|
+
count: S.number(),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const buf = createSpanBuffer(schema, createTestTraceRoot('trace-999'), DEFAULT_METADATA);
|
|
49
|
+
|
|
50
|
+
expect(buf.span_id).toBeGreaterThan(0);
|
|
51
|
+
expect(buf._hasParent).toBe(false);
|
|
52
|
+
expect(buf._parent).toBeUndefined();
|
|
53
|
+
expect(buf._children).toHaveLength(0);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('provides access to buffer stats via constructor', () => {
|
|
57
|
+
const schema = createTestSchema({
|
|
58
|
+
userId: S.category(),
|
|
59
|
+
count: S.number(),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Get SpanBufferClass to access stats
|
|
63
|
+
const SpanBufferClass = getSpanBufferClass(schema);
|
|
64
|
+
const buf = createSpanBuffer(schema, createTestTraceRoot('trace-456'), DEFAULT_METADATA, 64);
|
|
65
|
+
|
|
66
|
+
// Stats are accessible from constructor
|
|
67
|
+
expect(buf).toBeInstanceOf(SpanBufferClass);
|
|
68
|
+
expect(SpanBufferClass.stats.capacity).toBe(DEFAULT_BUFFER_CAPACITY);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('handles different schema sizes', () => {
|
|
72
|
+
// Define a larger schema
|
|
73
|
+
const largeSchema = createTestSchema({
|
|
74
|
+
field1: S.category(), // Category string
|
|
75
|
+
field2: S.number(),
|
|
76
|
+
field3: S.boolean(),
|
|
77
|
+
field4: S.text(), // Text string
|
|
78
|
+
field5: S.number(),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const buf = createSpanBuffer(largeSchema, createTestTraceRoot('trace-789'), DEFAULT_METADATA, 64);
|
|
82
|
+
|
|
83
|
+
// Should have TypedArray columns for all 5 attributes (each has _values and _nulls)
|
|
84
|
+
// Note: Columns are lazy-allocated via getters, so Object.keys() won't find them
|
|
85
|
+
// Access them directly to trigger allocation and verify they exist
|
|
86
|
+
expect(Array.isArray(buf.field1_values)).toBe(true); // category (raw strings)
|
|
87
|
+
expect(buf.field1_nulls).toBeInstanceOf(Uint8Array); // null bitmap
|
|
88
|
+
expect(buf.field2_values).toBeInstanceOf(Float64Array); // number
|
|
89
|
+
expect(buf.field2_nulls).toBeInstanceOf(Uint8Array);
|
|
90
|
+
expect(buf.field3_values).toBeInstanceOf(Uint8Array); // boolean
|
|
91
|
+
expect(buf.field3_nulls).toBeInstanceOf(Uint8Array);
|
|
92
|
+
expect(Array.isArray(buf.field4_values)).toBe(true); // text (raw strings)
|
|
93
|
+
expect(buf.field4_nulls).toBeInstanceOf(Uint8Array);
|
|
94
|
+
expect(buf.field5_values).toBeInstanceOf(Float64Array); // number
|
|
95
|
+
expect(buf.field5_nulls).toBeInstanceOf(Uint8Array);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('accesses schema from SpanBufferConstructor', () => {
|
|
99
|
+
const schema = createTestSchema({
|
|
100
|
+
userId: S.category(),
|
|
101
|
+
count: S.number(),
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
createSpanBuffer(schema, createTestTraceRoot('trace-123'), DEFAULT_METADATA);
|
|
105
|
+
const SpanBufferClass = getSpanBufferClass(schema);
|
|
106
|
+
|
|
107
|
+
// Schema is accessible via static property
|
|
108
|
+
expect(SpanBufferClass.schema).toBe(schema);
|
|
109
|
+
expect(SpanBufferClass.schema.fields.userId).toBeDefined();
|
|
110
|
+
expect(SpanBufferClass.schema.fields.count).toBeDefined();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('accesses stats from SpanBufferConstructor', () => {
|
|
114
|
+
const schema = createTestSchema({
|
|
115
|
+
userId: S.category(),
|
|
116
|
+
count: S.number(),
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
createBuffer(schema);
|
|
120
|
+
const SpanBufferClass = getSpanBufferClass(schema);
|
|
121
|
+
|
|
122
|
+
// Stats are accessible via static property (utilization-based tuning)
|
|
123
|
+
expect(typeof SpanBufferClass.stats.capacity).toBe('number');
|
|
124
|
+
expect(typeof SpanBufferClass.stats.totalWrites).toBe('number');
|
|
125
|
+
expect(typeof SpanBufferClass.stats.spansCreated).toBe('number');
|
|
126
|
+
});
|
|
127
|
+
});
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
import {
|
|
3
|
+
createAttributeColumns,
|
|
4
|
+
createColumnWriter,
|
|
5
|
+
DEFAULT_BUFFER_CAPACITY,
|
|
6
|
+
maskingTransforms,
|
|
7
|
+
} from '@smoothbricks/arrow-builder';
|
|
8
|
+
import { convertToArrowTable, createSpanBuffer, ENTRY_TYPE_SPAN_START, S } from '@smoothbricks/lmao';
|
|
9
|
+
import { defineOpContext } from '../../defineOpContext.js';
|
|
10
|
+
import { defineLogSchema } from '../../schema/defineLogSchema.js';
|
|
11
|
+
import { ENTRY_TYPE_INFO } from '../../schema/systemSchema.js';
|
|
12
|
+
import { TestTracer } from '../../tracers/TestTracer.js';
|
|
13
|
+
import type { AnySpanBuffer } from '../../types.js';
|
|
14
|
+
import { invokeWriterMethod, nextWriterRow, requireAnySpanBuffer } from '../arrow-test-helpers.js';
|
|
15
|
+
import {
|
|
16
|
+
createTestOpMetadata,
|
|
17
|
+
createTestSchema,
|
|
18
|
+
createTestTraceRoot,
|
|
19
|
+
createTestTracerOptions,
|
|
20
|
+
} from '../test-helpers.js';
|
|
21
|
+
|
|
22
|
+
describe('Buffer Integration', () => {
|
|
23
|
+
it('generates columns with proper names for defined schema', () => {
|
|
24
|
+
const schema = createTestSchema({
|
|
25
|
+
userId: S.category(), // Category: user IDs repeat
|
|
26
|
+
isActive: S.boolean(),
|
|
27
|
+
score: S.number(),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const capacity = 64;
|
|
31
|
+
// createAttributeColumns expects ColumnSchema instance (schema extends LogSchema extends ColumnSchema)
|
|
32
|
+
const columns = createAttributeColumns(schema, capacity);
|
|
33
|
+
|
|
34
|
+
// Keys - should have prefix
|
|
35
|
+
expect(columns).toHaveProperty('userId');
|
|
36
|
+
expect(columns).toHaveProperty('isActive');
|
|
37
|
+
expect(columns).toHaveProperty('score');
|
|
38
|
+
|
|
39
|
+
// All columns should have correct storage types
|
|
40
|
+
expect(Array.isArray(columns.userId)).toBe(true); // category (raw strings)
|
|
41
|
+
expect(columns.isActive).toBeInstanceOf(Uint8Array); // boolean
|
|
42
|
+
expect(columns.score).toBeInstanceOf(Float64Array); // number
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('creates a SpanBuffer with core and attribute columns', () => {
|
|
46
|
+
const schema = createTestSchema({
|
|
47
|
+
userId: S.category(), // Category: user IDs repeat
|
|
48
|
+
score: S.number(),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const capacity = 64;
|
|
52
|
+
const buf = createSpanBuffer(schema, createTestTraceRoot('test-trace'), createTestOpMetadata(), capacity);
|
|
53
|
+
|
|
54
|
+
// Core TypedArrays exist
|
|
55
|
+
expect(buf.timestamp).toBeInstanceOf(BigInt64Array);
|
|
56
|
+
expect(buf.entry_type).toBeInstanceOf(Uint8Array);
|
|
57
|
+
|
|
58
|
+
// Attribute columns exist with correct types (use _values suffix)
|
|
59
|
+
expect(Array.isArray(buf.userId_values)).toBe(true); // category (raw strings)
|
|
60
|
+
expect(buf.score_values).toBeInstanceOf(Float64Array); // number
|
|
61
|
+
|
|
62
|
+
// Metadata
|
|
63
|
+
expect(buf._capacity).toBe(capacity);
|
|
64
|
+
expect(buf._writeIndex).toBe(0);
|
|
65
|
+
expect(buf._children).toHaveLength(0);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('integrates schema definition with buffer creation', () => {
|
|
69
|
+
// Define schema with defineLogSchema
|
|
70
|
+
const schema = createTestSchema({
|
|
71
|
+
requestId: S.category(), // Category: request IDs repeat
|
|
72
|
+
httpStatus: S.number(),
|
|
73
|
+
operation: S.enum(['GET', 'POST', 'PUT', 'DELETE']), // Enum: known HTTP methods
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Create buffer with schema
|
|
77
|
+
const buffer = createSpanBuffer(schema, createTestTraceRoot('test-trace'), createTestOpMetadata());
|
|
78
|
+
|
|
79
|
+
// Verify all attribute columns created with correct types (use _values suffix)
|
|
80
|
+
expect(Array.isArray(buffer.requestId_values)).toBe(true); // category (raw strings)
|
|
81
|
+
expect(buffer.httpStatus_values).toBeInstanceOf(Float64Array); // number
|
|
82
|
+
expect(buffer.operation_values).toBeInstanceOf(Uint8Array); // enum
|
|
83
|
+
|
|
84
|
+
// Verify schema is accessible via _logSchema (underscore prefix for system properties)
|
|
85
|
+
expect(buffer._logSchema.fields).toBe(schema.fields);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('handles optional fields in schema', () => {
|
|
89
|
+
const schema = createTestSchema({
|
|
90
|
+
required: S.category(), // Category string
|
|
91
|
+
optional: S.optional(S.number()),
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const buffer = createSpanBuffer(schema, createTestTraceRoot('test-trace'), createTestOpMetadata());
|
|
95
|
+
|
|
96
|
+
// Both should have column storage (use _values suffix)
|
|
97
|
+
expect(Array.isArray(buffer.required_values)).toBe(true); // category (raw strings)
|
|
98
|
+
// Note: S.optional() wraps the inner schema, losing __schema_type metadata
|
|
99
|
+
// This falls back to Uint32Array (default)
|
|
100
|
+
expect(buffer.optional_values).toBeInstanceOf(Uint32Array);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('handles masked fields in schema', () => {
|
|
104
|
+
const schema = createTestSchema({
|
|
105
|
+
userId: S.category().mask('hash'),
|
|
106
|
+
email: S.text().mask('email'),
|
|
107
|
+
plainText: S.text(), // Text: unmasked plain text
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const buffer = createSpanBuffer(schema, createTestTraceRoot('test-trace'), createTestOpMetadata());
|
|
111
|
+
|
|
112
|
+
// All should have column storage (use _values suffix)
|
|
113
|
+
// Masking is applied during Arrow conversion (cold path), not buffer creation
|
|
114
|
+
// With chainable .mask(), the __schema_type metadata is preserved
|
|
115
|
+
expect(Array.isArray(buffer.userId_values)).toBe(true); // category (raw strings) - masked during Arrow conversion
|
|
116
|
+
expect(Array.isArray(buffer.email_values)).toBe(true); // text (raw strings) - masked during Arrow conversion
|
|
117
|
+
expect(Array.isArray(buffer.plainText_values)).toBe(true); // text (raw strings)
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('selects correct enum TypedArray size based on value count', () => {
|
|
121
|
+
// Small enum (<256 values) should use Uint8Array
|
|
122
|
+
const smallEnumSchema = createTestSchema({
|
|
123
|
+
operation: S.enum(['GET', 'POST', 'PUT', 'DELETE']), // 4 values → Uint8Array
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const smallBuffer = createSpanBuffer(smallEnumSchema, createTestTraceRoot('test-trace'), createTestOpMetadata());
|
|
127
|
+
|
|
128
|
+
// Should use Uint8Array for enums with ≤255 values (use _values suffix)
|
|
129
|
+
expect(smallBuffer.operation_values).toBeInstanceOf(Uint8Array);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('applies masking during Arrow conversion for category fields', () => {
|
|
133
|
+
const schema = createTestSchema({
|
|
134
|
+
userId: S.category().mask('hash'),
|
|
135
|
+
plainUserId: S.category(), // No masking
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const buffer = createSpanBuffer(schema, createTestTraceRoot('test-trace'), createTestOpMetadata());
|
|
139
|
+
|
|
140
|
+
// Use ColumnWriter fluent API to write values (createColumnWriter expects ColumnSchema instance)
|
|
141
|
+
const writer = createColumnWriter(schema, buffer);
|
|
142
|
+
// Dynamic fluent API - schema methods are generated at runtime and can't be typed statically
|
|
143
|
+
invokeWriterMethod(invokeWriterMethod(nextWriterRow(writer), 'userId', 'user-12345'), 'plainUserId', 'user-12345');
|
|
144
|
+
|
|
145
|
+
// Set required system columns
|
|
146
|
+
buffer.timestamp[0] = 1000n;
|
|
147
|
+
buffer.entry_type[0] = ENTRY_TYPE_SPAN_START;
|
|
148
|
+
buffer._writeIndex = 1;
|
|
149
|
+
|
|
150
|
+
// Convert to Arrow table
|
|
151
|
+
const table = convertToArrowTable(buffer);
|
|
152
|
+
|
|
153
|
+
// Get the userId column (should be masked)
|
|
154
|
+
const userIdCol = table.getChild('userId');
|
|
155
|
+
expect(userIdCol).toBeDefined();
|
|
156
|
+
|
|
157
|
+
// Get the plainUserId column (should NOT be masked)
|
|
158
|
+
const plainUserIdCol = table.getChild('plainUserId');
|
|
159
|
+
expect(plainUserIdCol).toBeDefined();
|
|
160
|
+
|
|
161
|
+
// Verify the masked value matches the expected hash
|
|
162
|
+
const maskedValue = userIdCol?.get(0);
|
|
163
|
+
const expectedHash = maskingTransforms.hash('user-12345');
|
|
164
|
+
expect(maskedValue).toBe(expectedHash);
|
|
165
|
+
|
|
166
|
+
// Verify the unmasked value is unchanged
|
|
167
|
+
const unmaskedValue = plainUserIdCol?.get(0);
|
|
168
|
+
expect(unmaskedValue).toBe('user-12345');
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('applies masking during Arrow conversion for text fields', () => {
|
|
172
|
+
const schema = createTestSchema({
|
|
173
|
+
email: S.text().mask('email'),
|
|
174
|
+
sqlQuery: S.text().mask('sql'),
|
|
175
|
+
plainText: S.text(), // No masking
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
const buffer = createSpanBuffer(schema, createTestTraceRoot('test-trace'), createTestOpMetadata());
|
|
179
|
+
|
|
180
|
+
// Use ColumnWriter fluent API to write values (createColumnWriter expects ColumnSchema instance)
|
|
181
|
+
const writer = createColumnWriter(schema, buffer);
|
|
182
|
+
const textRow = invokeWriterMethod(nextWriterRow(writer), 'email', 'john@example.com');
|
|
183
|
+
invokeWriterMethod(
|
|
184
|
+
invokeWriterMethod(textRow, 'sqlQuery', "SELECT * FROM users WHERE id = 123 AND name = 'test'"),
|
|
185
|
+
'plainText',
|
|
186
|
+
'Plain unmasked text',
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
// Set required system columns
|
|
190
|
+
buffer.timestamp[0] = 1000n;
|
|
191
|
+
buffer.entry_type[0] = ENTRY_TYPE_SPAN_START;
|
|
192
|
+
buffer._writeIndex = 1;
|
|
193
|
+
|
|
194
|
+
// Convert to Arrow table
|
|
195
|
+
const table = convertToArrowTable(buffer);
|
|
196
|
+
|
|
197
|
+
// Get columns
|
|
198
|
+
const emailCol = table.getChild('email');
|
|
199
|
+
const sqlQueryCol = table.getChild('sqlQuery');
|
|
200
|
+
const plainTextCol = table.getChild('plainText');
|
|
201
|
+
|
|
202
|
+
// Verify email masking
|
|
203
|
+
const maskedEmail = emailCol?.get(0);
|
|
204
|
+
expect(maskedEmail).toBe(maskingTransforms.email('john@example.com'));
|
|
205
|
+
expect(maskedEmail).toMatch(/^j\*\*\*\*\*@example\.com$/);
|
|
206
|
+
|
|
207
|
+
// Verify SQL masking
|
|
208
|
+
const maskedSql = sqlQueryCol?.get(0);
|
|
209
|
+
expect(maskedSql).toBe(maskingTransforms.sql("SELECT * FROM users WHERE id = 123 AND name = 'test'"));
|
|
210
|
+
expect(maskedSql).toBe('SELECT * FROM users WHERE id = ? AND name = ?');
|
|
211
|
+
|
|
212
|
+
// Verify plain text is unchanged
|
|
213
|
+
const plainValue = plainTextCol?.get(0);
|
|
214
|
+
expect(plainValue).toBe('Plain unmasked text');
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('applies custom mask function during Arrow conversion', () => {
|
|
218
|
+
// Custom mask function that keeps first 4 chars and replaces rest with *
|
|
219
|
+
const customMask = (value: string) => value.slice(0, 4) + '*'.repeat(Math.max(0, value.length - 4));
|
|
220
|
+
|
|
221
|
+
const schema = createTestSchema({
|
|
222
|
+
secretKey: S.text().mask(customMask),
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
const buffer = createSpanBuffer(schema, createTestTraceRoot('test-trace'), createTestOpMetadata());
|
|
226
|
+
|
|
227
|
+
// Use ColumnWriter fluent API to write value (createColumnWriter expects ColumnSchema instance)
|
|
228
|
+
const writer = createColumnWriter(schema, buffer);
|
|
229
|
+
invokeWriterMethod(nextWriterRow(writer), 'secretKey', 'sk_live_abcd1234efgh5678');
|
|
230
|
+
|
|
231
|
+
// Set required system columns
|
|
232
|
+
buffer.timestamp[0] = 1000n;
|
|
233
|
+
buffer.entry_type[0] = ENTRY_TYPE_SPAN_START;
|
|
234
|
+
buffer._writeIndex = 1;
|
|
235
|
+
|
|
236
|
+
// Convert to Arrow table
|
|
237
|
+
const table = convertToArrowTable(buffer);
|
|
238
|
+
|
|
239
|
+
// Get the column
|
|
240
|
+
const secretKeyCol = table.getChild('secretKey');
|
|
241
|
+
|
|
242
|
+
// Verify custom masking was applied
|
|
243
|
+
// Input is 24 chars, first 4 are kept, remaining 20 are replaced with *
|
|
244
|
+
const maskedValue = secretKeyCol?.get(0);
|
|
245
|
+
expect(maskedValue).toBe('sk_l********************');
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
describe('Cross-Package Integration', () => {
|
|
249
|
+
it('validates lmao schema creates correct arrow-builder column types', () => {
|
|
250
|
+
const schema = createTestSchema({
|
|
251
|
+
enumField: S.enum(['A', 'B', 'C']), // Maps to Uint8Array
|
|
252
|
+
categoryField: S.category(), // Maps to string[]
|
|
253
|
+
textField: S.text(), // Maps to string[]
|
|
254
|
+
numberField: S.number(), // Maps to Float64Array
|
|
255
|
+
booleanField: S.boolean(), // Maps to Uint8Array
|
|
256
|
+
optionalField: S.optional(S.number()), // Maps to Uint32Array
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
const buffer = createSpanBuffer(schema, createTestTraceRoot('test-trace'), createTestOpMetadata());
|
|
260
|
+
|
|
261
|
+
// Verify arrow-builder created correct column types for each schema type
|
|
262
|
+
expect(buffer.enumField_values).toBeInstanceOf(Uint8Array);
|
|
263
|
+
expect(Array.isArray(buffer.categoryField_values)).toBe(true);
|
|
264
|
+
expect(Array.isArray(buffer.textField_values)).toBe(true);
|
|
265
|
+
expect(buffer.numberField_values).toBeInstanceOf(Float64Array);
|
|
266
|
+
expect(buffer.booleanField_values).toBeInstanceOf(Uint8Array);
|
|
267
|
+
expect(buffer.optionalField_values).toBeInstanceOf(Uint32Array);
|
|
268
|
+
|
|
269
|
+
// Verify Arrow null bitmaps exist for all columns
|
|
270
|
+
expect(buffer.enumField_nulls).toBeInstanceOf(Uint8Array);
|
|
271
|
+
expect(buffer.categoryField_nulls).toBeInstanceOf(Uint8Array);
|
|
272
|
+
expect(buffer.textField_nulls).toBeInstanceOf(Uint8Array);
|
|
273
|
+
expect(buffer.numberField_nulls).toBeInstanceOf(Uint8Array);
|
|
274
|
+
expect(buffer.booleanField_nulls).toBeInstanceOf(Uint8Array);
|
|
275
|
+
expect(buffer.optionalField_nulls).toBeInstanceOf(Uint8Array);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it('ensures data flows correctly between lmao APIs and arrow-builder buffers', () => {
|
|
279
|
+
const schema = createTestSchema({
|
|
280
|
+
userId: S.category(),
|
|
281
|
+
operation: S.enum(['GET', 'POST']),
|
|
282
|
+
httpStatus: S.number(),
|
|
283
|
+
error: S.text().mask('email'),
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
const buffer = createSpanBuffer(schema, createTestTraceRoot('test-trace'), createTestOpMetadata());
|
|
287
|
+
|
|
288
|
+
// Use ColumnWriter API to write data (more robust than direct array access)
|
|
289
|
+
const writer = createColumnWriter(schema, buffer);
|
|
290
|
+
const row = invokeWriterMethod(nextWriterRow(writer), 'userId', 'user-123');
|
|
291
|
+
invokeWriterMethod(
|
|
292
|
+
invokeWriterMethod(
|
|
293
|
+
invokeWriterMethod(row, 'operation', 'POST'), // Use enum value string (ColumnWriter validates against enum values)
|
|
294
|
+
'httpStatus',
|
|
295
|
+
200,
|
|
296
|
+
),
|
|
297
|
+
'error',
|
|
298
|
+
'john@example.com',
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
// Set system columns
|
|
302
|
+
buffer.timestamp[0] = 1000n;
|
|
303
|
+
buffer.entry_type[0] = ENTRY_TYPE_INFO;
|
|
304
|
+
buffer._writeIndex = 1;
|
|
305
|
+
|
|
306
|
+
// Convert to Arrow using arrow-builder
|
|
307
|
+
const table = convertToArrowTable(buffer);
|
|
308
|
+
|
|
309
|
+
// Verify Arrow conversion preserves data and applies masking
|
|
310
|
+
expect(table.numRows).toBe(1);
|
|
311
|
+
expect(table.getChild('userId')?.get(0)).toBe('user-123');
|
|
312
|
+
expect(table.getChild('operation')?.get(0)).toBe('POST');
|
|
313
|
+
expect(table.getChild('httpStatus')?.get(0)).toBe(200);
|
|
314
|
+
expect(table.getChild('error')?.get(0)).toBe('j*****@example.com'); // Email masked
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Validates that SpanBuffer correctly exposes system properties.
|
|
319
|
+
*
|
|
320
|
+
* System properties use `_` prefix (e.g., `_logSchema`, `_capacity`)
|
|
321
|
+
* to distinguish them from user-defined schema columns which have no prefix.
|
|
322
|
+
* The `_` prefix does NOT mean private - these are readonly public properties.
|
|
323
|
+
*/
|
|
324
|
+
it('validates module context integration with buffer metadata', () => {
|
|
325
|
+
const schema = createTestSchema({
|
|
326
|
+
requestId: S.category(),
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
const buffer = createSpanBuffer(schema, createTestTraceRoot('test-trace'), createTestOpMetadata());
|
|
330
|
+
// Caller must set span name via message() - simulating writeSpanStart behavior
|
|
331
|
+
buffer.message(0, 'context-integration');
|
|
332
|
+
|
|
333
|
+
// Verify buffer properly references schema via constructor
|
|
334
|
+
expect(buffer._logSchema).toBe(schema);
|
|
335
|
+
expect(buffer.message_values[0]).toBe('context-integration');
|
|
336
|
+
|
|
337
|
+
// Verify system metadata columns are accessible
|
|
338
|
+
expect(buffer.span_id).toBeGreaterThan(0);
|
|
339
|
+
expect(typeof buffer._hasParent).toBe('boolean');
|
|
340
|
+
expect(buffer._children).toBeInstanceOf(Array);
|
|
341
|
+
expect(buffer._writeIndex).toBe(0);
|
|
342
|
+
expect(buffer._capacity).toBe(DEFAULT_BUFFER_CAPACITY);
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
describe('Timestamp Ordering', () => {
|
|
347
|
+
it('should write increasing timestamps for each entry', async () => {
|
|
348
|
+
// SpanBuffer is just storage - SpanLogger writes timestamps.
|
|
349
|
+
// Use the full system (Tracer + SpanLogger) to verify entries have increasing timestamps.
|
|
350
|
+
const ctx = defineOpContext({
|
|
351
|
+
logSchema: defineLogSchema({
|
|
352
|
+
userId: S.category(),
|
|
353
|
+
}),
|
|
354
|
+
});
|
|
355
|
+
const { trace } = new TestTracer(ctx, { ...createTestTracerOptions() });
|
|
356
|
+
|
|
357
|
+
let capturedBuffer: AnySpanBuffer | undefined;
|
|
358
|
+
await trace('test', async (ctx) => {
|
|
359
|
+
// Log multiple entries with small delays
|
|
360
|
+
ctx.log.info('first');
|
|
361
|
+
await new Promise((r) => setTimeout(r, 5));
|
|
362
|
+
ctx.log.info('second');
|
|
363
|
+
await new Promise((r) => setTimeout(r, 5));
|
|
364
|
+
ctx.log.info('third');
|
|
365
|
+
// Access internal buffer for test verification
|
|
366
|
+
const internalBuffer = Reflect.get(ctx, '_buffer');
|
|
367
|
+
if (internalBuffer) {
|
|
368
|
+
capturedBuffer = requireAnySpanBuffer(internalBuffer, 'Expected trace callback to expose a span buffer');
|
|
369
|
+
}
|
|
370
|
+
return ctx.ok('done');
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
// Verify timestamps are strictly increasing
|
|
374
|
+
// Row 0 = span-start, Row 1 = span-ok/span-err, Row 2+ = log entries
|
|
375
|
+
expect(capturedBuffer).toBeDefined();
|
|
376
|
+
if (capturedBuffer === undefined) {
|
|
377
|
+
throw new Error('Expected trace callback to capture a span buffer');
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const ts = capturedBuffer.timestamp;
|
|
381
|
+
const writeIndex = capturedBuffer._writeIndex;
|
|
382
|
+
|
|
383
|
+
// At minimum, span-start (row 0) should be before span-ok (row 1)
|
|
384
|
+
expect(ts[1]).toBeGreaterThan(ts[0]);
|
|
385
|
+
|
|
386
|
+
// All written timestamps should be > 0
|
|
387
|
+
for (let i = 0; i < writeIndex; i++) {
|
|
388
|
+
expect(ts[i]).toBeGreaterThan(0n);
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
});
|
|
392
|
+
});
|