You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 99554ed
Browse filesBrowse the repository at this point in the historyBrowse files
authored
fix(names): refuse a Bot name whose drawn form is already taken (#2937)
Fixes#2935
Owner: Dev-3
Reviewer: Reviewer
Written-by: Dev-3
Bot: FlyBot Dev-3
Claim-Id: 9b98f5ad369a4641a8f132f75b2a934c
Risk tier: T3 — `core/src/shared/**` is T3 in
`.github/agent/risk-rules.json` (`identity.js`, `mentions.js`);
`core/src/host/**` is T2; `core/test/**`, `core/client.js`,
`patches/**`, `changelog.d/**` are T1 and `docs/**` T0, so the highest
is T3
Base: 95a793e
Verified commit: 302a626 (tree
58c30dd)
## What this changes
`#2879` refused only a name that draws nothing at all. A name that draws
something and also carries a character the screen does not draw still
passed: `Dev` plus a combining grapheme joiner kept the identity key
`dev\u034f` beside `dev`, both rows read `Dev`, and `@Dev` could only
ever reach the one whose key is `dev`.
- `core/src/shared/identity.js` adds `drawnKey(value)`: `nameKey()` with
the code points that have no glyph of their own removed.
`core/src/shared/mentions.js` exports that explicit set as `NOT_DRAWN`.
- `core/src/host/roster.js` compares the drawn form in `createBot` and
`updateBot` beside the identity key, from either side, with the
sentences already in use (`A Bot named … already exists` / `Name … is
not available`). Nothing is stripped from the stored name, and a drawn
form nobody holds is still a name.
- `core/test/name-identity.test.js`: four new tests (the pure key,
create, rename, and the reverse case where the drawn spelling is held
first), plus a **counter-control**: two Thai names that differ only in a
combining vowel are both created. The `#2879` create test built
`De\u2800v` beside `Dev` — exactly the shape this rule now refuses — so
its seed renames `dev` to `Devx`, keeping its point (a blank between
drawn characters is part of the name); every other assertion there is
unchanged.
- `docs/subsystems/core-host.md` and `core-client.md` say what the drawn
key is and that the bundle carries it; one fragment
`changelog.d/2935-rendered-name-dedupe.fixed.md`.
- Regenerated `core/client.js` and `patches/ds-bot/` (0008 carries the
bundle, 0001/0002 the two shared/host files, `files/` mirrors the whole
files) in this same PR; the lane was free.
### The set: glyph-less code points, not the whole `\p{Mn}` class
A combining mark is drawn by the letter it sits on — `กิ` and `กี` are
two different names on screen — so `NOT_DRAWN` is an explicit list,
never a Unicode combining class: U+034F (CGJ),
U+115F/U+1160/U+3164/U+FFA0 (Hangul fillers), U+17B4/U+17B5 (Khmer
inherent vowels), U+180B–U+180D/U+180F (Mongolian free variation
selectors), U+2800 (braille blank), U+FE00–U+FE0F and U+E0100–U+E01EF
(variation selectors). `\p{Cf}` is still dropped earlier by
`stripInvisible`, so it is not listed twice. `nameProblem` keeps its
wider "draws nothing" class: a name made only of a lone combining mark
or a separator still draws nothing and is still refused (`#2879`), while
a mark beside a letter is a drawn name.
## Red first (tests before the source, on base 95a793e)
With the final test file on the base, the suite stops at the import:
`SyntaxError: The requested module '../src/shared/identity.js' does not
provide an export named 'drawnKey'`. Running the same file with the two
`drawnKey` assertions taken out (so the file is importable on base)
shows the three behavioral tests are real reds:
```
not ok 7 - #2935 the create path refuses a name whose drawn form is already taken
error: 'Missing expected rejection: ["44","65","76","34f"]' (core/test/name-identity.test.js:193)
not ok 8 - #2935 the rename path refuses a drawn name that is taken, and a free drawn name lands
error: 'Missing expected rejection: ["44","65","76","34f"]' (core/test/name-identity.test.js:204)
not ok 9 - #2935 a drawn blank beside drawn characters is a name, and it takes that drawn form
error: 'Missing expected rejection.' (core/test/name-identity.test.js:221)
```
The counter-control (`#2935 a combining mark is drawn with its letter,
so both spellings are names`) passes on the base by construction — that
is the point: it is the guard that the fix must not over-refuse.
After the source change the whole file is **14/14, twice**.
## Mutation
Each check reverted one piece of the fix at this tip and reran the file;
every variant went red and the restored tip is 14/14 again:
- A — `drawnKey` made equal to `nameKey`: 4 red (pure key + create +
rename + reverse).
- B — the create-side `drawnClash` removed: 2 red.
- C — the rename-side `drawnClash` removed: 1 red.
- D — `drawnKey` strips the whole `\p{Mn}` class instead of the explicit
list (the reverse of this fix): 2 red, including the counter-control —
its second Thai name is refused as "already exists".
## Checks at this tip (302a626)
- `node --import ./test/harness-resolve.mjs --test
test/name-identity.test.js` (TZ=UTC, `DSH_HARNESS`, `TMPDIR`) →
**14/14**, run twice.
- Full suite on `95a793ef`: **3157 / 3132 pass / 25 fail**; at this tip:
**3162 / 3137 pass / 25 fail**. Compared failure names one by one:
identical sets (the 25 are the standing base failures: bench/EROFS,
`#1433` ×3, `#1718`, `#2057`, the symlink probes, `#896` ×3, `#2167` ×2
…). The branch adds exactly the five new `#2935` tests, all green.
- `node core/scripts/build-client.mjs --check` → exit 0; `node
scripts/ds-bot-patches.mjs check` → pin ok, 10 patches apply cleanly,
`core/` equals `ds-bot/` + patches.
- `node core/scripts/check-arch-docs.mjs` → `OK (106 changed file(s))`;
`node .github/scripts/check-mojibake.mjs --check` → 0 U+FFFD.
- `cd core && npm run lint` → 0 errors, 88 warnings (the standing
count).
- Not run: the smoke test — this checkout cannot start the bench
(`EROFS` symlinking the pnpm store into it), same as on `#2933`; CI
covers it. `maintainer_can_modify: true`, non-draft.
## Checkpoint
<!-- flybot:checkpoint -->
```json
{
"pr": 2937,
"claim": "Dev-3",
"issue": 2935,
"summary": "A Bot name whose drawn form another Bot holds is refused by createBot and updateBot, from either side: two rows that read the same on screen but differed only by an invisible code point used to coexist, and @name could reach just one. The drawn key removes only the code points with no glyph of their own — an explicit list, not the whole Mn class, so a combining mark that draws on its letter keeps two Thai names apart. Nothing is stripped from a stored name.",
"files": [
"core/src/shared/identity.js",
"core/src/shared/mentions.js",
"core/src/host/roster.js",
"core/test/name-identity.test.js",
"core/client.js",
"patches/ds-bot/0008-client-bundle.patch",
"docs/subsystems/core-host.md",
"changelog.d/2935-rendered-name-dedupe.fixed.md"
],
"checks": {
"ran": "name-identity (--test); full suite on base and tip; build-client --check; ds-bot-patches check; check-arch-docs; mojibake; lint",
"result": "green",
"at": "302a6266526e08d8450439c4815f7052a571ea62"
},
"next": "none — ready for review; T3 needs a PASS at this tip"
}
```
<!-- /flybot:checkpoint -->
---------
Co-authored-by: FlyBot Dev-3 <dev3@flybot.local>
Co-authored-by: Dev-3 <dev-3@flybot.local>
A Bot name whose **drawn** form is already taken is refused. `#2879` refused only a name that draws nothing at all; a name that draws something and also carries a character the screen does not draw still passed, so `Dev` plus a combining grapheme joiner (or a braille blank, or a Hangul filler) sat beside the existing `Dev`: both rows read `Dev` while the identity key stayed distinct, and `@Dev` could only ever reach one of them. `createBot` and `updateBot` now compare `drawnKey()` — `nameKey()` with the code points that have no glyph of their own removed — beside `nameKey()`, from either side. A combining mark is not one of them: the letter under it draws it, so two names that differ there stay two names. A drawn form nobody holds is still a name, and nothing is stripped from the stored name ([#2935](https://github.com/ThinkFlowLab/FlyBot/issues/2935)).
var stripInvisible = (value) => String(value ?? "").replace(/\p{Cf}/gu, "");
2454
-
var NOT_DRAWN = /[\p{Mn}\p{Me}\p{Zs}\p{Zl}\p{Zp}\p{Default_Ignorable_Code_Point}\u2800]/gu;
2454
+
var NOT_DRAWN_RANGES = [
2455
+
[847, 847],
2456
+
[4447, 4448],
2457
+
[6068, 6069],
2458
+
[6155, 6157],
2459
+
[6159, 6159],
2460
+
[10240, 10240],
2461
+
[12644, 12644],
2462
+
[65440, 65440],
2463
+
[65024, 65039],
2464
+
[917760, 917999]
2465
+
];
2466
+
var NOT_DRAWN = new RegExp(`[${NOT_DRAWN_RANGES.map(([from, to]) => `\\u{${from.toString(16)}}${to === from ? "" : `-\\u{${to.toString(16)}}`}`).join("")}]`, "gu");
2467
+
var DRAWS_NOTHING = /[\p{Mn}\p{Me}\p{Zs}\p{Zl}\p{Zp}\p{Default_Ignorable_Code_Point}\u2800]/gu;
2455
2468
function nameProblem(name) {
2456
2469
const text2 = stripInvisible(name).trim();
2457
-
if (text2 === "" || text2.replace(NOT_DRAWN, "").trim() === "") return "A Bot needs a name";
2470
+
if (text2 === "" || text2.replace(DRAWS_NOTHING, "").trim() === "") return "A Bot needs a name";
2458
2471
if (/[@`\r\n]/.test(text2)) return "A Bot name cannot contain @, ` or a line break";
2459
2472
if (ALL_WORDS.includes(text2.toLowerCase())) return `"${text2}" calls everyone in a group, so it cannot be a Bot name`;
Copy file name to clipboardExpand all lines: docs/subsystems/core-client.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ owned_paths:
7
7
8
8
# core-client
9
9
10
-
The browser side of the patched `ds-bot` core (`core/`): sources in `core/src/client/`, built into the committed bundle `core/client.js`. Split out of [ds-bot-core](ds-bot-core.md) so a host-only change does not have to edit this page. `client.js` is generated: never hand-edit it, run `npm run build` in `core/` and commit both. The bundle also carries the `core/src/shared/` modules the client imports — `mentions.js` (the `@Name` rule, `nameProblem` and `stripInvisible`), `text-boundary.js`, `remote-label.js`, `approval-waiting.js`, `room-share.js`, `identity.js` (the name key`nameKey`, #2692, which `task-board.js` compares a role label with) among them — so a change in one of those rebuilds `client.js` too even when no file under `core/src/client/` was edited; the rules themselves are documented on [core-host](core-host.md#key-files).
10
+
The browser side of the patched `ds-bot` core (`core/`): sources in `core/src/client/`, built into the committed bundle `core/client.js`. Split out of [ds-bot-core](ds-bot-core.md) so a host-only change does not have to edit this page. `client.js` is generated: never hand-edit it, run `npm run build` in `core/` and commit both. The bundle also carries the `core/src/shared/` modules the client imports — `mentions.js` (the `@Name` rule, `nameProblem` and `stripInvisible`), `text-boundary.js`, `remote-label.js`, `approval-waiting.js`, `room-share.js`, `identity.js` (the name keys`nameKey`, #2692, which `task-board.js` compares a role label with, and `drawnKey`, #2935) among them — so a change in one of those rebuilds `client.js` too even when no file under `core/src/client/` was edited; the rules themselves are documented on [core-host](core-host.md#key-files).
0 commit comments