Skip to main content

collab-surface-core

Use when adding collaborative markdown, notes, or descriptions to a feature with collab surfaces. Covers parent entities, service entry points, authorization, content storage, and lifecycle.

来源信息

仓库
macro-inc/macro
最近来源活动
2026年10月5日 22:50
检测到的 SKILL.md 语言
英语
星标
4,599
分支
446

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

文件资源管理器
2 个文件

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
collab-surface-core
description
Use when adding collaborative markdown, notes, or descriptions to a feature with collab surfaces. Covers parent entities, service entry points, authorization, content storage, and lifecycle.
# Collab surface core Use collab surfaces for collaborative markdown within a feature. Each surface has its own Loro session in sync-service and can exist without a `Document` row. The surface is a child resource of an app entity: product names, owners, sharing, and discovery belong to the parent. ## Choose the entry point - **A field managed by its parent domain**, such as an initiative description: use `OwnedSurfaceService` through the feature's domain port. The owning domain authorizes callers and chooses the surface id before calling `ensure_owned_surface`, `owned_surface_markdown`, or `retire_surface`. - **A surface managed through the public API**, such as a channel's shared input: use `CollabSurfaceService` with an access receipt for the parent. Surface reads, connection tokens, and deletion derive their permissions from that parent. Check `surface_ownership` and the parent's access resolution when adding a new parent type. Parents marked `ParentDomain` use their domain's creation and retirement paths; the public API still provides connection tokens. Keep the trusted `OwnedSurfaceService` behind domain authorization, with adapters supplied by the composition root. ## Keep content and lifecycle with their owners - The Loro session is the source of truth for content. `collab_surfaces` records the id, parent, initialization state, timestamps, and soft deletion. - Use application-generated UUIDv7 ids and the service's ensure operation. It handles namespace collisions and retries initialization from `pending` to `ready`. The id also names the sync session and must never be recycled. - Initial markdown seeds a new session. Ensuring an existing surface preserves its content; subsequent edits go through the collaborative session. - Wire retirement into the owning feature's cleanup. The parent reference is polymorphic and has no foreign-key cascade. Retirement blocks new connection tokens; it does not reclaim the sync-service session. Read the [domain ports](../../../crates/collab_surface/src/domain/ports.rs) and [parent policy](../../../crates/collab_surface/src/domain/models.rs) before wiring a consumer. The [initiative adapter](../../../crates/initiative_description/src/lib.rs) shows how a feature reuses the service through its own domain port.
在 GitHub 查看