Scramble branch T-2459/bugfix-trips-disappear-packing remote head ef2f42edc401 full suite 806 passed / 38 failed / 12 skipped baseline retry same 38 failures

Pre-push review: T-2459 packing disappearance

Full CloudKit identity validation before inbound deletion; historical-event attribution remains unproven.

At a glance

  • Synthetic foreign-zone tombstone reproduced trip and packing-item deletion before the fix.
  • Final focused run: 21 passed declarations (34 executions); full run: 806 passed, 38 failed, 12 skipped. Every failed UI method also failed on unchanged baseline.
  • No live trip stores or cloud records accessed. No historical deletion or recovery claimed.

Verdict

Verified fix; pre-existing UI failures

38 failing UI tests in the single full run: 806 passed, 12 skipped. All 38 failed again in the single baseline retry, establishing pre-existing failures. Focused tests, all unit suites and lint passed. The baseline runner was terminated only after complete native results when bundle finalisation stalled.

Review findings

5 raised · 4 fixed · 1 skipped

Jump to findings →

Tests

Pass rate: 95% (806 of 844)

New tests: 6

Diff coverage: n/a

Jump to tests →

Commits

Three-level explanation

Record names live inside zones owned by users. The old handler discarded that address and could delete the wrong local trip. The fix compares the complete address.

UUID-filtered candidate fetches feed a full record-ID matcher. The existing zone resolver normalizes empty private owners; cached fields identify orphans. All decisions precede reverse-cascade mutation.

Zone-state reads remain bounded by candidate trip IDs. Snapshot cleanup also follows the canonical backlink. Inbound persistence bypasses the outgoing write hook to avoid echoing server tombstones. No schema or restore-policy change.

Important changes — detailed

Inbound deletion validates full identity

Scramble/Scramble/Sharing/TripSyncEngine+Deletions.swift

Why it matters. Foreign-zone or wrong-owner tombstones must not remove current local trips.

What to look at. apply(deletedRecordIDs:) and RecordDeletionMatcher.matches

Takeaway. Preserve CKRecord.ID through local matching; UUID-only keys lose the namespace.
Rationale. The synthetic regression failed both trip and packing-item retention assertions before the fix.

Valid deletions retain graph semantics

Scramble/Scramble/Sharing/TripSyncEngine+Deletions.swift

Why it matters. A preservation guard must still process genuine root and child tombstones.

What to look at. Reverse-cascade collections and snapshotsOfTrips(_:)

Takeaway. Resolve identity before nullification; query canonical backlinks for cleanup.
Rationale. Uses existing deletion ordering and avoids the outgoing LocalWriteHook.

Packing regressions use the real store topology

Scramble/Scramble/Persistence/UITestSeed+PackingStability.swift

Why it matters. Legacy fixtures seed globals while the Trips UI reads tripsLocal.

What to look at. seedPackingTripStability

Takeaway. Use production persistence entry points with synthetic two-store fixtures.
Rationale. Keeps globals people and trip-domain rows in the same containers used by the production UI.

Key decisions

Fix demonstrated sync boundary, retain historical uncertainty

Ordinary packing toggles, sync echoes and SQLite reopening passed. A foreign-zone tombstone failed. No logs establish that such a tombstone caused the historical last-trip event.

Reuse canonical owner normalization

Pre-push review found the empty-owner default; the matcher now uses TripZoneStateRecordTranslator.zoneID(for:) and includes a genuine default-owner regression.

PR feedback condition resolved

The automated code-review check passed. Its required baseline-attribution condition is resolved. Optional suggestions were documented; no Swift code changed after the completed tests.

Review findings

SeverityAreaFindingResolution
majorInbound record deletionBare UUID matching accepts a tombstone from another zone.Compare complete CKRecord.ID with derived owning zone before mutation.
minorOwner normalizationAn empty stored owner must map to the private default.Reuse existing canonical resolver and add defaultOwner test case.
minorSnapshot cleanupConvenience trip snapshot collection is not the canonical backlink authority.Union a bounded canonical-backlink fetch before deleting the root.
minorInvestigation evidenceA passed UI test was initially described as interrupted.Read the native test result and distinguish the passed test from its interrupted command teardown.
majorFull-suite UI verification38 UI methods failed in the required full run.All 38 methods failed again on unchanged baseline 0a37052. Exact selectors and teardown qualification are in verification.md; no unrelated code changes.

Tests

Source: local run at 2026-10-14T23:35:24.562199+00:00 · snapshot e8a60ccea435bca5c114dd3653d2c865b6ff7c39 (dirty working tree)

Baseline: none

Execution: failed · JUnit: 1 file · Coverage: none · Baseline: absent

Coverage scope: as the project configures it

Totals: 806 passed · 38 failed · 12 skipped · 0 errored · 0 flaky

Failed tests

SuiteTestJob or artifactMessage
ColdLaunchSequencingUITestsColdLaunchSequencingUITests/testColdLaunchScanCompletesBeforeAutoOpen()—Failed in native xcresult
PackingSheetUITestsPackingSheetUITests/testAddManualItemAppearsInUnpacked()—Failed in native xcresult
PackingSheetUITestsPackingSheetUITests/testInnerFormSwipeDownKeepsPackingSheet()—Failed in native xcresult
PackingSheetUITestsPackingSheetUITests/testLeftBehindRowIsReadOnly()—Failed in native xcresult
PackingSheetUITestsPackingSheetUITests/testPackingSummaryRendersInDayBeforePhase()—Failed in native xcresult
PackingSheetUITestsPackingSheetUITests/testPackModeCheckboxTogglesState()—Failed in native xcresult
PackingSheetUITestsPackingSheetUITests/testPhaseSublineCombined()—Failed in native xcresult
PackingSheetUITestsPackingSheetUITests/testRenameViaSwipe()—Failed in native xcresult
PackingSheetUITestsPackingSheetUITests/testRepackOpensFromDayBeforeReturn()—Failed in native xcresult
PackingSheetUITestsPackingSheetUITests/testRestoreReverses()—Failed in native xcresult
PackingSheetUITestsPackingSheetUITests/testSheetCounterIncludesDimmed()—Failed in native xcresult
PackingSheetUITestsPackingSheetUITests/testSkipMovesItemToNotBringing()—Failed in native xcresult
PackingSheetUITestsPackingSheetUITests/testTappingSummaryRowOpensSheet()—Failed in native xcresult
PackingSubItemsUITestsPackingSubItemsUITests/testAddRemoveAndReadOnlySubItem()—Failed in native xcresult
PersonDeletionGuardUITestsPersonDeletionGuardUITests/testPersonOwningMasterPackingItemCannotBeDeleted()—Failed in native xcresult
Phase5MigrationStateUITestsPhase5MigrationStateUITests/testFailedMigrationRowAppearsInRetryBanner()—Failed in native xcresult
Phase5MigrationStateUITestsPhase5MigrationStateUITests/testStageBInProgressTripShowsSyncingBadge()—Failed in native xcresult
Phase5SharingUITestsPhase5SharingUITests/testOwnerSideTapPresentsManageParticipantsAffordance()—Failed in native xcresult
Phase5SharingUITestsPhase5SharingUITests/testParticipantsSectionDisplayNameFallbackChain()—Failed in native xcresult
Phase5SharingUITestsPhase5SharingUITests/testParticipantsSectionDistinguishesPendingFromAccepted()—Failed in native xcresult
Phase5SharingUITestsPhase5SharingUITests/testParticipantsSectionIsReadOnlyForParticipants()—Failed in native xcresult
Phase5SharingUITestsPhase5SharingUITests/testShareButtonHiddenForParticipant()—Failed in native xcresult
Phase5SharingUITestsPhase5SharingUITests/testShareButtonVisibleForOwner()—Failed in native xcresult
RootNavigationUITestsRootNavigationUITests/testAutoOpenDoesNotRefireOnTabSwitch()—Failed in native xcresult
RootNavigationUITestsRootNavigationUITests/testColdLaunchOneQualifyingTripAutoOpensDetail()—Failed in native xcresult
RootNavigationUITestsRootNavigationUITests/testTabBarHiddenOnDetailRestoredOnPop()—Failed in native xcresult
RulesEnginePopulationUITestsRulesEnginePopulationUITests/testCreateTripPopulatesMatchingMasterPackingItem()—Failed in native xcresult
RulesEnginePopulationUITestsRulesEnginePopulationUITests/testEditTripAttributesPopulatesMatchingMasterPackingItem()—Failed in native xcresult
TimelineAndTaskUITestsTimelineAndTaskUITests/testAccordionAutoExpandsCurrentPhase()—Failed in native xcresult
TimelineAndTaskUITestsTimelineAndTaskUITests/testAssigneePickerEmptyParticipants()—Failed in native xcresult
TimelineAndTaskUITestsTimelineAndTaskUITests/testCheckboxToggleAndStrikethrough()—Failed in native xcresult
TimelineAndTaskUITestsTimelineAndTaskUITests/testManualTaskAddPersistsAcrossLaunch()—Failed in native xcresult
TimelineAndTaskUITestsTimelineAndTaskUITests/testOnlyOnePhaseExpandedAtATime()—Failed in native xcresult
TimelineAndTaskUITestsTimelineAndTaskUITests/testRuleDeletionPersistsAcrossReevaluation()—Failed in native xcresult
TimelineAndTaskUITestsTimelineAndTaskUITests/testSwipeRevealsEditAndDelete()—Failed in native xcresult
TripCRUDUITestsTripCRUDUITests/testDeleteTripRemovesItFromList()—Failed in native xcresult
TripCRUDUITestsTripCRUDUITests/testEditTripAttributesUpdatesChips()—Failed in native xcresult
TripEditorPickerReactivityUITestsTripEditorPickerReactivityUITests/testNewPersonCreatedInlineAppearsInPickerWithoutLeavingEditor()—Failed in native xcresult

New and removed tests

Derived by declaration name, from the diff (no baseline run).

Blast radius

Files that import a changed file on the left, changed files in the centre, files a changed file imports on the right. Snapshot working-tree against base 0a37052721da3b5bd0c8a0a99e019ab82511dc8f.

addedmodifieddeletedrenamedunchangedcollapsed package group or +N more⚑N test files with an edge to the node

Per-file diffs

11 files: 7 code · 4 docs. Click to expand.

Code (7)

Makefile Modified
diff --git a/Makefile b/Makefileindex c0e8d74..8d676f8 100644--- a/Makefile+++ b/Makefile@@ -6,6 +6,10 @@ PROJECT = Scramble/Scramble.xcodeproj BUNDLE_ID = me.nore.ig.Scramble CONFIG ?= Debug +# Use make test with -only-testing for narrow selection. test-quick/test-ui+# retain their broad bundle selectors; TEST_ARGS also accepts other test options.+TEST_ARGS ?=+ SIMULATOR ?= iPhone 17 Pro DEVICE_MODEL ?= iPhone 17 Pro @@ -92,6 +96,7 @@ test-quick: 		-scheme $(SCHEME) \ 		-destination 'platform=iOS Simulator,name=$(SIMULATOR)' \ 		-configuration Debug \+		$(TEST_ARGS) \ 		-derivedDataPath $(DERIVED_DATA) \ 		-only-testing:ScrambleTests \ 		-parallel-testing-worker-count 1 \@@ -107,6 +112,7 @@ test: 		-scheme $(SCHEME) \ 		-destination 'platform=iOS Simulator,name=$(SIMULATOR)' \ 		-configuration Debug \+		$(TEST_ARGS) \ 		-derivedDataPath $(DERIVED_DATA) \ 		-parallel-testing-worker-count 1 \ 		-maximum-concurrent-test-simulator-destinations 1 \@@ -119,6 +125,7 @@ test-ui: 		-scheme $(SCHEME) \ 		-destination 'platform=iOS Simulator,name=$(SIMULATOR)' \ 		-configuration Debug \+		$(TEST_ARGS) \ 		-derivedDataPath $(DERIVED_DATA) \ 		-only-testing:ScrambleUITests \ 		-parallel-testing-worker-count 1 \
Scramble/Scramble/Persistence/UITestSeed+PackingStability.swift Added
diff --git a/Scramble/Scramble/Persistence/UITestSeed+PackingStability.swift b/Scramble/Scramble/Persistence/UITestSeed+PackingStability.swiftnew file mode 100644index 0000000..47801c4--- /dev/null+++ b/Scramble/Scramble/Persistence/UITestSeed+PackingStability.swift@@ -0,0 +1,25 @@+import Foundation+import SwiftData++#if DEBUG+  extension UITestSeed {+    static func seedPackingTripStability(+      globals: ModelContext, trips: ModelContext, today: Date, calendar: Calendar+    ) {+      let person = Person(name: "Fixture Person", colorKey: "Cyan")+      globals.insert(person)+      let day = calendar.startOfDay(for: today)+      let draft = TripDraft(+        name: "Synthetic Packing Trip",+        startDate: calendar.date(byAdding: .day, value: 1, to: day)!,+        endDate: calendar.date(byAdding: .day, value: 6, to: day)!,+        attributes: TripAttributes(), participantIDs: [person.id])+      let (trip, _) = TripPersistence.create(from: draft, in: trips, globals: globals)+      let snapshot = (trip.participantSnapshots ?? []).first+      trips.insert(TripPackingItem(trip: trip, name: "Fixture item", personSnapshot: snapshot))+      try? globals.save()+      try? trips.save()+    }++  }+#endif
Scramble/Scramble/Persistence/UITestSeed.swift Modified
diff --git a/Scramble/Scramble/Persistence/UITestSeed.swift b/Scramble/Scramble/Persistence/UITestSeed.swiftindex fc4fe25..ad04ebf 100644--- a/Scramble/Scramble/Persistence/UITestSeed.swift+++ b/Scramble/Scramble/Persistence/UITestSeed.swift@@ -53,6 +53,8 @@       /// checkbox toggle, Skip/Restore, manual add, and dimmed-row counting       /// (including rule-driven items).       case phase4PackModeTrip = "phase4-pack-mode-trip"+      /// Synthetic two-store fixture exercising production packing writes.+      case packingTripStability = "packing-trip-stability"       /// Phase 4: trip currently on `.dayBeforeReturn` (today == end-1, start       /// == today-3) with two participants and a mix of packed/repacked/       /// unpacked/excluded items. Used by repack-mode UI tests covering the@@ -84,6 +86,10 @@       guard let fixture = parseFixture(from: arguments) else { return }       UITestSharingService.reset()       switch fixture {+      case .packingTripStability:+        seedPackingTripStability(+          globals: globalsContainer.mainContext,+          trips: tripsLocalContainer.mainContext, today: today, calendar: calendar)       case .phase5SharedTripOwner,         .phase5SharedTripParticipant,         .phase5MigrationStates:@@ -169,7 +175,7 @@       case .phase4PackModeTrip,         .phase4RepackModeTrip:         seedPhase4(fixture: fixture, in: context, day: day, calendar: calendar)-      case .phase5SharedTripOwner,+      case .packingTripStability, .phase5SharedTripOwner,         .phase5SharedTripParticipant,         .phase5MigrationStates:         // Phase 5 fixtures require the dual-container entry point; the
Scramble/Scramble/Sharing/TripSyncEngine+Deletions.swift Added
diff --git a/Scramble/Scramble/Sharing/TripSyncEngine+Deletions.swift b/Scramble/Scramble/Sharing/TripSyncEngine+Deletions.swiftnew file mode 100644index 0000000..e9feb08--- /dev/null+++ b/Scramble/Scramble/Sharing/TripSyncEngine+Deletions.swift@@ -0,0 +1,101 @@+import CloudKit+import Foundation+import SwiftData++extension TripSyncEngine {+  /// Apply tombstones only to the matching CloudKit identity (record name,+  /// zone name, and owner). A UUID alone is not an identity across zones.+  func apply(deletedRecordIDs: [CKRecord.ID]) throws {+    let deletions = Set(deletedRecordIDs)+    let ids = Set(deletedRecordIDs.compactMap { UUID(uuidString: $0.recordName) })+    guard !ids.isEmpty else { return }++    let trips = try context.fetch(+      FetchDescriptor<Trip>(predicate: #Predicate { ids.contains($0.id) }))+    let tasks = try context.fetch(+      FetchDescriptor<TripTask>(predicate: #Predicate { ids.contains($0.id) }))+    let items = try context.fetch(+      FetchDescriptor<TripPackingItem>(predicate: #Predicate { ids.contains($0.id) }))+    let snapshots = try context.fetch(+      FetchDescriptor<TripPersonSnapshot>(predicate: #Predicate { ids.contains($0.id) }))+    let tripIDs = Set(+      trips.map(\.id) + tasks.compactMap { $0.trip?.id }+        + items.compactMap { $0.trip?.id } + snapshots.compactMap { $0.trip?.id })+    let states = try context.fetch(+      FetchDescriptor<TripZoneState>(predicate: #Predicate { tripIDs.contains($0.tripID) }))+    let owners = Dictionary(+      states.map { ($0.tripID, TripZoneStateRecordTranslator.zoneID(for: $0).ownerName) },+      uniquingKeysWith: { first, _ in first })++    let matcher = RecordDeletionMatcher(deletions: deletions, owners: owners)++    // Resolve ownership BEFORE staging any delete: nullification can remove+    // the parent links needed by subsequent checks. Use reverse-cascade order+    // just like TripDeletion to avoid SwiftData snapshot traversal failures.+    let removedTrips = trips.filter {+      matcher.matches($0.id, trip: $0, systemFields: $0.ckRecordSystemFields)+    }+    let removedTripIDs = Set(removedTrips.map(\.id))+    let removedItems = Set(+      items.filter { matcher.matches($0.id, trip: $0.trip, systemFields: $0.ckRecordSystemFields) }+    )+    .union(removedTrips.flatMap { $0.packingItems ?? [] })+    let removedTasks = Set(+      tasks.filter { matcher.matches($0.id, trip: $0.trip, systemFields: $0.ckRecordSystemFields) }+    )+    .union(removedTrips.flatMap { $0.tasks ?? [] })+    let removedSnapshots = Set(+      snapshots.filter {+        matcher.matches($0.id, trip: $0.trip, systemFields: $0.ckRecordSystemFields)+      }+    )+    .union(removedTrips.flatMap { $0.participantSnapshots ?? [] })+    .union(try snapshotsOfTrips(removedTripIDs))+    for item in removedItems { context.delete(item) }+    for task in removedTasks { context.delete(task) }+    for snapshot in removedSnapshots { context.delete(snapshot) }+    for trip in removedTrips { context.delete(trip) }+    for state in states where removedTripIDs.contains(state.tripID) { context.delete(state) }+    try context.save()+  }++  private func snapshotsOfTrips(_ tripIDs: Set<UUID>) throws -> [TripPersonSnapshot] {+    guard !tripIDs.isEmpty else { return [] }+    return try context.fetch(+      FetchDescriptor<TripPersonSnapshot>(+        predicate: #Predicate { snapshot in+          if let trip = snapshot.trip {+            tripIDs.contains(trip.id)+          } else {+            false+          }+        }))+  }++}++@MainActor+private struct RecordDeletionMatcher {+  let deletions: Set<CKRecord.ID>+  let owners: [UUID: String]++  func matches(_ id: UUID, trip: Trip?, systemFields: Data?) -> Bool {+    let zoneID: CKRecordZone.ID+    if let trip {+      let cachedZone = trip.ckRecordSystemFields.flatMap { decodeSystemFields(from: $0) }?+        .recordID.zoneID+      let owner = owners[trip.id] ?? cachedZone?.ownerName ?? CKCurrentUserDefaultName+      zoneID = CKRecordZone.ID(+        zoneName: ZoneMigrationCoordinator.ownerZoneID(for: trip.id).zoneName, ownerName: owner)+    } else {+      // A child can arrive before its trip. Its cached full record identity+      // permits a genuine tombstone without guessing ownership for an orphan.+      guard let cached = systemFields.flatMap({ decodeSystemFields(from: $0) }),+        cached.recordID.recordName == id.uuidString+      else { return false }+      zoneID = cached.recordID.zoneID+    }+    return deletions.contains(CKRecord.ID(recordName: id.uuidString, zoneID: zoneID))+  }++}
Scramble/Scramble/Sharing/TripSyncEngine.swift Modified
diff --git a/Scramble/Scramble/Sharing/TripSyncEngine.swift b/Scramble/Scramble/Sharing/TripSyncEngine.swiftindex f905bc2..be0e885 100644--- a/Scramble/Scramble/Sharing/TripSyncEngine.swift+++ b/Scramble/Scramble/Sharing/TripSyncEngine.swift@@ -280,49 +280,6 @@ final class TripSyncEngine: NSObject, PendingChangeNotifier {     }   } -  /// Apply server-side deletions to the local store. Looks up the records-  /// by `recordName` in one fetch per entity type and deletes the matches.-  /// Skips entries whose record name doesn't parse as a UUID.-  func apply(deletedRecordIDs: [CKRecord.ID]) throws {-    let ids = Set(deletedRecordIDs.compactMap { UUID(uuidString: $0.recordName) })-    guard !ids.isEmpty else { return }--    let trips = try context.fetch(-      FetchDescriptor<Trip>(predicate: #Predicate { ids.contains($0.id) })-    )-    let foundTripIDs = Set(trips.map(\.id))-    // `Trip.participantSnapshots` uses `.nullify` (V3 cascade-traversal-    // workaround for iOS 26.4), so deleting the trip alone leaves the-    // snapshot rows behind. Walk each trip's snapshot collection and-    // remove them explicitly before the trip is deleted.-    for trip in trips {-      for snapshot in trip.participantSnapshots ?? [] {-        context.delete(snapshot)-      }-    }-    for trip in trips { context.delete(trip) }--    let remaining = ids.subtracting(foundTripIDs)-    if !remaining.isEmpty {-      let tasks = try context.fetch(-        FetchDescriptor<TripTask>(predicate: #Predicate { remaining.contains($0.id) })-      )-      for task in tasks { context.delete(task) }--      let items = try context.fetch(-        FetchDescriptor<TripPackingItem>(predicate: #Predicate { remaining.contains($0.id) })-      )-      for item in items { context.delete(item) }--      let snapshots = try context.fetch(-        FetchDescriptor<TripPersonSnapshot>(predicate: #Predicate { remaining.contains($0.id) })-      )-      for snapshot in snapshots { context.delete(snapshot) }-    }--    try context.save()-  }-   // MARK: - Share record outbound    /// Queue a `CKShare` for upload on the private engine. The share is
Scramble/ScrambleTests/Sharing/TripSyncEngineTests.swift Modified
diff --git a/Scramble/ScrambleTests/Sharing/TripSyncEngineTests.swift b/Scramble/ScrambleTests/Sharing/TripSyncEngineTests.swiftindex 2a959f8..abd3212 100644--- a/Scramble/ScrambleTests/Sharing/TripSyncEngineTests.swift+++ b/Scramble/ScrambleTests/Sharing/TripSyncEngineTests.swift@@ -152,7 +152,8 @@ struct TripSyncEngineTests {    // MARK: - Zone-not-found recovery (T-1670) -  @Test("classifyFailedSaves routes zoneNotFound to zone-create + retry, other errors to unrecoverable")+  @Test(+    "classifyFailedSaves routes zoneNotFound to zone-create + retry, other errors to unrecoverable")   func classifyFailedSavesPartitions() {     let zoneA = CKRecordZone.ID(zoneName: "trip-a", ownerName: CKCurrentUserDefaultName)     let zoneB = CKRecordZone.ID(zoneName: "trip-b", ownerName: CKCurrentUserDefaultName)@@ -267,6 +268,163 @@ struct TripSyncEngineTests {    // MARK: - Helpers +  @Test(+    "Foreign tombstones preserve the packing graph",+    arguments: ["legacy", "otherTrip", "otherOwner"], ["trip", "item", "task", "snapshot"])+  func foreignZoneDeletionPreservesPackingTrip(zoneKind: String, entityKind: String) throws {+    let container = try Self.makeContainer()+    let context = container.mainContext+    let engine = TripSyncEngine(+      context: context, container: CKContainer(identifier: "iCloud.test"),+      stateStore: InMemoryTripSyncStateStore())+    let trip = Trip(name: "Synthetic packing", startDate: .now, endDate: .now)+    context.insert(trip)+    let snapshot = TripPersonSnapshot(name: "Fixture", trip: trip)+    context.insert(snapshot)+    let task = TripTask(trip: trip, name: "Fixture task")+    context.insert(task)+    let item = TripPackingItem(trip: trip, name: "Fixture item", personSnapshot: snapshot)+    context.insert(item)+    try context.save()+    let tripID = trip.id+    let zone: CKRecordZone.ID+    switch zoneKind {+    case "otherTrip": zone = ZoneMigrationCoordinator.ownerZoneID(for: UUID())+    case "otherOwner":+      zone = CKRecordZone.ID(zoneName: "trip-\(tripID.uuidString)", ownerName: "foreign-owner")+    default: zone = CKRecordZone.ID(zoneName: "legacy-zone", ownerName: CKCurrentUserDefaultName)+    }+    let id = ["trip": tripID, "item": item.id, "task": task.id, "snapshot": snapshot.id][+      entityKind]!+    item.state = .packed+    try LocalWriteHook(notifier: engine).commit(context)+    try engine.apply(deletedRecordIDs: [CKRecord.ID(recordName: id.uuidString, zoneID: zone)])+    #expect(try context.fetch(FetchDescriptor<Trip>()).map(\.id) == [tripID])+    #expect(try context.fetchCount(FetchDescriptor<TripPackingItem>()) == 1)+    #expect(try context.fetchCount(FetchDescriptor<TripTask>()) == 1)+    #expect(try context.fetchCount(FetchDescriptor<TripPersonSnapshot>()) == 1)+    #expect(item.state == .packed)+  }++  @Test(+    "Genuine private and shared tombstones delete only their own trip graph",+    arguments: ["private", "shared", "defaultOwner"])+  func matchingZoneDeletionRemovesTripGraph(scope: String) throws {+    let container = try Self.makeContainer()+    let context = container.mainContext+    let engine = TripSyncEngine(+      context: context, container: CKContainer(identifier: "iCloud.test"),+      stateStore: InMemoryTripSyncStateStore())+    let trip = Trip(name: "Synthetic deleted trip")+    let survivor = Trip(name: "Synthetic retained trip")+    context.insert(trip)+    context.insert(survivor)+    let survivorID = survivor.id+    let snapshot = TripPersonSnapshot(name: "Fixture", trip: trip)+    context.insert(snapshot)+    context.insert(TripPackingItem(trip: trip, name: "Fixture item", personSnapshot: snapshot))+    context.insert(TripTask(trip: trip, name: "Fixture task"))+    let shared = scope == "shared"+    let owner = shared ? "fixture-owner" : CKCurrentUserDefaultName+    let state = TripZoneState(+      tripID: trip.id, zoneOwnerName: scope == "defaultOwner" ? "" : owner,+      zoneScope: shared ? "shared" : "private")+    context.insert(state)+    try context.save()+    let zone = CKRecordZone.ID(zoneName: "trip-\(trip.id.uuidString)", ownerName: owner)+    try engine.apply(deletedRecordIDs: [CKRecord.ID(recordName: trip.id.uuidString, zoneID: zone)])+    #expect(try context.fetch(FetchDescriptor<Trip>()).map(\.id) == [survivorID])+    #expect(try context.fetchCount(FetchDescriptor<TripPackingItem>()) == 0)+    #expect(try context.fetchCount(FetchDescriptor<TripTask>()) == 0)+    #expect(try context.fetchCount(FetchDescriptor<TripPersonSnapshot>()) == 0)+    #expect(try context.fetchCount(FetchDescriptor<TripZoneState>()) == 0)+  }++  @Test("A child tombstone uses its owning trip zone without deleting its parent")+  func matchingZoneChildDeletionPreservesTrip() throws {+    let container = try Self.makeContainer()+    let context = container.mainContext+    let engine = TripSyncEngine(+      context: context, container: CKContainer(identifier: "iCloud.test"),+      stateStore: InMemoryTripSyncStateStore())+    let trip = Trip(name: "Synthetic retained trip")+    context.insert(trip)+    let item = TripPackingItem(trip: trip, name: "Fixture item")+    context.insert(item)+    try context.save()+    let zone = ZoneMigrationCoordinator.ownerZoneID(for: trip.id)+    try engine.apply(deletedRecordIDs: [CKRecord.ID(recordName: item.id.uuidString, zoneID: zone)])+    #expect(try context.fetchCount(FetchDescriptor<Trip>()) == 1)+    #expect(try context.fetchCount(FetchDescriptor<TripPackingItem>()) == 0)+  }++  @Test("An orphaned child requires its cached full CloudKit identity for deletion")+  func orphanDeletionRequiresCachedIdentity() throws {+    let container = try Self.makeContainer()+    let context = container.mainContext+    let engine = TripSyncEngine(+      context: context, container: CKContainer(identifier: "iCloud.test"),+      stateStore: InMemoryTripSyncStateStore())+    let zone = ZoneMigrationCoordinator.ownerZoneID(for: UUID())+    let item = TripPackingItem(name: "Synthetic orphan")+    context.insert(item)+    let record = try TripPackingItemRecordTranslator.toRecord(item, in: zone)+    item.ckRecordSystemFields = encodeSystemFields(of: record)+    try context.save()+    let foreignZone = ZoneMigrationCoordinator.ownerZoneID(for: UUID())+    try engine.apply(deletedRecordIDs: [+      CKRecord.ID(recordName: item.id.uuidString, zoneID: foreignZone)+    ])+    #expect(try context.fetchCount(FetchDescriptor<TripPackingItem>()) == 1)+    try engine.apply(deletedRecordIDs: [record.recordID])+    #expect(try context.fetchCount(FetchDescriptor<TripPackingItem>()) == 0)+  }++  @Test("Repeated packing saves and sync echoes preserve trips across a disk reopen")+  func packingSavesPreserveTrips() throws {+    let directory = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)+    try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)+    defer { try? FileManager.default.removeItem(at: directory) }+    let schema = Schema(versionedSchema: SchemaV3.self)+    let configuration = ModelConfiguration(+      schema: schema, url: directory.appendingPathComponent("Synthetic.store"),+      cloudKitDatabase: .none)+    let container = try ModelContainer(for: schema, configurations: [configuration])+    let context = container.mainContext+    let engine = TripSyncEngine(+      context: context, container: CKContainer(identifier: "iCloud.test"),+      stateStore: InMemoryTripSyncStateStore())+    let hook = LocalWriteHook(notifier: engine)+    let trip = Trip(name: "Synthetic packing", startDate: .now, endDate: .now)+    context.insert(trip)+    let snapshot = TripPersonSnapshot(name: "Fixture", trip: trip)+    context.insert(snapshot)+    let item = TripPackingItem(trip: trip, name: "Fixture item", personSnapshot: snapshot)+    context.insert(item)+    try hook.commit(context)+    let tripID = trip.id+    let zone = ZoneMigrationCoordinator.ownerZoneID(for: tripID)+    let navigationHash = trip.hashValue+    let persistentID = trip.persistentModelID+    for index in 0..<24 {+      let cycle: [PackingState] = [.packed, .unpacked, .packed, .repacked, .packed, .unpacked]+      item.state = cycle[index % cycle.count]+      try hook.commit(context)+      #expect(try context.fetchCount(FetchDescriptor<Trip>()) == 1)+      let record = try TripPackingItemRecordTranslator.toRecord(item, in: zone)+      try engine.apply(fetchedRecords: [record])+      #expect(item.trip?.id == tripID)+      #expect(trip.hashValue == navigationHash)+      #expect(trip.persistentModelID == persistentID)+      #expect(trip.endDate >= trip.startDate)+    }+    let reopened = try ModelContainer(for: schema, configurations: [configuration])+    let trips = try reopened.mainContext.fetch(FetchDescriptor<Trip>())+    #expect(trips.map(\.id) == [tripID])+    #expect(trips.first?.packingItems?.count == 1)+    #expect(trips.first?.packingItems?.first?.state == .unpacked)+  }+   private static func makeContainer() throws -> ModelContainer {     let schema = Schema(versionedSchema: SchemaV3.self)     let config = ModelConfiguration(
Scramble/ScrambleUITests/PackingSheetUITests.swift Modified
diff --git a/Scramble/ScrambleUITests/PackingSheetUITests.swift b/Scramble/ScrambleUITests/PackingSheetUITests.swiftindex 7643bc6..58cd650 100644--- a/Scramble/ScrambleUITests/PackingSheetUITests.swift+++ b/Scramble/ScrambleUITests/PackingSheetUITests.swift@@ -201,6 +201,39 @@ final class PackingSheetUITests: XCTestCase {     )   } +  /// Packing progress must never remove the owning trip or dismiss its detail.+  @MainActor+  func testRepeatedPackingTogglesPreserveTripAcrossForeground() {+    let app = launchedApp(fixture: "packing-trip-stability")+    openTripDetail(app, tripName: "Synthetic Packing Trip")+    openPackingSheetForFirstParticipant(app)++    let header = app.descendants(matching: .any)+      .matching(identifier: "packingSheet.header").firstMatch+    XCTAssertTrue(header.waitForExistence(timeout: 5))+    for _ in 0..<4 {+      let row = app.descendants(matching: .any)+        .matching(identifier: "packingSheet.itemRow.Fixture item").firstMatch+      XCTAssertTrue(row.waitForExistence(timeout: 3))+      row.buttons["Mark packed"].tap()+      XCTAssertTrue(header.exists, "Checking must keep the packing sheet presented")+      let checkedRow = app.descendants(matching: .any)+        .matching(identifier: "packingSheet.itemRow.Fixture item").firstMatch+      XCTAssertTrue(checkedRow.buttons["Mark not packed"].waitForExistence(timeout: 3))+      checkedRow.buttons["Mark not packed"].tap()+      XCTAssertTrue(header.exists, "Unchecking must keep the packing sheet presented")+    }+    XCUIDevice.shared.press(.home)+    XCTAssertTrue(app.wait(for: .runningBackground, timeout: 5))+    app.activate()+    XCTAssertTrue(header.waitForExistence(timeout: 5))+    app.buttons["Close"].tap()+    XCTAssertTrue(app.staticTexts["Synthetic Packing Trip"].waitForExistence(timeout: 5))+    app.navigationBars.buttons["Trips"].tap()+    XCTAssertTrue(app.buttons["New Trip"].waitForExistence(timeout: 5))+    XCTAssertTrue(app.staticTexts["Synthetic Packing Trip"].exists, "Trip must remain in the list")+  }+   // MARK: - 4. Repack mode    @MainActor

Docs (4)

CHANGELOG.md Modified
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8a1a0b1..b71dc9c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -97,6 +97,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).  ### Fixed +- T-2459: Match complete CloudKit record and zone identities before applying inbound deletions, preventing foreign-zone tombstones from deleting local trips or packing items. Added synthetic packing, persistence, lifecycle and deletion regression coverage.+ - Unit-test flakiness — non-retained `ModelContainer` in test helpers (the dominant cause):   - Seven suites built a SwiftData `ModelContainer` as a local, derived a `ModelContext`/`@Model` from it, and returned only the context (or a struct/context that didn't include the container). A `ModelContext` does not keep its `ModelContainer` alive, so ARC could deallocate it mid-test and the next model access trapped inside SwiftData (`EXC_BREAKPOINT`/`SIGTRAP`). Non-deterministic ARC timing made a different test "crash" each run, with the host restarting and the remaining tests reporting as `0.000s` crashes — i.e. flaky. Confirmed via `~/Library/Logs/DiagnosticReports/Scramble-*.ips` (use-after-dealloc from a model setter called by the test), not the "Xcode 26.5 multi-container toolchain bug" previously assumed.   - Fixed by retaining the container for the caller's lifetime: `Scramble/ScrambleTests/Notifications/NotificationsServiceTests.swift` (`Setup` gains a `container` field), `RulesEngine/RulesEngineRunnerTests.swift` (`MatchedSeed` gains `container`), `Components/PackingItemRowAccessibilityTests.swift` + `Components/TaskRowAccessibilityTests.swift` (`Setup` gains `container`), and the bare-context helpers `Models/PackingItemContentBridgeTests.swift`, `Models/TripPackingItemBridgeTests.swift`, `Explainability/WhyResolverParticipantHideTests.swift` (helper now returns the `ModelContainer`; callers derive the context). Extends the earlier T-1605 fix (`d663be1`) that patched only two of the affected suites. Same root cause that crashed the on-device test host (see `docs/agent-notes/`); test-only change.
specs/bugfixes/trips-disappear-packing/implementation.md Added
diff --git a/specs/bugfixes/trips-disappear-packing/implementation.md b/specs/bugfixes/trips-disappear-packing/implementation.mdnew file mode 100644index 0000000..56a43da--- /dev/null+++ b/specs/bugfixes/trips-disappear-packing/implementation.md@@ -0,0 +1,52 @@+# T-2459 implementation explanation++## Beginner++Each synced record has an address: its name, the zone it belongs to, and the+zone's owner. The old deletion handler kept only the name. A deletion at a+different address could therefore remove a local trip with the same UUID.+The fix checks the complete address before removing anything.++Packing completion does not control the trip list. The synthetic packing tests+retain the trip through check/uncheck actions, background/reactivation and a+return to the trip list. These results do not identify the cause of a historical+incident without its logs or stored data.++## Intermediate++`TripSyncEngine+Deletions.swift` retains incoming `CKRecord.ID` values and fetches+candidate models by UUID. A matcher derives each candidate's owning trip zone+using the existing zone-state translator, including empty-owner normalization.+Without a state row, it uses the trip's cached owner or the private default.+Orphan children require a matching cached record ID rather than guessed ownership.++All matches are resolved before mutation, since deleting a parent can nullify+relationships needed by later checks. Genuine trip deletions collect dependent+records, including snapshots reachable only through their canonical back-reference,+and delete in the existing reverse-cascade order. Inbound changes save locally+without the outgoing `LocalWriteHook`.++The alternative of changing Active/Previous filtering or replacing model-based+navigation had no reproduced failure to justify it. Calling the outgoing trip+removal helper would introduce sync feedback. Neither was adopted.++## Expert++Candidate queries remain UUID-filtered; the zone-state query is bounded by their+owning trip IDs. A root deletion additionally fetches snapshots with a matching+`trip` backlink because the convenience collection is not the declared lifetime+authority. `Set` unions avoid duplicate model deletion when a batch contains both+a root and its child. Ownership is resolved before those relationships mutate.++A missing-parent child can still receive a valid deletion if its cached system+fields establish the full identity. Without either a parent or cached evidence,+the conservative result is preservation. The change has no schema impact and+makes no attempt to repair missing historical data or broaden sync restore policy.++## Completeness assessment++The reproduced foreign-zone local deletion is fixed and has regression coverage.+The synthetic packing path, sync echoes, navigation identity and disk reopening+are covered. Final check outcomes are recorded in `report.md`. The original+last-trip incident and historical data recovery remain unproven. No live trips,+cloud mutations, phone installation or merge are part of this implementation.
specs/bugfixes/trips-disappear-packing/report.md Added
diff --git a/specs/bugfixes/trips-disappear-packing/report.md b/specs/bugfixes/trips-disappear-packing/report.mdnew file mode 100644index 0000000..bf97f76--- /dev/null+++ b/specs/bugfixes/trips-disappear-packing/report.md@@ -0,0 +1,184 @@+# Bugfix Report: Trips disappear during packing (T-2459)++**Date:** 2026-10-14+**Status:** Reproduced sync deletion defect fixed; historical incident unattributed++## Description of the Issue++A user reported that trips disappeared while checking packing items on a trip.+The report does not establish whether the trip left the current screen, moved+into Previous, or was deleted from persistence. No live trips or cloud records+are used by this investigation, and no historical deletion or recovery is claimed.++## Investigation Summary++- Started from current `origin/main` (`0a37052`), including T-1670's separate+  zone creation and reinstall restoration fixes. Original checkout and its+  untracked `.kiro` directory were preserved.+- Trip List filters Active/Previous exclusively by `endDate`; packing completion+  does not participate in the predicate.+- Packing toggles only modify `TripPackingItem.state` and commit through+  `LocalWriteHook`. Rules evaluation flags unmatched items rather than deleting trips.+- Checked the navigation stack, packing sheet dismissal, lifecycle rules pass,+  local write hook, sync translations, and inbound record deletion path.+- Existing legacy packing UI fixtures seed globals while Trips reads tripsLocal;+  a new synthetic fixture uses `TripPersistence.create` across separate containers.+- `TripSyncEngine.apply(deletedRecordIDs:)` discards each deletion's zone identity,+  then deletes models with matching UUIDs. A focused regression supplies a foreign+  zone tombstone after a packing save; the pre-fix test failed both trip and packing-item retention assertions.++## Discovered Root Cause++Verified synthetic defect: the inbound deletion handler reduces CloudKit record IDs+to bare UUIDs, losing zone name and owner. A tombstone from `legacy-zone` with the+same record name as a current trip removes the current local trip and cascades its+packing items. The regression failed both retention assertions before the fix.++Why: incoming deletions trigger local fetches by UUID; the owning namespace was+discarded before those fetches; the local identity schema has only UUID fields;+existing tests did not exercise foreign-zone deletion. This is a sync identity+validation defect, not a packing-completion filter.++The pre-fix ordinary packing saves plus synthetic record echoes preserved the trip,+its navigation identity/hash, relationships, and final packing state across a+SQLite reopen. The focused UI test passed in 116.786 seconds, including eight check/uncheck+actions, background/reactivation, sheet dismissal, and final trip-list retention.+The activation step had a long XCTest delay; a stack sample showed the synthetic+app's main thread idle. The surrounding make command was interrupted during+teardown, so this is a passed test with an interrupted command, not a clean run exit.++The reported last-trip event has no device log or store evidence available.+Matching historical foreign-zone tombstones have not been observed. This defect+is verified, but attribution of the historical report remains unproven.++## Resolution for the Issue++- Match full CloudKit identity before staging any delete. Owning trip zones are+  derived from the canonical `TripZoneStateRecordTranslator.zoneID(for:)`, retaining+  its empty-owner normalization. Trips without a zone row use cached owner identity+  or the private-database default. An orphan child requires its exact cached identity.+- Resolve all candidates before mutation, then remove items, tasks, snapshots,+  trips and corresponding zone rows in reverse-cascade order. Snapshot cleanup+  includes the canonical `snapshot.trip` backlink as well as the convenience array.+- Keep inbound saves local; reuse of `TripDeletion.delete` would wrongly invoke+  the outgoing write hook and echo server deletions.+- No schema migration, recovery operation, cloud mutation, or phone installation.+- Added `TEST_ARGS` to Makefile test recipes for focused selectors; the default+  full-suite command is unchanged.++This is a narrow correction of sync identity matching. Changing trip filters or+navigation without a reproduced failure was rejected as speculative. Restoring+historical trips requires separate evidence about the local store and server data.++## Regression Tests++`PackingSheetUITests.testRepeatedPackingTogglesPreserveTripAcrossForeground`:+repeated check/uncheck, background/reactivation, sheet dismissal, and trip-list return.++`TripSyncEngineTests.packingSavesPreserveTrips`: repeated commits and synthetic+full-record echoes, then reopen a temporary SQLite store; CloudKit is disabled.++`TripSyncEngineTests.foreignZoneDeletionPreservesPackingTrip`: 12 combinations+cover legacy zone, another trip zone and another owner against root/item/task/snapshot.+All graph rows and the packing state must remain.++`matchingZoneDeletionRemovesTripGraph`: genuine private/shared/default-owner+root deletions remove only the targeted graph. `matchingZoneChildDeletionPreservesTrip`+checks child-only deletion. `orphanDeletionRequiresCachedIdentity` checks cached+full-identity matching for children whose parent has not arrived.++The final disk regression performs 24 transitions through unpacked, packed and+repacked, validates navigation hash/identity, and reopens the synthetic SQLite store.++## Verification++All tests use synthetic data, `.none` for CloudKit persistence, an engine that is+never started, and retained ModelContainers. The UI uses an in-memory two-store+fixture and a dedicated empty iOS 27.0 simulator.++- Red: focused `TripSyncEngineTests` ran 17 tests; one intended foreign-zone test+  failed both trip and packing-item retention assertions; 16 passed. The make+  command was terminated after native results during stalled teardown.+- Initial green: expanded `TripSyncEngineTests` ran 20 declarations, including 12+  foreign-zone and two genuine-deletion parameter cases; all passed. This precedes+  the review refinements (default-owner case and canonical snapshot cleanup).+- Focused UI: lifecycle regression passed; command interrupted during teardown.+- Strict lint: `swiftlint lint --strict --no-cache` passed, zero violations across+  228 files. `make lint` initially encountered the sandboxed user-cache write;+  the equivalent no-cache invocation avoids it.+- Final focused run: `make test SIMULATOR='Scramble Packing Regression 20261015,OS=27.0'+  XCBEAUTIFY= TEST_ARGS='-parallel-testing-enabled NO+  -only-testing:ScrambleTests/TripSyncEngineTests+  -only-testing:ScrambleUITests/PackingSheetUITests/testRepeatedPackingTogglesPreserveTripAcrossForeground'`+  completed with exit 0 and `TEST SUCCEEDED`. Native xcresult summary: 21 passed+  declarations (20 sync + one UI), zero failures/skips; dynamic parameters account+  for 34 executions, including 12 foreign-zone and three genuine-deletion cases.+  UI regression: 32.854 seconds. Result: `Test-Scramble-2026.10.15_10-15-25-+1100.xcresult`.+- Required full suite: completed once on unchanged Swift source, result bundle+  `/tmp/scramble-full-final.xcresult`; `make` exited 2 after xcodebuild exited 65.+  Native summary: **806 passed, 38 failed, 12 skipped, 856 total declarations**.+  All unit suites passed (`785 tests in 93 suites` in Swift Testing's log).+  UI results: 27 passed, 38 failed, nine skipped. The new packing regression passed.+  A single targeted retry of exactly those 38 methods on unchanged baseline app/test+  source at `0a37052721da3b5bd0c8a0a99e019ab82511dc8f` failed all 38 again.+  These UI failures predate this fix. Native retry results completed (38 failures in+  580.604 seconds); Xcode then stalled in result-bundle finalisation for over three+  minutes, so only that runner was terminated. The complete native log is retained;+  its incomplete xcresult is not treated as structured evidence. No full-suite+  rerun was performed.++See [verification.md](verification.md) for exact failed methods, commands, result+bundles, and the full/baseline comparison.++Default simulator lookup was ambiguous; an explicit dedicated simulator and+`-parallel-testing-enabled NO` avoid unrelated cloned-device startup delays.++## Review++Independent code quality, reuse, efficiency and evidence reviews completed.+Reuse review identified empty-owner normalization; the canonical resolver and a+regression were added. Quality review prompted canonical snapshot backlink cleanup.+Evidence review corrected a test-result attribution. No personal trips or secrets+were included in the reviewed diff.++## Historical Data and Recovery Limits++No historical trip store, device logs or live cloud data was inspected. The fix+prevents the reproduced wrong-zone local deletion; it does not establish that any+particular past trip was deleted, that a matching foreign tombstone occurred, or+that anything was recovered. The earlier T-1670 reinstall fix is already in the base.++## Prevention++Keep complete CloudKit record IDs through the inbound deletion boundary; never+substitute bare UUID equality for zone/owner identity. Keep synthetic UI fixture+store topology aligned with production, and test both preservation and genuine+deletion so a guard cannot silently disable sync removal.++## Related++- Transit **T-2459**, Scramble.+- [Draft PR #19](https://github.com/ArjenSchwarz/scramble/pull/19).++## PR Review Dispositions++The automated `claude-review` check passed on the code commit. Its required+baseline-attribution condition is resolved by the one retry: all 38 failed UI+methods also failed on unchanged main-source baseline `0a37052`.++The remaining suggestions were reviewed without changing the tested Swift source:++- Missing owner evidence can leave a stale shared trip rather than accepting a+  tombstone with unproven identity. This conservative preservation is intentional.+- An orphan child without cached system fields is preserved; the implementation+  explanation already records this limitation. No orphan repair is claimed.+- Zone names remain `trip-{UUID}` under `ZoneMigrationCoordinator.zoneName(for:)`.+  `TripZoneState` stores the trip UUID and owner, not an arbitrary alternate zone+  name; Stage B relocates between local containers using this canonical name.+  Accepting a foreign cached zone would undermine this bug's boundary guard.+- Debug fixture save/date style matches the existing seed conventions. Missing+  fixture data fails the UI assertions; strict formatting/lint are already clean.+- Repeated cache decoding is immaterial at the bounded batch size, consistent with+  the independent efficiency review. No speculative optimization was added.+- A Makefile comment now makes clear that narrow selectors should use `make test`;+  `test-ui` / `test-quick` keep their existing broad bundle selectors.
specs/bugfixes/trips-disappear-packing/verification.md Added
diff --git a/specs/bugfixes/trips-disappear-packing/verification.md b/specs/bugfixes/trips-disappear-packing/verification.mdnew file mode 100644index 0000000..2c16cf4--- /dev/null+++ b/specs/bugfixes/trips-disappear-packing/verification.md@@ -0,0 +1,114 @@+# T-2459 verification record++## Final source checks++The app and test Swift files stayed byte-identical through the final focused run,+the single full run, and publication. No source changes followed those runs.++| Run | Result |+| --- | --- |+| Focused final (fix + review refinements) | 21 declarations passed; zero failures/skips; 34 executions including dynamic parameters. `make` exit 0. |+| Single full suite | 806 passed, 38 failed, 12 skipped (856 declarations); all unit suites passed. `make` exit 2 / xcodebuild exit 65. |+| One baseline retry, source `0a37052721da3b5bd0c8a0a99e019ab82511dc8f` | All 38 failed UI methods failed again; zero passes. Native suite duration 580.604 seconds. Xcode stalled in bundle finalisation for over three minutes; only the runner was terminated after native completion. The complete log establishes all 38 failures; the baseline xcresult is incomplete. `make` returned 2 after xcodebuild was terminated (143). |+| Strict lint | `swiftlint lint --strict --no-cache`: zero violations across 228 files. |++Native full-suite UI totals were 27 passed, 38 failed, nine skipped. The new packing+lifecycle regression passed both focused and full runs. The live CloudKit harness+was skipped. No live trip store or cloud mutation was part of verification.++## Full and baseline failure comparison++| Existing UI class | Failed in full run | Failed on unchanged baseline |+| --- | ---: | ---: |+| `ColdLaunchSequencingUITests` | 1 | 1 |+| `PackingSheetUITests` | 12 | 12 |+| `PackingSubItemsUITests` | 1 | 1 |+| `PersonDeletionGuardUITests` | 1 | 1 |+| `Phase5MigrationStateUITests` | 2 | 2 |+| `Phase5SharingUITests` | 6 | 6 |+| `RootNavigationUITests` | 3 | 3 |+| `RulesEnginePopulationUITests` | 2 | 2 |+| `TimelineAndTaskUITests` | 7 | 7 |+| `TripCRUDUITests` | 2 | 2 |+| `TripEditorPickerReactivityUITests` | 1 | 1 |++These are pre-existing UI check failures. The legacy trip fixtures seed globals+while today’s Trips UI reads tripsLocal; several tests fail before reaching their+intended interaction. Migration/sharing and picker checks also fail on baseline.+Their individual root causes were not expanded into this sync bugfix. No unrelated+tickets were created and no failing expectations were weakened.++### Exact failed UI selectors++- `ScrambleUITests/ColdLaunchSequencingUITests/testColdLaunchScanCompletesBeforeAutoOpen`+- `ScrambleUITests/PackingSheetUITests/testAddManualItemAppearsInUnpacked`+- `ScrambleUITests/PackingSheetUITests/testInnerFormSwipeDownKeepsPackingSheet`+- `ScrambleUITests/PackingSheetUITests/testLeftBehindRowIsReadOnly`+- `ScrambleUITests/PackingSheetUITests/testPackModeCheckboxTogglesState`+- `ScrambleUITests/PackingSheetUITests/testPackingSummaryRendersInDayBeforePhase`+- `ScrambleUITests/PackingSheetUITests/testPhaseSublineCombined`+- `ScrambleUITests/PackingSheetUITests/testRenameViaSwipe`+- `ScrambleUITests/PackingSheetUITests/testRepackOpensFromDayBeforeReturn`+- `ScrambleUITests/PackingSheetUITests/testRestoreReverses`+- `ScrambleUITests/PackingSheetUITests/testSheetCounterIncludesDimmed`+- `ScrambleUITests/PackingSheetUITests/testSkipMovesItemToNotBringing`+- `ScrambleUITests/PackingSheetUITests/testTappingSummaryRowOpensSheet`+- `ScrambleUITests/PackingSubItemsUITests/testAddRemoveAndReadOnlySubItem`+- `ScrambleUITests/PersonDeletionGuardUITests/testPersonOwningMasterPackingItemCannotBeDeleted`+- `ScrambleUITests/Phase5MigrationStateUITests/testFailedMigrationRowAppearsInRetryBanner`+- `ScrambleUITests/Phase5MigrationStateUITests/testStageBInProgressTripShowsSyncingBadge`+- `ScrambleUITests/Phase5SharingUITests/testOwnerSideTapPresentsManageParticipantsAffordance`+- `ScrambleUITests/Phase5SharingUITests/testParticipantsSectionDisplayNameFallbackChain`+- `ScrambleUITests/Phase5SharingUITests/testParticipantsSectionDistinguishesPendingFromAccepted`+- `ScrambleUITests/Phase5SharingUITests/testParticipantsSectionIsReadOnlyForParticipants`+- `ScrambleUITests/Phase5SharingUITests/testShareButtonHiddenForParticipant`+- `ScrambleUITests/Phase5SharingUITests/testShareButtonVisibleForOwner`+- `ScrambleUITests/RootNavigationUITests/testAutoOpenDoesNotRefireOnTabSwitch`+- `ScrambleUITests/RootNavigationUITests/testColdLaunchOneQualifyingTripAutoOpensDetail`+- `ScrambleUITests/RootNavigationUITests/testTabBarHiddenOnDetailRestoredOnPop`+- `ScrambleUITests/RulesEnginePopulationUITests/testCreateTripPopulatesMatchingMasterPackingItem`+- `ScrambleUITests/RulesEnginePopulationUITests/testEditTripAttributesPopulatesMatchingMasterPackingItem`+- `ScrambleUITests/TimelineAndTaskUITests/testAccordionAutoExpandsCurrentPhase`+- `ScrambleUITests/TimelineAndTaskUITests/testAssigneePickerEmptyParticipants`+- `ScrambleUITests/TimelineAndTaskUITests/testCheckboxToggleAndStrikethrough`+- `ScrambleUITests/TimelineAndTaskUITests/testManualTaskAddPersistsAcrossLaunch`+- `ScrambleUITests/TimelineAndTaskUITests/testOnlyOnePhaseExpandedAtATime`+- `ScrambleUITests/TimelineAndTaskUITests/testRuleDeletionPersistsAcrossReevaluation`+- `ScrambleUITests/TimelineAndTaskUITests/testSwipeRevealsEditAndDelete`+- `ScrambleUITests/TripCRUDUITests/testDeleteTripRemovesItFromList`+- `ScrambleUITests/TripCRUDUITests/testEditTripAttributesUpdatesChips`+- `ScrambleUITests/TripEditorPickerReactivityUITests/testNewPersonCreatedInlineAppearsInPickerWithoutLeavingEditor`++## Reproduction commands++Focused final:++```sh+make test SIMULATOR='Scramble Packing Regression 20261015,OS=27.0' XCBEAUTIFY= \+  TEST_ARGS='-parallel-testing-enabled NO -only-testing:ScrambleTests/TripSyncEngineTests -only-testing:ScrambleUITests/PackingSheetUITests/testRepeatedPackingTogglesPreserveTripAcrossForeground'+```++Required full run (executed once):++```sh+make test SIMULATOR='Scramble Packing Regression 20261015,OS=27.0' XCBEAUTIFY= \+  TEST_ARGS='-parallel-testing-enabled NO -resultBundlePath /tmp/scramble-full-final.xcresult'+```++The baseline retry used the same dedicated empty simulator, baseline app/test source,+and only the 38 selectors above. Its sole checkout modification added `$(TEST_ARGS)`+forwarding to Makefile test recipes; no app or test code was changed. The exact+argument vector is retained at `/tmp/scramble-review-inputs/baseline-retry-command.json`.++## Retained local evidence++- Focused result: `DerivedData/Logs/Test/Test-Scramble-2026.10.15_10-15-25-+1100.xcresult`.+- Full result and log: `/tmp/scramble-full-final.xcresult`, `/tmp/scramble-full-final.log`.+- Baseline complete native log: `/tmp/scramble-baseline-retry.log`; `/tmp/scramble-baseline-retry.xcresult` is incomplete after stalled bundle finalisation and is not used as structured evidence.+- Structured results, JUnit conversion and source hashes: `/tmp/scramble-review-inputs/`.++## Unrun and unproven++- Physical-device and live CloudKit validation were not run.+- Historical last-trip deletion, its triggering event, and data recovery remain unproven.+- The fix prevents the reproduced foreign-zone local deletion; it is not a recovery operation.

Things to double-check

Historical data

No historical local/cloud data was examined or recovered. The PR prevents the synthetic defect and does not establish the past incident’s cause.

Baseline result bundle

The native baseline suite completed with 38/38 failures. Xcode stalled during bundle finalisation and was terminated; its complete log supports the comparison, and its incomplete xcresult is not used as structured evidence.