docs/superpowers/plans/2026-10-16-part1-foundation.md
306 lines · 25027 bytes
14 symbols in this file
Part 1: Foundation Implementation PlanGlobal ConstraintsReview FocusTask 0: Branch and issueTask 1: Test target and quiz itemsTask 2: Question picker and roundTask 3: Profiles and answer logTask 4: Profile sessionTask 5: Parent gateTask 6: Sound synthesis and engineTask 7: Celebration and round viewTask 8: Profile picker, setup, and parent areaTask 9: Home and topic hubsTask 10: Art/sound review, MR, merge
1# Part 1: Foundation Implementation Plan
2
3> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
4
5**Goal:** Profiles, parent gate, answer log, sound engine, celebration, question engine with rounds, and the option-C home/hub navigation, with a unit test target.
6
7**Architecture:** SwiftData models (`Profile`, `AnswerRecord`) behind a small `ProfileStore`. An `@Observable ProfileSession` holds the current child and decides when to show the picker. A pure question engine (`QuizItem`, `QuestionPicker`, `Round`) is driven by a generic `RoundView`. Sound effects are rendered to sample buffers by a pure `SoundSynth` and played by `SoundEngine` (AVAudioEngine). Home becomes a Today banner plus topic grid; each topic opens `CategoryHubView`.
8
9**Tech Stack:** SwiftUI, SwiftData, AVFoundation (AVAudioEngine), Swift Testing, Xcode 27, `xcodeproj` Ruby gem (1.28.1, installed) for adding the test target.
10
11**Spec:** `docs/superpowers/specs/2026-10-16-learning-games-design.md`
12
13Parts 2–7 get their own plans, each written after the previous part merges.
14
15## Global Constraints
16
17- Effective deployment target is iOS 17.5. Use only APIs available on 17.5.
18- Build settings: `SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor`, approachable concurrency on. Pure logic types that tests touch off the main actor must be `nonisolated`.
19- New app files go under `DayByDay/` (file-system-synchronized group). New test files go under `DayByDayTests/`.
20- No network, no analytics, no bundled image or audio files. All art in SwiftUI/SF Symbols, all sound synthesized at runtime.
21- Nothing requires reading. Every child-facing prompt is spoken through `SpeechSynthesizer.shared.speak(_:)`.
22- Wrong answers: soft sound plus spoken correction. No buzzer, no red X, no lost points.
23- Rounds end with "You did it!" after 5 correct answers.
24- Parent gate protects profile management. First-launch profile creation also goes through the gate.
25- Profile picker: shown at launch when more than one profile exists, and on return to foreground after 10 or more minutes in the background. Skipped with exactly one profile. Avatar button in the home corner opens it, ungated.
26- Weeks start on Sunday. The season is "Fall".
27- Every commit message references the part 1 issue (`Ref #N`; the final one `Closes #N`). No AI attribution anywhere.
28- Branch `feat/foundation` from `main`. Never push to `main`.
29
30## Review Focus
31
321. Deleting the profile that is currently selected → session clears `current`; picker (or setup, if none remain) shows; that profile's answers are deleted with it. Test in Task 3 and Task 4.
332. Deleting the last profile → app returns to first-launch setup. Test in Task 4.
343. A child tapping repeatedly while feedback plays → only the first tap per question is recorded; further taps are ignored until the next question appears. Test in Task 2 (`Round` rejects answers while `isAwaitingNext`).
354. Reduce Motion on → confetti does not animate particles; celebration uses a fade only. Checked in Task 7.
365. Category with fewer items than the requested choice count, or a blank/whitespace profile name → picker clamps to the item count; setup refuses blank names. Tests in Task 2 and Task 3.
37
38---
39
40### Task 0: Branch and issue
41
42- [ ] **Step 1:** `git checkout -b feat/foundation main`
43- [ ] **Step 2:** Create the issue and note its number as `N` for all commit messages:
44
45```bash
46gitbay issue create --title "Part 1: foundation (profiles, question engine, sound, home hubs)" --file - <<'EOF'
47Implements part 1 of docs/superpowers/specs/2026-10-16-learning-games-design.md.
48Plan: docs/superpowers/plans/2026-10-16-part1-foundation.md
49EOF
50```
51
52- [ ] **Step 3:** Commit the spec and this plan: `git add docs && git commit -m "docs: learning games design and part 1 plan" -m "Ref #N"`
53
54### Task 1: Test target and quiz items
55
56**Files:**
57- Create: `scripts/add-test-target.rb` (run once, committed for reproducibility)
58- Modify: `DayByDay.xcodeproj/project.pbxproj` (via script)
59- Create: `DayByDay.xcodeproj/xcshareddata/xcschemes/DayByDay.xcscheme` (via script)
60- Create: `DayByDay/Quiz/QuizItem.swift`
61- Test: `DayByDayTests/QuizItemTests.swift`
62
63**Interfaces:**
64- Produces: `struct QuizItem: Identifiable, Hashable, Sendable { let id: String; let name: String; let category: Category }`; `extension Category { var quizItems: [QuizItem]; static var gridCases: [Category] }`. `id` is `"<category>.<case>"`, e.g. `"days.tuesday"`, built with `String(describing:)` on the enum case. `name` is the spoken name (`LearnLetter` uses `spokenName`).
65
66- [ ] **Step 1:** Write `scripts/add-test-target.rb` using the `xcodeproj` gem: add a `DayByDayTests` unit-test bundle target (`com.apple.product-type.bundle.unit-test`) with `TEST_HOST`/`BUNDLE_LOADER` pointing at the app, deployment target 17.5, a file-system-synchronized root group for `DayByDayTests/`, and a shared `DayByDay` scheme whose test action includes `DayByDayTests`. If the gem cannot write a synchronized group for objectVersion 77, add the test files as regular file references instead.
67- [ ] **Step 2:** Write the failing test:
68
69```swift
70import Testing
71@testable import DayByDay
72
73struct QuizItemTests {
74 @Test func everyGridCategoryHasItems() {
75 for category in Category.gridCases { #expect(!category.quizItems.isEmpty) }
76 }
77 @Test func gridExcludesToday() {
78 #expect(!Category.gridCases.contains(.today))
79 #expect(Category.gridCases.count == 11)
80 }
81 @Test func idsAreUniqueAndStable() {
82 let all = Category.gridCases.flatMap(\.quizItems)
83 #expect(Set(all.map(\.id)).count == all.count)
84 #expect(Category.days.quizItems[2] == QuizItem(id: "days.tuesday", name: "Tuesday", category: .days))
85 }
86 @Test func lettersUseSpokenName() {
87 #expect(Category.alphabet.quizItems.first?.name == "a")
88 }
89}
90```
91
92- [ ] **Step 3:** Run `ruby scripts/add-test-target.rb`, then `xcodebuild test -project DayByDay.xcodeproj -scheme DayByDay -destination 'platform=iOS Simulator,name=iPhone 16 Pro' -only-testing:DayByDayTests/QuizItemTests`. Expected: build fails, `quizItems` not found.
93- [ ] **Step 4:** Implement `QuizItem.swift`: map each category to its enum (`DayOfWeek`, `MonthOfYear`, `Season`, `LearnNumber`, `LearnColor`, `LearnShape`, `LearnAnimal`, `LearnLetter`, `LearnWeather`, `LearnBodyPart`, `LearnFood`); `.today` returns `[]`.
94- [ ] **Step 5:** Run the same test command. Expected: PASS.
95- [ ] **Step 6:** Commit: `feat: add unit test target and quiz items` with `Ref #N`.
96
97### Task 2: Question picker and round
98
99**Files:**
100- Create: `DayByDay/Quiz/Question.swift`, `DayByDay/Quiz/Round.swift`
101- Test: `DayByDayTests/RoundTests.swift`
102
103**Interfaces:**
104- Consumes: `QuizItem`.
105- Produces:
106 - `struct Question: Equatable { let prompt: String; let choices: [QuizItem]; let answer: QuizItem }`
107 - `struct QuestionPicker { var choiceCount: Int; var prompt: (QuizItem) -> String; func next(from items: [QuizItem], excluding previous: QuizItem?, using rng: inout some RandomNumberGenerator) -> Question }`. It picks the answer uniformly at random, never equal to `previous` when `items.count > 1`. Choices are the answer plus `min(choiceCount, items.count) - 1` distinct others, shuffled.
108 - `enum AnswerOutcome: Equatable { case correct; case incorrect(correctName: String); case ignored }`
109 - `struct Round { static let length = 5; init(items: [QuizItem], picker: QuestionPicker, rng: some RandomNumberGenerator); private(set) var current: Question; private(set) var correctCount: Int; private(set) var isAwaitingNext: Bool; var isFinished: Bool; mutating func answer(_ item: QuizItem) -> AnswerOutcome; mutating func advance() }`. A wrong answer keeps the same question (retry). A correct answer sets `isAwaitingNext = true`; any answer while awaiting returns `.ignored`. `advance()` picks the next question. `isFinished` when `correctCount == Round.length`.
110 - Tests use a seeded generator: add `struct SeededGenerator: RandomNumberGenerator` (SplitMix64) in `DayByDayTests/SeededGenerator.swift`.
111
112- [ ] **Step 1:** Write the failing tests:
113
114```swift
115@Test func choicesIncludeAnswerAndAreDistinct() // 4 choices, contains answer, Set(choices).count == 4
116@Test func choiceCountClampsToItemCount() // Season (4 items), choiceCount 6 → 4 choices
117@Test func neverRepeatsPreviousAnswer() // 200 draws from days with previous set → answer != previous
118@Test func promptUsesClosure() // prompt { "Can you find \($0.name)?" } → "Can you find Tuesday?" when answer is Tuesday
119@Test func wrongAnswerRetriesSameQuestion() // outcome == .incorrect(correctName: answer.name); current unchanged; correctCount == 0
120@Test func tapsWhileAwaitingNextAreIgnored() // correct, then any answer → .ignored; correctCount == 1
121@Test func finishesAfterFiveCorrect() // 5 × (answer correct, advance) → isFinished
122```
123
124- [ ] **Step 2:** Run `xcodebuild test ... -only-testing:DayByDayTests/RoundTests`. Expected: FAIL (types not defined).
125- [ ] **Step 3:** Implement `Question.swift` and `Round.swift` per the interfaces. Mark both `nonisolated`.
126- [ ] **Step 4:** Run the same command. Expected: PASS.
127- [ ] **Step 5:** Commit: `feat: add question picker and round` with `Ref #N`.
128
129### Task 3: Profiles and answer log
130
131**Files:**
132- Create: `DayByDay/Profiles/Profile.swift`, `DayByDay/Profiles/AnswerRecord.swift`, `DayByDay/Profiles/ProfileStore.swift`, `DayByDay/Profiles/Avatar.swift`
133- Test: `DayByDayTests/ProfileStoreTests.swift`
134
135**Interfaces:**
136- Produces:
137 - `enum AvatarAnimal: String, CaseIterable { cat, dog, bird, fish, rabbit, tortoise, ladybug, hare }` with `var symbol: String` (`"cat.fill"`, `"dog.fill"`, `"bird.fill"`, `"fish.fill"`, `"rabbit.fill"`, `"tortoise.fill"`, `"ladybug.fill"`, `"hare.fill"`) and `var spokenName: String`.
138 - `enum ProfileColor: Int, CaseIterable` with 8 cases and `var color: Color`.
139 - `@Model final class Profile { var id: UUID; var name: String; var avatarRaw: String; var colorRaw: Int; var birthdayMonth: Int?; var birthdayDay: Int?; var createdAt: Date; @Relationship(deleteRule: .cascade, inverse: \AnswerRecord.profile) var answers: [AnswerRecord] }` with computed `avatar: AvatarAnimal` and `color: ProfileColor`.
140 - `@Model final class AnswerRecord { var categoryRaw: Int; var itemID: String; var isCorrect: Bool; var timestamp: Date; var profile: Profile? }`
141 - `enum ProfileError: Error, Equatable { case blankName; case invalidBirthday }`
142 - `final class ProfileStore { init(context: ModelContext); func all() -> [Profile]` (sorted by `createdAt`)`; func create(name: String, avatar: AvatarAnimal, color: ProfileColor, birthday: (month: Int, day: Int)?) throws -> Profile; func update(_ p: Profile, name: String, avatar: AvatarAnimal, color: ProfileColor, birthday: (month: Int, day: Int)?) throws; func delete(_ p: Profile); func record(_ item: QuizItem, correct: Bool, for p: Profile, at date: Date = .now); func answers(for p: Profile, category: Category?) -> [AnswerRecord] }`
143 - Names are trimmed; blank → `.blankName`. Birthday day must be valid for the month in a leap year (Feb allows 29) → else `.invalidBirthday`.
144 - `static func makeContainer(inMemory: Bool) -> ModelContainer` on `ProfileStore`.
145
146- [ ] **Step 1:** Write the failing tests (all on an in-memory container):
147
148```swift
149@Test func createTrimsName() // " Maya " → "Maya"
150@Test func blankNameThrows() // " " → ProfileError.blankName
151@Test func birthdayValidation() // (2, 29) ok; (2, 30) and (4, 31) and (13, 1) → .invalidBirthday
152@Test func allSortedByCreation()
153@Test func recordsAnswersPerProfile() // record for Maya and Sam; answers(for: maya, category: .days).count == 1
154@Test func deletingProfileDeletesAnswers() // delete(maya) → no AnswerRecord rows with profile == nil remain
155```
156
157- [ ] **Step 2:** Run `xcodebuild test ... -only-testing:DayByDayTests/ProfileStoreTests`. Expected: FAIL.
158- [ ] **Step 3:** Implement the files per the interfaces.
159- [ ] **Step 4:** Run the same command. Expected: PASS.
160- [ ] **Step 5:** Commit: `feat: add profiles and answer log` with `Ref #N`.
161
162### Task 4: Profile session
163
164**Files:**
165- Create: `DayByDay/Profiles/ProfileSession.swift`
166- Test: `DayByDayTests/ProfileSessionTests.swift`
167
168**Interfaces:**
169- Consumes: `Profile`, `ProfileStore`.
170- Produces: `@Observable final class ProfileSession { static let pickerAfterBackground: TimeInterval = 600; var current: Profile?; init(store: ProfileStore); var screen: SessionScreen; func select(_ p: Profile); func didEnterBackground(at: Date); func willEnterForeground(at: Date); func profilesChanged() }` and `enum SessionScreen: Equatable { case setup, picker, home }`.
171 - `screen`: no profiles → `.setup`; `current == nil` and one profile → auto-select it, `.home`; `current == nil` and several → `.picker`; otherwise `.home`.
172 - `willEnterForeground` clears `current` when profile count > 1 and the background interval ≥ 600 s.
173 - `profilesChanged()` clears `current` if it was deleted.
174
175- [ ] **Step 1:** Write the failing tests:
176
177```swift
178@Test func noProfilesShowsSetup()
179@Test func singleProfileAutoSelects() // screen == .home, current == only profile
180@Test func multipleProfilesShowPicker()
181@Test func shortBackgroundKeepsCurrent() // 599 s → .home
182@Test func longBackgroundShowsPickerWithSiblings() // 600 s, 2 profiles → .picker
183@Test func longBackgroundKeepsSoleProfile() // 600 s, 1 profile → .home
184@Test func deletingCurrentClearsIt() // delete current, profilesChanged() → .picker (2 left) / .home (1 left)
185@Test func deletingLastProfileShowsSetup()
186```
187
188- [ ] **Step 2:** Run `-only-testing:DayByDayTests/ProfileSessionTests`. Expected: FAIL.
189- [ ] **Step 3:** Implement `ProfileSession.swift`.
190- [ ] **Step 4:** Run it. Expected: PASS.
191- [ ] **Step 5:** Commit: `feat: add profile session` with `Ref #N`.
192
193### Task 5: Parent gate
194
195**Files:**
196- Create: `DayByDay/Parent/ParentGate.swift` (logic), `DayByDay/Parent/ParentGateView.swift`
197- Test: `DayByDayTests/ParentGateTests.swift`
198
199**Interfaces:**
200- Produces: `nonisolated struct ParentGateChallenge { let a: Int; let b: Int; var answer: Int { a + b }; static func random(using rng: inout some RandomNumberGenerator) -> ParentGateChallenge; func accepts(_ input: String) -> Bool }`. `a` and `b` in `6...9` (sums 12–18). `accepts` trims whitespace and compares as an integer. `static let holdDuration: TimeInterval = 2`.
201- Produces: `struct ParentGateView: View { init(onPass: @escaping () -> Void, onCancel: @escaping () -> Void) }`. Step 1: a "Hold for grown-ups" button that must be held for `holdDuration` (progress ring fills while held; release resets). Step 2: shows "What is a + b?" as text with a number-pad field; correct entry calls `onPass`, wrong entry shows a new challenge.
202
203- [ ] **Step 1:** Write failing tests: `operandsInRange` (1000 draws, both in 6...9), `acceptsCorrectSum` ("15", " 15 "), `rejectsWrong` ("14", "", "abc").
204- [ ] **Step 2:** Run `-only-testing:DayByDayTests/ParentGateTests`. Expected: FAIL.
205- [ ] **Step 3:** Implement `ParentGate.swift`, then `ParentGateView.swift`.
206- [ ] **Step 4:** Run it. Expected: PASS. Then check the view in an Xcode preview or the simulator: the hold resets on early release, and a correct sum passes.
207- [ ] **Step 5:** Commit: `feat: add parent gate` with `Ref #N`.
208
209### Task 6: Sound synthesis and engine
210
211**Files:**
212- Create: `DayByDay/Sound/SoundSynth.swift`, `DayByDay/Sound/SoundEngine.swift`
213- Test: `DayByDayTests/SoundSynthTests.swift`
214
215**Interfaces:**
216- Produces: `nonisolated enum SoundEffect: CaseIterable { case success, gentleMiss, tap, roundComplete }`; `nonisolated enum SoundSynth { static let sampleRate: Double = 44_100; static func render(_ effect: SoundEffect) -> [Float] }`; `final class SoundEngine { static let shared: SoundEngine; func play(_ effect: SoundEffect) }`.
217 - Shaping: `success` is a rising major arpeggio (about 3 notes, about 0.4 s); `gentleMiss` is a soft, low, two-note falling tone (about 0.35 s, quieter than success); `tap` is a short click-free blip (under 0.08 s); `roundComplete` is a longer fanfare (about 1.2 s). Use sine plus soft harmonics with an attack/release envelope.
218 - `SoundEngine` pre-renders every effect into an `AVAudioPCMBuffer` at init and plays it on an `AVAudioPlayerNode`. The audio session uses `.playback` like `SpeechSynthesizer`, plus `.mixWithOthers` so effects and speech overlap.
219
220- [ ] **Step 1:** Write the failing tests, one parameterized over `SoundEffect.allCases`:
221
222```swift
223@Test(arguments: SoundEffect.allCases) func noClipping(_ e: SoundEffect) // max(abs(sample)) <= 0.9
224@Test(arguments: SoundEffect.allCases) func noClicks(_ e: SoundEffect) // first and last 64 samples: abs < 0.01
225@Test(arguments: SoundEffect.allCases) func notSilent(_ e: SoundEffect) // RMS > 0.02
226@Test func durations() // tap < 0.08 s; success 0.3–0.6 s; gentleMiss 0.25–0.5 s; roundComplete 0.9–1.6 s
227@Test func missIsQuieterThanSuccess() // RMS(gentleMiss) < RMS(success)
228```
229
230- [ ] **Step 2:** Run `-only-testing:DayByDayTests/SoundSynthTests`. Expected: FAIL.
231- [ ] **Step 3:** Implement `SoundSynth.swift`, then `SoundEngine.swift`.
232- [ ] **Step 4:** Run it. Expected: PASS.
233- [ ] **Step 5:** Commit: `feat: add synthesized sound effects` with `Ref #N`.
234
235### Task 7: Celebration and round view
236
237**Files:**
238- Create: `DayByDay/Quiz/PraisePhrases.swift`, `DayByDay/Quiz/CelebrationOverlay.swift`, `DayByDay/Quiz/RoundView.swift`
239- Test: `DayByDayTests/PraisePhrasesTests.swift`
240
241**Interfaces:**
242- Consumes: `Round`, `QuestionPicker`, `QuizItem`, `SoundEngine`, `SpeechSynthesizer`, `ProfileStore.record`, `ProfileSession.current`.
243- Produces:
244 - `nonisolated struct PraisePhrases { static let all: [String]; mutating func next(using rng: inout some RandomNumberGenerator) -> String }`. At least 8 phrases ("Great job!", "You got it!", "Super!", "Way to go!", ...). Never returns the same phrase twice in a row. `static func correction(for name: String) -> String` returns `"That's \(name)! Try again."`.
245 - `struct CelebrationOverlay: View { init(isActive: Bool) }`: confetti burst in Canvas/TimelineView, about 1 s. With `accessibilityReduceMotion`, a static sparkle that fades instead.
246 - `struct RoundView<Choice: View>: View { init(items: [QuizItem], picker: QuestionPicker, @ViewBuilder choice: @escaping (QuizItem) -> Choice) }`. It speaks `current.prompt` on appear and on each new question, with a large replay-prompt button. On a tap it records via `ProfileStore.record` (skipped for `.ignored`). Correct: `SoundEngine.play(.success)`, overlay, speak praise, then `advance()` after 1.5 s. Incorrect: `.gentleMiss`, speak the correction, and that choice dims briefly. When finished it shows a "You did it!" screen with the mascot placeholder: it plays `.roundComplete`, speaks "You did it!", and offers a big "Play again" button plus back navigation.
247 - `struct MascotView: View { enum Mood { case idle, cheering }; init(mood: Mood) }`: placeholder (simple face in a circle), replaced in part 6.
248
249- [ ] **Step 1:** Write failing tests: `neverRepeatsConsecutively` (500 draws with seeded rng), `atLeastEightPhrases`, `correctionCopy` (`correction(for: "Thursday") == "That's Thursday! Try again."`).
250- [ ] **Step 2:** Run `-only-testing:DayByDayTests/PraisePhrasesTests`. Expected: FAIL.
251- [ ] **Step 3:** Implement `PraisePhrases.swift`, `CelebrationOverlay.swift`, `MascotView` (in `DayByDay/Mascot/MascotView.swift`), and `RoundView.swift`.
252- [ ] **Step 4:** Run it. Expected: PASS. In the simulator, with a temporary preview using `Category.days.quizItems` and `DayCard`-styled choices: rapid taps after a correct answer don't double-record; with Settings › Accessibility › Motion › Reduce Motion on, confetti doesn't fly.
253- [ ] **Step 5:** Commit: `feat: add celebration and round view` with `Ref #N`.
254
255### Task 8: Profile picker, setup, and parent area
256
257**Files:**
258- Create: `DayByDay/Profiles/ProfilePickerView.swift`, `DayByDay/Profiles/ProfileEditorView.swift`, `DayByDay/Parent/ParentAreaView.swift`
259
260**Interfaces:**
261- Consumes: `ProfileSession`, `ProfileStore`, `ParentGateView`, `AvatarAnimal`, `ProfileColor`.
262- Produces:
263 - `ProfilePickerView`: a grid of large avatar tiles on the profile color. Tapping one speaks "Hi, <name>!" and calls `session.select`. A small grown-ups button opens `ParentGateView` → `ParentAreaView`.
264 - `ProfileEditorView(profile: Profile?)`: name field, avatar grid, color swatches, optional birthday (month and day pickers, day range limited by month). Shows the `ProfileError` message inline.
265 - `ParentAreaView`: lists profiles with add, edit, and delete (delete asks for confirmation). Calls `session.profilesChanged()` after any change.
266 - The setup screen is `ParentGateView` → `ProfileEditorView(profile: nil)`, preceded by a short parent-facing line ("Set up a profile for your child").
267
268- [ ] **Step 1:** Build: `xcodebuild build -project DayByDay.xcodeproj -scheme DayByDay -destination 'platform=iOS Simulator,name=iPhone 16 Pro'`. Expected: `BUILD SUCCEEDED`.
269- [ ] **Step 2:** In the simulator, check: create two profiles; the picker speaks the name; delete the current profile from the parent area → picker; delete all → setup.
270- [ ] **Step 3:** Commit: `feat: add profile picker, editor, and parent area` with `Ref #N`.
271
272### Task 9: Home and topic hubs
273
274**Files:**
275- Create: `DayByDay/Home/HomeView.swift`, `DayByDay/Home/TodayBanner.swift`, `DayByDay/Home/CategoryHubView.swift`
276- Modify: `DayByDay/ContentView.swift` (routing by `session.screen`; keep `Category`, `CategoryTile`, `VoiceTipOverlay`), `DayByDay/DayByDayApp.swift` (model container, `ProfileSession` in the environment, scenePhase → `didEnterBackground`/`willEnterForeground`)
277
278**Interfaces:**
279- Consumes: everything above.
280- Produces:
281 - `TodayBanner`: `MascotView(mood: .idle)`, "Today is <day>!" and the date; tapping opens the existing `TodayView`.
282 - `HomeView`: `TodayBanner`, then a `LazyVGrid` of `CategoryTile` over `Category.gridCases`. Current avatar button in the top-trailing corner opens the picker. "Voice Quality Tips" button kept.
283 - `CategoryHubView(category:)`: large activity buttons, laid out the same way for every topic. Part 1 ships "Look and listen" (opens the existing per-category view). It has slots for "Find it!" (part 2) and the topic's special game (parts 3–4), hidden until those exist. Tapping a button also speaks its label.
284 - `ContentView` switches on `session.screen`: `.setup` → setup flow, `.picker` → `ProfilePickerView`, `.home` → `HomeView` in the existing `NavigationStack`.
285
286- [ ] **Step 1:** Build (same command as Task 8). Expected: `BUILD SUCCEEDED`.
287- [ ] **Step 2:** Run the full suite: `xcodebuild test -project DayByDay.xcodeproj -scheme DayByDay -destination 'platform=iOS Simulator,name=iPhone 16 Pro'`. Expected: `** TEST SUCCEEDED **`.
288- [ ] **Step 3:** In the simulator (iPhone, then an iPad simulator, portrait and landscape), check: home shows the banner and 11 topics; a topic opens the hub; "Look and listen" shows the old cards and they still speak. Background the app for more than 10 minutes (`xcrun simctl` to advance, or temporarily lower the constant) with two profiles → picker on return.
289- [ ] **Step 4:** Commit: `feat: add home banner and topic hubs` with `Ref #N`.
290
291### Task 10: Art/sound review, MR, merge
292
293- [ ] **Step 1:** Dispatch a fresh reviewer agent to review the art and sound in this branch: `SoundSynth` output (render each effect to a WAV in the scratchpad and inspect the waveform and spectrum), `CelebrationOverlay`, `MascotView` placeholder, avatars and colors, plus simulator screenshots. Block on clear defects (clipping, harsh or startling sound, unrecognizable drawing, poor contrast). Taste comments are advisory; after two rounds, note what's unresolved for the MR description.
294- [ ] **Step 2:** Fix blocking findings and rerun the full suite. Expected: `** TEST SUCCEEDED **`.
295- [ ] **Step 3:** Push and open the MR:
296
297```bash
298git push -u origin feat/foundation
299gitbay mr create --source feat/foundation --target main --title "Part 1: foundation" --file - <<'EOF'
300Profiles with parent gate, answer log, synthesized sound effects, celebration, question engine and rounds, home banner with topic hubs, unit test target.
301
302Closes #N
303EOF
304```
305
306- [ ] **Step 4:** Check CI with `gitbay build list` and `gitbay build log <n>` if present. When green, merge with `gitbay mr merge <mr> --strategy squash`, then `git checkout main && git pull && git branch -d feat/foundation && git push origin --delete feat/foundation`.