Task 4: Platform-illegal filename detection #4
Labels
No labels
data-integrity
engine
platform
procurement
remote
scaffold
ui
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Cordy/cairn-desktop#4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Depends on Task 3.
Goal
Detect paths that cannot exist on the target platform, so the engine can skip and report them instead of failing the entire sync.
Why
A file legally created on Linux may be impossible to create on Windows. If one bad filename aborts the run, the whole folder stops syncing — an outage caused by one file.
Files
internal/sync/names.go,internal/sync/names_test.goProduces
Rules to implement
< > : " | ? *CON PRN AUX NUL COM1–COM9LPT1–LPT9— reserved as the stem, with or without an extension, case-insensitively. SoCON,con.txtandCON.tar.gzare reserved, butCONSOLE.txtis fine.Steps
/and check each segment. The returned error text is shown to users, so make it say what is wrong and why — it becomes a skip reason in the UI.git commit -s -m "feat(sync): detect platform-illegal filenames"Acceptance criteria
baderrors; every name ingooddoes not.CONSOLE.txtandcomm1.txtare explicitly allowed — only exact reserved stems match.Done
296de58feat(sync): detect platform-illegal filenames3c43c2bfix(sync): reject control characters and superscript device names on WindowsWhat was built
internal/sync/names.go:Platform(PlatformPOSIX,PlatformWindows) andIllegalOn(p string, plat Platform) error./-segment checks on Windows: illegal characters< > : " | ? *, trailing dot/space, reserved device stemsCON PRN AUX NUL COM1-9 LPT1-9(exact-stem match, case-insensitive).< 0x20), superscriptCOM¹/COM²/COM³/LPT¹/LPT²/LPT³stems, and trailing-space-before-extension stem trimming ("CON .txt"→CON), per Microsoft's Naming Files, Paths, and Namespaces docs.Tests
TestIllegalOnWindows,TestPOSIXAllowsWindowsIllegalNames,TestNulByteIllegalEverywhere), plusTestIllegalOnWindowsDocumentedExtrasfor the fix round. Red→green shown for both rounds (compile-fail red on missingIllegalOn, then 9/9 red→green on the extras).go vet ./...,go test -count=1 ./...,gofmt -l .clean;go.mod/go.sumuntouched (onlyfmt/stringsimported — arch guard stays green).Acceptance criteria
baderrors; every name ingooddoes not." — met,TestIllegalOnWindowscovers all 14bad/ 5goodcases.CONSOLE.txtandcomm1.txtare explicitly allowed — only exact reserved stems match." — met, exact-key map lookup on the uppercased stem, no prefix/substring match.Rulings
git commit -s, with theCo-Authored-By: Claude Opus 5trailer — DCO is non-negotiable.296de58.<0x20control-character check and the superscriptCOM¹/²/³/LPT¹/²/³stems plus trailing-space stem trim, per Microsoft's current naming docs (a missed name could otherwise write silently to theNUL/CONdevice and later read as a delete).IllegalOnbefore Decide/FS/Remote, record exactly one Skip, never treat a skipped path as missing/delete-eligible) carried into #12, #13, #14.Deferred
Platformvalues fail open; illegal-character message doesn't name the offending character; tests don't pinCON.tar.gz/CON/b.txt/segment naming) were not in this round's ruling scope — deferred to the phase-1 final review.windowsReservedStemsdoc comment (still describes the stem cut without mentioning the trailing-space trim) — deferred.Implemented and reviewed by Claude (subagent-driven), landed on main after review and green CI.