Skip to content

feat(core)!: introduce the v0.8 rendering architecture#129

Draft
BalconyJH wants to merge 92 commits into
masterfrom
release/v0.8.0
Draft

feat(core)!: introduce the v0.8 rendering architecture#129
BalconyJH wants to merge 92 commits into
masterfrom
release/v0.8.0

Conversation

@BalconyJH

Copy link
Copy Markdown
Collaborator

背景

0.7 的渲染入口、backend session、资源解析和可选引擎逐渐形成了跨层耦合:调用方需要理解具体 backend,生命周期与 admission 缺少统一所有者,本地资源传输依赖部署拓扑,新增引擎还会扩大兼容壳和伪公共契约。

本 PR 汇总 v0.8 的破坏性架构升级,把 HTML 渲染、原生文档渲染与栅格场景统一到 Provider/Capability 模型,并把资源、生命周期、可观测性和发布门禁收回各自明确的边界。

方案

公共契约与运行时

  • 引入 typed render artifacts、Provider SDK/discovery 和稳定的 Capability lookup 路径;
  • Application、composition-owned runtime plan、admission 与 typed lease 统一启动、执行、排空和关闭;
  • 删除 legacy backend/session、bindings 与 enum 伪契约,把配置和领域类型移动到实际所有者;
  • 保留 nonebot-plugin-localstore 作为所有引擎共享的插件基础设施,而不是单一 Provider 的实现细节。

Provider、图形与资源

  • 完整接入 Playwright、HTMLKit 和 Takumi Provider,并新增 Pillow/Skia RasterScene graphics capability;
  • 建立中立的 PreparedHtml pipeline、composition-owned Resource Service、受限本地读取和有界缓存;
  • 为远程 Playwright 提供 render-scoped memory 与受请求头保护的 filehost transport;
  • 让 filehost 仅在认证成功后返回 CORS header,并用真实远程 Chromium 覆盖 Markdown 的 CSS、PNG 与 WOFF2 资源图;
  • 将 Sentry 与 Prometheus 作为 observer adapters 注入各引擎,而不污染核心渲染契约。

工程质量、文档与发布

  • 强制完整公共类型面,扩展架构契约、并发/生命周期、Provider 和远程浏览器测试;
  • 更新示例工程与用户/维护者文档,采用 Zensical 语义组件并自托管固定版本的 Mermaid runtime;
  • 加固 wheel/sdist、可选 extra、文档预览、Ruleset、TestPyPI、自动 tag、PyPI/GitHub Release 和版本文档发布链;
  • 明确 Prek 默认、commit-msg 与 manual stage 的本地和 CI 门禁。

行为、兼容性与风险

  • Breaking: 0.7 backend/session API、旧配置路径和内部兼容导出不再作为 0.8 契约;迁移方式见 v0.8 用户文档。
  • 渲染调用返回类型化产物;Provider 专属能力通过稳定 Capability 路径访问。
  • 核心包不隐式安装具体渲染引擎;Playwright、HTMLKit、Takumi、Pillow 与 Skia 由对应 extras 选择。
  • 本地资源读取受 allowlist、symlink 与大小策略约束;通配 CORS 只负责浏览器可读性,不替代 filehost 请求头授权。
  • 新架构扩大了变更面,主要风险集中在第三方 Provider 迁移、远程资源可达性、跨引擎输出差异和发布流程权限边界。

Important

release/v0.8.0 当前相对 master 落后 8 个、领先 92 个提交。主线独有内容属于 v0.7.2 发布线,其运行时修复已在 v0.8 新架构中等价吸收,但 Git 拓扑尚未同步。转为 Ready 前需要完成一次审计式主线合并并解决重写目录、workflow、迁移文档和版本文件的冲突;不应机械 cherry-pick 或重写这 92 个提交。

验证

  • make ruff-format-check(通过 make check
  • make ruff-check(通过 make check
  • make typecheck:Basedpyright 零诊断,公共类型完备性 100%
  • make ty
  • make test-ci:622 passed、2 skipped,coverage 90%
  • prek run --all-files
  • prek run actionlint --all-files --hook-stage=manual
  • make remote-smoke:远程 Chromium 的 memory/filehost transport 均通过
  • make docs-build:Zensical strict build 无问题
  • 已新增或更新 Provider、资源、生命周期、类型、文档契约和真实远程浏览器回归测试
  • 在当前 PR HEAD 上完成 package artifact 与本地浏览器门禁,或由对应 PR checks 给出结果

文档

  • 已更新受到影响的用户、迁移、Provider、架构、质量、发布与贡献文档
  • 本地 strict build 通过
  • CI 生成预览后检查关键页面和 Mermaid 图实际渲染

合并前

  • PR 标题可作为符合 type(scope): subject 的 squash commit subject
  • 完成 master 拓扑同步并重新运行受影响门禁
  • 处理阻塞 review,并在实质性更新后重新请求 review
  • 所有适用 checks 通过后转为 Ready

BalconyJH added 30 commits July 12, 2026 17:02
Introduce weighted LRU with per-key singleflight and a byte-budget
accountant backing the resource cache. Add logical package/filesystem
source addressing so package resources stay path-agnostic. Wire the
MEMORY remote-local resource policy.
Rebuild the filehost cache layer on the shared weighted cache and
tighten warmup handling.
Add token-aware HTML/CSS reference discovery, document-local
filesystem materialization, and binary template-variable staging into
backend-neutral prepared assets. Drop the cwd file:// base_url from the
deprecated template_to_pic path.
Rebuild the telemetry backends and stop auto-requiring optional
prometheus/sentry plugins at import time. Export PreparedStylesheet and
refresh plugin metadata.
Grow the Takumi runtime and resource source handling, add validation
for values crossing the Python-to-Rust boundary, and refine the native
render operations and error surface.
Overhaul the Playwright operations and prepared-asset handling to
consume the in-memory materialized assets, with corresponding model and
render adjustments.
Update release/publish workflows and auto-tag, add a distribution
verification script, and refresh the remote-test infra and smoke test.
… API

Emit text CSS via the safe filter and track the prepared-asset API
rename (render_prepared_html, prepared.html) in the render tests.
Add the v0.7.2 migration guide and update user/maintainer docs across
config, architecture, quality, and rendering guidance.
Baseline for 0.8 architecture work: extract path guard,
tighten cache concurrency, translate takumi native errors,
isolate telemetry exporter failures.
AST-based layer rules with a shrink-only legacy-edge allowlist, plus
characterization of Prometheus/Sentry metric names, labels and tags so
the 0.8 rework cannot silently break dashboards.
New rendering/ boundary (neutral requests, typed artifacts, stable
error model, executor/observer/lifecycle/capability ports) and
application/ layer (use cases, RendererBindings-derived capabilities,
idempotent Application lifecycle). preparation/service.py exposes the
injectable HtmlPreparer seam; prepare_template gains extensions
passthrough. No existing call chain is switched yet.
BalconyJH added 30 commits July 18, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant