feat(prune): R1 prune-reconcile pure core — (owned ∩ present) − referenced

Add REAPER-free/filesystem-free prune orphan-set core + additive
BankBook::referencedPaths() union query, with full unit coverage.
This commit is contained in:
2026-07-26 18:02:42 -04:00
parent b6464f78c8
commit 3cfa9239d2
6 changed files with 426 additions and 0 deletions
+17
View File
@@ -2,6 +2,7 @@
#include <algorithm>
#include <climits>
#include <unordered_set>
// bank_book implementation.
//
@@ -321,6 +322,22 @@ bool BankBook::hashReferencedElsewhere(const std::string& hash,
return false;
}
std::vector<std::string> BankBook::referencedPaths() const {
// Union across the whole book (pool first, then named banks in ordinal order —
// banks_ is kept ordinal-sorted). De-duplicate by exact string so a file a copy
// put in two banks appears once. Skip empty paths (they reference no file).
std::vector<std::string> paths;
std::unordered_set<std::string> seen;
for (const auto& b : banks_) {
for (const auto& s : b.index.all()) {
if (s.relativePath.empty()) continue;
if (seen.insert(s.relativePath).second)
paths.push_back(s.relativePath);
}
}
return paths;
}
// ===========================================================================
// JSON — writer
// ===========================================================================