Skip to content

coldstart: the app writes down where it was, and a cold boot goes back there - #56

Merged
GLinnik21 merged 2 commits into
mainfrom
b7-coldstart
Aug 23, 2026
Merged

GLinnik21 merged 2 commits into
mainfrom
b7-coldstart

Conversation

@GLinnik21

@GLinnik21 GLinnik21 commented Aug 23, 2026 •

Copy link
Copy Markdown
Collaborator

What this is

The persistence half of LG App Self Checklist #3 (Reboot), whose matrix
docs/lg-self-checklist.md records as entirely unrun.

The app-switch lifecycle was already built properly, and every bit of it lives in the
process: 0x103 snapshots the intended position, cancels an in-flight resolve, suspends
the buffer-feed and drops to Home; 0x106 rewinds and resume_ats before start_bufferfeed
so one Load carries the position. None of that survives the process ending. A cold start
— the set powered off and on, the mains pulled, the app closed from the Recent List and
launched again — came up from credential state alone (Login / Profiles / Onboard /
Home), because where you actually were was written down nowhere.

Now it is. rust-modules/src/coldstart.rs records a Place and the boot reads it back:

Place recorded from restored as
Home Home, Search, the person page nothing to do — the boot lands there anyway
Library { tab } the browse grid, as a tab PILL library::enter(tab, Arrival::Cut)
Item { machine, rk } a detail page, or the item a playback was of that item's detail page

Playback is deliberately restored to the detail page, never the player. Coming out of a
power cycle straight into a decoding video is an ambush, not a restore; the detail page puts
Resume one press away and the resume point is the server's viewOffset, which the app already
posts every 10 s. No playback position is stored locally — a second source of truth would
disagree exactly when it matters, since the case this feature is about (the mains pulled) is
the case where the local copy was never flushed.

Three decisions worth reviewing

1. The file is NOT in the runtime root, although that is where the unit was scoped to put
it and it is the obvious home for something this small. /tmp on a television is cleared by
a reboot
— this repo already leans on that in the other direction: tools/tv-lock.sh puts
the device lease under /tmp because a reboot should release it, and plex::session logs
"login will not survive a reboot" when it can reach none of the persistent paths. A cold-start
restore whose state file is erased by the cold start is a no-op. So it goes where the session
file goes — paths::last_place_candidates(), the same three-directory ladder, with its own
filename and no legacy-migration entry.

Two smaller wins fall out of the same choice, and they answer the trap the unit flagged:

  • The name is outside the plxnative-* trigger namespace, so it cannot suppress the
    who's-watching picker on every ordinary boot the way a state file in the runtime root would
    have (dev::any_trigger_present; tools/tv-lock.sh records the same trap from the other
    side). Nothing was added to dev::DIAG — the question cannot arise.
  • It is outside the glob tests/run.py sweeps, which means a teardown could not have
    undone it either. Harness determinism is bought where it belongs instead: nothing is
    recorded on an automated boot
    , and nothing is restored.

2. Not in Session, as the unit required. That file fails as a unit and a parse failure
there is a silent sign-out at every boot — every list in it is soft-parsed entry-by-entry for
exactly that reason. This owns its own file and format and fails soft to today's behaviour on
every path: absent, empty (the mains-pull shape), truncated, valid JSON of the wrong type,
unknown format version, no version at all, an item missing half its identity, a record
belonging to another profile, a server no longer registered, an unwritable location.

3. Two rules that stop the feature erasing its own state. Both came out of the code review
and both are load-bearing:

  • Nothing is recorded until the boot SEQUENCE has ended. arm() only reads the file;
    take_restore() decides, once the app is on a real page. The sign-in, the picker and the
    first-run question all hand over to Home when answered — a recorder open through that window
    writes home over the record before anybody could ask for it, permanently, on every boot, for
    exactly the multi-profile household the profile key exists for. It is also why the profile is
    compared in take_restore and not in arm: before the picker is answered,
    session::current_profile_key() still names whoever was last signed in.
  • Home is recorded as a RETURN, never as a landing. A boot whose restore was declined —
    the recorded item's server has not been re-registered by the async roster refresh yet — sits
    on Home, and recording that Home would destroy the record by way of the one boot that could
    not use it.

Two things that are NOT decided here

pkg/appinfo.json is unchanged. It still sets "handlesRelaunch": false and
"nativeLifeCycleInterfaceVersion": 2, and nothing in rust-modules/src/ reads or reacts to
either (grep handlesRelaunch: zero hits). Neither is evidence about a native app's cold-boot
behaviour on this firmware:

  • handlesRelaunch is documented by LG for re-launching an app that is already
    running
    — the app either handles the second launch request itself or is restarted. A cold
    boot is a process that was not running, so the flag says nothing about it. The page
    documenting it is written for the web runtime, and this repo's rule is that a
    develop/* page is context for a native app and never proof.
  • nativeLifeCycleInterfaceVersion is recorded in docs/distribution.md §1.6 as a webOS
    OSE property that no shipped native TV app sets — ours does, harmlessly.

So #3's verdict is not claimed. It needs a television, and the matrix below is the recipe.
I had no device access in this lane.

The native lifecycle matrix — the recipe for #3

Take the TV lock first (tv-lock skill), and read the event log's first line to confirm which
install you are grading. Every case is graded on the coldstart: lines in
$(make -s print-eventlog) plus what is on the panel.

Setup, once:

make FLAVOR=<flavour> deploy          # a dev build is fine; the feature is not gated
# sign in normally, or let the stored session stand — do NOT arm any plxnative-* trigger,
# which marks the boot automated and disables the feature by design

The state file, for each case (there is no trigger for it; it is not a dev surface):

# Developer Mode install:
ssh root@<tv> 'cat /media/developer/<app id>-lastplace.json'
# Homebrew Channel install:
ssh root@<tv> 'cat /media/internal/.<app id>-lastplace.json'
# Case Do Expect
1 Remote power off/on Open a film's detail page, wait 2 s, power off with the remote, power on, launch the app coldstart: place on file kind=item then coldstart: restored the item's detail page; that page on screen
2 AC unplug/replug Same, but pull the mains instead of using the remote Same. This is the case the atomic write (sibling tmp → fsync → rename) exists for — the record must be the whole previous file or the whole new one, never zero bytes
3 AC pull, then look for the file After case 2, confirm the record file still exists It must — if it does not, it was written to the runtime root and the whole feature is a no-op
4 Recent List Open the app, go to a library tab, press HOME, re-select the app from the Recent List This is a foreground event, not a cold start: the app was never killed, so nothing should be restored and nothing logged. Note whether webOS actually keeps it resident
5 Recent List after eviction As 4, but open several other apps first so the TV kills ours A cold start: the library tab restored
6 Launcher vs Recent List Cold-start once from each Identical behaviour; both should log coldstart:
7 Backgrounded playback Start a film, press HOME on the remote (app goes to background, session suspended), then power the set off at the wall The record must still name the film, not Home — this is the bg_was_playing guard
8 Who's watching With a multi-user Plex Home: as user A open a detail page, power-cycle, pick A at the picker The page restores the instant the picker hands over to Home — no Home flash
9 Who's watching, other profile As 8 but pick B the recorded place belongs to another profile — ignoring it; B lands on Home, and B's own first navigation replaces the record
10 Boot flash Watch case 1 closely with the splash Does the ~500 ms of Home before the restore read as a glitch? This is the one thing COLDSTART_RESTORE_MS trades and the only reason it is a number
11 Deleted item Record a detail page, delete the item from the library server-side, cold-start The page opens on the item's own art and the fetch fails — degraded, not fatal. Confirm it is not a wedge
12 Unreachable server Record a detail page on a shared source, take that server off the network, cold-start the recorded item's server is not registered — staying on Home, and no stall: the item path is the async detail::open_rk and the library path refuses rather than let library::enter reach its blocking discovery
13 First install Uninstall, reinstall, sign in, look at Home, close coldstart: no place recorded, and no file written — an install that never navigates must cost nothing
14 Harness safety ./tests/run.py (any tier), then cold-start by hand No coldstart: line in any harness run's log, and the record from before the run is unchanged
15 Two installs Repeat case 1 on stable and on debug Two separate records; neither restores the other's page
16 Release build make RELEASE=1 deploy, repeat case 1 Identical — this is a user feature, not a dev trigger, and is not behind devtriggers

Cases 4, 5 and 6 are what actually answer handlesRelaunch: if a Recent List re-selection turns
out to relaunch rather than foreground the app on this firmware, the flag becomes a real question
and docs/lg-self-checklist.md's #3 row should say so.

Verification done here

  • make check — 986 passed (10 new in coldstart), make lint clean.
  • cargo +nightly check --lib --no-default-features clean (the PostToolUse release-config
    hook ran on every edit).
  • python3 ci/check-package.py — all tracked-file assertions pass (appinfo.json untouched).
  • A real two-boot round trip in the desktop simulator, which is what proves the wiring the
    host tests cannot reach. Driven with a real session file in the instance root rather than
    make sim-token, because the token is a plxnative-* trigger and so marks the boot
    automated — which correctly disables the feature:
    • boot 1: down down ok into a detail page → coldstart: recorded place kind=item, and the
      record lands in the instance root;
    • boot 2: coldstart: place on file kind=item → coldstart: restored the item's detail page,
      with the page fully rendered in the screenshot (hero art, facts row, Play);
    • BACK to Home then records kind=home;
    • a hand-written kind:"library" record restores the browse grid;
    • a truncated record → no place recorded, boots to Home;
    • a boot with any non-DIAG plxnative-* file present → zero coldstart: lines, route
      stays Home, and the existing record is left untouched.
  • No device work at all — this lane had no television.

Corrections to the unit's brief, per "trust the file"

  • rust-modules/src/viewstate.rs already exists and is the server-side view-state WRITE
    path (Mark as Watched / Unwatched / Remove from Continue Watching, off the SDL thread). The new
    module is rust-modules/src/coldstart.rs.
  • The unit scoped the state file to the install's runtime root. That is where a reboot
    erases it; see decision 1 above. It is in the session file's persistent ladder instead.
  • app.rs:4149-4190 (the same block is now :4329-4385) is pre-loop declarations only, so
    the restore and the recorder cannot both live there — the restore needs data that has not
    landed at that point, and the recorder needs a per-frame call. The footprint outside that
    region is: one free fn block next to page_of (coldstart_frame / coldstart_place /
    apply_coldstart, well clear of both sibling lanes' regions) and one call immediately
    after let now = SDL_GetTicks(); in the dev-trigger area of the loop. Neither touches
    :4408-4577 (b6-keys) or :3858 / :3903-3958 (t1-origin).
  • img.rs's three stale comments were as described and are fixed.

Doc audit (second commit)

doc-claim-auditor over the diff, across 71 markdown files, the 11 skills, the 4 CLAUDE.mds
and 111 Rust module docs. Six contradictions, all fixed in 3505ff06:

Caused by this change (2). The release-notes "written outside its own directory" row
(TEMPLATE.md + README.md) was no longer exhaustive — coldstart is not behind
devtriggers, so a release binary always writes a second file into /media/{developer,internal}.
That row is a gate item and README's own standard is that "a property stated in a form that fails
the reader's own check reads as a lie"; it now names the file and its contents (page, profile id,
one server/item id — no token, no playback position). And docs/parity-gaps.md's inventory
sentence, "the only thing ever written to disk is the credentials session", said in two places
that the very precedent its own Where: asks for did not exist.

Already false in the prose the diff touches (4). requiredMemory: 60 in three more places
(two-installs.md §3.1, and the release-notes disclosure row and its worked example) — the same
string as the img.rs comments this branch fixes, each citing the §6.10 that says the number is 160
against a measured 152 MiB; the template would have had the next release publicly disclose a
defect that is fixed. lib.rs:22 called ff "the TV's own FFmpeg 3.3 via the stub-.so link",
inverted on both halves and three lines below the line this branch added. And
parity-gaps.md:1567 still carried "the raw-socket client cannot do chunked transfer" — the exact
sentence the root CLAUDE.md holds up as this repo's archetypal false claim, surviving in another
file.

Deliberately left: two-installs.md §3.1's shared-resource inventory (it refuses by
construction to be trusted as a list — "re-derived against the tree, not inherited"), the dated
*Verified:* blocks in parity-gaps.md, and lg-self-checklist.md's #3 row, which still says the
matrix is unrun — because it is.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

GLinnik21 and others added 2 commits August 23, 2026 13:23
…k there

The app-switch lifecycle was already handled properly, and all of it lives in
the PROCESS: background suspends the buffer-feed and drops to Home, foreground
reloads and resumes at the saved position with one Load. A COLD start — the set
powered off and on, the mains pulled, the app closed from the Recent List —
begins with a process that has seen none of that, and the boot route came purely
from credential state. Where you actually were was written down nowhere. That is
the persistence half of LG App Self Checklist #3 (Reboot).

`rust-modules/src/coldstart.rs` records a Place — Home, a library TAB PILL, or an
item addressed as (machineIdentifier, ratingKey) — and app.rs reads it back at
boot. A playback session records the played leaf and is restored to that item's
DETAIL page, never to the player: coming out of a power cycle into a decoding
video is an ambush, and the resume point is the server's `viewOffset` anyway.

Three decisions worth carrying:

* **Not the runtime root**, though that is the obvious home for a file this
  small. `/tmp` on a television is cleared by a reboot — this repo already leans
  on that in the other direction, since `tools/tv-lock.sh` puts the device lease
  there BECAUSE a reboot should release it — so a cold-start restore living
  there would be erased by the cold start. It goes where the session file goes
  (`paths::last_place_candidates`). Two smaller wins fall out: the name is
  outside the `plxnative-*` trigger namespace, so it cannot suppress the
  who's-watching picker the way a state file in `/tmp` would have, and it is
  outside the glob `tests/run.py` sweeps.

* **Not in `Session`.** That file fails as a unit and a parse failure there is a
  silent sign-out at every boot; every list in it is soft-parsed for exactly that
  reason. A convenience feature has no business in that blast radius, so this
  owns its own file, its own format, and fails soft to today's behaviour on
  every path — absent, empty, truncated, hand-edited, unknown version, foreign
  profile, a server no longer registered.

* **Two rules that stop the feature erasing its own state.** Nothing is recorded
  until the boot SEQUENCE has ended, because the sign-in, the picker and the
  first-run question all hand over to Home when answered — a recorder open
  through that window writes `home` over the record before anyone can ask for
  it, permanently, for exactly the multi-profile household the profile key
  exists for. And Home is recorded as a RETURN, never as a landing, so a boot
  whose restore was declined (the item's server not re-registered yet) does not
  destroy the record on its way past.

Nothing is recorded on an AUTOMATED boot, which is where the harness's
determinism is bought: this file is outside the glob `tests/run.py` clears, so
refusing to arm is the only place that can be done.

`pkg/appinfo.json` is UNCHANGED. `handlesRelaunch` and
`nativeLifeCycleInterfaceVersion` are documented in the module and left alone —
neither is evidence about a native app's cold-boot behaviour on this firmware,
and the verdict for #3 belongs to the device matrix in the PR body.

Also fixes three `requiredMemory: 60` comments in img.rs; the manifest says 160.

Verified: 986/986 host tests (10 new), `--no-default-features` clean, and a real
two-boot round trip in the simulator — navigate to a detail page, close, relaunch,
and the app comes up on that page; BACK then records Home; an automated boot
neither records nor restores; a truncated record boots to Home.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G
`doc-claim-auditor` on the coldstart diff. Two were caused by it and four were
already false in prose the diff touches — all six are the same failure mode, a
sentence that was true when written and that nothing compiles.

CAUSED BY THIS CHANGE:

* The release-notes **"written outside its own directory"** row (TEMPLATE.md and
  README.md) listed the three logs and the session file. `coldstart` is NOT
  behind `devtriggers` — `any_trigger_present()` is a compile-time `false` in a
  release build, so `arm()` always runs — and it writes a second file into
  `/media/{developer,internal}`. That row's whole value is being exhaustive; it
  is a gate item, and README's own standard is that "a property stated in a form
  that fails the reader's own check reads as a lie". Now names the file and what
  is in it: the page, the profile id, one server/item id, no token, no position.

* **`docs/parity-gaps.md`'s on-disk inventory** — "the only thing ever written to
  disk is the credentials session", and the same claim again 400 lines later.
  There are two files now, and the new one is the precedent that gap's own
  *Where:* asks for ("a new preferences file alongside plex/session.rs"), so the
  sentence said the thing it wanted did not exist.

ALREADY FALSE, in the same prose:

* `requiredMemory: 60` in **three more places** — `docs/two-installs.md` §3.1 and
  the release-notes template's disclosure row and its worked example. Identical
  string to the three img.rs comments this branch already fixed, stale since
  6d79230 (2026-08-22), and each one cites `distribution.md` §6.10 as its
  source — the section that says the "~74 MB peak" was never a measurement and
  that the number is 160 against a measured 152 MiB. The template would have had
  the next release publicly disclose a defect that is fixed.

* **`lib.rs:22`** described `ff` as "the TV's own FFmpeg 3.3 via the stub-.so
  link". Both halves inverted: the app bundles and pins FFmpeg 9.0 (56147f1)
  and `stub/` was deleted (72b7d71). Three lines below the line this branch
  added, in the list a newcomer reads first.

* **`parity-gaps.md:1567`** carried "the raw-socket client cannot do chunked
  transfer" — the exact sentence the root CLAUDE.md holds up as this repo's
  archetypal false claim, surviving in another file. `stream.rs` decodes chunked;
  its only disqualifiers are DNS and TLS.

Left alone deliberately: `two-installs.md` §3.1's shared-resource inventory does
not list the new per-install file, and that section refuses to be trusted as a
list by construction ("re-derived against the tree, not inherited"); the dated
`*Verified:*` blocks in parity-gaps.md keep their 2026-07-29 line numbers; and
`lg-self-checklist.md`'s #3 row still says the matrix is unrun, which is true.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G
@GLinnik21
GLinnik21 merged commit 36ed9fd into main Aug 23, 2026
2 checks passed
GLinnik21 added a commit that referenced this pull request Aug 26, 2026
…k there (#56)

* coldstart: the app writes down where it was, and a cold boot goes back there

The app-switch lifecycle was already handled properly, and all of it lives in
the PROCESS: background suspends the buffer-feed and drops to Home, foreground
reloads and resumes at the saved position with one Load. A COLD start — the set
powered off and on, the mains pulled, the app closed from the Recent List —
begins with a process that has seen none of that, and the boot route came purely
from credential state. Where you actually were was written down nowhere. That is
the persistence half of LG App Self Checklist #3 (Reboot).

`rust-modules/src/coldstart.rs` records a Place — Home, a library TAB PILL, or an
item addressed as (machineIdentifier, ratingKey) — and app.rs reads it back at
boot. A playback session records the played leaf and is restored to that item's
DETAIL page, never to the player: coming out of a power cycle into a decoding
video is an ambush, and the resume point is the server's `viewOffset` anyway.

Three decisions worth carrying:

* **Not the runtime root**, though that is the obvious home for a file this
  small. `/tmp` on a television is cleared by a reboot — this repo already leans
  on that in the other direction, since `tools/tv-lock.sh` puts the device lease
  there BECAUSE a reboot should release it — so a cold-start restore living
  there would be erased by the cold start. It goes where the session file goes
  (`paths::last_place_candidates`). Two smaller wins fall out: the name is
  outside the `plxnative-*` trigger namespace, so it cannot suppress the
  who's-watching picker the way a state file in `/tmp` would have, and it is
  outside the glob `tests/run.py` sweeps.

* **Not in `Session`.** That file fails as a unit and a parse failure there is a
  silent sign-out at every boot; every list in it is soft-parsed for exactly that
  reason. A convenience feature has no business in that blast radius, so this
  owns its own file, its own format, and fails soft to today's behaviour on
  every path — absent, empty, truncated, hand-edited, unknown version, foreign
  profile, a server no longer registered.

* **Two rules that stop the feature erasing its own state.** Nothing is recorded
  until the boot SEQUENCE has ended, because the sign-in, the picker and the
  first-run question all hand over to Home when answered — a recorder open
  through that window writes `home` over the record before anyone can ask for
  it, permanently, for exactly the multi-profile household the profile key
  exists for. And Home is recorded as a RETURN, never as a landing, so a boot
  whose restore was declined (the item's server not re-registered yet) does not
  destroy the record on its way past.

Nothing is recorded on an AUTOMATED boot, which is where the harness's
determinism is bought: this file is outside the glob `tests/run.py` clears, so
refusing to arm is the only place that can be done.

`pkg/appinfo.json` is UNCHANGED. `handlesRelaunch` and
`nativeLifeCycleInterfaceVersion` are documented in the module and left alone —
neither is evidence about a native app's cold-boot behaviour on this firmware,
and the verdict for #3 belongs to the device matrix in the PR body.

Also fixes three `requiredMemory: 60` comments in img.rs; the manifest says 160.

Verified: 986/986 host tests (10 new), `--no-default-features` clean, and a real
two-boot round trip in the simulator — navigate to a detail page, close, relaunch,
and the app comes up on that page; BACK then records Home; an automated boot
neither records nor restores; a truncated record boots to Home.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* docs: the six claims this change made false, and four it only sat beside

`doc-claim-auditor` on the coldstart diff. Two were caused by it and four were
already false in prose the diff touches — all six are the same failure mode, a
sentence that was true when written and that nothing compiles.

CAUSED BY THIS CHANGE:

* The release-notes **"written outside its own directory"** row (TEMPLATE.md and
  README.md) listed the three logs and the session file. `coldstart` is NOT
  behind `devtriggers` — `any_trigger_present()` is a compile-time `false` in a
  release build, so `arm()` always runs — and it writes a second file into
  `/media/{developer,internal}`. That row's whole value is being exhaustive; it
  is a gate item, and README's own standard is that "a property stated in a form
  that fails the reader's own check reads as a lie". Now names the file and what
  is in it: the page, the profile id, one server/item id, no token, no position.

* **`docs/parity-gaps.md`'s on-disk inventory** — "the only thing ever written to
  disk is the credentials session", and the same claim again 400 lines later.
  There are two files now, and the new one is the precedent that gap's own
  *Where:* asks for ("a new preferences file alongside plex/session.rs"), so the
  sentence said the thing it wanted did not exist.

ALREADY FALSE, in the same prose:

* `requiredMemory: 60` in **three more places** — `docs/two-installs.md` §3.1 and
  the release-notes template's disclosure row and its worked example. Identical
  string to the three img.rs comments this branch already fixed, stale since
  66688ed (2026-08-22), and each one cites `distribution.md` §6.10 as its
  source — the section that says the "~74 MB peak" was never a measurement and
  that the number is 160 against a measured 152 MiB. The template would have had
  the next release publicly disclose a defect that is fixed.

* **`lib.rs:22`** described `ff` as "the TV's own FFmpeg 3.3 via the stub-.so
  link". Both halves inverted: the app bundles and pins FFmpeg 9.0 (41720ab)
  and `stub/` was deleted (7e296ec). Three lines below the line this branch
  added, in the list a newcomer reads first.

* **`parity-gaps.md:1567`** carried "the raw-socket client cannot do chunked
  transfer" — the exact sentence the root CLAUDE.md holds up as this repo's
  archetypal false claim, surviving in another file. `stream.rs` decodes chunked;
  its only disqualifiers are DNS and TLS.

Left alone deliberately: `two-installs.md` §3.1's shared-resource inventory does
not list the new per-install file, and that section refuses to be trusted as a
list by construction ("re-derived against the tree, not inherited"); the dated
`*Verified:*` blocks in parity-gaps.md keep their 2026-07-29 line numbers; and
`lg-self-checklist.md`'s #3 row still says the matrix is unrun, which is true.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
GLinnik21 added a commit that referenced this pull request Aug 27, 2026
…k there (#56)

* coldstart: the app writes down where it was, and a cold boot goes back there

The app-switch lifecycle was already handled properly, and all of it lives in
the PROCESS: background suspends the buffer-feed and drops to Home, foreground
reloads and resumes at the saved position with one Load. A COLD start — the set
powered off and on, the mains pulled, the app closed from the Recent List —
begins with a process that has seen none of that, and the boot route came purely
from credential state. Where you actually were was written down nowhere. That is
the persistence half of LG App Self Checklist #3 (Reboot).

`rust-modules/src/coldstart.rs` records a Place — Home, a library TAB PILL, or an
item addressed as (machineIdentifier, ratingKey) — and app.rs reads it back at
boot. A playback session records the played leaf and is restored to that item's
DETAIL page, never to the player: coming out of a power cycle into a decoding
video is an ambush, and the resume point is the server's `viewOffset` anyway.

Three decisions worth carrying:

* **Not the runtime root**, though that is the obvious home for a file this
  small. `/tmp` on a television is cleared by a reboot — this repo already leans
  on that in the other direction, since `tools/tv-lock.sh` puts the device lease
  there BECAUSE a reboot should release it — so a cold-start restore living
  there would be erased by the cold start. It goes where the session file goes
  (`paths::last_place_candidates`). Two smaller wins fall out: the name is
  outside the `plxnative-*` trigger namespace, so it cannot suppress the
  who's-watching picker the way a state file in `/tmp` would have, and it is
  outside the glob `tests/run.py` sweeps.

* **Not in `Session`.** That file fails as a unit and a parse failure there is a
  silent sign-out at every boot; every list in it is soft-parsed for exactly that
  reason. A convenience feature has no business in that blast radius, so this
  owns its own file, its own format, and fails soft to today's behaviour on
  every path — absent, empty, truncated, hand-edited, unknown version, foreign
  profile, a server no longer registered.

* **Two rules that stop the feature erasing its own state.** Nothing is recorded
  until the boot SEQUENCE has ended, because the sign-in, the picker and the
  first-run question all hand over to Home when answered — a recorder open
  through that window writes `home` over the record before anyone can ask for
  it, permanently, for exactly the multi-profile household the profile key
  exists for. And Home is recorded as a RETURN, never as a landing, so a boot
  whose restore was declined (the item's server not re-registered yet) does not
  destroy the record on its way past.

Nothing is recorded on an AUTOMATED boot, which is where the harness's
determinism is bought: this file is outside the glob `tests/run.py` clears, so
refusing to arm is the only place that can be done.

`pkg/appinfo.json` is UNCHANGED. `handlesRelaunch` and
`nativeLifeCycleInterfaceVersion` are documented in the module and left alone —
neither is evidence about a native app's cold-boot behaviour on this firmware,
and the verdict for #3 belongs to the device matrix in the PR body.

Also fixes three `requiredMemory: 60` comments in img.rs; the manifest says 160.

Verified: 986/986 host tests (10 new), `--no-default-features` clean, and a real
two-boot round trip in the simulator — navigate to a detail page, close, relaunch,
and the app comes up on that page; BACK then records Home; an automated boot
neither records nor restores; a truncated record boots to Home.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* docs: the six claims this change made false, and four it only sat beside

`doc-claim-auditor` on the coldstart diff. Two were caused by it and four were
already false in prose the diff touches — all six are the same failure mode, a
sentence that was true when written and that nothing compiles.

CAUSED BY THIS CHANGE:

* The release-notes **"written outside its own directory"** row (TEMPLATE.md and
  README.md) listed the three logs and the session file. `coldstart` is NOT
  behind `devtriggers` — `any_trigger_present()` is a compile-time `false` in a
  release build, so `arm()` always runs — and it writes a second file into
  `/media/{developer,internal}`. That row's whole value is being exhaustive; it
  is a gate item, and README's own standard is that "a property stated in a form
  that fails the reader's own check reads as a lie". Now names the file and what
  is in it: the page, the profile id, one server/item id, no token, no position.

* **`docs/parity-gaps.md`'s on-disk inventory** — "the only thing ever written to
  disk is the credentials session", and the same claim again 400 lines later.
  There are two files now, and the new one is the precedent that gap's own
  *Where:* asks for ("a new preferences file alongside plex/session.rs"), so the
  sentence said the thing it wanted did not exist.

ALREADY FALSE, in the same prose:

* `requiredMemory: 60` in **three more places** — `docs/two-installs.md` §3.1 and
  the release-notes template's disclosure row and its worked example. Identical
  string to the three img.rs comments this branch already fixed, stale since
  68536a1 (2026-08-22), and each one cites `distribution.md` §6.10 as its
  source — the section that says the "~74 MB peak" was never a measurement and
  that the number is 160 against a measured 152 MiB. The template would have had
  the next release publicly disclose a defect that is fixed.

* **`lib.rs:22`** described `ff` as "the TV's own FFmpeg 3.3 via the stub-.so
  link". Both halves inverted: the app bundles and pins FFmpeg 9.0 (41720ab)
  and `stub/` was deleted (7e296ec). Three lines below the line this branch
  added, in the list a newcomer reads first.

* **`parity-gaps.md:1567`** carried "the raw-socket client cannot do chunked
  transfer" — the exact sentence the root CLAUDE.md holds up as this repo's
  archetypal false claim, surviving in another file. `stream.rs` decodes chunked;
  its only disqualifiers are DNS and TLS.

Left alone deliberately: `two-installs.md` §3.1's shared-resource inventory does
not list the new per-install file, and that section refuses to be trusted as a
list by construction ("re-derived against the tree, not inherited"); the dated
`*Verified:*` blocks in parity-gaps.md keep their 2026-07-29 line numbers; and
`lg-self-checklist.md`'s #3 row still says the matrix is unrun, which is true.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
GLinnik21 added a commit that referenced this pull request Aug 28, 2026
…k there (#56)

* coldstart: the app writes down where it was, and a cold boot goes back there

The app-switch lifecycle was already handled properly, and all of it lives in
the PROCESS: background suspends the buffer-feed and drops to Home, foreground
reloads and resumes at the saved position with one Load. A COLD start — the set
powered off and on, the mains pulled, the app closed from the Recent List —
begins with a process that has seen none of that, and the boot route came purely
from credential state. Where you actually were was written down nowhere. That is
the persistence half of LG App Self Checklist #3 (Reboot).

`rust-modules/src/coldstart.rs` records a Place — Home, a library TAB PILL, or an
item addressed as (machineIdentifier, ratingKey) — and app.rs reads it back at
boot. A playback session records the played leaf and is restored to that item's
DETAIL page, never to the player: coming out of a power cycle into a decoding
video is an ambush, and the resume point is the server's `viewOffset` anyway.

Three decisions worth carrying:

* **Not the runtime root**, though that is the obvious home for a file this
  small. `/tmp` on a television is cleared by a reboot — this repo already leans
  on that in the other direction, since `tools/tv-lock.sh` puts the device lease
  there BECAUSE a reboot should release it — so a cold-start restore living
  there would be erased by the cold start. It goes where the session file goes
  (`paths::last_place_candidates`). Two smaller wins fall out: the name is
  outside the `plxnative-*` trigger namespace, so it cannot suppress the
  who's-watching picker the way a state file in `/tmp` would have, and it is
  outside the glob `tests/run.py` sweeps.

* **Not in `Session`.** That file fails as a unit and a parse failure there is a
  silent sign-out at every boot; every list in it is soft-parsed for exactly that
  reason. A convenience feature has no business in that blast radius, so this
  owns its own file, its own format, and fails soft to today's behaviour on
  every path — absent, empty, truncated, hand-edited, unknown version, foreign
  profile, a server no longer registered.

* **Two rules that stop the feature erasing its own state.** Nothing is recorded
  until the boot SEQUENCE has ended, because the sign-in, the picker and the
  first-run question all hand over to Home when answered — a recorder open
  through that window writes `home` over the record before anyone can ask for
  it, permanently, for exactly the multi-profile household the profile key
  exists for. And Home is recorded as a RETURN, never as a landing, so a boot
  whose restore was declined (the item's server not re-registered yet) does not
  destroy the record on its way past.

Nothing is recorded on an AUTOMATED boot, which is where the harness's
determinism is bought: this file is outside the glob `tests/run.py` clears, so
refusing to arm is the only place that can be done.

`pkg/appinfo.json` is UNCHANGED. `handlesRelaunch` and
`nativeLifeCycleInterfaceVersion` are documented in the module and left alone —
neither is evidence about a native app's cold-boot behaviour on this firmware,
and the verdict for #3 belongs to the device matrix in the PR body.

Also fixes three `requiredMemory: 60` comments in img.rs; the manifest says 160.

Verified: 986/986 host tests (10 new), `--no-default-features` clean, and a real
two-boot round trip in the simulator — navigate to a detail page, close, relaunch,
and the app comes up on that page; BACK then records Home; an automated boot
neither records nor restores; a truncated record boots to Home.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* docs: the six claims this change made false, and four it only sat beside

`doc-claim-auditor` on the coldstart diff. Two were caused by it and four were
already false in prose the diff touches — all six are the same failure mode, a
sentence that was true when written and that nothing compiles.

CAUSED BY THIS CHANGE:

* The release-notes **"written outside its own directory"** row (TEMPLATE.md and
  README.md) listed the three logs and the session file. `coldstart` is NOT
  behind `devtriggers` — `any_trigger_present()` is a compile-time `false` in a
  release build, so `arm()` always runs — and it writes a second file into
  `/media/{developer,internal}`. That row's whole value is being exhaustive; it
  is a gate item, and README's own standard is that "a property stated in a form
  that fails the reader's own check reads as a lie". Now names the file and what
  is in it: the page, the profile id, one server/item id, no token, no position.

* **`docs/parity-gaps.md`'s on-disk inventory** — "the only thing ever written to
  disk is the credentials session", and the same claim again 400 lines later.
  There are two files now, and the new one is the precedent that gap's own
  *Where:* asks for ("a new preferences file alongside plex/session.rs"), so the
  sentence said the thing it wanted did not exist.

ALREADY FALSE, in the same prose:

* `requiredMemory: 60` in **three more places** — `docs/two-installs.md` §3.1 and
  the release-notes template's disclosure row and its worked example. Identical
  string to the three img.rs comments this branch already fixed, stale since
  fa257bd (2026-08-22), and each one cites `distribution.md` §6.10 as its
  source — the section that says the "~74 MB peak" was never a measurement and
  that the number is 160 against a measured 152 MiB. The template would have had
  the next release publicly disclose a defect that is fixed.

* **`lib.rs:22`** described `ff` as "the TV's own FFmpeg 3.3 via the stub-.so
  link". Both halves inverted: the app bundles and pins FFmpeg 9.0 (56147f1)
  and `stub/` was deleted (72b7d71). Three lines below the line this branch
  added, in the list a newcomer reads first.

* **`parity-gaps.md:1567`** carried "the raw-socket client cannot do chunked
  transfer" — the exact sentence the root CLAUDE.md holds up as this repo's
  archetypal false claim, surviving in another file. `stream.rs` decodes chunked;
  its only disqualifiers are DNS and TLS.

Left alone deliberately: `two-installs.md` §3.1's shared-resource inventory does
not list the new per-install file, and that section refuses to be trusted as a
list by construction ("re-derived against the tree, not inherited"); the dated
`*Verified:*` blocks in parity-gaps.md keep their 2026-07-29 line numbers; and
`lg-self-checklist.md`'s #3 row still says the matrix is unrun, which is true.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
@GLinnik21
GLinnik21 deleted the b7-coldstart branch September 3, 2026 18:09
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