Skip to content

feat(ticket): snapshot the owning organization on client tickets and scope Fae reads by it CU-17tkuw60wmg - #2857

Merged
hryhorii-chuhuievets merged 10 commits into
mainfrom
feat/fae-client-owner-organization
Nov 13, 2026
Merged

hryhorii-chuhuievets merged 10 commits into
mainfrom
feat/fae-client-owner-organization

Conversation

@hryhorii-chuhuievets

@hryhorii-chuhuievets hryhorii-chuhuievets commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

ClickUp task: CU-17tkuw60wmg BE: hide a device's earlier tickets and chats from Fae after it moves to another customer

Why

A device moves to another customer by re-running the install command with the new --orgId. The agent calls /reinstall with its saved machineId and the backend only rewrites machine.organizationId. Every Fae (AGENT token) read of tickets was scoped by owner.machineId alone, so the device under customer B kept listing the tickets it opened under customer A.

What

Owner organization snapshot (hide).

  • ClientTicketOwner.organizationId: the organization the machine belonged to when the ticket was created. Written once, never updated, so admin changes to ticket.organizationId cannot hide a ticket from its own device.
  • ClientOwnerScope (machine + its current organization) is the single rule: an AGENT sees an item when the owner machine matches and the owner's organization snapshot equals the machine's current organization. A missing snapshot (pre-backfill) stays visible, and so does everything when the machine has no organization.
  • ClientOwnerScopeResolver (api-lib) builds the scope for AGENT principals, and by machineId for deliveries without a principal, from MachineRepository on every call: a cached organization would keep leaking for the cache's lifetime after the move.
  • TicketService: the list query gets owner.organizationId $in [current, null]; ticket(id) and ticket-by-number apply the predicate after the lookup, so a hidden ticket is not found. Client-created tickets stamp the owner from the loaded machine.

Machines cascade (archive).

  • MachineEvent.organizationId: a reinstall under another customer publishes the change (and MachineWriter publishes organizationId writes like the other event fields).
  • MachineOnClientTicketsProjection (machine-on-client-tickets), registered on MachineAggregateSpec and run by the shared stream like its siblings: moves every client ticket of the machine whose owner snapshot names another customer to the tenant's ARCHIVED status (TicketProjectionRepository, $nin [null, current], tenant-scoped). A machine without an organization or a tenant without an ARCHIVED status archives nothing. Reconcile reports open client tickets whose snapshot differs from the machine's current organization.

Moving the device back to customer A makes A's tickets visible again (the rule is equality with the current organization, not a time cut-off); tickets archived by the projection stay archived.

The ticket owner backfill lives in openframe-saas-tenant with the other change units. Dialogs follow in openframe-saas-lib (owner snapshot + machine-on-client-dialogs projection) and openframe-saas-tenant (every AGENT access point in the AI agent, the client notification gate, both backfills).

Tests

ClientOwnerScopeTest, ClientOwnerScopeResolverTest, TicketServiceClientOwnerScopeTest, owner-scope cases in CustomTicketRepositoryFilterTest, MachineOnClientTicketsProjectionTest, MachineAggregateSpecTest, MachineWriterTest (event paths); existing TicketService*Test adjusted for the new dependency.

Enrollment cut-off

A device that comes back to a customer it belonged to before must look like a new device, so the customer snapshot alone is not enough. Machine.organizationAssignedAt is set on registration and on a reinstall under another customer (same-customer reinstalls keep it; one field-level write together with the other reinstall fields). ClientOwnerScope carries it and allows(owner, createdAt) hides every client item created before it; the ticket list query merges it with the caller's createdAtFrom into one createdAt bound. Null cut-off (legacy machines) keeps the old behaviour; an item without createdAt is hidden when a cut-off exists. The field is not part of MachineEvent, so the archive projections still react to the organization change only.

Change-Set: feat-fae-client-owner-organization

Change set flamingo-stack/openframe-oss-lib#2857: these pull requests are one change, reviewed together.

  • flamingo-stack/openframe-oss-lib#2857 (this pull request): feat(ticket): snapshot the owning organization on client tickets and scope Fae reads by it CU-17tkuw60wmg · landed
  • …and 6 pull requests not visible

Linked work

  • …and 1 linked item not shown here

Linked by the Depends-On / Change-Set lines in these descriptions; this block is maintained by the hub.

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🦩 Flamingo Code Review

✅ Tests and checks passed on this commit (2 lanes).

✅ No findings on the current head.

Advisory: findings do not block the merge.

Files Lines 🔴 Action required 🟠 Recommended 🔵 Informational
28 +1229 / -48 0 0 0

✅ What this change does well

  • TicketService.populateClientOrigin now snapshots both the device's machineId and current organizationId into ClientTicketOwner at ticket-creation time, closing the stale-ownership gap that ClientOwnerScope.allows() relies on for correct cross-tenant visibility.
  • ClientOwnerScopeResolverTest and TicketServiceClientOwnerScopeTest cover the key edge cases (unknown machine, missing machineId, pre-assignment tickets, organization change) with clear given/when/then naming.
  • AgentRegistrationService.isNewEnrollment correctly gates the new organizationAssignedAt stamp so re-registrations under the same organization do not reset the assignment timestamp.
  • MachineOnClientTicketsProjectionTest.java covers the full projection lifecycle (apply, countChanges, applyBatch, reconcile) including edge cases like missing organization and missing ARCHIVED status, giving real branch coverage.
  • TicketProjectionRepositoryTest.java verifies the exact Mongo Criteria/Update shape built by archiveClientTicketsOfOtherOrganizations and its batch variant, catching regressions in the generated query rather than just the return value.
10 possible problems checked and ruled out, 1 after reading more of the repository
  • openframe-data-mongo-sync/src/main/java/com/openframe/data/repository/device/publishing/MachineOnClientTicketsProjection.java:142 findByTenantIdInAndMachineIdIn is not a known MachineRepository method: MachineRepository.java:83 already declares ListMachine findByTenantIdInAndMachineIdIn(CollectionString, CollectionString), and it's already used identically by MachineOnTicketsProjection.java:102, so the method resolves and compiles fine.
  • openframe-data-mongo-sync/src/main/java/com/openframe/data/repository/ticket/CustomTicketRepository.java:20 Javadoc-style block comment added on buildTicketQuery's interface method: The added block is a short 2-line @‍param Javadoc comment explaining a non-trivial null-semantics contract on an interface method; while technically a /** */ block, it's borderline and documents a real behavioral nuance (null means unrestricted) rather than restating the obvious - a stylistic nitpick a strict CI linter might catch but not a substantive issue.
  • openframe-data-mongo-sync/src/main/java/com/openframe/data/repository/ticket/TicketProjectionRepository.java:172 countClientTicketsOfOtherOrganizations duplicates an existing definition: Dup-scan flags structural similarity between archive/count helper methods, but these implement distinct domain operations (archiving client tickets vs counting devices to update hostname) that happen to share a query+count/update pattern over a repository; not real duplicate logic worth merging.
  • openframe-api-lib/src/main/java/com/openframe/api/service/device/ClientOwnerScopeResolver.java:44 ClientOwnerScopeResolver.forMachine silently falls back to a scope without organization on an unknown machine: forMachine's fallback to null-organization scope on a missing machine is a deliberate documented behavior (comment: 'falls back to machine only'); treating missing machine same as missing org is plausible product behavior, not clearly a broken invariant that must throw.
  • openframe-api-lib/src/main/java/com/openframe/api/service/device/ClientOwnerScopeResolver.java:44 ClientOwnerScopeResolver.forMachine silently falls back instead of throwing on an unexpected invariant break: Same as candidate 3: falling back to null-org scope for a missing/not-yet-assigned machine is documented, deliberate behavior, not an invariant violation requiring an exception under OFJAVA-013/017.
  • openframe-api-lib/src/main/java/com/openframe/api/service/ticket/TicketService.java:487 populateClientOrigin sets a ClientTicketOwner with a null machineId instead of throwing on a broken precondition: Blank machineId on an AGENT-created ticket is logged as a warning and handled by setting an owner with that machineId and null org, which is a defensive fallback already guarded by a warn log, not a case the rule mandates throwing for; it's handled, not silently hidden.
  • openframe-client-core/src/main/java/com/openframe/client/service/agentregistration/AgentRegistrationService.java:208 isNewEnrollment issues an extra Mongo read right before machineWriter.update re-reads/writes the same machine: isNewEnrollment does an extra read before the write, but this is a minor efficiency nitpick (one extra findByMachineId on a single-document, indexed lookup by machineId), not an unbounded-data issue the cited rule (OFJAVA-038) addresses.
  • openframe-data-mongo-sync/src/main/java/com/openframe/data/repository/device/publishing/MachineOnClientTicketsProjection.java:141 findMachines queries across multiple tenants with no bound other than set membership: findMachines is bounded by the reconcile() batch's tenantIds/machineIds sets derived from projectedItems, which itself is presumably a bounded reconciliation batch; the $in query is scoped to that known key set, matching the rule's compliant pattern rather than violating it.
  • openframe-api-lib/src/main/java/com/openframe/api/service/ticket/TicketService.java:144 5 new or changed definitions have no test referencing them: Generic missing-test notice for new/changed definitions in a PR that already adds three dedicated test files (ClientOwnerScopeResolverTest, TicketServiceClientOwnerScopeTest, MachineOnClientTicketsProjectionTest, TicketProjectionRepositoryTest); not a specific gap worth flagging without checking test contents.
  • openframe-data-mongo-sync/src/main/java/com/openframe/data/repository/ticket/CustomTicketRepositoryImpl.java:133 Compound boolean expression in createdAtFrom is not extracted to a named predicate: createdAtFrom is a tiny null-coalescing/min-max helper already named descriptively; the rule targets readability of conditions in if-statements, not every ternary inside a small well-named static method.

Review again. New commits are not reviewed until you ask:

  • Review the new commits: only what was pushed since this review
  • Review the whole diff again: everything, including what was already reviewed

Or comment @flamingo-review (new commits) or @flamingo-review full (everything). Add the flamingo-review-always label to review every push.

🧪 Tests and mutation

Tests per lane

Language Project Command Status Counts Time
Java (Maven) . mvn -B -s ./.mvn/settings.xml test -pl openframe-api-lib,openframe-client-core,openframe-data-mongo-common,openframe-data-mongo-sync,openframe-external-api-service-core -am ✅ passed openframe-agent-key 4 · openframe-api-lib 810 · openframe-client-core 464 (4 skipped) · openframe-core 232 · openframe-core-crypto 8 · openframe-data-cassandra 20 · openframe-data-kafka 39 · openframe-data-loki 96 · openframe-data-mongo-sync 1874 (288 skipped) · openframe-data-nats 180 (4 skipped) · openframe-data-pinot 82 · openframe-data-timeentry-aspect 3 · openframe-event-publishing 103 (32 skipped) · openframe-exception 4 · openframe-external-api-service-core 634 · openframe-machine-delivery 147 · openframe-security-core 38 · fleetmdm 60 · 0 failures 383.1 s

Mutation testing

This build has no PIT plugin, so each module is mutated from the command line with pit-adhoc.sh, changing nothing in the repository; no production class changed in openframe-external-api-service-core: nothing there to mutate.

Module Classes Whole classes New lines only Time
api-lib ClientOwnerScopeResolver, TicketService 163 mutants, 76 killed (47%), 22 survived, 65 no coverage, test strength 78%, line coverage 64% 27 mutants: 21 killed, 3 survived, 3 no coverage 85 s
client-core AgentRegistrationService 55 mutants, 0 killed (0%), 55 no coverage, line coverage 0% 6 mutants: 6 no coverage 32 s
data-mongo-sync CustomTicketRepository, CustomTicketRepositoryImpl, MachineAggregateSpec, MachineEvent, MachineOnClientTicketsProjection, MachineWriter, TicketProjectionRepository 199 mutants, 101 killed (51%), 25 survived, 73 no coverage, test strength 80%, line coverage 58% 56 mutants: 51 killed, 1 survived, 4 no coverage 57 s
data-mongo-common Machine, ClientTicketOwner, ClientOwnerScope Gap: the module has no tests, so PIT was not run (every mutant would survive)

New code, its covering tests and the result

New code Covering tests Result
isOwnerScoped in ClientOwnerScopeResolver, line 27 ClientOwnerScopeResolverTest (1) killed
scopeOf in ClientOwnerScopeResolver, lines 33-36 ClientOwnerScopeResolverTest (3) killed
forMachine in ClientOwnerScopeResolver, lines 41-49 ClientOwnerScopeResolverTest (3), 1 more killed
getTickets in TicketService, line 94 TicketServiceStatusFilterTest (1), TicketServiceGetTicketsTest (1), TicketServicePaginationTest (1), 22 more killed
getTicket in TicketService, lines 125-129 TicketServiceClientOwnerScopeTest (3), 2 more killed
lambda$getTicket$0 in TicketService, line 130 TicketServiceClientOwnerScopeTest (3), 1 more killed
getTicketByNumber in TicketService, lines 136-140 TicketServiceClientOwnerScopeTest (2) 1 killed. Survived: line 140: replaced return value with Optional.empty for TicketService::getTicketByNumber. No coverage (line 137)
lambda$getTicketByNumber$0 in TicketService, line 141 TicketServiceClientOwnerScopeTest (2) 1 killed. Survived: line 141: replaced boolean return with false for TicketService::lambda$getTicketByNumber$0
createTicket in TicketService, lines 168-171 TicketServiceDeviceNameTest (1), TicketServiceInsightLinkTest (2), 3 more 1 killed. Survived: line 171: removed call to Ticket::setOwner
createTicketFromDialog in TicketService, line 210 TicketServiceClientOwnerScopeTest (1) killed
createEscalationTicket in TicketService, line 236 none no coverage (line 236)
buildTicketQuery in TicketService, line 438 TicketServicePaginationTest (1), TicketServiceStatusFilterTest (1), TicketServiceDeviceFilterTest (1), 22 more killed
populateClientOrigin in TicketService, lines 491-496 TicketServiceClientOwnerScopeTest (1), TicketServiceDeviceNameTest (1) 1 killed. No coverage (line 491)
createMachine in AgentRegistrationService, line 138 none no coverage (line 138)
updateMachine in AgentRegistrationService, line 196 none no coverage (line 196)
isNewEnrollment in AgentRegistrationService, line 209 none no coverage (line 209)
lambda$isNewEnrollment$0 in AgentRegistrationService, line 210 none no coverage (line 210)
projections in MachineAggregateSpec, line 38 MachineAggregateSpecTest (1) killed
name in MachineOnClientTicketsProjection, line 41 MachineOnClientTicketsProjectionTest (1) killed
apply in MachineOnClientTicketsProjection, line 49 MachineOnClientTicketsProjectionTest (3) killed
countChanges in MachineOnClientTicketsProjection, lines 62-65 MachineOnClientTicketsProjectionTest (2) killed
applyBatch in MachineOnClientTicketsProjection, lines 74-77 MachineOnClientTicketsProjectionTest (2) killed
projectedClass in MachineOnClientTicketsProjection, line 83 none no coverage (line 83)
projectedViewClass in MachineOnClientTicketsProjection, line 88 none no coverage (line 88)
reconcile in MachineOnClientTicketsProjection, lines 96-115 MachineOnClientTicketsProjectionTest (3) killed
lambda$reconcile$0 in MachineOnClientTicketsProjection, line 101 MachineOnClientTicketsProjectionTest (2) killed
lambda$reconcile$1 in MachineOnClientTicketsProjection, line 104 MachineOnClientTicketsProjectionTest (2) killed
lambda$reconcile$2 in MachineOnClientTicketsProjection, line 109 MachineOnClientTicketsProjectionTest (1) killed
lambda$reconcile$3 in MachineOnClientTicketsProjection, line 112 MachineOnClientTicketsProjectionTest (1) killed
archivedStatusId in MachineOnClientTicketsProjection, lines 120-127 MachineOnClientTicketsProjectionTest (3), 1 more 2 killed. Survived: line 124: negated conditional
isOpenClientTicketWithSnapshot in MachineOnClientTicketsProjection, lines 131-134 MachineOnClientTicketsProjectionTest (3) killed
clientOwner in MachineOnClientTicketsProjection, line 138 MachineOnClientTicketsProjectionTest (1) killed
findMachines in MachineOnClientTicketsProjection, line 147 MachineOnClientTicketsProjectionTest (1) killed
toMismatch in MachineOnClientTicketsProjection, lines 154-158 MachineOnClientTicketsProjectionTest (1) killed
buildTicketQuery in CustomTicketRepositoryImpl, lines 127-128 CustomTicketRepositoryFilterTest (3), 14 more killed
createdAtFrom in CustomTicketRepositoryImpl, lines 134-139 CustomTicketRepositoryFilterTest (3), 14 more killed
applyOwnerScope in CustomTicketRepositoryImpl, lines 145-149 CustomTicketRepositoryFilterTest (3), 14 more killed
findStatusId in TicketProjectionRepository, line 161 TicketProjectionRepositoryTest (1) killed
archiveClientTicketsOfOtherOrganizations in TicketProjectionRepository, line 169 TicketProjectionRepositoryTest (1) killed
countClientTicketsOfOtherOrganizations in TicketProjectionRepository, line 176 none no coverage (line 176)
The covering tests by name (32 methods)
  • ClientOwnerScopeResolver.isOwnerScoped: ClientOwnerScopeResolverTest.isOwnerScoped_onlyForAgents
  • ClientOwnerScopeResolver.scopeOf: ClientOwnerScopeResolverTest.scopeOf_agentOfUnknownMachine_scopeWithoutOrganization, ClientOwnerScopeResolverTest.scopeOf_agentWithoutMachineId_forbidden, ClientOwnerScopeResolverTest.scopeOf_agent_carriesTheMachinesCurrentOrganization
  • ClientOwnerScopeResolver.forMachine: ClientOwnerScopeResolverTest.scopeOf_agentOfUnknownMachine_scopeWithoutOrganization, ClientOwnerScopeResolverTest.forMachine_blankMachineId_rejected, ClientOwnerScopeResolverTest.forMachine_knownMachine_scopeCarriesItsCurrentOrganization, and 1 more
  • TicketService.getTickets: TicketServiceStatusFilterTest.getTickets_forAgent_isScopedToTheOwningMachine, TicketServiceGetTicketsTest.getTickets_agentPrincipal_queryScopedToOwnMachine, TicketServicePaginationTest.getTickets_onAnEmptyPage_hasNoCursors, and 22 more
  • TicketService.getTicket: TicketServiceClientOwnerScopeTest.getTicket_admin_unscopedLookup, TicketServiceClientOwnerScopeTest.getTicket_agentAndTicketCreatedUnderCurrentOrganization_found, TicketServiceClientOwnerScopeTest.getTicket_agentAndTicketWithoutSnapshot_stillFound, and 2 more
  • TicketService.lambda$getTicket$0: TicketServiceClientOwnerScopeTest.getTicket_agentAndTicketCreatedUnderCurrentOrganization_found, TicketServiceClientOwnerScopeTest.getTicket_agentAndTicketWithoutSnapshot_stillFound, TicketServiceClientOwnerScopeTest.getTicket_agentAndTicketFromBeforeTheCurrentEnrollment_notFound, and 1 more
  • TicketService.getTicketByNumber: TicketServiceClientOwnerScopeTest.getTicketByNumber_agentAndTicketCreatedUnderPreviousOrganization_notFound, TicketServiceClientOwnerScopeTest.getTicketByNumber_agentAndTicketFromBeforeTheCurrentEnrollment_notFound
  • TicketService.lambda$getTicketByNumber$0: TicketServiceClientOwnerScopeTest.getTicketByNumber_agentAndTicketCreatedUnderPreviousOrganization_notFound, TicketServiceClientOwnerScopeTest.getTicketByNumber_agentAndTicketFromBeforeTheCurrentEnrollment_notFound
  • TicketService.createTicket: TicketServiceDeviceNameTest.anAgentTicket_takesTheNicknameOfItsOwnDevice, TicketServiceInsightLinkTest.aBlankInsightIsTreatedAsNoLink, TicketServiceInsightLinkTest.aTicketFiledFromAnInsightIsLinkedToIt, and 3 more
  • TicketService.createTicketFromDialog: TicketServiceClientOwnerScopeTest.createTicketFromDialog_agent_ownerSnapshotsTheMachinesCurrentOrganization
  • TicketService.buildTicketQuery: TicketServicePaginationTest.getTickets_onAnEmptyPage_hasNoCursors, TicketServiceStatusFilterTest.getTickets_withoutFilter_appliesNoStatusNarrowing, TicketServiceDeviceFilterTest.getTickets_forwardsDeviceIdsToTheQuery, and 22 more
  • TicketService.populateClientOrigin: TicketServiceClientOwnerScopeTest.createTicketFromDialog_agent_ownerSnapshotsTheMachinesCurrentOrganization, TicketServiceDeviceNameTest.anAgentTicket_takesTheNicknameOfItsOwnDevice
  • MachineAggregateSpec.projections: MachineAggregateSpecTest.theSpec_isTheMachinesType_withTheTicketProjections
  • MachineOnClientTicketsProjection.name: MachineOnClientTicketsProjectionTest.everyViewField_isATicketProperty_storedUnderTheSameName
  • MachineOnClientTicketsProjection.apply: MachineOnClientTicketsProjectionTest.aMachineWithoutAnOrganization_archivesNothing, MachineOnClientTicketsProjectionTest.anEvent_archivesTheClientTicketsOpenedUnderAnotherCustomer_intoTheTenantsArchivedStatus, MachineOnClientTicketsProjectionTest.aTenantWithoutAnArchivedStatus_archivesNothing
  • MachineOnClientTicketsProjection.countChanges: MachineOnClientTicketsProjectionTest.theChanges_areCounted_andWrittenInBatches, MachineOnClientTicketsProjectionTest.aMachineWithoutAnOrganization_archivesNothing
  • MachineOnClientTicketsProjection.applyBatch: MachineOnClientTicketsProjectionTest.aTenantWithoutAnArchivedStatus_archivesNothing, MachineOnClientTicketsProjectionTest.theChanges_areCounted_andWrittenInBatches
  • MachineOnClientTicketsProjection.reconcile: MachineOnClientTicketsProjectionTest.anOpenTicketOfAPreviousCustomer_isAMismatch_butArchivedAdminAndGoneMachineTicketsAreNot, MachineOnClientTicketsProjectionTest.ticketsWithoutAClientSnapshot_areSkipped_withoutAQuery, MachineOnClientTicketsProjectionTest.ticketsOfATenantWithoutAnArchivedStatus_areNoMismatch
  • MachineOnClientTicketsProjection.lambda$reconcile$0: MachineOnClientTicketsProjectionTest.anOpenTicketOfAPreviousCustomer_isAMismatch_butArchivedAdminAndGoneMachineTicketsAreNot, MachineOnClientTicketsProjectionTest.ticketsOfATenantWithoutAnArchivedStatus_areNoMismatch
  • MachineOnClientTicketsProjection.lambda$reconcile$1: MachineOnClientTicketsProjectionTest.anOpenTicketOfAPreviousCustomer_isAMismatch_butArchivedAdminAndGoneMachineTicketsAreNot, MachineOnClientTicketsProjectionTest.ticketsOfATenantWithoutAnArchivedStatus_areNoMismatch
  • MachineOnClientTicketsProjection.lambda$reconcile$2: MachineOnClientTicketsProjectionTest.anOpenTicketOfAPreviousCustomer_isAMismatch_butArchivedAdminAndGoneMachineTicketsAreNot
  • MachineOnClientTicketsProjection.lambda$reconcile$3: MachineOnClientTicketsProjectionTest.anOpenTicketOfAPreviousCustomer_isAMismatch_butArchivedAdminAndGoneMachineTicketsAreNot
  • MachineOnClientTicketsProjection.archivedStatusId: MachineOnClientTicketsProjectionTest.anEvent_archivesTheClientTicketsOpenedUnderAnotherCustomer_intoTheTenantsArchivedStatus, MachineOnClientTicketsProjectionTest.theChanges_areCounted_andWrittenInBatches, MachineOnClientTicketsProjectionTest.aMachineWithoutAnOrganization_archivesNothing, and 1 more
  • MachineOnClientTicketsProjection.isOpenClientTicketWithSnapshot: MachineOnClientTicketsProjectionTest.anOpenTicketOfAPreviousCustomer_isAMismatch_butArchivedAdminAndGoneMachineTicketsAreNot, MachineOnClientTicketsProjectionTest.ticketsWithoutAClientSnapshot_areSkipped_withoutAQuery, MachineOnClientTicketsProjectionTest.ticketsOfATenantWithoutAnArchivedStatus_areNoMismatch
  • MachineOnClientTicketsProjection.clientOwner: MachineOnClientTicketsProjectionTest.anOpenTicketOfAPreviousCustomer_isAMismatch_butArchivedAdminAndGoneMachineTicketsAreNot
  • MachineOnClientTicketsProjection.findMachines: MachineOnClientTicketsProjectionTest.anOpenTicketOfAPreviousCustomer_isAMismatch_butArchivedAdminAndGoneMachineTicketsAreNot
  • MachineOnClientTicketsProjection.toMismatch: MachineOnClientTicketsProjectionTest.anOpenTicketOfAPreviousCustomer_isAMismatch_butArchivedAdminAndGoneMachineTicketsAreNot
  • CustomTicketRepositoryImpl.buildTicketQuery: CustomTicketRepositoryFilterTest.buildTicketQuery_noOwnerScope_noOwnerClauses, CustomTicketRepositoryFilterTest.buildTicketQuery_ownerScopeWithoutOrganization_machineOnly, CustomTicketRepositoryFilterTest.buildTicketQuery_ownerScopeWithCutOffAndNoFilter_createdAtStartsAtTheCutOff, and 14 more
  • CustomTicketRepositoryImpl.createdAtFrom: CustomTicketRepositoryFilterTest.buildTicketQuery_noOwnerScope_noOwnerClauses, CustomTicketRepositoryFilterTest.buildTicketQuery_ownerScopeWithoutOrganization_machineOnly, CustomTicketRepositoryFilterTest.buildTicketQuery_ownerScopeWithCutOffAndNoFilter_createdAtStartsAtTheCutOff, and 14 more
  • CustomTicketRepositoryImpl.applyOwnerScope: CustomTicketRepositoryFilterTest.buildTicketQuery_noOwnerScope_noOwnerClauses, CustomTicketRepositoryFilterTest.buildTicketQuery_ownerScopeWithoutOrganization_machineOnly, CustomTicketRepositoryFilterTest.buildTicketQuery_ownerScopeWithOrganization_machineAndOrganizationSnapshotOrLegacyNull, and 14 more
  • TicketProjectionRepository.findStatusId: TicketProjectionRepositoryTest.findStatusId_readsTheTenantsStatusOfThatKind
  • TicketProjectionRepository.archiveClientTicketsOfOtherOrganizations: TicketProjectionRepositoryTest.archive_matchesOnlyTheMachinesOpenClientTicketsWithAnotherCustomersSnapshot_andArchivesThem

17 mutants on lines this change added are not caught (4 survived, 13 with no test reaching them): each is annotated on its line in the Flamingo Code Review / tests and mutation check.

1 gap (not tested here):

  • Java (Maven) .: TicketClientOwnerView.java, MachineFields.java changed but not mutation-tested (outside the mutation targets openframe-data-mongo-sync configures)

Started 2026-11-13 12:06 UTC · updated 2026-11-13 12:09 UTC · workflow run

…nt tickets and scope Fae reads by it

A device re-enrolled under another customer keeps its machineId, and every Fae read was scoped by
owner.machineId alone, so the new customer saw the previous customer's tickets. ClientTicketOwner now
records the organization the machine belonged to at creation; ClientOwnerScope (machine + current
organization) decides what an AGENT may see and is applied to the ticket list query and the single
ticket reads. A snapshot that is still missing stays visible until the new Mongock unit backfills it
from the ticket's organization or the machine's current one.
… previous customer through the machines cascade

MachineEvent now carries the machine's organization, so a reinstall under another customer publishes
the change. MachineOnClientTicketsProjection, registered on the machines spec and run by the shared
stream like its siblings, moves every client ticket of the machine whose owner snapshot names another
customer to the tenant's ARCHIVED status; a machine without an organization or a tenant without an
ARCHIVED status archives nothing. MachineWriter publishes organizationId writes like the other event
fields. The ticket owner backfill moves to openframe-saas-tenant with the other change units.
…e, scope as a class, reconcile skips unarchivable tenants

Review follow-ups: an AGENT token without a machineId is refused instead of matching every owner without
one; ClientOwnerScope is a Lombok class and the resolver exposes isOwnerScoped/scopeOf instead of an
Optional; MachineOnClientTicketsProjection.reconcile ignores tenants without an ARCHIVED status, which
apply could never repair; TicketProjectionRepository gets its query tests.
@hryhorii-chuhuievets
hryhorii-chuhuievets force-pushed the feat/fae-client-owner-organization branch from 9ad350c to 0979803 Compare November 9, 2026 13:21
@hryhorii-chuhuievets hryhorii-chuhuievets added the build Run the PR builds and publish snapshots (Java, npm preview); stays on until removed label Nov 9, 2026
…ent enrollment

A reinstall under another customer stamps Machine.organizationAssignedAt; the
owner scope then hides client tickets created before it, so a device that
comes back to a customer starts clean.
…-organization

# Conflicts:
#	openframe-api-lib/src/main/java/com/openframe/api/service/ticket/TicketService.java
…-organization

# Conflicts:
#	openframe-data-mongo-sync/src/main/java/com/openframe/data/repository/device/publishing/MachineEvent.java
@hryhorii-chuhuievets

Copy link
Copy Markdown
Contributor Author

@flamingo-review

@hryhorii-chuhuievets
hryhorii-chuhuievets added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit 3ec3d40 Nov 13, 2026
20 checks passed
@hryhorii-chuhuievets
hryhorii-chuhuievets deleted the feat/fae-client-owner-organization branch November 13, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Run the PR builds and publish snapshots (Java, npm preview); stays on until removed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants