Repository navigation
feat: factory reset feature version 4, wcs service-info probe, drop reset mode 4 - #132
Conversation
…eature version 4 Adapt the factory-reset result wire types to the shape omnect-device-service publishes on FactoryResetV1 with factory_reset feature version 4: - status is a u32 with the codes success, invalid, error, configError and warning, plus a catch-all so a future code parses instead of failing the whole update - error and context arrive as null when nothing went wrong - data_wiped tells whether the destructive phase had already started Raise the required omnect-device-service version to 0.46.0. Signed-off-by: Jan Zachmann 50990105+JanZachmann@users.noreply.github.com
Use the service-info endpoint as the single availability probe. It returns version, interface name and live BLE state in one call, replacing the separate status and version requests. Report the version requirement the same way as for omnect-device-service: a semver requirement string plus a required/current/mismatch triple. Unlike the device service a stale wifi-commissioning-service does not block the UI, since WiFi is optional and gated on the socket being present — the mismatch shows in the WiFi section of the device info. Signed-off-by: Jan Zachmann 50990105+JanZachmann@users.noreply.github.com
service-info reports the version, so the separate version request has no caller left. Also correct the version floor comment: 0.2.0 already serves service-info, the floor tracks the released tag. Signed-off-by: Jan Zachmann 50990105+JanZachmann@users.noreply.github.com
Mode 4 ran a customer-supplied wipe hook in the initramfs. The hook is gone and the initramfs no longer accepts the mode: a trigger carrying it fails to parse, the device boots normally and no result is reported at all, so a reset requested with it would never be answered. The web API rejects the value now, instead of passing it on. Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
Fixes RUSTSEC-2026-0385, RUSTSEC-2026-0382 and RUSTSEC-2026-0383. Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
Move the wcs availability decision into a pure function with a test per branch and share one version check with the ods client. The result dialog names an unknown status, shows a warning's context, and no longer says a new reset fixes a failure after data was changed. Test status codes the UI does not know, reject mode 4, and cut comments and tests that add nothing. Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
JoergZeidler
left a comment
There was a problem hiding this comment.
Review of the three changes. All contracts are followed across core, generated types and the Vue shell; no correctness bugs. cargo +nightly fmt and cargo test --features mock pass locally. clippy could not run clean here because of a pre-existing unknown lint: clippy::unused_async_trait_impl in api.rs/certificate.rs (outside this PR) with no toolchain pinned — not a PR issue. tsc/biome/e2e were not run (no bun in my environment).
Inline comments hold the per-file findings. Two more that have no diff line to anchor to:
- Low —
project-context.mdnot updated. The new backend modulesrc/backend/src/version.rsis not in the "Project Structure" tree. The file's own rule asks for that section to be updated on a structure change. - Minor —
README.md:187wording. It says the WiFi entry shows the "minimum required version"; the UI now showscurrent (required: >=X). Small wording drift, not a contract break.
Unverified (no action needed, just noting): the three RUSTSEC advisory IDs in the dep-bump commit are not checked (no cargo-audit config / no network), and the external service payloads (factory_reset v4, /api/v1/service-info) are checked against this repo's client and tests plus the named producer PRs, not the other repos' source.
…hecks wifi-commissioning-service always sends status "ok" on HTTP 200 for service-info; a failure is a non-2xx answer, which is already reported as unavailable. The field is not needed. Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
JoergZeidler
left a comment
There was a problem hiding this comment.
All round-1 findings resolved in 718ecf6. Verified locally: cargo +nightly fmt --check and cargo test --features mock pass. Dropping the unused status field is serde-safe (no deny_unknown_fields), and the two e2e negative assertions are correct. clippy/tsc/biome/e2e not re-run in my environment; trusting your reported runs.
…act (#207) Closes #205 ## Summary omnect-os moves from the scripted initramfs to [omnect-os-init](https://github.com/omnect/omnect-os-init), an init written in Rust (omnect/meta-omnect#697). The init writes the factory-reset result to `/run/omnect-device-service/omnect-os-initramfs.json` in a new JSON format. This PR makes omnect-device-service read this format and report it to the twin. - Reads the key `factory_reset`. A result under the old key `factory-reset` is unusable: it is logged as an error and reported as `null`. A `null` under the old key is a normal boot. - The status codes have the omnect-os-init names: `0` success, `1` invalid, `2` error, `3` config error, and the new `4` warning (the reset worked, but a partition needed a second `mkfs`). The status is a `u32`, as omnect-os-init writes it. A status code this version does not know is reported as it is, and the raw result is logged as a warning. - `error` and `context` are optional, `paths` defaults to an empty list. `data_wiped` is required: a result without it is unusable and reported as `null`, because a missing value must not read as a safe abort. - Reports `data_wiped`: on error it tells a safe abort from a failure after data was already wiped. - Reports `error` and `context` as `null` instead of leaving them out: twin reports are merge patches, so a missing key would keep the value of a previous result. - The `factory_reset` feature version is 4, because the reported result changed. The crate version is 0.46.1. - Mode 4 is no longer accepted: the init does not support it, so a request with mode 4 would come back as `Invalid`, a reset that never runs. - The test files have the real omnect-os-init output. `testfiles/positive/contract` holds copies of the status files that omnect-os-init writes for every factory reset result (its `tests/contract`, omnect/omnect-os-init#40); a test parses each one and compares every field. - The README says that a result from before feature version 4 stays in the twin until the next reset, and that `preserve` accepts only the reported keys. - README and `update_validation.md` link the initramfs docs in omnect-os-init (`docs/usage.md`) instead of meta-omnect and the legacy scripts. The README documents the result fields, and that `preserve` is mandatory, as the parser already requires. - `update_validation.md` says that omnect-os-init deletes `update_validation_conf.json` on every boot without update validation (omnect/omnect-os-init#40), so a config written by hand is gone after the next reboot. ## Reason The parser did not match the omnect-os-init format: it read the key `factory-reset` and required an `error` string. So the result of the init was unusable and never reached the twin. See #205 for the full list of differences. omnect-os-init tests that it writes exactly the contract files, and this repo tests that it parses them. So a format change on one side fails a test once the copies are updated. omnect-ui reads the published result and must follow the new format and the removed mode 4: omnect/omnect-ui#132. The local web service keeps the channel `FactoryResetV1` and the route `/factory-reset/v1`, although the payload changed and mode 4 is rejected. An omnect-ui without omnect/omnect-ui#132 gets no signal about this. The only safeguard is that this PR, omnect/meta-omnect#697 and omnect/omnect-ui#132 reach a release together; omnect-ui#132 also requires ods `>=0.46.1`. --------- Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
## Summary - Bump the workspace version from 1.2.8 to 1.3.0 (`Cargo.toml`, `Cargo.lock`). ## Reason #132 was merged without a version bump. The QA pipeline then tries to tag 1.2.8 again and fails, because that tag already exists. #132 is a feature (factory reset feature version 4, no reset mode 4), so the minor version goes up. Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
…697) ## Summary omnect-os moves from the scripted initramfs to [omnect-os-init](https://github.com/omnect/omnect-os-init), an init written in Rust. This PR is the main integration step: it builds the init, installs it as `/init` and removes the scripted initramfs (`init.d/*` from `omnect-os-initramfs-scripts`). - `omnect-os-init`: Cargo features follow the machine and distro (`grub` or `uboot`, the partition table from `OMNECT_PART_TABLE`, `factory-reset`, `resize-data`, `persistent-var-log`, `release-image`, `flash-mode-2`, `flash-mode-2-direct` when `OMNECT_FLASH_MODE_2_DIRECT_FLASHING` is `1`, `flash-mode-3`, `rtc` from the machine feature, and `early-modules` when `OMNECT_EARLY_MODULES` is set). The partition and bootloader constants that flash mode 1 needs are exported into the build; for flash mode 2 also the boot partition offset and size and `OMNECT_USER_ID`. - `OMNECT_PART_TABLE` (`gpt` or `dos`, default `gpt`) selects the partition table the init is built for; a machine whose wks file uses `--ptable msdos` sets `dos`. - `OMNECT_USER_ID` (uid and gid of the omnect user) is a distro variable, so the init recipe and `omnect_user.bbclass` share one value. - `omnect-os-initramfs`: installs the tools the init calls (`bash` for the debug shell on non-release images, `e2fsprogs`, `dosfstools`, `util-linux-sfdisk`, `util-linux-blkid` on GRUB machines, `efibootmgr` on EFI machines, `dhcpcd` and `base-passwd` for flash modes 2 and 3, `dropbear` and the omnect user for flash mode 2, `curl` and `ca-certificates` for flash mode 3). It drops the legacy script packages, the initramfs-framework modules, `os-release`, `jq`, `kmod`, `util-linux-uuidgen`, `bmaptool` and `xz`. `dhcpcd` is built without udev: it runs only in the initramfs, where udevd does not run, so it no longer pulls udev into the initramfs. The `fsck.fat` links in `/sbin` are created only when `/sbin` is not merged into `/usr/sbin`; on a merged image they replaced `fsck.fat` with a link to itself, so the boot partition was never checked. - GRUB passes `bootpart_fsuuid` instead of `rootblk`, so the init finds its disk by the filesystem UUID of the boot partition (partition 1, read with `probe`). A flash mode 1 clone gets a new boot volume ID ([omnect-os-init#38](omnect/omnect-os-init#38)); the rootfs UUID would be the same on the clone and its source. - GRUB boots from the disk it was loaded from (taken from `$cmdpath`, which needs the `regexp` module), not from `hd0`. `hd0` is the first disk of the firmware: with a flash mode 1 clone and its source both attached, GRUB read the grubenv of the clone but loaded kernel and rootfs from the source. - U-Boot declares every environment variable the OS writes at runtime as writable (`omnect_first_boot_done`, `omnect_fsck_*`, `omnect_factory_reset_last_error`, `flash-mode-url`, `flash-mode-url-sha256`), so a `saveenv` in `omnect_update_flow` keeps them. `data-mount-options` and `resized-data` are no longer listed, because the init reads neither. - `u-boot-scr`: the boot script no longer appends the literal text `None` to `bootargs` when `OMNECT_APPEND_1ST_BOOT` is unset, as on developer images. - `OMNECT_EARLY_MODULES` lists the kernel modules the init loads before `switch_root` (`imx_sdma` on phytec-imx8mm). It selects the `early-modules` feature, and the new package `omnect-os-init-early-modules` installs the list into the rootfs as `/etc/omnect/early-modules.d/omnect.conf`. The `omnect-os-init` recipe is built per machine, because its features and `build.rs` read machine settings. rpi kernels build compressed modules, so they get `CONFIG_MODULE_DECOMPRESS` when the variable is set. - `omnect-base-files` adds the mount point `/mnt/rootCurrentPrivate`, where the init bind-mounts the root filesystem. Its tmpfiles config creates `/mnt/cert/ca` and `/mnt/cert/priv` (`d` instead of `z`), because the init does not create them. - The busybox `poweroff` config is removed; the init powers off itself. - Removed with the scripted initramfs: - The recipe `omnect-os-initramfs-scripts`. A layer with a `.bbappend` for it no longer parses, and own `init.d` scripts are no longer possible. - Factory reset wipe mode 4, a custom wipe added by such a `.bbappend`. A request with `mode` 4 now gets status 1. - The bootloader variable `data-mount-options`; the data partition is always mounted with the default options. - An optional `preserve`: the factory-reset request must now contain it, else it gets status 3. - `omnect-device-service` reads the factory-reset result the init writes ([omnect-device-service#207](omnect/omnect-device-service#207)). - The expected bootloader checksums of genericx86-64, rpi and phytec-imx8mm follow the changed bootloader inputs. - README and `doc/`: keep the build settings and link to the [omnect-os-init docs](https://github.com/omnect/omnect-os-init/blob/main/docs/usage.md) for the behaviour of flash modes, factory reset, filesystem check and the status file. ## Reason The initramfs moves from shell scripts to one Rust binary, for typed error handling, a defined result contract towards omnect-device-service, and unit tests for the boot, factory-reset and flash paths. - The `omnect-os-init` recipe builds the released version 0.1.0. It contains [omnect-os-init#40](omnect/omnect-os-init#40), which keeps what the scripted initramfs did: `/run` without suid and device files, the links of `create-fs-links.txt`, the persistent logs in `/mnt/data/log`, and the restored directories with their owner and mode. - The `omnect-device-service` recipe builds the released version 0.46.1, which contains [omnect-device-service#207](omnect/omnect-device-service#207). - [omnect-ui#132](omnect/omnect-ui#132) reads the new factory-reset result and no longer offers mode 4. The three PRs have to reach a release together. - The bootloader version changes on every machine, because `omnect_env.h` and the GRUB config are bootloader inputs (on phytec-imx8mm the boot script is one too); devices get a bootloader update with this image. A layer whose bootloader checksum covers `recipes-bsp/u-boot/u-boot/*` needs a new expected value at the same time. --------- Signed-off-by: Jan Zachmann 50990105+JanZachmann@users.noreply.github.com
Closes #125
Summary
omnect-os moves from the scripted initramfs to omnect-os-init, an init written in Rust (omnect/meta-omnect#697). The new init writes a different factory-reset result and does not support reset mode 4; omnect/omnect-device-service#207 publishes this result as
factory_resetfeature version 4. This PR makes omnect-ui follow both changes. It also changes the probe of wifi-commissioning-service.Factory reset result of feature version 4
statusis au32with the codessuccess,invalid,error,configErrorandwarningplus a catch-all,errorandcontextarenullwhen nothing went wrong, and the newdata_wipedflag tells whether the reset had already started to change data. The required omnect-device-service version is>=0.46.1.Unknownis the default and means "no result received yet", so the result dialog stays hidden.Unrecognizedis the catch-all, so a status code that a later omnect-device-service adds still reaches the user.warningcounts as success in the UI: the reset completed, but a partition needed a second format attempt.data_wipedis shown only on a failed result, where the device may be partly wiped and needs another reset.wifi-commissioning-service probe via service-info
GET /api/v1/service-info(wifi-commissioning-service 0.2.0, feat(api): add /api/v1/service-info exposing ble_enabled wifi-commissioning-service#3) is the only availability probe: it returns version, interface name and BLE state in one call. The probe no longer calls/api/v1/statusand/api/v1/version.>=0.2.1) and the existingVersionInfo { required, current, mismatch }.WifiAvailability::Unavailablecarriesversion_info: Option<VersionInfo>.Nonemeans the probe failed or the version does not parse; the device info showsunknown. An empty interface name also makes the service unavailable.ble_enabledis only logged.Factory reset mode 4 removed
Reason
With omnect/omnect-device-service#207,
errorisnullafter a successful reset, but omnect-ui requires aString. So every factory-reset result fails to deserialize, and the UI shows a parse error instead of the result. The status codes were renamed and extended in the same change, so the oldrepr(u8)enum with four variants cannot name what the device reports.The service-info probe needs one request instead of two. With the same requirement string and
VersionInfoas omnect-device-service, both services report an unsupported version in the same way. The required version>=0.2.1is the released wifi-commissioning-service tag.Mode 4 ran a customer wipe script inside the scripted initramfs. omnect-os-init has no such script and answers mode 4 with
Invalid, a reset that never runs. Rejecting the value here keeps the request from being sent at all.This PR, omnect/omnect-device-service#207 and omnect/meta-omnect#697 have to reach a release together, so no component offers a mode the device refuses, and the UI can read the result the device reports.