Skip to content

test(harness): three-tier bench harness — standalone binary + Claude Code + Codex (with isolated DBs/logs) #29

Closed

Description

@thehoff

Goal

Build a reproducible test harness so we can answer "is the crawler actually hitting?" with numbers, both standalone and inside the two agent harnesses (Claude Code, Codex). Today's measurements (codex 0% → 80% post-#9; Claude ~100% via hook; global 35.4%) were ad-hoc; we need them as a re-runnable artifact.

Three tiers, each measurable

Tier 1 — standalone binary microbench

  • Cargo integration test (tests/harness_standalone.rs)
  • Per-invocation isolation: RTK_DB_PATH=/tmp/cc-bench-{nonce}.db, temp log dir
  • Battery against tests/fixtures/bench/ (curated real inputs: git log, .xcstrings, large unknown-ext, grep over Rust src)
  • Reports: per-filter tokens in/out, savings %, exec time + aggregate
  • Output: bench/results-{git-sha}.json + matching .md
  • Reproducible, CI-runnable, bisectable. Catches binary regressions immediately.

Tier 2 — Claude Code harness (scripts/bench-claude.sh)

  • Drives claude --print --output-format=json with a fixed prompt battery ("read this file", "find usages", "show commits")
  • Parses tool-call trace; computes hook-driven compliance (% Bash calls auto-wrapped by contextcrawler hook claude) — should be ~100%
  • Captures gain delta on isolated DB
  • Catches hook breakage, settings.json drift

Tier 3 — Codex harness (scripts/bench-codex.sh)

Wrapper (scripts/bench-all.sh)

  • Runs all three; writes a single dated report. Pre/post compare-friendly.

Build order

  1. Tier 1 — pure Rust, no external calls, lowest cost. Probably 1 PR. Start here.
  2. Tier 3 — fold perf(codex): lift codex compliance from 80% → 95%+ — add missing patterns to AGENTS.md template + ship a compliance measurement #28 into this issue's PR sequence.
  3. Tier 2 — last, gated behind a flag in CI (Claude Code API calls cost money).

Design choices (documented for future me)

  • Fixtures live at tests/fixtures/bench/ (sibling to existing tests/fixtures/)
  • Scripts in scripts/ initially. Promote to contextcrawler bench/compliance subcommands only if usage justifies the binary surface.
  • Tier 1 runs on every PR. Tier 2/3 run weekly via a separate CI workflow or on-demand via a label.
  • Each tier gets a fresh DB so traffic from one tier doesn't pollute another's measurement.

Success criterion

After this issue lands:

  • cargo test --test harness_standalone produces a deterministic numeric report comparable across PRs
  • scripts/bench-codex.sh reports compliance % matching what we manually computed today (currently ~80%)
  • A simple before/after workflow exists for any future template or filter change: run wrapper, compare numbers, gate merge on improvement

Open backlog impact

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions