KU-K1 review: peek the reachability slot, MultiSource forwards last_failure

record_last_failure_transport now reads LAST_DECODE_REACHABILITY.with(|c|
c.get()) directly instead of take_last_decode_reachability(), so it no longer
erases the slot freemkv-library's server reads after resolve
(server/ripper/mod.rs:505, :1361) to avoid a second key-service call. Green:
the regression test now finds the verdict still in the slot after
get_unit_keys/get_fmts_indexes. MultiSource::last_failure_was_transport
forwards any(inner), matching answer_depends_on_samples (KU3-6).
This commit is contained in:
Matthew Jackson
2026-09-28 04:19:04 -07:00
parent 4e83b3c1f8
commit ad59f3ce45
2 changed files with 12 additions and 10 deletions
+6
View File
@@ -155,6 +155,12 @@ impl KeySource for MultiSource {
fn answer_depends_on_samples(&self) -> bool {
self.sources.iter().any(|s| s.answer_depends_on_samples())
}
// Same `any(inner)` rule (KU-K1 review): `resolve` retries the composition
// whenever any inner source's last failure was transport-class.
fn last_failure_was_transport(&self) -> bool {
self.sources.iter().any(|s| s.last_failure_was_transport())
}
}
#[cfg(test)]
+6 -10
View File
@@ -753,15 +753,12 @@ impl OnlineSource {
run_on_worker(&host, halt, move || job.run())
}
// KU-K1 (J15): classify the query just finished. A success resets it; a
// failure is transport-class only when its `DecodeReachability` says so —
// an HTTP answer (a 5xx included) is never transport-class.
// KU-K1 (J15): classify the query just finished, from a PEEK (never a
// `take`) at the slot — a caller downstream of `resolve` (freemkv-library's
// server) still needs to read the same verdict once (`query_with` clears it).
fn record_last_failure_transport(&self, result: &Result<Vec<UnitKey>, Error>) {
let transport = result.is_err()
&& matches!(
take_last_decode_reachability(),
Some(DecodeReachability::Transport)
);
&& LAST_DECODE_REACHABILITY.with(|c| c.get()) == Some(DecodeReachability::Transport);
self.last_failure_transport
.store(transport, Ordering::Relaxed);
}
@@ -2945,9 +2942,8 @@ mod tests {
}
// Regression: freemkv-library's server takes the reachability slot itself
// (`take_online_decode_reachability`) after `resolve`, to classify a no-key
// without a second probe. `last_failure_was_transport` must PEEK, not TAKE,
// or the server sees `None` and re-asks the service — never call it twice.
// after `resolve`, to classify a no-key without a second probe.
// `last_failure_was_transport` must PEEK it, not TAKE it (never ask twice).
#[test]
fn recording_last_failure_does_not_erase_the_reachability_slot() {
let addr = stub_server(Stub::Answer(422));