Repository navigation
run_application returns its exit; only the executable entry ends the process - #1479
Merged
Merged
Conversation
`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>
…e ends the process (W3c)
run_application now returns Exit{code, release: Complete|Retained} instead of calling _exit
from inside the app. port::plex_run calls exit_now with the code right after it returns, in
the order the process always ended in, so the executable and the simulator behave as before.
- exit.rs: Exit/Release, release_of (an exhaustive match over NativeExit, the one decision
quits_sdl now reads), entry (leaks the App on both entry kinds, so no drop runs under a
live worker), HostGate (stopping/inflight, Dekker-style enter) and the once-only Completion.
- The exit inventory is closed: the gfx shader and link exits return a typed GfxFault through
init_gl/init_text/init_image, and the boot chain returns Err(Exit) for every refusal.
Frame-time lazy links stay optional-only, pinned by a source test.
- watchdog::disarm/arm: the loop thread id lives on the signal state, arm re-captures it,
and disarm waits for an in-flight probe.
- The App carries a cfg(test) drop_probe at both construction sites, with a control test.
- The libc-exit source guard moved to exit.rs and covers the widened inventory.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… reaching app/mod.rs, quiet the probe's dead-code in plain builds 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>
This was referenced Nov 20, 2026
Making run_application return an Exit deleted the two `-> !` consts that app::boot's seam_order_tests held for it and run_and_shutdown, and nothing replaced them for the entry. plex_run was typed `-> c_int` and only diverged because its last expression happened to be exit_now(..), so a later edit to `run_application(..).code` would have compiled and passed every test. src/main.c does `return plex_run(..)`, so an entry that returns falls into __libc_start_main, which calls libc exit directly (the interposer in src/exit.c cannot catch that). OPENSSL_cleanup would then run under the live curl workers: the #1115 crash. Move the body into a private `plex_main(..) -> !`, keep plex_run as the one-line C-signature wrapper (C and bin/sim.rs call it), and pin `const _: fn(*const c_char, c_int) -> ! = plex_main;` beside it. The lifecycle scan in app/exit.rs now also requires that const to still be in port.rs and that plex_main is what calls exit_now, and the fnlen budget in ci/check-deps.sh counts plex_main (the body) plus the plex_run wrapper. No behaviour change. Co-Authored-By: Claude <noreply@anthropic.com>
The const beside plex_main proves only that plex_main never returns. plex_run, the C entry whose return would fall into libc exit (#1115), is still typed c_int, so an early `return 2;` above its call to plex_main compiled (the never type coerces), fit the fnlen budget of 5 and passed the exit scan, because nothing read plex_run's body. The scan now cuts plex_run's body and requires it, whitespace normalised, to be exactly `plex_main(pms_host, pms_port)`. The const-line and exit_now checks read comment-stripped lines, so a commented-out const or call no longer satisfies them, and a block comment in port.rs fails the scan outright rather than slipping past the line stripping. plex_run's fnlen budget drops from 5 to 3 (signature, call, brace). Co-Authored-By: Claude <noreply@anthropic.com>
GLinnik21
added a commit
that referenced
this pull request
Nov 20, 2026
…s gone The first cut of W2 kept the Platform in an app-crate OnceLock read through platform(), with Platform::HOST_TEST as the fallback. That fallback was live in production: an entry that forgot to install would have booted a television with a no-op shell (no bind, no grab, no bus pump) and said nothing. The platform plan's shape is `run_application(&'static Platform) -> Exit`, so the platform is now an argument and forgetting it does not compile. - run_application(platform, pms_host, pms_port) installs tv::Services from platform.services once, before anything reads tv, then enters as before. plex_main hands it &PLATFORM after the storage activator line. The #1479 const proof, the process-entry scan with its exactly-once asserts and the fnlen budgets (run_application 7, plex_main 6, plex_run 3) are unchanged. - app::platform loses INSTALLED, install() and platform(). App gets `platform: &'static Platform`, set at both construction sites (boot's literal and the run.rs test rig, which passes &Platform::HOST_TEST explicitly). Boot code that runs before an App exists (bind_window, grab_surface, arm_opaque_region) takes the platform as a parameter, and the loop reads app.platform.shell and app.platform.diag. - The dispatcher's two opaque-region hooks (Rig::opaque_route and clear_opaque_region) take no platform argument, so BridgeRetained holds the shell as a field, given to its constructors the way now_us is. run::rig_opaque_route and rig_clear_opaque_region take it as a parameter and stay the one place the bridge reaches the shell, which keeps the frame gate's call text in run.rs. The test constructors pass the host-test shell explicitly. - gfx's clear-probe hook takes plain functions and is a once-set, thread-local hook that boot installed. plex_main now installs it with the webOS probe's own functions, on the thread the app boots and draws on. No host test ever ran boot, so host tests still install nothing, as before. - The frame gate's receiver match, its self-tests and the prose that named platform() follow. No new process-global, no cfg(test) fork and no ledger line. Co-Authored-By: Claude <noreply@anthropic.com>
GLinnik21
added a commit
that referenced
this pull request
Nov 20, 2026
…::Platform (#1483) The bottom layer's hook table is split by who reads it (step W2 of the platform plan, discussion #1460). The lower layers keep `tv::Services`. The window, bus and frame-probe entries, which only the loop reads, move to an app-private `app::Platform` that `run_application` takes as a parameter. webOS and the simulator behave as before. - `plx_os::tv::Port` (27 fields) becomes `tv::Services` with the same function pointers in four groups: - `identity { probe_device, start_capability_probe, repair_sandbox, system_locale, sound_output }`; - `secure { seal, open, remove, mode }`, which absorbs W3a's separate once-set mode and `publish_mode`. `secure::mode()` keeps its signature and still reads the test override first; - `system { go_home, poll_home, deliver_toast }`; - `legacy_webos_media { sink, display_sink, uri_media }`. Every hook is required, and each group has a named `NONE`. `Services::HOST_TEST` replaces `ABSENT`. The install is still once-only. - The seven window and bus entries become the `Shell` trait and the six frame probes become `FrameProbe`. Both live in `app/platform.rs` beside the loop, and `tv/window.rs` is deleted. - `app::Platform { services, shell, diag }`. `Platform::new` builds it, and `install_services` is the only reader of the private `services`, so app code cannot call a raw hook past the guards in `tv`'s modules. - `run_application(platform, ..)` installs the services, and `App.platform` holds the platform at both construction sites. - Boot code that runs before `App` exists takes it as a parameter, and the bridge's opaque-region hooks read the shell from `BridgeRetained`. - `Platform::HOST_TEST` is `#[cfg(test)]`, so a production entry cannot boot with the no-op shell. - `port.rs` builds the webOS `SERVICES` and `PLATFORM` over the same `crate::system` functions as before. `plex_main` installs gfx's thread-local clear-probe hook. `plex_run` and the proof that `plex_main` never returns are unchanged. - The #1479 scan also asserts that `fn plex_run(` and `fn plex_main(` each occur exactly once in `port.rs`. A second, cfg-gated `plex_run` no longer passes it. - The `frame` gate in `ci/check-deps.sh` pins the call text of `pump_bus`, `opaque_route` and `clear_opaque_region` to `app/run.rs`. It matches the shell receiver, the trait path, and a chained call whose previous line ends in `shell`, so the bridge `Rig` trait's methods of the same name pass. Two self-tests in `tests/test_harness.py` cover both cases. On the dev set, three `--guest --mock` boots (this change, main, main) each reached idle Home and closed with `APP_CLOSED`, `exit_status: 0`. The logs match within the noise floor, apart from a race in the order of two lines and a one-block difference in the image cache's cap.
This was referenced Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step W3c of the platform plan (discussion #1460). A hosted library must never end its host's process: on Samsung the .NET host owns the process, and today
run_applicationends in_exit.run_applicationnow returns, and only the executable entry ends the process.What changes
run_applicationreturnsExit { code, release: Complete | Retained }.port::plex_runends the process throughplex_main, which callsplx_base::process::exit_now(exit.code)straight afterrun_applicationreturns, so the process ends in the same order as before. The C shim,sim.rs, the C ABI and the teardown order are untouched, and webOS behaviour is unchanged.plex_run(#[no_mangle],-> c_int, the same signature) wraps the privatefn plex_main(..) -> !, andconst _: fn(*const c_char, c_int) -> ! = plex_main;replaces the-> !consts onrun_and_shutdownandrun_applicationthis PR removes. Without that proof, a later edit that letplex_runreturn would compile.main.cwould then return into__libc_start_main's own libcexit, which the interposer cannot catch, andOPENSSL_cleanupwould run under live curl workers (Near-null SIGSEGV spike on 0.9.0 (Sentry PLX-NATIVE-P): frames unsymbolicated, cause undetermined #1115). The lifecycle scan asserts that the const andplex_main'sexit_now(are present, andci/check-deps.shbudgetsplex_main(10 lines) and theplex_runwrapper (5) separately.app/exit.rs:release_of, an exhaustive match overNativeExitwith no_arm. It is the one decision, andquits_sdlis now derived from it.entry<T>, which leaks the App throughManuallyDropon both entry kinds.HostGate { stopping, inflight }: enter increments, then readsstopping, and backs out on refusal, allSeqCst. A report answers "not yet" while a callback is in flight.Completionshared by the loop and deadline threads, which disarms the watchdog beforeon_stopped.DropProbe.plx_gfx's shader and link exits return a typedGfxFaultthroughinit_gl,init_textandinit_image.link_requiredruns over an injectedProgramDriver, so a test without GL can inject compile and link failures. Every refusal in the boot and construct chain returnsErr(Exit), with the same status (1) as before. A shader fault now unwinds like the SDL_Init and GL-context refusals already did, so it drops the telemetry guard on the way out. That guard'sDropstops the crash backend and removes its database, which the oldexit_nowfrom inside GL skipped.blur_lazy_init, run at boot byinit_blurand again from the frame) useslink_optional_program. A driver that rejects thefs_blurorfs_glasscompile used to refuse the boot with status 1. Now the app boots with blur off and opaque panels, as a link failure already did. A source-pin test keepslink_programfor boot-only required programs.watchdog::disarm,armandis_armed. The loop thread id sits in a mutex slot held across the signal send, sodisarmwaits for an in-flight probe. No new static.boot.rstoexit.rs'slifecycle_tests. It now also covers theexit_nowsites a hosted process can reach; the allowed owners areport.rs,bin/sim.rsanddev/framedump.rs.ci/check-deps.shis not edited.Tests
Bounded runs on the committed tree:
make test-crate C=plx_base T=watchdog:test result: ok. 52 passed; 0 failedC=plx_gfx T=fault:ok. 9 passedmake test-hostsim T=seam_order: green.make test-hostsim T=lifecyclecrashes on macOS with SIGSEGV, in the existing testplayer_owner_events_record_and_replay_through_the_actual_app_host:glUniform4fin the system libGL with no context, fromgfx::draw_ramp. The same crash happens onmain(the Rename the bottom layer crate plx_platform to plx_os #1474 gate saw it inplxnative_modulesandplx_screenstest binaries on both sides). The same compiled binary passed the other 197 lifecycle tests, including the 17 newapp::exittests and the App leak test with its control. CI's Linux runners show the whole filter.fw-compat-reviewer: PASS on the 9 gated releases (4.4.2 to 11.2.0); DT_NEEDED unchanged, 371 undefined dynamic symbols as on main,
exitexported and not imported; the new libc calls (pthread_self,pthread_kill) were already imported. Its one finding, the missing never-returns proof, is theplex_mainchange above.Television
513d07a02andmain(e059908, twice for the noise floor) were each booted--guest --mockon the dev set and closed with the system's close-by-app-id. The boot logs matchmainwithin the noise floor. The system's own record of each close is the same five-line sequence, endingAPP_CLOSEDwithexit_status: 0, and has no crash record or*** EXITline. Theplex_maincommit after it changes only types and checks, not what runs.Not run here: the ARM cross-build,
make check,check-nodef, and the bare--no-default-featuresandplx_base --features threadcheckbuilds that compile the watchdog's threadcheck code. CI gates them on this head. A--guest --mocktelevision check of the boot and quit order is batched with W3b.🤖 Generated with Claude Code