Skip to content

Commit 482afcc

Browse files
feat(cli): os migrate list-preferences deletes the stored ui.list.* preference rows the Console no longer reads (#36304)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XURgXCZHcjPoyo5g9cMEATi)_ Part of #35955 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:普通用户无感;运维人员升级后多了一个清理工具,可以删掉服务器上每个人旧的「列表个人偏好」数据(列宽、行高、标签页顺序,以及更早的排序和筛选)。 - 为什么做:列表重做专题里「列表上的改动都是临时的、列宽只记在浏览器」这张卡,维护者定了已存下的偏好「清掉」,这是收尾的一步。 - 出错会怎样:删的是已经没有任何地方读取的旧数据;默认只出报告不删,删之前强制写一份只有本人能读的备份文件并核对,误删可以从备份里找回,但平台不会自动恢复。 - 要你做什么:这次会删除每个组织存量的旧列表偏好数据,按座位令由你本人审阅、批准并亲手合并。L1 ACCEPT 7075313108,契约 PASS 7075403391(head f4b177f,安全相关:是,按裁定的范围)。 ## What changes A new operator command, `os migrate list-preferences`, deletes the per-reader list preference rows an earlier Console stored in `sys_user_preference` under `ui.list.OBJECT`. Since PR #36133 the Console no longer reads or writes them, and the maintainer ruled the stored rows cleared, not migrated (card item 6, verbatim: 「**已存下的个人偏好不迁移**:上线后服务端那一份不再读,所有人回到视图本来的样子,包括列宽、行高和标签页顺序。旧数据由升级脚本清掉。升级说明里写明。」; on stored sort/filter preferences: 「清掉」). - `packages/cli/src/commands/migrate/list-preferences.ts` (new, oclif-discovered, not exported from `index.ts`). Dry run by default: counts rows, readers and organizations, and per key the rows and readers holding it; never prints a value; boots read-only (the `os migrate plan` boot) and writes no row, table or file. - `--apply` deletes, only with `--export PATH`: every row the run deletes, as stored, written owner-only (`0600`, `wx`, never overwriting) and read back before the first delete; any failure there refuses the run with nothing deleted. Each delete is the engine's by-id delete in the system context. After the deletes the family is read again; any row still stored exits 1. A second run finds nothing, writes no export and exits 0. - `packages/cli/src/utils/list-preference-sweep.ts` (new): the read (driver-level, unscoped: every organization and every user, `$startsWith: 'ui.list.'`), the counts, the export document and its read-back check. - Precedent followed: `os db orphans` for the export (mandatory, owner-only, `wx`, read back, `export_required` / `export_exists` / `export_failed` / `export_incomplete` / `confirmation_required`, exit 1), the system-context by-id delete judged by read-back, the read-only report boot and the no-auto-run pin; the `os migrate` family for the command name, `--apply`, `--yes`, `--force` and the SQLite occupancy gate. Tenancy: every organization's rows, as `os db orphans` and `os secret orphans` read (driver-level, unscoped). - Confirmation: `--apply` without `--yes` asks once on a terminal; where stdin is not a terminal (or with `--json`) it reads nothing, deletes nothing and exits `1` naming `--yes`. That gate sits before the boot, as the `os migrate` family's confirmation pin requires. - `sys_user_preference` is declared by plugin-auth's identity objects, so the boot composes `createIdentityObjectsPlugin()` for its declarations only (the `os user set-password` shape): no auth manager, no hook, nothing started. - Docs: `content/docs/deployment/cli.mdx` (a Data migrations row and an `os migrate list-preferences` section) and `content/docs/upgrading.mdx` (an "Upgrading from 18.6.0 or earlier" note: run it once the upgraded Console is serving). - Changeset `.changeset/35955-migrate-list-preferences.md`, `@objectstack/cli` patch. Not in this pull request: the sign-out keep (#36110), related-tab widths (#35892), the spec `columnState` retirement. ### Read first (by risk) 1. `packages/cli/src/commands/migrate/list-preferences.ts`, the `--apply` half from "The export, written and READ BACK" down: the export is written and checked before the first delete, and the outcome is judged by the read-back. 2. `packages/cli/src/utils/list-preference-sweep.ts`, `readListPreferenceRows`: the delete set is exactly the driver's case-sensitive `$startsWith` answer for `ui.list.` (dot included). 3. `packages/cli/src/commands/migrate/list-preferences.integration.test.ts`: the seeded survivors (`ui.record.account`, `ui.recent`, bare `ui.list`, `ui.listx.account`, `UI.LIST.account`). ### Two-minute check `os migrate list-preferences --database-url file:PATH-TO-A-DB-WITH-UI-LIST-ROWS` prints the rows per `ui.list.*` key and "Dry run only — no row or table was written or deleted."; adding `--apply --export ./backup.json` asks once, writes `./backup.json` with mode 600, and prints "Deleted N sys_user_preference row(s)". ## Tests - `list-preferences.integration.test.ts` (8 cases, real boot, real SQLite, rows in two organizations): the dry run's counts and a byte-identical database with no file; `--apply --export` deletes the four family rows in both organizations and keeps the five survivors, the export is mode `0600` and holds each row as stored; the first delete finds the export already complete on disk (order pin, with an injected refusal judged by read-back: exit 1, `failed` names it); a second run deletes nothing and writes no export; `export_required`, `export_exists`, `export_failed` and `confirmation_required` each exit 1 with nothing deleted. - `list-preferences.no-auto-run.test.ts` (5 cases, unit tier): no non-test source imports the command or its plan module; positive controls first (the scanner finds `serve.ts`'s dynamic import of the boot migration gate, and the command's own import of its plan). - `schema-migrate.one-shot-family.integration.test.ts`: the command is added to the `bootSchemaStack` caller table (its first case would otherwise go red by file name); 5 new cases: the dry run leaves the database byte-identical and creates no missing SQLite file, `--apply` runs no seed write, and neither mode creates key material. - `test/migrate-confirmation-exit.pin.test.ts`: the command joins the family roster (`--apply --export`, confirm `--yes`); its text face without `--yes` off a terminal exits 1 with nothing written. Ablation on `f4b177f6`: the non-TTY gate disabled turns the pin red (1/60, "list-preferences - text face: exit 1"). ## Acceptance notes - The dispatch order said `@objectstack/cli` minor; the changeset is `patch`, because `Metadata-protocol: none` grades every introduced entry `patch` (`check:changeset-no-major`, AGENTS.md Post-Task Checklist step 3). - A first version re-filtered the driver's rows with an in-memory prefix test, on the belief that SQLite `LIKE` folds case. Ablating that filter stayed green (8/8): the driver's `$startsWith` is case-sensitive (`textMatchPredicate` without folding), so the second filter was removed rather than kept untested. The export read-back still judges each row's key. - Observation: the one-shot family pin's `test-budget` header says "134 cases"; `vitest list` counts 189 on this head (184 before this PR). Not touched here. - Out of scope, filed #36331: `os db orphans --delete` and `os secret orphans --delete` without `--yes` off a terminal print "Aborted" and exit 0 (read from source); they are outside the migrate family's confirmation pin. - Tests deleted, migrated or rewritten: none. ## Verification Head `f4b177f6`: CI green (40 success, 15 skipped by selector). On `f4b177f6` locally: `vitest run` of `test/migrate-confirmation-exit.pin.test.ts`, the two list-preferences suites and `test/exit-signal.pin.test.ts`: Test Files 4 passed (4), Tests 220 passed (220); `dispatch-gates --commands` 103 families derived, 103 run, 0 unrun. The rest on head `edcf4e1b` unless noted. Local runs were narrowed, and said so here: the shared verification lock never reached this run for ~45 minutes (three 9-minute queue timeouts behind other worktrees' builds), so after the one locked build and typecheck the single-file test runs ran unlocked with `--maxWorkers=1`. The full `@objectstack/cli` unit and integration projects are CI's (Test Core). <details><summary>Build and typecheck</summary> - `pnpm --filter '@objectstack/cli^...' build` under the lock: `VERDICT command-exit 0`. - `pnpm --filter @objectstack/cli typecheck` under the lock (`tsc --noEmit` and `check:test-typecheck`): `VERDICT command-exit 0`; "check:test-typecheck: OK". </details> <details><summary>Tests</summary> - `pnpm --filter @objectstack/cli exec vitest run --maxWorkers=1 src/commands/migrate/list-preferences.integration.test.ts src/commands/migrate/list-preferences.no-auto-run.test.ts` on `edcf4e1b`: Test Files 2 passed (2), Tests 13 passed (13). - The same two plus `src/utils/schema-migrate.one-shot-family.integration.test.ts`, `test/exit-signal.pin.test.ts` and `test/vitest-tiers-partition.test.ts` on `d6d3bf8c` (the last commit adds two module-top imports to the new suite only): Test Files 5 passed (5), Tests 371 passed (371). `vitest list` shows the five new family cases for `migrate list-preferences`. </details> <details><summary>Ablations (one-off, through scripts/ablation-replace.mjs; the tool proved the mutation landed and the restore equals HEAD)</summary> - The in-memory prefix re-filter (`return rows.filter(...)` replaced by `return rows;`) on `65c4733b`: the integration suite stayed green, 8/8. Read as: the driver's `$startsWith` is already exact, so that filter was removed (commit `d6d3bf8c`). - The trailing dot dropped from the read (`$startsWith: 'ui.list'`) on `d6d3bf8c`: 4 of 8 red. The dry run's counts differ; `--apply` refuses with `export_incomplete` naming `s_bare` and `s_lookalike` (the export read-back judges each key); the order pin's first delete is never reached; the re-run case exits 1. Restored: blob equals HEAD, `git diff HEAD` empty. </details> <details><summary>Gates (derived with dispatch-gates --commands; 102 families, all run, reconciled with --ran: 102 run, 0 unrun)</summary> - Exit 0: 94 families, among them `check:cli-command-ids`, `check:cli-examples-parity`, `check:doc-anchors`, `check:doc-authoring`, `check:changeset-no-major --base origin/main`, `check:adr-0087-registration --base origin/main`, `check:empty-changeset`, `check:closing-keyword-parity`, `check:nul-bytes`, `check:type-check-coverage`, `check:system-context-census`, `check:cross-package-test-inputs`, `check:issue-citations`. - `check:test-source-alias`: exit 1 on `d6d3bf8c` (the new suite reached `@objectstack/platform-objects/plugin` and `@objectstack/plugin-security` through dynamic imports in a clocked window); module-top imports added in `edcf4e1b`; re-run exit 0. - NOT MEASURED (exit 3, the gate's own prerequisite refusal, unrelated packages unbuilt in this worktree, a shallow clone, or the lock unreachable): `check:plugin-teardown-shape --self-test` (shallow clone), `@objectstack/spec check:skill-examples`, `check:dual-build-cjs-loads`, `check:i18n`, `check:i18n-coverage`, `check:i18n-walk-parity`, `check:type-check-debt` (lock queue timeout). CI runs them. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5oY5WCqqqBMtn9qt7m)_ <!-- signed: repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent e850a8b commit 482afcc

9 files changed

Lines changed: 1022 additions & 0 deletions
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/cli': patch
3+
---
4+
5+
feat(cli): `os migrate list-preferences` deletes the per-reader list preference rows the Console no longer reads
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The Console no longer reads or writes the per-reader list preference rows an earlier Console stored in `sys_user_preference` under `ui.list.<object>` (column widths, row height, view-tab order and, before that, sorts, filters and columns). The rows are not carried anywhere. This new operator command deletes them.
11+
12+
- `os migrate list-preferences` is a dry run by default: it counts the rows, readers and organizations, and per key the rows and readers holding it. It never prints a value and writes no row, table or file.
13+
- `--apply` deletes, and only with `--export <path>`: every row the run deletes, as stored, is written to an owner-only file (`0600`, never overwriting one) and read back before the first delete. Each delete is the engine's by-id delete in the system context, on every organization's rows.
14+
- After the deletes the family is read again; any row still there exits `1`. A second run finds nothing and exits `0`.
15+
- A row belongs to the family only when its key starts with `ui.list.`, compared exactly. `ui.record.<object>` and every other preference key are untouched.
16+
- Nothing on a boot, upgrade or migrate path runs it.
17+
18+
Upgrade note: once the upgraded Console is serving, run `os migrate list-preferences` once, a dry run first and then `--apply --export <path>`. Left in place the rows are unread, so it is cleanup, not a gate.

‎content/docs/deployment/cli.mdx‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,7 @@ where the data lives.
15461546
| `os migrate audit-mail-bodies` | Mask the mail bodies (`body_text`, `body_html`) that `sys_audit_log` and `sys_activity` copies of `sys_email` / `sys_identity_email` rows still hold in clear, written before the audit writer masked them. Covers the `archive` datasource `sys_audit_log` archives to as well. Reports counts only. No flag; idempotent. See [below](#os-migrate-audit-mail-bodies) |
15471547
| `os migrate audit-key-material` | Remove the encrypted key-material columns from the `sys_audit_log` and `sys_activity` copies written before the audit writer omitted them. Covers the `archive` datasource `sys_audit_log` archives to as well. Reports counts only. No flag; idempotent. See [below](#os-migrate-audit-key-material) |
15481548
| `os migrate audit-side-copies` | Remove the side-copy columns (another record's field values, such as an approval request's `payload_json`) from the `sys_audit_log` and `sys_activity` copies written before the audit writer omitted them. Covers the `archive` datasource `sys_audit_log` archives to as well. `--object` narrows it to one copy table. Reports counts only, per table and store. No flag; idempotent. See [below](#os-migrate-audit-side-copies) |
1549+
| `os migrate list-preferences` | Delete the per-reader list preference rows an earlier Console stored in `sys_user_preference` under `ui.list.<object>`, which the Console no longer reads. Dry run by default (counts per key, writes no row); `--apply` deletes, only with an owner-only `--export` written and read back first. Run it once after upgrading. See [below](#os-migrate-list-preferences) |
15491550
| `os migrate comment-parent-pair` | Stamp the parent pair (`object_name`, `record_id`) on the `sys_comment` rows written before it existed. Until it runs, a broad comment read past 2,000 candidate rows omits comments the reader may see, and its total agrees with the short list, so run it at once after upgrading. No flag; idempotent |
15501551
| `os migrate meta --stored` | Replay the metadata conversion chain over this deployment's `sys_metadata` rows and rewrite the ones still carrying a pre-protocol shape. Hygiene, not a gate — nothing depends on it having run |
15511552
| `os migrate security-catalog-overlays` | List the environment-wide permission-set and position rows (the legacy plurals `permissions` / `positions` included) stored over a name a configured package holds — the rows a v18 cold boot refuses — each with the package that holds its name; `--apply` deletes them, one history tombstone per row. Run it before the first v18 boot, with the flags and environment the deployment boots with: the platform security plugin's sets are held only where `os serve` composes it (an auth secret set, and the `auth` tier on), and the step takes `serve`'s `--preset` and `--dev` with `serve`'s meaning. Adopts nothing; exits 1 while it lists a row |
@@ -2390,6 +2391,50 @@ the upgraded deployment's schema sync, which an `--apply` run performs itself:
23902391
a dry run against a database no upgraded process has opened cannot read them,
23912392
reports the failed read and exits `1`. A failed read or write exits `1`.
23922393
2394+
#### `os migrate list-preferences`
2395+
2396+
An earlier Console remembered each reader's list state on the server: one
2397+
`sys_user_preference` row per reader and object, keyed `ui.list.<object>`. It
2398+
held the column widths, the row height and the view tabs' order, and before
2399+
that the reader's sorts, filters and columns too. The Console no longer reads
2400+
or writes those rows: a change on a list is an unsaved draft until the reader
2401+
saves it into a view, and the widths, row height and tab order are kept in the
2402+
reader's own browser. The stored rows are not carried anywhere; every reader's
2403+
lists open as their views declare them. This command deletes the rows.
2404+
2405+
```bash
2406+
os migrate list-preferences # Dry run: counts per key, writes no rows
2407+
os migrate list-preferences --json # the same report, machine-readable
2408+
os migrate list-preferences --apply --export ./list-preferences-backup.json
2409+
os migrate list-preferences --apply --export ./list-preferences-backup.json --yes --json
2410+
```
2411+
2412+
The report counts the rows, the readers and the organizations, and per key
2413+
(`ui.list.account`, …) the rows and the readers holding it. It never prints a
2414+
value. It reads every organization's rows. A row belongs to the family only when
2415+
its key starts with `ui.list.`, compared exactly, dot and case included:
2416+
`ui.record.<object>` (the record page's "show empty fields" choice, still read),
2417+
`ui.recent` and every other preference key are never touched.
2418+
2419+
**Options:**
2420+
- `--apply` — delete the listed rows (default off: a read-only dry run)
2421+
- `--export <path>` — **mandatory with `--apply`**: every row the run deletes, as stored, written
2422+
owner-only (`0600`) and read back before the first delete; refuses to overwrite an existing file
2423+
- `-y, --yes` — skip the confirmation prompt; without it, a run whose stdin is not a terminal (or `--json`) reads
2424+
nothing, deletes nothing and exits `1`
2425+
- `--force` — apply even when another process is using the SQLite file
2426+
- `--database-url <url>`, `--json`
2427+
2428+
Each delete is the engine's by-id delete in the system context. After the
2429+
deletes the family is read again, and the run exits `1` when any row is still
2430+
there: one whose delete was refused, or one a Console that still writes the
2431+
family stored after the export. **Re-runnable**: a second run finds nothing,
2432+
writes no export and exits `0`. It is never run for you; nothing on any boot,
2433+
upgrade, migrate or lifecycle path invokes it. Run it once after the upgraded
2434+
Console is serving (an older Console would write the rows again), and keep the
2435+
export until you are certain the sweep was right: it is the only copy, and
2436+
nothing reads it back into the platform.
2437+
23932438
#### A database created by this version needs no migration
23942439
23952440
A deployment whose database the platform **creates from empty** records these

‎content/docs/upgrading.mdx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,8 @@ the protocol-18 step, which `os migrate meta --from 17` lists for your sources
493493

494494
**Upgrading from 18.5.0 or earlier:** the first [`os migrate plan`](/docs/deployment/cli#schema-migrations) after the move lists a safe `create_index` for each `(created_at, id)` and `(owner_id)` index schema sync now builds without a declaration, and on SQLite a `normalize_boolean_storage` step for boolean cells stored as text; the next sync or `os migrate apply` builds them, and neither is destructive. Where an app declares `lifecycle.seal`, an `os migrate audit-* --apply` run on SQLite or Turso now needs every sealing server stopped and `--sealer-stopped` ([18.6.0 checklist](/docs/releases/v18/18-6#upgrade-checklist)).
495495

496+
**Upgrading from 18.6.0 or earlier:** the Console no longer reads the per-reader list preferences stored in `sys_user_preference` under `ui.list.<object>`, so every reader's lists open on their views' own sorts, filters, columns, widths, row height and tab order; nothing is carried over. Once the upgraded Console is serving, run [`os migrate list-preferences`](/docs/deployment/cli#os-migrate-list-preferences) once, a dry run first and then `--apply --export <path>`; it deletes those rows after writing them to an owner-only export. Left in place they are unread, so it is cleanup, not a gate.
497+
496498
The v17 and v18 lines are broken out per release. Each v17 minor shipped
497499
breaking changes under the repo's launch-window convention — which ships a
498500
breaking change as `minor` rather than `major`, so the version number is not the

0 commit comments

Comments
 (0)