Skip to content

Commit 6d83d3c

Browse files
kradalbyclaude
andcommitted
muninkit: remove Sourcery, promote hand-written Equatable
Swift 6.3's Equatable synthesis covers every AutoEquatable conformer that doesn't need ulp-tolerant Double comparison or explicit field exclusion. Drop Sourcery, its templates, the Autogenerated/ dir, and the AutoEquatable / Diffable marker protocols — the stencil had no exclusion mechanism anyway, and the last two commits (§14 self-heal and §15 jpegCompression fingerprint) both hand-edited the generated file. Stop pretending it's generated. Hand-written Equatable stays for the three types that actually need it, now living in Sources/MuninKit/Equality.swift: - Photo: deliberately excludes modifiedDate/fileSize (cache keys) and next/previous (derived navigation), deliberately includes sourceHash and encodingFingerprint. Same semantics as before — PhotoEqualityTests locks every exclusion. - GPS, LocationDegree: use `==~` (ulp-tolerant) for their Double fields because EXIF reads can drift bitwise on a photo whose bytes are otherwise unchanged. Album, Keyword, LocationData, Parent, ScaledPhoto get synthesized member-by-member `==` via their declared Hashable / Equatable conformance. The stencil used to emit a field-by-field guard chain — semantically identical to synthesis. Also drops `make generate`, the `sourcery` Brewfile entry, the `exclude: ["Templates"]` hack on the MuninKit target, and FUTURES.md §7. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 56c23ad commit 6d83d3c

15 files changed

Lines changed: 117 additions & 339 deletions

.sourcery.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

Brewfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
brew 'swift'
33
brew 'swiftlint'
44
brew 'swift-format'
5-
brew 'sourcery'
65

76
# Dependencies
87
brew 'gd'

FUTURES.md

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -106,27 +106,7 @@ Good next steps:
106106

107107
---
108108

109-
## 7. Remove Sourcery / `Autogenerated/` code generation
110-
111-
`Sources/MuninKit/Autogenerated/Equality.generated.swift` (and the
112-
corresponding `Diffable.generated.swift`) are generated by Sourcery from
113-
`Sources/MuninKit/Templates/*.stencil`. They contain hand-tuned `Equatable`
114-
behaviour (notably, Photo's `==` excludes the `next` / `previous`
115-
navigation fields — see commit 18).
116-
117-
With Swift 6.3, `Equatable` synthesis is essentially complete, and the
118-
diff algorithm could be rewritten on top of synthesized `==` plus an
119-
explicit list of "fields that participate in diff". Removing Sourcery
120-
would eliminate a codegen step and one more third-party tool from the
121-
development environment.
122-
123-
This is deliberately out of scope for the Swift 6 migration because
124-
changes to the generated `Equatable` will change the observable output of
125-
the diff pipeline, and regression-testing that shift is its own project.
126-
127-
---
128-
129-
## 8. Nix + Swift packaging
109+
## 7. Nix + Swift packaging
130110

131111
`flake.nix` intentionally does not provide a Swift toolchain because
132112
nixpkgs' Swift derivations trail Swift.org releases and interact awkwardly

Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ install: build-release
44
publish: build
55
scp ./.build/release/munin root@storage.terra.fap.no:/storage/nfs/k8s/builds/munin/.
66

7-
generate:
8-
sourcery
9-
make fmt
10-
117
build:
128
swift build -c debug
139

Package.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ let package = Package(
7171
.product(name: "SystemPackage", package: "swift-system"),
7272
.product(name: "Crypto", package: "swift-crypto"),
7373
"SwiftExif",
74-
],
75-
exclude: ["Templates"]
74+
]
7675
),
7776
.testTarget(
7877
name: "MuninTests",

Sources/MuninKit/Album.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
struct Album: Hashable, Comparable, Diffable, Sendable {
10+
struct Album: Hashable, Comparable, Sendable {
1111
var name: String
1212
var url: String
1313
var path: String
@@ -92,7 +92,7 @@ struct AlbumInAlbum: Codable, Sendable {
9292
var scaledPhotos: [ScaledPhoto]
9393
}
9494

95-
struct Parent: Codable, AutoEquatable, Comparable, Sendable {
95+
struct Parent: Codable, Equatable, Comparable, Sendable {
9696
var name: String
9797
var url: String
9898

@@ -139,7 +139,7 @@ extension Album: Decodable {
139139
}
140140
}
141141

142-
extension Album: AutoEquatable {
142+
extension Album {
143143
static func < (lhs: Album, rhs: Album) -> Bool {
144144
return lhs.name < rhs.name
145145
}

Sources/MuninKit/Autogenerated/Diffable.generated.swift

Lines changed: 0 additions & 6 deletions
This file was deleted.

Sources/MuninKit/Autogenerated/Equality.generated.swift

Lines changed: 0 additions & 260 deletions
This file was deleted.

Sources/MuninKit/AutogeneratedTypes.swift

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)