Skip to content

fix(bench): tighten OTLP-loader consistency surface (PR-K2.1) - #59

Merged
jensholdgaard merged 2 commits into
mainfrom
docs/rfc-0006-broaden-raw-corpus
May 29, 2026
Merged

fix(bench): tighten OTLP-loader consistency surface (PR-K2.1)#59
jensholdgaard merged 2 commits into
mainfrom
docs/rfc-0006-broaden-raw-corpus

Conversation

@jensholdgaard

@jensholdgaard jensholdgaard commented May 28, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to PR #58 addressing two Copilot threads on that PR + three on this one, plus two CodeRabbit threads on this PR's first revision. They all cluster as one coherent issue: the OTLP/JSON loader landed without fully consistent surfaces, and one of the gaps is a real correctness bug.

Fixes (G — the real bug)

§3.4.1's A1 math invariant requires both bytes(raw_corpus) and bytes(zstd_corpus) to process the same input. PR #58 broadened bytes(raw_corpus) to OTLP/JSON via the loader change but left zstd_level_19_bytes in a1.rs filtering on *.txt only — so an OTLP-only corpus would have bytes(raw_corpus) > 0 and bytes(zstd_corpus) = 0, producing zstd_ratio = 0 and an undefined A1 delta. zstd_level_19_bytes now consumes the same extension set as corpus::walk (.txt | .jsonl | .json), with a code comment on both sides noting they must stay in lockstep.

Tightens

  • corpus.rsCorpusLoad field docs + load()'s doc + the no non-empty corpus lines error message broadened to name the actual supported extensions. Extension dispatch dropped the per-entry to_ascii_lowercase allocation in favour of eq_ignore_ascii_case on the borrowed &str (match-with-guards per project convention). Local any_value_to_body deleted; the loader now calls ourios_core::otlp::Body::from_any_value directly (single-sourced fork — drift risk → 0).
  • main.rs — clap help text on --corpus broadened so ourios-bench --help matches RFC §3.7.
  • Cargo.toml — the with-serde comment now reads serde_json::from_str (matches the actual call; previous from_slice was wrong).
  • RFC §3.4.1corpus.directory claim reworded (a directory path can't disambiguate a mixed-format corpus; cleanly comparable runs need one encoding per dir; per-format byte breakdown noted as a future enhancement). bytes(zstd_corpus) definition spelled out to cover the same extension set with the math-invariant rationale. §5 Scenario RFC0006.1 broadened to match. find example uses -iname (case-insensitive, matching loader behavior).

Test plan

  • cargo fmt --all --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test --all-features285 passed / 19 ignored (+1 vs main: the new a1::tests::zstd_consumes_every_corpus_extension)
  • mdbook build

The new test guards against the failure mode the pre-fix txt-only filter introduced: a mixed-extension corpus produces > 0 zstd bytes, an OTLP-only corpus does too, and an unrelated .md file in the same dir leaves the byte count unchanged (the silent assertion the first revision missed).

Closes

5 files changed (§5.2 phase limit).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Updated bench harness methodology documentation to clarify corpus byte counting and supported file format definitions
    • Enhanced --corpus CLI help text to describe recursive directory loading and supported file extensions (*.txt, *.jsonl, *.json)
  • Improvements

    • Standardized corpus loader to consistently process plain-text and OTLP/JSON formats across all benchmark measurements and calculations

Review Change Stack

@jensholdgaard
jensholdgaard requested a review from Copilot May 28, 2026 21:55
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a59abbe6-f6ee-4244-8ec6-ba37a3d5b1b1

📥 Commits

Reviewing files that changed from the base of the PR and between c0d9792 and 5f9f8cd.

📒 Files selected for processing (2)
  • crates/ourios-bench/src/a1.rs
  • docs/rfcs/0006-bench-harness.md
✅ Files skipped from review due to trivial changes (1)
  • docs/rfcs/0006-bench-harness.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/ourios-bench/src/a1.rs

📝 Walkthrough

Walkthrough

Defines recursive corpus loading that consumes *.txt, *.jsonl, and *.json; zstd bytes are computed per-file over the same set; OTLP AnyValue→Body mapping delegated to Body::from_any_value; RFC and CLI help text updated to match.

Changes

Bench Harness Corpus Specification

Layer / File(s) Summary
Corpus loader and OTLP body mapping
crates/ourios-bench/src/corpus.rs
Case-insensitive extension dispatch for txt, jsonl, json; updated empty-corpus error text; removed local AnyValue helper and use Body::from_any_value; docs adjusted.
A1 zstd computation and tests
crates/ourios-bench/src/a1.rs
zstd_level_19_bytes compresses .txt/.jsonl/.json per-file; docs updated; new test ensures nonzero compressed bytes for mixed and OTLP-only corpora and that non-corpus extensions are ignored.
RFC, CLI help, Cargo comment
docs/rfcs/0006-bench-harness.md, crates/ourios-bench/src/main.rs, crates/ourios-core/Cargo.toml
RFC defines recursive bytes(raw_corpus) and per-file bytes(zstd_corpus) over supported extensions; CLI --corpus help text documents recursive traversal and skipped extensions; Cargo comment updated to from_str.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I hopped through files in sunlit rows,

counting bytes where the corpus grows.
Text and JSON now both take part,
zstd hums a compressed-heart.
Binpb waits — a future start.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing OTLP-loader consistency by tightening surfaces across multiple components.
Description check ✅ Passed The description comprehensively covers all template sections: Summary, Related (RFC + PR references), and Checklist with results for fmt, clippy, tests, and docs.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/rfc-0006-broaden-raw-corpus

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Actionable comments posted: 0

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates RFC 0006 (bench harness) documentation to be internally consistent with the already-landed OTLP/JSON corpus loader behavior from PR #58, specifically around corpus byte accounting and the --corpus flag surface.

Changes:

  • Broadens §3.4.1 bytes(raw_corpus) to include *.txt, *.jsonl, and *.json inputs and updates the find example accordingly.
  • Broadens §3.7 --corpus documentation to describe multi-format recursive loading and skipping unknown extensions.
  • Adds a note about OTLP/JSON envelope overhead affecting A1 comparability across encodings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/rfcs/0006-bench-harness.md Outdated
Comment thread docs/rfcs/0006-bench-harness.md
Comment thread docs/rfcs/0006-bench-harness.md
Follow-up to PR #58. Copilot and CodeRabbit between them flagged that
the OTLP/JSON loader landed with a surface that wasn't internally
consistent — and one of the issues was a real correctness bug. Bundles
the fixes here as a single squash-merge so the seven review threads
across PR #58 + PR #59 close together.

**Fixes (G — the real bug):** §3.4.1's A1 math invariant — both
`bytes(raw_corpus)` and `bytes(zstd_corpus)` must process the same
input. PR #58 broadened `bytes(raw_corpus)` to OTLP/JSON via the
loader change but left `zstd_level_19_bytes` in `a1.rs` filtering on
`*.txt` only. An OTLP-only corpus would therefore have
`bytes(raw_corpus) > 0` and `bytes(zstd_corpus) = 0`, producing
`zstd_ratio = 0` and an undefined A1 delta. The zstd reference codec
now consumes the same extension set (`.txt | .jsonl | .json`) — kept
in lockstep with `corpus::walk`'s dispatch via a comment on both sides.
RFC §3.4.1 amended to spell out the invariant.

**Tightens (consistency):**

- `corpus.rs` `CorpusLoad` field docs + the `no non-empty corpus
  lines` error message now name the actual supported extensions.
- The extension dispatch drops the per-entry `to_ascii_lowercase`
  allocation and uses `eq_ignore_ascii_case` on `&str` (allocation-
  free, hot loader path). `match`-with-guards per the project's
  feedback memory.
- `Body::from_any_value` (already the single-sourced fork in
  `ourios-core::otlp`) replaces the local duplicate `any_value_to_body`
  in the loader. Drift risk → 0.
- `main.rs` clap help text on `--corpus` broadened so
  `ourios-bench --help` matches RFC §3.7.
- `ourios-core/Cargo.toml` comment aligned to the actual
  `serde_json::from_str` call (was `from_slice`).
- RFC §3.4.1 reworded so `corpus.directory` no longer claims to
  disambiguate mixed-format corpora — mixed dirs produce an aggregate
  number; cleanly comparable runs need one encoding per dir. Per-format
  byte breakdown noted as a future enhancement.

**Test (+1):** `a1::tests::zstd_consumes_every_corpus_extension` —
mixed-extension corpus produces > 0 bytes, OTLP-only corpus does too
(guards the failure mode the pre-fix `txt`-only filter introduced).

Closes the Copilot threads on PR #58 (corpus.rs:38 / :459 / :275 +
Cargo.toml:19) and PR #59 (RFC :278 / :289 / :640).

5 files changed (§5.2 phase limit).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jensholdgaard
jensholdgaard force-pushed the docs/rfc-0006-broaden-raw-corpus branch from b7eb0e1 to c0d9792 Compare May 29, 2026 06:29
@jensholdgaard jensholdgaard changed the title docs(rfc-0006): broaden §3.4.1 + §3.7 corpus scope to OTLP/JSON (PR-K2.1) fix(bench): tighten OTLP-loader consistency surface (PR-K2.1) May 29, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/rfcs/0006-bench-harness.md`:
- Around line 282-284: Replace the case-sensitive find predicates (-name) with
case-insensitive ones (-iname) in the example find command that filters
extensions (the tokens '-name' used for '*.txt', '*.jsonl', '*.json') so the
manual size-summing command uses case-insensitive matching (i.e., use '-iname'
for those predicates) to match the runtime loader dispatch behavior.
- Around line 295-297: RFC0006.1's acceptance criteria are inconsistent with the
broadened corpus scope: update the Scenario RFC0006.1 wording so it no longer
restricts counting to "txt-only" but instead counts across the same extension
set covered by bytes(zstd_corpus)/bytes(raw_corpus); specifically, modify the
Scenario RFC0006.1 description (references: "Scenario RFC0006.1",
"bytes(zstd_corpus)", "bytes(raw_corpus)") to state that byte/count comparisons
and validation operate over the full extension set implied by bytes(zstd_corpus)
rather than only .txt files, and adjust any test/validation language that
mentions txt-only counting to reflect the unified extension set and math
invariant.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a8ac2494-ce80-4c84-93ee-3eb23daecdfe

📥 Commits

Reviewing files that changed from the base of the PR and between b7eb0e1 and c0d9792.

📒 Files selected for processing (5)
  • crates/ourios-bench/src/a1.rs
  • crates/ourios-bench/src/corpus.rs
  • crates/ourios-bench/src/main.rs
  • crates/ourios-core/Cargo.toml
  • docs/rfcs/0006-bench-harness.md
✅ Files skipped from review due to trivial changes (2)
  • crates/ourios-bench/src/main.rs
  • crates/ourios-core/Cargo.toml

Comment thread docs/rfcs/0006-bench-harness.md Outdated
Comment thread docs/rfcs/0006-bench-harness.md

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread docs/rfcs/0006-bench-harness.md
Comment thread crates/ourios-bench/src/a1.rs
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@jensholdgaard
jensholdgaard merged commit 106ae5c into main May 29, 2026
11 checks passed
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.

2 participants