diff --git a/doc/2026-11-08_design_id5856.md b/doc/2026-11-08_design_id5856.md new file mode 100644 index 0000000000..113a25033c --- /dev/null +++ b/doc/2026-11-08_design_id5856.md @@ -0,0 +1,356 @@ +# Design decision record: post-to-board flow & post semantics + +Issue: #5856 (follow-on design from parent #5680, decomposition item 1). +Programme: epic #2056. Boards v1: #2054. Status: decided (this record), +2026-11-08. Implementation is a separate, later decision — this record +settles the shape only, per the parent issue's filing note. + +Baseline: `origin/main` at `1f5ac11276` (code claims re-verified +2026-11-08; the first draft used `2b3ca04ac8`), worktree `~/git/fleet/10259`. +Verified at that baseline: `pkgs/id/src/boards.rs` implements the signed +board graph (board root, rules, forum, thread, post, attachment, +membership, role attestation, moderation action, fork, supersede, +tombstone, theme, board listing) and the three-layer view, but has **no +cross-board or off-board post source of any kind** — `Post` carries +`board`, `thread`, `parent_post`, `body`, `attachments`, `embed_ref` +only. `embed_ref` is a `GamePostRef` validated by +`BoardGraph::require_scoped` as a same-board `Post`, so it cannot carry +a foreign object. No design record for post-to-board semantics exists on +main (`git grep -il 'post-to-board' doc pkgs/id` returns nothing), and +no open PR implements one. + +## Scope and non-goals + +This record settles the general sharing flow the parent issue's §1 names +for **any** source object — a knowledge-layer note/page, a file, a chat +artefact, or a post already on another board — and the semantics that +travel with the resulting post. + +Not settled here, and not re-decided: + +- **Note→board sharing** is already decided by [#5830](https://github.com/developing-today/code/issues/5830) + (`doc/2026-11-08_design_id5830.md`, PR [#7581](https://github.com/developing-today/code/pull/7581)): + a signed post carrying `{note_id, pinned_revision_id}`, live render + with a visible pin, replies anchored to revisions. This record gives + that decision its general envelope (Decision 2) and does not alter it. +- **Curated-board intake**, approval queues, intake notifications: + [#5857](https://github.com/developing-today/code/issues/5857). Whether a + post lands immediately or waits for approval is that ticket's answer; + Decision 2's last bullet only states where the decision hooks in. +- **Theme format and precedence**: [#5858](https://github.com/developing-today/code/issues/5858). +- **Embed contract for live objects**: [#5859](https://github.com/developing-today/code/issues/5859). +- **Moderation roles, reports, audit, appeals**: [#5861](https://github.com/developing-today/code/issues/5861) on [#835](https://github.com/developing-today/code/issues/835). +- **Subscription, discovery, feed**: [#5862](https://github.com/developing-today/code/issues/5862) + (PR [#7586](https://github.com/developing-today/code/pull/7586)). This + record produces post references; the feed consumes them unchanged. + +Three further things this record deliberately does not do: it does not +change any #2054 v1 object (Board/Post/Thread/…) semantic, it does not +grant boards any power over objects they reference, and it does not +introduce a second identity or signature system. + +## Decision 1 — A post has a typed, signed source; the default is a pinned reference + +Every post may carry an optional `source` — a typed reference to the +object it is about — alongside its own body. The source is data in the +signed body, never a URL, a host pointer or a wholesale embedded copy of +the target's content; the one piece of target-derived text it may carry +is a bounded quotation (`excerpt`), and that quotation is gated by +target authority (see Decision 2). + +```text +Post.source: Option +PostSource { + target: RefTarget, // one of the enum arms below + pin: Option // exact revision/object version at share time + presentation: Full | Excerpt | LinkCard, + excerpt: Option, // target-derived quotation, gated (Decision 2) + commentary: Option, // the sharer's own words, always visible + widening: Option // present only when this share widens audience (Decision 2) +} +TargetQuotation { + text: String, // the quoted span, copied from the pinned revision + attribution: String // who wrote the quoted span; derived, never asserted by the sharer +} +RefTarget = BoardObject { hash: ArtifactHash, board: ArtifactHash } + | Note { note_id: String, revision: Option } + | Blob { hash: ArtifactHash, media_type: String } + | ChatArtefact { message: ArtifactHash, conversation: ArtifactHash } +``` + +- **The pin is the citation of record.** `pin` names the exact immutable + version that was current when the post was made — a board-object hash, + a note revision (#2048), a blob hash. It never changes after the post + is signed. Rationale: without a pin, every later edit to the target + silently rewrites what a board actually displayed, and moderation, + audit and quotes lose their referent. +- **The live view is a reading convenience, not the record.** A reader + of the post may be shown the target's current version, but only with + the pin one step away and an explicit "updated since posted" badge + when the two differ. That is #5830's rule (§2 of its record), applied + unchanged to every target kind rather than re-invented per kind. +- **`presentation` is authorial, not a copy mode.** `Full` renders the + whole target; `Excerpt` renders a bounded quotation the sharer + selected; `LinkCard` renders title/type/author only. All three still + carry the reference and the pin. `Excerpt` requires a non-empty + `excerpt`; `Full` and `LinkCard` carry none, so the mode and the + material cannot disagree. +- **Target-derived quotation is not commentary.** `excerpt` holds the + quoted span and `commentary` holds the sharer's own words; they are + separate fields because they have different authority. `excerpt` is + the target's content at second hand: it is withheld from any reader + who lacks read authority on the target, and the target's withdrawal + suppresses it exactly as it suppresses the live render (Decision 2, + Decision 4). Keeping it in `source` rather than in `body` is what + makes that withholding possible — a quotation pasted into the body + would inherit the body's unconditional visibility, and suppressing + only the renderer would leave the quote readable. `commentary` is the + sharer's own speech and stays visible, with the reference and the + unavailable state, when the target is unreadable. +- **Snapshot-as-default is rejected** (see the alternatives table) + because it severs provenance and makes withdrawal unenforceable. A true independent copy is a + *different* act ("copy into board ownership"), which this record does + not provide in v1; see the alternatives table. +- **Compatibility:** `Post` is `#[serde(deny_unknown_fields)]` and + `BoardObject::from_artifact` re-serializes to compare canonical shape, + so a new field is a schema change, not an additive detail. Implement + it exactly as `Board::theme_ref` was added: a `#[serde(default, + skip_serializing_if = "Option::is_none")]` field, so posts written + before the field existed decode as `None` and keep verifying. + +## Decision 2 — Posting requires read authority on the object and posting rights on the board + +- **Two independent gates.** To post a reference: (a) the sharer must be + able to read the target, and (b) the sharer must be allowed to post on + the target board. Either failure is a refusal, not a degraded post. + Neither gate implies the other: board posting rights never make a + private object readable, and note read authority never grants board + writing. +- **A post never widens the target's read audience.** The parent's rule + (its §1) is adopted as this record's first invariant and applies per + reader, at render time: a reader who may read the board but not the + target sees the post's body and `commentary` plus an explicit + "referenced content not available to you" state — never the target's + title, excerpt, thumbnail or revision count, and never + `source.excerpt`. +- **Widening is explicit, signed, narrow and revocable.** If the sharer + *is* the target's owner and chooses to make the post readable without + the target's own grant, the post carries `widening: WideningConfirm` + signed by the owner, naming the single board it applies to. It is not + transferable, does not create a grant on the object, and is withdrawn + by the owner's withdrawal event (Decision 4). A sharer who is not + the owner cannot widen, and a board owner cannot widen on someone + else's behalf. +- **Cross-owner posting is allowed, attribution is implied.** Anyone who + can read a target may post it to a board they may post to; the post's + author is the sharer, and the target's author is derived from the + referenced object, never asserted by the post. Presenting the target's + author as the poster of the board post is a rendering bug, not a + permitted shortcut. +- **Posting on a curated board** routes through #5857's intake decision + before it becomes visible; this record only requires that the pending + post is a real signed post (so provenance is fixed at submission, not + at approval). + +## Decision 3 — Board-to-board reposting is a chain of signed references + +- A repost is a new post on another board whose `source` names the + source **post** (`BoardObject` arm, `pin` = that post's hash) and + optionally adds the reposter's commentary. It is not a mutation of the + original post and not a re-signing of someone else's body. +- **The attribution chain is derived, not authored.** Original author → + original board → each sharer/reposter in turn is computed by walking + signed `source` references. No field on a post can *claim* a chain, so + a repost cannot launder authorship, and a client cannot be told a + different lineage than the graph shows. +- **Commentary never replaces commentary.** A repost carries the + original post's commentary as quoted context and its own commentary + separately; a repost cannot strip or rewrite the original words. This + is the parent's "original post commentary or the reposter's" open + question answered as **both, in separate fields**. +- **The chain must be acyclic.** A post may not cite an ancestor of + itself as `source`; insertion rejects a cycle the same way + `BoardObject::Supersede` already rejects one (`board graph` cycle + check in `validate_links`). Cycles would otherwise make "the original" + undefined and let a chain forge its own lineage. +- **Reposting requires read authority on the source post's target**, not + merely on the source post. A reader who can see a `LinkCard` in a + public board but cannot read the underlying object may still repost + the *card* (it discloses nothing beyond what they can already see) but + the new post inherits the same unavailable state; it must not upgrade + to `Full` presentation, and it must not attach an `excerpt` — an + excerpt is target content the reposter cannot read. +- Presentational depth collapsing (showing "via A via B") is a rendering + choice; the protocol sets no depth limit, but Decision 4's withdrawal + propagation means no depth survives the original's withdrawal. + +## Decision 4 — Withdrawal and revocation act on projections, and reach descendants + +- **The target's owner can withdraw it from every board it was posted + to.** A signed withdrawal event by the target's author, naming the + reference/posts it withdraws, is the mechanism. It is a signed graph + object (like a tombstone), not a board action, and needs no board + owner's consent. +- **Withdrawal is total for the author's own object and propagates to + reposts.** At the next render, the withdrawn post stops rendering its + target's content, and every descendant post in its `source` chain + degrades identically. A repost cannot outlive the original's + withdrawal — otherwise reposting is an escape hatch from it. +- **Nothing is erased.** The post, its commentary, the withdrawal event + and the chain stay in the graph and in the moderation/audit history + (#2054's transparency rule). The board's projection stops rendering + the content; a host still serving the underlying object is making a + statement about that host, not about the board. +- **Board moderation and author withdrawal are separate powers.** + A board's moderators may hide the *post* in that board's view (#2054 + board layer, #5861's roles); they cannot withdraw someone else's + object from other boards, cannot erase the withdrawal record, and + cannot force another host to stop serving. An owner's withdrawal is + not a moderation action and does not depend on board authority. +- **Post-side edits keep the identity and the pin.** `source.target` and + `source.pin` are immutable for the life of the post: a superseding + version must re-state both unchanged, and re-pointing a post at a + different target or a different pin is a new share event, never an + edit — otherwise "what was shared" is mutable after the fact. The + other `PostSource` fields are authorial and supersede normally: + `presentation`, `excerpt` and `commentary` may change, and a + `widening` confirmation may be added by the target's owner. + Immutability is scoped to identity-and-pin so that the permitted edits + are not rejected by the rule that protects the citation. + +## Decision 5 — Notifications, intake and feed are other tickets' decisions + +This record produces exactly one thing each of the neighbours consumes: +a signed post with a typed, pinned, attributed source. + +- Who is notified (board owner, board subscribers, target owner) and how + it is muted: #5862's `notify_mode` on subscriptions, plus #5857's + intake events. Not re-decided here. +- Where the post surfaces: #5862's feed, as a reference rendered under + this record's semantics. #5862's record already says a feed item + "renders under the post semantics #5856 settles"; that hook is now + filled by Decisions 1–2 and needs no change there. +- Whether an open board posts immediately: #5857. + +## Invariants implementation must hold + +1. **No authority widening.** Reading a post never grants read authority + on its target. The only widening path is an owner-signed + `WideningConfirm` scoped to one board (Decision 2). +2. **Render-time authority check.** Every surface re-checks target read + authority when rendering; cached or indexed post metadata never + proves access. Unreadable targets degrade to an explicit unavailable + state with no leaked metadata — including no `source.excerpt`. +3. **Identity and pin immutability.** A post's `target` and `pin` change + only by a new share event; ordinary edits may change `presentation`, + `excerpt` and `commentary` but cannot move either. Drift between pin + and live is always labelled, never silent. +4. **Derived attribution.** The author/board chain of a repost is + computed from signed references and cannot be asserted by any post + field; a repost cannot alter the original commentary. +5. **Withdrawal is total and propagates.** Target-owner withdrawal + degrades the post and every descendant post on the next render, with + no residual content, and deletes no signed history. +6. **No silent snapshot, and quotations are gated.** A post never + carries the target's content in `body`. The only target-derived text + is `source.excerpt`, which travels with the reference and is withheld + wherever the target is unreadable or withdrawn. +7. **Acyclic chains.** Insertion rejects a `source` edge that would close + a cycle in the post-reference graph. +8. **References are host-independent.** Stable IDs and content hashes + only; no URL, endpoint or hosting server is part of a reference. +9. **Moderation does not rewrite history.** Hides and withdrawals act on + projections; the post, withdrawal and chain stay attributable. +10. **Parity.** Post-to-board behaves identically on web, CLI/script and + agent surfaces (the parent's graph-parity requirement). + +## Alternatives considered and rejected + +| Option | Why rejected | +|---|---| +| **Snapshot by default** (copy the object into the post at share time) | Severs provenance and makes withdrawal unenforceable — the board keeps a copy its author cannot withdraw, and reposts cannot be traced to an original. It is the failure the parent's "object stays live" framing exists to prevent. | +| **Live-only reference (no pin)** | Citation rot. Every edit changes what the board displayed; quotes, moderation decisions and audit records lose their referent. This is exactly the mistake #5830 rejected for notes — applying it only to files and posts would give one board two incompatible citation models. | +| **Pin-only reference (no live view)** | Boards become archives of stale snapshots; readers must re-share to follow a living object. Loses the "boards are part of the knowledge surface" value the parent asks for. | +| **Host-mediated embed** (target's "home" server serves the content into the board) | Reintroduces a canonical host, requires it online, and lets one operator change or withdraw what every board displays — contradicting #2054's host independence and #2054's host-availability/board-projection separation. | +| **Copy into board ownership on share** | Transfers control to the board, forbids the author from continuing their own object as the shared thing, and contradicts #5677's sovereignty rule as applied in #5830. Not provided in v1. | +| **Reference stored as free text / URL in the body** | Unvalidatable, unenumerable for backlinks and withdrawal, and host-dependent. A reference must be typed data the graph can walk. | +| **Withdrawal scoped per board (board owner decides)** | Makes a repost an escape from an author's withdrawal and turns a courtesy into a negotiation. An author's withdrawal of their own object must be unilateral and total. | +| **Repost chain asserted by the reposter** (a stated "originally by …" field) | Forgeable. Attribution must be derived from signed edges, or it is just text. | + +## Parent-decision check + +Nothing here changes a decision in parent #5680; this record answers its +§1 questions, which the parent's decomposition names as this ticket's: + +- *"is a post a reference, a snapshot/copy, or author's choice per post? + Design all three, pick the default, make the state visible"* — + answered as: reference is the mechanism, the author chooses + **presentation** (full/excerpt/link card) rather than wholesale + copying, and the default is a pinned reference with a labelled live + view; the reference state is visible on every post. +- *"posting requires what rights on the board and on the object?"* — + answered in Decision 2 (two gates; no widening without owner + confirmation). +- *"cross-owner posting; attribution rules; the original owner's ability + to revoke/withdraw"* — answered in Decisions 2 and 4. +- *"board-to-board reposting … chain of attribution, and whether reposts + carry the original post commentary or the reposter's"* — answered in + Decision 3 as both, in derived and separate fields. +- Intake/approval (#5857), themes (#5858), embeds (#5859), moderation + (#5861) and subscription/feed (#5862) are left to their own tickets, + as the parent's decomposition intends. + +Where this record touches an adjacent decided design it applies it +rather than forking it: #5830's pin-plus-live rule for notes, #2054's +append-only/supersede/tombstone mechanics and three-layer view +composition, #2048's stable-note-identity model, and #5862's +"feed renders post semantics" hook. + +## Implementation notes and hazards (for the follow-on) + +Recorded now because they shape the slice, not because this record +implements them: + +1. **`embed_ref` cannot be reused.** `BoardGraph::require_scoped` + enforces `object.board_ref() == Some(value.board)` for every post + reference, and `GamePostRef` is additionally kind-checked as a + same-board `Post`. A cross-board/off-board source needs its own field + with its own validator: existence + kind check by hash, *not* board + scope. Widening `require_scoped` for posts would weaken every other + board-scope check. +2. **Off-graph targets cannot be inserted into `BoardGraph`.** Notes + (#2048) and blobs live outside the board object set, so their + references must validate as *opaque* typed references against the + store, not as graph members. `board_object_set`/replication must not + try to ship a note or a blob with the board; the honest degraded + state in Decision 2 is what a peer without the target sees. +3. **Backlinks** are a derived projection over `source` edges — add + `posted-into` and `repost-of` edge types where #2048/#5830 derive + `shared-into` and `reply-anchored-to`, with the same viewer-relative + filtering (no existence disclosure). +4. **Property tests** belong with the field: identity-and-pin immutability + under supersede (while presentation/excerpt/commentary do change), + acyclic chains, withdrawal propagation over a chain of arbitrary + length, no-widening (a reader without target authority never sees + target bytes, metadata *or an excerpt*), and canonical round-trip of + the new fields including posts written before they existed. + +## Follow-on + +Implementation is a separate decision (per the parent, possibly months +out). When scheduled it splits as: + +1. `PostSource` schema + reference validation (typed targets, pin, + presentation, excerpt, commentary, widening confirm; v1 posts decode + as `None`). +2. Post-to-board flow: read-authority and posting-right checks, widening + confirmation, unavailable-state rendering. +3. Board-to-board repost: source-post references, derived attribution + chain, cycle rejection. +4. Withdrawal: owner-signed withdrawal, projection degradation, + descendant propagation, audit visibility. +5. Backlink projection extension over `source` edges with viewer-relative + filtering. + +Each split is a separate issue when implementation is scheduled; none of +them may re-decide Decisions 1–4 without amending this record explicitly.