feat(core): virtual file system and Swift string semantics

The core gains Swift's virtual file system (paths, case-insensitive
lookup that keeps the spelling, quotas, atomic changes, the defaults of
a new device) and the string behaviour the ported code relies on without
saying so. Both are measured in the Swift oracle: 11 file system cases
(the three Swift tests among them) step by step, and trimming, lower
case, equality, ordering and Base64 case by case — whitespace and control
characters over all of Unicode.

Found by measuring:
- Swift trims NEL and ZERO WIDTH SPACE, not the BOM; JS trim() does the
  opposite. The .fls import now trims with swiftTrim.
- lowercased() maps scalar by scalar: a word-final sigma stays σ.
- Foundation decodes "====" and "Y===" as empty data.
- Foundation on Linux counts 24,735 plane-14 scalars as control
  characters, a table artefact; the port keeps Unicode Cc+Cf.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-29 21:23:45 +00:00
co-authored by Claude Opus 5.5
parent 51a83ea68d
commit a198d10b4a
15 changed files with 5247 additions and 18 deletions
+863
View File
@@ -0,0 +1,863 @@
[
{
"entries" : [
{
"kind" : "directory",
"path" : "\/"
},
{
"kind" : "directory",
"path" : "\/docs"
},
{
"kind" : "text",
"path" : "\/docs\/Readme.txt",
"text" : "two"
}
],
"name" : "whitespace components and case-insensitive siblings (Swift test)",
"results" : [
{
"ok" : true
},
{
"ok" : true
},
{
"error" : "invalidPathComponent",
"values" : [
" note.txt"
]
},
{
"ok" : true
},
{
"ok" : "two"
},
{
"ok" : {
"kind" : "text",
"path" : "\/docs\/Readme.txt",
"text" : "two"
}
},
{
"error" : "caseInsensitiveSiblingCollision",
"values" : [
"\/docs\/Readme.txt",
"\/docs\/README.txt"
]
},
{
"error" : "caseInsensitiveSiblingCollision",
"values" : [
"\/docs\/Readme.txt",
"\/docs\/readme.TXT"
]
}
]
},
{
"entries" : [
{
"kind" : "directory",
"path" : "\/"
},
{
"bytes" : 8388608,
"kind" : "binary",
"mediaType" : null,
"path" : "\/file-0.bin",
"sha256" : "001224bdbc0a675a104bc57050e10365bce70ab7ca449685f8142460b0dd5ba5"
},
{
"bytes" : 8388608,
"kind" : "binary",
"mediaType" : null,
"path" : "\/file-1.bin",
"sha256" : "001224bdbc0a675a104bc57050e10365bce70ab7ca449685f8142460b0dd5ba5"
},
{
"bytes" : 8388608,
"kind" : "binary",
"mediaType" : null,
"path" : "\/file-2.bin",
"sha256" : "001224bdbc0a675a104bc57050e10365bce70ab7ca449685f8142460b0dd5ba5"
},
{
"bytes" : 8388608,
"kind" : "binary",
"mediaType" : null,
"path" : "\/file-3.bin",
"sha256" : "001224bdbc0a675a104bc57050e10365bce70ab7ca449685f8142460b0dd5ba5"
}
],
"name" : "quotas are explicit and atomic (Swift test)",
"results" : [
{
"error" : "fileSizeQuotaExceeded",
"values" : [
"\/oversized.bin",
8388609,
8388608
]
},
{
"ok" : false
},
{
"ok" : true
},
{
"ok" : true
},
{
"ok" : true
},
{
"ok" : true
},
{
"error" : "deviceSizeQuotaExceeded",
"values" : [
41943040,
33554432
]
},
{
"ok" : false
}
]
},
{
"entries" : [
{
"kind" : "directory",
"path" : "\/"
},
{
"bytes" : 8388608,
"kind" : "binary",
"mediaType" : "application\/octet-stream",
"path" : "\/destination.bin",
"sha256" : "b16bd32b101132fd0102461bc75ea65442c37293ac881ae953486c8ac26a7388"
},
{
"bytes" : 8388608,
"kind" : "binary",
"mediaType" : "application\/octet-stream",
"path" : "\/fourth.bin",
"sha256" : "b16bd32b101132fd0102461bc75ea65442c37293ac881ae953486c8ac26a7388"
},
{
"bytes" : 8388608,
"kind" : "binary",
"mediaType" : "application\/octet-stream",
"path" : "\/third.bin",
"sha256" : "b16bd32b101132fd0102461bc75ea65442c37293ac881ae953486c8ac26a7388"
}
],
"name" : "overwrite uses the final state's quota, move is atomic (Swift test)",
"results" : [
{
"ok" : true
},
{
"ok" : true
},
{
"ok" : true
},
{
"ok" : true
},
{
"ok" : true
},
{
"error" : "deviceSizeQuotaExceeded",
"values" : [
41943040,
33554432
]
},
{
"ok" : true
},
{
"ok" : false
},
{
"ok" : true
}
]
},
{
"entries" : [
{
"kind" : "directory",
"path" : "\/"
}
],
"name" : "path normalization",
"results" : [
{
"error" : "pathMustBeAbsolute",
"values" : [
"a"
]
},
{
"ok" : "\/"
},
{
"ok" : "\/a\/c"
},
{
"error" : "pathEscapesRoot",
"values" : [
"\/.."
]
},
{
"error" : "pathEscapesRoot",
"values" : [
"\/a\/..\/.."
]
},
{
"ok" : "\/a\/b"
},
{
"error" : "invalidPathComponent",
"values" : [
" b"
]
},
{
"error" : "invalidPathComponent",
"values" : [
"b "
]
},
{
"error" : "invalidPathComponent",
"values" : [
"b\u0007"
]
},
{
"error" : "invalidPathComponent",
"values" : [
"b​"
]
},
{
"ok" : "\/a\/b"
},
{
"ok" : "\/a\/..."
},
{
"error" : "invalidPathComponent",
"values" : [
"…b"
]
},
{
"error" : "invalidPathComponent",
"values" : [
"b"
]
},
{
"error" : "invalidPathComponent",
"values" : [
" b "
]
},
{
"ok" : "\/é\/é"
}
]
},
{
"entries" : [
{
"kind" : "directory",
"path" : "\/"
},
{
"kind" : "directory",
"path" : "\/Kelvin"
},
{
"kind" : "directory",
"path" : "\/STRASSE"
},
{
"kind" : "directory",
"path" : "\/Straße"
},
{
"kind" : "directory",
"path" : "\/é"
},
{
"kind" : "text",
"path" : "\/é\/x.txt",
"text" : "1"
},
{
"kind" : "directory",
"path" : "\/ΟΔΟΣ"
}
],
"name" : "canonical equivalence and scalar-wise lower case",
"results" : [
{
"ok" : true
},
{
"ok" : {
"kind" : "directory",
"path" : "\/é"
}
},
{
"ok" : true
},
{
"error" : "itemAlreadyExists",
"values" : [
"\/é"
]
},
{
"ok" : true
},
{
"ok" : {
"kind" : "directory",
"path" : "\/ΟΔΟΣ"
}
},
{
"error" : "itemNotFound",
"values" : [
"\/οδος"
]
},
{
"ok" : true
},
{
"ok" : true
},
{
"ok" : true
},
{
"ok" : {
"kind" : "directory",
"path" : "\/Kelvin"
}
}
]
},
{
"entries" : [
{
"kind" : "directory",
"path" : "\/"
},
{
"kind" : "directory",
"path" : "\/Adir"
},
{
"kind" : "text",
"path" : "\/Zeta",
"text" : "Zeta"
},
{
"kind" : "text",
"path" : "\/a.txt",
"text" : "a.txt"
},
{
"kind" : "text",
"path" : "\/b.txt",
"text" : "b.txt"
},
{
"kind" : "text",
"path" : "\/file10",
"text" : "file10"
},
{
"kind" : "text",
"path" : "\/file2",
"text" : "file2"
},
{
"kind" : "directory",
"path" : "\/zdir"
},
{
"kind" : "text",
"path" : "\/émile",
"text" : "émile"
},
{
"kind" : "text",
"path" : "\/~",
"text" : "~"
},
{
"kind" : "text",
"path" : "\/😀",
"text" : "😀"
}
],
"name" : "listing order",
"results" : [
{
"ok" : true
},
{
"ok" : true
},
{
"ok" : true
},
{
"ok" : true
},
{
"ok" : true
},
{
"ok" : true
},
{
"ok" : true
},
{
"ok" : true
},
{
"ok" : true
},
{
"ok" : true
},
{
"ok" : [
{
"kind" : "directory",
"path" : "\/Adir"
},
{
"kind" : "directory",
"path" : "\/zdir"
},
{
"kind" : "text",
"path" : "\/Zeta",
"text" : "Zeta"
},
{
"kind" : "text",
"path" : "\/a.txt",
"text" : "a.txt"
},
{
"kind" : "text",
"path" : "\/b.txt",
"text" : "b.txt"
},
{
"kind" : "text",
"path" : "\/file10",
"text" : "file10"
},
{
"kind" : "text",
"path" : "\/file2",
"text" : "file2"
},
{
"kind" : "text",
"path" : "\/émile",
"text" : "émile"
},
{
"kind" : "text",
"path" : "\/~",
"text" : "~"
},
{
"kind" : "text",
"path" : "\/😀",
"text" : "😀"
}
]
}
]
},
{
"entries" : [
{
"kind" : "directory",
"path" : "\/"
},
{
"kind" : "directory",
"path" : "\/a"
},
{
"kind" : "directory",
"path" : "\/a\/Renamed"
},
{
"kind" : "directory",
"path" : "\/a\/Renamed\/c"
},
{
"kind" : "text",
"path" : "\/a\/Renamed\/c\/f.txt",
"text" : "f"
},
{
"kind" : "text",
"path" : "\/a\/g.txt",
"text" : "g"
}
],
"name" : "copy, move, rename and delete trees",
"results" : [
{
"ok" : true
},
{
"ok" : true
},
{
"ok" : true
},
{
"error" : "cannotMoveDirectoryIntoItself",
"values" : [
"\/a",
"\/a\/b\/x"
]
},
{
"error" : "itemAlreadyExists",
"values" : [
"\/"
]
},
{
"ok" : true
},
{
"ok" : [
{
"kind" : "text",
"path" : "\/copy\/c\/f.txt",
"text" : "f"
}
]
},
{
"ok" : true
},
{
"error" : "cannotMoveDirectoryIntoItself",
"values" : [
"\/a",
"\/a\/b"
]
},
{
"ok" : "\/a\/Renamed"
},
{
"error" : "invalidPathComponent",
"values" : [
"x\/y"
]
},
{
"error" : "directoryNotEmpty",
"values" : [
"\/a"
]
},
{
"error" : "cannotMutateRoot",
"values" : [
]
},
{
"error" : "expectedFile",
"values" : [
"\/a\/b"
]
},
{
"error" : "expectedDirectory",
"values" : [
"\/a\/g.txt"
]
},
{
"ok" : true
},
{
"error" : "expectedFile",
"values" : [
"\/a"
]
},
{
"error" : "expectedTextFile",
"values" : [
"\/a"
]
},
{
"error" : "parentDirectoryNotFound",
"values" : [
"\/a\/g.txt\/x"
]
},
{
"error" : "parentDirectoryNotFound",
"values" : [
"\/q\/r"
]
}
]
},
{
"entries" : [
{
"kind" : "directory",
"path" : "\/"
},
{
"bytes" : 10,
"kind" : "image",
"mediaType" : "image\/png",
"path" : "\/i.png",
"sha256" : "ffadf8d89d37b3b55fe1847b513cf92e3be87e4c168708c7851845df96fb36be"
}
],
"name" : "file kinds",
"results" : [
{
"ok" : true
},
{
"error" : "expectedTextFile",
"values" : [
"\/i.png"
]
},
{
"error" : "expectedFile",
"values" : [
"\/"
]
},
{
"error" : "itemNotFound",
"values" : [
"\/missing"
]
},
{
"ok" : {
"bytes" : 10,
"kind" : "image",
"mediaType" : "image\/png",
"path" : "\/i.png",
"sha256" : "ffadf8d89d37b3b55fe1847b513cf92e3be87e4c168708c7851845df96fb36be"
}
}
]
},
{
"entries" : [
{
"kind" : "directory",
"path" : "\/"
},
{
"kind" : "directory",
"path" : "\/home"
},
{
"kind" : "text",
"path" : "\/home\/lab-notes.txt",
"text" : "Document deterministic runtime notes here."
},
{
"kind" : "text",
"path" : "\/home\/topology-exports.csv",
"text" : "timestamp,event,detail\n"
},
{
"kind" : "directory",
"path" : "\/images"
},
{
"bytes" : 2352,
"kind" : "image",
"mediaType" : "image\/png",
"path" : "\/images\/network-map.png",
"sha256" : "4105bdb0131a539791f3b0f00e43341de6a5e04ab21b0cda19ac49548cd0cdd1"
},
{
"bytes" : 1478,
"kind" : "image",
"mediaType" : "image\/png",
"path" : "\/images\/switch-backplane.png",
"sha256" : "8ae2492515a66cd69d729d70d449ece4e6c23ee151f98da44c6b7862058c463f"
},
{
"bytes" : 6195,
"kind" : "image",
"mediaType" : "image\/png",
"path" : "\/images\/traffic-heatmap.png",
"sha256" : "6b541170a55a139281170fcf1176ce0b962f1ab58b1f26b9d2cff7558711825b"
},
{
"kind" : "directory",
"path" : "\/var"
},
{
"kind" : "directory",
"path" : "\/var\/log"
},
{
"kind" : "text",
"path" : "\/var\/log\/runtime-events.log",
"text" : "Virtual runtime initialized.\n"
}
],
"name" : "defaults of a new device",
"results" : [
{
"ok" : true
},
{
"ok" : [
{
"bytes" : 2352,
"kind" : "image",
"mediaType" : "image\/png",
"path" : "\/images\/network-map.png",
"sha256" : "4105bdb0131a539791f3b0f00e43341de6a5e04ab21b0cda19ac49548cd0cdd1"
},
{
"bytes" : 1478,
"kind" : "image",
"mediaType" : "image\/png",
"path" : "\/images\/switch-backplane.png",
"sha256" : "8ae2492515a66cd69d729d70d449ece4e6c23ee151f98da44c6b7862058c463f"
},
{
"bytes" : 6195,
"kind" : "image",
"mediaType" : "image\/png",
"path" : "\/images\/traffic-heatmap.png",
"sha256" : "6b541170a55a139281170fcf1176ce0b962f1ab58b1f26b9d2cff7558711825b"
}
]
}
]
},
{
"entries" : [
{
"kind" : "directory",
"path" : "\/"
},
{
"kind" : "text",
"path" : "\/a",
"text" : "a"
},
{
"kind" : "directory",
"path" : "\/b"
},
{
"kind" : "text",
"path" : "\/b\/c",
"text" : "c"
}
],
"name" : "entries need their parents",
"results" : [
{
"error" : "parentDirectoryNotFound",
"values" : [
"\/a\/b"
]
},
{
"error" : "itemAlreadyExists",
"values" : [
"\/"
]
},
{
"ok" : true
}
]
},
{
"entries" : [
{
"kind" : "directory",
"path" : "\/"
},
{
"kind" : "directory",
"path" : "\/é"
},
{
"kind" : "text",
"path" : "\/é\/x",
"text" : "x"
}
],
"name" : "canonically equal entries are one path",
"results" : [
{
"error" : "itemAlreadyExists",
"values" : [
"\/é"
]
},
{
"ok" : true
},
{
"ok" : [
{
"kind" : "directory",
"path" : "\/é"
}
]
}
]
}
]