Skip to content

impl(028): rustev trace tail - #160

Merged
bartekus merged 1 commit into
mainfrom
impl/028-d-tail-otlp
Oct 22, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/028-d-tail-otlp

Conversation

@bartekus

@bartekus bartekus commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Spec 028, split from the single PR #151 (its AI review timed out at 15 minutes three times) into #151, #158 and #159 (merging in that order), then #160 (increment 5), #164 (increment 6) and #165 (increment 7). Each part is one signed commit and builds on its own; later parts are stacked on the branch below and rebased onto main after each merge.

  • Increment 5, rustev trace tail (3.11, amends spec 006): --file, --trace-id, --redaction, --follow, --timeout-ms, --text, with rustev-contract alone and no new CLI dependency; the reader's policy applies on top of the line's, and keys outside the catalogue are counted, never echoed. End-to-end tests through the binary over the goldens.

Review responses (from the earlier #160 round on 6bf3bcd): node recursed with no cycle or depth bound; a span reached twice or deeper than 64 levels is now invalid_input naming the line, tested in a_cyclic_or_too_deep_span_tree_is_invalid_input_not_a_crash.

Local verification on this head: make gate, spec-spine couple and bash scripts/check-authored-content.sh pass. CI runs code, verify and boundaries.

Review response (round on 01146e8): the resource's withheld and uncatalogued attributes were counted into locals and dropped; the resource object now carries its own withheld_by_reader and not_in_catalogue, tested in a_key_outside_the_catalogue_is_withheld_with_a_notice.

@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff for bugs, security issues, and governance inconsistencies.

Governance / spec

Spec 028 moves from implementation: pending to complete and the spec itself records the implementation history. 028 is added to VERIFIED_SPECS in the Makefile, consistent with the verification block added to the spec. Archive policy gains src/trace.rs. All of this is self-consistent and within the spec's declared scope.

crates/rustev-cli/src/trace.rs — recursive node with no cycle detection (security)

The node function (approx. line 258 of the new file) collects children by scanning all lines for matching trace_id and parent_span_id, then recurses:

fn node(lines: &[TraceLine], i: usize, policy: &RedactionPolicy) -> Json {
    ...
    let children: Vec<Json> = lines
        .iter()
        .enumerate()
        .filter(|(_, c)| {
            c.trace_id == l.trace_id
                && c.parent_span_id.as_deref() == Some(l.span_id.as_str())
        })
        .map(|(j, _)| node(lines, j, policy))
        .collect();

There is no depth limit and no visited-set. span_id and parent_span_id are arbitrary strings parsed from user-supplied JSONL. A crafted file where span A names span B's span_id as its parent_span_id and span B names span A's span_id produces mutual infinite recursion and a stack overflow. Both spans need only share the same trace_id. Since rustev trace tail --file <path> accepts any file path, this is an exploitable denial-of-service: the process crashes with no output other than an OS-level signal.

Everything else checked

  • Budget accounting in read_more: correct; take(budget + 1) detects exhaustion before subtracting.
  • Endpoint allowlist: localhost correctly refused for plaintext (fails is_loopback_literal); OTEL_* env vars checked via check_all; unit tests confirm both paths.
  • export_logs mutex usage: lock acquired and released synchronously before the async block; no lock held across an await.
  • Histogram observation via observe hook plus counter-only snapshot in export_metrics: intentional and described in the implementation record.
  • Decision-loss counting in the refactored worker (first = spans.err().or(...)): correctly counts each decision once.
  • is_trace_id rejects uppercase; test confirms.
  • follow timeout math (div_ceil(POLL_MS) then n >= polls): correct; when follow = false, polls = 0 and the loop exits after the first failed find.
{"head": "6bf3bcdf47258f6558c728c637294cb92a889d8b", "verdict": "findings", "findings": [{"path": "crates/rustev-cli/src/trace.rs", "line": 258, "summary": "The `node` function recurses into child spans with no cycle detection or depth limit; a crafted JSONL file containing two spans whose `parent_span_id` fields each name the other causes infinite mutual recursion and a stack overflow, crashing the process."}]}

Subject: dacad91...6bf3bcd, diff digest f436fc94e2da57c2950da127efabd0bc8ed58c55887e5b2ab313909a1d82e3de, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 22, 2026 00:38 — with GitHub Actions Error
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff across all changed paths for bugs, security problems, and inconsistencies.

integrations/rustev-otel/src/endpoint.rs

The allowlist check and origin normalization look correct. Loopback-literal check (127.0.0.0/8, ::1) is applied after allowlist membership, so http://localhost:4318 can be added to an allowlist but check will always refuse it with PlaintextNotLoopback. The tests confirm this is intentional. The wildcard, user-info, and empty-list refusals are correct. Environment variable scanning in check_all covers all four standard OTLP vars. ✓

integrations/rustev-otel/src/otlp.rs

The endpoint re-check after build (for the programmatic endpoints handed to the builders) correctly strips paths via parse, so http://host:4318/v1/traces still resolves to origin http://host:4318. The OnRuntime wrapper that calls handle.block_on from the SDK reader's thread (launched via spawn_blocking) is correct — block_on on a Handle is safe from a non-async thread. The export_logs call drains collected after all emit calls complete; no lock is held across the .await. ✓

export_logs uses LogBatch::new (acknowledged in the implementation record as an internal SDK API). Not a defect in this PR.

integrations/rustev-otel/src/sink.rs worker refactor

The logs variable shadowing (Vec<LogRecord> → Result<(), LossReason>) is syntactically correct: the async move inside the else branch captures the Vec before shadowing occurs. Per-item attribution is correct: item.logs == 0 items correctly bypass log failure attribution both for lose_decision and for the waiter's result. ✓

crates/rustev-cli/src/trace.rs

Tail::read_more correctly double-checks file metadata (before and after open), seeks to self.offset, reads up to budget + 1 bytes to detect overflow without loading unbounded data, and then tracks remaining budget. Tail::find correctly restricts the policy-span search to lines[i..] (the exporter writes the policy span last), filters by trace_id and parent_span_id, and returns the last complete root in the file. Tail::parse correctly handles the partial-line oversized check on pending after draining complete lines.

The text_tree duration format (dur / 1_000_000 ms, (dur / 1_000) % 1_000 µs, {}.{:03}ms) is arithmetically correct; the confusingly-named ms closure is a style issue only.

The loop in run with polls = 0 when !follow terminates after exactly one read-and-check, returning trace_not_found on the first miss. ✓

Cargo.toml / integrations/rustev-otel/Cargo.toml

opentelemetry-http is specified directly in rustev-otel/Cargo.toml at version = "0.33" rather than being pinned in the workspace manifest alongside the other three OTel packages. The boundary grep in the verify block (^(opentelemetry|tracing-opentelemetry)) does match opentelemetry-http, so the boundary check still catches any leak outside integrations/. Minor inconsistency with the workspace comment's stated intent of centralization but not a correctness defect.

specs/028-opentelemetry-evidence-sink/spec.md

status: approved + implementation: complete is a valid final state per the lifecycle table. The verify:cli block replaces the pending paragraph as specified. 028 is added to VERIFIED_SPECS in Makefile. Consistent.


No concrete defects found.

{"head": "6bf3bcdf47258f6558c728c637294cb92a889d8b", "verdict": "no-findings", "findings": []}

Subject: dacad91...6bf3bcd, diff digest f436fc94e2da57c2950da127efabd0bc8ed58c55887e5b2ab313909a1d82e3de, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus force-pushed the impl/028-d-tail-otlp branch 2 times, most recently from 41e21a0 to 9990b52 Compare October 22, 2026 01:28
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the PR systematically across the changed paths.

integrations/rustev-otel/src/endpoint.rs — host validation

In parse(), the byte-level host check allows b':':

.all(|b| b.is_ascii_alphanumeric() || matches!(b, b'.' | b'-' | b':'))

This is inside the non-bracket code path. After rsplit_once(':') strips the port, the remaining host is checked with this validator. A host like foo:bar (from URL http://foo:bar:80) passes silently: foo:bar fails Ipv4Addr and Ipv6Addr parse, so is_loopback_literal() returns false, and plaintext-non-loopback is correctly refused. No allowlist bypass results, because both the allowlist entry and the endpoint go through the same parser and must produce identical Origin structs. However, the allowlist silently accepts a structurally invalid host rather than returning Malformed. This is a minor defect in input validation strictness rather than a security bypass.

Security-critical properties checked:

  • Allowlist exact-origin matching: correct. Allowlist::check calls parse() on both sides; only equal Origin values pass.
  • Plaintext-to-non-loopback refusal: correct. localhost fails Ipv4Addr/Ipv6Addr parse → is_loopback_literal() = false → PlaintextNotLoopback.
  • Environment variable endpoints checked against allowlist before any connection: correct via check_all + child-process test.
  • Redirects counted as failures, never followed: confirmed by a_redirect_is_an_export_failure_and_is_not_followed.
  • Secrets (header values) absent from errors and Debug: OtlpConfig::fmt uses finish_non_exhaustive; OtlpError::Header records only the name.

crates/rustev-cli/src/trace.rs — span tree rendering

  • Cycle detection via placed: Vec<bool> is correct; the placed check fires before recursing on a repeated line index, returning line i+1.
  • Depth guard at MAX_SPAN_DEPTH = 64 correctly stops at depth 64 (depth >= 64).
  • Budget enforcement in read_more: reads budget + 1 bytes to detect overrun, then subtracts exact amount read. Correct.
  • find() looks forward from the root's index for its policy span, matching the exporter's write order.

integrations/rustev-otel/src/sink.rs — split log export

The restructured worker now tracks span and log export outcomes separately and attributes decision loss to the first failing signal. The waiter receives spans.and(if item.logs > 0 { logs } else { Ok(()) }), which is correct.

Spec change

implementation: pending → implementation: complete on an approved spec is correct per the lifecycle table (approved + complete = settled, unresolved unit is an error). The verify block and VERIFIED_SPECS update are consistent.

No other concrete defects found. The endpoint validation quirk noted above is a strictness gap (silently accepts syntactically invalid hosts) but not a security bypass, since the allowlist check is symmetric and downstream HTTP/gRPC clients would reject malformed URIs before any connection is made.

{"head": "9990b52af6bf35423e3bd29d52b3589eb314ca30", "verdict": "no-findings", "findings": []}

Subject: 43ceaa9...9990b52, diff digest 31b950044c46650bfe07ee6e4c972569c0a4624712cdc36fa561d08e87765050, 1 call(s). An AI comment is not an approval.

@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the PR for rustev-otel OTLP transport, the trace tail CLI command, and the completion of spec 028.

Structural check: Spec 028 transitions from implementation: pending to implementation: complete with a verify:cli block and 028 added to VERIFIED_SPECS. The spec's own amendment rules allow this in-place edit. No governance inconsistency.

crates/rustev-cli/src/trace.rs — Tail::parse: The 64 KiB guard only covers the self.pending buffer (partial, newline-terminated lines still waiting). Complete newline-terminated lines are drained in the while loop and handed to TraceLine::parse_line with no size check. The spec implementation record says "a partial line already over 64 KiB is invalid_input", so the intent is partial-only; this matches spec text. No actionable finding here.

integrations/rustev-otel/src/endpoint.rs — parse host validation: After splitting authority on the last : via rsplit_once(':'), the host portion for a non-IPv6 authority is validated with a character set that includes ':' (shared with the IPv6 code path that uses a separate branch). For a URL like http://h1:h2:80, rsplit_once(':') yields host "h1:h2" and port 80; the colon in the host passes the matches!(b, b'.' | b'-' | b':') check and the origin is accepted as syntactically valid. The allowlist equality check and the inability to resolve h1:h2 via TLS/DNS limit practical impact, but the parser produces a structurally malformed Origin instead of a Malformed error.

integrations/rustev-otel/src/otlp.rs — gRPC ca_pem validation timing: The HTTP path (in otlp_http_client::client) validates ca_pem eagerly: it iterates CertificateDer::pem_slice_iter, maps each cert error to OtlpError::Tls(...), and fails at OtlpExporter::new(). The gRPC path (in the tonic_builder! macro) hands ca_pem directly to ClientTlsConfig::new().ca_certificate(Certificate::from_pem(pem.clone())) without parsing or validating the PEM bytes; tonic defers validation to connection time. An invalid ca_pem therefore passes OtlpExporter::new() for Protocol::Grpc but fails at the first dial attempt, contrary to the eager-failure contract that the HTTP path provides and that the OtlpError::Tls variants imply.

{"head": "9990b52af6bf35423e3bd29d52b3589eb314ca30", "verdict": "findings", "findings": [{"path": "integrations/rustev-otel/src/endpoint.rs", "line": null, "summary": "The character whitelist in `parse` permits ':' in non-IPv6 host names; after `rsplit_once(':')`, a URL like `http://h1:h2:80` produces host `\"h1:h2\"` rather than a `Malformed` error."}, {"path": "integrations/rustev-otel/src/otlp.rs", "line": null, "summary": "The gRPC path passes `ca_pem` to tonic's `Certificate::from_pem` without eager validation, so an invalid PEM silently passes `OtlpExporter::new()` and fails only at connection time, unlike the HTTP path which rejects invalid certs at construction."}]}

Subject: 43ceaa9...9990b52, diff digest 31b950044c46650bfe07ee6e4c972569c0a4624712cdc36fa561d08e87765050, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 22, 2026 01:37 — with GitHub Actions Error
@bartekus
bartekus force-pushed the impl/028-d-tail-otlp branch from 9990b52 to 63c6088 Compare October 22, 2026 01:48
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the changed files for bugs, security defects, and inconsistencies.

integrations/rustev-otel/src/endpoint.rs

The allowlist and plaintext-loopback enforcement look correct. Allowlist::new does not reject plaintext non-loopback entries at construction time (they only fail at check time), but check is always called before any connection is made, so no bypass exists. The is_loopback_literal check correctly handles both 127.0.0.0/8 and ::1. The environment-variable check in check_all covers all four OTLP endpoint variables. The re-check of built.endpoints after construction (with their /v1/traces etc. paths) correctly extracts the origin and verifies it, providing defense-in-depth against any SDK override.

integrations/rustev-otel/src/otlp.rs

The OnRuntime::export / drop ordering is safe: impl Drop::drop sets closing = true before fields are dropped in declaration order; meter_provider is the 5th field and closing is the 9th, so the flag is live and already true when the SDK shutdown path calls OnRuntime::export. The delta-counter logic in export_metrics (tracking seen to emit only increments) is correct. The spawn_blocking → provider.force_flush() → handle.block_on chain is valid because Tokio explicitly allows block_on from a blocking thread.

integrations/rustev-otel/src/otlp_http_client.rs

uri.host() from the http crate returns bare IPv6 addresses (without brackets); bare correctly strips non-existent brackets and connects using the bare address. The connector follows no redirects (HTTP 3xx causes a failed export, not a connection to the redirect target).

crates/rustev-cli/src/trace.rs

The placed bitmap prevents cycles and repeated span ids. MAX_SPAN_DEPTH (64) prevents stack overflow. The budget arithmetic is safe (take(budget + 1) then check > budget before subtracting). The find function searches only lines[i..] for the policy span, consistent with the exporter writing it last. The text_tree recursion is bounded by the same depth limit enforced in node. The --follow poll count uses div_ceil, which is correct.

integrations/rustev-otel/src/sink.rs worker changes

Span and log exports are correctly split into separate calls. Per-item statistics correctly attribute each signal to its own result. The decision-loss counter uses spans.err().or(if item.logs > 0 { logs.err() } else { None }), consistent with the waiter result spans.and(if item.logs > 0 { logs } else { Ok(()) }).

specs/028-opentelemetry-evidence-sink/spec.md

implementation advances from pending to complete. The verify:cli block and VERIFIED_SPECS addition are consistent. No governance rules prohibit this change.

No concrete defects found.

{"head": "63c6088aadc319d9828ac8d0303a8badad224782", "verdict": "no-findings", "findings": []}

Subject: 9510bef...63c6088, diff digest c93627cfe31844b0a99e89956f5e7bbfaf68b127edc8e859c9e505c340df659c, 1 call(s). An AI comment is not an approval.

@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the PR diff against the governance documents and repo context.

Scope: OTLP transport for rustev-otel (gRPC + HTTP), endpoint allowlist, rustev trace tail CLI command, redaction property test, overhead benchmark, and spec 028 moving from pending to complete.


Endpoint allowlist (integrations/rustev-otel/src/endpoint.rs)

The parse function correctly normalises schemes (lowercase), strips trailing dots, makes default ports explicit, and extracts the origin separate from any path. Allowlist::new rejects entries that carry a path. Allowlist::check rejects plaintext to anything that is not a loopback IP literal (127.0.0.0/8 or ::1); localhost is explicitly refused because its resolution is not checked, and the behaviour is tested. check_all covers all four standard OTEL_EXPORTER_OTLP_* endpoint variables. After the builders are constructed, the built endpoints are re-checked against the list to confirm the programmatic endpoint was used. No bypass is evident.

OTLP exporter (integrations/rustev-otel/src/otlp.rs)

OtlpExporter::new_with_env gates the allowlist check before touching the network. The double-check (allowlist → build → re-check built endpoints) closes the gap where a builder might ignore the programmatic endpoint. Header values are validated with http::HeaderName::from_bytes / HeaderValue::from_str (rejecting CRLF injection) and never appear in errors or Debug output. The closing atomic prevents the SDK's final metric flush from sending metrics outside the controlled flush_metrics path.

Log/span split in integrations/rustev-otel/src/sink.rs

Spans and logs are now exported in separate calls; each signal is counted by what happened to it, and a decision is counted once under the first reason that lost any of its telemetry. The waiter receives spans.and(if item.logs > 0 { logs } else { Ok(()) }). This is internally consistent.

trace tail CLI (crates/rustev-cli/src/trace.rs)

Tail::read_more double-checks is_file() before and after open_input (TOCTOU mitigation per spec 006 3.3.1). The budget is enforced with take(budget + 1). Cycle detection via the placed bitmap and depth bounding at MAX_SPAN_DEPTH = 64 prevent stack exhaustion on malformed files. Keys outside the catalogue increment not_in_catalogue and are never echoed. policy_mismatch is informational only; the reader's policy is always applied.

Spec 028 lifecycle change

status stays approved; only implementation advances from pending to complete. Per the contract table, this is a factual record change and does not require a new owner ratification.

Measurement type and TelemetryExporter additions

export_logs and observe are added with safe defaults (export_logs returns an error; observe is a no-op). OtelSink::new already guards against a logs: true sink paired with an exporter where takes_logs() is false, so the error-returning default can never be reached in valid configurations.

No concrete defects found across all changed paths.

{"head": "63c6088aadc319d9828ac8d0303a8badad224782", "verdict": "no-findings", "findings": []}

Subject: 9510bef...63c6088, diff digest c93627cfe31844b0a99e89956f5e7bbfaf68b127edc8e859c9e505c340df659c, 1 call(s). An AI comment is not an approval.

bartekus added a commit that referenced this pull request Oct 22, 2026
…y and trace line (#151)

Part 1 of 4 of spec 028, split from the single PR #151 because its AI
review timed out at 15 minutes three times. Merge in order: #151
(increments 1 and 2), #158 (increment 3), #159 (increment 4), #160
(increments 5 to 7). Each part is one signed commit; later parts are
stacked on the branch below and are rebased onto `main` after each
merge.

- Increment 1, `tools/rustev-boundaries` (3.12): the telemetry exporter
family (every `opentelemetry*` package and `tracing-opentelemetry`). A
crate outside `integrations/` that declares one as a normal or build
dependency (optional included) or reaches one through its resolved
normal and build graph is `TelemetryOutsideIntegrations`, naming the
path. Rule 3.4.1 for the pure crates is unchanged. The pinned facts of
3.2.1 were re-confirmed on 2026-10-21; the v1.41.1 pin stands.
- Increment 2, `rustev-contract` (3.3, 3.4, 3.10.1): `redaction` (field
classes and defaults, the lineage rule, the `rustev.redaction/1`
document and `RedactionPolicyId`, validation naming the entry for every
refusal of 3.4.2, the effective action, the keyed HMAC-SHA256 digest
through `hmac` 0.12, `DigestKey` that is never serialized and whose
`Debug` shows only the `key_id`, and `Redactor`); `trace_fields` (the
closed catalogue and the pinned schema URL); `trace` (the
`rustev.trace/1` line under the new `TRACE_V1` limits). Tests include
RFC 4231 vectors and independently computed Rustev vectors. No existing
document, schema string, limit, canonical byte or identity changes.

Owner decisions:
- 028 takes an `extends` edge on `tools/rustev-release/`: its new
contract source files and `crates/rustev-cli/src/trace.rs` join the
reviewed archive lists, and `rustev-otel` is listed as excluded in
`release-set.json` (as 027 and 033 took).
- JSON Schemas for `rustev.redaction/1` and `rustev.trace/1`: the owner
decided on 2026-10-21 that they join spec 027's emitter. That is out of
scope here (it regenerates the committed binding declarations under
`integrations/rustev-wasm/` and `integrations/rustev-node/`) and lands
in a follow-up PR after the 028 series merges, recorded as R-46.

Local verification on this head: `make gate` and `spec-spine couple`
pass; `bash scripts/check-authored-content.sh` passes. The combined tree
of all four parts is identical to the squashed #151 head 5c44374, whose
CI run passed every job except the timed-out AI review (code, verify,
boundaries, bindings, release-checks).

Review responses (round on 14b8c82):
- `TraceLine::check` now refuses a `schema_version` other than
`SPAN_SCHEMA_VERSION` (1), on read and on write; tested in
`bad_lines_are_refused`.
- `DigestKey` key bytes: overwritten on drop (`fill(0)` then
`std::hint::black_box`). This is best effort by design: spec 028 3.1.1
gives `rustev-contract` exactly one new dependency, `hmac` (quoted:
"with one new dependency, `hmac` (3.4.5), beside its existing `sha2`"),
so `zeroize` would need a spec amendment, and the crate has
`#![forbid(unsafe_code)]`, so no volatile write. The per-call HMAC state
derived from the key is not covered. The implementation record says so.
bartekus added a commit that referenced this pull request Oct 22, 2026
Part 2 of 4 of spec 028, split from the single PR #151 because its AI
review timed out at 15 minutes three times. Merge in order: #151
(increments 1 and 2), #158 (increment 3), #159 (increment 4), #160
(increments 5 to 7). Each part is one signed commit; later parts are
stacked on the branch below and are rebased onto `main` after each
merge.

- Increment 3, `integrations/rustev-otel` (3.5, 3.10.2): the projection
of a delivered `rustev.run/1` record to a span tree, every value through
`Redactor`; the append-only `0600` JSONL exporter bounded by
`max_bytes`; goldens for both reference plans and the scripted remote
exchange, under the default and an all-allow policy, reproduced byte for
byte. `publish = false`, listed as excluded in `release-set.json`.

Owner decisions:
- Readings chosen where the spec left room, each recorded in the spec's
implementation record: the projection knows only the `rustev.run/1`,
`rustev.evidence/1` and `rustev.judgment/1` versions and anything later
is `projection_unknown`; outcome parameter kinds are preserved (decimals
as exact strings, composites as canonical JSON); a reader without a
`fields` override applies the most withholding action a lineage-rule
field could take; conservation is per signal in items while
`rustev.telemetry.lost{reason}` counts decisions under exactly one
reason; metric dimensions only for `allow` fields; `logs: on` with the
JSONL exporter is refused; `schema` accepts `1` alone; the configuration
ranges; the trace-id ratio in integer form; `trace tail` completeness
(root plus policy span) and polling in 200 ms steps with no clock; an
`OTEL_*` endpoint variable outside the list refuses construction.

Local verification on this head: `make gate` and `spec-spine couple`
pass; `bash scripts/check-authored-content.sh` passes. The combined tree
of all four parts is identical to the squashed #151 head 5c44374, whose
CI run passed every job except the timed-out AI review (code, verify,
boundaries, bindings, release-checks).
@bartekus
bartekus force-pushed the impl/028-d-tail-otlp branch from 63c6088 to 01146e8 Compare October 22, 2026 03:33
@bartekus bartekus changed the title impl(028): rustev trace tail, OTLP export and verification impl(028): rustev trace tail Oct 22, 2026
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the PR, which adds rustev trace tail (spec 028, §3.11) to the CLI. I'll check the new trace.rs, the args changes, and the spec update.

args.rs — Switch arity and the trace tail command spec look correct. The duplicate-switch guard (insert returning Some) and the continue after insertion are both right.

trace.rs — general flow

  • is_trace_id: correctly accepts only 32 lowercase hex chars.
  • tail: forbid fires before p.uint is reached when --timeout-ms is given without --follow. Order is correct.
  • run: the Result<Exit, Exit> early-exit pattern is unusual but harmless; both arms of the caller's match extract the Exit.
  • Poll math: timeout_ms.div_ceil(POLL_MS) gives polls iterations after the first read; total wait is polls × POLL_MS ms, consistent with the test using --timeout-ms 400 expecting ~400 ms.
  • Tail::read_more: TOCTOU is mitigated by the second metadata() check on the already-open fd.
  • Tail::parse: line_no increments before the map_err call, so the 1-based line is correct. The pending-too-long check uses line_no + 1 for the not-yet-complete line, also correct.
  • Tail::find: reverse scan with self.lines[i..] finds the policy span at or after the decision span in file order. Correct.
  • node: cycle and depth guards are correct; placed array prevents revisiting the same index.
  • shown: event attributes look up {event_name}.{attr_key} in the policy catalogue but store only the local key in the output object — the right design.
  • text_tree: duration formatting dur/1_000_000 . (dur/1_000)%1_000 ms is correct sub-millisecond display.

Concrete defect — resource withheld/unknown silently discarded

In node() (lines 313–321), the resource attributes are filtered through shown() with fresh local accumulators u and w:

if let Some(r) = &l.resource {
    let mut u = 0;
    let mut w = vec![];
    n["resource"] = json!({
        "attributes": shown(policy, &r.attributes, None, &mut u, &mut w),
        ...
    });
}

u (uncatalogued count) and w (withheld field names) are populated by shown() and then silently dropped — they are never merged into the node's not_in_catalogue or withheld_by_reader fields. A resource attribute withheld by policy disappears from the output with no signal to the reader; the same is true for attributes outside the catalogue. This is inconsistent with how span and event attributes are handled (lines 305–312), where both are reported.

Tests — the test suite does not cover resource-level withheld attributes, so this gap goes undetected.

No other concrete defects found. The spec text, archive-policy update, and the --follow timeout logic all match the implementation.

{"head": "01146e8f9ed1f130d5bd0946eae1f78b61f33eea", "verdict": "findings", "findings": [{"path": "crates/rustev-cli/src/trace.rs", "line": 314, "summary": "Local accumulators `u` and `w` passed to `shown()` for resource attributes are discarded after the call; withheld and uncatalogued resource attributes are silently dropped with no entry in `withheld_by_reader` or `not_in_catalogue`, inconsistent with how span and event attributes are handled."}]}

Subject: 856d1d6...01146e8, diff digest 866df68ce69633cad2d90c9ff0dadf5b39cb57eaef13106937188fe227f5bbdc, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 22, 2026 03:42 — with GitHub Actions Error
@bartekus
bartekus force-pushed the impl/028-d-tail-otlp branch from 01146e8 to d4d98ac Compare October 22, 2026 03:48
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

I reviewed the diff carefully across all six changed paths.

crates/rustev-cli/src/args.rs
The new Arity::Switch variant and its parser path are correct. Duplicate-switch detection (is_some() check on insert) is right. The --text x usage-error case works because the base parser rejects unknown positional arguments. The COMMANDS entry and usage string match.

crates/rustev-cli/src/lib.rs
The early-return intercept for ["trace", "tail"] is placed before dispatch, so there is no double-dispatch risk.

crates/rustev-cli/src/trace.rs

Budget tracking. f.take(self.budget as u64 + 1) then bytes.len() > self.budget is a correct over-read-by-one guard. budget is always ≤ 256 MiB so the as u64 + 1 cannot overflow.

find() completeness check. Searching lines[i..] for the policy span assumes the exporter writes the policy span after the decision root — which the spec guarantees ("the exporter writes last, in the same write"). Correct per spec.

Cycle / depth guard. placed is indexed by line position (not by span-id), so two distinct lines with the same span-id will be independently marked. A span that names one of its own descendants as its parent is caught because that descendant's line is already in placed when the recursion backtracks to it.

Poll-based timeout. With polls = timeout_ms.div_ceil(POLL_MS) and the increment/compare order (n >= polls before n += 1), the loop performs exactly polls sleeps of 200 ms each, bounding total wait to approximately timeout_ms. Correct.

policy_mismatch logic. Correctly compares the root span's rustev.redaction.policy_id attribute (writer-side) against policy.policy_id() (reader-side); absent attribute → mismatch = true (conservative, as expected).

text_tree format. dur / 1_000_000 gives whole ms; (dur / 1_000) % 1_000 gives the sub-ms microseconds. The format {}.{:03}ms is correct for displaying sub-millisecond precision.

is_trace_id. Accepts only lowercase hex as the spec requires; the uppercase test case is correctly a usage error.

Import boundary. Only rustev_contract and serde_json (already a workspace dep) are imported — no new dependency, consistent with the spec amendment.

crates/rustev-cli/tests/trace.rs
Tests are comprehensive: last complete root, trace-id selection, redaction narrowing, unknown-catalogue key, malformed/oversized lines, cycle and depth limits, follow/timeout, text mode, every usage-error case, and invalid policy file. All paths through the implementation are exercised.

specs/028-opentelemetry-evidence-sink/spec.md
Increment 5 description is self-consistent with the code. The code references (3.11.1–3.11.5) align with the normative text added.

tools/rustev-release/archive-policy.json
src/trace.rs is added in alphabetical order within the crates/rustev-cli entry. Consistent with the new file.

No defects found.

{"head": "d4d98ac06f316f6deb9ab1c3ed5d4fa0382ce0fb", "verdict": "no-findings", "findings": []}

Subject: 25e0194...d4d98ac, diff digest 5547c27dc0b5667dc906c23ec7d5af37bca3b23f07bcee7bc1ae66ae0f6c68ca, 1 call(s). An AI comment is not an approval.

Base automatically changed from impl/028-c-sink to main October 22, 2026 04:26
bartekus added a commit that referenced this pull request Oct 22, 2026
Part 3 of 4 of spec 028, split from the single PR #151 because its AI
review timed out at 15 minutes three times. Merge in order: #151
(increments 1 and 2), #158 (increment 3), #159 (increment 4), #160
(increments 5 to 7). Each part is one signed commit; later parts are
stacked on the branch below and are rebased onto `main` after each
merge.

- Increment 4, the sink (3.6 to 3.9.4): `OtelSink` and `TeeSink`;
synchronous projection and redaction, metrics never sampled, sampling,
whole-tree queueing, `otel:accepted:` / `otel:exported:` /
`otel:sampled_out:` receipts; a worker exporting each batch as its own
task under the timeout so failures, hangs and panics are counted;
conservation per signal; W3C trace context, plan registration and the
exchange join buffer. Tested through the runtime under every spec 003
sink policy, including the equivalence of 3.8.6.

Owner decisions:
- SDK workarounds: metrics go through an SDK meter provider with a
periodic reader (interval one year) driven by `flush_metrics`, because
`ResourceMetrics` can only be filled by an SDK reader and the manual
reader's `collect` needs `experimental_metrics_custom_reader`, which
3.2.3 does not enable; the SDK's final export on drop is skipped so
metrics leave only through `flush_metrics`, where they are counted. Log
records are exported with `LogBatch::new`, which the SDK documents as
public but not meant for direct use, so an SDK upgrade may need to
revisit it.

Local verification on this head: `make gate` and `spec-spine couple`
pass; `bash scripts/check-authored-content.sh` passes. The combined tree
of all four parts is identical to the squashed #151 head 5c44374, whose
CI run passed every job except the timed-out AI review (code, verify,
boundaries, bindings, release-checks).

Review responses (round on 43ceaa9):
- `logs_of` no longer indexes `p.lines[0]` or `p.lines[a.line]`: it
returns no records without a root line and skips an attempt whose line
is out of range.
- `AttrSet::with` now checks the dimension class (enum, plan metadata,
model identity) at run time in every build instead of a `debug_assert!`;
a unit test grants `allow` to every grantable class and shows only the
enum field becomes an attribute.

Size: about 3,100 added lines, over the 2,000-line guideline, all
authored: `src/sink.rs` is one 1,256-line module (the sink, its queue
and its export worker) and `tests/sink.rs` its 990 lines of tests;
`context.rs`, `config.rs` and `metrics.rs` make up the rest. The only
cut available would still leave a part of about 2,300 lines, and the AI
review of this content has finished within its time limit on every run,
so it stays one PR (coordinator decision).

Head 856d1d6 failed `cargo fmt` (the new metrics unit test); fixed by
formatting only, no content change.
@bartekus
bartekus force-pushed the impl/028-d-tail-otlp branch from d4d98ac to e5fbb21 Compare October 22, 2026 06:25
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

I reviewed the diff carefully across all six changed paths. The implementation adds rustev trace tail to the CLI (spec 028 Increment 5), a new Arity::Switch parser variant, a trace.rs module, integration tests, the spec section, and an archive policy update.

Parser (args.rs): The Switch arity is correctly handled: an empty vec![] is inserted and a duplicate produces a usage error via is_some(). The --text x case (extra positional after a switch) is correctly rejected as a usage error per the test.

Tail::read_more: The file is checked as regular before and after open, the budget is enforced with a +1 read to detect exhaustion, and self.budget -= bytes.len() is safely guarded by the prior check.

Tail::parse: Complete lines are consumed and their count maintained; the partial-line size guard correctly uses self.line_no + 1 for the next line number. The TRACE_V1.max_bytes check fires before the \n is found, matching the spec wording.

Tail::find: Iterates in reverse and for each DECISION span checks lines[i..] for a direct-child POLICY span. The [i..] slice correctly relies on the exporter's guarantee that the policy span is written after the root. The "last complete root wins" semantics are correct.

node / cycle detection: placed[i] is set on entry, preventing the same line index from being visited twice. A repeated span_id in two file lines is caught only when both lines share the same children (which triggers the placed check). The spec increment text says "reaches a line twice (a span naming its own descendant as its parent, or a repeated span id)" — this language means the traversal reaches the same index twice, which the placed-array approach correctly captures. Two leaf lines with the same span_id field but no children would appear duplicated in output; however that scenario is not reachable via the traversal "reaching a line twice," so it is within the spec's stated scope.

Polling / timeout: polls = timeout_ms.div_ceil(POLL_MS) with n starting at 0 gives the expected number of sleeps. follow=false yields polls=0, so on the first iteration n >= polls is immediately true and returns trace_not_found. Correct.

text_tree / fixed::WITHHELD skip: The shown() function never inserts a key equal to fixed::WITHHELD into the attributes map (withheld entries are recorded in a separate withheld_by_reader node key), so the skip is dead code. It causes no incorrect output.

Spec change: The added increment section is consistent with the implementation. The spec file's frontmatter is not changed (the amends edge to spec 006 was established in an earlier increment of spec 028, not modified here).

Archive policy: src/trace.rs is added in alphabetical order, consistent with surrounding entries.

No concrete defect found.

{"head": "e5fbb217c9ab90b45a43ead28d69889a6f9cf60f", "verdict": "no-findings", "findings": []}

Subject: 1b0ce68...e5fbb21, diff digest 527074620b0b587a6eeb8253f7107f7bb2f036a46b4355b9e4833a04c8d8279b, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus enabled auto-merge (squash) October 22, 2026 06:32
@bartekus
bartekus disabled auto-merge October 22, 2026 06:32
@bartekus
bartekus force-pushed the impl/028-d-tail-otlp branch from e5fbb21 to 6b8fdae Compare October 22, 2026 06:36
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff across all six changed paths.

crates/rustev-cli/src/args.rs – Switch arity is added correctly; the duplicate-switch guard (values.insert(...).is_some()) and the continue that skips value consumption are both sound. The new trace tail command entry is consistent with the existing macro pattern.

crates/rustev-cli/src/lib.rs – The trace tail early-dispatch block is correctly placed before the generic dispatch call; the comment about non-JSON stdout is accurate.

crates/rustev-cli/src/trace.rs

  • Budget sentinel: f.take(self.budget as u64 + 1) then if bytes.len() > self.budget is the correct one-byte-over trick. Budget and offset updates are ordered correctly.
  • find: iterates rev() for "last complete root wins"; self.lines[i..] correctly requires the policy span to appear at or after the root line (exporter always writes policy span last). The double filter on trace_id and parent_span_id correctly distinguishes co-hosted decisions.
  • Cycle/depth guards: placed[i] keyed on line index, not span-id, but a true cycle (parent → descendant → back) still trips the placed check; MAX_SPAN_DEPTH = 64 is an independent backstop. Both are consistent with what the tests exercise.
  • is_trace_id: correctly rejects uppercase and wrong-length inputs.
  • Timeout arithmetic: div_ceil(POLL_MS) with n >= polls checked before sleep gives the right number of sleeps for a given timeout_ms; the test with timeout_ms=400 (2 sleeps × 200 ms) is consistent.
  • --timeout-ms without --follow is rejected via p.forbid; value range 1–3 600 000 matches spec and test cases.
  • text_tree duration format (dur/1_000_000 integer part, (dur/1_000)%1_000 three-digit decimal) correctly renders nanosecond timestamps as milliseconds with µs precision.
  • policy_mismatch treats a missing fixed::POLICY_ID attribute as a mismatch, which matches the test expectation for support.allow.trace.jsonl.
  • Unknown-key (not_in_catalogue) count is never echoed, only counted; withheld keys are catalogue names only. Both match spec 028 §3.11.4.

crates/rustev-cli/tests/trace.rs – Coverage is comprehensive: last-complete-root selection, --trace-id filtering, reader policy narrower than writer, not_in_catalogue on span and resource, malformed/foreign-schema/oversized lines, cycle and depth overflow, --follow across an append and to timeout, --text format, all usage-error cases, invalid policy file.

specs/028-opentelemetry-evidence-sink/spec.md – Increment 5 prose matches implementation: flags, switch grammar, usage errors, completeness criterion (root + policy span), cycle/depth limits, follow polling, output schema, text mode, and test inventory.

tools/rustev-release/archive-policy.json – src/trace.rs inserted in sorted position within the rustev-cli file list; no other entries disturbed.

No bugs, security issues, or spec inconsistencies found.

{"head": "6b8fdaefe03a0a24d2de7127b2edd01e4bab9f1f", "verdict": "no-findings", "findings": []}

Subject: 262b37c...6b8fdae, diff digest 527074620b0b587a6eeb8253f7107f7bb2f036a46b4355b9e4833a04c8d8279b, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus enabled auto-merge (squash) October 22, 2026 06:43
@bartekus
bartekus disabled auto-merge October 22, 2026 07:21
Spec 028 increment 5 (3.11, amends spec 006): rustev trace tail over rustev.trace/1 files under a reader redaction policy, using rustev-contract alone; a cyclic or too deep span tree is invalid_input.
@bartekus
bartekus force-pushed the impl/028-d-tail-otlp branch from 6b8fdae to e7ec0ab Compare October 22, 2026 07:24
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the PR, which adds rustev trace tail (spec 028 increment 5) to the CLI.

args.rs — Arity::Switch is added correctly. The parser inserts an empty vec![] for Switch flags and uses is_some() to enforce "at most once." The --text positional-arg rejection relies on the existing parser rejecting non--- tokens after the command path, which is consistent with the rest of the command table.

trace.rs — is_trace_id — Only accepts lowercase hex (a–f), length 32. The test includes an uppercase case that must be rejected; the function correctly rejects it.

trace.rs — run poll loop — With polls = timeout_ms.div_ceil(POLL_MS) and the check if n >= polls coming after each read attempt, a timeout_ms = 400 / POLL_MS = 200 yields polls = 2, meaning two sleeps (400 ms total) before returning trace_not_found. Non-follow case: polls = 0, so after one read (no find), 0 >= 0 returns immediately. Both are correct.

trace.rs — read_more budget — Uses f.take(budget + 1) to detect exhaustion in one read without a second syscall. If budget == 0, reads at most 1 byte and fails the > budget check. Metadata checked before and after open per spec 006 3.3.1.

trace.rs — parse — Partial lines without \n remain in pending, correctly waiting for the next poll. Lines exceeding TRACE_V1.max_bytes in the pending buffer produce invalid_input on the next line number (line_no + 1), which matches the test expecting line 13 for the oversized-line case.

trace.rs — find — Searches lines[i..] (not i+1..) for the POLICY child, which is correct because the policy span always has a higher index than the decision span (exporter writes it last). Uses .rev() to return the last complete root.

trace.rs — node cycle/depth — placed array guards against a span being visited twice (catches both cycles and duplicate span IDs). Depth check at entry before recursing prevents stack exhaustion. The test's cyclic case (parent_span_id of root set to a step's span_id) triggers placed[root] == true when following children back to the root, returning line 1 as expected.

trace.rs — text_tree — The k == fixed::WITHHELD skip when iterating n["attributes"] is worth noting: withheld_by_reader is a top-level node key, not stored inside attributes, so this branch is unreachable unless fixed::WITHHELD names an actual attribute that could appear in the shown() output. Without seeing the constant's value this is dead code at worst, not a correctness defect.

trace.rs — render policy_mismatch — Compares fixed::POLICY_ID attribute of the root span against policy.policy_id(). If the file was written under a wider policy, policy_mismatch is true. Correct.

archive-policy.json — src/trace.rs inserted in alphabetical order between sink.rs and tests/…. Correct.

Spec consistency — The increment text correctly describes what was implemented: Switch arities, the 256 MiB budget, TRACE_V1 per-line bound, the "last complete root" semantics, the not_in_catalogue count (never echoed), policy_mismatch, --text output format, and every usage-error rule. All are reflected faithfully in the code and tests.

No concrete defects found.

{"head": "e7ec0ab7d07f1311a3564d55d8468e63cc5a0531", "verdict": "no-findings", "findings": []}

Subject: 6060167...e7ec0ab, diff digest 94bce7f3c2f8493c2025deca8a10152d04ad8d11c6ca45588a7072c816347480, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus enabled auto-merge (squash) October 22, 2026 07:30
@bartekus
bartekus merged commit 21a00fc into main Oct 22, 2026
26 checks passed
@bartekus
bartekus deleted the impl/028-d-tail-otlp branch October 22, 2026 07:57
bartekus added a commit that referenced this pull request Oct 22, 2026
Spec 029 increment 3: repeat sets and `rustev.repeat-report/1` (3.1,
3.2.5, 3.5, 3.6). Library only; no CLI, ledger, baseline or gate yet; no
live run, provider call or spend. `implementation` stays `in-progress`.

- `rustev-eval/src/repeat.rs` (new): `repeat(RepeatInputs)` over N
reconciled runs. Refuses the `live` source (`live-source-unavailable`),
  N outside 1 to 64, unreconciled case measures (`reconcile`), runs that
  differ in dataset, split, evaluator configuration, plan or metric list
  or do not list the split's cases in manifest order (`mixed-runs`), a
  `replay` set whose runs are not identical (`not-reproducible`), an
  unreported stability metric or override, and a cohort over the
  bootstrap bound (`bootstrap-too-large`). The report names the source,
  configurations, dataset, split and fixed role (3.7.1), provenance,
  adapter rules, plan, each run's document digests and run seed, the
  stable cohort, and per cohort (`all`, then each slice) every metric's
per-run values, `mean`, `sd`, `min`, `max`, `pooled`, interval and band
  with its basis. Slices below their minimum are unknown throughout; a
metric without a per-case measure (cost totals, `brier`) has across-run
  statistics in `all` only. Latency, queue and cost metrics state their
observation (`historical` for candidate runs, 3.11.2). A held-out report
  records `held_out` as unknown until increment 4 adds the ledger.
- `rustev-eval/src/report.rs`, `eval_cases.rs`: `cost_per_1000/observed`
  and `/estimated` case measures (3.2.5), unknown unless cost units are
  declared comparable, the observed series unknown for a case with
  liability or an unknown charge; none for a candidate.
- `rustev-eval/src/repeat_stats.rs`: `across_runs`, factored out of
  `run_stats` unchanged, for metrics stated only by the run reports.
- Tests (`tests/reports.rs`): replay set (zero `deterministic_replay`
  band, pooled equal to the report, distinct run seeds, stable cohort,
  totals and `brier`, observations, unknown `cost_per_1000`, a reported
  slice and one below its minimum, round trip and byte determinism);
  captured set with a case losing its bundle (stable cohort, positive
  `k_sd` band); one captured run (unknown band); differing replays, the
  live source and N of 0 and 65 refused; mixed baseline and candidate
runs, unreconciled measures and an unreported stability metric refused;
  a candidate set with historical observations and `interval_width`
  bands.
- `tools/rustev-release/archive-policy.json`: `src/repeat.rs`.
- Spec 029: increment 3 record and engineering choices.

Still open from increment 2: owner decision D-029-1 (Brier per-case
measures), recorded in spec 029's implementation record.

Local verification (macOS arm64): `make gate` passes with spec-spine
0.31.0; `cargo clippy -p rustev-eval --all-targets -- -D warnings`,
`cargo test -p rustev-eval` and `cargo test -p rustev-fp-corpus` pass.

Review round 1 (1 finding, not a defect, evidence added): the finding
says
a candidate's cases get a known `cost_per_1000/observed` when costs are
comparable and known. The cost measures sit inside `case_measures_of`'s
`if inputs.candidate.is_none()` block (opened above the latency loop,
outside the reviewed hunk), so a candidate's cases carry none. A comment
now says so in the hunk, and a new test,
`cost_per_1000_is_measured_for_a_baseline_and_never_for_a_candidate`,
declares cost units comparable and checks that the baseline's cases
carry
cost per 1000 while the candidate's carry none and its repeat report's
`cost_per_1000/observed` is historical and unknown.

Review round 2: no findings. Rebased onto `main` after #159 (no
conflict).
`make code` passes locally on this head, except two failures caused by
other worktrees sharing the build target (a test binary removed by a
concurrent `cargo clean`, and `rustev-jev`'s `lodging_swap` finding its
output directory already created by a concurrent run); each passes when
rerun alone.

Review round 3 (1 finding, fixed by making the rule explicit): the
finding
says `cost_unknown_attempts` should carry no observation. It is one of
the
four cost series a spec 004 candidate report replaces with "the
candidate
was not executed; latency and cost are the baseline's", so it is an
observation of the runs and historical for a candidate, as 3.12.4 needs.
`observation` now lists latency, queue, the four cost series and
`cost_per_1000/*` by name instead of a `cost_` prefix, with that reason
in
its comment; the candidate test checks the cost series are historical
and
a quality metric has no observation.

Local on this head: `make gate` passes; `cargo test --workspace
--no-fail-fast` passes except `rustev-release --test manifests`, which
reports a `rustev-aicortex` member that exists only in another lane's
worktree sharing the build target, and passes when run alone; clippy,
fmt and boundaries pass.
Rebased onto `main` after #157 (no conflict); `rustev-eval` and
`rustev-release` tests (including `manifests`, now that
`rustev-aicortex` is on `main`) and `rustev-eval` clippy pass on the
rebased head.
Review round 4: no findings. Rebased onto `main` after #162 (no
conflict).
Review round 5: no findings. Rebased onto `main` after #160 (no
conflict); `make code` and `make gate` pass locally on this head.
Review round 6: no findings. Its `code` run failed in
`rustev-remote-http --test runtime_batch`

(`a_deadline_or_a_cancellation_after_send_ends_every_member_as_independent_calls_do`),
a timing test in a crate this PR does not touch. Rebased onto `main`
after
#167, which changes no Rust source, so the previous head's local `make
code`
still covers the Rust tree; `make gate` passes.
bartekus added a commit that referenced this pull request Oct 22, 2026
Spec 028, split from the single PR #151 (its AI review timed out at 15
minutes three times) into #151, #158 and #159 (merging in that order),
then #160 (increment 5), #164 (increment 6) and #165 (increment 7). Each
part is one signed commit and builds on its own; later parts are stacked
on the branch below and rebased onto `main` after each merge.

- Increment 6, OTLP (3.2.3, 3.9.1 to 3.9.3): `opentelemetry`,
`opentelemetry_sdk` and `opentelemetry-otlp` 0.33 with `default-features
= false`, used only by `rustev-otel` behind `otlp-grpc` and `otlp-http`;
no `reqwest`, no `internal-logs`, default features empty. `endpoint`
refuses, before anything is built or dialed, an origin not exactly in
the list, an empty list, user information, wildcards, plaintext to
anything but a loopback IP literal, and an `OTEL_*` endpoint variable
naming an origin outside the list. Redirects are never followed.
Loopback fake collectors on h2 and hyper.

Owner decisions:
- TLS paths (gRPC with the host's `ca_pem`, HTTP with given roots or the
Web PKI roots) are compiled and type-checked but not exercised by a
test: the workspace has no certificate generator. The tests run
plaintext to loopback only. The spec record says so.

Local verification on this head: `make gate`, `spec-spine couple` and
`bash scripts/check-authored-content.sh` pass. CI runs code, verify and
boundaries.

Review response (round on be6f412): an unbracketed IPv6 literal
(`http://::1:4318`) parsed, its last colon read as the port separator; a
colon left in the host outside brackets is now `Malformed` ("an IPv6
literal outside brackets"), tested in `endpoint::tests::refusals`.
Bracketed literals (`http://[::1]:4317`) are unchanged.

Review responses (round on 230e1eb):
- Duplicate header names: both builders validated every entry but HTTP
collected them into a map (and gRPC's `HeaderMap::insert` overwrote), so
one value was silently dropped. A name given twice, compared
case-insensitively, is now `OtlpError::DuplicateHeader` before anything
is built; tested in `header_values_never_appear_in_errors_or_debug`.
- Log severity: `export_logs` set `Severity::Warn` regardless of the
record. It now maps the record's own `severity_number` (1 to 24) to the
OpenTelemetry severity, leaving an out-of-range number unspecified;
unit-tested in `otlp::tests`. The sink writes only `WARN`/13 today, so
exported bytes are unchanged.

Review response (round on 0b09035): the finding read "3.12" in the
workspace `Cargo.toml` comment as a typo. It is not: spec 028 3.12 is
"Dependency boundary", the amendment of spec 001 3.5 that forbids every
`opentelemetry*` package outside `integrations/` (the rule `make
boundaries` enforces). The comment now names both cited sections by
title so the citation is checkable from the diff.
bartekus added a commit that referenced this pull request Oct 22, 2026
…on (#165)

Spec 028, split from the single PR #151 (its AI review timed out at 15
minutes three times) into #151, #158 and #159 (merging in that order),
then #160 (increment 5), #164 (increment 6) and #165 (increment 7). Each
part is one signed commit and builds on its own; later parts are stacked
on the branch below and rebased onto `main` after each merge.

- Increment 7 (3.14, Acceptance): the redaction property test (200
seeded decisions, canaries in every text and identifier slot, generated
policies; no canary of a `drop` field in any exported byte, raw or cut,
and no raw canary of a `digest` field), the overhead benchmark
`examples/overhead.rs` with its 100-decision smoke test, and the
`verify:cli` block.

Benchmark (`cargo run -p rustev-otel --release --all-features --example
overhead`), 10 000 decisions per configuration alternating the two
reference plans after 1 000 warm-up, concurrency 4 under `backpressure`
(64 pending). CPU and RSS are the whole process, which also hosts the
fake collector. No threshold is asserted (3.14.3).

| Configuration | Decision p50 / p95 / p99 ms | `deliver` p50 / p99 ms |
CPU ms per decision | Exported bytes per decision | Peak RSS KiB | Loss
|
|---|---|---|---|---|---|---|
| (a) in-memory sink | 0.197 / 0.254 / 0.276 | 0.0001 / 0.0001 | 0.153 |
0 | 12 704 | 0 |
| (b) no-op exporter | 0.180 / 0.234 / 0.250 | 0.603 / 0.846 | 0.722 | 0
| 14 672 | 0 |
| (c) JSONL file | 0.206 / 0.427 / 0.536 | 0.730 / 1.595 | 1.336 | 22
657 | 28 784 | 0 |
| (d) OTLP/gRPC, loopback | 0.187 / 0.249 / 0.266 | 0.633 / 0.885 |
0.874 | 13 566 | 31 008 | 0 |
| (e) OTLP/HTTP, loopback | 0.188 / 0.252 / 0.279 | 0.623 / 0.904 |
0.834 | 13 561 | 32 464 | 0 |

Loss is zero everywhere: no decision failure, no runtime sink failure,
timeout or drop, no telemetry lost and none in flight at the end.

Local verification on this head: `make gate`, `spec-spine couple` and
`bash scripts/check-authored-content.sh` pass. CI runs code, verify and
boundaries.

Review response (round on b1ad15f): the finding read
`exported_bytes_per_decision` as dividing warm-up-inclusive bytes by the
wrong count. It does not: `bytes_start` is read before the warm-up, so
the bytes cover all 11 000 decisions and dividing by 11 000 is right.
The real inconsistency was the CPU figure: `cpu_start` is also read
before the warm-up, but CPU time was divided by the 10 000 measured
decisions. Both now divide by every decision run (a comment in
`overhead.rs` says so). The CPU column above is the earlier run's CPU
time divided by 11 000 instead of 10 000 (each value times 10/11), not a
new run; bytes, latency and RSS are unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant