Skip to content

Commit afa4fff

Browse files
committed
refactor(core): group APIs and document design
1 parent 51240fe commit afa4fff

36 files changed

Lines changed: 693 additions & 242 deletions

‎docs/core-guide.zh.md‎

Lines changed: 449 additions & 0 deletions
Large diffs are not rendered by default.

‎docs/proposals/core.zh.md‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Core 提供共同的声明外壳和协商入口。领域协议负责解释自身
4949

5050
```ts
5151
interface ProtocolDeclaration {
52-
readonly participant: ParticipantIdentity
52+
readonly participant: { readonly id: string }
5353
readonly requires?: readonly ProtocolRequirement[]
5454
readonly supports?: readonly ProtocolSupport[]
5555
}
@@ -141,22 +141,20 @@ Core 只要求身份在当前协商范围内唯一。身份如何认证、是否
141141

142142
Manifest facet 不是 participant。Facet 是发行物中的静态声明和激活单位;participant 是 coordinator 为 activation instance 创建、实际参加某次协商的运行实体。组件模型第一版令一个 activation instance 对应一个本地 participant;同一 facet 的多次激活仍会产生不同 participants。产品也可以产生没有 manifest facet 的内建 participant。
143143

144-
Core 不把 component id、facet name 或进程位置规定为 `ParticipantIdentity` 的固定字段。需要归属信息的实现通过 lifecycle/provenance 保存本地关联;向连接对端公开哪些关联由 connection view 和 policy 决定。
144+
Core 不把 component id、facet name 或进程位置规定为 participant 身份的固定字段。需要归属信息的实现通过 lifecycle/provenance 保存本地关联;向连接对端公开哪些关联由 connection view 和 policy 决定。
145145

146146
### Protocol definition
147147

148148
`ProtocolDefinition` 是 evaluator 对一份领域协议的本地解释。概念接口如下:
149149

150150
```ts
151-
interface ProtocolValidationContext extends ApiReference {}
152-
153151
interface ProtocolDefinition<RequirementSpec = unknown, SupportSpec = unknown, Agreement = unknown>
154152
extends ApiReference {
155153
readonly accepts?: readonly string[]
156-
validateRequirement(spec: unknown, context: ProtocolValidationContext): RequirementSpec
157-
validateSupport(spec: unknown, context: ProtocolValidationContext): SupportSpec
158-
readonly validateAgreement?: (agreement: unknown, context: ProtocolValidationContext) => Agreement
159-
negotiate(input: ProtocolNegotiationInput<RequirementSpec, SupportSpec>): ProtocolNegotiationResult<Agreement>
154+
validateRequirement(spec: unknown, context: ApiReference): RequirementSpec
155+
validateSupport(spec: unknown, context: ApiReference): SupportSpec
156+
readonly validateAgreement?: (agreement: unknown, context: ApiReference) => Agreement
157+
negotiate(input: ProtocolNegotiationInput<RequirementSpec, SupportSpec>): ProtocolNegotiationOutcome<Agreement>
160158
}
161159
```
162160

@@ -248,6 +246,17 @@ Core 不能独自判断领域协议是否真正兼容。Evaluator 必须安装
248246

249247
## Implementation boundary
250248

249+
TypeScript 参考实现按用途提供四个入口:
250+
251+
| 入口 | 内容 |
252+
| --- | --- |
253+
| `@dsh-std/core` | 协议声明、definition、catalog 与协商报告 |
254+
| `@dsh-std/core/identity` | 协议坐标的校验、比较与索引键 |
255+
| `@dsh-std/core/json` | 协议 JSON 数据校验与冻结快照 |
256+
| `@dsh-std/core/version` | 组件包的 SemVer 与版本范围工具 |
257+
258+
参与者身份直接使用 `{ id }`,评估器身份直接使用 `{ name, version }`。校验上下文使用 `ApiReference`,协商输入的每行直接包含 participant 和相应 requirement 或 support。
259+
251260
`@dsh-std/core` 的参考实现只保留通用协议标识、声明、definition catalog 与协商分派。早期原型中的 `DshResource`、`ExecutionPlane`、插件关系、`PluginRegistry` 和 `RuntimeSnapshot` 已迁移出 core:
252261

253262
- 静态插件包声明和关系进入 manifest/composition;

‎docs/proposals/endpoint-connection.zh.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ interface ParticipantImplementationEndpoint {
159159
}
160160

161161
interface ParticipantLease {
162-
readonly participant: ParticipantIdentity
162+
readonly participant: { readonly id: string }
163163
readonly revision: number
164164
readonly signal: AbortSignal
165165

‎docs/proposals/events.zh.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ interface EventEnvelope<Payload = unknown> {
5555
readonly apiVersion: string
5656
readonly kind: string
5757
readonly id: string
58-
readonly source: ParticipantIdentity
58+
readonly source: { readonly id: string }
5959
readonly sequence?: number
6060
readonly time?: string
6161
readonly payload: Payload

‎docs/proposals/version-compatibility.zh.md‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,22 @@
5555

5656
`ProtocolDefinition.accepts` 可以把多个 `apiVersion` 映射到同一份 definition。每个被接受的版本仍与原 `kind` 组成独立坐标。Core 必须拒绝由不同 definitions 重复注册的相同坐标。
5757

58-
Core 不得从 `apiVersion` 的 group、major、stability、revision 或字符串顺序推断兼容关系。`protocolFamilyKey()` 只提供分组键,不构成互操作声明。
58+
Core 不得从 `apiVersion` 的 group、major、stability、revision 或字符串顺序推断兼容关系。
5959

6060
Definition 可以识别不同稳定度、不同 major,或由私有协议规定的离散版本集合。是否允许这些版本互操作完全由该协议的规范决定。
6161

6262
### 版本感知校验
6363

64-
Core 调用 `validateRequirement` 和 `validateSupport` 时,必须同时提供包含原始 `apiVersion + kind` 的 `ProtocolValidationContext`。Definition 必须针对声明的准确版本校验 `spec`,不得先把旧版本静默投影为新版本再按新 schema 接受。
64+
Core 调用 `validateRequirement` 和 `validateSupport` 时,必须同时提供包含原始 `apiVersion + kind` 的 `ApiReference`。Definition 必须针对声明的准确版本校验 `spec`,不得先把旧版本静默投影为新版本再按新 schema 接受。
6565

6666
概念接口如下:
6767

6868
```ts
69-
interface ProtocolValidationContext extends ApiReference {}
70-
7169
interface ProtocolDefinition<RequirementSpec, SupportSpec, Agreement, Policy>
7270
extends ApiReference {
7371
readonly accepts?: readonly string[]
74-
validateRequirement(spec: unknown, context: ProtocolValidationContext): RequirementSpec
75-
validateSupport(spec: unknown, context: ProtocolValidationContext): SupportSpec
72+
validateRequirement(spec: unknown, context: ApiReference): RequirementSpec
73+
validateSupport(spec: unknown, context: ApiReference): SupportSpec
7674
negotiate(
7775
input: ProtocolNegotiationInput<RequirementSpec, SupportSpec, Policy>,
7876
): ProtocolNegotiationOutcome<Agreement>
@@ -193,7 +191,7 @@ npm package version 与协议 `apiVersion` 是独立版本轴。更新 definitio
193191

194192
## 兼容性
195193

196-
只识别主坐标并执行精确版本协商的既有 definitions 不受影响。为校验函数增加 `ProtocolValidationContext` 是向后兼容的调用扩展:现有只接收 `spec` 的 TypeScript 函数仍可作为 validator;新 definition 可以读取第二个参数进行版本专属校验。
194+
只识别主坐标并执行精确版本协商的既有 definitions 不受影响。为校验函数增加 `ApiReference` 是向后兼容的调用扩展:现有只接收 `spec` 的 TypeScript 函数仍可作为 validator;新 definition 可以读取第二个参数进行版本专属校验。
197195

198196
把版本加入 `accepts` 是可观察的 definition 能力变更,但不自动建立任何兼容边。协议只有在规范、validator、协商器、agreement、fixtures 和方向性测试一致时,才能声称支持跨版本协商。
199197

‎packages/adapter-dsh/CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Updated core utility imports to the grouped public entry points.
6+
57
- Adapted lifecycle activation identities to carry a required generation while projecting UI contribution owners through the existing UI owner schema.
68

79
## 0.1.1-rc.4

‎packages/adapter-dsh/src/client.ts‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,8 @@ import { createElement as h, useEffect, useState, type ReactNode } from 'react'
55
import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
66
import type {} from '@deepseek-ai/dsh-client-ui-tool/client'
77
import type { TypertRemoteContribution } from '@deepseek-ai/dsh-typert-protocol'
8-
import {
9-
ProtocolCatalog,
10-
defineProtocolDeclaration,
11-
sameProtocol,
12-
type ApiReference,
13-
type NegotiatedProtocol,
14-
} from '@dsh-std/core'
8+
import { ProtocolCatalog, defineProtocolDeclaration, type ApiReference, type NegotiatedProtocol } from '@dsh-std/core'
9+
import { sameProtocol } from '@dsh-std/core/identity'
1510
import {
1611
defineComponentManifest,
1712
findFacet,

‎packages/adapter-dsh/src/index.ts‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,8 @@ import type {
1818
import type {} from '@deepseek-ai/dsh-agent'
1919
import { Remote, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol'
2020
import z from '@deepseek-ai/schemastery'
21-
import {
22-
ProtocolCatalog,
23-
defineProtocolDeclaration,
24-
sameProtocol,
25-
validateApiReference,
26-
type ApiReference,
27-
type ProtocolRequirement,
28-
type ProtocolSupport,
29-
} from '@dsh-std/core'
21+
import { ProtocolCatalog, defineProtocolDeclaration, type ApiReference, type ProtocolRequirement, type ProtocolSupport } from '@dsh-std/core'
22+
import { sameProtocol, validateApiReference } from '@dsh-std/core/identity'
3023
import {
3124
ManifestDefinitionCatalog,
3225
defineComponentManifest,

‎packages/command/CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Changes to `@dsh-std/command` are recorded here.
44

5+
## Unreleased
6+
7+
- Updated core utility imports to the grouped public entry points.
8+
59
## 0.1.1-rc.1
610

711
- Aligned the package with the workspace `0.1.1` prerelease line without changing the existing Command protocol semantics.

‎packages/command/src/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
ProtocolIssue,
66
ProtocolSupport,
77
} from '@dsh-std/core'
8-
import { validateApiReference } from '@dsh-std/core'
8+
import { validateApiReference } from '@dsh-std/core/identity'
99
import type { ManifestDefinitionCatalog, ManifestExtension } from '@dsh-std/manifest'
1010
import type {
1111
CapabilityCall,

0 commit comments

Comments
 (0)