fix(cat): you could not read the Cat's answer on your own private post - #820
Merged
Merged
Conversation
Ask the Cat under a private post and the answer is written, correctly, with the parent's visibility — a private thread should stay private. But the reply is authored by the CAT, and the rule for a private event is `actor_id = auth.uid()`. So the answer to your own question was visible to exactly one account, and it was not yours. Measured in production 2026-08-28 on post 5c3ad8ef. Three replies exist: 425a3d00 actor=cat private "Each person would owe 1,400 CHF" 52cc045c actor=mao private "@cat what is this" 3f9372ba actor=mao public "awdaw" The author could see two of them. The missing one was the answer they had asked for. Nothing errors; the thread renders without it, which reads as the Cat having ignored you. THE RULE ADDED: a private event is also visible to the author of the private post it replies to. Scoped to a private PARENT deliberately. The looser version — "the parent's author sees any private reply" — is a real privacy regression on PUBLIC posts, where anyone may reply and someone may write a private note to themselves under a stranger's post. That note stays theirs. With a private parent the set of possible repliers is closed: to reply to a private post you must first be able to read it, and the policy allows only its author. The one other writer is the Cat, whose worker uses the service role. So this exposes your own replies and the Cat's answers on your own private posts, and nothing else. Verified: a different user still sees one reply on that thread (the public one) and zero private events that are not theirs. The check runs in a SECURITY DEFINER function because a policy on timeline_events that queries timeline_events re-enters itself — "infinite recursion detected in policy for relation timeline_events", which is how the first attempt failed. It answers only "does the caller own this private parent" and returns no row content. Not keyed on the Cat's id or on metadata.is_cat_reply: either would put a second definition of who the Cat is into SQL, to drift against config/cat-identity.ts. The property that matters is structural. GATED, because the failure is silent — the Cat answers, the row exists, and the thread renders without it. timeline_policy_allows_own_thread() reports false against the policy in production today and true after this migration, so a future rewrite that drops the clause turns the nightly run red instead of quietly breaking the feature again. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012dpTLxh5GJWeWTF1UEvcD5
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.
Ask the Cat under a private post and the answer is written correctly, with the parent's visibility — a private thread should stay private. But the reply is authored by the Cat, and the rule for a private event is
actor_id = auth.uid(). So the answer to your own question was visible to exactly one account, and it was not yours.Measured in production on post
5c3ad8ef:425a3d0052cc045c3f9372baThe author could see two of them. The missing one was the answer they had asked for. Nothing errors — the thread just renders without it, which reads as the Cat having ignored you.
The rule added
A private event is also visible to the author of the private post it replies to.
Scoped to a private parent deliberately. The looser version — "the parent's author sees any private reply" — is a real privacy regression on public posts, where anyone may reply and someone may write a private note to themselves under a stranger's post. That note stays theirs.
With a private parent the set of possible repliers is closed: to reply to a private post you must first be able to read it, and the policy allows only its author. The one other writer is the Cat, whose worker uses the service role.
Verified against production, rolled back
The check runs in a
SECURITY DEFINERfunction because a policy ontimeline_eventsthat queriestimeline_eventsre-enters itself — "infinite recursion detected in policy", which is how my first attempt failed. It answers only "does the caller own this private parent" and returns no row content.Not keyed on the Cat's id or on
metadata.is_cat_reply: either would put a second definition of who the Cat is into SQL, to drift againstconfig/cat-identity.ts.Gated
The failure is silent, so
timeline_policy_allows_own_thread()reports false against the policy in production today and true after this migration. A future rewrite that drops the clause turns the nightly run red instead of quietly breaking the feature again.🤖 Generated with Claude Code
https://claude.ai/code/session_012dpTLxh5GJWeWTF1UEvcD5