From 66e5c9e021a4b159270d76855221dda996d02d32 Mon Sep 17 00:00:00 2001 From: scotares Date: Fri, 27 Nov 2026 13:55:13 +0800 Subject: [PATCH 1/4] feat(xtask): record each run's judge view against the judge's budget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A run whose view does not fit the judge is unjudged before any call, and the only place the estimate and the budget appeared was that run's error. A scenario could therefore sit within a few tokens of the budget and look healthy until a text change or a longer host path flipped it (#2256, #2257). `Judging` now keeps the pair the fit check compared, and the run record states `judgeEstimate` and `judgeBudget` beside the outcome. Both fields are optional on the wire, so runs.jsonl written before this change still reads; the re-judge and pool paths carry them through `SavedRun`. The fit flow asserts that the judged view keeps over 4 000 tokens of headroom and the overgrown one clears the budget by more than 4 000, so the fixture states its margin instead of relying on it. model-prompts §8.1 records that every run's record carries the pair. --- docs/design/model-prompts.md | 2 +- xtask/src/scenario_eval.rs | 57 +++++++++++++++++++++++++++++++----- 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/docs/design/model-prompts.md b/docs/design/model-prompts.md index 360ba2c0f6..8499288800 100644 --- a/docs/design/model-prompts.md +++ b/docs/design/model-prompts.md @@ -165,7 +165,7 @@ A probe's rate counts judged, non-failed runs only, and failed runs are compared The last row is the rule's limit at the floor: catching that loss 80% of the time needs about 44–51 runs per scenario per arm. The report therefore prints both arms' counts, both rates, the loss, the p-value and the Holm threshold for every comparison, so a reader sees a loss the rule did not flag as well as one it did. The measured table resamples whole runs, which keeps each run's probes together. The pooled rows do not: they count each probe of each run as an observation, and the probes of one run share a transcript, so those p-values are optimistic. That errs toward rejecting, which means failing a candidate, and the per-probe rows compare one probe over whole runs. -**Failed and unjudged runs.** A failed run is one that ended on an error or its wall-clock budget, or one whose judging did not happen: there was nothing the judge could be asked, or a judge call failed — a window overflow, a transport or an HTTP error, or a reply cut off at its output cap. An unjudged run is one the judge answered but gave no usable verdicts for after two re-asks, or one whose view does not fit the judge's budget, which is never asked: it enters none of its arm's probe rates, and the report counts it and lists it with its reason; the unjudged-run rate compares it. A failed run is out of the probe rates too, and is compared once, as the failed-run rate. Those two rates count the runs an arm had something to compare in — its judged, failed and unjudged runs — and an incomplete fixture is not one of them: it lowers neither rate, and the report states the arm's attempts and its incomplete fixtures beside the rates. An incomplete run is one the harness's turn cap stopped before a request its probes read existed: the step after the first idle never ran, or an input the runner submitted — the message, a request that step submitted, a switch follow-up or a steer — was not carried by the request of the turn that consumed it. A request carries an input when nothing begins or ends a turn between the consumption and the request's `step/model-start`, and either the request's own model call exists or the call of a request that replaced it in the same turn does. A run its wall clock stopped is a failed run, not an incomplete one, and a run that ended idle is scored for the requests its export holds. An incomplete run is neither a failed nor a judged run: it enters none of its arm's probe rates, does not count toward the floor, and the report lists it with its reason apart from the failed and unjudged runs, so a probe no request could answer is not read as the candidate's loss. A re-asked verdict comes from a longer conversation with the same judge at the same settings, and both arms are re-asked by the same rule. A run is judged through a view of its export: each request is given against the previous request of its line — the messages added since that request, or the whole message list after a history change — and every other field of the request appears in full only when it changed, or as an unchanged marker when it did not, so nothing is dropped. A request's consecutive `step/thinking` deltas are one line carrying their text in order, because a delta line is mostly an event id and field names and the judge reads the run as a whole. The judge reads the view in one call. A view that does not fit the judge's declared window — the window less the reply's `maxTokens` — is not split into parts: a probe that counts, orders or holds over a whole run cannot be answered from one part, so the run is unjudged before any call, and the report gives the estimate and the budget. The estimate is the runner's own and is taken before any call, so a predicted overflow is never asked. A call the provider refuses for a window overflow therefore means the declared window or the estimate was wrong, and it stays a failed run: a refusal is how a run outgrowing its model's real window shows up, and failed runs are compared between the arms. The scenario judge is asked for `present` or `absent`; the verdict parser the scenario and summary evaluations share also accepts `contradicted`, which a `must_not_show` probe treats as not shown. An evaluation whose judge declares no window fails before its first call. +**Failed and unjudged runs.** A failed run is one that ended on an error or its wall-clock budget, or one whose judging did not happen: there was nothing the judge could be asked, or a judge call failed — a window overflow, a transport or an HTTP error, or a reply cut off at its output cap. An unjudged run is one the judge answered but gave no usable verdicts for after two re-asks, or one whose view does not fit the judge's budget, which is never asked: it enters none of its arm's probe rates, and the report counts it and lists it with its reason; the unjudged-run rate compares it. A failed run is out of the probe rates too, and is compared once, as the failed-run rate. Those two rates count the runs an arm had something to compare in — its judged, failed and unjudged runs — and an incomplete fixture is not one of them: it lowers neither rate, and the report states the arm's attempts and its incomplete fixtures beside the rates. An incomplete run is one the harness's turn cap stopped before a request its probes read existed: the step after the first idle never ran, or an input the runner submitted — the message, a request that step submitted, a switch follow-up or a steer — was not carried by the request of the turn that consumed it. A request carries an input when nothing begins or ends a turn between the consumption and the request's `step/model-start`, and either the request's own model call exists or the call of a request that replaced it in the same turn does. A run its wall clock stopped is a failed run, not an incomplete one, and a run that ended idle is scored for the requests its export holds. An incomplete run is neither a failed nor a judged run: it enters none of its arm's probe rates, does not count toward the floor, and the report lists it with its reason apart from the failed and unjudged runs, so a probe no request could answer is not read as the candidate's loss. A re-asked verdict comes from a longer conversation with the same judge at the same settings, and both arms are re-asked by the same rule. A run is judged through a view of its export: each request is given against the previous request of its line — the messages added since that request, or the whole message list after a history change — and every other field of the request appears in full only when it changed, or as an unchanged marker when it did not, so nothing is dropped. A request's consecutive `step/thinking` deltas are one line carrying their text in order, because a delta line is mostly an event id and field names and the judge reads the run as a whole. The judge reads the view in one call. A view that does not fit the judge's declared window — the window less the reply's `maxTokens` — is not split into parts: a probe that counts, orders or holds over a whole run cannot be answered from one part, so the run is unjudged before any call, and the report gives the estimate and the budget. Every run's record states the estimate the fit check took and the judge's budget it compared, so a scenario that sits near the budget is visible before it flips a judgement. The estimate is the runner's own and is taken before any call, so a predicted overflow is never asked. A call the provider refuses for a window overflow therefore means the declared window or the estimate was wrong, and it stays a failed run: a refusal is how a run outgrowing its model's real window shows up, and failed runs are compared between the arms. The scenario judge is asked for `present` or `absent`; the verdict parser the scenario and summary evaluations share also accepts `contradicted`, which a `must_not_show` probe treats as not shown. An evaluation whose judge declares no window fails before its first call. **The candidate runs through the shipped assembly.** It is put in place at its author's factory configuration, as the summary strategy's optional system prompt member specified in [ContextCompaction §13.4](plugins/ContextCompaction.md#134-evaluation) allows a candidate prompt to replace the fixed one — the product profile never sets it — and never by patching strings in an evaluation-only path, so both arms run the shipped request building, chunking and failure handling. diff --git a/xtask/src/scenario_eval.rs b/xtask/src/scenario_eval.rs index fe50de9ebe..4038445270 100644 --- a/xtask/src/scenario_eval.rs +++ b/xtask/src/scenario_eval.rs @@ -1197,6 +1197,8 @@ fn pooled_record(source: &Path, run: SavedRun, scenarios: &[Scenario]) -> Result error: run.error, judge_error: run.judge_error, judge_reasks: run.judge_reasks, + judge_estimate: run.judge_estimate, + judge_budget: run.judge_budget, judge_calls: run.judge_calls, temperature_dropped: run.temperature_dropped, decline_retries: run.decline_retries, @@ -1300,6 +1302,8 @@ async fn rejudge_one( judge_error: judging.error, judge_reasks: judging.reasks, judge_calls: judging.calls, + judge_estimate: judging.fit.map(|(estimate, _)| estimate), + judge_budget: judging.fit.map(|(_, budget)| budget), temperature_dropped: Some(judging.temperature_dropped), decline_retries: saved.decline_retries, switch_retries: saved.switch_retries, @@ -1341,6 +1345,10 @@ struct SavedRun { #[serde(default)] judge_reasks: u32, #[serde(default)] + judge_estimate: Option, + #[serde(default)] + judge_budget: Option, + #[serde(default)] judge_calls: Vec, /// The texts the arm was given; empty in a record written before the /// runner recorded them. @@ -2856,6 +2864,13 @@ struct RunRecord { /// How many times the judge was asked again for an answer it could not /// use. judge_reasks: u32, + /// The view's estimate against the judge's budget the fit check compared; + /// `None` when no view reached the judge, and in records written before + /// the runner recorded them. + #[serde(default)] + judge_estimate: Option, + #[serde(default)] + judge_budget: Option, /// One entry per judge call the run made, in order: what its stream /// reported. judge_calls: Vec, @@ -3200,6 +3215,12 @@ struct ChildOutcome { /// The judge's declared window and output cap: `(0, 0)` when the child /// never resolved them, as a run the parent killed has not. judge_window: (u64, u64), + /// The view's estimate and the judge's budget the fit check compared; + /// absent in an outcome written before the child recorded them. + #[serde(default)] + judge_estimate: Option, + #[serde(default)] + judge_budget: Option, } /// The child outcome of a run the harness aborted. @@ -3230,6 +3251,8 @@ fn harness_outcome(error: String, preflight: Vec) -> ChildOutcom model_configuration: None, judge_configuration: None, judge_window: (0, 0), + judge_estimate: None, + judge_budget: None, } } @@ -3800,6 +3823,8 @@ async fn child_drive( model_configuration: carried_parts(&instrument_configuration(&model)), judge_configuration: carried_parts(&instrument_configuration(&judge)), judge_window: (limits.window, limits.max_output), + judge_estimate: judging.fit.map(|(estimate, _)| estimate), + judge_budget: judging.fit.map(|(_, budget)| budget), }) } @@ -5383,6 +5408,8 @@ fn supervisor_outcome( model_configuration: None, judge_configuration: None, judge_window: (0, 0), + judge_estimate: None, + judge_budget: None, } } @@ -5740,6 +5767,8 @@ fn child_record( judge_error: outcome.judge_error.clone(), judge_reasks: outcome.judge_reasks, + judge_estimate: outcome.judge_estimate, + judge_budget: outcome.judge_budget, judge_calls: outcome.judge_calls.clone(), temperature_dropped: Some(outcome.temperature_dropped), decline_retries: Some(outcome.decline_retries), @@ -5839,6 +5868,10 @@ struct Judging { calls: Vec, /// Whether the judge had to drop its temperature. temperature_dropped: bool, + /// The view's estimate and the judge's budget the fit check compared, + /// when a view reached the judge: `None` for a run that never produced + /// one (model-prompts §8.1). + fit: Option<(f64, f64)>, } impl Judging { /// A run the judge was never asked about: it left no export, the profile @@ -5852,6 +5885,7 @@ impl Judging { reasks: 0, calls: Vec::new(), temperature_dropped: false, + fit: None, } } /// A timed-out run whose judge did not answer within its cleanup grace: @@ -5864,6 +5898,7 @@ impl Judging { reasks: 0, calls: Vec::new(), temperature_dropped: false, + fit: None, } } /// A run the harness stopped before a request its probes read existed: @@ -5878,6 +5913,7 @@ impl Judging { reasks: 0, calls: Vec::new(), temperature_dropped: false, + fit: None, } } } @@ -9024,6 +9060,7 @@ async fn judge_export( let facts = window_facts(limits.window, allowance, &whole); let estimate = facts.count_tokens(&whole); let budget = facts.context_window() - facts.output_tokens(); + let fit = Some((estimate, budget)); if estimate > budget { return Judging { outcome: JudgeOutcome::Unfit, @@ -9034,6 +9071,7 @@ async fn judge_export( reasks: 0, calls: Vec::new(), temperature_dropped: false, + fit, }; } let (outcome, probes, error) = loop { @@ -9117,6 +9155,7 @@ async fn judge_export( reasks, calls, temperature_dropped: dropped, + fit, } } @@ -9848,6 +9887,8 @@ mod tests { error: None, judge_error: None, judge_reasks: 0, + judge_estimate: None, + judge_budget: None, judge_calls: Vec::new(), temperature_dropped: Some(false), decline_retries: Some(0), @@ -17197,24 +17238,24 @@ mod tests { assert_eq!(records.len(), 4, "one run per arm and scenario"); for record in &records { assert_eq!(record["failed"], false, "{record}"); + let estimate = record["judgeEstimate"].as_f64().unwrap(); + let budget = record["judgeBudget"].as_f64().unwrap(); if record["scenario"] == "case" { assert_eq!(record["judgeOutcome"], "judged", "{record}"); assert_eq!(record["probes"][0]["verdict"], "present", "{record}"); + assert!( + budget - estimate > 4_000., + "the judged view keeps headroom under the judge's budget: {record}" + ); } else { assert_eq!(record["judgeOutcome"], "unfit", "{record}"); assert_eq!(record["probes"][0]["verdict"], "unparsed", "{record}"); let error = record["judgeError"].as_str().unwrap(); assert!(error.starts_with("the judge view needs about "), "{error}"); assert!(error.contains(" tokens; the judge's budget is "), "{error}"); - let numbers = error - .split(|character: char| !character.is_ascii_digit() && character != '.') - .filter(|part| !part.is_empty()) - .map(|part| part.parse::().unwrap()) - .collect::>(); - assert_eq!(numbers.len(), 2, "{error}"); assert!( - numbers[0] - numbers[1] > 4_000., - "the overgrown view clears the judge's budget with room to spare: {error}" + estimate - budget > 4_000., + "the overgrown view clears the judge's budget with room to spare: {record}" ); } } From 760c89d8c2f34a0ad5af57f5e10c8ed04b3974cb Mon Sep 17 00:00:00 2001 From: scotares Date: Fri, 27 Nov 2026 14:16:15 +0800 Subject: [PATCH 2/4] fix(xtask): keep a timed-out judge's fit in the run record MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The phase budget and the cleanup grace replace the judging with `Judging::unfinished`, which dropped the estimate and budget the fit check had already taken. A run that reached the check and then timed out therefore read like one that never did, which is the distinction the record exists to carry. `judge_export` hands the pair back through a slot as soon as it takes it, and both timeout paths attach it to the unfinished judging. A new flow holds the judge past a 200 ms phase budget: the record keeps the pair beside `call_failed`, while a run that never reached the check still records none. model-prompts §8.1 states the distinction. --- docs/design/model-prompts.md | 2 +- xtask/src/scenario_eval.rs | 74 +++++++++++++++++++++++++++++++----- 2 files changed, 65 insertions(+), 11 deletions(-) diff --git a/docs/design/model-prompts.md b/docs/design/model-prompts.md index 8499288800..0cc4a0bb47 100644 --- a/docs/design/model-prompts.md +++ b/docs/design/model-prompts.md @@ -165,7 +165,7 @@ A probe's rate counts judged, non-failed runs only, and failed runs are compared The last row is the rule's limit at the floor: catching that loss 80% of the time needs about 44–51 runs per scenario per arm. The report therefore prints both arms' counts, both rates, the loss, the p-value and the Holm threshold for every comparison, so a reader sees a loss the rule did not flag as well as one it did. The measured table resamples whole runs, which keeps each run's probes together. The pooled rows do not: they count each probe of each run as an observation, and the probes of one run share a transcript, so those p-values are optimistic. That errs toward rejecting, which means failing a candidate, and the per-probe rows compare one probe over whole runs. -**Failed and unjudged runs.** A failed run is one that ended on an error or its wall-clock budget, or one whose judging did not happen: there was nothing the judge could be asked, or a judge call failed — a window overflow, a transport or an HTTP error, or a reply cut off at its output cap. An unjudged run is one the judge answered but gave no usable verdicts for after two re-asks, or one whose view does not fit the judge's budget, which is never asked: it enters none of its arm's probe rates, and the report counts it and lists it with its reason; the unjudged-run rate compares it. A failed run is out of the probe rates too, and is compared once, as the failed-run rate. Those two rates count the runs an arm had something to compare in — its judged, failed and unjudged runs — and an incomplete fixture is not one of them: it lowers neither rate, and the report states the arm's attempts and its incomplete fixtures beside the rates. An incomplete run is one the harness's turn cap stopped before a request its probes read existed: the step after the first idle never ran, or an input the runner submitted — the message, a request that step submitted, a switch follow-up or a steer — was not carried by the request of the turn that consumed it. A request carries an input when nothing begins or ends a turn between the consumption and the request's `step/model-start`, and either the request's own model call exists or the call of a request that replaced it in the same turn does. A run its wall clock stopped is a failed run, not an incomplete one, and a run that ended idle is scored for the requests its export holds. An incomplete run is neither a failed nor a judged run: it enters none of its arm's probe rates, does not count toward the floor, and the report lists it with its reason apart from the failed and unjudged runs, so a probe no request could answer is not read as the candidate's loss. A re-asked verdict comes from a longer conversation with the same judge at the same settings, and both arms are re-asked by the same rule. A run is judged through a view of its export: each request is given against the previous request of its line — the messages added since that request, or the whole message list after a history change — and every other field of the request appears in full only when it changed, or as an unchanged marker when it did not, so nothing is dropped. A request's consecutive `step/thinking` deltas are one line carrying their text in order, because a delta line is mostly an event id and field names and the judge reads the run as a whole. The judge reads the view in one call. A view that does not fit the judge's declared window — the window less the reply's `maxTokens` — is not split into parts: a probe that counts, orders or holds over a whole run cannot be answered from one part, so the run is unjudged before any call, and the report gives the estimate and the budget. Every run's record states the estimate the fit check took and the judge's budget it compared, so a scenario that sits near the budget is visible before it flips a judgement. The estimate is the runner's own and is taken before any call, so a predicted overflow is never asked. A call the provider refuses for a window overflow therefore means the declared window or the estimate was wrong, and it stays a failed run: a refusal is how a run outgrowing its model's real window shows up, and failed runs are compared between the arms. The scenario judge is asked for `present` or `absent`; the verdict parser the scenario and summary evaluations share also accepts `contradicted`, which a `must_not_show` probe treats as not shown. An evaluation whose judge declares no window fails before its first call. +**Failed and unjudged runs.** A failed run is one that ended on an error or its wall-clock budget, or one whose judging did not happen: there was nothing the judge could be asked, or a judge call failed — a window overflow, a transport or an HTTP error, or a reply cut off at its output cap. An unjudged run is one the judge answered but gave no usable verdicts for after two re-asks, or one whose view does not fit the judge's budget, which is never asked: it enters none of its arm's probe rates, and the report counts it and lists it with its reason; the unjudged-run rate compares it. A failed run is out of the probe rates too, and is compared once, as the failed-run rate. Those two rates count the runs an arm had something to compare in — its judged, failed and unjudged runs — and an incomplete fixture is not one of them: it lowers neither rate, and the report states the arm's attempts and its incomplete fixtures beside the rates. An incomplete run is one the harness's turn cap stopped before a request its probes read existed: the step after the first idle never ran, or an input the runner submitted — the message, a request that step submitted, a switch follow-up or a steer — was not carried by the request of the turn that consumed it. A request carries an input when nothing begins or ends a turn between the consumption and the request's `step/model-start`, and either the request's own model call exists or the call of a request that replaced it in the same turn does. A run its wall clock stopped is a failed run, not an incomplete one, and a run that ended idle is scored for the requests its export holds. An incomplete run is neither a failed nor a judged run: it enters none of its arm's probe rates, does not count toward the floor, and the report lists it with its reason apart from the failed and unjudged runs, so a probe no request could answer is not read as the candidate's loss. A re-asked verdict comes from a longer conversation with the same judge at the same settings, and both arms are re-asked by the same rule. A run is judged through a view of its export: each request is given against the previous request of its line — the messages added since that request, or the whole message list after a history change — and every other field of the request appears in full only when it changed, or as an unchanged marker when it did not, so nothing is dropped. A request's consecutive `step/thinking` deltas are one line carrying their text in order, because a delta line is mostly an event id and field names and the judge reads the run as a whole. The judge reads the view in one call. A view that does not fit the judge's declared window — the window less the reply's `maxTokens` — is not split into parts: a probe that counts, orders or holds over a whole run cannot be answered from one part, so the run is unjudged before any call, and the report gives the estimate and the budget. Every run's record states the estimate the fit check took and the judge's budget it compared, so a scenario that sits near the budget is visible before it flips a judgement. A run whose judging ended on a timeout keeps the pair when it reached the check; a run that never reached it, and a record written before the runner recorded the pair, states none. The estimate is the runner's own and is taken before any call, so a predicted overflow is never asked. A call the provider refuses for a window overflow therefore means the declared window or the estimate was wrong, and it stays a failed run: a refusal is how a run outgrowing its model's real window shows up, and failed runs are compared between the arms. The scenario judge is asked for `present` or `absent`; the verdict parser the scenario and summary evaluations share also accepts `contradicted`, which a `must_not_show` probe treats as not shown. An evaluation whose judge declares no window fails before its first call. **The candidate runs through the shipped assembly.** It is put in place at its author's factory configuration, as the summary strategy's optional system prompt member specified in [ContextCompaction §13.4](plugins/ContextCompaction.md#134-evaluation) allows a candidate prompt to replace the fixed one — the product profile never sets it — and never by patching strings in an evaluation-only path, so both arms run the shipped request building, chunking and failure handling. diff --git a/xtask/src/scenario_eval.rs b/xtask/src/scenario_eval.rs index 4038445270..c9b4732fe5 100644 --- a/xtask/src/scenario_eval.rs +++ b/xtask/src/scenario_eval.rs @@ -1282,7 +1282,11 @@ async fn rejudge_one( .join(format!("run-{}.judge-view.jsonl", saved.run)); let view = std::fs::read_to_string(&path) .map_err(|error| format!("{}: {error}", path.display()))?; - judge_export(host, resolver, judge, scenario, &view, limits, cancel).await + let mut fit = None; + judge_export( + host, resolver, judge, scenario, &view, limits, cancel, &mut fit, + ) + .await }; let stop = stop_name(&saved.stop)?; Ok(RunRecord { @@ -5888,9 +5892,10 @@ impl Judging { fit: None, } } - /// A timed-out run whose judge did not answer within its cleanup grace: - /// the call is recorded as failed, and every probe stays unparsed. - fn unfinished(scenario: &Scenario, error: String) -> Self { + /// A timed-out run whose judge did not answer within its grace: the call + /// is recorded as failed, every probe stays unparsed, and the fit the run + /// took before its first call is kept when it reached the check. + fn unfinished(scenario: &Scenario, error: String, fit: Option<(f64, f64)>) -> Self { Self { outcome: JudgeOutcome::CallFailed, probes: unparsed(scenario), @@ -5898,7 +5903,7 @@ impl Judging { reasks: 0, calls: Vec::new(), temperature_dropped: false, - fit: None, + fit, } } /// A run the harness stopped before a request its probes read existed: @@ -6140,10 +6145,13 @@ async fn drive_once( // answered by the deadline leaves the run's judgment unfinished instead of // holding the child — and the worker that runs it — open. A run that did // not stop on its wall clock judges as before. + let mut fit = None; let judging = if let Some(deadline) = driven.cleanup_deadline { match tokio::time::timeout_at( deadline, - judge_export(&host, &resolver, judge, scenario, &view, limits, cancel), + judge_export( + &host, &resolver, judge, scenario, &view, limits, cancel, &mut fit, + ), ) .await { @@ -6153,6 +6161,7 @@ async fn drive_once( "the judge did not finish within the cleanup grace after the run stopped on \ its wall clock" .to_owned(), + fit, ), } } else { @@ -6164,7 +6173,9 @@ async fn drive_once( let budget = judge_phase_budget(settings.judge_budget_ms); match tokio::time::timeout( budget, - judge_export(&host, &resolver, judge, scenario, &view, limits, cancel), + judge_export( + &host, &resolver, judge, scenario, &view, limits, cancel, &mut fit, + ), ) .await { @@ -6175,6 +6186,7 @@ async fn drive_once( "the judge did not finish within its phase budget of {}s", budget.as_secs_f64() ), + fit, ), } }; @@ -9036,6 +9048,7 @@ async fn judge_export( view: &str, limits: JudgeWindow, cancel: &CancellationToken, + fit: &mut Option<(f64, f64)>, ) -> Judging { let statements = scenario .probes @@ -9060,7 +9073,8 @@ async fn judge_export( let facts = window_facts(limits.window, allowance, &whole); let estimate = facts.count_tokens(&whole); let budget = facts.context_window() - facts.output_tokens(); - let fit = Some((estimate, budget)); + let pair = Some((estimate, budget)); + *fit = pair; if estimate > budget { return Judging { outcome: JudgeOutcome::Unfit, @@ -9071,7 +9085,7 @@ async fn judge_export( reasks: 0, calls: Vec::new(), temperature_dropped: false, - fit, + fit: pair, }; } let (outcome, probes, error) = loop { @@ -9155,7 +9169,7 @@ async fn judge_export( reasks, calls, temperature_dropped: dropped, - fit, + fit: pair, } } @@ -15013,6 +15027,7 @@ mod tests { max_output: 1_024, }, &CancellationToken::new(), + &mut None, ) .await; assert_eq!( @@ -15136,6 +15151,7 @@ mod tests { max_output: 384_000, }, &CancellationToken::new(), + &mut None, ) .await; assert_eq!( @@ -17290,6 +17306,44 @@ mod tests { ); } + /// A judge that outlives its phase budget records a failed call, and the + /// record keeps the fit the run took before the judge's first call, so it + /// reads apart from a run that never reached the check + /// (model-prompts §8.1). + #[tokio::test(flavor = "multi_thread", worker_threads = 4)] + async fn a_judge_that_outlives_its_budget_keeps_the_fit_it_took() { + let fixture = Fixture::holding( + "judge-timeout", + judged, + |text| { + text.contains("You check statements") + .then_some(Duration::from_secs(60)) + }, + json!({ + "message": "Say hello.", + "budget": {"turns": 4, "seconds": 120, "window": 24000}, + "probes": [{"id": "ran", "kind": "must_show", "text": "the run has a transcript"}] + }), + &[], + 24_000, + ) + .await; + let mut options = fixture.judge_options(fixture.directory.join("out")); + options.judge_budget_ms = Some(200); + fixture.evaluate(&options).await.unwrap(); + let records = fixture.records(&options.out); + assert_eq!(records.len(), 2, "one run per arm"); + for record in &records { + assert_eq!(record["judgeOutcome"], "call_failed", "{record}"); + let estimate = record["judgeEstimate"].as_f64().unwrap(); + let budget = record["judgeBudget"].as_f64().unwrap(); + assert!( + estimate < budget, + "the view fitted the judge before its first call: {record}" + ); + } + } + /// A run offers the shipped assembly's whole tool catalog — the workspace /// tools and Questions, not only the mock profile's three — carries a /// workspace tool's result into its next request (model-prompts §8.1), and From 1b2ba7b73f917ea81c8a0f9d4bf91dfc7acc666f Mon Sep 17 00:00:00 2001 From: scotares Date: Fri, 27 Nov 2026 14:27:15 +0800 Subject: [PATCH 3/4] fix(xtask): state the fit rule the record follows Review follow-up on #2261. `judge_export` needs an expectation for its argument count now that it takes the slot a timeout reads; the argument count error was what made `verify (linux)` fail. The two field comments said `None` when no view reached the judge, which inverts the case the fields exist for: an unfit view never reaches the judge and does carry the pair. Both now state the actual rule, and the re-judge flow pins it: a re-judged run states the fit its new judge took, and a run whose judge was never asked records none. `RunRecord` derives only `Serialize`, so its `#[serde(default)]` attributes had no effect; they are gone. The fit flow also asserts the narrow judge's budget is its declared window less the output cap. --- xtask/src/scenario_eval.rs | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/xtask/src/scenario_eval.rs b/xtask/src/scenario_eval.rs index c9b4732fe5..64e1805311 100644 --- a/xtask/src/scenario_eval.rs +++ b/xtask/src/scenario_eval.rs @@ -2868,12 +2868,11 @@ struct RunRecord { /// How many times the judge was asked again for an answer it could not /// use. judge_reasks: u32, - /// The view's estimate against the judge's budget the fit check compared; - /// `None` when no view reached the judge, and in records written before - /// the runner recorded them. - #[serde(default)] + /// The view's estimate against the judge's budget the fit check compared: + /// present when the check ran — judged, unreadable, a failed call, or + /// unfit — and `None` when no view was built, the judge was not resolved, + /// the run is incomplete, or the judge phase did not finish in time. judge_estimate: Option, - #[serde(default)] judge_budget: Option, /// One entry per judge call the run made, in order: what its stream /// reported. @@ -5873,8 +5872,9 @@ struct Judging { /// Whether the judge had to drop its temperature. temperature_dropped: bool, /// The view's estimate and the judge's budget the fit check compared, - /// when a view reached the judge: `None` for a run that never produced - /// one (model-prompts §8.1). + /// once the check has run — including a run it left unfit, and a judge + /// phase that then timed out (model-prompts §8.1). `None` before the + /// check, or when there was no view to check. fit: Option<(f64, f64)>, } impl Judging { @@ -9040,6 +9040,11 @@ async fn judge_window( /// probe without one, is asked again with what was wrong, at most [`REASKS`] /// times; a call that fails during a re-ask ends the asking. An answer that /// stays unusable leaves every probe `unparsed` (model-prompts §8.1). +#[expect( + clippy::too_many_arguments, + reason = "one parameter per part of one run's judging, plus the slot a timeout \ + reads so it can keep the fit the check took" +)] async fn judge_export( host: &Arc, resolver: &Arc, @@ -15530,6 +15535,18 @@ mod tests { "a re-judged run keeps the count its source recorded: {}", records[1] ); + for record in &records[..2] { + assert!( + record["judgeEstimate"].is_f64() && record["judgeBudget"].is_f64(), + "a re-judged run states the fit its new judge took: {record}" + ); + } + assert_eq!( + records[2]["judgeEstimate"], + Value::Null, + "a run whose judge was never asked records no fit: {}", + records[2] + ); assert_eq!( previously_unjudged["arm"], "current", "{previously_unjudged}" @@ -17256,6 +17273,10 @@ mod tests { assert_eq!(record["failed"], false, "{record}"); let estimate = record["judgeEstimate"].as_f64().unwrap(); let budget = record["judgeBudget"].as_f64().unwrap(); + assert_eq!( + budget, 39_800., + "the judge's budget is its declared window less its output cap" + ); if record["scenario"] == "case" { assert_eq!(record["judgeOutcome"], "judged", "{record}"); assert_eq!(record["probes"][0]["verdict"], "present", "{record}"); From 152ac692f7527dd1d29e16f96fa01ce0b5bbde6a Mon Sep 17 00:00:00 2001 From: scotares Date: Fri, 27 Nov 2026 14:40:01 +0800 Subject: [PATCH 4/4] docs(xtask): state what a timed-out judge records The record's field comment still said a judge phase that does not finish records none, while both timeout arms keep the pair once the fit check ran. It now says a phase that timed out after the check keeps it, and only a phase that timed out before the check records none. --- xtask/src/scenario_eval.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xtask/src/scenario_eval.rs b/xtask/src/scenario_eval.rs index 64e1805311..43a3584795 100644 --- a/xtask/src/scenario_eval.rs +++ b/xtask/src/scenario_eval.rs @@ -2869,9 +2869,10 @@ struct RunRecord { /// use. judge_reasks: u32, /// The view's estimate against the judge's budget the fit check compared: - /// present when the check ran — judged, unreadable, a failed call, or - /// unfit — and `None` when no view was built, the judge was not resolved, - /// the run is incomplete, or the judge phase did not finish in time. + /// present when the check ran — judged, unreadable, a failed call, unfit, + /// or a judge phase that timed out after it — and `None` when no view was + /// built, the judge was not resolved, the run is incomplete, or the judge + /// phase timed out before the check ran. judge_estimate: Option, judge_budget: Option, /// One entry per judge call the run made, in order: what its stream