Repository navigation
feat(audit): 审计异常文件到期自动移入回收站 - #2877
Merged
Merged
Conversation
Add an hourly per-tenant cleanup for source files whose terminal review failure is older than 24 hours. Files that are encrypted, damaged, unsupported, violating, or blocked by stale membership are soft-deleted through the existing knowledge-space delete path and land in the recycle bin; protected version/distribution entries are skipped. A migration freezes pre-existing abnormal rows so only terminal events after go-live are eligible, and the audit UI stops promising deletion for exempt history. Tests: backend 68 passed, platform 72 passed. Feature artifacts under features/v2.5.0-sg/088-abnormal-file-auto-delete.
likaiaki
added a commit
that referenced
this pull request
Dec 3, 2026
## What F088 首轮 171 验收发现两处阻塞,本 PR 只包含修复: 1. **并发重复回收**:删除前新增 `abnormal_auto_delete_claimed_at` 原子认领(迁移 `f126`,15 分钟 TTL)。并发任务只有一个 `UPDATE ... WHERE claimed_at IS NULL OR claimed_at < now-15m` 能拿到 rowcount=1,另一个跳过;删除成功/失败/跳过都会释放认领,认领/释放显式写回 `update_time`。 2. **迁移覆盖历史时间**:`f125` 的豁免 UPDATE 改为 `SET abnormal_auto_delete_exempt=1, update_time=update_time`,避免 `ON UPDATE CURRENT_TIMESTAMP` 把历史异常行的失败时间改成部署时间。 ## Why - 171 上两个任务同时处理同一文件时各写一批回收、一条审计;行锁在删除前提交,挡不住并发。 - 171 上旧版 f125 把状态 3/6/7 行的 `update_time` 全部改成部署时刻。 ## Test - 后端:**70 passed**(含并发服务测试、仓库原子 claim 测试、既有异常/回收回归)。 - 全新 MySQL 8.0 手工验证:新 f125 语句前后 `update_time` 不变、exempt 变 1;旧语句会改成执行时刻。 - `ruff check`/`ruff format --check`、pre-commit 钩子、`arch-guard` 通过。 ## 171 复测注意 - 本 PR 合并后需重建 171 镜像并执行 `f126`,确认 `abnormal_auto_delete_claimed_at` 列存在。 - 171 已执行旧版 f125 的历史行 `update_time` 无备份不可恢复;历史行已 exempt、不会被自动删除,仅展示/排序受影响。`f125` 保留修复只对全新迁移生效。 - 复测重点:同一到期文件并发触发两个任务,只产生一批回收、一条 `abnormal_upload.auto_delete` 审计;claim 释放后为空。 ## Related - 首轮 PR:#2877(已合并 `491b79e275`) - 修复 commit:`91d941337d` - 迁移:`v2_6_0_f126_abnormal_auto_delete_claim`;`v2_6_0_f125_abnormal_auto_delete` 修正 - 验收交接:`features/v2.5.0-sg/088-abnormal-file-auto-delete/acceptance-handoff.md` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
likaiaki
added a commit
that referenced
this pull request
Dec 3, 2026
## What 审计异常文件列表中,鼠标悬停到被禁用的「重新解析」按钮时显示提示: - 内容违规:`此文件因内容违规,无法使用。平台将于1个工作日后自动删除文件,请上传符合要求的文档。` - 归属已更新:`此文件因归属已更新,无法重新解析。平台将于1个工作日后自动删除文件,请上传符合要求的文档。` - 历史豁免记录:只显示原因与上传建议,不显示 1 个工作日删除说明。 - 其他可重试记录:不显示该提示。 实现使用 `bs-ui` 的 Radix Tooltip,禁用按钮外层加 `<span>` 承载鼠标事件;替换原生 `title`,不改变按钮禁用/点击行为。三语文案已补齐。 本次同时记录 171 复测验收结果:并发同一文件只产生一批回收/一条审计;全新 MySQL 8.0 f125 保留历史 `update_time`。 ## Why - 只有灰按钮没有原因说明,用户不知道为何不能重新解析、文件何时被处理。 - 历史豁免记录不会再自动删除,不能展示删除承诺。 ## 范围说明 本次只覆盖当前被禁用的两类(内容违规、归属已更新)。加密/损坏/格式不支持在 F087 中仍保持可重新解析,按钮未禁用,因此未加禁用提示;如需把它们也改为不可重试,请另开需求。 ## Test - 平台:**73 passed**(悬停 helper、豁免变体、三语文案、既有预览回归)。 - TypeScript:仅既有 `TS2802`。 - 未改后端代码。 ## Related - F088 首轮:#2877;修复:#2880 - 验收记录:`features/v2.5.0-sg/088-abnormal-file-auto-delete/acceptance.md` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
F088 审计异常文件到期自动移入回收站:
v2_6_0_f125_abnormal_auto_delete增加knowledgefile.abnormal_auto_delete_exempt,并把上线时已有的状态 3/6/7 记录标记为豁免;历史异常永不自动删除。KnowledgeSpaceService.delete_file,保留版本/分发/收藏/纠错保护;带版本链/分发入口的记录跳过并记日志。abnormal_upload.auto_delete审计;任务记录 scanned/deleted/skipped/failed。auto_delete_exempt;历史豁免记录不展示“1个工作日自动删除”文案;归属已更新记录补齐提示。Why
F087 的提示承诺“1 个工作日后自动删除”,但平台没有对应任务;用户要求实现定时删除,并最终选择删除进回收站而非立即物理删除。
需求/设计/用例/验收交接见
features/v2.5.0-sg/088-abnormal-file-auto-delete/。How
Test
本地:
pytest test/knowledge/test_abnormal_auto_delete.py test/knowledge/test_abnormal_upload_retry_batch.py test/knowledge/test_knowledge_recycle_bin.py test/knowledge/test_source_file_validation.py test/knowledge/test_unreadable_sync_file_cleanup.py→ 68 passedvitest run test/abnormalTerminalNotice.test.tsx test/abnormalPreviewLifecycle.test.ts test/abnormalFilePreview.test.ts→ 72 passedruff新文件、git diff --check、arch-guard.sh通过;平台 tsc 仅既有 TS2802。未验证: MySQL/DM8 实库迁移、真实 24h 任务窗口、回收站恢复/保留期与后续物理清理、多租户实库、版本/分发入口拒绝。
Known limits
Related
features/v2.5.0-sg/087-audit-unparseable-file-noticefeatures/v2.5.0-sg/088-abnormal-file-auto-delete/acceptance-handoff.md🤖 Generated with Claude Code