Files
w3cjandClaude Opus 5.5 ba510eec1f feat(vm): a folder moved across a restart keeps its VM, by its volume
A project folder's identity was its device, inode and birth time, and
since #60 a folder at its recorded path matched on another device. A
folder that moved while a restart gave its disk another device number
matched nothing, so plain devvm made it a second VM, and folderOf took a
renumbered disk for an unmounted one ("not connected"), so movedAway was
false too.

Each VM's state now records the folder's volume, which no renumbering
changes, as folder_volume, "<kind>:<value>:<ino>:<btime>", bound to the
folder it was read with (platform.VolumeOf, RecordedVolume): macOS's
volume UUID from diskutil (platform.VolumeUUID, only for the mount point
and device read from the folder opened with no link, its answer checked
against both), Linux's f_fsid on ext4, Btrfs and ZFS (StatFolder, read
from the open folder); none on a read-only volume or a snapshot, or
elsewhere. state.VM's folder is unexported: Folder(), FolderVolume() and
SetFolder(id, vol), the one writer, which creation, adopt, a move and
recordFolder (renumbered's successor, at each launch) use; a launch
records the volume of a VM made before, once it can (1 s at a launch,
5 s at an adopt or a move, one failure a run stops the rest, through
Env.Volumes and its run's cache).

moveHere matches a moved folder by its volume, inode and birth time
(platform.MayHaveMoved, MovedFolder), looking the volume up only once
the rest matches, with the identity it matched and records both read
from the folder opened with no link (hereOf), and folderOf compares the parent's volume where the
state records one (platform.OnRecordedDisk), through Env.folderState for
a move or an rm. The folder-ids rule now also reads Folder() and
FolderVolume() calls, FolderDevice, locals assigned from any of them,
switches and strings/slices comparisons.

An older devvm keeps folder_volume as it is (checked with 0.1.0's own
reader in a temp copy of its tree). A rename keeps the inode, so the
binding stays right; when an older devvm adopts another folder for the
VM, or a move across volumes copies it, the binding names another inode,
so the record names no volume and is recorded again. DEVVM_VOLUME stands
in for diskutil, and for Linux's f_fsid, in test builds (VolumesOnly).

Tests: TestFolderOf (not connected after a renumbering), TestMovedFrom
(moved and renumbered, and a split between the read that matched and
the one recorded), TestRecordFolder (made, a VM made before at its next
launch, a failed lookup, a renumbering keeping the bound volume),
TestVolumeOfCache, TestVolumeOf, TestMovedFolderAndRecordedDisk,
TestStatFolder(AndVolumeUUID), TestPlistStrings, the folder-ids rule's
new cases, fixture_v010_renumbered.txtar (0.1.0's VM records its volume,
then moved and renumbered it's offered, never a second VM), and e2e's
projectRenumbered (hdiutil, macOS) and the project section's volume
check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 01:59:06 -07:00

15 lines
341 B
Go

//go:build !darwin && !linux
package platform
import (
"context"
"errors"
)
// StatFolder is unsupported here.
func StatFolder(string) (FolderStat, error) { return FolderStat{}, errors.ErrUnsupported }
// VolumeUUID is unsupported here.
func VolumeUUID(context.Context, FolderStat) (string, error) { return "", errors.ErrUnsupported }