Skip to content

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

Open

Description

@aRustyDev

What

Re-clean the work-item descriptions that were stored under an older sanitiser policy, and fill in description_stripped for them, with a job that can be run again whenever thrust_html::SCHEMA_VERSION goes up.

Why

A work item stores its description as description_html (cleaned), description_stripped (the text, Django's strip_tags of it) and description_schema (the version of the policy it was cleaned under): migration 0019_description_stripped.sql, D-020, ADR-0012's "record a schema version". The use-cases write all three through thrust_html::describe (#305). Rows written before that, and rows written under an older version, were not changed, as decided in the planning of #48:

Rows description_schema description_stripped HTML cleaned by
written before migration 0019 (and the slice's) NULL NULL Plane's plain allow-list, or the first version of the hardened one (#302)
written under policy 1 (between #305 and #309) 1 set the hardened policy before a CSS escape or comment was read: may hold a style that policy 2 drops (j\61vascript:, \/* ... */)
written since #309 2 (SCHEMA_VERSION) set current

description_schema is the selector: IS NULL OR < SCHEMA_VERSION.

Why it is not urgent, and what is

  • description_stripped: nothing reads it. No route serves it, and there is no search or preview yet. The first reader (description search, a preview) needs this pass first.
  • The stored HTML of the first two kinds of row is what the API serves back. The payloads Plane's list lets through are the legacy-browser class (research/0008 §7, D-016; not run in a browser). Whether any such rows exist on staging or production is not known here: start by counting them (SELECT count(*) FROM work_items WHERE description_schema IS NULL OR description_schema < <current>), then decide the priority.

Design decisions to make

  1. How: a batch job that selects stale rows (keyset pagination, so it can stop and resume), runs thrust_html::describe, and writes the three columns in one statement; or a lazy re-clean on the next write (leaves the unread rows as they are, which is the ones that matter); or on read. A SQL migration cannot do it (it needs the Rust sanitiser), and migrations are expand-only (check-migration-lint.sh) anyway. Home: a scheduled job (for example beside the daily cleanup of feat(jobs): daily hard-delete retention cleanup (F-D10, 30-day default per D-001) #59), or an admin command.
  2. Not an edit: it must not bump updated_at or updated_by, write a work_item_history row, or appear in the activity feed. Whether the old history rows, which quote the old description, are touched is a decision of its own (they are an audit record; check whether and how the history routes serve them).
  3. Idempotent and general: a row at the current version is not selected or written, and the same job is what a later version bump runs. It is not a one-off for 0019.
  4. Failure: a description that no longer cleans (it is over the size limit) is left as it is, logged, and does not stop the batch.
  5. Both adapters: the Postgres one and the memory one (the memory adapter is the in-process target of the contract suite).

Done when

  • a test seeds rows at NULL, at an older version and at the current one: the first two come out cleaned, with their text and the current version; the third is byte-identical and not written (control: a job that rewrites every row fails it); an escaped-style row from policy 1 loses the style;
  • the job survives being stopped half way and run again (a model or property test over batches);
  • G-46 ("Not shown": "nothing re-cleans or backfills them") and D-020 say what now happens.

The pages half of #48 has no rows yet (no page exists), so it is not part of this.

Follows #48 (the work-item half: #300, #302, #305, #309).

🤖 Generated with Claude Code

Activity

  1. added
    area:app
    on Nov 18, 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:app

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions