Package Manager Update Status
OpenFrame Documentation
Get the most out of OpenFrame · Book 30 minutes with Conrad, 25 years in IT. He'll show you what Mingo and Fae can take off your list.
OpenFrame Documentation
Package Manager Update Status is the OpenFrame client agent’s terminal-status reporting boundary for package update orders. It converts an order rejected before acceptance, or displaced by a newer request for the same package, into a structured package-update status event and hands that event to a durable outbox when one is available. This gives the control plane an explicit outcome rather than leaving an order silently unresolved.
The implementation is supplied by the openframe_agent_lib Cargo dependency from OpenFrame OSS Library and is executed by this repository’s OpenFrame client service. The implementation source is status.rs.
PackageUpdateStatusMessage events with a unique event identifier and an RFC 3339 UTC timestamp.Superseded failure for a pending order replaced by a newer request for the same package.ResultStore when durable storage is enabled, then wake the outbox flusher.The module does not execute package managers, choose update eligibility, or maintain the update queue. Those responsibilities belong to the surrounding package-update runner, update gate, and order store.
flowchart LR
CommandListener["Command listener"] --> PackageHandler["Package update handler"]
PackageHandler --> OrderStore["Order store"]
OrderStore --> UpdateRunner["Package update runner"]
UpdateRunner --> UpdateGate["Update gate"]
UpdateGate --> PackageManager["Package manager"]
PackageHandler --> StatusReporter["Status reporter"]
OrderStore --> StatusReporter
UpdateRunner --> StatusReporter
StatusReporter --> ResultStore["Durable result store"]
ResultStore --> OutboxRunner["Result outbox runner"]
OutboxRunner --> Nats["NATS JetStream"]
StatusReporter --> Nats
Nats --> Backend["Client service status processing"]
StatusReporter is constructed with a NatsMessagePublisher, a shared ResultStore, and a shared Notify handle. The command-side package update handler holds both an OrderStore and a StatusReporter; it can therefore close the reporting loop for requests that cannot be accepted. The same reporter’s internal event builder is also available to the package-update workflow for waiting, completed, and failed events.
| Component | Role |
|---|---|
StatusReporter |
Cloneable façade that logs, serializes, and delivers package-update status events. Its production sink is an outbox; test builds can use an in-memory event vector. |
StatusReporter::new |
Creates the production reporter from the NATS publisher, durable result store, and outbox wake notification. |
StatusReporter::report_rejected |
Emits a failed status for an update message refused before it was admitted to the order store. It preserves the message request, source, and package fields and attaches the caller-provided failure reason and explanation. |
StatusReporter::report_superseded |
Emits a failed status for an existing order displaced by a newer request that matches the same package. It uses FailReason::Superseded and the fixed detail that a newer request replaced the order. |
build |
Internal event constructor used by the update workflow. It assigns identifiers and timestamps, carries optional installed and available versions, and maps waiting, done, or failure reports into the correct status fields. |
outbox_key |
Produces a time-first key with the event identifier as a tie breaker so persisted events are read in event order. |
rfc3339 |
Converts a Unix timestamp to an RFC 3339 UTC string for status-related time values. |
Each PackageUpdateStatusMessage contains:
| Field group | Contents |
|---|---|
| Identity | event_id, request_id, and machine_id identify the individual status event, requested operation, and target agent. |
| Time and target | at is generated as an RFC 3339 UTC timestamp with millisecond precision. source and package retain the dispatch origin and package reference. |
| Version context | installed_version and available_version are optional. Rejection and supersession reports intentionally leave both absent because no installation attempt is represented. |
| State | state is Waiting, Done, or Failed. Only the payload corresponding to the selected state is populated. |
| Waiting details | A waiting event may state why it waits, the prompt or countdown phase, process holders, and an optional closing deadline. |
| Completion details | A done event records whether the package was upgraded or was already current, plus reboot and relaunch indicators. |
| Failure details | A failed event records a reason, optional exit code, and optional human-readable message. |
The failure taxonomy includes manager errors or absence, application-close failure, timeout, unsupported packages, supersession, missing installation, and packages that are not upgradable. report_rejected accepts the applicable failure reason from its caller; report_superseded always uses the supersession reason.
stateDiagram-v2
[*] --> Received
Received --> Rejected: "Request cannot enter order store"
Received --> Pending: "Order accepted"
Pending --> Superseded: "Newer matching package request"
Pending --> Waiting: "Update gate delays execution"
Waiting --> Installing: "Gate permits execution"
Installing --> Done: "Upgraded or already latest"
Installing --> Failed: "Manager or execution failure"
Rejected --> [*]
Superseded --> [*]
Done --> [*]
Failed --> [*]
The module is directly responsible for the two early terminal outcomes:
Failed with the reason and detail supplied by that handler.OrderStore::submit removes a pending, non-installing order when a newer message matches its package. The older order receives a Failed event with Superseded, while the new order becomes pending.A currently installing order is not replaced by the order-store supersession path. It is allowed to finish, and the newer request follows it. This avoids reporting an in-flight installation as superseded when it has already begun.
sequenceDiagram
participant Reporter as Status reporter
participant Store as Result store
participant Notify as Flush notification
participant Flusher as Outbox runner
participant Nats as NATS JetStream
Reporter->>Reporter: Serialize status event as JSON
alt Durable store enabled
Reporter->>Store: Enqueue ordered subject and payload
Reporter->>Notify: Wake flusher
Flusher->>Store: Read pending keys in key order
Flusher->>Nats: Publish and await acknowledgement
Nats-->>Flusher: Acknowledgement
Flusher->>Store: Remove delivered entry
else Durable store disabled
Reporter->>Nats: Publish and await acknowledgement
Nats-->>Reporter: Acknowledgement or error
end
When ResultStore::enabled is true, the reporter serializes the event and enqueues it using a key shaped as package-update-status:<nanosecond-time>:<event-id>. The timestamp prefix preserves the order in which events are delivered by the outbox. After successful persistence, it signals the shared notification handle and returns; it does not send the event directly.
ResultOutboxRunManager wakes on that notification or its periodic interval, loads pending entries in key order, publishes them, and removes each entry only after successful delivery. It applies the configured publish timeout. A transient publishing failure leaves the entry in the store for a later retry.
If durable storage is disabled, the reporter immediately calls publish_acked for the machine-specific subject and limits the wait with FLUSH_PUBLISH_TIMEOUT_SECS. Failures, timeouts, and serialization errors are logged. Because no durable store exists in this mode, a failed immediate publish cannot be retried by this module and the event may be lost.
The subject is derived from the machine identifier using package_update_status_subject, yielding the package-update status channel for that machine. The message is published through NATS JetStream with an acknowledgement on the direct fallback path. On the service side, the client-core Java package-update status listener and processor consume these device status messages to record package-update execution state for the backend.
flowchart TD
Event["Package update status event"] --> Subject["Machine-specific status subject"]
Subject --> Stream["NATS JetStream"]
Stream --> Listener["Package update status listener"]
Listener --> Processor["Package update status processor"]
Processor --> DeviceState["Device update state"]
Processor --> ExecutionRecord["Package update execution record"]
When evolving this module:
request_id, machine_id, source, and package intact across every terminal report; backend correlation depends on them.event_id as an event identifier, not an order identifier. A single request can produce multiple lifecycle events.