Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions ci/allow/forks/plex.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# count: 31
# count: 12
# Test/production forks (docs/sans-io.md), area `plex`: one line per production-visible `#[cfg(..)]` / `cfg!(..)` whose predicate reads `test` or `feature = "test-support"`
# (`not(test)`, `not(any(test, feature = "test-support"))`, ...) in every machine crate (data/, plex/, media/, session/, screens/, ui/, appkit/ and machine/), keyed `<path>::<item name>` (an attribute on an item), `<path>::<enclosing fn>` (a statement or an inline `cfg!`) or `<path>::<struct>` (a field).
# Logic is one thing in production and tests deliver it events: there is no cfg(test) fork. Spec: ci/check-deps.sh `forks`.
Expand All @@ -10,27 +10,8 @@ rust-modules/plex/src/plex/origin.rs::store_policy_forced
rust-modules/plex/src/plex/servers.rs::register_captured_origin_with_connection
rust-modules/plex/src/plex/session.rs::auth_paths
rust-modules/plex/src/plex/session.rs::clear_for_erase
rust-modules/plex/src/plex/session.rs::clear_for_erase
rust-modules/plex/src/plex/session.rs::clear_for_erase
rust-modules/plex/src/plex/session.rs::publish
rust-modules/plex/src/plex/session.rs::read_into_cache_locked
rust-modules/plex/src/plex/session.rs::read_into_cache_locked
rust-modules/plex/src/plex/session/install_preferences.rs::candidates
rust-modules/plex/src/plex/session/install_preferences.rs::candidates
rust-modules/plex/src/plex/session/persistence.rs::bootstrap
rust-modules/plex/src/plex/session/persistence.rs::bootstrap
rust-modules/plex/src/plex/session/persistence.rs::bootstrap
rust-modules/plex/src/plex/session/persistence.rs::cleanup_after_confirmed_clear
rust-modules/plex/src/plex/session/persistence.rs::cleanup_after_confirmed_clear
rust-modules/plex/src/plex/session/persistence.rs::cleanup_temporaries
rust-modules/plex/src/plex/session/persistence.rs::cleanup_temporaries
rust-modules/plex/src/plex/session/persistence.rs::commit_cleared
rust-modules/plex/src/plex/session/persistence.rs::commit_cleared
rust-modules/plex/src/plex/session/persistence.rs::commit_data
rust-modules/plex/src/plex/session/persistence.rs::commit_data
rust-modules/plex/src/plex/session/persistence.rs::load
rust-modules/plex/src/plex/session/persistence.rs::load
rust-modules/plex/src/plex/session/persistence.rs::migrate_session
rust-modules/plex/src/plex/session/persistence.rs::migrate_session
rust-modules/plex/src/plex/session/persistence.rs::write_session
rust-modules/plex/src/plex/session/persistence.rs::write_session
21 changes: 14 additions & 7 deletions docs/platform-ports.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,11 @@ Citations in this section quote the tree at e9924f0f9 with its old names (see "N
`load_login_client_id`, `:4336-4349`), reusing one process-local id when storage is unavailable.
`install_preferences::Saved` is `deny_unknown_fields`, version 1 (`:28-38`): it cannot carry the id without a
new version.
- The authority is chosen by `target_arch = "arm"`, not by a platform value (`session/persistence.rs:1400-1425`,
- The authority was chosen by `target_arch = "arm"`, not by a platform value (`session/persistence.rs:1400-1425`,
`commit_data` `:288-308`); a Tizen ARM build would select the DB8 arm with no helper behind it (F12). The
`MemoryOnly` gate sits above that selection, and W8a re-keys it.
`MemoryOnly` gate sits above that selection. W8a re-keyed plex's 21 sites to `tv::authority::authority()`:
`persistence.rs`'s dispatchers take the authority and the helper's transport, so a host test drives the helper
arm with a fake one; telemetry's sites follow in its own PR.

### Evidence from the second reviews: F40-F46 (each citation checked in the tree)

Expand Down Expand Up @@ -502,9 +504,11 @@ Citations in this section quote the tree at e9924f0f9 with its old names (see "N
- `CompletionOutcome` (`plex/src/plex/session/async_persistence.rs:112`) and `LiveWrite` are matched in
`session.rs`, `session/{persistence,async_persistence,prefs/profile_prefs}.rs`, `session/src/auth/owner.rs`,
`telemetry/src/telemetry/incident.rs:592-600`, `src/app/adapters/session.rs` and three test files.
- `install_preferences::candidates` (`:40`) and `clear_for_erase` (`session.rs:5341`) key on the ARM cfg, so
Tizen ARM reads `native = true`; `load` accepts `version == 1` only (`:59`) and `Saved` is
`deny_unknown_fields`. The ARM canonical write is cfg'd out of host tests (`session/persistence.rs:1400-1425`).
- `install_preferences::candidates` (`:40`) and `clear_for_erase` (`session.rs:5341`) keyed on the ARM cfg, so
Tizen ARM read `native = true` (W8a re-keyed them to `tv::authority::authority()`); `load` accepts
`version == 1` only (`:59`) and `Saved` is `deny_unknown_fields`. The ARM canonical write was cfg'd out of
host tests (`session/persistence.rs:1400-1425`); it is now the `Helper` arm of `persistence::*_via`, which every
host runs over a fake transport.
- `ci/check-deps.sh`: `plex/` is in `FORK_SCOPE`, `session.rs` in `MACHINES` (`:1406-1408`): a new
`cfg(test)` branch there is a `forks` line, a new static a `statics` line. `platform/` is not in `FORK_SCOPE`,
and only `platform/src/tv/plane.rs` is in `MACHINES` (`:1406-1408`; the scan `find` at `:1439` lists it too). The
Expand Down Expand Up @@ -850,9 +854,12 @@ split by who reads it (critic M4):
- `system { go_home, poll_home, deliver_toast }`;
- `storage { authority }` (W8a): `Authority::Helper` (webOS: the LS2/DB8 storage helper is the canonical store of
the session, the install's preferences and the consent record; the app's own files there are the legacy
migration inputs and the marked fallback of a helper outage) or `Authority::Files` (desktop, Tizen, a host
migration inputs, the marked fallback of a helper outage and the install-preferences file a sign-out writes
when the helper's clear is not durable) or `Authority::Files` (desktop, Tizen, a host
test: the app's own record files are the store), read through
`tv::authority::authority()`. It replaces the `target_os = "linux"` + `target_arch = "arm"` fence the persistence
`tv::authority::authority()`. `secure::mode()` decides the session record ahead of it: under `MemoryOnly`
(where Tizen starts, W9) the session lives in memory and no credential store is read or written, whatever the
authority says; only the install's own preference file persists. It replaces the `target_os = "linux"` + `target_arch = "arm"` fence the persistence
layers chose their store by; the helper's wake-up (`storage::client::install_activator`) joins it after W7b;
- `legacy_webos_media { sink, display_sink, uri_media }`: the Starfish, ACB and `com.webos.media` verbs (F31),
named for what they are (critic M3). Every hook is required (Decision 2, C): a platform states each field,
Expand Down
7 changes: 5 additions & 2 deletions rust-modules/base/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1336,8 +1336,11 @@ mod tests {
}
}

/// Legacy JSON/host-simulator persistence root. The canonical ARM adapter uses helper-owned DB8;
/// this path exists for old-record migration and for host tests that must never touch the checkout.
/// Legacy JSON/host-simulator persistence root. Where the platform states the storage helper as the
/// canonical store (a webOS television, `plx_os::tv::authority`) the canonical record is
/// helper-owned DB8; where it states plain files (the desktop simulator) the canonical record files
/// are kept here. This path also exists for old-record migration and for host tests that must never
/// touch the checkout.
///
/// **Test builds never resolve this to the machine-wide runtime dir by accident.** A test that
/// calls [`redirect_persistent_state_root_for_test`] gets the directory it asked for; a test that
Expand Down
26 changes: 19 additions & 7 deletions rust-modules/os/src/tv/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@
//! state root ([`Authority::Files`]): the desktop simulator, a host test, and a platform with no
//! helper at all (Tizen).
//!
//! Under `Helper` the app's own files are not the store. They are the legacy migration inputs an
//! older build left, and the marked fallback the session layer writes when a commit to the helper is
//! not durable (a helper outage): while the helper cannot answer, that file is served as transient
//! state, and it never replaces the helper's record.
//! The authority is not the whole answer for the session record: the platform's persistence mode
//! ([`secure::mode()`](super::secure::mode)) decides it first. Under `StoreMode::MemoryOnly`, where
//! Tizen starts (W9), the session lives in memory and no credential store is read or written,
//! whatever the authority says; only the install's own preference file (client id, language and
//! Interface resolution) persists.
//!
//! Under `Helper` the app's own files are not the store. Three kinds remain:
//! - the legacy migration inputs an older build left;
//! - the marked fallback the session layer writes when a commit to the helper is not durable (a
//! helper outage): while the helper cannot answer, that file is served as transient state, and it
//! never replaces the helper's record;
//! - the install-preferences file a sign-out writes when the helper's clear is not durable
//! (`install_preferences::save`): an unmarked `….language.json` file beside a session candidate, which
//! `install_preferences::load` reads back into the `Locked` and `Cleared` states.
//!
//! The platform states the value once, as the `authority` of its [`StorageHooks`](super::StorageHooks),
//! and [`authority`] reads it. A process that installed no platform (a host test) reads
Expand All @@ -30,10 +40,12 @@
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum Authority {
/// The platform's storage helper (webOS: the LS2/DB8 service) is the canonical store. The app's
/// own files are only the legacy migration inputs and the session layer's marked fallback, which
/// is written during a helper outage and is never the record.
/// own files are only the legacy migration inputs, the session layer's marked fallback (written
/// during a helper outage, never the record) and the install-preferences file a sign-out writes
/// when the helper's clear is not durable.
Helper,
/// The app's own record files under its persistent state root are the canonical store.
/// The app's own record files under its persistent state root are the canonical store. A process
/// in `StoreMode::MemoryOnly` still keeps the session record in memory (see the module doc).
#[default]
Files,
}
Expand Down
21 changes: 20 additions & 1 deletion rust-modules/plex/src/plex/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,25 @@ a dead source is **absent** from Home and states itself in its own library secti
struct, and a new field follows the omit rule.
6. **The Settings row** (labels, i18n, picker) is a screens edit, and `Choice` gains a variant
(T-settings).
- **Which store holds the session is the platform's statement, `plx_os::tv::authority::authority()`**
(`Helper`: the LS2/DB8 storage helper, webOS; `Files`: the 0600 record files, the desktop, a host test and
any platform with no helper), never the build's CPU or OS. `session/persistence.rs` reads it once per
public call (`load`, `commit_data`, `commit_cleared`, `write_session`, `migrate_session`, `bootstrap`,
`cleanup_after_confirmed_clear`, `cleanup_temporaries`) and hands it to the `*_via(authority, helper, ..)`
form, so a test passes the authority it grades and, for `Helper`, a transport of its own (an in-memory
`Backend` or a closure); the real `NativeTransport` is named by those public forms and by two helpers
with no `_via` seam (`reset_cleared_language()`, which `clear_for_erase` calls under `Helper` and which is
device-only, and `helper_commit`, which has no caller here), because on a Linux host it waits out a 12 s
start deadline with no helper behind it. There is no process-global override.
Under `Helper` the dispatchers never answer for a helper that cannot answer (a blocked read stays blocked,
and a legacy file is neither imported nor retired on its word); the files a television does keep beside DB8
are `session.rs`'s own: the marked fallback `save_legacy_fallback_locked` writes when a commit is not
durable, which `read_legacy_filtered_locked` serves as transient state, the legacy migration inputs, and the
install-preferences file (`install_preferences::save`, an unmarked `….language.json` beside a session
candidate) that `clear_for_erase` writes when a sign-out's helper clear is not durable. `secure::mode()`'s
`MemoryOnly` is read before the authority: it holds the session in memory and touches no credential store.
`clear_for_erase`, `read_into_cache_locked` and `install_preferences::keeps_language_file` read the same
value; the telemetry sweep after a durable clear runs only under `Helper`.
- **The DB8 document may not pass `MAX_LOGICAL_BYTES` (256 KiB), and per-profile memory is what
grows it.** Past the cap EVERY write fails (`LogicalTooLarge`, reported as `InvalidSchema`), so
`persistence::commit_session_with` measures the projected document (the os layer's own
Expand Down Expand Up @@ -688,7 +707,7 @@ a dead source is **absent** from Home and states itself in its own library secti
copy** (`session/memory_only.rs`): reads, guarded edits, revocation and clear all resolve
against it, and no credential is committed anywhere, canonical store, sealed or plaintext
fallback or revocation marker. The gate sits in `read_live_locked`, `save_locked_with_authority`
and `clear_for_erase`, above every `TEST_FILE` and `target_arch` branch, so nothing behind them
and `clear_for_erase`, above every `TEST_FILE` and storage-authority branch, so nothing behind them
is reachable. A write answers `PersistOutcome::Memory`, which classifies as
`CompletionOutcome::Ephemeral`: signed in for this run, so the auth owner goes on to Home, but
never a saved-login claim and never a warning. `drop_cache_locked` must not run in this mode
Expand Down
24 changes: 12 additions & 12 deletions rust-modules/plex/src/plex/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub use prefs::{IntroSkipPref, CreditsSkipPref, DolbyVisionModePref, InstantDpad
ProfilePrefsRecord, ProfileSetting, ProfileWrite, QualityPref, Row, Setting, SkipIntervalPref,
SubtitlePositionPref, SubtitleSizePref, SubtitleTonePref, TrailerAutoplayPref, HudEndTimePref, UiResolutionPref, UnderPostersPref};
use prefs::ProfileMemory;
use plx_os::tv::authority::{authority as storage_authority, Authority};
use serde::de::DeserializeOwned;
use serde::{Deserialize, Deserializer, Serialize};
use std::sync::Mutex;
Expand Down Expand Up @@ -3225,8 +3226,9 @@ fn read_into_cache_locked(expected: Option<u64>) -> (std::sync::Arc<ReadState>,
let state = std::sync::Arc::new(CACHE_READ_FOR_TEST.with(|read| {
read.get().unwrap_or(read_live_locked)()
}));
#[cfg(all(target_os = "linux", target_arch = "arm", not(feature = "hostsim"), not(any(test, feature = "test-support"))))]
plx_base::eventlog::log("session: authority read reason=miss");
if storage_authority() == Authority::Helper {
plx_base::eventlog::log("session: authority read reason=miss");
}
if !replace_cache(cached_arm(state.clone()), expected, false) { return (state, false); }
if let ReadState::Ready { session, .. } = &*state { publish_identities(session); }
(state, true)
Expand Down Expand Up @@ -5331,7 +5333,7 @@ fn clear_cleanup_outcome(outcome: persistence::ClearCleanupOutcome) -> ClearOutc
/// load. The old-path copy goes too, or the migration fallback would resurrect the stale session.
/// **And commits an explicit Cleared record to the canonical authority** — the legacy-file sweep
/// below only ever touches pre-DB8 candidates; on a build where `persistence::load`/`write_session`
/// actually read/write the canonical store (DB8 or its host/ARM equivalent), that store is a
/// actually read/write the canonical store (DB8 or its host equivalent), that store is a
/// SEPARATE copy of the account token and roster, and clearing only the legacy files would leave a
/// clean-looking sign-out that the canonical authority still hands back on the next boot.
///
Expand Down Expand Up @@ -5367,7 +5369,7 @@ pub fn clear_for_erase(all_local: bool, retry: Option<Retained>) -> Erasure {
return memory_only::clear_locked(all_local, retry);
}
let kept = retry.unwrap_or_else(|| Retained::of(&session_from_read(&read_live_locked())));
let native = cfg!(all(target_os = "linux", target_arch = "arm", not(feature = "hostsim"), not(any(test, feature = "test-support"))));
let native = storage_authority() == Authority::Helper;
// File backends need a credential-free resource before the credential file disappears.
let mut preference_failures = Vec::new();
if !all_local && !native && !install_preferences::save(kept) {
Expand Down Expand Up @@ -5419,22 +5421,20 @@ pub fn clear_for_erase(all_local: bool, retry: Option<Retained>) -> Erasure {
// `auth_paths()` above only ever covered `paths::session_candidates()` — the legacy
// sign-in file and its pre-relocation predecessor. The recognized migration source set
// is bigger (`paths::session_migration_candidates()`, plus the pre-DB8 canonical JSON
// wrapper on ARM), and a candidate this sweep never visits is a live account token left
// wrapper where the helper is canonical), and a candidate this sweep never visits is a live account token left
// on a rooted, world-readable install prefix after a sign-out that otherwise looked
// clean. `cleanup_after_confirmed_clear` re-reads the authority to confirm it really is
// Cleared before retiring anything, so this can only ever remove residue, never data a
// concurrent re-login just wrote.
#[allow(unused_mut)] // only mutated on the ARM cfg arm below
let mut outcome = clear_cleanup_outcome(persistence::cleanup_after_confirmed_clear());
// Telemetry/consent's own legacy files are a SEPARATE candidate set from the session
// auth-token sweep above (`persistence::cleanup_after_confirmed_clear` never touches
// them — see `paths::telemetry_candidates` vs `paths::session_migration_candidates`).
// On ARM, `telemetry::persistence::forget_at` defers their removal to exactly this
// moment, once this canonical commit is confirmed durable (Copilot review on PR #105,
// finding 7; ported from `release/v0.6`'s `telemetry::cleanup_after_account_clear`,
// called here in that release).
#[cfg(all(target_os = "linux", target_arch = "arm", not(feature = "hostsim"), not(any(test, feature = "test-support"))))]
if !ACCOUNT_CLEAR_CLEANUP.get().is_none_or(|sweep| sweep()) {
// Where the storage helper is canonical, `telemetry::persistence::forget_at` defers their
// removal to exactly this moment, once this canonical commit is confirmed durable
// (Copilot review on PR #105, finding 7; ported from `release/v0.6`'s
// `telemetry::cleanup_after_account_clear`, called here in that release).
if native && !ACCOUNT_CLEAR_CLEANUP.get().is_none_or(|sweep| sweep()) {
plx_base::eventlog::log(
"session: canonical clear is durable but a telemetry/consent legacy \
candidate could not be retired — it remains on disk and will be swept \
Expand Down
Loading
Loading