Skip to content

impl(028): redaction property test, overhead benchmark and verification - #165

Merged
bartekus merged 1 commit into
mainfrom
impl/028-f-verification
Oct 22, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/028-f-verification

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 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.

@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the six changed paths for bugs, security problems, and inconsistencies.

integrations/rustev-otel/examples/overhead.rs

The measure function calculates exported_bytes_per_decision by dividing exported bytes by total, where total = load.warmup + load.decisions. Warmup rounds are included in the denominator but the metric is named "per decision". At the default load (1 000 warmup, 10 000 decisions), the reported value is ~9 % lower than a true per-decision figure, because warm-up exports are attributed against a larger total. The implementation record in the spec reproduces these slightly understated numbers in its benchmark table (e.g. 22 657 bytes/decision for JSONL is actually bytes/(warmup+decisions)). This is a concrete naming inconsistency between the field name, the calculation, and the recorded evidence.

integrations/rustev-otel/tests/collector/mod.rs

Two impl Seen blocks are now present (the new one adds record, the pre-existing one retains helpers like total_bytes). Multiple impl blocks are valid Rust. The ..Seen::default() initialisation relies on the pre-existing Default derivation; AtomicU64::default() is 0 and bool::default() is false, so the new fields initialise correctly. No issue.

integrations/rustev-otel/tests/overhead_smoke.rs

The #[path = "../examples/overhead.rs"] mod overhead include is valid; path resolution for the nested mod collector and mod common inside overhead.rs is relative to examples/, correctly resolving to tests/collector/mod.rs and tests/common/mod.rs. The fn main inside the module namespace does not conflict with the test harness. The assertion decision_ms.p50 >= 0.0 is trivially true for any non-NaN f64 but this is just a weak sanity check, not a crash. No structural bug.

integrations/rustev-otel/tests/redaction_property.rs

The canary alphabet (letters g–z) cannot appear in hex span-IDs or numeric values, eliminating false positives from those. Checking only the first 8 characters of each canary for Drop/Digest assertions carries a small birthday-collision risk (~1 %) across 200 iterations but the test is deterministic (seed 0x2028_1016), so a collision would be consistently reproducible; the implementer presumably verified it passes. Modulo bias in Rng::below is acceptable for a property test. No critical defect.

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

The lifecycle transition pending → complete on an approved spec is valid (contract table: settled, no further scheduling). Adding 028 to VERIFIED_SPECS in Makefile is consistent. The verify:cli block and the implementation record for increment 7 are internally consistent with each other and with the new test files, except that the benchmark table in the record (e.g. "22 657 bytes/decision") reflects the same incorrect denominator used in the code.


{"head": "b1ad15f105464086b94101609c460d8e2de5bb88", "verdict": "findings", "findings": [{"path": "integrations/rustev-otel/examples/overhead.rs", "line": 366, "summary": "exported_bytes_per_decision divides by load.warmup + load.decisions (total) instead of load.decisions, so the reported metric is ~9% lower than its name implies; the benchmark table in the spec's increment-7 record reproduces these understated values."}]}

Subject: be6f412...b1ad15f, diff digest 7614e799d64438505d5e73661fae49ff05a97124c4009698ae69809cdefde6cf, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 22, 2026 03:37 — with GitHub Actions Error
@bartekus
bartekus force-pushed the impl/028-f-verification branch from b1ad15f to 2f9c4e6 Compare October 22, 2026 03:48
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the six changed files: a Makefile update, a new benchmark example, an extended test collector, a smoke test for the benchmark, a redaction property test, and the spec completion update.

Makefile — adding 028 to VERIFIED_SPECS is consistent with the spec's verify:cli block and implementation: complete transition.

collector/mod.rs — The refactor introduces a total: AtomicU64 and count_only: bool alongside the existing requests mutex. record() always increments total and conditionally pushes to requests. Because http() / grpc() use count_only = false, existing callers that read total_bytes() see the same value as before (sum of body lengths). The two impl Seen blocks are valid Rust. The ..Seen::default() struct update initialises total to 0 and count_only to false, which is correct.

overhead.rs — CPU-time measurement is set after worker 0's task is spawned but before it is awaited, so early CPU cycles may be missed; this is a minor measurement inaccuracy in a benchmark that is explicitly described as "measured, not asserted" (principle XI). The ps and command calls use only hardcoded arguments so there is no injection risk. is_multiple_of is stable from Rust 1.87; the implementation record cites rustc 1.98.1. The 10 000 × 1 ms drain loop is a reasonable upper bound. No concrete defects.

overhead_smoke.rs — starts_with(&["a_memory","b_otel_noop","c_jsonl"]) correctly tests the always-present configurations while feature-gated ones are checked with cfg!(feature = …). The assertion that JSONL and OTLP configurations export a positive exported_bytes_per_decision is a correct losslessness check distinct from any latency threshold.

redaction_property.rs — Canaries are "zq" + 14 letters in ['g','z'], a character set absent from hex IDs, base64, or numbers. Checking the 8-byte prefix for Drop/Digest violations is sufficient given that prefix uniqueness. The Truncate arm is intentionally unchecked (the spec only claims Drop and raw-Digest invariants). The loop for _ in 0..1000 { … sleep(1ms) … } provides a 1-second drain window which is ample for 200 in-memory exports.

spec.md — implementation: pending → complete is appropriate after all seven increments land. The verify:cli block correctly covers rustev-contract, rustev-otel --all-features, rustev-cli, rustev-boundaries, the dependency tree scan, and the authorization-type grep. The tree-scan shell command iterates crates/*, backends/*, tools/*, packages/* but omits integrations/* intentionally (the telemetry packages live there). The Permitted|Grant grep pattern is correctly scoped.

No concrete bugs, security vulnerabilities, or governance violations found.

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

Subject: 76bad2a...2f9c4e6, diff digest ac1b3398ddcab9815cfd04584d7986666086fe1d7b66360f3add7d04effe5ba2, 1 call(s). An AI comment is not an approval.

@github-actions

Copy link
Copy Markdown

AI review (no-findings)

I reviewed the six changed files against the governance context and repo state.

Makefile — 028 added to VERIFIED_SPECS is consistent with the spec's new verify:cli block.

integrations/rustev-otel/tests/collector/mod.rs — The refactor splits impl Seen into two blocks (valid Rust). total_bytes() now reads an AtomicU64 directly instead of summing stored bodies. The Seen { count_only, ..Seen::default() } spread depends on Seen: Default, which must already hold since Seen::default() was called before this change. The u64 → usize cast in total_bytes() is immediately widened back to u64 at every call site, and this is non-production benchmark/test code on 64-bit targets.

integrations/rustev-otel/examples/overhead.rs — The ps helper interpolates the field arg into a format string but is only called with two hardcoded strings ("time", "rss"); no injection risk. The warm-up boundary (if i == warmup) will be hit by exactly one worker, so a few decisions at the warm-up edge may be mis-classified; this is an inherent measurement imprecision in a benchmark that makes no pass/fail assertions (consistent with Principle XI). The cpu_start capture races slightly with spawned workers but for the same reason is not a correctness issue. main() builds its own Tokio runtime correctly; the smoke test uses the tokio test harness instead.

integrations/rustev-otel/tests/overhead_smoke.rs — The #[path] re-inclusion of the example file is standard; inner mod collector and mod common paths resolve relative to the example file's location. The assertion names.starts_with(…) and the skip(2) exported-bytes check correctly handle the optional OTLP configs.

integrations/rustev-otel/tests/redaction_property.rs — The canary alphabet [g-z] cannot appear in hex HMAC-SHA256 digests (0-9, a-f only), so the 8-byte prefix check is sound. The Truncate branch is correctly left unchecked. The 200-iteration coverage counts (checked[0] > 500, checked[1] > 200, shown > 100) are consistent with the generator probabilities.

specs/028-opentelemetry-evidence-sink/spec.md — Changing implementation: pending to implementation: complete on an approved spec is the correct settled state per the contract governance table. The verify:cli block commands match the code paths described. The grep pattern for Permitted|Grant is syntactically correct (single-quoted shell, no expansion). The boundary-check shell loop iterates crates/, backends/, tools/, packages/ and flags any that reach opentelemetry*; the inclusion of rustev-cli in that scan is intentional and correct.

No concrete defects found.

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

Subject: 76bad2a...2f9c4e6, diff digest ac1b3398ddcab9815cfd04584d7986666086fe1d7b66360f3add7d04effe5ba2, 1 call(s). An AI comment is not an approval.

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 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`.
@bartekus
bartekus force-pushed the impl/028-e-otlp branch 4 times, most recently from ad34aa9 to f256e34 Compare October 22, 2026 09:27
Base automatically changed from impl/028-e-otlp to main October 22, 2026 15:13
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
bartekus enabled auto-merge (squash) October 22, 2026 15:21
@bartekus
bartekus disabled auto-merge October 22, 2026 16:29
@bartekus
bartekus force-pushed the impl/028-f-verification branch from 2f9c4e6 to 2b09c44 Compare October 22, 2026 16:41
Spec 028 increment 7 (3.14, Acceptance): the redaction property test, the overhead benchmark and its smoke test, and the verify block; 028 joins VERIFIED_SPECS and its implementation is complete.
@bartekus
bartekus force-pushed the impl/028-f-verification branch from 2b09c44 to e1e9bbb Compare October 22, 2026 16:43
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the six changed files for concrete defects.

Makefile — adds 028 to VERIFIED_SPECS; consistent with the spec's own verification section, which states "028 joins VERIFIED_SPECS".

integrations/rustev-otel/examples/overhead.rs — the ps/command helpers use hardcoded strings as arguments, no injection risk. The CPU-start timing (cpu_start is recorded after spawning worker 0 but before workers 1–3) slightly underestimates CPU use, but the spec explicitly states "No pass threshold: measured, not asserted (principle XI)". The drain loop (10 000 × 1 ms) is bounded and acceptable for a benchmark. #![allow(dead_code)] is intentional: main is dead when the file is included as a module by the smoke test.

integrations/rustev-otel/tests/collector/mod.rs — the split into http/grpc vs. http_with/grpc_with and the new record helper are clean. total_bytes() now reads the atomic counter directly instead of summing stored bodies; semantics are equivalent when count_only is false and correct-by-construction when it is true. AtomicU64: Default is stable, so ..Seen::default() remains valid after the new fields.

integrations/rustev-otel/tests/overhead_smoke.rs — the skip(2) correctly targets c_jsonl and optional OTLP entries; the lossless predicate covers all loss channels. The #[path = "../examples/overhead.rs"] pattern resolves relative to the example file's directory for its own inner #[path] declarations, so the collector and common modules resolve correctly.

integrations/rustev-otel/tests/redaction_property.rs — the SplitMix64 generator is seeded and deterministic. The canary alphabet (zq + letters g–z) cannot appear in HMAC hex digests (hex uses only 0–9, a–f; q is excluded). Checking the 8-byte head for Drop/Digest cases is sound: if the head is absent, the full canary is absent; and q ensures the head can never appear in any digest output. The validate().unwrap() on generated policies is safe because action(rng, true) is constrained to Drop/Digest only. The assert!(checked[0] > 500 && checked[1] > 200) guard ensures both properties are exercised.

specs/028-opentelemetry-evidence-sink/spec.md — implementation: pending → complete is correct per the contract (approved + complete → settled, not schedulable). The verify:cli block fulfils every item that the prior "Pending" paragraph promised: rustev-contract, rustev-otel --all-features (which runs both overhead_smoke and redaction_property), rustev-cli, rustev-boundaries, the cargo tree boundary walk, and the grep for forbidden authorization type names. The added Grant pattern in the grep is a stricter-than-required check, not a violation.

No concrete defects found.

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

Subject: ed1d191...e1e9bbb, diff digest 154555af5510de361b791ee307f1d529a12e74eff5217be6bb1cef665ca91387, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus merged commit f66e2cb into main Oct 22, 2026
26 checks passed
@bartekus
bartekus deleted the impl/028-f-verification branch October 22, 2026 17:23
bartekus added a commit that referenced this pull request Oct 22, 2026
Adds the six public document schemas from specs 019, 026 and 028 to spec
027's emitter under owner decision R-46. Contract tests validate the
documents, including trace JSONL goldens, against their emitted schemas.
Both bindings receive regenerated TypeScript declarations.

Diff size: 170 additions and 15 deletions are authored. The other 5,443
additions and 2,761 deletions are generated schemas, TypeScript
declarations and spec-spine shards. The two TypeScript files account for
most of the diff.

Validation: pinned spec-spine 0.31.0 refresh, make gate and coupling
pass. Hosted code and binding checks pass; declared acceptance is still
running. Local workspace validation is running. Pushed before local code
completion at the owner's request.

Rebased onto merged #165. Both AI review groups report no findings on
04dd831. Auto-merge is enabled pending
the final required acceptance check. R-46 records the owner ruling of
2026-10-21; the spec records now explicitly distinguish its
implementation date, 2026-10-22.
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