From 44165ccc3e6394177bb7e6dc2883f0984a5138a1 Mon Sep 17 00:00:00 2001 From: Turtle Date: Thu, 19 Nov 2026 10:27:07 +0800 Subject: [PATCH 1/5] docs: add DSH Core Guidelines with format and callback rules --- .agents/skills/dsh-code-review/SKILL.md | 1 + AGENTS.md | 8 +- docs/AGENTS.md | 3 +- docs/core-guidelines.i18n.yaml | 70 +++++++++++ docs/core-guidelines.md | 157 ++++++++++++++++++++++++ docs/core-guidelines.zh.md | 157 ++++++++++++++++++++++++ 6 files changed, 392 insertions(+), 4 deletions(-) create mode 100644 docs/core-guidelines.i18n.yaml create mode 100644 docs/core-guidelines.md create mode 100644 docs/core-guidelines.zh.md diff --git a/.agents/skills/dsh-code-review/SKILL.md b/.agents/skills/dsh-code-review/SKILL.md index 406375ff61..0a244716ed 100644 --- a/.agents/skills/dsh-code-review/SKILL.md +++ b/.agents/skills/dsh-code-review/SKILL.md @@ -12,6 +12,7 @@ description: Use when reviewing a pull request in the deepseek-harness repo — ## Sources of truth - [AGENTS.md](../../../AGENTS.md) and [packages/AGENTS.md](../../../packages/AGENTS.md): standing repository and package authoring rules. +- [DSH Core Guidelines](../../../docs/core-guidelines.md): numbered design rules every change follows; cite a violated rule by its ID. - [docs/defensive-patterns/](../../../docs/defensive-patterns/README.md): the architecture requirements a change must satisfy and the habits behind them. Each page owns one artifact; read every page the diff touches: - [general.md](../../../docs/defensive-patterns/general.md) — timing, async state, value representation, shared ownership, decentralization, refactors, migrations, performance evidence, disposal, callbacks, subprocesses. - [package-surface.md](../../../docs/defensive-patterns/package-surface.md) — exports, package shape, build faces, dependency declarations, resolve hooks. diff --git a/AGENTS.md b/AGENTS.md index f4b150a8df..ebb6b8dda5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -169,9 +169,11 @@ Real-API tests/demos read `DEEPSEEK_API_KEY`, optional `DEEPSEEK_BASE_URL`, and - TODO markers: `FIXME`/`TODO`/`XXX` by urgency ([semantics](docs/development.md)). - Files end with exactly one trailing newline; `git diff --cached --check` (pre-commit) gates it. -## Defensive patterns +## Review rules -Read [docs/defensive-patterns/README.md](docs/defensive-patterns/README.md) before changing a package surface, remote service, client component or state, conversation or Session behavior, or lifecycle, concurrency, subprocess, and teardown code. Its [review principles](docs/defensive-patterns/README.md#why-these-rules) apply per artifact. +Before finishing, self-review against [DSH Core Guidelines](docs/core-guidelines.md). + +Read [docs/defensive-patterns/README.md](docs/defensive-patterns/README.md) before changing a package surface, remote service, client component or state, conversation or Session behavior, or lifecycle, concurrency, subprocess, and teardown code. ## Type safety and documentation @@ -183,7 +185,7 @@ Docs accompany every code change: update affected README and JSDoc contracts tog ## Editing these instructions -`CLAUDE.md` symlinks `AGENTS.md` at root and `packages/`; edit the real file. Keep each rule self-contained while linking high-level docs. Condense when clarity survives; raise a `verify-doc-budgets` ceiling when the required content genuinely needs more space. +`CLAUDE.md` symlinks `AGENTS.md` at root and `packages/`; edit the real file. Keep each rule self-contained while linking high-level docs. Condense when clarity survives; raise a `verify-doc-budgets` ceiling when the required content needs more space. ## Vendoring policy diff --git a/docs/AGENTS.md b/docs/AGENTS.md index 70e40c2b68..83353bdbb7 100644 --- a/docs/AGENTS.md +++ b/docs/AGENTS.md @@ -24,6 +24,7 @@ Each fact has one home: the tier whose job it is; elsewhere, link there. | [subsystems/](subsystems/README.md) | One reference page per subsystem: type definitions, semantics, and the generated Cordis API | Behavior narration (→ architecture.md) | | [Agent Notes](../.agents/notes/README.md) | Active decision records: the why, what-was-given-up, and required verification; `implemented/` notes describe shipped reality in present tense | Migration plans, acceptance-task checklists, fixture walkthroughs, and spec-speak ("should…") once the decision has shipped; archived notes are frozen history, never current authority | | [defensive-patterns/](defensive-patterns/README.md) | Rules this repository enforces in review, split by artifact: one general bug-class page plus per-domain pages | Type definitions and semantics (→ subsystems), decision rationale (→ Agent Notes) | +| [core-guidelines.md](core-guidelines.md) | Numbered design rules that apply across artifacts, in the format its rule G.1 defines | Artifact-specific review rules (→ defensive-patterns/) | | [postmortem/](postmortem/README.md) | Incident stories — the only tier where war-story narrative belongs | — | | [Persistence history](persistence-changes/README.md) and [format references](persistence-changes/historical-formats/README.md) | Type-change acknowledgements, release comparisons, and complete historical format schemas | Behavior-only changes; current runtime contracts | | [cookbook/](cookbook/adding-a-package.md) | Step-by-step how-tos with numbered verify steps | Design rationale (→ the Agent Note each guide links) | @@ -33,7 +34,7 @@ Each fact has one home: the tier whose job it is; elsewhere, link there. | Generated reference: the per-page `cordis-surface` regions in [subsystems/](subsystems/README.md), the [Cordis core API + inherited tier](cordis-api/context.md), [tool-catalog](tool-catalog.md), [config-catalog](config-catalog.md), [persistence-catalog](persistence-catalog.md), [module-graph.md](module-graph.md), [cli-help](cli-help.md) | Exhaustive English sources regenerated from source and freshness-gated; reviewed Chinese counterparts follow the [pairing workflow](i18n/README.md#scope-and-exclusions) | Hand edits to generated English sources or regions; Chinese counterparts update through pairing only | | Skills (`.agents/skills/`) | Reusable workflows and specialized decision standards | Product and runtime contracts (→ docs or source) | -Placement: bugs → postmortems; rationale → Agent Notes; procedures → cookbooks; type definitions → subsystems; package contracts → READMEs; standing orders → root `AGENTS.md` with a rationale link; review-enforced rules → `defensive-patterns/`. +Placement: bugs → postmortems; rationale → Agent Notes; procedures → cookbooks; type definitions → subsystems; package contracts → READMEs; standing orders → root `AGENTS.md` with a rationale link; review-enforced rules → `defensive-patterns/`; numbered design rules → `core-guidelines.md`. ## Writing rules diff --git a/docs/core-guidelines.i18n.yaml b/docs/core-guidelines.i18n.yaml new file mode 100644 index 0000000000..9a2ef12b80 --- /dev/null +++ b/docs/core-guidelines.i18n.yaml @@ -0,0 +1,70 @@ +# Bilingual-pair consistency record for core-guidelines.md (docs/i18n/README.md): per heading +# section, a hash of its English and Chinese blocks outside code blocks and generated regions. +# After editing either side, bring the other along and re-record with: +# pnpm run verify-translation-pairing --write docs/core-guidelines.md +/dsh-core-guidelines: + en: 0d88d81c166137a1 + zh: 6fb75b66349a71c7 +/dsh-core-guidelines/summary: + en: 94a60bd7d96f9dd8 + zh: 34635496ca2df301 +/dsh-core-guidelines/table-of-contents: + en: 676d77a6df3ef329 + zh: 704976c22d1fed30 +/dsh-core-guidelines/introduction: + en: 471d3a01e46a044f + zh: bb723668575e357e +/dsh-core-guidelines/g-general: + en: 5a914c4912866bf1 + zh: a123355f35847798 +/dsh-core-guidelines/g-general/g-1-write-every-rule-in-the-standard-format: + en: c77afd940b6e2b93 + zh: 0e35654e184486ca +/dsh-core-guidelines/g-general/g-1-write-every-rule-in-the-standard-format/reason: + en: 94643c68676a916f + zh: 6c4c7a43b562a670 +/dsh-core-guidelines/g-general/g-1-write-every-rule-in-the-standard-format/example-bad: + en: 65b6e95e50f03989 + zh: a7c52ca22340707a +/dsh-core-guidelines/g-general/g-1-write-every-rule-in-the-standard-format/example: + en: 1e720ea2922f5b63 + zh: 84febcc229b4a659 +/dsh-core-guidelines/g-general/g-1-write-every-rule-in-the-standard-format/note: + en: 6c7f43c93975617d + zh: 381b92c255089193 +/dsh-core-guidelines/g-general/g-1-write-every-rule-in-the-standard-format/enforcement: + en: 32df1e18b06f45bc + zh: 9cba430d047ab565 +/dsh-core-guidelines/g-general/g-2-avoid-callbacks-in-public-interface-parameters: + en: 3f2b8e6b2e953ff8 + zh: 6156e6d170d26434 +/dsh-core-guidelines/g-general/g-2-avoid-callbacks-in-public-interface-parameters/reason: + en: cc8ca16db3a2da91 + zh: c05a6e21786901de +/dsh-core-guidelines/g-general/g-2-avoid-callbacks-in-public-interface-parameters/example-bad: + en: 3c9a74a8c000ae05 + zh: 96ead304ef98c8fd +/dsh-core-guidelines/g-general/g-2-avoid-callbacks-in-public-interface-parameters/example: + en: c66c0222aed09bd3 + zh: 017f2656c010a48d +/dsh-core-guidelines/g-general/g-2-avoid-callbacks-in-public-interface-parameters/alternative: + en: 0e2a32c8d51f4d87 + zh: faa8abfee1fb7fa1 +/dsh-core-guidelines/g-general/g-2-avoid-callbacks-in-public-interface-parameters/exception: + en: 4894c74a9319c956 + zh: a9fcac332f3d9320 +/dsh-core-guidelines/g-general/g-2-avoid-callbacks-in-public-interface-parameters/note: + en: 104d10a10fd00535 + zh: 4c1cb92cf2f50aef +/dsh-core-guidelines/g-general/g-2-avoid-callbacks-in-public-interface-parameters/enforcement: + en: c850502b3e29b501 + zh: 3c97c8807e632aa6 +/dsh-core-guidelines/f-frontend: + en: ba041561ab400a46 + zh: 78263a4c6e5f61da +/dsh-core-guidelines/b-backend: + en: 80f90e1debfdb017 + zh: bec00d38ccd1af65 +/dsh-core-guidelines/d-data-exchange: + en: bea86bb1a2093862 + zh: e03322d1b1045e04 diff --git a/docs/core-guidelines.md b/docs/core-guidelines.md new file mode 100644 index 0000000000..26870db8d2 --- /dev/null +++ b/docs/core-guidelines.md @@ -0,0 +1,157 @@ +# DSH Core Guidelines + +English | [中文](core-guidelines.zh.md) + +## Summary + +Rules for writing DeepSeek Harness code, in the style of the [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines). Each rule has a stable ID and the parts that [G.1](#g1) defines. + +## Table of Contents + +- [Introduction](#in) +- [G: General](#g) + - [G.1: Write every rule in the standard format](#g1) + - [G.2: Avoid callbacks in public interface parameters](#g2) +- [F: Frontend](#f) +- [B: Backend](#b) +- [D: Data exchange](#d) + + +## Introduction + +Before you finish a change, review the code it adds or modifies against every rule on this page. Fix each violation, or state in the change why the rule does not apply. A change does not have to migrate existing code it does not otherwise touch. + +Cite a rule by its ID, for example "violates G.2". Artifact-specific review rules live in [defensive patterns](defensive-patterns/README.md); read them as well. + + +## G: General + +Rules for all code in this repository, and for this page. + + +### G.1: Write every rule in the standard format + +#### Reason + +A fixed format puts the requirement, its justification, and its limits in the same place in every rule. A stable ID lets reviews cite a rule without quoting it. + +#### Example, bad + +```md +### Callbacks + +Callbacks caused bugs before, so prefer other designs where possible. +``` + +No ID. No imperative title. The requirement is buried in the rationale, and nothing says how to detect a violation. + +#### Example + +```md + +### G.9: + +#### Reason +#### Example, bad +#### Example +#### Enforcement +``` + +#### Note + +A rule section is a level-2 heading `: `, preceded by an `` anchor of its lowercased letter and followed by one paragraph that states its scope. `` is one or more capital letters, unique on this page. + +A rule is a level-3 heading `.: ` inside its rule section. An `<a id>` anchor, the lowercased ID without the dot, precedes the heading. `<n>` counts from 1 in order of addition. A removed rule's number is never reused. + +The title is one imperative sentence that states the requirement. + +The body is a sequence of level-4 headings in this order. `Reason` and `Enforcement` are required. Give at least one of `Example, bad` and `Example`. Omit any other heading that has no content. + +- `Reason`: the defect or cost the rule prevents. +- `Example, bad`: a violation. +- `Example`: compliant code for the same case. +- `Alternative`: what to use instead of a forbidden construct. +- `Exception`: cases the rule does not cover. +- `Note`: definitions and details. +- `Enforcement`: the check that rejects a violation, or what a reviewer flags. + +Write short, direct sentences. + +#### Enforcement + +Review: flag a rule that deviates from this format. `verify-translation-pairing` rejects a page whose two language versions differ in structure. + +<a id="g2"></a> +### G.2: Avoid callbacks in public interface parameters + +#### Reason + +A callback lets the callee run caller code at times the callee chooses. The signature does not say when the callback runs, how often, whether it runs after the returned promise settles, or where its exceptions go. The callee becomes a dispatcher that must [contain callback exceptions](defensive-patterns/general.md#contain-callback-exceptions-in-the-dispatcher) and stop calling after cancellation or disposal. A function cannot cross a process boundary, so the interface cannot later become a `@Remote` or SDK method. + +#### Example, bad + +```ts +export interface UploadProgress { readonly loaded: number; readonly total?: number } + +/** Upload `data`; `onProgress` runs for each chunk. */ +export declare function upload( + data: Uint8Array, + onProgress?: (progress: UploadProgress) => void, +): Promise<string> +``` + +Can `onProgress` run after the promise settles? What happens when it throws? The signature does not say. + +#### Example + +```ts +export type UploadEvent = + | { readonly type: 'progress'; readonly loaded: number; readonly total?: number } + | { readonly type: 'done'; readonly fileId: string } + +/** + * Upload `data`. Yields one `progress` per chunk, then one `done`. + * A failure rejects the next read; leaving the loop cancels the upload. + */ +export declare function upload(data: Uint8Array): AsyncIterable<UploadEvent> +``` + +Order, failure, and cancellation follow the iteration protocol. The caller's exceptions stay in the caller's loop. + +#### Alternative + +- One result: return a `Promise`. +- An intermediate result, such as the id of a created child before a later step: split the operation into calls that the caller sequences. +- A sequence of values: return an `AsyncIterable`. +- A notification for any number of listeners: emit a typed Cordis event that consumers subscribe to with `ctx.on()`. +- A replaceable strategy or factory: declare a Cordis service that providers implement. + +#### Exception + +- A registration API that returns its disposer, such as `ctx.on()`, `ctx.effect()`, or a registry's `register()`, including a registered object with handler members. +- A function that the callee finishes calling before the call returns or its promise settles, whose exceptions reach the caller, and that the callee does not keep, such as a comparator or a task run under a lock. +- A continuation the callee passes to a handler, such as a waterfall `next()`. +- An action callback in a client component prop or slot `inject` member, such as `onClick`. + +#### Note + +A public interface is a package entry-point export, a Cordis service method, a `@Remote` method, or an SDK method. + +#### Enforcement + +Review: flag a function-typed parameter, or a function-typed field of an options parameter, in a new or changed public interface that no exception covers. + +<a id="f"></a> +## F: Frontend + +Rules for client packages and apps that render the Web and Desktop UI. This section has no rules. + +<a id="b"></a> +## B: Backend + +Rules for Host-side packages: agent runtime, services, tools, and process management. This section has no rules. + +<a id="d"></a> +## D: Data exchange + +Rules for data that crosses a process, network, or storage boundary: `@Remote` and SDK messages, events, and persisted Session data. This section has no rules. diff --git a/docs/core-guidelines.zh.md b/docs/core-guidelines.zh.md new file mode 100644 index 0000000000..84146e0404 --- /dev/null +++ b/docs/core-guidelines.zh.md @@ -0,0 +1,157 @@ +# DSH 核心准则 + +[English](core-guidelines.md) | 中文 + +## 概述 + +编写 DeepSeek Harness 代码的规则,风格沿用 [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines)。每条规则有一个稳定编号,以及 [G.1](#g1) 规定的各个部分。 + +## 目录 + +- [引言](#in) +- [G:通用](#g) + - [G.1:每条规则都按标准格式编写](#g1) + - [G.2:避免在公共接口参数中使用回调](#g2) +- [F:前端](#f) +- [B:后端](#b) +- [D:数据交换](#d) + +<a id="in"></a> +## 引言 + +完成变更之前,对照本页每条规则审查该变更新增或修改的代码。修复每处违规,或在变更中说明该规则为何不适用。变更不必迁移它本来不改动的已有代码。 + +按编号引用规则,例如“违反 G.2”。针对具体产物的审查规则见[防御性模式](defensive-patterns/README.zh.md),同样需要阅读。 + +<a id="g"></a> +## G:通用 + +适用于本仓库全部代码以及本页本身的规则。 + +<a id="g1"></a> +### G.1:每条规则都按标准格式编写 + +#### 原因 + +固定格式让每条规则的要求、理由和适用范围都出现在同一位置。稳定编号让审查无需引述原文即可引用规则。 + +#### 反例 + +```md +### Callbacks + +Callbacks caused bugs before, so prefer other designs where possible. +``` + +没有编号,标题不是祈使句。要求埋在理由里,也没有说明如何发现违规。 + +#### 示例 + +```md +<a id="g9"></a> +### G.9: <One imperative sentence> + +#### Reason +#### Example, bad +#### Example +#### Enforcement +``` + +#### 注解 + +一个规则分组是一个二级标题 `<字母>:<名称>`,前面放一个取值为小写字母的 `<a id>` 锚点,后接一段说明该分组范围的文字。`<字母>` 由一个或多个大写字母组成,在本页内唯一。 + +一条规则是所属规则分组内的一个三级标题 `<字母>.<n>:<标题>`。标题前放一个 `<a id>` 锚点,取值为去掉点号的小写编号。`<n>` 按添加顺序从 1 开始计数。删除的规则编号不再复用。 + +标题是一句陈述要求的祈使句。 + +正文是按以下顺序排列的四级标题。`原因` 和 `检查方式` 必需。`反例` 与 `示例` 至少给出一个。其他标题没有内容时省略。括号中是英文版的标题。 + +- `原因`(`Reason`):规则防止的缺陷或代价。 +- `反例`(`Example, bad`):一处违规。 +- `示例`(`Example`):同一场景下合规的代码。 +- `替代方案`(`Alternative`):被禁止的写法应替换成什么。 +- `例外`(`Exception`):规则不覆盖的情形。 +- `注解`(`Note`):定义与细节。 +- `检查方式`(`Enforcement`):拒绝违规的检查,或审查者需要标记的情形。 + +句子简短直接。 + +#### 检查方式 + +审查:标记偏离此格式的规则。`verify-translation-pairing` 拒绝两种语言版本结构不一致的页面。 + +<a id="g2"></a> +### G.2:避免在公共接口参数中使用回调 + +#### 原因 + +回调让被调用方在它自己选定的时机运行调用方的代码。签名无法说明回调何时运行、运行几次、是否会在返回的 promise 落定后运行,以及它抛出的异常去向何处。被调用方因此变成分发器,必须[隔离回调异常](defensive-patterns/general.zh.md#contain-callback-exceptions-in-the-dispatcher),并在取消或 dispose(资源释放)后停止调用回调。函数无法跨越进程边界,因此这样的接口以后无法改为 `@Remote` 方法或 SDK 方法。 + +#### 反例 + +```ts +export interface UploadProgress { readonly loaded: number; readonly total?: number } + +/** Upload `data`; `onProgress` runs for each chunk. */ +export declare function upload( + data: Uint8Array, + onProgress?: (progress: UploadProgress) => void, +): Promise<string> +``` + +`onProgress` 会不会在 promise 落定后运行?它抛异常时会怎样?签名没有说明。 + +#### 示例 + +```ts +export type UploadEvent = + | { readonly type: 'progress'; readonly loaded: number; readonly total?: number } + | { readonly type: 'done'; readonly fileId: string } + +/** + * Upload `data`. Yields one `progress` per chunk, then one `done`. + * A failure rejects the next read; leaving the loop cancels the upload. + */ +export declare function upload(data: Uint8Array): AsyncIterable<UploadEvent> +``` + +顺序、失败和取消都遵循迭代协议。调用方的异常留在调用方自己的循环里。 + +#### 替代方案 + +- 单个结果:返回 `Promise`。 +- 中间结果,例如后续步骤之前创建的子项 id:把操作拆成由调用方按顺序发起的多次调用。 +- 一系列值:返回 `AsyncIterable`。 +- 面向任意数量监听器的通知:发出类型化 Cordis 事件,由消费方通过 `ctx.on()` 订阅。 +- 可替换的策略或工厂:声明一个由提供方实现的 Cordis 服务。 + +#### 例外 + +- 返回 disposer 的注册 API,例如 `ctx.on()`、`ctx.effect()` 或注册表的 `register()`,包括被注册的、带处理函数成员的对象。 +- 被调用方在调用返回或其 promise 落定之前就已调用完毕、异常会传回调用方、且不会保留的函数,例如比较函数或在锁内运行的任务。 +- 被调用方传给处理函数的续延,例如 waterfall 的 `next()`。 +- 客户端组件 prop 或 slot `inject` 成员中的操作回调,例如 `onClick`。 + +#### 注解 + +公共接口指包入口导出、Cordis 服务方法、`@Remote` 方法或 SDK 方法。 + +#### 检查方式 + +审查:在新增或修改的公共接口中,标记任何不属于例外的函数类型参数,或选项参数中的函数类型字段。 + +<a id="f"></a> +## F:前端 + +适用于渲染 Web 和 Desktop UI 的客户端包与应用的规则。本节没有规则。 + +<a id="b"></a> +## B:后端 + +适用于 Host 端包的规则:agent(智能体)运行时、服务、工具和进程管理。本节没有规则。 + +<a id="d"></a> +## D:数据交换 + +适用于跨越进程、网络或存储边界的数据的规则:`@Remote` 与 SDK 消息、事件以及持久化的 Session 数据。本节没有规则。 From 423d26abf8f9bc69641b5e5a134497634f2f2c7e Mon Sep 17 00:00:00 2001 From: Turtle <turtle1999@deepseek.com> Date: Thu, 19 Nov 2026 10:38:10 +0800 Subject: [PATCH 2/5] docs: separate core-guidelines and defensive-patterns placement criteria --- docs/AGENTS.md | 4 ++-- docs/defensive-patterns/README.i18n.yaml | 4 ++-- docs/defensive-patterns/README.md | 2 +- docs/defensive-patterns/README.zh.md | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/AGENTS.md b/docs/AGENTS.md index 83353bdbb7..b84c6e48ca 100644 --- a/docs/AGENTS.md +++ b/docs/AGENTS.md @@ -23,7 +23,7 @@ Each fact has one home: the tier whose job it is; elsewhere, link there. | [architecture.md](architecture.md) | Ordered map: composition, core packages, loop, seams, extension points; read before changing `packages/` | Type definitions (→ subsystems), per-package detail (→ package READMEs), decision rationale (→ Agent Notes), implementation-status annotations | | [subsystems/](subsystems/README.md) | One reference page per subsystem: type definitions, semantics, and the generated Cordis API | Behavior narration (→ architecture.md) | | [Agent Notes](../.agents/notes/README.md) | Active decision records: the why, what-was-given-up, and required verification; `implemented/` notes describe shipped reality in present tense | Migration plans, acceptance-task checklists, fixture walkthroughs, and spec-speak ("should…") once the decision has shipped; archived notes are frozen history, never current authority | -| [defensive-patterns/](defensive-patterns/README.md) | Rules this repository enforces in review, split by artifact: one general bug-class page plus per-domain pages | Type definitions and semantics (→ subsystems), decision rationale (→ Agent Notes) | +| [defensive-patterns/](defensive-patterns/README.md) | Rules this repository enforces in review, split by artifact: one general bug-class page plus per-domain pages | Type definitions and semantics (→ subsystems), decision rationale (→ Agent Notes), cross-artifact design rules (→ core-guidelines.md) | | [core-guidelines.md](core-guidelines.md) | Numbered design rules that apply across artifacts, in the format its rule G.1 defines | Artifact-specific review rules (→ defensive-patterns/) | | [postmortem/](postmortem/README.md) | Incident stories — the only tier where war-story narrative belongs | — | | [Persistence history](persistence-changes/README.md) and [format references](persistence-changes/historical-formats/README.md) | Type-change acknowledgements, release comparisons, and complete historical format schemas | Behavior-only changes; current runtime contracts | @@ -34,7 +34,7 @@ Each fact has one home: the tier whose job it is; elsewhere, link there. | Generated reference: the per-page `cordis-surface` regions in [subsystems/](subsystems/README.md), the [Cordis core API + inherited tier](cordis-api/context.md), [tool-catalog](tool-catalog.md), [config-catalog](config-catalog.md), [persistence-catalog](persistence-catalog.md), [module-graph.md](module-graph.md), [cli-help](cli-help.md) | Exhaustive English sources regenerated from source and freshness-gated; reviewed Chinese counterparts follow the [pairing workflow](i18n/README.md#scope-and-exclusions) | Hand edits to generated English sources or regions; Chinese counterparts update through pairing only | | Skills (`.agents/skills/`) | Reusable workflows and specialized decision standards | Product and runtime contracts (→ docs or source) | -Placement: bugs → postmortems; rationale → Agent Notes; procedures → cookbooks; type definitions → subsystems; package contracts → READMEs; standing orders → root `AGENTS.md` with a rationale link; review-enforced rules → `defensive-patterns/`; numbered design rules → `core-guidelines.md`. +Placement: bugs → postmortems; rationale → Agent Notes; procedures → cookbooks; type definitions → subsystems; package contracts → READMEs; standing orders → root `AGENTS.md` with a rationale link; artifact-specific review rules → `defensive-patterns/`; cross-artifact design rules → `core-guidelines.md`. ## Writing rules diff --git a/docs/defensive-patterns/README.i18n.yaml b/docs/defensive-patterns/README.i18n.yaml index 79e3b6cd15..7b8829a956 100644 --- a/docs/defensive-patterns/README.i18n.yaml +++ b/docs/defensive-patterns/README.i18n.yaml @@ -6,5 +6,5 @@ en: 7229c49e920aa5b3 zh: 1dd52db6b4d84952 /defensive-patterns/why-these-rules: - en: 7c012071b5af8c98 - zh: 298aaba83625c7a0 + en: aca10aff9de1160e + zh: a54752077cd25d63 diff --git a/docs/defensive-patterns/README.md b/docs/defensive-patterns/README.md index c74d1a4c29..d12adbacc9 100644 --- a/docs/defensive-patterns/README.md +++ b/docs/defensive-patterns/README.md @@ -22,4 +22,4 @@ Five habits cover most of what follows, and each page is their application to on | Session reads, retention, conversation nodes, renderers | [conversation-and-session.md](conversation-and-session.md) | | Timing, state representation, shared ownership, decentralization, refactors, migrations, performance evidence, disposal, callbacks, subprocesses | [general.md](general.md) | -Type definitions and per-subsystem semantics live in [subsystems/](../subsystems/README.md); this directory carries the rules, and the semantics pages carry what the types mean. [dsh-code-review](../../.agents/skills/dsh-code-review/SKILL.md) reads this directory when judging a pull request, and Development routes through the same table from [AGENTS.md](../../AGENTS.md). +Type definitions and per-subsystem semantics live in [subsystems/](../subsystems/README.md); this directory carries the rules, and the semantics pages carry what the types mean. [dsh-code-review](../../.agents/skills/dsh-code-review/SKILL.md) reads this directory when judging a pull request, and Development routes through the same table from [AGENTS.md](../../AGENTS.md). Design rules that apply across artifacts live in [DSH Core Guidelines](../core-guidelines.md). diff --git a/docs/defensive-patterns/README.zh.md b/docs/defensive-patterns/README.zh.md index 38d4c617d2..5cacb22f6c 100644 --- a/docs/defensive-patterns/README.zh.md +++ b/docs/defensive-patterns/README.zh.md @@ -24,4 +24,4 @@ | Session 读取、持有、会话节点、renderer | [conversation-and-session.zh.md](conversation-and-session.zh.md) | | 时序、状态表示、共享归属、去中心化、重构、迁移、性能证据、清理、回调、子进程 | [general.zh.md](general.zh.md) | -类型定义与各子系统语义见 [subsystems/](../subsystems/README.zh.md);本目录承载**规则**,语义页承载**类型的含义**。[dsh-code-review](../../.agents/skills/dsh-code-review/SKILL.md) 在评审 pull request 时读本目录,日常修改经 [AGENTS.md](../../AGENTS.md) 路由到同一张表。 +类型定义与各子系统语义见 [subsystems/](../subsystems/README.zh.md);本目录承载**规则**,语义页承载**类型的含义**。[dsh-code-review](../../.agents/skills/dsh-code-review/SKILL.md) 在评审 pull request 时读本目录,日常修改经 [AGENTS.md](../../AGENTS.md) 路由到同一张表。跨产物适用的设计规则见 [DSH 核心准则](../core-guidelines.zh.md)。 From 0daee08a35c6210baaef39b008899c25283a4d37 Mon Sep 17 00:00:00 2001 From: Turtle <turtle1999@deepseek.com> Date: Thu, 19 Nov 2026 10:47:26 +0800 Subject: [PATCH 3/5] docs: state the two reasons for G.2 directly --- docs/core-guidelines.i18n.yaml | 4 ++-- docs/core-guidelines.md | 3 ++- docs/core-guidelines.zh.md | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/core-guidelines.i18n.yaml b/docs/core-guidelines.i18n.yaml index 9a2ef12b80..87b8aca45c 100644 --- a/docs/core-guidelines.i18n.yaml +++ b/docs/core-guidelines.i18n.yaml @@ -39,8 +39,8 @@ en: 3f2b8e6b2e953ff8 zh: 6156e6d170d26434 /dsh-core-guidelines/g-general/g-2-avoid-callbacks-in-public-interface-parameters/reason: - en: cc8ca16db3a2da91 - zh: c05a6e21786901de + en: fd6d08a3ba8cd0ab + zh: 799f8d1d4e7fd861 /dsh-core-guidelines/g-general/g-2-avoid-callbacks-in-public-interface-parameters/example-bad: en: 3c9a74a8c000ae05 zh: 96ead304ef98c8fd diff --git a/docs/core-guidelines.md b/docs/core-guidelines.md index 26870db8d2..c042e53a88 100644 --- a/docs/core-guidelines.md +++ b/docs/core-guidelines.md @@ -86,7 +86,8 @@ Review: flag a rule that deviates from this format. `verify-translation-pairing` #### Reason -A callback lets the callee run caller code at times the callee chooses. The signature does not say when the callback runs, how often, whether it runs after the returned promise settles, or where its exceptions go. The callee becomes a dispatcher that must [contain callback exceptions](defensive-patterns/general.md#contain-callback-exceptions-in-the-dispatcher) and stop calling after cancellation or disposal. A function cannot cross a process boundary, so the interface cannot later become a `@Remote` or SDK method. +- Hard to read and reason about. The type of a callback parameter does not say when the callee calls it, how often, or what happens when it throws. +- Not serializable. A function cannot cross a process boundary, so the interface cannot be a `@Remote` or SDK method. #### Example, bad diff --git a/docs/core-guidelines.zh.md b/docs/core-guidelines.zh.md index 84146e0404..9d6eae2dbc 100644 --- a/docs/core-guidelines.zh.md +++ b/docs/core-guidelines.zh.md @@ -86,7 +86,8 @@ Callbacks caused bugs before, so prefer other designs where possible. #### 原因 -回调让被调用方在它自己选定的时机运行调用方的代码。签名无法说明回调何时运行、运行几次、是否会在返回的 promise 落定后运行,以及它抛出的异常去向何处。被调用方因此变成分发器,必须[隔离回调异常](defensive-patterns/general.zh.md#contain-callback-exceptions-in-the-dispatcher),并在取消或 dispose(资源释放)后停止调用回调。函数无法跨越进程边界,因此这样的接口以后无法改为 `@Remote` 方法或 SDK 方法。 +- 难以阅读和推理。回调参数的类型没有说明被调用方何时调用它、调用几次,以及它抛异常时会怎样。 +- 无法序列化。函数无法跨越进程边界,因此这样的接口不能作为 `@Remote` 方法或 SDK 方法。 #### 反例 From 1a42cb0e3fb7bbd5128268b89b840eaa0d4c1fce Mon Sep 17 00:00:00 2001 From: Turtle <turtle1999@deepseek.com> Date: Thu, 19 Nov 2026 11:09:04 +0800 Subject: [PATCH 4/5] docs: split core guidelines into one file per section; merge G.2 handler exceptions --- .agents/skills/dsh-code-review/SKILL.md | 2 +- AGENTS.md | 2 +- docs/AGENTS.md | 6 +- docs/core-guidelines.i18n.yaml | 70 ------------- docs/core-guidelines/README.i18n.yaml | 16 +++ docs/core-guidelines/README.md | 22 +++++ docs/core-guidelines/README.zh.md | 22 +++++ docs/core-guidelines/backend.i18n.yaml | 7 ++ docs/core-guidelines/backend.md | 5 + docs/core-guidelines/backend.zh.md | 5 + docs/core-guidelines/data-exchange.i18n.yaml | 7 ++ docs/core-guidelines/data-exchange.md | 5 + docs/core-guidelines/data-exchange.zh.md | 5 + docs/core-guidelines/frontend.i18n.yaml | 7 ++ docs/core-guidelines/frontend.md | 5 + docs/core-guidelines/frontend.zh.md | 5 + docs/core-guidelines/general.i18n.yaml | 49 ++++++++++ .../general.md} | 97 ++++++------------- .../general.zh.md} | 97 ++++++------------- docs/defensive-patterns/README.i18n.yaml | 4 +- docs/defensive-patterns/README.md | 2 +- docs/defensive-patterns/README.zh.md | 2 +- 22 files changed, 225 insertions(+), 217 deletions(-) delete mode 100644 docs/core-guidelines.i18n.yaml create mode 100644 docs/core-guidelines/README.i18n.yaml create mode 100644 docs/core-guidelines/README.md create mode 100644 docs/core-guidelines/README.zh.md create mode 100644 docs/core-guidelines/backend.i18n.yaml create mode 100644 docs/core-guidelines/backend.md create mode 100644 docs/core-guidelines/backend.zh.md create mode 100644 docs/core-guidelines/data-exchange.i18n.yaml create mode 100644 docs/core-guidelines/data-exchange.md create mode 100644 docs/core-guidelines/data-exchange.zh.md create mode 100644 docs/core-guidelines/frontend.i18n.yaml create mode 100644 docs/core-guidelines/frontend.md create mode 100644 docs/core-guidelines/frontend.zh.md create mode 100644 docs/core-guidelines/general.i18n.yaml rename docs/{core-guidelines.md => core-guidelines/general.md} (52%) rename docs/{core-guidelines.zh.md => core-guidelines/general.zh.md} (55%) diff --git a/.agents/skills/dsh-code-review/SKILL.md b/.agents/skills/dsh-code-review/SKILL.md index 0a244716ed..e04a1fade2 100644 --- a/.agents/skills/dsh-code-review/SKILL.md +++ b/.agents/skills/dsh-code-review/SKILL.md @@ -12,7 +12,7 @@ description: Use when reviewing a pull request in the deepseek-harness repo — ## Sources of truth - [AGENTS.md](../../../AGENTS.md) and [packages/AGENTS.md](../../../packages/AGENTS.md): standing repository and package authoring rules. -- [DSH Core Guidelines](../../../docs/core-guidelines.md): numbered design rules every change follows; cite a violated rule by its ID. +- [DSH Core Guidelines](../../../docs/core-guidelines/README.md): numbered design rules every change follows; cite a violated rule by its ID. - [docs/defensive-patterns/](../../../docs/defensive-patterns/README.md): the architecture requirements a change must satisfy and the habits behind them. Each page owns one artifact; read every page the diff touches: - [general.md](../../../docs/defensive-patterns/general.md) — timing, async state, value representation, shared ownership, decentralization, refactors, migrations, performance evidence, disposal, callbacks, subprocesses. - [package-surface.md](../../../docs/defensive-patterns/package-surface.md) — exports, package shape, build faces, dependency declarations, resolve hooks. diff --git a/AGENTS.md b/AGENTS.md index ebb6b8dda5..6a2ccfad64 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -171,7 +171,7 @@ Real-API tests/demos read `DEEPSEEK_API_KEY`, optional `DEEPSEEK_BASE_URL`, and ## Review rules -Before finishing, self-review against [DSH Core Guidelines](docs/core-guidelines.md). +Before finishing, self-review against [DSH Core Guidelines](docs/core-guidelines/README.md). Read [docs/defensive-patterns/README.md](docs/defensive-patterns/README.md) before changing a package surface, remote service, client component or state, conversation or Session behavior, or lifecycle, concurrency, subprocess, and teardown code. diff --git a/docs/AGENTS.md b/docs/AGENTS.md index b84c6e48ca..79d8229415 100644 --- a/docs/AGENTS.md +++ b/docs/AGENTS.md @@ -23,8 +23,8 @@ Each fact has one home: the tier whose job it is; elsewhere, link there. | [architecture.md](architecture.md) | Ordered map: composition, core packages, loop, seams, extension points; read before changing `packages/` | Type definitions (→ subsystems), per-package detail (→ package READMEs), decision rationale (→ Agent Notes), implementation-status annotations | | [subsystems/](subsystems/README.md) | One reference page per subsystem: type definitions, semantics, and the generated Cordis API | Behavior narration (→ architecture.md) | | [Agent Notes](../.agents/notes/README.md) | Active decision records: the why, what-was-given-up, and required verification; `implemented/` notes describe shipped reality in present tense | Migration plans, acceptance-task checklists, fixture walkthroughs, and spec-speak ("should…") once the decision has shipped; archived notes are frozen history, never current authority | -| [defensive-patterns/](defensive-patterns/README.md) | Rules this repository enforces in review, split by artifact: one general bug-class page plus per-domain pages | Type definitions and semantics (→ subsystems), decision rationale (→ Agent Notes), cross-artifact design rules (→ core-guidelines.md) | -| [core-guidelines.md](core-guidelines.md) | Numbered design rules that apply across artifacts, in the format its rule G.1 defines | Artifact-specific review rules (→ defensive-patterns/) | +| [defensive-patterns/](defensive-patterns/README.md) | Rules this repository enforces in review, split by artifact: one general bug-class page plus per-domain pages | Type definitions and semantics (→ subsystems), decision rationale (→ Agent Notes), cross-artifact design rules (→ core-guidelines/) | +| [core-guidelines/](core-guidelines/README.md) | Numbered design rules that apply across artifacts, one file per rule section, in the format its rule G.1 defines | Artifact-specific review rules (→ defensive-patterns/) | | [postmortem/](postmortem/README.md) | Incident stories — the only tier where war-story narrative belongs | — | | [Persistence history](persistence-changes/README.md) and [format references](persistence-changes/historical-formats/README.md) | Type-change acknowledgements, release comparisons, and complete historical format schemas | Behavior-only changes; current runtime contracts | | [cookbook/](cookbook/adding-a-package.md) | Step-by-step how-tos with numbered verify steps | Design rationale (→ the Agent Note each guide links) | @@ -34,7 +34,7 @@ Each fact has one home: the tier whose job it is; elsewhere, link there. | Generated reference: the per-page `cordis-surface` regions in [subsystems/](subsystems/README.md), the [Cordis core API + inherited tier](cordis-api/context.md), [tool-catalog](tool-catalog.md), [config-catalog](config-catalog.md), [persistence-catalog](persistence-catalog.md), [module-graph.md](module-graph.md), [cli-help](cli-help.md) | Exhaustive English sources regenerated from source and freshness-gated; reviewed Chinese counterparts follow the [pairing workflow](i18n/README.md#scope-and-exclusions) | Hand edits to generated English sources or regions; Chinese counterparts update through pairing only | | Skills (`.agents/skills/`) | Reusable workflows and specialized decision standards | Product and runtime contracts (→ docs or source) | -Placement: bugs → postmortems; rationale → Agent Notes; procedures → cookbooks; type definitions → subsystems; package contracts → READMEs; standing orders → root `AGENTS.md` with a rationale link; artifact-specific review rules → `defensive-patterns/`; cross-artifact design rules → `core-guidelines.md`. +Placement: bugs → postmortems; rationale → Agent Notes; procedures → cookbooks; type definitions → subsystems; package contracts → READMEs; standing orders → root `AGENTS.md` with a rationale link; artifact-specific review rules → `defensive-patterns/`; cross-artifact design rules → `core-guidelines/`. ## Writing rules diff --git a/docs/core-guidelines.i18n.yaml b/docs/core-guidelines.i18n.yaml deleted file mode 100644 index 87b8aca45c..0000000000 --- a/docs/core-guidelines.i18n.yaml +++ /dev/null @@ -1,70 +0,0 @@ -# Bilingual-pair consistency record for core-guidelines.md (docs/i18n/README.md): per heading -# section, a hash of its English and Chinese blocks outside code blocks and generated regions. -# After editing either side, bring the other along and re-record with: -# pnpm run verify-translation-pairing --write docs/core-guidelines.md -/dsh-core-guidelines: - en: 0d88d81c166137a1 - zh: 6fb75b66349a71c7 -/dsh-core-guidelines/summary: - en: 94a60bd7d96f9dd8 - zh: 34635496ca2df301 -/dsh-core-guidelines/table-of-contents: - en: 676d77a6df3ef329 - zh: 704976c22d1fed30 -/dsh-core-guidelines/introduction: - en: 471d3a01e46a044f - zh: bb723668575e357e -/dsh-core-guidelines/g-general: - en: 5a914c4912866bf1 - zh: a123355f35847798 -/dsh-core-guidelines/g-general/g-1-write-every-rule-in-the-standard-format: - en: c77afd940b6e2b93 - zh: 0e35654e184486ca -/dsh-core-guidelines/g-general/g-1-write-every-rule-in-the-standard-format/reason: - en: 94643c68676a916f - zh: 6c4c7a43b562a670 -/dsh-core-guidelines/g-general/g-1-write-every-rule-in-the-standard-format/example-bad: - en: 65b6e95e50f03989 - zh: a7c52ca22340707a -/dsh-core-guidelines/g-general/g-1-write-every-rule-in-the-standard-format/example: - en: 1e720ea2922f5b63 - zh: 84febcc229b4a659 -/dsh-core-guidelines/g-general/g-1-write-every-rule-in-the-standard-format/note: - en: 6c7f43c93975617d - zh: 381b92c255089193 -/dsh-core-guidelines/g-general/g-1-write-every-rule-in-the-standard-format/enforcement: - en: 32df1e18b06f45bc - zh: 9cba430d047ab565 -/dsh-core-guidelines/g-general/g-2-avoid-callbacks-in-public-interface-parameters: - en: 3f2b8e6b2e953ff8 - zh: 6156e6d170d26434 -/dsh-core-guidelines/g-general/g-2-avoid-callbacks-in-public-interface-parameters/reason: - en: fd6d08a3ba8cd0ab - zh: 799f8d1d4e7fd861 -/dsh-core-guidelines/g-general/g-2-avoid-callbacks-in-public-interface-parameters/example-bad: - en: 3c9a74a8c000ae05 - zh: 96ead304ef98c8fd -/dsh-core-guidelines/g-general/g-2-avoid-callbacks-in-public-interface-parameters/example: - en: c66c0222aed09bd3 - zh: 017f2656c010a48d -/dsh-core-guidelines/g-general/g-2-avoid-callbacks-in-public-interface-parameters/alternative: - en: 0e2a32c8d51f4d87 - zh: faa8abfee1fb7fa1 -/dsh-core-guidelines/g-general/g-2-avoid-callbacks-in-public-interface-parameters/exception: - en: 4894c74a9319c956 - zh: a9fcac332f3d9320 -/dsh-core-guidelines/g-general/g-2-avoid-callbacks-in-public-interface-parameters/note: - en: 104d10a10fd00535 - zh: 4c1cb92cf2f50aef -/dsh-core-guidelines/g-general/g-2-avoid-callbacks-in-public-interface-parameters/enforcement: - en: c850502b3e29b501 - zh: 3c97c8807e632aa6 -/dsh-core-guidelines/f-frontend: - en: ba041561ab400a46 - zh: 78263a4c6e5f61da -/dsh-core-guidelines/b-backend: - en: 80f90e1debfdb017 - zh: bec00d38ccd1af65 -/dsh-core-guidelines/d-data-exchange: - en: bea86bb1a2093862 - zh: e03322d1b1045e04 diff --git a/docs/core-guidelines/README.i18n.yaml b/docs/core-guidelines/README.i18n.yaml new file mode 100644 index 0000000000..34ed0170a2 --- /dev/null +++ b/docs/core-guidelines/README.i18n.yaml @@ -0,0 +1,16 @@ +# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading +# section, a hash of its English and Chinese blocks outside code blocks and generated regions. +# After editing either side, bring the other along and re-record with: +# pnpm run verify-translation-pairing --write docs/core-guidelines/README.md +/dsh-core-guidelines: + en: 98cc70438bfa7733 + zh: 2d295d0026eae37c +/dsh-core-guidelines/summary: + en: 60d80dd9a9b0c5ed + zh: a110afe0725237f7 +/dsh-core-guidelines/sections: + en: d01356208379d52c + zh: 5db9008bd7fd339f +/dsh-core-guidelines/introduction: + en: 820be59958fa40a7 + zh: c7eaf1b6174a7662 diff --git a/docs/core-guidelines/README.md b/docs/core-guidelines/README.md new file mode 100644 index 0000000000..554d0453aa --- /dev/null +++ b/docs/core-guidelines/README.md @@ -0,0 +1,22 @@ +# DSH Core Guidelines + +English | [中文](README.zh.md) + +## Summary + +Rules for writing DeepSeek Harness code, in the style of the [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines). Each rule has a stable ID and the parts that [G.1](general.md#g1) defines. + +## Sections + +- [G: General](general.md) + - [G.1: Write every rule in the standard format](general.md#g1) + - [G.2: Avoid callbacks in public interface parameters](general.md#g2) +- [F: Frontend](frontend.md) +- [B: Backend](backend.md) +- [D: Data exchange](data-exchange.md) + +## Introduction + +Before you finish a change, review the code it adds or modifies against every rule in these guidelines. Fix each violation, or state in the change why the rule does not apply. A change does not have to migrate existing code it does not otherwise touch. + +Cite a rule by its ID, for example "violates G.2". Artifact-specific review rules live in [defensive patterns](../defensive-patterns/README.md); read them as well. diff --git a/docs/core-guidelines/README.zh.md b/docs/core-guidelines/README.zh.md new file mode 100644 index 0000000000..15646dbc01 --- /dev/null +++ b/docs/core-guidelines/README.zh.md @@ -0,0 +1,22 @@ +# DSH 核心准则 + +[English](README.md) | 中文 + +## 概述 + +编写 DeepSeek Harness 代码的规则,风格沿用 [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines)。每条规则有一个稳定编号,以及 [G.1](general.zh.md#g1) 规定的各个部分。 + +## 分组 + +- [G:通用](general.zh.md) + - [G.1:每条规则都按标准格式编写](general.zh.md#g1) + - [G.2:避免在公共接口参数中使用回调](general.zh.md#g2) +- [F:前端](frontend.zh.md) +- [B:后端](backend.zh.md) +- [D:数据交换](data-exchange.zh.md) + +## 引言 + +完成变更之前,对照本准则的每条规则审查该变更新增或修改的代码。修复每处违规,或在变更中说明该规则为何不适用。变更不必迁移它本来不改动的已有代码。 + +按编号引用规则,例如“违反 G.2”。针对具体产物的审查规则见[防御性模式](../defensive-patterns/README.zh.md),同样需要阅读。 diff --git a/docs/core-guidelines/backend.i18n.yaml b/docs/core-guidelines/backend.i18n.yaml new file mode 100644 index 0000000000..c5d26e7767 --- /dev/null +++ b/docs/core-guidelines/backend.i18n.yaml @@ -0,0 +1,7 @@ +# Bilingual-pair consistency record for backend.md (docs/i18n/README.md): per heading +# section, a hash of its English and Chinese blocks outside code blocks and generated regions. +# After editing either side, bring the other along and re-record with: +# pnpm run verify-translation-pairing --write docs/core-guidelines/backend.md +/b-backend: + en: 86a5f492360c89e3 + zh: 2c4a7c2b6b1f9b60 diff --git a/docs/core-guidelines/backend.md b/docs/core-guidelines/backend.md new file mode 100644 index 0000000000..10cab05a40 --- /dev/null +++ b/docs/core-guidelines/backend.md @@ -0,0 +1,5 @@ +# B: Backend + +English | [中文](backend.zh.md) + +Rules for Host-side packages: agent runtime, services, tools, and process management. This section has no rules. diff --git a/docs/core-guidelines/backend.zh.md b/docs/core-guidelines/backend.zh.md new file mode 100644 index 0000000000..16114fd1ee --- /dev/null +++ b/docs/core-guidelines/backend.zh.md @@ -0,0 +1,5 @@ +# B:后端 + +[English](backend.md) | 中文 + +适用于 Host 端包的规则:agent(智能体)运行时、服务、工具和进程管理。本节没有规则。 diff --git a/docs/core-guidelines/data-exchange.i18n.yaml b/docs/core-guidelines/data-exchange.i18n.yaml new file mode 100644 index 0000000000..cc7e4f2e2c --- /dev/null +++ b/docs/core-guidelines/data-exchange.i18n.yaml @@ -0,0 +1,7 @@ +# Bilingual-pair consistency record for data-exchange.md (docs/i18n/README.md): per heading +# section, a hash of its English and Chinese blocks outside code blocks and generated regions. +# After editing either side, bring the other along and re-record with: +# pnpm run verify-translation-pairing --write docs/core-guidelines/data-exchange.md +/d-data-exchange: + en: 38fd72b45c5b46c9 + zh: fcafd7b2fabdb56d diff --git a/docs/core-guidelines/data-exchange.md b/docs/core-guidelines/data-exchange.md new file mode 100644 index 0000000000..c9ec721220 --- /dev/null +++ b/docs/core-guidelines/data-exchange.md @@ -0,0 +1,5 @@ +# D: Data exchange + +English | [中文](data-exchange.zh.md) + +Rules for data that crosses a process, network, or storage boundary: `@Remote` and SDK messages, events, and persisted Session data. This section has no rules. diff --git a/docs/core-guidelines/data-exchange.zh.md b/docs/core-guidelines/data-exchange.zh.md new file mode 100644 index 0000000000..221401d7a9 --- /dev/null +++ b/docs/core-guidelines/data-exchange.zh.md @@ -0,0 +1,5 @@ +# D:数据交换 + +[English](data-exchange.md) | 中文 + +适用于跨越进程、网络或存储边界的数据的规则:`@Remote` 与 SDK 消息、事件以及持久化的 Session 数据。本节没有规则。 diff --git a/docs/core-guidelines/frontend.i18n.yaml b/docs/core-guidelines/frontend.i18n.yaml new file mode 100644 index 0000000000..2297fbd94e --- /dev/null +++ b/docs/core-guidelines/frontend.i18n.yaml @@ -0,0 +1,7 @@ +# Bilingual-pair consistency record for frontend.md (docs/i18n/README.md): per heading +# section, a hash of its English and Chinese blocks outside code blocks and generated regions. +# After editing either side, bring the other along and re-record with: +# pnpm run verify-translation-pairing --write docs/core-guidelines/frontend.md +/f-frontend: + en: 4316a532a8a13a76 + zh: 541fe22ee04024bd diff --git a/docs/core-guidelines/frontend.md b/docs/core-guidelines/frontend.md new file mode 100644 index 0000000000..9dcd246e35 --- /dev/null +++ b/docs/core-guidelines/frontend.md @@ -0,0 +1,5 @@ +# F: Frontend + +English | [中文](frontend.zh.md) + +Rules for client packages and apps that render the Web and Desktop UI. This section has no rules. diff --git a/docs/core-guidelines/frontend.zh.md b/docs/core-guidelines/frontend.zh.md new file mode 100644 index 0000000000..c86cb5bd8d --- /dev/null +++ b/docs/core-guidelines/frontend.zh.md @@ -0,0 +1,5 @@ +# F:前端 + +[English](frontend.md) | 中文 + +适用于渲染 Web 和 Desktop UI 的客户端包与应用的规则。本节没有规则。 diff --git a/docs/core-guidelines/general.i18n.yaml b/docs/core-guidelines/general.i18n.yaml new file mode 100644 index 0000000000..22ee7f0703 --- /dev/null +++ b/docs/core-guidelines/general.i18n.yaml @@ -0,0 +1,49 @@ +# Bilingual-pair consistency record for general.md (docs/i18n/README.md): per heading +# section, a hash of its English and Chinese blocks outside code blocks and generated regions. +# After editing either side, bring the other along and re-record with: +# pnpm run verify-translation-pairing --write docs/core-guidelines/general.md +/g-general: + en: eeded9c200e31c82 + zh: 488049fad75b1944 +/g-general/g-1-write-every-rule-in-the-standard-format: + en: 812e982277f154f9 + zh: 85d293456add404e +/g-general/g-1-write-every-rule-in-the-standard-format/reason: + en: 58a1a93bb1664942 + zh: 83055bf39becba0a +/g-general/g-1-write-every-rule-in-the-standard-format/example-bad: + en: 0fafa3d89d20b56c + zh: f99acb925b2ca7f1 +/g-general/g-1-write-every-rule-in-the-standard-format/example: + en: b9b5449b4e5cc2bf + zh: fa9be57f4cf4a267 +/g-general/g-1-write-every-rule-in-the-standard-format/note: + en: f16ff8c2c486b139 + zh: 417d564a91671b67 +/g-general/g-1-write-every-rule-in-the-standard-format/enforcement: + en: 696490996bd95844 + zh: b8ded650efa9883b +/g-general/g-2-avoid-callbacks-in-public-interface-parameters: + en: b13d4402873fda38 + zh: a3fb45bd1563258f +/g-general/g-2-avoid-callbacks-in-public-interface-parameters/reason: + en: e8a0c671e66da673 + zh: 86352f61cfd97ac8 +/g-general/g-2-avoid-callbacks-in-public-interface-parameters/example-bad: + en: 6591f36eead7f5e1 + zh: e79e6a3200e5e889 +/g-general/g-2-avoid-callbacks-in-public-interface-parameters/example: + en: 55c0bd9d10b26852 + zh: 1b908e550a18e2da +/g-general/g-2-avoid-callbacks-in-public-interface-parameters/alternative: + en: f0dabc1cf7cd8b19 + zh: b00ed9e4f57c9111 +/g-general/g-2-avoid-callbacks-in-public-interface-parameters/exception: + en: fa372f0af794d371 + zh: f835e1ce06ad7677 +/g-general/g-2-avoid-callbacks-in-public-interface-parameters/note: + en: 7b73640586b3aeba + zh: 577477b5215ee03a +/g-general/g-2-avoid-callbacks-in-public-interface-parameters/enforcement: + en: 90b1409e10d2a31f + zh: c54325d63795657e diff --git a/docs/core-guidelines.md b/docs/core-guidelines/general.md similarity index 52% rename from docs/core-guidelines.md rename to docs/core-guidelines/general.md index c042e53a88..857dca55ca 100644 --- a/docs/core-guidelines.md +++ b/docs/core-guidelines/general.md @@ -1,71 +1,47 @@ -# DSH Core Guidelines +# G: General -English | [中文](core-guidelines.zh.md) +English | [中文](general.zh.md) -## Summary - -Rules for writing DeepSeek Harness code, in the style of the [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines). Each rule has a stable ID and the parts that [G.1](#g1) defines. - -## Table of Contents - -- [Introduction](#in) -- [G: General](#g) - - [G.1: Write every rule in the standard format](#g1) - - [G.2: Avoid callbacks in public interface parameters](#g2) -- [F: Frontend](#f) -- [B: Backend](#b) -- [D: Data exchange](#d) - -<a id="in"></a> -## Introduction - -Before you finish a change, review the code it adds or modifies against every rule on this page. Fix each violation, or state in the change why the rule does not apply. A change does not have to migrate existing code it does not otherwise touch. - -Cite a rule by its ID, for example "violates G.2". Artifact-specific review rules live in [defensive patterns](defensive-patterns/README.md); read them as well. - -<a id="g"></a> -## G: General - -Rules for all code in this repository, and for this page. +Rules for all code in this repository, and for these guidelines. <a id="g1"></a> -### G.1: Write every rule in the standard format +## G.1: Write every rule in the standard format -#### Reason +### Reason A fixed format puts the requirement, its justification, and its limits in the same place in every rule. A stable ID lets reviews cite a rule without quoting it. -#### Example, bad +### Example, bad ```md -### Callbacks +## Callbacks Callbacks caused bugs before, so prefer other designs where possible. ``` No ID. No imperative title. The requirement is buried in the rationale, and nothing says how to detect a violation. -#### Example +### Example ```md <a id="g9"></a> -### G.9: <One imperative sentence> +## G.9: <One imperative sentence> -#### Reason -#### Example, bad -#### Example -#### Enforcement +### Reason +### Example, bad +### Example +### Enforcement ``` -#### Note +### Note -A rule section is a level-2 heading `<Letter>: <Name>`, preceded by an `<a id>` anchor of its lowercased letter and followed by one paragraph that states its scope. `<Letter>` is one or more capital letters, unique on this page. +A rule section is one bilingual file pair in this directory, named for the section, such as `general.md` and `general.zh.md`. Its level-1 heading is `<Letter>: <Name>`, followed by one paragraph that states its scope. `<Letter>` is one or more capital letters, unique among sections. [README.md](README.md) lists every section. -A rule is a level-3 heading `<Letter>.<n>: <Title>` inside its rule section. An `<a id>` anchor, the lowercased ID without the dot, precedes the heading. `<n>` counts from 1 in order of addition. A removed rule's number is never reused. +A rule is a level-2 heading `<Letter>.<n>: <Title>` in its section file. An `<a id>` anchor, the lowercased ID without the dot, precedes the heading. `<n>` counts from 1 in order of addition. A removed rule's number is never reused. The title is one imperative sentence that states the requirement. -The body is a sequence of level-4 headings in this order. `Reason` and `Enforcement` are required. Give at least one of `Example, bad` and `Example`. Omit any other heading that has no content. +The body is a sequence of level-3 headings in this order. `Reason` and `Enforcement` are required. Give at least one of `Example, bad` and `Example`. Omit any other heading that has no content. - `Reason`: the defect or cost the rule prevents. - `Example, bad`: a violation. @@ -77,19 +53,19 @@ The body is a sequence of level-4 headings in this order. `Reason` and `Enforcem Write short, direct sentences. -#### Enforcement +### Enforcement -Review: flag a rule that deviates from this format. `verify-translation-pairing` rejects a page whose two language versions differ in structure. +Review: flag a rule that deviates from this format. `verify-translation-pairing` rejects a section whose two language versions differ in structure. <a id="g2"></a> -### G.2: Avoid callbacks in public interface parameters +## G.2: Avoid callbacks in public interface parameters -#### Reason +### Reason - Hard to read and reason about. The type of a callback parameter does not say when the callee calls it, how often, or what happens when it throws. - Not serializable. A function cannot cross a process boundary, so the interface cannot be a `@Remote` or SDK method. -#### Example, bad +### Example, bad ```ts export interface UploadProgress { readonly loaded: number; readonly total?: number } @@ -103,7 +79,7 @@ export declare function upload( Can `onProgress` run after the promise settles? What happens when it throws? The signature does not say. -#### Example +### Example ```ts export type UploadEvent = @@ -119,7 +95,7 @@ export declare function upload(data: Uint8Array): AsyncIterable<UploadEvent> Order, failure, and cancellation follow the iteration protocol. The caller's exceptions stay in the caller's loop. -#### Alternative +### Alternative - One result: return a `Promise`. - An intermediate result, such as the id of a created child before a later step: split the operation into calls that the caller sequences. @@ -127,32 +103,15 @@ Order, failure, and cancellation follow the iteration protocol. The caller's exc - A notification for any number of listeners: emit a typed Cordis event that consumers subscribe to with `ctx.on()`. - A replaceable strategy or factory: declare a Cordis service that providers implement. -#### Exception +### Exception -- A registration API that returns its disposer, such as `ctx.on()`, `ctx.effect()`, or a registry's `register()`, including a registered object with handler members. +- An event handler: a function or object registered to handle events, such as a `ctx.on()` listener, a handler passed to a registry's `register()`, or a client component's `onClick` prop. The registration returns its disposer. The waterfall `next()` passed to a handler is part of the handler's signature. - A function that the callee finishes calling before the call returns or its promise settles, whose exceptions reach the caller, and that the callee does not keep, such as a comparator or a task run under a lock. -- A continuation the callee passes to a handler, such as a waterfall `next()`. -- An action callback in a client component prop or slot `inject` member, such as `onClick`. -#### Note +### Note A public interface is a package entry-point export, a Cordis service method, a `@Remote` method, or an SDK method. -#### Enforcement +### Enforcement Review: flag a function-typed parameter, or a function-typed field of an options parameter, in a new or changed public interface that no exception covers. - -<a id="f"></a> -## F: Frontend - -Rules for client packages and apps that render the Web and Desktop UI. This section has no rules. - -<a id="b"></a> -## B: Backend - -Rules for Host-side packages: agent runtime, services, tools, and process management. This section has no rules. - -<a id="d"></a> -## D: Data exchange - -Rules for data that crosses a process, network, or storage boundary: `@Remote` and SDK messages, events, and persisted Session data. This section has no rules. diff --git a/docs/core-guidelines.zh.md b/docs/core-guidelines/general.zh.md similarity index 55% rename from docs/core-guidelines.zh.md rename to docs/core-guidelines/general.zh.md index 9d6eae2dbc..6fa950c619 100644 --- a/docs/core-guidelines.zh.md +++ b/docs/core-guidelines/general.zh.md @@ -1,71 +1,47 @@ -# DSH 核心准则 +# G:通用 -[English](core-guidelines.md) | 中文 +[English](general.md) | 中文 -## 概述 - -编写 DeepSeek Harness 代码的规则,风格沿用 [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines)。每条规则有一个稳定编号,以及 [G.1](#g1) 规定的各个部分。 - -## 目录 - -- [引言](#in) -- [G:通用](#g) - - [G.1:每条规则都按标准格式编写](#g1) - - [G.2:避免在公共接口参数中使用回调](#g2) -- [F:前端](#f) -- [B:后端](#b) -- [D:数据交换](#d) - -<a id="in"></a> -## 引言 - -完成变更之前,对照本页每条规则审查该变更新增或修改的代码。修复每处违规,或在变更中说明该规则为何不适用。变更不必迁移它本来不改动的已有代码。 - -按编号引用规则,例如“违反 G.2”。针对具体产物的审查规则见[防御性模式](defensive-patterns/README.zh.md),同样需要阅读。 - -<a id="g"></a> -## G:通用 - -适用于本仓库全部代码以及本页本身的规则。 +适用于本仓库全部代码以及本准则本身的规则。 <a id="g1"></a> -### G.1:每条规则都按标准格式编写 +## G.1:每条规则都按标准格式编写 -#### 原因 +### 原因 固定格式让每条规则的要求、理由和适用范围都出现在同一位置。稳定编号让审查无需引述原文即可引用规则。 -#### 反例 +### 反例 ```md -### Callbacks +## Callbacks Callbacks caused bugs before, so prefer other designs where possible. ``` 没有编号,标题不是祈使句。要求埋在理由里,也没有说明如何发现违规。 -#### 示例 +### 示例 ```md <a id="g9"></a> -### G.9: <One imperative sentence> +## G.9: <One imperative sentence> -#### Reason -#### Example, bad -#### Example -#### Enforcement +### Reason +### Example, bad +### Example +### Enforcement ``` -#### 注解 +### 注解 -一个规则分组是一个二级标题 `<字母>:<名称>`,前面放一个取值为小写字母的 `<a id>` 锚点,后接一段说明该分组范围的文字。`<字母>` 由一个或多个大写字母组成,在本页内唯一。 +一个规则分组是本目录中一对以分组命名的双语文件,例如 `general.md` 和 `general.zh.md`。其一级标题为 `<字母>:<名称>`,后接一段说明该分组范围的文字。`<字母>` 由一个或多个大写字母组成,在各分组之间唯一。[README.zh.md](README.zh.md) 列出全部分组。 -一条规则是所属规则分组内的一个三级标题 `<字母>.<n>:<标题>`。标题前放一个 `<a id>` 锚点,取值为去掉点号的小写编号。`<n>` 按添加顺序从 1 开始计数。删除的规则编号不再复用。 +一条规则是所属分组文件中的一个二级标题 `<字母>.<n>:<标题>`。标题前放一个 `<a id>` 锚点,取值为去掉点号的小写编号。`<n>` 按添加顺序从 1 开始计数。删除的规则编号不再复用。 标题是一句陈述要求的祈使句。 -正文是按以下顺序排列的四级标题。`原因` 和 `检查方式` 必需。`反例` 与 `示例` 至少给出一个。其他标题没有内容时省略。括号中是英文版的标题。 +正文是按以下顺序排列的三级标题。`原因` 和 `检查方式` 必需。`反例` 与 `示例` 至少给出一个。其他标题没有内容时省略。括号中是英文版的标题。 - `原因`(`Reason`):规则防止的缺陷或代价。 - `反例`(`Example, bad`):一处违规。 @@ -77,19 +53,19 @@ Callbacks caused bugs before, so prefer other designs where possible. 句子简短直接。 -#### 检查方式 +### 检查方式 -审查:标记偏离此格式的规则。`verify-translation-pairing` 拒绝两种语言版本结构不一致的页面。 +审查:标记偏离此格式的规则。`verify-translation-pairing` 拒绝两种语言版本结构不一致的分组文件。 <a id="g2"></a> -### G.2:避免在公共接口参数中使用回调 +## G.2:避免在公共接口参数中使用回调 -#### 原因 +### 原因 - 难以阅读和推理。回调参数的类型没有说明被调用方何时调用它、调用几次,以及它抛异常时会怎样。 - 无法序列化。函数无法跨越进程边界,因此这样的接口不能作为 `@Remote` 方法或 SDK 方法。 -#### 反例 +### 反例 ```ts export interface UploadProgress { readonly loaded: number; readonly total?: number } @@ -103,7 +79,7 @@ export declare function upload( `onProgress` 会不会在 promise 落定后运行?它抛异常时会怎样?签名没有说明。 -#### 示例 +### 示例 ```ts export type UploadEvent = @@ -119,7 +95,7 @@ export declare function upload(data: Uint8Array): AsyncIterable<UploadEvent> 顺序、失败和取消都遵循迭代协议。调用方的异常留在调用方自己的循环里。 -#### 替代方案 +### 替代方案 - 单个结果:返回 `Promise`。 - 中间结果,例如后续步骤之前创建的子项 id:把操作拆成由调用方按顺序发起的多次调用。 @@ -127,32 +103,15 @@ export declare function upload(data: Uint8Array): AsyncIterable<UploadEvent> - 面向任意数量监听器的通知:发出类型化 Cordis 事件,由消费方通过 `ctx.on()` 订阅。 - 可替换的策略或工厂:声明一个由提供方实现的 Cordis 服务。 -#### 例外 +### 例外 -- 返回 disposer 的注册 API,例如 `ctx.on()`、`ctx.effect()` 或注册表的 `register()`,包括被注册的、带处理函数成员的对象。 +- event handler(事件处理函数):为处理事件而注册的函数或对象,例如 `ctx.on()` 的监听器、传给注册表 `register()` 的处理函数,或客户端组件的 `onClick` prop。注册返回其 disposer。传给处理函数的 waterfall `next()` 属于处理函数签名的一部分。 - 被调用方在调用返回或其 promise 落定之前就已调用完毕、异常会传回调用方、且不会保留的函数,例如比较函数或在锁内运行的任务。 -- 被调用方传给处理函数的续延,例如 waterfall 的 `next()`。 -- 客户端组件 prop 或 slot `inject` 成员中的操作回调,例如 `onClick`。 -#### 注解 +### 注解 公共接口指包入口导出、Cordis 服务方法、`@Remote` 方法或 SDK 方法。 -#### 检查方式 +### 检查方式 审查:在新增或修改的公共接口中,标记任何不属于例外的函数类型参数,或选项参数中的函数类型字段。 - -<a id="f"></a> -## F:前端 - -适用于渲染 Web 和 Desktop UI 的客户端包与应用的规则。本节没有规则。 - -<a id="b"></a> -## B:后端 - -适用于 Host 端包的规则:agent(智能体)运行时、服务、工具和进程管理。本节没有规则。 - -<a id="d"></a> -## D:数据交换 - -适用于跨越进程、网络或存储边界的数据的规则:`@Remote` 与 SDK 消息、事件以及持久化的 Session 数据。本节没有规则。 diff --git a/docs/defensive-patterns/README.i18n.yaml b/docs/defensive-patterns/README.i18n.yaml index 7b8829a956..eaa4f80b0a 100644 --- a/docs/defensive-patterns/README.i18n.yaml +++ b/docs/defensive-patterns/README.i18n.yaml @@ -6,5 +6,5 @@ en: 7229c49e920aa5b3 zh: 1dd52db6b4d84952 /defensive-patterns/why-these-rules: - en: aca10aff9de1160e - zh: a54752077cd25d63 + en: f03b040447328e9f + zh: d193a4d70344c680 diff --git a/docs/defensive-patterns/README.md b/docs/defensive-patterns/README.md index d12adbacc9..fe4a307faf 100644 --- a/docs/defensive-patterns/README.md +++ b/docs/defensive-patterns/README.md @@ -22,4 +22,4 @@ Five habits cover most of what follows, and each page is their application to on | Session reads, retention, conversation nodes, renderers | [conversation-and-session.md](conversation-and-session.md) | | Timing, state representation, shared ownership, decentralization, refactors, migrations, performance evidence, disposal, callbacks, subprocesses | [general.md](general.md) | -Type definitions and per-subsystem semantics live in [subsystems/](../subsystems/README.md); this directory carries the rules, and the semantics pages carry what the types mean. [dsh-code-review](../../.agents/skills/dsh-code-review/SKILL.md) reads this directory when judging a pull request, and Development routes through the same table from [AGENTS.md](../../AGENTS.md). Design rules that apply across artifacts live in [DSH Core Guidelines](../core-guidelines.md). +Type definitions and per-subsystem semantics live in [subsystems/](../subsystems/README.md); this directory carries the rules, and the semantics pages carry what the types mean. [dsh-code-review](../../.agents/skills/dsh-code-review/SKILL.md) reads this directory when judging a pull request, and Development routes through the same table from [AGENTS.md](../../AGENTS.md). Design rules that apply across artifacts live in [DSH Core Guidelines](../core-guidelines/README.md). diff --git a/docs/defensive-patterns/README.zh.md b/docs/defensive-patterns/README.zh.md index 5cacb22f6c..aef8176f2d 100644 --- a/docs/defensive-patterns/README.zh.md +++ b/docs/defensive-patterns/README.zh.md @@ -24,4 +24,4 @@ | Session 读取、持有、会话节点、renderer | [conversation-and-session.zh.md](conversation-and-session.zh.md) | | 时序、状态表示、共享归属、去中心化、重构、迁移、性能证据、清理、回调、子进程 | [general.zh.md](general.zh.md) | -类型定义与各子系统语义见 [subsystems/](../subsystems/README.zh.md);本目录承载**规则**,语义页承载**类型的含义**。[dsh-code-review](../../.agents/skills/dsh-code-review/SKILL.md) 在评审 pull request 时读本目录,日常修改经 [AGENTS.md](../../AGENTS.md) 路由到同一张表。跨产物适用的设计规则见 [DSH 核心准则](../core-guidelines.zh.md)。 +类型定义与各子系统语义见 [subsystems/](../subsystems/README.zh.md);本目录承载**规则**,语义页承载**类型的含义**。[dsh-code-review](../../.agents/skills/dsh-code-review/SKILL.md) 在评审 pull request 时读本目录,日常修改经 [AGENTS.md](../../AGENTS.md) 路由到同一张表。跨产物适用的设计规则见 [DSH 核心准则](../core-guidelines/README.zh.md)。 From 49b2403397e38e4ac7fce23b7e94cfc844f3e837 Mon Sep 17 00:00:00 2001 From: Turtle <turtle1999@deepseek.com> Date: Thu, 19 Nov 2026 11:13:16 +0800 Subject: [PATCH 5/5] docs: tighten G.1 layout and G.2 event-handler exception wording --- docs/AGENTS.md | 6 +++--- docs/core-guidelines/general.i18n.yaml | 8 ++++---- docs/core-guidelines/general.md | 4 ++-- docs/core-guidelines/general.zh.md | 4 ++-- docs/defensive-patterns/README.i18n.yaml | 4 ++-- docs/defensive-patterns/README.md | 2 +- docs/defensive-patterns/README.zh.md | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/AGENTS.md b/docs/AGENTS.md index 79d8229415..95c6d1d75a 100644 --- a/docs/AGENTS.md +++ b/docs/AGENTS.md @@ -23,8 +23,8 @@ Each fact has one home: the tier whose job it is; elsewhere, link there. | [architecture.md](architecture.md) | Ordered map: composition, core packages, loop, seams, extension points; read before changing `packages/` | Type definitions (→ subsystems), per-package detail (→ package READMEs), decision rationale (→ Agent Notes), implementation-status annotations | | [subsystems/](subsystems/README.md) | One reference page per subsystem: type definitions, semantics, and the generated Cordis API | Behavior narration (→ architecture.md) | | [Agent Notes](../.agents/notes/README.md) | Active decision records: the why, what-was-given-up, and required verification; `implemented/` notes describe shipped reality in present tense | Migration plans, acceptance-task checklists, fixture walkthroughs, and spec-speak ("should…") once the decision has shipped; archived notes are frozen history, never current authority | -| [defensive-patterns/](defensive-patterns/README.md) | Rules this repository enforces in review, split by artifact: one general bug-class page plus per-domain pages | Type definitions and semantics (→ subsystems), decision rationale (→ Agent Notes), cross-artifact design rules (→ core-guidelines/) | -| [core-guidelines/](core-guidelines/README.md) | Numbered design rules that apply across artifacts, one file per rule section, in the format its rule G.1 defines | Artifact-specific review rules (→ defensive-patterns/) | +| [defensive-patterns/](defensive-patterns/README.md) | Rules this repository enforces in review, split by artifact: one general bug-class page plus per-domain pages | Type definitions and semantics (→ subsystems), decision rationale (→ Agent Notes), design rules for writing code (→ core-guidelines/) | +| [core-guidelines/](core-guidelines/README.md) | Numbered design rules for writing code, one file per area (general, frontend, backend, data exchange), in the format its rule G.1 defines | Review checks for one artifact's known bug classes (→ defensive-patterns/) | | [postmortem/](postmortem/README.md) | Incident stories — the only tier where war-story narrative belongs | — | | [Persistence history](persistence-changes/README.md) and [format references](persistence-changes/historical-formats/README.md) | Type-change acknowledgements, release comparisons, and complete historical format schemas | Behavior-only changes; current runtime contracts | | [cookbook/](cookbook/adding-a-package.md) | Step-by-step how-tos with numbered verify steps | Design rationale (→ the Agent Note each guide links) | @@ -34,7 +34,7 @@ Each fact has one home: the tier whose job it is; elsewhere, link there. | Generated reference: the per-page `cordis-surface` regions in [subsystems/](subsystems/README.md), the [Cordis core API + inherited tier](cordis-api/context.md), [tool-catalog](tool-catalog.md), [config-catalog](config-catalog.md), [persistence-catalog](persistence-catalog.md), [module-graph.md](module-graph.md), [cli-help](cli-help.md) | Exhaustive English sources regenerated from source and freshness-gated; reviewed Chinese counterparts follow the [pairing workflow](i18n/README.md#scope-and-exclusions) | Hand edits to generated English sources or regions; Chinese counterparts update through pairing only | | Skills (`.agents/skills/`) | Reusable workflows and specialized decision standards | Product and runtime contracts (→ docs or source) | -Placement: bugs → postmortems; rationale → Agent Notes; procedures → cookbooks; type definitions → subsystems; package contracts → READMEs; standing orders → root `AGENTS.md` with a rationale link; artifact-specific review rules → `defensive-patterns/`; cross-artifact design rules → `core-guidelines/`. +Placement: bugs → postmortems; rationale → Agent Notes; procedures → cookbooks; type definitions → subsystems; package contracts → READMEs; standing orders → root `AGENTS.md` with a rationale link; artifact-specific review rules → `defensive-patterns/`; design rules for writing code → `core-guidelines/`. ## Writing rules diff --git a/docs/core-guidelines/general.i18n.yaml b/docs/core-guidelines/general.i18n.yaml index 22ee7f0703..8749588d66 100644 --- a/docs/core-guidelines/general.i18n.yaml +++ b/docs/core-guidelines/general.i18n.yaml @@ -18,8 +18,8 @@ en: b9b5449b4e5cc2bf zh: fa9be57f4cf4a267 /g-general/g-1-write-every-rule-in-the-standard-format/note: - en: f16ff8c2c486b139 - zh: 417d564a91671b67 + en: bd7d2c77aac162e2 + zh: 6187fa099e222e66 /g-general/g-1-write-every-rule-in-the-standard-format/enforcement: en: 696490996bd95844 zh: b8ded650efa9883b @@ -39,8 +39,8 @@ en: f0dabc1cf7cd8b19 zh: b00ed9e4f57c9111 /g-general/g-2-avoid-callbacks-in-public-interface-parameters/exception: - en: fa372f0af794d371 - zh: f835e1ce06ad7677 + en: 8533ab3ff7b2c4b6 + zh: a05d8df7545508c8 /g-general/g-2-avoid-callbacks-in-public-interface-parameters/note: en: 7b73640586b3aeba zh: 577477b5215ee03a diff --git a/docs/core-guidelines/general.md b/docs/core-guidelines/general.md index 857dca55ca..1ee337e29e 100644 --- a/docs/core-guidelines/general.md +++ b/docs/core-guidelines/general.md @@ -35,7 +35,7 @@ No ID. No imperative title. The requirement is buried in the rationale, and noth ### Note -A rule section is one bilingual file pair in this directory, named for the section, such as `general.md` and `general.zh.md`. Its level-1 heading is `<Letter>: <Name>`, followed by one paragraph that states its scope. `<Letter>` is one or more capital letters, unique among sections. [README.md](README.md) lists every section. +A rule section is a bilingual pair in this directory other than `README.md`, named for the section, such as `general.md` and `general.zh.md`. Its level-1 heading is `<Letter>: <Name>`, followed by one paragraph that states its scope. `<Letter>` is one or more capital letters, unique among sections. [README.md](README.md) lists every section and rule; add each new rule there in the same change. A rule is a level-2 heading `<Letter>.<n>: <Title>` in its section file. An `<a id>` anchor, the lowercased ID without the dot, precedes the heading. `<n>` counts from 1 in order of addition. A removed rule's number is never reused. @@ -105,7 +105,7 @@ Order, failure, and cancellation follow the iteration protocol. The caller's exc ### Exception -- An event handler: a function or object registered to handle events, such as a `ctx.on()` listener, a handler passed to a registry's `register()`, or a client component's `onClick` prop. The registration returns its disposer. The waterfall `next()` passed to a handler is part of the handler's signature. +- An event handler: a function or object that a caller registers to receive events, such as a `ctx.on()` listener (the registration returns its disposer), or a client component's event prop such as `onClick`. A waterfall `next()` passed to a handler is part of the handler's signature. - A function that the callee finishes calling before the call returns or its promise settles, whose exceptions reach the caller, and that the callee does not keep, such as a comparator or a task run under a lock. ### Note diff --git a/docs/core-guidelines/general.zh.md b/docs/core-guidelines/general.zh.md index 6fa950c619..842e9205ce 100644 --- a/docs/core-guidelines/general.zh.md +++ b/docs/core-guidelines/general.zh.md @@ -35,7 +35,7 @@ Callbacks caused bugs before, so prefer other designs where possible. ### 注解 -一个规则分组是本目录中一对以分组命名的双语文件,例如 `general.md` 和 `general.zh.md`。其一级标题为 `<字母>:<名称>`,后接一段说明该分组范围的文字。`<字母>` 由一个或多个大写字母组成,在各分组之间唯一。[README.zh.md](README.zh.md) 列出全部分组。 +一个规则分组是本目录中除 `README.md` 外、以分组命名的一对双语文件,例如 `general.md` 和 `general.zh.md`。其一级标题为 `<字母>:<名称>`,后接一段说明该分组范围的文字。`<字母>` 由一个或多个大写字母组成,在各分组之间唯一。[README.zh.md](README.zh.md) 列出全部分组和规则;新增规则时在同一变更中把它加入其中。 一条规则是所属分组文件中的一个二级标题 `<字母>.<n>:<标题>`。标题前放一个 `<a id>` 锚点,取值为去掉点号的小写编号。`<n>` 按添加顺序从 1 开始计数。删除的规则编号不再复用。 @@ -105,7 +105,7 @@ export declare function upload(data: Uint8Array): AsyncIterable<UploadEvent> ### 例外 -- event handler(事件处理函数):为处理事件而注册的函数或对象,例如 `ctx.on()` 的监听器、传给注册表 `register()` 的处理函数,或客户端组件的 `onClick` prop。注册返回其 disposer。传给处理函数的 waterfall `next()` 属于处理函数签名的一部分。 +- 事件处理函数:调用方为接收事件而注册的函数或对象,例如 `ctx.on()` 的监听器(注册返回其 disposer),以及客户端组件的事件 prop,例如 `onClick`。传给处理函数的 waterfall `next()` 属于处理函数签名的一部分。 - 被调用方在调用返回或其 promise 落定之前就已调用完毕、异常会传回调用方、且不会保留的函数,例如比较函数或在锁内运行的任务。 ### 注解 diff --git a/docs/defensive-patterns/README.i18n.yaml b/docs/defensive-patterns/README.i18n.yaml index eaa4f80b0a..14634b8ae4 100644 --- a/docs/defensive-patterns/README.i18n.yaml +++ b/docs/defensive-patterns/README.i18n.yaml @@ -6,5 +6,5 @@ en: 7229c49e920aa5b3 zh: 1dd52db6b4d84952 /defensive-patterns/why-these-rules: - en: f03b040447328e9f - zh: d193a4d70344c680 + en: 3ba292a9f396a390 + zh: 5b99713fe1169f9c diff --git a/docs/defensive-patterns/README.md b/docs/defensive-patterns/README.md index fe4a307faf..5a5646e695 100644 --- a/docs/defensive-patterns/README.md +++ b/docs/defensive-patterns/README.md @@ -22,4 +22,4 @@ Five habits cover most of what follows, and each page is their application to on | Session reads, retention, conversation nodes, renderers | [conversation-and-session.md](conversation-and-session.md) | | Timing, state representation, shared ownership, decentralization, refactors, migrations, performance evidence, disposal, callbacks, subprocesses | [general.md](general.md) | -Type definitions and per-subsystem semantics live in [subsystems/](../subsystems/README.md); this directory carries the rules, and the semantics pages carry what the types mean. [dsh-code-review](../../.agents/skills/dsh-code-review/SKILL.md) reads this directory when judging a pull request, and Development routes through the same table from [AGENTS.md](../../AGENTS.md). Design rules that apply across artifacts live in [DSH Core Guidelines](../core-guidelines/README.md). +Type definitions and per-subsystem semantics live in [subsystems/](../subsystems/README.md); this directory carries the rules, and the semantics pages carry what the types mean. [dsh-code-review](../../.agents/skills/dsh-code-review/SKILL.md) reads this directory when judging a pull request, and Development routes through the same table from [AGENTS.md](../../AGENTS.md). Numbered design rules for writing code live in [DSH Core Guidelines](../core-guidelines/README.md). diff --git a/docs/defensive-patterns/README.zh.md b/docs/defensive-patterns/README.zh.md index aef8176f2d..af49d38d59 100644 --- a/docs/defensive-patterns/README.zh.md +++ b/docs/defensive-patterns/README.zh.md @@ -24,4 +24,4 @@ | Session 读取、持有、会话节点、renderer | [conversation-and-session.zh.md](conversation-and-session.zh.md) | | 时序、状态表示、共享归属、去中心化、重构、迁移、性能证据、清理、回调、子进程 | [general.zh.md](general.zh.md) | -类型定义与各子系统语义见 [subsystems/](../subsystems/README.zh.md);本目录承载**规则**,语义页承载**类型的含义**。[dsh-code-review](../../.agents/skills/dsh-code-review/SKILL.md) 在评审 pull request 时读本目录,日常修改经 [AGENTS.md](../../AGENTS.md) 路由到同一张表。跨产物适用的设计规则见 [DSH 核心准则](../core-guidelines/README.zh.md)。 +类型定义与各子系统语义见 [subsystems/](../subsystems/README.zh.md);本目录承载**规则**,语义页承载**类型的含义**。[dsh-code-review](../../.agents/skills/dsh-code-review/SKILL.md) 在评审 pull request 时读本目录,日常修改经 [AGENTS.md](../../AGENTS.md) 路由到同一张表。带编号的代码设计规则见 [DSH 核心准则](../core-guidelines/README.zh.md)。