feat(asap-precompute-rs): otap codec (Phase 5 step B) - #256
Merged
Merged
Conversation
Adds the Layer-4 OTAP-Rust codec at `asap-precompute-rs/src/otap/`, gated behind the non-default `otap` Cargo feature. Mirrors the two-layer split pinned by `docs/design-asap-otap-rust-integration.md` §2 and the Phase-4 Telegraf codec (PR #234) in shape: pure data-shape translation between `arrow::RecordBatch` and the host-neutral `Observation` / `SketchEnvelope` types, no Tokio tasks, no timers, no control-channel inbox. Lifecycle (Wakeup-driven flush, control channel, linkme registration) is Phase C and explicitly deferred. The Strategy-B carrier keys (_asap_envelope, _asap_sketch_type, etc.) are defined as constants matching edge-framework §7.2's table byte-for-byte so cross-platform interop holds. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase B of the OTAP-Rust integration (per
docs/design-asap-otap-rust-integration.md§11):the Layer-4 codec for the Arrow-native edge agent. Pure data-shape
translation between
arrow::RecordBatchand the host-neutralObservation/SketchEnvelopetypes — no Tokio tasks, no timers,no control-channel inbox.
The codec lives at
asap-precompute-rs/src/otap/, gated behind anon-default
otapCargo feature so that the existing crate consumers(
sketchcollector,sketchtelegraf, the futuresketchvector) don'thave to compile Apache Arrow when they don't need it.
New files
asap-precompute-rs/src/otap/mod.rs— module entry, public surface,schema documentation.
asap-precompute-rs/src/otap/schema.rs— well-known column /attribute names (Strategy-B carrier keys per
edge-framework §7.2).
asap-precompute-rs/src/otap/decode.rs—decode_batch(&RecordBatch) -> Result<Vec<Observation>, OtapDecodeError>. One observation perrow; routes envelope rows (non-null
_asap_envelopecell) throughKindEnvelope, scalar rows throughKindFloat. Resolves columnsonce per batch then walks rows by index (the design-doc §4
throughput win).
asap-precompute-rs/src/otap/encode.rs—encode_batch(&[SketchEnvelope]) -> Result<RecordBatch, OtapEncodeError>. Strategy-B carrier:payload as
Binarycolumn, metadata as typed columns, labels asthe sorted union of all envelope label keys.
asap-precompute-rs/src/otap/plugin.rs—StubPlugin<P: Precompute>,the minimal "plugin compiles" shell that threads decode → observe →
tick → encode. Comments mark the seams Phase C will fill in
(
NodeControlMsg::Wakeup, control-channel task, lifecycle drain).asap-precompute-rs/tests/otap_codec.rs— integration tests:decode→encode round trip, encode→decode round trip, per-sketch-type
smoke (DDSketch / KLL / HLL / CountSketch / CountMinSketch
envelopes round-trip with
payloadintact), scalar-row decodeasymmetry pin.
Verification
All four verification commands are green:
The 14 new
otap::*unit tests plus the 4 new integration tests allpass. No-feature build still passes the existing 88 tests; nothing in
otapleaked into the default build.Deliberately deferred (Phase C / D)
Per
docs/design-asap-otap-rust-integration.md§11, the followingare out of scope for Phase B and intentionally NOT in this PR:
Wakeup-driven flush ticker (Phase C).NodeControlMsg::Confighandling (Phase C).otap-patch/plugins/asap_sketches/directory and the real OTAPlocal::Processor<OtapPdata>impl (Phase C).linkmedistributed-slice registration inotap-patch/all/mod.rs(Phase D).
build_sketchotap.shbuild pipeline (Phase D).OtapArrowRecordsshape with sibling resource / scope /per-row attribute child batches joined by integer ids — Phase B
uses a flat per-row RecordBatch carrying the Strategy-B keys as
ordinary columns. The Phase-C plugin shell is the layer that runs
OTAP's native attribute join and projects an
OtapArrowRecordsdown to the codec's flat shape.
StubPluginexists solely to satisfy the §11 exit criterion ("plugincompiles"); Phase C replaces it with a real OTAP plugin.
Schema decision (v1)
The codec discovers a flat per-row RecordBatch with well-known
columns by name (per design doc §4: "v1: pin to OTel-Arrow's
well-known schema"). Columns:
time_unix_nanoUInt64orTimestamp(Nanosecond)metricUtf8valueFloat64_asap_envelopeBinary_asap_sketch_typeUtf8"DDSketch"/"KLLSketch"/ …_asap_agg_idUInt64_asap_schema_versionUInt32_asap_window_start_msUInt64_asap_window_end_msUInt64_asap_encodingUtf8"PROTO_FULL"/"PROTO_DELTA"/"MSGPACK"Utf8columnUtf8The Strategy-B keys are byte-identical to the table in
edge-framework §7.2;
schema.rs::tests::well_known_keys_match_edge_framework_docpinsthat contract.
Test plan
cargo test --release -p asap-precompute-rs --features otap— green.cargo test --release -p asap-precompute-rs— still green; nothing inotapleaked into default build.cargo clippy --release -p asap-precompute-rs --features otap --all-targets -- -D warnings— clean.cargo doc --no-deps -p asap-precompute-rs --features otap— no broken intra-doc links.OtapDecodeErrorwith informative variants (not panics).payloadintact.🤖 Generated with Claude Code