|
| 1 | +# AtomDocs 编译器正向架构 |
| 2 | + |
| 3 | +本文只定义 [[AD-ATOMDOCS|AtomDocs]] Core、CLI 与 Renderer 的本地编译架构。AtomLab 产品体系、 |
| 4 | +AtomStudio 文档工程环境和 AtomPage 可执行文档运行时的职责关系以 |
| 5 | +[工程认知资产入口](README.md)与 UL/PRD 为准;它们不是本架构的第五层。 |
| 6 | + |
| 7 | +## 产品本质 |
| 8 | + |
| 9 | +AtomDocs 在一个本地进程中把版本化领域数据和内容定义编译为目标格式产物。文件系统保存项目 |
| 10 | +资产,Python distribution 提供领域与格式下游;系统不拥有数据库、队列、控制面或在线状态。 |
| 11 | + |
| 12 | +## 四层编译模型 |
| 13 | + |
| 14 | +```text |
| 15 | +Ingestion Source --Connector--> JSON Record Sequence |
| 16 | +Data Record --Class--> Object |
| 17 | +Composition Authoring Source + Slot Binding --realize--> Content Block Graph |
| 18 | +Publication Content + Presentation Profile --Renderer--> Target Document --> Artifact |
| 19 | +
|
| 20 | +Quality Gates ──────────────── check every boundary ──────────────────────────▶ |
| 21 | +``` |
| 22 | + |
| 23 | +Quality Gate 横跨四层,不是 `Policy` 或第五个编译阶段。任一 Gate 失败时,当前构建不写出正式 |
| 24 | +Artifact。 |
| 25 | + |
| 26 | +### Ingestion |
| 27 | + |
| 28 | +Dataset 聚合本地文件或 Virtual Source。Connector 负责访问、解析、切分、Payload 映射与来源定位, |
| 29 | +统一输出带 Record ID、Class ID、Payload 和 Source 引用的 JSON Record Sequence。API、数据库、 |
| 30 | +数据湖和数据仓可以按页、游标、查询或分区读取,不要求完整 dump;无法提供稳定版本的上游必须 |
| 31 | +标记为 volatile。Source 在层内按需暴露 Parseable Resource,但它不是跨层合同。既有 Artifact |
| 32 | +只有经 Evidence Bundle 校验并显式声明为 Artifact Source 才能再接入。Ingestion 只验证 Record |
| 33 | +Envelope,不执行 Class 或 Field Validator。 |
| 34 | + |
| 35 | +### Data |
| 36 | + |
| 37 | +Data 只消费 JSON Record Sequence,不读取 Dataset、Source 或 Connector。Domain Plugin 暴露 |
| 38 | +Pydantic Class;Core 把 `model_fields` 描述为 Input Field,把 `@computed_field` 描述为 |
| 39 | +Computed Field;Record 反序列化后形成带 Class 身份和内容 fingerprint 的 Object。Content |
| 40 | +只能通过 Typed Slot 读取声明 Field。显式类型引用投影为确定性 Object Graph,不根据字符串 |
| 41 | +相等猜测关系。 |
| 42 | + |
| 43 | +Domain Data Contract 描述一次构建所接收的版本化静态快照。Class / Field 属于抽象定义层, |
| 44 | +Object / Property 属于运行时值层;Object 内部的无副作用确定性派生由 Computed Field 定义并 |
| 45 | +形成 Computed Property。跨 Object 或跨来源的交付判断进入 pytest Policy。Core 不建模命令、 |
| 46 | +对象状态迁移、生命周期或业务流程执行;文档可以描述这些概念,但 Compilation 不执行它们。 |
| 47 | + |
| 48 | +### Composition |
| 49 | + |
| 50 | +Block Tree / Markdown 是 Template Source Adapter,不是 Content IR。Adapter 先建立 Template: |
| 51 | +Slot 定义和由 Block Definition 构成的有根 Block Graph;Wiki Link / Reverse Wiki Link 声明 |
| 52 | +结构化取值,列表项与表格行在 Source 中显式存在。随后 Slot Binding 把 Object / Property 绑定到 Slot, |
| 53 | +Fixed / Parametric Definition 与显式 Generated Definition 实现为不可变 Content Block Graph。 |
| 54 | +Media 是 Block kind,其本地 Resource 在本层解析并记录 fingerprint。Block 保留 |
| 55 | +Definition、父节点、顺序、语义角色、Binding 与实现值,Outline 只从实际 heading Block 投影。 |
| 56 | + |
| 57 | +Authoring 以可追溯性为核心,用少而精的 Markdown 直接写作塑造文章流向,并显式区分原文引用、 |
| 58 | +Resource 引用、结构化引用和制导生成。Material 原文通过 Material Fragment 身份与 Source |
| 59 | +locator 进入 Content,不为复述正文而先转换为 Object;结构化值沿 Property、Object、Record、 |
| 60 | +Connector Run 追踪到 Source。Draft 可以从 Template 初始化;Template 通常是稳定真实 Draft 的 |
| 61 | +后补抽象,保存结构、Slot、引用规则、Resource 需求与 Generation Spec,不保存项目 Binding 或 |
| 62 | +Generation Result。 |
| 63 | + |
| 64 | +Generated Block 只接受显式 Block Tree Source 中的 heading/paragraph 叶定义;Core 使用 |
| 65 | +Generation Scope 向 Generator 暴露闭合的 Slot、既有 Block、Resource 与 Diagnostic,并在 |
| 66 | +验证输出合同、Evidence Binding 和可选复核后实现 Block。Source 不包含可执行的结构控制语句, |
| 67 | +也不能形成第二套 IR。 |
| 68 | + |
| 69 | +### Publication |
| 70 | + |
| 71 | +一个 Project 可以声明多个 Presentation Profile。Profile 选择 Target Format、Renderer、输出、 |
| 72 | +可选 Presentation Template、Style Binding、Semantic → Physical Style 映射、Layout 和后端参数。 |
| 73 | +Core 先形成带 fingerprint 的 Target Lowering,Renderer 只消费 Content、Profile 与 Lowering, |
| 74 | +再构造内存 Target Document;Core 在 Capability、Lowering、Target Format、syntax payload 与 |
| 75 | +fingerprint Gate 通过后,才原子写入 Artifact。 |
| 76 | + |
| 77 | +Artifact 记录 Content、Profile、Renderer、Presentation Template 与输出 fingerprint。同一 Content |
| 78 | +因此可以在一次构建中产生 Markdown 与 DOCX,而不由任何后端读取 Record 或 Template Source。 |
| 79 | +成功构建还写出包含 Source、Run、Record、Object Graph、Slot、Lowering、Target、Artifact 与 |
| 80 | +Diagnostic 的 Build Evidence Bundle。 |
| 81 | + |
| 82 | +## 分发边界 |
| 83 | + |
| 84 | +| Distribution | 责任 | |
| 85 | +|---|---| |
| 86 | +| `atomdocs` | Ingestion、Data、Composition、Publication 合同,编译编排与插件协议 | |
| 87 | +| `atomdocs-cli` | 只把终端调用适配到 Core 顶层公开 API | |
| 88 | +| `atomdocs-markdown-renderer` | Markdown Target Syntax Backend | |
| 89 | +| `atomdocs-docx-renderer` | WordprocessingML reference-template Backend | |
| 90 | + |
| 91 | +Markdown 与 DOCX 都通过 `atomdocs.renderers` entry point 发现。Core 不包含生产格式 Renderer;CLI |
| 92 | +不依赖具体后端。 |
| 93 | + |
| 94 | +Publication 只负责把 Content 实现为本地 Artifact。上传、发送、上线或同步到外部渠道属于 |
| 95 | +Distribution,不是 AtomDocs 编译层职责。 |
| 96 | + |
| 97 | +## 当前稳定变化点 |
| 98 | + |
| 99 | +| 变化 | 权威资产 | |
| 100 | +|---|---| |
| 101 | +| 来源访问、提取与归一化 | Dataset + Source + Connector | |
| 102 | +| 领域数据合同 | Domain Plugin Class | |
| 103 | +| 类型、Field 与固有不变量 | Domain Plugin Class | |
| 104 | +| 内容结构和实现规则 | Template Source → Template Graph | |
| 105 | +| 作者正文、引用与制导生成声明 | Draft / Template Authoring Source | |
| 106 | +| Object / Property 到 Slot 的绑定 | Project Manifest Slot Binding | |
| 107 | +| 可变业务规则 | pytest Policy + YAML | |
| 108 | +| 目标格式、Style 与 Layout | Presentation Profile + Renderer Backend | |
0 commit comments