player.setname writes the name durably, then pushes the effects (hello with me.name, the full resync, roster to everyone) and only then acks the intent. DESIGN 6.1's ack-before-effects rule runs the other way: the ack must be the first frame the client can observe for that reqId, so a client that gates its own state machine on the ack sees hello/resync/roster out of order, and a failed ack path can leave pushes already delivered.
Where
server/main.nim:766-770 — for c in app.conns.connectionsOf(...): sendHello / resync, then sendRoster(), then ackOk(conn, env.reqId).
Failure scenario
A player sets their name. The client has not yet seen the ack, so it still treats the player as unnamed, then receives hello with me.name and a full resync. A client that discards frames it cannot attribute to an outstanding request drops the resync, or applies the name change twice; a protocol test that asserts "ack first" for every intent fails or has to special-case this one. Every other mutating intent in the server acks first, so this is also an inconsistency a client author cannot predict.
Confidence
High — the order is explicit in the code; comment even states the intent, then does the opposite.
Fix direction
Ack first, then emit hello, the resync and the roster (or record the deviation explicitly in DESIGN 6.1 if the ordering is deliberate for a reason not yet written down). The durable write and registry update stay where they are, so nothing is acked before it is durable.
Acceptance
For player.setname, the ok ack precedes hello, the resync and the roster on that connection; other connections still get hello/resync/roster after the ack is produced.
The name is still persisted before the ack, and the same rename-to-taken case still answers error name-taken with no hello or resync.
If the ordering is deliberately changed, DESIGN 6.1 records it and the exception is named.
Regression test: a frame-order assertion in characters.test.mjs or protocol.test.mjs that player.setname's ack comes first and the effects follow.
## Summary
`player.setname` writes the name durably, then pushes the effects (`hello` with `me.name`, the full resync, `roster` to everyone) and only then acks the intent. DESIGN 6.1's ack-before-effects rule runs the other way: the ack must be the first frame the client can observe for that `reqId`, so a client that gates its own state machine on the ack sees `hello`/`resync`/`roster` out of order, and a failed ack path can leave pushes already delivered.
## Where
- `server/main.nim:766-770` — `for c in app.conns.connectionsOf(...): sendHello / resync`, then `sendRoster()`, then `ackOk(conn, env.reqId)`.
## Failure scenario
A player sets their name. The client has not yet seen the ack, so it still treats the player as unnamed, then receives `hello` with `me.name` and a full resync. A client that discards frames it cannot attribute to an outstanding request drops the resync, or applies the name change twice; a protocol test that asserts "ack first" for every intent fails or has to special-case this one. Every other mutating intent in the server acks first, so this is also an inconsistency a client author cannot predict.
## Confidence
High — the order is explicit in the code; comment even states the intent, then does the opposite.
## Fix direction
Ack first, then emit `hello`, the resync and the roster (or record the deviation explicitly in DESIGN 6.1 if the ordering is deliberate for a reason not yet written down). The durable write and registry update stay where they are, so nothing is acked before it is durable.
## Acceptance
- For `player.setname`, the `ok` ack precedes `hello`, the resync and the roster on that connection; other connections still get `hello`/`resync`/`roster` after the ack is produced.
- The name is still persisted before the ack, and the same rename-to-taken case still answers `error name-taken` with no `hello` or resync.
- If the ordering is deliberately changed, DESIGN 6.1 records it and the exception is named.
- Regression test: a frame-order assertion in `characters.test.mjs` or `protocol.test.mjs` that `player.setname`'s ack comes first and the effects follow.
## Related
- #23 (slice 8: characters and names).
- #2 (M3 planning map).
Category: bug Summary:player.setname must produce its ack before the hello, resync and roster frames it causes
Current behavior:
On a successful player.setname the server writes the name durably and then, still inside the same locked section, pushes the effects: hello with me.name to every connection of that player, the full resync on each of those connections, roster to everyone — and only then acks the intent. Every other mutating intent acks first and pushes afterwards, so this one is the single exception a client author cannot predict. A client that gates its own state machine on the ack sees hello, a full resync and roster for a request it still believes is pending, and a client that discards frames it cannot attribute to an outstanding request may drop the resync or apply the rename twice. The protocol's own rule (ack after the durable write, before the effect frames) is what the code contradicts; the comment at the call site even states that the ack should come first.
Desired behavior:
The success ack for player.setname is enqueued to the connection before any frame the intent causes: before that player's hello, before the first frame of the resync, before roster. In outbox order that means ack first; the ack is not a coalesced state message, so coalescing cannot reorder it behind them.
The durable write and the registry update happen exactly where they do today. Nothing is acked before it is committed: the ordering change moves the ack earlier than the effects, never earlier than the commit.
The effects themselves are unchanged: same content, same recipients, same order among themselves (hello, then the resync, then roster), same behaviour on every connection of that player.
Failure paths are unchanged: name-taken (and invalid, not-allowed) answers exactly one error ack and produces no hello, no resync and no roster.
No other intent's frame ordering changes.
If, after reading the code, the current ordering turns out to be deliberate for a reason not yet written down, the alternative is to record the exception explicitly in DESIGN 6.1 next to the ack-before-effects rule and name this intent. Silent divergence is the thing being fixed, not the specific order; but the default and expected outcome is ack-first, matching every other intent.
Key interfaces:
DESIGN 6.1's player.setname payload-rule paragraph already says the ordering the server must follow; it is the contract this bug violates. No DESIGN change is expected unless the alternative above is taken, in which case the exception is recorded there.
DESIGN 4.2's pipeline and the 6 "Ack" convention state ack-after-commit-then-effects for every intent. This intent must obey them rather than special-case itself.
hello / resync / roster emitters and the ack helper: the change is the order in which the handler calls them, under the same lock, with the ack enqueued between the commit and the first effect.
A frame-order assertion in the characters/names group and/or the protocol group: a single connection, one stream of frames, player.setname sent once, then the observed order of t values pinned. Prefer an assertion that names the intent so a future reader knows which rule it protects.
Acceptance criteria:
On success, the frames observed on the renaming connection are, in order: the ack for that reqId (ok:true), then hello, then the resync frames, with roster following; all of them still arrive.
The name is durable before the ack: a restart immediately after the ack still shows the name, or the stored state is asserted at ack time.
The same connection's resync content is unchanged by the reordering (same hello, same frames) — only the position of the ack moved.
name-taken still yields exactly one error/ok:false ack with name-taken and no hello, resync or roster; invalid and not-allowed likewise.
Every other intent's ack/effect order is unchanged; the existing protocol and characters/names groups stay green without modification to their ordering expectations.
A mutation that moves the ack back after the effects fails at least one test.
Out of scope:
The content, order or recipients of the resync sequence itself (DESIGN 6.3).
player.rename, key.*, player.remove and any other roster-emitting intent.
A general audit or refactor of ack ordering across all intents (the other intents already comply; if one does not, that is a separate issue).
Client-side handling of hello mid-connection and pending reqId semantics.
> *This was generated by AI during triage.*
## Agent Brief
**Category:** bug
**Summary:** `player.setname` must produce its ack before the `hello`, resync and roster frames it causes
**Current behavior:**
On a successful `player.setname` the server writes the name durably and then, still inside the same locked section, pushes the effects: `hello` with `me.name` to every connection of that player, the full resync on each of those connections, `roster` to everyone — and only then acks the intent. Every other mutating intent acks first and pushes afterwards, so this one is the single exception a client author cannot predict. A client that gates its own state machine on the ack sees `hello`, a full resync and `roster` for a request it still believes is pending, and a client that discards frames it cannot attribute to an outstanding request may drop the resync or apply the rename twice. The protocol's own rule (ack after the durable write, before the effect frames) is what the code contradicts; the comment at the call site even states that the ack should come first.
**Desired behavior:**
- The success ack for `player.setname` is enqueued to the connection before any frame the intent causes: before that player's `hello`, before the first frame of the resync, before `roster`. In outbox order that means ack first; the ack is not a coalesced state message, so coalescing cannot reorder it behind them.
- The durable write and the registry update happen exactly where they do today. Nothing is acked before it is committed: the ordering change moves the ack earlier than the effects, never earlier than the commit.
- The effects themselves are unchanged: same content, same recipients, same order among themselves (`hello`, then the resync, then `roster`), same behaviour on every connection of that player.
- Failure paths are unchanged: `name-taken` (and `invalid`, `not-allowed`) answers exactly one error ack and produces no `hello`, no resync and no `roster`.
- No other intent's frame ordering changes.
- If, after reading the code, the current ordering turns out to be deliberate for a reason not yet written down, the alternative is to record the exception explicitly in DESIGN 6.1 next to the ack-before-effects rule and name this intent. Silent divergence is the thing being fixed, not the specific order; but the default and expected outcome is ack-first, matching every other intent.
**Key interfaces:**
- **DESIGN 6.1's `player.setname` payload-rule paragraph** already says the ordering the server must follow; it is the contract this bug violates. No DESIGN change is expected unless the alternative above is taken, in which case the exception is recorded there.
- **DESIGN 4.2's pipeline and the 6 "Ack" convention** state ack-after-commit-then-effects for every intent. This intent must obey them rather than special-case itself.
- **`hello` / resync / `roster` emitters** and the ack helper: the change is the order in which the handler calls them, under the same lock, with the ack enqueued between the commit and the first effect.
- **A frame-order assertion** in the characters/names group and/or the protocol group: a single connection, one stream of frames, `player.setname` sent once, then the observed order of `t` values pinned. Prefer an assertion that names the intent so a future reader knows which rule it protects.
**Acceptance criteria:**
- [ ] On success, the frames observed on the renaming connection are, in order: the `ack` for that `reqId` (`ok:true`), then `hello`, then the resync frames, with `roster` following; all of them still arrive.
- [ ] The name is durable before the ack: a restart immediately after the ack still shows the name, or the stored state is asserted at ack time.
- [ ] The same connection's resync content is unchanged by the reordering (same `hello`, same frames) — only the position of the ack moved.
- [ ] `name-taken` still yields exactly one `error`/`ok:false` ack with `name-taken` and no `hello`, resync or roster; `invalid` and `not-allowed` likewise.
- [ ] Every other intent's ack/effect order is unchanged; the existing protocol and characters/names groups stay green without modification to their ordering expectations.
- [ ] A mutation that moves the ack back after the effects fails at least one test.
**Out of scope:**
- The content, order or recipients of the resync sequence itself (DESIGN 6.3).
- `player.rename`, `key.*`, `player.remove` and any other roster-emitting intent.
- A general audit or refactor of ack ordering across all intents (the other intents already comply; if one does not, that is a separate issue).
- Client-side handling of `hello` mid-connection and pending `reqId` semantics.
Fixed in 41c2fe6 (fix: player.setname acks before its effects (#33)), pushed to main.
Cause: on success the handler wrote the name durably but pushed hello, the full resync and roster before ackOk; the call-site comment already stated ack-first. Reproduced red with a frame-order assertion (first frame after the request was hello, not ack).
Fix: the durable write and registry update stay where they were; a small settleSetNameLocked now enqueues the ack first, then the same hello/resync and roster in their existing order. Failure paths are unchanged. No DESIGN change was needed: 6.1/4.2 already require ack after COMMIT and before effects.
Proof: new tools/characters.test.mjs case "player.setname: the ack precedes hello, the resync and roster" pins ack first, keeps hello->roster order, and asserts a name-taken refusal produces only its error ack (no hello/resync/roster). Full nimble test -y and Node suite (149/149) green after rebase.
Fixed in 41c2fe6 (`fix: player.setname acks before its effects (#33)`), pushed to `main`.
**Cause:** on success the handler wrote the name durably but pushed `hello`, the full resync and `roster` before `ackOk`; the call-site comment already stated ack-first. Reproduced red with a frame-order assertion (first frame after the request was `hello`, not `ack`).
**Fix:** the durable write and registry update stay where they were; a small `settleSetNameLocked` now enqueues the ack first, then the same `hello`/resync and `roster` in their existing order. Failure paths are unchanged. No DESIGN change was needed: 6.1/4.2 already require ack after COMMIT and before effects.
**Proof:** new `tools/characters.test.mjs` case "player.setname: the ack precedes hello, the resync and roster" pins ack first, keeps hello->roster order, and asserts a `name-taken` refusal produces only its error ack (no hello/resync/roster). Full `nimble test -y` and Node suite (149/149) green after rebase.
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
player.setnamewrites the name durably, then pushes the effects (hellowithme.name, the full resync,rosterto everyone) and only then acks the intent. DESIGN 6.1's ack-before-effects rule runs the other way: the ack must be the first frame the client can observe for thatreqId, so a client that gates its own state machine on the ack seeshello/resync/rosterout of order, and a failed ack path can leave pushes already delivered.Where
server/main.nim:766-770—for c in app.conns.connectionsOf(...): sendHello / resync, thensendRoster(), thenackOk(conn, env.reqId).Failure scenario
A player sets their name. The client has not yet seen the ack, so it still treats the player as unnamed, then receives
hellowithme.nameand a full resync. A client that discards frames it cannot attribute to an outstanding request drops the resync, or applies the name change twice; a protocol test that asserts "ack first" for every intent fails or has to special-case this one. Every other mutating intent in the server acks first, so this is also an inconsistency a client author cannot predict.Confidence
High — the order is explicit in the code; comment even states the intent, then does the opposite.
Fix direction
Ack first, then emit
hello, the resync and the roster (or record the deviation explicitly in DESIGN 6.1 if the ordering is deliberate for a reason not yet written down). The durable write and registry update stay where they are, so nothing is acked before it is durable.Acceptance
player.setname, theokack precedeshello, the resync and the roster on that connection; other connections still gethello/resync/rosterafter the ack is produced.error name-takenwith nohelloor resync.characters.test.mjsorprotocol.test.mjsthatplayer.setname's ack comes first and the effects follow.Related
Agent Brief
Category: bug
Summary:
player.setnamemust produce its ack before thehello, resync and roster frames it causesCurrent behavior:
On a successful
player.setnamethe server writes the name durably and then, still inside the same locked section, pushes the effects:hellowithme.nameto every connection of that player, the full resync on each of those connections,rosterto everyone — and only then acks the intent. Every other mutating intent acks first and pushes afterwards, so this one is the single exception a client author cannot predict. A client that gates its own state machine on the ack seeshello, a full resync androsterfor a request it still believes is pending, and a client that discards frames it cannot attribute to an outstanding request may drop the resync or apply the rename twice. The protocol's own rule (ack after the durable write, before the effect frames) is what the code contradicts; the comment at the call site even states that the ack should come first.Desired behavior:
player.setnameis enqueued to the connection before any frame the intent causes: before that player'shello, before the first frame of the resync, beforeroster. In outbox order that means ack first; the ack is not a coalesced state message, so coalescing cannot reorder it behind them.hello, then the resync, thenroster), same behaviour on every connection of that player.name-taken(andinvalid,not-allowed) answers exactly one error ack and produces nohello, no resync and noroster.Key interfaces:
player.setnamepayload-rule paragraph already says the ordering the server must follow; it is the contract this bug violates. No DESIGN change is expected unless the alternative above is taken, in which case the exception is recorded there.hello/ resync /rosteremitters and the ack helper: the change is the order in which the handler calls them, under the same lock, with the ack enqueued between the commit and the first effect.player.setnamesent once, then the observed order oftvalues pinned. Prefer an assertion that names the intent so a future reader knows which rule it protects.Acceptance criteria:
ackfor thatreqId(ok:true), thenhello, then the resync frames, withrosterfollowing; all of them still arrive.hello, same frames) — only the position of the ack moved.name-takenstill yields exactly oneerror/ok:falseack withname-takenand nohello, resync or roster;invalidandnot-allowedlikewise.Out of scope:
player.rename,key.*,player.removeand any other roster-emitting intent.hellomid-connection and pendingreqIdsemantics.Fixed in
41c2fe6(fix: player.setname acks before its effects (#33)), pushed tomain.Cause: on success the handler wrote the name durably but pushed
hello, the full resync androsterbeforeackOk; the call-site comment already stated ack-first. Reproduced red with a frame-order assertion (first frame after the request washello, notack).Fix: the durable write and registry update stay where they were; a small
settleSetNameLockednow enqueues the ack first, then the samehello/resync androsterin their existing order. Failure paths are unchanged. No DESIGN change was needed: 6.1/4.2 already require ack after COMMIT and before effects.Proof: new
tools/characters.test.mjscase "player.setname: the ack precedes hello, the resync and roster" pins ack first, keeps hello->roster order, and asserts aname-takenrefusal produces only its error ack (no hello/resync/roster). Fullnimble test -yand Node suite (149/149) green after rebase.