visibility-filtering: ignore expired safety labels when dropping posts - #10
Merged
Merged
Conversation
Drop rules only look at label type presence. Hydration copied every proto key into that set and threw away expires_at_msec, so a TTL-bound label such as SpamHighRecall kept suppressing out-of-network posts after the intended window. Filter expired proto rows before building the type set. A missing expiry stays permanent. Adds unit tests for the expiry fence and a drop-rule case that an expired SpamHighRecall allows. Co-authored-by: Jon Bailey <Pitchfork-and-Torch@users.noreply.github.com>
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.
Problem
Abuse-enforcement writes time-limited tweet labels (for example
SpamHighRecallwith a 30-dayexpiresAtMsec). Visibility filtering decodes that expiry onto the proto, thenSafetyLabelMap::from_proto_label_typeskeeps only the type key and builds a default label with no expiry.Drop rules (
SpamHighRecallDropRuleand the other tweet-label drops) callhas_label, which is type presence only. After the TTL, the post can still be dropped from out-of-network recommendations.Under the Hood already treats a past
expires_at_msecas inactive when it reads the same label store snapshot. The live filter path did not.Change
Filter proto rows whose
expires_at_msecis at or before now before inserting them into the type set used by drop rules. A missing expiry stays permanent.No change to write paths, TTLs, or which labels exist. GetSafetyLabels still returns the raw proto, including expired rows.
Tests
safety_labels.rs: permanent / future / past / exactly-now expiry, plus a mixed map that keeps the active sibling.tweet_label_drops.rs: an expiredSpamHighRecallproto row evaluates to Allow.This crate depends on internal
xai_*packages that are not in the repo, so the tests cannot be run here. Correctness is from the existing drop-rule path (has_label->SafetyLabelDropRule::evaluate) plus the expiry fence above it.Upstream
A straight cherry-pick onto
xai-org/x-algorithmmaindoes not apply. Upstream simplifiedSafetyLabelMapto a type-onlyHashSetand foldedtweet_label_drops.rsintotweet_rules.rs. The same expiry filter is ported there: xai-org#106