Latency follow-up on PR17; next-day and full-timer restart behavior preserved.
Inactive timer discovery avoids ownership scans; companion run projection shares one synchronous read scope.
Pending reconciliation, fresh mutation authorization and save-before-feedback ordering remain intact.
The initial UI gate exposed an inherited downward-swipe test bug. Its reviewed correction retains every assertion; focused and full reruns passed.
Four regular regression declarations were added. The separate benchmark.swift fixture is documentation outside all build targets.
Ready to push
Four independent source reviews completed, their fixture/coverage findings fixed, and the final serial native gate passed. The optimized unchanged benchmark reduces conditional observer-inclusive actions from about 2.1 seconds to 0.30–0.35 seconds at 25 retained timers.
working-tree Reduce routine observer latency and retain ownership/feedback contracts Finished timers remain in history but no longer slow down the next action by repeatedly checking the entire store. Temporary lookup results make Watch history cheaper to prepare.
Existing deadlines reconcile first. New discovery excludes inactive checkpoints and uses an operation-local ownership index for eligible running timers. Companion projection uses existing scoped definition/progress methods plus equivalent scoped lifecycle validation.
The scope never survives a mutation, suspension or later action. It ends before scheduling callbacks. Foreground catch-up and pending deadlines retain fresh checks. The repair removes retained-inactive-history amplification without claiming every active-timer path is globally linear.
Meddy/Meddy/Services/PhoneRoundAlertService.swift
Why it matters. Removes measured seconds of inline post-save work.
What to look at. runningTimer, discover, refresh, setActive
Meddy/Meddy/Services/PhoneCompanionService.swift
Why it matters. Avoids repeated inventory reads per retained run.
What to look at. snapshot, companionRun
Meddy/MeddyTests/MeddyPhoneRoundAlertTests.swift
Why it matters. Protects cancellation, owner isolation and save-before-feedback.
What to look at. discoveryRejectsInvalidRunningOwnersAndRechecksPendingLifecycle; corruptPendingCheckpointCancelsBeforeDiscoveringAnotherRunningTimer
Meddy/MeddyUITests/MeddyMedicationClassificationUITests.swift
Why it matters. The previous downward swipe could dismiss the sheet when hardware input hid the keyboard.
What to look at. choose
| Severity | Area | Finding | Resolution |
|---|---|---|---|
| major | Synthetic fixture | Cloned retained runs omitted encoded action IDs; initial test also had compile errors. | Copy encoded IDs, use valid timer enum and throwing assertions. |
| major | Running discovery coverage | Inactive-only fixture never entered the new scoped running filter. | Added mixed valid/stale/cross-owner/duplicate and corrupt-pending tests. |
| major | Existing UI test | Keyboard-dismiss swipe dismissed the medication editor. | Tap reachable picker or use bounded interior gesture; retain all assertions and rerun native UI gates. |
Source: local run at 2026-10-28T08:30:25.954474+00:00 · snapshot 1006abafb052f21a292d358840f1811de9fd2d1f (dirty working tree)
Baseline: none
Execution: passed · JUnit: 3 files · Coverage: none · Baseline: absent
Coverage scope: as the project configures it
Totals: 416 passed · 0 failed · 0 skipped · 0 errored · 0 flaky
Derived by declaration name, from the diff (no baseline run).
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 1006aba.
14 files: 6 code · 8 docs. Click to expand.
diff --git a/Meddy/Meddy/Services/PhoneCompanionService.swift b/Meddy/Meddy/Services/PhoneCompanionService.swiftindex 68539af..c9780a3 100644--- a/Meddy/Meddy/Services/PhoneCompanionService.swift+++ b/Meddy/Meddy/Services/PhoneCompanionService.swift@@ -177,7 +177,9 @@ final class PhoneCompanionService { calendar: .current) : [], schedule: item.kindRaw == "ordered" ? try schedules.snapshot(item) : nil) }- let runValues = try runs.map { try companionRun($0, service: service) }+ // One synchronous projection; never reuse this ownership index for a later action.+ let runScope = try ProfileAccess.ReadScope(context: context)+ let runValues = try runs.map { try companionRun($0, service: service, scope: runScope) } let revision = AppEnvironment.isTesting ? 1 : UserDefaults.standard.integer(forKey: "meddy.phone.snapshot-revision") + 1@@ -222,10 +224,11 @@ final class PhoneCompanionService { return value } private func companionRun(- _ item: RoutineRun, service: RoutineSessionService+ _ item: RoutineRun, service: RoutineSessionService, scope: ProfileAccess.ReadScope ) throws -> CompanionRun { var value = CompanionRun(- id: item.id, definition: try service.definition(item), progress: try service.progress(item),+ id: item.id, definition: try service.definition(item, scope: scope),+ progress: try service.progress(item, scope: scope), timer: try item.timerCheckpointData.map { try JSONDecoder().decode(TimerCheckpoint.self, from: $0) }, status: SessionPhase(rawValue: item.statusRaw) ?? .needsReview,@@ -238,7 +241,7 @@ final class PhoneCompanionService { value.ownershipVersion = item.ownershipVersion value.profileLifecycleID = item.profileLifecycleID ?? ProfileIdentity.selfLifecycle if value.profileID != ProfileIdentity.me,- value.profileLifecycleID != (try ProfileAccess.lifecycle(item, context: context)) {+ value.profileLifecycleID != (try scope.lifecycle(item)) { value.status = .paused if var timer = value.timer, timer.phase == .running { timer.phase = .interrupted
diff --git a/Meddy/Meddy/Services/PhoneRoundAlertService.swift b/Meddy/Meddy/Services/PhoneRoundAlertService.swiftindex d80b6c9..46ae8b7 100644--- a/Meddy/Meddy/Services/PhoneRoundAlertService.swift+++ b/Meddy/Meddy/Services/PhoneRoundAlertService.swift@@ -85,7 +85,7 @@ final class PhoneRoundAlertService { // for that deadline. Reconcile the saved boundary without duplicating that alert. do { for run in try context.fetch(FetchDescriptor<RoutineRun>())- where run.timerCheckpointData != nil && owns(run) {+ where runningTimer(run) != nil && owns(run) { let service = RoutineSessionService(context: context) guard let timer = try? service.timer(run), timer.phase == .running else { continue } if timer.deadline.map({ $0 <= clock().wall }) == true@@ -124,12 +124,10 @@ final class PhoneRoundAlertService { pending.removeValue(forKey: id) } }- // Untimed history cannot have a deadline. Pending entries above still reconcile- // removal/corruption before discovery, and actual timer actions revalidate ownership.- for run in runs where run.timerCheckpointData != nil && owns(run) {- guard let timer = try? service.timer(run), timer.phase == .running,- let deadline = timer.deadline- else { continue }+ // Reconcile pending entries before filtering discovery: removed/corrupt checkpoints+ // and completed rounds must still cancel old deadlines and deliver saved feedback.+ for (run, timer) in try discover(runs) {+ guard let deadline = timer.deadline else { continue } if let existing = pending[run.id], existing.round == timer.roundIndex, existing.deadline == deadline { continue@@ -146,6 +144,30 @@ final class PhoneRoundAlertService { } catch { onError(error.localizedDescription) } } + private func runningTimer(_ run: RoutineRun) -> TimerCheckpoint? {+ guard let data = run.timerCheckpointData,+ let timer = try? JSONDecoder().decode(TimerCheckpoint.self, from: data),+ timer.phase == .running+ else { return nil }+ return timer+ }+ private func discover(_ runs: [RoutineRun]) throws -> [(RoutineRun, TimerCheckpoint)] {+ let candidates = runs.compactMap { run -> (RoutineRun, TimerCheckpoint)? in+ guard let timer = runningTimer(run), timer.deadline != nil else { return nil }+ return (run, timer)+ }+ guard !candidates.isEmpty else { return [] }+ // End the read scope before scheduling callbacks. Actual deadline actions revalidate.+ let scope = try ProfileAccess.ReadScope(context: context)+ return candidates.filter { run, _ in+ (try? scope.owner(run)) != nil+ && (run.profileID == ProfileIdentity.me+ || run.profileLifecycleID == (try? scope.lifecycle(run)))+ && !run.isDeleted && run.statusRaw != "needsReview"+ && (run.executionDeviceID == nil || run.executionDeviceID == deviceID)+ }+ }+ private func complete(_ id: UUID, token: UUID) { guard active, let expected = pending[id], expected.token == token else { return } do {
diff --git a/Meddy/Meddy/Services/ProfileAccess.swift b/Meddy/Meddy/Services/ProfileAccess.swiftindex 19ff7c9..e7c0561 100644--- a/Meddy/Meddy/Services/ProfileAccess.swift+++ b/Meddy/Meddy/Services/ProfileAccess.swift@@ -99,6 +99,11 @@ import SwiftData try ProfileAccess.validateLinks(value, owner: id, matching: { rows[$0] ?? [] }) return id }+ func lifecycle(_ value: any ProfileOwned) throws -> UUID {+ let id = try owner(value)+ return try ProfileAccess.profile(id, profiles: profiles)?.lifecycleID+ ?? ProfileIdentity.selfLifecycle+ } func visible(_ value: any ProfileOwned, for id: UUID) -> Bool { (try? owner(value)) == id }
diff --git a/Meddy/MeddyTests/MeddyPhoneRoundAlertTests.swift b/Meddy/MeddyTests/MeddyPhoneRoundAlertTests.swiftindex bb56d82..41af6ee 100644--- a/Meddy/MeddyTests/MeddyPhoneRoundAlertTests.swift+++ b/Meddy/MeddyTests/MeddyPhoneRoundAlertTests.swift@@ -194,6 +194,85 @@ struct MeddyPhoneRoundAlertTests { old.action() #expect(old.cancelled && buzzes == 0) }+ @Test func discoveryRejectsInvalidRunningOwnersAndRechecksPendingLifecycle() throws {+ let store = try AppEnvironment.makeContainer(isolated: true)+ let context = store.mainContext+ defer { MutationEffects.remove(context) }+ let profile = CareProfile(displayName: "Synthetic timer owner")+ context.insert(profile)+ let routine = try RoutineService(context: context).createTimed(+ name: "Synthetic owned timer", rounds: 2, durationSeconds: 10, profileID: profile.id)+ let service = RoutineSessionService(context: context)+ let valid = try service.start(routine, deviceID: "phone")+ let sample = ClockSample(wall: Date(), monotonic: 100, continuityID: "synthetic")+ try service.changeTimer(valid, actionID: UUID(), clock: sample, operation: .start)+ var candidates: [RoutineRun] = []+ for _ in 0..<3 {+ let candidate = RoutineRun(routine: routine)+ candidate.profileLifecycleID = profile.lifecycleID+ candidate.definitionSnapshotData = valid.definitionSnapshotData+ candidate.stepProgressData = valid.stepProgressData+ candidate.timerCheckpointData = valid.timerCheckpointData+ candidate.processedActionIDsData = valid.processedActionIDsData+ context.insert(candidate)+ candidates.append(candidate)+ }+ candidates[0].profileLifecycleID = UUID()+ candidates[1].profileID = ProfileIdentity.me+ let collision = Medication(name: "Synthetic duplicate identity")+ collision.id = candidates[2].id+ context.insert(collision)+ try context.save()+ let scheduler = SyntheticDeadlineScheduler()+ var buzzes = 0+ let alerts = PhoneRoundAlertService(+ context: context, scheduler: scheduler, clock: { sample },+ feedback: { buzzes += 1 }, keepAwake: { _ in })+ alerts.deviceID = "phone"+ alerts.setActive(true)+ alerts.refresh()+ let pending = try #require(scheduler.entries.first)+ #expect(scheduler.entries.count == 1 && !pending.cancelled)+ profile.lifecycleID = UUID()+ try context.save()+ alerts.refresh()+ pending.action()+ #expect(pending.cancelled && scheduler.entries.count == 1 && buzzes == 0)+ #expect(try service.timer(valid).completedRounds == 0)+ #expect(!context.hasChanges)+ }++ @Test func corruptPendingCheckpointCancelsBeforeDiscoveringAnotherRunningTimer() throws {+ let (store, first, service) = try fixture()+ let context = store.mainContext+ defer { MutationEffects.remove(context) }+ let second = try service.start(try #require(first.routine))+ var sample = ClockSample(wall: Date(), monotonic: 100, continuityID: "synthetic")+ try service.changeTimer(first, actionID: UUID(), clock: sample, operation: .start)+ let scheduler = SyntheticDeadlineScheduler()+ var buzzes = 0+ var savedAtFeedback = false+ let alerts = PhoneRoundAlertService(+ context: context, scheduler: scheduler, clock: { sample },+ feedback: { buzzes += 1; savedAtFeedback = !context.hasChanges }, keepAwake: { _ in })+ alerts.setActive(true)+ let obsolete = try #require(scheduler.entries.first)+ second.timerCheckpointData = first.timerCheckpointData+ first.timerCheckpointData = Data([0xFF])+ try context.save()+ alerts.refresh()+ let fresh = try #require(scheduler.entries.last)+ #expect(obsolete.cancelled && fresh !== obsolete && scheduler.entries.count == 2)+ obsolete.action()+ #expect(buzzes == 0)+ sample.wall = sample.wall.addingTimeInterval(10)+ sample.monotonic += 10+ fresh.action()+ fresh.action()+ #expect(buzzes == 1 && savedAtFeedback)+ #expect(try service.timer(second).phase == .waiting)+ }+ @Test func removedTimerCheckpointStillCancelsPreviouslyScheduledDeadline() throws { let (store, run, service) = try fixture() defer { MutationEffects.remove(store.mainContext) }
diff --git a/Meddy/MeddyUITests/MeddyMedicationClassificationUITests.swift b/Meddy/MeddyUITests/MeddyMedicationClassificationUITests.swiftindex 585b9b8..d84b212 100644--- a/Meddy/MeddyUITests/MeddyMedicationClassificationUITests.swift+++ b/Meddy/MeddyUITests/MeddyMedicationClassificationUITests.swift@@ -41,7 +41,15 @@ import XCTest private func choose(_ title: String, app: XCUIApplication) { let picker = app.buttons["medicationClassificationPicker"] XCTAssertTrue(picker.waitForExistence(timeout: 5))- if app.keyboards.firstMatch.exists { app.collectionViews.firstMatch.swipeDown() }+ // A downward swipe can dismiss the editor sheet when hardware input hides the keyboard.+ // Tap an already reachable picker; otherwise reveal it with the editor's interior gesture.+ if !picker.isHittable {+ let form = app.collectionViews["medicationEditorForm"]+ form.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.45))+ .press(forDuration: 0.05, thenDragTo:+ form.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.15)))+ }+ XCTAssertTrue(picker.isHittable) picker.tap() app.buttons[title].tap() }
diff --git a/Users/arjen/Documents/Codex/2026-10-28/task/meddy/Meddy/MeddyTests/MeddyRoutineObserverPerformanceTests.swift b/Users/arjen/Documents/Codex/2026-10-28/task/meddy/Meddy/MeddyTests/MeddyRoutineObserverPerformanceTests.swiftnew file mode 100644index 0000000..4020ef8--- /dev/null+++ b/Users/arjen/Documents/Codex/2026-10-28/task/meddy/Meddy/MeddyTests/MeddyRoutineObserverPerformanceTests.swift@@ -0,0 +1,84 @@+import Foundation+import SwiftData+import Testing++@testable import Meddy++#if DEBUG || MEDDY_PERFORMANCE_TESTING+@MainActor+struct MeddyRoutineObserverPerformanceTests {+ @Test(arguments: [0, 25, 100])+ func inactiveTimersDoNotMultiplyAlertOrCompanionOwnershipReads(count: Int) throws {+ let store = try AppEnvironment.makeContainer(isolated: true)+ let context = store.mainContext+ defer { MutationEffects.remove(context); ProfileAccess.inspectedRows = nil }+ let routine = try RoutineService(context: context).createTimed(+ name: "Synthetic history", rounds: 2, durationSeconds: 60)+ let service = RoutineSessionService(context: context)+ let template = try service.start(routine)+ let phases: [TimerPhase] = [.ready, .paused, .waiting, .interrupted, .completed, .ended]+ for index in 0..<count {+ let run = RoutineRun(routine: routine)+ run.definitionSnapshotData = template.definitionSnapshotData+ run.stepProgressData = template.stepProgressData+ run.processedActionIDsData = template.processedActionIDsData+ var timer = try service.timer(template)+ timer.phase = phases[index % phases.count]+ run.timerCheckpointData = try JSONEncoder().encode(timer)+ context.insert(run)+ }+ try context.save()+ let alerts = PhoneRoundAlertService(context: context, feedback: {}, keepAwake: { _ in })+ var rows = 0+ ProfileAccess.inspectedRows = { rows += $0 }+ alerts.setActive(true)+ alerts.refresh()+ #expect(rows == 0)+ let snapshot = try PhoneCompanionService(context: context).snapshot()+ #expect(snapshot.runs.count == count + 1)+ // Constant scans of the complete owned inventory, independent of retained run count.+ #expect(rows <= 12 * (count + 2))+ #expect(!context.hasChanges)+ }++ @Test func companionProjectionRechecksLifecycleAndLinksOnEverySnapshot() throws {+ let store = try AppEnvironment.makeContainer(isolated: true)+ let context = store.mainContext+ let profile = CareProfile(displayName: "Synthetic owner")+ context.insert(profile)+ let routine = try RoutineService(context: context).createTimed(+ name: "Synthetic timer", rounds: 2, durationSeconds: 60)+ let service = RoutineSessionService(context: context)+ let run = try service.start(routine)+ let clock = ClockSample(wall: Date(), monotonic: 100, continuityID: "synthetic")+ try service.changeTimer(run, actionID: UUID(), clock: clock, operation: .start)+ routine.profileID = profile.id+ run.profileID = profile.id+ run.profileLifecycleID = profile.lifecycleID+ var definition = try JSONDecoder().decode(FrozenRoutineDefinition.self, from: run.definitionSnapshotData)+ definition.profileID = profile.id+ definition.profileLifecycleID = profile.lifecycleID+ run.definitionSnapshotData = try JSONEncoder().encode(definition)+ try context.save()+ let companion = PhoneCompanionService(context: context)+ let first = try #require(companion.snapshot().runs.first)+ #expect(first.timer?.phase == .running)+ #expect(try first.definition == service.definition(run))+ #expect(try first.progress == service.progress(run))+ profile.lifecycleID = UUID()+ try context.save()+ let stale = try #require(companion.snapshot().runs.first)+ #expect(stale.status == .paused && stale.timer?.phase == .interrupted)+ #expect(stale.timer?.deadline == nil)+ #expect(try service.timer(run).phase == .running)+ routine.profileID = ProfileIdentity.me+ try context.save()+ #expect(try companion.snapshot().runs.isEmpty)+ routine.profileID = profile.id+ profile.archivedAt = Date()+ try context.save()+ #expect(try companion.snapshot().runs.isEmpty)+ #expect(!context.hasChanges)+ }+}+#endif
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex bb0934f..bc5d63e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,7 @@ - Restore medication recognition photos throughout the redesigned iPhone care screens, bring the detail image and Add/Replace/Remove editor controls forward, and retain existing photo storage and Save/Cancel behavior. ### Fixed+- Reduce routine-action latency from retained timers by skipping inactive alert discovery and sharing read-only ownership lookups during companion projection, preserving pending alerts and save-before-feedback ordering. - T2495: Show Tomorrow instead of a clock-only next dose across phone and Watch, retaining the exact accessible due time and existing schedules. - Offer explicitly confirmed import recovery for two unused starter Me profiles in a cold session with managed CloudKit sync paused; validate the archive and exact destination, preserve edited/nonempty destinations, and support rollback and crash recovery. - T2471: Preserve immutable restored execution provenance when a completed child timer is explicitly moved, while retaining strict current-link, owner and target validation.
diff --git a/docs/meddy-implementation-plan.md b/docs/meddy-implementation-plan.mdindex 9d7158a..99a84dc 100644--- a/docs/meddy-implementation-plan.md+++ b/docs/meddy-implementation-plan.md@@ -408,3 +408,7 @@ Prescription URL verification: full serial `make pre-push` passed with 325 phone Implemented civil-day next-dose presentation and a confirmed phone-owned full-timer restart with preserved history, fresh callback identity and audited child replacement. Transit ticket reads timed out, so the supplied original requirements define coverage. Synthetic regressions include midnight/timezones/DST, restart phases/replay/ownership, old deadlines, canonical parent history, backup round trip and companion snapshots. Native results are recorded in [verification](../specs/next-day-timer-restart/verification.md); physical-device behavior is not claimed. Final verification: `make pre-push` exited 0 with strict lint (198 files, zero violations), widget simulator build, 363 phone domain tests, 17 Watch tests and 32 full phone UI journeys passing with zero failures/skips. The new next-day and restart UI journeys passed; no physical installation or live-data action occurred.++## Routine responsiveness follow-up (2026-10-28)++The synthetic investigation reproduced synchronous retained-timer ownership scans in foreground alerts and companion snapshots. The authorized PR17 follow-up skips inactive checkpoints before discovery validation and uses an operation-local read index for running candidates and companion run projection. Pending alerts reconcile first; deadline actions and care mutations keep fresh validation and feedback remains after save. Deterministic work-bound and mixed-ownership/corrupt-pending regressions accompany the unchanged benchmark. See [implementation](../specs/routine-responsiveness/implementation.md) and [verification](../specs/routine-responsiveness/verification.md).
diff --git a/specs/next-day-timer-restart/implementation.md b/specs/next-day-timer-restart/implementation.mdindex 90e2d5d..e989b05 100644--- a/specs/next-day-timer-restart/implementation.md+++ b/specs/next-day-timer-restart/implementation.md@@ -22,7 +22,7 @@ The restart control is phone-owned. The Watch receives the old and new attempts ## Review decisions -Independent reviews caught the unconverted Today Later row, missing detail clock invalidation, a misleading Watch cached-due label and a backup inverse-link conflict. These were corrected using existing presentation timing, pending-action and audited canonical-replacement patterns. No speculative latency changes are included; the separate responsiveness investigation owns that work.+Independent reviews caught the unconverted Today Later row, missing detail clock invalidation, a misleading Watch cached-due label and a backup inverse-link conflict. These were corrected using existing presentation timing, pending-action and audited canonical-replacement patterns. The measured routine-latency follow-up is now included; see [routine responsiveness](../routine-responsiveness/implementation.md). The next-day and restart behavior above is preserved. ## Verification
diff --git a/specs/next-day-timer-restart/verification.md b/specs/next-day-timer-restart/verification.mdindex 54023b9..723ffe9 100644--- a/specs/next-day-timer-restart/verification.md+++ b/specs/next-day-timer-restart/verification.md@@ -27,3 +27,7 @@ Independent code-quality/spec, reuse and efficiency reviews identified four issu Transit `query_tasks` returned `READ_TIMEOUT`; current ticket descriptions, comments and status remain unverified. Coverage follows the supplied original requirements. No Transit restart or ticket write occurred. Existing native logs include SwiftUI background-publication diagnostics and tiny synthetic-photo CVPixelBuffer diagnostics. The first build also reports the existing `MedicationPhoto.swift` actor-isolation warning. These were not introduced or suppressed by this change and are not counted as test failures. Physical iPhone/Watch installation, live medication records, CloudKit sync, paired transport and perceived hardware sound/haptics were not exercised. Restart is phone-owned; no new offline Watch restart control is provided.++## Authorized latency follow-up++The results above retain the original `1006aba` feature checkpoint. PR17 now also includes the measured routine-responsiveness fix. Its composed final gate passes 367 phone domain tests, 17 Watch tests and 32 full UI scenarios; see [routine responsiveness verification](../routine-responsiveness/verification.md) for before/after timings, independent review, the classification UI-test correction and supplemental-diagnostic limitation.
diff --git a/Users/arjen/Documents/Codex/2026-10-28/task/meddy/specs/routine-responsiveness/benchmark-summary.json b/Users/arjen/Documents/Codex/2026-10-28/task/meddy/specs/routine-responsiveness/benchmark-summary.jsonnew file mode 100644index 0000000..2ccfbb3--- /dev/null+++ b/Users/arjen/Documents/Codex/2026-10-28/task/meddy/specs/routine-responsiveness/benchmark-summary.json@@ -0,0 +1,621 @@+{+ "baseline": "a29ed3f",+ "after_base": "1006aba plus latency patch",+ "changed_service_files_identical_between_baseline_and_after_base": true,+ "mode": "Debug with invocation-only SWIFT_OPTIMIZATION_LEVEL=-O",+ "synthetic_history_rows": 500,+ "summary": [+ {+ "timers": 0,+ "stage": "alert-refresh",+ "samples": 3,+ "before_ms": 0.095,+ "after_ms": 0.069,+ "before_rows": [+ 0,+ 0,+ 0+ ],+ "after_rows": [+ 0,+ 0,+ 0+ ]+ },+ {+ "timers": 0,+ "stage": "companion-snapshot",+ "samples": 3,+ "before_ms": 176.41,+ "after_ms": 180.657,+ "before_rows": [+ 7070,+ 7070,+ 7070+ ],+ "after_rows": [+ 7575,+ 7575,+ 7575+ ]+ },+ {+ "timers": 0,+ "stage": "reminder-plan",+ "samples": 3,+ "before_ms": 155.361,+ "after_ms": 147.448,+ "before_rows": [+ 3030,+ 3030,+ 3030+ ],+ "after_rows": [+ 3030,+ 3030,+ 3030+ ]+ },+ {+ "timers": 0,+ "stage": "widget-capture",+ "samples": 3,+ "before_ms": 21.504,+ "after_ms": 20.464,+ "before_rows": [+ 505,+ 505,+ 505+ ],+ "after_rows": [+ 505,+ 505,+ 505+ ]+ },+ {+ "timers": 0,+ "stage": "run-read-fresh",+ "samples": 3,+ "before_ms": 0.0,+ "after_ms": 0.0,+ "before_rows": [+ 0,+ 0,+ 0+ ],+ "after_rows": [+ 0,+ 0,+ 0+ ]+ },+ {+ "timers": 0,+ "stage": "run-read-scoped",+ "samples": 3,+ "before_ms": 11.194,+ "after_ms": 11.044,+ "before_rows": [+ 505,+ 505,+ 505+ ],+ "after_rows": [+ 505,+ 505,+ 505+ ]+ },+ {+ "timers": 0,+ "stage": "bare-taken",+ "samples": 3,+ "before_ms": 115.175,+ "after_ms": 109.434,+ "before_rows": [+ 4556,+ 4583,+ 4610+ ],+ "after_rows": [+ 4556,+ 4583,+ 4610+ ]+ },+ {+ "timers": 0,+ "stage": "bare-open-timer",+ "samples": 3,+ "before_ms": 66.623,+ "after_ms": 61.385,+ "before_rows": [+ 2538,+ 2553,+ 2568+ ],+ "after_rows": [+ 2538,+ 2553,+ 2568+ ]+ },+ {+ "timers": 0,+ "stage": "alerts-taken",+ "samples": 3,+ "before_ms": 223.277,+ "after_ms": 110.999,+ "before_rows": [+ 7733,+ 8816,+ 9911+ ],+ "after_rows": [+ 4637,+ 4664,+ 4691+ ]+ },+ {+ "timers": 0,+ "stage": "alerts-open-timer",+ "samples": 3,+ "before_ms": 188.476,+ "after_ms": 64.196,+ "before_rows": [+ 6719,+ 7798,+ 8889+ ],+ "after_rows": [+ 2583,+ 2598,+ 2613+ ]+ },+ {+ "timers": 0,+ "stage": "alerts-watch-taken",+ "samples": 3,+ "before_ms": 805.628,+ "after_ms": 325.536,+ "before_rows": [+ 32543,+ 35897,+ 39287+ ],+ "after_rows": [+ 13118,+ 13193,+ 13268+ ]+ },+ {+ "timers": 0,+ "stage": "alerts-watch-open-timer",+ "samples": 3,+ "before_ms": 811.759,+ "after_ms": 272.448,+ "before_rows": [+ 32610,+ 35970,+ 39366+ ],+ "after_rows": [+ 11044,+ 11107,+ 11170+ ]+ },+ {+ "timers": 25,+ "stage": "alert-refresh",+ "samples": 3,+ "before_ms": 624.938,+ "after_ms": 1.042,+ "before_rows": [+ 26500,+ 26500,+ 26500+ ],+ "after_rows": [+ 0,+ 0,+ 0+ ]+ },+ {+ "timers": 25,+ "stage": "companion-snapshot",+ "samples": 3,+ "before_ms": 724.004,+ "after_ms": 205.378,+ "before_rows": [+ 34450,+ 34450,+ 34450+ ],+ "after_rows": [+ 8480,+ 8480,+ 8480+ ]+ },+ {+ "timers": 25,+ "stage": "reminder-plan",+ "samples": 3,+ "before_ms": 165.619,+ "after_ms": 159.15,+ "before_rows": [+ 3710,+ 3710,+ 3710+ ],+ "after_rows": [+ 3710,+ 3710,+ 3710+ ]+ },+ {+ "timers": 25,+ "stage": "widget-capture",+ "samples": 3,+ "before_ms": 22.027,+ "after_ms": 21.445,+ "before_rows": [+ 530,+ 530,+ 530+ ],+ "after_rows": [+ 530,+ 530,+ 530+ ]+ },+ {+ "timers": 25,+ "stage": "run-read-fresh",+ "samples": 3,+ "before_ms": 626.589,+ "after_ms": 608.751,+ "before_rows": [+ 26500,+ 26500,+ 26500+ ],+ "after_rows": [+ 26500,+ 26500,+ 26500+ ]+ },+ {+ "timers": 25,+ "stage": "run-read-scoped",+ "samples": 3,+ "before_ms": 12.699,+ "after_ms": 12.528,+ "before_rows": [+ 530,+ 530,+ 530+ ],+ "after_rows": [+ 530,+ 530,+ 530+ ]+ },+ {+ "timers": 25,+ "stage": "bare-taken",+ "samples": 3,+ "before_ms": 121.43,+ "after_ms": 122.626,+ "before_rows": [+ 4781,+ 4808,+ 4835+ ],+ "after_rows": [+ 4781,+ 4808,+ 4835+ ]+ },+ {+ "timers": 25,+ "stage": "bare-open-timer",+ "samples": 3,+ "before_ms": 65.791,+ "after_ms": 75.604,+ "before_rows": [+ 2663,+ 2678,+ 2693+ ],+ "after_rows": [+ 2663,+ 2678,+ 2693+ ]+ },+ {+ "timers": 25,+ "stage": "alerts-taken",+ "samples": 3,+ "before_ms": 883.484,+ "after_ms": 126.524,+ "before_rows": [+ 35158,+ 36441,+ 37736+ ],+ "after_rows": [+ 4862,+ 4889,+ 4916+ ]+ },+ {+ "timers": 25,+ "stage": "alerts-open-timer",+ "samples": 3,+ "before_ms": 865.698,+ "after_ms": 77.006,+ "before_rows": [+ 34144,+ 35423,+ 36714+ ],+ "after_rows": [+ 2708,+ 2723,+ 2738+ ]+ },+ {+ "timers": 25,+ "stage": "alerts-watch-taken",+ "samples": 3,+ "before_ms": 2061.918,+ "after_ms": 348.084,+ "before_rows": [+ 89093,+ 92897,+ 96737+ ],+ "after_rows": [+ 13743,+ 13818,+ 13893+ ]+ },+ {+ "timers": 25,+ "stage": "alerts-watch-open-timer",+ "samples": 3,+ "before_ms": 2163.357,+ "after_ms": 300.097,+ "before_rows": [+ 89260,+ 93070,+ 96916+ ],+ "after_rows": [+ 11569,+ 11632,+ 11695+ ]+ },+ {+ "timers": 100,+ "stage": "alert-refresh",+ "samples": 3,+ "before_ms": 2810.862,+ "after_ms": 3.661,+ "before_rows": [+ 121000,+ 121000,+ 121000+ ],+ "after_rows": [+ 0,+ 0,+ 0+ ]+ },+ {+ "timers": 100,+ "stage": "companion-snapshot",+ "samples": 3,+ "before_ms": 2684.079,+ "after_ms": 253.296,+ "before_rows": [+ 130075,+ 130075,+ 130075+ ],+ "after_rows": [+ 9680,+ 9680,+ 9680+ ]+ },+ {+ "timers": 100,+ "stage": "reminder-plan",+ "samples": 3,+ "before_ms": 176.632,+ "after_ms": 187.382,+ "before_rows": [+ 4235,+ 4235,+ 4235+ ],+ "after_rows": [+ 4235,+ 4235,+ 4235+ ]+ },+ {+ "timers": 100,+ "stage": "widget-capture",+ "samples": 3,+ "before_ms": 25.785,+ "after_ms": 27.001,+ "before_rows": [+ 605,+ 605,+ 605+ ],+ "after_rows": [+ 605,+ 605,+ 605+ ]+ },+ {+ "timers": 100,+ "stage": "run-read-fresh",+ "samples": 3,+ "before_ms": 2845.207,+ "after_ms": 2878.471,+ "before_rows": [+ 121000,+ 121000,+ 121000+ ],+ "after_rows": [+ 121000,+ 121000,+ 121000+ ]+ },+ {+ "timers": 100,+ "stage": "run-read-scoped",+ "samples": 3,+ "before_ms": 16.61,+ "after_ms": 16.526,+ "before_rows": [+ 605,+ 605,+ 605+ ],+ "after_rows": [+ 605,+ 605,+ 605+ ]+ },+ {+ "timers": 100,+ "stage": "bare-taken",+ "samples": 3,+ "before_ms": 138.58,+ "after_ms": 136.468,+ "before_rows": [+ 5456,+ 5483,+ 5510+ ],+ "after_rows": [+ 5456,+ 5483,+ 5510+ ]+ },+ {+ "timers": 100,+ "stage": "bare-open-timer",+ "samples": 3,+ "before_ms": 79.378,+ "after_ms": 78.663,+ "before_rows": [+ 3038,+ 3053,+ 3068+ ],+ "after_rows": [+ 3038,+ 3053,+ 3068+ ]+ },+ {+ "timers": 100,+ "stage": "alerts-taken",+ "samples": 3,+ "before_ms": 3206.194,+ "after_ms": 144.44,+ "before_rows": [+ 132433,+ 134316,+ 136211+ ],+ "after_rows": [+ 5537,+ 5564,+ 5591+ ]+ },+ {+ "timers": 100,+ "stage": "alerts-open-timer",+ "samples": 3,+ "before_ms": 3195.443,+ "after_ms": 81.346,+ "before_rows": [+ 131419,+ 133298,+ 135189+ ],+ "after_rows": [+ 3083,+ 3098,+ 3113+ ]+ },+ {+ "timers": 100,+ "stage": "alerts-watch-taken",+ "samples": 3,+ "before_ms": 6448.041,+ "after_ms": 405.808,+ "before_rows": [+ 288743,+ 293897,+ 299087+ ],+ "after_rows": [+ 15618,+ 15693,+ 15768+ ]+ },+ {+ "timers": 100,+ "stage": "alerts-watch-open-timer",+ "samples": 3,+ "before_ms": 6203.484,+ "after_ms": 344.557,+ "before_rows": [+ 289210,+ 294370,+ 299566+ ],+ "after_rows": [+ 13144,+ 13207,+ 13270+ ]+ }+ ]+}
diff --git a/Users/arjen/Documents/Codex/2026-10-28/task/meddy/specs/routine-responsiveness/benchmark.swift b/Users/arjen/Documents/Codex/2026-10-28/task/meddy/specs/routine-responsiveness/benchmark.swiftnew file mode 100644index 0000000..5c9c11a--- /dev/null+++ b/Users/arjen/Documents/Codex/2026-10-28/task/meddy/specs/routine-responsiveness/benchmark.swift@@ -0,0 +1,112 @@+import Foundation+import SwiftData+import Testing++@testable import Meddy++@MainActor+struct MeddyRoutineResponsivenessDiagnostics {+ private func measure<T>(_ stage: String, timers: Int, visit: Int, _ body: () throws -> T) rethrows -> T {+ var rows = 0+ ProfileAccess.inspectedRows = { rows += $0 }+ let start = ProcessInfo.processInfo.systemUptime+ defer {+ let ms = (ProcessInfo.processInfo.systemUptime - start) * 1000+ ProfileAccess.inspectedRows = nil+ print("ROUTINE_DIAG timers=\(timers) visit=\(visit) stage=\(stage) ms=\(ms) rows=\(rows)")+ }+ return try body()+ }++ @Test(arguments: [0, 25, 100])+ func retainedTimedHistory(timers: Int) throws {+ #expect(AppEnvironment.isTesting)+ let store = try AppEnvironment.makeContainer(isolated: true)+ let context = store.mainContext+ defer { MutationEffects.remove(context); ProfileAccess.inspectedRows = nil }+ let definitions = RoutineService(context: context)+ let sessions = RoutineSessionService(context: context)+ let medication = Medication(name: "Synthetic responsiveness medication")+ context.insert(medication)+ let timed = try definitions.createTimed(name: "Synthetic timer", rounds: 2, durationSeconds: 60)+ let ordered = try definitions.createOrdered(+ name: "Synthetic ordered routine",+ steps: [.init(kind: .medication, targetID: medication.id), .init(kind: .timedRoutine, targetID: timed.id)],+ confirmedMedicationIDs: [medication.id])+ let template = try sessions.start(timed)+ try sessions.changeTimer(template, actionID: UUID(), clock: ExecutionClock.sample(), operation: .end)+ for _ in 0..<timers {+ let retained = RoutineRun(routine: timed)+ retained.definitionSnapshotData = template.definitionSnapshotData+ retained.stepProgressData = template.stepProgressData+ retained.timerCheckpointData = template.timerCheckpointData+ retained.processedActionIDsData = template.processedActionIDsData+ retained.statusRaw = template.statusRaw+ retained.endedAt = template.endedAt+ context.insert(retained)+ }+ context.delete(template)+ for index in 0..<500 {+ let action = AdministrationAction(+ eventID: UUID(), medicationID: medication.id,+ timestamp: Date().addingTimeInterval(-Double(index + 1) * 86400), source: .phone,+ dose: .unknown, scheduleTypeAtRecording: .routineManaged, scheduleGenerationID: nil)+ context.insert(Administration(action: action, medication: medication))+ }+ try context.save()+ let alerts = PhoneRoundAlertService(context: context, feedback: {}, keepAwake: { _ in })+ alerts.setActive(true)+ MutationEffects.remove(context)+ let companion = PhoneCompanionService(context: context)+ let reminders = ReminderService(context: context, registerDelegate: false)+ for visit in 0..<3 {+ measure("alert-refresh", timers: timers, visit: visit) { alerts.refresh() }+ let snapshot = try measure("companion-snapshot", timers: timers, visit: visit) { try companion.snapshot() }+ #expect(snapshot.runs.count == timers && snapshot.appliedEventIDs.count == 500)+ _ = try measure("reminder-plan", timers: timers, visit: visit) { try reminders.plan(now: Date()) }+ _ = try measure("widget-capture", timers: timers, visit: visit) { try WidgetProjectionService(context: context).capture() }+ let runs = try context.fetch(FetchDescriptor<RoutineRun>())+ let values = try measure("run-read-fresh", timers: timers, visit: visit) {+ try runs.map { (try sessions.definition($0), try sessions.progress($0)) }+ }+ let scoped = try measure("run-read-scoped", timers: timers, visit: visit) {+ let scope = try ProfileAccess.ReadScope(context: context)+ return try runs.map { (try sessions.definition($0, scope: scope), try sessions.progress($0, scope: scope)) }+ }+ #expect(values.count == scoped.count)+ for (left, right) in zip(values, scoped) {+ #expect(left.0 == right.0 && left.1 == right.1)+ }+ #expect(!context.hasChanges)+ }+ for mode in ["bare", "alerts", "alerts-watch"] {+ for visit in 0..<3 {+ MutationEffects.remove(context)+ let parent = try sessions.start(ordered)+ let steps = try sessions.definition(parent).steps+ if mode != "bare" {+ MutationEffects.observe(context) { alerts.refresh() }+ }+ // Explicit synthetic stand-in for publish's conditional snapshot work only.+ // No Watch activation, outbox, transport, or network writes occur in test mode.+ if mode == "alerts-watch" {+ MutationEffects.observe(context) { _ = try! companion.snapshot() }+ }+ let event = try measure("\(mode)-taken", timers: timers, visit: visit) {+ let action = try ProfileAccess.stamp(AdministrationAction(+ eventID: UUID(), medicationID: medication.id, timestamp: Date(), source: .phone,+ dose: .unknown, scheduleTypeAtRecording: .routineManaged, scheduleGenerationID: nil),+ target: parent, context: context)+ return try sessions.recordMedication(action, in: parent, stepID: steps[0].id)+ }+ #expect(event.routineRunID == parent.id && !context.hasChanges)+ let child = try measure("\(mode)-open-timer", timers: timers, visit: visit) {+ try sessions.beginTimedStep(parent, stepID: steps[1].id)+ }+ #expect(child.parentRoutineRunID == parent.id && !context.hasChanges)+ #expect(try sessions.timer(child).phase == .ready)+ }+ }+ #expect(try context.fetchCount(FetchDescriptor<Administration>()) == 509)+ }+}
diff --git a/Users/arjen/Documents/Codex/2026-10-28/task/meddy/specs/routine-responsiveness/implementation.md b/Users/arjen/Documents/Codex/2026-10-28/task/meddy/specs/routine-responsiveness/implementation.mdnew file mode 100644index 0000000..84944a6--- /dev/null+++ b/Users/arjen/Documents/Codex/2026-10-28/task/meddy/specs/routine-responsiveness/implementation.md@@ -0,0 +1,35 @@+# Routine responsiveness++Routine saves waited for synchronous foreground alert discovery and, when a Watch app was available, companion snapshot construction. Both could revalidate every retained timer against the entire owned-record inventory. Finished timers therefore increased the delay before Taken returned or Start timer assigned its navigation destination.++## Implementation++Foreground discovery decodes each checkpoint first and excludes timers that are not running or lack a deadline before expensive ownership validation. Existing pending deadlines still reconcile first, including malformed/removed checkpoints, cancellation and saved completion feedback. Discovery uses one short-lived `ProfileAccess.ReadScope` for its running candidates and returns projections before scheduling callbacks. Foreground activation excludes inactive timers but keeps fresh reads around catch-up mutations.++Companion run projection passes one read scope through the existing definition/progress overloads and a matching scoped lifecycle reader. It keeps every eligible retained run and the existing stale-lifecycle pause/interruption behavior. Each snapshot creates a fresh scope; duplicate IDs, owner/version mismatches and required links still use the existing validator.++No mutation authorization is cached. Deadline callbacks, recording, restart and handoff still validate current state and save through the same transactions. Feedback and navigation remain after persistence. Pending active timers still incur fresh validation; this change targets retained inactive-history amplification, not all possible active-timer cost.++## Review and regressions++Four independent source reviews covered reuse, code quality, efficiency and specification/testing. They found a missing encoded action-ID array in the inherited test fixture and requested mixed running-candidate coverage. Those issues were fixed. The inherited test also contained an invalid timer phase and missing throwing markers; its failed compile is not counted as passing verification.++The new deterministic work-bound test varies retained inactive timers across 0, 25 and 100 and covers ready, paused, waiting, interrupted, completed and ended phases. Alert discovery performs no ownership scans for those rows; companion projection stays within a fixed inventory-scan bound. Snapshot tests verify lifecycle changes, cross-owner links and archive visibility without modifying saved checkpoints. Alert regressions test a valid dependant timer beside stale-lifecycle, cross-owner and duplicate-ID candidates, fresh lifecycle cancellation, and a corrupt pending checkpoint alongside another discoverable timer. Completion remains once-only after the save.++## Explanation at three levels++### Beginner++Finished timers remain in history, but checking them repeatedly should not delay the next button press. The phone now ignores finished timers when looking for the next alert and builds one temporary ownership lookup when preparing Watch history. Saved care and earlier attempts stay intact.++### Intermediate++The timer service separates reconciliation of existing deadlines from discovery of new ones. Discovery rejects irrelevant checkpoints before building a local index, then validates running candidates with the existing rules. Companion projection reuses the existing indexed read APIs for each run. Writes and deadline callbacks retain fresh context validation.++### Expert++The former discovery/companion loops performed O(retained runs × owned rows) materialization. Inactive-only discovery now decodes retained checkpoints without ownership scans; eligible discovery and companion run projection use a bounded inventory load plus per-record lookups. The read scope ends before callback scheduling and is not retained across saves, suspension or later actions. Pending reconciliation remains before filtering so a corrupt/removed or completed checkpoint cannot leave an old deadline alive or suppress saved completion feedback. Catch-up activation does not reuse an index across its potential mutations.++### Completeness assessment++The measured retained-history bottlenecks are addressed without moving saves, navigation or feedback. Existing next-day/restart features remain on the same branch. Simulator benchmarks and native tests establish synthetic behavior only; the user's live-phone data volume, paired Watch transport and perceived hardware responsiveness remain unmeasured. Full evidence is recorded in verification.md.
diff --git a/Users/arjen/Documents/Codex/2026-10-28/task/meddy/specs/routine-responsiveness/verification.md b/Users/arjen/Documents/Codex/2026-10-28/task/meddy/specs/routine-responsiveness/verification.mdnew file mode 100644index 0000000..4ff37d3--- /dev/null+++ b/Users/arjen/Documents/Codex/2026-10-28/task/meddy/specs/routine-responsiveness/verification.md@@ -0,0 +1,52 @@+# Verification — routine responsiveness++Branch: `feat/t2495-t2496-next-day-restart`, extending reviewed next-day/restart commit `1006aba`. The takeover found three partially edited service files and an untracked observer regression, with a failed compile and no active Meddy writer/job. Existing next-day and restart functionality was preserved.++## Before/after benchmark++The exact unchanged [benchmark.swift](benchmark.swift) ran with `SWIFT_OPTIMIZATION_LEVEL=-O`, existing Debug instrumentation, `MEDDY_TESTING=1`, isolated in-memory SwiftData stores and no CloudKit. Simulator: arm64 iPhone 17e, iOS 27.0 (`00C97143-9C70-41DD-813C-58983408CFBC`). It uses 500 synthetic medication history rows, two routine definitions and 0/25/100 ended timed sessions. Each stage has three samples.++The before archive is `a29ed3f`; after is `1006aba` plus the three service changes. Those three service files are byte-identical between `a29ed3f` and `1006aba`; the intervening next-day/restart features are not invoked by this diagnostic. Test bytes are identical. Both benchmark commands exited 0 with `TEST SUCCEEDED` (one declared test, three parameter cases). The ordinary final-branch full gate separately verifies the composed feature code.++| Stage, median milliseconds | 25 timers before → after | 100 timers before → after |+| --- | ---: | ---: |+| Foreground alert refresh | 624.9 → 1.0 | 2,810.9 → 3.7 |+| Companion snapshot | 724.0 → 205.4 | 2,684.1 → 253.3 |+| Taken with foreground alerts | 883.5 → 126.5 | 3,206.2 → 144.4 |+| Start timer with foreground alerts | 865.7 → 77.0 | 3,195.4 → 81.3 |+| Taken with alerts + conditional snapshot | 2,061.9 → 348.1 | 6,448.0 → 405.8 |+| Start timer with alerts + conditional snapshot | 2,163.4 → 300.1 | 6,203.5 → 344.6 |++Fixed-inventory alert ownership row visits fall from 26,500/121,000 to zero. Companion snapshot visits fall from 34,450/130,075 to 8,480/9,680. These count repeated visits, not distinct rows. Bare action timings remain similar: Taken 121.4→122.6 ms at 25 timers and 138.6→136.5 ms at 100, confirming the principal saving is observer work. The benchmark retains new sessions between its action modes, adding up to nine parent/child pairs and doses; before/after follows the exact same sequence. Fixed-inventory stage measurements establish the scaling independently. [All medians and work counts](benchmark-summary.json) are retained.++To reproduce, place `benchmark.swift` in `Meddy/MeddyTests/MeddyRoutineResponsivenessDiagnostics.swift` in an isolated source copy of the desired revision. Use the existing `make test-domain DOMAIN_TEST=MeddyTests/MeddyRoutineResponsivenessDiagnostics` with a coordinated simulator and isolated cache/results paths. Supply a tiny executable `XCODEBUILD` wrapper that invokes `/usr/bin/xcodebuild "$@" SWIFT_OPTIMIZATION_LEVEL=-O`; the Makefile quotes the executable name, so embedding flags directly in `XCODEBUILD` does not work. Do not copy the diagnostic into the application target or use a live container.++## Regression and review evidence++The corrected observer suite passes on final code. Its unchanged baseline run logs five expected work-bound failures: inactive alert reads are 12, 4,212 and 61,812 instead of zero; the combined companion bounds fail at 25 and 100 retained timers. Snapshot lifecycle assertions still pass. That old-code command stalled after reporting its test results and was interrupted during teardown; it is **incomplete command evidence**, not a completed red native run. The completed before benchmark and those logged deterministic failures still establish the old work amplification. No old-code retry, test relaxation or warning suppression was used. The retained process sample identifies simulator diagnostic collection (`simCtlDiagnose`) as the teardown wait; the owned xcodebuild and its orphaned diagnostic collector were stopped.++Four independent reviewers found no production correctness blockers. Their missing-action-ID fixture finding, compile issues and mixed-running-candidate coverage requests were fixed. Re-review accepted the new lifecycle, duplicate/cross-owner and corrupt-pending tests subject to execution. The final gate includes those tests plus existing restart, handoff, replay, pending-cancellation and save-feedback cases.++## UI harness correction++The first full gate passed lint/widget build, 367 phone domain tests and 17 Watch tests, then the classification UI test failed because its unconditional downward keyboard-dismiss swipe dismissed the editor sheet. Its accessibility snapshot showed the medication tab with no editor after the gesture. The helper now taps an already reachable picker or uses the existing bounded interior upward gesture, and asserts hittability. All save/cancel/clear/value assertions remain. Independent re-review accepted this actual test-harness correction. A focused native command passed in 44.921 seconds and exited 0 (`evidence/results-ui-correction/test-ui.1Gn7GU/Results.xcresult`). The superseded full UI run was interrupted after its failure; it is not passing gate evidence. A fresh complete serial gate follows.++The final UI assertions all passed before Xcode entered simulator diagnostic collection. The gate outcome below requires the overall command to finish; diagnostic finalization is not counted as another test run.++## Final required gate++The complete serial `make pre-push` command exited **0** with:++- Strict SwiftLint: **199 files, zero violations**, plus clean whitespace validation.+- Widget simulator build: `build/results/build-widgets.Ccknxy`.+- **367 phone domain tests**, 56 suites, zero failed/skipped: `build/results/test-domain.c2AJWM/Results.xcresult`.+- **17 Watch tests**, 2 suites, zero failed/skipped: `build/results/test-watch.kIKWG7/Results.xcresult`.+- **32 full phone UI scenarios**, zero failed/skipped: `build/results/test-ui-all.Oe1Ymg/Results.xcresult`. These include the corrected classification helper, Tomorrow presentation, restart/circle controls, saved child pause/resume, whole ordered-routine sequence, profiles and widgets.++All 209 recorded Swift/configuration input hashes remained unchanged during this final gate. The phone used simulator `350AEBDE-79A4-4F15-A2A5-75BCC3633AC9`, Watch used `4E8A129D-5459-489E-8983-9C4F3D723DEC`; neither conflicted with Asterism's targets. After all 32 UI assertions passed, Xcode's supplemental `simctl diagnose` collector reached its existing 600-second timeout. Xcode then finalized the native result with **TEST SUCCEEDED** and exit **0**. Supplemental simulator diagnostics are incomplete; the test result itself completed successfully. No diagnostic setting or timeout was changed to obtain this result.++## Evidence locations and limits++Original benchmark: `/Users/arjen/Documents/Codex/2026-10-28/task-2/evidence/run.log`, `results/test-domain.VFpIX1/Results.xcresult`. Improved benchmark: `evidence/after.log`, `results-after/test-domain.GslcrI/Results.xcresult`. Expected-failure diagnostic: `evidence/red.log` and `red-teardown-sample.txt`. Independent review notes, source manifests, native summaries and final-gate log are under the same task's `review-inputs/` directory. Relative evidence paths here resolve within that task folder, not the repository.++The existing `MedicationPhoto.swift` actor-isolation warning and native SwiftUI background-publication/photo diagnostics remain unsuppressed. Synthetic timings are not physical-phone tap-to-paint or SQLite/CloudKit measurements. Watch snapshot construction is conditional in production and its encoding/transport costs were not measured. No real medication data, physical installation, account/settings changes, merge or real care action occurred. Direct navigation to an already-saved timer was not separately timed. No blanket asynchronous save/navigation reorder or global authorization cache was introduced.
In-memory synthetic stores, no physical-phone or paired Watch tests. Timing includes conditional snapshot construction, not transport. Native results are converted losslessly at declared-test granularity from xcresult JSON; coverage was not enabled.
The unchanged old-code regression logged five expected work-bound failures then stalled collecting simulator diagnostics. Its command was stopped and remains incomplete evidence. Both before/after timing benchmarks and the final-code gates completed successfully.
After all 32 final UI tests passed, Xcode supplemental simulator diagnostic collection timed out at its existing 600-second limit. The native result then finalized with TEST SUCCEEDED and the complete make pre-push command exited 0. No timeout setting was changed; supplemental diagnostics are incomplete.