Deleted files records: purge audit target, restores missing from the change feed #920

Closed
opened 2026-10-15 20:59:38 +00:00 by Cordy · 3 comments
Owner

Follow-ups from fix-911 (v0.6.345). Related: #915 (a grantee's deletion is recorded under the owner) and #916 (restore activity is recorded with the backend path).

  1. Purge audit: a person's own purge is audited as trash:<id>, not with the path of the item.
  2. Change feed: restores from Deleted files never reach it, so sync clients only see a restored file on a full re-scan. Restores happen below the changes layer.

To do: decide what the audit and the change feed should record, then add tests through the rig.

Follow-ups from fix-911 (v0.6.345). Related: #915 (a grantee's deletion is recorded under the owner) and #916 (restore activity is recorded with the backend path). 1. **Purge audit:** a person's own purge is audited as `trash:<id>`, not with the path of the item. 2. **Change feed:** restores from Deleted files never reach it, so sync clients only see a restored file on a full re-scan. Restores happen below the `changes` layer. To do: decide what the audit and the change feed should record, then add tests through the rig.
Author
Owner

Deep research (2026-10-19)

The full write-up, with sources, is in ~/cairn-work/scratch/b7e/backlog/research-b4.md §2 and §3.

1. Purge audit

  • Cairn today: a person's own purge records Path: trash:<id>. Once the sidecar is gone, that id points at nothing. Admin purge (manual-purge) and the sweep (auto-purge) already record the item's original path.
  • Others: Nextcloud's admin_audit, OpenCloud (actor, owner, path, file id) and Seafile all record what was destroyed. NIST AU-3 asks for "filenames involved", and DSV Art. 4 explicitly lists "Vernichten" (destroying).
  • Recommendation: use the manual-purge format:
    • the actor;
    • the original backend path;
    • a note with recorded as … when the path changed (for example after a space rename), plus the entry id.
  • No UI change.

2. Restores and the change feed (confirmed on posix and s3)

  • What happens: after a delete and a restore, the feed only shows the delete. A sync client removes the file and only gets it back on a full re-scan. Restores run inside the trash driver, below the changes layer.

  • Others:

    • Seafile makes a restore a new commit.
    • Nextcloud makes it a filesystem move with ETag propagation.
    • Dropbox shows a restore as an ordinary metadata entry.

    None of them treats a restore as out of band.

  • Recommendation:

    • Add a restore hook inside the trash driver. It covers user restores, admin restores, resumed space restores and the sweeper. Each restore records a write at the restored path; a folder copy already uses the same entry type.
    • Harden the feed filter so /spaces/<x>/.trash paths can never leak.
    • A whole-space restore needs nothing extra: the space comes back deactivated and appears to members through the listing when it is reactivated.
    • Update the change-feed docs.
  • Multiple instances: the journal is per instance, like every other write today. That gap is filed on #742; this change does not widen it.

Decisions: asked now (D4: path format).

## Deep research (2026-10-19) The full write-up, with sources, is in `~/cairn-work/scratch/b7e/backlog/research-b4.md` §2 and §3. **1. Purge audit** - **Cairn today:** a person's own purge records `Path: trash:<id>`. Once the sidecar is gone, that id points at nothing. Admin purge (`manual-purge`) and the sweep (`auto-purge`) already record the item's original path. - **Others:** Nextcloud's admin_audit, OpenCloud (actor, owner, path, file id) and Seafile all record what was destroyed. NIST AU-3 asks for "filenames involved", and DSV Art. 4 explicitly lists "Vernichten" (destroying). - **Recommendation:** use the `manual-purge` format: - the actor; - the original backend path; - a note with `recorded as …` when the path changed (for example after a space rename), plus the entry id. - No UI change. **2. Restores and the change feed (confirmed on posix and s3)** - **What happens:** after a delete and a restore, the feed only shows the `delete`. A sync client removes the file and only gets it back on a full re-scan. Restores run inside the trash driver, below the `changes` layer. - **Others:** - Seafile makes a restore a new commit. - Nextcloud makes it a filesystem move with ETag propagation. - Dropbox shows a restore as an ordinary metadata entry. None of them treats a restore as out of band. - **Recommendation:** - Add a restore hook inside the trash driver. It covers user restores, admin restores, resumed space restores and the sweeper. Each restore records a `write` at the restored path; a folder copy already uses the same entry type. - Harden the feed filter so `/spaces/<x>/.trash` paths can never leak. - A whole-space restore needs nothing extra: the space comes back deactivated and appears to members through the listing when it is reactivated. - Update the change-feed docs. - **Multiple instances:** the journal is per instance, like every other write today. That gap is filed on #742; this change does not widen it. **Decisions:** asked now (D4: path format).
Author
Owner

Decision (Nikola, 2026-10-19). All recommendations accepted.

  • Purge audit (D4 a): a person's own purge is audited the same way as manual-purge. It records:
    • the acting person;
    • the original backend path;
    • a note with recorded as … when the path differs, plus the entry id.
  • Change feed: a hook in the trash driver records every restore as a write at the restored path. This covers user, admin and resumed restores, and the feed filter is hardened against trash paths. A whole-space restore adds nothing. The change-feed docs will be updated.

Implemented in batch 4 (v0.6.351).

**Decision (Nikola, 2026-10-19).** All recommendations accepted. - **Purge audit (D4 a):** a person's own purge is audited the same way as `manual-purge`. It records: - the acting person; - the original backend path; - a note with `recorded as …` when the path differs, plus the entry id. - **Change feed:** a hook in the trash driver records every restore as a `write` at the restored path. This covers user, admin and resumed restores, and the feed filter is hardened against trash paths. A whole-space restore adds nothing. The change-feed docs will be updated. Implemented in batch 4 (v0.6.351).
Author
Owner

Shipped in v0.6.351 (PR #984). Both dogfoods run it. Live check, 2026-10-20: PASS.

  • Change feed, on both instances. I uploaded a file, deleted it, then restored it from Deleted files. GET /api/v1/changes from the cursor taken before the upload now lists:

    • write …/r.txt
    • delete …/r.txt
    • write …/r.txt (this is the restore)

    Before, the restore was missing from the feed.

  • Purge audit (files-bao). I deleted the file again and used Delete forever. The audit records {"user":"nikola-test","action":"purge","path":"/home/nikola-test/b4live/r.txt","note":"entry dm9puhi8x9av-2"}. Before, the path was trash:<id>.

Not seen live: whole-space and renamed-space purge entries, and restores finished by the sweeper. Those are covered by tests on posix and s3. The test data is removed.

**Shipped in v0.6.351 (PR #984). Both dogfoods run it. Live check, 2026-10-20: PASS.** - **Change feed, on both instances.** I uploaded a file, deleted it, then restored it from Deleted files. `GET /api/v1/changes` from the cursor taken before the upload now lists: - `write …/r.txt` - `delete …/r.txt` - `write …/r.txt` (this is the restore) Before, the restore was missing from the feed. - **Purge audit (files-bao).** I deleted the file again and used Delete forever. The audit records `{"user":"nikola-test","action":"purge","path":"/home/nikola-test/b4live/r.txt","note":"entry dm9puhi8x9av-2"}`. Before, the path was `trash:<id>`. Not seen live: whole-space and renamed-space purge entries, and restores finished by the sweeper. Those are covered by tests on posix and s3. The test data is removed.
Cordy closed this issue 2026-10-20 13:58:10 +00:00
Sign in to join this conversation.
No labels
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Cordy/Cairn#920
No description provided.