feat(bat): 补全工作流校验与调度过滤
bat-rust / Build and test Rust (push) Canceled after 0s
bat-rust / Build and test Go API (push) Canceled after 0s

新增 parse clear-cache 和 i18n validate,补齐 schedule 的作用域过滤与单轮执行上限,并将列表过滤参数暴露给 bat-api dashboard。同步 RPC、OpenAPI、用户文档和回归测试。

Refs #43
This commit is contained in:
2026-08-03 23:47:59 +08:00
parent 0784d5b532
commit 1933d6acb0
19 changed files with 714 additions and 49 deletions
+31 -3
View File
@@ -52,6 +52,16 @@ bat parse run \
解析结果会刷新 `official-parse-cache.json``official-textunit-index.json` 和翻译队列。`--force` 忽略已有解析缓存,但仍要求输入 release 已通过官方下载 manifest 校验。
清理当前 release 的可再生解析缓存和离线翻译队列:
```bash
bat parse clear-cache \
--resource-root /tmp/bat-resources/versions/<release-id> \
--force
```
该命令不会删除 `translation-tasks.sqlite`;worker 状态必须通过任务接口单独维护。
批量 UnityFS 重打包使用 JSON spec。spec 的 `schema_version` 当前为 `1`,支持 `text_asset``string_field` 和受支持的语义 `field` 操作:
```bash
@@ -81,6 +91,17 @@ bat i18n set \
也可以使用 `--translated-file` 读取 UTF-8 文本。工作台会保存 source text、release ID、TextUnit 目标和人工译文;发布前会重新读取当前 TextUnit 索引,拒绝过期 release、source text 或 patch 目标。
发布前可只做工作台审计:
```bash
bat i18n validate \
--resource-root /tmp/bat-resources/versions/<release-id> \
--translation-file /tmp/bat-workbench.json
```
报告会区分未审核、原文未变化、可直接 `i18n publish` 的 TextAsset,以及必须使用
`parse repack` 的 TypeTree/嵌套 archive 条目。
发布汉化 release
```bash
@@ -123,7 +144,12 @@ bat res schedule run --state-dir /tmp/bat-schedule
`parse schedule add` 默认动作是 `run``i18n schedule add` 默认动作也是 `run`;可以用 `--schedule-action repack``--schedule-action publish` 选择对应动作。`--schedule-count` 限定执行次数,省略表示周期无限执行;没有 `--schedule-every` 的计划执行一次后自动停用。
`schedule update` 可以用 `--schedule-clear-every` 将周期计划改为单次计划;`schedule remove` 会删除计划。`schedule run --force` 会忽略到期时间立即执行指定计划。
`res/parse/i18n schedule list` 默认只显示对应一级命令的计划;也可以用
`--schedule-id``--schedule-enabled``--schedule-disabled` 过滤。计划删除和执行
会校验一级命令作用域,避免误操作其他工作流。`schedule update` 可以用
`--schedule-clear-every` 将周期计划改为单次计划;`schedule remove` 会删除计划。
`schedule run --force` 会忽略到期时间立即执行指定计划,`--schedule-max-runs N`
限制本轮最多执行 N 个到期计划。
## bat-api 调度接口
@@ -137,10 +163,12 @@ dashboard 通过 `bat-api` 转发到 Rust `bat.sock`,不维护第二份计划
`bat-api` 对应接口为 `GET /admin/schedules`
`POST /admin/control/schedule-add|schedule-update|schedule-remove|schedule-run`
均要求配置 `BAT_API_AUTH_TOKEN` 并携带管理 token。请求字段沿用 Rust
均要求配置 `BAT_API_AUTH_TOKEN` 并携带管理 token。列表接口支持 `id``group`
`enabled` query 过滤;请求字段沿用 Rust
contract`id``group``action``args``next_run_unix_seconds`
`delay_seconds``every_seconds``count``clear_args``clear_every`
`enabled``schedule.run` 额外接受 `force`
`enabled``schedule.list` 额外接受 `id``group``enabled` 过滤,
`schedule.run` 额外接受 `group``force``max_runs`
## 边界
+5 -3
View File
@@ -167,11 +167,11 @@ SQLite `ResourceRepository`,索引不存在时返回 `ok=true` 且
| 方法 | 状态 | params | data |
|---|---|---|---|
| `schedule.list` | 已实现 | `null` | `{ "command": "schedule-list", "schedules": [...] }`。 |
| `schedule.list` | 已实现 | `null``{ "id": "...", "group": "res", "enabled": true }` | `{ "command": "schedule-list", "query": {...}, "schedules": [...] }`。 |
| `schedule.add` | 已实现 | 调度 mutation | 新建 schedule report。 |
| `schedule.update` | 已实现 | 调度 mutation,必须有 `id` | 更新后的 schedule report。 |
| `schedule.remove` | 已实现 | `{ "id": "daily-pull" }` | 删除报告。 |
| `schedule.run` | 已实现 | `{ "id": "daily-pull", "force": true }`,字段可省略 | 到期或强制执行报告;省略 `id` 执行所有到期计划。 |
| `schedule.run` | 已实现 | `{ "id": "daily-pull", "group": "res", "force": true, "max_runs": 1 }`,字段可省略 | 到期或强制执行报告;省略 `id` 执行指定 group 的到期计划。 |
调度 mutation 字段如下:
@@ -179,7 +179,7 @@ SQLite `ResourceRepository`,索引不存在时返回 `ok=true` 且
|---|---|---|
| `id` | string | 计划 IDadd 必填,update/remove 用于定位。 |
| `group` | string | `res``parse``i18n`;对应一级工作流。 |
| `action` | string | `res``pull/refresh/verify/repair``parse``run/repack``i18n``run/export/publish`。 |
| `action` | string | `res``pull/refresh/verify/repair``parse``run/repack/clear-cache``i18n``run/export/validate/publish`。 |
| `args` | string[] | 目标工作流的 CLI 参数。 |
| `next_run_unix_seconds` | uint64 | 指定下一次执行时间;不能和 `delay_seconds` 同时使用。 |
| `delay_seconds` | uint64 | 从当前时间计算下一次执行时间。 |
@@ -189,6 +189,8 @@ SQLite `ResourceRepository`,索引不存在时返回 `ok=true` 且
| `clear_every` | bool | update 时清除周期并转为单次计划。 |
| `enabled` | bool | 启用或停用计划。 |
`schedule.run.max_runs` 必须大于 0,用于限制一次轮询最多领取的到期计划数。
`count > 1` 必须和周期同时存在;`schedule.run``force=true` 只忽略
到期时间,不会绕过 `enabled=false`。每次执行前先持久化下一次状态,执行后
再持久化成功/失败和错误信息,避免进程中断后重复领取同一计划。
+2 -1
View File
@@ -167,7 +167,7 @@ issue 43 例外说明:新增的 `parse repack` 只编排已有 TextAsset、Typ
- 通用 Binary/JSON/Text Patch crate 能力可作为后续发布流程输入。
- 文件级写入入口可用于隔离测试和上层工具显式产物生成。
- 发布级通用 `patch build` / `patch rollback`、复杂 AssetBundle 重打包和完整翻译文件集合的正式使用仍未完成;issue 43 的 `parse repack``i18n publish` 仅覆盖已有 patch 实现支持的安全子集。
- 发布级通用 `patch build` / `patch rollback`、复杂 AssetBundle 重打包和完整翻译文件集合的正式使用仍未完成;issue 43 的 `parse repack``parse clear-cache``i18n validate``i18n publish` 仅覆盖已有 patch 实现支持的安全子集。
验收:
@@ -294,6 +294,7 @@ issue 43 例外说明:新增的 `parse repack` 只编排已有 TextAsset、Typ
- `translation-tasks.sqlite``schema_migrations` 管理 durable task state、attempt count、provider run ID 和 failure reason;重复同步会保留已有 worker 状态。
- `translation.tasks` RPC/CLI 优先查询 `translation-tasks.sqlite`,旧 release 没有状态库时回退到 `official-textunit-tasks.json`;返回队列 `status`、worker `task_status`、failure reason 和时间/尝试次数。
- `translation.task.update` RPC 已提供 queued/running/failed/completed/skipped 状态回写契约,provider worker 可在消费 handoff 后按 task_id 更新并由同一查询接口反查。
- `i18n validate` 可在发布前校验工作台 release、source text、重复 patch 目标,并区分可直接发布的 TextAsset 与必须进入 `parse repack` 的条目;`parse clear-cache` 只删除可再生解析/队列 JSON,保留 `translation-tasks.sqlite` 的 worker 状态。
- 真实 Crowdin 网络 worker、翻译记忆和完整 localized repack 仍属于后续翻译系统工作,不在当前 Rust 离线状态仓储范围内。
验收: