Skip to content

Commit d6d3bf8

Browse files
committed
refactor(cli): list-preferences reads the family through the driver's case-sensitive prefix match alone
The ablation of the second, in-memory prefix filter stayed green: the driver's $startsWith already answers the family exactly. Claude-Session: https://claude.ai/code/session_01FEkQ5oY5WCqqqBMtn9qt7m Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 65c4733 commit d6d3bf8

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

‎packages/cli/src/commands/migrate/list-preferences.integration.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
* one in organization B;
1414
* - rows that must survive: `ui.record.account` (the record page's family,
1515
* still read), `ui.recent`, the bare key `ui.list`, a look-alike prefix
16-
* `ui.listx.account`, and `UI.LIST.account` — a key SQLite's `LIKE` matches
17-
* against the prefix, since it compares ASCII without case, so it proves
18-
* the family is judged byte for byte after the read.
16+
* `ui.listx.account`, and `UI.LIST.account` — together they pin that the
17+
* driver's `$startsWith` read is the family exactly: the trailing dot and
18+
* the case both count.
1919
*
2020
* ## What each case proves
2121
*

‎packages/cli/src/utils/list-preference-sweep.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
* `ui.record.<object>`, `ui.recent`, `ui.favorites`, `ui.app.last` and
2323
* `ui.flow.palette.recents` are other families and are never touched.
2424
*
25-
* The read may ask the driver for the prefix (`$startsWith`), which narrows
26-
* what is read and decides nothing: a SQL `LIKE` can match more than the
27-
* prefix (SQLite compares ASCII without case), so every row read is judged
28-
* again by {@link isListPreferenceKey}, and only rows that predicate admits
29-
* are counted, exported or deleted.
25+
* The read asks the driver for the prefix with `$startsWith`, whose contract
26+
* is a case-sensitive, escaped prefix match on every driver (the SQL driver's
27+
* `textMatchPredicate` without folding). So the driver's answer IS the family:
28+
* `ui.listx.account`, the bare `ui.list` and `UI.LIST.account` are not in it
29+
* (`commands/migrate/list-preferences.integration.test.ts` seeds all three
30+
* and holds them stored after an `--apply`). No second filter restates it here.
3031
*
3132
* Read-only by construction: nothing here holds a write verb.
3233
*/
@@ -37,7 +38,7 @@ export const LIST_PREFERENCE_PREFIX = 'ui.list.';
3738
/** The object the family is stored in. */
3839
export const LIST_PREFERENCE_OBJECT = 'sys_user_preference';
3940

40-
/** Does this stored key belong to the retired family? Byte-exact, the trailing dot included. */
41+
/** Does this key belong to the retired family? Byte-exact, the trailing dot included: the export's read-back judges with it. */
4142
export function isListPreferenceKey(key: unknown): key is string {
4243
return typeof key === 'string' && key.startsWith(LIST_PREFERENCE_PREFIX);
4344
}
@@ -53,10 +54,9 @@ export interface ListPreferenceReader {
5354
* and a row missing from it is a row the report never mentions.
5455
*/
5556
export async function readListPreferenceRows(reader: ListPreferenceReader): Promise<Record<string, unknown>[]> {
56-
const rows = await reader.find(LIST_PREFERENCE_OBJECT, {
57+
return reader.find(LIST_PREFERENCE_OBJECT, {
5758
where: { key: { $startsWith: LIST_PREFERENCE_PREFIX } },
5859
});
59-
return rows.filter((row) => isListPreferenceKey(row.key));
6060
}
6161

6262
/** One key of the family and how many rows and readers hold it. */

0 commit comments

Comments
 (0)