Repository navigation
Description
What
When pages exist, a page write stores the triple the web editor's fallback path sends: the HTML sanitised, the binary checked to decode with yrs, and the JSON. A truncated or non-Yjs binary gets a 400.
This is the pages half of #48, split out because pages are an M3 screen (PLAN.md: "Cycles, modules, views, pages, intake, webhooks, public spaces and exports are M3") and #48 is an M2 issue.
Why
#48 asked for two things. The work-item half is on main (#300, #302, #305, #309): work items store the sanitised description_html, description_stripped and description_schema, and no JSON or binary. The pages half could not be built, because there is no page table, port or route on main (the page.rs in crates/api/compat-plane is pagination, not pages).
The decision is already taken, in D-020 (round 29, FR-14) and in the answers to Q-F5.1 and Q-0061.4:
- Pages store the triple the fallback path sends (
apps/web/hooks/use-page-fallback.ts;research/0008lines 38 to 40). - The HTML is sanitised.
- The binary is base64-decoded and checked with
validate_binary_data, as Plane'sPageBinaryUpdateSerializerdoes (apps/api/plane/app/serializers/page.py:180-198), and also checked to decode withyrs. Plane does not do the last check, so a binary Plane accepts can be refused here. D-020 records that. - The optimistic version check (a stale save returns 409) is unchanged (Q-F5.1).
Where things stand (on main at 2bbda0f)
| Piece | State |
|---|---|
thrust_html::describe(sent) |
Done: sanitises, computes description_stripped, returns the policy version (crates/core/html/src/lib.rs:256). Work items use it from the use-cases. |
thrust_html::validate_binary_data(&[u8]) |
Done: Plane's check (size cap, at least 4 bytes, no suspicious text in the first 200 bytes) (:282). Nothing calls it from a product path yet. |
thrust_html::SCHEMA_VERSION |
2. |
the yrs decode check |
Only thrust_editor_doc::ydoc::decode(schema, update, fragment) (crates/editor/doc/src/ydoc.rs:237), behind that crate's yjs feature. The product crates (thrust-api-v1, thrust-compat-plane) do not depend on it. |
| pages table, port, route | None. The newest migration is 0020. |
Design decisions to make
- Where the
yrscheck lives.thrust-corecannot depend onthrust-editor-doc, becausecrates/editor/is outside core (scripts/check-layout.shrule 4; this is why the sanitiser moved intothrust-html). The page use-case therefore cannot calldecodeitself. Options: a port trait the use-case takes, implemented by a crate that may depend onthrust-editor-doc; or the check in the compat route before the use-case (cheapest, but the v1 and any later page routes would each repeat it); or moving the part ofydocthat checks into a core crate. Same shape as the feat(editor): work-item descriptions store sanitised HTML only; pages store the validated triple; hardened sanitiser #48 sanitiser decision. - What "decodes" means.
decodetakes a schema and a fragment name. A page's body is the default fragment and its title is a second fragment namedtitlein the same update (research/0008line 55). Whether a binary must decode for both, or for the body only, is not stated in D-020. - fix(editor-doc): ydoc::decode panics inside yrs 0.28.0 on a one-byte mutation, and its property test fails CI at random #114 comes first, or the check cannot be written safely.
ydoc::decodepanics insideyrs 0.28.0(assertion failed: value & Self::MASK == 0,block.rs:92) on an update mutated by one byte; its own property test fails CI at random. This check runsdecodeon request bytes. On the Worker (wasm32,panic=abort) a panic fails the request and cannot be caught at the call site, which ADR-0006's panic policy forbids for request-derived data. fix(editor-doc): ydoc::decode panics inside yrs 0.28.0 on a one-byte mutation, and its property test fails CI at random #114 has no chosen fix (a neweryrs, a pre-check on the bytes, or an upstream report), and it has not narrowed whether the panic is indecode_v1,apply_updateor the fragment read. This issue depends on that. - What is checked on the JSON. D-020 says the HTML is sanitised and the binary checked, and says nothing about the JSON. It is stored and served back, so decide at least a size cap and "is JSON", and whether it is compared with the editor schema.
description_strippedanddescription_schemafor pages. Plane recomputesdescription_strippedon every model save for pages too (research/0008line 44). The simple answer is to run the page HTML throughthrust_html::describeand store all three columns as work items do, so oneSCHEMA_VERSIONbump and one backfill (feat(issues): re-clean descriptions stored under an older sanitiser policy and fill in description_stripped, with a job that reruns on each SCHEMA_VERSION bump #314) cover both. Confirm that.- The 409. What a page description write sends for the version check, and what the stale-save response looks like, must be read off the oracle pin (
oracle/v1-pin-20261018) and not assumed.
Done when
- A page write with a truncated binary, and one with a non-Yjs binary, each get a
400, and nothing is stored. A valid fallback triple is stored and read back (the criterion left open on feat(editor): work-item descriptions store sanitised HTML only; pages store the validated triple; hardened sanitiser #48). - It is generative (AGENTS.md rule 9): truncated prefixes of valid updates, and random bytes, must be refused. The valid updates come from the editor-doc corpus and from the generators in
crates/editor/doc/tests/roundtrip.rs. Control: with theyrscheck off (Plane's behaviour) the truncated case is accepted, and the test fails. - The property that the check never panics on a one-byte mutation of a valid update holds (it is fix(editor-doc): ydoc::decode panics inside yrs 0.28.0 on a one-byte mutation, and its property test fails CI at random #114's property, run through the page route).
- The nine payload classes that survive Plane's allow-list (
research/0008§7) are sent through a page write and read back neutralised. Control: withplane_builder()the test fails. This is the page twin of the work-item contract tests from feat(html): make the hardened sanitiser the default, keeping the editor's embed and rel #302. - The page HTML keeps
issue-embed-componentandrel(D-017, D-018), checked on the page path. DEVIATIONS.mdD-020 names the tests that pin it, anddocs/src/testing/status.mdG-46 says the pages half is done.
Not in this issue
- Collaborative editing (M5, feat(collab): one
yrsroom hosted on a Durable Object and on axum (spike 0005 first) #54), page versions (F-C03) and page-to-work-item embeds beyond keeping the tag (F-C04). - Page CRUD, lock, archive, access, favourites and labels (F-C01): that is feat(pages): project pages (F-C01): create, list, edit, lock, archive, access, favourite and delete, with a plain-save description #323. This issue is the description write only, and it needs that work.
- Rows that exist before this: there are none, because no page exists.
Split from #48 (the work-item half: #300, #302, #305, #309). Related: #114, #313, #314.
Blocked by: #114, and #323 (the page CRUD work, F-C01).
🤖 Generated with Claude Code
Activity