The Osupdate Services module provides the device-side operating-system update domain services used by the OpenFrame client. It turns device reports into durable update inventory, pending-update state, installation history, reboot state, and device-level status. It also classifies updates and emits an event-log record for newly observed installation history.
The implementation is supplied by the com.openframe.oss:openframe-client-core library at version 7.0.11 and runs in this repository's openframe/services/openframe-client service. The source files are maintained in OpenFrame OSS Library.
The module has five related responsibilities:
- Update catalog management: Store updates by identifier, fill in incomplete metadata from later reports, and recalculate classifications.
- Device state management: Accept only the newest device OS-state report and preserve the start time of an ongoing reboot requirement.
- Pending-update reconciliation: Treat each pending-update report as the device's complete current list, preserve discovery timestamps, and retain failure context.
- Installation-history retention: Store previously unseen history entries within the configured retention period and publish known outcomes to the event log.
- Device inventory projection: Combine pending updates, successful installation history, and stored state into
OsUpdateDevicerecords with statuses such as installed, not installed, failed, and restart pending.
The module is a service layer over OS-update documents and repositories. Device reports enter through the surrounding RMM reporting pipeline. The services reconcile those reports, persist changes, update report metrics, and publish durable history events.
flowchart LR
Report["Device OS Update Report"] --> Catalog["OsUpdateService"]
Report --> State["DeviceOsStateService"]
Report --> Pending["DeviceOsPendingUpdateService"]
Report --> History["DeviceOsUpdateHistoryService"]
State --> Projection["OsUpdateDeviceService"]
Pending --> Projection
History --> Projection
Catalog --> CatalogStore["OsUpdate Repository"]
State --> StateStore["Device OS State Repository"]
Pending --> PendingStore["Pending Update Repository"]
History --> HistoryStore["Update History Repository"]
Projection --> DeviceStore["OS Update Device Repository"]
History --> Log["Event Logs Publisher"]
Catalog --> Metrics["Device OS Report Metrics"]
State --> Metrics
Pending --> Metrics
History --> Metrics
| Component | Responsibility | Main persistence or delivery boundary |
|---|---|---|
OsUpdateService |
Stores catalog updates for a tenant and platform, classifies new updates, and refreshes incomplete or reclassified records. | OsUpdateRepository |
StoredOsUpdateRefresher |
Copies missing category IDs and update type from a later report, then recalculates classification. | Mutates an existing OsUpdate before it is saved |
OsUpdateClassifier |
Applies the ordered Windows classification rules and returns OTHER for non-Windows updates or unmatched metadata. |
In-memory classification |
DeviceOsStateService |
Rejects older reports, replaces newer state, and tracks continuous reboot-pending time. | DeviceOsStateRepository |
DeviceOsPendingUpdateService |
Reconciles the complete pending-update list, preserving identity and discovery time for continuing updates. | DeviceOsPendingUpdateRepository |
DeviceOsUpdateHistoryService |
Filters history to the retention window and saves entries not already present by entry key. | DeviceOsUpdateHistoryRepository |
DeviceOsUpdateHistoryLogService |
Converts known history outcomes into Debezium-style create events and publishes them. | EventLogsPublisher |
OsUpdateDeviceService |
Projects pending and installed facts into per-device update records and derives their status. | OsUpdateDeviceRepository |
A report can contain catalog updates, device state, pending updates, and history entries. The surrounding client workflow should persist the constituent facts before building the device projection, because OsUpdateDeviceService uses the reconciled pending list and history to determine the device's current inventory.
flowchart TD
Start["Receive device report"] --> CatalogStep["Save and classify reported updates"]
CatalogStep --> StateStep["Accept state if not older"]
StateStep --> HistoryStep["Retain unseen history entries"]
HistoryStep --> PendingStep["Replace current pending list"]
PendingStep --> ProjectionStep["Build OS update device projection"]
ProjectionStep --> EventStep["Publish known history outcomes"]
EventStep --> EndStep["Record metrics and finish"]
OsUpdateClassifier classifies only Windows updates using Microsoft category identifiers. The first matching rule wins:
- Non-Windows updates are
OTHER. - Driver updates are
DRIVER. - The Windows upgrade category is
OS_VERSION. - Browse-only updates are
PREVIEW. - The security category is
SECURITY. - Critical updates, update rollups, ordinary updates, and service packs are
QUALITY. - Anything else is
OTHER.
Category identifiers are normalized to lower case and null values are ignored. This makes classification insensitive to the case used by a device report.
OsUpdateService.saveReported assumes one report belongs to one tenant and platform. It loads existing records by identifier, then processes each reported update:
- A new update is classified and saved individually. A duplicate-key race caused by another device report is logged at debug level and does not prevent the remaining updates from being processed.
- An existing update is passed to
StoredOsUpdateRefresher. - Missing category IDs and missing update type are filled only when the later report supplies them. Non-empty stored values are not overwritten by empty or null values.
- Classification is recalculated on every refresh, so a rule change can update the stored classification even when no metadata was filled in.
- Refreshed records are saved as a batch and reclassification metrics are recorded per affected platform.
This design makes the first complete description authoritative for most fields while still allowing later reports to improve incomplete metadata.
DeviceOsStateService.saveIfNotOlder implements report ordering using receivedAt:
- If no state exists, the report is saved.
- If the report is older than the stored state, it is rejected and returns
false. - If the report is equal or newer, it replaces the stored document and returns
true.
When rebootPending is YES, rebootPendingSince is preserved across reports. It is initialized from the first report's receivedAt and cleared when a report says that a reboot is no longer pending. Repository version information is copied to replacements so optimistic concurrency can cause a stale save to fail and be retried by the delivery workflow instead of overwriting a newer report.
DeviceOsPendingUpdateService.replacePendingUpdates treats the reported pending list as a full snapshot:
- Load the stored pending updates for the tenant and machine.
- Delete stored identifiers absent from the report.
- Match reported updates by identifier.
- For continuing updates, preserve the stored database ID and
discoveredAttimestamp. - For new updates, use the reported object and its discovery time.
- Derive
lastInstallFailedAtfrom the latest reported install history, while retaining a stored failure when the new report has shorter history. - Save only new or changed records.
Install history is compared by installedAt. Failed and aborted installs count as failures. If multiple entries share a timestamp, the non-failed result wins for the failure timestamp decision. This avoids incorrectly leaving an update marked as failed when a same-time successful outcome is the latest result.
The service records counts for added, changed, and removed pending updates through DeviceOsReportMetrics.
DeviceOsUpdateHistoryService.saveMissing first applies DeviceOsUpdateHistoryEntry.RETENTION. Entries outside the window are discarded before lookup, preventing an old entry repeated in a device report from being reintroduced after expiration. Remaining entries are compared by entryKey within the tenant and machine scope, and only missing entries are saved.
DeviceOsUpdateHistoryLogService.logNewEntries handles the entries returned by the save operation. It publishes only entries with both a known operation and a known result. Each event contains the tenant, machine, entry key, update identifier, title, operation, result, error code, and installation timestamp. The event is wrapped as a Debezium create payload and marked with the OS_UPDATE_HISTORY_EVENT message type.
sequenceDiagram
participant Client as "OpenFrame Client"
participant History as "History Service"
participant Repository as "History Repository"
participant Logger as "History Log Service"
participant Events as "Event Logs Publisher"
Client->>History: Report installation history
History->>History: Apply retention window
History->>Repository: Find stored entry keys
Repository-->>History: Existing keys
History->>Repository: Save missing entries
Repository-->>History: Newly saved entries
History-->>Logger: Newly saved entries
Logger->>Logger: Drop entries with unknown outcome
Logger->>Events: Publish OS update history event
OsUpdateDeviceService.replaceOsUpdateDevices creates the device-facing projection used for update inventory and status queries. It combines:
- Existing
OsUpdateDevicerecords. - Current pending updates.
- Successful retained history entries.
- The latest install entry, including failed installs used for error context.
- The current
DeviceOsState, including platform and manageability.
An update is included when it is pending or has a retained successful installation. For a device marked NOT_MANAGEABLE, pending updates are excluded from the projection, so pending counts do not imply that the device can be managed.
The derived status follows this order:
| Condition | Status |
|---|---|
| No pending update exists | INSTALLED |
| A pending update has a recorded failed or aborted install | FAILED |
| A pending update requires reboot | RESTART_PENDING |
| Otherwise | NOT_INSTALLED |
The installed timestamp is preserved until a later successful install or uninstall is reported. A shorter history report therefore cannot erase a previously known installation. The same preservation rule applies to the last failure and its error code when the failing entry is absent from a later report.
The module relies on repository operations supplied by the OpenFrame data libraries. Its consistency rules are intentionally different for each data shape:
- Catalog updates: Duplicate-key races are tolerated per update, allowing the rest of a report to continue.
- Device state: Newer
receivedAtwins, with repository versioning protecting replacement writes. - Pending updates: The report is authoritative for membership, but stored identity and discovery time survive for continuing identifiers.
- History: Entry keys provide idempotency, and retention prevents old entries from returning.
- Device projection: Stored installed and failure facts survive incomplete or shorter reports unless a later definitive outcome supersedes them.
- History events: Only newly stored entries with known operation and result are published, avoiding duplicate event emission from repeated reports.
All report-oriented services use DeviceOsReportMetrics to expose processing outcomes. The recorded dimensions include:
- First state reports and report intervals by platform.
- Pending updates added, changed, and removed.
- History entries outside retention and entries saved.
- History log events published.
- New catalog updates saved and existing updates reclassified.
These metrics help distinguish an empty device report, a report that removed state, and a report whose data was ignored because it was older or outside retention.
The implementation is in the openframe-oss-lib repository and is consumed by this repository's OpenFrame client service. The following links point to the exact source revision supplied in the component metadata:
- DeviceOsPendingUpdateService
- DeviceOsStateService
- DeviceOsUpdateHistoryLogService
- DeviceOsUpdateHistoryService
- OsUpdateClassifier
- OsUpdateDeviceService
- OsUpdateService
- StoredOsUpdateRefresher
Osupdate Services is an idempotent reconciliation layer rather than a package-installation engine. It does not itself execute an OS update. Instead, it records what the device reports, derives a stable view of pending and installed updates, preserves facts that shorter reports cannot safely invalidate, and emits durable history events for downstream processing and observability.