Skip to content

Plan #125: File API force delete non-empty directories - #126

Open
nil4u wants to merge 3 commits into
developfrom
125-file-api-force/plan
Open

nil4u wants to merge 3 commits into
developfrom
125-file-api-force/plan

Conversation

@nil4u

@nil4u nil4u commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Source issue: #125
Plan file: .issue-flow/issues/125-file-api-force/plan/001-implementation.md

Summary

  • 本 issue 以已完成切换的 file_entry 模式为唯一前置条件和权威关系;删除通过加锁 BFS 快照处理目录整棵子树,沿用 MAX_TREE_DEPTH=64、分块扫描和稳定锁序。
  • 默认删除非空目录在任何写入前返回 HTTP 409,使用稳定错误码 file_directory_not_empty;force=true 批量更新文件状态、删除整棵子树的 file_entry 并保持逐节点 FILE_DELETED 语义。
  • 文件状态按资源物理分片更新,file_entry 按当前关系空间路由;跨空间移动后再删除的场景纳入验收,避免文件分片与关系分片混用。
  • closure 表不在本 issue 读取、写入、校验或清理;closure 停写、迁移与残留清理由独立 issue 负责,避免在删除方案中保留 dual/closure 兼容分支。

Review focus

  • 是否确认本 issue 的实现前置条件是仓库已切换到 file-entry.write-mode=entry,且不需要兼容旧 closure/dual 写入路径?默认同意,相关切换和 closure 清理由独立 issue 负责。
  • 是否同意默认节点上限 10000、深度上限沿用 64,超限以 HTTP 409 且不写入?默认同意,可按容量评估调整配置值。
  • 是否同意不逐节点调用现有 public delete,而采用批量状态/file_entry 关系编排并保持逐节点删除事件?默认同意,以避免父节点先广播及部分完成语义。
  • 当前部署是否能证明文件物理分片与 file_entry 分片参与同一事务资源管理器?若不能,本方案默认预检拒绝,不引入本 issue 范围外的分布式补偿。

@nil4u nil4u added the mr-by::plan PR or MR was created by the plan action label Nov 17, 2026 — with agentrix-ai
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T14:15:37.085347Z 0a73a90 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0a73a90fa0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


- 在 `FileService` 增加“构造并锁定快照 → 预检 → 批量状态变更/关系清理 → 广播”的子树删除编排,并保留单节点删除作为同一底层删除原语的单节点调用;不要逐节点调用现有 public `delete`,避免重复查询、嵌套事务和父节点先广播造成部分完成观感。
- 快照按 `file_id` 携带完整 `FileDB`、`FileType`、`NodeType` 和原始 `OpenAIFile` 事件数据。`FILE`、`DIRECTORY`、`RESOURCE` 均纳入支持范围;每类节点沿用当前 `FileType.needsDirectorySupport()` 判断是否清理目录关系,未知类型在预检阶段拒绝。
- `FileRepo` 提供按物理文件分片分组的批量 `DELETED` 更新;每个更新必须校验影响行数与预期数量。入口写开启时,`FileEntryRepo` 按快照 entry ID 分块删除;闭包写开启时,按文件分片一次清理快照节点作为祖先或后代的闭包行。`entry`、`dual`、`closure` 三种模式都必须走对应的启用分支,不能只删除父入口或只删闭包。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Route closure operations by current space after cross-space moves

For a subtree containing a file previously moved across space shards in dual mode, grouping closure cleanup by the physical file shard targets the wrong table. FileEntryRepo.moveLeafClosureAcrossSpace moves closure rows to entryDb(targetSpaceCode), while updateFileSpaceCache leaves the physical file row and file ID in their original shard. Consequently, the proposed deletion either rejects a valid subtree during the dual-mode consistency check or leaves its migrated closure rows behind. Resolve closure shards from the current relationship space independently of file-state shards, including for the closure snapshot prescribed above, and cover a migrated leaf in the deletion tests.

Useful? React with 👍 / 👎.

nil4u commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

已处理该问题,方案已更新并推送到 2bd04d3:

  • file 状态更新继续按资源物理分片分组。
  • file_entry 与 file_closure 改为按当前关系空间独立路由,禁止使用文件 ID 分片推导 closure 分片。
  • 明确覆盖跨空间移动后“文件行仍在原分片、closure 已迁移到目标关系空间”的叶节点删除场景。
  • 在验收矩阵中新增先跨空间移动、再删除子树的 dual/closure 回归测试,验证不误报一致性冲突且不遗留 closure 行。

nil4u commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

根据最新决策已收窄方案边界并推送到 18868c0:

  • 本 issue 仅实现已切换完成的 file_entry 模式,不再保留 closure/dual 兼容删除分支。
  • closure 表不读取、不写入、不校验、不清理;相关停写、迁移和残留清理由独立 issue 负责。
  • 删除、上传、mkdir、move 仅围绕 file_entry 父入口锁和 BFS 子树快照协调。
  • 验收改为覆盖 entry 模式、跨空间移动后再删除,以及文件物理分片和 file_entry 空间分片的事务边界。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mr-by::plan PR or MR was created by the plan action

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant