Repository navigation
Commit 482afcc
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
File tree
- .changeset
- content/docs
- deployment
- packages/cli
- src
- commands/migrate
- utils
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1546 | 1546 | | |
1547 | 1547 | | |
1548 | 1548 | | |
| 1549 | + | |
1549 | 1550 | | |
1550 | 1551 | | |
1551 | 1552 | | |
| |||
2390 | 2391 | | |
2391 | 2392 | | |
2392 | 2393 | | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
2393 | 2438 | | |
2394 | 2439 | | |
2395 | 2440 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
493 | 493 | | |
494 | 494 | | |
495 | 495 | | |
| 496 | + | |
| 497 | + | |
496 | 498 | | |
497 | 499 | | |
498 | 500 | | |
| |||
0 commit comments