Skip to content

Add whole-repo agent mode alongside per-rule#38

Merged
isPANN merged 3 commits into
mainfrom
feat/whole-repo-mode
Jul 6, 2026
Merged

Add whole-repo agent mode alongside per-rule#38
isPANN merged 3 commits into
mainfrom
feat/whole-repo-mode

Conversation

@isPANN

@isPANN isPANN commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Adds a second, opt-in run mode so the two can be compared on the same scoring pipeline.

  • per-rule (default, unchanged): one isolated agent session per rule, budget split evenly.
  • whole-repo (new): ONE session over the whole library — the agent enumerates rules with pred list, triages by suspicion, and emits a certificate per bug under a single budget. Select with AGENT_MODE=whole-repo / --mode whole-repo.

Both produce the same submission.json and are scored by the same zero-trust pred re-verification, so results are directly comparable.

Changes

  • benchmark/config_repo.yaml — whole-repo prompt (enumerate + triage, emit many certificates, don't stop at the first).
  • run_mini.pyparse_all_certificates (multi-cert, de-duped) + run_repo_session (single session → one row per cert, shared trajectory).
  • run_submission.py--mode/AGENT_MODE, whole-repo branch, total_tokens_k override on build_submission.
  • verify_submission.py — provenance now matches any certificate block in the trajectory (a whole-repo run emits many), not just the last.
  • config.yaml — per-rule prompt gives a qualitative budget hint instead of the literal dollar figure.
  • submission.env.example + run-benchmark skill — document AGENT_MODE; skill now confirms experiment parameters (mode/budget) with the user before a run.
  • tests — test_whole_repo.py + a multi-cert provenance test (151 unit tests pass).

🤖 Generated with Claude Code

isPANN and others added 3 commits July 6, 2026 17:21
A second, opt-in run mode for comparison. per-rule (default, unchanged) runs
one isolated agent session per rule with the budget split evenly. whole-repo
runs ONE session over the whole library: the agent enumerates the rules with
`pred list`, triages them by suspicion, and emits a certificate per bug under a
single budget (its cost_limit). Both modes produce the same submission.json and
are scored by the same zero-trust pred re-verification, so results are directly
comparable. Select with AGENT_MODE=whole-repo (or --mode whole-repo).

- benchmark/config_repo.yaml: whole-repo prompt (enumerate + triage by
  suspicion, emit many certificates, don't stop at the first).
- run_mini.py: parse_all_certificates (multi-cert, de-duped) and
  run_repo_session (single session → one row per cert, shared trajectory).
- run_submission.py: --mode/AGENT_MODE, whole-repo branch, and a total_tokens_k
  override on build_submission (session totals don't live on per-rule rows).
- verify_submission.py: provenance now matches ANY certificate block in the
  trajectory, not just the last — a whole-repo run emits many in one trajectory.
- config.yaml: per-rule prompt gives a qualitative budget hint instead of the
  literal dollar figure (the agent can't meter its own spend).
- submission.env.example + run-benchmark skill: document AGENT_MODE; the skill
  now confirms experiment parameters (mode/budget) with the user before a run.
- tests: test_whole_repo.py + a multi-cert provenance test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018xw6L5yUrz33UrQpanbwnH
Code-quality cleanup from a /simplify pass:
- run_mini.py: extract _session_cost() + _trajectory() helpers shared by run_one
  and run_repo_session — the budget-faithful cost/token accounting lived in two
  runners and could drift. Drop a redundant `strategy or ""`.
- run_submission.py run(): assign `runner` in exactly one place (build the
  per-rule MiniSweRunner unconditionally in the real branch — its constructor is
  free), and call build_submission ONCE after the mode branch instead of in both.
- run_submission.py build_submission: rules_tested counts DISTINCT rules with a
  result, not row count — for whole-repo that's the distinct rules with a cert
  (a floor), fixing a docstring that claimed "rules attempted" for both modes.

Skipped (noted as follow-ups): the whole-repo session trajectory is duplicated
onto every bug row, so the backend re-parses it once per bug (O(bugs) over the
same log) and stores N copies — the real fix is to hold the trajectory once at
the envelope level, a schema change beyond this cleanup.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018xw6L5yUrz33UrQpanbwnH
A whole-repo run is one session that emits many bugs, but each bug row carried a
full copy of the shared trajectory — so submission.json duplicated the log N
times and the backend re-parsed it once per bug (O(bugs) over identical data).

Store it once: run_repo_session returns the trajectory; build_submission puts it
at submission["trajectory"]; rows carry only their certificate. score_submission
parses the envelope trajectory once and _provenance_ok matches each bug's cert
against it (or the row's own trajectory, unchanged for per-rule). Schema gains an
envelope-level `trajectory` and drops the row-level `trajectory` from the
bug_found requirement (provenance is enforced by the backend / submit CLI, which
now accept the trajectory on the row OR the envelope).

Per-rule mode is unchanged: each row keeps its own trajectory, no envelope one.

Tests: envelope-trajectory provenance + no-trajectory-anywhere rejection; updated
whole-repo row/wiring tests. 153 unit tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018xw6L5yUrz33UrQpanbwnH
@isPANN isPANN merged commit e34890d into main Jul 6, 2026
1 check passed
@isPANN isPANN deleted the feat/whole-repo-mode branch July 6, 2026 10:07
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.

1 participant