Repository navigation
feat(retrieval): add region and validity scope filters with asof, compiled apart from authorization - #24
Merged
Conversation
…piled apart from authorization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Milestone item 2.3. Region and validity are scope: they decide which documents apply to a query, not who may read them. Open question Q11 blocked this item, because it was undecided what
asOfselects. This PR records that decision as ADR-0005 and implements the scope filters.ADR-0005: what
asOfmeansasOffilters the current version of each document by its validity window. It never selects an older version, and authorization always uses the labels of the current version. A question about the past is answered by publishing the superseded policy as its own document with a closed validity window.Selecting historical versions is deferred. It would need rules for which version wins, for labels as they were at the time, for retention of replaced versions, and an evaluation oracle. A mistake in any of them would return content under the wrong labels, which is a leak.
Scope in the query
asOfdefaults to the time of the request, and the region defaults to the principal'sregionclaim. A document without regions applies everywhere. A principal without a region gets no region filter.Contract
includeOutOfScopedrops the scope condition and never the predicate. The evaluation needs it to compare everything a principal is authorized for with its hand-labelled visible set.V6adds the three columns todocument_versionand to queued job documents.How it is verified
asOfnot bringing back a replaced version, and scope never widening authorization.Evaluation impact
None on the metrics, as expected: the demo corpus has no regions or validity windows yet. The CI evaluation run of this PR has zero security violations and the same metric values as the published v2 report.
Of the 432 ranked lists, 430 are identical to the report. The other two are
dense-onlylists in which two adjacent candidates with near-equal scores swapped places at ranks 7 to 10, with no effect on any metric. All sparse, hybrid and BM25 lists are identical. The scope condition cannot reorder ties, so this is the known sensitivity of near-tied dense scores to the CPU the embeddings were computed on. It had been documented between arm64 and x86_64, and it now appears between two hosted x86_64 runners as well. A follow-up records the CPU model inrun.jsonand updates the reproducibility note.Scope cases (
as_of,region) and separate reporting of scope failures arrive with the next dataset version, together with the documents that exercise them.背景
里程碑的 2.3 项。region 和有效期属于适用范围:它们决定哪些文档适用于一次查询,而不决定谁可以读。这一项此前被开放问题 Q11 卡住,因为
asOf到底选中什么还没有定论。本 PR 把这个决定记录为 ADR-0005,并实现了范围过滤。ADR-0005:
asOf的含义asOf按有效期过滤每篇文档的当前版本。它不会选出更早的版本,授权始终使用当前版本的标签。要回答关于过去的问题,做法是把被取代的制度作为一篇独立的文档发布,并给它一个封闭的有效期。选取历史版本这件事推后处理。它需要一系列规则:多个版本并存时取哪个、按当时的标签还是现在的标签判断权限、旧版本保留多久,以及一个评测用的参考答案。其中任何一条出错,都会让内容在错误的标签下被返回,那就是泄漏。
查询里的范围条件
SQL 的变化见英文部分的 diff。
asOf默认是请求发生的时间,region 默认取身份 token 里的region。没有标注 region 的文档适用于所有地区。没有 region 的身份不做地区过滤。契约
接口的变化见英文部分的代码块。
includeOutOfScope只去掉范围条件,不会去掉授权谓词。评测需要它,才能把一个身份被授权的全部内容和人工标注的可见集合做比较。V6给document_version和排队中的任务文档加上了这三列。如何验证
asOf不会带回已被替换的版本,以及范围条件不会放宽授权。对评测的影响
指标没有变化,这符合预期:demo 语料还没有 region 和有效期。本 PR 的 CI 评测越权结果为 0,各项指标与已发布的 v2 报告相同。
432 个排序列表里有 430 个与报告完全一致。另外 2 个是
dense-only的列表:两个得分几乎相同的相邻候选在第 7 到第 10 名之间互换了位置,对任何指标都没有影响。sparse、hybrid 和 BM25 的列表全部一致。范围条件不可能改变并列候选的顺序,所以这是已知的现象:得分接近的 dense 结果对计算向量的 CPU 敏感。之前记录的是 arm64 和 x86_64 之间的差异,现在在两台托管的 x86_64 runner 之间也出现了。后续会在run.json里记录 CPU 型号,并更新可复现性的说明。带
as_of和region的范围用例,以及范围失败的单独统计,会随下一个数据集版本和对应的文档一起加入。