Skip to content

fix: tombston in inferMemberOrganizationStintChanges (CM-1367) - #4502

Open
ulemons wants to merge 1 commit into
mainfrom
fix/email-domain-org-tombstone
Open

fix: tombston in inferMemberOrganizationStintChanges (CM-1367)#4502
ulemons wants to merge 1 commit into
mainfrom
fix/email-domain-org-tombstone

Conversation

@ulemons

@ulemons ulemons commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes DE-1016/DE-1021: a human-deleted email-domain sourced org affiliation can reappear on a member profile once new matching activity comes in, because the infer-member-organization-stint-changes cron job only checked deletedAt and never deletedBy. PR #4476 (CM-1367) already fixed this for provider/enrichment-sourced affiliations, but the email-domain stint-inference path is a separate codepath that PR didn't touch. This PR closes that gap by making a human tombstone (deletedBy set) permanently block recreation of that org affiliation, regardless of whether the new activity date falls inside the deleted row's date range.

Changes

  • Added deletedBy?: string to IMemberOrganization (services/libs/types/src/organizations.ts) so the field can flow through to the stint-inference logic.
  • Added "deletedBy" to the SELECT column list in fetchMemberOrganizationsBySource (services/libs/data-access-layer/src/members/organizations.ts) — the cron job already fetches deleted rows via withDeleted: true, it just wasn't reading who deleted them.
  • inferMemberOrganizationStintChanges (services/libs/common_services/src/services/member-organization.ts) now computes a tombstonedOrgIds set from rows where both deletedAt and deletedBy are set, and skips any stint insert/extend for those organizationIds outright. This is intentionally stronger than the existing deletedRows suppression, which only blocks recreation for activity dates that intersect the deleted row's own date range — a human delete should hold regardless of date, while a system/provider delete (no deletedBy) keeps the narrower, date-scoped suppression.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Performance improvement
  • Chore / dependency update
  • Documentation

JIRA ticket

CM-13267

Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
@ulemons ulemons self-assigned this Aug 24, 2026
Copilot AI balanced review requested due to automatic review settings August 24, 2026 12:11
@ulemons ulemons added the Bug Created by Linear-GitHub Sync label Aug 24, 2026
@cursor

cursor Bot commented Aug 24, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes affiliation recreation logic for member-organization stints. Incorrect tombstone handling could hide valid affiliations or let deleted ones reappear.

Overview
Human-deleted email-domain org affiliations no longer come back when new matching activity arrives.

inferMemberOrganizationStintChanges now skips any org with both deletedAt and deletedBy set, for all dates—not just dates that overlap the deleted row. System deletes without deletedBy still use the existing date-range suppression.

fetchMemberOrganizationsBySource now selects deletedBy, and the field is added to IMemberOrganization so the cron path can see who deleted the row.

Reviewed by Cursor Bugbot for commit 910e2f3. Bugbot is set up for automated code reviews on this repo. Configure here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents manually deleted email-domain affiliations from being recreated during stint inference.

Changes:

  • Propagates deletedBy through organization types and DAL queries.
  • Skips all inferred changes for human-tombstoned organizations.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
services/libs/types/src/organizations.ts Adds deletedBy to the affiliation type.
services/libs/data-access-layer/src/members/organizations.ts Selects the tombstone actor field.
services/libs/common_services/src/services/member-organization.ts Suppresses inference for tombstoned organizations.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@skwowet skwowet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Labels

Bug Created by Linear-GitHub Sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants