diff --git a/doc/2026-11-08_design_id5861.md b/doc/2026-11-08_design_id5861.md new file mode 100644 index 0000000000..8b9236d589 --- /dev/null +++ b/doc/2026-11-08_design_id5861.md @@ -0,0 +1,375 @@ +# Design: board moderation hooks + +- Date: 2026-11-08 +- Status: **decision record** — board roles, moderation events, reports, + audit, and appeals are decided here. The authority boundary with #835 + is clarified explicitly in §1 and §7. +- Issue: [#5861](https://github.com/developing-today/code/issues/5861), + follow-on of [#5680](https://github.com/developing-today/code/issues/5680), + programme epic [#2056](https://github.com/developing-today/code/issues/2056). +- Board-design basis: the proposed signed-graph v1 in + [#2054](2026-11-01_design_id2054.md), especially its separation of + board, host, and personal views and its public moderation history. + +## 1. Ordering and authority boundary + +Board moderation is the step after boards v1. It operates on the public, +signed board graph and its view projection; it does not operate through +world-session frames. This record refines the proposed moderation part +of #2054; it does not claim that #2054 is approved or already +implemented. It does not change the sharing, theme, or playable-post +decisions in #5680. + +There is an explicit cross-reference correction here: #5680 says board +moderation is "built on the #835 authority wiring," but [#835's design](2026-11-01_design_id835.md) +defines `BUILDER` and `MODERATOR` capabilities for live world-session +module installation and participant revocation. Those world capabilities +are not board roles and do not authorize signed board actions. Reusing +them would join two different authority domains. This record therefore +uses the board's signed identity and role-attestation model proposed in +#2054; it does not alter #835. For the packet's “authority-bearing +session” invariant, an authority-bearing board session means the +signing operation that holds the actor's key, signs the event, and +includes the owner's board-role proof. The durable attribution is the +verifying key plus that proof, not a client actor field or an ephemeral +session ID. If “session” specifically means an #835 `WorldSession` +frame, that requirement conflicts with the signed-board model and is +recorded as an explicit parent/design change needed before +implementation, not an implicit adapter here. + +The powers remain separate: host availability controls what one host +stores or serves; board moderation controls the board's default +projection over signed history; each reader's personal overlay can +narrow only that reader's view. No moderator action deletes signed +objects, compels another host to serve or withhold bytes, or changes +personal filters. + +One #5680 open question is resolved explicitly: moderators can inspect +the board-visible post presentation and its board metadata, but do not +gain read access to the underlying object. If the object is not +otherwise readable to a moderator, a report and moderation view show +only the board presentation and a reference. This does not widen the +object's audience or change any settled parent sharing decision. + +## 2. Decision: board roles are signed, board-scoped attestations + +The event's verifying key is the actor identity. There is no account or +second board identity system. Board authority is derived as follows: + +- **Owner** — the signing key on the board root. It may perform board + moderation actions directly and may grant or revoke the board's + moderator role by signing a board-scoped `RoleAttestation`. The root + signature itself is the owner's proof; the owner does not need a + moderator self-attestation. Only the root signer may issue role + attestations; loss of the key has no moderator-quorum recovery in v1, + consistent with #2054. +- **Moderator** — a key with an active, owner-signed + `RoleAttestation` for this board. The grant is not portable to another + board. A moderator may publish the moderation actions below but may + not grant or revoke roles or install hooks. +- **Member** — an optional self-signed `Membership` statement. It does + not confer moderation authority; board posting still follows the + board's current rules. +- **Viewer** — any reader of a public board. Public v1 does not require + registration or membership to read. +- **Reporter** — not a role. Anyone who can see a board presentation + may submit a report. + +These are board-graph roles, not #835 world capabilities. In particular, +a #835 `MODERATOR` capability neither grants a board `Moderator` +attestation nor overrides a board's signed role frontier. Conversely, +a board moderator gets no world, host, or platform authority. + +Every moderator action must be signed by its actor key and reference the +board, target, and the authority proof and frontier the signer observed. +For an owner action, the board-root signature is the proof; for a +moderator action, it is the owner-signed role attestation. Proofs are +checked against that signed frontier, not a client-supplied actor ID or +wall-clock time. +Revocation prevents actions based on a frontier that includes the +revocation; it does not erase an earlier valid action. Earlier actions +remain in the public log and keep their effect until an explicit later +action supersedes or restores them. Concurrent grant, revocation, and +moderation events remain signed graph history and are resolved from +causal references, never arrival order. This deliberately rejects the +older investigation's suggestion that each client may independently +“distrust” a moderator and stop applying that moderator's actions: +that would make board moderation diverge by reader; personal hides +remain the reader-specific overlay. The current `boards.rs` validator +accepts any existing grant, while its projection rechecks the current +role set. Both validation and projection must change to enforce the +signing-frontier rule. + +## 3. Decision: moderation actions change only the board projection + +Board moderation records are signed, append-only events. V1's action +vocabulary is: + +- **Hide / restore** — remove a target from, or restore it to, the + board's default view. This is not deletion. A restore references the + specific hide it reverses; independent hides remain in force until + each is reversed. This replaces the current count-based projection + rule with causal, per-action references. +- **Label, pin / unpin, and lock / unlock** — change presentation or + board-level contribution policy only. They do not rewrite posts or + prove a host is serving a particular view. +- **Freeze / unfreeze embed** — disable the embedded interaction in + this board's presentation and show its safe fallback. It does not + stop the source object or copies on other boards. +- **View-ban a poster** — hide that key's posts in this board's default + projection. It cannot prevent the key from publishing, erase its + signed history, or bind other hosts and readers. + +Slow mode is not a signed board moderation action: it is a host's +resource/volume policy, if a later discussion surface needs one. This +keeps rate controls separate from a judgement that an author lacks +board authority, as #2054 requires. “Remove,” “ban,” and “freeze” in +#5680 therefore mean board-projection effects only, never global +takedown, posting prevention, or source-object mutation. + +Each action stays visible and attributable even when it no longer +affects the current projection. The signed action records its target, +action kind, author key, role proof/frontier, optional reason, and any +action it supersedes or restores. `Hide`/`Restore` are the only action +kinds currently in `pkgs/id/src/boards.rs`; the remaining vocabulary +is a design decision, not a claim that it is already implemented. + +## 4. Decision: owner-installed hooks observe committed events + +Hooks are signed, typed subscriptions in the board graph. Only the +board-root owner may install, update, disable, or remove them. Each +change is another signed event; a hook cannot rewrite or erase its +history. Board moderators cannot install hooks in v1. + +The allowed event set and triggers are: + +| Event | Trigger | +| --- | --- | +| `board.post.created` | A signed post is accepted into the board graph. | +| `board.report.received` | A configured endpoint accepts a report; host-local, not replicated. | +| `board.embed.changed` | A signed board event changes an embed's board-local presentation state. | +| `board.moderation.committed` | A valid board moderation action is accepted. | +| `board.role.changed` | An owner-signed moderator grant or revocation is accepted. | +| `board.appeal.filed` | A signed appeal referring to a moderation action is accepted. | +| `board.appeal.decided` | A signed appeal outcome is accepted. | + +Every event has a stable ID, board and target references as applicable, +event type, signer key when applicable, and the causal frontier. Events +are emitted only after signer validation, any required board authority +proof, and graph-reference validation. They omit report/appeal free +text and source-object contents. +The local report event is delivered only to the configured moderation +service and its authorized recipients; it is not broadcast to board +replicas. + +Hook rules are structured filters over this allowlisted event data, not +arbitrary code. A hook may notify an already-authorized audience, route +a report to the board moderation inbox, or add a non-binding review +flag. It cannot hide, remove, restrict, ban, freeze, lock, grant a role, +decide an appeal, invoke another hook, or call privileged APIs. An +authorized human must sign a separate board action. Hook delivery is +at-least-once with stable event IDs for deduplication; a missed or +duplicated notification cannot change board state. + +## 5. Decision: reports are private cases; action audit is public graph + +There are two separate reporting destinations: + +1. **Board report.** A reporter sends the board ID, target post, + attached-object, or embedded-presentation reference/version, + structured reason category, and optional plain-text context to the + board's configured moderator contact/service. The receiving service + keeps a private case record for its assigned board moderators; it is + not a canonical board object or replicated authority. If no board + report service is configured or reachable, the client says so and + does not pretend a report was filed. +2. **Platform/server report.** A separate action sends a minimal target + reference and reason category to that host's moderation service. + It is governed by that service's own authority and visibility + policy, not by board roles. Nothing is automatically copied between + the two destinations; a reporter may explicitly submit to both. + +The private case record contains a case ID, board and target +references, reporter verifying key, receipt time, category, optional +context as data, status, reviewer, and links to any signed moderation +action or appeal. It does not copy the target object's contents. Board +moderators see only the board presentation and their ordinary read +rights. The entire private case record—including metadata, identity, +status, links, evidence, and text—is retained for 90 days after final +resolution, including a resolved appeal, then deleted from that +service. A case with no final decision auto-closes as +`expired_unresolved` after 180 days without activity, or after one year +from creation regardless of activity, whichever comes first; its +complete private record is purged 90 days after closure. An appeal may +remain pending in the public graph after the private-record cap; only +its private case data expires. A later submission of appeal context +creates a new private record with a fresh retention clock; it never +restores purged data. Opening a case does not itself hide a post or +change its projection. + +The audit is the public, append-only signed board graph described by +#2054, not a private mutable service log. It includes every role +attestation and moderation action, including superseded or ineffective +actions, with the signer key, board/target references, role proof and +frontier, action kind, causal links, and optional reason. Appeal and +appeal-decision events expose their signer, target action, time, and +structured outcome; any free-text appeal context stays in the private +case service. The log is public by design and has no expiration: once +replicated, signed history cannot be recalled. Hosts may independently +decline to serve it under their own policy, but that is not board +authority. + +Any user-supplied report or appeal context, and any optional free-text +action reason, is inert data. It is stored as plain text and rendered +with normal output escaping; no consumer evaluates it as Markdown, +HTML, a template, query, command, regular expression, hook rule, or +program, and no link preview or remote fetch is triggered. Private +report text is never included in the public graph or hook event. + +## 6. Decision: signed appeals with no global board arbiter + +The author whose post or board-local access is affected may file one +signed appeal against a moderation action. The appeal references the +action and target, states a structured outcome requested, and may +include optional private text sent through the report service. Its +public graph event makes the appeal's existence and target auditable +without publishing that text. A 30-day filing target is advisory only: +a signed graph cannot prove when a person saw an action, so no peer +rejects an appeal based on an unverifiable “seen at” time. + +An appeal is reviewed by the board owner or a current moderator other +than the author of the challenged action. The action's author cannot +review their own appeal, including when the author is the board owner. +A reviewer who upholds, changes, or reverses an action signs a new board +action and a public appeal outcome; no record is edited in place. If no +independent reviewer is available, the appeal remains visibly pending. +The owner may appoint a moderator to review an owner-authored action, +but may not sign that appeal's outcome. A public board has no +platform-wide authority that can overrule its signed graph. The +appellant may instead apply a personal hide or fork the board; a host +may withhold content locally, without changing the board's outcome. An +appeal does not grant access to the underlying object. + +## 7. Invariants implementation must hold + +- **I1 — Attributable authority-bearing signing session.** Every board + moderation action and appeal is produced by a signing operation that + controls the actor's verifying key and proves owner-root or moderator + authority at its signed frontier. The event signature and authority + proof are the durable attribution; no client-supplied actor ID or + ephemeral session ID is accepted as proof. This is board-graph + authority, not #835 world-session scope. +- **I2 — Board-scoped authority.** A moderator role is an owner-signed + grant for one board. A role or action on one board grants nothing on + another board, host, or world session. +- **I3 — Valid-at-frontier actions.** Each action carries the owner or + moderator authority proof and causal frontier it used. Revocation + cannot erase a valid prior signature; corrections are explicit later + events. +- **I4 — Hooks cannot widen authority.** Hooks observe only validated + events and produce only the non-binding outputs in §4. They never + execute moderation actions, grant roles, or transfer authority. +- **I5 — Report data is inert.** Reported content, report context, + appeal text, and free-text reasons are data and are never executed + or evaluated as code, markup, templates, queries, or hook rules. +- **I6 — Public audit is append-only.** Board actions remain signed, + attributed, and visible in the graph even when superseded or + ineffective. No moderator or host can erase another host's copy. +- **I7 — No read or enforcement widening.** Board moderation changes + only board projection; it cannot expose more of the source object, + stop its author publishing, or compel another host or reader. +- **I8 — Deterministic projection.** Role proofs, action supersession, + and view results resolve from signed causal references, not wall + clock, arrival order, or one host's current state. +- **I9 — Appeals are attributable.** Appeal outcomes are new signed + events and cannot be decided by the actor who authored the + challenged action. + +## 8. Parent decisions consumed; explicit correction recorded + +This record refines #2054's proposed public signed graph, +board-scoped `RoleAttestation`, immutable moderation history, and +separation of board, host, and personal views. It does not re-decide +#5680's sharing flows, portable themes, playable-post safety, or +discussion surface. It resolves #5680's open moderator-read question +in §1. It also makes two moderation choices not settled in #2054: a +valid action remains effective after a later role revocation, and +`Restore` links to one specific `Hide` instead of using a count-based +balance. These choices are explicit implementation changes from the +current `boards.rs` substrate. + +The parent integration correction is the #835 cross-reference: +world-session `BUILDER`/`MODERATOR` capabilities are not board +authority. #835 remains unchanged; board moderation uses the signed +board roles. This is stated rather than silently forking the two +systems. #5680's example of slow mode is also narrowed: volume control +remains host resource policy, as #2054 specifies, rather than a signed +board authority. If the parent intended a different cross-domain or +slow-mode contract, it must be explicitly reconciled before +implementation. + +## 9. Rejected alternatives + +- **Use #835's world-session `MODERATOR` bit as a board role:** rejected + because #835 authorizes world operations, not board graph actions; + the two scopes have different principals and effects. +- **Make a host or platform the canonical board moderator:** rejected + because a host may control only its own availability, not other + replicas or the signed graph. +- **Hide or erase moderation history, or keep it in a private mutable + audit log:** rejected because #2054 requires public attribution and + append-only evidence; a view hide is not deletion. +- **Let revocation retroactively cancel signed actions or let every + client independently distrust a moderator:** rejected because a + valid role proof at the action's causal frontier is stable evidence; + later correction is another signed action, while personal distrust + belongs in the reader's personal overlay. The older board-model + investigation floated the latter as an option, not a settled + decision. +- **Put free-text reports in the public graph:** rejected because + replicated signed history cannot honor case-text expiration and may + reveal private reporter context. Only action and appeal metadata are + public; report/appeal text is private and expires. +- **Let hooks execute arbitrary code or take punitive actions:** + rejected because untrusted board content and event handlers must not + become a new authority or execution surface. +- **Treat a board view-ban as a global ban or source deletion:** rejected + because board projection cannot compel writers, hosts, or other + readers. + +## 10. Scope and implementation gate + +This is a design record only: it adds no moderation code, hook runner, +report service, or storage. The current `pkgs/id/src/boards.rs` +substrate has a board-scoped `Moderator` attestation and `Hide` / +`Restore` actions, but no hook, report, or appeal event types. Its +validator accepts an action if any granted role attestation exists; +its projection rechecks the current moderator set; and its hide balance +does not link a restore to a particular hide. The action record also +lacks the role-proof/frontier required here. Validation, projection, +action encoding, and tests must all change; these are implementation +gaps, not claims of existing behavior. + +Implement only against the signed board graph and the invariants above. +Any proposal to reuse #835 world authority, add global takedown, or +change #5680's sharing/theme/playable-post decisions must be surfaced +as an explicit parent/design change first. + +## References + +- [Issue #5861](https://github.com/developing-today/code/issues/5861), + [parent #5680](https://github.com/developing-today/code/issues/5680), + and [programme epic #2056](https://github.com/developing-today/code/issues/2056). +- [Issue #835](https://github.com/developing-today/code/issues/835) and + [its world-session authority design](2026-11-01_design_id835.md). +- [Boards v1 design #2054](2026-11-01_design_id2054.md), especially + §3 and its moderation invariants. +- `doc/2026-10-30T19-35-00Z_investigation_boards_model/` records, at + lines 165–169, the earlier tentative client-distrust suggestion + superseded by the decision in §§2 and 8. +- [`pkgs/id/src/boards.rs`](../pkgs/id/src/boards.rs#L187-L233) for the + current owner/role/action vocabulary; + [`RoleAttestation` validation](../pkgs/id/src/boards.rs#L700-L720), + [moderator action validation](../pkgs/id/src/boards.rs#L893-L923), + and [moderation projection](../pkgs/id/src/boards.rs#L1323-L1425) + for the current authority-frontier and hide/restore behavior.