Notes/Design.md (65790B)
1# Reportage Design
2
3## Context
4
5Reportage replaces Reporter, an iOS life-logging app that has been in daily use
6since February 2014 but is no longer maintained. Its weather integration died
7with the Dark Sky API on 2023-04-01 and other parts are starting to break.
8
9The interaction model is the same as Reporter's: the app sends notifications at
10random times during the day, each prompting a short survey about the user's
11current state. Each report also captures context automatically (location,
12weather, motion, device state). The accumulated data is the product.
13
14The aim is a great life-logging app in its own right. Carrying on the
15Reporter archive comes second: the importer exists and stays, but further
16work on Reporter data, such as backfilling it, waits until the app itself is
17settled.
18
19This note describes the design: the data model, how each subsystem works, and
20how the Reporter archive maps in.
21
22## Scope
23
24### In scope
25
26- Random daytime prompts: a configurable number per day at random times within
27 a waking window, like Reporter.
28- Wake and bedtime reports, started manually.
29- Question types: yes/no, multiple choice, tokens (free-form, growing
30 vocabulary), people, location, number and note.
31- Notification actions: **Instant Report** (create a passive report now, fill it
32 in later) and **Snooze**. Tapping the notification opens the full survey.
33- Automatic context: location and placemark, weather, Health data (sleep,
34 activity rings, steps, heart rate and so on), and device state (ambient noise,
35 battery, connectivity). Photos taken aren't recorded.
36- Import of the full Reporter archive, keeping everything Reportage models.
37- On-demand JSON export with a documented, versioned format.
38- Written narratives: each report reads as a short narrative built from its
39 answers, such as 'Not working. Reading at the library, with Sam. Feeling
40 great.' This is what sets Reportage apart from Reporter. See
41 [Narratives](#narratives).
42
43### Not in scope yet
44
45- The Apple Watch app. Mirrored notifications already bring prompts and
46 **Instant Report** to the wrist, which covers most of what it was for. See
47 [Passive Reports and the Watch](#passive-reports-and-the-watch).
48- Backfilling the Reporter archive: the weather gap from April 2023, Health
49 from 2014, and location answers skipped since Reporter lost venue lookup.
50 See [Backfills](#open-questions).
51- iPad and Mac apps.
52- CloudKit sync. With one iPhone and no Watch app, sync adds little: iCloud
53 Backup already includes the store, and JSON export gives a manual
54 off-device copy. Sync is built when a second device needs it, most likely
55 with the Watch app. See [Sync](#sync).
56- Answering surveys inline in the notification.
57
58### Hard requirement: never steal headphone audio
59
60Reporter samples ambient noise by switching the audio session into a recording
61category. That briefly moves whatever is playing on AirPods to the iPhone
62speaker. Reportage must never do this. See [Ambient noise](#ambient-noise).
63
64## Platforms and Project
65
66- iOS 26 and watchOS 26 minimum. Use platform APIs at these floors freely.
67- App Store distribution.
68- Structured like Crossmate:
69 - `project.yml` (XcodeGen). Bundle ID prefix `net.inqk.reportage`, iCloud
70 container `iCloud.net.inqk.reportage`.
71 - `Reportage/`: iOS app (`Models/`, `Persistence/`, `Sync/`, `Services/`,
72 `Views/`).
73 - `ReportageWatch/`: watchOS app.
74 - `Shared/`: code used by both apps: model types, persistence, sync record
75 building and applying, context capture, App Intents.
76 - `Tests/Unit/` and `Tests/Support/`: Swift Testing.
77 - `Scripts/`: `build.sh`, `test-unit.sh`, `select-simulator.sh`.
78 - `Notes/`: design notes like this one.
79 - `AGENTS.md`, with `CLAUDE.md` as a symlink to it.
80- Swift 6 language mode.
81- `reporter-export.json` contains a decade of personal data. It must be
82 gitignored and never committed. Importer tests use a small hand-made fixture
83 in `Tests/Support/` that mirrors the export's quirks.
84
85## Visual Design
86
87The look is called Almanac: ink on paper, like a printed journal.
88
89- **Colours** live in `Theme`: a cream paper, ink, a warm muted grey for
90 secondary text, a hairline rule and one accent (auburn), each with a
91 dark-mode value. The dark paper is a slightly warm near-black. Text keeps at
92 least 4.5:1 contrast against the paper in both modes.
93- **Type:** New York (the system serif) for what the user wrote: narratives,
94 prompts, answers and token names. SF for everything around it. Labels such
95 as dates and report kinds use small spaced capitals. Screen titles are the
96 serif in a warm ink softer than the text's; 'Reportage.' over the timeline
97 is a wordmark: italic, with its full stop in a brighter auburn (rust) than
98 the accent, since a mark that small has to stand out by colour alone. All
99 sizes are Dynamic Type styles.
100- **Tabs:** Timeline, Charts and Settings. The timeline keeps its serif
101 'Reportage' title, beside the quick log and new report buttons. The new
102 report button opens a menu of Manual, Wake Up and Bedtime, so the wake and
103 bedtime reports are visible. A tapped prompt switches to the timeline to
104 open its survey.
105- **Home screen:** reports grouped under day headings, newest first. Each
106 shows its own local time (the period beneath on a 12-hour clock, so times
107 fit one column), its kind, its narrative, any answers the narrative doesn't
108 cover, and a line of context: the city with its region ('Suginami, Tokyo',
109 put together from the locality and region for imported placemarks), the
110 weather, and Health: time asleep on a wake report, and steps so far that day
111 on the rest, with Reporter's step count standing in for a report Health
112 hasn't filled in. Days are grouped in the device's time zone: grouping by
113 each report's own zone would put reports out of order around midnight after
114 a change of zone, which a sectioned fetch can't show. Grouping by a computed
115 day loads every report the fetch covers, and regroups them all whenever one
116 changes, so the list covers the newest 300 reports back to the start of a
117 day, and reaches back 500 more each time it's scrolled to its end.
118- **Report detail:** tapping a report in the timeline pushes its detail view:
119 the day, the time in the report's own zone and its kind, a map of where it
120 was made (with a circle for the fix's accuracy), every answer with the
121 prompt it was asked under ('Skipped' for questions left unanswered), then
122 every value recorded with it, in titled sections (Time, Place, Location,
123 Weather, Device, Motion, Sound, Photos, Record) of label and value rows; the
124 address in the place's own language is labelled 'Endonymic Address'. The
125 map can be panned and zoomed, but not rotated; once moved, a button in its
126 corner brings it back to the report's spot. It has no zoom buttons, as maps
127 on iPhone don't. The narrative isn't repeated here. Activities and people are
128 shown as pills, one per token, since an answer can have several: the name
129 in the serif on a faint wash of the accent, quieter than the survey's
130 ink-filled tokens, which can be tapped where these can't. Measurements are
131 shown in the user's locale's units. Edit (or Answer, for an instant report)
132 opens the survey, and Delete Report deletes it after asking. Deleting
133 removes the report and its responses but keeps its tokens.
134- **Survey:** a flat header (Cancel, the kind and time, '3 / 6' and a progress
135 bar with a segment per question) instead of the glass toolbar, a serif
136 prompt, ink-outlined answer buttons, chips for chosen tokens and an
137 underlined search field.
138
139Spacing lives in `Theme` as a few values named by role (the screen margin,
140the gap between a prompt and its answer, between items in a group and so on),
141so one role can change without others that share its value. Gaps tuned to
142particular fonts and the sizes of particular controls stay with their views.
143
144## Data Model
145
146Persistence is Core Data with raw `CKSyncEngine`, as in Crossmate. It does not
147use `NSPersistentCloudKitContainer` or SwiftData. The local store is normalised
148for querying. CloudKit records are coarser (see [Sync](#sync)).
149
150The model has a single version, edited in place. Lightweight migration is on,
151and a SQLite store keeps a copy of the model it was made with, so a change
152Core Data can infer (adding or removing an attribute or entity, or renaming
153one with a renaming ID) migrates an existing store without the old model in
154the app. A change that needs data rewritten would need a migration of its own.
155
156### Question
157
158| Field | Notes |
159|---------------|--------------------------------------------------------------|
160| `id` | String. Imported questions keep Reporter's `uniqueIdentifier` (e.g. `default-question-2`). New questions use UUIDs. |
161| `prompt` | Text shown to the user. |
162| `kind` | `yesNo`, `choice`, `tokens`, `people`, `location`, `number`, `note`. |
163| `options` | For `choice`: the fixed answer list. |
164| `placeholder` | Optional. |
165| `narrativeRule` | How answers read in a narrative (see [Drafts](#drafts)). Missing when the kind implies the rule. |
166| `askOn` | Set of report kinds the question appears in: `random`, `wake`, `bedtime`. |
167| `order` | Sort order within a survey, one order across all surveys. Narratives read in the current order, so reordering a question changes past narratives too. |
168| `showsInTimeline` | Whether answers appear in the timeline's narratives. Hidden answers are still shown in a report's details. |
169| `archivedAt` | Questions with answers are archived, never deleted, so history keeps its meaning. One never answered can be deleted. |
170
171Reporter's `questionType` values map as: 0 → `tokens`, 1 → `choice`,
1722 → `yesNo`, 3 → `location`, 4 → `people`, 5 → `number`, 6 → `note`.
173
174Reporter's question records don't store which survey each question belongs to.
175The importer infers `askOn` from the most recent report of each kind, which
176shows each survey as last configured (skipped questions still appear as empty
177responses). A question in none of those surveys gets every survey it ever
178appeared in.
179
180The export doesn't include the answer lists for choice questions either. The
181importer rebuilds them from the answers given, most common first.
182
183A fresh install starts with a default question set covering every question
184kind (`DefaultQuestions`). The defaults are only added to a store with no
185questions at all, and an import that adds questions archives them, so they
186never mix with an imported archive in the surveys; answers already given to
187them keep their meaning. They have fixed
188IDs (`reportage-default-` plus a name), so seeding is idempotent and two
189devices that both seed them end up with the same questions after syncing.
190They're seeded with `modifiedAt` at the Unix epoch, so an edited copy from
191an export or another device is always newer and wins over a fresh seed.
192Their prompts are written in the user's language at seeding time and are
193ordinary data after that.
194
195**The Questions screen.** Settings lists the questions by survey (prompted,
196wake, bedtime), plus those not asked in any and those archived. Dragging reorders a question
197among those in the same survey, leaving the rest of the order alone. Opening
198a question edits it in place: its prompt, a choice question's answers,
199whether it shows in the timeline and how it reads there, and the surveys it's
200asked in. Each field is saved when it's finished, not on every keystroke.
201Rewording a question leaves past reports with the prompt they were answered
202under. Renaming a choice answer renames it in past reports too, as renaming a
203token does, and those reports count as modified; removing one leaves past
204answers as they were.
205
206The screen avoids the word 'narrative', which means nothing to someone using
207the app: a question's type is shown with a sentence on how its answers appear
208in the timeline, and the narrative rule's fields sit in the Timeline section
209under Show in Timeline, with an example of how answers read. The type is
210chosen when a question is added, in the same form, and is shown but can't be
211changed after that, since answers already given wouldn't fit another type.
212Text fields sit on a faint wash of ink (`Theme.field`) so they read as
213somewhere to type, and each answer is its own field, without rules between. A
214new question goes to the end of the order, asked in the prompted survey.
215Asking an archived question brings it back in that survey alone.
216
217A question with no answers can be deleted, after a confirmation; the reports'
218records of it being skipped go with it, and those reports count as modified.
219A question with answers can't be deleted, since the answers would lose their
220meaning, so the screen says how many reports answered it and offers Archive
221Question instead, which stops it being asked. Archived questions are listed
222in their own section with a note on why they're kept, and their answers still
223show in their reports and narratives.
224
225A question with answers can be merged into another of the same type with
226**Merge Into…**, after a confirmation. Its responses are reassigned to the
227other question; the prompt text stored with each response is unchanged. Its
228tokens are reassigned too, and a token with the same name as one of the other
229question's is merged into that one. Its choice answers join the other's,
230and the merged question is deleted. Unlike merging tokens, this can't be
231undone. An archived question with no answers, such as a default the Reporter
232import replaced, can be deleted.
233
234**Editable questions.** Every question is the user's to edit, the defaults
235included: there is no fixed built-in set. Each question stores its own
236[narrative rule](#drafts), so rewording a question or its rule never depends
237on its ID. The default questions get their rules from `NarrativeRule.builtIn`
238when they're seeded, and Reporter's built-in questions (`default-question-1` to
239`-7`) get the rules of the defaults that ask the same things when they're
240imported, so imported answers read as narratives too.
241
242### Report
243
244| Field | Notes |
245|---------------|--------------------------------------------------------------|
246| `id` | UUID. Imported reports keep Reporter's `uniqueIdentifier`, which makes re-import idempotent. |
247| `date` | The moment being described: when the prompt notification or the passive log was tapped, not when the survey was finished. |
248| `timeZone` | IANA identifier, stored explicitly. Reporter didn't do this and its export lost every report's local time. |
249| `kind` | `random`, `wake`, `bedtime`, `manual`. |
250| `trigger` | `notification`, `app`, `watch`, `intent` (Shortcuts, Control Center, Action button), `imported`. |
251| `state` | `passive` (logged, awaiting answers), `complete`. |
252| `promptedAt` | Fire time of the notification that prompted it, if any. Used to analyse response delay. |
253| `completedAt` | When the survey was submitted. |
254| `context` | Encoded `Context` value (below). |
255| `modifiedAt` | Used for last-writer-wins on sync. |
256
257### Response
258
259One per question answered in a report.
260
261| Field | Notes |
262|---------------|--------------------------------------------------------------|
263| `questionID` | Reference to `Question.id`. |
264| `prompt` | The prompt text at the time of answering. Questions can be reworded later, and Reporter stores it the same way. |
265| `value` | Tagged union, by question kind: `options: [String]` · `tokens: [Token.ID]` · `number: Decimal` · `text: String` · `place: PlaceAnswer`. `nil` when the question was shown but skipped. |
266
267`PlaceAnswer` holds the place's token ID, plus the coordinate and accuracy of
268where the answer was given.
269
270### Token
271
272A reusable answer to a `tokens`, `people` or `location` question: an activity,
273a person or a place. Responses refer to tokens by ID rather than copying their
274text, so editing a token renames it throughout history. Reporter worked the
275same way: it shared one ID between every answer using a token, and renaming
276'Driving' to 'Driving a car', or the old 'Home' after a move, updated every
277past narrative.
278
279| Field | Notes |
280|---------------|--------------------------------------------------------------|
281| `id` | String. Imported tokens keep Reporter's `uniqueIdentifier`. New tokens use UUIDs. |
282| `questionID` | The question whose answers the token belongs to. |
283| `text` | The name shown. Editing it is a rename. |
284| `place` | For location tokens: a representative coordinate, names from the directory by language, and an optional external ID. |
285| `mergedInto` | Set when the token has been merged into another. Answers referring to it read as referring to that token, so a merge rewrites no reports and can be undone. |
286| `archivedAt` | Tokens are archived, never deleted. |
287| `narrativeForm` | Optional. How the token reads in a narrative, used as written in place of the rules: an English form of a name written in kanji ('Hanako' for 山田花子), 'my desk' for a place, or an activity's casing. Answers shown outside the narrative keep `text`. |
288| `modifiedAt` | Used for last-writer-wins on sync. |
289
290**Places** keep their names and coordinate, not just an external ID, so the
291record keeps its meaning if a directory goes away. Foursquare is the example:
292its venue lookups stopped working in Reporter on 2026-09-01, but each answer
293already held the name and coordinate. Imported places keep their Foursquare
294venue IDs (3,362 answers). New places use MapKit's `MKMapItem.Identifier`.
295
296A place's `text` is what the user chose. Its directory name is kept beside
297it as a `(language, text)` pair: see [Place names](#place-names).
298
299**Settings → Vocabulary** lists the activities, people and places in use,
300most used first, where each can be renamed and given a narrative form. A
301token can also be merged into another of the same kind, from any question
302of that kind: **Merge Into…** on its detail screen picks the other token
303and asks for confirmation. The surviving token's screen lists what was
304merged into it, under **Merged Into This**, with each token's own report
305count, and swiping one separates it again. A merge only sets `mergedInto`,
306so separating restores the token as it was, with its name and narrative
307form. Merges can chain: a token merged into one that's later merged
308elsewhere follows it, and is listed on the token at the end of the chain.
309
310A merged token's name still finds the token it went into when answering a
311survey, so typing an old name doesn't add it again. An answer that used two
312tokens since merged names the token once.
313
314### Vocabulary (local only)
315
316Suggestions for token, people and place answers are ranked from a derived
317local index built from response history: use count, last used, and the
318coordinate centroid for places. It is rebuilt from responses and never synced.
319Token identity and text are not part of the index: they live in the synced
320`Token` records.
321
322### Carrying people forward
323
324In a new report, the people of the previous report are chosen already when
325the place is the same as that report's place: being in the same place
326shortly after is good evidence of being with the same people. The previous
327report is the latest answered one before this report, if it's no more than
3282 hours earlier. Instant Reports still waiting for answers are passed over.
329The place counts whether the user chose it or it was pre-filled from the
330location. Places and people are compared as the tokens they were merged
331into, and people no longer suggested are left out.
332
333The people follow the place: choosing a different place, or none, takes
334them away, and choosing the same place again brings them back. Once the
335user changes the people answer, it's left alone. Activities aren't carried
336forward: they change more often than company, and copying them would
337undercut a random prompt. As with the place pre-fill, this applies to new
338reports only, not to reports being edited or Instant Reports being filled
339in.
340
341### Place names
342
343A place has one name: the one MapKit gave when it was chosen, in the app's
344language, or the one the user typed. Renaming it in Settings → Vocabulary
345changes it everywhere. Places aren't shown in a list of languages the user
346knows: on-device MapKit returns names in the app's language only, and the
347Maps Server API that takes a language needs a signed key, which wasn't worth
348it once places could be renamed and given narrative forms. The directory's
349name and its language are still stored, so a renamed place can be told
350apart from one that kept the directory's name.
351
352### Choosing a place
353
354MapKit is the place directory: it needs no key or server and costs nothing.
355Google Places was ruled out because its terms only allow place IDs to be
356stored, so a life log built on it would hold IDs that need a paid lookup to
357read and that lose their meaning if the API changes. Open Places API (hosted
358Overture data) allows storage but has weaker data and an unnamed operator; it
359is a fallback if MapKit's terms turn out to forbid storing names.
360
361Candidates, in order:
362
3631. **The user's saved places**: the places they named themselves, ranked by
364 distance from the current location, then by use and recency. This needs no
365 network, and covers most answers: 14 saved names account for 80% of the
366 archive's location answers. As in Reporter, picking a venue from the
367 directory doesn't add it to this list, so venues answered once don't crowd
368 it. A venue joins the list once the user renames it or gives it a
369 narrative form, since that marks it as one of theirs, such as their
370 workplace. Other venues answered before come back when the directory lists
371 them again, merged with their token, or in a search. A place is saved when
372 its token has no external ID, or its name isn't the directory's, or it has
373 a narrative form; in the archive, no place was used both ways.
3742. **Nearby places** from `MKLocalPointsOfInterestRequest`, when nothing in
375 history is close.
3763. **Search** across history and MapKit together. MapKit matches queries in
377 either language: 東京タワー finds Tokyo Tower with the app in English.
3784. **A new place**: a name the user types for the current location.
379
380Candidates are merged by external ID, and Foursquare-era places (which have no
381MapKit ID) by name and distance.
382
383In the survey (`PlacePicker`):
384
385- **Ranking.** Distances fall into bands (150 m, 400 m, 1 km, 5 km, 25 km,
386 beyond, unknown), and places rank by band, then by use and recency. Two
387 places a few hundred metres apart are both within the fix's error and the
388 spread of past answers, so the one used more is the better guess. A place's
389 coordinate is the token's own, or else the centre of where its answers were
390 given.
391- **Sections.** With a location: the user's saved places within 500 m, then
392 nearby MapKit places (within 250 m, closest first). Places further away are
393 found by searching. Without a location: all the saved places by use. A
394 search lists the user's matching places, saved or venues, at any distance,
395 then MapKit's results in MapKit's order, biased to a 20 km region around
396 the location.
397- **Pre-filling.** When the fix arrives and it's accurate to 50 m, the
398 user's place within 50 m of it is chosen already, but only if it's the
399 only one that close: home and the café next door can't be told apart, so
400 neither is chosen. It applies to new reports only, not to reports being
401 edited or Instant Reports being filled in, and not once the user has
402 chosen or started searching. A kept pre-fill is stored like any other
403 answer.
404- **Merging.** A MapKit place that's one of the user's places is shown as
405 theirs, at MapKit's coordinate: the same MapKit ID, or a place without one
406 with the same name within 200 m.
407- **Timing.** Capture reports the fix as soon as it has one, before the
408 address lookup, and the nearby search starts then. The list is ranked once,
409 for that fix, so it doesn't reshuffle while the user is choosing.
410- **New tokens.** Choosing a MapKit place makes a token holding its name (with
411 the app's language) and MapKit ID. Its coordinate is the report's own
412 location, when the report is within the place's region; a place chosen from
413 further away gets none, and comes back through MapKit by its ID. Adding a
414 typed name makes one at the report's location. Either is saved only if it's
415 still the answer when the survey closes.
416- **Regions.** A place is its name and a location: it covers 500 m around its
417 coordinate, the same as the near distance. Typing a place's name inside that
418 region chooses the place; typing it further away adds a new place with the
419 same name, so 'Home' after a move is a new place rather than one stretched
420 over two addresses. Reporter's saved places worked this way: each of the
421 archive's 14 had a single coordinate, and over 99% of reports were within
422 500 m of the saved place they answered. A place without a coordinate has no
423 region, and is matched by name alone, as everything is without a location.
424- **Telling places apart.** Places sharing a name show, beneath the name, the
425 locality of the last report that used them. This is shown only in the
426 picker: narratives use the place's name alone.
427- **The map** shows the report's location, and pins the chosen place, centred
428 on it and zoomed out far enough to keep the location in view. It makes way
429 for the keyboard while searching.
430
431### Context
432
433`Context` is a `Codable` struct stored on the report rather than separate
434entities. Every section is optional, and each section records a `source` where
435more than one provider exists over time.
436
437- `location`: coordinate, altitude, accuracies, speed, course, fix timestamp
438 and placemark: the name, city and country, the region code, the city with
439 its region, the full and short addresses, and the language they're in, with
440 the address in other languages beside it (see [Location](#location)).
441 Imported reports have Reporter's placemark (thoroughfare, locality,
442 administrative area, postal code and so on) until **Upgrade Address Format**
443 replaces it.
444- `weather`: normalised to metric: condition, temperature, feels-like, dew
445 point, humidity, pressure, wind speed, gust and direction, visibility, UV,
446 cloud cover, precipitation. `source` is `wunderground`, `darkSky` or
447 `weatherKit`.
448- `audio`: average and peak dB, plus `source`. Only `microphone` values are
449 stored here; Health noise goes in the Health cache.
450- `motion`: steps, floors ascended and descended, barometric pressure,
451 relative altitude.
452- `device`: battery level and state, connectivity (`wifi`, `cellular`, `none`).
453- `photos`: count and lightweight metadata of photos taken since the previous
454 report. Only reports imported from Reporter have it; Reportage doesn't record
455 photos itself.
456
457Health context isn't part of `Context`. It's a local cache kept beside the
458report and never synced (see [Health](#health)).
459
460Context fields fall into two groups, and this shapes the whole capture design:
461
462- **Live**: fields that only exist at that moment: location if there's no
463 history, ambient noise from the microphone, battery, connectivity. These are
464 captured immediately or not at all.
465- **Derivable**: fields that can be computed afterwards for any timestamp:
466 Health samples and historical weather. These are filled in lazily when
467 possible, and can be backfilled.
468
469## Narratives
470
471Each report reads as a short written narrative, built deterministically from
472the answers. The same answers always read the same way, with nothing invented,
473dropped or changed.
474
475### Drafts
476
477Each question has a `NarrativeRule` saying how its answer reads:
478
479| Rule | Used for | Example |
480|------|----------|---------|
481| Activities | `tokens` questions that open the sentence | 'Reading, drinking coffee and watching Netflix…' |
482| Place | `location` questions | '…at the library…' |
483| People | `people` questions | '…, with Sam and Kai.' |
484| Phrases | yes/no | 'Yes' → 'Working', 'No' → 'Not working' |
485| Template | choice; `tokens` questions with a sentence of their own | 'Feeling %@' → 'Feeling great' |
486| Count | number | '1 coffee', '2 coffees' |
487| Quote | note | "Learned: 'The neighbours are nice people.'" |
488
489Answers read in the questions' current order, so the user decides how
490narratives read by reordering questions, and every narrative follows,
491including imported ones. Activities, place and people join one clause, placed
492where the first of those answers comes. Other answers are one sentence each.
493Only one list question can be set to open the sentence in the question
494editor; one that already does in an older store keeps doing so, and a store
495can have several.
496An answer to a question with no rule, or a rule left blank, is shown beneath
497the narrative as its prompt and answer. Answers to a question not shown in
498the timeline are left out of both.
499
500Notes are quoted exactly as written and never rewritten: free writing breaks
501templates in ways casing can't fix (several sentences, first person, lists).
502
503Later activities in a list are lowercased only when the first word is
504capitalised just at its start, its lowercase form is an ordinary English word
505(`UITextChecker`) and the language tagger doesn't mark it as a name. So
506'Drinking coffee' becomes 'drinking coffee', while 'Watching Netflix',
507'Studying Japanese' and 'TV' keep their capitals. People are shown by the part
508of their name before the first space ('Sam' for 'Sam Lee'), except names in
509Chinese, Japanese or Korean script, which put the family name first and are
510shown whole. Places read as below. A token's `narrativeForm`, when set, wins
511over all of these.
512
513Narratives are English only; other languages aren't planned. A name in
514another script can be given an English narrative form.
515
516### Places
517
518A place reads after 'at', decided in this order:
519
5201. **A directory's name** is shown as written: a place with a MapKit or
521 Foursquare ID whose text is still one of its directory names ('at Blue
522 Bottle Coffee', 'at 吉祥寺駅'). A place with no directory names, as with
523 imported Foursquare venues, counts as named by its directory. Once renamed,
524 the place is the user's own word and goes through the rules below.
5252. **Places that read without an article** (`PlacePhrase.barePlaces`: home,
526 work, school, bed, church…) are lowercased: 'at home'.
5273. **Ordinary words** are lowercased and take 'the' ('at the library', 'at
528 the coffee shop'), or keep an article they already have ('The beach'
529 becomes 'the beach'). That means only the first letter is a capital,
530 every word has letters with case and nothing else, every word passes the
531 spell checker (`UITextChecker`), and the language tagger doesn't mark the
532 text as a name.
5334. **Anything else** is taken to be a name and shown as written: 'Central
534 Library', 'IKEA', 'Mum's', 'Kichijōji'.
535
536The rules guess wrong now and then (a restaurant typed as 'Bank' becomes 'the
537bank'), so a place's `narrativeForm` wins over them. It replaces what follows
538'at', not the preposition.
539
540### Why not the on-device model
541
542The on-device model (`SystemLanguageModel`) isn't used to write or proofread
543narratives:
544
545- **Writing narratives from scratch** invents details (a kitchen table, a
546 date, a time of night), changes what notes mean, drops answers and assigns
547 people to the wrong activities.
548- **Proofreading** is safe only behind placeholders for names and non-ASCII
549 words, and a check that every output keeps every word. Even then the model
550 leaves text unchanged about three times in ten ('at Home' keeps its
551 capital), so narratives would need retries, storage, versioning and a
552 'Writing narrative…' state while they're written. Its only real job would
553 be places, which the rules above do reliably, at once and the same way
554 every time.
555
556## Prompt Scheduling
557
558### Generating times
559
560Settings (`PromptSettings`): prompts on or off, prompts per day `n` (default
5614), a waking window (default 9:00 to 22:00, optionally different on weekends,
562and able to run past midnight), a minimum gap between prompts (default 30
563minutes) and the snooze length (default 15 minutes). Prompts are off until the
564user turns them on in Settings. The settings live in `UserDefaults` and
565don't sync: only the iPhone that schedules prompts uses them, and a second
566phone is set up on purpose rather than doubling the prompts. Exports leave
567them out too.
568
569Times are **stratified random** (`PromptSchedule`). The waking window is split
570into `n` equal slots with one time drawn uniformly in each. Unlike drawing `n`
571times uniformly from the whole day, this avoids clusters and long silences,
572while still keeping each prompt unpredictable. To keep the minimum gap, the
573slots share the window less the `n - 1` gaps, and each later time is pushed on
574by one more gap. A gap too large for the window shrinks to fit.
575
576Draws are **deterministic per day**. The random generator (SplitMix64, written
577out so an OS update can't change it) is seeded from a per-install secret plus
578the calendar date. Rescheduling is then idempotent: re-running the scheduler
579at any point produces the same times, so pending notifications don't get
580reshuffled every time the app launches.
581
582Prompts use calendar triggers without a time zone, so they fire at the same
583local time wherever the phone is. Each notification's identifier is its kind
584and local fire time (`prompt.20261014-090507`), so the scheduler only adds and
585removes the difference between the plan and what's pending.
586
587### The 64-notification limit
588
589iOS keeps at most 64 pending local notifications per app. The scheduler keeps a
590rolling horizon (default 7 days × `n`, capped at about 50 so there's room left
591for snoozes) and tops it up whenever the app gets execution time:
592
593- launch and moving to the foreground
594- handling a notification action (actions launch the app in the background)
595- saving a report
596- a `BGAppRefreshTask`, requested about every six hours while prompts are on
597
598The last notification in the horizon is replaced by a reminder ('Reminders
599Ending: Open Reportage to keep reminders enabled.'), so a long stretch without
600opening the app ends with a nudge instead of silently stopping. Prompts
601themselves read 'Reporting Time: How are things going?'.
602
603Only the iPhone schedules prompts. watchOS mirrors iPhone notifications,
604including their action buttons, so prompts and **Instant Report** work from the
605wrist with no extra work.
606
607### Notification actions
608
609Category `prompt`:
610
611- **Instant Report** runs in the background. It creates a `passive` report with
612 `date` set to now, `promptedAt` set to the fire time, and captures live
613 context.
614- **Snooze** runs in the background and schedules a one-off repeat of the
615 prompt in 15 minutes (configurable). The snoozed prompt keeps the original
616 `promptedAt`.
617- **Tapping the notification** opens the survey with `date` set to when the
618 notification was tapped and `promptedAt` set to when the prompt first
619 fired. If a survey or Settings is already open, it
620 waits until that closes.
621
622Location for background actions requires 'Always' authorisation, and
623'Always' only counts while the app holds an `.always` `CLServiceSession`. A
624new session only takes effect in the foreground: one started when an action
625launches the app grants nothing, and Core Location withholds its updates. So
626with 'Always' granted, the app holds one session for as long as it runs,
627renewed each time it comes to the foreground and taken again as soon as it
628launches, which Core Location allows for a few seconds after any launch if
629the app held one when it last stopped. It also monitors significant location
630changes, so Core Location relaunches it as the user moves, which keeps the
631session going and leaves a recent fix for the next capture. iOS reminds the
632user now and then that Reportage has used their location in the background,
633which is true and fine. A force-quit or restart ends the session until the
634app is next opened. Without 'Always', passive reports logged from a notification get
635no location, and the Prompts section of Settings says so, with a link to
636Settings.
637
638The first time the app is opened, a welcome screen says what Reportage does
639and why it will ask for location and notifications; Continue asks for
640location, then notifications (alert and sound). Reporting is the app's purpose and every report
641records its location, so a report made before the user had decided, or that
642went without, would look like the app not working. Location is asked for as
643'Always', which iOS shows as the usual 'While Using' prompt; choosing that
644grants 'Always' provisionally, and iOS confirms it with the user later.
645Allowing notifications turns on random prompts. If they weren't allowed then,
646turning prompts on in Settings asks again.
647
648## Passive Reports and the Watch
649
650A passive report records "this moment" with its context and nothing else. It
651appears in the timeline like any other report, labelled 'Instant', rather than
652in a list of unfinished reports: some users will want to keep such reports as
653they are, and shouldn't feel pressed to fill them in. Its detail view offers
654**Answer**, which fills it in, answering the survey as of the report's
655original `date` with the context it was logged with. Only the answers and its
656completion are saved, so a context capture still under way isn't
657overwritten.
658
659A passive report is saved as soon as it's logged, so it's in the timeline at
660once, and its context is added when the capture finishes (`PassiveLog`). The
661home screen's quick log button, a bolt beside the +, makes one without
662opening the survey. The app icon isn't badged: an instant report is a
663finished record, not something left to do.
664
665Any finished report can be edited the same way, with **Edit** in its detail
666view. The survey shows the questions the report answered, in its order and
667as they were asked, including archived ones, rather than today's survey:
668adding new questions to an old report would rewrite history. Answers using
669archived or merged tokens still show as chosen. An answer left as it was keeps
670its response exactly, with the prompt it was given under and where a place
671answer was given, and responses to questions that no longer exist are kept.
672A changed answer keeps its original prompt. The report keeps when it was
673completed; its narrative is rewritten because its draft changes.
674
675There's one App Intent, `LogPassiveReportIntent`, in `Shared/`. It drives every
676quick-log surface:
677
678- the Watch app's main button
679- a watchOS Smart Stack widget and a Control
680- the iOS Control Center control and Lock Screen widget
681- the Action button (iPhone and Apple Watch Ultra)
682- Siri and Shortcuts
683
684Controls and widgets live in a widget extension, and an intent they trigger
685runs in the extension's process by default. `LogPassiveReportIntent` conforms
686to `LiveActivityIntent` so the system runs it in the app's process instead,
687launching the app in the background if need be, as a notification's Instant
688Report does. Capture needs the app: location is live, and a short-lived
689extension with its own memory limit is a poor place to wait for a fix. It
690also keeps the store in the app's container, so there's no App Group and only
691one process writes to it. The extension compiles the intent but never
692performs it; the app supplies the logging through `AppDependencyManager`.
693
694**The Watch app is deferred.** A prompt mirrored to the Watch already logs
695an instant report from the wrist, with the iPhone capturing its location in
696the background. A Watch app would add logging from the wrist without a
697prompt, logging when the iPhone isn't nearby (prompts are scheduled on the
698phone, so none reach the Watch without it) and answering quick questions on
699the wrist. It's reconsidered if those are missed. The rest of this section
700describes it as planned.
701
702The Watch app is otherwise minimal: log, see recent passive reports, and
703optionally answer the quick questions (yes/no and choice) on the wrist. Token,
704people and place answers are left for the phone.
705
706The Watch captures what it can at log time: timestamp, time zone and
707location. Heart rate and other Health context are filled in later on the
708phone, into its local Health cache, from the samples the Watch has synced to
709Health.
710
711## Context Capture
712
713Capture runs under a time budget (about 10 seconds; background actions get
714roughly 30), and each provider runs concurrently and independently. A failed or
715denied provider leaves its section `nil`. It never blocks saving the report.
716
717### Location
718
719`CLLocationUpdate.liveUpdates()`, taking the first recent fix within an
720accuracy threshold (50 m), then falling back to the best fix within the
721budget, less 3 seconds kept for looking up the address. A fix counts as
722recent if it's at most 30 seconds old or the update says the device is
723stationary. Core Location often starts with a cached fix, which can be
724accurate but minutes old and somewhere else, so an older fix never ends the
725search early: it's kept as a fallback, and any recent fix beats it. Authorisation is asked for when
726the app is first opened (see [Notification actions](#notification-actions));
727holding a `CLServiceSession` would otherwise ask for 'While Using' the first
728time a survey opens. Capture starts
729when the survey opens, so the fix describes the moment of the report, and a
730place answer records the fix as where it was given.
731
732Addresses come from MapKit as `MKMapItem`s: the placemark holds the name,
733city and country, the language, the region code, the city with its region
734and the full and short addresses. Reverse geocoding uses MapKit's
735`MKReverseGeocodingRequest` (`CLGeocoder` is deprecated in iOS 26), using
736`preferredLocale`: once in the user's first language, and again in the
737place's local language when that differs (worked out from the first result's
738country: `ja` for Japan, `zh-Hant` for Taiwan), so the detail view can show
739the address in the place's own language too. Apple throttles geocoding: two requests per
740report is fine, and **Upgrade Address Format** (see [Behaviour](#behaviour)) looks
741up older addresses again at the pace it allows.
742
743### Weather
744
745WeatherKit current conditions at the report's coordinate, captured live
746(`AppleWeather`). The request starts as soon as there's a fix and runs
747alongside the address lookup, within the same allowance, so the capture keeps
748its budget; no answer in time leaves `weather` empty. The condition is stored
749as WeatherKit's description in the app's language, and the readings in metric.
750This needs the WeatherKit entitlement, and the App ID needs WeatherKit
751enabled. The report detail view shows the Apple Weather mark and a link to its
752data sources beneath the Weather section of reports with WeatherKit weather.
753
754WeatherKit's historical hourly data goes back to August 2021, so the gap in
755the Reporter archive from April 2023 could be backfilled (about 5,000
756requests, well within the free quota), with values tagged `source: weatherKit`
757and `backfilled: true`. This is deferred with the rest of the Reporter work.
758
759### Health
760
761Read-only HealthKit access, to begin with:
762
763- **Activity so far today:** steps, walking and running distance, and flights
764 climbed, from local midnight in the report's time zone up to the report.
765 Statistics queries sum them, which merges the iPhone's and the Watch's
766 samples without counting them twice.
767- **Sleep, on wake reports only:** the night before, from sleep samples in
768 the 18 hours up to the report. iPhone and Watch both record sleep, and their
769 samples overlap, so one source is used: the one with the most time asleep.
770 Its asleep samples are split into sessions wherever they're more than an
771 hour apart, so an afternoon nap isn't joined to the night, and the longest
772 session is the night. From it come when sleep started and ended, the time asleep, and the time in
773 each stage (core, deep, REM, awake) where the source records stages.
774
775Activity rings, heart rate and environmental noise may follow; they aren't
776read yet.
777
778Health access is asked for in the welcome, after location and notifications.
779An install that was welcomed before Health was asked for sees the welcome
780once more, so it can ask.
781
782Reports filed after Health was first asked for are filled in automatically:
783as soon as they're saved if the iPhone is unlocked, and otherwise the next
784time the app comes to the foreground. Earlier reports, the imported archive included, are filled in only when the
785user asks, with **Import Health Data**, on the Historical Data screen in Settings' Data section. It works
786newest first and in batches, and can be stopped and run again; it skips
787reports already settled.
788
789Reportage never writes to HealthKit. Its own store is the record of
790everything it captures; HealthKit is only read from.
791
792**Health context is a local cache, not synced data.** Values read from
793HealthKit are kept in Core Data on the iPhone, in their own entity rather
794than in the `Context` blob, and are left out of CloudKit records.
795HealthKit already syncs and restores Health data across the user's devices
796with end-to-end encryption, so a new device rebuilds the cache from its own
797store. Keeping it out of iCloud also follows App Review's rule against
798storing personal health information there. The Watch never needs the cache.
799
800HealthKit data is unavailable while the device is locked. Most background
801actions happen while locked, so Health context is derived later. On the next
802foreground launch, reports without settled Health context are filled in by
803querying for samples around their timestamp. The same mechanism fills in
804Health context for imported Reporter reports, as far back as the user's
805Health history goes. That's kept apart from imported values: Reporter's steps
806and noise came from Core Motion and the microphone, so they stay in `motion`
807and `audio` and sync with the report.
808
809- **Settling.** Health data keeps arriving after the moment it describes:
810 Watch samples sync late, sleep sessions are finalised after waking, and
811 'steps today' depends on when the Watch last synced. Each cache entry
812 records when it was derived. It's re-derived on later launches until it is
813 24 hours past the report, then treated as settled.
814- **Missing values.** A report with no cache entry hasn't been filled in. An
815 entry with a value left out means Health had nothing for it: HealthKit
816 reports denied read access as empty results, so 'no samples' and 'not
817 allowed' look the same and the cache doesn't try to tell them apart.
818 Nothing is read until Health access has been asked for, so 'never asked'
819 is never confused with either. Settled entries aren't read again.
820- **Export.** Exports leave the cache out, since a new device rebuilds it
821 from Health.
822
823### Ambient noise
824
825In order of preference:
826
8271. **HealthKit `environmentalAudioExposure`**, recorded by the Watch's Noise
828 app. It never touches the audio session, and is derivable, so it can be
829 filled in later. Like other Health values, it goes in the local Health
830 cache rather than in the synced `audio` section.
8312. **Microphone sampling** for about 2 seconds, only when the current output
832 route is the built-in speaker or receiver. The session uses `.playAndRecord`
833 with `[.mixWithOthers, .allowBluetoothA2DP]` and the built-in mic as the
834 preferred input. That should keep playback on AirPods, but behaviour
835 depends on the route, so this must be verified on a device. Until it is,
836 the rule is simple: **if headphones of any kind are connected, don't touch
837 the audio session.**
838
839Microphone sampling is deferred. It needs its own permission and the route
840check verified on a device. Health noise isn't among the first Health values
841either, so ambient noise isn't recorded yet, and both are reconsidered when
842Health grows.
843
844### Device
845
846Battery from `UIDevice`, connectivity from `NWPathMonitor`.
847
848## App Lock
849
850**Settings → App Lock** can lock the app behind Face ID, falling back to the
851device passcode. It's off by default, and turning it on or off asks for Face
852ID first. The lock comes back immediately on leaving the app, or after 1, 5
853or 15 minutes in the background. Only a return from the background locks:
854Face ID's own prompt and Control Center make the app inactive without
855leaving it.
856
857While the app is in the background with the lock on, a window above
858everything else blurs it, so the app switcher's snapshot shows nothing
859legible. iOS animates a returning app from that snapshot, so the blur shows
860briefly on every return; it comes off as soon as the app starts coming back,
861when it's inactive, rather than once it's active. If the app was away long
862enough to lock, the window shows the lock screen instead, and a survey
863opened by tapping a prompt waits beneath it until the app is unlocked. Notification actions, Instant Reports and Shortcuts show
864nothing, so they work while locked. The setting is per device and isn't
865synced or exported.
866
867## Sync
868
869Deferred until a second device needs it (see
870[Not in scope yet](#not-in-scope-yet)). This is the plan for when it's built.
871
872Private CloudKit database via `CKSyncEngine`, with two custom zones:
873
874- `Config`: `Question` records, including which surveys ask each one. No
875 settings sync: the prompt settings and the rest of `UserDefaults` are
876 per device.
877- `Reports`: one `Report` record per report. Responses and context are
878 encoded into the record rather than stored as separate records. A report
879 is the unit of editing, so coarse records keep record counts and
880 operations low. At about 2 KB each, the imported archive is roughly
881 20,000 records and about 40 MB. `Token` records live here too, one per token
882 (about 1,200 in the archive). Keeping tokens separate means renaming 'Home'
883 changes one record instead of the thousands of reports that use it.
884
885Sensitive fields (responses, context, token text and places) go in
886`encryptedValues`.
887
888Conflicts are resolved last-writer-wins per record using `modifiedAt`. Editing
889the same report on two devices at once is rare enough not to need anything
890finer. Deletions sync too: deleting a report deletes its record, and Delete
891All Data clears both zones, or the next fetch would bring everything back.
892
893**The Watch only fetches the `Config` zone**
894(`CKSyncEngine.FetchChangesOptions` scope). It writes passive reports into
895`Reports` without downloading the archive. The iPhone fetches both zones. If
896watch-to-cloud turns out unreliable, `WatchConnectivity.transferUserInfo` to
897the phone is the fallback.
898
899Uploading the archive for the first time means pushing about 20,000 records.
900`CKSyncEngine` batches and handles `CKRetryAfter`, but the import UI should
901show sync progress, and the upload must survive the app being suspended.
902
903## Reporter Import
904
905Source: Reporter's JSON export, which has two top-level arrays, `questions` and
906`snapshots`. The user's export is 91 MB with 20,580 snapshots from 2014-02-08 to
9072026-10-13.
908
909### Quirks found in the real export
910
9111. **Junk prefix.** The file starts with `EF BF BF` (U+FFFF) before the opening
912 `{`. Skip everything before the first `{`.
9132. **Every timestamp is rendered in +0900**, including reports logged abroad.
914 The moments in time are correct but the local time zone was lost. The fix:
915 - Assign zones from the placemark country and administrative area. Japan
916 covers 20,166 reports. 384 are elsewhere: New South Wales (309, which maps
917 to `Australia/Sydney` because it observes daylight saving), Vietnam (28),
918 Hong Kong (16), Taiwan (7) and Shanghai (2).
919 - Match country names in both Japanese and English (`日本` and `Japan`,
920 `オーストラリア` and `Australia`, and so on).
921 - For the 52 reports with no placemark, inherit the zone from neighbouring
922 reports.
923 - Unknown countries go to the nearest-neighbour fallback and are logged
924 during import.
9253. **Weather comes in three eras:**
926 - Weather Underground (2014–2019: `stationID`, both °C and °F, kph and mph).
927 - Dark Sky (2019–2023: `cloudCover`, `precipIntensity`).
928 - After Dark Sky: records with placeholder zeros (temperatures of 0 °F
929 rendered as −17.8 °C) and no `weather` condition key, or no record at all.
930 These start on 2023-03-23, a week before Dark Sky's last record, so the
931 importer classifies records by their keys, not their dates.
932
933 Normalise the first two eras. Treat the third as no weather. Some Weather
934 Underground records have an empty
935 condition but valid readings, and use `-999` for missing values.
9364. **Numbers are mixed int and float** for the same field, and some numbers are
937 strings (`relativeHumidity: "50%"`, `numericResponse: "0"`). Decode leniently.
9385. **Photos are metadata only.** Asset URLs use the dead `assets-library://`
939 scheme. The EXIF metadata is kept. Re-linking the records to real photos via
940 PhotoKit is a possible later enhancement.
9416. **`reportImpetus`** values: 0 manual, 2 notification, 3 bedtime, 4 wake. The
942 meaning of 1 (6 reports) is unknown, and 80 reports have no value. For
943 these, infer the kind from which questions were answered. The random and
944 manual surveys ask the same questions, so a report that looks like either
945 is classed as `manual`: nothing shows that a prompt fired.
9467. **Responses reference questions by prompt only.** There's no question ID on
947 a response, so the importer matches `questionPrompt` against the question
948 list. Every response in the real export matches. A prompt that matches
949 nothing gets an archived question synthesised from the prompt, with a
950 stable ID (`reporter-prompt-` plus a hash of the prompt).
9518. **Invalid readings are negative.** As in Core Location, a negative speed,
952 course or accuracy means "invalid", and a negative vertical accuracy
953 invalidates the altitude. Photo coordinates are unsigned, with the
954 hemisphere in `latitudeRef` and `longitudeRef`.
9559. **`connection`** is undocumented. From its distribution (77% 1, 23% 0, 19
956 reports with 2), the importer reads it as 1 Wi-Fi, 0 cellular, 2 none.
95710. **Tokens have stable IDs.** Every token, person and place answer carries a
958 `uniqueIdentifier` that Reporter shares between all answers using it (571
959 activity texts with 571 IDs, 105 people with 105 IDs). The importer keeps
960 these as token IDs. Renames in Reporter reached back through history, so
961 the export already carries the current names. Places have 510 IDs for 493
962 names, because some names cover several venues (branches of a chain). One
963 ID appears under two questions, on a stray token attached to a yes/no
964 answer, which the importer ignores.
96511. **Foursquare venue lookup stopped on 2026-09-01.** Answers after that use
966 saved names only, and skipped location answers roughly doubled. Those
967 reports still have their location context, so places could be filled in
968 later.
969
970### Behaviour
971
972- Runs on the iPhone only, off the main actor, inserting in batches. It's
973 started from **Import Reports** in Settings' Data section, which picks
974 the export with `fileImporter` and shows the counts when it's done; the full
975 summary goes to the log, as counts and IDs only.
976- **Idempotent and repeatable.** Reports, questions and tokens keep their
977 Reporter IDs, so importing a newer export adds only what's new. The user can
978 keep using Reporter while Reportage is under development and re-import at
979 the switch. Reports already in the store are left alone. Questions and
980 tokens already in the store keep any edits made in Reportage, so a renamed
981 token stays renamed; questions only gain new choice options.
982- **Place answers record the report's location** as where they were given,
983 as new answers do. Reporter stored the place's own location with each
984 answer; that becomes the place token's coordinate.
985- **Venues stay Foursquare's.** Imported venues keep their Foursquare IDs,
986 names and coordinates, and aren't matched to MapKit places: some have
987 closed, and a wrong match would be worse than none.
988- **Addresses are updated to MapKit's form afterwards.** Reporter's
989 addresses came from the geocoder of their day, in whatever language the
990 device used, without the country code or city with its region that
991 MapKit gives. **Upgrade Address Format**, on the Historical Data screen in Settings' Data section, looks each
992 one up again as capture does, in the user's first language and the
993 place's own, and replaces it. Reports
994 within 25 m of each other share a lookup, since a fix is rarely better
995 than that: the archive's 20,552 located reports need about 1,700. It
996 waits out MapKit's throttling, keeps the screen on while it runs, and
997 skips reports whose address is already MapKit's (it records its
998 language), so stopping and starting again carries on. A spot MapKit has
999 no address for keeps the old one. A report without an address has
1000 nothing to upgrade, so it's left without one.
1001- **The export file is the original.** Reportage keeps what it models and
1002 drops the rest: imperial duplicates of metric readings, weather and
1003 altitude fields it doesn't show, Reporter's own flags and sub-record IDs,
1004 and timestamps as Reporter wrote them. The snapshot JSON itself isn't
1005 kept: it would double the store's size for data nothing reads. The user
1006 keeps the export file, and every snapshot can be matched to its report by
1007 ID.
1008- **Snapshots are decoded one at a time.** The importer slices each
1009 snapshot's bytes out of the export and decodes them separately, so one
1010 that can't be read is reported as a failure rather than failing the whole
1011 import.
1012- Produces an import summary: counts by kind, question and year, plus zone
1013 assignments and every report that needed a fallback.
1014- Verification: the importer test suite runs against the fixture. A debug-only
1015 check (`ReporterImportVerifier`) compares the real export to the imported
1016 store, report by report and response by response. An opt-in test runs it on
1017 the real export:
1018 `TEST_RUNNER_REPORTAGE_REAL_EXPORT="$PWD/reporter-export.json" bash Scripts/test-unit.sh`.
1019
1020## Export
1021
1022On-demand JSON from **Export Reports** in Settings' Data section, written to
1023a temporary file and saved with `fileExporter`. The top level is
1024`{"format": "reportage", "version": 1, "exportedAt": ..., "questions": [...],
1025"tokens": [...], "reports": [...]}`. Tokens are included because responses
1026refer to them by ID. Dates inside a report are ISO 8601 with the report's own
1027offset, plus an explicit `timeZone` field; other dates are UTC. Records are
1028written one per line, in batches, so the archive is never held in memory as a
1029whole. The schema is documented in `Notes/ExportFormat.md` and covered by
1030round-trip tests.
1031
1032**Import Reports** reads these exports as well as Reporter's, telling them
1033apart by the top-level `format` member, which only Reportage's exports have.
1034Records are matched by ID: one missing from the store is added, and one
1035already there is replaced only if the export's `modifiedAt` is later, so an
1036older export never undoes newer edits and re-importing changes nothing. The
1037export doesn't record deletions, so anything deleted since it was made comes
1038back. Reports are decoded one at a time, and one that can't be read is
1039skipped and counted. This restores a backup onto a fresh install.
1040
1041**Delete All Data**, also in the Data section, asks first, then deletes every
1042report, question and token and seeds the default questions again, leaving
1043the app as a fresh install has it. Prompt settings are kept.
1044
1045## Charts
1046
1047The Charts tab covers a period ending now: the past week, month or year, or
1048all time. These trail back from today rather than following the calendar,
1049so the start of a month isn't nearly empty. The period chosen is
1050remembered.
1051
1052Under a Questions heading, the tab shows one card per question answered in
1053the period: unarchived questions in survey order, then archived ones. A card gives the gist: the
1054top three answers for token and choice questions, the share answering yes,
1055the average of a number, or the count of notes. Tapping it opens the
1056question in full, with every answer, the lowest, average and highest number,
1057or the notes, newest first.
1058
1059Answers are counted per report, so a report that gave two answers to a
1060question counts once for each, and a token merged into another counts as
1061that token, once. Shares are of the reports that answered the question, not
1062of every report. Yes/no and choice answers keep the question's order, so an
1063answer keeps its place as the period changes; tokens are most used first.
1064
1065Bars are drawn by hand: a ranked list with a bar under each name reads
1066better than an axis. Charts over time use Swift Charts.
1067
1068**Trends.** A question's detail screen charts it over the period: the share
1069answering yes, the average number, or how often one answer came up. Token
1070and choice questions chart one answer at a time, the most given to begin
1071with, and choosing another in the list below switches to it, so the chart
1072needs only one colour. Notes have no trend. Spans follow the period: days
1073for the past week or month, weeks for the past year, and months for all
1074time. Touching a chart shows a span's value.
1075
1076**Context.** After the questions, a Context section has Calendar, Places,
1077Steps and Temperature. Calendar shows the latest month as small squares,
1078each day shaded by how many reports were filed on it (none, 1, 2–3, 4–5,
10796 or more, so a day of prompts with a wake and bedtime report reaches the
1080darkest), and how many of the period's days had one. It opens a month grid
1081for each month the period touches, newest first, with days outside the
1082period unshaded; a day with reports opens them as the timeline shows them.
1083Days are the device's, as in the timeline, so a day shows the same reports
1084in both. The calendar starts on the period's first whole day, since the
1085day it starts on is only partly in it. Places shows the period's places on a small map and opens a
1086full one: a circle for each place given as a location answer, from any
1087location question, sized by how many reports chose it (by area, so the
1088square root of the count), and tapping one names it. A merged place counts
1089as the one it went into. Each is shown at its own coordinate or else at
1090the centre of where its answers were given; places with neither are
1091counted and noted. Report locations aren't plotted: for all time they
1092would run to thousands of marks. Steps and Temperature each open a
1093trend. A day's steps are the highest count
1094among its reports, since each is the count so far that day, in the day of
1095the report's own time zone; spans longer than a day average their days. A
1096day without a report late in it undercounts, which the chart notes.
1097Temperature charts each span's range with its average marked, in the units
1098the locale uses for weather. Sleep isn't charted.
1099
1100## Phases
1101
11021. **Foundation.** Project scaffold, Core Data model, Reporter importer with
1103 tests, JSON export. This proves the model against real data before any UI
1104 depends on it.
11052. **Logging on iPhone.** Survey UI for every question type, wake, bedtime and
1106 manual reports, written narratives, passive reports, and live context
1107 capture (location, device, safe ambient noise).
11083. **Prompts.** Scheduler, notification actions, background refresh.
11094. **Quick logging.** `LogPassiveReportIntent` and the iOS surfaces it drives:
1110 the Control Center control, Lock Screen widget, Action button, Siri and
1111 Shortcuts. The Watch app is deferred.
11125. **Derived context.** Health. Live weather is part of capture (see
1113 [Weather](#weather)). Backfills are deferred (see
1114 [Open Questions](#open-questions)).
11156. **Visualisations.** The Charts tab, in steps: per-question summaries,
1116 then trends over time, a map of places, and a calendar of reports. Time
1117 of day is deferred.
1118 See [Charts](#charts).
11197. **Synced schema.** Settle the [open questions](#open-questions) that change
1120 synced data before the record formats are fixed. The Reporter import
1121 stays, with addresses updated to MapKit's form. Missed prompts aren't
1122 recorded: a prompt that's never answered leaves nothing behind, as in
1123 Reporter. Choice answers are already stored as lists, so multi-select
1124 can come later without changing the format.
11258. **Sync.** `CKSyncEngine`, both zones, first upload. Deferred until a
1126 second device needs it, most likely the Watch app. Sync comes last
1127 because CloudKit's Production schema can only be added to, so it should
1128 be deployed once, after everything else has settled the shape of the
1129 data. Until then, local changes keep sync in mind: stable UUIDs,
1130 `modifiedAt` updated on every edit, and no data that only one device can
1131 interpret.
1132
1133## Open Questions
1134
1135- **Backfills.** Weather from August 2021 onwards and Health from 2014 onwards.
1136 Both are optional and can be done at any time. Location answers skipped
1137 since Reporter lost venue lookup (2026-09-01) could be filled in from each
1138 report's location context. Deferred: the app comes first, and Reporter data
1139 is worked on later.
1140- **Multi-select choice questions.** Reporter stores choice answers as arrays,
1141 but every answer in the archive has a single value. The survey takes one
1142 answer for now. Deferred: choice answers are already stored as lists, so
1143 this needs no format change.