Skip to content

feat(eval-harness): wire context-rebuilder eval harness commit-1 (#592) - #596

Merged
robotrocketscience merged 7 commits into
mainfrom
feat/issue-592-eval-harness-wire
May 10, 2026
Merged

feat(eval-harness): wire context-rebuilder eval harness commit-1 (#592)#596
robotrocketscience merged 7 commits into
mainfrom
feat/issue-592-eval-harness-wire

Conversation

@robotrocketscience

Copy link
Copy Markdown
Owner

Closes part of #592 (commit 1 of the proposed three).

What lands

Wires three of the five NotImplementedError integration points in
benchmarks/context-rebuilder/eval_harness.py, plus a non-crashing stub
for the fourth, plus a .meta.json for the bundled synthetic fixture
so --mode threshold-sweep runs end-to-end out of the box.

Function Before After
replay_to_fork raises NotImplementedError builds in-memory MemoryStore, ingests turns 0..fork_turn-1 via ingest_jsonl
run_rebuilder raises calls rebuild_v14 with floor_session=floor_l1=trigger_threshold; returns (block, latency_ms)
measure_token_cost raises returns estimate_tokens(rebuilt) / estimate_tokens(pre_clear) via the shared 4-chars-per-token estimator
replay_post_fork raises placeholder records with reason="needs_replay_client" so score_fidelity returns 0.0 instead of crashing
score_fidelity unchanged already returns 0.0 on matched=False rows

Threshold-sweep semantics

The harness's trigger_threshold axis maps to rebuild_v14's v1.7
per-lane composite-score floors (floor_session + floor_l1). L0
locked beliefs are unaffected per the documented v1.4 contract; the
sweep answers "at what relevance floor does the rebuilder still pack
useful content for this task family?" — which is the closest existing
rebuild-time knob to the harness's "threshold" wording. The original
issue body framed the threshold as a compaction-trigger, but no such
knob exists on main; mapping to floors is the implementable v0
that produces meaningful sweep curves today. This is documented in
the run_rebuilder docstring.

Atomic commits

7 SSH-signed commits in dependency order:

  1. feat(eval-harness): wire replay_to_fork to MemoryStore + ingest_jsonl (#592)
  2. feat(eval-harness): wire run_rebuilder to rebuild_v14 (#592)
  3. feat(eval-harness): wire measure_token_cost via shared estimator (#592)
  4. feat(eval-harness): non-crashing replay_post_fork stub (#592)
  5. feat(eval-harness): add meta.json for synthetic fixture (#592)
  6. test(eval-harness): end-to-end smoke for --mode threshold-sweep (#592)
  7. docs(changelog): unreleased entry for #592 eval-harness commit-1 wiring

Verification

  • uv run pytest -x -q3282 passed, 53 skipped (3267 baseline + 15 new).
  • CLI smoke: uv run python benchmarks/context-rebuilder/eval_harness.py --mode threshold-sweep --corpus benchmarks/context-rebuilder/fixtures/synthetic/ --out /tmp/sweep.json produces a valid JSON report with one case, five runs (default 5 thresholds), summary keyed by task_type then threshold.
  • All 7 commits SSH-signed.
  • Discretion grep clean.

Acceptance progress

  • --mode threshold-sweep runs to completion against eval_corpus/-equivalent (the bundled synthetic fixture). Produces results/sweep_<date>.json.
  • At least one synthetic post-compact task_type=hot_start scenario added to the eval corpus. Deferred to follow-up — depends on the <working-state> rebuilder sub-block from feat(rebuilder): post-compact hot-start — preserve working-state delta alongside retrieval #587 / PR feat(rebuilder): post-compact <working-state> hot-start (#587) #591 landing first.
  • Hot-start scenarios score ≥80%. Deferred — requires the model-invocation client (commit 2) and the hot-start scenario.
  • Cold-start scenarios continue to score in line with their current calibration target (no regressions; the bundled fixture's runs produce valid latency/token-cost numbers, fidelity is the documented 0.0 placeholder).

Out of scope (explicit follow-ups)

…#592)

Replaces the NotImplementedError stub in benchmarks/context-rebuilder/
eval_harness.py with a working implementation: builds a fresh in-memory
MemoryStore and ingests turns 0..fork_turn-1 from the case's JSONL via
ingest_jsonl. Truncation is local — keeping it inside the harness avoids
coupling the production ingest path to harness internals.

Adds a sys.path shim so the script form (`python ...eval_harness.py`)
can resolve aelfrice imports despite the hyphenated parent directory
blocking `python -m`.

3 new tests in tests/test_context_rebuilder_eval_harness_wiring.py
exercise: returns a populated MemoryStore, fork_turn boundary monotonic
in belief count, fork_turn=0 returns an empty store.
Replaces the run_rebuilder stub with a real call to
aelfrice.context_rebuilder.rebuild_v14. The harness's `trigger_threshold`
sweep axis maps to the v1.7 per-lane composite-score floors (floor_session
+ floor_l1) — the closest existing rebuild-time knob to a "relevance
threshold" sweep. L0 locked beliefs are unaffected by the floor per the
documented v1.4 contract.

Adds a `_recent_turns_pre_fork` helper that mirrors the production hook's
adapter — reads pre-fork lines from the JSONL, skips compaction markers
and malformed lines, returns the last DEFAULT_N_RECENT_TURNS as
RecentTurn records ready for rebuild_v14.

3 new tests: returns (str, latency≥0); high floor packs ≤ low floor;
empty store + empty recent_turns returns the empty block (rebuild_v14's
silent-path contract).
Replaces the measure_token_cost stub with a real ratio:
estimate_tokens(rebuilt) / estimate_tokens(pre_clear). Both sides use
benchmarks.context_rebuilder.measure.estimate_tokens — the 4-chars-per-
token heuristic that mirrors aelfrice.context_rebuilder._CHARS_PER_TOKEN
so the harness measurement stays aligned with the rebuilder's own
budget bookkeeping.

Adds a `_pre_clear_text` helper that concatenates the `text` fields of
turns 0..fork_turn-1. Empty pre-clear (fork_turn=0) returns 0.0 instead
of dividing by zero — documented corner.

3 new tests: zero pre-clear → 0.0; smaller rebuilt → smaller ratio;
shared-estimator parity (ratio matches estimate_tokens(rebuilt) /
estimate_tokens(pre_clear) byte-for-byte).
Replaces the NotImplementedError with placeholder records so that
threshold-sweep and budget-sweep modes can run end-to-end producing
latency and token-cost numbers, even before the model-invocation client
lands.

Each placeholder is `{turn_idx, expected, actual="", matched=False,
reason=REPLAY_PENDING_REASON}`. The `expected` field is pulled from
the captured transcript at the eval-turn line index so summaries can
still surface what the agent should have continued with. score_fidelity
reads `matched=False` and returns 0.0 — no crash, just a documented
floor until the model client wires up.

The REPLAY_PENDING_REASON marker is exported as a public-ish constant
so summary readers can distinguish "skipped, judge required" from a
real fidelity miss. The model-client follow-up will swap the stub for
a real replay; the placeholder shape is preserved so downstream
consumers don't change.

4 new tests: one placeholder per eval_turn; expected pulled from
transcript; empty eval_turns → []; score_fidelity returns 0.0 instead
of crashing.
The eval harness's load_corpus walks `<corpus>/*.jsonl` and pairs each
with a same-stem `.meta.json` carrying task_type, fork_turn, and
eval_turns. The shipped synthetic fixture had no meta file, so the
harness loaded zero cases out of the box.

Adds debugging_session_001.meta.json: midpoint fork at turn 8 of the
16-turn fixture, eval_turns = the four post-fork user prompts (indices
8/10/12/14). Operators can now run:

  uv run python benchmarks/context-rebuilder/eval_harness.py \\
      --mode threshold-sweep \\
      --corpus benchmarks/context-rebuilder/fixtures/synthetic/ \\
      --out benchmarks/context-rebuilder/results/sweep.json

against the bundled fixture without setting up a separate corpus.
Two new tests cover the integration of all four wired functions
(replay_to_fork, run_rebuilder, measure_token_cost, replay_post_fork
stub) plus the corpus-loader path against the bundled synthetic
fixture:

- threshold_sweep_runs_end_to_end_on_synthetic_fixture: loads the
  fixture via load_corpus, runs a 2-threshold sweep, asserts the JSON
  output schema (mode, runs[*].fidelity/latency/token_cost_ratio,
  summary[task][threshold=...] metric keys).
- run_one_returns_runresult_without_crashing: verifies run_one
  threads through replay → rebuild → replay-stub → score without
  raising and surfaces the REPLAY_PENDING_REASON marker on every
  unmatched eval_turn so summary readers can distinguish "skipped,
  judge required" from real fidelity misses.

Locks in the harness's runnable contract before the model-invocation
client lands.
Documents the three pure-Python integration points wired in this PR
(replay_to_fork, run_rebuilder, measure_token_cost), the non-crashing
replay_post_fork stub, and the synthetic-fixture meta.json that makes
the bundled corpus resolve out of the box. Calls out the explicit
follow-ups: model-invocation client and LLM judge.

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

Sorry @robotrocketscience, you have reached your weekly rate limit of 2500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented May 10, 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 19 minutes and 41 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: 875af652-7c6b-450c-a78d-61c57bb47a2a

📥 Commits

Reviewing files that changed from the base of the PR and between e46a665 and 907c5a6.

⛔ Files ignored due to path filters (1)
  • CHANGELOG.md is excluded by !**/CHANGELOG.md
📒 Files selected for processing (3)
  • benchmarks/context-rebuilder/eval_harness.py
  • benchmarks/context-rebuilder/fixtures/synthetic/debugging_session_001.meta.json
  • tests/test_context_rebuilder_eval_harness_wiring.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/issue-592-eval-harness-wire

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-Maxwell PR coordination mutex attn:review Needs review (PR open, awaiting reviewer) labels May 10, 2026
Comment on lines +37 to +42
from aelfrice.context_rebuilder import ( # noqa: E402
DEFAULT_N_RECENT_TURNS,
DEFAULT_REBUILDER_TOKEN_BUDGET,
RecentTurn,
rebuild_v14,
)
@robotrocketscience

Copy link
Copy Markdown
Owner Author

[claim:review:Leibniz:2026-05-10T15:13:25Z]

@robotrocketscience

Copy link
Copy Markdown
Owner Author

[claim:review:planck:2026-05-10T15:14:25Z]

@robotrocketscience

Copy link
Copy Markdown
Owner Author

[release:review:planck:2026-05-10T15:14:30Z]

@robotrocketscience
robotrocketscience merged commit 907c5a6 into main May 10, 2026
23 checks passed
@robotrocketscience
robotrocketscience deleted the feat/issue-592-eval-harness-wire branch May 10, 2026 15:14
@robotrocketscience

Copy link
Copy Markdown
Owner Author

Merged via local FF push to main as 907c5a6. All CI green, 7 commits SSH-signed, discretion clean. Reviewed by Leibniz.

@robotrocketscience

Copy link
Copy Markdown
Owner Author

[release:review:Leibniz:2026-05-10T15:15:03Z]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

attn:review Needs review (PR open, awaiting reviewer) author-Maxwell PR coordination mutex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants