A plain token cannot be linked to a character through token.update at all: the handler forbids names in the patch when the link is set, and validation requires a linked token to carry empty names, but the patch keeps the plain token's existing names. The candidate token therefore always fails validation, so the only outcome of a link attempt is invalid. Only unlinking works.
Where
server/main.nim:1095-1098 — when character_id is a non-null id, the patch is rejected if it carries descriptive_name or actual_name.
server/tokens.nim:232-234 — validToken's namesOk: a token with a character must have descriptiveName.len == 0 and actualName.len == 0.
server/tokens.nimpatched — applies the patch field by field, so the plain token's own names survive the link and the candidate violates namesOk.
tests/characters.test.mjs:377-379 — the only linking coverage is unlinking; no test links through token.update.
Failure scenario
GM creates a plain token ("a wolf" / "a huge wolf"), then links it to an existing character with token.update {"id": ..., "character_id": "<cid>"}. The server answers error ... invalid and the token keeps its own names. The client's only workaround is to delete and recreate the token (losing its position history, properties, and encountered entries) or to create it already linked. Since token.create accepts character_id with no names, the asymmetry is not intentional and is not documented in DESIGN 6.1.
Confidence
High — verified on the build; the two rules are mutually exclusive by construction.
Fix direction
Linking is a name handover: the token's own names are dropped as part of the link patch, and the character's names are what reach clients. Keep rejecting a patch that supplies names alongside a link (that stays invalid), and keep requiring both names on unlink. Do not let this change weaken the "plain token always carries its own two names" rule.
Acceptance
token.update {"id", "character_id": "<cid>"} on a named plain token is acked ok; the token's created/detail frames then show the character's names, and settings carries the link.
A patch that links and supplies descriptive_name or actual_name is still invalid.
Unlinking without both names is still invalid; unlinking with both names is ok and the token carries the supplied names.
A linked token still cannot be created or updated with names of its own.
Regression test: characters.test.mjs gains a link-via-update case (plain token with names -> link -> view shows the character's names -> unlink with names restores the token's own), plus a validToken unit case for the linked-with-names rejection.
## Summary
A plain token cannot be linked to a character through `token.update` at all: the handler forbids names in the patch when the link is set, and validation requires a linked token to carry empty names, but the patch keeps the plain token's existing names. The candidate token therefore always fails validation, so the only outcome of a link attempt is `invalid`. Only unlinking works.
## Where
- `server/main.nim:1095-1098` — when `character_id` is a non-null id, the patch is rejected if it carries `descriptive_name` or `actual_name`.
- `server/tokens.nim:232-234` — `validToken`'s `namesOk`: a token with a character must have `descriptiveName.len == 0 and actualName.len == 0`.
- `server/tokens.nim` `patched` — applies the patch field by field, so the plain token's own names survive the link and the candidate violates `namesOk`.
- `tests/characters.test.mjs:377-379` — the only linking coverage is unlinking; no test links through `token.update`.
## Failure scenario
GM creates a plain token ("a wolf" / "a huge wolf"), then links it to an existing character with `token.update {"id": ..., "character_id": "<cid>"}`. The server answers `error ... invalid` and the token keeps its own names. The client's only workaround is to delete and recreate the token (losing its position history, properties, and encountered entries) or to create it already linked. Since `token.create` accepts `character_id` with no names, the asymmetry is not intentional and is not documented in DESIGN 6.1.
## Confidence
High — verified on the build; the two rules are mutually exclusive by construction.
## Fix direction
Linking is a name handover: the token's own names are dropped as part of the link patch, and the character's names are what reach clients. Keep rejecting a patch that supplies names *alongside* a link (that stays `invalid`), and keep requiring both names on unlink. Do not let this change weaken the "plain token always carries its own two names" rule.
## Acceptance
- `token.update {"id", "character_id": "<cid>"}` on a named plain token is acked `ok`; the token's `created`/`detail` frames then show the character's names, and `settings` carries the link.
- A patch that links *and* supplies `descriptive_name` or `actual_name` is still `invalid`.
- Unlinking without both names is still `invalid`; unlinking with both names is `ok` and the token carries the supplied names.
- A linked token still cannot be created or updated with names of its own.
- Regression test: `characters.test.mjs` gains a link-via-update case (plain token with names -> link -> view shows the character's names -> unlink with names restores the token's own), plus a `validToken` unit case for the linked-with-names rejection.
## Related
- #23 (slice 8: characters and names).
- #2 (M3 planning map).
Fix — server/tokens.nimpatched: a link patch now drops the token's own two names (character_id set ⇒ descriptiveName/actualName cleared), so the candidate satisfies validToken's namesOk and a plain token can be linked through token.update. A patch that supplies names with a link is still rejected as invalid in the handler; unlinking still requires both names; a linked token still cannot carry names. server/main.nim also rewrites that token's encountered snapshots on the link change (names + character link), through the same helper as a rename.
Regression test (red -> green) — tools/characters.test.mjs, new test "token.update links a plain token to a character: the names are handed over (#29)": plain token with names, GM links it with a bare token.update {character_id}.
old code: AssertionError: {"t":"ack","reqId":6,"ok":false,"code":"invalid","n":16} !== true
after: ack ok; GM token frame carries character_id and no descriptive_name/actual_name; the character's owner sees name: "Lady Vex"; her encountered entry follows to Lady Vex; link + names is still invalid; unlink without names is invalid, with both names ok and restores a wolf/Fang.
Unit level: tests/tcharacters.nim "linking through a patch hands the names over (#29)" pins patched (link clears both names, unlink restores them, a plain name patch still applies) and the existing validToken case keeps the linked-with-names rejection. Mutation e3 ("a link patch keeps the token's own names") fails exactly that test.
Commits — 8e045b0 names: per-player reveal, one encountered write path, link by update (#27, #29, #30); b4bddf1 design (6.1: "a link is a name handover"); e13fa90 results.
Gates — devbox run test: 107/107 node tests + all Nim suites pass; devbox run mutation: exit 0, every mutation passes.
Fixed and pushed on `main`.
**Fix** — `server/tokens.nim` `patched`: a link patch now **drops the token's own two names** (`character_id` set ⇒ `descriptiveName`/`actualName` cleared), so the candidate satisfies `validToken`'s `namesOk` and a plain token can be linked through `token.update`. A patch that supplies names *with* a link is still rejected as `invalid` in the handler; unlinking still requires both names; a linked token still cannot carry names. `server/main.nim` also rewrites that token's encountered snapshots on the link change (names + character link), through the same helper as a rename.
**Regression test (red -> green)** — `tools/characters.test.mjs`, new test "token.update links a plain token to a character: the names are handed over (#29)": plain token with names, GM links it with a bare `token.update {character_id}`.
- old code: `AssertionError: {"t":"ack","reqId":6,"ok":false,"code":"invalid","n":16} !== true`
- after: ack `ok`; GM token frame carries `character_id` and no `descriptive_name`/`actual_name`; the character's owner sees `name: "Lady Vex"`; her encountered entry follows to `Lady Vex`; `link + names` is still `invalid`; unlink without names is `invalid`, with both names `ok` and restores `a wolf`/`Fang`.
Unit level: `tests/tcharacters.nim` "linking through a patch hands the names over (#29)" pins `patched` (link clears both names, unlink restores them, a plain name patch still applies) and the existing `validToken` case keeps the linked-with-names rejection. Mutation `e3` ("a link patch keeps the token's own names") fails exactly that test.
**Commits** — `8e045b0` names: per-player reveal, one encountered write path, link by update (#27, #29, #30); `b4bddf1` design (6.1: "a link is a name handover"); `e13fa90` results.
**Gates** — `devbox run test`: 107/107 node tests + all Nim suites pass; `devbox run mutation`: exit 0, every mutation passes.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
A plain token cannot be linked to a character through
token.updateat all: the handler forbids names in the patch when the link is set, and validation requires a linked token to carry empty names, but the patch keeps the plain token's existing names. The candidate token therefore always fails validation, so the only outcome of a link attempt isinvalid. Only unlinking works.Where
server/main.nim:1095-1098— whencharacter_idis a non-null id, the patch is rejected if it carriesdescriptive_nameoractual_name.server/tokens.nim:232-234—validToken'snamesOk: a token with a character must havedescriptiveName.len == 0 and actualName.len == 0.server/tokens.nimpatched— applies the patch field by field, so the plain token's own names survive the link and the candidate violatesnamesOk.tests/characters.test.mjs:377-379— the only linking coverage is unlinking; no test links throughtoken.update.Failure scenario
GM creates a plain token ("a wolf" / "a huge wolf"), then links it to an existing character with
token.update {"id": ..., "character_id": "<cid>"}. The server answerserror ... invalidand the token keeps its own names. The client's only workaround is to delete and recreate the token (losing its position history, properties, and encountered entries) or to create it already linked. Sincetoken.createacceptscharacter_idwith no names, the asymmetry is not intentional and is not documented in DESIGN 6.1.Confidence
High — verified on the build; the two rules are mutually exclusive by construction.
Fix direction
Linking is a name handover: the token's own names are dropped as part of the link patch, and the character's names are what reach clients. Keep rejecting a patch that supplies names alongside a link (that stays
invalid), and keep requiring both names on unlink. Do not let this change weaken the "plain token always carries its own two names" rule.Acceptance
token.update {"id", "character_id": "<cid>"}on a named plain token is ackedok; the token'screated/detailframes then show the character's names, andsettingscarries the link.descriptive_nameoractual_nameis stillinvalid.invalid; unlinking with both names isokand the token carries the supplied names.characters.test.mjsgains a link-via-update case (plain token with names -> link -> view shows the character's names -> unlink with names restores the token's own), plus avalidTokenunit case for the linked-with-names rejection.Related
Fixed and pushed on
main.Fix —
server/tokens.nimpatched: a link patch now drops the token's own two names (character_idset ⇒descriptiveName/actualNamecleared), so the candidate satisfiesvalidToken'snamesOkand a plain token can be linked throughtoken.update. A patch that supplies names with a link is still rejected asinvalidin the handler; unlinking still requires both names; a linked token still cannot carry names.server/main.nimalso rewrites that token's encountered snapshots on the link change (names + character link), through the same helper as a rename.Regression test (red -> green) —
tools/characters.test.mjs, new test "token.update links a plain token to a character: the names are handed over (#29)": plain token with names, GM links it with a baretoken.update {character_id}.AssertionError: {"t":"ack","reqId":6,"ok":false,"code":"invalid","n":16} !== trueok; GM token frame carriescharacter_idand nodescriptive_name/actual_name; the character's owner seesname: "Lady Vex"; her encountered entry follows toLady Vex;link + namesis stillinvalid; unlink without names isinvalid, with both namesokand restoresa wolf/Fang.Unit level:
tests/tcharacters.nim"linking through a patch hands the names over (#29)" pinspatched(link clears both names, unlink restores them, a plain name patch still applies) and the existingvalidTokencase keeps the linked-with-names rejection. Mutatione3("a link patch keeps the token's own names") fails exactly that test.Commits —
8e045b0names: per-player reveal, one encountered write path, link by update (#27, #29, #30);b4bddf1design (6.1: "a link is a name handover");e13fa90results.Gates —
devbox run test: 107/107 node tests + all Nim suites pass;devbox run mutation: exit 0, every mutation passes.