bench: cache+branch-sim profiles, hypothesis-granular ledger memory, long-poll read_verdict

- Profiles regenerated with callgrind --cache-sim --branch-sim for both
  targets: per-function D1/LL miss and branch-mispredict columns unlock
  playbook class-4 preconditions (comrak: syntect write_highlighted owns
  31% of D1 read misses; tokei: parse_lines owns 56% of Ir).
- tokei workspace: accepted Phase 0 wins banked as a local commit so
  stash-based baseline rebuilds attribute only the marginal patch to new
  attempts (false-accept trap closed before grinding).
- read_ledger now returns per-attempt history (class, hotspot,
  hypothesis, verdict): a class may be re-entered with a materially new
  hypothesis, never a duplicate one. Task prompt updated to match.
- read_verdict long-polls the ledger up to 45s server-side (under the
  60s MCP cap), cutting the agent's polling turn burn ~15x.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EcKPWQ3MQD4NdEHwar96u2
This commit is contained in:
Claude
2026-07-10 04:49:19 +00:00
parent e0c5018008
commit 017491010b
7 changed files with 52055 additions and 66 deletions
+21
View File
@@ -165,6 +165,27 @@ impl Ledger {
Ok(rows.collect::<Result<Vec<_>, _>>()?)
}
/// Per-attempt history for a target: class, hotspot, hypothesis,
/// verdict. The agent's anti-duplicate memory at hypothesis
/// granularity — a class may be re-entered with a materially new
/// hypothesis, but never the same (hotspot, class, hypothesis).
pub fn attempt_history(&self, target: &str) -> Result<Vec<serde_json::Value>, LedgerError> {
let mut stmt = self.conn.prepare(
"SELECT run_id, playbook_class, hotspot, hypothesis, verdict \
FROM attempts WHERE target = ?1 ORDER BY rowid",
)?;
let rows = stmt.query_map([target], |r| {
Ok(serde_json::json!({
"run_id": r.get::<_, String>(0)?,
"playbook_class": r.get::<_, u8>(1)?,
"hotspot": r.get::<_, String>(2)?,
"hypothesis": r.get::<_, String>(3)?,
"verdict": r.get::<_, String>(4)?,
}))
})?;
Ok(rows.collect::<Result<Vec<_>, _>>()?)
}
/// Read-only verdict summary for one run — the agent's only window
/// onto a completed attempt (harnessd `read_verdict`). Returns the
/// verdict plus the bench CIs; never enough to game, since the row