Skip to content

feat(os-update): device lists of a policy and Add All Devices at save CU-17tkuw67mjh - #3331

Merged
semen-flamingo merged 4 commits into
mainfrom
feat/os-update-policy-devices
Dec 4, 2026
Merged

semen-flamingo merged 4 commits into
mainfrom
feat/os-update-policy-devices

Conversation

@semen-flamingo

@semen-flamingo semen-flamingo commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

What

The device picker of the OS auto-update policy form (tabs Available Devices / Selected Devices, search, filter funnels, Add All Devices) gets the API it needs. The policy is still saved as a whole with machineIds; the form keeps the selection itself.

Stacked on #3330 (the removal of the Advanced settings): the base of this PR is that branch.

Read

  • OsUpdatePolicy.deviceCount: number of devices the policy names (machineIds). The policies list still costs one query.
  • OsUpdatePolicy.assignedDevices(filter, search, sort, first, after, last, before): DeviceConnection!: the devices the policy names, filtered, searched, sorted and paged as the devices query. The Selected Devices tab.
  • OsUpdatePolicy.assignedDeviceFilters(filter, search): DeviceFilters!: the filter options of that list with their counts.
  • osUpdatePolicyAssignableDevices gains filter: DeviceFilterInput (the Customer funnel and the others of the devices table).
  • New osUpdatePolicyAssignableDeviceFilters(filter, search): DeviceFilters!: the filter options of the Available Devices tab.

The set of assignable devices is unchanged and still decided in one place, OsUpdatePolicyDeviceChecker: the device reported its OS, Windows, manageable, in no other policy. The filter and the search only narrow it.

Add All Devices

A new optional argument of both save mutations, as on addAllDevicesToSoftwareBundle:

createOsUpdatePolicy(input: OsUpdatePolicyInput!, allAssignableDevices: OsUpdatePolicyAllAssignableDevicesInput): OsUpdatePolicy!
updateOsUpdatePolicy(id: ID!, input: OsUpdatePolicyInput!, allAssignableDevices: OsUpdatePolicyAllAssignableDevicesInput): OsUpdatePolicy!

input OsUpdatePolicyAllAssignableDevicesInput { filter: DeviceFilterInput  search: String }

At save the backend finds every assignable device that matches the filter and the search and stores it in the policy together with machineIds. The argument is not stored. Null = only machineIds.

  • The filter passes through GraphQLDeviceMapper, as the filter of osUpdatePolicyAssignableDevices does: the same filter gives the same devices and the same refusal (mdmStates, diskEncryptionStates).
  • The stored list = machineIds + the found devices, each once.
  • "At least one device" is checked on that sum; when neither part gives a device, the refusal says so.
  • Race: a device taken by another policy between the read and the save hits the unique index; the whole save is refused with OS_UPDATE_POLICY_CONFLICT naming that policy and up to 10 devices.
  • Cost: three more reads at save (Windows OS states, the policies, the matching device ids). The ids are held in memory.

Code

  • No new service or repository. Reused: DeviceService.queryDevicesAmong, getDeviceFiltersAmong, GraphQLDeviceMapper.
  • Added: DeviceService.findDeviceIdsAmong (ids of the devices among a given set that match a filter and a search), OsUpdatePolicyService.getAssignableDeviceFilters, the wire class OsUpdatePolicyAllAssignableDevicesInput (api-service-core) and its service-side OsUpdatePolicyAllAssignableDevicesCriteria (api-lib), the same split as DeviceFilterInput / DeviceFilterCriteria.
  • OsUpdatePolicyValidator.validate takes one OsUpdatePolicyValidationContext instead of a row of collections.
  • A device given twice in machineIds is stored once.

Schema

Additive only. The tenant federation snapshot changes with the next lib bump.

Open

  • Turn On for All and default policies are not here; the product side is deciding their rules.

Tests

  • Unit: OsUpdatePolicyServiceTest, OsUpdatePolicyValidatorTest, OsUpdatePolicyResponseMapperTest, OsUpdatePolicyDataFetcherTest, OsUpdatePolicyAllAssignableDevicesInputBindingTest, GraphQLDeviceMapperTest, DeviceServiceTest, OsUpdateSchemaContractTest; the full unit run of api-lib and api-service-core is green.
  • Integration: OsUpdatePolicySettingsIT has new cases for the lists and Add All; they compile and were not run.

Change-Set: feat-os-update-policy-devices
Depends-On: #3330

🤖 Generated with Claude Code

https://claude.ai/code/session_01EnBSFTsNdA8c4yRH3Lehi4

Change set flamingo-stack/feat-os-update-policy-devices: these pull requests are one change, reviewed together.

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.

semen-flamingo and others added 2 commits December 3, 2026 16:11
…d security-only settings of the policy CU-17tkuw67mjh

The product dropped the Advanced block of the OS update policy form. The three settings leave the stored
document, the input, the response, the validation and the GraphQL schema, with OsUpdateInstallWindow and
the DayOfWeek enum that only they used. Documents stored with these fields are still read: nothing maps,
indexes or migrates them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EnBSFTsNdA8c4yRH3Lehi4
… CU-17tkuw67mjh

OsUpdatePolicy gets deviceCount, assignedDevices and assignedDeviceFilters; the assignable devices take the
devices filter and get their filter options (osUpdatePolicyAssignableDeviceFilters).
OsUpdatePolicyInput.allAssignableDevices adds every assignable device that matches a filter and search to
machineIds at save; it is resolved by the backend and not stored.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EnBSFTsNdA8c4yRH3Lehi4
@flamingo

flamingo Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

🦩 Flamingo Code Review

5 findings: 🔴 1 action required · 🟠 0 recommended · 🔵 4 informational

Advisory: findings do not block the merge.

Rules cited: OFJAVA-024, OFJAVA-003, OFJAVA-007, OFJAVA-022, OFJAVA-002

Files Lines 🔴 Action required 🟠 Recommended 🔵 Informational
17 +864 / -63 1 0 4

🔴 Action required (1)

# Where Finding Flagged by
1 OsUpdatePolicyAllAssignableDevicesInput.java:15 allAssignableDevices.filter binds GraphQL DeviceFilterInput straight onto the service criteria type, bypassing GraphQLDeviceMapper OFJAVA-024

🔵 Informational (4)

# Where Finding Flagged by
2 OsUpdateSchemaContractTest.java:432 OsUpdateSchemaContractTest unwraps Optional type lookups with .get() instead of a pipeline (Minor) OFJAVA-003
3 OsUpdatePolicyValidator.java:142 Compound || guard in validateMachineIds not extracted to a named predicate (Minor) OFJAVA-007
4 OsUpdatePolicyValidator.java:38 OsUpdatePolicyValidator.validate grows to six positional parameters, four of them Collections (Minor) OFJAVA-022
5 OsUpdatePolicyResponseMapper.java:28 machineIds.size() called inside the builder argument list in OsUpdatePolicyResponseMapper (Minor) OFJAVA-002

✅ What this change does well

  • OsUpdatePolicyService.mergeMachineIds uses a LinkedHashSet so a device given explicitly and resolved by "Add All Devices" is stored once, and the new service test createPolicy_deviceGivenTwice_storedOnce covers it.
  • The validator change distinguishes an empty machineIds with no allAssignableDevices from an allAssignableDevices that matched nothing, with a dedicated field error and tests for both branches in OsUpdatePolicyValidatorTest.
  • OsUpdateSchemaContractTest.java pins the new OsUpdatePolicy fields and asserts the assignable-devices arguments match Query.devices exactly, so schema drift between the two device lists fails the build.
  • OsUpdatePolicyInputBindingTest.java covers the non-obvious DGS binding of allAssignableDevices.filter straight to DeviceFilterCriteria, including the empty-input and absent-input cases.
  • OsUpdatePolicySettingsIT.java adds integration coverage that allAssignableDevices is not persisted on the policy document and that an empty match is refused with VALIDATION_ERROR.

Inline comments: 5 new

4 possible problems checked and ruled out
  • openframe-api-lib/src/main/java/com/openframe/api/dto/rmm/osupdate/OsUpdatePolicyResponse.java:10 OsUpdatePolicyResponse gains a field but still lacks @‍NoArgsConstructor/@‍AllArgsConstructor: OsUpdatePolicyResponse.java:10-12 has only @‍Data @‍Builder, but that is pre-existing (the PR only adds a field at line 20) and it is an outbound response never Jackson-deserialized, so no breakage.
  • openframe-api-service-core/src/main/java/com/openframe/api/datafetcher/rmm/OsUpdatePolicyDataFetcher.java:113 OsUpdatePolicy.assignedDevices/assignedDeviceFilters resolvers query DeviceService per policy row: The DataLoader rule names resolvers fetching a related entity; these resolvers take per-field pagination/filter/sort args (lines 100-116) which cannot be batched, and the candidate itself concedes this. Generic N+1 wish.
  • openframe-api-service-core/src/main/java/com/openframe/api/datafetcher/rmm/OsUpdatePolicyDataFetcher.java:93 deleteOsUpdatePolicy is changed and no test references it: deleteOsUpdatePolicy is a two-line delegate unchanged in substance; an integration test suite (OsUpdatePolicySettingsIT) exists for this feature. Missing-test on trivial delegation is noise.
  • openframe-api-service-core/src/test/java/com/openframe/api/integration/osupdate/OsUpdatePolicySettingsIT.java:300 New IT setup nests input(...) inside the create(...) argument list: Nested helper calls in integration-test setup (create(input(...)), new HashMap(input(...))), a pedantic style flag on test fixtures that a senior reviewer would not raise.
🤖 Prompt for AI agents: fix every finding
Address these code-review findings on pull request #3331 of flamingo-stack/openframe-oss-lib, most important first.
For each one, make the minimal change that resolves it and do not refactor unrelated code.
If you can show a finding is wrong, skip it and say why.

1. [Action required] openframe-api-lib/src/main/java/com/openframe/api/dto/rmm/osupdate/OsUpdatePolicyAllAssignableDevicesInput.java:15 allAssignableDevices.filter binds GraphQL DeviceFilterInput straight onto the service criteria type, bypassing GraphQLDeviceMapper
   The new mutation input field exposes the service-layer criteria class DeviceFilterCriteria as the GraphQL input type instead of an API class, and the comment admits GraphQL binds it field by field with no mapper. Every other device query goes through GraphQLDeviceMapper.toDeviceFilterCriteria (openframe-api-service-core/.../GraphQLDeviceMapper.java:35-55), which (a) rejects mdmStates/diskEncryptionStates with IllegalArgumentException("Filtering devices by MDM or disk encryption state is not available yet") and (b) maps only the supported subset. Binding DeviceFilterInput directly means those two fields are either silently dropped or fail to bind, while DeviceFilterCriteria-only fields (pattern, hostnames, nicknames, manageableByPackageManagers) become settable from the wire. So the device set the user previewed via osUpdatePolicyAssignableDevices (mapped) and the set the mutation resolves (unmapped) can differ for the same filter.
2. [Informational] openframe-api-service-core/src/test/java/com/openframe/api/schema/OsUpdateSchemaContractTest.java:432 OsUpdateSchemaContractTest unwraps Optional type lookups with .get() instead of a pipeline
   The new test osUpdatePolicyDeviceLists_... obtains Optional<ObjectTypeDefinition> from schema.getType(...) and then unwraps it with .get() (osUpdatePolicy.get(), and further down softwareBundle.get() twice at the verification block). OFJAVA-003 forbids calling .get() on an Optional: it must be consumed as a pipeline or with orElseThrow.
3. [Informational] openframe-api-lib/src/main/java/com/openframe/api/service/rmm/osupdate/OsUpdatePolicyValidator.java:142 Compound || guard in validateMachineIds not extracted to a named predicate
   The new guard combines two negated emptiness checks with `||` inline. OFJAVA-007 makes a named private predicate mandatory for any condition containing `&&` or `||`; here a method such as `namesAnyDevice(osUpdatePolicyInput, allAssignableMachineIds)` would state the intent. The call `CollectionUtils.isEmpty(osUpdatePolicyInput.getMachineIds())` additionally nests a method call inside an argument list, which OFJAVA-002 forbids.
4. [Informational] openframe-api-lib/src/main/java/com/openframe/api/service/rmm/osupdate/OsUpdatePolicyValidator.java:38 OsUpdatePolicyValidator.validate grows to six positional parameters, four of them Collections
   The change adds a sixth parameter, `allAssignableMachineIds`, to `validate`, leaving four same-shaped Collection arguments in a row. OFJAVA-022 requires such a data clump to become a parameter object (a Lombok command class, e.g. OsUpdatePolicyValidationRequest carrying the input, the resolved assignable ids, the other policies and the added device state).
5. [Informational] openframe-api-lib/src/main/java/com/openframe/api/mapper/OsUpdatePolicyResponseMapper.java:28 machineIds.size() called inside the builder argument list in OsUpdatePolicyResponseMapper
   The added line passes a method call as an argument, which PMD's NoMethodCallAsArgument (priority 1) fails the build on per OFJAVA-002. Extract the count into a named local before the builder chain.

Next: commit a suggestion, or hand a comment's prompt to your coding agent. React 👍 on a finding that helped and 👎 on one that is wrong: the reviewer learns from both.

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.

Updated 2026-12-03 15:35 UTC · reviewed from Semen Lisak's machine

@flamingo

flamingo Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

🦩 Flamingo Code Review / security

✅ No findings on the current head.

Advisory: findings do not block the merge.

Files Lines 🔴 Action required 🟠 Recommended 🔵 Informational
17 +864 / -63 0 0 0

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

  • Security-check the new commits: only what was pushed since this security review
  • Security-check the whole diff again: everything, including what was already checked

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

Updated 2026-12-03 15:39 UTC · reviewed from Semen Lisak's machine

…device filter, review notes CU-17tkuw67mjh

allAssignableDevices moves from OsUpdatePolicyInput to an argument of createOsUpdatePolicy and updateOsUpdatePolicy;
its filter goes through GraphQLDeviceMapper, so it gives the same set and the same refusal as the assignable list.
The validator takes one OsUpdatePolicyValidationContext; Optional.get, the || guard and nested calls are cleaned up.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EnBSFTsNdA8c4yRH3Lehi4
Base automatically changed from refactor/os-update-policy-remove-advanced to main December 4, 2026 11:33
@semen-flamingo
semen-flamingo dismissed yevhenii-flamingo’s stale review December 4, 2026 11:33

The base branch was changed.

…-devices

# Conflicts:
#	openframe-api-service-core/src/main/resources/schema/os-update-policy.graphqls
#	openframe-api-service-core/src/test/java/com/openframe/api/integration/osupdate/OsUpdatePolicySettingsIT.java
@semen-flamingo
semen-flamingo added this pull request to the merge queue Dec 4, 2026
Merged via the queue into main with commit 1543a45 Dec 4, 2026
29 checks passed
@semen-flamingo
semen-flamingo deleted the feat/os-update-policy-devices branch December 4, 2026 11:37
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