Repository navigation
Open
Description
Taking it, if it is free: the Library Trash, phase 4a of 01-sources-and-folders.md. It is the first line of Known gaps in docs/architecture/documents.md: "Deleting a folder is permanent; the Trash is designed, not built."
What is on dev (36c42457b)
0025_source_roots_and_foldersalready hasfolders.statewithtrashedanddeleting, plustrash_kindandtrashed_at.source_scope/resolve.pyand the agent'sthread_folder/mirror_path.pyalready leave outtrashedanddeletingsubtrees.- The tree's delete still goes to
DELETE /folders/{id}(folders/delete_folder.py) andDELETE /documents/{id}, both permanent. - There is no
trash.py,purge.py,/trashroute orblob_tombstonesyet.
Plan. Three PRs against dev, each built to the proposal as written:
- Move to Trash and Restore (
modules/folders/trash.py,POST /trash,GET /trash,POST /trash/{folder_id}/restore):- A folder is marked
trashedin place. - Loose documents go into one "Deleted {date} {time}" wrapper per source folder.
- The subtree's pending and processing rows are cancelled in the same transaction.
- Filed artifacts pass
versions.guard_deletefirst. - Restore handles the " (restored)" rename and the re-queue at
PRIORITY_BULK. FOLDERSevents carry the ids.
- A folder is marked
- Purge (
purge.py,DELETE /trash/{folder_id},DELETE /trash):- Every subtree is set to
deletingfirst. Documents are then removed in batches of up to 500, each in its own transaction, then folders deepest first. - A
blob_tombstonestable (a new plain migration) gets a row for eachdocuments/<id>/andartifacts/<id>/directory as it is removed. orphan_directories.py::sweep_tombstonesruns at start.- An hourly lifespan task purges entries older than 30 days.
- Every subtree is set to
- Frontend:
- The Trash row at the end of the Library, with counts, size and purge date. Each entry has Restore and Delete now, plus Empty Trash.
- The tree's delete moves rows to the Trash with an Undo toast.
DELETE /documents/{id}keeps its permanent meaning for plugins. - This PR moves the Trash part of the design into
docs/architecture/documents.mdand removes the Known gaps line.
Each backend PR comes with tests for its steps from the proposal: scope exclusion at once, restore intact, a cancelled job no-oping at begin_job, batch size, deepest-first order, and a tombstone kept when a directory cannot be removed. Linked roots (4b) are out of scope.
Two questions before I start
- Is anyone already on this, or is it planned on your side?
- The proposal's status is
in-progress. Do you want anything changed in the Trash section first, such as the 30-day estimate or the "Deleted {date} {time}" wrapper name, or should I build it as written?
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]Library Trash (phase 4a of 01-sources-and-folders): taking it, if it is free[/-][+]Library Trash (the Trash part of phase 1 of 01-sources-and-folders): taking it, if it is free[/+]ybai08 commentedon Nov 4, 2026
A correction to my title and first line: in the proposal's Phases table, the Trash ("Trash, restore, batched purge and tombstone sweep") is part of phase 1, Folders in the Library. Phase 4a is "Link a folder: scan and reconcile". I had taken "phases 4a and 4b" from the status line near the top, which reads "The Trash and linking a folder on disk (phases 4a and 4b) are designed, not built". That line and the table disagree; I can fix the status line in the first PR if you like.
The rest of the plan and the two questions above are unchanged: is the Trash free to take, and should it be built as the proposal describes it?