visibility-filtering: ignore expired safety labels when dropping posts - #106
Open
Pitchfork-and-Torch wants to merge 1 commit into
Open
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. Co-authored-by: Jon Bailey <Pitchfork-and-Torch@users.noreply.github.com>
Pitchfork-and-Torch
marked this pull request as ready for review
September 4, 2026 16:29
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.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.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-> tweet-label drop specs) plus the expiry fence above it.Fork
Same fix on the Pitchfork-and-Torch fork: Pitchfork-and-Torch#10
The fork still has the older
SafetyLabelMap(HashMap plus type set) andtweet_label_drops.rs, so this is a port of that patch onto currentxai-org/x-algorithmmainrather than a clean cherry-pick.