feat(wiki): prune empty folders after document retract

Automatically remove wiki folders that become empty when knowledge is
retracted, using the durable finalize lane so pruning waits until ingest
drains. Repository DeleteFolder now atomically checks emptiness to avoid
races with concurrent page or child-folder writes.
This commit is contained in:
wizardchen
2026-07-22 17:57:55 +08:00
committed by lyingbug
parent ab0b1d65b5
commit 4c3ae69b49
10 changed files with 444 additions and 18 deletions
+4
View File
@@ -185,6 +185,10 @@ type WikiPageService interface {
// DeleteFolder removes an empty folder. Fails if it still contains pages
// or child folders (the UI must move or delete contents first).
DeleteFolder(ctx context.Context, kbID string, id string) error
// PruneEmptyFolderChains deletes candidate folders that are still empty,
// walking upward through newly-empty ancestors. Candidates are supplied by
// document retract cleanup so unrelated user-created empty folders remain.
PruneEmptyFolderChains(ctx context.Context, kbID string, folderIDs []string) ([]string, error)
// FindOrCreateFolderPath resolves a category path (e.g. ["AI","RAG"]) to a
// folder id, creating any missing intermediate folders. Returns the leaf
// folder id and the canonical (cleaned) path. An empty/blank path resolves