From 072fdce65cd6e27cdb3b6f6de03ed84de763956b Mon Sep 17 00:00:00 2001 From: repo-worker-code-k Date: Sun, 8 Nov 2026 19:29:34 -0600 Subject: [PATCH 1/4] docs(id): decide chat anchor data model --- ...01-27-00Z_design_chat_anchor_data_model.md | 234 ++++++++++++++++++ doc/README.md | 1 + planning/architecture/README.md | 1 + 3 files changed, 236 insertions(+) create mode 100644 doc/2026-11-09T01-27-00Z_design_chat_anchor_data_model/2026-11-09T01-27-00Z_design_chat_anchor_data_model.md diff --git a/doc/2026-11-09T01-27-00Z_design_chat_anchor_data_model/2026-11-09T01-27-00Z_design_chat_anchor_data_model.md b/doc/2026-11-09T01-27-00Z_design_chat_anchor_data_model/2026-11-09T01-27-00Z_design_chat_anchor_data_model.md new file mode 100644 index 0000000000..c896ee9667 --- /dev/null +++ b/doc/2026-11-09T01-27-00Z_design_chat_anchor_data_model/2026-11-09T01-27-00Z_design_chat_anchor_data_model.md @@ -0,0 +1,234 @@ +# Chat anchor data model: typed links and durable part selectors + +**Status:** Decision record for [#5870](https://github.com/developing-today/code/issues/5870) + +**Parent:** [#5682](https://github.com/developing-today/code/issues/5682) + +**Decision date:** 2026-11-09 (UTC) + +## Decision summary + +Represent conversation-to-object relationships as first-class, addressable +`ConversationLink` records, separate from chat messages. A record has a typed +relationship and typed endpoints; a part link carries one revision-bound, +object-native selector. Link records are the source of truth in both +directions: reverse navigation is an index, not a second mirrored link. + +Keep the original target revision and selector immutable. Resolve an anchor on +later revisions using the object's stable part IDs and revision edit map first, +then a unique exact content fingerprint. Show a relocation warning when +content matching moves the anchor. Never silently choose among approximate or +multiple matches. Preserve an orphaned or tombstoned link and its conversation +rather than deleting or retargeting it. + +The link model is application metadata, not message content or a new required +chat-protocol field. All link, selector, fingerprint, status, and reverse-index +data remains subject to the target object's access checks: a caller who cannot +read a private target must not learn that a link or target exists. + +## Context and scope + +Issue #5682 extends ID chat v1 (#2051), which uses the messaging/relay protocol +in #2036, with conversation/object links, talk pages, and terminal +participation. Its first feature calls for links to addressable ID objects, +typed relationships, navigation in both directions, cross-object conversations, +and anchors that survive edits, versions, and deletion. It also requires that +private-object content and existence not leak to non-readers. + +This record settles the structural model for the first feature only. It does +not decide talk-page lifecycle or visibility policy, terminal interaction, +notifications, presence, search semantics, or the discussion-to-edit workflow +(the sibling designs #5871–#5875, including #5874). It does not add fields to +chat messages, require a new #2036 protocol version, or decide the policy for +who may read a conversation. Any such policy must still satisfy #5682's +private-object non-disclosure constraint. + +## Chosen model + +### Link record + +Use one canonical record with this logical shape: + +```text +ConversationLink { + link_id: LinkId, + source: ConversationRef { conversation_id, thread_id? }, + target: ObjectRef { object_id } | ConversationRef { conversation_id, thread_id? }, + relation: about | "anchored-to-part" | "derived-from" | "resolved-into", + part_anchor?: PartAnchor, + created_at: Timestamp, + created_by: ActorId, +} +``` + +`thread_id` is absent when the relation applies to the whole conversation. +`target` is a tagged reference, never a pasted URL or copied object title. +The link contains no target excerpt or preview. The allowed combinations are: + +| Relation | Target | Part anchor | Meaning | +| --- | --- | --- | --- | +| `about` | ID object | absent | The conversation/thread discusses the object generally. | +| `anchored-to-part` | ID object | required | The conversation/thread refers to exactly one selected part of the object. | +| `derived-from` | conversation/thread | absent | The conversation/thread was forked or spun out of that source conversation/thread. | +| `resolved-into` | ID object | absent | The discussion produced or points to an addressable edit, decision, or other result object. | + +The `resolved_into` edge records a result reference only; it does not define +proposal, approval, or editing semantics. Those remain with the separate +discussion-to-edit design. A result that is not an addressable ID object is +not a `resolved_into` target until it has an object identity. + +A conversation may have any number of links, including links to several +objects. Each part link names one selector; use another link record for another +selected part. This keeps one selector's lifecycle independent of the others. +`link_id` identifies the canonical edge. Object-to-conversation and +conversation-to-result navigation use reverse indexes over that same edge; +do not write a duplicate reciprocal edge that could disagree. Exact repeated +creation of the same edge is idempotent, while distinct part selectors remain +distinct links. + +### Part-anchor representation + +A `PartAnchor` is pinned to the immutable object revision in which it was +created: + +```text +PartAnchor { + origin_revision_id: RevisionId, + selector: TextRange | Block | Region, + resolver_fingerprint?: OpaqueTargetScopedFingerprint, +} +``` + +The selector variants are: + +- **Text range:** `{ part_id, start, end, unit: "unicode-scalar" }`. `start` + and `end` are zero-based, half-open offsets into the object's canonical text + representation for that part; `end` must be greater than `start`. UI cursor + and grapheme positions are converted at the client boundary. The wire/storage + coordinates do not depend on UTF-8 byte offsets or a client's UTF-16 index. +- **Block:** `{ part_id, block_id }`, where `block_id` is stable within the + object's revision lineage. Use this for a paragraph, board post/card, cell, + or other addressable structured unit when a text range is not the right + granularity. +- **Region:** `{ part_id?, selector_type, value }`, where `selector_type` is + registered by the object type and `value` is its canonical typed selector. + Units and coordinate spaces are part of that selector's definition (for + example, a media time interval or a table cell address); untyped coordinates + are not valid. Prefer stable logical identifiers over positions when the + object type has them. + +The optional fingerprint is private resolver metadata, not a quote. It may be +computed from selected content and bounded context, but it must be opaque and +available only to the authorized resolver. Do not put raw selected text, +object titles, or previews in a link record or expose a fingerprint as a public +selector. The object type remains responsible for the canonical text and +revision mapping its selector uses. + +### Edit, version, and delete survival + +The original `origin_revision_id` and selector are immutable. For a target at a +later revision, expose a separate resolution projection for that revision; +never rewrite the original selector to make a link appear current. Resolution +uses this order: + +1. If the object supplies a deterministic revision map and stable part/block + identity maps the selection exactly, resolve it as **current** with no + warning. +2. Otherwise, if the resolver finds exactly one match for the opaque content + fingerprint in the same object's revision lineage, resolve it as + **relocated** and show a non-blocking “anchor moved” warning. Preserve both + original and resolved selectors. +3. If only an approximate match exists, or more than one candidate exists, + mark it **drifted**. Warn, retain the original anchor, and require a person + or object-specific resolver to confirm a candidate before navigation + retargets. Candidate details are visible only to readers of the object. +4. If the selected part or range no longer exists and there is no candidate, + mark it **orphaned**. Keep the link and conversation; do not guess a new + target. +5. If the whole object is deleted, mark its target **tombstoned**. Keep the + link and conversation, but do not preserve a content preview or make the + tombstone visible to a caller who could not read the object. + +An anchor follows revisions of the same object identity only. A copied object, +fork with a new object ID, or unrelated object that happens to contain the +same text does not inherit the link automatically. When the original revision +is retained and authorized, clients may offer it as an explicit destination; +otherwise navigation uses the latest confirmed resolution. A change in anchor +status never deletes the conversation or changes its message history. + +### Protocol and privacy boundary + +The link is application-level metadata attached to a conversation/thread, not +a message body field. A client that understands links can resolve the record +and navigate; a client that does not understand links can still exchange the +underlying chat messages. If link records need replication, use the optional +application metadata/extension path already supported by #2036. Do not require +a new message kind, a new mandatory envelope field, or a protocol-version bump +for ordinary chat. The exact transport/storage endpoint remains an +implementation choice within that boundary. + +Apply authorization before returning a link or any projection of it. This +includes its ID, endpoint IDs, relationship, part selector, fingerprint, +resolution status, candidate count, reverse-index result, notification, and +search hit. If the caller cannot read the target object, return no indication +that the edge or target exists. Link metadata does not grant target access or +change conversation membership. Conversation visibility itself remains a +#5682 policy decision; implementations must ensure that transcript, title, +preview, and notification rendering do not disclose the private target. + +## Alternatives rejected + +| Alternative | Reason for rejection | +| --- | --- | +| A pasted URL in a message | Not a first-class relationship, cannot reliably support reverse navigation, and has no typed selector or lifecycle. URLs may be kept as user-authored content but are not the canonical link. | +| Store the relationship only in the message body or envelope | Couples link lifecycle to message history, makes multi-object/thread links awkward, and risks exposing private target metadata through ordinary transcript delivery. | +| Store only offsets against the current object | Edits and version changes silently retarget positions; the same offsets can point at unrelated content. | +| Store raw quote text in the link | Duplicates potentially private object content and can disclose it through sync, indexes, logs, or clients that lack object access. | +| Always choose the “closest” or first relocation candidate | Approximate and ambiguous matches can point a discussion at the wrong content. Drift must be visible and confirmation required. | +| Delete links when a part/object is deleted | Breaks reverse history and disconnects a conversation that the parent design says must survive; use orphan and tombstone states instead. | +| Publish a tombstone or relation to every conversation reader | Reveals private-object existence; access checks must hide the edge itself, not merely its preview. | +| One universal coordinate format for all object regions | Text, media, tables, boards, and other object types have different semantics and units; typed object-native selectors are less ambiguous. | +| Duplicate a reverse link record | Creates two sources of truth that can disagree; derive reverse navigation from the canonical edge. | +| Require new core protocol fields or a protocol-version change | Expands the parent protocol/client scope unnecessarily; optional application metadata preserves compatibility with ordinary chat clients. | + +## Implementation invariants + +Implementations of this decision must hold all of the following: + +1. Every link has a stable `link_id`, a typed source and target, and one of the + four allowed relation/endpoint combinations above. +2. `anchored-to-part` has exactly one object target, one origin revision, and + one valid selector. Ranges are non-empty half-open Unicode-scalar ranges; + block and region selectors are valid for the target object type. +3. Link creation is idempotent for an identical edge, but separate selectors + are not collapsed. Bidirectional navigation is derived from the same + canonical record. +4. No link or anchor field, status, candidate, count, search result, or + notification reveals a private target's content or existence to a + non-reader. A link never grants access. +5. Original revision and selector are immutable. Resolution is revision-bound + derived state, and only an exact deterministic mapping or unique exact + fingerprint match may retarget automatically. +6. Approximate or ambiguous matches are `drifted`, visibly warned, and never + silently followed. Missing selectors are `orphaned`; deletion of the whole + object is `tombstoned`. +7. Orphaning or tombstoning a target does not delete the link, its conversation, + or chat messages. No resolver follows content into a different object ID. +8. Unknown or unsupported link metadata does not prevent a client from reading + or sending ordinary chat messages; clients that render a link preserve its + status and warning rather than presenting a stale selector as current. +9. Reverse lookup, search, and rendering apply object authorization before + returning any existence-bearing result. + +## Parent-decision check and implementation handoff + +This record refines the first feature in #5682; it does not reverse a parent +choice or take on talk-page, thread-visibility, terminal, or edit-loop policy. +It applies the parent's existing private-object non-disclosure constraint to +the link and resolver data. The optional-metadata boundary above is a +compatibility constraint for this model, not a replacement for #5682's +protocol design. + +No implementation code is included here. The link shape and resolver form one +cohesive design unit; implementation sequencing and issue splitting remain +follow-up planning rather than additional decisions in this record. diff --git a/doc/README.md b/doc/README.md index 5b2d6875ef..aa05b7aa3c 100755 --- a/doc/README.md +++ b/doc/README.md @@ -55,6 +55,7 @@ Folders are named `__`. The kinds in use are `feature` - [The shared load & workload generator](2026-11-08T11-27-00Z_design_shared_workload_generator/2026-11-08T11-27-00Z_design_shared_workload_generator.md) (decision record for #5891: one generator core for honest and adversarial profiles, the three-surface target abstraction, and the measurement/assertion contracts for the #5685 programme) - [Server-side invariants: budgets, observability, exploit resistance, containment](2026-11-09T05-15-00Z_design_id_server_invariants/2026-11-09T05-15-00Z_design_id_server_invariants.md) (design for #5962: the budget set B1–B7 with enforcement classes, the trip-observability surface per audience, the platform attack-surface checklist over all 20 registered providers, and co-resident-world failure containment) - [Two-level metering: burst bucket + hard per-tick ceiling, per function](2026-11-10T03-10-00Z_design_id_two_level_metering/2026-11-10T03-10-00Z_design_id_two_level_metering.md) (design for #6001: Screeps two-level metering mapped term-by-term to per-function fuel accounting — refill/bucket/ceiling as world-author configuration under server caps, the getUsed self-observation API, and the bucket-exhausted throttle outcome) +- [Chat anchor data model](2026-11-09T01-27-00Z_design_chat_anchor_data_model/2026-11-09T01-27-00Z_design_chat_anchor_data_model.md) (decision record for #5870: typed conversation links, revision-bound part selectors, edit relocation, drift, orphan, and tombstone behavior) - [Atlas storage growth model](2026-11-08T11-18-02Z_design_atlas_storage_growth_model/2026-11-08T11-18-02Z_design_atlas_storage_growth_model.md) (design for #6061: per-source churn x retention growth model against the #6019 plan envelope, the ledger-fed calibration procedure, conservative v1 retention defaults for the #6026 rule engine, and staging modelled separately from the retained corpus) - [Writer sets v2: view-as-object, set algebra, federation, discovery v2](2026-11-08T11-10-00Z_design_id_writer_sets_v2/2026-11-08T11-10-00Z_design_id_writer_sets_v2.md) (design for #5789: pinned/tracking view references, derived sets with provenance and exclusions winning, federation claim discipline via #5675/#5672, inherited uncounted-side honesty, and the three v1 open questions answered) - [Curated-board submissions: intake queues, intake roles, notifications](2026-11-08T13-45-00Z_design_id5857_curated_board_submissions/2026-11-08T13-45-00Z_design_id5857_curated_board_submissions.md) (decision record for #5857: `open`/`curated` intake policy, a separate owner-granted `Intake` role, submission as a signed post plus a signed `IntakeDecision` with pending derived rather than stored, and intake events delivered through #5862's notification model) diff --git a/planning/architecture/README.md b/planning/architecture/README.md index 1d7dbf97ee..223721e6c9 100644 --- a/planning/architecture/README.md +++ b/planning/architecture/README.md @@ -78,6 +78,7 @@ records. - [Two-level metering: burst bucket + hard per-tick ceiling, per function](../../doc/2026-11-10T03-10-00Z_design_id_two_level_metering/2026-11-10T03-10-00Z_design_id_two_level_metering.md) - [Framing and fragmentation across ID carrier classes](../../doc/2026-11-09_decision_id5810_carrier_framing.md) (decision for #5810: length-prefixed stream frames, datagram whole-frame-or-checked-chunk assembly, store-and-forward opaque-object-or-checked-chunk assembly, and the invariants each adapter must hold) - [Draft approval queues, outcomes, and rejected-draft forks](../../doc/2026-11-08T11-06-39Z_design_id_draft_approval_flow/2026-11-08T11-06-39Z_design_id_draft_approval_flow.md) +- [Chat anchor data model: typed links and durable part selectors](../../doc/2026-11-09T01-27-00Z_design_chat_anchor_data_model/2026-11-09T01-27-00Z_design_chat_anchor_data_model.md) ## Package architecture docs (living, with the code) From 6d02cc5f5467117b9fb5dd5c2a988ad46be85e74 Mon Sep 17 00:00:00 2001 From: repo-worker-code-k Date: Sun, 8 Nov 2026 23:07:21 -0600 Subject: [PATCH 2/4] docs(id): align anchor model with #5872/#5873/#5874 and review - Fold about/anchored-to-part/derived-from from chat.anchor.v1 (#5872); resolved-into from chat.resolution.v1 kind edit (#5874) - Add unresolved resolver outcome; name the six resolution states - Add URL-fragment-safe textual selector form per #5873 frame - Drop unverified #2036 extension-path claim; no message-body fields, no version bump (unknown-kind tolerance, #5872 invariant 7) - Fix resolved-into spelling; add deterministic-fold invariant --- ...01-27-00Z_design_chat_anchor_data_model.md | 106 +++++++++++++----- 1 file changed, 80 insertions(+), 26 deletions(-) diff --git a/doc/2026-11-09T01-27-00Z_design_chat_anchor_data_model/2026-11-09T01-27-00Z_design_chat_anchor_data_model.md b/doc/2026-11-09T01-27-00Z_design_chat_anchor_data_model/2026-11-09T01-27-00Z_design_chat_anchor_data_model.md index c896ee9667..523e95eb5d 100644 --- a/doc/2026-11-09T01-27-00Z_design_chat_anchor_data_model/2026-11-09T01-27-00Z_design_chat_anchor_data_model.md +++ b/doc/2026-11-09T01-27-00Z_design_chat_anchor_data_model/2026-11-09T01-27-00Z_design_chat_anchor_data_model.md @@ -18,12 +18,22 @@ Keep the original target revision and selector immutable. Resolve an anchor on later revisions using the object's stable part IDs and revision edit map first, then a unique exact content fingerprint. Show a relocation warning when content matching moves the anchor. Never silently choose among approximate or -multiple matches. Preserve an orphaned or tombstoned link and its conversation -rather than deleting or retargeting it. - -The link model is application metadata, not message content or a new required -chat-protocol field. All link, selector, fingerprint, status, and reverse-index -data remains subject to the target object's access checks: a caller who cannot +multiple matches. When the resolver has neither a deterministic map, nor a +unique fingerprint match, nor a retained origin revision to offer, the anchor +is explicitly `unresolved` rather than guessed. Preserve an orphaned or +tombstoned link and its conversation rather than deleting or retargeting it. + +On the wire this record consumes the sibling mechanisms already decided: +`about`, `anchored-to-part`, and `derived-from` edges fold from #5872's +append-only `chat.anchor.v1` events on the conversation log (`talk-for` +remains #5872's separate canonical talk-page binding), and `resolved-into` +edges fold from #5874's `chat.resolution.v1` events. The log is the durable +source; the `ConversationLink` is the canonical projected edge. Part +selectors additionally satisfy #5873's terminal constraint: every selector has +a URL-fragment-safe textual form. + +All link, selector, fingerprint, status, and reverse-index data remains +subject to the target object's access checks: a caller who cannot read a private target must not learn that a link or target exists. ## Context and scope @@ -35,7 +45,10 @@ typed relationships, navigation in both directions, cross-object conversations, and anchors that survive edits, versions, and deletion. It also requires that private-object content and existence not leak to non-readers. -This record settles the structural model for the first feature only. It does +This record settles the structural model for the first feature only. +Mechanically it builds on the sibling decisions without re-deciding them: +#5872's anchor events, #5873's fragment-safe textual selector frame, and +#5874's resolution events. It does not decide talk-page lifecycle or visibility policy, terminal interaction, notifications, presence, search semantics, or the discussion-to-edit workflow (the sibling designs #5871–#5875, including #5874). It does not add fields to @@ -72,10 +85,17 @@ The link contains no target excerpt or preview. The allowed combinations are: | `derived-from` | conversation/thread | absent | The conversation/thread was forked or spun out of that source conversation/thread. | | `resolved-into` | ID object | absent | The discussion produced or points to an addressable edit, decision, or other result object. | -The `resolved_into` edge records a result reference only; it does not define +Mechanically, `about`, `anchored-to-part`, and `derived-from` edges are the +folded projection of #5872's append-only `chat.anchor.v1` events on the +conversation log; `talk-for` stays #5872's separate canonical talk-page +binding and is not a fifth value of this vocabulary. `resolved-into` edges +fold from #5874's `chat.resolution.v1` events (kind `edit`): only an +addressable edit result produces an object-side edge, per #5874. + +The `resolved-into` edge records a result reference only; it does not define proposal, approval, or editing semantics. Those remain with the separate discussion-to-edit design. A result that is not an addressable ID object is -not a `resolved_into` target until it has an object identity. +not a `resolved-into` target until it has an object identity. A conversation may have any number of links, including links to several objects. Each part link names one selector; use another link record for another @@ -117,6 +137,16 @@ The selector variants are: are not valid. Prefer stable logical identifiers over positions when the object type has them. +Every selector variant has a URL-fragment-safe textual form for terminal and +link rendering: the `id://` object reference with a `#`-suffixed selector +fragment, per the frame fixed by #5873. The textual form encodes the same +canonical selector (offsets, block ID, or typed region value); it never +carries raw content. Object types own the exact fragment encoding of their +region selectors, but every encoding must survive URL-fragment transport +without loss or ambiguity. If a future object type cannot express its +selector as a fragment, that is a change to #5873's record and must be +recorded there, not silently absorbed here. + The optional fingerprint is private resolver metadata, not a quote. It may be computed from selected content and bounded context, but it must be opaque and available only to the authorized resolver. Do not put raw selected text, @@ -142,13 +172,25 @@ uses this order: mark it **drifted**. Warn, retain the original anchor, and require a person or object-specific resolver to confirm a candidate before navigation retargets. Candidate details are visible only to readers of the object. -4. If the selected part or range no longer exists and there is no candidate, +4. If the resolver has neither a deterministic revision map, nor a unique + fingerprint match, nor a retained origin revision to offer (for example + the fingerprint was never recorded and the origin revision is pruned), + mark the anchor **unresolved**. Warn, retain the original anchor, and + offer no navigation target until a person or object-specific resolver + confirms one. An `unresolved` anchor is never silently followed. +5. If the selected part or range no longer exists and there is no candidate, mark it **orphaned**. Keep the link and conversation; do not guess a new target. -5. If the whole object is deleted, mark its target **tombstoned**. Keep the +6. If the whole object is deleted, mark its target **tombstoned**. Keep the link and conversation, but do not preserve a content preview or make the tombstone visible to a caller who could not read the object. +The resolution states are `current`, `relocated`, `drifted`, `unresolved`, +`orphaned`, and `tombstoned`. Anchor absence (no link record at all) is a +valid state, not an error, per #5872; `talk-for` binding disputes +(`disputed`) belong to #5872's canonical-binding rule, not to this +vocabulary. + An anchor follows revisions of the same object identity only. A copied object, fork with a new object ID, or unrelated object that happens to contain the same text does not inherit the link automatically. When the original revision @@ -158,13 +200,13 @@ status never deletes the conversation or changes its message history. ### Protocol and privacy boundary -The link is application-level metadata attached to a conversation/thread, not -a message body field. A client that understands links can resolve the record -and navigate; a client that does not understand links can still exchange the -underlying chat messages. If link records need replication, use the optional -application metadata/extension path already supported by #2036. Do not require -a new message kind, a new mandatory envelope field, or a protocol-version bump -for ordinary chat. The exact transport/storage endpoint remains an +`about`, `anchored-to-part`, and `derived-from` links replicate as #5872's +additive `chat.anchor.v1` log events; `resolved-into` edges replicate as +#5874's `chat.resolution.v1` events. No message-body field, no mandatory +envelope field, and no protocol-version bump are required: clients that +predate the extensions skip the new event kinds and link metadata without +failing ordinary chat projection (unknown-kind tolerance, #5872 invariant 7). +The exact storage endpoint for the folded link index remains an implementation choice within that boundary. Apply authorization before returning a link or any projection of it. This @@ -189,7 +231,7 @@ preview, and notification rendering do not disclose the private target. | Publish a tombstone or relation to every conversation reader | Reveals private-object existence; access checks must hide the edge itself, not merely its preview. | | One universal coordinate format for all object regions | Text, media, tables, boards, and other object types have different semantics and units; typed object-native selectors are less ambiguous. | | Duplicate a reverse link record | Creates two sources of truth that can disagree; derive reverse navigation from the canonical edge. | -| Require new core protocol fields or a protocol-version change | Expands the parent protocol/client scope unnecessarily; optional application metadata preserves compatibility with ordinary chat clients. | +| Put link state in message bodies or require a protocol-version change | Couples link lifecycle to message history and breaks older clients; the additive event kinds decided in #5872 already preserve compatibility without a version change, so this record specifies no further protocol change. | ## Implementation invariants @@ -199,7 +241,9 @@ Implementations of this decision must hold all of the following: four allowed relation/endpoint combinations above. 2. `anchored-to-part` has exactly one object target, one origin revision, and one valid selector. Ranges are non-empty half-open Unicode-scalar ranges; - block and region selectors are valid for the target object type. + block and region selectors are valid for the target object type. Every + selector has a URL-fragment-safe textual form (the `id://` reference with + a `#`-suffixed selector fragment) encoding the same canonical selector. 3. Link creation is idempotent for an identical edge, but separate selectors are not collapsed. Bidirectional navigation is derived from the same canonical record. @@ -210,8 +254,10 @@ Implementations of this decision must hold all of the following: derived state, and only an exact deterministic mapping or unique exact fingerprint match may retarget automatically. 6. Approximate or ambiguous matches are `drifted`, visibly warned, and never - silently followed. Missing selectors are `orphaned`; deletion of the whole - object is `tombstoned`. + silently followed. A resolver with no deterministic map, no unique + fingerprint match, and no retained origin revision marks the anchor + `unresolved` and offers no target until confirmation. Missing selectors are + `orphaned`; deletion of the whole object is `tombstoned`. 7. Orphaning or tombstoning a target does not delete the link, its conversation, or chat messages. No resolver follows content into a different object ID. 8. Unknown or unsupported link metadata does not prevent a client from reading @@ -219,15 +265,23 @@ Implementations of this decision must hold all of the following: status and warning rather than presenting a stale selector as current. 9. Reverse lookup, search, and rendering apply object authorization before returning any existence-bearing result. +10. `about`, `anchored-to-part`, and `derived-from` edges fold + deterministically from `chat.anchor.v1` events and `resolved-into` edges + from `chat.resolution.v1` events (kind `edit`); replicas folding the same + log converge on the same edge set. ## Parent-decision check and implementation handoff This record refines the first feature in #5682; it does not reverse a parent choice or take on talk-page, thread-visibility, terminal, or edit-loop policy. -It applies the parent's existing private-object non-disclosure constraint to -the link and resolver data. The optional-metadata boundary above is a -compatibility constraint for this model, not a replacement for #5682's -protocol design. +It consumes the sibling mechanisms without re-deciding them: #5872's +`chat.anchor.v1` anchor events and `talk-for` binding, #5873's fragment-safe +textual selector frame, and #5874's `chat.resolution.v1` ownership of +`resolved-into` edges. It applies the parent's existing private-object +non-disclosure constraint to the link and resolver data. The one parent +wording boundary (a decision summary or no-action outcome with no addressable +result object remains thread-resolution state, not a reverse object edge) is +recorded explicitly on #5682 rather than silently forked. No implementation code is included here. The link shape and resolver form one cohesive design unit; implementation sequencing and issue splitting remain From 158715c31dcb9bc7adb207f1591cc8209ce6186f Mon Sep 17 00:00:00 2001 From: repo-worker-code-k Date: Sun, 8 Nov 2026 23:35:35 -0600 Subject: [PATCH 3/4] docs(id): settle anchor selector grammar, identity contract, and survival states (#5870) - Specify the version-1 fragment-safe part-selector grammar (range, block, region) that satisfies #5873's conditional requirement on this record. - Add the object identity/revision contract an anchor needs to follow edits; anchors on revision-only object IDs stay pinned instead of following a save. - Add the TalkPageBinding projection (separate from ordinary links), the disputed and unbound states, and the causal-fold rules for anchor mutations, keeping #5872's event-ID tie-break as fold determinism, not semantic choice. - Cite #5872's decision comment, #5873's frame (PR #7614), and #5874's landed record instead of re-describing them. --- ...01-27-00Z_design_chat_anchor_data_model.md | 405 +++++++++++------- 1 file changed, 254 insertions(+), 151 deletions(-) diff --git a/doc/2026-11-09T01-27-00Z_design_chat_anchor_data_model/2026-11-09T01-27-00Z_design_chat_anchor_data_model.md b/doc/2026-11-09T01-27-00Z_design_chat_anchor_data_model/2026-11-09T01-27-00Z_design_chat_anchor_data_model.md index 523e95eb5d..635bd614ec 100644 --- a/doc/2026-11-09T01-27-00Z_design_chat_anchor_data_model/2026-11-09T01-27-00Z_design_chat_anchor_data_model.md +++ b/doc/2026-11-09T01-27-00Z_design_chat_anchor_data_model/2026-11-09T01-27-00Z_design_chat_anchor_data_model.md @@ -8,33 +8,30 @@ ## Decision summary -Represent conversation-to-object relationships as first-class, addressable -`ConversationLink` records, separate from chat messages. A record has a typed -relationship and typed endpoints; a part link carries one revision-bound, -object-native selector. Link records are the source of truth in both -directions: reverse navigation is an index, not a second mirrored link. +Represent conversation-to-object relationships as first-class +`ConversationLink` projections, not duplicated mutable records. Ordinary +`about`, `anchored-to-part`, and `derived-from` links fold from #5872's +append-only `chat.anchor.v1` events. `resolved-into` links fold from +`chat.resolution.v1` edit results under #5874. A talk-page `talk-for` binding +is a separate projection over `chat.anchor.v1`, not an ordinary relation in +this link graph. Each part link carries one revision-bound, object-native +selector. Reverse navigation is an index over the owning event stream(s), not +a second mirrored link. Keep the original target revision and selector immutable. Resolve an anchor on later revisions using the object's stable part IDs and revision edit map first, -then a unique exact content fingerprint. Show a relocation warning when -content matching moves the anchor. Never silently choose among approximate or -multiple matches. When the resolver has neither a deterministic map, nor a -unique fingerprint match, nor a retained origin revision to offer, the anchor -is explicitly `unresolved` rather than guessed. Preserve an orphaned or -tombstoned link and its conversation rather than deleting or retargeting it. - -On the wire this record consumes the sibling mechanisms already decided: -`about`, `anchored-to-part`, and `derived-from` edges fold from #5872's -append-only `chat.anchor.v1` events on the conversation log (`talk-for` -remains #5872's separate canonical talk-page binding), and `resolved-into` -edges fold from #5874's `chat.resolution.v1` events. The log is the durable -source; the `ConversationLink` is the canonical projected edge. Part -selectors additionally satisfy #5873's terminal constraint: every selector has -a URL-fragment-safe textual form. - -All link, selector, fingerprint, status, and reverse-index data remains -subject to the target object's access checks: a caller who cannot -read a private target must not learn that a link or target exists. +then a unique exact content fingerprint. Record accepted relocation as a new +`chat.anchor.v1` event; show a warning for content-based movement. Never +silently choose among approximate or concurrent matches. Distinguish +`current`, `relocated`, `drifted`, `disputed`, `unresolved`, `orphaned`, +`tombstoned`, and explicitly `unbound` links. Preserve event history and the +conversation through all of these states. + +The link model is not a `chat.message.v1` body field. It consumes #5872's +additive `chat.anchor.v1` event contract; it does not introduce a second wire +format. All link, selector, fingerprint, status, and reverse-index data remains +subject to the target object's access checks: a caller who cannot read a +private target must not learn that a link or target exists. ## Context and scope @@ -45,66 +42,87 @@ typed relationships, navigation in both directions, cross-object conversations, and anchors that survive edits, versions, and deletion. It also requires that private-object content and existence not leak to non-readers. -This record settles the structural model for the first feature only. -Mechanically it builds on the sibling decisions without re-deciding them: -#5872's anchor events, #5873's fragment-safe textual selector frame, and -#5874's resolution events. It does -not decide talk-page lifecycle or visibility policy, terminal interaction, -notifications, presence, search semantics, or the discussion-to-edit workflow -(the sibling designs #5871–#5875, including #5874). It does not add fields to -chat messages, require a new #2036 protocol version, or decide the policy for -who may read a conversation. Any such policy must still satisfy #5682's -private-object non-disclosure constraint. +This record settles the link vocabulary, part-selector grammar, and anchor +survival states for the first feature only. It consumes [#5872's decision on +`chat.anchor.v1` and `talk-for`](https://github.com/developing-today/code/issues/5872#issuecomment-6658733227), +[#5873's fragment-safe selector requirement](https://github.com/developing-today/code/pull/7614), +and [#5874's `chat.resolution.v1` projection](../2026-11-08_decision_id5874_thread_resolution.md). +It leaves talk-page lifecycle and visibility policy, terminal interaction, +notifications, presence, search semantics, and discussion-to-edit mechanics to +the sibling designs #5871–#5875. It does not change `chat.message.v1`, add a +mandatory envelope field, require a protocol version bump, or choose who may +read a conversation. Any such policy must still satisfy #5682's private-object +non-disclosure constraint. ## Chosen model ### Link record -Use one canonical record with this logical shape: +Fold the chained anchor events into one logical record with this projected +shape: ```text ConversationLink { - link_id: LinkId, + link_id: EventId, // owning event: initial bind or resolution event source: ConversationRef { conversation_id, thread_id? }, - target: ObjectRef { object_id } | ConversationRef { conversation_id, thread_id? }, - relation: about | "anchored-to-part" | "derived-from" | "resolved-into", + target: ObjectRef { object_id, author_key }, + relation: "about" | "anchored-to-part" | "derived-from" | "resolved-into", part_anchor?: PartAnchor, - created_at: Timestamp, - created_by: ActorId, + target_revision_id?: RevisionId, // required for resolved-into edit results + resolution?: AnchorResolution, +} + +TalkPageBinding { + binding_id: EventId, + conversation_id: ConversationId, + target: ObjectRef { object_id, author_key }, + state: canonical | disputed | unbound, } ``` +The source conversation is the group that contains the owning event; `thread_id` is absent when the relation applies to the whole conversation. -`target` is a tagged reference, never a pasted URL or copied object title. -The link contains no target excerpt or preview. The allowed combinations are: +`target` is an addressable ID object reference (object ID plus author key), +never a pasted URL or copied object title. A chat message/event is also an +addressable object and may be a target. `derived-from` targets the source chat +object (the source conversation or, for a message-level fork, its named +message/event). The link contains no target excerpt or preview. The four +relationship names in the table are the #5682/#5870 conversation-link +vocabulary: | Relation | Target | Part anchor | Meaning | | --- | --- | --- | --- | | `about` | ID object | absent | The conversation/thread discusses the object generally. | | `anchored-to-part` | ID object | required | The conversation/thread refers to exactly one selected part of the object. | -| `derived-from` | conversation/thread | absent | The conversation/thread was forked or spun out of that source conversation/thread. | -| `resolved-into` | ID object | absent | The discussion produced or points to an addressable edit, decision, or other result object. | - -Mechanically, `about`, `anchored-to-part`, and `derived-from` edges are the -folded projection of #5872's append-only `chat.anchor.v1` events on the -conversation log; `talk-for` stays #5872's separate canonical talk-page -binding and is not a fifth value of this vocabulary. `resolved-into` edges -fold from #5874's `chat.resolution.v1` events (kind `edit`): only an -addressable edit result produces an object-side edge, per #5874. - -The `resolved-into` edge records a result reference only; it does not define -proposal, approval, or editing semantics. Those remain with the separate -discussion-to-edit design. A result that is not an addressable ID object is -not a `resolved-into` target until it has an object identity. +| `derived-from` | addressable chat object | absent | The conversation/thread was forked or spun out of the source conversation/thread or named message/event. | +| `resolved-into` | result object | absent | The discussion produced an addressable edit result; target revision identifies the exact edit/revision. | + +`about`, `anchored-to-part`, and `derived-from` edges are projections of +`chat.anchor.v1` bind/relocate events. A `resolved-into` edge is instead a +projection of a `chat.resolution.v1` event of kind `edit`, per #5874; its +`target_revision_id` is the named edit event/resulting revision. Do not also +emit a `chat.anchor.v1` edge for the same outcome. The `chat.resolution.v1` +fold owns re-open/re-resolve and concurrent-resolution behavior. A decision +summary or no-action resolution that has no addressable result object is not a +`resolved-into` edge; it remains a thread-resolution outcome, not a fabricated +object target. Proposal and approval mechanics remain with #5874. + +`talk-for` is a separate `chat.anchor.v1` binding projection, not a fifth +`ConversationLink` relation. #5872 already defines its single-canonical +binding and disputed-conflict fold; #5871 owns who may bind and the lifecycle +and visibility policy. This record neither adds a second talk-page relation +nor redefines that fold. A conversation may have any number of links, including links to several -objects. Each part link names one selector; use another link record for another -selected part. This keeps one selector's lifecycle independent of the others. -`link_id` identifies the canonical edge. Object-to-conversation and -conversation-to-result navigation use reverse indexes over that same edge; -do not write a duplicate reciprocal edge that could disagree. Exact repeated -creation of the same edge is idempotent, while distinct part selectors remain -distinct links. +objects. Each part link names one selector; use another binding event for +another selected part. This keeps one selector's lifecycle independent of the +others. The initial `chat.anchor.v1` bind event ID is the stable `link_id`; +unbind and relocation events refer to it. For `resolved-into`, the +`chat.resolution.v1` event ID is the `link_id`. Object-to-conversation and +conversation-to-result navigation use reverse indexes over the owning folded +event set; do not write a duplicate reciprocal edge that could disagree. +Repeated delivery of the same event is idempotent, while distinct bind +events/selectors remain distinct links. ### Part-anchor representation @@ -137,15 +155,27 @@ The selector variants are: are not valid. Prefer stable logical identifiers over positions when the object type has them. -Every selector variant has a URL-fragment-safe textual form for terminal and -link rendering: the `id://` object reference with a `#`-suffixed selector -fragment, per the frame fixed by #5873. The textual form encodes the same -canonical selector (offsets, block ID, or typed region value); it never -carries raw content. Object types own the exact fragment encoding of their -region selectors, but every encoding must survive URL-fragment transport -without loss or ambiguity. If a future object type cannot express its -selector as a fragment, that is a change to #5873's record and must be -recorded there, not silently absorbed here. +For references such as `id://#`, serialize a +fragment-safe version-1 selector using these forms: + +```text +pa1~r~~~~ +pa1~b~~~ +pa1~g~~0~~ +pa1~g~~1~~~ +``` + +`r`, `b`, and `g` mean range, block, and region. The revision, part, block, +and selector-type fields are UTF-8 percent-encoded, leaving only ASCII +alphanumerics, `.`, `_`, and `-` unescaped (`~` is always escaped inside a +field, so it remains an unambiguous separator). In the region form, `0` means +there is no part ID and `1` means the next field is a part ID; no sentinel is +overloaded as a valid ID. Range offsets are decimal Unicode-scalar values. The +region `value` is the unpadded base64url encoding of the object type's +canonical UTF-8 selector value. This grammar is safe in a URL fragment and has +a stable parse; the target object type defines the canonical region-value +schema. The resolver fingerprint is deliberately not part of this public +selector. The optional fingerprint is private resolver metadata, not a quote. It may be computed from selected content and bounded context, but it must be opaque and @@ -154,12 +184,30 @@ object titles, or previews in a link record or expose a fingerprint as a public selector. The object type remains responsible for the canonical text and revision mapping its selector uses. +#### Object identity and revision contract + +`ObjectRef` identifies one addressable object record; `origin_revision_id` +identifies the exact immutable version selected. An object type that supports +anchors following edits MUST expose a stable logical object identity across +revisions, immutable revision IDs, and an ordered revision lineage. It must +also provide a deterministic selector mapping or enough authorized resolver +material to attempt exact relocation. Do not infer a logical identity by +matching content hashes or similar text. + +Some ID object records use the signed event ID as their object ID, with each +save creating a new event ID (the document model described in #2259 is an +example). Such an ID is version-specific unless that object type separately +defines a stable logical ID. `about` may target any addressable ID object. A +part anchor can follow later edits only when the object's adapter supplies the +identity/revision contract above; otherwise the anchor is pinned to that +version and cannot automatically follow a new object ID. + ### Edit, version, and delete survival The original `origin_revision_id` and selector are immutable. For a target at a later revision, expose a separate resolution projection for that revision; never rewrite the original selector to make a link appear current. Resolution -uses this order: +uses these states and rules: 1. If the object supplies a deterministic revision map and stable part/block identity maps the selection exactly, resolve it as **current** with no @@ -167,122 +215,177 @@ uses this order: 2. Otherwise, if the resolver finds exactly one match for the opaque content fingerprint in the same object's revision lineage, resolve it as **relocated** and show a non-blocking “anchor moved” warning. Preserve both - original and resolved selectors. + original and resolved selectors. Confirmed relocation is recorded by a + new `chat.anchor.v1` event; the initial binding event is never rewritten. 3. If only an approximate match exists, or more than one candidate exists, mark it **drifted**. Warn, retain the original anchor, and require a person or object-specific resolver to confirm a candidate before navigation retargets. Candidate details are visible only to readers of the object. -4. If the resolver has neither a deterministic revision map, nor a unique - fingerprint match, nor a retained origin revision to offer (for example - the fingerprint was never recorded and the origin revision is pruned), - mark the anchor **unresolved**. Warn, retain the original anchor, and - offer no navigation target until a person or object-specific resolver - confirms one. An `unresolved` anchor is never silently followed. -5. If the selected part or range no longer exists and there is no candidate, - mark it **orphaned**. Keep the link and conversation; do not guess a new - target. +4. If the resolver lacks enough evidence to determine whether the selector + moved or disappeared—for example, there is no revision map or fingerprint, + or the origin revision is no longer retained—mark it **unresolved**. Warn + that the anchor cannot be verified; do not navigate to a guessed current + location or call it orphaned. If the origin revision remains available and + authorized, it may still be opened directly. A person may explicitly + re-anchor it with a later relocation event. +5. If the object's revision history proves the selected part or range was + removed and no candidate remains, mark it **orphaned**. Keep the link and + conversation; do not guess a new target. 6. If the whole object is deleted, mark its target **tombstoned**. Keep the - link and conversation, but do not preserve a content preview or make the - tombstone visible to a caller who could not read the object. - -The resolution states are `current`, `relocated`, `drifted`, `unresolved`, -`orphaned`, and `tombstoned`. Anchor absence (no link record at all) is a -valid state, not an error, per #5872; `talk-for` binding disputes -(`disputed`) belong to #5872's canonical-binding rule, not to this -vocabulary. - -An anchor follows revisions of the same object identity only. A copied object, -fork with a new object ID, or unrelated object that happens to contain the -same text does not inherit the link automatically. When the original revision -is retained and authorized, clients may offer it as an explicit destination; -otherwise navigation uses the latest confirmed resolution. A change in anchor -status never deletes the conversation or changes its message history. - -### Protocol and privacy boundary - -`about`, `anchored-to-part`, and `derived-from` links replicate as #5872's -additive `chat.anchor.v1` log events; `resolved-into` edges replicate as -#5874's `chat.resolution.v1` events. No message-body field, no mandatory -envelope field, and no protocol-version bump are required: clients that -predate the extensions skip the new event kinds and link metadata without -failing ordinary chat projection (unknown-kind tolerance, #5872 invariant 7). -The exact storage endpoint for the folded link index remains an -implementation choice within that boundary. + link and conversation, but do not preserve a content preview or expose the + tombstone to a caller who cannot read the target. A terminal client may + render a deleted marker only after the authorized view includes the link; + “always visible” never overrides the private-object non-disclosure rule. +7. If concurrent `chat.anchor.v1` mutations leave multiple maximal + operations for one `link_id`, mark it **disputed**. Preserve the competing + states, warn authorized readers, and do not choose a selector or navigate + until a later mutation causally observes all competing heads and resolves + them. +8. An explicit, causally unambiguous unbind makes the link **unbound**: exclude + it from the active relation index but retain its event history. Rebinding + creates a new `link_id`; a relocation cannot resurrect an unbound link. + +An anchor follows revisions of the same stable logical object identity only. A +copied object, fork with a new object ID, or unrelated object that happens to +contain the same text does not inherit the link automatically. When the +original revision is retained and authorized, clients may offer it as an +explicit destination; otherwise navigation uses the latest confirmed +resolution, or no destination when the state is unresolved, orphaned, +tombstoned, disputed, or unbound. A change in anchor status never deletes the +conversation or changes its message history. + +### Event, client, and privacy boundary + +The durable source of `about`, `anchored-to-part`, `derived-from`, and +`talk-for` mutations is the additive `chat.anchor.v1` chained-permanent event +in the conversation's existing group, as decided by #5872. Ordinary link +events bind, unbind, or re-locate an edge and carry the object ID plus author +key, relation, and by-reference selector when the relation is +`anchored-to-part`; they never embed object content or a capability. +`resolved-into` is not an anchor event: it is projected only from +`chat.resolution.v1` edit events under #5874. The event log(s) are authoritative; +`ConversationLink`, `TalkPageBinding`, current resolution, and reverse indexes +are deterministic projections. + +The existing `ChatLink` in `chat.message.v1` may also carry the `object` kind +selected by #5872 for an in-message object reference or a recognized pasted +link. That message link is not a substitute for a conversation/thread anchor +event. Ordinary `chat.message.v1` messages remain unchanged, and clients that +do not understand the anchor event can continue reading and sending ordinary +chat messages under #5872's unknown-event tolerance invariant. + +For ordinary links, fold mutations by causal ancestry in the event's `after` +frontier, not by arrival time or a presentation sort. A causally later event +supersedes only the operations it observes. If two unbind/relocate operations +are concurrent maximal heads for one `link_id`, preserve both as `disputed`; +#5872's event-ID tie-break orders the fold deterministically but is never +read as choosing one mutation. A resolving mutation must causally observe all +current heads. An unbind that has been resolved cannot be undone by a +relocation; a fresh bind receives a new `link_id`. `talk-for` +conflicts use #5872's separate single-canonical/disputed fold, and +`resolved-into` concurrency uses #5874's resolution fold. Apply authorization before returning a link or any projection of it. This includes its ID, endpoint IDs, relationship, part selector, fingerprint, resolution status, candidate count, reverse-index result, notification, and search hit. If the caller cannot read the target object, return no indication that the edge or target exists. Link metadata does not grant target access or -change conversation membership. Conversation visibility itself remains a -#5682 policy decision; implementations must ensure that transcript, title, -preview, and notification rendering do not disclose the private target. +change conversation membership. The parent sets the non-disclosure invariant; +the mixed-access conversation/talk-page visibility policy belongs to #5871, +not this record. Implementations must ensure that transcript, title, preview, +and notification rendering do not disclose the private target. The “always +visible” tombstone rendering in the #5873 terminal design applies only after +the authorized view includes the link; it never means that non-readers may +learn a private target exists. ## Alternatives rejected | Alternative | Reason for rejection | | --- | --- | | A pasted URL in a message | Not a first-class relationship, cannot reliably support reverse navigation, and has no typed selector or lifecycle. URLs may be kept as user-authored content but are not the canonical link. | -| Store the relationship only in the message body or envelope | Couples link lifecycle to message history, makes multi-object/thread links awkward, and risks exposing private target metadata through ordinary transcript delivery. | +| Store anchor state only in `chat.message.v1` or require a new mandatory envelope field | Couples link lifecycle to message history, makes multi-object/thread links awkward, and risks exposing private target metadata through ordinary transcript delivery. Use the already-decided additive `chat.anchor.v1` event instead. | | Store only offsets against the current object | Edits and version changes silently retarget positions; the same offsets can point at unrelated content. | | Store raw quote text in the link | Duplicates potentially private object content and can disclose it through sync, indexes, logs, or clients that lack object access. | | Always choose the “closest” or first relocation candidate | Approximate and ambiguous matches can point a discussion at the wrong content. Drift must be visible and confirmation required. | | Delete links when a part/object is deleted | Breaks reverse history and disconnects a conversation that the parent design says must survive; use orphan and tombstone states instead. | | Publish a tombstone or relation to every conversation reader | Reveals private-object existence; access checks must hide the edge itself, not merely its preview. | +| Treat `talk-for` as an ordinary `about` link | Loses #5872's one-canonical-talk-page binding and disputed-conflict semantics; keep a separate projection over its `chat.anchor.v1` binding. | +| Emit `resolved-into` as a `chat.anchor.v1` edge | Conflicts with #5874, which derives result-edit edges from `chat.resolution.v1` and pins the exact edit/revision. | +| Resolve concurrent mutations with last-write-wins or event-ID order | Event arrival and presentation tie-breaks do not establish user intent; preserve concurrent maxima as disputed until a causally later event resolves them. | | One universal coordinate format for all object regions | Text, media, tables, boards, and other object types have different semantics and units; typed object-native selectors are less ambiguous. | | Duplicate a reverse link record | Creates two sources of truth that can disagree; derive reverse navigation from the canonical edge. | -| Put link state in message bodies or require a protocol-version change | Couples link lifecycle to message history and breaks older clients; the additive event kinds decided in #5872 already preserve compatibility without a version change, so this record specifies no further protocol change. | +| Add another anchor wire format or change `chat.message.v1` | Duplicates the `chat.anchor.v1` event selected by #5872 or breaks v1 message compatibility; this record defines the selector carried by that event instead. | ## Implementation invariants Implementations of this decision must hold all of the following: -1. Every link has a stable `link_id`, a typed source and target, and one of the - four allowed relation/endpoint combinations above. +1. Every link has a typed source and object target and one of the four allowed + relation/endpoint combinations above. Its `link_id` is the initial + `chat.anchor.v1` bind event, or the owning `chat.resolution.v1` event for a + `resolved-into` result. Bind, unbind, relocation, and resolution events are + immutable and folded deterministically by their owning projection. 2. `anchored-to-part` has exactly one object target, one origin revision, and one valid selector. Ranges are non-empty half-open Unicode-scalar ranges; - block and region selectors are valid for the target object type. Every - selector has a URL-fragment-safe textual form (the `id://` reference with - a `#`-suffixed selector fragment) encoding the same canonical selector. -3. Link creation is idempotent for an identical edge, but separate selectors - are not collapsed. Bidirectional navigation is derived from the same - canonical record. + block and region selectors are valid for the target object type. Cross-edit + following is available only when that type provides the stable + identity/revision contract. +3. Re-delivery of an event is idempotent; separate bind events/selectors are + not collapsed. Bidirectional navigation is derived from the same folded + event history. `talk-for` is a separate binding projection, never a fifth + ordinary conversation-link relation. 4. No link or anchor field, status, candidate, count, search result, or notification reveals a private target's content or existence to a non-reader. A link never grants access. -5. Original revision and selector are immutable. Resolution is revision-bound - derived state, and only an exact deterministic mapping or unique exact - fingerprint match may retarget automatically. -6. Approximate or ambiguous matches are `drifted`, visibly warned, and never - silently followed. A resolver with no deterministic map, no unique - fingerprint match, and no retained origin revision marks the anchor - `unresolved` and offers no target until confirmation. Missing selectors are - `orphaned`; deletion of the whole object is `tombstoned`. +5. Original revision and selector are immutable. Cross-edit following is + allowed only for object types with the stable identity/revision contract. + Resolution is revision-bound derived state, and only an exact deterministic + mapping or unique exact fingerprint match may retarget automatically. +6. Approximate or ambiguous candidate matches are `drifted`; insufficient + evidence is `unresolved`; concurrent mutation heads are `disputed`. All + three are visibly warned and never silently followed. Proven removal is + `orphaned`; whole-object deletion is `tombstoned`; explicit unbind is + `unbound` and removes the edge from active navigation without erasing its + event history. 7. Orphaning or tombstoning a target does not delete the link, its conversation, or chat messages. No resolver follows content into a different object ID. -8. Unknown or unsupported link metadata does not prevent a client from reading - or sending ordinary chat messages; clients that render a link preserve its - status and warning rather than presenting a stale selector as current. +8. Unknown or unsupported `chat.anchor.v1` events do not prevent a client from + reading or sending ordinary `chat.message.v1` messages. `resolved-into` + projection follows #5874's `chat.resolution.v1` fold; clients that render a + link preserve its status and warning rather than presenting a stale + selector as current. No `resolved-into` edge is duplicated in + `chat.anchor.v1`. 9. Reverse lookup, search, and rendering apply object authorization before returning any existence-bearing result. -10. `about`, `anchored-to-part`, and `derived-from` edges fold - deterministically from `chat.anchor.v1` events and `resolved-into` edges - from `chat.resolution.v1` events (kind `edit`); replicas folding the same - log converge on the same edge set. +10. For one anchor `link_id`, a causally later mutation supersedes only the + events it observes. Concurrent maximal mutations remain `disputed`; + #5872's event-ID tie-break only makes the fold deterministic, never a + semantic winner. An explicit resolving mutation must observe every + competing head. A resolved unbind + cannot be undone by relocation; rebinding creates a fresh `link_id`. +11. `talk-for` cardinality/conflict folding follows #5872, and target binding + authority/visibility follows #5871; this link record does not duplicate or + override either policy. ## Parent-decision check and implementation handoff -This record refines the first feature in #5682; it does not reverse a parent -choice or take on talk-page, thread-visibility, terminal, or edit-loop policy. -It consumes the sibling mechanisms without re-deciding them: #5872's -`chat.anchor.v1` anchor events and `talk-for` binding, #5873's fragment-safe -textual selector frame, and #5874's `chat.resolution.v1` ownership of -`resolved-into` edges. It applies the parent's existing private-object -non-disclosure constraint to the link and resolver data. The one parent -wording boundary (a decision summary or no-action outcome with no addressable -result object remains thread-resolution state, not a reverse object edge) is -recorded explicitly on #5682 rather than silently forked. - -No implementation code is included here. The link shape and resolver form one -cohesive design unit; implementation sequencing and issue splitting remain -follow-up planning rather than additional decisions in this record. +This record refines the first feature in #5682 and consumes #5872, #5873, and +#5874; it does not take on talk-page, thread-visibility, terminal, or edit-loop +policy. It applies the parent's private-object non-disclosure constraint to +link, tombstone, and resolver data; the terminal tombstone marker is never +visible to a non-reader. + +One boundary is made explicit for the parent: #5682 describes `resolved-into` +as an edit/decision link, while #5874's selected event shape creates an +object-side `resolved-into` edge for an addressable edit result +(`chat.resolution.v1`, kind `edit`). A decision summary or no-action outcome +without an addressable result object remains a thread-resolution outcome, not +an object edge. This record does not alter #5874; if #5682 requires reverse +object navigation to non-object decision summaries as well, that requires a +parent decision and an addressable decision result. + +No implementation code is included here. The existing implementation track +[#6222](https://github.com/developing-today/code/issues/6222) consumes the +#5870 link vocabulary and selector grammar along with the #5871 visibility +decision; its gates remain unchanged. This record does not create a duplicate +implementation issue or change those gates. From 175cf52afbebe1838e1b97362d1f64091a23406e Mon Sep 17 00:00:00 2001 From: repo-worker-code-k Date: Tue, 10 Nov 2026 15:01:16 -0600 Subject: [PATCH 4/4] docs(id): address CodeRabbit review on chat anchor record (#5870) --- ...01-27-00Z_design_chat_anchor_data_model.md | 55 +++++++++++++++---- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/doc/2026-11-09T01-27-00Z_design_chat_anchor_data_model/2026-11-09T01-27-00Z_design_chat_anchor_data_model.md b/doc/2026-11-09T01-27-00Z_design_chat_anchor_data_model/2026-11-09T01-27-00Z_design_chat_anchor_data_model.md index 635bd614ec..6a698d91cd 100644 --- a/doc/2026-11-09T01-27-00Z_design_chat_anchor_data_model/2026-11-09T01-27-00Z_design_chat_anchor_data_model.md +++ b/doc/2026-11-09T01-27-00Z_design_chat_anchor_data_model/2026-11-09T01-27-00Z_design_chat_anchor_data_model.md @@ -107,6 +107,17 @@ summary or no-action resolution that has no addressable result object is not a `resolved-into` edge; it remains a thread-resolution outcome, not a fabricated object target. Proposal and approval mechanics remain with #5874. +Projecting a `resolved-into` edge requires the target `ObjectRef`, and the +mapping to it is guaranteed, not heuristic: the `chat.resolution.v1` edit +event names the target object and the resulting revision, and the +`author_key` is read from that object's own record. Where an object type +identifies edit results only by a stable logical ID, its adapter must +supply a deterministic mapping from that logical ID to the record +`(object_id, author_key)` pair as part of the identity contract below. +If no such mapping exists, the edge is not projected; the outcome stays +a thread-resolution outcome until the result has an addressable object +identity. + `talk-for` is a separate `chat.anchor.v1` binding projection, not a fifth `ConversationLink` relation. #5872 already defines its single-canonical binding and disputed-conflict fold; #5871 owns who may bind and the lifecycle @@ -167,9 +178,16 @@ pa1~g~~1~~~ `r`, `b`, and `g` mean range, block, and region. The revision, part, block, and selector-type fields are UTF-8 percent-encoded, leaving only ASCII -alphanumerics, `.`, `_`, and `-` unescaped (`~` is always escaped inside a -field, so it remains an unambiguous separator). In the region form, `0` means -there is no part ID and `1` means the next field is a part ID; no sentinel is +alphanumerics, `.`, `_`, and `-` unescaped. Inside a field, a literal `~` +is written `~~` and a literal `%` is written `%25`; the field encoding +never uses `%7E`. Parsing scans a field left to right: `~~` decodes to +one literal `~`, a lone `~` is the separator, and percent-decoding runs +exactly once, only after the fields have been split. Because no field +can contain `%7E`, a URL normalizer that decodes percent-encoded +unreserved characters cannot manufacture a separator inside a field, +and a fragment whose field count does not match the form above is +malformed and must be rejected, never parsed leniently. In the region +form, `0` means there is no part ID and `1` means the next field is a part ID; no sentinel is overloaded as a valid ID. Range offsets are decimal Unicode-scalar values. The region `value` is the unpadded base64url encoding of the object type's canonical UTF-8 selector value. This grammar is safe in a URL fragment and has @@ -199,8 +217,10 @@ save creating a new event ID (the document model described in #2259 is an example). Such an ID is version-specific unless that object type separately defines a stable logical ID. `about` may target any addressable ID object. A part anchor can follow later edits only when the object's adapter supplies the -identity/revision contract above; otherwise the anchor is pinned to that -version and cannot automatically follow a new object ID. +identity/revision contract above, including, for record-per-save models, a +deterministic mapping from each new record object ID to the same stable +logical ID; otherwise the anchor is pinned to that version and cannot +automatically follow a new object ID. ### Edit, version, and delete survival @@ -213,10 +233,13 @@ uses these states and rules: identity maps the selection exactly, resolve it as **current** with no warning. 2. Otherwise, if the resolver finds exactly one match for the opaque content - fingerprint in the same object's revision lineage, resolve it as - **relocated** and show a non-blocking “anchor moved” warning. Preserve both - original and resolved selectors. Confirmed relocation is recorded by a - new `chat.anchor.v1` event; the initial binding event is never rewritten. + fingerprint in the target revision, resolve it as + **relocated** and show a non-blocking “anchor moved” warning. Candidate + counting is scoped to the target revision: matches in other revisions + of the lineage neither add candidates nor make this one ambiguous. + Preserve both original and resolved selectors. Confirmed relocation is + recorded by a new `chat.anchor.v1` event; the initial binding event is + never rewritten. 3. If only an approximate match exists, or more than one candidate exists, mark it **drifted**. Warn, retain the original anchor, and require a person or object-specific resolver to confirm a candidate before navigation @@ -267,6 +290,12 @@ key, relation, and by-reference selector when the relation is `ConversationLink`, `TalkPageBinding`, current resolution, and reverse indexes are deterministic projections. +Link events replicate with the conversation group's existing event +stream, exactly as the other chained events in that group do; this +record defines no new replication transport and does not rely on a +#2036 application metadata/extension path, which #2036 does not define +for link records. + The existing `ChatLink` in `chat.message.v1` may also carry the `object` kind selected by #5872 for an in-message object reference or a recognized pasted link. That message link is not a substitute for a conversation/thread anchor @@ -340,7 +369,8 @@ Implementations of this decision must hold all of the following: 5. Original revision and selector are immutable. Cross-edit following is allowed only for object types with the stable identity/revision contract. Resolution is revision-bound derived state, and only an exact deterministic - mapping or unique exact fingerprint match may retarget automatically. + mapping or a unique exact fingerprint match within the target revision + may retarget automatically. 6. Approximate or ambiguous candidate matches are `drifted`; insufficient evidence is `unresolved`; concurrent mutation heads are `disputed`. All three are visibly warned and never silently followed. Proven removal is @@ -348,7 +378,10 @@ Implementations of this decision must hold all of the following: `unbound` and removes the edge from active navigation without erasing its event history. 7. Orphaning or tombstoning a target does not delete the link, its conversation, - or chat messages. No resolver follows content into a different object ID. + or chat messages. No resolver follows content into a different logical + object: following across changing record object IDs is permitted only + where the identity contract maps them to the same stable logical + identity, and content similarity alone never establishes that mapping. 8. Unknown or unsupported `chat.anchor.v1` events do not prevent a client from reading or sending ordinary `chat.message.v1` messages. `resolved-into` projection follows #5874's `chat.resolution.v1` fold; clients that render a