Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Xcode
build/
# Local build copies. They carried a signed app with an embedded.mobileprovision,
# so they must never reach a commit.
build-dev
build-final
DerivedData/
xcuserdata/
*.xcuserstate
Expand All @@ -15,6 +19,10 @@ FitCheck/Info.plist
# Agent workspace — briefs, plans and scratch files for a run, never staged.
.opencode/

# The demo wardrobe is local-only: 39 garments with their PNGs, restored from
# docs/demo-assets.md. A -seedDemo launch without it warns instead of crashing.
Mocks/

# Swift Package Manager
.build/
.swiftpm/
Expand Down
20 changes: 20 additions & 0 deletions .gitleaks.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,29 @@ title = "FitCheck gitleaks config"
[extend]
useDefault = true

[[rules]]
# An Apple team ID is the account identifier that signing is tied to, and it
# must come from FITCHECK_TEAM_ID at build time, never from a tracked file.
id = "apple-team-id"
description = "Apple Developer Team ID"
regex = '''(?i)(?:TeamIdentifier|DEVELOPMENT_TEAM|PROVISIONING_TEAM|team-identifier)(?:[ \t]*["']?[ \t]*[=:>][ \t]*["']?[A-Z0-9]{10}\b|\s*</key>\s*<string>\s*[A-Z0-9]{10}\b)'''
keywords = ["teamidentifier", "development_team", "provisioning_team", "team-identifier"]
tags = ["apple", "identity"]

[[rules]]
# A provisioning profile carries the team ID, the device UDIDs and the
# entitlements; it is signed output for one machine and never committed.
id = "apple-provisioning-profile"
description = "Apple provisioning profile"
regex = '''(?i)(?:<key>[ \t]*(?:ProvisionedDevices|TeamIdentifier)[ \t]*</key>|BEGIN[ \t]+PROVISIONING[ \t]+PROFILE|ProvisioningProfile:[ \t]*[A-Za-z0-9._-]+)'''
keywords = ["provisioneddevices", "teamidentifier", "provisioning profile"]
tags = ["apple", "identity"]

[allowlist]
description = "Global allowlist"
paths = [
'''(?i)\.lock$''',
'''(?i)package-lock\.json$''',
]
# The ten-X placeholder in the docs is not a team ID.
regexes = ['''X{10}''']
6 changes: 4 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Simulator names are version-specific and go stale — `xcodebuild` prints the va
3. **`WeatherKitProvider`** — compiled and deliberately unwired. A free provisioning profile cannot carry the WeatherKit entitlement, so it can neither run nor be tested. Removed by the release flip: the entitlement in `project.yml`, WeatherKit enabled on the App ID, and `WeatherProviderKind.active` moved to `.weatherKit`.
4. **Apple Intelligence paths** — `OutfitGenerator.generate` past the empty-closet guard, `ModelUnavailability.current` (which reads the device's own answer), and in `GarmentClassifier` only Vision and the live inference. Neither CI nor the Simulator carries model assets, and faking the model is forbidden: the product promises to say the model is unavailable, not to guess. The classifier's **prompt builder is not on this list**: `GarmentClassifier.instructions(language:)`, `vocabulary` and `prompt(for:)` are pure — no session, no device, no image; the evidence they render is a `GarmentEvidence` value — and [`ClassifierPromptTests`](FitCheckTests/LocalizationPromptTests.swift) covers them, which is why the file reads 45.98% instead of 0%. The cut-out `Attachment` on iOS 27 is inside the live inference, so it is on the list with the model call it belongs to. Removed when the suite runs on a device that has Apple Intelligence.
5. **Defensive branches unreachable by construction** — `OpenMeteoProvider`'s `components.url` guard (the base URL is hardcoded and valid), the `@unknown default` arms, and `UserSettings.reminderDate`'s nil-coalescing on a valid hour and minute. They exist for the day the input changes; no input reaches them today. Removed when an input can actually produce one, at which point its test arrives with it.
6. **Process wiring** — `FitCheckApp`'s container creation and seeding, the store opener it builds and hands to the scene along with the deleter behind `Start over`, and `UserDefaults.forCurrentRun`'s UI-testing branch. They need a launched app, which makes them the UI tests' business rather than the unit target's: the wiring and the deleter in `FitCheckApp` only run inside a launched app, and a store that fails to open cannot be produced from the unit target. `-failFirstStoreOpen` is what closes that gap: on a `-uiTesting` launch it makes the first open throw and every later one succeed, so [`RecoveryUITests.testUnreadableStoreRecoversThroughStartOver`](FitCheckUITests/RecoveryUITests.swift) can reach the recovery screen, tap through `Start over`, land on the empty closet, and then relaunch without the argument to prove the failure is one-shot and a normal launch unaffected — which is also the test the [`StoreRecoveryView`](FitCheck/Features/Recovery/StoreRecoveryView.swift) allowlist reason names. `StoreOpener`'s own decision is not here — it takes its opener and deleter as closures precisely so it is unit-tested — and `StoreRecoveryView` is a view body, under entry 1.
6. **Process wiring** — `FitCheckApp`'s container creation and seeding, the store opener it builds and hands to the scene along with the deleter behind `Start over`, and `UserDefaults.forCurrentRun`'s UI-testing branch. They need a launched app, which makes them the UI tests' business rather than the unit target's: the wiring and the deleter in `FitCheckApp` only run inside a launched app, and a store that fails to open cannot be produced from the unit target. `-failFirstStoreOpen` is what closes that gap: on a `-uiTesting` launch it makes the first open throw and every later one succeed, so [`RecoveryUITests.testUnreadableStoreRecoversThroughStartOver`](FitCheckUITests/RecoveryUITests.swift) can reach the recovery screen, tap through `Start over`, land on the empty closet, and then relaunch without the argument to prove the failure is one-shot and a normal launch unaffected — which is also the test the [`StoreRecoveryView`](FitCheck/Features/Recovery/StoreRecoveryView.swift) allowlist reason names. `StoreOpener`'s own decision is not here — it takes its opener and deleter as closures precisely so it is unit-tested — and `StoreRecoveryView` is a view body, under entry 1. `DemoCloset` is here for the same reason: its `-seedDemo` seeding and its `Bundle.main` lookups only run inside a launched app, and the folder it reads is local-only, so the unit target has neither the launch path nor the files the lookups ask for.
7. **`AppState` (99.13%, 227/229)** — `generate` is covered through the injected `OutfitGenerating`: the four outcomes, the exclusion set, cancellation, the deleted-garment guard and the toast dismissal are all driven by a stub. The two lines still uncovered are line 290 (`ToastMessage.id`) and line 315 (`Confirmation.id`), the compiler-generated `UUID()` default initialisers, which xccov reports as unexecuted although both types are constructed in covered tests — an instrumentation gap, not untested behaviour. Kept because those lines cannot be covered from the unit target; removed when the instrumentation reports them, or when the ids stop being `UUID()` properties.
8. **Vision's foreground instances** — in `GarmentSegmenter` the request itself, the per-instance masks it returns and the selection that reads them: `VNGenerateForegroundInstanceMaskRequest` answers only against a real image on the Vision stack, and the unit target carries neither, so the request and the instance selection cannot be unit-tested. It is not the whole file: the matte refinement and the compositing are [`CutoutMatte`](FitCheck/Services/CutoutMatte.swift), which knows nothing of Vision or SwiftData and takes bytes in and bytes out — its erosion, feather, transparent margin, soft alpha range and largest-instance comparison by non-zero area are tested on synthetic masks — and the colour measurement, `colourShares(in:limit:)`, is bytes in and hex-plus-share out, testable on a rendered image. That is the same split as the classifier's prompt builder. Removed when the suite runs where the request can answer.
9. **Photo policy adapters** — `SystemPhotoSafety` and `VisionPhotoSafety` in [`PhotoSafety`](FitCheck/Services/PhotoSafety.swift): the first answers only when the system's own Sensitive Content Analysis runs, which the unit target cannot produce and which is inert without the paid-account entitlement ([`docs/photo-policy.md`](docs/photo-policy.md) §5); the second reads a Vision taxonomy that carries no nudity or gore identifier to match. The rule they feed is not on this list: `PhotoVerdict` and the `PhotoIntake` decision above the adapters are pure and expected at 100% through a fake `PhotoSafetyChecking`. Removed per adapter only by pulling logic out of it and behind a fakeable seam — never by faking the framework to chase the number.
Expand Down Expand Up @@ -131,7 +131,9 @@ Because the container is declared once on the `WindowGroup`, feature views get t
xcrun simctl launch booted com.mxo01.FitCheck -uiTesting -seedDemo
```

It is data, not code: [`DemoCloset`](FitCheck/App/DemoCloset.swift) only knows how to decode it, so adding a garment means dropping a PNG in and adding an entry to the JSON. The folder is a *folder reference* in `project.yml`, which is what keeps the subdirectory structure alive inside the bundle for `Bundle.main.url(forResource:subdirectory:)` to find.
The folder is **not tracked**: it is local-only, restored from [`docs/demo-assets.md`](docs/demo-assets.md), and a `-seedDemo` launch without it warns instead of crashing.

It is data, not code: [`DemoCloset`](FitCheck/App/DemoCloset.swift) only knows how to decode it, so adding a garment means dropping a PNG in and adding an entry to the JSON. A `postBuildScripts` phase in `project.yml` copies the folder into the bundle when it is present — keeping the subdirectory structure alive for `Bundle.main.url(forResource:subdirectory:)` to find — and removes any stale copy when it is not, so a tree without `Mocks/` still builds.

Not to be confused with `-seedCloset`, the five-garment fixture the UI tests assert against down to the item count.

Expand Down
43 changes: 34 additions & 9 deletions FitCheck/App/DemoCloset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,34 @@ import SwiftData
/// move because the screenshots want a fuller closet.
enum DemoCloset {

/// What a seeding pass did, so the caller can tell an empty demo closet
/// from an absent one. Silence was the old answer, and it read as a bug in
/// the screenshot run rather than as a folder that never reached the bundle.
enum Outcome: Equatable {
case seeded(garments: Int)
/// `Mocks/` is not in this build — the folder is local-only.
case assetsUnavailable
}

/// Where the folder reference lands inside the app bundle.
private static let folder = "Mocks"
private static let garmentsFolder = "Mocks/Garments"

/// Whether the demo wardrobe reached the bundle at all. The folder is
/// local-only, so a tree without it builds and runs — it just has no
/// closet to seed, and this is how a caller finds that out before asking.
static var isBundled: Bool {
catalogueURL != nil
}

/// The catalogue's own location, resolved once so `isBundled` and the
/// loader cannot disagree about what "present" means.
private static var catalogueURL: URL? {
Bundle.main.url(
forResource: "closet", withExtension: "json", subdirectory: folder
)
}

/// The shape of `Mocks/closet.json`.
///
/// `ClothingCategory` and `Warmth` are `Codable` over their own raw
Expand Down Expand Up @@ -63,8 +87,9 @@ enum DemoCloset {
}
}

static func seed(into context: ModelContext) {
guard let catalogue else { return }
@discardableResult
static func seed(into context: ModelContext) -> Outcome {
guard let catalogue else { return .assetsUnavailable }

var inserted: [String: ClothingItem] = [:]

Expand Down Expand Up @@ -103,21 +128,21 @@ enum DemoCloset {
}

try? context.save()

return .seeded(garments: catalogue.garments.count)
}

private static var catalogue: Catalogue? {
guard let url = Bundle.main.url(
forResource: "closet", withExtension: "json", subdirectory: folder
) else {
assertionFailure("\(folder)/closet.json is missing from the bundle")
return nil
}
// Absent is not a failure: the folder is local-only, and `isBundled`
// is what the screen reads to say so.
guard let url = catalogueURL else { return nil }

do {
return try JSONDecoder().decode(Catalogue.self, from: Data(contentsOf: url))
} catch {
// Loud in debug, silent in release: a malformed catalogue should
// stop whoever is editing it, not the person running the app.
// stop whoever is editing it, not the person running the app. The
// assertion stays — the file is there, so this is a defect.
assertionFailure("\(folder)/closet.json could not be read: \(error)")
return nil
}
Expand Down
3 changes: 3 additions & 0 deletions FitCheck/App/FitCheckApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ struct FitCheckApp: App {
// second round of screenshots used to stack another closet on top of
// the first.
if isEmpty(container), Self.shouldSeedDemo {
// The outcome is not acted on here: the scene's content reads
// `DemoCloset.isBundled` itself and warns on screen when the folder
// is missing, which is the only thing a caller could do with it.
DemoCloset.seed(into: ModelContext(container))
} else if isEmpty(container), Self.shouldSeedCloset {
let context = ModelContext(container)
Expand Down
14 changes: 14 additions & 0 deletions FitCheck/App/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,20 @@ private struct AppContent: View {
}
.environment(\.theme, theme)
.animation(.snappy(duration: 0.28), value: app.isSelecting)
// `Mocks/` is local-only data, so a `-seedDemo` launch on a tree
// without it comes up on an empty closet that looks like a broken
// screenshot run. Say why, once, and name the folder to restore.
.task {
guard !FitCheckApp.isUnitTestHost,
FitCheckApp.shouldSeedDemo,
!DemoCloset.isBundled
else { return }
app.showToast(
.warning,
"Demo closet unavailable",
"Mocks/ is not bundled - restore it with docs/demo-assets.md."
)
}
}

/// Selected tabs take the filled symbol, the rest the outlined one.
Expand Down
10 changes: 10 additions & 0 deletions FitCheckTests/LocalizationPromptTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,15 @@ struct ClassifierPromptTests {
),
]

/// Whether `Mocks/` reached the test host's bundle. The folder is
/// local-only, so the reviewed-seasons test is skipped rather than failed
/// on a tree that does not carry it.
private static var answerKeyIsBundled: Bool {
Bundle.main.url(
forResource: "closet", withExtension: "json", subdirectory: "Mocks"
) != nil
}

/// Read through `Bundle.main` because the unit target is hosted by the app:
/// `Mocks` is a folder reference in the app bundle, and the key is only ever
/// there. A missing bundle is reported as a missing bundle rather than
Expand All @@ -993,6 +1002,7 @@ struct ClassifierPromptTests {

@Test(
"The reviewed answer key seasons jewellery, belts and sunglasses as the issue settled",
.enabled(if: Self.answerKeyIsBundled),
arguments: Self.reviewedSeasons
)
func answerKeyCarriesTheReviewedSeasons(reading: AnswerKeyReading) throws {
Expand Down
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
All rights reserved.

Copyright (c) 2026 Mario Di Modica

This repository is published so it can be read. It is not open source and no licence is granted: no part of it — source code, documentation, design or other content — may be copied, modified, merged, published, distributed, sublicensed, sold or otherwise used without the copyright holder's prior written permission.

Third-party assets keep their own licences. The demo garment photographs, when restored locally, come from Unsplash and remain under the Unsplash licence; every dependency remains under the terms it ships with.

The software is provided "as is", without warranty of any kind, express or implied.
Binary file removed Mocks/Garments/demo-bead-necklace.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-beanie.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-black-jeans.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-blanket-scarf.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-blazer.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-blue-jeans.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-brown-glasses.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-bucket-hat.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-cap.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-cotton-tee.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-court-sneakers.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-denim-jacket.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-drop-earrings.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-field-jacket.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-fringed-scarf.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-grey-trousers.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-hoodie.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-knit-sweater.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-leather-belt.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-leather-brogues.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-leather-jacket.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-navy-belt.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-patterned-socks.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-pearl-necklace.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-relaxed-jeans.png
Binary file not shown.
Binary file removed Mocks/Garments/demo-ribbed-socks.png
Diff not rendered.
Binary file removed Mocks/Garments/demo-round-glasses.png
Diff not rendered.
Binary file removed Mocks/Garments/demo-running-sneakers.png
Diff not rendered.
Binary file removed Mocks/Garments/demo-silk-scarf.png
Diff not rendered.
Binary file removed Mocks/Garments/demo-silver-rings.png
Diff not rendered.
Binary file removed Mocks/Garments/demo-sport-glasses.png
Diff not rendered.
Binary file removed Mocks/Garments/demo-striped-socks.png
Diff not rendered.
Binary file removed Mocks/Garments/demo-suede-belt.png
Diff not rendered.
Binary file removed Mocks/Garments/demo-suede-trainers.png
Diff not rendered.
Binary file removed Mocks/Garments/demo-wayfarers.png
Diff not rendered.
Binary file removed Mocks/Garments/demo-white-tee.png
Diff not rendered.
Binary file removed Mocks/Garments/demo-wool-scarf.png
Diff not rendered.
Binary file removed Mocks/Garments/demo-wool-socks.png
Diff not rendered.
Binary file removed Mocks/Garments/demo-woven-belt.png
Diff not rendered.
33 changes: 0 additions & 33 deletions Mocks/README.md

This file was deleted.

Loading
Loading