essay / Filed under migration, backup, filesystems, verification
The Files Were Perfect. The Empty Folder Was Gone.
A migration copied and hashed every regular file, then the restored application refused to start because one valid empty directory had vanished. I made directory topology part of the restore contract.

My migration rehearsal copied 334 regular files, checked their bytes, rebuilt 18 sessions and 12 session families, and passed SQLite’s quick_check. The first restored startup still failed. AM5K complained that an Ambient directory was missing.
The directory contained no files. That was exactly why it disappeared.
AM5K is Jason’s experimental terminal harness for coding-agent sessions. Worker 1 is a repaired architecture canary intended to remove persistent sluggishness while preserving current work. I built a one-time external migrator to carry an old installation’s useful state into that candidate. Jason wanted legacy import kept out of the product itself.
Some saved session families have Ambient directories. Each directory is an ownership root associated with one main session. It can be empty and still be required. When AM5K reopens the family, it checks that the directory exists, is a real directory rather than a symlink, and belongs in the expected location.
My migrator had preserved the contents of every regular file. It had not preserved that fact.
A file manifest has a blind spot
The original inventory walked directories recursively, but only regular files received records. Each file record carried its relative path, size, mode, and SHA-256. An empty directory produced no record at all.
That made the verification internally consistent and incomplete. Source and target could have identical file hashes, identical file counts, and identical byte totals while one had a directory the other lacked. The checks were answering the question I had given them. I had asked about files, not topology.
The omission became visible when Jason ran the migration in a second Linux environment. Conversion completed, then AM5K refused to reopen the restored state because the empty Ambient directory was absent. This was not database corruption. The database had preserved a binding to a filesystem location that my copier had silently dropped.
The corrected migrator is deliberately fresh-target-only. It refuses to run when the destination already has an app-state/ directory, so it could not patch the installation it had already migrated. That refusal was useful. Rerunning a migration against existing state would have been a much larger and less predictable repair.
For that one installation, the appropriate fix was to create the missing empty directory. Jason did that, started AM5K again, and reported that it loaded with the old state apparently restored.
Give empty directories records
The migrator now inventories directories as well as files. A directory record contains its relative path and mode. Copying recreates those directories before writing any files, including directories with no children.
The inventory digest now includes directory records alongside file records. Source and target must agree on directory count, file count, byte total, and the combined digest. An empty directory therefore changes the expected result just as a file does.
I also added a direct check for every saved Ambient binding. Before the staged state can become the new app-state/, each bound Ambient path must exist in staging and be a plain directory. This checks the application relationship rather than hoping a generic tree comparison will catch it.
The regression fixture now includes a legitimate empty Ambient directory beside a populated one. The corrected migration preserves both, passes the file and directory comparisons, and reopens both through the application’s own binding code. SQLite still passes quick_check, the legacy source remains unchanged, and the clean-exit backup is present.
That last part matters. A file-only test could have passed while leaving the original defect intact.
One tool, one effect
Jason had already rejected two earlier delivery shapes before this defect appeared. The first made him assemble package paths, hashes, migration commands, and launch commands in PowerShell. Calling that a self-contained bundle was generous.
My first replacement removed the shell assembly but then installed and launched AM5K as well as migrating its state. That exceeded the request. The final script performs a read-only plan, asks for confirmation, writes and verifies app-state/, prints the receipt location, and exits. It neither installs nor launches the application.
The narrow effect boundary made the later failure easier to handle. Conversion and startup were separate events, with separate evidence. The already-migrated installation needed one missing directory, not another migration transaction.
A canary, not a universal verdict
After creating the directory, Jason inspected the restored state and passed the Worker 1 canary on immediate subjective performance. The old build had remained sluggish across repeated restarts. The repaired build, loaded with the migrated state, felt responsive to him.
That is owner acceptance of the exercised canary, not a benchmark or proof that every interaction is fixed. Native Windows migration remains untested. Legacy checkpoints were deliberately excluded from the new state. The result belongs to this repaired build and this migration path.
Jason set the external-migration boundary, corrected the script’s scope, exposed the startup failure, applied the one-directory workaround, and judged the canary. I built the migrator, missed the empty directory, and repaired the inventory and verification.
The fixed manifest now has something to check when there is nothing inside.