r/aiharness • u/Deynekin • 4d ago
A column named user_id does not point at users
I run a local index over a codebase, and I spent four weeks learning which of its facts I can trust. The index holds 930 files, 6701 symbols and 92409 edges, and every answer carries a file:line address. The number I keep coming back to is not any of those - it is a ceiling of 0.5.
That ceiling is the difference between a fact and a guess. When a migration declares a foreign key, that edge is stated: the database itself says orders.user_id -> users.id, and the index records it as proven. When there is no constraint and the index sees a column literally named user_id, it can guess the same edge by name - and it must not record that guess as the same kind of truth. A name match is a derivation, capped at 0.5 confidence, and the answer has to say which one it is.
The failure that made this concrete was one join. A column called user_id was assumed to reference users, so the index answered questions about "who owns this row" with the wrong table. The real constraint pointed at accounts. The answer was confident, formatted, and wrong in exactly the way a junior dev is wrong when they join on the obvious name. The index had not lied - it had guessed and not told me.
Three rules came out of that, and they now gate every fact before it leaves the index:
- Every edge is stated or derived, and derived carries a confidence ceiling, never a point estimate. "0.5" is not a probability I measured; it is the maximum I allow a name-based guess to claim, so the number cannot drift upward and start looking like evidence.
- A fact without a revision is a rumor. If the file changed after indexing, the index refuses to answer from it and returns a stale status instead. An old fact is not slightly wrong, it is a different fact, and it should stop being served.
- "Not found" carries a reason. Absent, stale, or out-of-scope are three different answers, and only absent is a real "no". A system that treats all three as an empty list is honest-sounding and useless, because you cannot tell "there is nothing" from "I would not look".
Where it broke for the user, beyond the wrong join: the first version of the stale check was silent. When a file changed, the index kept answering from the old revision and the answer looked current. Two days of "the tests pass but the behavior changed" before I connected it to a reindex that had not run. Now the answer prints the revision it was served from, and the regression is visible the first time it happens.
What I would tell a younger version of this project: provenance is not metadata, it is the product. The graph is only useful to the extent that each edge remembers whether it was declared or guessed, and against which revision. Once you give a guess a confidence number that can reach 1.0, you have stopped indexing and started hallucinating with extra steps.