# Base on the Mac and iPhone

Status: draft for Paul's review, 2026-11-23. Read against Base main `d8700cf`,
rastrillo/native `0254817`, Home `8125a3c`, Docs `d5a328a`, Equipo `a697cde9`.

Decided by Paul so far:

- The native "launcher" we once discussed for Oficina is **Base**, not a
  native Oficina Home (2026-11-23).
- **Base probably replaces Oficina Home in the end; Home stays for now**,
  as a slightly different concern (2026-11-24).
- Base's branches land on main first (done: `d8700cf`).
- **Native Base follows Base's look**, not Oficina's Calma (2026-11-23).
- **Mac main window: B**, Ask in the middle with the apps in a floating
  sidebar, "for now" (2026-11-23, from the slice 1 mockups).
- **iPhone first screen: A**, Ask first, with the apps one tap away
  (2026-11-23).
- **Ask is set up during sign-in, in slice 1** (2026-11-23): nobody approves
  a code in Equipo before Ask works (3.8).
- **Slice 2 approved with every recommendation** (2026-11-28): section 7,
  and its rulings in 7.9.
- **Jobs started in Equipo stay in Equipo, and jobs started in Base stay in
  Base** (2026-11-28): notifications, decision cards and Live Activities.
- **Base takes over the Live Activity for jobs started from Ask** in slice 3
  (2026-11-28).

Mockups: `.superpowers/mockups/native/` (git-ignored: it holds the licensed
font; `python3 build.py` draws it), shown to Paul on 2026-11-23.

## 1. What native Base is for

Base's direction is "all about doing work and giving the user something to see
very quickly" (Paul, 2026-11-20, jobs design). The native app serves that,
not app launching. On a Mac the Dock and Spotlight already launch apps, and on
an iPhone the Home Screen does. A grid of icons in a window would only copy them.

What only a native Base can do:

1. **Ask Base from anywhere.** One keystroke on the Mac, or Siri and Shortcuts
   on the iPhone, opens Ask without finding a browser tab first.
2. **Tell you when a job needs you.** It sends a notification when a job is
   ready, done, stuck or waiting on your decision. The answer's buttons sit on
   the notification where the platform allows it.
3. **Sign in once.** It uses the same Oficina ID as Docs, Sheets, Calls and
   Equipo, and goes straight in if one of them already holds it.
4. **Open your apps.** It opens the native app when one is installed, and the
   web app otherwise.

*My call:* the order of importance is 1, 2, 3, 4, and the first slice is
built to match (section 6).

## 2. What exists today (audit)

### 2.1 Base's server

- **Every screen is a server-rendered page behind a browser cookie**
  (`internal/web/app.go:160-208`). There is no JSON API for a person. The one
  bearer API, `/api/v1/operations`, is for Equipo's Assistant
  (`internal/operations`).
- **Sign-in is either Base's own** (email link or passkey) **or Oficina ID**,
  through Home's browser handoff (`internal/web/oficina.go`). There is no
  native exchange.
- **Ask runs through Base.** Base enrols with Equipo as a device for each
  person (`internal/equipo/equipo.go:168-208`). It keeps that person's Equipo
  key sealed with `BASE_INSTANCE_KEY`, and relays the snapshot, events,
  messages, cancel and card answers (`internal/web/ask*.go`).
  - **Connecting Equipo is a one-time code** the person approves in Equipo
    (`ask_connect.go:41-135`).
  - **Connecting Oficina apps to the Assistant** goes through
    oficina-connect (`ask_oficina.go`).
- **Home's apps come from two places.** The team's Oficina apps come from
  `BASE_OFICINA_APPS` (`internal/config/oficina.go`) and open in a new tab.
  The rest are apps installed from the Store. Base's own pages (Store,
  People, Settings) form the dock (`internal/web/home.go:21-50`).
- **Appearance** is System, Light or Dark, stored for each member
  (`internal/web/settings.go:44-47`).
- **The jobs design** (`2026-11-20-jobs-that-keep-moving-design.md`, direction
  approved) is not built yet. Until it is, job cards can't carry their own
  decision, on the web or in a native app.

### 2.2 The shared native kit (RastrilloApple)

- **Oficina ID sign-in:** an email code or a passkey, with straight-in when
  another app holds the ID and a chooser when there are two or more IDs
  (`OficinaID/OficinaIDModel.swift`).
- **Keychain and App Group:** identities go in the shared group
  `9U4A84C4WK.works.oficina.id`. Sessions go in each app's own group. The App
  Group is `group.works.oficina` on iOS and `9U4A84C4WK.works.oficina` on the
  Mac.
- **Also in the kit:** several accounts, a team step, an offline banner, and
  quiet Sparkle updates.
- **Not in the kit:** an account or team menu (Equipo built its own), the
  Colophon (each app has its own) and a string catalog.
- **`OficinaApp` has no `base` case** (`OficinaAppearance.swift:7-8`).

### 2.3 Equipo's native app

- **Chat:** `EquipoKit` has public chat pieces: `ConversationScreen`,
  `ChatMarkdownView`, `ThinkingLine` and an SSE reader. They are bound to the
  Coordinator's routes and `EquipoSession`, and nothing calls the Assistant
  routes. Base can adapt them, not drop them in.
- **Push:** registrations, an outbox and payloads are built. Sending is a stub
  until the CARLOS `/v1/push` verb and rastrillo's push client exist. Paul
  has still to rule who holds the Apple push key (Equipo native slice 2 plan).
- **Live Activities** exist in Equipo's iOS widget extension.

### 2.4 Opening other apps

- **Bundle IDs:** every Oficina native app is `works.oficina.<app>` on every
  build (D1, ruled 11-14). D2 puts "Oficina <Name>" in Finder and the plain
  name inside the app.
- **Docs, Sheets, Calendar and Memoria** only handle `…://signin`. Opening
  their scheme with anything else just launches them.
- **Calls** handles `oficina-calls://join`, and **Equipo** handles
  `works.oficina.equipo://task/<id>`.
- **Missing:** universal links, and opening a given document by link. "Open
  on the web, already signed in" is spec'd as Home slice D but not built.

## 3. How it works

### 3.1 Signing in

- **Oficina ID only, with the kit's flow** (email code, passkey, straight-in).
- **Base becomes a Home consumer.** Its origin is added to `HOME_CONSUMERS`,
  and it mounts `connect.Bridge.NativeExchange` at `POST /native/oficina-id`,
  as Docs did in `9de84e4`. The exchange mints a native session (method
  `home-assertion-native`, seven days). The answer is `ok`, `failed`,
  `unknown`, `choose` or `unavailable`, with the kit's handling of each.
- **Also mounted:** `POST /signout`, `POST /native/web/end` and the choose
  page at `/account/home/choose`.
- **A Base without Oficina ID** (self-hosted, Base's own sign-in only) gets a
  "Use the browser instead" path in a later slice, not in slice 1 (*my
  call*). Every Base Paul runs has Oficina ID.

### 3.2 A small JSON API for people

Under `/api/v1`, with the native session. The routes are the web pages'
reads and writes, not new behaviour:

- `GET me`: the member, the Base's name and the appearance.
- `GET home`: the steps and the apps in Home's order. Each app carries:
  - `kind`: `oficina`, `installed` or `own`;
  - its name and web address;
  - its tint and icon;
  - for Oficina apps, the native bundle ID.
- `ask/*`: the same relay as today's `/ask/*` (state, events, messages, turn
  cancel, card answer, connect, check and disconnect), returning JSON and
  SSE.

*My call:* the native app talks **only to Base**, never to Equipo directly.
Base already holds each person's Equipo key, registers itself as the
Assistant's host and translates cards. A second, native path to Equipo would
fork all of that.

### 3.3 Ask

- **Mac:** one window (B, chosen). Ask fills it. A floating glass sidebar
  holds Ask Base (with a badge counting jobs waiting on the person), Getting
  started while any step is open, every app (Oficina apps, then installed
  ones), then Store and People, and the person and team at its foot.
  Settings is the app's Settings window (⌘,). The web's layout, Home and Ask
  side by side (A), was the alternative.
  - A **menu-bar item and a global shortcut** open a small Ask panel from
    anywhere. Its text field has focus, and the reply streams in.
  - The native-levelup audit says to ask before adding a menu-bar item: this
    is that ask (Q3).
- **iPhone:** Ask is the first screen (A, chosen). Home's apps sit behind one
  button, top left, in a sheet. Home first, as the web's phone layout, was
  the alternative.
- **Cards:** they draw what Base's web draws today: question, confirm,
  outcome, connect and job cards, with jobs as pills. When the jobs design
  lands, the job pill carries its decision on both web and native at once,
  because both read the same JSON.
- **Code:** adapted from `EquipoKit`'s chat views and SSE reader, pointed at
  Base's `ask/*`.

### 3.4 Opening apps

- **Mac:** if the Oficina app's bundle ID is installed, open it with
  `NSWorkspace`. Otherwise open its web address in the default browser.
- **iPhone:** an app can't be opened by bundle ID, so the kit's
  `handleOpenURL` gains `…://open`, a small kit change that every app picks up
  at its next repin. Until then, the web address.
- **Store apps** always open on the web.
- **When Home slice D lands**, "open on the web" arrives already signed in.
  Until then the browser may ask once.

### 3.5 Notifications (slice 2)

- **Equipo sends them**, to the Base app's device registrations, through
  Equipo's existing outbox. *My call:* Equipo knows every job's state the
  moment it changes, and Base only sees it while relaying a chat.
- **Blocked on** the CARLOS push verb and the ruling on who holds the Apple
  push key, the same blockers as Equipo's own push.
- **Decided in section 7** (2026-11-28): Equipo sends, to registrations
  Base relays, and each app hears only the jobs started in it (7.2).

### 3.6 The look

Base's approved look (first-slice spec section 6), translated:

- **Sky and fog:** the deep indigo sky with teal, violet, rose and mist fog,
  and the swaying amber beam. Drawn with SwiftUI `MeshGradient` and `Canvas`.
  Fog loops of 10 to 17 seconds, still when Reduce Motion is on.
- **Glass:** system materials with Base's dark tint (`--glass-base`
  `rgba(14,17,42,.40)`) and a thin bright top edge. Text keeps WCAG AA on
  every frame.
- **Accent and buttons:** teal `#6EE7DC` only for finished steps and progress.
  Primary buttons are frost white with dark text.
- **Type:** Timeless Sans, the Grotesk cut for headings, bundled through a
  fetch step with a pinned checksum. Never committed. No FOUT: the font is in
  the bundle, so nothing paints in a fallback face.
- **Appearance:** System, Light and Dark, from the member's setting.
- **Platform rules:** standard platform controls (menus, sheets, toolbars,
  Settings), with Base's colours and type. The Mac window is a real window;
  nothing in it pretends to be an operating system.

### 3.7 Where it lives

- **Code:** `native/` in this repo, laid out like Equipo's: `apple/`
  (BaseKit), `ios/` and `macos/`, on RastrilloApple.
- **Kit changes:** a `base` case on `OficinaApp`, and the `open` URL.
- **Distribution:** Mac through Sparkle and the Mac release assets, iPhone
  through TestFlight.

### 3.8 Ask set up during sign-in

Today a person connects Equipo once from Base's web: Base enrols a device key
with Equipo (`internal/equipo/equipo.go:168-208`), the person approves its
code in Equipo, and Base keeps the resulting Equipo key sealed. In the native
app that step disappears: signing in to Base with Oficina ID also connects
Ask, the first time, with nothing to approve.

Both ends already know the person through Oficina ID, so the approval can be
an Oficina ID proof in place of the code. Two shapes, to settle in the plan
with Equipo's owner:

- **Base asks for it.** Base's server gets a short-lived Oficina ID assertion
  for the person addressed to Equipo (a Home consumer change: Base may ask
  for another app's audience only for the person it holds a session for) and
  presents it with its device proof. Equipo checks the assertion and the
  person's membership, and issues the person's key to Base. The native app
  does nothing extra.
- **The app carries it.** At sign-in the native app fetches a second
  assertion from Home with Equipo's audience, as it fetched Base's, and
  hands it to Base with the exchange. Base presents it to Equipo as above.
  No change to Home's rules about audiences, one more round trip for the app.

*My call:* the second, because it keeps Home's rule that an assertion is
fetched by the person's own device for one app. Either way the web keeps its
code as a fallback, and a person whose Equipo membership is missing sees
Ask's existing "isn't set up for you yet" state.

## 4. Questions for Paul

1. **Base and Oficina Home.** Decided (Paul, 2026-11-24): Base probably
   replaces Home as Oficina's front door in the end, but Home stays for now,
   because it is a slightly different concern (Oficina ID, the team
   directory and the suite's own front page). Nothing in this slice moves
   Home's work into Base.
2. **Bundle ID and name.** Base isn't only Oficina's: it fronts Keymail,
   Sporran and the rest. Recommended: `works.oficina.base`, named "Base". It
   lives at base.oficina.works and shares Oficina ID's keychain group. The
   alternative is a CARLOS ID such as `com.carloku.base`.
3. **Mac menu-bar item and global shortcut** for Ask. Recommended: yes, with
   the shortcut off until the person sets one.
4. **Store, People and Settings in slice 1?** Recommended: Settings natively
   (account, appearance, sign out, Equipo connection). Store and People open
   Base on the web in slice 1 and go native in slice 2.
5. **Notifications:** sent by Equipo (recommended) or by Base. Decided
   (Paul, 2026-11-28): Equipo (7.2, 7.9).

## 5. Not doing

- A grid-of-icons launcher as the main screen.
- Base's own sign-in in the native app (slice 1).
- Installing Oficina, Keymail or Sporran from the Store. That is the web
  Store's later slice; native follows it.
- Widgets and Live Activities before notifications.

## 6. Slices

1. **Sign in, Ask, Home.**
   - Server: native exchange, JSON API.
   - Native: Mac window with menu-bar Ask, iPhone with Ask first, Home's apps
     opening as in 3.4, Settings.
   - Mockups first, for Paul to approve. Then the plan.
2. **Notifications, Store and People native, and the jobs design's
   decisions on cards** (if not already built for the web). Specified in
   section 7, in four parts (7.11); part 1 is planned in
   `docs/superpowers/plans/2026-11-28-native-slice2-part1.md`.
3. **Siri and Shortcuts** ("Ask Base"), a share extension ("Send to Base"),
   and Live Activities for running jobs.

## 7. Slice 2: notifications, decisions on cards, Store and People, files

Approved by Paul on 2026-11-28, with every recommendation as written (7.9).
Read against Base main `07ec2ec`, Equipo origin/main `8bd40ed1`, CARLOS
origin/main `e210550b1` and its push branch `379d97d17`
(`design/platform-push-submission`), rastrillo `0033fa0e` (v0.47.0),
rastrillo/native `bb989a7`, Docs `78fb1db`, Sheets `76b7abc`, Slides
`a27d28d`, Home `88f610a`.

Mockups: `.superpowers/mockups/native-s2/` (git-ignored: it holds the
licensed font; `python3 build.py` draws them), shown to Paul on 2026-11-28.

Rulings this section works under:

- **Keep working through the plan in order** (Paul, 2026-11-28).
- **"Equipo jobs started in Equipo should stay in Equipo and jobs started in
  Base should stay in Base"** (Paul, 2026-11-28). That covers notifications,
  decision cards and, later, Live Activities. Base shows and notifies only
  the jobs started from Ask, and Equipo only its own.
- **In slice 3, Base takes over the Live Activity for jobs started from Ask**,
  so there's never a duplicate with Equipo's (Paul, 2026-11-28).
- **Files in Ask** (2026-11-26): Equipo holds the bytes (R1), the Assistant
  reads a file for 14 days (R3), and native copies Equipo's attachment code
  into BaseKit (R5).

### 7.1 What exists today

#### Push

- **CARLOS `/v1/push` is a spec, not code on main.**
  - The spec was approved on 2026-11-20:
    `docs/superpowers/specs/2026-11-20-platform-push-submission-design.md`
    at `379d97d17`.
  - The build is uncommitted work in `carlos/platform-wt-push-build`
    (`internal/pusher/`, `internal/pushsubmit/`). Main and v0.44.0 have no
    pusher.
  - A box-local `carlos-pusher` holds the Apple key, plus a grant file that
    names which `(account, app)` may push to which topic (decisions 4 and 9,
    and §5 `apns.conf`):
    ```
    key NS36T57NS4 9U4A84C4WK production works.oficina.equipo
    grant <sqid>/equipo works.oficina.equipo
    ```
- **rastrillo's push client** (`push.FromCarlos`, `push.Submit`) is
  uncommitted on `feat/push-submit` in `rastrillo/rastrillo-push-submit`, and
  has no tag.
- **Equipo can't send to its own app yet.**
  - Registrations, the outbox and the payloads are all built.
  - The transport is a stub: `push.FromCarlos` refuses boot when
    `CARLOS_PUSH=submit` (`internal/equipo/push/transport.go:50-64`, "SEAM
    (2026-11-20)").
  - The topic is a constant, `push.Topic = "works.oficina.equipo"`
    (`push/push.go:19`).
- **Equipo's registrations have no app or topic.**
  - The table is `push_registrations(credential PRIMARY KEY, person, token,
    environment, platform, start_token, …)`
    (`migrations/0096_push.sql:8`), with `actions_version` and
    `binding_id` added in 0111.
  - The routes are `POST /api/v1/push-registrations` and
    `…/activities` (`chat/http.go:95-96`).
  - Recipients are `push.Devices(person)` (`push/store.go:286`).
- **The Apple key is topic-specific and production-only.** From the CARLOS
  spec's "Facts (2026-11-20)":
  > "key ID `NS36T57NS4`, Team ID `9U4A84C4WK`. It is **production only**
  > and **topic-specific**: its only topic is `works.oficina.equipo` … The
  > `.p8` has not been downloaded yet; Apple allows one download."

  So Equipo's key can't push to `works.oficina.base`, and Base needs a key of
  its own.
- **Base's app has no push.** Both entitlements files say "No push until
  slice 2" (`native/ios/BasePhone.entitlements`,
  `native/macos/DeveloperID.entitlements`). Equipo's Mac app shows that a
  Developer ID app can get push: it carries
  `com.apple.developer.aps-environment = production`
  (`equipo native/macos/DeveloperID.entitlements:10-11`).

#### Where a job started (for the ruling)

- **Every turn, card and task has a lane** (`wire/assistant.go:8-24`).
  - `""` is the Coordinator (Equipo's own conversation).
  - `assistant` is Base's Ask.
  - `job:h_<id>` is "the Coordinator thread of one job Base handed off".
- **A task's lane comes from the turn that made it.** `chat_tasks.lane` is
  set in `chat/tasks.go:866` (migration 0084), and cards inherit it
  (`tasks.go:898`).
- **Hand-offs list their tasks** in `chat_handoff_tasks(handoff_id, task_id)`
  (0079), and their lane in `chat_handoffs.lane` (0083).
  - Hand-offs from before job threads existed have an empty lane.
  - Their tasks still appear in `chat_handoff_tasks`, so that table is the
    reliable test.
- **Equipo's push rules only half follow the ruling today**
  (`push/rules.go:123-200`).
  - **Followed:** `card_opens` and `reply_unseen` fire only for the
    Coordinator lane (`:126`, `:138`).
  - **Not followed:** `task_ends`, `task_fails`, `badge` and the four
    `activity_*` rules check no lane. A task Base handed off therefore ends,
    fails and runs a Live Activity on Equipo's app today.
  - **Why:** `pushTask` (`chat/push.go:426`) builds the change from
    `wire.Task`, which has no lane field.
- **No message records which client sent it.** `PersonPrincipal` carries
  the credential for each request, but it isn't stored
  (`personapi/types.go:16-21`). The lane is the origin, and it is enough.

#### Decisions on cards

- **"The jobs design's decisions on cards"** means phase 1 of
  `2026-11-20-jobs-that-keep-moving-design.md`, plus Paul's addendum on
  context and a recommendation:
  - **K1:** the job card carries `ask`, `options`, `actions` and
    `receipts`.
  - **K2:** one act endpoint, bound to the decision and its revision.
  - **K6:** stops, with their reasons and next steps.
  - **K11:** "What next?" on a first look.
  - **Addendum:** each decision gets context, a link, a recommended option
    and a line for each option.
  - Folding (K9) is phase 4.
- **None of it is built.**
  - **Equipo:** there is no `JobAsk` and no job act route on origin/main.
    `decision-cards-context` (`cf0614ec`, 11-20) is unmerged.
  - **Base:** `equipo.Card` has no `Ask`, `Actions` or `Receipts`
    (`internal/equipo/chat.go:60-76`), and there is no `/ask/jobs/{id}/act`
    (`internal/web/ask.go:47-68`).
- **What Base can act on today:**
  - question, confirm and outcome cards (`POST /ask/cards/{id}/answer`);
  - a paused job's Carry on now (`POST /ask/cards/{id}/carry_on`).
  - A job pill shows only its state, its status and one more sentence.
- **Waiting cards** (Equipo `50029aba`) aren't something Base draws. They
  are a note in the Assistant's frame, listing Equipo's own open cards
  (`chat/waiting_cards.go`).

#### Store and People on the web

- **Store** (`internal/web/store.go:32-116`, `templates/store.html`):
  - It lists the catalogue: Welcome, Scratchpad and Contra
    (`internal/catalog/catalog.json`).
  - Each app shows its state: installing, installed or failed (with the
    reason).
  - The owner can Install, Try again, or Uninstall (with a confirm page).
    Everyone else sees "Installed".
  - The page refreshes every 2 s while anything is installing.
- **People** (`internal/web/people.go:30-96`, `templates/people.html`):
  - It lists the members, each with their initial, name or address, and
    Owner, Member or Invited ("Invited. Hasn't signed in yet.").
  - The owner can invite by address. The invitation is sent again until one
    is delivered.
  - There is no Remove: `store.RemoveMember` exists but no route calls it.
- **Neither has JSON.** The native app opens both on the web:
  `apiHomeRead` points Base's own pages at `origin + href`
  (`internal/web/api.go:115-118`).

#### Files in Ask

- **The server side is done.** Slice 1 landed on Base `07ec2ec` and in
  Equipo (`can_attach`, `wire/assistant.go:157`; `read_attachment`).
- **Native has every route it needs**, documented in
  `docs/api/base-native-v1.md:262-311`: upload, delete, discard, read and
  preview.
- **The app shows files only as a line of names** today
  (`BaseKit/Ask/Thread.swift:135-159`).
- **Equipo's native code to copy (R5):**

  | File | What it does |
  |---|---|
  | `EquipoKit/API/Attachments.swift` | the client |
  | `Attachments/PhoneAttachmentPicker.swift` | `PhotosPicker`, `fileImporter`, paste |
  | `AttachmentDraft.swift` | draft state and refusal codes |
  | `AttachmentViews.swift` | the chips (`AttachmentDraftStrip`), the bubble's thumbnails (`MessageAttachments`), the full-size preview |
  | `native/share/Sources/EquipoShareCore/AttachmentFile.swift:58-93` | HEIC, HEIF and TIFF to JPEG, a 2560 px long edge |
  | `EquipoMac/MacComposer.swift:13-31`, `AttachmentPromises.swift` | paste, drag, and file promises on the Mac |

  Equipo has no Quick Look.

#### Opening Docs, Sheets and Slides

- **Base can launch the Docs or Sheets app, not open a document in it.**
  - On the Mac, `Opener.mac` opens the app by its bundle ID
    (`BaseKit/Home/Opener.swift:22`).
  - On the iPhone, everything except Calls and Equipo opens on the web
    (`Opener.swift:34`).
- **The kit can open a path; the apps don't use it yet.**
  - The kit handles `<scheme>://open?path=…` (`rastrillo/native`
    `NativeConnection.swift:82-123`, since `8dc540a`).
  - Docs and Sheets pin kits from before that change (`0254817` and
    `1e36aac`), and neither sets `onOpen`.
- **No universal links:**
  - The only association file is Home's, and it is webcredentials only
    (`home internal/home/native_passkey.go:285-312`).
  - The app hosts' `/.well-known/apple-app-site-association` answer 404.
  - No app claims `applinks:`.
- **Slides has no native app**, and doesn't mount `/native/oficina-id`.
- **Nothing can be framed, and there's no read-only view.**
  - Every app sends `frame-ancestors 'none'` and `X-Frame-Options: DENY`
    (`rastrillo serve.go:464,480`).
  - None has a signed-in read-only or embed view.
  - The only read-only pages are the owner's public links: Docs `/p/{token}`,
    Sheets `/l/{token}`, Slides `/s/{token}`.
- **Exports exist:**
  - Docs: `/d/{sqid}/export.pdf` and `.md`.
  - Sheets: `/sheets/{id}/export.xlsx`.
  - Slides: a PDF job (`POST /d/{sqid}/export`).
- **Path-based team URLs don't work natively.** `NativeHTTP.origin` rejects
  an origin with a path (`NativeHTTP.swift:94-100`), and Docs is the pilot
  for path-based teams (ruling 11-26).

### 7.2 Notifications

#### Who sends

**Decided (7.9, 1): Equipo, through its outbox, to the Base app's
registrations**, as 3.5 said. Equipo learns of every change in the
transaction that makes it. It already has everything else: the outbox,
once-only dedupe, collapse, holds, sealed payloads, retries, action
bindings and receipts. Base would have to build all of that again.

- **The app still talks only to Base** (3.2).
  - It registers its token with Base: `POST /api/v1/push` with `{token,
    environment, platform, install, start_token: null}`.
  - Base relays the registration to Equipo with the person's bearer, adding
    `app: "base"`.
  - Answers from a notification go to Base's own routes, as everything else
    does.
- **The alternative** was Base sending. Equipo would call Base, as the
  Assistant's host, on every job change, and Base would keep its own
  devices, outbox and CARLOS grant. Rejected: it is a second outbox and a
  new callback channel, for words Equipo already writes. A job card's words
  are already Base-facing (Base shows them as given).

#### What Equipo changes

- **E-P1. Registrations know their app and device.**
  - `push_registrations` gains `app` (`equipo` | `base`) and `install` (the
    app install's id).
  - The key becomes `(credential, install)`. Base holds one Equipo
    credential per person, but that person may have Base on a Mac and on an
    iPhone.
  - The topic follows from `app`. `push.Topic` becomes a lookup.
- **E-P2. One rule for where work started.** A change is Base's when:
  - its lane is `assistant` or starts `job:`; or
  - its task is in `chat_handoff_tasks`, which catches hand-offs from
    before job threads.

  The rule is computed once into `push.Change` as `Origin`, because
  `wire.Task` has no lane. Every rule then reads it:
  - Equipo-origin changes go only to `app = equipo` devices.
  - Base-origin changes go only to `app = base` devices.
  - The rules that don't look at the lane today (`task_ends`, `task_fails`,
    `badge`) gain the check. That stops Equipo's app hearing about Ask jobs,
    which fixes a breach of the ruling that exists today.
- **E-P3. Base's rules, from the Assistant-lane job card**, not the task.
  - A job is a hand-off that may run several tasks. Base knows it by its
    job card id.
  - Each rule's collapse id is the job card's id, so a newer state replaces
    the older notification on every device.
  - Its thread id is `job:<card>`.
  - Its dedupe is the card's id, state and decision.
  - The table follows.
- **E-P4. Base's payload.**
  - `aps.alert{title: job title, body: the decision's text or the state
    line}`, plus `category`, `thread-id` and `interruption-level`.
  - A custom key:
    ```
    base: {origin, member, job, revision, decision, actions: {binding, notification_id}}
    ```
  - The app needs `origin` and `member` to pick the right account, since
    the kit holds several. The words never name Equipo (Review 8).
- **E-P5. Withdraw on settle.**
  - When a decision is settled anywhere (a tap, the web, another device),
    Equipo sends a background push for that job.
  - The app then removes the notifications delivered in its thread
    (`removeDeliveredNotifications`).
  - Each app also tidies itself whenever it opens.
- **E-P6. The grant.** On each box running an Equipo that serves a Base:
  ```
  key <BASE-KEY-ID> 9U4A84C4WK production works.oficina.base
  grant <equipo-sqid>/equipo works.oficina.base
  ```
  The Live Activity topic `works.oficina.base.push-type.liveactivity` is
  allowed with it (CARLOS spec §5).

#### Which job events notify

Decided (7.9, 2):

| Job state (Base's pill) | Notification | Actions (with K1/K2; until then, a tap opens the job) |
|---|---|---|
| Asking: a question | alert | its choices (recommended first, at most 3), and Something else… when words are allowed |
| Asking: "First look ready" | alert | Build it; Try again… (asks "What should change?") |
| Asking: needs your OK (approvals) or replace | alert | none: a tap opens the job (approvals stay on Equipo's pages, K6; Replace drops work) |
| Ready to try | alert | Try it (opens the link) |
| Stopped, with Try again offered | alert | Try again |
| Stopped, otherwise | alert | none |
| Paused | quiet (`passive`) | none: Carry on now spends money, so it stays in the app |
| Done | quiet (`passive`) | none |
| Working, any stage | never | (Live Activities, slice 3) |
| The Assistant replied with no Ask open | alert, Ask's own (7.9, 4) | none |

- **Never on a notification:** Drop it, Dismiss, Replace it, or anything
  that publishes, spends or grants without a confirm in the app.
- **The badge** on the app's icon counts the jobs waiting on you, the same
  number as the sidebar's.
- **In the foreground**, a job on screen shows no banner. Anything else
  shows one.

#### The buttons

- **Actions answer without opening the app.** They use
  `.authenticationRequired` and not `.foreground`, so the device must be
  unlocked.
  - Each is bound to the decision and revision the notification showed, with
    its notification id as the idempotency key.
  - A `409` (the decision has moved on) answers nothing. The app posts a
    local "That's changed since. Open it to see." with Open.
  - Equipo's buttons, by contrast, all bring the app forward
    (`NotificationResponse.swift:81-93`).
- **Labels are the decision's own** ("Fri 18 Dec"), so categories can't be
  fixed ahead.
  - A notification service extension (iOS, and macOS 11 or later) registers
    one category per decision before the notification shows.
  - If that ever loses the race, the fallback is Equipo's: one "Choose…"
    that opens the app at the decision. (7.9, 3)
- **On the Mac,** a banner's actions sit under Options. Alert style shows
  them as buttons. Both work the same.

#### Not notifying twice

- **By construction** (E-P2). A job started in Ask notifies only Base's
  devices, and a job started in Equipo only Equipo's. A person with both
  apps hears each job once.
- **Across devices:** collapse by job, and withdraw on settle (E-P5).
- **No fallback** (7.9, 5). With no Base app installed, an Ask
  job does not notify through Equipo's app. Web push for Base is for later.

#### What slice 2 does so that slice 3 can take over Live Activities

1. **The origin rule (E-P2) decides the Live Activity rules too.**
   - Slice 2 makes `activity_*` read `Origin`.
   - Until slice 3 ships, Base-origin tasks keep Equipo's Live Activity, as
     today (7.9, 6).
   - Then one Equipo release switches them to Base's start tokens. It
     switches only for people whose Base registration carries a
     `start_token`, so there is never both and never a gap.
2. **Registrations carry `start_token` from day one** (null until slice 3).
   `app` decides the topic (`works.oficina.base.push-type.liveactivity`).
3. **One activity per job, not per task.** Slice 2's collapse ids already
   map a task to its hand-off and then to its job card
   (`chat_handoff_tasks`). The activity reuses that mapping.
4. **The payload names `origin` and `member`**, so the widget extension can
   pick the account.
5. **The same Base push key serves Live Activities.** The extension needs
   its own App ID (`works.oficina.base.activity`) in slice 3.

### 7.3 Decisions on the cards

- **Native draws what the web draws, from the same JSON** (3.3). It does
  that once the jobs design's phase 1 is in Equipo and Base's web (7.9, 10), and
  is never built native-first.
- **`Models.swift` gains** the K1 fields: `ask{kind, decision, text, words,
  note}`, `options`, `actions`, `receipts`, `updated_at` and `hidden`. It
  also gains the addendum's `context`, `link`, `recommended` and each
  option's `detail`.
- **The pill** carries the decision under it, as the mockups show:
  - the context, the link to the thing, the question;
  - the choices, with Recommended and why;
  - Something else as a one-line field.
- **Actions:**
  - Try again opens its field.
  - Drop it confirms ("Drop this job too?").
  - Stops show their reason and Try again.
- **The act:** `POST /ask/jobs/{id}/act` as JSON, with the idempotency key
  and revision. A `409` redraws the card from the answer.
- **The job view** adds the first look's picture as a link, the receipts,
  Dismiss with Undo for 8 s, and "Open in Equipo" as the title's link.
- **Placement:** jobs that need you move to the end of the thread.
  "Waiting on you" and "N finished" fold, by `state` and `updated_at`
  (K9, phase 4, when the web has it).

### 7.4 Store and People, native

A small JSON API beside the pages, built from the same builders, behind the
same owner checks:

- **`GET /api/v1/store`:** `{owner, rows: [{id, name, summary, tint,
  icon_svg, state, error}]}`. `state` is `""`, `installing`, `installed` or
  `failed`.
- **`POST /api/v1/store/{app}/install`:** `202 {store}`, then poll every
  2 s while any row is installing, as the web does.
  - An app already installing answers `202`, and one already installed
    `200`, both with the store and without starting anything.
  - If starting the install fails, the store is read again. A row that now
    shows installing (another request started it) answers `202` as it
    stands. Otherwise the answer is `503 unavailable`, and nothing was
    claimed: starting fails only before its claim, so a row that still
    reads failed shows an earlier failure.
- **`POST /api/v1/store/{app}/uninstall`:** `200 {store}`, `409 busy`
  while installing, `403 owner_only` if not the owner.
- **`GET /api/v1/people`:** `{owner, people: [{id, initial, name, email,
  role}]}`. `role` is `owner`, `member` or `invited` (not yet signed in),
  so no separate `joined` is sent.
- **`POST /api/v1/people`:** `{email}`. It answers `200 {person}` with the
  person invited (or already here), `422 bad_email`, `502 mail_failed`
  (invite again to retry), or `403 owner_only`.
- **Every route** answers `503 unavailable` when Base can't read its own
  store, as the pages do, and `401 unauthenticated` without a member's
  session. Nothing removes a member: `DELETE /api/v1/people/{id}` stays
  unrouted.
- **Where they show:**
  - **Mac:** in the window's pane, from the sidebar.
  - **iPhone:** pushed from the apps sheet's new "Your team" section.
  - Uninstall confirms with the web's words.
- **`GET /api/v1/home`'s** `own` apps keep their web URLs for older builds.
  New builds route Store and People natively by `id`.
- **Not doing:** removing a member. The web has no such action either.

### 7.5 The sidebar

- **Apps folds** (Paul).
  - On both, the "Apps" heading is a button with a chevron: in the Mac's
    glass sidebar (which isn't a `List`, so not `Section(isExpanded:)`) and
    in the iPhone's apps sheet.
  - Folded, it shows the count.
  - The state is remembered for each person on each device, in
    `UserDefaults`. It is keyed by a hash of the signed-in account the
    session already holds, so it is right before `/api/v1/me` loads and
    offline. It isn't synced, and the web's rail setting (migration 0007)
    is its own.
  - It starts open.
- **Made with Base.** Decided yes (7.9, 7). It lists what you made through
  Ask that has an address:
  - **What:** a published site, which shows a filled dot and its address; or
    a first look that is still up, which shows a hollow dot and "First
    look". Newest first, at most five, then "Show all".
  - **Whose:** only jobs started in Base (the ruling). Equipo's own projects
    stay in Equipo.
  - **Data:**
    - Published sites are in `chat_steps.publish`, and reach a task as
      `wire.Task.site{app, url, state, at}` (`wire/tasks.go:457`,
      `publish.go:102`).
    - A task's job is found through `chat_handoff_tasks`.
    - `chat_project_places` (0112) holds the deploy binding but no person.
      `GET /api/v1/projects` has no site URL (`api.go:302-334`).
    - So Equipo adds `GET /api/v1/assistant/made`: the person's Base-origin
      jobs with a site or a live first look, as `{job, title, url, kind,
      state, at}`. Base relays it as `GET /api/v1/made`, and the web can
      show it too.
  - **A click** opens the address in the browser. The context menu adds
    "Show the job" and "Copy address".
  - **Why yes:** it is what Base is for ("something to see very quickly").
    Without it, a finished site falls out of the snapshot after 7 days
    (K9), and the only way back to it is Equipo.
  - **Why it might be no:** a new Equipo route and section for what may be
    only a handful of sites. It comes last in the slice for that reason.
  - **Later**, Docs and Sheets the Assistant made through `use` could list
    here too.

### 7.6 Files in Ask, native (attachments slice 2)

No server change: the routes exist. BaseKit copies Equipo's code (R5) and
points it at Base's `/ask/attachments`.

- **Mac:**
  - A paperclip left of Send opens the file panel.
  - Files can be dropped on the composer or anywhere on the window; the
    outline uses the web's words.
  - ⌘V pastes. A paste with words pastes the words (D8). Base's composer is
    a SwiftUI field, not Equipo's `NSTextView`, so Base takes Paste in its
    own Edit menu command and narrows the field's drag types. The plan
    says how, and when it falls back to Equipo's editor.
  - File promises are honoured, from Photos and Mail.
- **iPhone:** a `+` left of the field, with Photos (`PhotosPicker`, no
  permission needed), Camera (`NSCameraUsageDescription`), Files and Paste
  (as Equipo's menu has). The field also takes a pasted image.
- **On the device,** HEIC, HEIF and TIFF become JPEG, and anything over
  2560 px is scaled down, before uploading (`AttachmentFile.swift`). A chip
  says "from HEIC". 48 MP photos stop being refused.
  - At most two files are prepared at once, behind the same gate as the
    uploads. A file whose size already rules it out is refused without
    being read.
  - Only converted output loses its metadata on the device. A PNG or JPEG
    at or under 2560 px goes up as it is, and Equipo strips an image's
    location on arrival (files spec 1.1).
- **Chips:**
  - each has a thumbnail, name, size, an upload ring and Remove;
  - Remove deletes the upload;
  - uploads and chips survive the app going to the background. An upload
    in flight runs as a background task so it can finish. A lost answer
    shows Retry, and a retry is a second upload, so an orphan may count
    against the 20 for a day;
  - unsent uploads are discarded, as best the app can, when the session
    ends (`end()`: sign-out, account switch, a rejected session), bounded
    at 2 s. When another Oficina app signs the ID out, the session has
    gone before Base hears, so nothing can be discarded. Equipo's 24-hour
    drop catches that, a killed app, and quitting;
  - two uploads at a time. A busy answer is retried by itself up to three
    times with backoff, then the chip says busy and offers Retry;
  - the paperclip shows only while `can_attach`;
  - every refusal has the web's words (copy review 13), and the PDF chip
    says "Ask can't read PDFs yet.";
  - refused files never take Ask down (D5).
- **In the thread:** thumbnails, then file pills, then the words, as the
  web draws them.
  - On the Mac, a click or Space opens Quick Look (`QLPreviewPanel`), with
    Open with Preview and Share.
  - On the iPhone, a tap opens `QLPreviewController`, with Share.
  - The original is fetched from `/ask/attachments/{id}` into the app's
    cache (7.9, 12):
    - **Path:** `Caches/Attachments/<account hash>/<attachment id>/<name>`.
      The name is its last path component, with the extension taken from
      the media type, so a file can't preview or open as another type.
    - **Protection:** kept out of backups. On iOS it uses
      `NSFileProtectionComplete`.
    - **When it's cleared:**
      - on `end()`, and when Ask is disconnected;
      - 14 days after the message was sent (the file's date is set to the
        message's at download);
      - folders of accounts no longer signed in are cleared too;
      - the sweep runs at launch, on each return to the foreground, and on
        the Mac each time a window opens and daily.
    - **One download per file:** a double tap shares it.
    - **Copies:** Share and Open with Preview hand a copy to another app,
      which is outside these rules once the person sends it there.
- **Not doing:** Equipo's "recent screenshot" suggestion
  (`RecentScreenshot.swift`). It needs Photos permission.

### 7.7 Opening Docs, Sheets and Slides

#### In the right app (decided for slice 2: 7.9, 9)

- **When a reply links an Oficina document,** Base opens it in the
  installed app with `works.oficina.docs://open?path=/d/<sqid>` (Sheets:
  `/sheets/<id>`), and otherwise on the web.
  - Base recognises a link by its host, from `BASE_OFICINA_APPS`, and by
    the app's path patterns.
  - On the iPhone, Base adds both schemes to `LSApplicationQueriesSchemes`.
- **Each app needs** a kit repin to `8dc540a` or later, and an `onOpen`
  that routes the path to the document:
  - **Mac:** look up the local document by its sqid and open its window.
  - **iPhone:** push the document.
- **Slides** opens on the web: it has no native app.
- **Later:** universal links, once portero serves `applinks` (Home spec
  appendix D). They make the same links work from anywhere.
- **Flag:** path-based team URLs (the Docs pilot) need `NativeHTTP.origin`
  to accept a path before any of this works for them.

#### A read-only view inside Base (7.9, 8)

| | WKWebView of the web app | Render from JSON | Quick Look of an export |
|---|---|---|---|
| **Sign-in** | Needs a web session in the view's cookie store. Home's slice D is for the default browser and isn't built. A cookie bridge (an exchanged native session put into `WKHTTPCookieStore`) is possible, but no spec sanctions it, and `/native/web/end` isn't served | An exchanged session for that app | An exchanged session: Base asks Oficina ID for an assertion addressed to Docs and trades it at Docs' `/native/oficina-id`, as it already does for Equipo. No second sign-in |
| **What each app needs** | A read-only or embed view, which none has today. Framing headers don't matter to a top-level web view | Docs keeps only CRDT updates (`/d/{sqid}/updates`), so Base would need a Yjs reader and a renderer. Sheets' cells are workable | Nothing for Docs (PDF) or Sheets (XLSX). Slides needs `/native/oficina-id` mounted |
| **Fidelity** | Exact and live | Base's own drawing, which drifts from each app | A faithful snapshot, not live |
| **Cost** | High: a new view in three apps, plus a web-session story for embedded views and its security review | Highest, and duplicated per app | Lowest |

- **Decided: Quick Look of the export now** (7.9, 8).
  - Mac: `QLPreviewView` in a pane beside Ask, as in the mockup.
  - iPhone: `QLPreviewController`.
  - The bar says "Read only" and holds **Edit in Oficina Docs**. It opens
    the Docs app at that document when it's installed (as above), and
    otherwise the web.
  - It reuses slice 2's Quick Look code, and the session is per app and
    asked for only when needed.
- **WKWebView later**, once slice D gives embedded views a sanctioned
  sign-in and the apps have a read-only view. Then it becomes live.
- **Placement:** after the rest of slice 2. Its Slides half waits on Slides
  mounting the exchange.

### 7.8 Paul's portal steps (Apple Developer, team 9U4A84C4WK)

1. **Identifiers → `works.oficina.base`:**
   - Tick **Push Notifications**, then Save. Changing a capability makes the
     existing profiles invalid.
   - Don't create a Push certificate: the key replaces it.
2. **Keys → "+":**
   - Name: "Oficina Base Push Production".
   - Tick **Apple Push Notifications service (APNs)**, then Configure.
   - **Environment: Production.** TestFlight and Developer ID builds both
     use production.
   - **Key restriction: Topic Specific, topic `works.oficina.base`.** This
     matches Equipo's key, and CARLOS's decision 5 counts on a key for one
     topic.
   - Save, Continue, Register.
3. **Download `AuthKey_<KEYID>.p8` once**, and note the Key ID.
   - Apple allows a single download.
   - It goes to the operator for `/etc/carlos-pusher/` on each box running
     an Equipo that serves a Base (E-P6).
   - It must never go in a repo or a chat.
   - Equipo's own `.p8` (`NS36T57NS4`) hasn't been downloaded yet either.
     Doing both in one sitting saves a second trip.
4. **Profiles:** regenerate the iOS App Store profile and the macOS
   Developer ID profile for `works.oficina.base`, so that both carry
   `aps-environment`. Install them where the release scripts read
   `OFICINA_PROVISIONING_PROFILE`.
5. **For the notification service extension (7.9, 3):**
   - register `works.oficina.base.notify` (iOS and macOS) with the App
     Group `group.works.oficina` on iOS and `9U4A84C4WK.works.oficina` on
     the Mac;
   - make its two profiles.
6. **In slice 3 (not now):** `works.oficina.base.activity` for the widget
   extension.

### 7.9 Paul's rulings (2026-11-28)

Paul approved every recommendation as written. Each is now decided:

1. **Who sends Base's notifications.** **Decided:** Equipo, through its
   outbox, to registrations Base relays (7.2). Alternative: Base sends.
2. **Which job states notify.** **Decided:** the table in 7.2. Asking,
   first look, ready and stopped alert. Done and paused are quiet. Working
   never notifies.
3. **Buttons on notifications.** **Decided:**
   - the decision's own choices, answered without opening the app, through
     a notification service extension;
   - never Drop, Replace, publishing or spending;
   - "Choose…" as the fallback.
4. **Assistant replies.** When the Assistant answers and no Ask is open
   anywhere, should Base notify? **Decided:** yes, as Equipo does for its
   Coordinator (`reply_unseen`).
5. **A person without the Base app.** Should Ask jobs fall back to Equipo's
   app? **Decided:** no, by the ruling. Web push for Base later.
6. **Equipo's Live Activities for Ask jobs until slice 3.** **Decided:**
   keep them until Base's ship, then switch in one release (7.2), so
   there's never a gap. Alternative: stop them now.
7. **"Made with Base" in the sidebar.** **Decided:** yes, named "Made
   with Base", listing published sites and live first looks from Ask jobs,
   with a new Equipo route. Last in the slice. Alternative names: "Your
   sites", "Things you made".
8. **Reading a Doc inside Base.** **Decided:** Quick Look of the export
   now, with Edit in Oficina Docs; a web view later, after slice D.
9. **Opening a linked Doc or Sheet in its app.** **Decided:** yes in
   slice 2, through `://open?path=`. It needs Docs and Sheets to repin and
   route the path.
10. **Decisions on cards wait for the web.** **Decided:** yes. Native
    follows phase 1 on the web and is never built first, so both read the
    same JSON.
11. **The push key.** **Decided:** a production, topic-specific key for
    `works.oficina.base`. Alternative: one team-wide key for every Oficina
    app. That is simpler, but it loses the per-app bound CARLOS relies on.
12. **Opened files on the device.** **Decided:** kept in the app's cache,
    out of backups, cleared on sign-out and after 14 days (matching R3).
    Never anywhere else.

### 7.10 Blockers

- **B1. CARLOS `/v1/push`:** the spec is approved, but the build is
  uncommitted and undeployed (`carlos/platform-wt-push-build`).
- **B2. rastrillo `push`:** uncommitted, no tag (`feat/push-submit`).
- **B3. Equipo's transport seam:** `push/transport.go:50-64`. It also needs
  E-P1 to E-P6 (7.2).
- **B4. Apple:** the Base push key doesn't exist yet, and Paul downloads it
  (7.8). The App ID needs Push Notifications and new profiles. Equipo's
  `.p8` isn't downloaded either.
- **B5. The jobs design's phase 1** isn't built in Equipo or Base. It is
  needed for decisions on the cards and for notification buttons.
- **B6. "Made with Base"** needs Equipo's `GET /api/v1/assistant/made`.
- **B7. Opening documents** needs the Docs and Sheets kit repins and
  `onOpen`. Slides needs its exchange mounted. Path-based teams need the
  kit's origin fix.

### 7.11 Slice plan

In the plan's order (Paul, 2026-11-28). Within slice 2, the unblocked parts
come first.

1. **2a. No blockers.**
   - Store and People: the JSON API (7.4) and native screens.
   - Apps folding.
   - Files in Ask: native copy of Equipo's code, Quick Look, and the HEIC
     conversion.
   - Copy review of the new strings.
2. **2b. Notifications, tap to open.** Needs B1 to B4.
   - Base: `POST /api/v1/push` relay.
   - Equipo: E-P1 to E-P6.
   - App: registration, categories, the badge, foreground rules, withdraw.
   - Ships without buttons.
3. **2c. Decisions on the cards, and notification buttons.** Needs B5.
   - Pills, the job view, the act, folding when the web has it.
   - Then the service extension and the bound actions.
4. **2d. Made with Base, and opening documents.** Needs B6 and B7.
   - The sidebar section.
   - `://open` into Docs and Sheets.
   - The Quick Look viewer with Edit in Oficina Docs.

The mockups are signed off (2026-11-28). Each part gets a plan, reviews as before,
and TestFlight and Sparkle releases.

### 7.12 Not doing in slice 2

- Siri, Shortcuts, the share extension and Live Activities: slice 3.
- Removing members natively.
- Base paths for approvals (K6 keeps them on Equipo's pages).
- A live embedded editor of any Oficina app.
