Skip to content

feat: count writer slots by the diary's walk on the clients - #722

Merged
rodrigopavezi merged 23 commits into
mainfrom
feat/writer-slot-clients
Nov 17, 2026
Merged

rodrigopavezi merged 23 commits into
mainfrom
feat/writer-slot-clients

Conversation

@rodrigopavezi

Copy link
Copy Markdown
Contributor

Parte da #350.

O que muda e por quê

Os clientes passam a contar as vagas de escritor pela caminhada das vagas do próprio diário (#713), a mesma regra dos semeadores e da dobra.

  • Entrar num grupo ou numa comunidade, no nó core e no nó do navegador, confere as 8 vagas vivas da conta ali, e não mais os escritores guardados nem as 8 primeiras entradas.
  • Um aparelho que troca o próprio escritor (depois de uma saída, ou quando o escritor de comunidade que ele citava foi retirado) grava a entrada desligada e um corte no escritor antigo antes da entrada nova. O corte devolve a vaga enquanto houver reserva. A caminhada é conferida antes de qualquer escrita: sem vaga, nada é gravado e a entrada é recusada (GROUP_FULL, COMMUNITY_FULL).
  • A dobra da comunidade lê os cortes do diário, como a dobra do grupo, no nó do navegador e no catálogo da sincronização do nó core.
  • Um banimento, uma admissão ou um rebaixamento nomeia os mesmos escritores nos dois nós: um escritor congelado entra no corte dele, um liberado nunca.
  • A sincronização busca até 32 escritores por diário e grupo (8 vivos, 8 congelados e 16 liberados), como os semeadores guardam. A troca periódica de chave deixa de contar os envelopes de um escritor depois do corte.
  • group.info e community.info do navegador informam writersFrozen e frozenRoom, e writersBound é o número de vagas vivas (rpc.md 5.37, 5.42, 5.59 e 5.63).
  • App: a recusa com as 8 vagas em uso diz "Para liberar a vaga, desconecte um aparelho antigo em Ajustes, Aparelhos conectados.", e um aviso diz quando desconectar pode não devolver a vaga.

docs/protocol.md ("Writers named by a node", "Bounds on hints", "Slot walk") descreve as regras. Os Termos não mudam.

Como verificar

Os testes, o que cada um cobre, a prova de que falham sem a mudança e o que fica de fora estão em docs/verification/feat-writer-slot-clients.md.

node packages/core/test/writer-slot-member.test.js
node packages/core/test/sync-groups-2.test.js
node packages/core/test/group-rekey.test.js
node packages/web-member/test/group-ops.test.js
node packages/web-member/test/community-ops.test.js
node packages/web-member/test/sync-groups-2.test.js
cd apps/app && node test/groups.test.js

Local, com a main em c0f85f2: npm run lint limpo, npm run demo termina com DEMO OK e npm test -- --affected=origin/main com 833 arquivos e uma falha, em packages/core/test/community-member-leave-5.test.js: o teste 7 esperava nenhum corte antes da saída final, e a volta agora corta o escritor que ela troca. O teste passou a fixar esse corte (0c9be34) e passa sozinho com 10/10. Depois veio a main em 5ff127c, num merge sem conflito.

Não conferi no Android nem no simulador iOS: a recusa e o aviso novos só aparecem com as 8 vagas em uso ou sem reserva, e apps/app/test/groups.test.js cobre os dois textos.

Checklist

  • npm run lint, npm test -- --affected=origin/main e npm run demo passam
  • docs/protocol.md e docs/rpc.md atualizados
  • Entrada do changelog em docs/changelog/feat-writer-slot-clients.md e verificação em docs/verification/feat-writer-slot-clients.md
  • Textos para o usuário estão em pt-BR
  • Conferido no Android e no simulador iOS
  • Nenhum segredo, chave ou dado pessoal no diff

community.join checks the own diary's slot walk instead of the CWs held.
A group join that replaces this device's writer (retired by a leave, or
naming a retired CW) writes the off join and a cut at the length held
before the new join, once the walk has room.
The browser node checks group and community joins against the own
diary's slot walk, cuts the writer a join replaces before the new join,
and reports the live and frozen slots in group.info and community.info
(writersFrozen, frozenRoom, and Geral's). The sync fetches up to 32 cores
per (group, diary), as the seeder holds them, and the community fold
reads the diary cuts. Leaves and grants name the live writers only, as
the core node does.
The sync fetches up to 32 cores per (group, diary), the 8 live, 8 frozen
and 16 released writers of the diary's slot walk, as the seeder holds
them: a frozen or released writer may hold a leave the fold reads. The
slots still go to the earliest proven joins.
The rekey policy's facts skip the group-sealed blocks a frozen or
released writer wrote at or past its cut, as the fold drops them. Its
key blocks still count. Both nodes pass the fold's cuts.
The diary root adoption keeps the own diary's cuts with its joins, so a
writer that takes a slot a cut released binds its root and is chased.
liveDiaryWriters moves to the module so a unit test reaches it, and an
end-to-end test has a second device fetch such a root.
With a node that reports frozenRoom, the reserve warning says each device
uses one of the account's 8 slots and that disconnecting an old one in
Aparelhos conectados gives it back, or that it no longer does once the
frozen reserve is gone. A full-root refusal at 8 live devices points
there too. An older node keeps the old words.
protocol.md and rpc.md say joins count the own diary's live slots, how a
replaced writer is cut, the sync cap of 32 per diary, and the new
writersFrozen and frozenRoom fields of group.info and community.info.
app.md follows the new reserve warning. Changelog and verification
fragments for the branch.
Conflict only in the web-member sync.js exports: both the slot walk names
of this branch and the retry names of #715 stay.
The reserve warning and the full refusal name the way to the connected
devices screen as Ajustes lists it, and the test ties the words to its
label.
community.join retires the CW it replaces as group.join does: its off
join and its cut count in the walk check before anything is written,
then the cut goes after any leave the join appends to that CW and before
the new CW's join. Both nodes.
A demotion past MAX_GROUP_CUTS writers names the first by key and is
never refused; only a grant past the cap gets COMMUNITY_FULL.
The community fold of the sync catalogue reads the diaries' cuts, like
the group fold, as foldCommunity does: a CW a cut let in is awaited
before the fold gives the catalogue. The fold moves to foldedCatalogue,
a pure helper with its own test.
protocol.md: community.join cuts the retired CW like group.join, the
community fold reads the diaries' cuts like the group fold, and a
community demotion is never refused for its size. rpc.md 5.37 counts
the live slots of the walk. The changelog and the verification file
cover the merge of main, the new tests, their proofs and the decisions.
The core node's sync catalogue fold now passes the diaries' cuts to
buildCommunity, like the group fold, loadCommunity and the two browser
paths. The fold moves to heldCatalogue, a pure module function, so a
unit test reaches it.
A group admit, ban or demotion written by the core node left out a frozen
writer whose cut was at or below its length, since it takes no probe post.
A record that does not name a writer covers it from seq 0, so a core ban hid
that writer's posts below its cut while the browser node kept them. groupCuts
now also names every frozen writer the fold counts, at its length or the
diary's cut when lower, and never a released one, as cutsFor does.
The fold lists the groups by key and the keys are random, so the control
assertion compared against a fixed order and failed in some runs.
A rejoin skipped the cut on this device's retired writer when the diary
already had a mark at or below it. If that mark came while the frozen
reserve was full, the writer stayed live, and every later join planned only
the off join and got GROUP_FULL. Both nodes now write the cut again while the
walk has the writer live, at the lowest mark when that is lower, never
higher, and run makeGroupRoom before the off join and the cut, as
communityJoin does.
The full refusal now reads "Para liberar a vaga, desconecte um aparelho
antigo em Ajustes, Aparelhos conectados." With frozenRoom 0 the warning says
a disconnect may not give the slot back, since a cut at 0 still releases one
while releases remain.
rpc.md 5.42 says frozenRoom covers cuts of 1 or more, and 5.63 names the own
diary's 8 live slots among the community.join errors, as 5.37 does.
protocol.md "Bounds on hints" says both nodes keep the 32 earliest proven
joins per group and diary, and that only the diary itself can write joins
its walk refuses. The roomFor comment says its count is stricter than the
walk. The verification file records this round.
Brings in #716, #717 and #718. Conflicts: the web sync.js exports keep both
lists (restartWait and the restart constants with WALK_TYPES,
liveDiaryWriters, foldedCatalogue and MAX_GROUP_HELD_PER_DIARY); the test
files keep the tests and imports of both sides, and sync-groups-3 drops
MAX_GROUP_WRITERS_PER_DIARY, which only the cap loop now replaced by CAP used.
The return in this test replaces this device's cw2 after the leave it
writes there, so the diary now holds the cut on cw2 at its length (#350).
The assertion pins that cut as the only mark, with the leave below it, and
still means no root is marked before the later leave.
@rodrigopavezi
rodrigopavezi requested a review from a team as a code owner November 17, 2026 06:38
@rodrigopavezi
rodrigopavezi merged commit 4e901c1 into main Nov 17, 2026
24 checks passed
@rodrigopavezi
rodrigopavezi deleted the feat/writer-slot-clients branch November 17, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant