Skip to content

Scope Brazil2026ElectionFilter to viewers in Brazil - #64

Open
keithadler wants to merge 1 commit into
xai-org:mainfrom
keithadler:scope-brazil-election-filter-to-br
Open

Scope Brazil2026ElectionFilter to viewers in Brazil#64
keithadler wants to merge 1 commit into
xai-org:mainfrom
keithadler:scope-brazil-election-filter-to-br

Conversation

@keithadler

Copy link
Copy Markdown

Brazil2026ElectionFilter never reads the viewer's country, so as written it applies to every For You request in every country rather than to the viewers the Electoral Court order covers.

Evidence

should_remove takes only the candidate and the viewer's follow list (filter L1363), and the filter is added to the pre-scoring chain unconditionally (pipeline L368).

Both mechanisms needed to scope it already exist and are unused:

Eight other filters in the same chain already use enable() for exactly this: VideoFilter, TopicIdsFilter, NewUserMinEngagementFilter, InventoryHoldoutFilter and others.

There is also a layering signal. Every other jurisdiction-scoped rule in the repo lives in visibility-filtering and checks viewer country. No filter in home-mixer/filters/ reads viewer country at all, so this is the only geo-scoped rule in a service with no geo-scoping convention.

Change

Adds an enable() override gating the filter on country_code == "br", case-insensitively.

Unknown or empty country codes leave the filter disabled, which matches the existing convention for legal withholding: viewer_in_withheld_country in visibility-filtering/rules/tes_rules.rs returns false when the viewer country is not known. Happy to invert that to fail-closed if you would rather over-apply than under-apply on unknown geo.

Adds four tests. Existing tests call filter() directly and are unaffected.

If this is intentional

Applying globally does guarantee compliance regardless of geolocation accuracy, which matters with VPNs and travel. If that is the reasoning, please close this, though a comment recording the decision might be worth adding, since the surrounding conventions read the other way.

Caveat

home-mixer ships no Cargo.toml, so I could not compile or run the tests. The file is rustfmt --check clean under edition 2021. Verification of the change is on you.

Brazil2026ElectionFilter is added to the For You pre-scoring chain
unconditionally and never reads the viewer's country, so it currently
applies to every viewer in every country rather than to the viewers the
Electoral Court order covers.

The scoping mechanisms already exist and were simply unused:

  - ScoredPostsQuery carries country_code
  - Filter::enable(&self, query) gates a filter per request, and is
    honoured by the pipeline at candidate_pipeline.rs:352

Eight other filters in the same chain already use enable() for this
purpose (VideoFilter, TopicIdsFilter, NewUserMinEngagementFilter,
InventoryHoldoutFilter and others).

Unknown or empty country codes leave the filter disabled, matching the
existing convention for legal withholding in visibility-filtering, where
viewer_in_withheld_country returns false when the viewer country is not
known.

Adds tests for the enabled, disabled, case-insensitive and unknown-country
cases. Existing tests call filter() directly and are unaffected.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ByteJoseph

Copy link
Copy Markdown

Hi.
I think their goal in open-sourcing this algorithm was just transparency, not open-source collaboration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants