test(corpus): 23 .fls files and the Swift reader's view of them

The oracle gains a corpus mode; run.sh now stops on a failed build
instead of running a stale binary. Swift reads all 23 files but drops
Java gateways labelled 'Heimrouter' and nodes whose bounds are written
through XMLEncoder back-references.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-29 19:36:37 +00:00
co-authored by Claude Opus 5.5
parent 5c16cf18b4
commit 8866df5f21
29 changed files with 490 additions and 2 deletions
@@ -257,8 +257,50 @@ func run(_ scenario: Scenario) -> JSON {
]
}
// MARK: - .fls corpus
/// Imports every .fls under `root` and summarizes what the Swift reader made of it.
func readCorpus(root: URL) throws -> JSON {
var result: JSON = [:]
let enumerator = FileManager.default.enumerator(at: root, includingPropertiesForKeys: nil)
var files: [URL] = []
while let item = enumerator?.nextObject() as? URL {
if item.pathExtension == "fls" { files.append(item) }
}
for file in files.sorted(by: { $0.path < $1.path }) {
let name = String(file.path.dropFirst(root.path.count + 1))
do {
let imported = try TopologyProjectStore.importFiliusArchive(Data(contentsOf: file))
let state = imported.state
var kinds: [String: Int] = [:]
for node in state.graph.nodes { kinds[node.kind.rawValue, default: 0] += 1 }
result[name] = [
"version": imported.report.filiusVersion ?? NSNull(),
"nodes": imported.report.importedNodeCount,
"links": imported.report.importedLinkCount,
"documentation": imported.report.importedDocumentationItemCount,
"skipped": imported.report.skippedNodeCount,
"warnings": imported.report.warnings,
"residual": imported.opaqueContent.residualCount,
"kinds": kinds,
] as JSON
} catch {
result[name] = ["error": String(describing: error)] as JSON
}
}
return result
}
// MARK: - Main
if CommandLine.arguments.count == 4, CommandLine.arguments[1] == "--corpus" {
let summary = try readCorpus(root: URL(fileURLWithPath: CommandLine.arguments[2]))
let data = try JSONSerialization.data(withJSONObject: summary, options: [.prettyPrinted, .sortedKeys])
try (data + Data("\n".utf8)).write(to: URL(fileURLWithPath: CommandLine.arguments[3]))
print("corpus: \(summary.count) files")
exit(0)
}
let directory = URL(fileURLWithPath: CommandLine.arguments.dropFirst().first ?? ".")
let files = try FileManager.default.contentsOfDirectory(at: directory, includingPropertiesForKeys: nil)
.filter { $0.lastPathComponent.hasSuffix(".scenario.json") }
Binary file not shown.
Binary file not shown.
+6 -2
View File
@@ -6,5 +6,9 @@ set -eu
here="$(cd "$(dirname "$0")" && pwd)"
root="$(cd "$here/../.." && pwd)"
[ -d "$here/Sources/FiliusCore" ] || "$here/fetch-upstream.sh"
docker run --rm -v "$root:/work" -w /work/tools/swift-oracle swift:6.1-jammy \
sh -c 'swift build -q 2>&1 | grep -v "Sendable\|^ *|\|^ *\`" ; .build/debug/Oracle /work/packages/core/test/scenarios'
# A failed build must stop here: a stale binary would write stale references.
docker run --rm -v "$root:/work" -w /work/tools/swift-oracle swift:6.1-jammy sh -c '
set -e
swift build -q
.build/debug/Oracle /work/packages/core/test/scenarios
.build/debug/Oracle --corpus /work/corpus /work/corpus/corpus.swift.json'