Guard every tracked events.py against PII, not just Run and Actor - #796
Merged
Conversation
test_run_events_carry_no_pii.py and test_actor_events_carry_no_pii.py each hardcoded one file, so a new event anywhere else carrying a 2-BM directory path (which embeds a surname and proposal number) or other PII-shaped field shipped with zero objection. Replace both with test_events_carry_no_pii.py, which discovers every events.py via tracked_python_files() and checks it against a shared deny-list, plus an Actor-only extension for name/display_name (globalizing those two terms flags 28 ordinary entity-label fields elsewhere with no real PII among them, so they stay scoped to Actor's own file). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.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.
Summary
Two PII fitness tests existed, and each scanned exactly one hardcoded file:
run/aggregates/run/events.pyandaccess/aggregates/actor/events.py. Every other bounded context's events were scanned by nothing.The deny-list was already correct and already listed
observed_path,capture_path,path,directory,file_path,surname,proposal_number. It simply never ranged over the files where a violation would land. 2-BM's directory layout embeds{UserLastName}-{ProposalNumber}, and events are immutable and INSERT-only at the role level, so a path written into one can never be erased.Found while designing a new Data BC event: it would have carried a capture path and shipped green.
Coverage: 2 files -> 43, across 18 bounded contexts.
Changes
test_events_carry_no_pii.py, discovering everyevents.pyviatracked_python_files()(git-aware, neverglob()/iterdir(), so the file set matches what pre-commit sees).name/display_namestay scoped to Actor's own file. Globalizing them flags 28 ordinary entity-label fields across 15 files (equipment, recipe, campaign, dataset, procedure, sample, Trust zone) with no real PII among them, includingRunStarted.namein the very file whose curated list already omitted barenamefor that reason.email/phone/orcid/affiliation, and Actor's forpath/directory/surname/proposal_number.event_activity_trail.pydocstring asserted "the only two fitness tests ... cover exactly two of the twenty-five stream types", which this change falsifies; updated, and made more honest about what a field-name deny-list can and cannot guarantee.Test plan
observed_path: strto a real Data BC event fails withdata/aggregates/acquisition/events.py line 87: AcquisitionRecorded.observed_path. That field on that file shipped green before this change.events.py, 18 bounded contexts.test_pii_scan_discovers_events_file_for_every_bounded_contextfails if discovery silently returns an empty or partial set, which would otherwise make the whole test pass over zero files.🤖 Generated with Claude Code