Repository navigation
Description
What
An unscoped write to the codebase-analytics ChromaDB collection is silent, and the place to make it audible cannot take the code.
chromadb_storage.py:300 — and four sibling preparers at :588, :613, :635, :711 — all do:
if source_id:
metadata["source_id"] = source_idWhen source_id is absent the key is simply omitted. Every codebase-analytics endpoint filters {"source_id": source_id}, so those rows are matched by no per-source query: present, healthy, unreachable. 11,241 rows reached that state before anyone noticed (#17651), because the omission was silent on both sides — the writer skipped the key and the readers returned an honest zero.
#17651 fixes the immediate cause (the only index trigger in the frontend now sends source_id) and adds a contract guard. It does not make the runtime event visible, and this issue is that gap.
Why it is not already fixed
The warning belongs at the write boundary, in _store_problems_batch_to_chromadb. That file is grandfathered at exactly 1470 lines. Adding a 15-line guarded warning took it to 1486 and check_python_file_size refused:
chromadb_storage.py: 1486 lines, over its recorded ceiling of 1470.
A grandfathered file may not grow (#14236) — the exemption freezes the size it
was granted for, it does not license more.
That rule is right and I am not arguing with it. But the consequence is worth stating plainly: a file at its frozen ceiling cannot accept safety code, and the safety code this one needs is small. The options are all real work — split the module, or spend the budget elsewhere in it — and neither belongs inside a fix for a different defect.
The shape, stated generally
An optional write of a key that every reader requires is not an optional key. The producer treats absence as a smaller record; every consumer treats it as a non-existent one. This is the fourth instance in a day of a consumer requiring what a producer does not emit (#17643, #17651), and the first where the fix is blocked by an unrelated constraint rather than by not knowing what to do.
Acceptance criteria
- An unscoped write logs once per batch, naming the row count and that those rows will not appear in any per-source view — not once per row
- It fires from all five preparers, or from a single shared boundary they all pass through; a warning on
_prepare_problem_documentalone repeats bug(analytics): 13+ codebase-analytics panels render empty, and two of them cannot report a failure at all #17651's own guard defect -
chromadb_storage.pyis under its ceiling afterwards, by splitting rather than by raising the ceiling (RATCHET_BASELINES.md) - A test asserts the warning fires for an unscoped batch and does not fire for a scoped one — both directions, or it proves nothing
- Whether the root_path-only indexing mode should exist at all is answered: if every legitimate caller has a source, the warning should be a refusal instead
Not claimed
Whether any production path legitimately indexes without a source_id. The endpoint supports root_path alone, so the mode exists; whether anything uses it is unmeasured, and it decides warn-versus-refuse above.
Activity
mrveiss commentedon Sep 27, 2026
One suggested addition to criterion 2 — it forbids the instance but not the mechanism
The criteria here are stronger than most, and criterion 2 already names the trap explicitly: "It fires from all five preparers, or from a single shared boundary they all pass through; a warning on
_prepare_problem_documentalone repeats #17651's own guard defect."The gap is one level out. That forbids the instance — a warning on one preparer — and not the mechanism. A test can satisfy it by naming the five, which is a hand-written list, and preparer six then arrives with no warning and no failing test. That is exactly the step #17651's guard had to take: its first version inspected one function, and the fix was not "inspect five" but "discover the population".
Suggested wording, as an addition rather than a replacement:
repo_tests/analytics_metadata_contract_17651_test.pydoes, rather than naming its members — a list of five cannot fail when a sixth appearsAnd the corollary worth stating, because it makes the whole question disappear: if the shared-boundary branch is taken, there is nothing to discover. A warning at
_store_problems_batch_to_chromadbcovers every preparer by construction, including ones nobody has written yet. That is an argument for preferring the boundary over per-preparer calls, independent of the line budget that caused the deferral.One note on criterion 3 while I am here: "under its ceiling afterwards, by splitting rather than by raising" is right, and the file is grandfathered at 1470 with the warning taking it to 1486. Whatever split lands should bank the resulting count in both
scripts/python_file_size_known_large.pyandrepo_tests/python_file_size_ratchet_baseline.py— the two records are mirrored, and a shrink recorded in one and not the other leaves headroom to regrow into (#14498).Criterion 5 is the best of them, for what it is worth: "if every legitimate caller has a source, the warning should be a refusal instead" questions whether a warning is the right instrument at all, which is a better question than how to place one.
mrveiss commentedon Sep 27, 2026
Adding a criterion, and it may dissolve the choice rather than constrain it.
Criterion 2 currently says the warning must fire from all five preparers or from a shared boundary. Those two branches are not equivalent, and the difference decides whether this issue can recur:
_store_problems_batch_to_chromadb): every preparer passes through it by construction, including ones nobody has written. There is nothing to discover and nothing to keep in sync.So:
repo_tests/analytics_metadata_contract_17651_test.pynow does, so an unwritten preparer fails rather than passes silentlyThe second half of that matters because the line budget is what deferred this issue in the first place, and a constraint that decided the deferral should not silently decide the design. If the boundary is chosen, it should be because the guarantee is stronger there, with the file split as a consequence rather than a reason.
Related, from #17651's review
The contract guard now carries a second discovery that is worth mirroring here: functions are found by behaviour — assigning a dict to a variable named
metadata— as well as by name, and the two sets must agree. A key-based alternative was tried and rejected because it fires onmake_problem_dictand_delete_source_documents, requiring an allowlist of exceptions that goes stale exactly like the thing it guards.Whatever shape the warning takes, the same test applies: can it be satisfied by a check that enumerates today's members? If yes, it will not survive the sixth one.
github-actions commentedon Nov 2, 2026
needs-structure: this issue is missing:Parent: #Nin the body), unless this is an umbrella with sub-issuesThe label clears on the next issue event once all three are present (#19522).