RFC-0001:AI 原生 CAD 系统架构:身份、证据、存储与恢复
主文档与完整目录。本分篇与主文档共同构成同一规范,版本、状态与权威以主文档为准;仅拆分阅读结构,条款编号和正文语义不变。
13. ArtifactGraph 与稳定引用
Section titled “13. ArtifactGraph 与稳定引用”13.1 图模型
Section titled “13.1 图模型”ArtifactGraph 是每次执行产生的不可变、有类型 DAG。节点包括:
- AMIR node/port;
- kernel body、shell、face、edge、vertex 或 mesh component;
- conversion artifact;
- validation/certificate;
- RenderPacket primitive、triangle range、selection segment;
- import/export blob。
边至少包括:
- generatedFrom;
- modifiedFrom;
- splitFrom;
- mergedFrom;
- deletedFrom;
- derivedFrom;
- convertedFrom;
- tessellatedFrom;
- bakedFrom;
- renderedFrom;
- validatedFrom。
所有 lineage 边统一从结果/后代/tombstone 指向来源/前代;删除创建 tombstone,再用 deletedFrom 指向旧实体。每个边携带 adapter、operation、revision、confidence/provenance grade 和必要的局部映射。ArtifactGraph 自身可持久化和查询,但永远可以由 revision 和执行清单重建,因此不是 authoring source。
13.2 SemanticRef
Section titled “13.2 SemanticRef”13.2.1 Authoring
Section titled “13.2.1 Authoring”Authoring 定义用户/AI 想持续引用的语义:scope、entity kind、origin/role、lineage、predicate、cardinality、 ordering 与 evolutionPolicy。创建引用时必须形成绑定 authoring Revision/Evaluation/ArtifactGraph/ ExecutionManifest 的 authoring witness,记录当时的完整候选集合与 lineage fan-out;witness hash 进入后续 resolution request,不把 kernel index 变成永久 ID。
13.2.2 Resolution
Section titled “13.2.2 Resolution”SemanticRef 的解析顺序:
- feature named output 和 adapter history;
- ArtifactGraph lineage 与拓扑/邻接结构;
- 几何 predicate;
- cardinality contract。
引用至少包含 scope、entity kind、origin/role、lineage、predicate、cardinality 和显式 evolutionPolicy。split、merge、delete 或 kind change 必须按 AMIR v0.1 第 8 节 处理;任何允许继续的策略仍需重新应用完整查询。禁止“取第一个”。结果必须返回:
- resolved artifact IDs;
- 每个过滤阶段的候选数;
- 被排除候选及原因;
- missing / ambiguous / changed-kind 诊断;
- 与上一 revision 的 identity survival 结果。
当前 Revision 使用 resolve,跨 Revision/分支/表示使用 resolveAcross。两者共享
SemanticRef v0.1 契约 的闭合 wire:结果始终是 candidates 集合,固定
declared/actual cardinality、七阶段 trace、creation/no-effect/modified/split/merge/delete/kind-change/
converted evolution、显式 status 与 resolution hash。heuristic/unknown evidence 不得 authoritative
publish;namingAlgorithmVersion 必须进入 ExecutionManifest 并由最终 validation token 绑定。
13.3 四向 Source Map
Section titled “13.3 四向 Source Map”系统维护:
OriginAnchor ⇄ AMIR node/port ⇄ kernel artifact/subshape ⇄ RenderPacket primitive/triangle
OriginAnchor = SourceSpan | JsonPointer | PatchOpId | ImportElementId这使 viewer picking、代码定位、AI query、诊断高亮和 feature-ID segmentation 使用同一身份链,而不是颜色或数组下标猜测。
14. Geometry Certificate
Section titled “14. Geometry Certificate”Geometry Certificate 是某个 artifact 在指定 ExecutionManifest 下的机器可读证据,不是形式化证明。
14.1 唯一协议与必需字段
Section titled “14.1 唯一协议与必需字段”Geometry Certificate 的唯一 wire schema 由 AMIR v0.1 第 13 节 和生成的 runtime/geometry-certificate.schema.json 定义;本 RFC 不维护第二套字段。核心结构为:
GeometryCertificate { certificateVersion certificateId subject { artifactId, artifactContentHash, producedBy } source { revisionId } | { candidateId, baseRevision, patchHash } evaluationId executionManifestHash executionClass assuranceProfiles[] representation approximationClass inputArtifactsByLogicalKey kernel numericPolicy checks metrics conversionHistory[] provenanceCoverage determinism diagnosticIds[]}Candidate certificate 与 committed Revision certificate 使用不同 source binding 和 certificateId;只要模型内容、authoring lock、ExecutionManifest、execution/quality profile 与输入 artifacts 完全相同,它们可以引用同一 EvaluationId。
14.2 证据内容
Section titled “14.2 证据内容”- bbox、面积、体积、重心、惯量及其适用条件;
- body/shell/face/edge/vertex 或 component/triangle 计数;
- curve/surface 类型分布;
- closed、valid solid、watertight、manifold、自相交、退化元素、负体积状态;
- constraint DOF、最大 residual、冗余和冲突集合;
- Field bounds、sign、采样分辨率、距离性质和 bake 误差;
- 每个 conversion 的 loss kind、estimated bound、provenance retention;
- assertions 与制造检查;
- 执行时间、峰值内存、输出规模、缓存命中;
- Diagnostic warning、受限 fixes 和未验证项。
检查状态只能写作 pass、fail、unknown 或 notApplicable。未知必须写作 unknown,不能省略后由调用方解释为通过。导出证书必须引用导出 blob hash;更换导出参数后原证书不可复用。
14.3 执行类别与保证范围
Section titled “14.3 执行类别与保证范围”证书使用两个正交维度,禁止把“权威执行”和“制造验证”混成一个枚举:
executionClass:preview或authoritative。Preview 只用于交互反馈;Authoritative 按锁定 manifest 和项目容差执行,可被提交策略引用。assuranceProfiles:已通过的检查范围,可包含geometric、requirements、manufacturing、exchange。其中 Exchange 必须绑定具体导出 blob、格式 profile 和 round-trip/保留报告。
项目 policy 决定某类 commit/export 所需的 execution class 与 assurance profiles。没有执行的检查必须写作 unknown,不得由更高名称暗示为通过。
15. Three.js Viewer 与 Render Bridge
Section titled “15. Three.js Viewer 与 Render Bridge”Three.js Viewer 是纯派生客户端。Render Bridge 输出版本化 RenderPacket:
RenderPacket { source { revisionId } | { candidateId, baseRevision, patchHash } evaluationId sourceArtifactHash geometryBuffers materialSlots primitiveArtifactIds triangleToArtifactRanges bounds lodAndError selectionBuffers}规则:
- viewer 不持有 ExactSolid、MeshSolid 或 Field3D 的规范对象。
- viewer 中的拖拽、布尔按钮、删除和属性编辑只产生 intent/patch,交给 Model Service。
- picking 返回 RenderPacket artifact ID,再经 ArtifactGraph 解析 SemanticRef;triangle index 只在该 RenderPacket 生命周期内有效。
- WebGL2 是基线;WebGPU/TSL 用于 Field 预览和增强效果,不改变提交语义。
- Three.js 通过内部 renderer adapter 固定版本,升级需视觉、拾取、buffer schema 和性能回归。
- 大模型使用 LOD、分块、延迟 attribute 和 BVH;任何简化均标注 screen/geometric error。
- viewer 可在 preview 和 authoritative 工件间切换,必须明显展示近似、失效和正在精化状态。
- GLB 可由 RenderPacket 导出,但不能从 GLB 回写 feature graph。
16. 存储模型
Section titled “16. 存储模型”16.1 逻辑存储
Section titled “16.1 逻辑存储”| 存储 | 内容 | 一致性 |
|---|---|---|
| Revision Store | canonical AMIR、parents、branch head、patch、schema/manifest | 强一致、不可变 revision |
| Evaluation Store | modelHash + authoringLockHash + ExecutionManifest + execution/quality profile + 输入 artifacts 对应的 EvaluationId,以及 Candidate/Revision bindings | 不可变执行身份;source binding 追加写;artifacts 可重复生成 |
| Audit/Event Store | transaction lifecycle、actor、intent、diagnostics、policy | 追加写 |
| Blob Store | imports、exports、截图、RenderPacket payload | content-addressed |
| Artifact Store | kernel serialization、ArtifactGraph、certificate | content-addressed、可重建 |
| Query Index | 参数、拓扑摘要、来源、全文/向量索引 | 派生、可重建 |
| Cache | compiler、subgraph、tessellation、query、preview | 可删除、按策略淘汰 |
16.2 项目包
Section titled “16.2 项目包”project.aira/ manifest.json model.aira # 可选人类投影,不是规范源 model.amir.json authoring/ # 可选 CST、trivia、source-map 附件 imports/ assets/ history/ certificates/ exports/ previews/ cache/ # 可删除,不进入规范历史manifest.json 记录 project/schema policy、锁定包、adapter compatibility 和 branch head;canonical AMIR hash 决定 model identity。model.amir.json 是规范源;若存在 model.aira,其 manifest 必须声明所投影的 model hash,失配时只能标记 stale、重新编译或再生成,不能覆盖 canonical AMIR。
BREP、mesh 或 GLB 可以存在于 cache、imports 或 exports 中,但删除 cache 后不得丢失已提交设计语义。若用户仅导入一个 BREP/STEP 文件,AMIR 的 source 是带 blob hash、格式、单位和 import policy 的 import node,而不是某次内存中的 TopoDS_Shape。
16.3 本地与云实现
Section titled “16.3 本地与云实现”- 浏览器:IndexedDB/OPFS 保存 revision、blob 与 cache;关键提交使用写前日志和原子 head 更新。
- 桌面:SQLite 或等价事务库保存 metadata/event,文件 CAS 保存大 blob。
- 服务端:PostgreSQL/等价事务库保存 revisions/heads/events,对象存储保存 CAS,队列只传 hash/handle。
不同部署实现必须通过相同的 storage conformance tests。
17. 缓存与增量计算
Section titled “17. 缓存与增量计算”17.1 缓存层
Section titled “17.1 缓存层”- parse/CST cache;
- canonical AMIR 和 type-check cache;
- compiled subgraph/KernelPlan cache;
- authoritative artifact cache;
- preview artifact cache;
- tessellation/RenderPacket/LOD cache;
- query/certificate derivation cache。
17.2 缓存键
Section titled “17.2 缓存键”缓存键至少覆盖:
- canonical subgraph hash;
- compiler build/schema;
- adapter/kernel/plugin build hashes;
- operation descriptor version;
- input artifact/blob hashes;
- unit normalization 和 tolerance profile;
- seed、thread/determinism profile;
- quality、bounds、sampling、deflection、LOD;
- platform ABI 中会影响结果的字段。
禁止只用 node ID、文件名或“模型未改”作为几何缓存键。preview 与 authoritative cache 使用不同 namespace。错误可以短时 negative-cache,但 revision、adapter 版本、budget 或输入变化时必须失效。
17.3 增量规则
Section titled “17.3 增量规则”- patch 先计算语义 changed set,再沿 typed DAG 标记 dirty descendants;
- 未改变且缓存 manifest 匹配的 artifact 保持 hash 和身份;
- SemanticRef 解析依赖的 history/adjacency 变化会使消费者 dirty;
- global tolerance、kernel/plugin upgrade 和 import blob 变化按影响范围失效;
- viewer-only material/camera 修改不得触发 CAD 重算;
- coarse preview 不能污染 authoritative cache。
18. 部署拓扑
Section titled “18. 部署拓扑”18.1 浏览器 Worker
Section titled “18.1 浏览器 Worker”Main Thread Three.js Viewer + UI | Model/Transaction Worker (Rust WASM or TS bootstrap) | +-- OCCT WASM Worker +-- Manifold WASM Worker +-- Field CPU/GPU Worker +-- Constraint WASM Worker +-- Import/Export Worker- 首屏不加载完整 OCCT;按 capability 懒加载、预热和缓存最小 custom build。
- worker 之间只传 handle/transferable buffer;UI 主线程不得运行权威几何。
- 每个 worker 有内存软/硬上限、deadline、cancel、heartbeat 和 crash recovery。
- 浏览器不支持所需能力时,返回 capability negotiation 结果,允许用户显式选择 native/server execution。
18.2 桌面原生
Section titled “18.2 桌面原生”- Rust Model Service/transaction/compiler 作为本地服务;
- OCCT/Manifold 可使用原生库进程,提高启动、内存和线程能力;
- Three.js 在 WebView 或桌面 Web runtime 中保持同一 RenderPacket 协议;
- kernel 进程崩溃不拖垮 UI;大 blob 用共享内存/内存映射和 CAS handle;
- native adapter 与 WASM adapter 必须通过相同 operation/certificate conformance suite。
18.3 服务端
Section titled “18.3 服务端”- Model Service 无状态扩展,revision/transaction state 在持久层;
- scheduler 按 capability、tenant、kernel version 和 resource class 路由到隔离 worker pool;
- job queue 传递不可变 hash,结果以原子 CAS write + transaction compare-and-swap 发布;
- 每租户有 CPU、内存、wall time、并发、blob、triangle/cell 和导出配额;
- worker 默认无网络和无宿主文件系统写权限;
- 服务端结果返回完整 ExecutionManifest,客户端不能把不同 manifest 的 preview 与 commit 混为一体。
18.4 跨部署一致性
Section titled “18.4 跨部署一致性”协议版本和 AMIR 语义一致,但不承诺不同平台逐位相同。项目可配置 execution policy:
- local-only;
- prefer-local-with-explicit-server-fallback;
- pinned-server-authoritative;
- reproducible-build worker image。
权威 commit 必须记录实际执行位置和完整 build hash。
19. 确定性与容差
Section titled “19. 确定性与容差”19.1 确定性契约
Section titled “19.1 确定性契约”系统承诺:
相同 canonical AMIR revision、输入 blobs、ExecutionManifest 和资源策略,应产生满足同一结构不变量及证书误差界的结果。
系统不承诺跨 CPU、编译器、线程调度或 kernel 版本的二进制逐位一致。
为缩小差异:
- pin compiler/adapter/kernel/plugin build;
- 所有随机性显式 seed;
- canonical order 不依赖 hash map 或 kernel traversal;
- authoritative test profile 可禁用非确定性并行路径;
- 浮点环境、base units、线程数和可影响结果的优化进入 manifest;
- 比较 validity、类型、质量属性、拓扑摘要、SemanticRef survival 和带界几何距离,不比较 BREP 字节或 face 枚举顺序;
- 升级内核复用现有构建、类型检查及相关实际产品操作核对几何、诊断和资源行为;变化记入现有实施记录,新结果绑定新的 Evaluation。历史结果不可覆盖,不为未发布版本新增迁移器、测试框架或报告树。
19.2 容差配置
Section titled “19.2 容差配置”AMIR settings.tolerances 是内嵌、版本化的 ToleranceProfile,必须拆分而不是使用一个全局 epsilon:
- modelingLinear;
- modelingAngular;
- intersectionLinear;
- fuzzyBooleanLinear;
- sewingLinear;
- constraintLinearResidual;
- constraintAngularResidual;
- validationDistance;
- quantityRelative。
优先级固定为:Document profile → Operation descriptor 明确允许的普通 input override → adapter effective value。前两层进入 model/subgraph hash;最后一层进入 ExecutionManifest、EvaluationId 和 Geometry Certificate。Adapter 不得静默放宽容差。Canonical conversion 的 tessellation/Field sampling 参数是普通 Node input;仅视图/导出使用的 chordal、angular、cell size、LOD 等进入独立 view/delivery quality profile 及其 job hash,不混入建模 tolerance。
profile 有稳定 ID 和版本。operation 可以收紧但不能在不记录的情况下放宽项目 policy。adapter 必须报告实际使用值和内核修正/放宽。单位变化不能改变物理容差含义。
20. 错误模型与恢复
Section titled “20. 错误模型与恢复”20.1 统一结构
Section titled “20.1 统一结构”唯一 Diagnostic 协议和 code registry 由 AMIR v0.1 第 11 节 与后续生成的 runtime/diagnostic.schema.json 定义;本 RFC 不维护第二套结构。核心字段为 id、code、severity、phase、at、context、messageKey、details、relatedArtifacts、retryability 与 fixes。
phase 的规范值为 schema、static、resolve、kernel、conversion、assertion、transaction 或 migration。messageKey 与结构化 payload 是机器契约;本地化 message 不是。kernel exception 文本只能作为已清理的调试附件,不能作为上层分支条件。
20.2 顶层错误族
Section titled “20.2 顶层错误族”- AMIR_PARSE_ERROR;
- SCHEMA_VERSION_UNSUPPORTED;
- TYPE_MISMATCH / UNIT_DIMENSION_MISMATCH;
- DEPENDENCY_CYCLE / COST_UNBOUNDED;
- REVISION_CONFLICT / PRECONDITION_FAILED / IDEMPOTENCY_CONFLICT;
- SEMANTIC_REF_MISSING / SEMANTIC_REF_AMBIGUOUS / SEMANTIC_REF_CHANGED_KIND;
- CONSTRAINT_UNDERCONSTRAINED / OVERCONSTRAINED / SOLVER_DIVERGED;
- KERNEL_PRECONDITION_FAILED / KERNEL_OPERATION_FAILED / WORKER_CRASHED;
- GEOMETRY_INVALID / SELF_INTERSECTION / NOT_MANIFOLD;
- ERROR_BOUND_UNAVAILABLE / ERROR_BUDGET_EXCEEDED / PROVENANCE_LOST;
- RESOURCE_BUDGET_EXCEEDED / CANCELLED / CANCEL_TOO_LATE / DEADLINE_EXCEEDED;
- CAPABILITY_UNAVAILABLE;
- IMPORT_REJECTED / EXPORT_POLICY_FAILED;
- PLUGIN_PERMISSION_DENIED / PLUGIN_NONDETERMINISTIC。
fixes 是 catalog 中定义的受限 action,例如 reduceRadius、excludeCandidate、increaseBounds、decreaseResolution、repairInput、chooseAuthority;它们必须重新走 propose/preview/validate,不得由 adapter 私自修改模型。
21. 安全
Section titled “21. 安全”21.1 AMIR 与执行安全
Section titled “21.1 AMIR 与执行安全”- AMIR 是纯数据,不允许网络、文件、系统调用、动态加载、反射或无界循环。
- bounded pattern/map/reduce 必须可静态估算上限。
- 每个 Field 执行计划强制有限
evaluationClip或meshingBounds、max cells、max triangles 和最大求值深度;Field 的mathematicalDomain可以是allSpace。 - 表达式、图深度、节点数、字符串、数组和 recursion 都有解析限额。
- 所有 kernel 和 import worker 支持 deadline、cancel、内存上限和 crash isolation。
- 不信任 kernel 返回的长度、索引和 buffer;跨边界重新校验。
21.2 输入与供应链
Section titled “21.2 输入与供应链”- import 先做 magic/format sniff、大小限制、压缩炸弹、路径穿越和恶意嵌套检查;
- 外部 blob 以 hash、MIME、原始文件名和来源策略记录,解析器无网络;
- WASM/native/package 构建可复现并生成 SBOM、许可证清单和签名;
- adapter/plugin 版本按 allowlist 和内容 hash 锁定,不能使用浮动 latest;
- OCCT LGPL-2.1 + exception、WASM/静态分发和应用商店场景在发布前完成法务复核;官方许可证说明是工程输入而非法律意见。OCCT License
- Manifold 为 Apache-2.0,仍需保留 notice 与供应链记录。Manifold License
21.3 多租户与隐私
Section titled “21.3 多租户与隐私”- project、blob、cache、log、trace 按 tenant 隔离;
- 日志默认不记录完整模型、prompt、文件名或几何 buffer;
- 支持本地-only 和无遥测模式;
- 服务端下载/导出使用短期 capability URL;
- 管理员不能通过调试接口取得 raw kernel memory;
- 审计保留期、模型内容和 AI prompt 保留策略分开配置。