Skip to content

feat: isolate and persist completed notebook SDK cache generations #31

Open

Description

@0702hjj

问题与边界

外部 notebook 的 SDK cell 缓存位于可变目录,不能直接作为平台阶段完成事实,也不能跨模型共享或让并发执行互相清理。现有整脚本工作流可以恢复已验证产品,但没有受控的完整 notebook 缓存包适配。

本次仅增加显式可选的 SimpleCADAPI 适配:用户包装脚本仍导出 IFC/ASCII DXF;不增加产品格式,不复制 Python SDK,不保存 Python 栈或逐 cell 崩溃进度。SDK key 只作报告,不当稳定业务单元 ID。

按层实现

层 行为
源码契约 PEP723 声明 adapter/notebooks/reuse,默认不持久复用;作者显式声明依赖/副作用安全
沙箱 固定只读输入,只有声明目录下的 marimo 使用每次尝试独立可写副本;拒绝上传缓存
环境 完整内容 seal 与管理员地址空间预算绑定,旧整脚本定义保留原 engine,新 notebook 定义使用独立 engine
报告与包 校验完整返回报告、源摘要、definition/cell 状态;64 MiB/4096普通文件/1 MiB清单、路径/遍历/摘要校验;Go 不解 pickle
PostgreSQL 同 namespace/model 的不可变 generation + 当前引用,切换后清理无引用代际;缺失/损坏冷执行并可修复
编辑/工作流 在原模型发布或受 fence 的 geometry checkpoint 事务接受缓存;失败/取消/删除不提交迟到缓存
可观察性 版本/current build 保存状态、SDK ran/cached/skipped 计数、报告和 definition 摘要

Architecture(局部)

橙色为新增/修改职责,其他节点为未变上下文。

flowchart LR
 API[Existing gateway / source APIs] --> DECL[Explicit notebook policy]
 DECL --> CACHE[Model-scoped generation / private copy]
 PG[(PostgreSQL)] --> CACHE
 CACHE --> SANDBOX[bubblewrap / fixed inputs / private SDK state]
 SANDBOX --> SDK[External SDK / user geometry wrapper]
 SDK --> CHECK[Report + product + map + environment checks]
 CHECK --> PACK[Bounded opaque cache package]
 PACK --> TX[Existing fenced model or checkpoint transaction]
 TX --> PG
 classDef changed fill:#fff3e0,stroke:#b45309,stroke-width:3px,color:#111;
 class DECL,CACHE,SANDBOX,CHECK,PACK changed;
Loading

Data flow(局部)

flowchart TB
 SNAP[Capture source and project inputs] --> IDENT[Wrapper / environment / budget / non-notebook input identity]
 IDENT --> RESTORE{Compatible server generation?}
 RESTORE -->|Yes| COPY[Verify and copy into private attempt]
 RESTORE -->|Missing or damaged| COLD[Run required cells cold]
 COPY --> RUN[External notebook completes]
 COLD --> RUN
 RUN --> REPORT[Validate completion and output]
 REPORT --> COMMIT[Cache + product publication or checkpoint commit]
 COMMIT --> GC[Replace reference / collect old generation]
 RUN -.Failure or cancellation.-> DISCARD[Discard private cache / no success record]
 classDef changed fill:#fff3e0,stroke:#b45309,stroke-width:3px,color:#111;
 class IDENT,RESTORE,COPY,REPORT,COMMIT,GC,DISCARD changed;
Loading

验收

真实已发布 SimpleCADAPI 2.2.0b1 的冷/热/局部 cell 修改与 cache=False 比较产品和 definition;模块/输入/环境/预算失效;并发私有目录;数据库重开;损坏修复;checkpoint故障回滚;取消/删除竞争;包路径/大小/数量与摘要限制。独立真实 SDK CI 加入 Verify;原严格几何/转换/race 与仓库门禁继续保留。

地址空间默认仍为1 GiB;可选 notebook 的更高预算只能由管理员环境配置,不能由客户端请求提升。该限制不是 RSS 配额。每模型保留一个当前缓存代际,不提供全局存储或内存硬配额。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions