# -*- coding: utf-8 -*- """Build paper 15's claim ledger, typed honestly. own-data-derived : this bench measured it, and the row names the artefact external-cited : read at primary source, and the row says where assumption : an argument or a design judgement, not a measurement The rule learned from paper 14's retraction: arithmetic over assumed inputs is an assumption however many decimal places it carries, and a row whose source paper types a claim as an assumption cannot be upgraded to external-cited in transit. """ import csv import io import json import os B = (r'C:\xampp\htdocs\playground\ai-portfolio\whitepapers' r'\15-rag-access-control') os.makedirs(os.path.join(B, 'claims'), exist_ok=True) R = json.load(open(os.path.join(B, 'data', 'results2.json'), encoding='utf-8')) V = json.load(open(os.path.join(B, 'data', 'signatures.json'), encoding='utf-8'))['versions'] COV = json.load(open(os.path.join(B, 'data', 'coverage.json'), encoding='utf-8')) D = '2026-11-24' SELF = 'self, this bench' rows = [] n = [0] def add(claim, section, typ, source, notes='', verified='yes'): n[0] += 1 rows.append({'claim_id': 'K%03d' % n[0], 'claim': claim, 'section': section, 'type': typ, 'source': source, 'verified': verified, 'verifier': SELF if typ == 'own-data-derived' else 'self, read at source', 'verified_date': D, 'notes': notes}) disc = [x for x in R if x['category'] == 'silently_ignored'] deg = [x for x in R if x.get('degenerate')] paths = {x['path'].split(':')[0] for x in deg} # --- s01, the finding add('langchain-chroma %s max_marginal_relevance_search declares **kwargs and ' 'does not forward them to max_marginal_relevance_search_by_vector' % V.get('langchain-chroma'), '01', 'external-cited', 'langchain_chroma/vectorstores.py line 1075, read in the installed wheel and ' 'on langchain-ai/langchain master', 'data/source-evidence.txt') add('Its docstring states the kwargs are passed to the Chroma collection query', '01', 'external-cited', 'same file, docstring of the same method', 'the identical line appears on similarity_search, which does forward them') add('similarity_search in the same file forwards **kwargs', '01', 'external-cited', 'same file, similarity_search', '') add('langchain-community %s carries the same shape at chroma.py line 617' % V.get('langchain-community'), '01', 'external-cited', 'langchain_community/vectorstores/chroma.py line 617', 'one code lineage in two distributions, NOT an independent replication') add('Passing where= to max_marginal_relevance_search returns rows a filter for ' 'an owner holding no documents should have withheld', '01', 'own-data-derived', 'data/results2.json, UPSTREAM-ISSUE.md reproduction', 'ranking independent: an applied filter must return zero rows') add('Passing filters= to the same method is also discarded', '01', 'own-data-derived', 'data/predictions.json P1', 'predicted from source before the run') add('max_marginal_relevance_search_by_vector rejects where=, because it does ' 'forward kwargs', '01', 'own-data-derived', 'data/predictions.json P2', 'this is the control that locates the defect in the outer method') add('as_retriever(search_type="mmr", search_kwargs={"where": ...}) is discarded', '01', 'own-data-derived', 'data/predictions.json P3', 'the path applications are built on') add('langchain-core %s VectorStoreRetriever passes search_kwargs into ' 'max_marginal_relevance_search' % V.get('langchain-core'), '01', 'external-cited', 'langchain_core/vectorstores/base.py, read in the wheel', '') add('Chroma, LanceDB and llama-index each applied their own documented filter ' 'in every cell that had one', '01', 'own-data-derived', 'data/results2.json', '') add('llama-index documents where= as a chroma escape hatch and raises ' 'ValueError if filters= and where= are both given', '01', 'external-cited', 'llama_index/vector_stores/chroma/base.py query(), docstring and body', 'read in the source, then tested; the cell confirms it') add('The defect was reported upstream as langchain-ai/langchain issue 42065 on ' '24 November 2026, open and labelled bug and chroma', '01', 'own-data-derived', 'data/UPSTREAM-ISSUE-FILED.json and the issue itself', 'scoped to langchain-chroma because the form requires confirming the issue ' 'is not about langchain-community') add('Two contributors unconnected to this work ran the published script ' 'unchanged and reported the same four numbers, at 31 and 80 minutes after ' 'filing, on langchain-chroma 1.2.0 and 1.1.0, the second also confirming ' 'the code path on master at fb10639', '01', 'external-cited', 'comments on langchain-ai/langchain issue 42065, timestamps from the API', 'REPRODUCTION, not replication: they ran this paper script on versions it ' 'named, so it rules out a machine artefact and nothing more') add('Forwarding the kwargs is not a sufficient fix: the explicit where=filter at ' 'seven __query_collection call sites collides with a caller supplied where', '01', 'external-cited', 'comment on issue 42065, verified by its author in a scratch install', 'this corrects the fix suggested in the filed issue, and was found by a ' 'reader rather than by this bench') add('A first attempt, issue 42064, was submitted through the REST API and closed ' '13 seconds later by a triage bot for being submitted programmatically', '01', 'own-data-derived', 'issue 42064 and its bot comment', 'the content was never assessed; it was resubmitted through the web form ' 'and the duplicate is disclosed there') add('No claim is made that any real codebase passes the wrong name', '01', 'assumption', 'no survey was performed', 'the form is author-constructed; no prevalence statement anywhere') # --- s02, instrument add('%d observations over %d cells' % (len(R), len({(x['cell'], x['path']) for x in R})), '02', 'own-data-derived', 'data/results2.json', '') add('Corpus is 240 paragraphs from 21 of 30 fetched English Wikipedia articles, ' 'CC BY-SA 4.0, revision ids recorded', '02', 'own-data-derived', 'data/corpus.json, data/corpus-sources.json', '') add('Owners are assigned round robin, so owner is independent of content', '02', 'own-data-derived', 'data/corpus.py', 'largest share from one article 13.8%') add('Ground truth is joined by document id and an owner is never read back out ' 'of a search result', '02', 'own-data-derived', 'data/bench2.py classify()', '') add('%d deliberately broken filters ran across %d distinct call paths and none ' 'scored as applied' % (len(deg), len(paths)), '02', 'own-data-derived', 'data/results2.json, draft/tables/self-check.md', 'a single one scoring applied exits non-zero and voids the run') add('The negative control ran on %d of %d observations and no cell failed it' % (sum(1 for x in R if x.get('control2_run')), len(R)), '02', 'own-data-derived', 'data/results2.json field control2_run', 'it was registered as required and missing from the first version') add('A filter on a misspelled field returns empty, which passes a leak test, a ' 'negative control and a dialect log simultaneously', '02', 'assumption', 'the design argument for control 4', 'demonstrated by the degenerate forms, but the reasoning is an argument') # --- s03 add('Six cells discarded a filter argument without error', '03', 'own-data-derived', 'draft/tables/discards.md', 'counts are single observations, never rates') add('Chroma honoured the filter across four mutated index states', '03', 'own-data-derived', 'draft/tables/index-states.md', '') add('The owner-change cell was uninformative at k=10 rather than a failure: the ' 'document ranks 201st of 240 and appears at position 50 of 61 in the full ' 'filtered result', '03', 'own-data-derived', 'data/index-update-verification.json', 'reporting this as a failure would have been the easiest wrong finding here') add('LanceDB with prefilter=False returned 2 rows of 10 requested, with no ' 'error', '03', 'own-data-derived', 'data/results2.json', 'post-ANN filtering; a correctness finding, not a leak') add('LanceDB refuses an unknown field with a schema error naming it and listing ' 'the valid fields', '03', 'own-data-derived', 'data/results2.json', 'described, not ranked against other libraries') # --- s04, advice is argument add('Asserting on the returned rows catches both a discarded filter and one ' 'that matched nothing', '04', 'assumption', 'design argument', '') add('A metadata filter is a query-time convention rather than an enforced ' 'boundary', '04', 'assumption', 'design argument', 'not measured here; one collection per tenant was not tested') add('An honoured filter built from request input is honoured into the wrong ' "tenant's documents", '04', 'assumption', 'design argument', '') # --- s05, limits add('This bench measures whether a supplied predicate is applied, and does not ' 'test tenant isolation', '05', 'assumption', 'scope statement, registered before the run', 'PRE-REGISTRATION.md, binding on anyone quoting this work') add('Self-query retrievers in both wrappers have a model construct the filter', '05', 'external-cited', 'both packages ship self-query retrievers', '') add('qdrant-client %s local mode is a separate pure-Python implementation and ' 'is excluded from the results' % V.get('qdrant-client'), '05', 'external-cited', 'qdrant_client/local/, read in the installed package', '') add('No prevalence claim is made; the library set is a convenience sample', '05', 'assumption', 'scope statement', '') # --- s07, limits measured mn = min(c['coverage_pct'] for c in COV.values()) mx = max(c['coverage_pct'] for c in COV.values()) add('Per-document coverage of foreign documents ranges from %.1f%% to %.1f%% ' 'across cells' % (mn, mx), '07', 'own-data-derived', 'data/coverage.json', 'this bounds every applied result, not the discards') add('Every filter tested is a single equality on one string field', '07', 'own-data-derived', 'data/call-forms.md, data/bench2.py', '') add('Both LangChain packages were the latest published releases on the run date', '07', 'external-cited', 'pypi.org/pypi//json, fetched 2026-11-24', '') add('The defect is present on the project master branch, not only in the ' 'release', '07', 'external-cited', 'raw.githubusercontent.com langchain-ai/langchain master, fetched 2026-11-24', '') add('PR #13260, merged 2023-11-13, fixed the same defect shape for PGVector', '07', 'external-cited', 'api.github.com repos/langchain-ai/langchain/' 'issues/13260, read at source', 'PRECEDENT, not proof of intent: #13260 concerns a declared filter parameter ' 'not being carried to the inner call in PGVector, which is a dropped declared ' 'argument rather than dropped **kwargs, and it is one PR in another ' 'integration') # --- s08, corrections add('Control 4 was relaxed for re-ranking paths after the first run', '08', 'own-data-derived', 'DEVIATIONS.md item 6', 'a deviation from the pre-registration, recorded as one') add("The first run's output was NOT preserved: results.json was overwritten and " 'the file published as results-run1-exact-control4.json was a byte identical ' 'copy of the later output. It has been removed.', '08', 'own-data-derived', 'cmp of the two files, performed by an independent audit session', 'an earlier version of this paper claimed the first run was preserved; that ' 'claim was false and this row replaces it') add('MMR with the correct filter returned 10 of 10 rows all belonging to the ' 'subject, and the first checker scored that unknown', '08', 'assumption', 'the figures as quoted in section 08; the run output was overwritten', 'typed as an assumption because the artefact is gone, which is a weaker ' 'footing than this programme accepts') add('Seven deviations from the pre-registration are recorded', '08', 'own-data-derived', 'DEVIATIONS.md', 'three were omissions of mine found by an independent audit') add('Three of the four index-state cells are uninformative by construction', '03', 'own-data-derived', 'data/results2.json, section 03', 'the mutated document ranked 201 of 240, and the delete cell removed foreign ' 'documents while filtering for the subject') add('No index was built on the LanceDB table, so every LanceDB cell ran an exact ' 'search rather than an approximate one', '03', 'own-data-derived', 'data/bench2.py, which never calls create_index', 'the post-filter behaviour is unchanged but the stated mechanism was wrong') add("Qdrant's multitenancy guidance recommends one collection with payload " 'partitioning and calls a collection per tenant rarely the most efficient ' 'approach', '04', 'external-cited', 'qdrant.tech multitenancy guidance', 'cited because it contradicts an unsourced claim an earlier draft made') add('SelfQueryRetriever lives in the langchain package; langchain-community ships ' 'ChromaTranslator; langchain-chroma 1.2.0 ships neither', '05', 'external-cited', 'the installed packages', 'corrects an earlier claim that both wrapper packages ship self-query ' 'retrievers') add("langchain-community 0.4.2's MMR docstring does not mention kwargs, so three " 'of the six discards are undocumented rather than contradicted', '01', 'external-cited', 'langchain_community/vectorstores/chroma.py', 'the docstring promise holds for langchain-chroma only') add('The largest share of one owner from a single article is 18.3%', '02', 'own-data-derived', 'data/corpus.json', 'an earlier draft said 13.8%, which was the whole-corpus figure') add('Only one cell ran more than a single query', '07', 'own-data-derived', 'data/bench2.py, data/coverage.json', 'which is why five of six cells sit at 4.4 to 6.1 per cent coverage') add('This harness and its write-up got six things wrong and the libraries under ' 'test one', '08', 'assumption', 'a judgement about the count in section 08', 'four of the six were found by an independent audit session') F = os.path.join(B, 'claims', 'claim-ledger.csv') with io.open(F, 'w', encoding='utf-8', newline='') as fh: wr = csv.DictWriter(fh, fieldnames=['claim_id', 'claim', 'section', 'type', 'source', 'verified', 'verifier', 'verified_date', 'notes']) wr.writeheader() wr.writerows(rows) import collections print('ledger: %d claims' % len(rows)) for t, k in collections.Counter(r['type'] for r in rows).most_common(): print(' %-18s %d' % (t, k))