1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! The retrieval policy: who the result is for, and what that means for a
//! contract whose computed schema state is `Stale`.
//!
//! This is the single place that decides whether a computed-stale contract
//! reaches the caller. Three model-facing call sites — prompt recall,
//! `contract_search`, `contract_read` — all pass [`RetrievalPolicy::ForModel`]
//! and so drop a contract whose claims aggregate to `Stale`. The human-review
//! sites — `contracts list`/`show`/`queue`, import reporting — pass
//! [`RetrievalPolicy::ForHumanReview`] and keep stale contracts, their
//! fingerprints and the reason they are stale, because that *is* the point of a
//! review path.
//!
//! Only *computed* `Stale` is excluded here. A claim whose persisted status is
//! already `Stale` never reaches this layer — `is_recallable` excluded it in
//! selection. `NeedsReview` is **not** excluded: if it were, one unrelated
//! column added to a wide table would silently mute every claim on that table,
//! and `Stale` and `NeedsReview` would stop meaning different things.
//! `LiveSchemaUnavailable` is not excluded either — "could not read the schema"
//! is not "a column is gone", and hiding it would let an unreadable cache pass
//! as an empty memory.
use crate;
/// Who a retrieval's result is for. See the module docs for the contract.
pub
/// Drops computed-`Stale` contracts from `contracts` when `policy` is
/// [`RetrievalPolicy::ForModel`], counting each dropped contract in
/// `diag.excluded_by_schema` so the exclusion is observable. `ForHumanReview`
/// returns `contracts` untouched.
///
/// Called once per retrieval path (`recall`, `show`) so every model-facing call
/// site gets the same rule without re-implementing it — the shared-operation
/// rule this bug violated.
pub