Skip to content

Rename the bottom layer crate plx_platform to plx_os - #1474

Merged
GLinnik21 merged 4 commits into
mainfrom
refactor/plx-os-rename
Nov 20, 2026
Merged

GLinnik21 merged 4 commits into
mainfrom
refactor/plx-os-rename

Conversation

@GLinnik21

@GLinnik21 GLinnik21 commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

First step of the platform plan from discussion #1460 (webOS, the desktop simulators and Samsung Tizen as separate platforms in one repo). The bottom layer is renamed before anything else, so the later PRs and the plan document use the final names.

What changes

  • plx_platform → plx_os, rust-modules/platform/ → rust-modules/os/, layer [platform] → [os], fence keyword [port X] → [platform X], SRC_PLATFORM → SRC_OS. The inner tv module stays. No behaviour change.
  • The rewrite is tools/rename-os-layer.py (stdlib, run with -I), shipped for the open PRs and the release lines:
    • forward (idempotent) and --reverse (a tree), plus --reverse-patch FILE (a backport's diff, rewritten to the old names so it applies on a release line);
    • --check: every old-name site in all three spellings, plus every prose use of "platform layer"/"platform crate", separator lists and table cells, classified or failing;
    • --equivalence BASE: HEAD against script(BASE), and BASE against reverse(HEAD). The only differences it allows are the two certificates and their pins, Cargo.lock re-sorted, reflow, and the tool itself.
  • ci/test_rename_os_layer.py (20 cases) is wired into ci/check-python-steps.txt.
  • Before the tool was finished, every platform in the tree was swept once (675 hits: 91 name the layer, 584 do not), so --check covers the whole class rather than the sites reviews happened to find.
  • Both reviewed certificates are re-pinned. Every changed hash follows from the rename: package and module names, platform/… paths becoming os/…, manifest and lock hashes, and certified sources whose only change is a comment or the package name.
    • ci/readonly_generated.py: 1b3b34fa… → 55e6b3ac…; its current i18n snapshot 2c978e3a… → 867bb410… (MACHINE_SOURCES unchanged).
    • ci/readonly_dependencies.py: 915ab64b… → 47228bf8….
  • Cargo.lock: the same lines as main, with plx_os re-sorted before plx_owp. No version moves.

After it merges

  • Crash reports from builds with this change name frames plx_os::… where earlier ones named plx_platform::…. Sentry groups Rust events by in-app function names, so an existing issue whose top frames are in this crate can open as a new issue after the next release.
  • The cargo seed key changes (the lock and ten manifests move), so each lane builds its third-party crates cold once.
  • The certificate file keeps its old name, ci/proofs/platform-generated-enums.json. Renaming it is left for a separate change.

Open PRs and release lines

Rehearsed on #1387, #1407 and release/v0.10. Recipe for an open PR:

  1. git merge origin/main, with this PR merged;
  2. python3 -I tools/rename-os-layer.py;
  3. python3 -I tools/rename-os-layer.py --check;
  4. commit.

Merging first gave 0 conflicts on #1387. Running the script first gave 2 mechanical conflicts. For a backport, run --reverse-patch on the post-rename diff before git apply.

Build inputs

Measured base 8230e3232 against head 9d5360cc0. The commits after it change comments, test strings, the crate description, build-bench's constant names and the tool, and no build input.

  • RUST_INPUTS: 1500 files on each side, identical after the rename. STORAGE_INPUTS: 16 on each side, identical.
  • make -s print-bench-config print-playback-config print-rust-codegen print-rust-toolchain print-disk-entries: byte-identical output.
  • Every Cargo.toml differs only by the rename.

build-bench

Same Mac (Apple M4, 10 cores), one sitting, 3 interleaved runs per scenario, rustc 1.100.0. Both target dirs are on an external build volume, so absolute times include that disk. Head printed three load warnings (gfx run 1, telemetry run 1, os run 3); base printed none. The table pairs base's platform row with head's os row.

Scenario Base median (min–max) Head median (min–max)
No-op host test build 56.3 s (0.1–58.5)* 47.9 s (12.9–59.0)*
Edit leaf plx_base cbuf.rs 62.7 s (53.5–95.9) 52.8 s (49.2–54.5)
Edit leaf plx_machine landgate.rs 54.5 s (51.9–73.5) 57.2 s (45.1–115.6)
Edit leaf of this crate (devcaps.rs) 54.3 s (53.0–64.8) 55.8 s (44.9–73.6)
Edit leaf plx_gfx overdraw.rs 43.5 s (36.5–98.2) 48.5 s (31.9–76.7)
Edit leaf plx_net stream_redirect.rs 49.2 s (41.2–58.8) 46.8 s (41.6–71.5)
Edit leaf plx_ui dwell.rs 34.7 s (29.0–41.4) 31.6 s (26.8–49.3)
Edit leaf plx_plex retry.rs 48.2 s (40.0–53.2) 49.5 s (39.6–63.1)
Edit leaf plx_telemetry window.rs 43.3 s (38.2–50.6) 52.4 s (36.4–61.7)
Edit leaf plx_data tape.rs 41.1 s (40.5–42.2) 50.2 s (37.6–56.0)
Edit leaf plx_session scripted.rs 36.7 s (28.0–43.9) 41.8 s (29.0–42.4)
Edit leaf plx_media units.rs 35.9 s (33.8–48.6) 43.1 s (32.4–46.4)
Edit leaf plx_appkit skip_pill.rs 39.8 s (30.6–65.5) 36.4 s (28.6–38.8)
Edit leaf plx_screens clock_readout.rs 37.1 s (27.5–43.7) 35.1 s (26.6–37.9)
Edit leaf app coldstart.rs 24.6 s (24.5–26.2) 25.4 s (17.0–26.2)
Edit hub plx_ui lib.rs 31.1 s (29.8–32.1) 27.8 s (23.9–28.4)
Edit leaf plx_base cbuf.rs, incremental 333.2 s (315.3–369.7) 286.1 s (260.6–356.4)
Edit hub plx_ui lib.rs, incremental 96.3 s (79.4–118.2) 72.5 s (46.9–102.6)
ARM staticlib rebuild 44.3 s (43.7–45.7), 126.2 MiB 35.4 s (30.8–47.0), 126.1 MiB

Every row's base and head ranges overlap except the non-incremental hub edit, where head is faster. The units rebuilt per scenario are the same on both sides (35, 27, 23, 9, 19, 7, 15, 13, 9, 5, 7, 5, 3, 1 and 7 of 190).

* The no-op row is wrong on both sides, and the cause is already on main. The ARM row touches rust-modules/src/lib.rs (tools/build-bench.py:646) and nothing restores its mtime, so the no-op runs after it recompile the app crate. The first no-op after warm-up rebuilt 0 units: base 10.1 s, head 12.9 s.

The unit-suite scenario has no row on either side. On this Mac, plxnative_modules and plx_screens test binaries die with SIGSEGV inside macOS libGL (glClearColor from gfx::frame_clear, glUniform4f from gfx::draw_ramp). It happens identically on base, twice, and on head. The cause is not determined. It is not this change.

The tool's target-dir sizes print 0 MB because du -sk does not follow symlinked target dirs. Real sizes, base → head: target 3171 → 3255 MB, target-fast 5203 → 5309 MB, target-storage 74 → 74 MB.

Television

Three boots of plain make builds on the dev set: head, base, and base again for the noise floor. Each ran under its own 6-minute lease, with --guest --mock against the synthetic PMS, the identity lines checked first, and no keys sent. Each binary's md5 matched on the host, in the app directory and at /proc/<pid>/exe.

Each log was cut from install: to the first idle Home heartbeat (78 lines each) and normalised. The only lines that differ beyond what also differs between the two base boots: imgcache: cap= is 12,288 bytes higher on head. The cap is half the free space plus what the cache holds, and head's binary is 23,540 bytes smaller, which frees six 4 KiB blocks (24,576 bytes); half of that is 12,288. No log line names either crate.

Gates

  • CI: this PR's own run, green on 17425b0a5.
  • Local, on the committed tree: --check 0 old-name sites; --equivalence origin/main ok; make test-crate C=plx_os 442 passed; ci/check-module-layers.py 0 entries; ci/check-deps.sh green. The gate regenerated both certificates at 9d5360cc0 and they were byte-identical to the committed files; the later pins are checked by CI's readonly steps on 17425b0a5.
  • fw-compat-reviewer: clean. pr-reviewer on 17425b0a5: 0 blockers, 1 major (this description lacked the build-bench table, now added) and 1 minor.

🤖 Generated with Claude Code

GLinnik21 and others added 4 commits November 20, 2026 04:38
`plx_platform` becomes `plx_os`, `rust-modules/platform/` becomes `rust-modules/os/`, the layer
`[platform]` becomes `[os]`, the fence keyword `[port X]` becomes `[platform X]` and `SRC_PLATFORM`
becomes `SRC_OS`. No behaviour change. The inner `tv` module stays.

The rewrite is `tools/rename-os-layer.py` (stdlib, run with -I), shipped for the open PRs and the
release lines that still carry the old names:
  - forward (idempotent) and `--reverse`, which rewrites only the sites the forward pass writes;
  - `--reverse-patch FILE`, the backport route: a post-rename `git diff` is rewritten hunk line by hunk
    line (the enumerated sites are per file) so `git apply` accepts it on a line with the old names;
  - `--check`: every old-name site in the three spellings (the package, the path incl. the bare
    `platform/..` and `../platform` forms, the layer token) plus every enumerated literal site, and
    every quoted "platform" in both quote styles is classified (a JSON key, a Sentry field,
    sys.platform) or fails; a quoted platform in a list of layer names is never a keeper (the
    report.rs and release-config-check.py lists, N1);
  - `--equivalence BASE`: HEAD against script(BASE) and BASE against reverse(HEAD), allowing only
    (a) the two certificates and their pin lines, (b) Cargo.lock as a sorted-line multiset,
    (c) a .rs hunk with the same token multiset, (d) the tool, its test and its two lines in ci/check-python-steps.txt.
`ci/test_rename_os_layer.py` (16 cases, synthetic trees and a throwaway git repo) is wired into
`ci/check-python-steps.txt`. rustfmt was not run: there is no fmt gate and no line needed a reflow.

Cargo.lock: the script renames the package, then cargo (a plain `make test-crate`, offline) re-sorts
it: `plx_os` sorts before `plx_owp`, so that one package block moved above it. The lines are the
same multiset as origin/main's with plx_platform spelled plx_os, so no version moved (`--equivalence`
checks exactly that), and `cargo metadata --offline --locked` accepts the committed lock.

Certificate re-pins (both reviewed; every changed hash is a consequence of the rename):
ci/proofs/platform-generated-enums.json (keeps its name), pinned by ci/readonly_generated.py
  CERTIFICATE_SHA256 1b3b34fa...6503 -> ac7a32d9...60c3
  I18N_SOURCES[1] (the reviewed variant of os/src/i18n/mod.rs; its only change is the comment path
  platform/build_support/catalog.rs) 2c978e3a...4d52 -> 7119e673...b463
  changed: package, module, the key platform/ -> os/ for 5 sources and the manifest key; hashes of
  os/Cargo.toml, os/src/lib.rs, os/src/i18n/mod.rs, build_support/install_identities.rs, the lock
  and the manifests of the root, appkit, data, media, play-feed, play-uri, plex, screens, session,
  storage, telemetry, ui and os. Unchanged: os/build.rs, os/build_support/catalog.rs, machine/*.
ci/proofs/serde-json-immutable.json (serde_json 1.0.154, archive checksum verified), pinned by
ci/readonly_dependencies.py
  CERTIFICATE_SHA256 915ab64b...6540 -> dc193808...2fc4f
  changed: lock_sha256, the same 13 manifest hashes and the manifest key platform -> os, and the
  lib_sha256 of the owners os, data, media, net, play-feed, plex, session, storage and telemetry
  (their lib files name the layer in a doc comment or a #[path]).

Verified here: `--check` 0 sites left; `--equivalence origin/main` ok; ci/test_rename_os_layer.py,
ci/test_readonly_{generated,dependencies}.py, test_module_graph, test_build_bench,
test_no_host_staticlib, test_storage_package_isolated, test_check_machine_shape, test_ci_split,
test_cargo_seed, check-module-layers (0 migration entries), check-list-caps, check-localization,
check-deps.sh (all green); cargo check --workspace --locked; make test-crate C=plx_os (442 passed).
Not run here: make check, check-nodef, the ARM cross-build, build-bench, a TV boot.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…/../platform"; --reverse-patch names its weak rewrites

Two findings from the review of PR #1474, both in the tool and its test.

--check: the old patterns needed `base platform` / `machine platform` or a quoted
"platform", so `for c in net platform gfx`, `--only machine,platform` and
`base -> platform -> ui` passed unseen, and the bare-path rule's lookbehind
rejected a `/` before `../` (`"/../platform/src"`). BARE_OLD/NEW and UP_OLD/NEW now
start after a `/` that directly precedes a `../`, and a new class,
"3 layer token in a separator list", flags `platform` beside a layer name with a
space, comma, `>` or `-` between them. Two hits on the head tree are not the
layer and are named in SEP_KEEP (path + line regex + label): the Plex
client-identification field list in docs/plex-api-design.md and the prose
"machine, platform API" in session/src/auth/owner.rs.

The class finds three real stale spellings the forward pass does not rewrite
(docs/module-layers.md:112, docs/watchlist-plan.md:112,
rust-modules/base/src/eventlog/scrub.rs:1079), so `--check` on this head reports
3 sites, not 0. They are not classified away; fixing them touches files outside
this commit and is left to the PR's owner.

--reverse-patch: a weak pattern (backticked `os`, a quoted "os" in a layer list,
`base os`, `+ os machine base`, `os::member`, `os/` in a directory list) rewrote
an `os` that may be the operating system back to `platform`, in every file outside
NATURAL_OS, without a word. rewrite() takes weak=False to skip them; reverse_patch
compares both ways per hunk line and prints every line the weak patterns changed to
stderr as `file:line: old -> new` (new-side line, old-side for a `-` line), plus a
count. Hunk line counts now decide what is a hunk line, so a removed `--- x` line
is no longer read as a file header.

Tests: one case for the check class (and `/../`), two for the report (weak lines
named, strong-only patch silent); the shared runner swallows stderr.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…(graph row, two layer lists)

`--check`'s separator-list class found three places that still named the layer
`platform` and that no general rule reads: the layer graph's own row in
docs/module-layers.md (`os` keeps the `machine base` column where it was), the layer
list in docs/watchlist-plan.md ("base, machine, os. NOT net") and the comment above
the log-scan roots in rust-modules/base/src/eventlog/scrub.rs ("the machine, net, os,
gfx, ... layers"). Each is a per-file LITERALS entry in tools/rename-os-layer.py, so
the forward pass writes it, `--reverse` undoes it and `--check` flags the old text;
the three files are the script's output, not hand edits, and `--equivalence` holds.

One line changes in each file. None of the three is pinned by a certificate or a
`ci/readonly_*` digest.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…; --check sees a table cell and `platform layer/crate`

The re-review found two table cells that still said `platform` (docs/module-layers.md:121 and the layer
cell of docs/watchlist-plan.md:119). Rather than patch those two, every standalone `platform` or
`Platform` left in the tree (675 lines in 244 files, minus dated records, the tool and its test, the
platform-webos/-desktop/-tizen names, `plx_platform_*`, `[platform X]` and `app::Platform`) was read and
classified. 91 lines name the layer and are rewritten, each by a per-file LITERALS entry of
tools/rename-os-layer.py run by the script (the forward pass writes them, `--reverse` restores them
exactly, `--check` flags the old text). 584 lines are not the layer and stay: the Plex `X-Plex-Platform`
fields, the Sentry/manifest `"platform"` field, Python's `platform` module and `sys.platform`, TrueType
name-record platform ids, the webOS "platform release" in the release notes, the OpenAPI JSON key, the
dated records, and prose about the host or TV platform ("the platform bus", "a platform difference").
Eight more lines hold the layer's own constants (PLATFORM_LEAF, PLATFORM_LEAF_FILE, PLATFORM_PACKAGE,
PLATFORM_CRATE, the "PLATFORM layer crate" docstring): OS_*.

`--check` gains two classes: a table cell that is the layer's name (`| platform |`) and `platform layer`
/ `platform crate` (also possessive). Against the previous head's text they flag exactly the two cells
the review found and the `platform crate` / `platform layer` prose; on this tree they report 0 sites
with no keeper needed. The tool's docstring no longer says layer prose is left alone.

The reverse leg of `--equivalence` caught a defect in the new entries: a reverse run (and a forward dry
run) reads files that still sit under rust-modules/platform/, but LITERALS is keyed by head paths, so the
five entries under rust-modules/os/ never matched and `--reverse` left "the os layer" behind.
rewrite() and `--check` now look a file up by head_name(rel). The fixture gains
rust-modules/platform/build.rs; against the previous tool the suite failed 4 cases (the reverse round
trip and the three equivalence cases that run the reverse leg).

ci/test_rename_os_layer.py: the `/` before `platform/` assertions use real fixtures
(`rust-modules/platform/src` keeps its own class, `x/platform/src` is not flagged), the prose line has no
layer neighbour and `data platform` is asserted as a separator hit, and one case covers the cell and
noun classes (20 cases). The fixture's natural-`os` file no longer says "the platform layer".

Certificates (reviewed; every changed hash is a consequence of five edited files):
ci/proofs/serde-json-immutable.json, pinned by ci/readonly_dependencies.py
  CERTIFICATE_SHA256 dc193808...2fc4f -> 47228bf8...2fec9
  changed: the manifest hashes of rust-modules/Cargo.toml, os/Cargo.toml and storage/Cargo.toml (a
  comment or the crate description names the layer); nothing else.
ci/proofs/platform-generated-enums.json (keeps its name), pinned by ci/readonly_generated.py
  CERTIFICATE_SHA256 ac7a32d9...460c3 -> 55e6b3ac...7a718
  I18N_SOURCES[1] (the reviewed variant of os/src/i18n/mod.rs; two doc comments) 7119e673...b463 ->
  867bb410...37e1
  changed: the same three manifest hashes, os/Cargo.toml, os/build.rs (a doc comment), the i18n variant.

Verified here: ci/test_rename_os_layer.py (20), ci/test_readonly_{generated,dependencies}.py (22, 64),
test_build_bench (46), test_build_not_always_dirty (10), test_storage_package_isolated (7),
release-config-check-test (75/75), check-module-layers, check-list-caps, check-localization;
`make test-crate C=plx_plex T=t_account` (prefs_tests.rs renames a local; 2 passed).
Not run here: make check, check-nodef, the ARM cross-build, a TV boot.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@GLinnik21
GLinnik21 marked this pull request as ready for review November 20, 2026 04:49
@GLinnik21
GLinnik21 merged commit e208805 into main Nov 20, 2026
24 checks passed
@GLinnik21
GLinnik21 deleted the refactor/plx-os-rename branch November 20, 2026 04:49
GLinnik21 added a commit that referenced this pull request Nov 20, 2026
GLinnik21 added a commit that referenced this pull request Nov 20, 2026
GLinnik21 added a commit that referenced this pull request Nov 20, 2026
# Conflicts:
#	rust-modules/src/app/boot.rs
GLinnik21 added a commit that referenced this pull request Nov 20, 2026
GLinnik21 added a commit that referenced this pull request Nov 20, 2026
GLinnik21 added a commit that referenced this pull request Nov 20, 2026
The first W4 rule moved all 14 positive lines that name no test term. Read one
by one, only 4 of them are host arms: six are frame-probe no-op stubs that every
TV build without devtriggers compiles, a RELEASE build included, three are
dead-code attributes on TV items, and one is a statement inside a TV function.
The simulator table's own test (`port.rs`, all(test, hostsim, play-feed)) names a
type that exists only under hostsim and moves with the table. The rule, the
Test line and the platform-crate list now say 77 television gates, 10 seams,
6 stubs, 4 lines that stay and 5 host arms that move, which add up to the 102.

Also: L15c no longer lists Wave R as planned (it landed as #1474), and the
plan records that; the H7 and H8 bullets pin the README to e8da14c; "363 arms"
reads "363 `hostsim` cfg lines"; F44 cites the `MACHINES` and `FORK_SCOPE`
lines of `ci/check-deps.sh` at e9924f0 once and the same way; the W9 retail
run takes the same dev-token shape as the emulator MVP, with the plex.tv
sign-in a follow-up, because the loopback-only override cannot be reached from
a retail set; and the L15c-to-L15h text states which workstreams are steps of
the table instead of a "no layer rule" reason the table itself contradicts.

Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant