Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions docs/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,49 @@ retrievals require separate evidence. Review query text and paths before sharing
distinct hit refs across searches, and distinct refs with supported use.
Later reads are separate events. File paths, qualified CLI refs and
versioned Indexer entries keep their recorded identities.
- `adoption` splits `used` by the observation that its use evidence cites.
Each part has its own denominator. `search_hits.adopted /
search_hits.unique_hits` counts distinct search-hit refs with supported use
over distinct hit refs. `direct_reads.adopted / direct_reads.read_only`
counts refs with an observed read at a revision that no search in the
round returned. A direct read is not search conversion. A trace command
records its own read. A capture's explicit-ID selection counts as a read
only when its return of that ref was observed. Otherwise the ref is counted
under `unverified_reads.adopted / unverified_reads.refs`, which has no state
or rate. This applies even when a search returned the same revision; the
hit stays in the search-hit denominator. An observed read is a read of a
hit of the same ref when it records that hit's revision, or when neither
the read nor any hit of the ref records a revision, as in a file trace.
It is a direct read when every hit of the ref records a revision and none
is the read's. Otherwise only one side records a revision, as when an
unversioned CLI Find is followed by a versioned Read. Such a read is
neither the hit's read nor a direct read. The hit stays in the search-hit
denominator and the read joins no denominator. `other_adopted`
counts adopted refs seen only through other
operations, such as an inventory, and has no denominator. Use evidence
is bound to the event it names: an archive review's `event_id`, an
optimization log's capture `context_id`, or the observations before a
caller-reviewed decision line. Evidence without such a locator matches
every observation of the ref. Evidence whose locator names no
observation of the ref counts under `attribution_unknown`. An observed
hit or delivered read outranks an
unverified read, which outranks other operations. If the cited
observations include both a search hit and a direct read, or include a
read whose revision relation to the hits is unknown, the ref
counts under `attribution_unknown` and is credited to neither. All
counts are deduplicated by ref. One ref can appear in more than one
denominator when the round observed different revisions of it. Use is
recorded per ref, not per revision.
`unique_hit_revisions` counts distinct `(ref, revision)` pairs among
search hits. It is null when coverage is not complete or any hit has no
recorded revision; `rg` hits carry none. The `state` of the search-hit
and direct-read parts is `unknown` when coverage is not complete or
`attribution_unknown` is nonzero, `not_applicable` when its denominator is
zero, and otherwise `complete`. The record stores no rate. The
dashboard derives a percentage only for a `complete` part, never shows 0%
for a zero denominator, and shows "Not recorded" for earlier records without
this block. These figures are associations; they do not establish causal or
performance credit, and they include no token or cost data.
- Supply `--complete` only when the selected inputs cover every in-scope
retrieval for the round. Otherwise only observed counts are known and
`counts` is null. A complete round without a search has zero searches.
Expand Down
27 changes: 25 additions & 2 deletions docs/examples/dashboard-profile-review.html

Large diffs are not rendered by default.

25 changes: 24 additions & 1 deletion src/inferrsi/apps/views/knowledge_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
const el=(tag,text)=>{const n=document.createElement(tag);if(text!=null)n.textContent=String(text);return n;};
const tr=(en,zh)=>getLanguage()==='zh'?zh:en;
const unknown=()=>tr('Not recorded','未记录');
const words={applied:['Ranking applied','已执行排序'],explicit_ids:['Explicit IDs · caller order','显式 ID · 调用者顺序'],not_requested:['Not requested','未请求'],performed:['Performed','已执行'],unknown:['Unknown','未知'],not_recorded:['Not recorded','未记录'],recorded:['Recorded','已记录'],linked:['Linked','已关联'],used:['Used','采用'],rejected:['Rejected','舍弃'],used_and_rejected:['Used and rejected','采用且舍弃'],local_v1:['Local v1 evidence','本地 v1 依据'],archive_reviewed:['Archive-reviewed association','存档 review 关联'],complete:['Complete','完整'],partial:['Partial','部分'],missing:['Missing','缺失'],context_limit:['Context budget','上下文预算'],output_limit:['Output limit','输出限制'],unsupported_context:['Unsupported assembly','不支持装配'],visible:['Visible return recorded','已记录可见返回'],ref_visible:['Reference visible','引用可见']};
const words={applied:['Ranking applied','已执行排序'],explicit_ids:['Explicit IDs · caller order','显式 ID · 调用者顺序'],not_requested:['Not requested','未请求'],performed:['Performed','已执行'],unknown:['Unknown','未知'],not_recorded:['Not recorded','未记录'],recorded:['Recorded','已记录'],linked:['Linked','已关联'],used:['Used','采用'],rejected:['Rejected','舍弃'],used_and_rejected:['Used and rejected','采用且舍弃'],local_v1:['Local v1 evidence','本地 v1 依据'],archive_reviewed:['Archive-reviewed association','存档 review 关联'],complete:['Complete','完整'],partial:['Partial','部分'],missing:['Missing','缺失'],context_limit:['Context budget','上下文预算'],output_limit:['Output limit','输出限制'],unsupported_context:['Unsupported assembly','不支持装配'],visible:['Visible return recorded','已记录可见返回'],ref_visible:['Reference visible','引用可见'],not_applicable:['Not applicable','不适用']};
const label=x=>words[x]?tr(...words[x]):x??unknown();
const json=x=>JSON.stringify(x,null,2);
let selected=null,round='',initial=true;
Expand Down Expand Up @@ -110,13 +110,36 @@
links(b,c.links,scope+':'+c.context_id);
});
}
function adoption(box,s){
const a=s.adoption,complete=s.coverage==='complete';
const gap=()=>!a?unknown():tr('Unknown (incomplete capture)','未知(采集不完整)');
// A rate is derived only for a complete round with a nonzero denominator.
const ratio=(part,den)=>{
if(a&&complete&&part?.state==='unknown'&&a.attribution_unknown>0)return tr('Unknown (attribution ambiguous)','未知(归属不明确)');
if(!a||part?.state==='unknown')return gap();
if(part.state==='not_applicable')return tr('Not applicable (zero denominator)','不适用(分母为零)');
const n=part.adopted,d=part[den],pct=n===d?100:Math.min(99.9,Math.round(1000*n/d)/10);
return n+' / '+d+' ('+pct+'%)';
};
const versions=!a||!complete?gap():a.unique_hit_revisions==null?tr('Unknown (a hit has no recorded revision)','未知(存在未记录版本的命中)'):a.unique_hit_revisions;
table(box,[tr('Adoption measure','采用口径'),tr('Value','数值'),tr('Definition','定义')],[
[tr('Search-hit adoption','检索命中采用'),ratio(a?.search_hits,'unique_hits'),tr('Distinct search-hit refs with recorded use evidence / distinct refs returned by a search in this round.','有采用依据的去重检索命中条目 / 本轮检索返回的去重条目。')],
[tr('Direct-read adoption','直接读取采用'),ratio(a?.direct_reads,'read_only'),tr('Distinct refs with an observed read at a revision no search returned in this round, whose use evidence cites that read / those refs. A capture read counts only when its return of the ref was observed. Not search conversion.','本轮在检索未返回的版本上有已观测读取的去重条目中,采用依据指向该读取者 / 此类条目。捕获中的读取仅在观测到该条目返回时计入。不计为检索转化。')],
[tr('Reads without observed delivery (no rate)','未观测送达的读取(无比率)'),!a||!complete?gap():tr('Refs: ','条目:')+a.unverified_reads.refs+' · '+tr('with use evidence: ','有采用依据:')+a.unverified_reads.adopted,tr('Distinct refs selected by explicit ID in a capture whose return of the ref was not observed (prepared only or delivery unknown). Not counted as reads.','在捕获中按显式 ID 选取、但未观测到该条目返回的去重条目(仅准备或送达未知)。不计为读取。')],
[tr('Other adopted (no denominator)','其他采用(无分母)'),!a||!complete?gap():a.other_adopted,tr('Adopted refs observed only by other operations, such as an inventory. No rate is shown.','仅由其他操作(如清单列举)观测到的采用条目。不计算比率。')],
[tr('Attribution unknown (no denominator)','归属未知(无分母)'),!a||!complete?gap():a.attribution_unknown,tr('Adopted refs whose use evidence cannot be credited to one observation: it cites both a search hit and a direct read, names an event that did not observe the ref, or cites a read whose revision cannot be matched to a hit because only one side records a revision. While nonzero, both rates are unknown.','采用依据无法归于单一观测的条目:同时指向检索命中与直接读取、所指事件未观测到该条目,或所指读取因仅一方记录版本而无法与命中匹配。非零时两个比率均为未知。')],
[tr('Unique hit versions (ref, revision)','去重命中版本(条目, 版本)'),versions,tr('Distinct (ref, revision) pairs among search hits. Unknown when any hit lacks a revision.','检索命中中去重的(条目, 版本)对。任一命中缺版本时为未知。')],
]);
p(box,tr('Counts are distinct refs; adoption is recorded per ref, not per revision, and is credited to the observation its use evidence cites. A zero denominator is not applicable rather than 0%. These are associations only: they do not establish causal or performance credit and include no token or cost data.','计数均按去重条目;采用按条目记录而非按版本,并归属于其采用依据所指向的观测。分母为零时为不适用,而非 0%。以上仅为关联,不证明因果或性能收益,也不含 token 或费用数据。'),'kt-note');
}
function search(box,s){
fold(box,'R'+s.round+' · v'+s.schema_version+' · '+label(s.coverage||s.state),s.path,b=>{
p(b,s.path+' · SHA-256 '+(s.sha256||unknown()));
if(s.state!=='recorded'){p(b,label(s.state),'kt-warning');return;}
p(b,s.schema_version===1?tr('Local v1: retained legacy use semantics; not archive-reviewed evidence.','本地 v1:保留旧版使用口径,不属于存档 review 关联。'):tr('Portable v2: declarations and archive-reviewed associations are separate.','可移植 v2:声明与存档 review 关联分开展示。'),'kt-note');
p(b,tr('v1 and v2 are alternative records of this round; counts are not added.','v1/v2 是同轮的不同记录,计数不相加。'),'kt-note');
table(b,[tr('Coverage','覆盖'),tr('Counts','完整计数'),tr('Observed in supplied records','所提供记录中的观测')],[[label(s.coverage),s.counts==null?unknown():json(s.counts),json(s.observed)]]);
adoption(b,s);
for(const issue of s.issues||[])p(b,label(issue),'kt-warning');
for(const id of s.context_ids||[])button(b,tr('Open retrieval · ','打开检索 · ')+id,()=>showCapture(id));
table(b,[tr('Material','条目'),tr('Recorded use','记录的采用状态'),tr('Evidence / declaration','依据 / 声明')],(s.materials||[]).map(m=>{
Expand Down
41 changes: 39 additions & 2 deletions src/inferrsi/apps/views/retrieval_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,39 @@ def _read(root, path):
return None, "invalid_format", None


def _count(value):
return type(value) is int and value >= 0


def _valid_adoption(adoption, coverage, observed):
"""Keep each numerator inside its own denominator; incomplete or ambiguous rounds stay
unknown."""
if not isinstance(adoption, dict) or not all(
_count(adoption.get(key)) for key in ("other_adopted", "attribution_unknown")):
return False
revisions = adoption.get("unique_hit_revisions")
if revisions is not None and (coverage != "complete" or not _count(revisions)):
return False
ambiguous = adoption["attribution_unknown"]
adopted = adoption["other_adopted"] + ambiguous
for key, denominator in (("search_hits", "unique_hits"), ("direct_reads", "read_only"),
("unverified_reads", "refs")):
part = adoption.get(key)
if (not isinstance(part, dict) or not _count(part.get("adopted"))
or not _count(part.get(denominator)) or part["adopted"] > part[denominator]):
return False
# A read without observed delivery has no rate and therefore no state.
expected = (None if key == "unverified_reads" else
"unknown" if coverage != "complete" or ambiguous else
"not_applicable" if part[denominator] == 0 else "complete")
if part.get("state") != expected:
return False
adopted += part["adopted"]
hits = adoption["search_hits"]["unique_hits"]
return (hits == observed["unique_hits"] and adopted == observed["used"]
and (revisions is None or revisions >= hits))


def _validate(record, campaign_id, number, version):
if type(record.get("schema_version")) is not int or record["schema_version"] != version:
return "unsupported_version"
Expand All @@ -118,6 +151,10 @@ def _validate(record, campaign_id, number, version):
return "invalid_counts"
if record["coverage"] != "complete" and record.get("counts") is not None:
return "invalid_counts"
# Records written before the adoption split have no such block.
if "adoption" in record and not _valid_adoption(
record["adoption"], record["coverage"], record["observed"]):
return "invalid_counts"
if any(not isinstance(m, dict) or m.get("use") not in
("unknown", "used", "rejected", "used_and_rejected")
for m in record["materials"].values()):
Expand Down Expand Up @@ -310,8 +347,8 @@ def read_searches(root: Path, campaign_id, rows, retrievals):
declarations.append({**public_value(declaration), "state": declaration_state})
results.append({**view, "state": "recorded", "issues": sorted(set(issues)),
**public_value({k: record.get(k) for k in (
"coverage", "counts", "observed", "context_ids", "corpus",
"unresolved_details")}), "declarations": declarations,
"coverage", "counts", "observed", "adoption", "context_ids",
"corpus", "unresolved_details")}), "declarations": declarations,
"materials": materials, "events": events, "links": links})
return results

Expand Down
Loading
Loading