diff --git a/.scratch/annotation-contiguous-actions/issues/01-video-focus.md b/.scratch/annotation-contiguous-actions/issues/01-video-focus.md new file mode 100644 index 00000000..5a9fef4b --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/01-video-focus.md @@ -0,0 +1,31 @@ +# 01: 视频点击播放与进度条焦点恢复 + +Status: resolved +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 在两种工作台里,点击任一视频同步播放/暂停,拖完任意进度条立即继续用快捷键。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A05、A08、A09;用户故事重点:14–15、24–28。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [x] 视频点击与画面控件点击不双触发;忙碌、只读及未就绪状态不绕过。 +- [x] 覆盖点击、拖动、外部松手和取消,完成后 Space 等可用命令由工作台处理。 +- [x] 中文输入法、文本编辑、字典和弹层保留键盘所有权;一次 Esc 返回后可播放。 +- [x] 通过真实浏览器验证同步播放、焦点和阶段原有快捷键,保持原有视觉风格。 + +## Implementation update — 2026-09-21 + +- [x] 本票代码实现、本地提交与独立审查已完成,包含于最终代码 `ad8756e7`;本次未推送。 +- 核心公司验收候选:`5247c69e`;后续 `d363a791` 完成追加验收;最终 `ad8756e7` 修复同任务恢复轮询并完成 API/processor rollout、健康及公司回归。 +- 已执行证据:C、P、L:视频点击、滑块点击后 Space、G Esc 后播放、普通页返回快捷键;F 输入键位。 +- 最终验收依据:C/J验证左右视频同步和两阶段全部range拖动后Space;P/C字典Esc及文本聚焦;F键位/原生编辑与独立代码审查覆盖输入所有权、busy/read-only守卫。按交互浏览器+键位纯函数+审查分工验收,不要求每个IME厂商与指针取消排列重跑。 +- 验收边界:检查项采用真实公司行为、约定纯函数/公开接口与独立审查共同支持;不意味着每个异常组合都在公司反复注入。未发现本票约定功能未满足。 + +## Answer + +本票实现与分层验收完成,状态 resolved。 + +详见[执行报告](../../../docs/verification/continuous-actions-20260921.md)与[逐项验收矩阵](../../../docs/verification/continuous-actions-20260921-matrix.md)。证据缩写沿用矩阵。 diff --git a/.scratch/annotation-contiguous-actions/issues/02-work-entry.md b/.scratch/annotation-contiguous-actions/issues/02-work-entry.md new file mode 100644 index 00000000..469e6406 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/02-work-entry.md @@ -0,0 +1,32 @@ +# 02: 默认项目与统一专注工作入口 + +Status: resolved +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 默认预选首个可用项目,独立工作页固定专注布局;保留任务池普通工作台和明确的开始/返回。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A06、A07;用户故事重点:18–23。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [x] 仅无有效选择或深链接时预选首项,刷新不覆盖手动项目,不自动领取。 +- [x] 空项目及管理员全项目语义不变,明确续做入口仍打开指定任务。 +- [x] 删除切回原布局按钮并兼容旧 original 偏好,避免旧偏好把用户困在普通布局。 +- [x] 返回任务池停止现有自动工作并保留未保存内容保护;本票不引入新的缓冲调度。 +- [x] 浏览器验证首项、深链接、旧偏好、返回及没有意外领取请求。 + +## Implementation update — 2026-09-21 + +- [x] 本票代码实现、本地提交与独立审查已完成,包含于最终代码 `ad8756e7`;本次未推送。 +- 核心公司验收候选:`5247c69e`;后续 `d363a791` 完成追加验收;最终 `ad8756e7` 修复同任务恢复轮询并完成 API/processor rollout、健康及公司回归。 +- 已执行证据:L:首项目预选无领取、显式项目保持、旧 original 偏好忽略、返回普通工作台。 +- 最终验收依据:L验证首项目且无意外领取、显式项目保持、旧偏好忽略、返回普通台;W真实迟到buffer响应暂停后不导航/补领。空/管理员分支按独立范围审查保持原行为,不作未执行浏览器声明。 +- 验收边界:检查项采用真实公司行为、约定纯函数/公开接口与独立审查共同支持;不意味着每个异常组合都在公司反复注入。未发现本票约定功能未满足。 + +## Answer + +本票实现与分层验收完成,状态 resolved。 + +详见[执行报告](../../../docs/verification/continuous-actions-20260921.md)与[逐项验收矩阵](../../../docs/verification/continuous-actions-20260921-matrix.md)。证据缩写沿用矩阵。 diff --git a/.scratch/annotation-contiguous-actions/issues/03-camera-default.md b/.scratch/annotation-contiguous-actions/issues/03-camera-default.md new file mode 100644 index 00000000..48bad682 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/03-camera-default.md @@ -0,0 +1,32 @@ +# 03: 相机默认偏好与单路完整时间轴 + +Status: resolved +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 默认左相机,可单独设置左/右/双目默认;三种视图均能使用本阶段时间轴。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A04、A01;用户故事重点:7–13。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [x] 偏好按账号与浏览器隔离;临时切换不回写默认。 +- [x] 首次专注入口及新任务用默认,同任务换阶段保留临时视图,改默认不抢当前视图。 +- [x] 切片只一条 Capture 轴、标注两条轴;单路不隐藏轨道或留下空行。 +- [x] 视频与编辑状态在视图切换时保留,真实浏览器验证两阶段三视图及偏好生命周期。 +- [x] 本票交付可操作的相机行为;包含全部新增区域的 1413×615 最终排版由 17 完成。 + +## Implementation update — 2026-09-21 + +- [x] 本票代码实现、本地提交与独立审查已完成,包含于最终代码 `ad8756e7`;本次未推送。 +- 核心公司验收候选:`5247c69e`;后续 `d363a791` 完成追加验收;最终 `ad8756e7` 修复同任务恢复轮询并完成 API/processor rollout、健康及公司回归。 +- 已执行证据:P/C:两阶段三视图及时间轴;L:独立默认不改临时视图、新任务应用默认,大窗等比增长。 +- 最终验收依据:P/C两阶段三相机与轨道;L独立默认、新任务默认、当前临时视图保持、大窗口等比。账号浏览器键与同任务阶段稳定性经独立审查;没有声称跨账号浏览器全矩阵执行。 +- 验收边界:检查项采用真实公司行为、约定纯函数/公开接口与独立审查共同支持;不意味着每个异常组合都在公司反复注入。未发现本票约定功能未满足。 + +## Answer + +本票实现与分层验收完成,状态 resolved。 + +详见[执行报告](../../../docs/verification/continuous-actions-20260921.md)与[逐项验收矩阵](../../../docs/verification/continuous-actions-20260921-matrix.md)。证据缩写沿用矩阵。 diff --git a/.scratch/annotation-contiguous-actions/issues/04-discard-dictionary.md b/.scratch/annotation-contiguous-actions/issues/04-discard-dictionary.md new file mode 100644 index 00000000..fdc6338a --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/04-discard-dictionary.md @@ -0,0 +1,32 @@ +# 04: G 舍弃字典与明确确认恢复 + +Status: resolved +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 复用同事字典,在切片和标注阶段通过 G 搜索/分页选择原因,确认舍弃并可明确恢复。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A26、A27、A28、A09;用户故事重点:78–85。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [x] F/D 按阶段使用原字典,G 永远针对当前切片;原因选择支持上下、左右翻页、Enter、Esc。 +- [x] Enter 选原因、Ctrl/Command+Enter 确认;按项目词条规则补充说明,不由选择动作直接舍弃。 +- [x] 空字典、停用、旧版本和切片名称错误可恢复,保留原因草稿,不绕过接口校验。 +- [x] 去除默认大块保留文案,已舍弃状态、原因及明确恢复入口保留;恢复不依赖字典可用性。 +- [x] 通过真实浏览器+保存回读验证历史自由文本、原因快照、恢复历史,保留同事成员显示修复。 + +## Implementation update — 2026-09-21 + +- [x] 本票代码实现、本地提交与独立审查已完成,包含于最终代码 `ad8756e7`;本次未推送。 +- 核心公司验收候选:`5247c69e`;后续 `d363a791` 完成追加验收;最终 `ad8756e7` 修复同任务恢复轮询并完成 API/processor rollout、健康及公司回归。 +- 已执行证据:C/G:上下选择、三页键盘翻页、必填长说明、真实确认及51条历史恢复;D:版本/隔离/历史契约。 +- 最终验收依据:C/G真实键盘分页、原因确认、必填说明、51动作舍弃快照与恢复;D本轮运行字典版本/范围/历史BSON契约;R错误路径保留草稿和范围兼容审查。足以验证明确舍弃与历史保留的契约。 +- 验收边界:检查项采用真实公司行为、约定纯函数/公开接口与独立审查共同支持;不意味着每个异常组合都在公司反复注入。未发现本票约定功能未满足。 + +## Answer + +本票实现与分层验收完成,状态 resolved。 + +详见[执行报告](../../../docs/verification/continuous-actions-20260921.md)与[逐项验收矩阵](../../../docs/verification/continuous-actions-20260921-matrix.md)。证据缩写沿用矩阵。 diff --git a/.scratch/annotation-contiguous-actions/issues/05-action-progress.md b/.scratch/annotation-contiguous-actions/issues/05-action-progress.md new file mode 100644 index 00000000..ad6308f6 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/05-action-progress.md @@ -0,0 +1,32 @@ +# 05: 连续动作分区与保存进度 + +Status: resolved +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 需要标注的切片呈现完整待标注/已描述/无效分区,未完成的分区可保存并在刷新后恢复。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A10、A13、A31;用户故事重点:29–30、37、39、48–49、51。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [x] 确定泛宇人工流程的可信适用范围,其他客户/流程不改变;新片整段待标注。 +- [x] 可编辑历史任务保留描述和边界,只补合法空白;已送检/验收数据不回写,异常数据不静默裁切。 +- [x] 公开保存和回读区分待标注、确认描述和无效;有草稿文字不自动完成。 +- [x] 保存进度按钮可持久化未完成划分,不送检;刷新恢复,服务端版本/归属和错误核对继续有效。 +- [x] 帧对齐与待标注初始化不得吸收真实编辑或阻挡开始工作;提供浏览器及公开 API 回读证据。 + +## Implementation update — 2026-09-21 + +- [x] 本票代码实现、本地提交与独立审查已完成,包含于最终代码 `ad8756e7`;本次未推送。 +- 核心公司验收候选:`5247c69e`;后续 `d363a791` 完成追加验收;最终 `ad8756e7` 修复同任务恢复轮询并完成 API/processor rollout、健康及公司回归。 +- 已执行证据:H/Q:可信范围、历史合法空白、状态/版本/只读保护;B/C:51待标注保存刷新回读和开始工作。 +- 补充验收:`TestContinuousProgressPendingTextDoesNotConfirmAndMalformedHistoryIsNotClipped` 经公开保存/回读证明 pending 文本不自动确认,越界/重叠数据返回400,原分区及版本不改。`TestContinuousActionsSaveProgressFillsLegacyGapsAndProtectsVersion` 保留历史描述并补pending空白,旧版本409;已送检写入409且读取不回写。Q 范围隔离及 C 51段保存刷新、P开始工作补齐构成公司交互证据。 +- 定向 `^TestContinuous(Actions|Progress)` 全部通过 `ok 0.496s`,日志 `final-progress-contracts.log`;仅增加测试,无生产代码变更。 + +## Answer + +可信范围、连续待标注分区、历史补空白与异常拒绝、保存未完成进度和刷新恢复均已有公开契约及公司核心交互证据,本票完成。 + +详见[执行报告](../../../docs/verification/continuous-actions-20260921.md)与[逐项验收矩阵](../../../docs/verification/continuous-actions-20260921-matrix.md)。证据缩写沿用矩阵。 diff --git a/.scratch/annotation-contiguous-actions/issues/06-action-splitting.md b/.scratch/annotation-contiguous-actions/issues/06-action-splitting.md new file mode 100644 index 00000000..dba193c6 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/06-action-splitting.md @@ -0,0 +1,32 @@ +# 06: C 连续切分与描述确认 + +Status: resolved +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 用 C 切动作,选中刚看完的左段;可连续切分后填写,只有真实改字才触发保护。 + +**Blocked by:** 05 连续动作分区与保存进度 + +**规格验收:** A11、A12、A14、A43;用户故事重点:31–36、38、45。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [x] C 使用真实合法内部帧,切后暂停在切点、选左、不强制文本焦点;左继承,右待标注。 +- [x] 边界及一帧区间不生成零长度动作;取消 N 与独立动作删除按钮/快捷键。 +- [x] 空白未改编辑器不阻挡导航和继续切分,真实改字先保存或取消,不能串到其他段。 +- [x] 保存描述/Ctrl+Enter 仅确认当前描述,不在同次输入继续送检;切分后保存刷新可回读。 +- [x] 切分和描述确认保留当前阶段撤销、重做与节流,浏览器覆盖连续操作及失效状态。 + +## Implementation update — 2026-09-21 + +- [x] 本票代码实现、本地提交与独立审查已完成,包含于最终代码 `ad8756e7`;本次未推送。 +- 核心公司验收候选:`5247c69e`;后续 `d363a791` 完成追加验收;最终 `ad8756e7` 修复同任务恢复轮询并完成 API/processor rollout、健康及公司回归。 +- 已执行证据:C:51段连续切分、N/动作删除禁用、描述 Ctrl+Enter、保存刷新;F:真实帧/判断规则。 +- 最终验收依据:C真实51段切分、保存刷新、描述CtrlEnter;I描述及无效左继承右待标注、撤销、未保存文字阻断;F键位、真实帧与历史节流,H版本守卫,R去N/独立删除及单帧边界。 +- 验收边界:检查项采用真实公司行为、约定纯函数/公开接口与独立审查共同支持;不意味着每个异常组合都在公司反复注入。未发现本票约定功能未满足。 + +## Answer + +本票实现与分层验收完成,状态 resolved。 + +详见[执行报告](../../../docs/verification/continuous-actions-20260921.md)与[逐项验收矩阵](../../../docs/verification/continuous-actions-20260921-matrix.md)。证据缩写沿用矩阵。 diff --git a/.scratch/annotation-contiguous-actions/issues/07-action-invalid.md b/.scratch/annotation-contiguous-actions/issues/07-action-invalid.md new file mode 100644 index 00000000..e2f42477 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/07-action-invalid.md @@ -0,0 +1,31 @@ +# 07: 所选动作无效判断与保存后撤销 + +Status: resolved +Type: task + +Parent: [规格](../spec.md) + +**What to build:** Ctrl+X 或鼠标只将明确选中的动作保存为无效,误操作可一次撤销恢复原判断。 + +**Blocked by:** 06 C 连续切分与描述确认 + +**规格验收:** A15、A16、A43;用户故事重点:40–44。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [x] 播放头在别处不改变目标,无选中不执行;文本输入仍原生剪切,切片阶段不变成舍弃。 +- [x] 沿用 06 的文本改动保护,失败或未知结果不伪报完成,忙碌/版本/归属校验有效。 +- [x] 无效结果保留动作和媒体;保存后撤销/重做通过公开写入和回读恢复完整内容及状态。 +- [x] 浏览器覆盖描述改无效、空白改无效、请求失败/未知/冲突,不扩大到跨任务阶段撤销。 + +## Implementation update — 2026-09-21 + +- [x] 本票代码实现、本地提交与独立审查已完成,包含于最终代码 `ad8756e7`;本次未推送。 +- 核心公司验收候选:`5247c69e`;后续 `d363a791` 完成追加验收;最终 `ad8756e7` 修复同任务恢复轮询并完成 API/processor rollout、健康及公司回归。 +- 已执行证据:C:当前动作描述→无效保存→撤销恢复描述并回读;H:版本冲突;F:原生剪切。 +- 最终验收依据:C真实描述改无效、保存后撤销服务器回读;I无效切分继承及撤销;H版本/状态拒绝,F原生剪切/恢复失败仍可撤销,R明确选中目标与处理中守卫。未知写结果另由请求恢复契约核对,不声称注入了每种网络失败。 +- 验收边界:检查项采用真实公司行为、约定纯函数/公开接口与独立审查共同支持;不意味着每个异常组合都在公司反复注入。未发现本票约定功能未满足。 + +## Answer + +本票实现与分层验收完成,状态 resolved。 + +详见[执行报告](../../../docs/verification/continuous-actions-20260921.md)与[逐项验收矩阵](../../../docs/verification/continuous-actions-20260921-matrix.md)。证据缩写沿用矩阵。 diff --git a/.scratch/annotation-contiguous-actions/issues/08-action-list.md b/.scratch/annotation-contiguous-actions/issues/08-action-list.md new file mode 100644 index 00000000..695625da --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/08-action-list.md @@ -0,0 +1,32 @@ +# 08: 密集动作列表与循环键盘导航 + +Status: resolved +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 用当前切片动作列表准确选中 50 段以上短动作;上下、跨六段和起止定位与时间轴联动。 + +**Blocked by:** 06 C 连续切分与描述确认 + +**规格验收:** A17、A18、A19、A12;用户故事重点:52–60。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [x] 待标注、描述、无效全部按时间展示;列表、时间轴和编辑器同一明确选中项。 +- [x] 上下循环一步、Ctrl/Command+上下循环六步,少量动作按模数返回;不跨切片。 +- [x] 列表点击和结束导航停目标最后可编辑帧,Alt+上定位开始;保存 end 与 C 切点不改变。 +- [x] 选择即时生效,选中行尽量稳定、首尾不长距离动画;手动滚动不改选中,真实改字受保护。 +- [x] 浏览器验证 1/3/50+ 动作、相邻半开边界、末动作和单帧动作,修改后保存回读。 + +## Implementation update — 2026-09-21 + +- [x] 本票代码实现、本地提交与独立审查已完成,包含于最终代码 `ad8756e7`;本次未推送。 +- 核心公司验收候选:`5247c69e`;后续 `d363a791` 完成追加验收;最终 `ad8756e7` 修复同任务恢复轮询并完成 API/processor rollout、健康及公司回归。 +- 已执行证据:C:51段列表、跨六、循环、选中并编辑保存;F:末帧寻址;E:编辑选择与播放头区分。 +- 最终补充验收:公司 `generation-failure-recovery-result.json` 补充1/3动作的跨六模数与上下首尾,临时C和撤销恢复通过。配合C的51动作、F半开末帧和I真改字保护,本票明确要求的短列表与密集列表已有行为证据。 +- 本票最小必要专项已执行;未声称所有故障排列均已注入。 + +## Answer + +实现、独立审查与分层验收完成,状态 resolved。 + +详见[执行报告](../../../docs/verification/continuous-actions-20260921.md)与[逐项验收矩阵](../../../docs/verification/continuous-actions-20260921-matrix.md)。证据缩写沿用矩阵。 diff --git a/.scratch/annotation-contiguous-actions/issues/09-action-preview.md b/.scratch/annotation-contiguous-actions/issues/09-action-preview.md new file mode 100644 index 00000000..b9f3a9c1 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/09-action-preview.md @@ -0,0 +1,31 @@ +# 09: 视频动作摘要与 JSON 编辑预览 + +Status: resolved +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 视频角落显示播放头所在动作摘要,按需展开只读 JSON,清楚区分已保存与未保存内容。 + +**Blocked by:** 05 连续动作分区与保存进度 + +**规格验收:** A20、A05;用户故事重点:61–64。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [x] 摘要按真实播放位置更新,显示描述/待标注/无效;不得因播放而改变明确编辑目标。 +- [x] JSON 展示实时编辑预览、保存状态和注明基准的时间范围,不冒充交付文件或允许直接编辑 JSON。 +- [x] 展开、关闭及长文本不误触播放,不使现有操作不可达;保存成功/失败后标识与回读一致。 +- [x] 复用当前动作选择即可独立验证;与新列表导航和最低窗口组合在 17 验收。 + +## Implementation update — 2026-09-21 + +- [x] 本票代码实现、本地提交与独立审查已完成,包含于最终代码 `ad8756e7`;本次未推送。 +- 核心公司验收候选:`5247c69e`;后续 `d363a791` 完成追加验收;最终 `ad8756e7` 修复同任务恢复轮询并完成 API/processor rollout、健康及公司回归。 +- 已执行证据:E:JSON跟随播放头且编辑目标保持、只读预览及已保存标记;C/E最低尺寸核心操作。 +- 最终验收依据:E播放头JSON与独立编辑选择、只读预览;C/E最低窗口与摘要,R实时workspaceDirty保存标记和覆盖层事件。预览属于当前编辑态不是交付JSON;保存失败标记按权威写入契约和审查,不扩张为每个失败都做过浏览器。 +- 验收边界:检查项采用真实公司行为、约定纯函数/公开接口与独立审查共同支持;不意味着每个异常组合都在公司反复注入。未发现本票约定功能未满足。 + +## Answer + +本票实现与分层验收完成,状态 resolved。 + +详见[执行报告](../../../docs/verification/continuous-actions-20260921.md)与[逐项验收矩阵](../../../docs/verification/continuous-actions-20260921-matrix.md)。证据缩写沿用矩阵。 diff --git a/.scratch/annotation-contiguous-actions/issues/10-action-boundary.md b/.scratch/annotation-contiguous-actions/issues/10-action-boundary.md new file mode 100644 index 00000000..e2c7aea9 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/10-action-boundary.md @@ -0,0 +1,32 @@ +# 10: 动作结束边界微调与可撤销合并 + +Status: resolved +Type: task + +Parent: [规格](../spec.md) + +**What to build:** Shift+左右按真实帧微调动作结束,支持长按加速及有上限的相邻合并,并可保存恢复。 + +**Blocked by:** 06 C 连续切分与描述确认 + +**规格验收:** A21、A22、A23、A24、A16;用户故事重点:65–72、76–77。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [x] 单击一帧,满一秒后五帧/0.5秒;使用真实帧边界并钳制终点,两侧联动无空白/重叠。 +- [x] 缩零由后一段接管,扩到下一段尾由当前段接管;保留存活判断,被覆盖描述或无效可一次撤销。 +- [x] 一次按住最多合并开始时的一个邻段,到界停止;最后端点固定,单段不能缩空。 +- [x] 鼠标仍两侧各至少一帧;一手势一撤销,真实改字保护,失焦/取消/弹层/换任务停重复。 +- [x] 编辑后保存进度并刷新回读完整分区,验证混合判断及失败/冲突;在可工作的动作路径内整理共享帧手势能力供 11 复用。 + +## Implementation update — 2026-09-21 + +- [x] 本票代码实现、本地提交与独立审查已完成,包含于最终代码 `ad8756e7`;本次未推送。 +- 核心公司验收候选:`5247c69e`;后续 `d363a791` 完成追加验收;最终 `ad8756e7` 修复同任务恢复轮询并完成 API/processor rollout、健康及公司回归。 +- 已执行证据:C/E:微调、长按失焦停止、缩零/吞并撤销、一手势一邻段、末段终点固定;F存活状态规则。 +- 最终验收依据:C/E单步/长按、缩零与一邻段吞并撤销、终点固定、聚焦停重复;J鼠标共同边界一撤销;I判断继承及撤销;F非均匀帧与存活判断。精确1000ms/500ms常量和取消入口由独立审查支持,未声称浏览器测量每次定时抖动。 +- 验收边界:检查项采用真实公司行为、约定纯函数/公开接口与独立审查共同支持;不意味着每个异常组合都在公司反复注入。未发现本票约定功能未满足。 + +## Answer + +本票实现与分层验收完成,状态 resolved。 + +详见[执行报告](../../../docs/verification/continuous-actions-20260921.md)与[逐项验收矩阵](../../../docs/verification/continuous-actions-20260921-matrix.md)。证据缩写沿用矩阵。 diff --git a/.scratch/annotation-contiguous-actions/issues/11-slice-boundary.md b/.scratch/annotation-contiguous-actions/issues/11-slice-boundary.md new file mode 100644 index 00000000..fbac92ed --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/11-slice-boundary.md @@ -0,0 +1,31 @@ +# 11: 切片结束边界微调与舍弃保护 + +Status: resolved +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 把已验收的帧微调与合并手势用于切片阶段,保留存活片名称和舍弃证据。 + +**Blocked by:** 10 动作结束边界微调与可撤销合并 + +**规格验收:** A21、A23、A24、A25;用户故事重点:73–75。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [x] Shift+左右仅在切片阶段调整切片,标注阶段不能修改已生成切片边界。 +- [x] 复用 10 的加速、到界停止、失焦取消和一手势一撤销;鼠标不缩零,首尾与完整覆盖不丢失。 +- [x] 合并保留存活切片名称,不拼名;已舍弃片及相关共享边界先恢复才允许改动。 +- [x] 通过浏览器确认切片并公开回读验证新边界;恢复舍弃后历史和媒体审核证据保留。 + +## Implementation update — 2026-09-21 + +- [x] 本票代码实现、本地提交与独立审查已完成,包含于最终代码 `ad8756e7`;本次未推送。 +- 核心公司验收候选:`5247c69e`;后续 `d363a791` 完成追加验收;最终 `ad8756e7` 修复同任务恢复轮询并完成 API/processor rollout、健康及公司回归。 +- 已执行证据:R/F:共享帧边界、存活名称与舍弃边界保护;P/B:真实切片生成和回读。 +- 最终验收依据:I切片合并保留存活名称并一手势撤销;J切片鼠标共同边界;P/B真实切片确认处理回读,G/D舍弃历史恢复;R舍弃片及相邻边界保护、阶段守卫。 +- 验收边界:检查项采用真实公司行为、约定纯函数/公开接口与独立审查共同支持;不意味着每个异常组合都在公司反复注入。未发现本票约定功能未满足。 + +## Answer + +本票实现与分层验收完成,状态 resolved。 + +详见[执行报告](../../../docs/verification/continuous-actions-20260921.md)与[逐项验收矩阵](../../../docs/verification/continuous-actions-20260921-matrix.md)。证据缩写沿用矩阵。 diff --git a/.scratch/annotation-contiguous-actions/issues/12-coverage-gate.md b/.scratch/annotation-contiguous-actions/issues/12-coverage-gate.md new file mode 100644 index 00000000..371bcbd3 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/12-coverage-gate.md @@ -0,0 +1,32 @@ +# 12: 完整动作覆盖才可送检 + +Status: resolved +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 已描述或明确无效的动作完整覆盖后才允许正式送检,同时保留舍弃、旧结果和范围外规则。 + +**Blocked by:** 07 所选动作无效判断与保存后撤销 + +**规格验收:** A29、A30、A31、A28;用户故事重点:46–51。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [x] 界面、直接/旧客户端请求、异步完整生成和复用媒体更新路径都拒绝待标注、缺段、重叠、越界及非法帧。 +- [x] 普通保存进度仍允许未完成,不能将草稿校验错误提升成必须完成才可保存。 +- [x] 正常完整描述、含无效、混合舍弃和全部舍弃均走真实送检,审核证据及原因快照保持。 +- [x] 历史可编辑/退回按新规则;已送检/验收不追改,其他流程保留旧政策;舍弃恢复后的空白重新待标注。 +- [x] 从真实工作台完成并回读质检状态,补充绕过界面和两种后台产物路径的接口证据。 + +## Implementation update — 2026-09-21 + +- [x] 本票代码实现、本地提交与独立审查已完成,包含于最终代码 `ad8756e7`;本次未推送。 +- 核心公司验收候选:`5247c69e`;后续 `d363a791` 完成追加验收;最终 `ad8756e7` 修复同任务恢复轮询并完成 API/processor rollout、健康及公司回归。 +- 已执行证据:H:完整门禁、保存pending、旧客户端不能绕过、已送检只读;B/S真实送检质检回读;Q范围隔离。 +- 补充契约:`annotation_contiguous_acceptance_test.go` 已验证 generate/reuse 两路径 overlap/outside/zero/end-gap 均400且不预留/推进,以及 mixed/all-discarded 经真实公开舍弃接口后送检201、质检状态与快照保留。H覆盖pending/旧客户端及历史只读,Q范围外策略,T真实退回公共池。 +- 公司最终补充:X task03全舍弃经过真实切片202→processor完成→combined202到质检;主代理核对mixed task02也由唯一送检POST实际进入quality_review。混合任务的丢响应/暂停恢复归16验收,不影响本票覆盖门禁事实。 + +## Answer + +前后端完整覆盖门禁、正常保存pending、旧接口拒绝绕过、两种产物路径拒绝非法分区、混合/全舍弃真实质检与证据保留均已验收,本票 resolved。 + +详见[执行报告](../../../docs/verification/continuous-actions-20260921.md)与[逐项验收矩阵](../../../docs/verification/continuous-actions-20260921-matrix.md)。证据缩写沿用矩阵。 diff --git a/.scratch/annotation-contiguous-actions/issues/13-task-capacity.md b/.scratch/annotation-contiguous-actions/issues/13-task-capacity.md new file mode 100644 index 00000000..86a7bdd5 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/13-task-capacity.md @@ -0,0 +1,32 @@ +# 13: 个人容量设置与统一领取上限 + +Status: resolved +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 按账号+项目保存默认 2、可设 2–8 的容量,所有手动和自动随机领取都不能绕过它。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A32、A34、A35、A36、A42;用户故事重点:86–89、101。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [x] 界面可配置并回读容量,拒绝非法值;可信流程范围和账号项目隔离有效。 +- [x] 待切、生成中、待标注、送检中和失败占位,真正交质检才释放;不能直接使用我的任务列表长度。 +- [x] 降低容量保留已有任务,不释放或隐藏;等于/超过上限不新领。 +- [x] 服务端原子处理并发容量、归属与幂等回执;重放原成功领取不再占位,也不能因满容量丢失核对。 +- [x] 浏览器手动领取与并发公开请求验证跨页/跨浏览器、权限变化及公共池不足,不新增自动补齐行为。 + +## Implementation update — 2026-09-21 + +- [x] 本票代码实现、本地提交与独立审查已完成,包含于最终代码 `ad8756e7`;本次未推送。 +- 核心公司验收候选:`5247c69e`;后续 `d363a791` 完成追加验收;最终 `ad8756e7` 修复同任务恢复轮询并完成 API/processor rollout、健康及公司回归。 +- 已执行证据:Q/M:容量设置、降容超额、并发原子占位、满池与交接后回执;B/S状态占位;E暂停8→2。 +- 补充验收:`annotation_work_buffer_lifecycle_test.go` 公共 HTTP 验证 slice/submit 的 queued/running/failed/completed 都继续占位,实际进入质检才可补领;空公共池不占名额;两账号/两项目设置及占位隔离;供应商失效后 GET/PUT/领取均403。定向六项容量测试重跑 `ok 0.486s`,日志 `buffer-lifecycle.log`。 +- 验收判断:UI 设置由 E/L 公司浏览器、真实占位由 B/S、跨页面原子容量由独立 handler/store 的 Mongo 并发测试 M 验证;权限与空池由上述公开 HTTP 补充,覆盖本票约定能力,无需穷举浏览器种类。无已知未满足需求。 + +## Answer + +容量 2–8、作用域隔离、所有未交质检状态占位、降容保留、并发原子领取和满池回执均已实现并有行为证据;本票完成。 + +详见[执行报告](../../../docs/verification/continuous-actions-20260921.md)与[逐项验收矩阵](../../../docs/verification/continuous-actions-20260921-matrix.md)。证据缩写沿用矩阵。 diff --git a/.scratch/annotation-contiguous-actions/issues/14-buffer-start-pause.md b/.scratch/annotation-contiguous-actions/issues/14-buffer-start-pause.md new file mode 100644 index 00000000..9a10524d --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/14-buffer-start-pause.md @@ -0,0 +1,32 @@ +# 14: 开始补齐与立即暂停连续工作 + +Status: resolved +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 从已确定的工作入口显式开始/继续时补满容量;暂停、返回、刷新后停止自动领取。 + +**Blocked by:** 02 默认项目与统一专注工作入口;13 个人容量设置与统一领取上限 + +**规格验收:** A33、A36、A41、A42、A07;用户故事重点:90、99–100、102。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [x] 开始/继续按当前账号项目补齐可用容量,公共池不足只领实际数量;增大容量只在激活状态补齐。 +- [x] 立即暂停取代完成后停止,保留当前编辑及已发后台任务,不主动释放已领取任务。 +- [x] 返回、关闭、刷新后需明确继续;已发领取响应核对并保留归属,但不能再补领或抢占导航。 +- [x] 保留同浏览器互斥和 HTTP 手动模式限制;窗口/身份/权限变化和迟到响应不绕过控制。 +- [x] 独立演示开始补齐→暂停→返回/刷新→明确继续,并用接口回读及请求记录验证。 + +## Implementation update — 2026-09-21 + +- [x] 实现、本地提交与独立审查完成,最终运行代码 `ad8756e7`;公司 API/processor rollout、health/ready/公网无认证健康核对通过,未推送 Git。 +- 最终 AA:`unknown-submission-result.json` passed=true。真实 mixed task02 combined POST 总计1次,202响应被主动中断;暂停后领取0,回读进入quality_review/pending_quality,原因快照版本1及无效动作保留。 +- 恢复专项发现并修复真实缺陷:旧d363同任务继续后旧location来源使轮询失效,15秒occupied1不补领为RED。ad875新增location.key依赖并保留latefence;`resume-green/buffer-resume-result.json`实际占位1→2、恰好领取1次、无送检,08演示任务仍pending_annotation。 +- 新版迟到响应复测通过:真实buffer响应延迟到暂停后释放,不导航、不恢复连续、不领取。Y真实生成失败保留名额、其他任务可编辑、UI重试真正完成;Z公开契约覆盖送检失败/CAS预留/重载/幂等恢复;T退回公共池,Q/M统一容量与回执;P/C/E/G/I/J/L提供两阶段布局、51动作及完整作业证据。 +- 按公司关键路径+公开HTTP/Mongo契约+约定纯函数与独立审查分工完成;不将每种账号、窗口及网络排列都称为已跑公司浏览器。精确边界见报告与矩阵。 + +## Answer + +本票最小必要专项已完成,状态 resolved。最终验证包括真实处理、失败恢复、送检丢响应与暂停后明确恢复补位,不仅是部署成功。 + +详见[执行报告](../../../docs/verification/continuous-actions-20260921.md)与[逐项验收矩阵](../../../docs/verification/continuous-actions-20260921-matrix.md)。 diff --git a/.scratch/annotation-contiguous-actions/issues/15-background-handoff.md b/.scratch/annotation-contiguous-actions/issues/15-background-handoff.md new file mode 100644 index 00000000..67369c4c --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/15-background-handoff.md @@ -0,0 +1,32 @@ +# 15: 后台切片期间接续其他任务 + +Status: resolved +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 切片后台任务被确定受理后自动打开另一条可工作任务,生成完成不打断当前编辑。 + +**Blocked by:** 14 开始补齐与立即暂停连续工作 + +**规格验收:** A37、A38、A41、A42;用户故事重点:91–96。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [x] 仅确定受理后切走,未知请求核对原请求;开始生成仍截断该切片阶段撤销。 +- [x] 优先已生成待标注,再待切片,同类先领先做;明确续做所选任务不被队列优先级覆盖。 +- [x] 处理中算占位但不进入编辑;满池都在处理则等待,不超额领取、不暴露候选视频。 +- [x] 跟踪缓冲内后台状态,不只跟踪屏幕任务;生成就绪不抢当前编辑,生成失败明显提示、占位、可重试并允许做其他任务。 +- [x] 用真实受理/完成与故障注入证明跨任务接续、原任务可恢复、暂停和迟到结果不触发错误切换。 + +## Implementation update — 2026-09-21 + +- [x] 本票代码实现、本地提交与独立审查已完成,包含于最终代码 `ad8756e7`;本次未推送。 +- 核心公司验收候选:`5247c69e`;后续 `d363a791` 完成追加验收;最终 `ad8756e7` 修复同任务恢复轮询并完成 API/processor rollout、健康及公司回归。 +- 已执行证据:P切片202后接续;B真实后台生成;S待标注优先;Q回执恢复;R手动选择不被抢。 +- 最终补充验收:公司 `generation-failure-recovery-result.json`:仅隔离02视频副本后半负载暂时损坏以制造处理故障(finally恢复原副本),202后后台failed;UI显示错误与现有重试入口,08仍可编辑且取消临时文字;失败任务占位2、不领取新任务;02通过UI重试后真实processor completed。结合P后台受理后接续、S优先级、W迟到暂停及Q回执恢复,失败不阻断链路完成。 +- 本票最小必要专项已执行;未声称所有故障排列均已注入。 + +## Answer + +实现、独立审查与分层验收完成,状态 resolved。 + +详见[执行报告](../../../docs/verification/continuous-actions-20260921.md)与[逐项验收矩阵](../../../docs/verification/continuous-actions-20260921-matrix.md)。证据缩写沿用矩阵。 diff --git a/.scratch/annotation-contiguous-actions/issues/16-submission-refill.md b/.scratch/annotation-contiguous-actions/issues/16-submission-refill.md new file mode 100644 index 00000000..5edfdee0 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/16-submission-refill.md @@ -0,0 +1,32 @@ +# 16: 送检成功补位与连续作业恢复 + +Status: resolved +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 只有实际送检成功才补一个名额;送检失败、未知结果和审核退回都能持续正确处理。 + +**Blocked by:** 15 后台切片期间接续其他任务 + +**规格验收:** A39、A40、A41、A42、A34;用户故事重点:95–98、102。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [x] 送检受理和真实成功分开,处理中继续占位,真成功且连续激活才补领。 +- [x] 送检失败保留任务并可重试,不阻断其他可做任务;未知结果核对原请求,不重复送检或补领。 +- [x] 质检及后续审核按现规则退回公共池,不自动归原人;重新随机领取受共同容量限制。 +- [x] 暂停/返回/刷新、请求迟到、调小容量和权限变化交错时,不错腾位、不后台偷领、不丢归属。 +- [x] 端到端执行提交→后台结果→质检回读→补位,另执行失败恢复及退回重新领取;本票复用既有送检边界,12 独立负责新的完整覆盖政策。 + +## Implementation update — 2026-09-21 + +- [x] 实现、本地提交与独立审查完成,最终运行代码 `ad8756e7`;公司 API/processor rollout、health/ready/公网无认证健康核对通过,未推送 Git。 +- 最终 AA:`unknown-submission-result.json` passed=true。真实 mixed task02 combined POST 总计1次,202响应被主动中断;暂停后领取0,回读进入quality_review/pending_quality,原因快照版本1及无效动作保留。 +- 恢复专项发现并修复真实缺陷:旧d363同任务继续后旧location来源使轮询失效,15秒occupied1不补领为RED。ad875新增location.key依赖并保留latefence;`resume-green/buffer-resume-result.json`实际占位1→2、恰好领取1次、无送检,08演示任务仍pending_annotation。 +- 新版迟到响应复测通过:真实buffer响应延迟到暂停后释放,不导航、不恢复连续、不领取。Y真实生成失败保留名额、其他任务可编辑、UI重试真正完成;Z公开契约覆盖送检失败/CAS预留/重载/幂等恢复;T退回公共池,Q/M统一容量与回执;P/C/E/G/I/J/L提供两阶段布局、51动作及完整作业证据。 +- 按公司关键路径+公开HTTP/Mongo契约+约定纯函数与独立审查分工完成;不将每种账号、窗口及网络排列都称为已跑公司浏览器。精确边界见报告与矩阵。 + +## Answer + +本票最小必要专项已完成,状态 resolved。最终验证包括真实处理、失败恢复、送检丢响应与暂停后明确恢复补位,不仅是部署成功。 + +详见[执行报告](../../../docs/verification/continuous-actions-20260921.md)与[逐项验收矩阵](../../../docs/verification/continuous-actions-20260921-matrix.md)。 diff --git a/.scratch/annotation-contiguous-actions/issues/17-compact-integration.md b/.scratch/annotation-contiguous-actions/issues/17-compact-integration.md new file mode 100644 index 00000000..de085376 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/17-compact-integration.md @@ -0,0 +1,33 @@ +# 17: 1413×615 完整工作页与集成验收 + +Status: resolved +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 把全部已交付能力放入既有风格的最低尺寸工作页,验证两阶段三视图及完整连续作业。 + +**Blocked by:** 01 视频点击播放与进度条焦点恢复;03 相机默认偏好与单路完整时间轴;04 G 舍弃字典与明确确认恢复;08 密集动作列表与循环键盘导航;09 视频动作摘要与 JSON 编辑预览;11 切片结束边界微调与舍弃保护;12 完整动作覆盖才可送检;16 送检成功补位与连续作业恢复 + +**规格验收:** A01、A02、A03、A43;用户故事重点:1–6、16–17、28、103–104。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [x] 标题/状态局部移右,动作列表窄区放左;视频完整等比,切片一轴、标注两轴,核心编辑保存提交不用整页滚动。 +- [x] 在 1413×615 与更大/缩放窗口验证三相机、两阶段、50+动作、JSON、字典、长任务名/说明及失败提示,不能把操作挤出窗口。 +- [x] 不足尺寸暂停播放、长按与自动行为,已发请求继续核对;恢复尺寸须手动继续,任务草稿与撤销保留。 +- [x] 两阶段快捷键帮助与真实行为一致,普通工作台共享行为不回归;旧 Space、逐帧、B/V、切片导航、撤销边界验证。 +- [x] 使用真实双目及公开 API 回读走完连续切分→描述/无效→完整送检→后台接续→补位/暂停,复核所有 A01–A43。 +- [x] 每票此前已有自己的测试,本票补组合与真实完整流程证据、实际运行范围及残余限制;不自动推送/部署。 + +## Implementation update — 2026-09-21 + +- [x] 实现、本地提交与独立审查完成,最终运行代码 `ad8756e7`;公司 API/processor rollout、health/ready/公网无认证健康核对通过,未推送 Git。 +- 最终 AA:`unknown-submission-result.json` passed=true。真实 mixed task02 combined POST 总计1次,202响应被主动中断;暂停后领取0,回读进入quality_review/pending_quality,原因快照版本1及无效动作保留。 +- 恢复专项发现并修复真实缺陷:旧d363同任务继续后旧location来源使轮询失效,15秒occupied1不补领为RED。ad875新增location.key依赖并保留latefence;`resume-green/buffer-resume-result.json`实际占位1→2、恰好领取1次、无送检,08演示任务仍pending_annotation。 +- 新版迟到响应复测通过:真实buffer响应延迟到暂停后释放,不导航、不恢复连续、不领取。Y真实生成失败保留名额、其他任务可编辑、UI重试真正完成;Z公开契约覆盖送检失败/CAS预留/重载/幂等恢复;T退回公共池,Q/M统一容量与回执;P/C/E/G/I/J/L提供两阶段布局、51动作及完整作业证据。 +- 按公司关键路径+公开HTTP/Mongo契约+约定纯函数与独立审查分工完成;不将每种账号、窗口及网络排列都称为已跑公司浏览器。精确边界见报告与矩阵。 + +## Answer + +本票最小必要专项已完成,状态 resolved。最终验证包括真实处理、失败恢复、送检丢响应与暂停后明确恢复补位,不仅是部署成功。 + +详见[执行报告](../../../docs/verification/continuous-actions-20260921.md)与[逐项验收矩阵](../../../docs/verification/continuous-actions-20260921-matrix.md)。 diff --git a/.scratch/annotation-contiguous-actions/map.md b/.scratch/annotation-contiguous-actions/map.md new file mode 100644 index 00000000..361b9c1c --- /dev/null +++ b/.scratch/annotation-contiguous-actions/map.md @@ -0,0 +1,153 @@ +# 连续动作标注与摄像机工作视图:设计讨论 + +Type: grilling + +日期:2026-09-18,2026-09-21 更新。状态:原业务与快捷键选择作为基线;九项追加需求已完成 Q16–Q32 的逐项裁决,合并规则见[追加讨论](./supplement-20260921.md)。已发布[正式规格](./spec.md),状态为 `ready-for-agent`。保留现有页面风格,以局部排版调整承载新能力;此前独立布局示意仍撤回。以上为实施前讨论基线;2026-09-21 已完成本轮实现与公司部署,最终状态见下方“实施与验收”及执行报告。 + +## Notes + +本轮依据用户转述的客户新要求、当前源码和仓库内既有规格核验;未直接读取客户原始需求文档。最初产品代码基线为 `ab6e3b15`,此前随机领取后工作页入口的修复已部署,仍为本地提交。按 Q9 要求已拉取 `origin/dev` 到 `883f47ff`,确认 PR #1 已合并;详见[上游核验](./upstream-invalid-audit.md)。2026-09-20 本地已通过 `587cc9d1` 合并该上游。2026-09-21 再次 fetch 后 `dev` 未变,但查全部远端分支发现同事的 `feature/discard-reason-dictionary=6072116e`,包含项目成员显示、舍弃原因字典、恢复时保留历史三个提交。完成 Q16–Q32 后,按用户明确要求将该分支无冲突合入本地 `09bb9b41`,保留工作入口修复及设计文档;基础检查与影响分析见[合并记录](./supplement-20260921.md#本地代码合并与需求影响)。不能将“dev 无更新”扩大解释为“同事没有新代码”。 + +### 用户已明确要求 + +- 以已有工作台版本为基础微调,保留现有界面结构、区域位置、视觉样式和工作习惯,不按独立示意重新排版;以下已确认的功能变化仍成立。 +- 点击视频画面可以播放或暂停。 +- 进入专注模式默认放大左摄像机,最好允许自定义默认视图。 +- 放大左或右摄像机时保留当前阶段所需时间轴:切片阶段只有 Capture 切片时间轴;动作标注阶段才同时显示 Capture 切片时间轴和片内动作时间轴。 +- 切片内的动作标注改为首尾相接的连续区间,每段都需要描述或明确标记为无效。 +- 去除 N 快捷键,沿用 C 切分动作区间。 +- Ctrl+X 改为将明确选中的动作区间标为无效;目标与内容恢复按 Q3 确认,Q10 确认直接保存、可撤销。 +- 所有需要标注的切片、动作区间完成后才能提交,明确无效也计为已处理。 +- 其他操作保持既有行为;动作删除按重新确认的 Q9 取消,边界编辑按 Q15 保持两侧联动。 + +### 核验出的规则变化 + +1. 变更前的领域词汇和[人工闭环五项规则](../../docs/annotation-five-rules.md)允许部分或全部语义留空;[旧键盘规格](../annotation-keyboard-workflow/spec.md)要求删除动作后留下空白、Ctrl+X 批量标记整片空白无效。本轮要求改变这些业务含义,不只是把时间轴块画得更紧。当前[领域词汇](../../CONTEXT.md)已开始记录用户确认的目标模型。 +2. 当前 `src/pages/AnnotationOperations.tsx` 的 `submissionCheck` 检查已添加描述合法性与切片覆盖,允许没有动作描述的时间范围。完整动作覆盖需要前后端一致的送检约束,不能只禁用界面按钮。 +3. [旧工作页规格](../annotation-workspace-layout/spec.md)明确在单路放大时将详细时间轴收成进度条,以换取 1280×640 内容区下至少 490×398 的单路有效画面。`src/styles/capture-workspace.css` 的单路检查样式确实隐藏了详细切片与动作时间轴;本轮明确替代这一隐藏规则,原尺寸下限需要重新评估。 +4. `src/components/CaptureAnnotationWorkbench.tsx` 已有同步播放控制,但视频元素本身没有点击播放绑定。单路检查选择只存在当前组件状态,切换任务/阶段会复原;没有摄像机默认视图的持久偏好。现有布局偏好按当前账号和浏览器保存,可供设计参考。 +5. [ADR-0001](../../docs/adr/0001-annotation-undo-stage-boundary.md)的当前任务、当前编辑阶段撤销边界继续适用。本轮尚未提出恢复跨任务或跨送检阶段的历史。 + +## Decisions-so-far + +以下 Q1–Q15 为此前确认的基线。9 月 21 日新增的 1413×615 目标、Ctrl+上下跳六段、零长度合并、后台切片期间切换任务、移除布局切换按钮及新增动作列表,需要按[追加讨论](./supplement-20260921.md)处理明确替代和剩余裁决,不能机械沿用冲突的旧条目。 + +- Q1 已确认:独立的左/右/双目默认视图,首次默认左路,按账号和浏览器记住;临时切换不覆盖默认,切片和标注共用设置,三种视图都保留当前阶段所需时间轴与编辑操作。 +- Q2 已确认:每个保留切片先有一整段待标注,C 在播放头分割所在区间;全部区间首尾相接、无重叠,每段保存描述或明确标无效后才完成。 +- Q3 已确认:Ctrl+X 只作用于明确选中的动作区间,可替换已有描述、一次撤销恢复原内容;没有明确选中目标时不操作,文本输入保持原生剪切。播放头不改变此命令的目标。 +- Q4 已确认:新任务和仍在编辑的任务执行完整标注要求,已有描述保留、空白补成待标注;已送检和已验收数据不追溯修改,退回后再按新规则提交;明确舍弃的切片仍以原因及证据处理,无须填写动作。 +- Q5 已确认:新规则用于当前泛宇客户人工切片/标注流程下的全部项目;其他客户或其他工作流保留原规则。范围内存量任务按 Q4 处理。 +- Q6 已确认:允许提高专注模式的最小窗口尺寸,以保留可用的视频尺寸和完整时间轴;不采用以压缩画面满足旧 1280×640 底线的建议。2026-09-19 补充:必须基于现有界面的局部调整核算尺寸,不能借提高底线重排界面;具体宽高尚未最终确认,当前产品底线未修改。 +- Q7 已确认:C 在播放头切分并暂停于切点,选中刚看完的左段,不自动进入文本输入;允许继续播放或连续切分后再逐段填写。 +- Q8 已确认:重新拆分已标好的动作时,左段保留原描述或无效判断,右段恢复待标注,不自动把两段都计为完成。 +- Q9 原建议撤回并重新确认:无效动作保留为动作标注结果,不自动清空、删除或过滤媒体;动作标注阶段取消删除按钮和删除快捷键,通过修改、改判和撤销纠错,误切用撤销。切片层面的删除与独立舍弃规则保留。 +- Q10 已确认:Ctrl+X 与鼠标“设为无效”直接保存所选区间判断,可撤销;服务端成功后才计为完成,失败保留编辑。存在未保存文字时先要求保存或取消,输入框内仍是原生剪切。 +- Q11 历史选择:曾选择 **1440×900 CSS 像素浏览器内容区**制作候选示意。2026-09-19 用户要求沿用现有版本微调,该独立示意撤回;其尺寸和控件排布不作为实施约束,也不能据此直接将产品底线改为 1440×900。 +- Q12 已确认:首次进入专注模式和每条新任务采用默认摄像机;同一任务内切片转标注、切换布局保留临时选择。修改默认设置作用于下次进入或新任务,当前视图可直接切换。 +- Q13 已确认:增加“保存进度”,持久保留动作分区及待标注状态,刷新可恢复;待标注不能送检。“保存描述 / Ctrl+Enter”仍确认当前描述。 +- Q14 已确认:有未保存文字修改时,切分或切换动作先要求保存/取消;仅选中但未改字时允许连续 C 和上下导航,不能被空白编辑框锁死。 +- Q15 已确认:拖动共同边界时两侧联动、每段至少一帧、保持连续,描述保留;整个拖动为一次可撤销修改,切片首尾固定。 +- 2026-09-19 视觉纠正:切片阶段只显示一条切片时间轴,不显示动作时间轴,也不为其留下空行;腾出的空间用于视频。标注阶段保持两条时间轴。此前示意误将两阶段都画成两条,已修正;这不代表用户已接受其余视觉设计。 +- 2026-09-19 最终视觉方向纠正:回到现有产品界面做小幅调整,取消独立示意的结构重排。此反馈改变呈现方案,不撤销已确认的连续动作分区、无效保留、保存进度、撤销与快捷键规则。 +- 已按 Q2 将“动作区间”“待标注区间”写入 [领域词汇](../../CONTEXT.md),并按 Q2/Q4/Q5 记录 [ADR-0002](../../docs/adr/0002-contiguous-action-coverage.md)。这些是已确认的目标规则,尚未实现。 +- 已确认的是目标设计;旧规格中的历史规则不直接改写为已实施的新行为。 + +### 实施与验收 — 2026-09-21 + +保留以上裁决及历史调查原文,不把当时的“尚未实现”理解为最终产品状态。17 张任务票的功能已实现并本地提交;公司 poc 最终已部署 `ad8756e7`,API 与 annotation processor rollout、health/ready 均成功。验收采用真实双目公司浏览器、公开 HTTP 保存回读、真实 Mongo 并发与约定纯函数测试,以及独立 Standards/Spec 审查共同支撑。 + +- [实施报告](../../docs/verification/continuous-actions-20260921.md)、[A01–A43 证据矩阵](../../docs/verification/continuous-actions-20260921-matrix.md)记录实际运行与限制,不把全部组合都称为公司动态测试通过。 +- 任务票:[01 视频焦点](issues/01-video-focus.md)、[02 工作入口](issues/02-work-entry.md)、[03 相机默认](issues/03-camera-default.md)、[04 舍弃字典](issues/04-discard-dictionary.md)、[05 保存进度](issues/05-action-progress.md)、[06 连续切分](issues/06-action-splitting.md)、[07 无效动作](issues/07-action-invalid.md)、[08 动作列表](issues/08-action-list.md)、[09 JSON预览](issues/09-action-preview.md)、[10 动作边界](issues/10-action-boundary.md)、[11 切片边界](issues/11-slice-boundary.md)、[12 覆盖门禁](issues/12-coverage-gate.md)、[13 容量](issues/13-task-capacity.md)、[14 开始暂停](issues/14-buffer-start-pause.md)、[15 后台接续](issues/15-background-handoff.md)、[16 送检补位](issues/16-submission-refill.md)、[17 集成验收](issues/17-compact-integration.md)。17票均已resolved,证据与限制见各票及报告;最后同任务恢复轮询缺陷已在ad875修复,并有旧RED/新GREEN与真实丢响应恢复验收。 +- 本轮未推送 Git;隔离验收副本及回滚配置留在忽略目录,未修改客户原视频或 BOS 对象。原有测试债务与大视频性能验收限制在报告中明确保留。 + +## 当前界面调整边界 + +2026-09-21 补充:用户明确允许将工作页标题/连续状态/任务标识移至右侧,并要求左侧动作列表;这是对下述“不移动现有区域”的局部例外。仍保持现有风格,不恢复已撤回的独立布局示意。 + +实施基于现有 `AnnotationOperations`、`CaptureAnnotationWorkbench` 和工作页样式,保留专注/原布局的已有骨架与切换方式,不另建一套工作台。 + +| 现有区域 | 保留内容 | 本轮局部变化 | +| --- | --- | --- | +| 视频与播放控制 | 原容器、区域位置、画面比例和同步播放控制 | 画面点击播放/暂停;默认左路和紧凑的默认视图设置;单路查看不再隐藏本阶段时间轴 | +| 切片与动作时间轴 | 原来的上下位置、播放进度及帧对齐方式 | 切片阶段一条、标注阶段两条;动作块连续无空白,显示待标注/描述/无效;必要时局部调整高度与间距 | +| 切片命名、动作编辑与字典 | 原编辑区、字典入口及返回方式,已有表单组织和样式 | 配合完整动作分区;取消 N 和动作删除入口,其余已确认快捷键沿用 | +| 保存与提交 | 原有按钮区域、确认方式和状态提示位置 | 在已有操作区补充保存进度;Ctrl+X 直接保存当前无效判断;完整处理后才可送检 | + +不把表单改成示意中的大块文本区域,不迁移既有保存/提交按钮到新页脚,不重新组织顶部栏、侧栏或整页栅格。新默认视图设置与保存进度以邻近原入口的小控件补充;具体尺寸依据旧结构调整后的实际空间确定。 + +## 设计树与第一轮 + +### 视图与播放 + +- 已定:画面点击播放/暂停;默认左路;单路查看保留当前阶段时间轴(切片一条、标注两条)。 +- **Q1 已答:默认偏好。** 接受推荐,见 Decisions-so-far。 +- 按 Q6 在现有布局上评估是否及如何提高底线;Q11 的独立示意已撤回。默认应用时点按 Q12。点击任一可见视频沿用同一双路同步播放动作,保留已有播放范围和暂停限制;控件点击不重复触发画面播放。 + +### 连续动作区间 + +- 已定:动作首尾相接,N 改为 C,完整处理后方可送检。 +- **Q2 已答:初始分区。** 接受推荐,见 Decisions-so-far。 +- 切分目标与继承按 Q7/Q8;删除按 Q9 取消,保存进度、文字保护与共同边界分别按 Q13–Q15。 +- **Q3 已答:无效标记目标。** 接受推荐,见 Decisions-so-far。 + +### 提交与历史兼容 + +- 已定:需要标注的部分必须全部完成,不把空白自动当无效。 +- **Q4 已答:历史适用范围。** 接受推荐,见 Decisions-so-far。 +- 适用范围按 Q5,并记录 ADR-0002;保存未完成进度与完整送检分离。正式规格需落实前后端一致、旧客户端校验、范围识别与可回退方案。 + +## 第二轮与后续澄清记录 + +第一轮已答复后,根据源码调查展开的新问题。保留原始选项用于追溯,实际选择见最后一列;未回答的问题不视为接受推荐。 + +| 问题 | 推荐 | 另一选择 | 用户选择 | +| --- | --- | --- | --- | +| Q5 项目/流程范围 | 当前泛宇客户人工切片/标注流程下全部项目;其他客户或流程保持原规则 | 仅当前 SL-data 项目,或整个平台全部人工标注流程 | 推荐 | +| Q6 小屏空间 | 时间轴、编辑和保存提交常驻;视频按剩余空间完整等比显示,不再以隐藏时间轴满足旧单路画面尺寸 | 提高最小内容区要求 | 提高最小窗口尺寸 | +| Q7 C 后选中段 | 暂停在切点,选中刚看完的左段;不自动进入文本输入,允许继续播放和连续切分后再填 | 沿用选中右段 | 推荐 | +| Q8 拆已完成动作 | 左段保留原描述或无效判断,右段待标注 | 两段继承原内容并都计完成 | 推荐 | +| Q9 删除动作 | 原推荐清空内容已撤回 | 核验最新上游后重新讨论是否取消动作删除 | 已选择取消动作删除,保留修改/改判/撤销 | +| Q10 无效保存 | Ctrl+X 与鼠标按钮均直接保存所选区间的无效判断;一次可撤销,成功后才完成,未保存文字先要求处理 | 仅改草稿,再 Ctrl+Enter 保存 | 推荐 | + +后续 Q11–Q15 已分别确认候选尺寸、默认视图时点、保存进度、未保存文字保护及共同边界,见 Decisions-so-far。送检继续要求所有需要标注的区间已确认描述或无效判断;保存失败、冲突和结果未知沿用现有保护,不伪报完成。2026-09-21 Q22/Q30 替代旧导航细节:Ctrl+上下循环跨六段,Alt+上下定位起止,结束导航停目标最后可编辑帧;输入法隔离继续保留。 + +### Q6 后续事实调查:最小内容区候选 + +以下保留最初只读 CSS 核算;当时建议 **1280×800 CSS 像素浏览器内容区**作为视觉候选。用户后续在 Q11 明确选择更大的 **1440×900**,因此下表不是最终选定的底线。 + +按当前布局恢复完整时间轴,标注阶段的非画面高度约为:外层上下内边距 24 + 工作页标题 36 + 间距 4 + 任务标题 26 + 间距 4 + 相机切换行 22 + 播放控制 64 + 两时间轴底部区域 164 = 344 像素。因此画面可用高度约为内容区高度减 344;左侧总宽约为内容区宽度减去外边距 24、右侧编辑 350、分栏间距 8。 + +依据 `src/components/Layout.tsx` 的 `p-3` 和 `src/styles/capture-workspace.css` 的专注布局、标注阶段行高,以既有 590×480 素材比例估算: + +| 内容区候选 | 单路有效画面 | 双路每路有效画面 | 相对旧画面下限 | +| --- | --- | --- | --- | +| 1280×720 | 约 462×376 | 约 449×365 | 单路不足 490×398 | +| 1280×800 | 约 561×456 | 约 449×365 | 单路和双路都有余量 | +| 1440×800 | 约 561×456 | 约 529×430 | 双路更大,单路仍受高度限制 | + +上述计算假设取消单路视图当前隐藏时间轴和跨行扩张的样式,并保持既有其他行高。新增默认视图设置、提示或文字换行可能改变结果,正式确定底线前需在现有布局的局部调整方案中检查两阶段、左/右/双目、字典、长文字及错误提示的实际控件边界。800 是浏览器内容区高度,不是显示器标称高度;不能据此宣称 1366×768 显示器仍满足完整专注布局。 + +## 1440×900 交互示意(已撤回,仅保留讨论历史) + +用户于 2026-09-19 明确要求“按照之前的版本微调,不要有界面结构的大改”。因此本示意不再作为实现或验收依据,下面的尺寸与检查记录仅说明当时的探索,不授权将其结构复制进产品。 + +示意曾在本会话中呈现,使用 59:48 的占位画面和两条样例切片;不连接业务 API、不加载或保存真实任务。源码位于本线程可视化目录的 `continuous-action-workspace.html`,没有加入产品路由或构建。 + +- 初版在 1440×900、1920×1080、2560×1440 三档内容区,两阶段与三种摄像机视图,共 18 种状态检查未发现控件越界或页面脚本异常;该检查未发现切片阶段误显示第二条时间轴的问题,不作为阶段语义正确的证据。 +- 1440×900 的**标注阶段**示意中,单路有效画面约 **585×476**,双路各约 **518×421**;两条时间轴、编辑、保存描述、保存进度和送检均可见。这里只验证示意,不代表现有产品已达标。 +- 2026-09-19 修正后,在 1440×900 两阶段、三种摄像机视图共 6 个组合中确认切片只显示一条、标注显示两条时间轴,没有控件越界或页面脚本异常。切片单路画面增至约 **698×568**,没有为隐藏的动作时间轴保留空行。证据为 `preview-stage-correction-20260919.json` 与对应截图。 +- 样例交互检查了 C 分成相邻两段并选中左段、设为无效后保留动作、撤销回待标注、文字修改保护、保存描述、画面点击播放/暂停及低于候选尺寸的提示。 +- 演示的保存仅用于呈现界面反馈;真实 API 持久化、刷新恢复、冲突、撤销写回、后台任务和业务送检均不属于本次示意验证。 +- 截图与检查结果位于忽略目录 `local-data/verification/continuous-actions-upstream-20260918/`。本轮没有运行本地产品测试套件,也未修改公司数据。 + +## Fog + +以下“当前产品”“尚未开始”等描述是实施前历史问题记录,不覆盖本次实现与验收结果;最终状态见 Decisions-so-far 的“实施与验收”。后续后台清理系统依旧不在本轮范围。 + +- 独立示意已撤回。后续规格应以现有界面截图/组件为对照,逐项标明局部变化,不继续索取对已撤回示意的认可。 +- 2026-09-21 Q16 已明确新底线为 1413×615 网页实际内容区,替代此前未定的较大候选;在现有风格上局部挪动标题与增加列表后,画面大小和控件边界仍需实际布局验证。 +- 当前产品仍有 N、动作删除、留空送检和原单路时间轴隐藏规则;正式实施需根据本讨论调整,文档确认不代表功能已经改变。 +- 当前前后端 v6+ 流程及异步产物路径都允许动作不覆盖切片;进度计算也不能直接表示完整动作覆盖。正式规格需覆盖送检入口、异步校验、进度、舍弃恢复与旧客户端,不能只调整按钮。 +- 已明确适用当前泛宇人工标注流程的全部项目;正式规格需准确识别该业务范围,不能通过泛化模板版本条件影响其他客户或流程。 +- 后续后台怎样根据无效动作过滤或删除媒体尚未在本仓库实现;维持当前保留契约,若要消费结构化类别需另定交付字段,不能悄悄扩展本轮为后台清理系统。 +- 正式规格已发布为 `ready-for-agent`,验收边界沿用用户已确认的真实浏览器与公开 API 保存回读,详见规格。拆票和实施尚未开始;此前孤立示意检查不代表本规格界面与业务已经验收。 diff --git a/.scratch/annotation-contiguous-actions/spec.md b/.scratch/annotation-contiguous-actions/spec.md new file mode 100644 index 00000000..8258a970 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/spec.md @@ -0,0 +1,327 @@ +# 泛宇连续动作标注与任务缓冲工作页规格 + +Status: ready-for-agent + +日期:2026-09-21。代码基线:`153687b4`,已合入同事的舍弃原因字典及历史恢复修复。依据:原 Q1–Q15 与追加 Q16–Q32 的最终裁决。本文固定目标行为,不代表这些功能已经实现。 + +## Problem Statement + +标注员需要在有限屏幕空间里长时间观看双目视频、切片并精细标注动作。当前单路放大会隐藏时间轴,拖动进度条后部分工作台快捷键被滑块接管;顶部状态占据高度,频繁选择项目和返回不同布局也打断作业。客户要求在 1413×615 的网页实际内容区内完成核心操作,并保留现有页面风格。 + +一个切片可能包含 50 个或更多短动作,单靠时间轴难以准确选择和修改。现有动作描述可以留空,无法可靠区分待处理和明确无效;切分、边界微调、列表导航及画面中的标注内容缺少一致的操作方式。一次误操作还可能覆盖已经确认的内容,因此保存、撤销和区间合并必须有明确边界。 + +切片提交后的后台生成耗时较长,当前连续工作停留在处理页,标注员无法接着处理其他任务。需要受容量约束的个人任务缓冲池,在后台生成期间处理其他可操作任务,同时避免重复领取、把受理误当送检成功或在用户退出后继续领取。 + +同事已实现舍弃原因字典、项目成员显示修复及恢复片段时的历史保留。本轮应复用这些能力,增加顺畅的键盘交互,而不是重复开发或削弱历史证据与项目权限。 + +## Solution + +在现有普通工作台和独立工作页的共享编辑能力上改进。独立工作页统一采用专注布局,默认左相机,可独立设置左/右/双目默认视图;标题和工作状态局部移到右侧,左侧增加当前切片的动作列表。切片阶段保留一条 Capture 切片时间轴,标注阶段保留 Capture 切片及片内动作两条时间轴,单路与双路视图都能直接编辑。视频完整等比自适应,核心操作常驻,长列表内部滚动、字典搜索分页。 + +需要标注的切片由首尾相接的动作区间完整覆盖。每段明确处于待标注、有描述或无效状态,使用 C 切分;每段确认描述或无效判断后才能送检。增加保存进度、动作列表导航、Shift 边界微调、只读 JSON 编辑预览,并保留当前任务与阶段内的撤销能力。F 按阶段打开命名/描述字典,G 选择当前切片的舍弃原因并明确确认。 + +个人任务缓冲池按账号与项目计数,默认容量 2、可设 2–8。开始/继续时补齐,切片后台请求被确定受理后接续其他任务,优先已生成待标注任务;真实送检成功才腾出容量。暂停连续工作立即停止自动切换和补领,保留当前编辑及已经发出的后台处理。退回仍回公共池,随后随机领取。 + +## User Stories + +1. As an annotator, I want the workbench to retain its existing visual style, so that I can keep using familiar controls. +2. As an annotator, I want a complete focused workspace at a 1413×615 browser content viewport, so that I can work on the customer's available screens. +3. As an annotator, I want task headings and continuous-work status arranged compactly on the right, so that video and timelines have more vertical space. +4. As an annotator, I want core editing and submission controls visible without scrolling the page, so that I can work without repeatedly searching for buttons. +5. As an annotator, I want video to remain fully visible at its original aspect ratio, so that relevant details are not cropped. +6. As an annotator, I want video to grow with the available viewport, so that larger screens improve inspection without changing the workflow. +7. As an annotator, I want the left camera enlarged on my first focused entry, so that the initial view matches my usual work. +8. As an annotator, I want an independent left/right/both default-view setting remembered for my account and browser, so that I can choose my preferred starting view. +9. As an annotator, I want temporary camera switches to leave my saved default unchanged, so that inspecting another camera does not change later tasks. +10. As an annotator, I want a new task to use my default view while stage changes within the same task retain my temporary view, so that cameras do not switch unexpectedly. +11. As an annotator, I want usable slicing controls in left-only, right-only and dual-camera views, so that camera choice does not restrict editing. +12. As an annotator, I want both annotation timelines in every camera view, so that I can inspect and edit actions without restoring a different layout. +13. As an annotator, I want only the Capture slice timeline during slicing, so that an irrelevant action row does not waste space. +14. As an annotator, I want clicking either video to toggle synchronized playback, so that I can pause and resume directly on the image. +15. As an annotator, I want clicks on overlay controls to perform only their intended action, so that opening information does not also start playback. +16. As an annotator, I want an undersized window to pause playback and automatic work while preserving my task, so that resizing does not lose progress. +17. As an annotator, I want to resume explicitly after restoring the viewport, so that work does not restart before I am ready. +18. As an annotator, I want the first available project preselected only when I have no valid selection, so that I can start without an unnecessary extra choice. +19. As an annotator, I want manual project choices and task links preserved, so that a project refresh does not move me to different work. +20. As an annotator, I want project preselection to remain separate from task claiming, so that merely opening the page does not assign work. +21. As an annotator, I want the dedicated work page to open consistently in focused mode, so that an old layout preference does not strand me in the wrong view. +22. As an annotator, I want to return directly to the task pool, so that a redundant layout-switch button is unnecessary. +23. As an annotator, I want the normal task-pool workbench to remain available, so that returning to the pool does not remove existing task access. +24. As an annotator, I want playback shortcuts immediately after clicking or dragging a progress slider, so that mouse seeking does not interrupt keyboard work. +25. As an annotator, I want shortcut ownership restored after releasing a drag outside the slider or cancelling it, so that focus does not become stuck. +26. As an annotator, I want text fields, Chinese composition and dictionary dialogs to keep their own keys, so that editing text cannot accidentally cut or invalidate video intervals. +27. As an annotator, I want one Escape to return from a dictionary to the workbench, so that I do not need repeated dismissal keystrokes. +28. As an annotator, I want different shortcut help for slicing and annotation, so that the help describes actions available in the current stage. +29. As an annotator, I want a newly editable slice to start as one pending action interval, so that all required time is represented. +30. As an annotator, I want action intervals to remain contiguous and nonoverlapping, so that no time is silently skipped or counted twice. +31. As an annotator, I want C to split the interval under the playhead, so that I can use the same cutting habit in both stages. +32. As an annotator, I want a cut to pause at the cut point and select the left interval without forcing text focus, so that I can label what I just watched or continue cutting. +33. As an annotator, I want the left side of a split to retain its judgment and the right side to become pending, so that a completed label is not silently copied onto unseen work. +34. As an annotator, I want the obsolete N action removed, so that there is one clear action-splitting workflow. +35. As an annotator, I want unchanged pending selections to allow navigation and further cuts, so that an empty editor does not block continuous cutting. +36. As an annotator, I want genuinely edited text protected before switching or cutting, so that a partial description is not lost or applied to another interval. +37. As an annotator, I want to save unfinished action partitions, so that refreshing can restore structural progress without pretending annotation is complete. +38. As an annotator, I want Save Description and Ctrl+Enter to confirm the current description only, so that saving text does not also submit the task for review. +39. As an annotator, I want pending, described and invalid intervals visibly distinguished, so that completion is clear. +40. As an annotator, I want Ctrl+X to invalidate only the explicitly selected action, so that its target is predictable. +41. As an annotator, I want the mouse invalid action and Ctrl+X to save the same judgment, so that keyboard and mouse workflows agree. +42. As an annotator, I want an invalid judgment to count as complete only after the server confirms it, so that a failed save cannot hide unfinished work. +43. As an annotator, I want undo to restore a description replaced by an invalid judgment, so that misclassification is recoverable. +44. As an annotator, I want invalid actions retained as annotation results, so that marking invalid does not delete media or discard the whole slice. +45. As an annotator, I want action correction through editing, reclassification, undo and explicit boundary merging, so that a separate action-delete command cannot create gaps. +46. As an annotator, I want every required interval completed before submission, so that incomplete actions cannot accidentally reach quality review. +47. As a reviewer, I want explicitly discarded slices handled through their reasons and evidence, so that they do not require artificial action descriptions. +48. As an annotator, I want existing descriptions preserved when gaps become pending intervals, so that adopting the new workflow does not erase previous work. +49. As a reviewer, I want already submitted and accepted results left unchanged, so that a new editing policy does not rewrite review history. +50. As an annotator, I want returned work to follow the new completion rules when resubmitted, so that corrected work meets the current standard. +51. As an operator of another workflow, I want my existing annotation policy preserved, so that the Fanyu change does not alter unrelated work. +52. As an annotator, I want an action list containing every interval in the current slice, so that I can find short pending, described and invalid actions. +53. As an annotator, I want at least 50 densely packed actions to remain individually selectable, so that narrow timeline blocks do not prevent correction. +54. As an annotator, I want the list, timeline and editor to share one selected action, so that I always know which result I am changing. +55. As an annotator, I want list clicks and Up/Down to select adjacent actions and loop within the current slice, so that reviewing does not require precise mouse targeting. +56. As an annotator, I want Ctrl+Up/Down to perform six action-navigation steps, so that I can move quickly through dense annotations. +57. As an annotator, I want Alt+Up/Down to locate the selected action's start or last editable frame, so that precise review remains available after the shortcut change. +58. As an annotator, I want end navigation to show a frame belonging to the selected action, so that its video and annotation preview agree. +59. As an annotator, I want selection to take effect immediately while the list scrolls smoothly toward a stable row position, so that animation never delays editing. +60. As an annotator, I want manual list scrolling to leave selection unchanged, so that browsing the list does not move the video unexpectedly. +61. As an annotator, I want a short annotation summary to follow the playhead, so that I can see the judgment for the image being displayed. +62. As an annotator, I want full JSON available as a read-only expansion, so that I can inspect structured information without permanently covering the video. +63. As an annotator, I want the JSON preview to identify saved and unsaved content, so that a draft is not mistaken for the delivered result. +64. As an annotator, I want playback to update the image summary without changing my editing selection, so that watching ahead does not replace my editing target. +65. As an annotator, I want Shift+Left/Right to move the selected interval's end by one real frame, so that fine corrections do not require dragging. +66. As an annotator, I want a held boundary key to accelerate after one second to five frames per half-second, so that larger adjustments remain efficient. +67. As an annotator, I want the shared boundary to move both adjacent intervals together, so that adjustment cannot introduce gaps or overlap. +68. As an annotator, I want shrinking the selected action to zero to merge its range into the following action, so that an unnecessary cut can be removed. +69. As an annotator, I want extending to the next action's end to merge that action into the selected one, so that I can remove the next cut deliberately. +70. As an annotator, I want the surviving interval to retain its judgment after a merge, so that the outcome follows the selected direction consistently. +71. As an annotator, I want a single held key to consume at most one neighbor, so that acceleration cannot silently remove many actions. +72. As an annotator, I want the last endpoint fixed and ordinary mouse dragging to retain at least one frame on each side, so that full coverage remains protected. +73. As an annotator, I want the same boundary keyboard behavior for slices during slicing, so that precise adjustment uses one consistent habit. +74. As an annotator, I want merged slices to retain the surviving slice's name, so that names are not combined or fabricated. +75. As an annotator, I want discarded slices restored before their boundaries can be changed, so that discard evidence is not silently reassigned. +76. As an annotator, I want one held adjustment or mouse drag to be one undo step, so that a correction can be reversed predictably. +77. As an annotator, I want held adjustments to stop on release, focus loss, dialogs or task changes, so that delayed key repeats cannot edit a different target. +78. As an annotator, I want F to open the current stage's naming or description dictionary, so that existing dictionary habits remain useful. +79. As an annotator, I want G to open discard reasons for the current slice in either stage, so that whole-slice discard is distinct from action invalidation. +80. As an annotator, I want discard reasons searchable and pageable with keyboard selection, so that a large dictionary is usable without page scrolling. +81. As an annotator, I want Enter to select a reason and Ctrl+Enter to confirm discard after any required note, so that browsing choices cannot discard accidentally. +82. As an annotator, I want missing, disabled or changed dictionary entries explained without losing my note, so that I can recover from configuration changes. +83. As a project administrator, I want the existing project-enabled discard dictionary reused, so that I do not maintain a second reason system. +84. As a reviewer, I want historical reason text and snapshots preserved across renaming and restoration, so that audit evidence remains trustworthy. +85. As an annotator, I want a compact discarded status and explicit restore entry instead of a large default keep banner, so that useful space is recovered without hiding a real discard. +86. As an annotator, I want my personal task capacity configurable from two to eight with a default of two, so that I can balance waiting and work in progress. +87. As an annotator, I want capacity shared by my manual and automatic claims within a project, so that switching entry points does not exceed the limit. +88. As an annotator, I want processing and failed tasks to keep their slots until real submission succeeds, so that occupancy reflects unfinished work. +89. As an annotator, I want existing tasks preserved when I reduce capacity, so that changing a setting never releases assigned work. +90. As an annotator, I want explicit start or continue to fill available capacity, so that useful work is ready while another task is generating slices. +91. As an annotator, I want the next task opened only after slice generation has been definitely accepted, so that uncertain requests do not abandon my current task. +92. As an annotator, I want ready annotation tasks selected before unsliced tasks, so that completed media is used promptly. +93. As an annotator, I want background completion to leave my active editor in place, so that tasks cannot steal my attention mid-edit. +94. As an annotator, I want an honest waiting state when my full buffer is processing, so that the application does not claim extra work to conceal the wait. +95. As an annotator, I want a single background failure visible and retryable while other tasks remain usable, so that one failure does not halt all productive work. +96. As an annotator, I want uncertain operations reconciled through their original request identity, so that retries do not allocate or submit duplicates. +97. As an annotator, I want successful quality-review handoff to free a slot and refill the buffer while continuous work is active, so that my workload remains steady. +98. As an annotator, I want returned tasks to re-enter the public pool, so that the existing return-assignment policy is preserved. +99. As an annotator, I want Pause Continuous Work to stop automatic switching and claiming immediately, so that I retain control without cancelling background processing. +100. As an annotator, I want returning, closing or refreshing to require explicit continuation before more automatic claims, so that inactive pages do not acquire work. +101. As an annotator, I want concurrent pages and browsers to respect one server-enforced capacity per account and project, so that races cannot overfill my buffer. +102. As an annotator, I want permission changes, stale responses and version conflicts to preserve an honest recoverable state, so that older operations cannot overwrite newer work. +103. As an annotator, I want the existing undo throttle and task/stage boundaries preserved, so that undo cannot roll back media generation or another task. +104. As a maintainer, I want browser-visible behavior verified through public API readback, so that implementation refactoring does not invalidate the meaning of acceptance tests. + +## Implementation Decisions + +### 适用范围、基线与优先级 + +- 以已合并的代码基线继续开发,共用现有任务协调、工作台编辑、同步播放器、字典、公开接口和后台生成能力。保留帧初始化不应误判为用户编辑的工作入口修复,也保留项目成员显示修复。 +- 连续动作覆盖及个人任务缓冲规则面向当前泛宇人工切片/标注流程的全部项目;通过可信组织、项目和工作流范围识别,不只根据一个泛化模板版本或前端页面开关决定,不扩大到其他客户/流程。 +- 新任务及仍在编辑的范围内任务适用;已有描述和边界原样保留,仅将合法空白补成待标注。已经送检/验收的结果不迁移,退回编辑后重新按新规则送检。已有异常边界不得通过静默裁切或重叠覆盖来“修复”。 +- 普通工作台与专注工作页共享动作模型、焦点、快捷键、保存和送检规则;1413×615 的整页免滚动布局要求专用于独立工作页,不把平台其他页面一并重排。 +- 本文替代旧规格中的单路隐藏时间轴、旧窗口及画面像素底线、动作 N、动作删除留空、Ctrl+X 批量填空白、Ctrl+上下起止定位、留空送检和串行等待规则。没有被明确替代的播放、字典权限、审核、舍弃证据和撤销边界继续成立。 + +### 布局、相机与进入工作 + +- 维持现有视觉风格与共享编辑器。仅局部移动工作页标题、任务标识与连续状态到右側,增加左侧窄动作列表,压缩无意义默认文案及冗余入口;不采用之前已撤回的独立重排示意,不新建另一套工作台。 +- 最小完整工作内容区为宽 1413、高 615 CSS 像素,以浏览器实际网页可用区计算。视频完整等比显示、不裁切,以列表、阶段所需时间轴、当前编辑、保存/提交等核心操作可达为优先,不沿用旧固定最小画面像素。 +- 切片仅有 Capture 切片时间轴;标注才同时有 Capture 切片和片内动作时间轴。不为不存在的第二条轴保留空行。左/右/双目视图均不隐藏需要编辑的轨道。 +- 页面不整体滚动来找核心功能。动作列表在自己的区域内滚动,字典沿用搜索与分页,长文本和按需展开的 JSON 在受限区域阅读;这些内容不能把常驻保存、提交和返回挤出窗口。 +- 默认相机首次为左;单独提供左/右/双目默认设置,按账号及浏览器保存。首次进入专注模式、开始新任务使用默认,同一任务的阶段或布局上下文变化保留临时选择;修改默认不立即抢占当前视图,临时切换不回写默认。 +- 点击任一可见视频使用共享同步播放/暂停动作,遵守当前可播放范围及处理限制。点击画面上的控件不再触发第二次播放切换。 +- 独立工作页删除“切回原布局”,统一进入专注模式并兼容已有 original 偏好。任务池内普通工作台仍存在;“返回任务池”保留并暂停连续工作,离开未保存内容的既有保护不取消。 +- 标注员入口在没有当前有效选择或明确项目/任务链接时,预选授权项目下拉的第一项;沿用列表现有顺序,不另建排序。保留手动选择和深链接,列表刷新不切换正在使用的项目,无项目显示原有空状态;管理员的全项目语义不改变。预选不自动领取,仍显式点击开始工作。 +- 小于内容区底线时暂停播放、长按微调、自动切换与补领,保留当前任务、草稿及会话内撤销;已发请求继续核对。恢复尺寸后由用户手动继续,不因窗口恢复自动领取。 + +### 连续动作区间、保存与送检 + +- 切片和动作均使用现有统一真实帧边界及半开范围语义,动作始终在所属切片内首尾相接、无重叠、无遗漏。每个需要标注的新切片初始为一整段待标注;明确舍弃的切片按独立舍弃规则处理。 +- 持久化进度和公开回读必须能区分待标注、有已确认描述和明确无效。输入框有文字不等于已确认,普通草稿保存不自动将文字或空白标为完成。不得只用“存在一条描述”判定整片完成。 +- C 分割播放头所在区间,仅在内部合法帧边界执行;在已有边界或一帧区间不能制造零长度分区。切后暂停于真实切点、选中左段,不强制聚焦文本。左段继承原描述/无效/待标注状态,右段待标注;N 不再启动或结束动作创建。 +- 仅选中但未改字时可继续 C、列表选择及动作导航;确有未保存文字时先保存或取消,不能把文字带到另一段,也不能以一个空编辑框阻挡连续切分。改边界同样遵守此保护。 +- 保存进度持久保存分区、完成状态和可恢复的编辑进度,允许待标注,刷新可回读;它不送检,也不把未确认内容自动完成。保存描述/Ctrl+Enter 只确认当前描述,不能在同次按键中继续送检。 +- Ctrl+X 与“设为无效”只针对明确选中的动作,允许替换已有描述;没有明确选择时不操作,播放头不改变目标,文本输入内保留原生剪切。操作直接保存;成功后才计完成,失败/未知时保留可恢复状态,不伪报完成。 +- 一次撤销恢复 Ctrl+X 之前的完整判断和内容,已保存内容通过受版本及归属校验的公开写入恢复。无效判断保留动作与媒体,不等于舍弃切片或触发后台删除。 +- 取消动作阶段独立删除按钮及删除快捷键。纠错使用修改、改判、撤销及下述明确的键盘边界合并;切片阶段既有删除划分及独立舍弃规则保留。 +- 送检要求每个需要标注的切片完整覆盖,所有动作都已确认描述或无效,且没有未处理的编辑草稿/未知保存结果。明确舍弃切片凭合法原因与证据处理,包括原有全部舍弃流程;不能为了过覆盖检查给它们伪造动作。 +- 同一校验须覆盖前端、公开保存/提交入口、直接或旧客户端提交、异步完整生成与复用媒体/描述更新路径。缺失动作、待标注、重叠、越界或不合法帧不允许被另一条路径绕过;草稿与正式送检的校验目的必须区分。 +- 历史 gap 补待标注与帧对齐属于受当前任务/版本约束的初始化,不得吸收已经开始的用户编辑,也不能重新引入默认片段被当作脏修改而阻挡开始工作的缺陷。首次真实编辑或显式保存后才相应产生进度变更。 +- 还原舍弃切片时保留原有动作证据;恢复出来的空白按当前范围补待标注并再次接受完整送检检查,不改写旧审核事实。 + +### 动作列表、导航与视频信息 + +- 列表范围是当前切片的全部动作区间,按时间排列,包含待标注/描述/无效;不是过去版本的操作日志,不混入其他切片。至少覆盖 50 段密集短动作的可读选择场景。 +- 列表、动作时间轴和描述编辑器共用选中对象;提供明确高亮、序号、时间范围和描述/状态。手动滚列表不改变选择;点击或导航才改变编辑目标和视频位置。 +- 上下在当前切片内循环一步,Ctrl/Command+上下等于循环六步;少于六段仍按重复六次计算,可能回到同一项,不跨切片。没有选中项时沿用按播放头确定导航起点的既有习惯。切换切片继续使用既有 Ctrl/Command+左右。 +- 选择变化立即生效,列表平滑调整,尽量让选中行保持固定位置。首尾循环不得漫长地滚过所有条目,连续按键以最新选择为准;动画不能阻挡输入或把键盘焦点交给内部按钮。 +- 列表点击、上下、跨六段及 Alt+下暂停并停在目标动作的最后一个可编辑帧;Alt+上停开始帧。最后可编辑帧从统一帧边界求取,不通过减固定帧率秒数或微小偏移猜测;单帧动作定位其开始帧。 +- 表单显示和保存的结束时间仍是真实排他边界,C 后仍停真实切点。不得为修复导航而全局改变播放器 seek 或媒体导出边界语义。 +- 视频角落默认显示实际播放头所在动作的简短描述/无效/待标注摘要;完整 JSON 同区按需展开、只读,展示当前编辑预览及明确的已保存/未保存状态,包括时间范围、描述和判断。时间需注明所属时间基准,与工作台现有时间显示一致,不把片内与原视频时间混用。 +- 预览不是最终交付 JSON,不改变输出契约。播放经过别的动作时更新画面信息,但不擅自更改编辑器的明确选中项;输入长文本、展开 JSON 不使核心操作越界或误切换播放。 + +### 边界微调、合并与撤销 + +- Shift+左右调整明确选中区间的结束边界:切片阶段作用于当前切片,标注阶段作用于当前动作;标注阶段不能借此修改已生成切片边界。无明确目标、帧未就绪、忙于权威写入或文本/弹层拥有键盘时不执行。 +- 按下立即走一帧;持有未满一秒不依赖系统重复键持续走帧,满一秒开始每 0.5 秒走五帧。移动使用统一真实帧边界,并钳制到合法终点,不因五帧跨步跳过合并上限。 +- 共同边界联动相邻两段,保持连续。正常微调保留两段描述/判断;一次按住或一次鼠标拖动是一个可撤销编辑,而不是每一帧一个历史项。微调改变编辑进度,不每 0.5 秒发一次自动保存。 +- A 在 B 之前时,A 的结束退到 A 的开始,A 消失,B 接管原 A+B 范围并保留 B 的描述/待标注/无效判断;A 的结束推进到 B 的结束,B 消失,A 接管范围并保留 A 的判断。切片同理继承存活片名称。被覆盖判断可随整次撤销恢复,不删除媒体。 +- 一次按住以开始操作时的相邻段为限,最多合并一段,到界停止;须松开重按才能继续操作新的相邻段,不允许加速连续吞掉多段。合并后明确选择存活区间。 +- 最后一个区间的结束固定,单个完整区间不能缩空;普通鼠标拖动仍保证相邻两段各至少一帧,不通过鼠标缩零合并。切片首尾和动作所属切片范围固定。 +- 已舍弃切片及其相邻共享边界不得直接改变、删除或合并,先明确恢复再编辑;不重新分配其原因快照和审核证据。 +- 按键释放、取消、窗口失焦、弹层打开、任务或阶段变化立即停止重复;迟到的定时动作不能编辑新任务。文本中 Shift+方向键仍为原生选择文字。 +- Ctrl/Command+Z 每秒最多一次,忽略长按重复,保留最多 100 步及既有重做规则。只针对当前任务与当前阶段;开始生成、重新切片、送检或切换任务截断历史,刷新不承诺恢复撤销栈。舍弃/恢复沿用现有权威保存和证据流程,不因新增 G 就自动获得跨用途变更撤销能力。 + +### 字典、舍弃与键盘归属 + +- F/既有 D 别名分别打开切片名称或动作描述字典;G 在两阶段都针对当前切片打开舍弃原因选择,与 Ctrl+X 的动作无效完全区分。 +- 复用同事已完成的组织词条管理、项目启用、版本校验、原因快照及恢复实现。工作台选择界面支持搜索、分页、上下选项、左右翻页、Enter 选中、Esc 返回,并适应可用空间。 +- Enter 只选原因,按需填写说明;Ctrl/Command+Enter 或明确按钮再执行确认舍弃。不能因选项点击或重复键自动跳过确认。“其他”或要求说明的词条必须补充,说明最多 1000 字;新舍弃不能用自由文本绕过字典。 +- 词条为空、加载失败、停用或版本变化时保留原因草稿并给出刷新/重新选择入口,校验未通过不得提交。切片命名错误仍能返回修正并保留原因草稿。 +- 已舍弃片段保持紧凑的状态、原因和明确恢复入口;G 不自动切换为恢复。删掉默认“保留片段·正常标注与交付”等大块文案,不删除有意义的舍弃状态及审核证据。 +- 历史自由文本和当时的 ID/版本/名称/说明快照保留;字典改名或停用不追写历史,恢复不依赖字典可用。完整生成与复用媒体的审核产物继续携带原因快照,舍弃媒体仍供审核、最终交付继续排除已舍弃片段。 +- 任何进度条的点击、拖动完成、外部松手和取消后,工作台恢复快捷键归属;不要求通过拆掉组件层级实现。键位所有权在文本/输入法、字典或确认层、工作台之间清楚分配,不能重复执行。 +- Escape 关闭当前最上层字典/弹层或退出输入焦点,保留未保存内容,返回后 Space 直接操作视频,不再次触发旧按钮。按键重复不得跨层连选或连确认;与鼠标入口遵循相同的保存和禁用条件。 + +| 按键 | 切片阶段 | 标注阶段 | +| --- | --- | --- | +| Space | 同步播放/暂停 | 同步播放/暂停 | +| 左/右 | 上/下一真实帧 | 上/下一真实帧 | +| C | 播放头切分切片 | 播放头切分动作,取代 N | +| F/D | 切片名称字典 | 动作描述字典 | +| G | 当前切片舍弃原因字典 | 当前切片舍弃原因字典 | +| 上/下 | 不增加动作导航 | 当前切片内循环一步,停目标末帧 | +| Ctrl/Command+上/下 | 不增加动作导航 | 当前切片内循环六步,停目标末帧 | +| Alt+上/下 | 不增加动作定位 | 当前动作开始帧/最后可编辑帧 | +| Shift+左/右 | 当前切片结束边界微调 | 当前动作结束边界微调 | +| Ctrl+X | 不执行动作无效命令 | 明确选中动作标无效并保存 | +| Ctrl/Command+Enter | 既有切片确认流程 | 当前描述保存,不同时送检 | +| Ctrl/Command+左右 | 既有前后切片导航 | 既有前后切片导航并保留跨片草稿 | +| B/V | 既有复查/返回工作点 | 既有复查/返回工作点 | +| Ctrl/Command+Z、重做键 | 当前阶段撤销/重做 | 当前阶段撤销/重做 | +| Shift+Delete/Mac Shift+Backspace | 既有明确选中切片的删除划分 | 不再删除动作 | +| Esc/? | 返回工作台/本阶段帮助 | 返回工作台/本阶段帮助 | + +舍弃面板内 Ctrl/Command+Enter 专用于确认舍弃;输入框内原生剪切、选择和撤销保持。既有速度键和未明确更改的键位继续保留。帮助按当前阶段及弹层说明,不能把不同命令混成通用清单,也不能承诺不可用状态下按键有效。 + +### 个人任务缓冲池与后台接续 + +- 以组织内当前账号+项目为边界保存容量,默认 2,支持整数 2–8;独立于相机的浏览器偏好。读取容量、更新容量、本人未完成任务及占位状态通过应用公开边界提供,不把浏览器内数组长度当服务端事实。 +- 已领取且仍处于标注处理链路的待切片、切片生成中、待标注、送检处理中及失败待处理任务均占位;已真实转交质检的任务不占位,即使历史“我的任务”列表仍显示它们。只有同一项目同一账号计数,不跨项目争用一个总额度。 +- 手动随机领取与自动补领共用服务端容量约束、权限和原子归属分配。跨页/跨浏览器并发不得越额;已有请求回执重放不再领取一条或消耗新槽位,不能因容量已满而丢失对原成功领取的核对能力。 +- 显式开始/继续时补齐不足容量,实际送检成功或连续工作期间增大容量后补足;公共池不足仅领取实际可得数量。更新容量本身不在暂停状态偷偷开始领取。 +- 降低容量不释放、隐藏或中止已有任务;达到或超过容量时停止新领取,直到真实占位低于目标。服务端拒绝不合法容量,用户不能用旧客户端或另一个领取按钮绕过。 +- “确认切片”成功持久受理后台工作后,当前页可以切换到其他可操作任务,不等待媒体生成完成;HTTP 请求发出、乐观状态或网络超时均不能被当成确定受理。保留原提交确认,开始生成仍截断切片阶段撤销。 +- 自动选择下一任务时,优先本人已生成且可标注的任务,再待切片,同类按领取先后;用户明确从我的任务继续某条时仍续做所选任务,队列优先级不覆盖明确选择或未保存草稿。处理中任务算占位但不进入可编辑队列。已有后台任务完成只更新状态,不抢走用户当前编辑。缓冲已满且全部处理中时等待,不突破容量。 +- 扩展现有任务查询和轻量状态核对以跟踪本人缓冲任务,不只轮询当前屏幕任务;对用户只显示已归属任务及允许的随机池计数,不暴露未领取视频供挑选。 +- 真正送检成功才腾位并在连续模式下补领。异步送检失败仍占位;单条失败显著提示、可重试,允许继续其他任务,不让失败任务静默丢失或被当作已完成。 +- 结果未知时使用原请求标识核对;版本、任务、身份或权限变更后,迟到响应不能覆盖当前编辑、抢占导航或触发无权补领。处理失败后必须按当前权威状态恢复,不重复发起同一未知作业。 +- 退回保持现有规则:清除标注员归属,回公共可领取池,之后随机领取;不自动归还原标注员,不以原作者身份给个人池增加占位。重新领取的退回任务也受容量限制。 +- “完成当前任务后停止”改成“暂停连续工作”,立即停止新的自动切换与补领,保留当前编辑、已领取任务和已发后台工作。返回任务池、关闭、刷新后不自动恢复补领,用户须明确继续。 +- 暂停时已经发出的请求仍核对结果;已经成功领取的任务保留归属,不因暂停而主动释放,但也不能因此继续发补齐请求或强制打开任务。无可操作任务、空公共池或全部失败时展示真实状态及继续/重试入口,不伪造持续有任务可做。 +- 延续已有安全连接和同浏览器账号+项目工作页互斥;HTTP 手动模式不通过本需求绕过 Web Locks 前提。服务器容量校验需覆盖其他浏览器的请求,但不宣称新增跨设备完整编辑互斥锁。普通手动入口同样执行容量限制。 + +## Testing Decisions + +测试边界沿用用户此前明确接受的方案:以真实浏览器操作共享工作台和独立工作页、通过现有公开 API 保存及回读为主;接口层补充版本冲突、幂等、处理中限制与并发容量;纯函数仅补充精确键位、真实帧寻址、撤销与长按节流。没有新增一套仅供测试调用的业务接口,不重复发起需求访谈。 + +好的测试驱动操作者可执行的行为,观察画面、选中项、焦点、可操作状态、网络结果和重新读取的持久数据;不把私有状态、组件层数、源码字符串匹配或仅出现页面标题当作验收。单独计算区间正确不能替代真实视频定位和保存回读,模拟所有写入成功的界面用例不能替代真实应用接口核验。 + +### 覆盖模块与既有测试方式 + +- 主线覆盖任务协调器、共享编辑器、同步播放器、相机设置、三类字典、动作列表和个人缓冲池;普通工作台与专注页都验证共享业务行为。 +- 延续现有工作页尺寸/相机/导航/字典浏览器用例、真实帧时间轴及工作入口回归用例;对长按、焦点和末帧的检查使用真正的输入与播放器,不读取私有组件变量。 +- 复用现有草稿保存与回读、权威写入恢复、撤销、随机领取回执、异步生成/送检冲突等 HTTP 测试方式。并发容量通过并发公共请求和最终归属回读证明,不通过检查客户端计数实现证明。 +- 延续同事的舍弃字典独立词条、版本/组织/项目隔离、必填说明、历史恢复和媒体证据测试;项目成员显示无需重写,但不得被合并及后续界面修改回归破坏。 +- 保留其他流程留空规则的回归样例;范围内新任务、历史可编辑任务、已提交任务和退回重做分开验证。修正被新规则明确替代的旧断言,不删除范围外保护来使测试变绿。 +- 全流程至少含真实双目素材及统一帧时间线、保存后刷新、后台切片完成、送检到质检的状态核对;完整生成和复用媒体更新路径都要覆盖正式完整性约束与舍弃原因快照。 +- 用隔离账号/项目/任务开展写入验收;沿用既有环境授权,不因发布本规格自动写公司数据或部署。上一轮本地合并检查只证明基线兼容,不算本轮验收证据。 +- 类型检查、构建及相关前后端检查必须通过;既有全量测试债务独立记录,不能掩盖本轮新回归。交付报告写清实际运行环境、操作、回读证据与未验证范围。 + +### 验收矩阵 + +| 编号 | 场景 | 可观察/可回读的通过条件 | +| --- | --- | --- | +| A01 | 1413×615,切片/标注×左/右/双目 | 核心操作不依赖整页滚动;切片一轴、标注两轴;单路不丢轴;视频完整等比 | +| A02 | 大窗口、缩放、长任务名、字典、长描述、失败提示 | 可用区测量正确,核心按钮不越界;窗口增大画面增大,不采用撤回示意 | +| A03 | 缩到门槛以下再恢复,期间后台请求完成 | 播放和自动行为暂停,草稿与当前任务保留;请求结果核对,恢复后须手动继续 | +| A04 | 首次/新任务/同任务换阶段/改默认/切账号 | 默认首次左;默认设置与临时视图分离,作用时点及账号浏览器隔离正确 | +| A05 | 点击左右视频、摘要展开按钮与播放器控件 | 视频同步播放/暂停,控件不双触发;忙碌/只读状态不绕过 | +| A06 | 首次项目列表、手动选择、深链接、列表刷新、无项目 | 无选择时预选第一项;不覆盖有效选择,不自动领取,不改变管理员全项目语义 | +| A07 | 旧 original 偏好进入工作页,返回任务池 | 工作页专注且无切回按钮,返回仍可使用普通工作台,自动工作暂停 | +| A08 | 各进度滑块点击/拖动/外部松手/取消后按 Space、C、Ctrl+X | 可用工作台快捷键正常响应,不再被旧滑块或按钮夺取;无重复操作 | +| A09 | 文本、中文输入法、字典搜索、弹层及一次 Esc | 原生编辑与弹层键位正确,Esc 后工作台可直接播放,不误切/误提交 | +| A10 | 新切片、旧合法空白与已有描述混合 | 初始完整待标注,旧判断及边界保留,空白补待标注;初始化不阻挡工作入口 | +| A11 | 连续 C、切已描述/无效段、已有边界、一帧动作 | 合法切分选左且原地暂停,左继承右待标注;无零长度,N 不创建动作 | +| A12 | 空编辑器和真实未保存文字分别导航/切分 | 空选择不阻挡;真实文字须保存或取消且不串段、不丢失 | +| A13 | 保存含待标注的进度并刷新 | 划分与状态恢复,未确认文字不被当完成,任务未送检 | +| A14 | 保存当前描述及连续按 Ctrl+Enter | 描述保存可回读,同次操作不送检,重复输入不跨确认层执行 | +| A15 | 选择 A、播放头在 B,Ctrl+X;无选择;输入框剪切 | 仅明确选择 A 被保存为无效;无选择不变;文本仍剪切,普通切片阶段不舍弃 | +| A16 | 已描述段标无效后撤销/重做,保存失败/未知/版本冲突 | 正常恢复原判断,服务器与界面一致;异常不假成功、不覆盖新权威状态 | +| A17 | 50 段以上含极短、待标注及无效的动作 | 列表均可选择,时间轴和编辑器同一高亮;手动滚动不跳视频 | +| A18 | 上下首尾、Ctrl+上下六步,动作数1/3/50 | 限当前片循环并可回原项;目标立即选中,动画不阻塞或长距离遍历 | +| A19 | 相邻动作边界导航、Alt+上下、单帧及末动作 | 末端导航显示目标末帧及对应信息;保存 end 不变,C 停点不受影响 | +| A20 | 播放跨动作、编辑草稿、展开 JSON | 摘要跟画面,选中编辑目标不被抢走;JSON 只读、保存状态及时间基准明确 | +| A21 | Shift 单击、持有不足1秒、持续加速、非匀速真实帧 | 单击一帧;约定时点进入五帧/0.5秒,按真实帧走且不会越界 | +| A22 | 向前缩零/向后吞并,混合描述与无效,撤销 | 范围完整,存活段判断正确,被覆盖记录可一次撤销恢复;媒体不删除 | +| A23 | 长按越过下一段、松开再按、焦点离开/开弹层/换任务 | 单次最多合并一邻段,到界停止;旧重复事件不能影响新目标 | +| A24 | 鼠标拖共同边界,末段/单段,切片与动作两阶段 | 鼠标两段各至少一帧;末端固定;阶段目标正确;一手势一撤销 | +| A25 | 切片合并名称、已舍弃片与相邻边界 | 名称来自存活片;舍弃未恢复不能改界/吞并;恢复后证据保留 | +| A26 | F/G、大字典分页、普通词条/其他/必填说明 | 阶段和对象正确;Enter 选项,Ctrl+Enter 确认;不能跳过必填说明 | +| A27 | 空/停用/旧版本/跨项目词条、命名错误返回 | 不可绕过校验;草稿保留且可重选,历史文本不被新选择静默替代 | +| A28 | 舍弃、字典改名/停用、恢复、保存并回读 | 历史及原因快照保留;恢复不依赖字典;无效动作仍与舍弃区分 | +| A29 | 含待标注、缺段、重叠、越界/非法帧的直接提交 | 前后端一致拒绝;旧客户端、异步完整/复用路径不能绕过 | +| A30 | 所有动作已确认、混合舍弃、全部舍弃 | 真实送检成功,质检结果可回读,舍弃原因及媒体证据沿用,待标注不流入正式产物 | +| A31 | 已送检/已验收、退回编辑、范围外流程 | 不追改旧结果;退回再提交执行新规则;其他流程不被扩大影响 | +| A32 | 容量默认2、修改2/8、非法值、跨账号项目 | 持久设置和隔离正确,非法值拒绝;自动和手动共享真实占位 | +| A33 | 开始/继续补齐、增大容量、公共池不足 | 只补可用名额及实际任务;自动预选项目不领任务,暂停时改容量不启动 | +| A34 | 待切/生成中/待标注/送检中/失败/已送检混合 | 前五类按规则占位,真实送检后才腾位;我的任务历史列表不影响计数 | +| A35 | 并发手动/自动/另一浏览器领取,同请求重试 | 服务端不越容量且一任务不双分配;回执恢复同一结果,不再消耗槽位 | +| A36 | 下调容量至低于占位、逐条完成 | 已领任务不释放;到等于容量仍不领,低于容量且连续激活时才补 | +| A37 | 切片成功受理、超时未知、后台失败 | 确定受理才切走;未知先核对;失败保留槽位并可做其他任务 | +| A38 | 多个就绪任务、全池处理、后台中途完成 | 待标注优先,同类先领先做;处理中跳过但占位;完成不抢正在编辑的任务 | +| A39 | 送检受理/真正成功/失败 | 受理不腾槽,真成功才补;失败可见并可重试,不误发重复提交 | +| A40 | 质检/后续审核按现流程退回 | 回公共池,不自动归原人;再次随机领取仍受容量限制 | +| A41 | 暂停/返回/刷新/关闭,伴随请求正在返回 | 无后续自动切换或补领;已发结果核对并保留任务;明确继续才恢复 | +| A42 | 同浏览器重复页、HTTP手动模式、权限撤销、迟到响应 | 既有入口限制与互斥有效;容量仍由服务端保证;无跨任务覆盖/无权领取 | +| A43 | 原 Space、逐帧、切片导航、B/V、撤销节流及两阶段帮助 | 未改键位不回归;新旧替代清楚,动作删除及 N 不再可用;撤销不跨任务阶段 | + +## Out of Scope + +- 不采用已撤回的 1440×900 独立新布局,不新增弹出浏览器窗口、整个平台重排、拖拽分栏或图片裁切来强行放大视频。 +- 不重建已经合入的舍弃字典管理、项目成员显示或历史快照机制;不把原因选择退回为自由文本,不改变审核证据与最终交付过滤规则。 +- 不实现按无效动作自动删视频、后台清理媒体或新的结构化交付类别;视频 JSON 面板不是交付格式编辑器。 +- 不回写已经送检/验收的数据,不把新完整覆盖规则强加给其他客户/流程,不允许动作真实重叠。 +- 不恢复独立动作删除/N 创建动作,不允许一次长按吞并多个邻段、鼠标拖动缩零、跨已舍弃边界合并或在标注阶段改已生成切片边界。 +- 不建立跨任务/阶段/刷新持久撤销,也不把舍弃恢复或异步作业回滚纳入普通 Ctrl+Z。 +- 不把退回任务自动归给原标注员,不新增任意释放已领取任务、不暴露未领取候选视频供挑选;不承诺跨设备完整编辑会话互斥。 +- 不重写后台媒体处理架构、调整公司集群资源或宣称缩短切片编码本身耗时;本轮解决的是等待期间可以继续工作。 +- 不改公司部署环境、不自动推送或部署、不更新真实客户数据;发布规格不等于实施或验收完成,也不包含拆分任务票。 +- 不清理无关历史测试债务,不把原“11 个任务”的数量作为本轮拆票约束。 + +## Further Notes + +- 本文发布于项目本地 Markdown issue tracker,状态为 `ready-for-agent`;用户已要求将已确认需求固定,Q1–Q32 中冲突项按最新裁决收敛,不再访谈。 +- 测试边界复用此前用户明确确认的真实浏览器+公开 API 保存回读方案;新增容量并发与后台接续仍在同一应用边界验证,不增加测试专用业务通道。 +- 代码基线包含同事三次提交(项目成员显示、项目舍弃字典、Mongo 历史恢复)和本地工作入口修复。合并时基础检查通过,但本规格的新界面和业务尚未实现或验收。 +- 原讨论记录、旧规格和上游核验保留用于追溯;在本轮适用范围内,遇到已明确替代的旧条目以本文为准。舍弃与无效、进度保存与送检成功、播放头与编辑选中项必须始终区分。 +- 领域词汇及三个 ADR 分别约束当前阶段撤销、连续动作完整覆盖、有限个人任务缓冲;实现和拆票不得把这些约束拆散后丢失跨模块验收。 +- 未直接读取客户原始需求文件,本规格依据用户转述、截图、逐项裁决和实际源码;不将截图中的文字当成额外指令。 +- 追溯:[原设计记录](./map.md)、[追加裁决及合并记录](./supplement-20260921.md)、[领域词汇](../../CONTEXT.md)、[撤销边界](../../docs/adr/0001-annotation-undo-stage-boundary.md)、[完整动作覆盖](../../docs/adr/0002-contiguous-action-coverage.md)、[个人缓冲池](../../docs/adr/0003-bounded-annotation-work-buffer.md)、[同事舍弃字典契约](../../docs/discard-reason-dictionary.md)。 diff --git a/.scratch/annotation-contiguous-actions/supplement-20260921.md b/.scratch/annotation-contiguous-actions/supplement-20260921.md new file mode 100644 index 00000000..2de9a6be --- /dev/null +++ b/.scratch/annotation-contiguous-actions/supplement-20260921.md @@ -0,0 +1,182 @@ +# 九项追加需求:任务缓冲、密集动作编辑与紧凑工作页 + +Type: grilling + +日期:2026-09-21。状态:Q16–Q32 已全部裁决,追加需求与原方案已合并记录;[正式规格](./spec.md)已发布为 `ready-for-agent`。本文件与[原设计记录](./map.md)保留决策来源,本轮新功能尚未实施,拆票仍待后续阶段。 + +## Notes + +- 用户提供九项追加需求及三张现有界面截图;截图仅作呈现参考,需求以用户文字及后续裁决为准。 +- 本地基线 `587cc9d1`;2026-09-21 已 fetch,远端 `origin/dev` 仍为 `883f47ff`,本地已包含该分支。随后核对全部远端 heads,发现并拉取 `origin/feature/discard-reason-dictionary=6072116e`:同事的新功能尚未合入 dev,不能遗漏。`origin/poc` 另更新为 `549d2e65`,本轮未合并该分支。 +- 原 Q1–Q15 中未被本次明确替代的规则继续保留,包括默认摄像机偏好、C 选左段、Ctrl+X 所选区间直接保存无效、待标注不能送检、保存进度、未保存文字保护与任务/阶段撤销边界。 +- 本轮需求讨论只更新设计记录。讨论后按用户明确要求本地合并同事三个提交,见下方合并记录;未实施 Q1–Q32 新功能,未部署、领取任务或写公司数据。 + +## 用户本轮明确提出 + +| 编号 | 追加要求 | 与既有规则的关系 | +| --- | --- | --- | +| 1 | F 切片字典;G 舍弃原因字典;舍弃与命名入口放在一起,交互形式相似 | 舍弃字典当前实现需核验;动作阶段 F 仍有描述字典职责,需要界定 G 的目标和确认行为 | +| 2 | 最低适配 1413×615;默认左相机;单左、单右、双目均能切分和标注;工作页标题等可移右 | 替代此前提高窗口尺寸的候选方向;单位及可用视频空间待确认。仍是切片一轴、标注两轴 | +| 3 | 所有进度条拖动后立即可继续使用工作台快捷键 | 问题是交互焦点归属;无需因用户所说“取消分级组件”就预设重写组件结构。保留文字、输入法与弹层隔离 | +| 4 | 进入时自动选择项目下拉第一项,能够直接点击开始工作 | 预选不等于自动开始或领取;选择刷新、既有选项是否覆盖待核对 | +| 5 | 删除专注模式的“切回原布局”,返回任务池即可 | 替代原布局随时切换及偏好入口;旧偏好恢复要避免用户困在原布局 | +| 6 | 确认切片后后台生成,直接继续其他可工作的任务;容量可设 2–8,送检成功后补领,超过容量时等待自然回落 | 替代旧“处理期间不切换/不领取”规则;容量计数、调度、失败与停止语义待裁决 | +| 7 | 当前动作的列表回查、选中反馈、与视频/时间轴/上下键联动;首尾循环、固定选中行附近;视频显示标注 JSON | 列表是否包括待标注、JSON 内容与显示方式待裁决;连续动作区间仍不允许重叠 | +| 7a | Shift+左右调整所选动作或切片的结束边界;按下先一帧,持续 1 秒后每 0.5 秒五帧;缩到零合并,扩大可吞并下一段 | 替代 Q15 的最少一帧规则,亦构成 Q9 无动作删除入口的例外;内容继承、最后一段、连吞与撤销需明确 | +| 7b | Ctrl+上下跨六个动作,相当于六次上下 | 明确替代原 Ctrl+上/下定位所选动作起止时间,旧定位是否另配按键需裁决;普通上下及列表同一选中目标 | +| 8 | 去除“保留片段·正常标注与交付”等含义不清、占空间的文字 | 可去默认状态大块文案,但明确舍弃的可辨识状态与原因不能因此丢失 | +| 9 | 不改变页面风格;同步维护切片、标注两阶段快捷键提示;与原讨论一并处理冲突 | 允许标题移右、列表等本轮明确的局部调整,不恢复之前被否定的整页重排 | + +## 设计树 + +1. 视图:内容区尺寸口径 → 左右空间分配与最小视频尺寸 → 左/右/双目及字典、列表、JSON 的低高度可用性;移除切换入口后的旧偏好兼容。 +2. 字典与舍弃:现有配置事实 → G 作用目标、选择后的确认/保存、恢复方式、空字典与无效动作的区分。 +3. 密集编辑:当前区间列表范围与选中目标 → 首尾循环、跳六段、导航与播放头;边界合并继承 → 连吞限制、最后一段、切片舍弃冲突、撤销。 +4. 连续工作:后台切片与领取事实 → 个人任务缓冲池范围和计数 → 容量默认/补齐时机、任务顺序、失败与未知结果、停止/返回/刷新、多页及审核退回。 +5. 验收:拖动后键盘焦点 → 不同拖动方式与输入隔离;项目预选与开始工作;两阶段帮助与权限、窗口状态。 + +## 第一轮记录(接续 Q1–Q15) + +| 问题 | 推荐 | 备选 | 状态 | +| --- | --- | --- | --- | +| Q16 尺寸口径 | 1413×615 为网页实际内容区 | 整屏分辨率,另扣工具栏 | 已采用推荐 | +| Q17 动作边界合并后的判断 | 保留存活区间描述/无效状态,整次按住可一次撤销 | 合并后待标注 | 已采用推荐 | +| Q18 列表范围 | 当前切片全部动作区间(待标注/描述/无效),不是旧版本审计日志 | 只列已完成动作 | 已采用推荐 | +| Q19 视频标注信息 | 播放头对应的简短描述/状态常显,完整只读 JSON 按需展开 | 始终完整 JSON;旁边显示 | 已采用推荐 | + +## Decisions-so-far + +- Q16:1413×615 指浏览器实际网页内容区;正式替代之前未定的较大候选,不以显示器标称分辨率验收。三种摄像机视图与两阶段核心操作均须可达。 +- Q17:A=[0,10)、B=[10,20),A 缩至零后 B 覆盖 [0,20),保留 B 的判断;A 扩到 20 后 A 覆盖 [0,20),保留 A 的判断。被吞并的旧描述/无效结果可通过整次操作撤销恢复;不删除媒体。 +- Q18:动作列表展示当前切片完整分区,包括待标注/描述/无效;点击、上下、跨六段导航共用选中项。首尾循环,选中行尽量保持固定视觉位置。它不是旧版本日志。 +- Q19:视频角落显示播放头所在动作的简短描述/状态,完整 JSON 按需展开且只读。明确选中项用于编辑,不随播放经过其他动作而擅自换掉编辑目标。 +- Q20:G 在切片/标注阶段均针对当前切片打开舍弃原因选择,支持搜索、分页与键盘选择;Enter 选原因,按字典要求填写说明,再 Ctrl+Enter 确认舍弃。保留明确的已舍弃状态和恢复入口;F 仍按阶段打开切片名称/动作描述字典。 +- Q21:Shift+左右一次按住最多合并一个相邻区间,以按下时的邻段为上限;到界停止,松开后重新按才继续。最后一段结束固定,不能把单段缩空。鼠标拖动仍保证相邻两段各至少一帧。切片阶段只调切片并继承存活片名称,已舍弃片须先恢复;标注阶段只调动作。 +- Q22:Alt+上/下接替当前动作起止定位;Ctrl+上/下改为当前切片内循环跨六个动作,与上下键和列表共用选中项并定位目标结束时间。动作数较少时循环六步可能回到原项,已明确接受。 +- Q23:个人任务缓冲池按当前账号+当前项目计算,默认容量 2,可设 2–8。待切片、切片生成中、待标注、送检处理中、失败待处理均占位;真实送检成功才腾出名额。调小不释放已领取任务,超额时停止补领,直至低于容量。 +- Q24:用户选择维持现有退回规则——回公共池,再随机领取;不自动归还原标注员。退回本身不会自动计入原人的个人缓冲池,之前“被回退导致超额”的设想据此撤回。调小容量导致已有任务超额仍按 Q23 处理。 +- Q25:显式开始/继续时补满设定容量;实际送检成功或增大容量后补足;容量按账号+项目保存。暂停、返回、关闭或刷新后不自动领取,重新明确继续才补。公共池不足时只领实际可得数量。 +- Q26:确认切片获得服务端已受理的确定结果后可切走;下一项优先已生成待标注,其次待切片,同类按领取先后。后台完成不抢当前编辑任务,满容量且全部处理中时等待,不超额领取。 +- Q27:单任务切片/送检失败不阻断其他可工作任务;保留失败任务及容量占位,提供明显提示和重试入口。结果未知时核对原请求,不重复提交,也不假定成功而补领。 +- Q28:原“完成当前任务后停止”改为“暂停连续工作”,立即停自动切换与补领,保留编辑及已发出的后台处理。返回任务池同样暂停;之后明确继续才恢复。 +- Q29:JSON 为当前动作的实时编辑预览,明确标记已保存/未保存,包含描述、状态与时间范围;不将其称为最终交付 JSON。 +- Q30:列表点击、上下、Ctrl+上下以及 Alt+下定位目标动作的最后一个可编辑帧,确保画面与按播放头展示的信息属于目标动作。编辑区/保存数据仍使用真实排他结束边界,C 后停切分点不变;Alt+上仍定位开始帧。 +- Q31:手动“随机领取”和自动补领共同受当前账号+项目容量限制,继续已领取任务不受影响,已有超额任务不释放;不能用手动入口绕过容量。 +- Q32:1413×615 下以视频、时间轴、动作列表和编辑操作完整可用为优先,标题移右、列表使用左侧窄区;视频完整等比自适应,不裁切,不再坚持旧方案固定最小画面像素,扩大窗口后自动放大,保持既有页面风格。 +- 原先已确认的连续覆盖和未保存文字保护仍适用。新要求不允许真实动作区间重叠;密集短区间的可辨识性由列表和选中反馈改善。 + +## 最新代码核验 + +### 同事的独立字典分支 + +- `32534003`:项目成员名称不再依赖“添加账号”候选列表,响应直接提供可见用户姓名、邮箱和状态。 +- `3affa0df`:新增 `discard_reason` 第三类字典、组织管理与项目启用;舍弃必须从项目启用词条单选。“其他”或 `requiresNote` 要求补充说明,最多 1000 字。新舍弃不能用自由文本绕过,历史文本保持“历史填写”,恢复不依赖字典可用性。 +- `6072116e`:修复 Mongo 路径恢复片段时丢失既有舍弃历史的问题。 +- 来源:该分支 `docs/discard-reason-dictionary.md`、`docs/project-member-display.md`、`src/components/DiscardReasonFields.tsx`、`internal/api/discard_reason_dictionary.go` 与 `slice_disposition.go`。字典 ID/版本/名称/说明快照、审核产物和历史兼容均应复用。 +- 当前上游舍弃交互仍是搜索框、原生选择框、说明框及确认按钮,尚无 G 键或统一分页键盘选择。新需求应改造已有选择界面,不重建字典契约。 + +### 快捷键与布局事实(当前本地基线) + +- 两个 range 共用 `CaptureAnnotationWorkbench.tsx:701–728`,结束拖动只 `finishScrub`,不回工作台焦点;根点击又排除 input(1564–1571),解析器将其视作原生控件(1598–1603)。与 Space/Ctrl+X 等被控件拦截相符,尚未浏览器复现,不能泛称所有键都失效。 +- 现有时间轴边界拖动已经归还焦点。修复目标为统一非文字进度控件的键盘归属,不要求拆除组件架构;文本/输入法/字典/弹窗继续拥有各自键盘行为。 +- `capture-workspace.css:1209–1240` 主动隐藏单路视图详细时间轴;`AnnotationOperations.tsx:520–539` 当前 1280×640 门槛会阻止 1413×615。标题移右理论可回收左侧约 62–70px,但须实际验证右编辑区及字典、长文字、错误状态。 +- 删除布局切换按钮时,独立工作页应统一采用专注布局,避免旧 `original` 偏好让用户困在旧布局;任务池普通工作台仍保留。 +- 默认项目取当前下拉顺序第一项,仅在没有选择/有效深链接时采用,不覆盖正在工作的项目;不因项目列表刷新跳项目,不等于自动开始/领取,无权限项目维持空状态。 + +### 任务状态事实 + +- 确认切片已返回 HTTP 202 并使用持久后台任务,但当前 UI 留在生成页。最终真实送检成功后才自动续接,旧“处理期间不会领取”需更改。 +- `mine` 包含已送检项,不能直接用数组长度作为占位;当前续作筛选也没有完整排除后台处理中任务。 +- 当前随机领取已有权限、原子归属和请求回执幂等,但没有个人容量 2–8 的额度约束。多浏览器安全需要服务端保证,不能只靠前端数数。 +- 当前退回会清空 `AssignedUserID`,回到可领取池,而不是自动返还原标注员。用户提出的退回超额若要成立,需要新增归属规则。 +- 已舍弃切片的边界和记录受服务端保护,须先恢复才能改界;舍弃/恢复本身仍有权威保存和历史证据。动作标无效与舍弃不同。 + +## 第二轮记录 + +| 问题 | 推荐 | 备选 | 状态 | +| --- | --- | --- | --- | +| Q20 G 选择与提交 | 当前切片,搜索分页,Enter 选原因,必要时补充说明,Ctrl+Enter 确认舍弃;保留恢复入口 | 普通词条选择即舍弃 | 已采用推荐 | +| Q21 微调边界保护 | 一次按住最多合并一邻段,末段结束固定;鼠标仍各至少一帧;切片阶段改切片、标注阶段改动作,舍弃片须先恢复 | 鼠标也允许缩零合并 | 已采用推荐 | +| Q22 起止定位替代 | Alt+上下定位当前动作起止,Ctrl+上下按循环跳六段 | 取消起止快捷键 | 已采用推荐 | +| Q23 容量范围 | 账号+项目,未真实送检者占位,默认2,可调2–8,不主动释放超额任务 | 账号跨项目总量 | 已采用推荐 | +| Q24 退回归属 | 自动回原标注员;原人无权限/停用则管理员处理 | 维持公共池随机领取 | 已选择维持公共池 | + +## 第三轮记录 + +| 问题 | 推荐 | 备选 | 状态 | +| --- | --- | --- | --- | +| Q25 补齐时机 | 显式开始/继续、真实送检成功或增大容量后补齐;退出/暂停/刷新后不自动领取;容量按账号项目保存 | 开始一条,按需逐步补 | 已采用推荐 | +| Q26 调度顺序 | 服务端确认受理切片后才切走;已生成待标注优先,再待切片,同类按领取时间;后台就绪不抢当前任务,满池处理中则等 | 纯领取顺序并跳过处理中 | 已采用推荐 | +| Q27 后台失败 | 显示失败并保留占位,允许做其他任务;未知结果核对原请求,不当成功补领 | 任一失败暂停整池 | 已采用推荐 | +| Q28 停止语义 | “暂停连续工作”立即停补领与自动切换;后台任务不中止,编辑保留,返回任务池也暂停 | 当前任务送检后停止 | 已采用推荐 | +| Q29 JSON 保存状态 | 实时编辑预览,明确已保存/未保存,不冒充最终交付文件 | 仅服务器已保存结果 | 已采用推荐 | + +## 第四轮记录 + +| 问题 | 推荐 | 备选 | 状态 | +| --- | --- | --- | --- | +| Q30 导航结束画面 | 列表/上下/跨六段/Alt+下停目标最后一个可编辑帧,结束边界字段及 C 停点不变 | 仍停精确排他结束边界 | 已采用推荐 | +| Q31 手动领取容量 | 所有标注员随机领取入口共用账号+项目容量,已领任务不释放 | 仅自动补领受限 | 已采用推荐 | +| Q32 低高度画面取舍 | 保持完整等比,以核心操作和列表可见优先,取消旧固定画面像素下限 | 低高度默认收起列表以放大画面 | 已采用推荐 | + +### Q30 的源码依据 + +`internal/api/annotation_boundary_grid.go:10–11` 和物化产物约定为半开区间 `[start,end)`。当前 `CaptureAnnotationWorkbench.tsx:1472` 导航原样 seek 到 `end`;`media-seek-queue.js:1–7` 还向边界后偏微量,以免浮点误差显示前帧。因此 A.end=B.start 时,选择 A 的结束实际可显示 B 首帧,与按播放头展示 JSON 有冲突。若采用推荐,仅导航选择使用 end 前的统一帧边界,不改保存范围,不减固定 1/30 秒,不全局改变 seek。此为源码结论,尚未浏览器复现。 + +## 合并后的操作约束 + +- 页面:保留现有颜色、组件风格和编辑习惯;只做本轮明确允许的标题/状态右移、左侧动作列表、相机与字典入口的局部排版。点击画面同步播放/暂停;默认左路及独立默认视图偏好沿用原 Q1/Q12。三种视图均保留当前阶段所需时间轴,不再隐藏。 +- 项目与布局:无既有项目或有效任务链接时默认选下拉第一项,不覆盖手动选择或随刷新切换项目;不自动开始领取。独立工作页移除“切回原布局”,忽略旧工作页 original 偏好;仍可返回任务池的普通工作台。两种工作台共用业务与编辑键位。 +- 文案:去除默认“保留片段·正常标注与交付”的大块状态区;明确舍弃时仍有小型状态、原因与恢复入口。G 不自动翻转当前用途,恢复保持明确确认。沿用同事的必填说明、字典版本、历史快照和媒体审核规则。 +- 焦点:操作进度条后归还工作台键盘控制,适用于点击、拖动、外部松手及取消;不破坏文字输入、输入法、字典选择或弹层内部键位。以行为为验收,不以是否拆分组件为验收。 +- 动作:列表、时间轴、编辑区共用明确选中项。手动滚列表不自动更改选中;导航立即选中,动画只作反馈,首尾循环不长距离滚过全部条目。播放头所在动作的摘要独立更新;JSON 是带保存状态的只读编辑预览。 +- 帧微调:Shift+左右按下立即一帧,持续满 1 秒后进入每 0.5 秒五帧的加速;使用真实统一帧边界。单次最多合并一个邻段,到界停止;按键松开、窗口失焦、打开弹层、任务或阶段改变时停止重复。一次按住为一次撤销,改动作为编辑进度保存,不逐次按键自动发保存请求。未保存文字先按原 Q14 处理。 +- 原 Q9 取消独立动作删除入口仍保留,但 Q17/Q21 明确允许键盘结束边界合并这一例外;鼠标拖动仍各至少一帧。切片末尾和整个任务范围不得缩空,已舍弃片须先恢复。 +- 连续工作:按项目、账号容量预领,后台切片受理后先做其他可操作任务;待标注优先。生成和送检处理均计入容量,只有真实送检成功才腾位;单条失败保留并提示,不导致已领取任务丢失。暂停不取消已发出的后台处理,不重新发起未知结果请求。 +- 旧保护:原任务/阶段撤销边界、未保存文字、冲突与未知结果核对、权限、同浏览器工作页互斥、窗口不足暂停并手动继续等规则保留。多个浏览器的领取容量应由服务端共同保证,前端互斥不冒充跨设备锁。 + +## 快捷键变化对照 + +| 按键 | 切片阶段 | 标注阶段 | +| --- | --- | --- | +| F(已有 D 别名沿用) | 切片名称字典 | 动作描述字典 | +| G | 当前切片舍弃原因字典 | 当前切片舍弃原因字典,不是动作无效 | +| C | 播放头切分切片 | 播放头切分动作区间,取代 N | +| Ctrl+X | 不启用动作无效命令;输入框仍是剪切文字 | 所选动作标无效并保存,可撤销 | +| 上/下 | 不新增动作导航 | 循环上/下动作,联动列表并停目标末帧 | +| Ctrl+上/下 | 不新增动作导航 | 循环跨六个动作,停目标末帧 | +| Alt+上/下 | 不新增动作定位 | 当前动作开始帧/最后可编辑帧 | +| Shift+左/右 | 当前切片结束边界前/后一帧,可按规定合并 | 当前动作结束边界前/后一帧,可按规定合并 | +| Ctrl+Enter | 原切片确认流程;舍弃面板内确认舍弃 | 当前描述保存;舍弃面板内确认舍弃 | + +其余播放、逐帧、切片切换、B 复查、V 工作点、撤销/重做等按原规则保留。两阶段帮助分别显示本阶段可用键位;Mac 的既有 Ctrl/Command 别名和输入框原生编辑规则延续。 + +## Fog + +- Q16–Q32 已逐项获得回答,无仍待裁决的本轮选项;正式规格已合并旧记录中仍有效的规则,不把已替代的旧要求继续列为验收条件。实现以规格为准,本文件保留问答历史与事实核验来源。 +- 同事的字典分支 `6072116e` 已按用户要求合入本地,工作入口修复与全部设计记录保留;后续实现直接基于该合并结果。poc 的其他平台/同步工具变更不在本轮合并范围内。 +- 目前历史规格明确处理期间不领取、真实送检成功再续接;该契约必须与后台流水作业一并替代,不能只改一段提示文字。 +- 帧调整须基于真实帧位置,不将“五帧”简单当成固定秒数;区间仍需连续、无重叠、完整覆盖。零长度是合并动作,不能留下零长度记录。 +- 1413×615 下真实视频尺寸、三种相机、字典、50 段以上动作列表及错误提示尚未做产品浏览器验证。当前是源码与需求核验,不宣称界面已经可用或问题已修复。 + +## 本地代码合并与需求影响 + +2026-09-21,按用户“同事新代码合并本地”的指示,再次获取最新远端:`dev` 仍为 `883f47ff`,字典分支仍为 `6072116e`。将该分支的三个提交合入本地 `feature/local-dev-toolkit`(合并前 `09bb9b41`),自动合并成功,无冲突。对照同事分支核验 `AnnotationOperations.tsx`,本地额外的帧初始化/干净基线修复完整保留;没有合并 poc 的其他变更。 + +**结论:不需要重新裁决业务需求。** Q20 和 Q21 已按这条同事分支设计。后续实现范围及验收应明确为: + +1. 不再开发舍弃字典管理、项目启用、保存接口和原因快照;复用合并后的实现,扩展 G 入口、与 F 一致的搜索/分页/选择交互、确认和焦点恢复。 +2. 新舍弃必须选当前项目启用的词条,不能把自由文本作为替代;“其他”及要求说明的词条必须补充说明。字典为空、词条停用或版本变化时要显示可恢复的错误,不能让快捷键绕过后端规则。 +3. 保留历史自由文本、舍弃及恢复的前后快照,字典改名不回写历史;恢复不依赖字典可用性。验收覆盖已舍弃片段恢复后的历史保留,以及新生成/复用媒体中的原因快照。已舍弃片段仍须先恢复才能调边界或合并。 +4. 1413×615、动作列表、连续动作分区、Shift 微调、任务缓冲池、退回公共池、暂停连续工作等既定需求维持不变;同事这三个提交没有实现或改变它们。项目成员显示修复直接保留,不扩大标注方案范围。 + +合并后基础验证: + +- `npm run lint:web`:通过。 +- `npm run build:web`:通过;有 Node 弃用提示和大 chunk 提示,无构建失败。 +- `go build ./...`:通过。 +- 运行 `internal/api` 中 4 个 `TestDiscardReason*`、`TestProjectMemberDisplayScopedBatch` 及 4 个舍弃/恢复/覆盖保护测试:通过。使用隔离 fixture,未运行线上 live 测试;同命令的 `internal/store` 没有匹配测试。 +- `node --test tests/frontend/slice-disposition.test.mjs tests/frontend/annotation-authoritative-mutation.test.mjs tests/frontend/annotation-timeline-initialization.test.mjs`:19 项通过、0 失败。 +- `git diff --cached --check`:通过。 + +这些是本地合并兼容检查,不等于新需求浏览器验收或公司部署验证。没有启动或重启业务服务,没有推送远端或部署。 diff --git a/.scratch/annotation-contiguous-actions/ticket-breakdown-draft.md b/.scratch/annotation-contiguous-actions/ticket-breakdown-draft.md new file mode 100644 index 00000000..9dd9aeed --- /dev/null +++ b/.scratch/annotation-contiguous-actions/ticket-breakdown-draft.md @@ -0,0 +1,302 @@ +# 连续动作标注任务拆分草案 + +日期:2026-09-21。阶段:用户已授权按本拆分协调实施;17 张任务票已发布至 `issues/`。 + +依据已发布的《泛宇连续动作标注与任务缓冲工作页规格》,包含 Q1–Q32 最终裁决和同事已合并的字典实现。父规格不修改、不关闭。以下 17 项为已获实施授权的纵向切片,每票负责自己的可观察行为及保存/回读验证;不是先写所有前端、再写后端、最后补测试。 + +## 拆分原则 + +- 每项能在一个新的上下文窗口中完成并独立演示;复用已存在的应用接口,不要求每项都创造新 schema 或新 API。 +- 未发现必须先做的大范围机械重构。不另设横向“全局重构/搭建测试层”票;每项如需局部整理,先保行为整理再实现该项。共享动作分区随 05 建立,共享帧手势随 10 交付后由 11 复用,共享容量约束随 13 交付。 +- 依赖只表示功能先决条件;共享同一组件文件可能需要串行整合,但不自动成为业务阻塞边。 +- 每票遵循范围隔离、身份/版本校验、失败与未知结果核对、原任务/阶段撤销边界、输入法和弹层键盘归属。涉及新增键位的票同步更新对应帮助;17 复核整体一致性。 +- 独立可验收不等于可提前对客户发布不完整业务。整个功能交付以 17 的完整组合验收为收口,不以中间状态替代正式规格。 +- 当前只有评审草案。确认后才按依赖顺序发布一票一文件,标记 ready-for-agent;不会把本草案当作一张混合实施票。 + +## 编号总览 + +1. **视频点击播放与进度条焦点恢复**。阻塞于:无。交付:在两种工作台里,点击任一视频同步播放/暂停,拖完任意进度条立即继续用快捷键。 + +2. **默认项目与统一专注工作入口**。阻塞于:无。交付:默认预选首个可用项目,独立工作页固定专注布局;保留任务池普通工作台和明确的开始/返回。 + +3. **相机默认偏好与单路完整时间轴**。阻塞于:无。交付:默认左相机,可单独设置左/右/双目默认;三种视图均能使用本阶段时间轴。 + +4. **G 舍弃字典与明确确认恢复**。阻塞于:无。交付:复用同事字典,在切片和标注阶段通过 G 搜索/分页选择原因,确认舍弃并可明确恢复。 + +5. **连续动作分区与保存进度**。阻塞于:无。交付:需要标注的切片呈现完整待标注/已描述/无效分区,未完成的分区可保存并在刷新后恢复。 + +6. **C 连续切分与描述确认**。阻塞于:05。交付:用 C 切动作,选中刚看完的左段;可连续切分后填写,只有真实改字才触发保护。 + +7. **所选动作无效判断与保存后撤销**。阻塞于:06。交付:Ctrl+X 或鼠标只将明确选中的动作保存为无效,误操作可一次撤销恢复原判断。 + +8. **密集动作列表与循环键盘导航**。阻塞于:06。交付:用当前切片动作列表准确选中 50 段以上短动作;上下、跨六段和起止定位与时间轴联动。 + +9. **视频动作摘要与 JSON 编辑预览**。阻塞于:05。交付:视频角落显示播放头所在动作摘要,按需展开只读 JSON,清楚区分已保存与未保存内容。 + +10. **动作结束边界微调与可撤销合并**。阻塞于:06。交付:Shift+左右按真实帧微调动作结束,支持长按加速及有上限的相邻合并,并可保存恢复。 + +11. **切片结束边界微调与舍弃保护**。阻塞于:10。交付:把已验收的帧微调与合并手势用于切片阶段,保留存活片名称和舍弃证据。 + +12. **完整动作覆盖才可送检**。阻塞于:07。交付:已描述或明确无效的动作完整覆盖后才允许正式送检,同时保留舍弃、旧结果和范围外规则。 + +13. **个人容量设置与统一领取上限**。阻塞于:无。交付:按账号+项目保存默认 2、可设 2–8 的容量,所有手动和自动随机领取都不能绕过它。 + +14. **开始补齐与立即暂停连续工作**。阻塞于:02、13。交付:从已确定的工作入口显式开始/继续时补满容量;暂停、返回、刷新后停止自动领取。 + +15. **后台切片期间接续其他任务**。阻塞于:14。交付:切片后台任务被确定受理后自动打开另一条可工作任务,生成完成不打断当前编辑。 + +16. **送检成功补位与连续作业恢复**。阻塞于:15。交付:只有实际送检成功才补一个名额;送检失败、未知结果和审核退回都能持续正确处理。 + +17. **1413×615 完整工作页与集成验收**。阻塞于:01、03、04、08、09、11、12、16。交付:把全部已交付能力放入既有风格的最低尺寸工作页,验证两阶段三视图及完整连续作业。 + +## 每项的验收边界 + +### 01 视频点击播放与进度条焦点恢复 + +**What to build:** 在两种工作台里,点击任一视频同步播放/暂停,拖完任意进度条立即继续用快捷键。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A05、A08、A09;用户故事重点:14–15、24–28。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 视频点击与画面控件点击不双触发;忙碌、只读及未就绪状态不绕过。 +- [ ] 覆盖点击、拖动、外部松手和取消,完成后 Space 等可用命令由工作台处理。 +- [ ] 中文输入法、文本编辑、字典和弹层保留键盘所有权;一次 Esc 返回后可播放。 +- [ ] 通过真实浏览器验证同步播放、焦点和阶段原有快捷键,保持原有视觉风格。 + +### 02 默认项目与统一专注工作入口 + +**What to build:** 默认预选首个可用项目,独立工作页固定专注布局;保留任务池普通工作台和明确的开始/返回。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A06、A07;用户故事重点:18–23。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 仅无有效选择或深链接时预选首项,刷新不覆盖手动项目,不自动领取。 +- [ ] 空项目及管理员全项目语义不变,明确续做入口仍打开指定任务。 +- [ ] 删除切回原布局按钮并兼容旧 original 偏好,避免旧偏好把用户困在普通布局。 +- [ ] 返回任务池停止现有自动工作并保留未保存内容保护;本票不引入新的缓冲调度。 +- [ ] 浏览器验证首项、深链接、旧偏好、返回及没有意外领取请求。 + +### 03 相机默认偏好与单路完整时间轴 + +**What to build:** 默认左相机,可单独设置左/右/双目默认;三种视图均能使用本阶段时间轴。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A04、A01;用户故事重点:7–13。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 偏好按账号与浏览器隔离;临时切换不回写默认。 +- [ ] 首次专注入口及新任务用默认,同任务换阶段保留临时视图,改默认不抢当前视图。 +- [ ] 切片只一条 Capture 轴、标注两条轴;单路不隐藏轨道或留下空行。 +- [ ] 视频与编辑状态在视图切换时保留,真实浏览器验证两阶段三视图及偏好生命周期。 +- [ ] 本票交付可操作的相机行为;包含全部新增区域的 1413×615 最终排版由 17 完成。 + +### 04 G 舍弃字典与明确确认恢复 + +**What to build:** 复用同事字典,在切片和标注阶段通过 G 搜索/分页选择原因,确认舍弃并可明确恢复。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A26、A27、A28、A09;用户故事重点:78–85。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] F/D 按阶段使用原字典,G 永远针对当前切片;原因选择支持上下、左右翻页、Enter、Esc。 +- [ ] Enter 选原因、Ctrl/Command+Enter 确认;按项目词条规则补充说明,不由选择动作直接舍弃。 +- [ ] 空字典、停用、旧版本和切片名称错误可恢复,保留原因草稿,不绕过接口校验。 +- [ ] 去除默认大块保留文案,已舍弃状态、原因及明确恢复入口保留;恢复不依赖字典可用性。 +- [ ] 通过真实浏览器+保存回读验证历史自由文本、原因快照、恢复历史,保留同事成员显示修复。 + +### 05 连续动作分区与保存进度 + +**What to build:** 需要标注的切片呈现完整待标注/已描述/无效分区,未完成的分区可保存并在刷新后恢复。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A10、A13、A31;用户故事重点:29–30、37、39、48–49、51。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 确定泛宇人工流程的可信适用范围,其他客户/流程不改变;新片整段待标注。 +- [ ] 可编辑历史任务保留描述和边界,只补合法空白;已送检/验收数据不回写,异常数据不静默裁切。 +- [ ] 公开保存和回读区分待标注、确认描述和无效;有草稿文字不自动完成。 +- [ ] 保存进度按钮可持久化未完成划分,不送检;刷新恢复,服务端版本/归属和错误核对继续有效。 +- [ ] 帧对齐与待标注初始化不得吸收真实编辑或阻挡开始工作;提供浏览器及公开 API 回读证据。 + +### 06 C 连续切分与描述确认 + +**What to build:** 用 C 切动作,选中刚看完的左段;可连续切分后填写,只有真实改字才触发保护。 + +**Blocked by:** 05 连续动作分区与保存进度 + +**规格验收:** A11、A12、A14、A43;用户故事重点:31–36、38、45。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] C 使用真实合法内部帧,切后暂停在切点、选左、不强制文本焦点;左继承,右待标注。 +- [ ] 边界及一帧区间不生成零长度动作;取消 N 与独立动作删除按钮/快捷键。 +- [ ] 空白未改编辑器不阻挡导航和继续切分,真实改字先保存或取消,不能串到其他段。 +- [ ] 保存描述/Ctrl+Enter 仅确认当前描述,不在同次输入继续送检;切分后保存刷新可回读。 +- [ ] 切分和描述确认保留当前阶段撤销、重做与节流,浏览器覆盖连续操作及失效状态。 + +### 07 所选动作无效判断与保存后撤销 + +**What to build:** Ctrl+X 或鼠标只将明确选中的动作保存为无效,误操作可一次撤销恢复原判断。 + +**Blocked by:** 06 C 连续切分与描述确认 + +**规格验收:** A15、A16、A43;用户故事重点:40–44。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 播放头在别处不改变目标,无选中不执行;文本输入仍原生剪切,切片阶段不变成舍弃。 +- [ ] 沿用 06 的文本改动保护,失败或未知结果不伪报完成,忙碌/版本/归属校验有效。 +- [ ] 无效结果保留动作和媒体;保存后撤销/重做通过公开写入和回读恢复完整内容及状态。 +- [ ] 浏览器覆盖描述改无效、空白改无效、请求失败/未知/冲突,不扩大到跨任务阶段撤销。 + +### 08 密集动作列表与循环键盘导航 + +**What to build:** 用当前切片动作列表准确选中 50 段以上短动作;上下、跨六段和起止定位与时间轴联动。 + +**Blocked by:** 06 C 连续切分与描述确认 + +**规格验收:** A17、A18、A19、A12;用户故事重点:52–60。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 待标注、描述、无效全部按时间展示;列表、时间轴和编辑器同一明确选中项。 +- [ ] 上下循环一步、Ctrl/Command+上下循环六步,少量动作按模数返回;不跨切片。 +- [ ] 列表点击和结束导航停目标最后可编辑帧,Alt+上定位开始;保存 end 与 C 切点不改变。 +- [ ] 选择即时生效,选中行尽量稳定、首尾不长距离动画;手动滚动不改选中,真实改字受保护。 +- [ ] 浏览器验证 1/3/50+ 动作、相邻半开边界、末动作和单帧动作,修改后保存回读。 + +### 09 视频动作摘要与 JSON 编辑预览 + +**What to build:** 视频角落显示播放头所在动作摘要,按需展开只读 JSON,清楚区分已保存与未保存内容。 + +**Blocked by:** 05 连续动作分区与保存进度 + +**规格验收:** A20、A05;用户故事重点:61–64。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 摘要按真实播放位置更新,显示描述/待标注/无效;不得因播放而改变明确编辑目标。 +- [ ] JSON 展示实时编辑预览、保存状态和注明基准的时间范围,不冒充交付文件或允许直接编辑 JSON。 +- [ ] 展开、关闭及长文本不误触播放,不使现有操作不可达;保存成功/失败后标识与回读一致。 +- [ ] 复用当前动作选择即可独立验证;与新列表导航和最低窗口组合在 17 验收。 + +### 10 动作结束边界微调与可撤销合并 + +**What to build:** Shift+左右按真实帧微调动作结束,支持长按加速及有上限的相邻合并,并可保存恢复。 + +**Blocked by:** 06 C 连续切分与描述确认 + +**规格验收:** A21、A22、A23、A24、A16;用户故事重点:65–72、76–77。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 单击一帧,满一秒后五帧/0.5秒;使用真实帧边界并钳制终点,两侧联动无空白/重叠。 +- [ ] 缩零由后一段接管,扩到下一段尾由当前段接管;保留存活判断,被覆盖描述或无效可一次撤销。 +- [ ] 一次按住最多合并开始时的一个邻段,到界停止;最后端点固定,单段不能缩空。 +- [ ] 鼠标仍两侧各至少一帧;一手势一撤销,真实改字保护,失焦/取消/弹层/换任务停重复。 +- [ ] 编辑后保存进度并刷新回读完整分区,验证混合判断及失败/冲突;在可工作的动作路径内整理共享帧手势能力供 11 复用。 + +### 11 切片结束边界微调与舍弃保护 + +**What to build:** 把已验收的帧微调与合并手势用于切片阶段,保留存活片名称和舍弃证据。 + +**Blocked by:** 10 动作结束边界微调与可撤销合并 + +**规格验收:** A21、A23、A24、A25;用户故事重点:73–75。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] Shift+左右仅在切片阶段调整切片,标注阶段不能修改已生成切片边界。 +- [ ] 复用 10 的加速、到界停止、失焦取消和一手势一撤销;鼠标不缩零,首尾与完整覆盖不丢失。 +- [ ] 合并保留存活切片名称,不拼名;已舍弃片及相关共享边界先恢复才允许改动。 +- [ ] 通过浏览器确认切片并公开回读验证新边界;恢复舍弃后历史和媒体审核证据保留。 + +### 12 完整动作覆盖才可送检 + +**What to build:** 已描述或明确无效的动作完整覆盖后才允许正式送检,同时保留舍弃、旧结果和范围外规则。 + +**Blocked by:** 07 所选动作无效判断与保存后撤销 + +**规格验收:** A29、A30、A31、A28;用户故事重点:46–51。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 界面、直接/旧客户端请求、异步完整生成和复用媒体更新路径都拒绝待标注、缺段、重叠、越界及非法帧。 +- [ ] 普通保存进度仍允许未完成,不能将草稿校验错误提升成必须完成才可保存。 +- [ ] 正常完整描述、含无效、混合舍弃和全部舍弃均走真实送检,审核证据及原因快照保持。 +- [ ] 历史可编辑/退回按新规则;已送检/验收不追改,其他流程保留旧政策;舍弃恢复后的空白重新待标注。 +- [ ] 从真实工作台完成并回读质检状态,补充绕过界面和两种后台产物路径的接口证据。 + +### 13 个人容量设置与统一领取上限 + +**What to build:** 按账号+项目保存默认 2、可设 2–8 的容量,所有手动和自动随机领取都不能绕过它。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A32、A34、A35、A36、A42;用户故事重点:86–89、101。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 界面可配置并回读容量,拒绝非法值;可信流程范围和账号项目隔离有效。 +- [ ] 待切、生成中、待标注、送检中和失败占位,真正交质检才释放;不能直接使用我的任务列表长度。 +- [ ] 降低容量保留已有任务,不释放或隐藏;等于/超过上限不新领。 +- [ ] 服务端原子处理并发容量、归属与幂等回执;重放原成功领取不再占位,也不能因满容量丢失核对。 +- [ ] 浏览器手动领取与并发公开请求验证跨页/跨浏览器、权限变化及公共池不足,不新增自动补齐行为。 + +### 14 开始补齐与立即暂停连续工作 + +**What to build:** 从已确定的工作入口显式开始/继续时补满容量;暂停、返回、刷新后停止自动领取。 + +**Blocked by:** 02 默认项目与统一专注工作入口;13 个人容量设置与统一领取上限 + +**规格验收:** A33、A36、A41、A42、A07;用户故事重点:90、99–100、102。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 开始/继续按当前账号项目补齐可用容量,公共池不足只领实际数量;增大容量只在激活状态补齐。 +- [ ] 立即暂停取代完成后停止,保留当前编辑及已发后台任务,不主动释放已领取任务。 +- [ ] 返回、关闭、刷新后需明确继续;已发领取响应核对并保留归属,但不能再补领或抢占导航。 +- [ ] 保留同浏览器互斥和 HTTP 手动模式限制;窗口/身份/权限变化和迟到响应不绕过控制。 +- [ ] 独立演示开始补齐→暂停→返回/刷新→明确继续,并用接口回读及请求记录验证。 + +### 15 后台切片期间接续其他任务 + +**What to build:** 切片后台任务被确定受理后自动打开另一条可工作任务,生成完成不打断当前编辑。 + +**Blocked by:** 14 开始补齐与立即暂停连续工作 + +**规格验收:** A37、A38、A41、A42;用户故事重点:91–96。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 仅确定受理后切走,未知请求核对原请求;开始生成仍截断该切片阶段撤销。 +- [ ] 优先已生成待标注,再待切片,同类先领先做;明确续做所选任务不被队列优先级覆盖。 +- [ ] 处理中算占位但不进入编辑;满池都在处理则等待,不超额领取、不暴露候选视频。 +- [ ] 跟踪缓冲内后台状态,不只跟踪屏幕任务;生成就绪不抢当前编辑,生成失败明显提示、占位、可重试并允许做其他任务。 +- [ ] 用真实受理/完成与故障注入证明跨任务接续、原任务可恢复、暂停和迟到结果不触发错误切换。 + +### 16 送检成功补位与连续作业恢复 + +**What to build:** 只有实际送检成功才补一个名额;送检失败、未知结果和审核退回都能持续正确处理。 + +**Blocked by:** 15 后台切片期间接续其他任务 + +**规格验收:** A39、A40、A41、A42、A34;用户故事重点:95–98、102。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 送检受理和真实成功分开,处理中继续占位,真成功且连续激活才补领。 +- [ ] 送检失败保留任务并可重试,不阻断其他可做任务;未知结果核对原请求,不重复送检或补领。 +- [ ] 质检及后续审核按现规则退回公共池,不自动归原人;重新随机领取受共同容量限制。 +- [ ] 暂停/返回/刷新、请求迟到、调小容量和权限变化交错时,不错腾位、不后台偷领、不丢归属。 +- [ ] 端到端执行提交→后台结果→质检回读→补位,另执行失败恢复及退回重新领取;本票复用既有送检边界,12 独立负责新的完整覆盖政策。 + +### 17 1413×615 完整工作页与集成验收 + +**What to build:** 把全部已交付能力放入既有风格的最低尺寸工作页,验证两阶段三视图及完整连续作业。 + +**Blocked by:** 01 视频点击播放与进度条焦点恢复;03 相机默认偏好与单路完整时间轴;04 G 舍弃字典与明确确认恢复;08 密集动作列表与循环键盘导航;09 视频动作摘要与 JSON 编辑预览;11 切片结束边界微调与舍弃保护;12 完整动作覆盖才可送检;16 送检成功补位与连续作业恢复 + +**规格验收:** A01、A02、A03、A43;用户故事重点:1–6、16–17、28、103–104。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 标题/状态局部移右,动作列表窄区放左;视频完整等比,切片一轴、标注两轴,核心编辑保存提交不用整页滚动。 +- [ ] 在 1413×615 与更大/缩放窗口验证三相机、两阶段、50+动作、JSON、字典、长任务名/说明及失败提示,不能把操作挤出窗口。 +- [ ] 不足尺寸暂停播放、长按与自动行为,已发请求继续核对;恢复尺寸须手动继续,任务草稿与撤销保留。 +- [ ] 两阶段快捷键帮助与真实行为一致,普通工作台共享行为不回归;旧 Space、逐帧、B/V、切片导航、撤销边界验证。 +- [ ] 使用真实双目及公开 API 回读走完连续切分→描述/无效→完整送检→后台接续→补位/暂停,复核所有 A01–A43。 +- [ ] 每票此前已有自己的测试,本票补组合与真实完整流程证据、实际运行范围及残余限制;不自动推送/部署。 + +## 依赖核对 + +- 可立即开展:01、02、03、04、05、13。 +- 动作路径:05 → 06 → 07 → 12;06 → 08;05 → 09;06 → 10 → 11。 +- 连续工作路径:02+13 → 14 → 15 → 16。 +- 最终收口:01、03、04、08、09、11、12、16 → 17,其余节点由这些依赖传递覆盖。 +- 09 不依赖 08:原工作台已有明确动作选择,JSON 预览可先独立验证,最终再与新列表组合。 +- 11 不依赖 04:已合入的上游已经有舍弃与恢复约束;G 键选择交互并非切片边界保护的前提。 +- 16 不依赖 12:现有代码已有真实送检状态及公开查询,补位策略可基于其验证;12 负责新的完整覆盖政策,两者在 17 合并验收。 +- 17 依赖全部前置能力的最终叶节点,因为它必须在最低尺寸下验证已完成的全部交互,不是假设其他票可以不验收。 + +## 发布前确认项 + +用户已授权协调完成全部任务、基础验证与审查后部署公司集群验收。独立任务已发布;以任务文件记录实施进展,父规格保持不变。 diff --git a/.scratch/annotation-contiguous-actions/upstream-invalid-audit.md b/.scratch/annotation-contiguous-actions/upstream-invalid-audit.md new file mode 100644 index 00000000..9db27fd3 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/upstream-invalid-audit.md @@ -0,0 +1,40 @@ +# 最新上游无效动作保留规则核验 + +日期:2026-09-18。范围:响应用户 Q9,拉取同事最新代码后核验无效标记、标注删除与媒体交付的区别。只读代码和文档,未运行产品测试,未合并到本地工作分支,未部署或修改业务数据。 + +## 拉取结果 + +- 已检查并脱敏显示既有 Gitea 远端,拉取 `dev`;`origin/dev` 从 `cb474b6a` 更新到 `883f47ff0e52a4e94172a1d6e3b8b7d957374cb9`。 +- 最新提交为上一版 PR #1 的合并提交,合并时间为 2026-09-18 17:59:51 +08:00。`git diff 22d6e68e origin/dev` 为空,最新上游文件树与已发布 PR 头一致,没有额外一版未见过的无效处理改动。 +- 远端 `feature/local-dev-toolkit` 分支已不存在;本地同名分支及其后续修复、设计文档均保留。最初同时获取两个引用时遇到远端个人分支不存在,随后单独拉取 `dev` 成功。 +- 本地工作分支在拉取时仍为 `8e6885c2`。本轮涉及的无效、删除、舍弃、交付代码与最新上游相同。 +- 拉取前后提交记录保存在忽略目录 `local-data/verification/continuous-actions-upstream-20260918/`;没有将凭据写入文档。 + +## 已核实的含义 + +以下行号以 `883f47ff` 的源码为准。 + +| 操作或链路 | 行为 | 依据 | +| --- | --- | --- | +| 标为无效 | 保留动作记录,设置 `isInvalid=true` 和“无效片段”描述/标签 | `internal/domain/annotation_operations.go:101`;`src/components/CaptureAnnotationWorkbench.tsx:1144` | +| 删除动作描述 | 移除该条描述记录并保存,留下语义空白;不删除视频 | `src/components/CaptureAnnotationWorkbench.tsx:1414` | +| 删除切片 | 去掉一个划分并将其范围并入相邻切片,视频处理覆盖不减少 | `src/pages/AnnotationOperations.tsx:2125` | +| 舍弃切片 | 独立的 `deliveryDisposition=discard`,原因必填,动作保留在审核证据中,恢复时回填 | `internal/api/slice_disposition.go:136`、`:168` | +| 完整物化 | 保留切片内全部动作进入 `annotation.json`,不按无效标记排除动作 | `internal/api/human_slice_materialization.go:915` | +| 只更新描述产物 | 同样保留非舍弃切片的全部动作 | `internal/api/annotation_metadata_revision.go:144` | +| 交付打包 | 按切片 keep/discard 筛选;保留切片的视频、PTS、IMU 和 annotation.json 原物化文件进入交付,不按无效动作重新剪视频 | `backend/operators/builtin/package/operator.py:1113`、`:1159` | + +结论:用户所说“无效作为一种动作标注结果保留”与最新实现一致。无效本身不会删除动作或对应媒体;是否排除一个完整切片属于独立的舍弃规则。 + +本仓库未找到“标无效后由后台自动删除对应视频”的后续流程。用户所说的后续后台处理应保留为外部/后续业务约定,不能当成已经交付的现有能力。 + +另外,完整物化、描述更新及旧 Worker 导出的 actions/descriptions 保留“无效片段”文本,但没有显式导出 `isInvalid` 字段(旧 Worker 见 `internal/worker/annotation_gate.go:1060`)。若后续系统需要结构化类别,应明确交付字段契约,不能假定下游已经依据布尔标记工作。 + +## 对设计讨论的影响 + +- Q10 已确认:Ctrl+X 直接保存所选区间的无效判断,可撤销;它不触发舍弃或媒体删除。 +- 撤回 Q9 原建议中的“删除时清空无效标记”。用户未接受该方案。 +- 核验后重新提出 Q9,用户确认取消动作编辑区删除按钮/快捷键,使用修改、改判和撤销纠错;没有选择保留清空普通描述入口。连续区间保留,不把无效偷偷转为舍弃。 +- 已确定的切片删除、舍弃及撤销阶段边界不因这次概念澄清自动改变。 + +相关上游历史:`4be5968d` 引入无效动作标记,`29ed9d24` 增加独立舍弃及交付过滤,`a2ddd07c` 允许语义留空但保留媒体交付。本轮连续覆盖方案会替代适用范围内的留空送检规则,保持无效与舍弃的区分。 diff --git a/AGENTS.md b/AGENTS.md index 78dd0bbd..4ec6c5b0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -7,8 +7,8 @@ ## Deployment Environment -- Develop on `dev`. For Fanyu releases, explicitly select `DEPLOY_ENV=fanyu` and verify the target cluster; do not rely on the scripts' default `poc` selection. -- Deploy only to the environment explicitly requested by the user. +- The `dev` branch uses the `poc` deployment and test environment. +- Leave `DEPLOY_ENV` unset on `dev`; the deploy scripts should resolve it to `poc`. - Do not deploy `dev` to `wjzh` unless the user explicitly overrides this rule. ## Git Workflow @@ -17,9 +17,7 @@ - After making code or documentation changes for the user, stage only the files changed for that task. - Commit with an English, emoji-prefixed commit message. - **Push only when the user explicitly says push.** Default action after commit: stay local. -- Work directly on `dev`; do not create local or remote feature, fix, or performance branches or branch-based worktrees. -- Keep only these four local and Gitea branches: `dev`, `poc`, `backup/poc-before-fanyu-rollback-20260905`, and `wujiezhihang`. -- When push is approved, push `dev`. Do not modify the other three branches unless explicitly requested. +- When push is approved, push the user's personal feature branch only; never push `dev` or `poc` directly. - Do not stage or commit unrelated user changes already present in the working tree. ## Credentials diff --git a/CONTEXT.md b/CONTEXT.md index f598b3b1..f350cb17 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -6,17 +6,25 @@ **Capture(源采集)**:一次源采集所关联的双目视频、时间戳与传感器数据,是本流程组织人工处理和审核的对象。 -**切片**:标注员在源采集的统一有效帧范围内划定的连续区间。全部切片完整覆盖该范围,互不重叠;一个切片可以包含多条动作描述。 +**切片**:标注员在源采集的统一有效帧范围内划定的连续区间。全部切片完整覆盖该范围,互不重叠;一个切片可以包含多个动作区间。 _Avoid_:动作描述区间(两者不是同一层级) -**动作描述区间**:属于一个切片、具有起止边界和描述内容的语义区间。已有描述互不重叠,可以在切片中留下空白。 +**动作区间**:属于一个切片、具有起止边界的语义区间,可处于待标注、有动作描述或明确无效的状态。连续动作标注中的各动作区间首尾相接、互不重叠,完整覆盖需要标注的切片。 +_Avoid_:子切片、子标注(容易与媒体切片或描述文本混淆) + +**动作描述区间**:已经填写动作描述内容的动作区间,不包含待标注区间。 _Avoid_:切片(描述边界不等于切片边界) +**动作列表**:按时间顺序展示当前切片全部动作区间的列表,包括待标注、有描述和无效的区间,用于选择、回查和修改当前结果。 +_Avoid_:历史操作日志(本列表不展示修改前的旧版本) + ## 留空与交付 -**语义留空**:保留切片内未填写动作描述的时间范围,可以覆盖部分或全部切片。留空仍参与审核和媒体交付,不自动代表无效或舍弃。 +**待标注区间**:尚未确认动作描述或明确无效判断的动作区间,是未完成的标注工作。 -**无效区间**:标注员明确标记为无效的动作描述区间。它表达语义判断,不等于从交付范围中舍弃切片。 +**语义留空**:切片内尚未填写动作描述、也未明确标为无效的时间范围,可以覆盖部分或全部切片。留空不自动代表无效或舍弃。 + +**无效区间(无效动作)**:标注员明确判断为无效、仍作为动作标注结果保留的区间。无效标记本身不删除动作记录或对应视频,也不等于从交付范围中舍弃切片。 **舍弃切片**:标注员明确选择不交付、并记录原因的切片。切片及其证据仍参与审核,舍弃本身不移动相邻边界。 @@ -26,16 +34,29 @@ _Avoid_:切片(描述边界不等于切片边界) **删除动作描述**:移除一条语义描述并保留原时间范围的空白,不合并相邻动作,也不删除视频。 +**动作改判**:将动作区间的原描述或无效判断更正为另一项语义判断,不等于删除该区间或对应视频。 + +**动作区间合并**:调整两个相邻动作区间的共同边界,使其中一段归入另一段;存活区间覆盖合并后的范围并保留原描述、待标注或无效判断,被合并区间不再单独存在,视频不因此删除。 + +**保存进度**:保留当前动作划分和完成状态,允许仍有待标注区间;不代表标注已经完成或已经送检。 + **切片字典**:项目启用的切片名称集合;新确认的切片名称从中选择,多个切片可以同名。 **描述字典**:用于填写动作描述草稿的模板集合;选择后允许编辑描述文本。 +**舍弃原因字典**:管理员维护并由项目启用的舍弃原因词条集合;舍弃切片时选定原因,并按词条要求补充说明。已记录的原因保留当时快照,不随字典后续修改而改写。项目未配置舍弃原因字典时允许手填非空原因;字典加载失败或已配置但无可用词条不属于未配置。 + ## 连续作业 **送检**:标注结果及其审核数据已经准备完成,任务交给质检环节等待处理。送检成功不代表质检通过。 _Avoid_:质检完成(属于后续审核结果) -**连续工作**:标注员在所选项目内连续完成任务的工作方式;当前任务送检后先续做本人尚未完成的任务,没有时再随机领取下一条。 +**连续工作**:标注员在所选项目内接续处理本人可操作任务的工作方式;切片在后台生成时可处理另一任务,任务实际交给质检后再按个人缓冲容量补充随机任务。 + +**个人任务缓冲池**:当前标注员在一个项目内已经领取、尚未实际交给质检的任务集合;包括正在切片生成、送检处理或失败待处理的任务,用于在后台处理期间继续其他可操作任务。 +_Avoid_:公共可领取任务池(其中的任务尚未归属当前标注员) + +**暂停连续工作**:停止自动切换任务和补充领取,保留当前编辑、已领取任务及已经开始的后台处理;不是释放任务或取消切片生成。 **随机领取**:在操作者有权限的项目和供应商范围内,从可领取的标注任务中随机分配任务;操作者在领取前不能挑选视频。它不包含主动释放已领取任务。 diff --git a/docs/adr/0002-contiguous-action-coverage.md b/docs/adr/0002-contiguous-action-coverage.md new file mode 100644 index 00000000..40b1bffc --- /dev/null +++ b/docs/adr/0002-contiguous-action-coverage.md @@ -0,0 +1,15 @@ +--- +status: accepted +--- + +# 泛宇连续动作标注以完整语义覆盖作为送检条件 + +此前允许切片内部分或全部语义留空后送检,无法区分标注员有意跳过的内容与尚未完成的工作。按客户本轮要求,当前泛宇人工切片/标注流程下全部项目采用连续动作区间:需要标注的切片由首尾相接、互不重叠的区间完整覆盖,每段必须明确填写动作描述或标为无效后才能送检;待标注与明确无效保持不同,舍弃切片继续遵守原有原因及证据规则。 + +这一变更适用于新任务和仍在编辑的任务,保留已有描述及边界,仅将语义空白呈现为待标注区间;已送检、已验收的数据不追溯改写,退回重做后再按新规则提交。该边界接受编辑中任务补齐语义的成本,同时避免以新规则改写既有审核与交付事实;其他客户或其他工作流保持原规则。 + +无效动作作为标注结果保留,不因无效判断自动删除记录、裁去视频或变为舍弃切片。后续后台如何消费无效标记属于独立的处理约定;当前代码保留无效动作与视频,但并未实现按该标记自动删除媒体的流程。 + +2026-09-21 用户明确允许通过结束边界微调主动合并相邻动作区间:缩至零时由后一段接管范围,扩至下一段结束时由当前段接管;保留存活段的判断,整次按住操作可一次撤销。这是对“取消动作删除入口”的有意合并例外,不允许留下零长度或重叠区间,也不意味着无效标记会自动删除数据或媒体。具体键盘与鼠标边界限制见追加讨论。 + +以上为 2026-09-18 设计讨论中用户对 Q2、Q4、Q5 及无效保留语义确认的目标规则,连续覆盖部分尚未实现。Q9 后续明确取消动作标注阶段的删除入口,保留修改、改判和撤销;其余交互与兼容事项记录在[设计讨论](../../.scratch/annotation-contiguous-actions/map.md)中。撤销仍受 [ADR-0001](./0001-annotation-undo-stage-boundary.md)的任务与阶段边界约束。 diff --git a/docs/adr/0003-bounded-annotation-work-buffer.md b/docs/adr/0003-bounded-annotation-work-buffer.md new file mode 100644 index 00000000..11a5f4dc --- /dev/null +++ b/docs/adr/0003-bounded-annotation-work-buffer.md @@ -0,0 +1,11 @@ +--- +status: accepted +--- + +# 后台切片期间使用有容量限制的个人任务缓冲池 + +切片生成会让串行工作停顿,因此泛宇人工标注改为在后台任务被确定受理后接续处理其他可操作任务;个人缓冲池按账号与项目计数,默认 2、可设 2–8,手动随机领取和自动补领共用容量约束。处理中、失败待处理的任务继续占位,只有实际送检成功才腾位,避免将“已受理”误当完成而持续占用更多任务;调小容量保留既有任务,退回仍进入公共可领取池。 + +开始/继续时补齐,优先处理已生成待标注的任务;单个后台任务失败不阻断其他任务。暂停或返回任务池停止自动切换与补领,但不取消后台处理;刷新后须明确继续,以在连续作业效率与操作者可控性之间保留边界。 + +这是 2026-09-21 Q23–Q28、Q31 已确认的目标规则,尚未实施;具体交互与历史规则替代见[追加讨论](../../.scratch/annotation-contiguous-actions/supplement-20260921.md)。任务切换仍遵守 [ADR-0001](./0001-annotation-undo-stage-boundary.md)的撤销边界。 diff --git a/docs/discard-reason-dictionary.md b/docs/discard-reason-dictionary.md index 09d3f751..4e2a7b6a 100644 --- a/docs/discard-reason-dictionary.md +++ b/docs/discard-reason-dictionary.md @@ -2,17 +2,17 @@ 在项目“语义标签”页增加“舍弃原因字典”。与切片、动作描述字典共用同一组件,直接添加、编辑、删除;只显示当前项目词条,无启用/停用开关。三个字典分别按名称防重,修改当前项目不改变其他项目及历史审核。 -舍弃片段必须单选项目已有的原因。补充说明默认选填;“其他”以及历史上已有说明要求的词条要求说明,最多 1000 字。未配置时阻止新的舍弃并提示管理员配置;不自动生成示例词条。恢复为保留不依赖字典可用性。 +项目已配置字典时,舍弃片段必须单选项目已有的原因。补充说明默认选填;“其他”以及历史上已有说明要求的词条要求说明,最多 1000 字。项目未配置字典时允许手填非空原因,最多 1000 字;字典读取失败或已配置但没有有效词条时仍禁止绕过校验,不自动生成示例词条。恢复为保留不依赖字典可用性。 接口: - `GET /api/annotation-labels?kind=discard_reason`:管理员组织字典。 - `POST /api/annotation-labels`、`PATCH /api/annotation-labels/{id}`:复用词条管理,新增 `requiresNote`。 -- `GET/PUT /api/projects/{id}/discard-reason-labels`:项目词条/项目引用列表,PUT 使用 `labelIds`。 -- `POST /api/plugins/annotation-qa/tasks/{id}/slice-dispositions`:新增 `reasonLabelId`、`reasonVersion`、`reasonNote`;新舍弃不再接受自由文本原因作为替代。 +- `GET/PUT /api/projects/{id}/discard-reason-labels`:项目词条/项目引用列表,PUT 使用 `labelIds`,GET 返回 `allowManual` 表示是否允许手填。 +- `POST /api/plugins/annotation-qa/tasks/{id}/slice-dispositions`:新增 `reasonLabelId`、`reasonVersion`、`reasonNote`;仅项目未配置字典时接受 `reason` 手填原因;有配置时不可用自由文本替代选词。 后端校验组织、项目引用、词条类型、有效状态和版本;耗时的帧校验完成后再次检查词条。记录的 `discardReasonLabelId`、`discardReasonVersion`、`discardReasonName`、`discardReasonNote` 均由服务端确认。兼容字符串 `discardReason` 为名称与说明的可读组合。 -已有自由文本原样保留并显示“历史填写”。普通保存不能篡改原因快照;字典改名/停用不追写历史。舍弃/恢复记录保留前后快照。新生成和复用媒体的审核 JSON 均保留词条快照。舍弃仍保留完整审核媒体,不改变切片边界,也不进入最终交付。 +已有自由文本原样保留,无词条 ID 的原因显示“手动填写”。普通保存不能篡改原因快照;字典改名/停用不追写历史。舍弃/恢复记录保留前后快照。新生成和复用媒体的审核 JSON 均保留词条快照。舍弃仍保留完整审核媒体,不改变切片边界,也不进入最终交付。 未修改的历史切片名称沿用现有兼容规则;新改动的非法名称明确指出切片编号和名称,提供“返回修正切片名称”,关闭重开保留原因草稿。 @@ -23,3 +23,5 @@ - `TestDiscardReasonDictionaryLiveFixture`:显式开启的独立组织验收;只引用既有合成视频,不启动接入监听、不改客户账号,验收后停用测试账号。 线上媒体验收需要遵循 Fanyu 工作区连接的组织范围:字典管理使用独立组织;媒体舍弃使用工作区所属组织中的独立项目、专用供应商和受限标注/审核账号,不新增客户组织管理员。只引用已有合成媒体。测试词条带唯一验收后缀,结束时连同验收账号停用。 + +工作台通过 G 打开右侧舍弃面板,Esc 返回,Ctrl/⌘+Enter 确认;切换切片时关闭旧目标面板,不会将其原因误用于另一片。 diff --git a/docs/verification/account-annotation-merge-20260921.md b/docs/verification/account-annotation-merge-20260921.md new file mode 100644 index 00000000..da049e82 --- /dev/null +++ b/docs/verification/account-annotation-merge-20260921.md @@ -0,0 +1,34 @@ +# 账号管理与标注工作台合并核验 + +2026-09-21,按用户转述的双方确认方案,将 `origin/feat/account-supplier-hierarchy`(`e48c4cca`)合入个人功能分支。合并前备份:`codex/backup-before-account-merge-20260921`(`6bb14205`)。未推送,未修改公司部署或客户数据。 + +## 合并内容与取舍 + +同事分支包含账号/供应商统一管理、单账号角色授权、账号变更与领取互斥、字典直接增删改、质检验收渐进加载及证据缓存、Worker readiness 容差修复。 + +两处文本冲突按双方已确认意图合并: + +1. `resolveDiscardReason` 保留项目未配置字典时的 `allowManual` 手填规则;有配置、读取失败、失效或跨项目词条不可绕过校验。文档同步到最新客户规则。 +2. Mongo 领取外层使用同事的账号变更锁,内层仍以 `EnforceBuffer || Receipt.Intent != nil` 进入本地容量约束及幂等领取路径。没有去掉个人任务缓冲的容量检查。 + +保留缓冲和领取接口名称补全、专注模式布局、右侧舍弃面板、连续动作及快捷键。管理员和供应商管理员都有账号管理入口;供应商管理员受后端供应商范围限制。项目成员表示参与关系,角色以账号为准。 + +上游持久账号锁不自动过期。一般未知领取结果仍按原请求核对;若崩溃留下账号锁,需运维确认原进程停止并核对结果后处理,不能以自动到期解锁替代保护。发布账号规则时应同时更新 API、前端和 Worker,并先只读核对历史账号/供应商归属。 + +## “去掉超级管理员”核验 + +本次 fetch 后账号管理分支没有新增提交,`origin/poc` 更新到 `bb524b3e`。可见代码仍保留 `IsSuperAdmin`、初始化超级管理员、`/api/admin` 鉴权和 `SuperAdminConsole`。账号管理页面的 `manageable` 会过滤超级管理员账号,因此普通账号列表不再提供该账号的管理操作;但独立超级管理员控制台和后端身份仍存在。若“去掉”仅指从普通账号列表隐藏,这部分已实现;若指取消整个身份体系,则不能把“已删除超级管理员”作为当前合并结果。 + +`poc` 的 `38d5a46f` 删除旧 `operator/auditor`,采用 POC 的五角色模型;它不包含泛宇的标注员、质检员、最终验收员和供应商管理员。`7ca47c62` 还包含大量运行时兼容清理。这两项并非超级管理员删除,未直接合入,避免生产账号被新白名单拒绝。已向用户请求该功能准确的分支或提交号;后续需按实际提交核验。 + +## 本地验证 + +- TypeScript 与 Vite 生产构建通过。 +- 隔离内存 API + 真实浏览器验证管理员、供应商管理员的 `/users` 页面均通过,无页面异常;供应商管理员仅返回三种生产角色,未混入 POC 角色。 +- 标注工作台真实浏览器 13 组回归通过,覆盖实际切片/标注阶段、1413×615 等三尺寸、单目/双目、保存提交区、任务名称、G/Esc、无字典手填和切换切片目标保护。 +- 连续动作、任务缓冲、随机领取、舍弃、草稿与切片恢复 API 测试通过;Store 测试通过。 +- 账号权限、项目成员、供应商、审核证据缓存与产物目录测试通过;Worker readiness、供应商及角色相关测试通过;全项目 Go 编译通过。 +- 前端全量 590 项:578 通过、12 失败。原本地基线为 10 个失败,另外 2 个已在同事纯分支独立复现:旧测试仍要求“用户管理”旧标题和项目批量角色控件;没有为让源码字符串断言通过而恢复已取消的角色管理功能。 +- 权限测试用例按新契约补齐供应商和项目成员;生产权限校验未放宽。 + +浏览器证据在忽略目录 `local-data/verification/account-merge-20260921/`;自动检查日志为 `/tmp/account-merge-*.log`、`/tmp/merge-api-check.log`、`/tmp/merge-store-check.log`。本次验证为本地,不代表公司集群已升级。 diff --git a/docs/verification/continuous-actions-20260921-matrix.md b/docs/verification/continuous-actions-20260921-matrix.md new file mode 100644 index 00000000..20411aa0 --- /dev/null +++ b/docs/verification/continuous-actions-20260921-matrix.md @@ -0,0 +1,87 @@ +# A01–A43 验收追溯记录 + +基线时点:2026-09-21;公司候选 `5247c69e` 的最终 51 动作浏览器、扩展场景、舍弃恢复与真实送检补位均已有成功日志。`d363a791` 仅修正连续标注提交提示文案,独立审查无阻塞,新鲜归档的 web / Linux amd64 构建及校验通过(见 final-d363a791/build-validation.json);已完成部署及 I/J/W/X/Y 所列最终公司追加场景,health/ready成功。本表只记录各证据实际断言,不把分层验收等同于全部组合浏览器穷举。 + +最终候选更新:`ad8756e7` 修复同任务继续后轮询仍持有旧导航来源的问题。旧 d363a791 的 `resume-red/buffer-resume-result.json` 明确 RED(15秒 occupied1≠2、claims0/submissions0);新增 effect 依赖保留 late fence,独立审查通过。新版本双组件rollout及health/ready成功,真实GREEN占位1→2、领取1、送检0;新版latepause再次通过。 + +## 证据索引与边界 + +- **H(本轮已执行通过)**:`internal/api/annotation_contiguous_http_test.go` 的 `TestContinuousActionsSavePendingProgressAndReadBack`、`TestContinuousActionsRejectIncompleteSubmissionWithoutClientFlag`、`TestContinuousActionsConfirmedInvalidCanReachReview`、`TestContinuousActionsSaveProgressFillsLegacyGapsAndProtectsVersion`、`TestContinuousActionsRejectContradictoryAndUnknownJudgments`、`TestContinuousActionsLegacyEndpointCannotBypassCombinedGate`、`TestContinuousActionsSubmittedTaskCannotBeRewrittenByProgressSave`。通过公开 HTTP 保存、回读和拒绝场景;多数使用内存存储,不能替代真实媒体生成。 +- **Q(本轮已执行通过)**:`internal/api/annotation_work_buffer_test.go` 的 `TestAnnotationBufferCapacityAndReplay`、`TestAnnotationBufferConcurrentClaimsUseSharedCapacity`、`TestAnnotationBufferLeavesOtherWorkflowsUnchanged`、`TestAnnotationBufferDoesNotClaimOtherWorkflowInMixedProject`;`internal/api/annotation_continuous_recovery_test.go` 的 `TestContinuousClaimLostResponseReplaysWithoutConsumingNextTask`、`TestContinuousPendingSubmissionReadbackRetainsCurrentTask`;相关 `TestRandomClaim*`。公开 HTTP 覆盖容量、版本/归属、丢响应回执及范围隔离。 +- **M(本轮真实 Mongo 已执行通过)**:`internal/api/annotation_work_buffer_mongo_http_test.go::TestAnnotationBufferMongoHTTPConcurrencyAndReceipt`,本地独立临时数据库、两套 handler/store、5 轮每轮 16 并发与同期查询,覆盖容量 2、回执重放、实际交接后腾位及补领;临时数据库清理。`ac8496c8` 后重跑结果 `ok 1.770s`。 +- **P(公司浏览器已通过,但旧候选)**:忽略目录 `prepare-browser.mjs`、`prepare-browser.log`、`browser-prepare-events.json`。1413×615,切片三相机一轴、F 选名、G 打开后 Esc/Space、开始补到 2、真实切片 202 后切到另一任务及暂停。**默认左相机当时失败后手动切左;日志舍弃选项为 0,不能据此声称 G 选择/分页成功。** +- **B(公司真实接口已通过)**:`cluster-probe-summary.json` 与 `cluster-probe-*` 回读。隔离 task04,两真实切片 202→实际生成 2/2;待标注保存/回读、未完成送检 400、无效保存、送检 202 仍占 2、真正 `quality_review/pending_quality` 后占 1。没有执行 UI 自动补领。 +- **C(最终公司浏览器已通过)**:`tests/browser/continuous-actions-workbench.mjs`;`final-editor.log` 最终输出 passed=true、actions=51、viewport=[1413,615]、task=annotation-task-continuous-actions-20260921-08、errors=[]。候选 `5247c69e`。包括默认左相机、标注三相机两轴、G 控件可达且无需弹层滚动/上下导航、视频点击、滑块后 Space、51 段 C、保存刷新、跨六/首尾、微调、文本聚焦停长按、描述/Ctrl+X/撤销及 HTTP 回读。早期 `editor-intermediate.log` fixture 已有51段导致的失败保留为历史记录,不是最终成功证据。 +- **E(最终公司扩展浏览器已通过)**:`extended-browser-result.json` passed=true、pageErrors=[];六项 checks 为 JSON follows playhead/selected editor retained、shrink-zero undo、one-neighbor merge undo、final endpoint fixed、undersize pause restore、paused capacity8 then2 no claims。窗口恢复使用显式继续后完成;早期超时日志不覆盖,已由本次完整成功结果取代。 +- **F(前端整体运行证据)**:`tests/frontend/continuous-shortcuts.test.mjs` 含键位/native剪切、真实帧末帧、存活判断合并纯函数断言;`annotation-history.test.mjs`、`annotation-authoritative-mutation.test.mjs` 覆盖撤销/权威写入公共模块行为。全套前端 583 项中 573 通过、10 失败,与基线相同;Go 顶层失败与基线同为 63。`regression-summary.json` 只能证明“未新增基线失败”,不能把全套写成全绿。旧源码字符串测试不作交互验收。 +- **D(本轮定向契约已执行通过)**:`/tmp/annotation-implementation/final-contracts.log`:`ok droboticflow/internal/api 3.540s`;主代理确认本次选择器包含 `internal/api/discard_reason_dictionary_test.go` 的 validation/snapshots、project isolation、legacy name、BSON restore。该汇总日志不逐项展开测试名称;不把旧1280×640浏览器脚本计为本轮验收。 +- **G(最终公司舍弃浏览器已通过)**:`discard-browser.mjs`、`discard-browser-result.json`;1413×615、task08,G 右键分页到3/3、上下及Enter选择、缺少必填说明时保持弹层、长说明不要求弹层滚动、Ctrl+Enter真实舍弃保存、51条历史快照、恢复后51条动作回读。 +- **S(最终公司送检接续浏览器已通过)**:`submit-refill-browser.mjs`、`submit-refill-result.json`;task01的51条中剩余pending先经公开API标为invalid,然后浏览器确认送检202,实际进入quality_review/pending_quality,优先转task08,随机补领task03使占位回到2,再点击暂停。记录1次combined-submissions POST及1次random-claims POST;不据此声称全舍弃/故障注入已覆盖。 +- **L(最终公司布局/偏好浏览器已通过)**:`layout-preferences-result.json` passed=true,8项检查包括首项目预选不领取、显式项目保持、忽略旧original偏好、默认相机独立于临时视图、新任务采用默认、大视口视频等比增长、1413×615两轴可见、返回普通工作台后Space正常。 +- **T(公司真实退回链路已通过)**:`cluster-probe-return-summary.json`;QC领取task04后退回HTTP201,进入annotation_combined/rework v10,assignedUserId/claimedAt清空,公共池4→5,原标注员仍占2(task03/08),未自动领取。未据此声称后续再领取/再提交也已执行。 +- **U(补充本地公共 HTTP 验收通过)**:`annotation_work_buffer_lifecycle_test.go` 两项新测试覆盖处理/失败占位、真正阶段交接才补领、空池、两账号/两项目隔离与供应商权限失效;连同四项原容量测试重跑 `buffer-lifecycle.log`:ok 0.486s。Fixture只设置生命周期状态,断言通过公开HTTP,不冒充真实后台编码或前端迟到响应验证。 +- **V(补充连续分区公共 HTTP 验收通过)**:`annotation_contiguous_progress_acceptance_test.go` pending文字保存不确认、非法重叠/越界不裁切且不改版本;`annotation_contiguous_acceptance_test.go` generate/reuse非法覆盖拒绝、mixed/all-discarded公开舍弃后复用路径到质检并保留证据。`final-progress-contracts.log` 的 `^TestContinuous(Actions|Progress)` 汇总通过0.496s;新媒体生成性能与全舍弃公司处理另列。 +- **I(最终 d363a791 公司继承/切片验收通过)**:`inheritance-slice-result.json`:描述及无效切分左继承/右pending、撤销恢复判断、未保存文字阻止C/导航、切片合并保留存活名称、一手势撤销恢复分区。 +- **J(最终 d363a791 公司交互追加通过)**:`editor-additional-result.json`:右视频同步播放暂停、两阶段所有range拖动后Space、阶段帮助、动作/切片鼠标共同边界联动并一次撤销、提交提示新文案。 +- **W(最终公司真实迟到响应通过)**:`buffer-late-pause-result.json`:route.fetch获得真实buffer响应,仅延迟交付;暂停后释放原响应,5秒内URL/任务不变、不恢复连续模式、没有random-claim请求。W 只证明读取响应迟到;写请求丢响应另由 AA 真实浏览器及回执恢复 HTTP/Mongo 契约覆盖。 +- **X(最终公司全舍弃新媒体处理通过)**:`all-discard-result.json`、`all-discard-final.json`:task03切片202后实际processor完成,再combined202到quality_review/pending_quality,保留原因。不是只有复用产物的模拟测试。 +- **Y(最终公司生成故障恢复+短列表通过)**:`generation-failure-recovery-result.json`;隔离02在真实数据故障后后台失败,错误与重试入口可见,另一个任务仍可编辑(临时文本取消),失败仍占2且无领取;恢复素材后UI重试真正processor完成。1/3动作跨六取模、单步首尾和临时切分撤销均通过;测试源副本finally恢复。 +- **Z(送检恢复定向HTTP通过)**:`final-submission-recovery.log` ok2.609s:InvalidatedSubmissionReplacesSupersededDescriptions、CombinedSubmissionFinalCASFailureDoesNotPublishQualityTask、FanyuV5CombinedSubmissionReservationPreventsConcurrentOverwrite、FanyuV5CombinedReservationResumesAfterReloadWithIncrementedVersion、FanyuV5CombinedPayloadSHAIgnoresCASVersionForRetry。失败不发布质检、预留/版本/重试SHA边界由契约验证。 +- **AA(最终送检丢响应/明确恢复通过)**:`unknown-submission-result.json` passed=true、`unknown-final.log`;真实mixed task02唯一combined POST返回202后abort,暂停claims0,质量阶段和原因版本1/invalid保留。`resume-red/buffer-resume-result.json`复现旧版不补领;`resume-green/buffer-resume-result.json`验证ad875修复后只claim1、占位1→2、submit0、08仍pending_annotation。新版真实buffer迟到响应暂停后无导航/claims。初次脚本quality字符串错误修正只读复核,未重复送检;随后真正补领缺陷单独修复并回归。 +- **R(代码已审查,非动态验证)**:三项 Spec 发现、相机进专注默认、G 弹窗布局、任务名称展示等已修复并复核。无剩余代码阻塞发现不等于每个 A 场景已动态验证。 + +## 逐项矩阵 + +本表分开记录“实现及契约验收”与“每种组合是否都做过公司浏览器测试”。右栏为证据边界,不自动意味着需求未实现或票必须保持未完成;存在最小必要专项时在票内明确记录。 + +| 验收 | 当前证据/准确支持范围 | 当前等级 | 证据边界/未穷举组合 | +|---|---|---|---| +| A01 最小尺寸两阶段三相机 | P切片三视图一轴;C最终标注三视图双轴;L最小尺寸双轴与大窗口contain视频 | 公司主要布局自动验证 | 切片与标注全部核心按钮的每种视图组合未穷举 | +| A02 大窗口、缩放、长文和错误 | L:1920×1080视频等比增长;G:长必填说明且弹层不整体滚动;C最小窗口 | 部分公司自动验证 | 浏览器缩放、超长所有词条、5原因+双错误同时显示等仍未穷举 | +| A03 缩小暂停并手动恢复 | E:缩小暂停、保留51段、恢复后手动继续完整通过 | 公司核心自动验证 | 长按/后台请求返回恰逢缩窗等组合故障未注入 | +| A04 默认相机生命周期 | C默认左;L独立设置不覆盖临时视图,新任务采用默认 | 公司主要偏好自动验证 | 账号/浏览器隔离及同任务跨阶段按R生命周期审查;未额外遍历各浏览器账号组合 | +| A05 视频点击和覆盖层 | C/J:左右视频点击同步播放/暂停;P:G Esc后Space;E JSON展开不改变选中 | 公司关键交互通过+守卫审查 | J左右视频同步已验证;JSON/忙碌/只读守卫按审查,不声称所有组合浏览器注入 | +| A06 默认首项目 | L:首项目预选无领取请求、显式项目保持 | 公司核心自动验证 | 无项目、列表刷新/权限变化、手动改选后更新列表未逐项注入 | +| A07 旧布局偏好与返回 | L:旧original偏好忽略、返回普通工作台后Space正常;P进入工作页 | 公司核心自动验证 | 返回时恰遇在途请求的迟到响应保护未注入 | +| A08 所有滑块恢复快捷键 | C/J:两阶段所有range拖动后Space同步;R共享焦点处理 | 公司两阶段range通过+焦点审查 | J实际拖动后Space同步;取消/外部松手共享焦点处理按审查 | +| A09 文本、IME、弹层、Esc | P:G打开Esc后Space;C:文本保存及聚焦停长按;F native键位 | 部分自动验证 | 中文组合输入、搜索/补充说明原生键;一次Esc焦点恢复、不误切/误提交 | +| A10 初始化分区与历史空白 | H:SavePendingProgress、SaveProgressFillsLegacyGaps;C fresh整片待标注;V异常保存不裁切 | 自动接口+部分公司验证 | 混合历史描述/无效间隙在真实工作入口不变脏,边界/历史判断保持 | +| A11 C切分继承规则 | C:50次连续C生成51段,N禁用;I:描述/无效左继承右pending及撤销 | 公司继承与连续切分通过+帧规则 | I已描述/无效左继承右pending;已有边界/单帧由帧规则与审查,不再列核心继承待验 | +| A12 未保存文字保护 | C:空编辑器可连续C/导航;I:真改文字阻止C/导航 | 公司文字保护验证 | I真正改字后C/导航被拦截;跨任务迟到组合另列 | +| A13 保存未完成并刷新 | H、B:pending保存回读;C最终5247的51待标注保存并刷新恢复成功 | 公司核心链路验证 | V公开保存回读pending文字不确认;真实异常网络UI组合另列 | +| A14 当前描述保存 | C:Ctrl+Enter响应及描述回读;H confirmations版本保护 | 部分公司自动验证 | 连按/长按Ctrl+Enter不触发质检确认层,不重复提交 | +| A15 明确选中Ctrl+X | C:选中第一段Ctrl+X→HTTP回读invalid;F输入native剪切 | 部分公司自动验证 | 播放头在另一段、无选择、输入框剪切、切片阶段;明确只变所选一段 | +| A16 无效撤销/异常 | C:描述→无效→Ctrl+Z原描述回读;F authoritative mutation/history;H stale进度409 | 核心公司验证+异常契约 | Ctrl+Shift+Z;保存失败/响应丢失/409后不假成功或覆盖新版本,服务器与UI一致 | +| A17 密集动作选择 | C:51段均出现在列表,单独选择并编辑保存 | 已有公司核心验证 | 极短混合待标注/描述/无效、滚动选中稳定;手动滚列表不能跳视频 | +| A18 循环和跨六 | C:51段跨六及环绕;Y:1/3段模数与首尾 | 部分公司自动验证 | Y已补1/3少量跨六;切片范围及首尾滚动策略经R审查 | +| A19 半开边界末帧 | F lastActionFrame非等距帧;C Alt+上;E playhead JSON归属验证部分 | 纯函数+部分公司验证 | 真视频单帧/末动作/相邻边界,Alt+下和点击/上下结束定位停目标末帧;end保存值不改 | +| A20 JSON预览 | E明确PASS JSON随播放头、选中仍#1、preview=true、saved=true | 部分公司自动验证 | 未保存描述和微调时saved=false;只读及时间基准;展开/收起不播放或抢编辑选择 | +| A21 Shift帧步进与加速 | C单击边界增大并保存;F真实帧寻址;E 2600ms长按合并 | 部分公司自动验证 | 精确单击1真实帧、<1秒不加速、满1秒后5帧/0.5秒节律及非等距帧 | +| A22 缩零/吞并/撤销 | E明确PASS缩零/扩邻段数量减1、一次撤销恢复;F存活描述/无效纯函数 | 核心公司验证+存活判断纯函数 | 混合描述/无效的真实存活判断与被吞记录恢复;保存刷新回读连续完整区间 | +| A23 一邻段上限及失焦 | E长按只减1并撤销;C输入焦点停止长按 | 部分公司自动验证 | 松开重按可再合并;弹层/失焦/换任务/阶段/缩窗取消;旧repeat不改新目标 | +| A24 鼠标共同边界与固定终点 | E末动作结束固定;J两阶段鼠标共同边界及一次撤销;F/history公共行为 | 公司共同边界及撤销验证 | J两阶段鼠标联动一拖一撤销;E最终端点固定;极端指针组合未穷举 | +| A25 切片名与舍弃保护 | I:切片合并名称与一手势撤销;R舍弃及相邻边界阻挡;G/D历史恢复 | 公司切片合并+舍弃契约与审查 | I存活名称和撤销已验证;G/D真实历史恢复;舍弃相邻边界禁用按R审查 | +| A26 F/G分页和说明 | P:F切片选名;C:G上下首尾与按钮可达;G:3页、必填说明、Ctrl+Enter真实舍弃 | 公司主要交互自动验证 | 两阶段所有选填/搜索组合与F多页未全部重复 | +| A27 字典异常与恢复 | D:本轮字典版本/项目/快照契约通过;G:缺必填说明不提交 | 自动契约+部分公司验证 | 空/停用/旧版本等所有UI恢复流程未在公司逐项注入 | +| A28 舍弃历史与无效区分 | G:真实舍弃保存51条历史快照、恢复51条回读;D:历史/BSON恢复;H/B无效保留 | 公司核心交互+契约验证 | 线上改名/停用后再恢复历史未操作,契约覆盖相关快照行为 | +| A29 完整覆盖强制门禁 | H blank/gap/pending/contradictory/legacy绕过拒绝;B真实pending送检400 | 核心接口验证 | V补充generate/reuse路径overlap/outside/zero/end-gap均400且不预留推进;H无flag旧客户端拒绝 | +| A30 完整/混合/全舍弃送检 | H/B:invalid可到质检;S:51段任务浏览器确认并真实quality_review、回读成功 | 公司真实送检验证 | V混合/全舍弃接口复用产物送检通过;X公司全舍弃新媒体处理通过,AA公司混合处理到质检且原因/invalid保留通过 | +| A31 历史只读/退回/范围外 | H SubmittedTaskCannotBeRewritten;Q LeavesOtherWorkflowsUnchanged/MixedProject | 核心接口验证 | 真实退回任务再次提交执行新规则、已验收不改写、范围外浏览器串行行为 | +| A32 容量设置隔离 | Q:默认2、3、非法值及降容;M:持久并发;E:浏览器暂停中设8再2;U:账号/项目/权限隔离 | 自动HTTP/Mongo+公司部分验证 | U已验证账号/项目服务端隔离及失效权限;切项目瞬间显示未专项 | +| A33 补齐时机 | P开始补2;E暂停调8再2无领取;S真实送检后自动补回2;Q/M容量 | 公司主要补位链路验证 | 活跃调大、公共池不足、无任务入口不领等尚未逐一动态验收 | +| A34 状态占位 | B生成/送检受理仍占2,真实质检后占1;Q/M容量事实 | 部分公司真实接口验证 | U补充queued/running/failed/completed占位与实际阶段腾位;不使用mine长度 | +| A35 并发与回执 | Q20并发剩7名额;M两实例5×16并发+查询,满池回执/交接恢复 | 自动核心验证已通过 | 可选公司双浏览器并发佐证;不需要把前端锁当服务端原子性证据 | +| A36 降容超额 | Q:已占3降2仍3拒绝领取;M满池重放;E暂停调8再2无领取 | 自动接口+公司部分验证 | UI真实超额后降至等于/低于阈值完整多次循环未执行 | +| A37 切片确定受理再切走 | P观测slice-confirmations202后URL换task08;B后台真实完成 | 公司核心浏览器验证 | Y真实生成失败保留名额,其他可编辑,UI重试真实完成;未知受理回执由Q/M契约 | +| A38 优先级与不抢任务 | S:真实送检后优先选已有待标注task08,再补待切片task03;P切片处理中切走;R手动选择保护 | 公司核心优先级验证 | 同类领取时间排序、全池忙等待、后台完成不抢手动失败项仍主要审查 | +| A39 送检成功才补位 | B:202仍占2、真实质检后1;S:实际质检后浏览器自动补1次回2;M交接腾位 | 公司核心送检补领验证 | Y真实生成失败占位和重试、Z送检失败/预留恢复;AA送检202响应丢失、暂停零领取、明确恢复补位通过 | +| A40 退回公共池 | T:QC退回201清归属、公共池4→5、原人容量保持2且不自动领取 | 公司真实接口验证 | 退回后受限随机重领及重新完整送检未继续执行;容量入口另由Q/M验证 | +| A41 暂停/返回/刷新/关闭与在途 | P/S暂停;E暂停不领;C刷新明确继续;W真实buffer迟到不导航/补领;Q丢响应回执 | 公司暂停迟到验证+回执契约 | W只读迟到及AA真实送检响应丢失均通过;刷新后同任务继续有RED/GREEN证据,其他返回/关闭时序排列未穷举 | +| A42 互斥/HTTP/权限/迟到 | Q权限隔离/重复回执;F权威请求作用域;公司通过标准安全隧道 | 部分接口验证 | 同浏览器重复页、权限撤销、账号/项目切换迟到;公网HTTP绕过未执行不能声称验证通过 | +| A43 保留快捷键/阶段帮助 | C Space、逐帧、C、N禁用、动作删除禁用、撤销;F键位/历史节流 | 公司阶段帮助及核心键+历史纯函数 | J阶段帮助/所有range、C动作键与撤销、F历史节流;B/V等原行为分支按审查,未逐一浏览器重跑 | + +## 已验结果与证据边界 + +1. 17票已按公司核心浏览器/真实处理、公开HTTP与Mongo契约、约定纯函数和独立审查完成验收并resolved;矩阵仍如实区分证据层次,不称43项所有子组合都做过公司动态测试。 +2. 最终runtime为ad8756e7,双组件部署及健康通过。旧版同任务恢复轮询RED、新版GREEN、真正处理失败重试、送检202丢响应/暂停/明确恢复均有记录;保留历史脚本错误日志,不冒称每次测试都成功。 +3. 未穷举账号项目切换迟到排列、跨浏览器完整交互、所有缩放及长错误组合、定时器抖动与全部相邻判断排列。精确长按节律常量经审查、关键长按行为经浏览器;不以小媒体验收推断大视频吞吐达标。 diff --git a/docs/verification/continuous-actions-20260921.md b/docs/verification/continuous-actions-20260921.md new file mode 100644 index 00000000..b899448a --- /dev/null +++ b/docs/verification/continuous-actions-20260921.md @@ -0,0 +1,99 @@ +# 连续动作标注与个人任务池:实施及集群验证记录 + +日期:2026-09-21。规格:[固定需求](../../.scratch/annotation-contiguous-actions/spec.md)。范围:17 张票;17 票代码均已实现并本地提交,核心公司浏览器与真实接口链路已通过。17 票均已完成分层验收并 resolved;这不等于每个组合都经过公司浏览器穷举。逐项范围见[43 项验收矩阵](continuous-actions-20260921-matrix.md)。 + +## 版本与部署 + +- 分支:`feature/local-dev-toolkit`;本次未推送 Git,也未创建新的 PR。 +- 审查基线:`b13568b0`;部署代码:`ad8756e7fcad36292009818f12ec7428adfa4661`。 +- 环境:公司 `poc`,namespace `droboticflow-fanyu`;未部署 `wjzh`。 +- 更新组件:API、annotation processor;ad8756e7 最终镜像均已完成 rollout。 +- 镜像摘要:`sha256:f06b86f1f3b0e365ec384ee2bdeccc1549ed7c7d76219167eb43e351df1ede86`。 +- 主要公司浏览器与追加故障验收分别运行于 `5247c69e`/`d363a791`。最后恢复验收发现同任务恢复后的轮询失效,已在 `ad8756e7` 修复并独立审查;该版本 Web/Linux API 构建、最终部署及回归均通过。 +- 最终 ad8756e7 的 health/ready及无认证公网健康检查均通过,版本匹配;证据 final-health.json、final-ready.json、final-public-health.json。 +- 原镜像及 Deployment 配置保存在本机忽略目录 `local-data/verification/continuous-actions-20260921/`,可用于回滚;该目录不随 Git 推送。 + +## 已实现 + +| 票 | 行为 | 主要提交 | +| --- | --- | --- | +| 01–03 | 视频点击播放/暂停;滑块交互后恢复快捷键;默认项目;独立相机默认偏好;1413×615 专注布局,切片一轴、标注两轴 | `b66c0947`、`7d1c1e7f` | +| 04 | G 打开舍弃原因字典,搜索、分页、上下选择及确认;F 保留阶段字典语义 | `b66c0947`、`c1024e54` | +| 05–07 | 完整连续动作分区、保存未完成进度;C 切分左段继承/右段待标注;选中动作 Ctrl+X 保存无效并支持撤销 | `a05eddc3`、`b66c0947` | +| 08–09 | 当前动作列表、上下循环、Ctrl+上下六步、Alt 起止定位;播放头摘要与只读 JSON 编辑预览 | `b66c0947`、`b2b94336` | +| 10–11 | Shift+左右逐帧/长按边界调整,一次最多吞并一个相邻区间;共同边界联动与撤销、舍弃片段保护 | `b66c0947`、`dee6c619`、`b2b94336` | +| 12 | 前后端完整覆盖检查;待标注不得送检;无效保留为结果;历史已送检数据不回写 | `a05eddc3` | +| 13–16 | 账号+项目容量 2–8;原子领取和回执恢复;开始/暂停、后台切片接续、真实送检成功才补位 | `7d1c1e7f`、`0b97ed25`、`b6ce3290`、`c5f731bb`、`ac8496c8`、`ad8756e7` | +| 17 | 两阶段帮助、紧凑布局与集成验收脚本 | `b66c0947`、`c1024e54` | + +泛宇范围由服务端创建的 raw_human 批次及既有三阶段人工流程确定,不能通过客户端标记扩大。范围外工作流仍使用原先串行行为。 + +## 基础验证 + +- TypeScript 检查、Vite 正式构建、Linux amd64 API 构建通过。 +- 票 05 补充 pending 草稿文字与非法历史分区公开保存回读验收,通过后 resolved;连续分区定向测试合并运行 `ok 0.496s`。票 12 的生成/复用路径非法覆盖拒绝及混合/全舍弃复用送检契约已通过,公司新媒体专项另列。 +- 相关接口测试覆盖:连续分区保存回读、历史空白补齐、覆盖门禁、无效状态、版本/处理中限制、容量及回执恢复。 +- 补充容量生命周期公开 HTTP 测试通过:两账号/两项目隔离、空公共池不占容量、供应商失效权限拒绝、生成/送检各处理中和失败状态持续占位,真正质检交接后才可领取。六项定向容量测试重跑 `ok 0.486s`;票 13 已完成验收并 resolved。 +- 真实 Mongo HTTP 并发测试通过:两套 handler/store、5 轮每轮 16 个并发请求,核对容量 2、满池回执重放、已交接请求恢复和腾位补领。测试临时数据库已清理。 +- 前端全套:583 项,573 通过、10 失败;固定基线亦有同样 10 个失败;ad875修复后最新重跑的失败名称集合完全一致,未新增失败(final-frontend-after-resume.log)。 +- Go 全套:与固定基线相同的 63 个顶层失败,未发现新增失败。既有失败包含旧路由预期与 worker Python 环境缺少 cv2。**全套测试不是全绿**。 +- 原始日志位于本机 `/tmp/annotation-implementation/`;回归计数记录位于上述忽略的验证目录。 + +旧的源码字符串断言不作为本次交互验收证据;旧 1280×640 浏览器脚本未被当作新 1413×615 验收通过。 + +## Standards + +独立审查未发现文档化规范违反。提出 1 项低优先级重复状态归一化建议,已统一到 `effectiveActionStatus`,并补验证。剩余已知阻塞项:0。 + +## Spec + +独立审查发现并修复 3 项问题:任务池范围过宽;Shift 长按在文本聚焦后仍可能继续;未选中动作时上下导航未以播放头为起点。审查代理复核修复后无剩余代码阻塞项。字典搜索框上键进入末项的追加修复亦已复核。集群浏览器随后发现“普通页进入专注页丢失默认左相机”及“舍弃弹窗底部按钮需滚动”两个问题,已在 `88eb8fd7`/`5247c69e` 修正,最终公司浏览器默认左相机及 G 弹窗可达性复测通过。 + +最后恢复专项发现一项真实缺陷:直接打开/刷新工作页后,对同一任务点击继续,导航 key 更新而 buffer 轮询 effect 未重新建立,旧来源校验一直判 stale,界面显示连续工作但不补领。旧版本真实浏览器回归明确 RED:15 秒内仍占 1、应占 2,领取请求为 0,送检请求为 0(`resume-red/buffer-resume-result.json`)。`ad8756e7` 将 `location.key` 加入 effect 依赖并保留迟到响应校验,独立审查通过;新版真实 GREEN:占位从1补到2,恰好1次领取、0次送检,演示task08仍pending_annotation;随后新版late-pause复测仍无导航或补领。保留旧RED与新GREEN证据,不把代码修复本身当作测试通过。 + +审查计数:Standards 0 项规范违反、1 项建议已处理;独立Spec 3项发现均已修复。公司验收另发现相机默认、G弹窗及同任务恢复轮询缺陷,均已修复并复测。代码审查与动态证据分列;不能由无阻塞审查推断所有异常组合已验收。 + +## 公司验收范围与限制 + +仅在隔离项目 `[TEST] 连续动作与任务缓冲 20260921` 创建测试任务和输出。真实双目视频及帧时间戳从既有素材复制到独立验收目录;没有修改客户原任务、原视频或 BOS 对象。项目仅授权现有专用测试角色。 + +公司浏览器通过标准 Kubernetes 安全转发访问真实服务,保留普通 HTTP 入口既有安全限制。原始测试副本在该验证连接上多次出现加载超时,后来对隔离副本生成低带宽预览,并用 ffprobe 逐帧核对 PTS 一致。保留原副本;这次小体积真实双目验收证明交互和处理链路,不能作为生产大视频网络吞吐或性能保证。 + +### 已通过的核心公司验收 + +证据原件位于本机忽略目录 `local-data/verification/continuous-actions-20260921/`。下列简写与矩阵一致,不将日志、账号会话或集群配置提交到仓库。 + +| 证据 | 已执行内容 | +| --- | --- | +| P、B | 切片三相机、一条时间轴,F 选名称,开始补齐到 2;切片确认 202 后切到其他任务。隔离 task04 真实双切片首次执行完成 2/2;待标注保存回读、未完成送检 400、无效保存、送检 202 仍占位,真正质检后腾位。 | +| C | `final-editor.log`:1413×615,task08,51 动作,errors=[];默认左相机、标注三视图两轴、G 控件可达、视频点击、滑块后快捷键、C 连续分区、保存刷新、跨六与循环、边界调整、文本聚焦停长按、描述/无效保存与撤销回读。 | +| E | `extended-browser-result.json`:JSON 跟随播放头且编辑选中保持;缩零/吞并一次撤销;一手势最多一邻段;末端固定;缩窗暂停后手动继续;暂停期间容量 8→2 不领取。 | +| G | `discard-browser-result.json`:G 三页键盘翻页、选原因、必填说明缺失不提交、长说明不要求弹层滚动、真实舍弃保存 51 条历史快照、恢复后仍有 51 条动作。 | +| S | `submit-refill-result.json`:51 动作 task01 经真实浏览器确认送检并到达质检;优先切到已可标注 task08,补领 task03,使占位回到 2;记录一次送检和一次随机领取,然后暂停。 | +| L | `layout-preferences-result.json`:首项目预选不领取、显式项目保持、旧 original 偏好忽略、临时视图与默认独立、新任务应用默认、1920×1080 等比放大、1413×615 两轴可见、返回普通工作台后 Space 正常。 | +| T | `cluster-probe-return-summary.json`:QC 退回 task04 返回 201,进入 rework、清空归属,公共池 4→5,原标注员仍只占 task03/08 两项,未自动领取。 | +| I、J | d363a791 阶段追加验收:描述/无效切分继承与撤销、未保存文字阻止切分导航、切片合并名称;右视频同步、全部range拖动恢复Space、两阶段帮助、动作/切片鼠标共同边界与一次撤销、提交提示。 | +| W | 真实 work-buffer 响应先由 route.fetch 取得,仅延迟交付;暂停后释放,5秒内URL/任务不变、不恢复连续模式、无领取请求。 | +| X | task03 全舍弃:真实切片202→processor完成→combined202→质检,原因证据保留。早期测试脚本步骤错误不作产品失败,最终正确流程通过。 | +| Y | 隔离02真实生成故障后错误/重试入口可见,08仍可编辑(临时文本取消),失败持续占位且无新领取;隔离副本从备份finally还原,UI重试真实processor完成。1/3动作取模与首尾导航、临时C撤销通过。 | +| Z | 送检失败/CAS/预留重载/版本变化与重试SHA定向公开契约通过 `ok2.609s`。 | +| AA | mixed task02真实送检202响应中断,总计1次combined POST;暂停领取0,质检状态、原因快照版本1及无效动作回读正确。ad875明确恢复后只补领1次,占位1→2、无送检;新版迟到暂停复测无导航/领取。 | +| D | 本轮定向接口契约包含字典版本、项目隔离、自由文本兼容、快照与 BSON 恢复,`final-contracts.log` 为 `ok 3.540s`。 | + +送检脚本将剩余待标注区间通过公开 API 保存为无效后再通过浏览器提交,不宣称每一段都是通过 UI 手工输入。真正送检成功与受理中的占位差异均有公开 API 回读。早期 fixture 重复使用及恢复按钮选择问题导致的失败日志保留,最终成功结果不掩盖这些历史运行。 + +### 自测与演示入口 + +在公司网站选择隔离项目 **[TEST] 连续动作与任务缓冲 20260921**,进入“我的任务”,继续 task08(任务编号末尾 `-08`):它保留 51 个动作,适合演示上下/跨六选择、JSON、单路/双路、G 字典和微调撤销。切勿把这批隔离测试任务当作客户待交付任务。 + +验收结果可在任务流转中核对:task01 正常送检,task03 全舍弃送检,task02 混合舍弃送检,均进入质检;task04 经 QC 退回公共池。新领取数量及当前任务以“个人任务池”实时显示为准。返回任务池或点击“暂停连续工作”会停止补领;修改演示任务前可先记下内容,临时切分可用撤销恢复。 + +### 验收结论与明确限制 + +17 票已完成实现、独立审查与约定的分层验收,全部 resolved。公司最终真实链路包括切片后台接续、51动作保存刷新、无效/撤销、全舍弃及混合舍弃质检、真实生成故障及重试、送检响应丢失核对、暂停与明确恢复补位。最终轮询缺陷有旧版 RED/修复版 GREEN,不留 claimed 中间态。 + +仍未穷举所有账号/项目切换的迟到排列、各浏览器组合、全部缩放与超长错误同时出现的情况。长按精确1000ms/500ms调度常量与取消入口由审查支持,真实浏览器验证了单步、持续按住、吞并上限及失焦停止,未声称测量每次定时器抖动。基线全套测试依然存在相同已知失败;小体积真实视频验证不能代表大视频网络性能。矩阵保留各项证据来源和这些边界。 + +公司浏览器验收已结束,连续工作已暂停、无在途测试请求,标准验证转发已关闭。 + +本次未推送 Git。部署使用公司 poc,未涉及 wjzh;测试仅操作独立验收副本与任务,客户原视频及 BOS 对象未修改。 diff --git a/docs/verification/dev-merge-20260921.md b/docs/verification/dev-merge-20260921.md new file mode 100644 index 00000000..53f42615 --- /dev/null +++ b/docs/verification/dev-merge-20260921.md @@ -0,0 +1,32 @@ +# Dev 最新提交与本地标注版本合并核验 + +2026-09-21,按用户要求 fetch 后,将 `origin/dev` 的 `50968761` 合入当前个人分支 `feature/local-dev-toolkit`。合并前为 `0462e1f4`,备份分支为 `codex/backup-before-dev-merge-20260921-0462e1f4`。本次仅本地合并和验证,未推送、未部署、未修改公司数据。 + +## 同事新增内容 + +相对之前已合入的账号管理版本 `e48c4cca`,新增三笔提交: + +- `a8830a61`:账号管理新增供应商级联删除。先预览范围,再输入供应商名称并确认停止相关运行资源;后台处理支持进度、失败重试和审计。保护默认供应商、其他供应商的数据、共享项目和原始采集输入。 +- `dd2c2dc5`:收紧共享工作目录的删除范围,并更改上游开发与发布规则。 +- `50968761`:兼容空标注数组的历史 `null` 数据,舍弃后恢复空片段时返回空数组,避免页面异常;补齐账号权限测试数据。格式错误的非数组数据仍明确报错,不当作空标注覆盖。 + +## 合并处理 + +- 内存存储字段冲突同时保留个人任务池容量和供应商删除记录。 +- 草稿测试的项目成员配置去重,按照账号的单一生产角色生成项目职责;未领取任务仍不能保存。 +- 自动合并后的 Mongo 领取同时保留项目范围删除锁、账号变更锁,以及 `EnforceBuffer` 容量和幂等路径。 +- 保留本地连续动作、快捷键、任务名称补全、紧凑布局和无字典手填舍弃面板。 +- 上游 `AGENTS.md` 要求只在 `dev` 工作和推送,与本次用户明确提供的个人分支规则冲突。文件保持合并前内容,未切换或推送 `dev`,未删除本地分支。 +- 两个独立 Mongo 测试的旧账号缺少供应商归属,已补齐测试字段;生产权限未放宽。 + +## 验证结果 + +- TypeScript、Vite 生产构建、`go build ./...` 通过。 +- Store 全量测试通过;账号、项目成员、供应商删除、随机领取、个人任务池、连续动作、舍弃、草稿和恢复的定向 API 测试通过。 +- 供应商级联删除的内存和独立 Mongo 测试通过,启用 Go race 检查。测试使用本地新建 `supplier_cascade_test_*` 库并清理;没有删除现有供应商数据。 +- 独立 Mongo HTTP 验证通过:五轮各十六个并发领取请求,容量二、重复请求回放、送检后的补领及中断回执恢复。独立 Store 领取竞争和恢复测试也通过。 +- 本地 API 3001 已重启至合并版本,5173 真实浏览器十三组回归通过:切片和标注、1413×615/1440×900/1920×1080、左/右/双目、时间轴、保存提交可见性、G/Esc、无字典手填、切换切片的舍弃目标保护,以及未点击任务的名称一致性。 +- 前端全量 594 项:582 通过、12 失败。与合并前相比增加四项通过,无新增失败;十二项为之前已记录的测试债。 +- 扩大 API 检查范围时发现 `TestProjectWorkflowInstanceBindsValidatedSupplier` 仍按旧单次模板建立工作流。已在临时目录的合并前 `0462e1f4` 上复现相同 `continuous_capture_only` 失败,单独记录为已有问题,其余定向检查通过。 + +证据:`local-data/verification/dev-merge-20260921/`(忽略目录);日志:`/tmp/dev-merge-*.log`。本次不代表公司集群已升级,也未执行公司供应商级联删除验收。 diff --git a/docs/verification/merged-frontend-cluster-20260921.md b/docs/verification/merged-frontend-cluster-20260921.md new file mode 100644 index 00000000..be667026 --- /dev/null +++ b/docs/verification/merged-frontend-cluster-20260921.md @@ -0,0 +1,48 @@ +# 合并版本公司前端部署与验证 + +2026-09-21,按用户“先部署到公司集群中测试一下前端功能”的授权执行。目标为泛宇公司集群 `droboticflow-fanyu`,公网入口为 `http://120.48.180.80`,未操作 wjzh、未推送 Git。 + +## 最终发布 + +- 发布前公司版本为同事已合并的 `50968761`。 +- 首次部署本地合并版本 `4f7274b2`;公司截图检查发现长任务名仍可挤压顶部状态徽标,修复并提交为 `36269350`。 +- 最终 API、annotation processor、Worker 均为 `362693503137d31709a2caa5454c4604e7d93152`,三个 Deployment 都达到 1/1 Ready。 +- API/processor 镜像:`sha256:b5a1caa0a8597f7b1b67b0025d84529b057b15c6559b39cd4ae3e32b0dd07446`。 +- Worker 镜像:`sha256:541724cb44b3d2e8e56cff2f4752b7562a1751b74dae2962e75daf82a0b1879b`。 +- 公网 API health/ready 正常,Worker ready 为 true、首次成功调度约 140 秒、stuckRunCount 为 0。API 使用原有 Recreate 策略,发布期间存在短暂 502;就绪后已恢复。 + +镜像包只包含前端 dist 和已验证的 Linux 二进制。最终修订只改 CSS 和浏览器回归,已核对 Go 源码与 `4f7274b2` 相同,因此复用该版本二进制。部署仅替换镜像和相应版本元数据,使用资源版本及旧镜像断言避免覆盖其他发布;未修改密钥、网络策略、数据库连接或容量配置。 + +原 Worker 已包含同事后端规则,但保留旧提交会在前端显示“组件版本不一致”,因此最终同提交构建并发布 Worker。协调器、算子镜像和其他服务未更新。 + +## 实际前端检查 + +公司浏览器连接通过标准 Kubernetes 安全转发访问真实服务,使用已有测试账号及隔离项目 `[TEST] 连续动作与任务缓冲 20260921`。公网 HTTP 的专注模式安全连接要求未修改。 + +- 切片/标注两个阶段,1413×615、1440×900、1920×1080,左/右/双摄像机:视频、时间轴、编辑和保存提交区域可见。 +- G 在右侧打开舍弃原因面板,分页和 Esc 返回;F 切片名称字典、分阶段快捷键帮助正常。 +- 视频点击播放/暂停;可见进度条拖动后 Space 仍可控制播放。 +- 51 动作列表的上下选择、Ctrl+下跨六段、C 切分及撤销恢复通过;JSON 预览可展开。 +- 任务池未点击条目与个人任务下拉名称一致,不显示“未识别 Capture”。 +- 供应商管理员通过真实浏览器重新登录,账号管理页正常,返回本供应商七名生产账号,未出现页面异常。本次没有执行供应商删除操作。 +- 公司复现长名称导致的状态标签裁切:原来徽标超出 26px 标题行;修复后名称可缩略、状态不换行,最终公司 DOM 边界检查全部在行内。没有调整页面骨架。 +- 该 CSS 修复的本地类型检查、生产构建和十三组真实浏览器回归通过,回归增加长名称压测。 +- 最终 `36269350` 补充浏览器脚本通过:普通布局 G/Esc、专注页 51 动作与 JSON、返回任务池实际路由;页面错误为零,未发送任务保存或提交请求。 + +无字典手填在同一合并代码的本地真实浏览器和 API 测试中已验证;本次公司隔离项目配置了舍弃字典,未为测试而清空该字典,不把公司字典面板检查当作无字典提交验收。 + +## 测试过程与数据恢复 + +早期浏览器脚本把可见文字当作按钮无障碍名、将链接当作按钮,以及未等待焦点稳定,出现过脚本超时。后续按实际 DOM 修正并补充验证,保留失败日志。 + +“继续工作”自动选择了优先任务,早期脚本原计划重置隔离 task04,实际请求重置了隔离 task08。发现后立即用预先保存的快照,通过公开切片确认及描述确认 API 恢复 task08;已逐项比较切片、51 条动作、操作和状态,内容一致。任务版本及确认时间因恢复而增加;task04 未被重置。没有修改客户任务、原视频或 BOS 对象。该错误属于测试任务定位,不能把计划中的 task04 操作当成实际证据。 + +恢复后的 task08 仍可作为 51 动作演示任务。公司测试中的切片阶段检查实际发生在该隔离任务恢复前;标注阶段、普通布局 G、JSON 与返回任务池分别保留补充验证。 + +## 证据与回滚 + +本机忽略目录 `local-data/verification/merged-frontend-deploy-20260921/` 保存各次发布前配置、镜像摘要、受限文件权限的测试会话、截图、任务快照和恢复结果。`final/` 保存最终部署及 ready 证据;`heading-red-green.json` 和最终截图记录标题问题修复。原始日志在 `/tmp/merged-frontend-*.log`。 + +完整构建回滚配置已留存。回滚脚本会校验当前镜像,不能不核对线上版本就重放。验收不包含完整质检/验收交付链路、供应商级联删除或大视频性能压测;之前已有的全量测试债仍按本地合并报告记录,未宣称全量测试全绿。 + +验收完成后已清理本次上传的四个远端构建压缩包,关闭临时验证转发;本地回滚配置和证据保留。 diff --git a/docs/verification/random-claim-work-entry-20260918.md b/docs/verification/random-claim-work-entry-20260918.md new file mode 100644 index 00000000..bad2a18d --- /dev/null +++ b/docs/verification/random-claim-work-entry-20260918.md @@ -0,0 +1,57 @@ +# 随机领取后工作模式入口被禁用(2026-09-18) + +## 现象与根因 + +先按用户要求将已有版本推送到个人分支并更新 PR #1,PR head 为 `22d6e68e`;随后单独排查本问题。 + +在公司网站使用两个刚领取、尚未编辑的任务复现:`开始工作` 被禁用,并显示“请先确认当前编辑”。测试浏览器具备安全上下文和 Web Locks,因此本次失败与普通 HTTP 的手动模式限制不同。没有为复现新增随机领取。 + +浏览器只延迟帧范围响应,即可区分故障发生点: + +| 时机 | 开始工作 | 未保存提示 | +| --- | --- | --- | +| 任务详情已加载,帧范围尚未返回 | 可用 | 无 | +| 真实帧范围返回,默认切片自动对齐 | 禁用 | 出现 | + +该任务详情的初始范围为 `0–899.833008` 秒;真实公共帧范围为 `0.03332714844444444–899.7996808515555` 秒。`loadFrameTimeline` 正确地对齐了系统默认切片,但未更新用于判断未保存编辑的 `annotationBaselineRef`。因此自动初始化后,当前工作区和比较基准不同,被当成了用户编辑。刷新或重新打开同类任务会重复触发,与用户是否操作过无关。 + +复现脚本在旧版本稳定失败,输出 `startEnabled=false`、`dirtyWarning=1`;两条任务均保持 version=2,没有保存、提交或领取请求。 + +## 修复边界 + +仅在允许初始化系统默认切片、仍是同一任务和同一已加载工作区快照、比较基准尚未被后续保存替换时,使用该快照计算对齐后的干净基准。不会把当前实时编辑内容吸收到基准,不修改服务端保存内容或放开导航保护。已有人工切片、保存草稿、切换任务和过期响应沿用原保护。 + +新增真实浏览器回归 `tests/browser/annotation-frame-initialization-entry.mjs`,使用外部指定的已领取任务与认证状态,拦截所有业务写入。覆盖默认初始化、帧范围失败后重试、真正切分仍被保护、撤销后恢复干净状态,以及同标签页进入原任务工作模式。 + +沿用用户要求,不运行本地测试套件;静态类型检查通过,修复后的实际验收在公司网站执行。诊断、发布及会话资料仅保存在忽略目录 `local-data/verification/random-claim-entry-20260918/`。 + +## 发布记录 + +- 修复源码提交:`f46d96d0c517b653ba08a9e27fc5b16d3fc6162b`。 +- 部署目标:`droboticflow-fanyu` 的 API 前端。 +- 镜像:`ccr-29eug8s3-vpc.cnc.bj.baidubce.com/fanyu/droboticflow-api@sha256:6bd7c7e61d550bb2827c101f3344313090f0e26d88e84ce2d0605f6fed5a6758`。 +- 从已提交的干净源码构建,类型检查和 Vite 构建通过。保留发布前镜像及公开构建版本字段,后端二进制与切片处理器沿用原版本。 + +## 公司环境验收结果 + +API rollout 成功、1 个副本就绪;公开就绪接口返回修复提交及镜像,61 个前端文件的 SHA-256 与构建产物一致。API 二进制仍为 `7d823fc765b334f980a2701d7b903e3dd5ed1fc445fb52e879cd86a24b527876`,保留此前帧数和心跳修复。 + +同一真实浏览器回归在旧线上版本失败,在修复版本通过;两个已领取任务分别完整执行,脚本退出码均为 0: + +| 场景 | 两条任务的结果 | +| --- | --- | +| 默认切片完成真实帧范围初始化 | “开始工作”可用,无未保存提示 | +| 帧范围读取失败后,点击显式重试 | 重试成功后仍为干净状态,可进入工作模式 | +| 在视频四分之一位置按 C 真正切分 | 未保存提示出现,“开始工作”被禁用 | +| Ctrl+Z 撤销刚才切分 | 恢复默认切片,未保存提示消失,入口重新可用 | +| 点击开始工作 | 同标签页进入 `/work`,taskId 保持原任务,无额外随机领取 | +| API 回读 | 两条任务均保持 version=2,工作区内容不变 | +| 网络与页面异常 | 无业务写入请求,无页面脚本异常 | + +重试场景只在隔离浏览器内替换一次读取响应为 500,并未让服务端故障。502/503/504 会被现有 API 客户端自动重试,因此不用于触发显式重试按钮。回归定位已按实际界面使用“返回任务池”链接,并等待帧加载提示消失后再操作。 + +独立代码复核未发现剩余重要问题;确认帧范围就绪的测试时序问题已按复核意见修正。本轮没有重放随机领取接口,而是使用已领取、未保存编辑的任务验证同一个初始化入口,避免占用新任务。普通 HTTP 的安全连接限制保持原样,独立工作页仍使用此前获准的测试浏览器来源例外验收。 + +回滚补丁通过服务端 dry-run,未实际回退。临时构建 Job、ConfigMap、已校验上传包均已清理,测试登录会话已退出。 + +Git 发布边界:此前完成版本已推送到 [PR #1](https://gitea.d-robotics.cc/longtao.wu/droboticflow/pulls/1),head 为 `22d6e68e`。本问题的后续修复和验收记录本地提交,已部署公司环境,未追加推送到 PR。 diff --git a/docs/verification/workspace-panel-repair-20260921.md b/docs/verification/workspace-panel-repair-20260921.md new file mode 100644 index 00000000..8e9a4cc8 --- /dev/null +++ b/docs/verification/workspace-panel-repair-20260921.md @@ -0,0 +1,27 @@ +# 工作台布局、舍弃输入与任务名称修复 + +2026-09-21,修复用户六张截图所指出的四项问题。沿用既有页面风格与切片/标注阶段结构。 + +## 修复与根因 + +- 工作状态说明与任务徽标原来使用重叠的绝对定位空间,现分配到右侧独立位置。 +- 描述编辑区的弹性高度和可见溢出会挤压底部;标注时间轴所在网格行还会把提交区拉高,与舍弃栏相交。现限制描述输入高度,分开舍弃栏与提交区,缩紧操作间距;长描述仍可展开编辑。 +- G 舍弃原因改为右侧非模态编辑面板,保留 Enter 选词、Ctrl/⌘+Enter 确认和 Esc 返回。切换切片时关闭旧目标面板,不自动提交。恢复片段也在同一面板操作。 +- 项目确实未配置舍弃字典时,支持必填手动原因(去首尾空白,最多 1000 字)。服务器通过 `allowManual` 明确告知前端;字典读取失败、有配置但词条不可用、搜索无结果都不等于允许手填。已有字典仍校验项目、版本和必填补充说明。 +- 个人任务缓冲/随机领取接口原来返回未补全的 HumanItem,前端用这些数据覆盖已有列表,造成未点击卡片显示“未识别 Capture”;点击后详情接口补全名称,才恢复显示。现复用业务显示信息解析器补全接口,并统一下拉框、恢复列表、任务卡片和详情标题的名称规则,不使用原始 run/artifact 文件名作显示名。 + +## 验证 + +- 公开 HTTP 回归先失败后通过:缓冲和领取任务无需点击详情就带有 Capture 名称;无字典手填可保存并公开回读;空白、超长、有配置却绕过字典、读取失败均被拒绝。 +- TypeScript 检查、相关 Go API 测试、业务显示名称 5 项测试、Vite 生产构建通过。 +- 全量前端测试 583 项:573 通过,10 项失败;与既有基线失败名称完全一致,无新增失败。 +- 浏览器回归脚本:`tests/browser/workspace-panel-repair.mjs`。使用本地隔离项目 `project-workspace-layout-acceptance`,验证实际阶段而非仅按任务名称判断;覆盖 1413×615、1440×900、1920×1080 内容区,左右单目和双目、状态与徽标不重叠、保存提交区可见且不被容器裁切、时间轴、G/Esc、目标切换、原布局以及未点击任务卡片与下拉框同名。 +- 使用修复前 CSS 运行同一浏览器检查,明确失败于状态说明与任务徽标重叠;已恢复修复后的 CSS。 +- 本地浏览器真实 Ctrl+Enter 手填舍弃请求返回 200,公开任务接口回读原因成功,再通过 UI 恢复片段。测试未对客户任务作写入。 +- 将旧的 UI 源码字符串断言替换为真实浏览器交互检查,避免实现代码格式影响验收结论。 + +本地截图、API 记录和浏览器结果保存在忽略目录 `local-data/verification/workspace-repair-20260921/`。本地验收批次补充 `raw_human` 属性,以覆盖当前连续动作流程。 + +## 发布边界 + +本次未推送 Git、未覆盖公司部署。只读检查发现,公司当前实际运行提交为 `ab8cbb01edfe553ebf494b4072cda51e213cc282`(本地仓库无该提交),其个人任务缓冲接口返回 404,与此前验收的 `ad8756e7` 不同。因此本报告的本轮交互验收范围是本地;部署前需核对线上版本的来源和差异,避免覆盖同事更新。 diff --git a/internal/api/annotation_contiguous.go b/internal/api/annotation_contiguous.go new file mode 100644 index 00000000..7ee75b2b --- /dev/null +++ b/internal/api/annotation_contiguous.go @@ -0,0 +1,157 @@ +package api + +import ( + "context" + "droboticflow/internal/domain" + "fmt" + "sort" + "strings" +) + +// The human batch is created by the workflow runner, never supplied by an +// annotation request. Template version alone must not change another workflow. +func (s *server) continuousActionsForItem(ctx context.Context, item *domain.HumanItemRecord) bool { + if item == nil || item.PluginID != "annotation-qa" { + return false + } + batch, err := s.store.GetHumanBatch(ctx, item.BatchID) + return err == nil && batch != nil && batch.OrganizationID == item.OrganizationID && batch.ProjectID == item.ProjectID && batch.WorkflowID == item.WorkflowID && batch.ProcessingProfile == domain.ProcessingProfileRawHuman && domain.IsFanyuV58ThreeRoleHumanLoop(batch.Stages) +} + +func effectiveActionStatus(segment domain.AnnotationSegment) string { + if segment.Status != "" { + return segment.Status + } + if segment.IsInvalid { + return "invalid" + } + if strings.TrimSpace(segment.Description) != "" { + return "described" + } + return "pending" +} + +func validateContinuousActions(slices []domain.SliceSegment, segments []domain.AnnotationSegment, complete bool) []validationIssue { + issues := validateDescriptionIntervals(slices, segments, true) + if len(slices) == 0 { + issues = append(issues, validationIssue{Field: "sliceSegments", Code: "annotation_coverage_gap", Message: "必须保留完整切片范围"}) + } + for i, segment := range segments { + status := effectiveActionStatus(segment) + message := "" + switch status { + case "pending": + if complete { + message = "仍有待标注动作,请填写描述或明确设为无效" + } + if segment.IsInvalid { + message = "待标注动作不能同时标为无效" + } + case "described": + if strings.TrimSpace(segment.Description) == "" || segment.IsInvalid { + message = "已描述动作必须有描述且不能同时标为无效" + } + case "invalid": + if !segment.IsInvalid { + message = "无效动作状态必须与无效判断一致" + } + default: + message = "未知动作状态" + } + if message != "" { + issues = append(issues, validationIssue{Field: fmt.Sprintf("segments.%d.status", i), Code: "action_annotation_incomplete", Message: message}) + } + } + return issues +} + +// Legacy editable data is represented as pending gaps only when the operator +// explicitly saves progress. Reads and submitted revisions are never rewritten. +func fillPendingActionGaps(slices []domain.SliceSegment, segments []domain.AnnotationSegment) []domain.AnnotationSegment { + result := append([]domain.AnnotationSegment{}, segments...) + seen := map[string]bool{} + for i := range result { + seen[result[i].ID] = true + result[i].Status = effectiveActionStatus(result[i]) + } + for _, slice := range slices { + if slice.IsDiscarded() { + continue + } + events := []domain.AnnotationSegment{} + for _, e := range segments { + if e.Start >= slice.Start && e.End <= slice.End { + events = append(events, e) + } + } + sort.Slice(events, func(i, j int) bool { return events[i].Start < events[j].Start }) + cursor := slice.Start + add := func(end float64) { + if end-cursor <= 1e-6 { + return + } + id := fmt.Sprintf("pending-%s-%.9f", slice.ID, cursor) + for seen[id] { + id += "-gap" + } + seen[id] = true + result = append(result, domain.AnnotationSegment{ID: id, Start: cursor, End: end, Status: "pending"}) + } + for _, e := range events { + add(e.Start) + cursor = e.End + } + add(slice.End) + } + sort.SliceStable(result, func(i, j int) bool { return result[i].Start < result[j].Start }) + return result +} + +// A client cannot use the metadata-reuse path to smuggle sub-frame intervals. +func (s *server) continuousActionFrameIssues(ctx context.Context, task domain.AnnotationTaskRecord, item *domain.HumanItemRecord, segments []domain.AnnotationSegment) []validationIssue { + if item == nil || stringValue(mapValue(item.Subject.Payload["sliceWorkflow"])["boundaryContract"]) != "hardware-frame-v1" { + return nil + } + timeline, err := s.annotationFrameTimelineForTask(ctx, task, "left") + if err != nil { + return []validationIssue{{Field: "segments", Code: "annotation_frame_unavailable", Message: "无法核对动作帧边界,请稍后重试"}} + } + seconds, ok := timeline["boundariesSeconds"].([]float64) + if !ok || len(seconds) < 2 { + return []validationIssue{{Field: "segments", Code: "annotation_frame_unavailable", Message: "统一帧边界不可用"}} + } + grid := annotationBoundaryGrid{Seconds: seconds} + for i, e := range segments { + a, ae := grid.resolve(e.Start) + b, be := grid.resolve(e.End) + if ae != nil || be != nil || b <= a { + return []validationIssue{{Field: fmt.Sprintf("segments.%d", i), Code: "annotation_frame_invalid", Message: "动作区间必须对齐真实帧且至少包含一帧"}} + } + } + return nil +} + +func continuousSliceStatuses(slices []domain.SliceSegment, segments []domain.AnnotationSegment) map[string]domain.SliceAnnotationStatus { + statuses := map[string]domain.SliceAnnotationStatus{} + for i := range slices { + if slices[i].IsDiscarded() { + continue + } + status := domain.SliceAnnotationLabeled + found := false + for _, e := range segments { + if e.Start >= slices[i].Start && e.End <= slices[i].End { + found = true + if effectiveActionStatus(e) == "pending" { + status = domain.SliceAnnotationPending + } + } + } + if !found { + status = domain.SliceAnnotationPending + } + slices[i].AnnotationStatus = status + statuses[slices[i].ID] = status + } + return statuses +} diff --git a/internal/api/annotation_contiguous_acceptance_test.go b/internal/api/annotation_contiguous_acceptance_test.go new file mode 100644 index 00000000..b8b1b740 --- /dev/null +++ b/internal/api/annotation_contiguous_acceptance_test.go @@ -0,0 +1,97 @@ +package api + +import ( + "encoding/json" + "net/http" + "testing" + + "droboticflow/internal/domain" +) + +func TestContinuousActionsMalformedCoverageRejectedBeforeBothSubmissionPaths(t *testing.T) { + for _, reuse := range []bool{false, true} { + for name, segments := range map[string][]domain.AnnotationSegment{ + "overlap": {{ID: "a", Start: 0, End: 6, Description: "拿起"}, {ID: "b", Start: 5, End: 10, Description: "放下"}}, + "outside": {{ID: "a", Start: -1, End: 10, Description: "拿起"}}, + "zero": {{ID: "a", Start: 0, End: 0, Description: "拿起"}, {ID: "b", Start: 0, End: 10, Description: "放下"}}, + "end-gap": {{ID: "a", Start: 0, End: 9, Description: "拿起"}}, + } { + t.Run(name+map[bool]string{false: "/generate", true: "/reuse"}[reuse], func(t *testing.T) { + f := continuousFixture(t) + if reuse { + seedCompletedMaterialization(t, f, 1) + } + r := f.request(http.MethodPost, "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/combined-submissions", f.annotator, map[string]any{"version": f.item.Version, "sliceSegments": []domain.SliceSegment{{ID: "s", Name: "测试切片", Start: 0, End: 10}}, "segments": segments}) + if r.Code != http.StatusBadRequest { + t.Fatalf("malformed coverage accepted: %d %s", r.Code, r.Body.String()) + } + item, _ := f.store.GetHumanItem(f.ctx, f.item.ID) + if item.Version != f.item.Version || item.PendingCombinedSubmissionID != "" || item.CurrentStageID != f.item.CurrentStageID { + t.Fatal("rejected submission reserved or advanced the task") + } + }) + } + } +} + +func TestContinuousActionsMixedAndAllDiscardedReachReviewWithEvidence(t *testing.T) { + for _, all := range []bool{false, true} { + t.Run(map[bool]string{false: "mixed", true: "all-discarded"}[all], func(t *testing.T) { + f := continuousFixture(t) + body := dispositionFixturePayload(t, f) + for i := range body.SliceSegments { + body.SliceSegments[i].Name = "测试切片" + } + body.Segments = []domain.AnnotationSegment{{ID: "a-action", Start: 0, End: 3, Description: "拿起"}, {ID: "b-action", Start: 3, End: 7, Description: "放下"}, {ID: "c-action", Start: 7, End: 10, Status: "invalid", IsInvalid: true}} + ids := []string{"b"} + if all { + ids = []string{"a", "b", "c"} + } + for _, id := range ids { + body.SliceID = id + r := f.request(http.MethodPost, "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/slice-dispositions", f.annotator, body) + if r.Code != http.StatusOK { + t.Fatalf("discard %s: %d %s", id, r.Code, r.Body.String()) + } + var got struct { + Item domain.HumanItemRecord `json:"item"` + Workspace combinedAnnotationDraftInput `json:"workspace"` + } + if err := json.Unmarshal(r.Body.Bytes(), &got); err != nil { + t.Fatal(err) + } + body.combinedAnnotationDraftInput = got.Workspace + body.Version = got.Item.Version + } + seedCompletedMaterialization(t, f, 1) + r := f.request(http.MethodPost, "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/combined-submissions", f.annotator, body.combinedAnnotationDraftInput) + if r.Code != http.StatusCreated { + t.Fatalf("submit: %d %s", r.Code, r.Body.String()) + } + item, _ := f.store.GetHumanItem(f.ctx, f.item.ID) + if item.CurrentStageID != domain.FanyuV58StageQualityReview { + t.Fatal("not sent to quality") + } + revisions, err := f.store.ListSliceRevisions(f.ctx, f.task.OrganizationID, f.task.ID) + if err != nil || len(revisions) != 1 { + t.Fatalf("slice revisions: %v %v", revisions, err) + } + count := 0 + for _, s := range revisions[0].Segments { + if s.IsDiscarded() { + count++ + if s.DiscardReasonLabelID != "discard-fixture" || s.DiscardedByUserID != f.annotator.ID || len(s.DiscardedAnnotations) != 1 { + t.Fatalf("lost audit snapshot: %+v", s) + } + } + } + if count != len(ids) { + t.Fatalf("discard count=%d", count) + } + annotations, err := f.store.ListAnnotationRevisions(f.ctx, f.task.OrganizationID, f.task.ID) + if err != nil || len(annotations) != 1 || len(annotations[0].Segments) != 3-len(ids) { + t.Fatalf("unexpected active annotation results: %+v %v", annotations, err) + } + }) + } +} diff --git a/internal/api/annotation_contiguous_http_test.go b/internal/api/annotation_contiguous_http_test.go new file mode 100644 index 00000000..578490e9 --- /dev/null +++ b/internal/api/annotation_contiguous_http_test.go @@ -0,0 +1,193 @@ +package api + +import ( + "droboticflow/internal/domain" + "encoding/json" + "net/http" + "testing" +) + +func continuousFixture(t *testing.T) combinedDraftFixture { + f := newCombinedDraftFixture(t) + b, _ := f.store.GetHumanBatch(f.ctx, f.item.BatchID) + b.ProcessingProfile = domain.ProcessingProfileRawHuman + if err := f.store.UpsertHumanBatch(f.ctx, *b); err != nil { + t.Fatal(err) + } + f.task.ProcessingProfile = domain.ProcessingProfileRawHuman + if err := f.store.UpsertAnnotationTask(f.ctx, f.task); err != nil { + t.Fatal(err) + } + seedSliceDictionary(t, f, "测试切片") + return f +} + +func TestContinuousActionsSavePendingProgressAndReadBack(t *testing.T) { + f := continuousFixture(t) + r := f.request(http.MethodPut, "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/drafts", f.annotator, map[string]any{ + "version": f.item.Version, + "sliceSegments": []map[string]any{{"id": "s", "name": "测试切片", "start": 0, "end": 10}}, + "segments": []map[string]any{{"id": "a", "start": 0, "end": 4, "status": "pending"}, {"id": "b", "start": 4, "end": 10, "status": "described", "description": "拿取"}}, + }) + if r.Code != http.StatusOK { + t.Fatalf("save: %d %s", r.Code, r.Body.String()) + } + r = f.request(http.MethodGet, "/api/plugins/annotation-qa/tasks/"+f.task.ID, f.annotator, nil) + if r.Code != http.StatusOK { + t.Fatalf("read: %d %s", r.Code, r.Body.String()) + } + var response struct { + Task struct { + ContinuousActions bool `json:"continuousActions"` + } `json:"task"` + HumanItem struct { + Subject struct { + Payload struct { + Draft struct { + Segments []struct { + Status string `json:"status"` + } `json:"segments"` + } `json:"annotationDraft"` + } `json:"payload"` + } `json:"subject"` + CurrentStageID string `json:"currentStageId"` + } `json:"humanItem"` + } + if err := json.Unmarshal(r.Body.Bytes(), &response); err != nil { + t.Fatal(err) + } + if !response.Task.ContinuousActions || len(response.HumanItem.Subject.Payload.Draft.Segments) != 2 || response.HumanItem.Subject.Payload.Draft.Segments[0].Status != "pending" { + t.Fatalf("pending partition / scope missing: %s", r.Body.String()) + } + if response.HumanItem.CurrentStageID != domain.FanyuV58StageAnnotationCombined { + t.Fatal("saving progress submitted task") + } +} + +func TestContinuousActionsRejectIncompleteSubmissionWithoutClientFlag(t *testing.T) { + for name, segments := range map[string][]map[string]any{ + "blank": {}, + "gap": {{"id": "a", "start": 0, "end": 4, "description": "拿取"}}, + "pending": {{"id": "a", "start": 0, "end": 10, "description": "未确认文字", "status": "pending"}}, + } { + t.Run(name, func(t *testing.T) { + f := continuousFixture(t) + r := f.request(http.MethodPost, "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/combined-submissions", f.annotator, map[string]any{"version": f.item.Version, "sliceSegments": []map[string]any{{"id": "s", "name": "测试切片", "start": 0, "end": 10}}, "segments": segments}) + if r.Code != http.StatusBadRequest { + t.Fatalf("incomplete must reject before media work: %d %s", r.Code, r.Body.String()) + } + }) + } +} + +func TestContinuousActionsConfirmedInvalidCanReachReview(t *testing.T) { + f := continuousFixture(t) + seedCompletedMaterialization(t, f, 1) + r := f.request(http.MethodPost, "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/combined-submissions", f.annotator, map[string]any{"version": f.item.Version, "sliceSegments": []map[string]any{{"id": "s", "name": "测试切片", "start": 0, "end": 10}}, "segments": []map[string]any{{"id": "a", "start": 0, "end": 10, "status": "invalid", "isInvalid": true}}}) + if r.Code != http.StatusCreated { + t.Fatalf("confirmed invalid should reach quality: %d %s", r.Code, r.Body.String()) + } + r = f.request(http.MethodGet, "/api/plugins/annotation-qa/tasks/"+f.task.ID, f.annotator, nil) + var response struct { + Revisions []struct { + Segments []domain.AnnotationSegment `json:"segments"` + } `json:"revisions"` + } + if err := json.Unmarshal(r.Body.Bytes(), &response); err != nil { + t.Fatal(err) + } + if len(response.Revisions) != 1 || len(response.Revisions[0].Segments) != 1 || !response.Revisions[0].Segments[0].IsInvalid { + t.Fatalf("invalid result lost: %s", r.Body.String()) + } +} + +func TestContinuousActionsSaveProgressFillsLegacyGapsAndProtectsVersion(t *testing.T) { + f := continuousFixture(t) + item := f.item + item.Subject.Payload["sliceWorkflow"] = map[string]any{"status": "completed", "phase": "annotate"} + if err := f.store.UpsertHumanItem(f.ctx, item); err != nil { + t.Fatal(err) + } + payload := map[string]any{"version": item.Version, "sliceSegments": []map[string]any{{"id": "s", "name": "测试切片", "start": 0, "end": 10}}, "segments": []map[string]any{{"id": "old", "start": 2, "end": 4, "description": "历史动作"}}} + endpoint := "/api/plugins/annotation-qa/tasks/" + f.task.ID + "/annotation-confirmations" + r := f.request(http.MethodPost, endpoint, f.annotator, payload) + if r.Code != http.StatusOK { + t.Fatalf("save progress: %d %s", r.Code, r.Body.String()) + } + r = f.request(http.MethodGet, "/api/plugins/annotation-qa/tasks/"+f.task.ID, f.annotator, nil) + var response struct { + HumanItem struct { + Subject struct { + Payload struct { + Workspace struct { + Segments []domain.AnnotationSegment `json:"segments"` + } `json:"annotationWorkspace"` + } `json:"payload"` + } `json:"subject"` + } `json:"humanItem"` + } + if err := json.Unmarshal(r.Body.Bytes(), &response); err != nil { + t.Fatal(err) + } + segments := response.HumanItem.Subject.Payload.Workspace.Segments + if len(segments) != 3 || segments[0].Start != 0 || segments[0].End != 2 || segments[0].Status != "pending" || segments[1].ID != "old" || segments[1].Description != "历史动作" || segments[2].Start != 4 || segments[2].End != 10 || segments[2].Status != "pending" { + t.Fatalf("legacy gaps: %+v", segments) + } + r = f.request(http.MethodPost, endpoint, f.annotator, payload) + if r.Code != http.StatusConflict { + t.Fatalf("stale progress overwrote: %d %s", r.Code, r.Body.String()) + } +} + +func TestContinuousActionsRejectContradictoryAndUnknownJudgments(t *testing.T) { + for _, segment := range []map[string]any{ + {"id": "a", "start": 0, "end": 10, "status": "mystery", "description": "test"}, + {"id": "a", "start": 0, "end": 10, "status": "described"}, + {"id": "a", "start": 0, "end": 10, "status": "pending", "isInvalid": true}, + {"id": "a", "start": 0, "end": 10, "status": "invalid"}, + } { + f := continuousFixture(t) + r := f.request(http.MethodPut, "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/drafts", f.annotator, map[string]any{"version": f.item.Version, "sliceSegments": []map[string]any{{"id": "s", "start": 0, "end": 10}}, "segments": []map[string]any{segment}}) + if r.Code != http.StatusBadRequest { + t.Fatalf("contradictory judgment: %d %s", r.Code, r.Body.String()) + } + } +} + +func TestContinuousActionsLegacyEndpointCannotBypassCombinedGate(t *testing.T) { + f := continuousFixture(t) + r := f.request(http.MethodPost, "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/revisions", f.annotator, map[string]any{"segments": []any{}}) + if r.Code != http.StatusConflict { + t.Fatalf("legacy stage bypass: %d %s", r.Code, r.Body.String()) + } +} + +func TestContinuousActionsSubmittedTaskCannotBeRewrittenByProgressSave(t *testing.T) { + f := continuousFixture(t) + item := f.item + item.CurrentStageID = "quality_review" + item.Status = domain.HumanItemSubmitted + item.LatestAuthorUserID = f.annotator.ID + if err := f.store.UpsertHumanItem(f.ctx, item); err != nil { + t.Fatal(err) + } + r := f.request(http.MethodPut, "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/drafts", f.annotator, map[string]any{"version": f.item.Version, "sliceSegments": []map[string]any{{"id": "s", "start": 0, "end": 10}}, "segments": []any{}}) + if r.Code != http.StatusConflict { + t.Fatalf("submitted progress mutation: %d %s", r.Code, r.Body.String()) + } + r = f.request(http.MethodGet, "/api/plugins/annotation-qa/tasks/"+f.task.ID, f.annotator, nil) + var response struct { + HumanItem struct { + Version int `json:"version"` + Subject struct { + Payload map[string]any `json:"payload"` + } `json:"subject"` + } `json:"humanItem"` + } + if err := json.Unmarshal(r.Body.Bytes(), &response); err != nil { + t.Fatal(err) + } + if response.HumanItem.Version != item.Version || response.HumanItem.Subject.Payload["annotationDraft"] != nil { + t.Fatalf("read or rejected save rewrote old task: %s", r.Body.String()) + } +} diff --git a/internal/api/annotation_contiguous_progress_acceptance_test.go b/internal/api/annotation_contiguous_progress_acceptance_test.go new file mode 100644 index 00000000..849d5815 --- /dev/null +++ b/internal/api/annotation_contiguous_progress_acceptance_test.go @@ -0,0 +1,62 @@ +package api + +import ( + "encoding/json" + "net/http" + "testing" + + "droboticflow/internal/domain" +) + +func TestContinuousProgressPendingTextDoesNotConfirmAndMalformedHistoryIsNotClipped(t *testing.T) { + f := continuousFixture(t) + endpoint := "/api/plugins/annotation-qa/tasks/" + f.task.ID + payload := map[string]any{"version": f.item.Version, "sliceSegments": []domain.SliceSegment{{ID: "s", Name: "测试切片", Start: 0, End: 10}}, "segments": []domain.AnnotationSegment{{ID: "unfinished", Start: 0, End: 10, Status: "pending", Description: "尚未确认的草稿"}}} + r := f.request(http.MethodPut, endpoint+"/drafts", f.annotator, payload) + if r.Code != 200 { + t.Fatalf("save pending text: %d %s", r.Code, r.Body.String()) + } + read := func() (int, []domain.AnnotationSegment) { + t.Helper() + r := f.request(http.MethodGet, endpoint, f.annotator, nil) + var detail struct { + HumanItem struct { + Version int `json:"version"` + CurrentStageID string `json:"currentStageId"` + Subject struct { + Payload struct { + Draft struct { + Segments []domain.AnnotationSegment `json:"segments"` + } `json:"annotationDraft"` + } `json:"payload"` + } `json:"subject"` + } `json:"humanItem"` + } + if err := json.Unmarshal(r.Body.Bytes(), &detail); err != nil { + t.Fatal(err) + } + if r.Code != 200 || detail.HumanItem.CurrentStageID != domain.FanyuV58StageAnnotationCombined { + t.Fatalf("read progress advanced: %d %s", r.Code, r.Body.String()) + } + return detail.HumanItem.Version, detail.HumanItem.Subject.Payload.Draft.Segments + } + version, segments := read() + if len(segments) != 1 || segments[0].Status != "pending" || segments[0].Description != "尚未确认的草稿" { + t.Fatalf("pending text confirmed or lost: %+v", segments) + } + for _, bad := range [][]domain.AnnotationSegment{ + {{ID: "a", Start: -1, End: 10, Description: "outside"}}, + {{ID: "a", Start: 0, End: 6, Description: "overlap"}, {ID: "b", Start: 5, End: 10, Description: "overlap"}}, + } { + payload["version"] = version + payload["segments"] = bad + r = f.request(http.MethodPut, endpoint+"/drafts", f.annotator, payload) + if r.Code != 400 { + t.Fatalf("malformed saved rather than rejected: %d %s", r.Code, r.Body.String()) + } + after, current := read() + if after != version || len(current) != 1 || current[0].ID != "unfinished" || current[0].Status != "pending" { + t.Fatalf("rejection changed authoritative draft: v%d %+v", after, current) + } + } +} diff --git a/internal/api/annotation_draft_test.go b/internal/api/annotation_draft_test.go index bb2a7000..8cdaff4f 100644 --- a/internal/api/annotation_draft_test.go +++ b/internal/api/annotation_draft_test.go @@ -168,7 +168,10 @@ func TestCombinedAnnotationDraftRejectsAnnotatorWhoDidNotClaimTheItem(t *testing if err := fixture.store.UpsertProjectAnnotationMembership(fixture.ctx, domain.ProjectAnnotationMembershipRecord{ID: "other-draft-membership", OrganizationID: domain.DefaultOrganizationID, ProjectID: fixture.task.ProjectID, UserID: other.ID, AssignmentRole: domain.AnnotationRoleAnnotator}); err != nil { t.Fatal(err) } - if err := fixture.store.UpsertProjectMember(fixture.ctx, domain.ProjectMemberRecord{ID: "other-draft-member", OrganizationID: domain.DefaultOrganizationID, ProjectID: fixture.task.ProjectID, UserID: other.ID, SupplierID: other.SupplierID, Roles: domain.AccountProductionRoles(other)}); err != nil { + if err := fixture.store.UpsertProjectMember(fixture.ctx, domain.ProjectMemberRecord{ + ID: "other-draft-member", OrganizationID: other.OrganizationID, ProjectID: fixture.task.ProjectID, + UserID: other.ID, SupplierID: other.SupplierID, Roles: domain.AccountProductionRoles(other), + }); err != nil { t.Fatal(err) } recorder := fixture.request(http.MethodPut, "/api/plugins/annotation-qa/tasks/"+fixture.task.ID+"/drafts", other, map[string]any{ diff --git a/internal/api/annotation_labels.go b/internal/api/annotation_labels.go index adb1edbb..53f7a686 100644 --- a/internal/api/annotation_labels.go +++ b/internal/api/annotation_labels.go @@ -290,7 +290,11 @@ func (server *server) handleProjectAnnotationLabelsGet(writer http.ResponseWrite items = append(items, label) } } - renderJSON(writer, http.StatusOK, map[string]any{"projectId": project.ID, "labelIds": ids, "items": items}) + response := map[string]any{"projectId": project.ID, "labelIds": ids, "items": items} + if projectDictionaryKind(request) == "discard_reason" { + response["allowManual"] = selection.OrganizationID == project.OrganizationID && len(ids) == 0 + } + renderJSON(writer, http.StatusOK, response) return } renderJSON(writer, http.StatusOK, selection) diff --git a/internal/api/annotation_metadata_revision.go b/internal/api/annotation_metadata_revision.go index a9519712..d6a7bfc0 100644 --- a/internal/api/annotation_metadata_revision.go +++ b/internal/api/annotation_metadata_revision.go @@ -97,7 +97,7 @@ func (s *server) tryAnnotationMetadataRevision(ctx context.Context, task domain. segments[i].Start, segments[i].End = grid.Seconds[a], grid.Seconds[b] segments[i].StartTimestampUS, segments[i].EndTimestampUS = grid.Timestamps[a], grid.Timestamps[b] } - if issues := validateDescriptionIntervals(slices, segments, task.TemplateVersion < 6); len(issues) > 0 { + if issues := validateDescriptionIntervals(slices, segments, (!payload.sliceOnly && s.continuousActionsForItem(ctx, &item)) || task.TemplateVersion < 6); len(issues) > 0 { return nil, fmt.Errorf("%s", issues[0].Message) } stage, e := os.MkdirTemp("", "annotation-metadata-") diff --git a/internal/api/annotation_operations.go b/internal/api/annotation_operations.go index e6f11ba1..fa5a7ea8 100644 --- a/internal/api/annotation_operations.go +++ b/internal/api/annotation_operations.go @@ -629,6 +629,7 @@ func (server *server) handleAnnotationTaskGet(writer http.ResponseWriter, reques renderJSON(writer, http.StatusForbidden, map[string]string{"error": "current human stage role is required"}) return } + item.ContinuousActions = server.continuousActionsForItem(request.Context(), linkedHumanItem) // Polling must not load histories, enrich media, recover state, or rebuild // timelines. A transition/interrupted job asks the client to fetch detail once. if request.URL.Query().Get("view") == "summary" { @@ -1054,6 +1055,8 @@ type sliceRevisionInput struct { // Slice correction and semantic labels are persisted together only after both // validate, so a quality reviewer never receives one without the other. type combinedAnnotationSubmissionInput struct { + // Set only by the internal cut job; never accepted from JSON. + sliceOnly bool Version int `json:"version"` SliceSegments []domain.SliceSegment `json:"sliceSegments"` SliceOperations []domain.SliceOperation `json:"sliceOperations,omitempty"` @@ -1459,6 +1462,12 @@ func (server *server) handleCombinedAnnotationDraftPut(writer http.ResponseWrite return } payload.SliceSegments = canonical + if server.continuousActionsForItem(request.Context(), humanItem) { + payload.Segments = fillPendingActionGaps(payload.SliceSegments, payload.Segments) + payload.Statuses = continuousSliceStatuses(payload.SliceSegments, payload.Segments) + issues = append(issues, validateContinuousActions(payload.SliceSegments, payload.Segments, false)...) + issues = append(issues, server.continuousActionFrameIssues(request.Context(), *task, humanItem, payload.Segments)...) + } issues = append(issues, validateDraftCombinedAnnotationEvents(payload.Segments, *task)...) issues = append(issues, validateDraftStatuses(payload.Statuses, payload.SliceSegments)...) template, templateErr := server.store.GetAnnotationTemplate(request.Context(), task.TemplateID) @@ -1592,6 +1601,11 @@ func (server *server) handleAnnotationConfirmationCreate(writer http.ResponseWri } } issues := validateSliceSegments(slices, *task) + if server.continuousActionsForItem(request.Context(), item) { + payload.Segments = fillPendingActionGaps(slices, payload.Segments) + payload.Statuses = continuousSliceStatuses(slices, payload.Segments) + issues = append(issues, validateContinuousActions(slices, payload.Segments, false)...) + } issues = append(issues, validateCompleteSliceCoverage(slices, *task)...) issues = append(issues, validateDraftCombinedAnnotationEvents(payload.Segments, *task)...) template, templateErr := server.store.GetAnnotationTemplate(request.Context(), task.TemplateID) @@ -1660,7 +1674,7 @@ func (server *server) finishSliceConfirmation(ctx context.Context, taskID string Revision: revision, Segments: slices, Operations: payload.SliceOperations, AuthorUserID: actorUserID, ChangeReason: strings.TrimSpace(payload.ChangeReason), CreatedAt: nowISO(), } - materialization, processErr := server.materializeCombinedSliceSubmission(ctx, *task, *item, combinedAnnotationSubmissionInput{SliceSegments: slices, Segments: []domain.AnnotationSegment{}}, revision) + materialization, processErr := server.materializeCombinedSliceSubmission(ctx, *task, *item, combinedAnnotationSubmissionInput{sliceOnly: true, SliceSegments: slices, Segments: []domain.AnnotationSegment{}}, revision) close(done) <-heartbeatStopped if _, durable := ctx.Value(annotationJobLeaseKey{}).(annotationJobLease); durable && (ctx.Err() != nil || server.assertAnnotationLease(ctx) != nil) { @@ -1987,6 +2001,21 @@ func (server *server) handleCombinedAnnotationSubmission(writer http.ResponseWri return } } + if server.continuousActionsForItem(request.Context(), humanItem) { + for i := range payload.Segments { + if payload.Segments[i].IsInvalid && strings.TrimSpace(payload.Segments[i].Description) == "" { + payload.Segments[i].Description = "无效片段" + } + } + if issues := server.continuousActionFrameIssues(request.Context(), *task, humanItem, payload.Segments); len(issues) > 0 { + renderValidationError(writer, issues...) + return + } + if issues := validateContinuousActions(payload.SliceSegments, payload.Segments, true); len(issues) > 0 { + renderValidationError(writer, issues...) + return + } + } if issues := validateCombinedAnnotationEvents(payload.Segments, *task); len(issues) > 0 && !allSlicesDiscarded(payload.SliceSegments, payload.Segments) { renderValidationError(writer, issues...) return diff --git a/internal/api/annotation_random_claim.go b/internal/api/annotation_random_claim.go index f6708b87..2d2ff95d 100644 --- a/internal/api/annotation_random_claim.go +++ b/internal/api/annotation_random_claim.go @@ -158,8 +158,9 @@ func (s *server) handleAnnotationRandomClaim(w http.ResponseWriter, r *http.Requ return } var body struct { - ProjectID string `json:"projectId"` - RequestID string `json:"requestId"` + ProjectID string `json:"projectId"` + RequestID string `json:"requestId"` + BufferOnly bool `json:"bufferOnly,omitempty"` } if !decodeJSON(w, r, &body) { return @@ -258,6 +259,9 @@ func (s *server) handleAnnotationRandomClaim(w http.ResponseWriter, r *http.Requ if batch == nil || batch.OrganizationID != project.OrganizationID || batch.ProjectID != project.ID || batch.Status == domain.HumanBatchCompleted || !annotationClaimStage(batch, candidate.CurrentStageID) { continue } + if body.BufferOnly && (batch.WorkflowID != candidate.WorkflowID || batch.ProcessingProfile != domain.ProcessingProfileRawHuman || !domain.IsFanyuV58ThreeRoleHumanLoop(batch.Stages)) { + continue + } item, e := s.store.GetHumanItem(ctx, candidate.ID) if e != nil { renderError(w, 500, e) @@ -278,7 +282,7 @@ func (s *server) handleAnnotationRandomClaim(w http.ResponseWriter, r *http.Requ if item.ReviewRound > 0 && item.CurrentStageID == domain.FanyuV58StageAnnotationCombined { status = domain.AnnotationTaskStatusRework } - commit := store.HumanClaimCommit{Receipt: store.HumanClaimReceipt{ID: key, ItemID: item.ID, UserID: p.User.ID, ProjectID: project.ID, OrganizationID: project.OrganizationID}, Item: *item, ExpectedVersion: previous, BindSupplier: bind, TaskStatus: status, + commit := store.HumanClaimCommit{EnforceBuffer: batch.WorkflowID == item.WorkflowID && batch.ProcessingProfile == domain.ProcessingProfileRawHuman && domain.IsFanyuV58ThreeRoleHumanLoop(batch.Stages), Receipt: store.HumanClaimReceipt{ID: key, ItemID: item.ID, UserID: p.User.ID, ProjectID: project.ID, OrganizationID: project.OrganizationID}, Item: *item, ExpectedVersion: previous, BindSupplier: bind, TaskStatus: status, Attempt: domain.HumanStageAttemptRecord{OrganizationID: item.OrganizationID, ItemID: item.ID, StageID: item.CurrentStageID, Round: item.ReviewRound, Status: domain.HumanItemClaimed, AssigneeUserID: p.User.ID}, Event: domain.HumanEventRecord{ID: "human-event-random-" + key, OrganizationID: item.OrganizationID, BatchID: item.BatchID, ItemID: item.ID, StageID: item.CurrentStageID, Round: item.ReviewRound, EventType: "claimed", ActorUserID: p.User.ID, ItemVersion: item.Version, Payload: map[string]any{"mode": "project_random", "supplierId": supplierID}}, } @@ -312,6 +316,10 @@ func (s *server) handleAnnotationRandomClaim(w http.ResponseWriter, r *http.Requ } func renderRandomClaimError(w http.ResponseWriter, err error) { + if errors.Is(err, store.ErrAnnotationBufferFull) { + renderJSON(w, 409, map[string]string{"code": "annotation_buffer_full", "error": "个人任务池已满;请送检完成已有任务或调整容量"}) + return + } if errors.Is(err, store.ErrHumanClaimCandidateTaken) { renderJSON(w, 409, map[string]string{"code": "claim_candidate_taken", "error": "该任务刚被其他人领取或已变化,本次未分配新任务,请再次随机领取"}) return @@ -339,5 +347,9 @@ func (s *server) renderRandomClaimResult(ctx context.Context, w http.ResponseWri renderJSON(w, 409, map[string]string{"error": "任务已经领取,但关联数据已不可用,请联系管理员;不会重新分配另一条任务", "code": "claim_result_unavailable"}) return } + if err := newHumanDisplayResolver(s).enrichItem(ctx, item); err != nil { + renderError(w, http.StatusInternalServerError, err) + return + } renderJSON(w, 200, map[string]any{"item": item, "task": task, "replayed": replayed}) } diff --git a/internal/api/annotation_work_buffer.go b/internal/api/annotation_work_buffer.go new file mode 100644 index 00000000..3cc9623f --- /dev/null +++ b/internal/api/annotation_work_buffer.go @@ -0,0 +1,102 @@ +package api + +import ( + "droboticflow/internal/domain" + "net/http" + "strings" +) + +func (s *server) handleAnnotationWorkBuffer(w http.ResponseWriter, r *http.Request) { + p, _ := currentPrincipal(r) + if !randomClaimAnnotator(p) { + renderJSON(w, 403, map[string]string{"error": "仅标注员使用个人任务池"}) + return + } + projectID := strings.TrimSpace(r.URL.Query().Get("projectId")) + project, err := s.store.GetProject(r.Context(), projectID) + if err != nil { + renderError(w, 500, err) + return + } + if project == nil || project.OrganizationID != p.User.OrganizationID || project.DeletionTaskID != "" || strings.EqualFold(string(project.Status), "archived") { + renderJSON(w, 403, map[string]string{"error": "项目不可用"}) + return + } + members, err := s.annotationMembershipsForUser(r.Context(), p.User.OrganizationID, projectID, p.User.ID) + if err != nil { + renderError(w, 500, err) + return + } + allowed := false + for _, m := range members { + if m.Role == domain.AnnotationRoleAnnotator && m.SupplierID != "" { + supplier, e := s.store.GetSupplier(r.Context(), m.SupplierID) + if e != nil { + renderError(w, 500, e) + return + } + if supplier != nil && supplier.OrganizationID == p.User.OrganizationID && strings.EqualFold(supplier.Status, "active") { + allowed = true + } + } + } + if !allowed { + renderJSON(w, 403, map[string]string{"error": "没有该项目的有效标注权限"}) + return + } + // Scope comes from runner-created batches, including empty active batches; + // merely using annotation-qa or a template version never enables buffering. + batches, err := s.store.ListHumanBatches(r.Context(), p.User.OrganizationID, domain.HumanBatchQuery{ProjectID: projectID, PluginID: "annotation-qa"}) + if err != nil { + renderError(w, 500, err) + return + } + enabled := false + for _, batch := range batches { + if batch.OrganizationID == p.User.OrganizationID && batch.ProjectID == projectID && batch.ProcessingProfile == domain.ProcessingProfileRawHuman && domain.IsFanyuV58ThreeRoleHumanLoop(batch.Stages) && batch.Status != domain.HumanBatchCompleted { + enabled = true + break + } + } + if !enabled { + if r.Method == http.MethodPut { + renderJSON(w, 409, map[string]string{"code": "annotation_buffer_not_supported", "error": "该项目流程不使用个人任务缓冲"}) + return + } + renderJSON(w, 200, map[string]any{"enabled": false, "capacity": 2, "occupied": 0, "items": []domain.HumanItemRecord{}, "processing": map[string]any{}}) + return + } + capacity := 0 + if r.Method == http.MethodPut { + var body struct { + Capacity int `json:"capacity"` + } + if !decodeJSON(w, r, &body) { + return + } + capacity = body.Capacity + if capacity < 2 || capacity > 8 { + renderValidationError(w, validationIssue{Field: "capacity", Message: "容量必须是2至8的整数"}) + return + } + } + buffer, err := s.store.AnnotationWorkBuffer(r.Context(), p.User.OrganizationID, p.User.ID, projectID, capacity) + if err != nil { + renderError(w, 500, err) + return + } + resolver := newHumanDisplayResolver(s) + for index := range buffer.Items { + if err := resolver.enrichItem(r.Context(), &buffer.Items[index]); err != nil { + renderError(w, http.StatusInternalServerError, err) + return + } + } + processing := map[string]any{} + for _, item := range buffer.Items { + if job := item.ProcessingJob; job != nil { + processing[item.ID] = map[string]string{"status": job.Status, "kind": job.Kind, "error": job.Error} + } + } + renderJSON(w, 200, map[string]any{"enabled": true, "capacity": buffer.Capacity, "occupied": buffer.Occupied, "items": buffer.Items, "processing": processing}) +} diff --git a/internal/api/annotation_work_buffer_display_test.go b/internal/api/annotation_work_buffer_display_test.go new file mode 100644 index 00000000..3e86d19b --- /dev/null +++ b/internal/api/annotation_work_buffer_display_test.go @@ -0,0 +1,73 @@ +package api + +import ( + "encoding/json" + "net/http" + "testing" + + "droboticflow/internal/domain" +) + +func TestAnnotationBufferAndClaimExposeCaptureNameBeforeTaskIsOpened(t *testing.T) { + f := randomClaimFixture(t, 1) + batch, _ := f.store.GetHumanBatch(f.ctx, f.item.BatchID) + batch.ProcessingProfile = domain.ProcessingProfileRawHuman + if err := f.store.UpsertHumanBatch(f.ctx, *batch); err != nil { + t.Fatal(err) + } + const name = "FYLX_S15_AZEC86400BP_19700103_161946/part0011" + capture := domain.CaptureRecord{ID: "display-capture", OrganizationID: f.item.OrganizationID, ProjectID: f.task.ProjectID, CaptureID: name} + if err := f.store.UpsertCaptureRecord(f.ctx, capture); err != nil { + t.Fatal(err) + } + run := domain.RunRecord{ID: "display-run", OrganizationID: f.item.OrganizationID, ProjectID: f.task.ProjectID, TaskID: capture.ID} + if err := f.store.UpsertRun(f.ctx, run); err != nil { + t.Fatal(err) + } + for _, id := range []string{f.item.ID, "random-item-0"} { + item, _ := f.store.GetHumanItem(f.ctx, id) + item.RunID = run.ID + item.Subject.ItemKey = "run-opaque-artifact-source-left.mp4" + if err := f.store.UpsertHumanItem(f.ctx, *item); err != nil { + t.Fatal(err) + } + } + check := func(item domain.HumanItemRecord) { + t.Helper() + if item.Display == nil || len(item.Display.CaptureDirectories) != 1 || item.Display.CaptureDirectories[0] != name { + t.Errorf("capture name missing before detail hydration: item=%s display=%+v", item.ID, item.Display) + } + } + r := f.request(http.MethodGet, "/api/plugins/annotation-qa/work-buffer?projectId="+f.task.ProjectID, f.annotator, nil) + var buffer struct { + Items []domain.HumanItemRecord `json:"items"` + } + if err := json.Unmarshal(r.Body.Bytes(), &buffer); err != nil { + t.Fatal(err) + } + if r.Code != 200 || len(buffer.Items) != 1 { + t.Fatalf("buffer %d %s", r.Code, r.Body.String()) + } + check(buffer.Items[0]) + r = f.request(http.MethodPost, "/api/plugins/annotation-qa/random-claims", f.annotator, map[string]any{"projectId": f.task.ProjectID, "requestId": "capture-name-before-detail"}) + var claim struct { + Item domain.HumanItemRecord `json:"item"` + } + if err := json.Unmarshal(r.Body.Bytes(), &claim); err != nil { + t.Fatal(err) + } + if r.Code != 200 { + t.Fatalf("claim %d %s", r.Code, r.Body.String()) + } + check(claim.Item) + r = f.request(http.MethodGet, "/api/plugins/annotation-qa/work-buffer?projectId="+f.task.ProjectID, f.annotator, nil) + if err := json.Unmarshal(r.Body.Bytes(), &buffer); err != nil { + t.Fatal(err) + } + if r.Code != 200 || len(buffer.Items) != 2 { + t.Fatalf("refreshed buffer %d %s", r.Code, r.Body.String()) + } + for _, item := range buffer.Items { + check(item) + } +} diff --git a/internal/api/annotation_work_buffer_lifecycle_test.go b/internal/api/annotation_work_buffer_lifecycle_test.go new file mode 100644 index 00000000..62e2af5a --- /dev/null +++ b/internal/api/annotation_work_buffer_lifecycle_test.go @@ -0,0 +1,161 @@ +package api + +import ( + "encoding/json" + "fmt" + "net/http" + "testing" + + "droboticflow/internal/domain" +) + +// Fixtures set server lifecycle states; assertions use only the public buffer +// and claim routes. This complements actual company processor handoff tests. +func TestAnnotationBufferProcessingAndFailureKeepCapacityUntilHandoff(t *testing.T) { + f := randomClaimFixture(t, 2) + batch, _ := f.store.GetHumanBatch(f.ctx, f.item.BatchID) + batch.ProcessingProfile = domain.ProcessingProfileRawHuman + if err := f.store.UpsertHumanBatch(f.ctx, *batch); err != nil { + t.Fatal(err) + } + claimed := claimRandom(t, f, "lifecycle-reserved-task") + path := "/api/plugins/annotation-qa/work-buffer?projectId=" + f.task.ProjectID + for _, kind := range []string{"slice", "submit"} { + for _, status := range []string{"queued", "running", "failed", "completed"} { + claimed.ProcessingJob = &domain.AnnotationProcessingJob{ID: "lifecycle-job", Kind: kind, Status: status, Error: "fixture failure"} + if err := f.store.UpsertHumanItem(f.ctx, claimed); err != nil { + t.Fatal(err) + } + r := f.request(http.MethodGet, path, f.annotator, nil) + var result struct { + Occupied int `json:"occupied"` + Processing map[string]struct { + Status string `json:"status"` + Kind string `json:"kind"` + } `json:"processing"` + } + if err := json.Unmarshal(r.Body.Bytes(), &result); err != nil { + t.Fatal(err) + } + if r.Code != 200 || result.Occupied != 2 || result.Processing[claimed.ID].Status != status || result.Processing[claimed.ID].Kind != kind { + t.Fatalf("%s/%s: %d %s", kind, status, r.Code, r.Body.String()) + } + r = f.request(http.MethodPost, "/api/plugins/annotation-qa/random-claims", f.annotator, map[string]any{"projectId": f.task.ProjectID, "requestId": fmt.Sprintf("blocked-%s-%s", kind, status)}) + if r.Code != 409 { + t.Fatalf("processing freed capacity: %d %s", r.Code, r.Body.String()) + } + } + } + claimed.CurrentStageID = "quality_review" + claimed.Status = domain.HumanItemSubmitted + claimed.Version++ + if err := f.store.UpsertHumanItem(f.ctx, claimed); err != nil { + t.Fatal(err) + } + next := claimRandom(t, f, "lifecycle-refill-after-handoff") + if next.ID == claimed.ID || next.ID == "" { + t.Fatal("handoff did not admit another task") + } +} + +func TestAnnotationBufferEmptyPoolAndAccountIsolation(t *testing.T) { + f := randomClaimFixture(t, 0) + batch, _ := f.store.GetHumanBatch(f.ctx, f.item.BatchID) + batch.ProcessingProfile = domain.ProcessingProfileRawHuman + if err := f.store.UpsertHumanBatch(f.ctx, *batch); err != nil { + t.Fatal(err) + } + other := f.annotator + other.ID = "buffer-other-account" + if err := f.store.UpsertUser(f.ctx, other); err != nil { + t.Fatal(err) + } + if err := f.store.UpsertProjectMember(f.ctx, domain.ProjectMemberRecord{ID: "buffer-other-member", OrganizationID: other.OrganizationID, ProjectID: f.task.ProjectID, UserID: other.ID, SupplierID: "random-supplier", Roles: []domain.AnnotationAssignmentRole{domain.AnnotationRoleAnnotator}}); err != nil { + t.Fatal(err) + } + path := "/api/plugins/annotation-qa/work-buffer?projectId=" + f.task.ProjectID + if r := f.request(http.MethodPut, path, f.annotator, map[string]any{"capacity": 8}); r.Code != 200 { + t.Fatal(r.Body.String()) + } + for _, user := range []domain.UserRecord{f.annotator, other} { + for i := 0; i < 3; i++ { + r := f.request(http.MethodPost, "/api/plugins/annotation-qa/random-claims", user, map[string]any{"projectId": f.task.ProjectID, "requestId": fmt.Sprintf("empty-%s-%d", user.ID, i), "bufferOnly": true}) + var claim struct { + Item *domain.HumanItemRecord `json:"item"` + } + if err := json.Unmarshal(r.Body.Bytes(), &claim); err != nil { + t.Fatal(err) + } + if r.Code != 200 || claim.Item != nil { + t.Fatalf("empty pool: %d %s", r.Code, r.Body.String()) + } + } + r := f.request(http.MethodGet, path, user, nil) + var result struct { + Capacity int `json:"capacity"` + Occupied int `json:"occupied"` + } + if err := json.Unmarshal(r.Body.Bytes(), &result); err != nil { + t.Fatal(err) + } + wantCap, wantCount := 2, 0 + if user.ID == f.annotator.ID { + wantCap, wantCount = 8, 1 + } + if r.Code != 200 || result.Capacity != wantCap || result.Occupied != wantCount { + t.Fatalf("account isolation: %d %s", r.Code, r.Body.String()) + } + } + + // A second trusted empty project has its own default, despite this user's + // capacity 8 in the original project; neither occupancy nor settings leak. + project, err := f.store.GetProject(f.ctx, f.task.ProjectID) + if err != nil || project == nil { + t.Fatal("missing fixture project") + } + project.ID = "buffer-isolated-project" + if err := f.store.UpsertProject(f.ctx, *project); err != nil { + t.Fatal(err) + } + secondBatch := *batch + secondBatch.ID = "buffer-isolated-batch" + secondBatch.ProjectID = project.ID + if err := f.store.UpsertHumanBatch(f.ctx, secondBatch); err != nil { + t.Fatal(err) + } + if err := f.store.UpsertProjectMember(f.ctx, domain.ProjectMemberRecord{ID: "buffer-isolated-project-member", OrganizationID: f.annotator.OrganizationID, ProjectID: project.ID, UserID: f.annotator.ID, SupplierID: "random-supplier", Roles: []domain.AnnotationAssignmentRole{domain.AnnotationRoleAnnotator}}); err != nil { + t.Fatal(err) + } + otherPath := "/api/plugins/annotation-qa/work-buffer?projectId=" + project.ID + for _, query := range []struct { + path string + capacity, occupied int + }{{otherPath, 2, 0}, {path, 8, 1}} { + r := f.request(http.MethodGet, query.path, f.annotator, nil) + var result struct { + Capacity int `json:"capacity"` + Occupied int `json:"occupied"` + } + if err := json.Unmarshal(r.Body.Bytes(), &result); err != nil { + t.Fatal(err) + } + if r.Code != 200 || result.Capacity != query.capacity || result.Occupied != query.occupied { + t.Fatalf("project isolation: %d %s", r.Code, r.Body.String()) + } + } + supplier, _ := f.store.GetSupplier(f.ctx, "random-supplier") + supplier.Status = "disabled" + if err := f.store.UpsertSupplier(f.ctx, *supplier); err != nil { + t.Fatal(err) + } + for _, method := range []string{http.MethodGet, http.MethodPut} { + r := f.request(method, path, f.annotator, map[string]any{"capacity": 2}) + if r.Code != 403 { + t.Fatalf("revoked permission %s: %d %s", method, r.Code, r.Body.String()) + } + } + r := f.request(http.MethodPost, "/api/plugins/annotation-qa/random-claims", f.annotator, map[string]any{"projectId": f.task.ProjectID, "requestId": "revoked-after-settings"}) + if r.Code != 403 { + t.Fatalf("revoked claim %d %s", r.Code, r.Body.String()) + } +} diff --git a/internal/api/annotation_work_buffer_mongo_http_test.go b/internal/api/annotation_work_buffer_mongo_http_test.go new file mode 100644 index 00000000..2468f63e --- /dev/null +++ b/internal/api/annotation_work_buffer_mongo_http_test.go @@ -0,0 +1,171 @@ +package api + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "net/http" + "net/http/httptest" + "os" + "sync" + "testing" + "time" + + "droboticflow/internal/domain" + "droboticflow/internal/store" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" +) + +// Opt-in, isolated database on the local Mongo replica. All assertions cross +// public HTTP routes; neither receipt documents nor slot ledgers are inspected. +func TestAnnotationBufferMongoHTTPConcurrencyAndReceipt(t *testing.T) { + if os.Getenv("ANNOTATION_BUFFER_MONGO_HTTP") != "1" { + t.Skip("opt-in local Mongo HTTP verification") + } + ctx, cancel := context.WithTimeout(context.Background(), 90*time.Second) + defer cancel() + client, err := mongo.Connect(ctx, options.Client().ApplyURI("mongodb://127.0.0.1:27018/?directConnection=true")) + if err != nil { + t.Fatal(err) + } + defer client.Disconnect(context.Background()) + db := client.Database(fmt.Sprintf("annotation_buffer_http_test_%d", time.Now().UnixNano())) + defer func() { + cleanup, done := context.WithTimeout(context.Background(), 10*time.Second) + defer done() + if err := db.Drop(cleanup); err != nil { + t.Error(err) + } + }() + ds := store.NewMongoStore(db) + for _, name := range []string{"projects", "users", "suppliers", "projectMembers", "annotationTasks", "humanBatches", "humanItems", "humanEvents", "humanStageAttempts", "humanClaimRequests"} { + if _, err := db.Collection(name).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{{Key: "id", Value: 1}}, Options: options.Index().SetUnique(true)}); err != nil { + t.Fatal(err) + } + } + must := func(err error) { + t.Helper() + if err != nil { + t.Fatal(err) + } + } + org := "buffer-http-org" + user := domain.UserRecord{ID: "buffer-http-user", OrganizationID: org, SupplierID: "buffer-http-supplier", Role: domain.UserRoleAnnotator, Status: domain.UserStatusActive} + must(ds.UpsertUser(ctx, user)) + must(ds.UpsertSupplier(ctx, domain.SupplierRecord{ID: "buffer-http-supplier", OrganizationID: org, Status: "active"})) + // Separate handlers/stores model requests routed to different API replicas. + handlers := []http.Handler{NewHandler(ds, nil), NewHandler(store.NewMongoStore(db), nil)} + call := func(handler int, method, path string, body any) *httptest.ResponseRecorder { + data, _ := json.Marshal(body) + req := httptest.NewRequest(method, path, bytes.NewReader(data)) + req.Header.Set("Content-Type", "application/json") + req.AddCookie(&http.Cookie{Name: csrfCookieName, Value: "buffer-http-csrf"}) + req.Header.Set(csrfHeaderName, "buffer-http-csrf") + req = req.WithContext(context.WithValue(ctx, authContextKey{}, &authenticatedPrincipal{User: user, Organization: domain.OrganizationRecord{ID: org, Status: domain.OrganizationStatusActive}})) + rec := httptest.NewRecorder() + handlers[handler%2].ServeHTTP(rec, req) + return rec + } + for round := 0; round < 5; round++ { + project := fmt.Sprintf("buffer-http-project-%d", round) + must(ds.UpsertProject(ctx, domain.ProjectRecord{ID: project, OrganizationID: org})) + must(ds.UpsertProjectMember(ctx, domain.ProjectMemberRecord{ID: "member-" + project, OrganizationID: org, ProjectID: project, UserID: user.ID, SupplierID: "buffer-http-supplier", Roles: []domain.AnnotationAssignmentRole{domain.AnnotationRoleAnnotator}})) + batch := domain.HumanBatchRecord{ID: "batch-" + project, OrganizationID: org, ProjectID: project, WorkflowID: "workflow-" + project, RunID: "run-" + project, GateNodeID: "gate", PluginID: "annotation-qa", SupplierID: "buffer-http-supplier", Status: domain.HumanBatchActive, ProcessingProfile: domain.ProcessingProfileRawHuman, Stages: domain.DefaultFanyuV58HumanStages()} + must(ds.UpsertHumanBatch(ctx, batch)) + for n := 0; n < 16; n++ { + task := domain.AnnotationTaskRecord{ID: fmt.Sprintf("task-%s-%d", project, n), OrganizationID: org, ProjectID: project, WorkflowID: batch.WorkflowID, SupplierID: batch.SupplierID, Status: domain.AnnotationTaskStatusPendingAnnotation, TemplateVersion: 6} + must(ds.UpsertAnnotationTask(ctx, task)) + must(ds.UpsertHumanItem(ctx, domain.HumanItemRecord{ID: "item-" + task.ID, OrganizationID: org, ProjectID: project, WorkflowID: batch.WorkflowID, PluginID: "annotation-qa", BatchID: batch.ID, LegacyTaskID: task.ID, SupplierID: batch.SupplierID, Subject: domain.HumanSubjectRef{ItemKey: task.ID}, CurrentStageID: domain.FanyuV58StageAnnotationCombined, Status: domain.HumanItemReady, Version: 1})) + } + bufferPath := "/api/plugins/annotation-qa/work-buffer?projectId=" + project + var wg sync.WaitGroup + type claim struct{ requestID, id string } + successes := make(chan claim, 16) + for n := 0; n < 16; n++ { + wg.Add(1) + go func(n int) { + defer wg.Done() + requestID := fmt.Sprintf("mongo-buffer-%02d-request-%02d", round, n) + // Concurrent buffer polling exercises reconciliation while ownership writes finish. + _ = call(n, "GET", bufferPath, nil) + r := call(n, "POST", "/api/plugins/annotation-qa/random-claims", map[string]any{"projectId": project, "requestId": requestID}) + if r.Code == 200 { + var out struct { + Item domain.HumanItemRecord `json:"item"` + } + if err := json.Unmarshal(r.Body.Bytes(), &out); err != nil { + t.Error(err) + } + successes <- claim{requestID, out.Item.ID} + } else if r.Code != 409 { + t.Errorf("claim: %d %s", r.Code, r.Body.String()) + } + }(n) + } + wg.Wait() + close(successes) + claims := []claim{} + for result := range successes { + claims = append(claims, result) + } + if len(claims) != 2 { + t.Fatalf("round %d: capacity 2 assigned %d", round, len(claims)) + } + r := call(0, "GET", bufferPath, nil) + var buffer struct { + Capacity int `json:"capacity"` + Occupied int `json:"occupied"` + Items []domain.HumanItemRecord `json:"items"` + } + must(json.Unmarshal(r.Body.Bytes(), &buffer)) + if r.Code != 200 || buffer.Capacity != 2 || buffer.Occupied != 2 || len(buffer.Items) != 2 { + t.Fatalf("round %d buffer: %d %s", round, r.Code, r.Body.String()) + } + for _, result := range claims { + r = call(1, "POST", "/api/plugins/annotation-qa/random-claims", map[string]any{"projectId": project, "requestId": result.requestID}) + var replay struct { + Item domain.HumanItemRecord `json:"item"` + Replayed bool `json:"replayed"` + } + must(json.Unmarshal(r.Body.Bytes(), &replay)) + if r.Code != 200 || !replay.Replayed || replay.Item.ID != result.id { + t.Fatalf("full buffer receipt replay: %d %s", r.Code, r.Body.String()) + } + } + // Fixture fault: ownership succeeded and work reached review, but the + // durable receipt finalization was interrupted. A full current buffer + // must not prevent recovering that original request on another replica. + original := claims[0] + item, err := ds.GetHumanItem(ctx, original.id) + must(err) + item.CurrentStageID = "quality_review" + item.Status = domain.HumanItemSubmitted + item.LatestAuthorUserID = user.ID + item.Version++ + must(ds.UpsertHumanItem(ctx, *item)) + _, err = db.Collection("humanClaimRequests").UpdateOne(ctx, bson.M{"itemId": original.id}, bson.M{"$set": bson.M{"state": "pending"}}) + must(err) + r = call(0, "POST", "/api/plugins/annotation-qa/random-claims", map[string]any{"projectId": project, "requestId": fmt.Sprintf("mongo-buffer-%02d-refill-after-review", round)}) + if r.Code != 200 { + t.Fatalf("refill after handoff: %d %s", r.Code, r.Body.String()) + } + r = call(1, "POST", "/api/plugins/annotation-qa/random-claims", map[string]any{"projectId": project, "requestId": original.requestID}) + var recovered struct { + Item domain.HumanItemRecord `json:"item"` + Replayed bool `json:"replayed"` + } + must(json.Unmarshal(r.Body.Bytes(), &recovered)) + if r.Code != 200 || !recovered.Replayed || recovered.Item.ID != original.id || recovered.Item.CurrentStageID != "quality_review" { + t.Fatalf("interrupted receipt recovery after handoff: %d %s", r.Code, r.Body.String()) + } + r = call(0, "GET", bufferPath, nil) + must(json.Unmarshal(r.Body.Bytes(), &buffer)) + if r.Code != 200 || buffer.Occupied != 2 || len(buffer.Items) != 2 { + t.Fatalf("receipt replay consumed capacity: %d %s", r.Code, r.Body.String()) + } + + } +} diff --git a/internal/api/annotation_work_buffer_test.go b/internal/api/annotation_work_buffer_test.go new file mode 100644 index 00000000..e8aeeb0c --- /dev/null +++ b/internal/api/annotation_work_buffer_test.go @@ -0,0 +1,189 @@ +package api + +import ( + "droboticflow/internal/domain" + "encoding/json" + "fmt" + "net/http" + "sync" + "testing" +) + +func TestAnnotationBufferCapacityAndReplay(t *testing.T) { + f := randomClaimFixture(t, 12) + batch, _ := f.store.GetHumanBatch(f.ctx, f.item.BatchID) + batch.ProcessingProfile = domain.ProcessingProfileRawHuman + if e := f.store.UpsertHumanBatch(f.ctx, *batch); e != nil { + t.Fatal(e) + } + path := "/api/plugins/annotation-qa/work-buffer?projectId=" + f.task.ProjectID + r := f.request(http.MethodGet, path, f.annotator, nil) + if r.Code != 200 { + t.Fatalf("read buffer: %d %s", r.Code, r.Body.String()) + } + var initial struct { + Capacity int `json:"capacity"` + Occupied int `json:"occupied"` + } + json.Unmarshal(r.Body.Bytes(), &initial) + if initial.Capacity != 2 || initial.Occupied != 1 { + t.Fatalf("unexpected initial buffer %+v", initial) + } + first := claimRandom(t, f, "buffer-first-request-01") + var wg sync.WaitGroup + for i := 0; i < 8; i++ { + wg.Add(1) + go func(i int) { + defer wg.Done() + r := f.request("POST", "/api/plugins/annotation-qa/random-claims", f.annotator, map[string]any{"projectId": f.task.ProjectID, "requestId": fmt.Sprintf("buffer-concurrent-%02d", i)}) + if r.Code != 409 { + t.Errorf("full buffer allowed claim: %d %s", r.Code, r.Body.String()) + } + }(i) + } + wg.Wait() + if replay := claimRandom(t, f, "buffer-first-request-01"); replay.ID != first.ID { + t.Fatal("full buffer lost receipt") + } + r = f.request(http.MethodPut, path, f.annotator, map[string]any{"capacity": 3}) + if r.Code != 200 { + t.Fatalf("change capacity: %d %s", r.Code, r.Body.String()) + } + claimRandom(t, f, "buffer-second-request-01") + for _, v := range []any{1, 9, 2.5} { + r = f.request(http.MethodPut, path, f.annotator, map[string]any{"capacity": v}) + if r.Code < 400 { + t.Fatalf("accepted invalid capacity %v", v) + } + } + r = f.request(http.MethodPut, path, f.annotator, map[string]any{"capacity": 2}) + if r.Code != 200 { + t.Fatal(r.Body.String()) + } + json.Unmarshal(r.Body.Bytes(), &initial) + if initial.Capacity != 2 || initial.Occupied != 3 { + t.Fatalf("lowering released work %+v", initial) + } +} + +func TestAnnotationBufferConcurrentClaimsUseSharedCapacity(t *testing.T) { + f := randomClaimFixture(t, 20) + batch, _ := f.store.GetHumanBatch(f.ctx, f.item.BatchID) + batch.ProcessingProfile = domain.ProcessingProfileRawHuman + if err := f.store.UpsertHumanBatch(f.ctx, *batch); err != nil { + t.Fatal(err) + } + path := "/api/plugins/annotation-qa/work-buffer?projectId=" + f.task.ProjectID + if r := f.request("PUT", path, f.annotator, map[string]any{"capacity": 8}); r.Code != 200 { + t.Fatal(r.Body.String()) + } + var wg sync.WaitGroup + successes := make(chan string, 20) + for i := 0; i < 20; i++ { + wg.Add(1) + go func(i int) { + defer wg.Done() + r := f.request("POST", "/api/plugins/annotation-qa/random-claims", f.annotator, map[string]any{"projectId": f.task.ProjectID, "requestId": fmt.Sprintf("capacity-race-request-%02d", i)}) + if r.Code == 200 { + var response struct { + Item domain.HumanItemRecord `json:"item"` + } + json.Unmarshal(r.Body.Bytes(), &response) + successes <- response.Item.ID + } else if r.Code != 409 { + t.Errorf("unexpected claim result %d %s", r.Code, r.Body.String()) + } + }(i) + } + wg.Wait() + close(successes) + seen := map[string]bool{} + for id := range successes { + if id == "" || seen[id] { + t.Fatalf("duplicate/missing assignment %q", id) + } + seen[id] = true + } + if len(seen) != 7 { + t.Fatalf("expected seven free slots, got %d", len(seen)) + } + r := f.request("GET", path, f.annotator, nil) + var buffer struct { + Occupied int `json:"occupied"` + Items []domain.HumanItemRecord `json:"items"` + } + json.Unmarshal(r.Body.Bytes(), &buffer) + if r.Code != 200 || buffer.Occupied != 8 || len(buffer.Items) != 8 { + t.Fatalf("authoritative buffer %d %s", r.Code, r.Body.String()) + } +} + +func TestAnnotationBufferLeavesOtherWorkflowsUnchanged(t *testing.T) { + f := randomClaimFixture(t, 4) + path := "/api/plugins/annotation-qa/work-buffer?projectId=" + f.task.ProjectID + r := f.request("GET", path, f.annotator, nil) + var result struct { + Enabled bool `json:"enabled"` + Items []domain.HumanItemRecord `json:"items"` + } + json.Unmarshal(r.Body.Bytes(), &result) + if r.Code != 200 || result.Enabled || len(result.Items) != 0 { + t.Fatalf("other workflow buffer enabled: %d %s", r.Code, r.Body.String()) + } + if r = f.request("PUT", path, f.annotator, map[string]any{"capacity": 8}); r.Code != 409 { + t.Fatalf("unsupported workflow settings changed: %d %s", r.Code, r.Body.String()) + } + for i := 0; i < 3; i++ { + claimRandom(t, f, fmt.Sprintf("legacy-no-capacity-%02d", i)) + } + batch, _ := f.store.GetHumanBatch(f.ctx, f.item.BatchID) + batch.ProcessingProfile = domain.ProcessingProfileRawHuman + if e := f.store.UpsertHumanBatch(f.ctx, *batch); e != nil { + t.Fatal(e) + } + r = f.request("GET", path, f.annotator, nil) + json.Unmarshal(r.Body.Bytes(), &result) + if r.Code != 200 || !result.Enabled || len(result.Items) != 4 { + t.Fatalf("trusted batch scope unavailable: %d %s", r.Code, r.Body.String()) + } +} + +func TestAnnotationBufferDoesNotClaimOtherWorkflowInMixedProject(t *testing.T) { + f := randomClaimFixture(t, 1) + batch, _ := f.store.GetHumanBatch(f.ctx, f.item.BatchID) + batch.ProcessingProfile = domain.ProcessingProfileRawHuman + if e := f.store.UpsertHumanBatch(f.ctx, *batch); e != nil { + t.Fatal(e) + } + legacy := *batch + legacy.ID = "other-workflow-batch" + legacy.ProcessingProfile = "" + if e := f.store.UpsertHumanBatch(f.ctx, legacy); e != nil { + t.Fatal(e) + } + candidate, _ := f.store.GetHumanItem(f.ctx, "random-item-0") + candidate.BatchID = legacy.ID + if e := f.store.UpsertHumanItem(f.ctx, *candidate); e != nil { + t.Fatal(e) + } + r := f.request("POST", "/api/plugins/annotation-qa/random-claims", f.annotator, map[string]any{"projectId": f.task.ProjectID, "requestId": "buffer-filter-scope-01", "bufferOnly": true}) + var claim struct { + Item *domain.HumanItemRecord `json:"item"` + } + json.Unmarshal(r.Body.Bytes(), &claim) + if r.Code != 200 || claim.Item != nil { + t.Fatalf("buffer claimed another workflow: %d %s", r.Code, r.Body.String()) + } + if item := claimRandom(t, f, "manual-other-workflow-01"); item.ID != "random-item-0" { + t.Fatal("legacy manual claim changed") + } + r = f.request("GET", "/api/plugins/annotation-qa/work-buffer?projectId="+f.task.ProjectID, f.annotator, nil) + var buffer struct { + Enabled bool `json:"enabled"` + Occupied int `json:"occupied"` + } + json.Unmarshal(r.Body.Bytes(), &buffer) + if r.Code != 200 || !buffer.Enabled || buffer.Occupied != 1 { + t.Fatalf("legacy task occupies scoped buffer: %d %s", r.Code, r.Body.String()) + } +} diff --git a/internal/api/discard_reason_dictionary.go b/internal/api/discard_reason_dictionary.go index 4411f90e..b5629fda 100644 --- a/internal/api/discard_reason_dictionary.go +++ b/internal/api/discard_reason_dictionary.go @@ -15,6 +15,18 @@ func (s *server) resolveDiscardReason(ctx context.Context, item *domain.HumanIte if err != nil { return issue("舍弃原因字典加载失败,请重试") } + // Only a successfully read, unconfigured project permits a free-text reason. + // A stale/foreign selection or failed lookup must never bypass the dictionary. + if selection == nil || (selection.OrganizationID == item.OrganizationID && len(selection.DiscardReasonLabelIDs) == 0) { + if body.ReasonLabelID != "" || body.ReasonVersion != 0 { + return issue("舍弃原因字典已变化,请刷新后填写原因") + } + reason := strings.TrimSpace(body.Reason) + if reason == "" || len([]rune(reason)) > 1000 { + return nil, []validationIssue{{Field: "reason", Code: "discard_reason_required", Message: "请填写舍弃原因,最多 1000 字"}} + } + return nil, nil + } enabled := false if selection != nil && selection.OrganizationID == item.OrganizationID { for _, id := range selection.DiscardReasonLabelIDs { @@ -25,7 +37,7 @@ func (s *server) resolveDiscardReason(ctx context.Context, item *domain.HumanIte } } if !enabled { - return issue("请从当前项目舍弃原因字典选择原因;没有词条请联系管理员添加") + return issue("请从当前项目舍弃原因字典选择原因") } label, err := s.store.GetAnnotationLabel(ctx, body.ReasonLabelID) if err != nil { diff --git a/internal/api/discard_reason_manual_test.go b/internal/api/discard_reason_manual_test.go new file mode 100644 index 00000000..65bade31 --- /dev/null +++ b/internal/api/discard_reason_manual_test.go @@ -0,0 +1,115 @@ +package api + +import ( + "context" + "droboticflow/internal/domain" + "droboticflow/internal/store" + "encoding/json" + "errors" + "strings" + "testing" +) + +func TestDiscardReasonWithoutProjectDictionaryAcceptsManualReason(t *testing.T) { + f := randomClaimFixture(t, 0) + body := dispositionFixturePayload(t, f) + if err := f.store.UpsertProjectDiscardReasonLabels(f.ctx, domain.ProjectAnnotationLabelsRecord{ProjectID: f.item.ProjectID, OrganizationID: f.item.OrganizationID}); err != nil { + t.Fatal(err) + } + body.ReasonLabelID = "" + body.ReasonVersion = 0 + body.Reason = " 画面持续遮挡,无法辨认动作 " + r := f.request("POST", "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/slice-dispositions", f.annotator, body) + if r.Code != 200 { + t.Fatalf("manual reason rejected: %d %s", r.Code, r.Body.String()) + } + var got struct { + Workspace combinedAnnotationDraftInput `json:"workspace"` + } + if err := json.Unmarshal(r.Body.Bytes(), &got); err != nil { + t.Fatal(err) + } + sl := got.Workspace.SliceSegments[1] + if sl.DiscardReason != "画面持续遮挡,无法辨认动作" || sl.DiscardReasonLabelID != "" || sl.DiscardReasonVersion != 0 || sl.DiscardReasonName != "" { + t.Fatalf("incorrect manual evidence: %+v", sl) + } + r = f.request("GET", "/api/plugins/annotation-qa/tasks/"+f.task.ID, f.annotator, nil) + if r.Code != 200 { + t.Fatal(r.Body.String()) + } + var detail struct { + HumanItem domain.HumanItemRecord `json:"humanItem"` + } + if err := json.Unmarshal(r.Body.Bytes(), &detail); err != nil { + t.Fatal(err) + } + raw, _ := json.Marshal(detail.HumanItem.Subject.Payload["annotationWorkspace"]) + var saved combinedAnnotationDraftInput + if err := json.Unmarshal(raw, &saved); err != nil { + t.Fatal(err) + } + if saved.SliceSegments[1].DiscardReason != sl.DiscardReason { + t.Fatal("manual reason not retained on public readback") + } +} + +type unavailableDiscardDictionaryStore struct{ store.Store } + +func (s unavailableDiscardDictionaryStore) GetProjectAnnotationLabels(context.Context, string) (*domain.ProjectAnnotationLabelsRecord, error) { + return nil, errors.New("dictionary unavailable") +} +func TestDiscardReasonManualEligibilityAndValidation(t *testing.T) { + for _, mode := range []string{"blank", "too_long", "configured", "inactive", "lookup_failure", "empty"} { + t.Run(mode, func(t *testing.T) { + f := randomClaimFixture(t, 0) + body := dispositionFixturePayload(t, f) + if mode != "configured" && mode != "inactive" { + if err := f.store.UpsertProjectDiscardReasonLabels(f.ctx, domain.ProjectAnnotationLabelsRecord{ProjectID: f.item.ProjectID, OrganizationID: f.item.OrganizationID}); err != nil { + t.Fatal(err) + } + } + body.ReasonLabelID = "" + body.ReasonVersion = 0 + body.Reason = "手填原因" + switch mode { + case "blank": + body.Reason = " " + case "too_long": + body.Reason = strings.Repeat("字", 1001) + case "inactive": + label, _ := f.store.GetAnnotationLabel(f.ctx, "discard-fixture") + label.Status = domain.AnnotationLabelInactive + if err := f.store.UpsertAnnotationLabel(f.ctx, *label); err != nil { + t.Fatal(err) + } + case "lookup_failure": + f.handler = NewHandler(unavailableDiscardDictionaryStore{f.store}, nil) + } + r := f.request("GET", "/api/projects/"+f.task.ProjectID+"/discard-reason-labels", f.annotator, nil) + if mode == "lookup_failure" { + if r.Code != 500 { + t.Fatalf("lookup failure not surfaced: %d", r.Code) + } + } else { + var d struct { + AllowManual bool `json:"allowManual"` + } + if err := json.Unmarshal(r.Body.Bytes(), &d); err != nil { + t.Fatal(err) + } + expected := mode != "configured" && mode != "inactive" + if d.AllowManual != expected { + t.Fatalf("manual eligibility %s: %s", mode, r.Body.String()) + } + } + r = f.request("POST", "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/slice-dispositions", f.annotator, body) + if mode == "empty" { + if r.Code != 200 { + t.Fatal(r.Body.String()) + } + } else if r.Code < 400 { + t.Fatalf("accepted invalid %s", mode) + } + }) + } +} diff --git a/internal/api/human_evidence_cache_test.go b/internal/api/human_evidence_cache_test.go index 14b2e95b..aa36b147 100644 --- a/internal/api/human_evidence_cache_test.go +++ b/internal/api/human_evidence_cache_test.go @@ -132,8 +132,11 @@ func TestHumanEvidenceHTTPReusesIndexAndRechecksAccessAndFiles(t *testing.T) { must(ds.UpsertProject(ctx, domain.ProjectRecord{ID: projectID, OrganizationID: domain.DefaultOrganizationID})) manifest := domain.ExecutionArtifact{ID: "evidence", RunID: runID, Name: "review.directory.index", Path: root, Data: map[string]any{"schemaVersion": "droboticflow.directory-index/v1", "rootPath": root, "datasetType": "directory", "presentation": "collection"}} must(ds.UpsertRun(ctx, domain.RunRecord{ID: runID, OrganizationID: domain.DefaultOrganizationID, ProjectID: projectID, Artifacts: []domain.ExecutionArtifact{manifest}})) - user := domain.UserRecord{ID: "reviewer", OrganizationID: domain.DefaultOrganizationID, Role: domain.UserRoleQualityReviewer} + supplierID := domain.DefaultSupplierID(domain.DefaultOrganizationID) + must(ds.UpsertSupplier(ctx, domain.SupplierRecord{ID: supplierID, OrganizationID: domain.DefaultOrganizationID, Name: "Evidence fixture supplier", Status: "active"})) + user := domain.UserRecord{ID: "reviewer", OrganizationID: domain.DefaultOrganizationID, SupplierID: supplierID, Role: domain.UserRoleQualityReviewer, Status: domain.UserStatusActive} must(ds.UpsertUser(ctx, user)) + must(ds.UpsertProjectMember(ctx, domain.ProjectMemberRecord{ID: "evidence-reviewer-member", OrganizationID: domain.DefaultOrganizationID, ProjectID: projectID, UserID: user.ID, SupplierID: supplierID, Roles: []domain.AnnotationAssignmentRole{domain.AnnotationRoleQualityReviewer}})) must(ds.UpsertProjectAnnotationMembership(ctx, domain.ProjectAnnotationMembershipRecord{OrganizationID: domain.DefaultOrganizationID, ProjectID: projectID, UserID: user.ID, WorkgroupID: "wg", AssignmentRole: domain.AnnotationRoleQualityReviewer})) batch := domain.HumanBatchRecord{ID: "batch", OrganizationID: domain.DefaultOrganizationID, PluginID: "annotation-qa", ProjectID: projectID, RunID: runID, Stages: domain.DefaultFanyuV58HumanStages()} must(ds.UpsertHumanBatch(ctx, batch)) diff --git a/internal/api/human_slice_materialization.go b/internal/api/human_slice_materialization.go index ee88727e..85b1ddb6 100644 --- a/internal/api/human_slice_materialization.go +++ b/internal/api/human_slice_materialization.go @@ -502,6 +502,12 @@ func (server *server) materializeCombinedSliceSubmission(ctx context.Context, ta if err := server.assertAnnotationLease(ctx); err != nil { return nil, err } + continuous := !payload.sliceOnly && server.continuousActionsForItem(ctx, &item) + if continuous { + if issues := validateContinuousActions(payload.SliceSegments, payload.Segments, true); len(issues) > 0 { + return nil, fmt.Errorf("%s", issues[0].Message) + } + } started := time.Now() ctx, cancel := context.WithTimeout(ctx, 24*time.Hour) defer cancel() @@ -552,6 +558,11 @@ func (server *server) materializeCombinedSliceSubmission(ctx context.Context, ta if segments == nil { segments = append([]domain.AnnotationSegment(nil), payload.Segments...) } + if continuous { + if issues := validateContinuousActions(slices, segments, true); len(issues) > 0 { + return nil, fmt.Errorf("%s", issues[0].Message) + } + } return &humanSliceMaterialization{Artifact: existing, Payload: map[string]any{"status": "completed", "revision": revision, "sliceCount": sliceCount, "coverage": coverage, "deliverySelection": existing.Data["deliverySelection"], "runId": task.RunID, "artifactId": existing.ID, "manifestSha256": manifestSHA}, Slices: slices, Segments: segments, CoverageStartSecond: floatValue(coverage["startSecond"]), CoverageEndSecond: floatValue(coverage["endSecond"])}, nil } } @@ -796,8 +807,8 @@ func (server *server) materializeCombinedSliceSubmission(ctx context.Context, ta segment.StartTimestampUS, segment.EndTimestampUS = grid.Timestamps[si], grid.Timestamps[ei] normalizedSegments = append(normalizedSegments, segment) } - if len(normalizedSegments) > 0 { - if issues := validateDescriptionIntervals(normalizedSlices, normalizedSegments, task.TemplateVersion < 6); len(issues) > 0 { + if len(normalizedSegments) > 0 || continuous { + if issues := validateDescriptionIntervals(normalizedSlices, normalizedSegments, continuous || task.TemplateVersion < 6); len(issues) > 0 { return nil, fmt.Errorf("%s", issues[0].Message) } } diff --git a/internal/api/server.go b/internal/api/server.go index 9a048cf5..cc87b4a4 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -1356,6 +1356,8 @@ func NewHandlerWithConfig(dataStore store.Store, aiService ai.Service, appConfig router.Use(instance.requireBusinessRole(domain.UserRoleAdmin, domain.UserRoleAnnotator, domain.UserRoleQualityReviewer, domain.UserRoleAcceptanceReviewer)) router.Post("/api/human-items/{id}/claim", instance.handleHumanItemClaim) router.Post("/api/plugins/annotation-qa/random-claims", instance.handleAnnotationRandomClaim) + router.Get("/api/plugins/annotation-qa/work-buffer", instance.handleAnnotationWorkBuffer) + router.Put("/api/plugins/annotation-qa/work-buffer", instance.handleAnnotationWorkBuffer) router.Post("/api/human-items/{id}/release", instance.handleHumanItemRelease) router.Post("/api/human-items/{id}/submissions", instance.handleHumanItemSubmission) router.Post("/api/human-items/{id}/decisions", instance.handleHumanItemDecision) diff --git a/internal/api/slice_disposition.go b/internal/api/slice_disposition.go index 5994579c..1685ab8b 100644 --- a/internal/api/slice_disposition.go +++ b/internal/api/slice_disposition.go @@ -140,6 +140,7 @@ func (s *server) handleSliceDisposition(w http.ResponseWriter, r *http.Request) renderValidationError(w, validationIssue{Field: "disposition", Message: "用途必须为 keep 或 discard"}) return } + body.Reason = strings.TrimSpace(body.Reason) body.ReasonNote = strings.TrimSpace(body.ReasonNote) var reasonLabel *domain.AnnotationLabelRecord if body.Disposition == "discard" { @@ -149,9 +150,13 @@ func (s *server) handleSliceDisposition(w http.ResponseWriter, r *http.Request) renderValidationError(w, issues...) return } - body.Reason = reasonLabel.Name - if body.ReasonNote != "" { - body.Reason += ":" + body.ReasonNote + if reasonLabel != nil { + body.Reason = reasonLabel.Name + if body.ReasonNote != "" { + body.Reason += ":" + body.ReasonNote + } + } else { + body.ReasonNote = "" } } @@ -190,9 +195,14 @@ func (s *server) handleSliceDisposition(w http.ResponseWriter, r *http.Request) if body.Disposition == "discard" { next.DeliveryDisposition = "discard" next.DiscardReason = body.Reason - next.DiscardReasonLabelID = reasonLabel.ID - next.DiscardReasonVersion = reasonLabel.Version - next.DiscardReasonName = reasonLabel.Name + next.DiscardReasonLabelID = "" + next.DiscardReasonVersion = 0 + next.DiscardReasonName = "" + if reasonLabel != nil { + next.DiscardReasonLabelID = reasonLabel.ID + next.DiscardReasonVersion = reasonLabel.Version + next.DiscardReasonName = reasonLabel.Name + } next.DiscardReasonNote = body.ReasonNote next.DiscardedByUserID = p.User.ID next.DiscardedAt = nowISO() diff --git a/internal/domain/annotation_operations.go b/internal/domain/annotation_operations.go index f0c6c65b..68bc77ee 100644 --- a/internal/domain/annotation_operations.go +++ b/internal/domain/annotation_operations.go @@ -99,6 +99,7 @@ type AnnotationTemplateRecord struct { } type AnnotationSegment struct { + Status string `json:"status,omitempty" bson:"status,omitempty"` ID string `json:"id" bson:"id"` LabelID string `json:"labelId" bson:"labelId"` Label string `json:"label" bson:"label"` @@ -171,6 +172,7 @@ type SliceRevisionRecord struct { type SemanticAnnotationRevisionRecord = AnnotationRevisionRecord type AnnotationTaskRecord struct { + ContinuousActions bool `json:"continuousActions,omitempty" bson:"-"` ProcessingScope string `json:"processingScope,omitempty" bson:"processingScope,omitempty"` ProcessingProfile string `json:"processingProfile,omitempty" bson:"processingProfile,omitempty"` ID string `json:"id" bson:"id"` diff --git a/internal/store/annotation_work_buffer.go b/internal/store/annotation_work_buffer.go new file mode 100644 index 00000000..ee8b84fc --- /dev/null +++ b/internal/store/annotation_work_buffer.go @@ -0,0 +1,172 @@ +package store + +import ( + "context" + "crypto/sha256" + "droboticflow/internal/domain" + "errors" + "fmt" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" +) + +var ErrAnnotationBufferFull = errors.New("annotation work buffer is full") + +type AnnotationWorkBuffer struct { + Capacity int `json:"capacity" bson:"capacity"` + Occupied int `json:"occupied" bson:"-"` + Items []domain.HumanItemRecord `json:"items" bson:"-"` + Version int `json:"-" bson:"version"` + Slots map[string]string `json:"-" bson:"slots"` +} + +func bufferKey(org, user, project string) string { + return fmt.Sprintf("%x", sha256.Sum256([]byte(org+"\x00"+user+"\x00"+project))) +} +func occupiesAnnotationBuffer(item domain.HumanItemRecord, org, user, project string) bool { + return item.OrganizationID == org && item.ProjectID == project && item.AssignedUserID == user && item.PluginID == "annotation-qa" && item.LegacyTaskID != "" && (item.CurrentStageID == "annotation_combined" || item.CurrentStageID == "semantic_annotation") && (item.Status == domain.HumanItemClaimed || item.Status == domain.HumanItemInProgress || item.Status == domain.HumanItemRework) +} +func annotationBufferBatchMatches(item domain.HumanItemRecord, batch domain.HumanBatchRecord) bool { + return batch.OrganizationID == item.OrganizationID && batch.ProjectID == item.ProjectID && batch.WorkflowID == item.WorkflowID && batch.ProcessingProfile == domain.ProcessingProfileRawHuman && domain.IsFanyuV58ThreeRoleHumanLoop(batch.Stages) +} +func (s *MemoryStore) AnnotationWorkBuffer(_ context.Context, org, user, project string, capacity int) (AnnotationWorkBuffer, error) { + s.mu.Lock() + defer s.mu.Unlock() + key := bufferKey(org, user, project) + if s.annotationBufferCapacities == nil { + s.annotationBufferCapacities = map[string]int{} + } + if capacity > 0 { + s.annotationBufferCapacities[key] = capacity + } + n := s.annotationBufferCapacities[key] + if n == 0 { + n = 2 + } + out := AnnotationWorkBuffer{Capacity: n, Items: []domain.HumanItemRecord{}} + for _, item := range s.humanItems { + if occupiesAnnotationBuffer(item, org, user, project) && annotationBufferBatchMatches(item, s.humanBatches[item.BatchID]) { + out.Items = append(out.Items, clone(item)) + } + } + out.Occupied = len(out.Items) + return out, nil +} + +// The single-document CAS ledger also protects standalone Mongo. Pending claim +// intents retain their slot across process restarts; only a definitive conflict +// or handoff frees it. A receipt retry reuses the same slot even after downsizing. +func (s *MongoStore) annotationBuffer(ctx context.Context, org, user, project string, capacity int, reserve *HumanClaimReceipt) (AnnotationWorkBuffer, error) { + key := bufferKey(org, user, project) + collection := s.db.Collection("annotationWorkBuffers") + for { + if err := ctx.Err(); err != nil { + return AnnotationWorkBuffer{}, err + } + var old AnnotationWorkBuffer + err := collection.FindOne(ctx, bson.M{"_id": key}).Decode(&old) + if err == mongo.ErrNoDocuments { + _, e := collection.InsertOne(ctx, bson.M{"_id": key, "capacity": 2, "version": 0, "slots": bson.M{}}) + if e != nil && !mongo.IsDuplicateKeyError(e) { + return old, e + } + continue + } + if err != nil { + return old, err + } + next := old + next.Items = []domain.HumanItemRecord{} + next.Slots = map[string]string{} + items, err := s.ListHumanItems(ctx, org, domain.HumanItemQuery{ProjectID: project, PluginID: "annotation-qa", ActorUserID: user}) + if err != nil { + return old, err + } + occupiedIDs := map[string]bool{} + batches := map[string]*domain.HumanBatchRecord{} + trusted := func(item domain.HumanItemRecord) (bool, error) { + batch, ok := batches[item.BatchID] + if !ok { + var e error + batch, e = s.GetHumanBatch(ctx, item.BatchID) + if e != nil { + return false, e + } + batches[item.BatchID] = batch + } + return batch != nil && annotationBufferBatchMatches(item, *batch), nil + } + for _, item := range items { + scoped, e := trusted(item) + if e != nil { + return old, e + } + if !scoped { + continue + } + if occupiesAnnotationBuffer(item, org, user, project) { + next.Items = append(next.Items, item) + occupiedIDs[item.ID] = true + } + } + for request, id := range old.Slots { + item, e := s.GetHumanItem(ctx, id) + if e != nil { + return old, e + } + receipt, e := s.GetHumanClaimReceipt(ctx, request) + if e != nil { + return old, e + } + if item != nil { + scoped, e := trusted(*item) + if e != nil { + return old, e + } + if !scoped { + continue + } + } + pending := receipt != nil && receipt.State == "pending" && receipt.Intent != nil && item != nil && item.ClaimRequestID != request && validClaimSnapshot(*item, *receipt.Intent) + if item != nil && occupiesAnnotationBuffer(*item, org, user, project) && !occupiedIDs[id] { + occupiedIDs[id] = true + next.Items = append(next.Items, *item) + } + if occupiedIDs[id] || pending { + next.Slots[request] = id + occupiedIDs[id] = true + } + } + if capacity > 0 { + next.Capacity = capacity + } + full := false + if reserve != nil { + if _, exists := next.Slots[reserve.ID]; !exists { + if len(occupiedIDs) >= next.Capacity { + full = true + } else { + next.Slots[reserve.ID] = reserve.ItemID + occupiedIDs[reserve.ItemID] = true + } + } + } + next.Occupied = len(occupiedIDs) + next.Version = old.Version + 1 + result, e := collection.ReplaceOne(ctx, bson.M{"_id": key, "version": old.Version}, next, options.Replace()) + if e != nil { + return old, e + } + if result.MatchedCount == 0 { + continue + } + if full { + return next, ErrAnnotationBufferFull + } + return next, nil + } +} +func (s *MongoStore) AnnotationWorkBuffer(ctx context.Context, org, user, project string, capacity int) (AnnotationWorkBuffer, error) { + return s.annotationBuffer(ctx, org, user, project, capacity, nil) +} diff --git a/internal/store/human_claim.go b/internal/store/human_claim.go index 440e3786..85702d6a 100644 --- a/internal/store/human_claim.go +++ b/internal/store/human_claim.go @@ -27,6 +27,7 @@ type HumanClaimReceipt struct { } type HumanClaimCommit struct { + EnforceBuffer bool Receipt HumanClaimReceipt Item domain.HumanItemRecord ExpectedVersion int @@ -113,6 +114,21 @@ func (s *MemoryStore) CommitHumanClaim(_ context.Context, c HumanClaimCommit) (* v = clone(v) return &v, nil } + if c.EnforceBuffer { + capacity := s.annotationBufferCapacities[bufferKey(c.Receipt.OrganizationID, c.Receipt.UserID, c.Receipt.ProjectID)] + if capacity == 0 { + capacity = 2 + } + occupied := 0 + for _, item := range s.humanItems { + if occupiesAnnotationBuffer(item, c.Receipt.OrganizationID, c.Receipt.UserID, c.Receipt.ProjectID) && annotationBufferBatchMatches(item, s.humanBatches[item.BatchID]) { + occupied++ + } + } + if occupied >= capacity { + return nil, ErrAnnotationBufferFull + } + } old, ok := s.humanItems[c.Item.ID] if !ok || !validClaimSnapshot(old, c) { return nil, ErrHumanClaimConflict @@ -171,7 +187,7 @@ func (s *MongoStore) CommitHumanClaim(ctx context.Context, c HumanClaimCommit) ( } func (s *MongoStore) commitHumanClaimWithAccountLock(ctx context.Context, c HumanClaimCommit) (*domain.HumanItemRecord, error) { - if c.Receipt.Intent != nil { + if c.EnforceBuffer || c.Receipt.Intent != nil { return s.commitHumanClaimStandalone(ctx, c) } item, err := s.commitHumanClaimTransaction(ctx, c) diff --git a/internal/store/human_claim_mongo_test.go b/internal/store/human_claim_mongo_test.go index e32ab9e9..09445658 100644 --- a/internal/store/human_claim_mongo_test.go +++ b/internal/store/human_claim_mongo_test.go @@ -48,7 +48,7 @@ func TestHumanClaimMongoStandalone(t *testing.T) { s.UpsertProject(ctx, domain.ProjectRecord{ID: project, OrganizationID: org}) s.UpsertSupplier(ctx, domain.SupplierRecord{ID: supplier, OrganizationID: org, Status: "active"}) for _, id := range []string{"actor-a", "actor-b"} { - s.UpsertUser(ctx, domain.UserRecord{ID: id, OrganizationID: org, Role: domain.UserRoleAnnotator, Status: domain.UserStatusActive}) + s.UpsertUser(ctx, domain.UserRecord{ID: id, OrganizationID: org, SupplierID: supplier, Role: domain.UserRoleAnnotator, Status: domain.UserStatusActive}) s.UpsertProjectMember(ctx, domain.ProjectMemberRecord{ID: "member-" + id, OrganizationID: org, ProjectID: project, UserID: id, SupplierID: supplier, Roles: []domain.AnnotationAssignmentRole{domain.AnnotationRoleAnnotator}}) } create := func(id, request, actor string) HumanClaimCommit { diff --git a/internal/store/human_claim_standalone.go b/internal/store/human_claim_standalone.go index d1bae8e8..9c28d03a 100644 --- a/internal/store/human_claim_standalone.go +++ b/internal/store/human_claim_standalone.go @@ -71,6 +71,13 @@ func (s *MongoStore) commitHumanClaimStandalone(ctx context.Context, proposed Hu if !validClaimSnapshot(*item, c) { return conflict() } + // A claim already applied to this item owns its original result even if + // a later handoff/downsize has removed the slot; replay only repairs it. + if c.EnforceBuffer { + if _, err := s.annotationBuffer(ctx, r.OrganizationID, r.UserID, r.ProjectID, 0, r); err != nil { + return nil, err + } + } project, e := s.GetProject(ctx, c.Item.ProjectID) if e != nil { return nil, e diff --git a/internal/store/memory.go b/internal/store/memory.go index 75ec41eb..82bd9c74 100644 --- a/internal/store/memory.go +++ b/internal/store/memory.go @@ -12,74 +12,75 @@ import ( ) type MemoryStore struct { - supplierDeletions map[string]domain.SupplierDeletionTask - annotationTimelineIndexes map[string]domain.AnnotationTimelineIndex - annotationIndexJobs map[string]domain.AnnotationIndexJob - mu sync.Mutex - organizations map[string]domain.OrganizationRecord - projects map[string]domain.ProjectRecord - projectDeletions map[string]domain.ProjectDeletionTask - operators map[string]domain.OperatorRecord - builtinOperatorDeletions map[string]domain.BuiltinOperatorDeletionRecord - workflows map[string]domain.WorkflowRecord - workflowRuntimePolicies map[string]domain.WorkflowRuntimePolicyRecord - templates map[string]domain.TemplateRecord - workflowReleases map[string]domain.WorkflowReleaseRecord - projectWorkflowInstances map[string]domain.ProjectWorkflowInstanceRecord - runs map[string]domain.RunRecord - sourceStates map[string]domain.SourceStateRecord - captureRecords map[string]domain.CaptureRecord - collectionTasks map[string]domain.CollectionTaskRecord - datasetVersions map[string]domain.DatasetVersionRecord - dataMetricFacts map[string]domain.DataMetricFactRecord - auditTasks map[string]domain.AuditTaskRecord - samplingTasks map[string]domain.SamplingTaskRecord - annotationWorkgroups map[string]domain.AnnotationWorkgroupRecord - annotationMemberships map[string]domain.ProjectAnnotationMembershipRecord - suppliers map[string]domain.SupplierRecord - projectMembers map[string]domain.ProjectMemberRecord - annotationLabels map[string]domain.AnnotationLabelRecord - projectAnnotationLabels map[string]domain.ProjectAnnotationLabelsRecord - annotationTemplates map[string]domain.AnnotationTemplateRecord - annotationTasks map[string]domain.AnnotationTaskRecord - annotationRevisions map[string]domain.AnnotationRevisionRecord - sliceRevisions map[string]domain.SliceRevisionRecord - annotationReviews map[string]domain.AnnotationReviewRecord - annotationWorklogEvents map[string]domain.AnnotationWorklogEventRecord - organizationPlugins map[string]domain.OrganizationPluginRecord - humanBatches map[string]domain.HumanBatchRecord - humanItems map[string]domain.HumanItemRecord - humanClaimReceipts map[string]HumanClaimReceipt - humanStageAttempts map[string]domain.HumanStageAttemptRecord - humanEvents map[string]domain.HumanEventRecord - humanRejects map[string]domain.HumanRejectRecord - releasePartitions map[string]domain.ReleasePartitionRecord - deliveryPackages map[string]domain.DeliveryPackageRecord - users map[string]domain.UserRecord - sessions map[string]domain.SessionRecord - storageConnections map[string]domain.StorageConnectionRecord - uploadSessions map[string]domain.ObjectStorageUploadSessionRecord - mongoConnections map[string]domain.MongoConnectionRecord - objectSyncSpaces map[string]domain.ObjectSyncSpaceRecord - objectSyncDevices map[string]domain.ObjectSyncDeviceRecord - objectSyncAuthorizations map[string]domain.ObjectSyncDeviceAuthorizationRecord - objectSyncCredentials map[string]domain.ObjectSyncCredentialRecord - objectSyncSessions map[string]domain.ObjectSyncSessionRecord - objectSyncItems map[string]domain.ObjectSyncItemRecord - objectSyncLeases map[string]domain.ObjectSyncLeaseRecord - objectSyncHeads map[string]domain.ObjectSyncObjectHeadRecord - objectSyncVersions map[string]domain.ObjectSyncVersionRecord - objectSyncAuditEvents map[string]domain.ObjectSyncAuditEvent - objectSyncAuditSeals map[string]domain.ObjectSyncAuditSealRecord - objectSyncReleases map[string]domain.ObjectSyncReleaseRecord - objectSyncClientReleases map[string]domain.ObjectSyncClientReleaseRecord - objectSyncReconciles map[string]domain.ObjectSyncReconcileRecord - objectSyncIdempotency map[string]domain.ObjectSyncIdempotencyRecord - objectSyncRateLimits map[string]domain.ObjectSyncRateLimitRecord - databaseCollections map[string][]map[string]any - databaseIndexes map[string][]domain.DatabaseIndexSummary - settings *domain.SettingsRecord - artifactStorageSettings map[string]domain.ArtifactStorageSettings + annotationBufferCapacities map[string]int + supplierDeletions map[string]domain.SupplierDeletionTask + annotationTimelineIndexes map[string]domain.AnnotationTimelineIndex + annotationIndexJobs map[string]domain.AnnotationIndexJob + mu sync.Mutex + organizations map[string]domain.OrganizationRecord + projects map[string]domain.ProjectRecord + projectDeletions map[string]domain.ProjectDeletionTask + operators map[string]domain.OperatorRecord + builtinOperatorDeletions map[string]domain.BuiltinOperatorDeletionRecord + workflows map[string]domain.WorkflowRecord + workflowRuntimePolicies map[string]domain.WorkflowRuntimePolicyRecord + templates map[string]domain.TemplateRecord + workflowReleases map[string]domain.WorkflowReleaseRecord + projectWorkflowInstances map[string]domain.ProjectWorkflowInstanceRecord + runs map[string]domain.RunRecord + sourceStates map[string]domain.SourceStateRecord + captureRecords map[string]domain.CaptureRecord + collectionTasks map[string]domain.CollectionTaskRecord + datasetVersions map[string]domain.DatasetVersionRecord + dataMetricFacts map[string]domain.DataMetricFactRecord + auditTasks map[string]domain.AuditTaskRecord + samplingTasks map[string]domain.SamplingTaskRecord + annotationWorkgroups map[string]domain.AnnotationWorkgroupRecord + annotationMemberships map[string]domain.ProjectAnnotationMembershipRecord + suppliers map[string]domain.SupplierRecord + projectMembers map[string]domain.ProjectMemberRecord + annotationLabels map[string]domain.AnnotationLabelRecord + projectAnnotationLabels map[string]domain.ProjectAnnotationLabelsRecord + annotationTemplates map[string]domain.AnnotationTemplateRecord + annotationTasks map[string]domain.AnnotationTaskRecord + annotationRevisions map[string]domain.AnnotationRevisionRecord + sliceRevisions map[string]domain.SliceRevisionRecord + annotationReviews map[string]domain.AnnotationReviewRecord + annotationWorklogEvents map[string]domain.AnnotationWorklogEventRecord + organizationPlugins map[string]domain.OrganizationPluginRecord + humanBatches map[string]domain.HumanBatchRecord + humanItems map[string]domain.HumanItemRecord + humanClaimReceipts map[string]HumanClaimReceipt + humanStageAttempts map[string]domain.HumanStageAttemptRecord + humanEvents map[string]domain.HumanEventRecord + humanRejects map[string]domain.HumanRejectRecord + releasePartitions map[string]domain.ReleasePartitionRecord + deliveryPackages map[string]domain.DeliveryPackageRecord + users map[string]domain.UserRecord + sessions map[string]domain.SessionRecord + storageConnections map[string]domain.StorageConnectionRecord + uploadSessions map[string]domain.ObjectStorageUploadSessionRecord + mongoConnections map[string]domain.MongoConnectionRecord + objectSyncSpaces map[string]domain.ObjectSyncSpaceRecord + objectSyncDevices map[string]domain.ObjectSyncDeviceRecord + objectSyncAuthorizations map[string]domain.ObjectSyncDeviceAuthorizationRecord + objectSyncCredentials map[string]domain.ObjectSyncCredentialRecord + objectSyncSessions map[string]domain.ObjectSyncSessionRecord + objectSyncItems map[string]domain.ObjectSyncItemRecord + objectSyncLeases map[string]domain.ObjectSyncLeaseRecord + objectSyncHeads map[string]domain.ObjectSyncObjectHeadRecord + objectSyncVersions map[string]domain.ObjectSyncVersionRecord + objectSyncAuditEvents map[string]domain.ObjectSyncAuditEvent + objectSyncAuditSeals map[string]domain.ObjectSyncAuditSealRecord + objectSyncReleases map[string]domain.ObjectSyncReleaseRecord + objectSyncClientReleases map[string]domain.ObjectSyncClientReleaseRecord + objectSyncReconciles map[string]domain.ObjectSyncReconcileRecord + objectSyncIdempotency map[string]domain.ObjectSyncIdempotencyRecord + objectSyncRateLimits map[string]domain.ObjectSyncRateLimitRecord + databaseCollections map[string][]map[string]any + databaseIndexes map[string][]domain.DatabaseIndexSummary + settings *domain.SettingsRecord + artifactStorageSettings map[string]domain.ArtifactStorageSettings } func NewMemoryStore() *MemoryStore { diff --git a/internal/store/store.go b/internal/store/store.go index f3094f75..8ad13540 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -216,6 +216,7 @@ type Store interface { ListHumanItems(context.Context, string, domain.HumanItemQuery) ([]domain.HumanItemRecord, error) ListAnnotationClaimCandidates(context.Context, string, string) ([]domain.HumanItemRecord, error) GetHumanClaimReceipt(context.Context, string) (*HumanClaimReceipt, error) + AnnotationWorkBuffer(context.Context, string, string, string, int) (AnnotationWorkBuffer, error) CommitHumanClaim(context.Context, HumanClaimCommit) (*domain.HumanItemRecord, error) GetHumanItem(context.Context, string) (*domain.HumanItemRecord, error) UpsertHumanItem(context.Context, domain.HumanItemRecord) error diff --git a/src/components/CaptureAnnotationWorkbench.tsx b/src/components/CaptureAnnotationWorkbench.tsx index de2c9709..3a1846dd 100644 --- a/src/components/CaptureAnnotationWorkbench.tsx +++ b/src/components/CaptureAnnotationWorkbench.tsx @@ -1,5 +1,7 @@ import { DiscardReasonFields, type DiscardReasonChoice } from "./DiscardReasonFields"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import { lastActionFrame, moveActionBoundary } from "../lib/action-frame-boundary.js"; +import { actionJudgment } from "../lib/continuous-actions.js"; import { adjacentAnnotation } from "../lib/annotation-list-navigation.js"; import { WorkspaceDictionaryPanel } from "./WorkspaceDictionaryPanel"; import { SliceNameDictionaryPicker } from "./SliceNameDictionaryPicker"; @@ -102,6 +104,7 @@ type Props = { labels?: SemanticLabelDefinition[]; discardReasons?: AnnotationLabelRecord[]; discardReasonsLoading?: boolean; + discardReasonsAllowManual?: boolean; discardReasonsError?: string; onRefreshDiscardReasons?: () => void; sliceDictionary?: { id: string; name: string }[]; @@ -152,6 +155,7 @@ type Props = { } | null; onSplitSlice?: (sliceIndex: number, at: number) => string | undefined; onDeleteSlice?: (sliceIndex: number) => void; + onMergeSliceBoundary?: (sliceId: string, direction: "shrink" | "expand") => void; onConfirmSlices?: () => void; canConfirmSlices?: boolean; onConfirmAnnotations?: ( @@ -174,6 +178,10 @@ type Props = { onMediaDuration?: (duration: number) => void; browserReadyMedia?: boolean; seekRequest?: { time: number; revision: number } | null; + cameraPreferenceKey?: string; + continuousActions?: boolean; + progressSaved?: boolean; + onSaveProgress?: (segments: AnnotationSegment[]) => Promise; initialCameraVisibility?: { left: boolean; right: boolean }; onCameraVisibilityChange?: (value: { left: boolean; right: boolean }) => void; }; @@ -225,6 +233,7 @@ export function CaptureAnnotationWorkbench({ labels = [], discardReasons = [], discardReasonsLoading = false, + discardReasonsAllowManual = false, discardReasonsError = "", onRefreshDiscardReasons, sliceDictionary = [], @@ -265,6 +274,7 @@ export function CaptureAnnotationWorkbench({ historyReveal, onSplitSlice, onDeleteSlice, + onMergeSliceBoundary, onConfirmSlices, canConfirmSlices = false, onConfirmAnnotations, @@ -283,6 +293,10 @@ export function CaptureAnnotationWorkbench({ onMediaDuration, browserReadyMedia = false, seekRequest, + cameraPreferenceKey = "", + continuousActions = false, + progressSaved = true, + onSaveProgress, initialCameraVisibility, onCameraVisibilityChange, }: Props) { @@ -306,7 +320,12 @@ export function CaptureAnnotationWorkbench({ stageDialogRef.current?.focus(); } else stageDialogRef.current?.close(); }, [stageConfirmation]); - const dispositionDialogRef = useRef(null); + const dispositionDialogRef = useRef(null); + const [dispositionOpen, setDispositionOpen] = useState(false); + const closeDisposition = () => { + setDispositionOpen(false); + requestAnimationFrame(focusWorkbench); + }; const [dispositionDraft, setDispositionDraft] = useState( { sliceId: "", reasonNote: "", discard: false }, ); @@ -339,7 +358,24 @@ export function CaptureAnnotationWorkbench({ const [showRight, setShowRight] = useState(initialCameraVisibility?.right ?? Boolean(rightVideoSource)); const effectiveShowLeft = focusedLayout || showLeft; const effectiveShowRight = focusedLayout ? Boolean(rightVideoSource) : showRight; - const [inspectionCamera, setInspectionCamera] = useState<"left" | "right" | null>(null); + const cameraStorageKey = cameraPreferenceKey ? `annotation-camera-default:${cameraPreferenceKey}` : ""; + const readCameraDefault = () => { + try { + const value = cameraStorageKey && localStorage.getItem(cameraStorageKey); + return value === "right" || value === "both" ? value : "left"; + } catch { + return "left"; + } + }; + const [defaultCamera, setDefaultCamera] = useState(readCameraDefault); + const [inspectionCamera, setInspectionCamera] = useState<"left" | "right" | null>(() => + readCameraDefault() === "both" ? null : (readCameraDefault() as "left" | "right"), + ); + useEffect(() => { + const preference = readCameraDefault(); + setDefaultCamera(preference); + setInspectionCamera(preference === "both" ? null : (preference as "left" | "right")); + }, [taskId, cameraStorageKey]); const [selectedBoundary, setSelectedBoundary] = useState(null); const [splitPreview, setSplitPreview] = useState(null); const [editingAnnotation, setEditingAnnotation] = useState(null); @@ -367,9 +403,8 @@ export function CaptureAnnotationWorkbench({ const [showDictionary, setShowDictionary] = useState(false); const [expandedDescription, setExpandedDescription] = useState(false); useEffect(() => setExpandedDescription(false), [editingAnnotation?.id]); - useEffect(() => { - if (!focusedLayout) setInspectionCamera(null); - }, [focusedLayout]); + // Normal and focused layouts share this task's temporary camera choice. + // Only a new task/account above applies the saved default again. useEffect(() => { if (showDictionary && !focusedLayout) ( @@ -392,7 +427,6 @@ export function CaptureAnnotationWorkbench({ setEndSelection(null); setEditingAnnotation(null); setShowDictionary(false); - setInspectionCamera(null); shortcutHelpRef.current?.close(); setSelectedBoundary(null); setSelectedAnnotationBoundary(null); @@ -419,6 +453,14 @@ export function CaptureAnnotationWorkbench({ slices.findIndex((slice) => slice.id === selectedSliceId), ); const selectedSlice = (slices && slices.length > 0 ? slices[selectedSliceIndex] || slices[0] : null) || fallbackSlice; + useEffect(() => { + // This side panel is non-modal: timeline and previous/next clicks can change + // the visible slice. Never leave a confirmation bound to the former slice. + if (dispositionOpen && dispositionDraft.sliceId !== selectedSlice?.id) { + setDispositionOpen(false); + setDispositionError(""); + } + }, [selectedSlice?.id, dispositionOpen, dispositionDraft.sliceId]); const playbackBounds = capturePlaybackBounds(phase, selectedSlice, clipStart, clipEnd, reviewPlayback); const playheadSliceIndex = sliceIndexAtPlayhead(slices, currentTime); const playheadSlice = playheadSliceIndex >= 0 ? slices[playheadSliceIndex] : null; @@ -451,6 +493,28 @@ export function CaptureAnnotationWorkbench({ ).sort((left, right) => left.start - right.start); }, [annotationSegments, editingAnnotation]); + const [showActionJSON, setShowActionJSON] = useState(false); + const actionListRef = useRef(null); + const listSelectedIndex = annotationForRender.findIndex((action) => action.id === editingAnnotation?.id); + const previousListIndex = useRef(-1); + useEffect(() => { + const list = actionListRef.current; + const row = list?.querySelector("[aria-selected='true']"); + if (list && row) { + const wrap = Math.abs(previousListIndex.current - listSelectedIndex) > 6; + list.scrollTo({ + top: Math.max(0, row.offsetTop - list.clientHeight * 0.4), + behavior: wrap ? "instant" : "smooth", + }); + } + previousListIndex.current = listSelectedIndex; + }, [editingAnnotation?.id, listSelectedIndex]); + const displayedAction = annotationForRender.find( + (action) => currentTime >= action.start - 1e-7 && currentTime < action.end - 1e-7, + ); + const displayedActionSaved = displayedAction && segments.find((action) => action.id === displayedAction.id); + const previewSaved = + progressSaved && displayedAction && JSON.stringify(displayedAction) === JSON.stringify(displayedActionSaved); const lowerAnnotation = selectedSlice?.start ?? clipStart; const upperAnnotation = selectedSlice?.end ?? clipEnd; @@ -476,13 +540,13 @@ export function CaptureAnnotationWorkbench({ if ( !selectingEnd && saved && - (saved.description?.trim() || saved.isInvalid) && + (continuousActions || saved.description?.trim() || saved.isInvalid) && JSON.stringify(saved) === JSON.stringify(editor.annotation) ) return []; return [{ sliceId, annotation: editor.annotation, selectingEnd, isNew: !saved }]; }); - }, [parkedEditors, selectedSlice.id, editingAnnotation, endSelection, segments, isQualityReview]); + }, [parkedEditors, selectedSlice.id, editingAnnotation, endSelection, segments, isQualityReview, continuousActions]); useEffect(() => { onDraftsChange?.(outstandingDrafts); }, [outstandingDrafts, onDraftsChange]); @@ -728,14 +792,17 @@ export function CaptureAnnotationWorkbench({ onPointerUp: () => { sliderDragging.current = false; transport.finishScrub(); + focusWorkbench(); }, onPointerCancel: () => { sliderDragging.current = false; transport.finishScrub(); + focusWorkbench(); }, onLostPointerCapture: () => { sliderDragging.current = false; transport.finishScrub(); + focusWorkbench(); }, onBlur: () => { sliderDragging.current = false; @@ -998,6 +1065,37 @@ export function CaptureAnnotationWorkbench({ const editAnnotationBoundary = (field: "start" | "end", time: number) => { if (!editingAnnotation || !selectedSlice || !Number.isFinite(time)) return; + if (continuousActions) { + if (outstandingDrafts.some((draft) => draft.sliceId === selectedSlice.id)) { + setError("请先保存或取消当前文字,再调整边界。"); + return; + } + const own = annotationSegments.findIndex((action) => action.id === editingAnnotation.id); + const index = field === "end" ? own : own - 1; + const left = annotationSegments[index], + right = annotationSegments[index + 1]; + if (!left || !right || !exactFrames) { + setError("切片首尾边界固定。"); + return; + } + const at = clamp( + snap(time), + stepFrameBoundary(frameBoundaries, left.start, 1), + stepFrameBoundary(frameBoundaries, right.end, -1), + ); + const changed = moveActionBoundary(annotationSegments, left.id, at); + const next = segments + .filter((action) => !annotationSegments.some((old) => old.id === action.id)) + .concat(changed) + .sort((a, b) => a.start - b.start); + const editor = changed.find((action) => action.id === editingAnnotation.id); + recordEditorEdit({ annotation: editor, endSelection: null }, next, at); + onChange(next); + setEditingAnnotation(editor); + seek(at); + setError(""); + return; + } if (field === "end") { if (!selectingEnd && !beginEndSelection()) return; seek(snap(time)); @@ -1173,6 +1271,7 @@ export function CaptureAnnotationWorkbench({ end, description, label, + ...(continuousActions ? { status: isInvalid ? ("invalid" as const) : ("described" as const) } : {}), }; if (isInvalid) { candidate.isInvalid = true; @@ -1236,7 +1335,11 @@ export function CaptureAnnotationWorkbench({ focusWorkbench(); }; const requestStageConfirmation = (keyboard = false) => { - if (saving || readOnly || isQualityReview || mediaOnly || phase === "materializing") return; + if (saving || readOnly || isQualityReview || mediaOnly) return; + if (continuousActions && keyboard && phase === "annotate") { + if (editingAnnotation) void confirmAnnotation(); + return; + } // Saving a draft is its own command, even when validation fails. if (keyboard && outstandingDrafts.some((draft) => draft.sliceId === selectedSlice.id)) { void confirmAnnotation(); @@ -1271,6 +1374,50 @@ export function CaptureAnnotationWorkbench({ else onSubmitTask?.(); }; + const markSelectedInvalid = async () => { + if (!editingAnnotation || !canEdit || saveInFlightRef.current) return; + const candidate: AnnotationSegment = { + ...editingAnnotation, + status: "invalid", + isInvalid: true, + description: "无效片段", + label: "无效片段", + labelId: "", + }; + const next = segments.map((segment) => (segment.id === candidate.id ? candidate : segment)); + saveInFlightRef.current = true; + setDescriptionSaving(true); + try { + if ((await onConfirmAnnotations?.(next, selectedSlice.id, annotationEditState())) === false) return; + onChange(next); + setEditingAnnotation(candidate); + setError(""); + focusWorkbench(); + } catch (cause) { + setError(cause instanceof Error ? cause.message : "保存无效判断失败"); + } finally { + saveInFlightRef.current = false; + setDescriptionSaving(false); + } + }; + const saveProgress = async () => { + if (!onSaveProgress || !canEdit || saveInFlightRef.current) return; + if (outstandingDrafts.length) { + setError("请先保存或取消当前文字,再保存进度。"); + return; + } + saveInFlightRef.current = true; + setDescriptionSaving(true); + try { + if (await onSaveProgress(segments)) setError(""); + } catch (cause) { + setError(cause instanceof Error ? cause.message : "保存进度失败"); + } finally { + saveInFlightRef.current = false; + setDescriptionSaving(false); + focusWorkbench(); + } + }; const markUnannotatedInvalid = async () => { if (readOnly || saving || editingAnnotation || !sliceAligned || !selectedSlice || !annotationGaps.length) return; if ( @@ -1309,6 +1456,10 @@ export function CaptureAnnotationWorkbench({ const beginAnnotationBoundaryDrag = (event: ReactPointerEvent, index: number) => { if (readOnly || saving || phase !== "annotate" || selectingEnd || !annotationTrackRef.current) return; + if (continuousActions && outstandingDrafts.some((draft) => draft.sliceId === selectedSlice.id)) { + setError("请先保存或取消当前文字,再调整边界。"); + return; + } if (Math.abs(annotationSegments[index]?.end - annotationSegments[index + 1]?.start) > 0.000001) { setError("这两段之间有未标注区间,请先补标,不会自动拉伸描述填空。"); return; @@ -1391,7 +1542,19 @@ export function CaptureAnnotationWorkbench({ }; const insertAnnotationSplit = (segmentIndex: number, time: number) => { - if (readOnly || isQualityReview || saving || phase !== "annotate" || !selectedSlice || editingAnnotation) return; + if ( + readOnly || + isQualityReview || + saving || + phase !== "annotate" || + !selectedSlice || + (!continuousActions && editingAnnotation) + ) + return; + if (outstandingDrafts.some((draft) => draft.sliceId === selectedSlice.id)) { + setError("请先保存或取消当前动作描述,再切分。"); + return; + } const target = annotationSegments[segmentIndex]; if (!target) return; const splitPoint = snap(time); @@ -1403,6 +1566,7 @@ export function CaptureAnnotationWorkbench({ }; const secondSegment: AnnotationSegment = { id: `description-${selectedSlice.id}-${Date.now()}`, + ...(continuousActions ? { status: "pending" as const } : {}), labelId: "", label: "", description: "", @@ -1419,10 +1583,13 @@ export function CaptureAnnotationWorkbench({ return [seg]; }); - recordEditorEdit({ annotation: secondSegment, endSelection: null }, next, splitPoint); + const selectedPart = continuousActions ? firstSegment : secondSegment; + pausePlayback(); + recordEditorEdit({ annotation: selectedPart, endSelection: null }, next, splitPoint); onChange(next); setAnnotationSplitPreview(null); - setEditingAnnotation(secondSegment); + setEditingAnnotation(selectedPart); + setEndSelection(null); seek(splitPoint); }; @@ -1484,12 +1651,24 @@ export function CaptureAnnotationWorkbench({ setReviewPlayback(false); setSelectedAnnotationBoundary(null); setAnnotationSplitPreview(null); - seek(segment[edge]); + seek( + continuousActions && edge === "end" && exactFrames ? lastActionFrame(frameBoundaries, segment) : segment[edge], + ); focusWorkbench(); }; - const navigateAnnotation = (direction: -1 | 1) => { - const target = adjacentAnnotation(annotationForRender, editingAnnotation?.id, currentTime, direction); + const navigateAnnotation = (direction: -1 | 1, count = 1) => { + let target = adjacentAnnotation(annotationForRender, editingAnnotation?.id, currentTime, direction); + if (continuousActions && annotationForRender.length) { + const selectedIndex = annotationForRender.findIndex((action) => action.id === editingAnnotation?.id); + // The first unselected step follows the playhead, just like the original + // navigation. Further steps wrap within this slice. + const firstIndex = + selectedIndex < 0 ? annotationForRender.findIndex((action) => action.id === target?.id) : selectedIndex; + const steps = selectedIndex < 0 ? count - 1 : count; + const length = annotationForRender.length; + target = annotationForRender[(((firstIndex + direction * steps) % length) + length) % length]; + } if (target) seekAnnotation(target, "end"); }; @@ -1542,8 +1721,33 @@ export function CaptureAnnotationWorkbench({ setShowDictionary(false); focusWorkbench(); }; + const openDisposition = (restore = false) => { + if (saving || readOnly || isQualityReview || mediaOnly || phase === "materializing" || !onSliceDispositionChange || (selectedDiscarded && !restore)) return; + if (outstandingDrafts.some((draft) => draft.sliceId === selectedSlice.id)) { + setError("请先保存或取消当前描述,再设置舍弃原因。"); + return; + } + setDispositionDraft((previous) => + previous.sliceId === selectedSlice.id + ? { ...previous, discard: !restore } + : { sliceId: selectedSlice.id, reasonNote: "", discard: !restore }, + ); + if (!restore) onRefreshDiscardReasons?.(); + setDispositionError(""); + setShowDictionary(false); + setDispositionOpen(true); + requestAnimationFrame(() => { + const panel = dispositionDialogRef.current; + const target = panel?.querySelector("input, textarea") || panel?.querySelector("button"); + target?.focus(); + }); + }; const splitAtPlayhead = () => { - if (!canEdit || editingAnnotation) return; + if (!canEdit || (!continuousActions && editingAnnotation)) return; + if (outstandingDrafts.some((draft) => draft.sliceId === selectedSlice.id)) { + setError("请先保存或取消当前描述,再切分。"); + return; + } if (phase === "slice") { if (!onSplitSlice) return; if (playheadSliceIndex < 0) { @@ -1558,6 +1762,119 @@ export function CaptureAnnotationWorkbench({ ); }; + const boundaryHoldRef = useRef<{ stop: () => void } | null>(null); + const stopBoundaryHold = () => { + boundaryHoldRef.current?.stop(); + boundaryHoldRef.current = null; + }; + useEffect(() => { + const released = (event: KeyboardEvent) => { + if (["Shift", "ArrowLeft", "ArrowRight"].includes(event.key)) stopBoundaryHold(); + }; + const blurred = () => stopBoundaryHold(); + window.addEventListener("keyup", released); + window.addEventListener("blur", blurred); + return () => { + window.removeEventListener("keyup", released); + window.removeEventListener("blur", blurred); + stopBoundaryHold(); + }; + }, [taskId, phase]); + useEffect(() => { + stopBoundaryHold(); + }, [selectedSlice.id, editingAnnotation?.id]); + useEffect(() => { + if (viewportSuspended || saving || showDictionary || stageConfirmation) stopBoundaryHold(); + }, [viewportSuspended, saving, showDictionary, stageConfirmation]); + const startBoundaryHold = (direction: -1 | 1) => { + if (!continuousActions || !canEdit || !exactFrames || boundaryHoldRef.current) return; + if (outstandingDrafts.some((draft) => draft.sliceId === selectedSlice.id)) { + setError("请先保存或取消当前文字,再调整边界。"); + return; + } + const items = phase === "slice" ? slices : annotationSegments; + const id = phase === "slice" ? selectedSlice.id : editingAnnotation?.id; + const index = items.findIndex((item) => item.id === id); + const current = items[index], + following = items[index + 1]; + if (!current || !following) return; + if ( + phase === "slice" && + ((current as SliceSegment).deliveryDisposition === "discard" || + (following as SliceSegment).deliveryDisposition === "discard") + ) { + setError("请先恢复相邻舍弃片段,再调整边界。"); + return; + } + pausePlayback(); + const before = annotationEditState(); + let nextSegments = segments; + let last = current.end; + let nextEditor = editingAnnotation; + let stopped = false; + let timer: ReturnType | undefined; + let interval: ReturnType | undefined; + if (phase === "slice") onSliceBoundaryEditStart?.(current.id); + const finish = () => { + if (stopped) return; + stopped = true; + clearTimeout(timer); + clearInterval(interval); + if (phase === "slice") onSliceBoundaryEditEnd?.(); + else if (nextSegments !== segments) + onAnnotationEdit?.(before, { + ...before, + segments: nextSegments, + time: last, + editor: nextEditor ? { annotation: nextEditor, endSelection: null } : null, + }); + boundaryHoldRef.current = null; + }; + const move = (count: number) => { + if (stopped) return; + const active = document.activeElement; + if ( + !workbenchRef.current?.contains(active) || + (active instanceof HTMLElement && + active.matches("input, textarea, select, button, a, [contenteditable], [role='button']")) || + workbenchRef.current?.querySelector("dialog[open], [role='dialog']") + ) { + finish(); + return; + } + let next = last; + for (let frame = 0; frame < count; frame++) next = stepFrameBoundary(frameBoundaries, next, direction); + next = clamp(next, current.start, following.end); + const merged = next <= current.start || next >= following.end; + last = next; + if (phase === "slice") { + if (merged) { + onMergeSliceBoundary?.(current.id, next <= current.start ? "shrink" : "expand"); + if (next <= current.start) setSelectedSliceId(following.id); + } else onSliceBoundaryChange?.(current.id, "end", next); + } else { + const changed = moveActionBoundary(annotationSegments, current.id, next); + nextSegments = segments + .filter((item) => !annotationSegments.some((old) => old.id === item.id)) + .concat(changed) + .sort((a, b) => a.start - b.start); + nextEditor = changed.find((item) => item.id === (next <= current.start ? following.id : current.id)) || null; + onChange(nextSegments); + setEditingAnnotation(nextEditor); + setEndSelection(null); + } + seek(next); + if (merged) finish(); + }; + boundaryHoldRef.current = { stop: finish }; + move(1); + if (!stopped) + timer = setTimeout(() => { + move(5); + if (!stopped) interval = setInterval(() => move(5), 500); + }, 1000); + }; + if (!selectedSlice) { return (
@@ -1573,10 +1890,12 @@ export function CaptureAnnotationWorkbench({ data-testid="capture-annotation-workbench" data-stage={phase} data-quality-review={isQualityReview || undefined} + data-continuous-actions={continuousActions || undefined} data-camera-inspection={focusedLayout ? inspectionCamera || undefined : undefined} data-adaptive-slice={adaptiveLayout && phase === "slice" && !mediaOnly && !isQualityReview ? true : undefined} tabIndex={0} onPointerDownCapture={(event) => { + stopBoundaryHold(); if ( !(event.target as HTMLElement).closest( "input, textarea, select, button, a, [contenteditable], dialog, [role='dialog']", @@ -1585,6 +1904,15 @@ export function CaptureAnnotationWorkbench({ event.currentTarget.focus({ preventScroll: true }); } }} + onBlurCapture={(event) => { + const next = event.relatedTarget; + if ( + !event.currentTarget.contains(next as Node) || + (next instanceof HTMLElement && + next.matches("input, textarea, select, button, a, [contenteditable], [role='button']")) + ) + stopBoundaryHold(); + }} onKeyUpCapture={(event) => { if (event.key === "Enter") stageEnterReleasedRef.current = true; }} @@ -1618,11 +1946,13 @@ export function CaptureAnnotationWorkbench({ nativeControl: Boolean(target.closest("button, a, input, select, [role='button']")), selectingEnd, phase, + continuousActions, }, ); if (!action) return; event.preventDefault(); if (action === "consume") return; + if (action !== "adjust-boundary") stopBoundaryHold(); if (action === "escape") { focusWorkbench(); return; @@ -1635,7 +1965,8 @@ export function CaptureAnnotationWorkbench({ if (action === "play") togglePlay(); else if (action === "step") step(event.key === "ArrowLeft" ? -1 : 1); else if (action === "navigate-slice") navigateSlice(event.key === "ArrowLeft" ? -1 : 1); - else if (action === "navigate-annotation") navigateAnnotation(event.key === "ArrowUp" ? -1 : 1); + else if (action === "navigate-annotation" || action === "navigate-annotation-six") + navigateAnnotation(event.key === "ArrowUp" ? -1 : 1, action === "navigate-annotation-six" ? 6 : 1); else if ((action === "annotation-start" || action === "annotation-end") && editingAnnotation) seekAnnotation(editingAnnotation, action === "annotation-start" ? "start" : "end"); else if (action === "review-slice") reviewSlice(); @@ -1649,9 +1980,11 @@ export function CaptureAnnotationWorkbench({ !annotationBoundaryDragRef.current ) void onHistoryCommand?.(action); + else if (action === "discard-dictionary") openDisposition(); else if (action === "save") requestStageConfirmation(true); else if (canEdit) { - if (action === "split") splitAtPlayhead(); + if (action === "adjust-boundary") startBoundaryHold(event.key === "ArrowLeft" ? -1 : 1); + else if (action === "split") splitAtPlayhead(); else if (action === "delete-selected") { if (phase === "slice") deleteSliceAtIndex(selectedSliceIndex); else if ( @@ -1660,7 +1993,8 @@ export function CaptureAnnotationWorkbench({ annotationSegments.some((segment) => segment.id === editingAnnotation.id) ) void deleteAnnotationLeavingBlank(editingAnnotation.id); - } else if (action === "mark-invalid" && phase === "annotate") void markUnannotatedInvalid(); + } else if (action === "mark-invalid" && phase === "annotate") + void (continuousActions ? markSelectedInvalid() : markUnannotatedInvalid()); else if (action === "new" && phase === "annotate" && sliceAligned) addAnnotation(); else if (action === "confirm-end" && selectingEnd && editingAnnotation) confirmEndSelection(); else if (action === "edit-description" && editingAnnotation && !selectingEnd) @@ -1672,6 +2006,35 @@ export function CaptureAnnotationWorkbench({ } }} > + {continuousActions && phase === "annotate" && !selectedDiscarded && ( + + )} ))} -

语义留空合法,保留的媒体仍参与审核和交付;舍弃片段保留审核证据。

+

+ {continuousActions + ? "保留切片的所有动作区间必须保存为描述或无效后才能送检;舍弃片段保留审核证据。" + : "语义留空合法,保留的媒体仍参与审核和交付;舍弃片段保留审核证据。"} +

{stageConfirmation === "slice" ? "生成完成后才进入描述编辑。" : "审核数据完成后才流转质检。"} 开始后不能通过撤销回退阶段。 @@ -1802,6 +2169,7 @@ export function CaptureAnnotationWorkbench({ {annotationShortcutHelpForContext(phase, { + continuousActions, editing: Boolean(editingAnnotation), selectingEnd, }) @@ -1991,6 +2359,26 @@ export function CaptureAnnotationWorkbench({ + {inspectionCamera && phase === "slice" && !readOnly && !isQualityReview ? ( + {showActionJSON && ( +

+                      {JSON.stringify(
+                        {
+                          preview: true,
+                          saved: Boolean(previewSaved),
+                          保存状态: previewSaved ? "已保存" : "未保存",
+                          timeBasis: "capture-seconds; end-exclusive",
+                          ...displayedAction,
+                        },
+                        null,
+                        2,
+                      )}
+                    
+ )} +
+ )}