feat(notes): compact the operation log and purge old tombstones
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m17s

- Background job at start and every 6 h: log entries older than 30 days
  (private notes: 7) are removed, documents.log_floor marks the boundary;
  clients behind it get resync and keep their queued changes
- Deleted blocks are purged 30 days after deleted_at via a "purge" log
  effect, so open editors drop them without reloading; a tombstone stays
  while a deleted child still points to it
- Text for a purged block becomes a new block at the end; inserts under a
  purged parent go to the top level (server and browser model)
- doc_op_results kept for 90 days; expired lease/session maps are swept
- Tests: storage, API, engine resync, simulation with compactions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sandrodachandClaude Opus 5.5 committed 2026-10-28 15:08:13 +01:00
1 parent aea4324c20
commit f26f286fb8
17 files changed
+653 -48

No files matched your search

+20
View File
@@ -195,3 +195,23 @@ func (s leaseSnapshot) HolderOf(blockID string) (string, bool) {
c, ok := s[blockID]
return c, ok
}
// Sweep drops expired leases and sessions of all documents and forgets documents nobody uses any more,
// so the maps do not grow with every note ever opened.
func (m *LeaseManager) Sweep() {
m.mu.Lock()
defer m.mu.Unlock()
now := m.now()
for docID := range m.leases {
m.prune(docID, now)
if len(m.leases[docID]) == 0 {
delete(m.leases, docID)
}
}
for docID := range m.sessions {
m.prune(docID, now)
if len(m.sessions[docID]) == 0 {
delete(m.sessions, docID)
}
}
}