Skip to content

docs+infra: YAML_SCHEMA covers v1 features, Docker survives long LLM calls - #67

Merged
shanchuann merged 1 commit into
mainfrom
docs/schema-and-docker
Jun 7, 2026
Merged

shanchuann merged 1 commit into
mainfrom
docs/schema-and-docker

Conversation

@shanchuann

Copy link
Copy Markdown
Owner

功能描述

两件事:

docs/YAML_SCHEMA.md 补足:之前文档写于 `/editor` 还是原型期、`/export` + `/refine/scene` 还没存在的时候。补 5 个新章节让评委只读这一份文档就能完整理解 "YAML 出来之后被怎么消费的"。

Docker 部署纠正 + 验证清单:发现 nginx `proxy_read_timeout=60s` 跟 PR XII 加的 `read=180s` 撞了——长 beats / refine 调用会被代理 504 切断;同时 `.dockerignore` 漏了 `logs/` 等会膨胀 build context 的目录。再加一份 9 步验证清单帮评委自查。

实现思路

YAML_SCHEMA.md 五个新章节

  • §11 `quality_metrics` 响应包络:把 `ai_stages_applied` + `llm_provider` 这两个前端徽标依赖的字段画清楚,说明"为什么不放进 YAML 顶层"。
  • §12 编辑器数据流:`patchScreenplayYaml` 的 js-yaml round-trip 思路 + Adapt ↔ Editor 三时机回流(mount / focus / visibilitychange),消除 PR XIX 修的双源 bug 残影。
  • §13 Schema 字段 → 导出格式映射表:每条 `beats[].kind` / metadata 字段在 Fountain / TXT / Markdown 三种格式里被翻译成什么;包括 SLUG 来源优先级(auto-prepend > 合成 > 跳过)和未知 speaker 的 `CHAR_<raw_id>` fallback。
  • §14 字段交叉约束清单:dialogue 的 `speaker` + `text` 必填、`character.id` 全局唯一、`additionalProperties: false` 锁等所有跨字段规则汇总成一张表,便于复审。
  • §15 字段未来路线图:`dramatic_unit` / `emotional_tone` / `relationships` / `camera_hint` 等已设计但未落地的字段,标注"加为 optional + `additionalProperties: false` 不必放宽"的演进策略,便于 v0.2 引入时不破现有契约。

Docker

  • nginx:`proxy_read_timeout 60s → 300s`,`proxy_send_timeout 300s`,`proxy_connect_timeout 10s`。代码里写明"≥ 后端 LLM read budget + 余量",下次有人调 LLM 超时记得同步改这里。
  • .dockerignore:加 `logs/`、`novel*.txt` / `novel*.md` / `novel*.docx` / `image*.png` / `image*.jpg`——这些是评委本地烟测扔到根目录的文件,不该进 build context。
  • README Docker 验证清单:9 步从容器健康 → 后端 /health → /adapt 规则路径 round-trip → /export → 缓存卷 → 静态资源长缓存全部覆盖,每步注明期望输出便于定位问题在哪一层。

测试方式

  • 后端 `pytest`: 318 passed
  • `py -m ruff check`: clean
  • 前端 `tsc -b`: clean
  • 前端 `npm run build`: 488 KB / 153 KB gzip(含 js-yaml + lucide-react)
  • 静态验证 docker:`docker compose config` 通过;Python 包 auto-discover 覆盖新增 `story2script.export` 模块;`.dockerignore` 规则覆盖新增运行时目录
  • 未实测 `docker compose up`:本会话 Docker daemon 未运行;评委本地按 README 验证清单 9 步跑一遍即可

依赖与复用声明

无新增第三方依赖。复用:

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

…calls

YAML_SCHEMA.md was written when /editor was prototype and /export +
/refine/scene didn't exist. Four new sections close the gap so a
grader reading the schema doc can answer "what happens to my draft
after the LLM hands it off" without crossing over to API.md:

- §11 quality_metrics envelope: ai_stages_applied + llm_provider
  fields the frontend badge depends on.
- §12 editor data flow: js-yaml round-trip patcher + Adapt ↔ Editor
  back-sync mechanism (mount + focus + visibility triggers) so
  exports always reflect the author's latest edits.
- §13 schema-to-export mapping table: every beat kind and metadata
  field's behavior in Fountain / txt / md renderers, including
  SLUG line precedence (auto-prepended vs synthesized vs skipped)
  and the unknown-speaker fallback that surfaces broken ids
  instead of swallowing them.
- §14 cross-field constraints summary: the if/then dialogue rule,
  speaker / first_appearance referential integrity, additional-
  Properties:false lock, all in one table for review.
- §15 future fields roadmap: dramatic_unit, emotional_tone,
  relationships, camera_hint — flagged as optional additions so
  v0.2 doesn't accidentally break v0.1 clients.

Docker side:

- nginx proxy_read_timeout was 60s. Backend LLM read budget is
  180s, so a slow beats / refine call could be 504'd by the proxy
  before the model finished streaming. Bumped to 300s with 120s
  headroom and a code comment so future tweaks to the LLM budget
  also move the proxy bound.
- .dockerignore extended to exclude logs/ and root-level
  smoke-test artifacts (novel*.txt, image*.png) that would
  otherwise bloat the build context.
- README has a new 9-step Docker verification checklist a grader
  can paste line-by-line after `docker compose up` to confirm
  each layer (container health, internal /health, /adapt rule
  path round-trip, /export, cache volume, static asset caching)
  is working before recording the demo.

Static validation pass: pyproject auto-packages discover the new
story2script.export module without config changes; web build
produces a clean Vite bundle; pytest 318/318. Live compose run not
executed (Docker daemon not running in this environment); checklist
in README is what to run locally.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@shanchuann
shanchuann merged commit 8459b95 into main Jun 7, 2026
2 checks passed
@shanchuann
shanchuann deleted the docs/schema-and-docker branch June 7, 2026 10:22
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