Skip to content

fix(bench/tolerance): _walk_leaves recurses into bare '_' sentinel - #492

Merged
robotrocketscience merged 1 commit into
mainfrom
fix/issue-490-walk-leaves-sentinel
May 8, 2026
Merged

robotrocketscience merged 1 commit into
mainfrom
fix/issue-490-walk-leaves-sentinel

Conversation

@robotrocketscience

@robotrocketscience robotrocketscience commented May 8, 2026

Copy link
Copy Markdown
Owner

Why

benchmarks/run.py:241 uses "_" as the sub-bucket key for single-invocation adapters:

if r.invocation.sub_key is None:
    bucket["_"] = payload   # ← single-invocation sentinel

Three adapters route through _: locomo, longmemeval, amabench. Their output.* metric leaves (overall_f1, avg_latency_ms, total_qa, …) live under results.<adapter>._.output.*.

benchmarks/tolerance._walk_leaves previously skipped every key starting with _, so those metrics were never enumerated and the cron's tolerance.check_report would silently pass even on a 100% latency regression. Multi-invocation adapters (mab, structmemeval) were unaffected — their sub-keys are e.g. Conflict_Resolution, not _.

Fix

One-line change to _walk_leaves:

if isinstance(k, str) and k.startswith("_") and k != "_":
    continue

Walker recurses into "_" and the next level (output, _status, _elapsed_sec) is re-filtered by the same rule, so metadata nested under "_" still gets skipped.

Verification

  • existing 19 test_bench_tolerance.py tests still pass
  • 3 new tests:
    • test_walk_leaves_recurses_into_bare_underscore_sentinel — direct _walk_leaves test, _ recursed, _status/_elapsed_sec inside _ skipped
    • test_check_report_band_checks_single_invocation_adapter — the regression case: 100% latency drift on longmemeval._.output.avg_latency_ms now FAILs (instead of silently passing)
    • test_check_report_passes_inside_band_for_single_invocation_adapter — confirms band classification works through the sentinel, not just visibility
  • full suite 2834 passed, 41 skipped
  • discretion grep clean, sig G

Out of scope

  • No change to metric_overrides defaults
  • No change to badge-text rendering
  • No change to current v2.0.0.json canonical (locomo currently has _status: error and no output; longmemeval / amabench output will start being band-checked once cron rebuilds with this fix)

Source: Setr's PR #489 review notes, "Side effects to flag" §1, 2026-05-08.

Closes #490.

Summary by Sourcery

Ensure benchmark tolerance checking walks metrics under the single-invocation '_' bucket while still skipping underscore-prefixed metadata keys.

Bug Fixes:

  • Fix omission of single-invocation adapter metrics under the '_' sentinel from tolerance band checks so regressions are detected correctly.

Tests:

  • Add tests covering walk_leaves recursion into the '' sentinel and band-check behavior for single-invocation adapters across regression and within-band cases.

)

`benchmarks/run.py:241` uses `"_"` as the sub-bucket key for
single-invocation adapters (locomo, longmemeval, amabench). The
previous filter `k.startswith("_")` skipped that bucket entirely,
so their `output.*` metrics under `results.<adapter>._.output.*`
were never band-checked by the cron — a 100% latency regression
on longmemeval would have silently passed.

The fix narrows the filter to skip metadata keys (`_status`,
`_elapsed_sec`, `_error_message`) but recurse into the bare `"_"`
sentinel. Recursion re-filters at each level, so metadata nested
inside `"_"` is still skipped.

Multi-invocation adapters (mab, structmemeval) are unaffected —
their sub_keys (e.g. `Conflict_Resolution`, `accounting`) don't
start with `_`.

Verification:
- existing 19 tolerance tests still pass
- 3 new tests cover: walker recurses into `_`, single-invocation
  band-check FAILs on regression, single-invocation band-check
  PASSes inside band
- full suite 2834 passed, 41 skipped

Setr flagged this in PR #489 review notes ("Side effects to flag"
§1, 2026-05-08).

Closes #490.
@sourcery-ai

sourcery-ai Bot commented May 8, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adjusts the benchmarks tolerance leaf-walking logic so it still skips underscore-prefixed metadata keys but recurses into the bare '_' sentinel used for single-invocation adapters, and adds tests to ensure single-invocation metrics are band-checked correctly for latency and counts.

Sequence diagram for tolerance.check_report handling single-invocation '_' sentinel

sequenceDiagram
    actor Cron
    participant BenchmarksRun as BenchmarksRun_py
    participant Results as Results_dict
    participant Tolerance as tolerance_check_report
    participant Walker as _walk_leaves

    Cron->>BenchmarksRun: run_benchmarks()
    BenchmarksRun->>Results: build results with sub_key "_" for single-invocation adapters
    BenchmarksRun-->>Cron: results

    Cron->>Tolerance: check_report(results)
    Tolerance->>Walker: _walk_leaves(results)

    loop traverse_results
        Walker->>Results: iterate keys
        alt key starts_with_underscore and key != "_"
            Walker-->>Results: skip metadata key (e.g. _status, _elapsed_sec)
        else key == "_"
            Walker->>Walker: recurse into "_" sub-dict
        end
    end

    Walker-->>Tolerance: list of metric_leaves (includes results.adapter._.output.*)
    Tolerance->>Tolerance: compute_bands_and_check(latency, counts, other_metrics)
    Tolerance-->>Cron: pass_or_fail_based_on_bands
Loading

File-Level Changes

Change Details Files
Update walk_leaves to recurse into the bare '' sentinel while still skipping underscore-prefixed metadata keys at every level.
  • Change the underscore-key filter to only skip keys that start with '' and are not exactly ''
  • Document in the walk_leaves docstring that '' is used as a sub-bucket key for single-invocation adapters and that recursion re-filters to keep skipping metadata keys like _status and _elapsed_sec
benchmarks/tolerance.py
Add tests ensuring single-invocation adapters’ metrics under the '_' sentinel are walked and band-checked.
  • Add a direct walk_leaves test that verifies recursion into '' and skipping of nested status/elapsed_sec keys
  • Add a regression test that a 100% latency increase for longmemeval..output.avg_latency_ms now fails the tolerance check
  • Add a test that a small change within band for amabench..output.total_qa passes the tolerance check
tests/test_bench_tolerance.py

Assessment against linked issues

Issue Objective Addressed Explanation
#490 Modify benchmarks/tolerance.walk_leaves so that it recurses into the bare '' sentinel key while still skipping other underscore-prefixed metadata keys (e.g. '_status', 'elapsed_sec'), allowing single-invocation adapter metrics under results...output.* to be band-checked.
#490 Update and extend tests in tests/test_bench_tolerance*.py to cover single-invocation adapters: keep existing tests passing and add coverage that metrics under results.._.output.* are walked and band-checked (including a FAIL case when out-of-band).

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@robotrocketscience has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 36 minutes and 40 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9a509f7f-bbe3-4f40-b4de-1006d7ca8493

📥 Commits

Reviewing files that changed from the base of the PR and between ef0c477 and 2af0a49.

📒 Files selected for processing (2)
  • benchmarks/tolerance.py
  • tests/test_bench_tolerance.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-490-walk-leaves-sentinel

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@robotrocketscience robotrocketscience added author-Toug PR coordination mutex attn:review Needs review (PR open, awaiting reviewer) eval-harness Continuation-fidelity / benchmarks work labels May 8, 2026

@sourcery-ai sourcery-ai 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.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@robotrocketscience

Copy link
Copy Markdown
Owner Author

[claim:review:kulili:2026-05-08T16:02:58Z]

@robotrocketscience
robotrocketscience merged commit 2af0a49 into main May 8, 2026
24 of 31 checks passed
@robotrocketscience
robotrocketscience deleted the fix/issue-490-walk-leaves-sentinel branch May 8, 2026 16:03
@robotrocketscience

Copy link
Copy Markdown
Owner Author

[release:review:kulili:2026-05-08T16:03:45Z]

@robotrocketscience robotrocketscience removed the attn:review Needs review (PR open, awaiting reviewer) label May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author-Toug PR coordination mutex eval-harness Continuation-fidelity / benchmarks work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(bench/tolerance): _walk_leaves skips single-invocation adapter '_' sentinel — locomo/longmemeval/amabench metrics never band-checked

1 participant