Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 66 additions & 14 deletions crates/ourios-bench/src/c2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,12 @@ impl C2Accumulator {
let template_count_at_end = self.curve.last().map_or(0, |s| s.template_count);
let corpus_at_least_1m = self.total_lines >= ONE_MILLION;

let (template_count_at_1m_lines, convergence_ratio, pass) = if corpus_at_least_1m {
// Whole-corpus convergence — a **diagnostic** now, not the gate
// (the gate is per-service below, RFC 0006 §3.4.3 as amended
// for #444): on a multi-service corpus a whole-corpus ratio
// conflates a noisy broker with clean application services
// (v8 §9.12).
let (template_count_at_1m_lines, convergence_ratio) = if corpus_at_least_1m {
Comment thread
jensholdgaard marked this conversation as resolved.
Resolved
// Sample whose 1-based line number is closest to
// 1 M; on a tie the earlier (smaller `lines`)
// sample wins — the `(distance, lines)` key makes
Expand All @@ -231,10 +236,9 @@ impl C2Accumulator {
let ratio = count_1m.and_then(|c| {
(template_count_at_end > 0).then(|| (c as f64) / (template_count_at_end as f64))
});
let pass = ratio.map(|r| r >= 0.5);
(count_1m, ratio, pass)
(count_1m, ratio)
} else {
(None, None, None)
(None, None)
Comment thread
jensholdgaard marked this conversation as resolved.
Resolved
};

// Per-service decomposition, largest service first. Each
Expand Down Expand Up @@ -268,6 +272,8 @@ impl C2Accumulator {
.then(a.service_name.cmp(&b.service_name))
});

let pass = gate_pass(&by_service);
Comment thread
jensholdgaard marked this conversation as resolved.
Resolved

C2Result {
sample_cadence: self.cadence,
total_lines: self.total_lines,
Expand All @@ -283,6 +289,22 @@ impl C2Accumulator {
}
}

/// The per-service C2 **gate** (RFC 0006 §3.4.3 as amended for #444):
/// a corpus passes iff every service with ≥ 1 M lines passes its own
/// ratio ≥ 0.5 (each such service has `pass = Some(_)`); a corpus where
/// no service reaches 1 M lines abstains (`None`). A single-service
/// corpus — including the plain-text `<unknown>` bucket — collapses to
/// the whole-corpus verdict, so historical text-corpus rows are
/// unchanged; only multi-service OTLP corpora differ.
fn gate_pass(by_service: &[PerServiceC2]) -> Option<bool> {
let gated: Vec<bool> = by_service.iter().filter_map(|s| s.pass).collect();
if gated.is_empty() {
None
} else {
Some(gated.iter().all(|&p| p))
}
}
Comment thread
jensholdgaard marked this conversation as resolved.
Resolved
Comment thread
jensholdgaard marked this conversation as resolved.
Resolved

/// The record's `service.name` resource attribute, or a sentinel when
/// absent. Borrowed — the caller copies into the map key only on a
/// first sighting.
Expand Down Expand Up @@ -346,17 +368,22 @@ mod tests {
/// Exercises the full ≥ 1 M gate math at scale without the
/// miner.
Comment thread
jensholdgaard marked this conversation as resolved.
Resolved
#[test]
fn stable_corpus_passes_the_gate() {
fn stable_curve_ratio_is_one() {
// `run_stable` drives `observe` (no `service.name`), so it
// exercises the whole-corpus ratio *diagnostic*; the per-service
// gate needs record input and is covered by `gate_pass_*` +
// the partition test.
let r = run_stable(1_000_000, 8);
assert!(r.corpus_at_least_1m);
assert_eq!(r.template_count_at_end, 8);
assert_eq!(r.template_count_at_1m_lines, Some(8));
assert_eq!(r.convergence_ratio, Some(1.0));
assert_eq!(r.pass, Some(true));
// No service data → the per-service gate abstains.
assert_eq!(r.pass, None);
}

/// A corpus below 1 M lines abstains: no 1 M count, no
/// ratio, `pass = None`.
/// A corpus below 1 M lines has no 1 M count, no ratio; the gate
/// abstains.
#[test]
fn short_corpus_abstains() {
let r = run_stable(10_000, 5);
Expand All @@ -369,6 +396,33 @@ mod tests {
assert_eq!(r.template_count_at_end, 5);
}

/// The per-service gate fold: pass iff every ≥ 1 M service passes;
/// abstain when none are gated; a `<1 M` service (pass = None) does
/// not veto a passing sibling.
#[test]
fn gate_pass_folds_over_gated_services() {
let svc = |name: &str, pass: Option<bool>| PerServiceC2 {
service_name: name.to_string(),
lines: 0,
templates_created: 0,
templates_created_at_1m_lines: None,
convergence_ratio: None,
pass,
};
// No gated service → abstain.
assert_eq!(gate_pass(&[svc("a", None), svc("b", None)]), None);
// All gated services pass → pass.
assert_eq!(
gate_pass(&[svc("a", Some(true)), svc("b", None), svc("c", Some(true))]),
Some(true)
);
// One gated service fails → fail (even with passing siblings).
assert_eq!(
gate_pass(&[svc("a", Some(true)), svc("b", Some(false))]),
Some(false)
);
}

/// A corpus whose template count is still climbing steeply
/// at 1 M lines (no plateau) fails the gate: `count_1m` is
/// far under half the end count.
Expand Down Expand Up @@ -396,13 +450,11 @@ mod tests {
let ratio = r.convergence_ratio.expect("ratio on ≥1M corpus");
assert!(
ratio < 0.5,
"templates still climbing at 1 M → ratio {ratio} must be < 0.5",
);
assert_eq!(
r.pass,
Some(false),
"a non-converged corpus must fail the C2 gate",
"templates still climbing at 1 M → whole-corpus ratio {ratio} must be < 0.5",
);
// `observe` has no service data, so the per-service gate abstains
// here — the fold's fail path is covered by `gate_pass_*`.
assert_eq!(r.pass, None);
}

/// A `MinedRecord` carrying just the two fields the per-service
Expand Down
32 changes: 21 additions & 11 deletions crates/ourios-bench/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,27 +583,37 @@ pub struct C1Mismatch {
pub actual: String,
}

/// §3.6 `c2` block (populated only when C2 ran). `pass` is
/// `None` when the corpus is `< 1 M lines` (§3.4.3 abstention).
/// §3.6 `c2` block (populated only when C2 ran).
///
/// The gate is **per service** (RFC 0006 §3.4.3 as amended for #444):
/// `pass` is the fold over [`Self::by_service`] — `Some(true)` iff every
/// service with ≥ 1 M lines passes its own ratio ≥ 0.5, `Some(false)` if
/// any ≥ 1 M service fails, `None` when no service reaches 1 M lines.
Comment thread
jensholdgaard marked this conversation as resolved.
Resolved
/// The whole-corpus [`Self::convergence_ratio`] /
/// [`Self::template_count_at_1m_lines`] are retained as **diagnostics**
/// (on a multi-service corpus they conflate a noisy broker with clean
/// application services — v8 §9.12).
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct C2Result {
pub sample_cadence: u64,
pub total_lines: u64,
/// Whole-corpus diagnostic (not the gate — see the type doc).
pub template_count_at_1m_lines: Option<u64>,
pub template_count_at_end: u64,
/// Whole-corpus diagnostic (not the gate — see the type doc).
pub convergence_ratio: Option<f64>,
pub convergence_curve: Vec<ConvergenceSample>,
/// The per-service gate verdict (see the type doc).
pub pass: Option<bool>,
pub corpus_at_least_1m: bool,
/// Per-`service.name` convergence, largest service first.
/// **Diagnostic only** — the gate above is defined on the whole
/// corpus; this decomposition attributes it. On a multi-service
/// corpus (every OTel-Demo capture) a whole-corpus C2 conflates a
/// noisy broker with clean application services, so this surfaces
/// where non-convergence actually lives (v8 §9.12 / #444). A
/// plain-text corpus (no `service.name`) collapses to a single
/// `<unknown>` bucket rather than being empty; empty only when C2
/// did not run.
/// Per-`service.name` convergence, largest service first — the
/// **gate basis** (RFC 0006 §3.4.3 as amended for #444). On a
/// multi-service corpus (every OTel-Demo capture) a whole-corpus C2
/// conflates a noisy broker with clean application services, so the
/// gate is evaluated here per service; this also surfaces where
/// non-convergence actually lives (v8 §9.12). A plain-text corpus
/// (no `service.name`) collapses to a single `<unknown>` bucket
/// rather than being empty; empty only when C2 did not run.
#[serde(default)]
pub by_service: Vec<PerServiceC2>,
/// The distinct-`service.name` cap (`MAX_SERVICES`) was hit and
Expand Down
22 changes: 11 additions & 11 deletions crates/ourios-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,29 +315,29 @@ fn print_summary(results: &ourios_bench::ResultsFile) {
);
}
if let Some(c2) = &results.c2 {
// `pass = None` is the §3.4.3 abstention (corpus
// < 1 M lines) — surface it as ABSTAIN, not a silent
// omission. (C2 isn't computed yet; this line is ready
// for when it lands.)
// The gate is per service (RFC 0006 §3.4.3, #444). `None` is the
// abstention — no service reaches 1 M lines.
let verdict = match c2.pass {
Some(true) => "PASS",
Some(false) => "FAIL",
None => "ABSTAIN (corpus < 1 M lines)",
None => "ABSTAIN (no service ≥ 1 M lines)",
};
let ratio = c2
.convergence_ratio
.map_or_else(|| "n/a".to_string(), |r| format!("{r:.3}"));
// The verdict is per-service; the whole-corpus ratio is a
// diagnostic, so it is labelled as such to avoid reading as the
// gate (on a multi-service corpus the two can disagree).
println!(
" C2 convergence: ratio {ratio} (end template count {}, sample cadence {}) — {verdict}",
" C2 convergence (per-service gate): {verdict} \
— whole-corpus ratio {ratio} (diagnostic; end templates {}, cadence {})",
c2.template_count_at_end, c2.sample_cadence,
);
// Per-service decomposition (diagnostic) — printed whenever the
// Per-service breakdown — the gate basis. Printed whenever the
// corpus resolves to more than one bucket (distinct `service.name`
// values plus any `<unknown>`/`<other>`), since a whole-corpus
// ratio then conflates a noisy broker with clean application
// services (v8 §9.12 / #444).
// values plus any `<unknown>`/`<other>`).
if c2.by_service.len() > 1 {
println!(" C2 by service (diagnostic; creations sum to the end count):");
println!(" C2 by service (the gate; creations sum to the end count):");
Comment thread
jensholdgaard marked this conversation as resolved.
Resolved
for svc in &c2.by_service {
let per = match (svc.convergence_ratio, svc.pass) {
(Some(r), Some(true)) => format!("ratio {r:.3} PASS"),
Expand Down
34 changes: 24 additions & 10 deletions docs/benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ every run.
- **Bar**: must-win.
- **Metric**: template count as a function of lines ingested, on a
corpus from a single stable service.
- **Grain (amended for #444, 2026-07-10)**: because the metric is
defined *per stable service*, the gate is evaluated **per
`service.name`** on a multi-service corpus, not on the whole corpus.
A corpus passes iff every service with ≥ 1 M lines converges; a
single-service (or plain-text `<unknown>`) corpus is unchanged. The
whole-corpus ratio is retained as a diagnostic. See RFC 0006 §3.4.3.
- **Target**: template count grows **sub-linearly** and plateaus
within **2×** of its steady-state value by 1 M lines. Steady-state
value is corpus-specific but is on the order of 10²–10⁴ templates
Expand Down Expand Up @@ -1102,11 +1108,17 @@ bodies retained, and C1 = 1.000000 over the remaining 4,948,579 rows
— the honesty contract holds at 4.9 M rows through failure-mode
churn.

**C2 — template-count convergence (bar: ratio ≥ 0.5 at 1 M lines):
FAIL on the whole corpus — attributed.** Ratio **0.199**, end
template count **14,631** (sample cadence 4,833). The per-service
decomposition (splitting the corpus on `service.name` and re-running
the gates per service) localises the failure completely:
**C2 — template-count convergence (bar: ratio ≥ 0.5 at 1 M lines,
evaluated per service since #444): PASS.** Under the per-service gate
(RFC 0006 §3.4.3, amended 2026-07-10) the corpus passes: the only
service that clears the 1 M-line evaluation floor is **cart**, which
converges at ratio **1.000** with two templates. Every other service
abstains for want of volume; the whole-corpus ratio (**0.199**, end
template count **14,631**, sample cadence 4,833) is retained below as
a diagnostic — it is a category error to grade a multi-service corpus
as one Drain stream (§3.4.3 rationale). The per-service decomposition
(splitting on `service.name` and re-running the gates per service)
localises the whole-corpus fragmentation completely:

| service | lines | end templates | C2 |
|---|---|---|---|
Expand All @@ -1116,7 +1128,9 @@ the gates per service) localises the failure completely:
| ad | 486,726 | 3 | abstain (< 1 M) |
| **kafka** | **136,790** | **14,608** | abstain (< 1 M) |

Every application service converges essentially perfectly — cart
The gate folds over the gated services (those ≥ 1 M lines): cart is
the sole such service and it passes, so the corpus passes. Every
application service converges essentially perfectly — cart
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
passes the formal gate at 2.76 M lines with **two** templates. The
kafka broker mints 14,608 templates on 2.8 % of the lines. Mechanism
(measured): kafka's cleaner logs emit **3-token lines whose third
Expand All @@ -1137,10 +1151,10 @@ than one bucket — distinct `service.name` values plus any
`<unknown>`/`<other>`); template creation is a globally-monotonic
Comment thread
jensholdgaard marked this conversation as resolved.
Resolved
event attributed to the minting service, so per-service creations
partition the whole-corpus count exactly (2 + 17 + 1 + 3 + 14,608 =
14,631) in `O(services)` memory — no per-service id set. The gate
itself is unchanged (whole-corpus); the breakdown is additive, so
option 3 of #444 ("scope C2 per service") can be evaluated on real
numbers without a code change first.
14,631) in `O(services)` memory — no per-service id set. As of #444
(option 3) this decomposition **is** the gate: C2 is evaluated per
service and folds over the services that clear the 1 M-line floor,
with the whole-corpus ratio kept as a diagnostic (RFC 0006 §3.4.3).

**What the fragmentation actually costs — B2 pricing (indicative,
local M-series).** Running the B2 windowed query on the fragmented
Expand Down
33 changes: 28 additions & 5 deletions docs/rfcs/0006-bench-harness.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,34 @@ Pinned definitions:
corpora of `≥ 1_000_000` lines.
- **Convergence ratio**: `count_at_1m / SS`. By monotonicity,
this lives in `(0.0, 1.0]`.
- **Pass condition** (gate): `convergence_ratio ≥ 0.5` on a
corpus of `≥ 1_000_000` lines. This is the "within 2× of
SS by 1 M lines" rule. Corpora smaller than 1 M lines are
recorded as `c2.pass = null` (insufficient data); the §9
row notes the corpus size and the gate is not asserted.
- **Pass condition** (gate) — **per service** (amended for
Comment thread
jensholdgaard marked this conversation as resolved.
Resolved
#444, maintainer-approved 2026-07-10): C2 is defined over
"a corpus from a single **stable service**", so on a
multi-service corpus the gate is evaluated **per
`service.name`**, not on the whole corpus. Each service's
ratio is `count_at_1m / SS` over *that service's* lines
(template creation is a globally-monotonic event attributed
to the minting service, so per-service creations partition
the whole-corpus template count exactly). A corpus **passes**
iff every service with `≥ 1_000_000` lines has ratio `≥ 0.5`;
it **fails** if any such service is below `0.5`; it **abstains**
(`c2.pass = null`) when no service reaches 1 M lines. A
Comment thread
jensholdgaard marked this conversation as resolved.
Resolved
single-service corpus — including the plain-text `<unknown>`
bucket (no `service.name`) — collapses to the whole-corpus
verdict, so every historical text-corpus row is unchanged;
only multi-service OTLP corpora differ. **Rationale**:
running one whole-corpus ratio over a multi-service capture
(e.g. the OTel-Demo) is a category error — it conflates a
noisy infra service (a broker emitting high-cardinality
offset/path tokens) with clean application services, so the
whole-corpus number fails even when every application service
converges perfectly (v8 §9.12). The whole-corpus
`convergence_ratio` is retained as a **diagnostic** (the
`by_service` breakdown is the gate basis). Note: token-level
Comment thread
jensholdgaard marked this conversation as resolved.
Resolved
polishing of high-cardinality infra logs is an OTel Collector
concern (a `transform`/`redaction` processor upstream), not
the miner's — consistent with "format parsing is the
Collector's job".
- **Plateau-detection diagnostic** (not a gate): the curve
is "plateaued" at the sample where the trailing `K = 64`
samples all lie within `± 5%` of the SS. The diagnostic is
Expand Down