Files
crearte-monorepo/docs/plans/2026-10-01-p8-long-tail.md

38 lines
4.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# P8 长尾打包(第一批)· 实施计划
依据:`docs/specs/2026-10-01-p8-long-tail-design.md`(D-1…D-5)。分支名 `feat/p8-long-tail`,各仓实现者自拉自提交**不 push**;合主由控制者 `--no-ff`。
## Task 1 · server(crearte-server,→0.14.0)
基线 master(`3e11446` 起)。改动点:
1. **②-1 `games.Detail` 400 细分**(`src/internal/handler/games.go:44-50`):把单一 `"invalid game id"` 拆为可区分消息——user 不合 `UsernamePattern` → `user: invalid format`;slug 不合 `SlugPattern` → `slug: invalid format`(两者都错时按 user 优先,或返回逗号并列,实现者择一但须有测试钉住)。沿用 `WriteError(400,"invalid_request",…)`,不改状态码。核既有 `games_test.go`/`router_test.go` 是否断言该文案,有则同步。
2. **②-2 admin 工作路由校验**:`handler/admin.go` 四条 handler(Unpublish/Republish/SetWorkFeatures/RevokeVersion)入口补 `UsernamePattern/SlugPattern` 前置校验(与 `games.Detail:47` 同款),非法即 `WriteError(400,"invalid_request","invalid work id")` 并 return。**不改** `adminWorkID`(`:115`,纯拼接 helper)。若抽出小 helper(如 `validWorkParams(c) bool`)四 handler 共用,允许。
3. **②-3 approve 同名竞态测试**:新增测试(`internal/service/content_test.go` 或新文件,视该包既有并发测试风格)——并发对同一 `work_id` 的两个 new_work 提交走 approve,断言:仅一条成功;其余返回 `ErrWorkIDTaken`/`ErrSubmissionConflict`;库中该 work 恰一行。**只加测试不改行为**。若既有测试用真库则归集成腿、若用 memory store 则单测即可(实现者按仓内既有模式定,注明)。
4. **⑤ CHANGELOG 头部**(`docs/CHANGELOG.md` 顶部):去「模板/建议统一记录」腔,改为项目口径(保留一句格式出处),不动历史条目。
5. `docs/CHANGELOG.md` 追加 `## [0.14.0] - 2026-10-01`(Fixed:②-1/②-2;Tests:②-3;Docs:⑤),中英成对。
红线:zero 新依赖/迁移;approve 行为不变;路由常量不动。
验证:容器内 `gofmt -l` 空、`go vet ./...`、`go build ./...`、`go test -p 1 ./internal/...` RC=0(容器姿势同 AGENTS.md,goproxy.cn)。集成腿由控制者跑。
## Task 2 · crearte(→0.20.0)
基线 master(`9bd9372` 起),源码根 `crearte/src`。改动点:
1. **① 权限开关全量**(`app/content/features.ts`):`EditableFeatures` 扩至七键 `eval, inlineScript, inlineStyle, wasm, coop, fullscreen, gamepad`;`EMPTY_FEATURES` 七键 false;`FEATURE_ITEMS` 补五条(**每条中文 label + hint 写清风险与适用场景**——这是本任务主要工作量);`collectFeatures` 输出七键齐全;`featuresToForm` 回读七键缺省 false;`hasAnyFeature` 自然覆盖。
2. 三处 UI 自动同步(均读 `FEATURE_ITEMS`,核实无硬编码遗漏):投稿表单勾选区、`AdminView.vue` 作品展开行、`AdminSubmissionView.vue` 只读展示。若某处有超出 `FEATURE_ITEMS` 的定制文案/布局,补齐。
3. 测试:`features` 单测(collectFeatures 七键、featuresToForm 回读、hasAnyFeature);投稿表单/审核详情相关 vitest 补断言(新开关出现、勾选进载荷)。
4. **⑤ CHANGELOG 头部**(`docs/CHANGELOG.md` 顶部):「本**模板**…建议统一记录」改为项目口径。
5. `docs/CHANGELOG.md` 追加 `## [0.20.0] - 2026-10-01`,中英成对。
红线:不动运行时三件套 / GameHost / useGameFrame(flag 消费端已存在);不为单处 UI 另开硬编码;不动管理面路由。
验证(`crearte/src`):`npx vitest run`、`npm run typecheck`、`npx playwright test e2e/admin-flow.spec.ts`、`npm run e2e` 全 RC=0。
## 合主与验收(控制者)
双路独立审查(依据 spec §1-§3 全量对照)→ 六腿验收 → `--no-ff` 合主推送 → wrapper 记账 0.2.8 → 删分支。
**注(教训落地)**:审查员任务书须显式要求「对照 spec 全文,任务书与 spec 冲突时以 spec 为准,并报告 spec 中未落地项」——P6 D-D 的漏项即由此产生。