diff --git a/doc/2026-11-08_design_id5871.md b/doc/2026-11-08_design_id5871.md new file mode 100644 index 0000000000..9a76f6fb73 --- /dev/null +++ b/doc/2026-11-08_design_id5871.md @@ -0,0 +1,142 @@ +# Design: talk-page semantics — lifecycle, permissions, and binding authority + +- Date: 2026-11-08 +- Status: **design** — records a decision only; no implementation code, no protocol change beyond what #5872 already fixed. +- Issue: [#5871](https://github.com/developing-today/code/issues/5871), “id: design: talk-page semantics (from #5682)”. +- Parent: [#5682](https://github.com/developing-today/code/issues/5682) §2 (talk-page semantics). Programme: epic [#2056](https://github.com/developing-today/code/issues/2056). +- Fixed by a sibling, not re-decided here: [#5872](https://github.com/developing-today/code/issues/5872) decision record (2026-11-05) — a talk page **is** a chat conversation whose log carries a `chat.anchor.v1` *talk-for* binding; one canonical binding per object, first valid in causal order, later conflicts fold to a visible **disputed** state. That record explicitly assigns *binding authority* and the *visibility-intersection rules* to this one. + +## 1. Decision to make + +#5682 §2 fixes what a talk page **is** and leaves four semantics open: + +1. **Creation** — one canonical talk page per object, created lazily on first discussion, or eager (present, empty) from object creation? Storage and privacy cost of each? +2. **Lifecycle** — archive with the object, follow ownership transfer, and what happens on object tombstone/delete. +3. **Permissions vs the object's read-authority** — intersection, object-owner-decides, or thread-owner-decides-with-warnings, with the hard rule that a talk page never leaks a private object's content **or existence**. +4. **Moderation and binding authority** — object-owner rights (lock/close/pin) versus server moderation (#835), and who may bind the talk page. + +**Decision, in one paragraph.** A talk page is **created lazily** — it exists only as the `talk_for` binding on the first signed post, so an untouched object costs zero storage and zero discoverable surface. It **follows the object through archive and ownership transfer**, and on object tombstone the conversation is **preserved, never cascade-deleted**, with the anchor folded to an `orphaned` state that is invisible from the dead object. Readability is the **intersection** of object read-authority and conversation membership, and the intersection is **narrowing-only**: an object owner may restrict who sees the talk page but can never widen it past the object's own read-authority. Moderation is **split**: the object owner holds *governance* rights (lock, close, pin, announce, slow-mode) as signed events, while server moderation (#835) retains *takedown* authority over content for abuse and legal reasons. Only the **object owner** (or a delegate the owner names by signed event) may issue a binding. + +## 2. Context and evidence + +### What exists at current main + +- **Conversations are channel groups with signed, chained events.** `pkgs/id/src/chat.rs` defines `chat.message.v1` authorship by signing key, causal order by the `after` frontier with a deterministic author-backlink/event-ID tie-break, and `ChatLink` with exactly two kinds — `Blob` (BLAKE3 hash) and `Event`. A link names content by hash plus author and **never embeds a capability** (`pkgs/id/src/chat.rs:65-105`). +- **Access is a group-policy question, not a chat question.** `pkgs/id/src/groups/policy.rs` carries the join-visibility axis as `History { Full, Recent(u32), FromJoin, Causal }` (`:232-245`), with only an `Admin` able to change roles or the policy record (`:254-260`) and `Recent(0)` rejected as unusable (`:330-336`). There is no per-object ACL in this file; object read-authority enters through membership, which is exactly the seam this design has to use. +- **The anchor vocabulary and part-selectors belong elsewhere.** #5870 owns anchor grammar and drift; #5872 already added the third `ChatLink` kind (`object`) and the `chat.anchor.v1` event. This record consumes both and must not fork them. + +### What the fixed context already answers + +#5682 §2 states the talk page “shar[es] its identity and its read-authority unless explicitly overridden”, that talk-page moderation “follows the object's moderation context”, and that notification/watch is per object. #5872 fixes one canonical binding plus a disputed fold, and says conflict is visible on all replicas rather than silently forked. Nothing in either record requires eager creation, a separate store, or a second permission system. + +## 3. Options and trade-offs + +### 3.1 Creation + +| Option | Benefits | Costs / why not chosen | +| --- | --- | --- | +| **A. Lazy — a `talk_for` binding appears with the first post** (chosen) | Zero storage and zero discoverable surface per untouched object; “has a talk page” is an index/fold question, not a row; no empty-group spam at ID's object scale; private objects cost nothing while undiscussed. | The object view must distinguish “no talk page” from “talk page with no visible threads” only after the binding exists; needs the anchor index (#5872 §5: indexes are application-layer). | +| B. Eager — every object carries an empty talk page from creation | Simpler object view; uniform code path. | A row/group per object at ID scale, most empty; every object's existence gains a second artifact, which enlarges the leak surface for private objects; still needs lazy semantics for objects created before the model. Rejected. | +| C. Lazy but pre-registered by the object creator | Predictable URLs/naming early. | Registers a discussion artifact on behalf of a possibly-nonexistent audience and lets a third party claim a page before any discourse exists; conflicts with “first post makes it real”. Rejected. | + +### 3.2 Permissions model + +| Option | Benefits | Costs / why not chosen | +| --- | --- | --- | +| **A. Intersection — readable iff reader can read the object *and* is a conversation member; narrowing-only owner control** (chosen) | Never widens past object read-authority by construction; composes with group `History`; a thread can be narrower than the object but never wider; the leak rule is a theorem rather than a review checklist. | More restrictive than participants may expect when a reader gains object access but not membership (mitigated: joining the read set is a membership grant, §4.2). | +| B. Object-owner-decides | One accountable party; simple to explain. | Makes the object owner a censor of readers who already see the object, and lets a new owner silently widen a historical conversation. Rejected. | +| C. Thread-owner-decides-with-warnings | Maximally permissive; matches “warn, don't block” UX. | Warnings are not enforcement; a thread owner can expose a private object's discussion to a non-reader by definition of the leak rule. Rejected. | + +### 3.3 Moderation and binding + +| Option | Benefits | Costs / why not chosen | +| --- | --- | --- | +| **A. Split — object owner governs structure (lock/close/pin/announce/slow), server moderation (#835) may take down content, binding by owner or owner-named delegate** (chosen) | Keeps the discussion attached to the thing governed; keeps host-level abuse/legal authority where the #835 machinery already lives; every action is a signed event, auditable. | Two authorities must agree on vocabulary (§6 invariant 6); requires moderation events to be first-class rather than deletions. | +| B. Object owner holds all moderation including delete | Single authority. | Gives an object owner the power to erase another author's signed history, which contradicts #2036's chained-permanent immutability and #2051 authorship. Rejected. | +| C. Server moderation governs talk pages outright | One escalation path. | Detaches talk-page governance from the object, contradicting #5682 §2's “follows the object's moderation context”. Rejected. | + +## 4. Decision detail + +### 4.1 Creation: lazy, binding-on-first-post + +1. An object has **no talk page** until some member posts with a `talk_for` binding in the same causal step (the binding event may precede the first message by one event). “Has a talk page” means “the anchor index holds a canonical `talk_for` binding for this object” — an index over logs (#5872 §5), never an object field. +2. Discovery is **gated by read-authority**: an object view shows a talk-page affordance and thread count only to a reader who may read the object. Non-readers see nothing — not a count, not a badge, not a disabled control, and never an error that would confirm the page exists. +3. Storage cost of an undiscussed object is **zero**; the cost of a discussed object is exactly one conversation log, which is the v1 chat cost. +4. A client may offer “start the discussion” on any object it can read; the first signed post creates the binding under §4.4 authority. There is no pre-creation and no reserved page. + +### 4.2 Permissions: intersection, narrowing only + +1. **Read rule (hard):** `can_read(talk_page) = can_read(object) ∧ is_member(conversation)`, evaluated at read time. Neither side alone is sufficient. +2. **Membership is the object's read set, projected.** A member is a key that currently holds read-authority over the object (owner, direct grantee, or member of a group the object names). Granting object read-authority therefore makes a key eligible to join; it does not retroactively inject them into a conversation they never joined. Revoking object read-authority removes membership and its future reads. +3. **Cross-object threads** intersect over **all** anchored objects: a thread anchored to two objects is readable only by keys that can read both. Any anchor added to a thread can only narrow it; adding one never widens an existing thread (invariant 3). +4. **Narrowing-only overrides.** The object owner (and, for a thread, its creator within the object's audience) may restrict visibility further — e.g. a members-only thread inside a public object's talk page. No override may admit a key that fails rule 1. An override is a signed policy/binding event, visible to every reader of the thread. +5. **No existence leak (hard).** For a key that cannot read the object: no talk-page listing, no thread count, no unread badge, no anchor backlink from any readable object, and no distinguishable “permission denied” response — the surface is absent, as if no page existed. This is the rule #5682 §1 states for anchored threads and it applies here verbatim. +6. **Where a narrowing override conflicts with the object's own read set** (owner narrows, then grants object access to someone outside the thread): the thread simply remains invisible to the new grantee. No warning is required, because nothing leaks; the UI may say “some discussions are restricted” at the talk-page level without naming them. + +### 4.3 Lifecycle + +1. **Follows the object, never owns it.** The conversation's identity and history are independent of the object's version; an object edit never rewrites the log (the anchor may re-locate under #5870, which is drift, not lifecycle). +2. **Archive with the object.** When the object is archived, the talk page becomes **read-only architecturally**: posting is refused at admission with a typed “object archived” error, not hidden client-side. Unarchiving restores posting. Existing threads stay readable under §4.2. +3. **Ownership transfer.** Transfer of the object moves **binding and governance authority** to the new owner by definition, not by re-bind. The canonical binding does not change, so no disputed state is induced by a transfer. The new owner may re-delegate (§4.4). Prior moderation events remain in force and visible. +4. **Object tombstone / delete.** The conversation is **preserved and never cascade-deleted** — it is a chained-permanent log (#2036) authored by many keys, and deletion would erase other people's signed words. Instead: + - the `talk_for` binding folds to `orphaned` (a derived state, not a new event); + - the object-side entry point disappears entirely, so nobody reaches the page *through the object*; + - existing members keep the conversation and can still read it, but no new member can be admitted via the object, and no new anchor to the dead object is accepted; + - a re-created object with the same identity does **not** silently re-adopt the orphaned page; re-adoption requires a fresh binding by the new owner, and the old page stays orphaned. This avoids resurrecting a conversation across a delete/recreate boundary that others may not expect. +5. **Talk pages all the way down — cut here.** A conversation may be anchored to another conversation as *about*, but a `talk_for` binding whose target is itself a conversation is **rejected at admission**. Discussion of a talk page is a reply in that talk page, not a nested page. Recursion depth is exactly one, enforced by the target check (invariant 5). + +### 4.4 Binding authority + +1. **Who may bind.** Only the object's owner key, or a delegate the owner names by a signed `chat.anchor.v1`-family delegation event that names the delegate and the object. Delegation is revocable by the owner; revocation affects future bindings only. +2. **One canonical binding.** First valid binding in causal order wins; a later valid-but-conflicting binding by an authorized key folds to **disputed** and is visible on every replica (#5872). A binding by an unauthorized key is **rejected at admission** and never enters the log — the disputed state is for legitimate disagreements, not for spam. +3. **Rebinding after transfer** is not required and would create a pointless disputed state; authority moves with the object (§4.3.3). +4. **Server moderation may unbind** a binding that violates host policy (impersonation, illegal content). Unbinding is a signed moderation event, leaves the conversation intact, and leaves an auditable trail. It is not a delete. + +### 4.5 Mapping onto group membership and `History` + +This is the part #5872 delegates explicitly, and it resolves against the code that exists: + +1. **Membership = the object's read set.** The talk-page group's member list is not authored independently; it is the projection of object read-authority (§4.2.2). Because only an `Admin` may change roles or policy in `policy.rs`, the projection is implemented as an **authority that the object's policy drives**, not as a second, independently-administered roster. A group that names a different membership source than the object is a misconfiguration the implementation must reject. +2. **`History` default is `Full` for unconditional audiences** (public object, or a group whose membership is stable and already public): a reader sees the discussion that shaped the object, which is the point of a talk page. +3. **`History::FromJoin` is required when object read-authority is granted per key** (direct grants, invitation-only objects, anything whose read set can shrink). A key admitted to a private object later must not retroactively learn discussion from before their access; `FromJoin` is the existing mechanism that expresses this and needs no new code. +4. **`Recent(n)` is permitted only to tighten a `FromJoin` page further**, never to replace `Full` on a public object, so a public talk page cannot develop invisible history. +5. **`Causal` remains deferred** as in `policy.rs`; this record does not use it. +6. **Revocation cannot un-deliver.** A key that read a message before its object access was revoked retains what it saw. The design says so plainly rather than pretending otherwise; the mitigation is key rotation and prompt membership removal for per-key-granted objects, and the key-distribution mechanics are #5801's, not this record's. This is the one honest limitation of intersection semantics. + +## 5. Alternatives rejected (summary) + +- **Separate talk-page store or entity** — forks moderation, search, presence and the terminal client; contradicts #5682 §2 and #5872. Rejected. +- **Eager empty page per object** — storage and leak surface at ID scale for no discourse. Rejected (§3.1 B). +- **Object-owner-decides or thread-owner-decides permissions** — permits widening past object read-authority, which the leak rule forbids. Rejected (§3.2 B/C). +- **Cascade-delete the conversation with the object** — destroys other authors' signed history; incompatible with #2036 chained permanence. Rejected (§4.3.4). +- **Re-adopting an orphaned page on object re-creation** — silently revives a conversation across a delete boundary. Rejected (§4.3.4). +- **A nested talk page for talk pages** — unbounded recursion with no product need. Rejected at admission (§4.3.5). +- **Content deletion as the moderation primitive** — replaced by signed takedown events that preserve the log (§3.3 A). + +## 6. Invariants an implementation must hold (testable) + +1. **Intersection is enforced at read time.** For every message, a reader sees it iff they can read the object **and** are a member; a test that grants object access without membership (and vice versa) sees nothing. +2. **No existence leak.** For a non-reader of the object, the talk-page API and UI are indistinguishable from an object that has no talk page — equal response shape, equal timing class, no counts, no badges, no backlinks. +3. **Narrowing-only.** Adding an anchor to a thread, or applying an owner override, never increases the set of keys that can read any existing message. Property test: `readers(after) ⊆ readers(before)` for every narrowing operation. +4. **Lazy equivalence.** A projection of a log with no `talk_for` binding is byte-identical to the pre-#5871 object view; an object with no discussion exposes no talk-page artifact anywhere. +5. **Recursion depth one.** A `talk_for` binding whose target is a conversation is rejected at admission with a typed error; a conversation may still be *about* another conversation. +6. **Preservation.** Deleting or tombstoning an object never removes a message event; the only observable change is the derived `orphaned` state and the disappearance of the object-side entry point. +7. **Authority determinism.** Binding state — canonical, disputed, unbindable, or unauthorized-rejected — is a pure fold over the log under #5872's causal order and event-ID tie-break; all replicas converge, including on disputed and orphaned states. +8. **Archive is architectural.** A post to a talk page of an archived object is refused at admission with a typed error and appears in no replica; unarchiving restores acceptance without re-binding. +9. **History mapping is total.** Every talk-page group resolves to exactly one `History` value from §4.5, chosen from the object's read-authority kind; an unresolvable or contradictory configuration is a hard error, not a default. + +## 7. What this changes for the parents and siblings (stated explicitly) + +- **#5682 §2** — preserved. Talk page remains a conversation; nothing here introduces an entity or a store. *Refined, not contradicted:* “sharing its read-authority unless explicitly overridden” is read as intersection with narrowing-only overrides (§4.2). If #5682 instead intends “anyone who can read the object reads every thread regardless of membership”, that is a parent change and must be recorded there — this record does not make it silently. +- **#5682 open questions** — the lazy/eager question, the visibility question, and the moderation-authority question are answered here (§4.1, §4.2, §3.3/§4.4); the recursion question is answered by the depth-one cut (§4.3.5); anchor drift stays #5870's. +- **#5872** — unchanged. Its one-canonical/disputed rule stands; this record supplies the binding authority it delegated (§4.4) and the visibility intersection it delegated (§4.2). +- **#5870** — unchanged; this record consumes its part-selectors by reference and adds no grammar. +- **#835** — unchanged; server moderation gains an unbind/takedown *event* surface, not a new authority. +- **#5873/#5874/#5875** — untouched (rendering, resolved-into, notifications). Resolution markers remain #5874's; a resolved thread is a thread-level annotation over the same log. +- **Implementation timing** — separate and gated, as #5682 states; nothing here schedules code. The nearest implementation seams are `pkgs/id/src/chat.rs` (third link kind already decided by #5872; binding event decode), `pkgs/id/src/groups/policy.rs` (`History` mapping, §4.5), and the anchor index (#5872 §5). + +## 8. Open questions this record deliberately leaves + +1. **Index projection cost** — the anchor index that answers “does this object have a talk page” is application-layer (#5872 §5); its storage and refresh cost at ID's object scale is an implementation question, not a semantic one. +2. **Cross-object thread admission UX** — the intersection over all anchors is decided; how a client explains “you can see this thread because you can read both objects” is presentation (#5873). +3. **Delegate discovery** — owner-named delegates are decided; whether delegates are enumerable to non-owners is a privacy choice deferred to the #835/notification work.