DEV Community

Discussion on: Chat history is a second read path into your RAG data — gate the replay like the search

Collapse
 
rdiegoss profile image
Rodrigo Diego •

"Delivered speech vs derived artifact" is the line I should have drawn, and it's closer to where we landed than my original one. Since the post, the transcript replays turns as they were shown, cards included; a revoked capability now governs the next turn, not the record (note at the top).

That makes your provenance stamp more relevant, not less. If the record replays as seen, the honest version tells the reader the capability behind it is no longer granted, and the replay response carries no field for that today. "A card wearing prose" is the right name for the verbatim-quote case, too.

On timing: the existence oracle you're worried about is unknown-vs-foreign session id, and both go through the same owner-scoped lookup (session id, tenant and user in one WHERE), so same query, same plan. Malformed ids short-circuit before any query, but a malformed id reveals nothing about existence. Entitlement denial left the 404 bucket entirely: it's a typed 403 now, the same answer the turn gate gives, and it only tells a caller something about their own org. I still haven't put a number on any of it, and you're right that it's the first measurement to run.

Do come back with the supersession-banner result. That kind of leak never shows up in a response-shape test, which is the whole case for not-awaited assertions

Collapse
 
heinrichneb profile image
Heinrich Neb •

I said I'd come back with the banner result, including if it was embarrassing. It was, a bit.

The banner did what I'd worried about: it named a private successor and told the reader how to fetch it. It no longer does, and a record that can't be read now counts as private rather than public. Fail closed in both places.

The bigger find was one step to the side, and it's your title almost word for word. Search checked visibility at read time. The exact lookup by name didn't. Group-scoped lessons went to anyone who knew the name, and names show up in every result list and every banner. It now runs the same check, and the refusal reads exactly like "not found".

One thing I'd have got wrong without a control: the test that should show a group member reading their own lesson failed too, at first. Not the product, the test double. It had no set membership, so every group looked empty. Without that second test I'd have fixed a bug that didn't exist.

Your gold standard is still open here: proving the protected read never ran, instead of checking what came back. And the typed 403 makes sense to me for the same reason ours had to go the other way. Your denial tells callers about their own org; ours was about somebody else's lesson.

Thread Thread
 
rdiegoss profile image
Rodrigo Diego •

You said you'd come back even if it was embarrassing, and you did. That's rarer than the bug. :D

The by-name lookup is the version of this I'd worry about most. A name that shows up in every result list and every banner isn't a secret, it's a pointer, so a lookup by name is just the search path with the visibility filter left off.

The test double is the part I'm taking with me. A fail-closed test passes for free if the double denies everyone, so the negative control only means something next to a positive one, and that one has to run against something that actually models membership. Ours ended up split that way. The repository test uses a scripted pool and asserts exactly one query ran, the ownership check, and that the turns SELECT never did. The ownership test that matters runs against a real Postgres in CI: the same session read by the owner, by another user, and with an id that doesn't exist. The mock tells you the gate asked the right question. Only the database tells you the answer.

If you write up the by-name find, I'd read it.

Thread Thread
 
heinrichneb profile image
Heinrich Neb •

I'm writing it up. The by-name find sits in the middle of it, and I'd like to quote your line about names in it, with credit, if that's alright: a name that shows up in every result list and every banner isn't a secret, it's a pointer.

My negative and positive controls both ran against a double. The positive one is what caught the broken double, which was luck more than design. "The mock tells you the gate asked the right question. Only the database tells you the answer" is what the design should have been.

The positive control against the real store goes in before the post does.