Skip to content

§9. Mounts, .rehuco, and Cross-Box Visibility

[[[mounts-and-storage]]]

§9.1 The problem

[[[mounts-and-storage#the-problem]]]

One share, many machines, many paths. The same folder on the NAS is U:\Tutorials on the Windows PC, /System/Volumes/Data/mount/DATA/Tutorials on the Mac mini and /mnt/nas/Tutorials on a Linux box; a folder on one PC's own disk is reachable from the others only once that PC shares it, under yet another path. The catalog must know that these are one place, keep each machine's cache current when another machine changes a file there, and open the same .rehuco on every one of them.

§9.2 Identity is the UUID, not the path

[[[mounts-and-storage#uuid-not-paths]]]

A resource reached by two paths — two machines' mounts of one share, a backup on a shelf, a borrowed copy — is recognized as one resource because its .rehu UUID matches, never by guessing that one path corresponds to another ([[instances-and-dedup#uuid-is-lineage]]). A key is a location, not an identity ([[nodes#access-seam]]).

A rename is a filesystem operation on the machine that issues it. Within one process a job holds a ResourceLocation rather than a path, and the rename rewrites it (#241); the other views follow through the notifier's Moved event. Another machine learns of the rename the same way every change travels: the SMB server reports it, that machine's notifier announces it, its cache follows ([[mounts-and-storage#out-of-band]]). A request that still names the old path arrives at a file that is no longer there and is refused with the reason, not guessed at. There is no cross-machine rename request and so nothing to coalesce.

§9.3 .rehuco: the user's roots, mapped per machine

[[[mounts-and-storage#rehuco-scope]]]

A .rehuco file names the folder roots to catalog, and is shareable across machines: it may sit on the share and be opened from every box, or be copied around. By default it is a local file — New proposes the app folder and Open starts there; putting one on the share is the user's choice, and nothing else changes. It declares:

  • the roots, each with a stable id the cache keys its rows on, a label (defaulting to the folder's name, made unique with a suffix on a clash; what the browser shows and what a folder filter addresses, folder="<label>/<relative path>", [[plugins#browsers]]) and a machine-independent location (below) — nothing that is a fact about one machine; where each machine finds a root is that machine's mapping, kept apart. Each root is a .rehuroot file of its own ([[mounts-and-storage#rehuroot]], format 4), and the .rehuco holds only an ordered list of references to them;
  • which plugins ([[plugins#overview]]) to load;
  • a home for each kind of grouping-entity document — creators, collections, learning paths ([[plugins#grouping-entities]]) — as homes: {"creator": {"root": <root id>, "path": <relative path>}, "collection": …, "learning_path": …}, each a folder under one of its roots, the three free to be one folder. A new or materialized entity of that kind is created there, and the location editor offers it as a move. It is set from a root's or a folder's context menu in the Root Catalog panel, Set as Home for Creators / Collections / Learning Paths, and that row carries the role's glyph; a home whose root is removed, or whose folder is gone, is unset and the panel says so. With no home set, creating an entity asks for one first. Discovery of existing entity documents needs no home — it is type-based, so the scanner finds them wherever they sit in any scanned root.

A root's identity is its location; what differs per machine is its mapping. The location is the same on every box: for a share, the server and share path (//nas/data/Tutorials), read from this machine's mount table when the root is added (WNetGetConnection on Windows, the mount table on macOS and Linux); for a folder on one machine's own disk, that machine's name and path (//ryzen-5600/d/Downloads/FOO). The host is lower-cased, and a server spelled by name on one machine and by address on another is two locations.

{
  "format_version": 4,
  "id": "…",
  "roots": [ { "file": "tutorials.rehuroot" } ]
}

A mapping is kept per machine, in that machine's data folder, never in a shared file. It says where this machine finds a root and carries what is a fact about this machine rather than about the root — the folder and the storage — plus whether the user chose to skip the root:

{
  "format_version": 2,
  "roots": {
    "<root id>": { "path": "U:\\Tutorials", "storage": "network" },
    "<root id>": { "skipped": true }
  }
}

One machine writes it, so it takes no lock. The agent and the node of one machine read the same file ([[nodes#node-actions]]), so a root mapped in the agent is served by the node. A root's id is the same in every catalog that lists it, so a mapping is keyed by the root id alone ([[mounts-and-storage#rehuroot]]): moving or renaming a .rehuco keeps it, and a machine that is renamed loses nothing, since nothing in a shared file names it.

  • The storage kind is detected, not declared — local disk, network share, removable drive or disc — from the drive type on Windows and the mount table elsewhere, when the mapping is written; the notifier picks its backend from it ([[mounts-and-storage#out-of-band]]) and retention takes its default from it ([[mounts-and-storage#durable-retention]]). There is no user override: the system marks them.
  • Opening the file on a machine with no mapping resolves what it can and asks for the rest. A root whose server and share this machine mounts, or whose location names this machine, is mapped from the mount table or the drive table without asking; the rest are listed in a wizard with Browse and Skip per row. A skipped root stays visible but disabled — not scanned, not browsed, not served by the node — and is not asked about again; a root neither mapped nor skipped (the wizard was canceled) is asked again at the next open. Map… in the Roots view maps a root later, once the share is mounted or the folder shared, and replaces a skip. A root a machine cannot reach by nature (another box's local disk, not shared) sits there the same way.
  • The .rehuco changes only when the roots do — one added, removed or moved; a relabel writes the root's .rehuroot instead — so two machines rarely save it at once, and mapping a root never writes it. The save goes through the same lock as a .rehu ([[sync#overview]]) and then compares the file with what this machine last read or wrote: if another machine changed it since, nothing is written, the catalog is read again and the user is told to repeat the edit. There is no merge of structural edits.
  • Format 2 (plain paths and a user-declared storage) is not migrated: a root's location is computed on the machine that finds the folder, so the file is made again by adding its roots to a new catalog. Opening one says so.

Per .rehuco, not per machine singleton. A machine may keep several .rehuco files — each a set of roots browsed together — and the agent opens one at a time ([[data-model#local-file-trio]], #371). Removing a root asks first, states that its files stay where they are, and drops only the reference and the root's cached entries ([[data-model#cache-schema]]): its .rehuroot and this machine's mapping of it stay, since another catalog may list it.

Roots do not overlap within one file ([[multiplicity#instances]]), and no root has an owner.

§9.3.1 .rehuroot: a root as a file of its own

[[[mounts-and-storage#rehuroot]]]

With a root's id, label and location inline in the .rehuco, the same folder listed by two catalogs is two roots: two ids, two mappings, two caches, and nothing that is a fact about the root — how it is laid out — has a home at all. So a root becomes a file of its own, <name>.rehuroot, and the .rehuco becomes an ordered list of references to such files and nothing more about a root: its role is to aggregate and order roots.

{
  "format_version": 1,
  "id": "…",
  "label": "Tutorials",
  "location": "//nas/data/Tutorials",
  "layouts": { "*": ["*"] },
  "fallbacks": { "authors": "Unknown" }
}
  • It never lives inside the root. [[mounts-and-storage#fingerprint-map]] retired files dropped into the user's folders, and that holds. A .rehuroot lives beside the .rehuco files — by default the .rehuco's own folder — and a .rehuco names it by a path relative to itself: "roots": [ { "file": "tutorials.rehuroot" }, … ], format
  • It is saved as the .rehuco is: under the lock, compared with what this machine last read, refused when another machine changed it meanwhile.
  • id is the root's id, minted once and shared by every catalog that lists the file. Mappings are therefore keyed by root id alone — {"format_version": 2, "roots": {"<root id>": {"path": …, "storage": …} | {"skipped": true}}} — one mapping per root per machine, whichever catalogs list it. The cache stays per catalog (<rehuco id>.rehudb), so a root two catalogs share is scanned into both; a cache per root is the follow-up ([[appendices.open-questions#still-open]]), not this.
  • layouts says where a record of each type lives under this root: a map from a resource type's main key, or * for any type not named, to a list of path templates (#638; a plain string reads as a list of one, and a save writes lists) — each the Locations grammar ([[plugins#tutorial-plugin]]'s placeholders, {site}, {site_id} and {author_0} (the first author alone, #707) among them, {{ … }} optional groups, {count} where the type declares it, the Location Replacements applied after) plus / as a level separator and {buckets}, a level spreading the next over prefix buckets ([[mounts-and-storage#buckets]]), each segment sanitized as a name is today and the separators kept; a segment that starts with a dot refuses the layout for that record (#680). The value * means keep the record's current folder name, at the root's top, under the record's own root too (#643); the place the record sits at is a row of its own in the path row. The list's order is the order the path row offers the places in: a template that cannot render for a record is skipped, and two rendering one place offer it once. A type's own list replaces the * one for that type. The default {"*": ["*"]} admits anything under its current name; {"tutorial": ["{authors}/{title}{{ [{year}]}}"]} groups tutorials under their authors and admits no other type — a type with no entry and no * cannot be moved here.
  • fallbacks names what a placeholder renders as when the record leaves it empty — outside an optional group only: a group whose placeholder is empty drops out, a fallback for it notwithstanding. An empty placeholder outside an optional group with no fallback forbids the root for that record, and the renderer says why; the path row offers no place in that root ([[plugins#tutorial-plugin]]). A field's own / opens no level.
  • A reference whose .rehuroot is missing or unreadable — a file on a share that is offline, one deleted by hand — does not refuse the catalog: the root is listed grayed under its file's name, with one row saying its file cannot be read and the reason as the tooltip, offering neither Map… nor a name to edit; the reference survives a save, and Remove Root drops it. The cache keeps what it held of that root, matched to it by the file, as it keeps an offline root's: its records still show, grayed, and nothing scans or watches it. Only Remove Root clears them; a reference this machine never read holds nothing to keep.
  • Adding a root is picking existing .rehuroot files, or a folder, which makes one with a layout chosen from the default root layouts the settings keep ([[plugins#rehuco-dock]]), many at once; the Roots view edits a root's layouts and fallbacks in its edit mode, with its name. A folder's new root file is named after its location (#626): its segments, // dropped, each sanitized as a name is, joined by -- -- nas--data_14t--DATA1--TUTORIALS.rehuroot -- and not after its label, so two catalogs naming one root differently still agree on the file; a name taken is suffixed, one typed or browsed to wins, and files already written keep their names. Root files and root folders compare case-folded on every platform (#629), since a .rehuroot can land on NTFS, APFS or a share, all of which fold case: a new root file for //nas/data/blender beside a NAS--data--Blender.rehuroot is nas--data--blender (2).rehuroot, spelled as its source, and a folder in another case is the same root. A resource's key and the cache's path keys keep the platform's own rule ([[nodes#access-seam]]).
  • Nothing is migrated, as format 2 was not: a format-3 .rehuco is refused with a message saying to add its roots again, and a format-1 mapping file is set aside, as root-mappings.format-1.json. Overlap is checked across the catalog's .rehuroots as it was across its roots.

§9.4 The node serves what its machine reaches

[[[mounts-and-storage#nodes-serve-mounted]]]

The node has no roots of its own ([[nodes#two-roles]]): it reads the user's .rehuco from the shared app folder and serves every root this machine has a working mapping for — a local disk, a mounted share — plus its borrow store. A root mapped but offline shows as offline on the web pages as it does in the agent; an unmapped one is not served.

§9.5 The file notifier: one change source, and the catch-alls behind it

[[[mounts-and-storage#out-of-band]]]

Every view in the app — the cache and its browsers, the Roots view, the Files dock, open documents — learns that something on disk changed from one source, the FileNotifier in rehuco-core, publishing on the ChangeFeed ([[nodes#access-seam]]). Nothing announces its own writes to the others any more: a save, a screenshot written, a checksum record, a change made by another machine or by hand reach the views by the same path, as what the disk says happened. One exception: a rename this machine runs is published at once by the rename coordinator, with its exact plan, so no holder keeps the old path while the notifier catches up; the notifier's own report of it arrives after and finds nothing at its sources to move. The notifier runs per root, with a backend chosen by the mapping's storage kind, measured in #502:

Root on Backend Measured
A local disk or removable drive Native events (watchdog: ReadDirectoryChangesW, FSEvents, inotify), recursive Ordinary on all three OSes
An SMB share Our own SMB session: smbprotocol opens the root on a session of its own and waits on CHANGE_NOTIFY with the tree flag; the server answers from its inotify watches, so every writer on every client is seen. Data still flows through the OS mount; this session carries notifications only. Complete against the TS-230, mini2 and esprimo: create, write, rename (an old-name/new-name pair), atomic replace, delete, ~5 ms after a local write, ~100 ms after another machine's; a 2000-file burst delivered in full. Needs the share's credentials: the Windows logon serves as is; on macOS and Linux the agent asks once and keeps them in the OS keychain.
A share without credentials, anything else, any backend that failed Polling of the cache's known records by stat signature, on a timer The floor, never the design: a stat per record over the LAN is 1–3 ms, so 10k records sweep in 10–30 s at a few minutes' interval.

The OS client's own watcher on a share is not a backend: on Windows it works (ReadDirectoryChangesW is forwarded to the server) but drops events under load with no overflow signal; on macOS FSEvents over SMB produced four nameless "folder modified" events for a 500-file burst; on Linux inotify on cifs sees only this machine's writes.

Rules:

  • Events are debounced and coalesced into the feed's Changed, FolderChanged and Moved; a rename's pair becomes one Moved with the executed plan — the (source, destination) pairs — and each holder applies a path at or beneath a renamed source lands at the same offset beneath its destination to everything it holds, which covers every scoping case ([[data-model#resource-scoping]]).
  • A notify-buffer overflow publishes RootStale for that root, and every holder re-reads it as F5 does — the root is scanned again. On a local disk, too: ReadDirectoryChangesW reports an overflow as a successful read of zero bytes, which watchdog passes over in silence, so the notifier reads that itself.
  • The notifier runs on a daemon thread and survives the mount dropping ([[mounts-and-storage#offline-mounts]]): a backend that fails falls back to polling, which also says whether the root can be reached — published as RootReachable, and written into the cache — and the backend is tried again every 30 s while it can; once it is back, the root is RootStale, since a sweep finds only the records it knew. A root that cannot be reached keeps its rows in the browsers, grayed and not opened; browsing what is retained of it is [[mounts-and-storage#durable-retention]]'s.
  • The folder of a document opened from outside every root is watched too, with the same backends: everything beneath a directory-scoped record's folder, a file-scoped one's folder alone, a folder already covered by another's watch not again.
  • A watch never holds a rename up. Measured on NTFS with a live watch: a folder beneath the watched one renames, and so does the watched folder itself; only the watched folder's parent is refused, its handle being open beneath it. A root's watch therefore stands in no rename the app makes — it renames nothing above a root — though a rename of the folder holding a root, in Explorer, waits for the app to close. An open document's folder watch lets go for every directory rename and watches again once it is over. Samba holds no such lock: a share's session never refuses one.
  • Verify-on-access and the incremental scan stay as the catch-alls. The cache stores each .rehu's stat signature and content hash ([[data-model#scan-and-staleness]]); opening, browsing to or serving a resource re-checks it, and the version-aware incremental scan finds what no event and no visit did. A polled root relies on them.

Browsing never blocks a rename. A directory-scoped rename on NTFS fails while any handle is open beneath the directory, so no browsing view or scan holds one between reads: every directory listing is one chunk under the rename coordinator's hold, closed before the next, and yields when a rename asks (#241, #372, #378).

§9.6 Progress follows the user, not a node

[[[mounts-and-storage#node-handoff]]]

A user may watch a tutorial in the agent, carry on from the tablet through a node, and come back. There is no handoff between nodes to design: progress is written every few seconds (and on pause, seek and stop) into the user's sidecar on the share ([[field-schema#watch-progress]], [[data-model#single-file]]), and every player reads it from there before resuming — the agent directly, the web page through its node — so whoever picks it up is at most seconds behind.

§9.7 Example deployment: several machines on one share

[[[mounts-and-storage#example-deploy]]]

The PC, the Mac mini and a Linux box all mount the TS-230's share; each runs its agent over its own .rehudb and, while its user is logged in, its node. "Who serves a resource" needs no answer: every machine reaches the files itself, and the node a tablet talks to is the one its user chose ([[nodes#node-actions]]). The machine that travels takes its borrowed copies along and serves them from its own node with everything at home switched off ([[borrowing#vacation-topology]]). The TS-230 runs nothing of rehuco's ([[packaging-deployment#ts230-as-nas]]).

One thing several machines on one share cannot do: yield to each other's renames (#241). Within one process a rename asks the jobs reading beneath it to close their handles, and they do so at the next chunk boundary — measured at ~7 ms. That request does not cross a machine boundary: a directory rename issued on box A while box B reads inside it over SMB can be refused by the server, for the one chunk in which B's handle is open. File-level operations are fine regardless — readers open sharing every right including delete, so renaming or replacing the file being read succeeds from any machine, with one caveat measured in #503: the macOS client keeps a closed file's handle for a while, so a replace from another machine right after a Mac read may need a retry. The rename reports the refusal and offers to retry; there is no coordinator across machines and none planned.

§9.8 Configurable durable retention of offline-media metadata

[[[mounts-and-storage#durable-retention]]]

.rehuco can opt in, per root and per machine (it is in the mapping), to keeping a durable local copy of that root's metadata — so a root whose medium sits in a drawer, or whose share is switched off (the library shelf, [[borrowing#library-shelf]]), stays browsable. The UI calls this caching a root; the spec keeps retention, because everywhere else here a cache is disposable and this copy is not (below).

  • Why: offline media are painful to rescan one-by-one, and a switched-off NAS's content would otherwise drop out of the catalog. Retaining their metadata locally keeps them browsable while disconnected, and — because the retained copies are ordinary local files — keeps them present across a full cache rebuild ([[architecture-design#why-distributed]]).
  • A default by the detected storage kind, nothing else to configure:
Root Retention
Removable (USB stick, external drive, CD/DVD) Forced on — removable by definition, so it must stay browsable without its medium
Network share On by default; the user may turn it off for a share known to stay online, where retaining only buys speed
Local disk Off — the disk is always there to read

It is per root, not per resource: keeping one resource whole on this machine is a borrow ([[borrowing#another-instance-role]]), not retention. - What is retained is enough to browse, never to watch. Per resource: the .rehu itself, the user's own sidecar, its screenshots copied as they are, and its file structure: every file's relative path and size, plus each video's duration and resolution. That is what lets the browser, the Description View and the Files dock show an offline resource, read-only. No content file is copied; watching a resource whose source is offline needs a borrow. - Durable, not disposable. A removable root cannot be rescanned while its medium is absent, so its retained copy is the only one there is. The store therefore sits beside .rehudb ([[data-model#local-file-trio]]), never inside it: a cache rebuild must not wipe it. - Per-user state for a source that can never be written — a CD/DVD, a read-only share — is tracked on the retained copy, which stays writable for per-user data only ([[field-schema#watch-progress]]). - Retained copies are read-only stand-ins for the details ([[offline-editing#overview]]); a per-user edit made against one is a queued save ([[sync#apply-payload]]). - Staleness is resolved by comparison, not blind overwrite. When a retained source is reachable again, the notifier and verify-on-access re-pull only what moved ([[data-model#scan-and-staleness]]).

§9.9 Tolerating offline mounts without blocking

[[[mounts-and-storage#offline-mounts]]]

An agent and its node run while the boxes whose shares they mount — the TS-230 in particular — are powered off or unreachable for long stretches. A mapped root is therefore frequently present in .rehuco but currently dead, and everything else must keep working without stalling on it.

The hazard is concrete: on a dead SMB/NFS mount, ordinary filesystem calls (stat, open, directory listing) block for the mount's timeout — tens of seconds, or indefinitely with a hard mount — so code that naively touches a mounted path wedges whatever thread it is on.

Rules:

  • Treat every mounted root as possibly-offline. Reachability is runtime state, not config; never assume a mount is live because it is declared.
  • Probe reachability cheaply and out-of-band. Check liveness with a single bounded-timeout operation (a stat of the mount root) on a worker, not on the GUI thread or a request path. Cache the up/down result and back off before re-probing, so a dead mount is consulted rarely and a flapping one causes no churn.
  • All mount I/O is timeout-wrapped and off the hot path. File reads through a mount run on workers with their own deadlines, so one dead mount never blocks the window, a request, or another mount's traffic.
  • Offline ⇒ show last-known, read-only. The browser shows the cached rows, the Roots view the retained structure ([[mounts-and-storage#durable-retention]]), with status offline, showing last-known; a save for a record there waits in the queue ([[sync#apply-payload]]).
  • Recovery is the notifier's, not a rescan's. When a probe succeeds again the share's notification session is re-opened and verify-on-access catches up on what was touched meanwhile; the mount coming back forces no full rescan.

The agent applies the same rules to what it remembers (#464). At start, the recent files, the recent root catalogs and the session's open documents are each judged present, gone or offline (borco_core.path_presence). A fixed local drive is checked at once — it answers, so a missing file is gone. A share, a removable drive or a disc is classified without touching it (the drive letter's type, the mount table), its server is asked with a 0.3 s connection attempt rather than a stat (measured: a stat under a switched-off SMB host blocks 21 s, the connection attempt 0.3 s), and only a server that answered is stat-ed. All of it runs on daemon threads, so neither the start nor the quit waits for a dead mount. In the recents, gone is forgotten; offline is kept, shown disabled, and asked again next run.

Every session document comes back with the window, in its place (#698). A document on a fixed local drive is restored as before, unread until its tab is shown; one whose file is gone was forgotten by the check above. A document on a share, a removable drive or a disc gets its dock too, and is held: locked, with nothing read of it, until its storage has answered. So the saved layout is applied once, with every dock in it, and the tab order, the splits and the focused document do not depend on how fast a share answers or on the order the answers come in. Nothing of a held document reads its storage, whichever of its panels the reader opens meanwhile: the On Disk, Files, Checksums and video tree panels wait as the document does, and catch up when it is let go. What the storage says decides what happens to the held dock, and the reader decides the rest:

  • It is there: the dock unlocks where it stands, and is read when its tab is in front, as any restored document.
  • It does not answer: the dock stays locked and says so. It is asked again every 10 s while it is the tab in front, a maximized view of it included, and each time its tab is shown, and unlocks when it answers. The reader closes it or leaves it; left open, it is saved in the layout like any dock, so a run with the share off costs it neither its place nor its entry.
  • The file is gone: the file was deleted, as a local one found gone at start was: its dock is closed and the recents and the session forget it. Nothing of it had been read or edited.

A maximized view the session remembers for a held document is stood in for on its surface by a notice that says what is being restored and what it waits for ([[plugins#session-restore]]). The log says how many documents were restored, how many of them wait, and what each one's storage answered.

Deployment note: mount the shares soft / with short timeouts so failed syscalls return an error quickly rather than hanging. Hard mounts defeat this discipline.

§9.10 Fingerprint files

[[[mounts-and-storage#fingerprint-map]]]

Retired. Fingerprint files dropped into roots let nodes discover that two of them served one storage and how the paths mapped. The .rehuco's explicit location per root ([[mounts-and-storage#rehuco-scope]]), resolved through each machine's mount table, answers the same question without writing anything into the user's folders.

§9.11 Adding a root

[[[mounts-and-storage#folder-add]]]

Retired as a primary/remote declaration; there is no owner to declare ([[multiplicity#instances]]). Adding roots is picking folders and existing .rehuroot files, many at once ([[plugins#rehuco-dock]], #578): a folder's location is read from this machine's mount table and it becomes a new .rehuroot; an existing file keeps its own, and is mapped where it resolves here or left unmapped. A pick that overlaps a root already listed, or one picked before it, is refused, through links too; the rest are added with one save, and this machine's mappings written ([[mounts-and-storage#rehuco-scope]]).

§9.12 Measuring a machine's throughput

[[[mounts-and-storage#node-benchmark]]]

Retired as a grading scheme that fed a dispatcher. The one decision it would have driven — where a checksum run executes — is settled by locality instead: a node that reaches the root's disk locally may be handed the job ([[nodes#node-status]]). What remains is the checksum algorithm benchmark in rehuco-core's tests, which chose the hash ([[data-model#checksums]]).

§9.13 Verified copies and moves

[[[mounts-and-storage#safe-move-rename]]]

Note

Implement the cross-filesystem move with Opus, not the auto-switched Sonnet. The copy → verify-checksum-on-target → delete-source-only-if-verified sequence is data-loss-sensitive: a wrong ordering or a skipped verification can delete the only good copy. Override to /model opus for the cross-FS path.

The system chooses how to perform a move/rename rather than assuming:

  • Rename or copy is decided up front (#339). The same local volume, or the same \\server\share however this machine reaches it (a UNC path or a drive letter mapped to it), is a rename: a near-instant metadata operation, including over SMB, where the rename is server-side ([[packaging-deployment#ts230-as-nas]]). Anything else is a copy. A rename the operating system refuses as crossing devices (EXDEV, ERROR_NOT_SAME_DEVICE) becomes the copy, so two roots on one share or one disk move at once and a wrong guess costs nothing.
  • A rename is verified when the Files page asks — on a local disk (off by default), on a network share (on): verify, rename, verify, as a task. Unverified, it runs at once, as the move in place within a root always has.
  • The source must be checkable first (#339). A copy can only be proven against what the record claims, so the record must exist and cover every content file the move carries. A missing record, or files it does not cover, is refused with the remedy — unless Create missing checksum on verify is on, when the source verify writes them from the source's own bytes. With check the original before copying on (the default), the source is verified in full before anything is copied.
  • Cross-filesystem moves are checksum-gated (hard rule): verify the source against its checksum record → copy → verify the checksum on the target → delete the source only if verification passes. An interrupted move leaves the source untouched and the partial target resumable, so it never loses data. The target check adopts nothing: a file there the record does not list fails it. Files no checksum covers (the .rehu, screenshots) are compared byte for byte before the source goes.
  • The copy is resumable, per file. A verified copy that stops — the NAS switched off, the laptop closed, a quit — picks up where it was: a target file whose hash already matches the record is not copied again, and a partial one is copied whole. The .rehu is written last, so the target is a record only once complete. Resuming inside one file from the bytes already on the target, which is what rsync would have bought and the one thing it would have ([[appendices.post-mortem#architecture]]), is #632's.
  • The source stops being a record on the GUI thread, inside the rename barrier, so a video playing from it lets go first, and every holder of its paths — the open document, a queued save, the cache's rows — follows the announced move to the copy. Only the quick part runs there: the source is listed once and must be exactly as the job's own thread last compared it (the same files, sizes and dates), then its .rehu and .checksum go. The slow parts stay on the job's thread — before it, comparing the files no checksum covers and copying again what changed; after it, a kept cleanup phase removing the rest, so a quit in between still removes it. A source found changed is compared again; a reader that does not let go in time, a save not landed, a lock held elsewhere make the move wait, not fail.
  • An end that goes away makes the move wait, not fail (#634). Whatever a phase fails with — an I/O error, or a check that could not read what it checked — each end is asked whether it answers, through its root's folder and the 0.3 s connection attempt ([[mounts-and-storage#offline-mounts]]), never a stat. One that does not makes the move wait in the queue as a save does, for as long, its row naming the end; its phase and its copy are kept, and the retry goes on from the first file not yet whole. The cleanup asks the source before it removes and again after, whatever the removal reported: a share that is off reads as nothing there, which a removal takes for already gone. A rename whose check afterward could not read its share waits in that check, and makes it again. A failure with both ends answering is what it says: a refusal of the disk (access denied, disk full) fails, a verdict refuses. The check before every start lets a record whose share does not answer be tried, so the wait carries on by itself.
  • Each step says it ended (#713), in one INFO line led by the move's label, with its count and its place -- counts only, never a line per file: the checksums verified before copying, the files copied (what this run wrote and its size, and apart what an earlier run had written) to the destination folder, the checksums verified after, the files no checksum covers compared byte for byte, and the files and folders of the original that are gone from its folder -- the whole original, whichever step or earlier run took each -- with how many files and folders could not be removed. A rename says renamed with its two places, and its two verifies when the Files page asks for them. A run that goes on from a later phase, or starts over with an earlier copy kept, says so first; a canceled run says canceled, with where its copy stays when it was kept, and a copy taken back says what was removed. A wait and a pause with a reason are the queue's own lines.
  • The document stays editable while its move runs, and the record may be renamed: the copy holds its record and every file as tracked locations, so its reads follow the rename.
  • A cancel removes what the copy wrote and the folders it made, and nothing that was there before, for as long as the source is whole — whether the job runs or sits paused, when the queue tells it so ([[appendices.task-queue#kept]]). The Tasks dock asks first (#634): Cancel offers removing the partial copy (the default) or keeping it, for a Retry to go on from; clearing a failed or canceled move that still holds one asks the same, since a copy left behind blocks a new move to the same place. A copy whose destination does not answer is never removed through it: the question says it stays, for the owner to remove by hand. A retried move starts over from its source check with its copy kept, and is asked about there too. A refusal always takes the copy back: a copy that did not match its record, a source that did not verify or changed under the copy — nothing unverified is left at the destination. A copy stopped by anything else (an end gone, a pause, a quit, a failure) is kept, to resume from. What the copy wrote is kept relative to the folder the record lands in, so it is still found after the destination root is mapped elsewhere.
  • Once the source stopped being a record, the cleanup always runs. The copy verified, so a cancel past that point takes nothing back: a job given up on in its cleanup phase finishes removing the source instead.
  • A cleanup that could not remove everything keeps its listing (#712), and the move ends done but not clean. Retry then runs that cleanup again and nothing else — no check, no copy — and ends clean once all of it went, or not clean again with what is still there. The listing is saved with the queue, and so is where the record was, for the Tasks dock to show. What the move says of them is short whatever the count (#708): up to three are named with the system's reason, more are counted by kind and grouped by reason, with the first three named and a pointer to the log, which holds one WARNING per item. A named item's path starts at the folder the record was in, which the removal's line and the row's Show Source give; a WARNING carries the whole path. The task row, the log line and the banner read the same text.
  • A read-only original is removed too (#711). Archives carry the modes and attributes of what they stored. Windows refuses to remove a file or folder whose read-only attribute is set; POSIX asks the folder holding it, so a file in a read-only folder is refused whatever its own mode. A refused removal makes the path writable and tries once more, and makes the folder holding it writable too when that folder is the record's own, one the removal takes as well; it gets its mode back right after. The folder holding the record's own folder, a file record's folder and the root are never changed: a record's folder in a read-only one stays, emptied, and is reported. What still refuses (a file another program holds open, a folder not empty) gets every mode back and is reported, as before. A cancel's removal of the copy and the buckets a join empties (one customized in Explorer is read-only) follow the same rule; the folders a move in place leaves empty are removed when read-only, never made writable to remove one inside. A folder a move left that holds only excluded files (.DS_Store, Thumbs.db, the user's own patterns) is empty (#714): they go to the Recycle Bin when the setting is on and a bin can take them, and are deleted for good otherwise, read-only or not, with no question; then the folder goes. One holding anything else keeps them. A path found gone once refused is gone, not refused. The copy itself is written afresh and its folders made, so it is never read-only, whatever the source was: its .rehu and sidecars stay writable for a later save, rename or delete.
  • A record holding a symbolic link or a junction is not copied. A copy neither follows a link nor carries one, so the move is refused naming the link, and anything already transferred is removed. A rename on one volume moves the folder whole and is not affected.

One verified copy, three uses (#339). The sequence is built as a reusable verified copy, and the moves and borrows are made from it:

Operation Built as
Move to another filesystem verified copy, then delete the source only if the target verified (#339)
Borrow onto a machine verified copy into that machine's node's borrow store, no delete ([[borrowing#another-instance-role]])
Return verified copy back of what changed (the sidecars, possibly the record), then the copy is removed

The bytes travel over the mounts, read by the machine doing the copy; a node with local access to one end may run the verify there ([[nodes#node-status]], #632). The job records each end as a root and a root-relative path, never an absolute path, so it survives restarts and a machine's remapping — except a source under no root (a record opened from outside every root), which has no root to be named by and is recorded by its absolute path.

A file record's checksum entries are its files' own names, so renaming it — in place, by a move, or into its copy — renames its entries with its files (#339); a folder record's are relative to its folder and never change.

§9.14 Prefix buckets: many small records in one root

[[[mounts-and-storage#buckets]]]

A store library ([[assets]]) is thousands of file records, each a .rehu and a few screenshots, with no folder of its own. Left flat that is tens of thousands of files in one directory, which every file manager and every share handles badly. So a layout ([[mounts-and-storage#rehuroot]]) may spread a level over buckets named by the start of its entries' names, one character more per level (#680):

fab/
  .rehubuckets
  0/
    .rehubuckets
    00/
    01/
      01abc.rehu
  a/
    a0f3.rehu

It is one more placeholder in the Locations grammar, not a second placement system: {buckets}, a level of its own, which spreads the level after it -- a record, or a folder of records -- over prefix buckets. Any type's layout may name it, as often as it likes, but never inside an optional group, never as the last level, and never right after another {buckets}; a rename pattern, which names one level, refuses it. Beside it, {site} is the primary source's publisher, which a scraper fills with its site's name ([[assets#site-id]]), and {site_id} that source's id. These are all layouts the owner uses:

Layout What is bucketed
{site}/{buckets}/{site_id} a store library's records, by their ids
TUTORIALS/{buckets}/{title}{{ - {authors}}} records, by their titles
AUTHORS/{buckets}/{authors} - {title} records, by their authors
{publisher}/{buckets}/{authors}/{title} author folders, each moved whole with its records
{site}/{buckets}/{authors}/{buckets}/{title} author folders, then the titles inside each
  • A folder that has been split holds a marker, an empty file .rehubuckets. An unmarked folder holds entries; a marked one at depth n -- its own prefix n characters, the layout's folder 0 -- holds buckets named by n+1 characters, and only those entries too short to descend, which can never be named like a bucket. A folder named .rehubuckets keeps its parent a plain folder that is never split; a marker file's content is ignored.
  • A folder holds entries until it passes the limit, then it splits. Each entry long enough moves into the deepest bucket of its name, and every bucket that then holds more than the limit splits the same way. A small library stays flat, and only the crowded prefixes grow deeper.
  • A bucket is built aside, then renamed into place. Only a folder whose name is a bucket's own length could be taken for one, so before the marker is written each such folder moves into a temporary bucket, .rehubuckets-tmp-<prefix>-<token>, which is renamed to its prefix once the marker is there: a tutorial folder ab in a crowded a/ ends at a/ab/ab. A folder holding a temporary bucket is a split under way.
  • Every step is one rename through the rename barrier ([[mounts-and-storage#safe-move-rename]]): a file record with its sidecars, a folder record, or a folder with every record beneath it. So a stop between two steps leaves every record whole and in one place, the cache and an open document follow each move as they follow any rename, and settling the folder again from the disk alone finishes the split. A record locked by a write elsewhere, or a reader slow to let go, makes the split wait, as a move waits.
  • An entry's place follows from its name and the folders there are: down every split folder to the bucket of one more of its characters, made when it is missing; a bucket being built is landed in under its temporary name. Nothing is looked up and nothing is stored about where an entry went.
  • A folder record is never a bucket, however it is named: one put by hand where a bucket of its name would be is an entry, and the next split puts it into that bucket. Nor is a system's folder (a Recycle Bin) an entry.
  • Names compare case-folded, as root folders do. A prefix no folder may be named by -- one ending in a dot or a space, or one the sanitize step would change -- makes no bucket: its entries stay where they are.
  • The limits are on the Files page, under Moving records: a folder splits above 200 entries by default, never under 50, below which the tree deepens without any folder becoming easier to read; and a split folder is joined back at or below 100 by default, never above half the split limit, so a folder never splits and joins back over one record. Each move asks the split limit as it settles, never captured; a rebalance works with the two it was started with.
  • No location starts with a dot, buckets or not: a level rendering one refuses the layout for that record, a rename suggestion rendering one is not offered, and a typed rename to one is refused. That keeps every name clear of the marker and the temporary buckets; a name a record already has is never refused.

The split is a move's last step. The path row ([[plugins#tutorial-plugin]]) draws a bucketed place with its buckets as the disk has them now (Fab: fab/0/01/01abc, #681), disabled with the lock when something is there already, as any place is; one whose buckets cannot be read is drawn with a … for them and left to its move. It counts the record as already there, with nothing read, when its folders are the place's with any chain of its buckets. A click always queues a move ([[mounts-and-storage#safe-move-rename]]), even an unverified rename: the move reads the buckets itself as it starts moving and keeps them once it has files there, so a stopped copy goes on into the same folder; once the record landed, a kept split phase settles each bucketed level the place went into, innermost first, since an outer split moves the inner levels' folders whole -- so a record whose arrival splits its folder ends a level deeper than the row said. A rename where the record's own name is bucketed is such a move: ab/ab123 renamed to ac123 lands in ac/ac123, never ab/ac123, its title edited first or not, and is shown as taken when ac holds it. A record whose other path fields were edited too, so that no template's place fits where it lies, is told by the disk: lying in the buckets of its name under a split folder, it moves to the new name's bucket under that same folder.

A path that leads into a split folder its layout does not bucket is locked (#681) -- its {buckets} rule was removed, or another template or type's rule buckets it. A folder record put there would lie beside the buckets, and a name of a bucket's length would be taken for one. So the path row shows such a place disabled, with the reason; every rename of a record lying there is locked too, but for one its own type's templates still bucket somewhere while its edited fields render no place it sits at; a click on a row drawn before is refused the same way; and a queued move and a library scan ask again as they start moving or place a record, and pause with the reason. Moving a record out is free, and a copy with files there goes on. A .rehubuckets folder locks nothing: it splits nothing. A balance joins a folder no rule governs ([[mounts-and-storage#bucket-rebalance]]), and the rule put back makes it a working split folder again.

Naming a record by its store id is what makes buckets cheap. An id never collides, where two items of one publisher can share a title; it never changes, so correcting a title moves nothing; and an id made of hex digits splits every level into sixteen even parts. A layout that names records by title still works: a rename then moves the record's few files, possibly into another bucket. Nobody browses a library root by folder; the browser dock is how a record is found.

§9.14.1 Rebalancing is a job

[[[mounts-and-storage#bucket-rebalance]]]

A changed limit moves nothing by itself: it counts for the next record that arrives, which splits the folder it crowds. The trees as they are are brought in line by hand (#681), by Tools > Balance Buckets... or the same entry on a root in the Roots view ([[plugins#rehuco-dock]]). Both open one dialog: the two limits, and the open catalog's roots this machine maps, each with a checkbox. Start saves the limits as the Files page would and enqueues a rebalance job per root checked; Cancel does neither. From the menu the roots checked are those of the last run accepted from there, and for a catalog with none of those every root with a {buckets} rule; from a root, that root alone, which the menu does not remember. The dialog keeps its geometry on either exit.

  • Split limit lowered (1000 to 50): every folder over the limit is split, and its buckets again, until none is.
  • Join limit raised: a split folder whose whole subtree holds the join limit or fewer is joined back -- its buckets' entries moved up, the buckets and its marker removed.
  • The cache's paths are updated with each move, as a record's move updates them.
  • Splitting happens as records arrive; joining happens only here, and only at or below the join limit, half the split limit at most: a folder near the limit would otherwise split and join with every record added and removed.
  • A folder is rebalanced when a record of the cache sits at its own layout's place in it, the path row's already there: a template's placeholders would fit another layout's folders, and a record's own. Inner folders come first, since an outer one's step moves them whole.
  • The limits are the job's own, the two the dialog showed, clamped as they are used and kept across a restart; its row names them (Balance buckets (200/100) - Library). Asked again with the same two while one is unfinished, no second is queued; with others one is, behind it, and the last one started decides.

A split folder no rule governs any more is joined whole, whatever it holds, before the bucketed folders are balanced. The job walks the root for the folders that are split (the disk knows one emptied by hand, the cache does not), leaving out folder records and a system's folders, and asks of each:

  • some record has its bucketed place there, sitting at it or not: it is governed, and balanced as above;
  • the root has no {buckets} rule at all, or a scan has read it, the cache knows records beneath the folder, and none of the root's has its bucketed place there: joined, with no limit;
  • nothing says -- a template of the root cannot be used (it may be a {buckets} mistyped), no scan has read the root, or the cache knows nothing beneath the folder: joined at or below the join limit only, so one emptied by hand loses its marker and a library is never flattened by a mistake.

One still split after that is always named in the outcome, with why, since nothing may be put there meanwhile.

A join is stopped anywhere, as a split is. Every entry beneath moves straight up into the folder, each one rename through the rename barrier; the emptied buckets are removed, each nested marker just before its folder, and the folder's own marker after them. Until then it is a split folder, and whoever settles it moves the entries down again, each to the deepest bucket its name lands in. A folder named as long as a bucket (a/ab/ab) would be taken for one by a folder still marked, so it waits in a temporary bucket until the marker is gone: a stop between the two leaves what a split stopped before its marker leaves, which a split finishes as a split and a rebalance as a join.

What keeps a folder split is asked of every bucket beneath before the first move, so nothing is half joined:

  • a file that belongs to no record, in the folder's buckets: the folder is left whole, and the job's outcome and the log name the file. Junk -- what the Files page's excluded patterns name -- is deleted instead, as the app deletes anything (its Recycle Bin choice included); one that cannot be deleted keeps the folder split too;
  • two entries of one name, one of them put there by hand: told as a stray file is. A split leaves such an entry where it is, told too, and moves the rest;
  • a bucket beneath marked never split, by a folder named .rehubuckets: the owner's choice, said nowhere.

A bucket that gains something while it is joined stays, and its folder with it, not split again in the same run.

A rebalance and a library scan never move files at the same time. Both run on one chain of the task queue ([[appendices.task-queue#serial]]), so a rebalance enqueued during a scan runs when the scan ends. To have it sooner the user pauses the scan: a paused job has returned ([[appendices.task-queue#cursor]]), so the rebalance runs, and the scan carries on after it.

A record's move runs on another chain, so a rebalance waits for it, naming it: before every step it asks for a move into a bucketed place of its root that has read its buckets and not ended -- running, waiting or paused -- or that stopped with part of its copy there, and for one out of its root about to remove what is left of the original. It would otherwise move a half-copied record, the bucket a waiting rename is to land in, or the leftovers away from their removal. The asking and the step are one, as a move's reading of its buckets and its saying so are (BUCKETS_GUARD). A move that failed before it wrote anything reads its buckets again when it is retried, since a rebalance may have joined them.

The scan therefore reads the limit, and the folders, before every record it creates, never once at its start: the limit may have changed while it ran or sat paused, and the tree may have been rebuilt under it. It keeps neither in its captured state.