Pass 2 of 4 · mechanism · about 60 min
Exact code and maths
The same nine pictures with the Rust beside them and the equations coloured to match.
0 of 18 concepts in this pass seen
Before we start
E1E5E8
Three questions from Pass 1, without looking back. Wrong answers send you to the exact lab state that fixes them.
Someone edits node 7's line in the JSONL transcript and Same Again re-imports it. Which ids change?
Two policies are identical. You run a standard 5% test after every pair, from pair 5 to pair 150, and stop the first time it says 'significant'. How often do you ship a change that does nothing?
An agent passes a task 60% of the time. It will run unattended every night for a week. Which number tells you how often the whole week goes cleanly?
Digests with a domain
S2E1
Reminder: a node's id names its bytes. Here is the exact recipe. Every typed digest hashes a domain string, a NUL byte, then the content [code]crates/sa-core/src/digest.rs:97.
/// Hash canonical bytes with `K::DOMAIN` + NUL domain separation.
pub fn of_canonical(bytes: &[u8]) -> Self {
let mut hasher = Sha256::new();
Highlighted: hasher.update(K::DOMAIN.as_bytes());
Highlighted: hasher.update([0u8]);
hasher.update(bytes);
let node_id = Digest::<TraceKind>::of_parts(&[
Highlighted: SourceKind::ClaudeCode.as_str().as_bytes(),
Highlighted: item.path_str.as_bytes(),
Highlighted: &off_bytes,
Highlighted: raw_digest.as_bytes(),
]);
Look at what is not in that list: the parent's id. So a trace node id is content-addressed but not Merkle over its parents. The Merkle property lives one level up, in the cut id, which feeds every prefix node id in order [code]crates/sa-core/src/cut.rs:228-231.
let mut canonical = Vec::new();
canonical.extend_from_slice(session_uid.as_bytes());
canonical.push(0);
canonical.extend_from_slice(role_tag);
canonical.push(0);
canonical.extend_from_slice(cut_node_id.as_bytes());
canonical.push(0);
canonical.extend_from_slice(ws_tag.as_bytes());
canonical.push(0);
canonical.extend_from_slice(pol_hex.as_bytes());
Highlighted: for turn in prefix {
Highlighted: canonical.push(0);
Highlighted: canonical.extend_from_slice(turn.node_id.as_bytes());
Highlighted: }
The same bytes are hashed once as a trace digest and once as a policy digest. Are the two digests equal?
The split rule
S3E2
Reminder: the agent sees the past, the grader keeps the future. In code, the past is every node with seq < cut_seq [code]crates/sa-core/src/cut.rs:140.
for n in ordered {
Highlighted: if n.seq < cut_seq {
agent_prefix.push(CutPrefixTurn {
After the cut is written to disk, sa cut runs two checks: no .git anywhere under agent/, and no held-out node id hex string inside prompt_prefix.json [code]crates/sa-ingest/src/cut.rs:200-210. Pass both and the manifest says isolation_verified: true.
// Post-materialisation isolation verification:
Highlighted: // 1. No `.git` directory or file anywhere inside `agent/`.
Highlighted: verify_no_git_metadata(&agent_dir)?;
Highlighted: // 2. No held-out witness node ID appears in `agent/prompt_prefix.json`.
Highlighted: for w in &isolated.grader_held_out {
Highlighted: if prefix_json.contains(&w.node_id.to_hex()) {
Read those two checks again and ask what they do not look at. Neither compares the workspace's git tree with the time of the cut. Hold that thought for Pass 3.
Kleene's three values
E3
Reminder: Unknown means missing evidence. Kleene's strong logic, K3, is the rule that never invents evidence. The whole of Verdict::and fits on one screen [code]crates/sa-core/src/verdict.rs:47-54.
pub fn and(self, other: Self) -> Self {
match (self, other) {
Highlighted: (Self::Fail, _) | (_, Self::Fail) => Self::Fail,
Highlighted: (Self::Pass, Self::Pass) => Self::Pass,
(Self::Unknown(a), Self::Unknown(b)) => Self::Unknown(format!("{a}; {b}")),
(Self::Unknown(r), _) | (_, Self::Unknown(r)) => Self::Unknown(r),
}
}
Notice the reasons. Two Unknowns joined by AND keep both reasons, separated by a semicolon, so a report can say 'grader timed out; answer.md missing' instead of a bare Unknown.
A grader that cannot skip calibration
S5E4
Reminder: a grader must reject a bad witness and accept a good one before it may score. Same Again enforces this with the type system. Predicate<T, Uncalibrated> and Predicate<T, Calibrated> are different types [code]crates/sa-core/src/predicate.rs:80-84, and only the calibrated one has evaluate.
pub fn calibrate_all(
self,
bad_witnesses: &[&T],
good_witnesses: &[&T],
unknown_witnesses: &[&T],
) -> Result<Predicate<T, Calibrated>, CalibrationError> {
The order matters. Empty witness sets are rejected first, then every bad witness must give Fail, then every good one Pass, then every optional unknown witness must stay Unknown [code]crates/sa-core/src/predicate.rs:185-226. The first broken rule returns its error.
| Grader | Behaviour | calibrate_all |
|---|---|---|
| Always Pass | Pass on everything | BadWitnessNotRejected |
| Always Fail | Fail on everything | GoodWitnessNotAccepted |
| Timeout-happy | Pass when the file is missing | UnknownWitnessNotUnknown |
| File-exists | Pass if answer.md exists | Passes, if the bad witness lacks the file |
| Discriminating | Checks the claim's freshness | Passes |
What stops a developer from scoring trials with a grader that has never been calibrated?
An always-Pass grader is run through calibrate_all. Which error comes back first?
The e-value: a bet that cannot be gamed by peeking
E5S6
Reminder: you may check sa diff after every pair. Here is why. Only discordant pairs carry evidence: B passed and A failed (count b), or the reverse (count a). Ties tell you nothing about which is better.
Under 'no difference', each discordant pair is a fair coin. The e-value averages the likelihood of the observed (b, a) over every possible bias, with a flat Beta(1, 1) prior, and divides by the fair-coin likelihood [code]crates/sa-core/src/stats.rs:350-360.
pub fn beta_binomial_e_value(b_better: usize, a_better: usize) -> f64 {
let m = b_better + a_better;
if m == 0 {
return 1.0;
}
Highlighted: let log_e =
Highlighted: (m as f64) * std::f64::consts::LN_2 + ln_factorial(b_better) + ln_factorial(a_better)
Highlighted: - ln_factorial(m + 1);
log_e.exp()
}
Under the null its expected value is exactly 1 at every step. Ville's inequality then says the chance it ever reaches 1/α is at most α, no matter when you look or when you stop.
Worked. Seven straight B wins: . Under 20, so not yet.
From evidence to a verdict
E5S6
The e-value says whether B differs from A. A confidence sequence says by how much. It is an interval around the estimate that stays valid at every n at once, and its radius shrinks slowly [code]crates/sa-core/src/stats.rs:365-376.
Here n counts decisive pairs: ties included, Unknown pairs left out. Then decide_verdict walks four gates in order [code]crates/sa-core/src/stats.rs:305-339.
let unk_a = arm_a.unknown_rate();
let unk_b = arm_b.unknown_rate();
Highlighted: if unk_a > config.max_unknown_rate || unk_b > config.max_unknown_rate {
return DiffVerdict::Inconclusive(format!(
"excessive Unknown rate (arm_a={:.1}%, arm_b={:.1}%, cap={:.1}%)",
unk_a * 100.0,
unk_b * 100.0,
config.max_unknown_rate * 100.0
));
}
Highlighted: if e_value >= threshold {
if paired.b_better > paired.a_better {
return DiffVerdict::Better;
}
if paired.a_better > paired.b_better {
return DiffVerdict::Worse;
}
}
- No pairs at all: Inconclusive.
- Either arm more than 20% Unknown: Inconclusive.
- : Better or Worse by the sign of b − a.
- At least 5 decisive pairs and the whole interval inside ±0.05: Equivalent. Otherwise Inconclusive.
With the default --max-trials 20 (10 pairs) and margin 0.05, can sa diff ever return Equivalent?
Why pairing halves the variance
F4E7
Reminder: a shared task drags both arms together. The variance of a difference subtracts their covariance.
Worked. Both arms pass with p = 0.6, so each variance is . With Cov = 0.12 on the same task: . Unpaired it would be 0.48. Half the variance means half as many pairs for the same precision.
Retries cut the other way. With m retries per task and intra-task correlation ρ, the design effect is . Eight retries at ρ = 0.6 give a design effect of 5.2, so eight runs carry about 1.54 tasks' worth of information [toy]designEffect(8, 8, 0.6).
Both arms pass with p = 0.6 and Cov(A, B) = 0.12 on the same task. What is Var(A − B)?
pass@k and pass^k in the code
E8
Reminder: capable is not reliable. sa-core estimates both from n attempts with c passes on one cut [code]crates/sa-core/src/stats.rs:395-420.
pub fn pass_pow_k(n: usize, c: usize, k: usize) -> Option<f64> {
if k == 0 || n == 0 || c > n {
return None;
}
Highlighted: let p = (c as f64) / (n as f64);
Highlighted: let exp = i32::try_from(k).unwrap_or(i32::MAX);
Highlighted: Some(p.powi(exp))
}
pass@k is the unbiased draw-without-replacement estimator from the HumanEval paper. pass^k is not. Raising an estimate to a power is a convex operation, so on average it overshoots. Pass 3 measures by how much.
A cut has n = 5 attempts with c = 3 passes. What do pass_at_k and pass_pow_k report for k = 3?
Bounds instead of a guess
E6
Reminder: Unknown pairs vanish from the evidence. The estimate uses only decisive pairs, so the denominator shrinks with the fog.
Manski's idea is to stop guessing what the fog hides. Fill it in the worst way for B, then the best way, and report the range. Every filling-in the data allows lies inside it. This is a proposal, not in same-again.
ddmin, line by line
S8E9
Reminder: shrink keeps removing units while the check still passes. ddmin_shrink first probes the full set and the empty set, then loops: try each chunk alone, then each complement, then split finer [code]crates/sa-core/src/search.rs:120-172.
// 2. Try each complement (remove one chunk at a time).
for (skip_i, _) in chunks.iter().enumerate() {
let complement: Vec<usize> = chunks
.iter()
.enumerate()
.filter(|&(j, _)| j != skip_i)
.flat_map(|(_, c)| c.iter().copied())
.collect();
let Some(v) = run_probe(&complement, &mut probes, &mut budget_exhausted)? else {
break;
};
Highlighted: if v.is_pass() {
Highlighted: active = complement;
Highlighted: granularity = (granularity - 1).max(2);
reduced = true;
break;
}
}
The real fixture has 8 units: six AGENTS.md sections and two skills, with Git, Testing and rust-feedback needed. With a perfect oracle, ddmin needs 48 probes. The CLI default is --max-trials 24 [code]crates/sa-cli/src/main.rs:524, so it stops at six units with budget_exhausted [toy]ddminShrink(8, 24, requiredSetOracle(W7_ACTIVE)).
ShrinkProbe records step for step.Eight policy units, three of them needed, a perfectly deterministic oracle and the CLI default budget of 24 probes. Does ddmin finish?
bisect, line by line
S7E10
Reminder: a bracket cannot recover from a lie. bisect_revisions checks that revision 0 passes and the last one fails, then halves [code]crates/sa-core/src/search.rs:303-331. A midpoint Unknown stops the search with Inconclusive.
while hi - lo > 1 {
let mid = lo + (hi - lo) / 2;
let Some(mid_v) = eval(mid, &mut probes)? else {
Offline, sa bisect reuses stored trials instead of new runs. A revision counts as Fail if any stored trial failed [code]crates/sa-ingest/src/experiment.rs:485-490. A good revision that passes 90% of the time, with 10 stored trials, gets called Fail about 65% of the time, because [toy]offlineAnyFailRate(0.9, 10).
Probabilistic bisection keeps a belief over every possible first-bad revision. Where does it probe next?
Counting your looks
E11
Reminder: every look at the same cuts is a ticket. With t independent looks at level α, the chance of at least one false alarm is bounded by:
E-values make the fix cheap. Bonferroni for e-values just raises the bar: reject only when , which is 400 for 20 looks. e-BH (Wang and Ramdas, 2022) is gentler: sort the e-values and reject the k largest when the kth is at least .
Mixed practice
E5E11E2E9E6
Five questions, shuffled across threads. Part of the exercise is noticing which idea applies.
B wins every discordant pair and A wins none. How many straight B wins before sa diff can say Better at α = 0.05?
You tweak a grader 20 times and run a 5% diff after each tweak, on the same cuts, when nothing really changed. Under independence, what is the upper bound on the chance of at least one false Better?
A cut is taken at cut_seq = 40. Which of these may reach the agent's side?
Shrink removes the Testing section and the agent passes once. With a flaky agent, which mistake is more dangerous here?
Policy B times out on 15 of 100 tasks, all of them hard ones that A passed. The diff drops those 15 pairs. What happens to B's apparent advantage?