Skip to content

feat(pages): store a page description as the validated triple (sanitised HTML, a binary that decodes with yrs, JSON) #320

Open

Description

@aRustyDev

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/0008 lines 38 to 40).
  • The HTML is sanitised.
  • The binary is base64-decoded and checked with validate_binary_data, as Plane's PageBinaryUpdateSerializer does (apps/api/plane/app/serializers/page.py:180-198), and also checked to decode with yrs. 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

  1. Where the yrs check lives. thrust-core cannot depend on thrust-editor-doc, because crates/editor/ is outside core (scripts/check-layout.sh rule 4; this is why the sanitiser moved into thrust-html). The page use-case therefore cannot call decode itself. Options: a port trait the use-case takes, implemented by a crate that may depend on thrust-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 of ydoc that 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.
  2. What "decodes" means. decode takes a schema and a fragment name. A page's body is the default fragment and its title is a second fragment named title in the same update (research/0008 line 55). Whether a binary must decode for both, or for the body only, is not stated in D-020.
  3. 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::decode panics inside yrs 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 runs decode on 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 newer yrs, a pre-check on the bytes, or an upstream report), and it has not narrowed whether the panic is in decode_v1, apply_update or the fragment read. This issue depends on that.
  4. 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.
  5. description_stripped and description_schema for pages. Plane recomputes description_stripped on every model save for pages too (research/0008 line 44). The simple answer is to run the page HTML through thrust_html::describe and store all three columns as work items do, so one SCHEMA_VERSION bump 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.
  6. 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

Not in this issue

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

  1. added this to the M3 Breadth milestone on Nov 19, 2026
  2. added
    area:app
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:appprio:p1

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions