docs: make bilingual pairing universal

This commit is contained in:
Tianyi Cui
2026-07-26 15:06:51 +08:00
parent df8756ccf5
commit b4d032c1a2
24 changed files with 85 additions and 444 deletions
+2 -2
View File
@@ -2,5 +2,5 @@
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write
README.md: 6dec68bef44350895d30058b994ddacb63c70822
README.zh.md: a9d8e6c74c757271841b3f9ad208fe5e6350d645
README.md: d2f6d216b151673d818337c67a78dbe908786c8b
README.zh.md: 4c7f785ba7478f35cade742409d87746ddcdf8ec
+1 -1
View File
@@ -39,7 +39,7 @@ Every non-trivial change MUST add or update at least one Agent Note in the same
Updating the Agent Note that already owns the decision satisfies the rule; do not create a duplicate. Only a purely mechanical or local edit with no behavioral, contractual, structural, process, or rationale change is exempt. An Agent Note is never edited into a *different decision*: supersede it with a new one, and keep both notes cross-linked unless the old note is later fully consolidated under the rule below. Editing an `implemented/` Agent Note to track where its existing decision lives is required, not forbidden; see [implemented/AGENTS.md](implemented/AGENTS.md).
An implemented Agent Note that is fully superseded may be consolidated into the current owning note and deleted. Before deletion, the owner must preserve every unique rationale, alternative, consequence, verification contract, and named coverage gap; repair every inbound link; and delete any Chinese counterpart, consistency record, and `required` entry in [the translation-pairing manifest](../../scripts/translation-pairing.manifest.json) in the same change. Partial supersession does not qualify: keep both notes cross-linked and update every fact that remains current. Consolidation must not rewrite the old file into its opposite or rely on git history as the only copy of rationale.
An implemented Agent Note that is fully superseded may be consolidated into the current owning note and deleted. Before deletion, the owner must preserve every unique rationale, alternative, consequence, verification contract, and named coverage gap; repair every inbound link; and delete the Chinese counterpart and consistency record in the same change. Partial supersession does not qualify: keep both notes cross-linked and update every fact that remains current. Consolidation must not rewrite the old file into its opposite or rely on git history as the only copy of rationale.
A feature-addition note may be consolidated into the later removal note only when the feature is absent from production code, configuration, schemas, durable or wire formats, migration, and compatibility behavior; no current documentation presents it as available; and no test exercises it as supported behavior. Removal rationale and tests that verify absence may remain. The removal owner preserves the original motivation, why it no longer justified the feature, alternatives to full removal, the capability given up, conditions for reintroduction, and verification of complete absence. Obsolete implementation inventories and tests that only verified the deleted behavior are not current verification contracts. Removing one transport, default, implementation, or presentation is partial supersession, as is any surviving durable data or compatibility handling.
+1 -1
View File
@@ -41,7 +41,7 @@
更新已经拥有该决策的 Agent Note 即可满足规则;不要创建重复记录。只有不涉及行为、契约、结构、流程或理由变化的纯机械性或局部编辑才可豁免。Agent Note 永远不会被编辑为一个*不同的决策*:用新 Agent Note 取代旧记录,并让两个记录保持互相链接,除非后续依据下方规则完全合并旧记录。编辑 `implemented/` Agent Note 以跟踪其现有决策的所在位置是必需的,而非禁止的;见 [implemented/AGENTS.md](implemented/AGENTS.md)。
被完全取代的 implemented Agent Note 可以合并到当前持有该决策的记录中,并删除原文件。删除前,当前记录必须保存所有独有的决策依据、备选方案、影响、验证契约和明确指出的覆盖缺口;修复所有入站链接;并在同一变更中删除中文对侧文件一致性记录,以及[翻译配对 manifest(元数据清单)](../../scripts/translation-pairing.manifest.json)中对应的 `required` 条目。仅部分被取代的记录不符合此条件:保留两个记录并让它们互相链接,同时更新所有仍然适用的事实。合并不得将旧文件改写成与其相反的决策,也不得让 git 历史成为决策依据的唯一副本。
被完全取代的 implemented Agent Note 可以合并到当前持有该决策的记录中,并删除原文件。删除前,当前记录必须保存所有独有的决策依据、备选方案、影响、验证契约和明确指出的覆盖缺口;修复所有入站链接;并在同一变更中删除中文对侧文件一致性记录。仅部分被取代的记录不符合此条件:保留两个记录并让它们互相链接,同时更新所有仍然适用的事实。合并不得将旧文件改写成与其相反的决策,也不得让 git 历史成为决策依据的唯一副本。
只有当一项功能已从生产代码、配置、schema、持久化格式或协议格式、迁移和兼容行为中完全消失,当前文档不再将其描述为可用,且没有测试把它作为受支持行为来执行时,新增该功能的 Agent Note 才可合并进后续的移除记录。移除决策的依据和验证该功能已不存在的测试可以保留。移除决策的持有记录必须保留最初动机、为什么该动机已不足以证明保留该功能的合理性、完全移除之外的备选方案、放弃的能力、重新引入的条件,以及证明已彻底移除的验证。过时的实现清单和只验证已删除行为的测试不属于当前验证契约。仅移除一种传输、默认值、实现或展示属于部分取代;仍有任何持久数据或兼容处理也同样如此。
@@ -2,5 +2,5 @@
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write
2026-07-02-bilingual-docs-and-pairing-gate.md: 45a587586b1387d7c351f9c268bd038fcd549ed5
2026-07-02-bilingual-docs-and-pairing-gate.zh.md: 4875e48b43f2324ae117bb7aec1bf81dce3bc2bb
2026-07-02-bilingual-docs-and-pairing-gate.md: 3732e6812a3f1f40242aa5a83a0bf1d1bc4d6139
2026-07-02-bilingual-docs-and-pairing-gate.zh.md: a870e063230a34b807eed2f4ffc1c6067cb3aedc
@@ -6,14 +6,14 @@ English | [中文](2026-07-02-bilingual-docs-and-pairing-gate.zh.md)
## Problem
This repo's README and docs tree are read by people and agents inside and outside the company, in both English and Chinese. Maintaining a second language by hand, with no mechanism, is how translations rot: one side moves on, the other silently lies, and no gate notices. The repo's standing answer to invariants of this kind is to encode them as a mechanical check (see [quality gates](2026-06-11-quality-gates.md) and [doc-sync enforcement](2026-06-11-doc-sync-enforcement.md)), so the bilingual policy ships with one.
This repo's documentation corpus is read by people and agents inside and outside the company, in both English and Chinese. Maintaining a second language by hand, with no mechanism, is how translations rot: one side moves on, the other silently lies, and no gate notices. The repo's standing answer to invariants of this kind is to encode them as a mechanical check (see [quality gates](2026-06-11-quality-gates.md) and [doc-sync enforcement](2026-06-11-doc-sync-enforcement.md)), so the bilingual policy ships with one.
## Decision
- **Paired sibling files with equal authority.** A documentation pair is three sibling files: English `foo.md`, Chinese `foo.zh.md`, and a consistency record `foo.i18n.yaml`. Neither language is canonical — a document may be authored and reviewed Chinese-first and translated to English afterwards, or the reverse; what binds the pair is that both sides must say the same thing, and pairs merge whole (both languages plus the record, never one alone). Policy: [docs/i18n/README.md](../../../../docs/i18n/README.md); translation rules: [docs/i18n/translation-rules.md](../../../../docs/i18n/translation-rules.md); terminology source of truth: [docs/i18n/terminology.md](../../../../docs/i18n/terminology.md).
- **A sidecar record of both blob hashes makes consistency checkable.** `foo.i18n.yaml` holds the full git blob hash of each side as of the last confirmed-consistent state. An edit to either side without re-confirming the pair is then mechanically detectable as a pure content comparison — no history lookup — and the hashes are computable for files edited in the same PR, which a commit-hash record is not. Re-recording (`verify-translation-pairing --write`) produces a reviewable yaml diff: confirming consistency is an explicit, visible act in the PR.
- **`verify-translation-pairing` joins `doc-sync`.** The gate ([scripts/verify-translation-pairing.ts](../../../../scripts/verify-translation-pairing.ts)) enforces: sources selected explicitly, by document class, or by the manifest's `requiredSince` cutoff have complete pairs; every existing pair is complete (all three files) and consistent (both hashes match, switcher links both ways, structural signatures identical); and excluded generated, instruction, or bilingual-by-construction files stay unpaired. The `requiredClasses` set in [scripts/translation-pairing.manifest.json](../../../../scripts/translation-pairing.manifest.json) closes a translated class for all present and future files instead of relying on an enumerated snapshot. Source-oriented code gates consume a `.zh.md` fence sequence as a derivative only when its unsuffixed sibling has the same tracked fences in the same order with byte-identical bodies; an incomplete, reordered, reclassified, or changed sequence stays independent, so the owning code gate or pairing gate reports the mismatch.
- **The enforcement frontier advances in coherent review batches, then closes by class.** Explicit `required` entries admit related files while their back-catalog is still being reviewed; after that catalog is complete, its `non-readme` or `readme` class enters `requiredClasses` and can no longer grow a backlog. Both classes are closed. README discovery covers every case-insensitive README basename outside vendored, dependency, and ignored build-output trees, including future top-level directories. A site-published pair uses `pairedPages()` so the root locale projects `.zh.md` and `/en/` projects `.md`; creating a counterpart alone does not publish it.
- **`verify-translation-pairing` joins `doc-sync`.** The gate ([scripts/verify-translation-pairing.ts](../../../../scripts/verify-translation-pairing.ts)) enforces: every discovered, non-excluded source has a complete pair; every existing pair is complete (all three files) and consistent (both hashes match, switcher links both ways, structural signatures identical); and excluded generated, instruction, or bilingual-by-construction files stay unpaired. [scripts/translation-pairing.manifest.json](../../../../scripts/translation-pairing.manifest.json) contains only explicit exclusions, so no requirement can bypass discovery and receive a weaker check. Source-oriented code gates consume a `.zh.md` fence sequence as a derivative only when its unsuffixed sibling has the same tracked fences in the same order with byte-identical bodies; an incomplete, reordered, reclassified, or changed sequence stays independent, so the owning code gate or pairing gate reports the mismatch.
- **One corpus-wide requirement.** Every document in scope requires a complete pair from creation; the policy has no per-file rollout state, date cutoff, or README-specific class. README discovery covers every case-insensitive README basename outside vendored, dependency, and ignored build-output trees, including future top-level directories. A site-published pair uses `pairedPages()` so the root locale projects `.zh.md` and `/en/` projects `.md`; creating a counterpart alone does not publish it.
- **Pairing records are metadata, not Cordis Loader configuration.** Cordis configuration discovery accepts actual `.cordis.yml` and `.cordis.yaml` files while excluding `*.i18n.yaml`, even when the document name contains `cordis`. This preserves validation of executable Loader entries without parsing translation hashes as configuration.
- **Translation is agent work with human review.** The committed workflow is [.agents/skills/dsh-translate-docs](../../../skills/dsh-translate-docs/SKILL.md), following the same pattern as [dsh-code-review](../../../skills/dsh-code-review/SKILL.md): the skill carries the workflow and defers to the docs as sources of truth. The skill directs the orchestrating agent to delegate translation writing to a subagent.
@@ -40,5 +40,5 @@ Paired sibling files with locale suffixes are the dominant Chinese big-tech conv
- Every pair adds a third file to the tree. The record is machine-written (`--write`), so the cost is directory noise, not maintenance effort; in exchange, "who confirmed these consistent, and when" is answerable from git blame on the yaml.
- When the two sides disagree, no mechanical rule picks a winner — the PR review does. That is the price of equal authority, accepted deliberately: the alternative (a canonical language) forbids Chinese-first authoring.
- Generated docs (`cordis-catalog/`, `tool-catalog/`, `module-graph.md`) are excluded for now; the planned follow-up is to teach their generators to emit Chinese alongside English, at which point they leave the exclusion list.
- Explicit `required` entries and the date cutoff preserve the reviewed rollout history, while the two closed classes make every current and future in-scope document mandatory. No document class can grow a new backlog.
- The exclusions-only manifest makes every current and future in-scope document mandatory through the same path. There is no explicit requirement, cutoff, or class entry that can fall outside discovery while appearing enforced.
- The recorded hashes double as the update tool (`git cat-file -p <hash>` recovers either side's last-confirmed text for a minimal diff-based update), so re-translation of whole files is never forced by the mechanism.
@@ -6,14 +6,14 @@ Status: implemented
## 问题
本仓库的 README 与 docs 目录树会被公司内外的人和 agent(智能体)以中英两种语言阅读。在没有机制的情况下纯靠手工维护第二语言,正是译文腐烂的根源:一侧持续演进,另一侧默默失实,而没有门禁会注意到。对于这类不变式,本仓库一贯的做法是将其编码为机械检查(见[质量门禁](2026-06-11-quality-gates.md)与 [doc-sync 强制](2026-06-11-doc-sync-enforcement.md)),因此双语政策随附一道门禁一起交付。
本仓库的文档语料会被公司内外的人和 agent(智能体)以中英两种语言阅读。在没有机制的情况下纯靠手工维护第二语言,正是译文腐烂的根源:一侧持续演进,另一侧默默失实,而没有门禁会注意到。对于这类不变式,本仓库一贯的做法是将其编码为机械检查(见[质量门禁](2026-06-11-quality-gates.md)与 [doc-sync 强制](2026-06-11-doc-sync-enforcement.md)),因此双语政策随附一道门禁一起交付。
## 决策
- **配对兄弟文件,两种语言同权。** 一对文档由三个兄弟文件组成:英文 `foo.md`、中文 `foo.zh.md`,以及一份一致性记录 `foo.i18n.yaml`。没有哪种语言是正典:一篇文档可以先用中文撰写和评审、之后再译成英文,反之亦可;约束配对的是:两侧必须表达相同的内容,且配对整体合并(两种语言加记录,绝不单独落一侧)。政策见 [docs/i18n/README.md](../../../../docs/i18n/README.md);翻译规则见 [docs/i18n/translation-rules.md](../../../../docs/i18n/translation-rules.md);术语真源见 [docs/i18n/terminology.md](../../../../docs/i18n/terminology.md)。
- **伴随记录保存两侧 blob hash,使一致性可检查。** `foo.i18n.yaml` 保存两侧文件在上一次确认一致时各自的完整 git blob hash。此后修改了任一侧而未重新确认配对,都能被机械检测出来(纯内容比较,无需查询历史),而且同一个 PR(Pull Request)内改动的文件也能计算出 hash,commit hash 式的记录做不到这一点。重新记录(`verify-translation-pairing --write`)会产生一份可评审的 yaml diff:确认一致在 PR 中是一个显式、可见的动作。
- **`verify-translation-pairing` 加入 `doc-sync`。** 门禁([scripts/verify-translation-pairing.ts](../../../../scripts/verify-translation-pairing.ts))强制执行以下规则:通过显式指定、文档类别或 manifest(元数据清单)的 `requiredSince` 分界日期选中的源文档必须有完整配对;任何已存在的配对必须完整(三个文件齐全)且一致(两个 hash 匹配、切换行双向互链、结构签名一致);被排除的生成文档、指令文档或本身即双语的文档不得配对。[scripts/translation-pairing.manifest.json](../../../../scripts/translation-pairing.manifest.json) 中的 `requiredClasses` 集合会将已完成翻译的类别纳入强制范围,对其当前及今后所有文件强制执行契约,而不再依赖一份枚举式快照。只有当 `.zh.md` 围栏序列与其无后缀兄弟文件拥有顺序相同、正文按字节一致的同一组受跟踪围栏时,面向源码的代码门禁才会将其作为派生内容消费;不完整、顺序变更、重分类或已改动的序列仍会独立受检,因此由其所属的代码门禁或配对门禁报告不匹配。
- **执行红线按连贯的评审批次推进,再以类别为单位完成强制覆盖。** 在存量文档仍处于评审阶段时,显式 `required` 条目会纳入相关文件;存量文档全部完成后,其 `non-readme``readme` 类别进入 `requiredClasses`,不再产生新的 backlog。这两个类别均已纳入强制范围。README 发现会覆盖 vendor 源码、依赖目录与被忽略的构建产物目录之外所有文件名不区分大小写匹配 README 的文件,包括今后新增的顶层目录。发布到文档站的配对使用 `pairedPages()`,由根 locale 投影 `.zh.md`,由 `/en/` 投影 `.md`;仅创建对侧文件并不会发布它。
- **`verify-translation-pairing` 加入 `doc-sync`。** 门禁([scripts/verify-translation-pairing.ts](../../../../scripts/verify-translation-pairing.ts))强制执行以下规则:每个已发现且未排除的源文档有完整配对;每个现有配对都完整(三个文件齐全)且一致(两个 hash 匹配、切换行双向互链、结构签名一致);被排除的生成文档、指令文档或本身即双语的文档不得配对。[scripts/translation-pairing.manifest.json](../../../../scripts/translation-pairing.manifest.json) 只包含显式排除项,因此任何要求都无法绕过发现流程而接受较弱的检查。只有当 `.zh.md` 围栏序列与其无后缀兄弟文件拥有顺序相同、正文按字节一致的同一组受跟踪围栏时,面向源码的代码门禁才会将其作为派生内容消费;不完整、顺序变更、重分类或已改动的序列仍会独立受检,因此由其所属的代码门禁或配对门禁报告不匹配。
- **全语料统一要求。** 范围内的每篇文档从创建起就必须有完整配对;政策没有逐文件推进状态、日期分界或 README 专用类别。README 发现会覆盖 vendor 源码、依赖目录与被忽略的构建产物目录之外所有文件名不区分大小写匹配 README 的文件,包括今后新增的顶层目录。发布到文档站的配对使用 `pairedPages()`,由根 locale 投影 `.zh.md`,由 `/en/` 投影 `.md`;仅创建对侧文件并不会发布它。
- **配对记录是元数据,而不是 Cordis Loader 配置。** Cordis 配置发现会接受实际的 `.cordis.yml``.cordis.yaml` 文件,同时排除 `*.i18n.yaml`,即使文档名中包含 `cordis` 也不例外。这样既能继续校验可执行的 Loader 配置项,又不会把翻译 hash 当作配置来解析。
- **翻译是 agent 的工作,由人评审。** 仓库内置的工作流是 [.agents/skills/dsh-translate-docs](../../../skills/dsh-translate-docs/SKILL.md),与 [dsh-code-review](../../../skills/dsh-code-review/SKILL.md) 模式相同:skill(技能)承载工作流,并将文档作为真源。该 skill 要求编排 agent 把翻译写作委派给 subagent。
@@ -40,5 +40,5 @@ Status: implemented
- 每个配对给目录树多添一个文件。记录由机器写入(`--write`),代价是目录噪音而非维护负担;换来的是「谁在何时确认过这对文档一致」可以从 yaml 的 git blame 直接回答。
- 两侧说法冲突时,没有机械规则裁决谁赢,由 PR 评审裁决。这是同权的代价,且是有意接受的:另一个选项(正典语言)会禁止中文先行撰写。
- 生成文档(`cordis-catalog/``tool-catalog/``module-graph.md`)暂被排除;计划中的后续工作是让生成器在输出英文的同时输出中文,届时将这些文件移出排除清单。
- 显式 `required` 条目与日期分界保留已经评审的推进历史,而两个已纳入强制范围的类别会将当前及今后所有范围内的文档列为必选项。任何文档类别都不能新增 backlog(待翻清单)
- 只含排除项的 manifest 通过同一路径,要求当前及今后纳入范围的每篇文档都必须配对。不存在显式要求、分界或类别条目可以落在发现范围之外,却看似已经强制执行
- 记录的 hash 兼作更新工具(`git cat-file -p <hash>` 能还原任一侧上次确认的文本,用于基于 diff 的最小更新),因此这套机制从不强迫整篇重译。
@@ -2,5 +2,5 @@
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write
2026-07-04-doc-tiers-and-budgets.md: 7acdba8bfd96d183c418b3935d7b8e7f237d3607
2026-07-04-doc-tiers-and-budgets.zh.md: 0f07a92740d31dd13cb523d73ac8a3699d666d30
2026-07-04-doc-tiers-and-budgets.md: a52c40a9a147fd39fdec4c61079822f1b1115227
2026-07-04-doc-tiers-and-budgets.zh.md: d03c2046c9963e4d62d2a7221d4563f60d3f4953
@@ -12,7 +12,7 @@ Standing docs accumulated repeated rules, retold incidents, duplicated package m
- **A tier taxonomy with one home per fact.** [docs/AGENTS.md](../../../../docs/AGENTS.md) is the documentation standard: it assigns every Markdown tier a single job (standing orders, system map, type catalog, decision records, incident stories, how-tos, per-package contracts, generated catalogs, workflows), forbids restating a fact outside its home tier (link instead), and carries the slop checklist used when writing or reviewing any doc.
- **A narrow, hard budget gate.** [scripts/verify-doc-budgets.ts](../../../../scripts/verify-doc-budgets.ts) joins `doc-sync`: every doc listed in [scripts/doc-budgets.manifest.json](../../../../scripts/doc-budgets.manifest.json) must stay under its word ceiling (`wc -w` semantics, whole file), and a budgeted file that is missing fails the gate so a rename cannot silently orphan its budget. Scope is deliberately only the accretion-prone standing docs — the root and subtree `AGENTS.md` files, `architecture.md`, `packages/README.md`, and the standing policy docs they evict content into (`docs/testing.md`, `docs/defensive-patterns.md`). Reference docs, Agent Notes, and package READMEs are unbudgeted: length is legitimate there when every row is a fact, and review plus the slop checklist govern them.
- **Ceilings are an enforcement frontier that ratchets.** A ceiling sits at least 5% above the doc's current size — working headroom, so routine wording edits pass while real growth still trips the gate — and ratchets down, keeping that margin, as the doc is brought to its target budget (root `AGENTS.md` ≤ 1,500 words; `architecture.md` ≤ 1,800; subtree `AGENTS.md` ≤ 600; `packages/README.md` ≤ 600) — the same rollout mechanism as the [translation-pairing `required` list](2026-07-02-bilingual-docs-and-pairing-gate.md). When the gate goes red the fix is to relocate or condense per the taxonomy; raising a ceiling is permitted only with explicit justification in the PR description, the manifest diff being the reviewable act.
- **Ceilings are an enforcement frontier that ratchets.** A ceiling sits at least 5% above the doc's current size — working headroom, so routine wording edits pass while real growth still trips the gate — and ratchets down, keeping that margin, as the doc is brought to its target budget (root `AGENTS.md` ≤ 1,500 words; `architecture.md` ≤ 1,800; subtree `AGENTS.md` ≤ 600; `packages/README.md` ≤ 600). When the gate goes red the fix is to relocate or condense per the taxonomy; raising a ceiling is permitted only with explicit justification in the PR description, the manifest diff being the reviewable act.
- **A thin workflow skill, contracts in docs.** [.agents/skills/dsh-doc-standards](../../../skills/dsh-doc-standards/SKILL.md) carries the placement/audit/red-gate workflow and defers to the standard as its source of truth, the same split as [dsh-translate-docs](../../../skills/dsh-translate-docs/SKILL.md) over the i18n contract.
## Alternatives considered
@@ -12,7 +12,7 @@ Status: implemented
- **每项事实只归属一处的层级分类。**[docs/AGENTS.md](../../../../docs/AGENTS.md) 是文档标准:它为每种 Markdown 层级分配单一职责(常设指令、系统图、类型目录、决策记录、事件故事、操作指南、各包契约、生成式目录、工作流),禁止在事实归属层级之外重复陈述(应改为链接),并包含编写或评审任何文档时使用的赘余检查清单。
- **范围窄且严格的预算门禁。**[scripts/verify-doc-budgets.ts](../../../../scripts/verify-doc-budgets.ts) 接入 `doc-sync`[scripts/doc-budgets.manifest.json](../../../../scripts/doc-budgets.manifest.json) 列出的每份文档都必须低于其字数上限(采用 `wc -w` 语义,统计整个文件);预算内文件缺失也会使门禁失败,使重命名无法悄然遗落其预算。范围刻意只涵盖容易膨胀的常设文档——根目录和子树中的 `AGENTS.md` 文件、`architecture.md``packages/README.md`,以及它们将内容移入的常设策略文档(`docs/testing.md``docs/defensive-patterns.md`)。参考文档、Agent Note 和包 README 不设预算:只要每一行都是事实,长度在这些位置就是合理的;评审和赘余检查清单负责约束它们。
- **上限是只进不退的执行红线。** 上限设定为文档当前字数的至少 105%(留出工作余量,使日常措辞调整能通过,而真正的膨胀仍会触发门禁),并随着文档被精简到目标预算而同步下调、保持该余量(根 `AGENTS.md` ≤ 1,500 词;`architecture.md` ≤ 1,800;子树 `AGENTS.md` ≤ 600`packages/README.md` ≤ 600)。推进机制与[翻译配对的 `required` 清单](2026-07-02-bilingual-docs-and-pairing-gate.md)相同。门禁变红时,修复方式是按分类体系迁移或压缩内容;只有在 PR(Pull Request)描述中给出明确理由时才允许提高上限,manifest(元数据清单)的 diff 本身即为可评审的动作。
- **上限是只进不退的执行红线。** 上限设定为文档当前字数的至少 105%(留出工作余量,使日常措辞调整能通过,而真正的膨胀仍会触发门禁),并随着文档被精简到目标预算而同步下调、保持该余量(根 `AGENTS.md` ≤ 1,500 词;`architecture.md` ≤ 1,800;子树 `AGENTS.md` ≤ 600`packages/README.md` ≤ 600)。门禁变红时,修复方式是按分类体系迁移或压缩内容;只有在 PR(Pull Request)描述中给出明确理由时才允许提高上限,manifest(元数据清单)的 diff 本身即为可评审的动作。
- **精简的工作流 skill(技能),契约归文档。**[.agents/skills/dsh-doc-standards](../../../skills/dsh-doc-standards/SKILL.md) 承载放置/审计/红灯门禁工作流,并以文档标准为真源,与 [dsh-translate-docs](../../../skills/dsh-translate-docs/SKILL.md) 和 i18n 契约之间的分工相同。
## 曾考虑的替代方案
@@ -2,5 +2,5 @@
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write
2026-07-19-require-agent-notes-for-non-trivial-changes.md: 32d7408b3d56e6571a14a8191e9b4b0fe901f5a3
2026-07-19-require-agent-notes-for-non-trivial-changes.zh.md: 713845706e650b4b4acd591368d9bcff137a38b7
2026-07-19-require-agent-notes-for-non-trivial-changes.md: 162ae61affb4c1b0ad526fa0da41f84ebbb02089
2026-07-19-require-agent-notes-for-non-trivial-changes.zh.md: cd015ba62f1f2b1e9e5e6c36d1cde5bd35cba84c
@@ -14,7 +14,7 @@ Every non-trivial change adds or updates at least one Agent Note in the same PR.
Updating the note that already owns a decision satisfies the rule; a new note is required only when no note owns it. Purely mechanical or local edits with no behavioral, contractual, structural, process, or rationale change are exempt. The [Agent Notes README](../../README.md#when-to-write-one) owns this boundary, while root `AGENTS.md` carries the standing order.
A fully superseded implemented note may be consolidated into the current owning note and deleted only after that owner preserves every unique rationale, alternative, consequence, verification contract, and named coverage gap. The same change repairs inbound links and removes any Chinese counterpart, consistency record, and `required` entry in `scripts/translation-pairing.manifest.json`. Partial supersession keeps both notes cross-linked and current; consolidation neither rewrites an old decision into its opposite nor leaves git history as the only copy of rationale.
A fully superseded implemented note may be consolidated into the current owning note and deleted only after that owner preserves every unique rationale, alternative, consequence, verification contract, and named coverage gap. The same change repairs inbound links and removes the Chinese counterpart and consistency record. Partial supersession keeps both notes cross-linked and current; consolidation neither rewrites an old decision into its opposite nor leaves git history as the only copy of rationale.
When a later decision removes an earlier feature completely, the removal note becomes the current owner only after the feature is absent from production code, configuration, schemas, durable or wire formats, migration, and compatibility behavior; no current documentation presents it as available; and no test exercises it as supported behavior. Removal rationale and tests that verify absence may remain. The removal owner preserves the feature's original motivation, why that motivation no longer justified the surface, alternatives to full removal, the capability given up, conditions for reintroduction, and verification of complete absence. Implementation inventories and tests that only described the deleted behavior are obsolete rather than current verification contracts. A removal limited to one transport, default, implementation, or presentation remains partial supersession.
@@ -42,5 +42,5 @@ Review enforces the semantic boundary. No automated gate attempts to classify a
- Contributors maintain an existing owning note instead of creating duplicate records.
- Fully superseded records can collapse into one current owner without losing their unique rationale or verification contract.
- Features that were later removed can have one current owner without carrying obsolete implementation and test inventories forward.
- Partial supersession remains explicit and cross-linked, while deletion requires link, bilingual-pair, and required-manifest cleanup in the same change.
- Partial supersession remains explicit and cross-linked, while deletion requires link and bilingual-pair cleanup in the same change.
- Mechanical edits remain lightweight, and the gate topology and runtime remain unchanged.
@@ -14,7 +14,7 @@ Status: implemented
更新已经持有该决策的 Agent Note 即满足规则;仅当没有 Agent Note 持有该决策时才新增记录。完全机械或局部、且不改变行为、契约、结构、流程或决策依据的编辑可豁免。[Agent Notes README](../../README.md#when-to-write-one) 持有这条边界,根目录 `AGENTS.md` 则携带常驻指令。
只有在当前持有该决策的记录保存了所有独有的决策依据、备选方案、影响、验证契约和明确指出的覆盖缺口后,才可将被完全取代的 implemented Agent Note 合并到该记录中并删除。同一变更还要修复入站链接,并删除中文对侧文件一致性记录,以及 `scripts/translation-pairing.manifest.json` 中对应的 `required` 条目。仅部分被取代时,两个记录仍需互相链接并保持与现状一致;合并既不将旧决策改写成与其相反的决策,也不让 git 历史成为决策依据的唯一副本。
只有在当前持有该决策的记录保存了所有独有的决策依据、备选方案、影响、验证契约和明确指出的覆盖缺口后,才可将被完全取代的 implemented Agent Note 合并到该记录中并删除。同一变更还要修复入站链接,并删除中文对侧文件一致性记录。仅部分被取代时,两个记录仍需互相链接并保持与现状一致;合并既不将旧决策改写成与其相反的决策,也不让 git 历史成为决策依据的唯一副本。
后续决策完全移除较早的功能时,只有该功能已从生产代码、配置、schema、持久化格式或协议格式、迁移和兼容行为中消失,当前文档不再将其描述为可用,且没有测试把它作为受支持行为来执行,移除记录才会成为当前持有记录。移除决策的依据和验证该功能已不存在的测试可以保留。它必须保留该功能的最初动机、为什么该动机已不足以证明继续保留该功能、完全移除之外的备选方案、放弃的能力、重新引入的条件,以及证明已彻底移除的验证。只描述已删除行为的实现清单和测试已经过时,不属于当前验证契约。仅移除一种传输、默认值、实现或展示仍属于部分取代。
@@ -42,5 +42,5 @@ Status: implemented
- 贡献者维护现有的决策持有记录,而不是创建重复记录。
- 被完全取代的记录可以归并到一个当前持有记录中,同时不丢失其独有的决策依据或验证契约。
- 后来被移除的功能可以只有一个当前持有记录,而无需继续保留过时的实现与测试清单。
- 仅部分被取代的情况仍需明确记录并互相链接;删除记录则必须在同一变更中清理链接双语配对`scripts/translation-pairing.manifest.json``required` 条目
- 仅部分被取代的情况仍需明确记录并互相链接;删除记录则必须在同一变更中清理链接双语配对。
- 机械编辑仍保持轻量,门禁拓扑和运行时间也保持不变。
@@ -75,7 +75,7 @@ Follow the deletion rule in the [Agent Note contract](../../notes/README.md#when
1. Identify the current owner from shipped code, configuration, generated catalogs, package docs, newer Agent Notes, and inbound links; dates and titles are discovery hints, not proof.
2. Classify the old note as fully or partially superseded. Any surviving behavior, current contract, durable format, compatibility obligation, or independently current rejected alternative makes it partial. Rationale that can be transferred to the current owner does not by itself make supersession partial.
3. For full supersession, move every unique rationale, alternative, consequence, shipped verification contract, and named coverage gap into the current owner. An inventory that only describes deleted implementation mechanics is not one of those decision facts.
4. Repair every inbound link, then delete the English note, Chinese counterpart, consistency record, and required-pair manifest entry together.
4. Repair every inbound link, then delete the English note, Chinese counterpart, and consistency record together.
5. Search exact filenames, symbols, config keys, event names, and wire strings after the edit. Keep partial supersessions cross-linked and current.
An added-then-removed feature is a common full-supersession case. Let the removal note own the history only when the feature is absent from production code, configuration, schemas, durable or wire formats, migration, and compatibility behavior; no current documentation presents it as available; and no test exercises it as supported behavior. Removal rationale and tests that enforce absence may remain. Preserve why the feature originally existed, why that motivation no longer justified it, alternatives to full removal, the capability given up, conditions for reintroduction, and evidence that removal is complete. Old tests and implementation mechanics that verified only the deleted behavior are not current verification contracts.
+3 -3
View File
@@ -17,7 +17,7 @@ When this skill fires and translations need to be written, do not translate your
These are authoritative; read them at the source so this skill never drifts out of sync.
- **[docs/i18n/README.md](../../../docs/i18n/README.md)** — the pairing contract: the three-file pair (`foo.md`, `foo.zh.md`, `foo.i18n.yaml`), the consistency record's both-side blob hashes, the language-switcher lines, scope/exclusions, and the rollout manifest.
- **[docs/i18n/README.md](../../../docs/i18n/README.md)** — the pairing contract: the three-file pair (`foo.md`, `foo.zh.md`, `foo.i18n.yaml`), the consistency record's both-side blob hashes, the language-switcher lines, scope, and exclusions.
- **[docs/i18n/translation-rules.md](../../../docs/i18n/translation-rules.md)** — how to translate: faithfulness, structure preservation, terminology discipline, typography (MUST/SHOULD levels).
- **[docs/i18n/terminology.md](../../../docs/i18n/terminology.md)** — the terminology table, binding in both directions. Load it BEFORE translating, not when a term feels uncertain; the terms you don't notice are the ones that drift.
- **[docs/i18n/translation-prompt.md](../../../docs/i18n/translation-prompt.md)** — the automated pipeline's calibrated machine-consumed template. Agents using this skill do not render it; the terminology table is the only repository file the automated renderer injects, while this skill and `translation-rules.md` remain binding for agent-authored translations.
@@ -25,7 +25,7 @@ These are authoritative; read them at the source so this skill never drifts out
## Find the work
- `pnpm run verify-translation-pairing --list` prints every in-scope document as missing / out-of-sync / ok — the work list for a translation batch.
- `pnpm run verify-translation-pairing --list` prints every in-scope document as missing / out-of-sync / ok. Missing and out-of-sync rows are contract violations; the normal check rejects them.
- In a PR that edits paired docs, the work list is the diff itself: every changed side of a pair needs its counterpart updated and the pair re-recorded in the same PR, and the gate goes red if you forget.
## Triage by change type
@@ -56,7 +56,7 @@ Do not process every file the same way:
1. Switcher: `[English](foo.md) | 中文` immediately after the Chinese file's H1, `English | [中文](foo.zh.md)` after the English file's H1 — add both if this is a new pair.
2. Record consistency: `pnpm run verify-translation-pairing --write` recomputes and records both sides' full blob hashes in `foo.i18n.yaml`. The yaml diff in your PR is the reviewable statement "I confirmed these two say the same thing" — only run it after you actually have.
3. New batch landed? Add the `.md` paths to `required` in [scripts/translation-pairing.manifest.json](../../../scripts/translation-pairing.manifest.json) so the gate ratchets forward.
3. No manifest entry is needed for an ordinary document: every in-scope source requires a pair. Change [scripts/translation-pairing.manifest.json](../../../scripts/translation-pairing.manifest.json) only when the owning policy documents a genuine generated, instructional, or bilingual-by-construction exclusion.
## Verify the mechanical and human halves
+2 -2
View File
@@ -2,5 +2,5 @@
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write
README.md: 25c4698b2efacbb0cb1dd5b8f27ad94be051c558
README.zh.md: e5faefff97d4ef8de9bf05613f257ede06c5e4a7
README.md: 504e042eee5382d92f1b3f007c1d39695ff2ddde
README.zh.md: e39bb2b0ca3e4fc4b831ded50ad91f4f1bf2285a
+6 -7
View File
@@ -2,7 +2,7 @@
English | [中文](README.zh.md)
This repo's documentation is read by people and agents both inside and outside the company, so the README, Agent Notes, and docs tree are maintained in English and Simplified Chinese. This page defines the pairing contract, the enforcement gate, and the rollout policy; [translation-rules.md](translation-rules.md) defines how to translate; [terminology.md](terminology.md) is the terminology source of truth. The committed agent workflow lives in [.agents/skills/dsh-translate-docs](../../.agents/skills/dsh-translate-docs/SKILL.md).
This repo's documentation is read by people and agents both inside and outside the company, so every document in scope is maintained in English and Simplified Chinese. This page defines the pairing contract, enforcement gate, scope, and exclusions; [translation-rules.md](translation-rules.md) defines how to translate; [terminology.md](terminology.md) is the terminology source of truth. The committed agent workflow lives in [.agents/skills/dsh-translate-docs](../../.agents/skills/dsh-translate-docs/SKILL.md).
## The pairing contract
@@ -23,20 +23,19 @@ This repo's documentation is read by people and agents both inside and outside t
`pnpm run verify-translation-pairing` (part of `doc-sync`, which contributors run locally for documentation changes and CI runs exhaustively) enforces the contract mechanically:
1. Every file listed as `required`, and every document whose class appears in `requiredClasses`, in [scripts/translation-pairing.manifest.json](../../scripts/translation-pairing.manifest.json) has a complete pair. The classes are `non-readme` and `readme`; class matching is case-insensitive on the basename, so `missions/readme.md` is a README.
2. Every pair that exists at all — required or not — is complete and consistent: all three files present, each side's current blob hash equals the recorded one (editing either side without re-confirming the pair goes red), both sides carry the language switcher, and the structural signatures match in order — heading depths, verbatim code blocks (info string and content), table row and column counts, list kinds, ordered-list starts, item counts, and every link target apart from the switcher.
1. Every document in scope has a complete pair. README discovery is case-insensitive on the basename, so `missions/readme.md` is in scope alongside the other documentation roots.
2. Every pair artifact that exists at all is complete and consistent: all three files present, each side's current blob hash equals the recorded one (editing either side without re-confirming the pair goes red), both sides carry the language switcher, and the structural signatures match in order — heading depths, verbatim code blocks (info string and content), table row and column counts, list kinds, ordered-list starts, item counts, and every link target apart from the switcher.
3. Files listed as `excluded` have no `.zh.md` and no `.i18n.yaml` at all.
4. Every date-named document (`yyyy-mm-dd-*.md`) dated on or after the manifest's `requiredSince` cutoff has a complete pair — new date-named Agent Notes merge bilingual from birth.
Source-oriented code gates consume an exact `.zh.md` fence sequence as a derivative of its unsuffixed sibling instead of compiling or manifesting the same code twice. The sequence must match in length, order, fence kind, and byte-exact body; otherwise both copies remain independently checked and the pairing gate reports the structural mismatch.
`pnpm run verify-translation-pairing --list` prints the current pairing state of every document in scope — missing, out-of-sync, or ok — and is the work list for translation batches. It never fails; it reports.
`pnpm run verify-translation-pairing --list` prints the current pairing state of every document in scope — missing, out-of-sync, or ok. It never fails; `missing` and `out-of-sync` rows identify violations that the normal check rejects.
The practical rule this gate creates: **when a PR edits either side of a paired document, the same PR updates the counterpart and re-records the pair** (run the [dsh-translate-docs](../../.agents/skills/dsh-translate-docs/SKILL.md) skill, then `--write`), exactly like the repo's existing doc-sync rule for code and READMEs. A PR that leaves a pair out of sync goes red in CI.
The gate's limit, stated plainly: **a green gate means the pair was confirmed consistent at these exact contents, not that the confirmation was sound.** It checks hashes and shape; it cannot judge whether the two sides actually say the same thing, or whether the wording is accurate, well-termed, and natural — that is the reviewer's half of the contract, per [translation-rules.md](translation-rules.md). A re-recorded pair with a sloppy counterpart passes the gate; it must not pass review.
## Scope, exclusions, and rollout
## Scope and exclusions
**Scope**: every non-vendor README, plus every document under `.agents/notes/**`, `docs/**`, and `python/**`. README matching is case-insensitive on the basename and covers future directories without another manifest edit. Dependency and ignored build-output trees are discovery exclusions, not source documentation.
@@ -47,7 +46,7 @@ The gate's limit, stated plainly: **a green gate means the pair was confirmed co
- `docs/i18n/terminology.md` and [style-samples.md](style-samples.md) — both are bilingual by construction.
- [translation-prompt.md](translation-prompt.md) — the automated pipeline's prompt template; its body is machine-consumed verbatim, so a paired translation would change pipeline behavior.
**Enforcement frontier**: `requiredClasses` closes a whole document class after its back-catalog has been translated. Both `non-readme` and `readme` are closed: every current or future in-scope document must merge bilingual. The manifest's `required` list retains already-admitted files, and a date-named document (`yyyy-mm-dd-*.md`, i.e. an Agent Note) dated on or after `requiredSince` must merge with its pair regardless of class. `--list` reports any unclosed-class backlog while every existing pair remains governed by the full contract.
**Universal requirement**: every current or future document in scope must merge as a complete bilingual pair. [scripts/translation-pairing.manifest.json](../../scripts/translation-pairing.manifest.json) contains only explicit exclusions; there is no per-file rollout list, date cutoff, or README-specific policy class.
## Division of labor
+6 -7
View File
@@ -2,7 +2,7 @@
[English](README.md) | 中文
本仓库的文档会被公司内外的人和 agent(智能体)阅读,因此 README、Agent Noteagent 决策记录)与 docs 目录树以英文和简体中文双语维护。本页定义配对契约、强制门禁与推进策略[translation-rules.md](translation-rules.md) 定义如何翻译;[terminology.md](terminology.md) 是术语真源。仓库内置的 agent 工作流见 [.agents/skills/dsh-translate-docs](../../.agents/skills/dsh-translate-docs/SKILL.md)。
本仓库的文档会被公司内外的人和 agent(智能体)阅读,因此范围内的每篇文档都以英文和简体中文维护。本页定义配对契约、强制门禁、范围与排除规则[translation-rules.md](translation-rules.md) 定义如何翻译;[terminology.md](terminology.md) 是术语真源。仓库内置的 agent 工作流见 [.agents/skills/dsh-translate-docs](../../.agents/skills/dsh-translate-docs/SKILL.md)。
## 配对契约
@@ -23,20 +23,19 @@
`pnpm run verify-translation-pairing``doc-sync`(文档同步门禁)的一环,贡献者会针对文档变更在本地运行,CI 则会完整运行)机械地强制执行这份契约:
1. [scripts/translation-pairing.manifest.json](../../scripts/translation-pairing.manifest.json) 中 `required` 列出的每个文件,以及所属文档类别出现在 `requiredClasses` 中的每篇文档都有完整配对。类别分为 `non-readme` 和 `readme`;判断类别时,basename 不区分大小写,因此 `missions/readme.md` 也属于 README
2. 任何已存在的配对(无论是否 required都完整且一致:三个文件齐全、每一侧的当前 blob hash 等于记录值(改了任一侧而没重新确认配对就变红)、双方都带语言切换行、结构签名按序一致:标题深度、逐字节一致的代码块(信息字符串与内容)、表格行列数、列表类型、有序列表起始编号、列表项数量,以及除切换行之外的每个链接目标。
1. 范围内的每篇文档都有完整配对。发现 README 时,basename 不区分大小写,因此 `missions/readme.md` 与其他文档根一样属于范围
2. 任何已存在的配对产物都完整且一致:三个文件齐全、每一侧的当前 blob hash 等于记录值(改了任一侧而没重新确认配对就变红)、双方都带语言切换行、结构签名按序一致:标题深度、逐字节一致的代码块(信息字符串与内容)、表格行列数、列表类型、有序列表起始编号、列表项数量,以及除切换行之外的每个链接目标。
3. 列为 `excluded` 的文件完全没有 `.zh.md`,也没有 `.i18n.yaml`。
4. 凡文件名符合 `yyyy-mm-dd-*.md` 且日期不早于 manifest(元数据清单)中 `requiredSince` 分界日期的文档,都必须有完整配对;新建的日期命名 Agent Note 从创建起便须配齐中英文。
面向源码的代码门禁会把精确的 `.zh.md` 围栏序列视为其无后缀兄弟文件的派生内容,而不会再次编译相同代码或在 manifest 中重复登记。该序列必须在长度、顺序、围栏类型和按字节精确的正文上一致;否则两份副本仍会独立受检,配对门禁也会报告结构不匹配。
`pnpm run verify-translation-pairing --list` 打印范围内每篇文档的当前配对状态(missing、out-of-sync 或 ok,是翻译批次的工作清单。它从不失败;它只报告
`pnpm run verify-translation-pairing --list` 打印范围内每篇文档的当前配对状态(missing、out-of-sync 或 ok。它从不失败;其中 missing 与 out-of-sync 行指出普通检查会拒绝的违规
这个门禁带来的实际规则是:**当一个 PR 修改了已配对文档的任一侧时,同一个 PR 更新另一侧并重新记录配对**(运行 [dsh-translate-docs](../../.agents/skills/dsh-translate-docs/SKILL.md) skill(技能),再 `--write`),与本仓库既有的代码与 README 的 doc-sync 规则完全一致。留下失去同步的配对的 PR 会在 CI 变红。
把门禁的边界说白:**门禁通过意味着这组文档在当前内容上的一致性得到了确认,不代表确认本身正确可靠。** 它检查记录的 hash 与结构签名;它无法判断两侧是否真的在说同样的话,也无法判断措辞是否准确、术语是否得当、行文是否自然;这部分契约由评审者把关,见 [translation-rules.md](translation-rules.md)。重新记录了 hash 但另一侧翻得潦草的配对能通过门禁;它不得通过评审。
## 范围排除与推进
## 范围排除
**范围**:除 vendor 源码外的全部 README,以及 `.agents/notes/**`、`docs/**` 与 `python/**` 下的全部文档。匹配 README 时只看文件名且不区分大小写,因此今后新增的目录无需再修改 manifest。依赖目录和被忽略的构建产物目录只在发现阶段排除,并非源文档。
@@ -47,7 +46,7 @@
- `docs/i18n/terminology.md` 与 [style-samples.md](style-samples.md):二者本身即为中英对照文档。
- [translation-prompt.md](translation-prompt.md):自动翻译流水线的提示词模板;正文逐字进入模型请求,配对翻译会改变流水线行为。
**执行红线**:某个文档类别的存量文档全部翻译完成后,`requiredClasses` 会将整个类别纳入强制范围。`non-readme` 与 `readme` 均已纳入强制范围:当前及今后所有纳入范围的文档,合并时都必须配齐双语文件。manifest 的 `required` 列表保留已纳入的文件;以日期命名的文档(`yyyy-mm-dd-*.md`,即 Agent Note)只要日期不早于 `requiredSince`,就无论所属类别都必须与对侧文件一同合并。`--list` 会报告尚未纳入强制范围的类别中的任何 backlog(待翻清单),而每个已存在的配对仍受完整契约约束
**统一要求**:当前及今后纳入范围的每篇文档,合并时都必须构成完整的双语配对。[scripts/translation-pairing.manifest.json](../../scripts/translation-pairing.manifest.json) 只包含显式排除项;不存在逐文件推进清单、日期分界或 README 专用政策类别
## 分工
+4 -4
View File
@@ -68,17 +68,17 @@
对比双语文件的 git 时间戳(无记录方案)——不予采纳:仅调整格式的改动会触发误报,无关修改后再提交译文又会造成漏检。只有基于内容本身的标识(每侧文件的 blob hash 与伴随记录比对),才能承载门禁所声称的语义。
## ⑦ 推进策略(长段拆分示范)
## ⑦ 统一要求(长段拆分示范)
> **Enforcement frontier**: a document class enters the manifest's `requiredClasses` set only after its back-catalog has been translated and reviewed. The `non-readme` and `readme` classes are closed, so every current or future in-scope document must merge bilingual. […] Pairing a document is a commitment: every later edit to either side must carry the counterpart along, so close a class only when translation review can sustain it.
> **Universal requirement**: every in-scope document merges as a complete bilingual pair. The manifest contains only explicit exclusions: it has no per-file rollout list, date cutoff, or README-specific policy class. […] Pairing is a continuing obligation: every later edit to either side updates the counterpart and consistency record in the same change.
**执行红线**只有在某个文档类别的存量文档全部完成翻译和评审后,该类别才会进入 manifest(元数据清单)的 `requiredClasses` 集合。`non-readme``readme` 类别均已纳入强制范围,因此当前及今后所有纳入范围的文档,合入时都必须配齐双语文件。(……)一旦文档完成配对,后续修改任一侧都必须同步更新另一侧。因此,只有在翻译评审能力足以持续支撑时,才应将整个类别纳入强制范围
**统一要求**每篇纳入范围的文档合入时都必须构成完整的双语配对。manifest(元数据清单)只包含显式排除项:其中没有逐文件推进清单、日期分界或 README 专用政策类别。(……)配对是一项持续义务:后续修改任一侧时,都必须在同一变更中同步更新对侧文件和一致性记录
## 从样例提炼的要点
- 语体是规范制度文:完整主谓、确定语气;不口语化,也不学术腔。
- 给句子补显式执行主体:英文的被动句和抽象主语,中文写成「系统/门禁/工具/评审人」做主语。
- 用中文工程惯用语替换直译:false positive/negative→误报/漏检、enforcement frontier→执行红线、ratchet→只向前收紧不倒退放宽、reviewable act→评审凭证。
- 用中文工程惯用语替换直译:false positive/negative→误报/漏检、ratchet→只向前收紧不倒退放宽、reviewable act→评审凭证。
- 隐喻本地化而非移植:bilingual from birth→从创建起就要求双语齐备;grandfathered→历史存量遗留。
- 类别名词说中文并在首现括注英文:实操手册(cookbook)、事故复盘(postmortem);指目录或路径时保留代码体英文。
- 长段按语义单元拆段,一段一件事;名词短语展开为动词句。
-2
View File
@@ -36,7 +36,6 @@
| Agent Note | Agent Note | Agent Noteagent 决策记录) | 智能体注记、智能体笔记 | 本仓库中由 agent 撰写的提案与决策记录 |
| agent harness | agent harness | agent harness(智能体框架) | | agent 组合词(agent harness/workflow/loop/skill 等)整体保留英文;未括注过 agent 时首现按对应组合词或 agent 行处理 |
| agent loop | agent loop | agent loop(智能体循环) | | |
| backlog | backlog | backlog(待翻清单) | | 仅在双语翻译语境里括注`待翻清单` |
| blob hash | blob hash | | | `git hash-object` 的结果 |
| Cordis | Cordis | | | |
| dispose | dispose | dispose(资源释放) | | |
@@ -103,7 +102,6 @@
| deploy root | 部署根目录 | | | |
| durability | 持久性 | | | |
| feature requirement | 功能依赖 | | | 功能或功能选项通过 `requires` 声明的关系 |
| enforcement frontier | 执行红线 | | 强制边界 | i18n 配对机制用语:manifest `required` 清单所划的门禁生效范围;与金标样例(style-samples ⑦)一致 |
| ergonomics | 易用性 / 开发体验 | | 人体工学 | API 或面向模型的接口用「易用性」;工具链或开发者工作流用「开发体验」 |
| event | 事件 | | | |
| event log | 事件日志 | | | |
File diff suppressed because one or more lines are too long
+1 -214
View File
@@ -1,216 +1,4 @@
{
"requiredClasses": [
"non-readme",
"readme"
],
"requiredSince": "2026-07-14",
"required": [
".agents/notes/README.md",
".agents/notes/implemented/architecture/2026-06-11-content-block-vocabulary.md",
".agents/notes/implemented/architecture/2026-06-11-dev-invariants-over-deep-readonly.md",
".agents/notes/implemented/architecture/2026-06-11-event-sourced-sessions.md",
".agents/notes/implemented/architecture/2026-06-11-microkernel-event-taxonomy.md",
".agents/notes/implemented/architecture/2026-06-11-runtime-arg-validation.md",
".agents/notes/implemented/architecture/2026-06-11-structured-error-taxonomy.md",
".agents/notes/implemented/architecture/2026-06-11-tool-schemas-in-prompt-assembly.md",
".agents/notes/implemented/architecture/2026-06-13-capability-seams.md",
".agents/notes/implemented/architecture/2026-06-13-twin-llm-adapters.md",
".agents/notes/implemented/architecture/2026-06-14-session-persistence.md",
".agents/notes/implemented/architecture/2026-06-15-turn-enclosure-invariant.md",
".agents/notes/implemented/architecture/2026-06-17-filesystem-capability-seam.md",
".agents/notes/implemented/architecture/2026-06-18-agent-lifecycle-and-ownership-seams.md",
".agents/notes/implemented/architecture/2026-06-18-session-surface.md",
".agents/notes/implemented/architecture/2026-06-18-shared-persistence-write-coordinator.md",
".agents/notes/implemented/architecture/2026-06-20-branded-ids.md",
".agents/notes/implemented/architecture/2026-06-20-extract-example-app-packages.md",
".agents/notes/implemented/architecture/2026-06-20-generic-long-running-tool-runtime.md",
".agents/notes/implemented/architecture/2026-06-20-package-hierarchy.md",
".agents/notes/implemented/architecture/2026-06-21-mandatory-app-attribution-headers.md",
".agents/notes/implemented/architecture/2026-06-24-web-capability-seam.md",
".agents/notes/implemented/architecture/2026-06-26-file-context-as-event-gate.md",
".agents/notes/implemented/architecture/2026-06-30-bash-stdin-env-trusted-plugin-surface.md",
".agents/notes/implemented/architecture/2026-06-30-event-domain-semantics.md",
".agents/notes/implemented/architecture/2026-07-02-fs-per-session-cwd.md",
".agents/notes/implemented/architecture/2026-07-02-result-time-applied-hunk-diffs.md",
".agents/notes/implemented/architecture/2026-07-02-tool-render-intent-union.md",
".agents/notes/implemented/architecture/2026-07-03-filesystem-directory-listing-seam.md",
".agents/notes/implemented/architecture/2026-07-05-prompt-variables-and-tool-guidance-ownership.md",
".agents/notes/implemented/architecture/2026-07-05-reconstructable-requests.md",
".agents/notes/implemented/architecture/2026-07-05-subagent-provider-lifecycle-events.md",
".agents/notes/implemented/architecture/2026-07-06-timeout-deadline-library.md",
".agents/notes/implemented/architecture/2026-07-07-tool-call-timeout-policy.md",
".agents/notes/implemented/architecture/2026-07-08-agent-scope-contexts.md",
".agents/notes/implemented/architecture/2026-07-10-single-file-executable-sdk-runtime-distribution.md",
".agents/notes/implemented/architecture/2026-07-12-agent-scope-runtime-design.md",
".agents/notes/implemented/architecture/2026-07-16-explicit-turn-cancellation.md",
".agents/notes/implemented/architecture/2026-07-19-gui-layering-and-rpc-protocol.md",
".agents/notes/implemented/architecture/2026-07-19-gui-web-client-architecture.md",
".agents/notes/implemented/architecture/2026-07-22-slot-type-chain-implementation.md",
".agents/notes/implemented/architecture/2026-07-23-client-plugin-loading-model.md",
".agents/notes/implemented/feature/2026-06-14-acp-multi-session.md",
".agents/notes/implemented/feature/2026-06-15-code-mode.md",
".agents/notes/implemented/feature/2026-06-17-filesystem-tool-schemas.md",
".agents/notes/implemented/feature/2026-06-18-compaction-capability-seam.md",
".agents/notes/implemented/feature/2026-06-21-subagent-capability-seam.md",
".agents/notes/implemented/feature/2026-06-22-acp-subagent-backend.md",
".agents/notes/implemented/feature/2026-06-25-ask-user-question.md",
".agents/notes/implemented/feature/2026-06-29-todo-write-tool.md",
".agents/notes/implemented/feature/2026-06-30-hook-bridges.md",
".agents/notes/implemented/feature/2026-06-30-hook-protocol-lib.md",
".agents/notes/implemented/feature/2026-06-30-interception-seams.md",
".agents/notes/implemented/feature/2026-06-30-session-store-fork-api.md",
".agents/notes/implemented/feature/2026-06-30-subagent-observe-enrich.md",
".agents/notes/implemented/feature/2026-07-05-dynamic-workflows.md",
".agents/notes/implemented/feature/2026-07-05-skill-system.md",
".agents/notes/implemented/feature/2026-07-06-approval-seam.md",
".agents/notes/implemented/feature/2026-07-06-explicit-tool-order.md",
".agents/notes/implemented/feature/2026-07-06-sandbox.md",
".agents/notes/implemented/feature/2026-07-07-mcp-client-plugin.md",
".agents/notes/implemented/feature/2026-07-07-session-prefix.md",
".agents/notes/implemented/feature/2026-07-08-repeat-tool-guard.md",
".agents/notes/implemented/feature/2026-07-08-self-referential-cordis-toolset.md",
".agents/notes/implemented/feature/2026-07-10-session-query-service.md",
".agents/notes/implemented/feature/2026-07-12-subagent-persona-tool-filter-and-depth.md",
".agents/notes/implemented/process/2026-06-11-doc-sync-enforcement.md",
".agents/notes/implemented/process/2026-06-11-quality-gates.md",
".agents/notes/implemented/process/2026-06-11-tsdown-over-dumble.md",
".agents/notes/implemented/process/2026-06-11-vendor-cordis-as-source.md",
".agents/notes/implemented/process/2026-06-16-pnpm-over-yarn.md",
".agents/notes/implemented/process/2026-06-17-ts-build-config.md",
".agents/notes/implemented/process/2026-06-18-markdown-cross-link-lint.md",
".agents/notes/implemented/process/2026-06-20-agent-note-classification.md",
".agents/notes/implemented/process/2026-06-20-core-data-structures-catalog.md",
".agents/notes/implemented/process/2026-06-20-generated-cordis-catalog.md",
".agents/notes/implemented/process/2026-07-02-bilingual-docs-and-pairing-gate.md",
".agents/notes/implemented/process/2026-07-02-tool-schema-catalog.md",
".agents/notes/implemented/process/2026-07-03-documentation-graph-atlas.md",
".agents/notes/implemented/process/2026-07-04-cordis-jsdoc-completeness-gate.md",
".agents/notes/implemented/process/2026-07-04-doc-tiers-and-budgets.md",
".agents/notes/implemented/process/2026-07-04-persistence-log-catalog.md",
".agents/notes/implemented/process/2026-07-05-uniform-agent-note-format.md",
".agents/notes/implemented/process/2026-07-06-export-surface-jsdoc-gate.md",
".agents/notes/implemented/process/2026-07-06-generated-config-catalog.md",
".agents/notes/implemented/process/2026-07-06-node-engine-floor.md",
".agents/notes/implemented/process/2026-07-06-parallel-pre-push-gates.md",
".agents/notes/implemented/process/2026-07-10-readme-known-limitations-gate.md",
".agents/notes/implemented/process/2026-07-12-package-model-experience-contract.md",
".agents/notes/implemented/process/2026-07-19-web-styling-system.md",
".agents/notes/implemented/simplification/2026-06-19-drop-mutable-session-summary.md",
".agents/notes/implemented/simplification/2026-06-20-collapse-trace-only-session-events.md",
".agents/notes/implemented/simplification/2026-06-20-drop-unconsumed-llm-adapter-change-event.md",
".agents/notes/implemented/simplification/2026-06-20-drop-unconsumed-llm-assembled-surfaces.md",
".agents/notes/implemented/simplification/2026-06-20-prune-dead-seam-methods.md",
".agents/notes/implemented/simplification/2026-06-20-public-agent-stop-surface.md",
".agents/notes/implemented/simplification/2026-06-20-remove-agent-boundary-mirror-events.md",
".agents/notes/implemented/simplification/2026-06-20-unify-agent-and-session-id.md",
".agents/notes/implemented/simplification/2026-06-26-fsspec-style-fs-seam.md",
".agents/notes/implemented/simplification/2026-07-02-remove-stream-chunk-mirror.md",
".agents/notes/implemented/simplification/2026-07-04-drop-image-content-block.md",
".agents/notes/implemented/simplification/2026-07-04-drop-inert-request-knobs.md",
".agents/notes/implemented/simplification/2026-07-04-drop-unconsumed-web-observation-surface.md",
".agents/notes/implemented/simplification/2026-07-04-prune-producerless-vocabulary-variants.md",
".agents/notes/implemented/simplification/2026-07-04-prune-write-only-fs-surface.md",
".agents/notes/implemented/simplification/2026-07-04-remove-agent-steering-mirror.md",
".agents/notes/implemented/simplification/2026-07-04-share-app-bin-boot-glue.md",
".agents/notes/implemented/simplification/2026-07-04-tighten-hook-protocol-contract.md",
".agents/notes/implemented/simplification/2026-07-04-trim-acp-bridge-unreachable-surface.md",
".agents/notes/implemented/simplification/2026-07-12-drop-unconsumed-skill-provider-events.md",
".agents/notes/implemented/simplification/2026-07-12-prune-unused-web-seam-fields.md",
".agents/notes/implemented/simplification/2026-07-12-simplify-session-log-representation.md",
".agents/notes/implemented/testing/2026-06-11-property-based-testing.md",
".agents/notes/implemented/testing/2026-06-19-acp-snapshot-tests.md",
".agents/notes/implemented/testing/2026-06-19-real-api-e2e-ci.md",
".agents/notes/implemented/testing/2026-06-20-remove-redundant-snapshot-log-expected-output.md",
".agents/notes/implemented/testing/2026-06-22-fork-child-replay-seed-boundary.md",
".agents/notes/implemented/testing/2026-06-22-fork-snapshot-scenarios.md",
".agents/notes/implemented/testing/2026-06-22-subagent-snapshot-replay.md",
".agents/notes/implemented/testing/2026-07-04-hook-snapshot-matrix.md",
".agents/notes/implemented/testing/2026-07-04-single-source-acp-replay-config.md",
".agents/notes/implemented/testing/2026-07-06-pin-request-header-content-in-one-scenario.md",
".agents/notes/implemented/testing/2026-07-08-shared-acp-snapshot-package.md",
".agents/notes/proposed/architecture/2026-06-16-typed-event-schemas.md",
".agents/notes/proposed/feature/2026-06-30-pre-tool-input-rewrite.md",
".agents/notes/proposed/feature/2026-07-07-claude-code-and-codex-subagent-backends.md",
".agents/notes/proposed/feature/2026-07-08-interactive-side-sessions.md",
".agents/notes/implemented/feature/2026-07-10-sqlite-session-query-provider.md",
".agents/notes/rejected/feature/2026-07-13-stream-workflow-progress-through-tool-calls.md",
".agents/notes/proposed/process/2026-06-11-api-extractor-reports.md",
".agents/notes/proposed/process/2026-06-11-architectural-conformance.md",
".agents/notes/proposed/process/2026-06-11-supply-chain-and-vendor-drift.md",
".agents/notes/proposed/process/2026-06-20-discover-package-inventory.md",
".agents/notes/proposed/simplification/2026-07-04-prune-dead-core-spine-surface.md",
".agents/notes/proposed/testing/2026-06-11-deterministic-and-stress-testing.md",
".agents/notes/proposed/testing/2026-06-11-mutation-testing.md",
".agents/notes/rejected/architecture/2026-06-11-immutable-public-surfaces.md",
".agents/notes/rejected/architecture/2026-06-20-providerless-example-base.md",
".agents/notes/rejected/process/2026-07-04-generate-agent-note-index-tables.md",
".agents/notes/rejected/simplification/2026-06-20-assembled-assistant-messages-only.md",
".agents/notes/rejected/simplification/2026-06-20-drop-acp-session-load.md",
".agents/notes/rejected/simplification/2026-06-20-drop-acp-terminal-meta.md",
".agents/notes/rejected/simplification/2026-06-20-drop-bash-output-spill-files.md",
".agents/notes/rejected/simplification/2026-06-20-drop-durable-step-boundaries.md",
".agents/notes/rejected/simplification/2026-06-20-drop-unused-session-lineage.md",
".agents/notes/rejected/simplification/2026-06-20-fold-session-persistence-interface.md",
".agents/notes/rejected/simplification/2026-06-20-generic-tool-rendering.md",
".agents/notes/rejected/simplification/2026-06-20-retire-mid-turn-steering.md",
".agents/notes/rejected/simplification/2026-06-20-single-session-acp-bridge.md",
".agents/notes/rejected/simplification/2026-06-20-truncate-interrupted-turns.md",
".agents/notes/rejected/simplification/2026-07-04-prune-unimplemented-subagent-vocabulary.md",
".agents/notes/rejected/simplification/2026-07-12-collapse-workflow-to-foreground-core.md",
".agents/notes/rejected/simplification/2026-07-12-prune-unused-skill-registry-surface.md",
"README.md",
"docs/architecture.md",
"docs/cookbook/adding-a-package.md",
"docs/cookbook/adding-a-tool.md",
"docs/cookbook/adding-a-vendored-package.md",
"docs/cookbook/adding-an-llm-adapter.md",
"docs/cookbook/extension-cookbook.md",
"docs/cookbook/responding-to-pr-review-on-a-stack.md",
"docs/cordis-primer.md",
"docs/core-data-structures/approval.md",
"docs/core-data-structures/bash.md",
"docs/core-data-structures/code-runtime.md",
"docs/core-data-structures/compaction.md",
"docs/core-data-structures/core.md",
"docs/core-data-structures/filesystem.md",
"docs/core-data-structures/llm-streaming.md",
"docs/core-data-structures/persistence.md",
"docs/core-data-structures/sandbox.md",
"docs/core-data-structures/scope.md",
"docs/core-data-structures/session-query.md",
"docs/core-data-structures/session.md",
"docs/core-data-structures/skills.md",
"docs/core-data-structures/subagent.md",
"docs/core-data-structures/system-prompt.md",
"docs/core-data-structures/tools.md",
"docs/core-data-structures/user-interaction.md",
"docs/core-data-structures/web.md",
"docs/core-data-structures/workflow.md",
"docs/defensive-patterns.md",
"docs/development.md",
"docs/glossary.md",
"docs/i18n/README.md",
"docs/i18n/translation-rules.md",
"docs/postmortem/0001-acp-default-export-drops-inject.md",
"docs/postmortem/0002-js-expression-disabled-filesystem-tools.md",
"docs/postmortem/README.md",
"docs/testing.md",
"docs/user/develop/basic/config.md",
"docs/user/develop/basic/index.md",
"docs/user/develop/basic/tool.md",
"docs/user/develop/framework/events.md",
"docs/user/develop/framework/index.md",
"docs/user/develop/framework/service.md",
"docs/user/develop/practice/index.md",
"docs/user/develop/practice/llm-adapter.md",
"docs/user/guide/config.md",
"docs/user/guide/index.md",
"docs/user/guide/quickstart.md",
"docs/user/index.md",
"python/README.md",
"python/sdk-runtime/README.md",
"python/sdk/README.md"
],
"excluded": [
".agents/notes/AGENTS.md",
".agents/notes/implemented/AGENTS.md",
@@ -228,7 +16,6 @@
"docs/module-graph.md",
"docs/persistence-catalog.md",
"docs/tool-catalog.md",
"docs/tool-execution-pipeline.md",
"python/sdk-runtime/src/deepseek_harness_runtime/runtime/node/"
"docs/tool-execution-pipeline.md"
]
}
+13 -82
View File
@@ -1,15 +1,10 @@
/** Regression tests for the bilingual cutoff and structural signature. */
/** Regression tests for the bilingual corpus scope and structural signature. */
import { describe, expect, it } from 'vitest'
import {
datedDocumentDate,
isIsoDate,
isTranslationScopeFile,
parseTranslationMarkdown,
parseTranslationPairingManifest,
requiresPairByDate,
requiresTranslationPair,
translationDocumentClass,
translationStructureDiff,
translationStructureSignature,
} from './translation-pairing.ts'
@@ -19,78 +14,30 @@ function signature(markdown: string) {
}
describe('translation pairing manifest', () => {
it('accepts a real ISO cutoff and string-array fields', () => {
it('accepts an exclusions-only manifest', () => {
expect(parseTranslationPairingManifest(JSON.stringify({
requiredSince: '2026-07-14',
required: ['README.md'],
requiredClasses: ['non-readme'],
excluded: ['docs/generated/'],
}))).toEqual({
requiredSince: '2026-07-14',
required: ['README.md'],
requiredClasses: ['non-readme'],
excluded: ['docs/generated/'],
})
})
it.each(['2026-7-14', '2026-02-29', '2026-13-01', 'not-a-date'])('rejects invalid cutoff %s', (cutoff) => {
expect(isIsoDate(cutoff)).toBe(false)
it.each([
['required', ['packages/README.md']],
['requiredClasses', ['readme']],
['requiredSince', '2026-07-14'],
] as const)('rejects obsolete policy field %s instead of accepting an inert requirement', (field, value) => {
expect(() => parseTranslationPairingManifest(JSON.stringify({
requiredSince: cutoff,
required: [],
requiredClasses: [],
excluded: [],
}))).toThrow('requiredSince must be a valid YYYY-MM-DD date')
[field]: value,
}))).toThrow(`unsupported field(s): ${field}; every in-scope document is required`)
})
it('rejects non-string manifest arrays', () => {
it('rejects a missing or non-string exclusion list', () => {
expect(() => parseTranslationPairingManifest('{}')).toThrow('excluded must be an array of strings')
expect(() => parseTranslationPairingManifest(JSON.stringify({
requiredSince: '2026-07-14',
required: [42],
requiredClasses: [],
excluded: [],
}))).toThrow('required must be an array of strings')
})
it('rejects unknown and duplicate document classes', () => {
const manifest = (requiredClasses: string[]) => JSON.stringify({
requiredSince: '2026-07-14',
required: [],
requiredClasses,
excluded: [],
})
expect(() => parseTranslationPairingManifest(manifest(['guide']))).toThrow('requiredClasses must contain only')
expect(() => parseTranslationPairingManifest(manifest(['readme', 'readme']))).toThrow('requiredClasses must not contain duplicates')
})
})
describe('document-class pairing frontier', () => {
const manifest = parseTranslationPairingManifest(JSON.stringify({
requiredSince: '2026-07-14',
required: ['docs/legacy/README.md'],
requiredClasses: ['non-readme'],
excluded: [],
}))
it('classifies README basenames case-insensitively', () => {
expect(translationDocumentClass('packages/core/README.md')).toBe('readme')
expect(translationDocumentClass('missions/readme.md')).toBe('readme')
expect(translationDocumentClass('docs/readme-guide.md')).toBe('non-readme')
})
it('requires every non-README while retaining explicit README entries', () => {
expect(requiresTranslationPair('docs/guide.md', manifest)).toBe(true)
expect(requiresTranslationPair('docs/legacy/README.md', manifest)).toBe(true)
expect(requiresTranslationPair('docs/new/README.md', manifest)).toBe(false)
})
it('requires both document classes after the README frontier closes', () => {
const closed = parseTranslationPairingManifest(JSON.stringify({
...manifest,
requiredClasses: ['non-readme', 'readme'],
}))
expect(requiresTranslationPair('docs/guide.md', closed)).toBe(true)
expect(requiresTranslationPair('future/subtree/README.md', closed)).toBe(true)
excluded: [42],
}))).toThrow('excluded must be an array of strings')
})
})
@@ -124,22 +71,6 @@ describe('translation scope discovery', () => {
})
})
describe('date-based pairing frontier', () => {
const cutoff = '2026-07-14'
it('enforces the cutoff day and every later day, but not the preceding day', () => {
expect(requiresPairByDate('.agents/notes/2026-07-13-before.md', cutoff)).toBe(false)
expect(requiresPairByDate('.agents/notes/2026-07-14-at-cutoff.md', cutoff)).toBe(true)
expect(requiresPairByDate('.agents/notes/2026-07-15-after.md', cutoff)).toBe(true)
})
it('matches only a date at the start of the basename', () => {
expect(datedDocumentDate('.agents/notes/2026-07-14-proposal.md')).toBe('2026-07-14')
expect(datedDocumentDate('docs/release-notes-2026-07-14-alpha.md')).toBeUndefined()
expect(requiresPairByDate('docs/release-notes-2026-07-14-alpha.md', cutoff)).toBe(false)
})
})
describe('translation structural signature', () => {
it('accepts matching list kinds, starts, and item counts', () => {
const source = signature('3. One\n4. Two\n\n- A\n- B\n')
+12 -71
View File
@@ -1,7 +1,7 @@
/**
* Pure parsing and structural helpers for the bilingual-document pairing
* gate. Kept separate from the CLI so cutoff and signature behavior can be
* regression-tested without reading or mutating the repository tree.
* gate. Kept separate from the CLI so corpus discovery and signature behavior
* can be regression-tested without reading or mutating the repository tree.
*/
import { fromMarkdown } from 'mdast-util-from-markdown'
@@ -11,21 +11,10 @@ import type { Nodes } from 'mdast'
/** Validated shape of `scripts/translation-pairing.manifest.json`. */
export interface TranslationPairingManifest {
required: string[]
/** Document classes whose complete in-scope population must be paired. */
requiredClasses: TranslationDocumentClass[]
/** Source documents exempt from pairing because they are generated, instructional, or bilingual by construction. */
excluded: string[]
/** Date-named documents on or after this day must merge bilingual. */
requiredSince: string
}
/** Stable classes used to close one translation rollout without enumerating files. */
export type TranslationDocumentClass = 'readme' | 'non-readme'
const TRANSLATION_DOCUMENT_CLASSES: TranslationDocumentClass[] = ['readme', 'non-readme']
const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/
const DATED_DOCUMENT = /(?:^|\/)(\d{4}-\d{2}-\d{2})-[^/]*\.md$/
const README_ARTIFACT = /(?:^|\/)readme(?:\.md|\.zh\.md|\.i18n\.yaml)$/i
const NON_SOURCE_DIRECTORIES = new Set([
'node_modules',
@@ -84,39 +73,19 @@ export function isTranslationScopeFile(file: string): boolean {
|| file.startsWith('python/'))
}
/** Whether a string names one real calendar day in canonical ISO form. */
export function isIsoDate(value: string): boolean {
if (!ISO_DATE.test(value)) return false
const date = new Date(`${value}T00:00:00.000Z`)
return !Number.isNaN(date.getTime()) && date.toISOString().slice(0, 10) === value
}
/** Read one manifest string-array field or fail before enforcement starts. */
function stringArrayField(record: Record<string, unknown>, field: 'required' | 'excluded'): string[] {
const value = record[field]
/** Read the manifest exclusion list or fail before enforcement starts. */
function excludedField(record: Record<string, unknown>): string[] {
const value = record.excluded
if (!Array.isArray(value)) {
throw new Error(`translation-pairing.manifest.json: ${field} must be an array of strings`)
throw new Error('translation-pairing.manifest.json: excluded must be an array of strings')
}
const entries: unknown[] = value
if (!entries.every((entry): entry is string => typeof entry === 'string')) {
throw new Error(`translation-pairing.manifest.json: ${field} must be an array of strings`)
throw new Error('translation-pairing.manifest.json: excluded must be an array of strings')
}
return entries
}
/** Read and validate the manifest's closed document-class set. */
function requiredClassesField(record: Record<string, unknown>): TranslationDocumentClass[] {
const value = record.requiredClasses
if (!Array.isArray(value) || !value.every((entry): entry is TranslationDocumentClass =>
typeof entry === 'string' && TRANSLATION_DOCUMENT_CLASSES.includes(entry as TranslationDocumentClass))) {
throw new Error('translation-pairing.manifest.json: requiredClasses must contain only "readme" and "non-readme"')
}
if (new Set(value).size !== value.length) {
throw new Error('translation-pairing.manifest.json: requiredClasses must not contain duplicates')
}
return value
}
/** Parse and validate the checked-in bilingual manifest. */
export function parseTranslationPairingManifest(content: string): TranslationPairingManifest {
const value: unknown = JSON.parse(content)
@@ -124,39 +93,11 @@ export function parseTranslationPairingManifest(content: string): TranslationPai
throw new Error('translation-pairing.manifest.json: expected an object')
}
const record = value as Record<string, unknown>
const requiredSince = record.requiredSince
if (typeof requiredSince !== 'string' || !isIsoDate(requiredSince)) {
throw new Error(`translation-pairing.manifest.json: requiredSince must be a valid YYYY-MM-DD date; got ${JSON.stringify(requiredSince)}`)
const unsupported = Object.keys(record).filter(field => field !== 'excluded')
if (unsupported.length > 0) {
throw new Error(`translation-pairing.manifest.json: unsupported field(s): ${unsupported.join(', ')}; every in-scope document is required`)
}
return {
required: stringArrayField(record, 'required'),
requiredClasses: requiredClassesField(record),
excluded: stringArrayField(record, 'excluded'),
requiredSince,
}
}
/** Classify a Markdown source by whether its basename is README, case-insensitively. */
export function translationDocumentClass(file: string): TranslationDocumentClass {
return /(?:^|\/)readme\.md$/i.test(file) ? 'readme' : 'non-readme'
}
/** Whether the manifest requires this in-scope source to have a complete pair. */
export function requiresTranslationPair(file: string, manifest: TranslationPairingManifest): boolean {
return manifest.required.includes(file)
|| manifest.requiredClasses.includes(translationDocumentClass(file))
|| requiresPairByDate(file, manifest.requiredSince)
}
/** Return the leading date of a `yyyy-mm-dd-*.md` basename, if present. */
export function datedDocumentDate(file: string): string | undefined {
return DATED_DOCUMENT.exec(file)?.[1]
}
/** Whether a date-named document falls on or after the pairing cutoff. */
export function requiresPairByDate(file: string, requiredSince: string): boolean {
const date = datedDocumentDate(file)
return date !== undefined && date >= requiredSince
return { excluded: excludedField(record) }
}
/** The structural surface compared between the two sides of a pair. */
+8 -22
View File
@@ -1,8 +1,7 @@
/**
* Enforce complete English/Chinese pairs, matching structure, and recorded git
* blob hashes under the bilingual manifest. Required files and date-named docs
* at or after `requiredSince`, plus every source in a required document class,
* must be paired; excluded docs may have neither a counterpart nor sidecar.
* blob hashes for every in-scope document. The manifest contains only explicit
* exclusions, which may have neither a counterpart nor a sidecar.
* `--list` reports state and `--write` records both sides after human review.
* Translation quality remains a review responsibility.
* See `docs/i18n/README.md` for the owning contract.
@@ -16,9 +15,7 @@ import {
parseTranslationMarkdown,
parseTranslationPairingManifest,
isTranslationScopeFile,
requiresTranslationPair,
TRANSLATION_SCOPE_GLOB_EXCLUDES,
translationDocumentClass,
translationStructureDiff,
translationStructureSignature,
} from './translation-pairing.ts'
@@ -119,26 +116,17 @@ if (writeMode) {
const errors: string[] = []
const state = new Map<string, 'ok' | 'out-of-sync' | 'missing'>()
// 1. Explicit manifest entries name existing source documents.
for (const req of manifest.required) {
if (!existsSync(join(root, req))) {
errors.push(`${req}: listed in translation-pairing.manifest.json \`required\` but the file does not exist`)
}
}
// 2. Every source selected explicitly, by document class, or by the dated-document
// cutoff merges bilingual. Class enforcement closes a rollout for future files too.
// 1. Every discovered, non-excluded source merges bilingual.
for (const source of sources) {
if (isExcluded(source)) continue
if (!requiresTranslationPair(source, manifest)) continue
const { zh } = pairPaths(source)
if (!existsSync(join(root, zh))) {
errors.push(`${source}: required to merge bilingual as a ${translationDocumentClass(source)} document (docs/i18n/README.md); add the counterpart and record the pair`)
errors.push(`${source}: in-scope documentation must merge bilingual (docs/i18n/README.md); add the counterpart and record the pair`)
state.set(source, 'missing')
}
}
// 3. Every pair that exists at all is complete and consistent. Anchor on the
// 2. Every pair that exists at all is complete and consistent. Anchor on the
// union of .zh.md files and .i18n.yaml records so a half-deleted pair is
// caught from either remnant.
const pairAnchors = new Set<string>()
@@ -198,7 +186,7 @@ for (const source of [...pairAnchors].sort()) {
if (!state.has(source)) state.set(source, 'ok')
}
// Complete the state map for --list: any in-scope, non-excluded document with no pair yet is backlog.
// Complete the state map for --list: any in-scope, non-excluded document with no pair is missing.
for (const source of sources) {
if (!isExcluded(source) && !state.has(source)) state.set(source, 'missing')
}
@@ -207,9 +195,7 @@ if (listMode) {
const order = { 'out-of-sync': 0, missing: 1, ok: 2 } as const
const rows = [...state.entries()].sort((a, b) => order[a[1]] - order[b[1]] || a[0].localeCompare(b[0]))
for (const [file, status] of rows) {
const required = requiresTranslationPair(file, manifest)
const tag = required ? ` (required ${translationDocumentClass(file)})` : ' (backlog)'
console.log(`${status.padEnd(11)} ${file}${status === 'missing' ? tag : ''}`)
console.log(`${status.padEnd(11)} ${file}${status === 'missing' ? ' (required)' : ''}`)
}
const counts = { 'ok': 0, 'out-of-sync': 0, 'missing': 0 }
for (const status of state.values()) counts[status]++
@@ -218,7 +204,7 @@ if (listMode) {
}
if (errors.length === 0) {
console.log(`verify-translation-pairing: ${pairAnchors.size} pair(s) checked against ${manifest.required.length} explicit requirements and required classes [${manifest.requiredClasses.join(', ')}], all consistent.`)
console.log(`verify-translation-pairing: ${pairAnchors.size} pair(s) checked across all in-scope documentation, all consistent.`)
process.exit(0)
}