fix(studio): survive damaged package meta; clean up OPFS write husks#116
Merged
Conversation
The studio bricked on load in iOS Safari with "missing session: library: meta: parse meta: expected value at line 1 column 1": a damaged (zero- filled) /.lp/meta.json. The history event log tolerates such damage (it reads as empty), which routes PackageHandle::load into the strict read_meta origin fallback — one unparseable provenance sidecar then permanently fails every project open. Two fixes: - read_meta parses leniently: damage logs a warning and reads as absent; origin_event_for(None) already falls back to a Created origin. - opfs write_file removes the empty husk it created when the stage-and-swap fails on a file that did not previously exist. The createWritable atomic swap only protects content — getFileHandle (create: true) makes the entry immediately, so a tab jetsammed mid-flush (common on iOS) persisted a lie. Verified: lpa-studio-core suite (453 tests), lpa-fs-opfs real-browser OPFS suite (18 tests via chromedriver), wasm32 check, just check. Co-Authored-By: Claude Fable 5 <[email protected]>
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.
Summary
missing session: library: meta: parse meta: expected value at line 1 column 1. Chain: a damaged (zero-filled)/.lp/meta.json+ an event log that tolerates the same damage (a garbage log reads as empty via the torn-tail drop) routesPackageHandle::loadinto the strictread_metaorigin fallback — one unparseable provenance sidecar then permanently fails every open of that project, including boot-time session restore.read_metanow parses leniently: damage logs a warning and reads as absent (origin_event_for(None)already falls back to aCreatedorigin). Provenance is a best-effort sidecar and should never be load-bearing — this matches the existing leniency in the event log and the gallery's skip-bad-cards behavior.write_fileinlpa-fs-opfsnow removes the empty husk it created when the stage-and-swap fails on a file that did not previously exist. ThecreateWritableatomic swap only protects content;getFileHandle(create: true)makes the entry immediately, so a tab jetsammed mid-flush (common on iOS) could persist an entry whose content never committed.serde_jsonsayscolumn 1(notcolumn 0/EOF), i.e. the file had non-JSON content — the zero-filled signature of size-persisted-but-content-lost, consistent with WebKit OPFS durability behavior under process kill.Validation
meta.jsonboth read as absent.cargo test -p lpa-studio-core: 453 passed.just lpa-fs-opfs-test(real Chrome + real OPFS via chromedriver): 18 passed across the three suites, exercising the reworkedwrite_filesuccess path end-to-end. (The failure branch is not exercisable in Chrome, whosecreateWritabledoesn't fail on demand.)cargo check -p lpa-fs-opfs --target wasm32-unknown-unknown,just check: clean.Contribution Terms
By opening this pull request, I confirm that I have the right to submit these
changes and agree to the contribution terms in
CONTRIBUTING.md.🤖 Generated with Claude Code