| 1 | # Oficina ID native adoption |
| 2 | |
| 3 | Branch: `native/oficina-id`. Implements step 5 of the approved |
| 4 | [spec](../docs/superpowers/specs/2026-11-20-equipo-native-oficina-id.md). |
| 5 | |
| 6 | ## What a person sees |
| 7 | |
| 8 | - First Oficina app: the kit's Welcome, passkey or email/code, then the team. |
| 9 | - One readable Oficina ID and one Equipo team: straight in, with no sign-in |
| 10 | form or team address. Several identities use the kit's identity chooser. |
| 11 | - Several Equipo teams: the kit's Team step. The account menu can change teams. |
| 12 | - No Equipo teams: the kit's zero-teams help. Other apps' teams are filtered out. |
| 13 | - Other ways to sign in: the existing address, code and browser approval. |
| 14 | Saved pairings still open. This route suspends automatic Oficina ID sign-in; |
| 15 | Sign in with Oficina ID returns to it. |
| 16 | - Sign out: the kit forgets the shared identity and its app sessions; Equipo |
| 17 | forgets and best-effort revokes that identity's device credentials, detaches |
| 18 | push registration, unregisters remote notifications, clears the badge and |
| 19 | ends Live Activities. Use another goes through the kit's confirmation and |
| 20 | the same cleanup. Signing out elsewhere also clears Equipo's native account. |
| 21 | - An outage during renewal keeps the conversation and pending writes, with |
| 22 | a retry notice when the kit reports the failure. Foreground and stream |
| 23 | retries recover when Home returns. |
| 24 | |
| 25 | The existing server contract still requires an Oficina ID linked to an active |
| 26 | Equipo member. A directory entry alone grants no access; the kit shows the |
| 27 | server's refusal. |
| 28 | |
| 29 | ## Implementation |
| 30 | |
| 31 | `RastrilloApple` was initially pinned to Docs' `1e36aac95ed252848722926efc8ba8f9dc803216`. |
| 32 | The current pin is `a18c32b3584ab5cadb8327f8f52a6186721f58dd`; see the kit update below. |
| 33 | The kit selects an identity/team and mints its session. Equipo posts the session |
| 34 | cookie, same-origin header, a fresh Curve25519 signing public key and device |
| 35 | label to the native device endpoint. It persists the returned bearer and key |
| 36 | in `DeviceAccounts`, as pairing does. Engine requests remain device bearers. |
| 37 | |
| 38 | Optional account metadata binds a saved device to its identity, team and the |
| 39 | hash of its source session. Existing account JSON still decodes. Renewal updates |
| 40 | the current `EquipoSession` without discarding its conversation or pending |
| 41 | writes. The kit renews on foreground and a 24-hour clock; an updated session |
| 42 | registers a replacement device and retires the previous device best effort. |
| 43 | HTTP 401/403 and rejected event streams re-mint and retry once, retaining the |
| 44 | original request body, revision and idempotency key. A definite permission |
| 45 | refusal remains a 403 after the retry. Re-mints are coalesced and |
| 46 | limited to once a minute. Late answers after leaving cannot restore an account. |
| 47 | |
| 48 | Both entitlement files retain the old default Keychain group first, |
| 49 | `9U4A84C4WK.works.oficina.equipo`, followed by the shared identity group. |
| 50 | They add the platform's App Group and webcredentials association and retain |
| 51 | push entitlements. The new signing check verifies the old default group. |
| 52 | |
| 53 | Mac packaging already delegates to the kit's bundler, which at the pinned |
| 54 | revision supports both `--provisioning-profile` and `--entitlements`, embeds the |
| 55 | profile before signing and strips restricted grants from ad hoc development |
| 56 | builds. The wrapper now documents these options; the gate exercises profile |
| 57 | embedding and ad hoc behavior with dummy bytes and mocked signing. The existing |
| 58 | configuration retains the private profile path. No profile is copied into this |
| 59 | repository and verification does not read it or invoke a signing identity. |
| 60 | |
| 61 | ## Verification |
| 62 | |
| 63 | Tests use `FakeOficinaIDService`, in-memory identity/device stores and |
| 64 | `ScriptedTransport`. No test uses a real identity or Keychain. The initial suite |
| 65 | failed on the absent adoption; additional failing tests exposed native-device |
| 66 | rejection, cold-launch orphan cleanup, recovery after a Home outage and starting the |
| 67 | conversation when sign-in completes in an already active scene. A final |
| 68 | regression test distinguishes definite permission refusals from renewal outages. |
| 69 | |
| 70 | The native gate is `native/scripts/check-native.sh`: signing contract, API |
| 71 | fixtures, strings, web parity, reference scan, Swift tests, Mac build and an |
| 72 | unsigned iOS Simulator build. The initial gate passed 114 Swift tests, including 20 Oficina ID adoption tests. |
| 73 | All 28 deliberate mutations below failed their selected check; each change was |
| 74 | restored before the final gate. Two initially surviving mutations led to stronger |
| 75 | assertions for local credential removal and absence of fallback Home requests. |
| 76 | |
| 77 | Live loopback check: |
| 78 | |
| 79 | ```sh |
| 80 | CGO_ENABLED=0 go test ./internal/plan3test -run '^TestPersonAPINativeLiveExchange$' -count=1 |
| 81 | ``` |
| 82 | |
| 83 | Passed. The existing test runs fake Home and the production Equipo router on |
| 84 | loopback listeners, exchanges an assertion, registers a device, checks the |
| 85 | session/device expiry match and reads the engine snapshot with the bearer. |
| 86 | The Swift integration suite tests the app side separately with the kit fake; |
| 87 | this was not a signed app or passkey UI smoke test. |
| 88 | |
| 89 | ## Copy reviewed by Luna |
| 90 | |
| 91 | Five new English strings; existing Equipo strings are unchanged: |
| 92 | |
| 93 | | Key | Text | |
| 94 | | --- | --- | |
| 95 | | `oficina.sign_in` | Sign in with Oficina ID | |
| 96 | | `oficina.connecting` | Connecting to your team | |
| 97 | | `oficina.device_failed` | Could not connect to this team. | |
| 98 | | `oficina.retry` | Connect again | |
| 99 | | `oficina.current_team` | Current team | |
| 100 | |
| 101 | The onboarding, Other ways to sign in, Use another Oficina ID, identity/team |
| 102 | rows, replacement confirmation and identity-labelled Sign out reuse the kit's |
| 103 | copy. Both existing string catalogs are generated from the English source; |
| 104 | string and web-parity checks pass. Luna reviewed all five strings; her three |
| 105 | edits are applied exactly. Her brief and result are copied below. |
| 106 | |
| 107 | ## Controller follow-up |
| 108 | |
| 109 | Review the branch. The five strings have Luna's delegated approval. Signed-device/shared-Keychain and |
| 110 | Developer ID launch checks remain with the controller: this task does not |
| 111 | change profiles, identities, App Store Connect or Keychains. Nothing is merged, |
| 112 | deployed or uploaded. |
| 113 | |
| 114 | ## Deliberate mutations |
| 115 | |
| 116 | Each Swift mutation ran `swift test --package-path native/apple --filter` with |
| 117 | its protecting test, observing an assertion failure (not a compiler failure). |
| 118 | The signing mutations ran `python3 native/scripts/check-oficina-id.py`. Kit |
| 119 | mutations used a temporary module copy because SwiftPM's checkout is read-only. |
| 120 | |
| 121 | | Guard broken | Protecting check | |
| 122 | | --- | --- | |
| 123 | | Same-origin header | `firstAppShowsWelcomeThenKeepsDeviceAndFreshKey` | |
| 124 | | Cookie restricted to device registration | `onlyDeviceRegistrationMaySendTheSessionCookie` | |
| 125 | | Submitted public key matches fresh stored key | `firstAppShowsWelcomeThenKeepsDeviceAndFreshKey` | |
| 126 | | Device persisted before adoption | `firstAppShowsWelcomeThenKeepsDeviceAndFreshKey` | |
| 127 | | Directory filtered for Equipo | `oneIdentityGoesStraightInAndSeveralTeamsOrNoneUseKit` | |
| 128 | | Credential bound to its source session | `renewsAfter24HoursWithoutReplacingConversationSession` | |
| 129 | | Late device response refused after sign-out | `lateRegistrationCannotRestoreSignedOutDevice` | |
| 130 | | Orphaned credential removed on cold launch | `nativeCredentialWhoseIdentityWasRemovedCannotSurviveRelaunch` | |
| 131 | | Old paired account restored | `oldSavedPairingStillLoadsWithoutOficinaID` | |
| 132 | | Re-mint rate limited | `repeatedRejectionsAreRateLimitedAndKeepConversation` | |
| 133 | | Device endpoint refusal re-mints | `deviceEndpointRejectionRemintsTheKitSession` | |
| 134 | | Engine 403 re-mints | `rejectionsRemintOnceAndRetryWithTheNewBearer` | |
| 135 | | Retry uses replacement bearer | `rejectionsRemintOnceAndRetryWithTheNewBearer` | |
| 136 | | Clock waits 24 hours | `dailyTimerRenewsWhileAppStaysOpen` | |
| 137 | | Equipo device revoked | `signOutStopsPushesAndRevokesThisDevice` | |
| 138 | | Notifications unregistered and badge cleared | `signOutStopsPushesAndRevokesThisDevice` | |
| 139 | | Kit identity signs out | `signOutStopsPushesAndRevokesThisDevice` | |
| 140 | | Unavailable team retried on foreground | `foregroundRecoversAfterARejectedSessionMetAnOutage` | |
| 141 | | Shared sign-out leaves fallback pairing alone | `sharedIdentityRemovalLeavesAnActiveFallbackPairingAlone` | |
| 142 | | Local device removed on sign-out | `signOutStopsPushesAndRevokesThisDevice` | |
| 143 | | Fallback suppresses automatic Home requests | `pairingFallbackSuspendsStraightInAndReturnResumesIt` | |
| 144 | | Old default Keychain group retained | Signing check | |
| 145 | | Mac profile embedded | Signing check with dummy profile and mocked signing | |
| 146 | | Ad hoc build strips restricted grants | Signing check with dummy profile and mocked signing | |
| 147 | | Foreground sign-in starts conversation | `signingInWhileAlreadyForegroundStartsTheConversation` | |
| 148 | | Push registrar detached on sign-out | `signOutStopsPushesAndRevokesThisDevice` | |
| 149 | | Definite permission refusal remains a 403 | `aDefinite403StaysARefusalAfterRemint` | |
| 150 | | Event-stream authentication re-mints | `rejectedEventStreamRemintsAndPreservesCursor` | |
| 151 | |
| 152 | |
| 153 | ## Independent review fixes |
| 154 | |
| 155 | Astra requested changes at `7f4e1006`: a snapshot released after sign-out could |
| 156 | save the departed account's bearer and private key while updating its team name; |
| 157 | a failed re-mint could leave the kit unavailable with no error string and hence |
| 158 | no recovery notice. |
| 159 | |
| 160 | The three new regression tests first failed with six assertions. The snapshot |
| 161 | was held until after sign-out, then released: the old session became ready and |
| 162 | saved its credential again. A held renewal plus a queued session update also |
| 163 | restored metadata. The unavailable test reproduced an engine 401 followed by |
| 164 | Home offline, with both error strings nil and no notice. |
| 165 | |
| 166 | Departing sessions now become permanently invalid before they are released. |
| 167 | Snapshot completion, direct metadata application and renewal all respect that |
| 168 | invalidation. Sign-out, replacement, pairing fallback and session expiry use the |
| 169 | same invalidation. Native device registration retains its existing epoch/state |
| 170 | check before persistence, tested with a renewal response released after sign-out. |
| 171 | Pairing sign-out forgets its credential before network cleanup, so a late |
| 172 | revocation cannot remove a newly saved credential at the same origin. Push |
| 173 | cleanup remains in place. |
| 174 | |
| 175 | The mounted conversation explicitly shows the kit's unavailable title when the |
| 176 | kit is unavailable, even without error strings. Its Connect again button retries |
| 177 | the kit and refreshes the conversation. Recovery removes the notice. |
| 178 | |
| 179 | Regression commands: |
| 180 | |
| 181 | ```sh |
| 182 | swift test --package-path native/apple --filter 'OficinaIDTests/(lateSnapshot|lateRenewal|unavailableRenewal)' |
| 183 | swift test --package-path native/apple --filter OficinaIDTests |
| 184 | ``` |
| 185 | |
| 186 | First command before fixes: three tests failed, six assertions. The mutation |
| 187 | checks remove one guard at a time and run its selected test, requiring an |
| 188 | assertion failure rather than a compiler error; every mutation is restored. |
| 189 | |
| 190 | | Guard broken | Regression test | |
| 191 | | --- | --- | |
| 192 | | Invalidate departing session | lateSnapshotCannotRestoreSignedOutDevice | |
| 193 | | Ignore late snapshot completion | lateSnapshotCannotRestoreSignedOutDevice | |
| 194 | | Ignore direct metadata on invalid session | lateRenewalCannotRestoreSignedOutDevice | |
| 195 | | Refuse renewal of invalid session | lateRenewalCannotRestoreSignedOutDevice | |
| 196 | | Reject native device response from departed epoch | lateRenewalCannotRestoreSignedOutDevice | |
| 197 | | Show unavailable notice without an error | unavailableRenewalShowsRecoveryWithoutAnErrorString | |
| 198 | | Invalidate when switching to pairing | departingSessionCannotPersistAfterItsReplacement | |
| 199 | | Invalidate when replacing team | departingSessionCannotPersistAfterItsReplacement | |
| 200 | | Forget paired credential before revocation awaits | latePairingRevocationCannotRemoveANewCredential | |
| 201 | |
| 202 | The review gate passed `native/scripts/check-native.sh`: 119 Swift tests in |
| 203 | 14 suites (25 Oficina ID tests), Mac build, unsigned iOS Simulator build, |
| 204 | 7 fixtures, 169 strings, 23 parity entries and a clean reference scan. All nine |
| 205 | review mutations above failed their intended assertion and were restored. The |
| 206 | loopback native exchange test also passed again. Logs are under the ignored |
| 207 | `native/build/logs` directory: `review-red.log`, `review-mutations`, |
| 208 | `review-native-gate.log` and `review-loopback.log`. |
| 209 | |
| 210 | ## Luna's brief and verdict |
| 211 | |
| 212 | The controller supplied this review from `gpt-5.6-luna`, with Paul's instruction |
| 213 | to apply the verdicts as approved copy. Source: the controller's `luna-oid` |
| 214 | brief and result, copied verbatim below. All three changes are applied in |
| 215 | `strings.json` and both generated catalogs. None has a web parity mapping. |
| 216 | |
| 217 | ### Brief |
| 218 | |
| 219 | # Copy review brief: Equipo's apps sign in with Oficina ID (native, 2026-11-20) |
| 220 | |
| 221 | Paul delegates copy review for this work to you. You are the copy editor. Your |
| 222 | edits will be applied as approved copy. |
| 223 | |
| 224 | ## Context |
| 225 | |
| 226 | Equipo is Oficina's team app, on iPhone and Mac. It now signs in with Oficina |
| 227 | ID, the one account behind every Oficina app. It uses a shared sign-in kit |
| 228 | whose own screens (Welcome, "Sign in with a passkey", email and code, choosing |
| 229 | a team, "Other ways to sign in…", "Sign out", "Try again") are reviewed |
| 230 | already and are not yours to change. The strings below are Equipo's own and |
| 231 | appear next to the kit's. With an Oficina ID already on the device, the app |
| 232 | goes straight in. The person never types anything. "Other ways to sign in…" |
| 233 | opens the older pairing (type the team's address, approve a code in the |
| 234 | browser). |
| 235 | |
| 236 | ## The strings (ids are fixed, text is yours to change) |
| 237 | |
| 238 | - `oficina.sign_in`: a button at the bottom of the pairing screen, which |
| 239 | takes the person back to signing in with Oficina ID. Draft: `Sign in with Oficina ID` |
| 240 | - `oficina.connecting`: the label of a spinner, shown after Oficina ID has |
| 241 | signed the person in while the app gets its own access to the chosen team |
| 242 | (normally a second or less). Draft: `Signing in to your team` |
| 243 | - `oficina.device_failed`: an error shown on that same screen when the app |
| 244 | could not get access to the team (network or server failure). Below it are |
| 245 | a retry button, "Other ways to sign in…" and "Sign out". Draft: |
| 246 | `Could not sign in to this team. Try again.` |
| 247 | - `oficina.retry`: the retry button under that error. Draft: `Try again`. |
| 248 | The kit already has a "Try again" string of its own. |
| 249 | - `oficina.current_team`: the accessibility label (VoiceOver) of a checkmark |
| 250 | next to the team the app is using, in the account menu's list of teams. |
| 251 | Draft: `Current team` |
| 252 | |
| 253 | ## House rules (Paul's, all binding) |
| 254 | |
| 255 | - No em dashes, ever. No exclamation marks. |
| 256 | - Plain words. No jargon a reader would not know. Short. Sentence case. |
| 257 | - Say what happened and what to do. |
| 258 | - Use the product names exactly: Oficina ID, Equipo. |
| 259 | - Do not change the facts. If something looks wrong, flag it. |
| 260 | |
| 261 | ## Output |
| 262 | |
| 263 | 1. A table of every string: `id | current | new (or "unchanged") | why`. |
| 264 | 2. A list of flagged rows: `id | problem`. |
| 265 | 3. One line of counts: changed, flagged, left alone. |
| 266 | |
| 267 | ### Verdict |
| 268 | |
| 269 | | id | current | new | why | |
| 270 | |---|---|---|---| |
| 271 | | `oficina.sign_in` | Sign in with Oficina ID | unchanged | Clear and accurate. | |
| 272 | | `oficina.connecting` | Signing in to your team | Connecting to your team | Oficina ID has already signed the person in. | |
| 273 | | `oficina.device_failed` | Could not sign in to this team. Try again. | Could not connect to this team. | Describes the app's access problem. The retry button gives the next step. | |
| 274 | | `oficina.retry` | Try again | Connect again | Avoids repeating the sign-in kit's “Try again” label. | |
| 275 | | `oficina.current_team` | Current team | unchanged | Clear accessibility label. | |
| 276 | |
| 277 | Flagged rows: |
| 278 | |
| 279 | | id | problem | |
| 280 | |---|---| |
| 281 | | `oficina.connecting` | “Signing in” suggests the person is signing in again. | |
| 282 | | `oficina.device_failed` | “Sign in” describes the wrong failure, and the sentence duplicates the retry button. | |
| 283 | | `oficina.retry` | Duplicates the sign-in kit's “Try again” label. | |
| 284 | |
| 285 | Changed: 3. Flagged: 3. Left alone: 2. |
| 286 | |
| 287 | |
| 288 | ## Shared sign-in lifetime review |
| 289 | |
| 290 | Astra's re-review of `f90cf412` found two further crossings of the sign-in |
| 291 | boundary: cancelled pairing could persist a late exchange or `/me` answer, |
| 292 | and a departed card-answer retry could borrow the bearer of a later sign-in |
| 293 | to the same identity and team. |
| 294 | |
| 295 | Before implementation, the new reproductions failed with 19 assertions across |
| 296 | two tests (the pairing test has four cases: exchange or `/me`, each with and |
| 297 | without signing out after switching to Oficina ID). The persistence source |
| 298 | check also failed because there was no common guarded commit boundary. |
| 299 | |
| 300 | `SignInLifetime` now represents authority for one sign-in. `SignInLifetimes` |
| 301 | is shared through `DeviceAccounts` by pairing, Oficina ID and the app model. |
| 302 | Beginning another sign-in ends the previous token. Pairing captures its token |
| 303 | synchronously when Start is tapped, before scheduling its task. An approved |
| 304 | pairing hands that same token to the conversation. Native renewal retains its |
| 305 | token; identity/team/origin changes, cancellation, replacement and sign-out end |
| 306 | it. A token cannot be reactivated. |
| 307 | |
| 308 | Every Equipo-owned write of a device, private key, account index or sign-in |
| 309 | route goes through `DeviceAccounts.commit`. The raw store is private. Commit |
| 310 | requires the captured token to be both active and the current token. Its check |
| 311 | and writes are synchronous on MainActor. Removal also matches the saved private |
| 312 | key, so cleanup cannot remove another sign-in's saved account at the same |
| 313 | origin. The pinned kit continues to own its shared identity store and its own |
| 314 | epoch checks; Equipo does not write that store directly. |
| 315 | |
| 316 | Bound async flows: |
| 317 | |
| 318 | - Pairing start, challenge retries, exchange polling, credential persistence, |
| 319 | authenticated `/me`, and metadata persistence. |
| 320 | - Native startup/restore, selection callbacks, Home renewal, rejection recovery, |
| 321 | native device registration and credential installation. |
| 322 | - Snapshot/task/Needs you refresh, metadata persistence, stream setup and |
| 323 | consumption, reconnects and queued refreshes. |
| 324 | - Message and thread sends, waiting-message delivery, card answers, Set aside |
| 325 | and Undo retries, and turn cancellation. |
| 326 | - Retained clients and credential providers. Both the transport and its provider |
| 327 | capture the original token; matching the same identity/team after another |
| 328 | sign-in cannot authorize them. |
| 329 | - Session renewal/adoption, foreground continuation and push attachment. Push |
| 330 | registration passes also retain the lifetime alongside their existing |
| 331 | generation check. A queued old attachment cannot replace the new session. |
| 332 | |
| 333 | A scene's daily clock is an app-level scheduler: each renewal it starts captures |
| 334 | the then-current token, while an already running renewal retains its original |
| 335 | token. Old registration/renewal tasks cannot clear a newer task's coalescing |
| 336 | slot because those slots have distinct task IDs. |
| 337 | |
| 338 | Late pairing exchanges and native device mints are decoded so their abandoned |
| 339 | credentials can be revoked best effort. Revocation is the sole network cleanup |
| 340 | allowed after a lifetime ends: `DeviceRevocation` uses only the abandoned |
| 341 | credential, never a current credential provider, and never persists anything. |
| 342 | Cancelling after a pairing credential arrived also schedules revocation at once. |
| 343 | |
| 344 | Additional regressions cover cancellation without a replacement sign-in, |
| 345 | ended/foreign persistence tokens, late transport responses and later requests, |
| 346 | both write retry loops stopping without a sleep, a retained provider refusing a |
| 347 | later sign-in's bearer, late push attachment, and abandoned native revocation. |
| 348 | `check-sign-in-lifetime.py` is part of the native gate. It rejects raw store or |
| 349 | Keychain writes outside the approved boundary and rejects an unguarded commit. |
| 350 | |
| 351 | Mutation commands use `swift test --package-path native/apple --filter` with |
| 352 | the listed regression, or `python3 native/scripts/check-sign-in-lifetime.py`. |
| 353 | Each mutation must produce an assertion failure, not a compiler error, and is |
| 354 | restored before the gate: |
| 355 | |
| 356 | | Mutation | Regression | |
| 357 | | --- | --- | |
| 358 | | Pairing cancellation leaves token active | cancellingPairingAloneEndsItsLifetime | |
| 359 | | New lifetime leaves previous token active | endedTransportRefusesLateResponsesAndNewRequests | |
| 360 | | Commit skips lifetime validation | endedOrForeignLifetimesCannotPersistAnything | |
| 361 | | Provider ignores captured lifetime | departedWriteCannotRetryWithALaterSignInsBearer | |
| 362 | | Answer/visibility retries ignore ended lifetime | endedWriteLoopsDoNotWaitOrRetry | |
| 363 | | Abandoned pairing is not revoked | cancelledPairingCannotOverwriteNativeSignIn | |
| 364 | | Abandoned native device is not revoked | lateRenewalCannotRestoreSignedOutDevice | |
| 365 | | Push attach accepts an ended lifetime | lateAttachCannotReplaceTheNextSignIn | |
| 366 | | Transport ignores lifetime | endedTransportRefusesLateResponsesAndNewRequests | |
| 367 | | Source has unguarded commit | check-sign-in-lifetime.py | |
| 368 | | Source adds raw secret-store write | check-sign-in-lifetime.py | |
| 369 | | Source adds another writer inside DeviceAccounts | check-sign-in-lifetime.py | |
| 370 | | Native sign-out leaves onboarding token active | signOutBeforeRegistrationEndsThePendingLifetime | |
| 371 | | App sign-out leaves onboarding token active | signOutBeforeRegistrationEndsThePendingLifetime | |
| 372 | | Session removal ends the gate before forgetting | signingOutAfterTheSessionEndsStillForgetsItsCredential | |
| 373 | |
| 374 | The early sign-out regression first failed at both entry points, then passed. |
| 375 | Cancellation-alone also tests signing out while pairing is pending, ensuring |
| 376 | its staged key is removed before the token ends. All fifteen deliberate |
| 377 | mutations failed their assertions and were restored. Evidence is in the ignored |
| 378 | `native/build/logs/lifetime-*` logs, including the two mutation result files. |
| 379 | |
| 380 | No user-facing strings changed in this review. Luna's approved copy above is |
| 381 | unchanged. Signed-device and shared-Keychain launch checks remain with the |
| 382 | controller; this work does not touch actual profiles, identities or Keychains. |
| 383 | |
| 384 | The final audit also reproduced sign-out after session removal: ending the token |
| 385 | before forgetting could correctly reject the later cleanup write. Session removal, |
| 386 | account switching and pairing fallback now forget through the still-valid token, |
| 387 | then end it. Terminal engine authentication failure likewise removes its saved |
| 388 | credential before invalidation. No stale-token exception was added to commit. |
| 389 | |
| 390 | |
| 391 | Final lifetime gate: `native/scripts/check-native.sh` passed with 128 tests in |
| 392 | 15 Swift suites, both native builds, the lifetime persistence scan, 7 fixtures, |
| 393 | 169 strings, 23 parity entries and a clean reference scan. The loopback native |
| 394 | exchange test passed again. The existing push sign-out regression also passes: |
| 395 | notification cleanup still runs when sessionEnded is called with no session, |
| 396 | while a nested coordinator callback is handled only once. |
| 397 | |
| 398 | |
| 399 | ## Shared kit stale-grant fix |
| 400 | |
| 401 | Both Package.swift and Package.resolved now pin rastrillo/native main at |
| 402 | `a18c32b3584ab5cadb8327f8f52a6186721f58dd`, as supplied by the controller. |
| 403 | The kit binds grant-ended handling to its epoch and the grant and stamps |
| 404 | identity items with their grant ID, protecting a newer sign-in from a stale |
| 405 | refreshTeams response. No shared-kit source was changed in this worktree. |
| 406 | |
| 407 | Equipo has no custom OficinaSecureStore conformances or wrappers. Its sign-in |
| 408 | tests use the kit's OficinaMemoryStore directly; the pinned implementation |
| 409 | supports tagged and referenced conditional writes. No adapter changes are |
| 410 | needed. The existing Equipo lifetime regressions remain in place; no additional |
| 411 | Equipo regression or guard was introduced in this dependency-only update. |
| 412 | No user-facing strings changed. |
| 413 | |
| 414 | Validation: `native/scripts/check-native.sh` passed at this pin: 128 Swift tests |
| 415 | in 15 suites, Mac build, unsigned iOS Simulator build, lifetime persistence |
| 416 | scan, old-default-Keychain-group and profile-embedding checks, 7 fixtures, |
| 417 | 169 strings, 23 parity entries and the reference scan (2527 files, 2846 matches, |
| 418 | 0 failures). Evidence: `native/build/logs/kit-pin-native-gate.log`. |
| 419 | |
| 420 | |
| 421 | ## Fable final-review follow-up |
| 422 | |
| 423 | The first two P3 findings are fixed. Leaving Oficina sign-in now removes every |
| 424 | saved DeviceAccount with an oficinaIdentity and best-effort revokes each bearer, |
| 425 | even before the bridge synchronizes or the kit loads an identity. Pairing-made |
| 426 | accounts remain saved. The bridge observes the kit identity during onboarding, |
| 427 | so confirmed Use another also performs this cleanup from Continue as and |
| 428 | unavailable. Cleanup tasks retain earlier revocations when a second leave has |
| 429 | nothing left to remove. All persistence still uses the lifetime-guarded commit. |
| 430 | |
| 431 | The app distinguishes the kit leaving from the server ending a session. A local |
| 432 | sign-out or confirmed identity replacement clears endedTeam. A server-ended |
| 433 | session retains the existing team notice when pairing opens. Push cleanup and |
| 434 | lifetime invalidation still run in both cases. No strings changed. |
| 435 | |
| 436 | Tests were added before the fixes. Running |
| 437 | `swift test --package-path native/apple --filter 'leavingBeforeBridgeSynchronizes|onlyServerSessionEnd|permissionRefusalDuringHomeOutage'` |
| 438 | failed with 28 assertions: all eight combinations of Continue as/unavailable |
| 439 | and app sign-out/bridge sign-out/replacement/pairing, the three deliberate-leave |
| 440 | notice cases, and the lost kit session. The tests also retain a pairing-made |
| 441 | account and require revocation of both native accounts, including another |
| 442 | identity. A further three-case regression covers leaving before any identity |
| 443 | has loaded. Evidence: `native/build/logs/fable-p3-red.log`, |
| 444 | `fable-p3-green.log` and `fable-p3-boundaries.log` in the same log directory. |
| 445 | |
| 446 | ### Remaining kit limitation: 403 during Home outage |
| 447 | |
| 448 | The third P3 is reproduced but cannot be safely fixed through the current kit |
| 449 | API. At the pinned revision, OficinaIDModel.sessionRejected deletes the stored |
| 450 | session before calling open. open can fall back during an outage only to the |
| 451 | stored session it reads, which has already been deleted. renewIfNeeded retains |
| 452 | sessions on outage but refuses to mint until the stored session is 24 hours |
| 453 | old. choose/retry reuse a fresh session, so they cannot force a re-mint for a |
| 454 | possibly stale 403. Equipo must not manufacture kit timestamps or restore |
| 455 | session records outside the kit's grant/epoch guards. |
| 456 | |
| 457 | No kit source, pin or 403 behavior was changed. The needed kit change is an |
| 458 | API for forced renewal that preserves a still-usable session until a replacement |
| 459 | is available, or until authoritative evidence says the session/grant has ended. |
| 460 | The controller must arrange that shared-kit change before this third finding |
| 461 | can be closed. |
| 462 | |
| 463 | permissionRefusalDuringHomeOutageKeepsTheKitSession remains an executable |
| 464 | reproduction using FakeOficinaIDService and ScriptedTransport. Only its missing |
| 465 | stored-session assertion is marked with Swift Testing's withKnownIssue; it |
| 466 | reports one known issue and fails on unexpected success when the kit is fixed. |
| 467 | The surrounding assertions still require the actual 403 and the mounted |
| 468 | conversation. This is documented outstanding work, not a fixed or mutation-checked |
| 469 | guard. The initial unmarked assertion failure is recorded in the red log. |
| 470 | |
| 471 | |
| 472 | Eight deliberate mutations were caught by assertion failures, then restored: |
| 473 | |
| 474 | | Mutation | Regression | |
| 475 | | --- | --- | |
| 476 | | Remove only the tracked identity's accounts | leavingBeforeBridgeSynchronizesForgetsEveryNativeAccount | |
| 477 | | Stop observing identity before synchronization | leavingBeforeBridgeSynchronizesForgetsEveryNativeAccount | |
| 478 | | Gate bridge sign-out on a loaded identity | leavingBeforeIdentityLoadsForgetsTheSavedBearer | |
| 479 | | Gate pairing fallback cleanup on a loaded identity | leavingBeforeIdentityLoadsForgetsTheSavedBearer | |
| 480 | | Route app sign-out away from the bridge before identity loads | leavingBeforeIdentityLoadsForgetsTheSavedBearer | |
| 481 | | Skip saved native bearer revocation | leavingBeforeBridgeSynchronizesForgetsEveryNativeAccount | |
| 482 | | Report kit leave as server-ended | onlyServerSessionEndShowsTheEndedTeamNotice | |
| 483 | | Clear the notice for a real server-ended session | onlyServerSessionEndShowsTheEndedTeamNotice | |
| 484 | |
| 485 | Each mutation ran `swift test --package-path native/apple --filter` with the |
| 486 | listed regression. All eight returned an assertion failure, not a build failure. |
| 487 | Evidence: `native/build/logs/fable-p3-mutations/results.json` and its sibling logs. |
| 488 | |
| 489 | |
| 490 | Final native gate: `native/scripts/check-native.sh` passed with 132 tests in |
| 491 | 15 suites and the one explicitly recorded kit issue described above. The Mac |
| 492 | and unsigned iOS Simulator builds, lifetime persistence scan, old default |
| 493 | Keychain group and profile checks, 7 fixtures, 169 strings, 23 parity entries |
| 494 | and reference scan all passed. Evidence: `native/build/logs/fable-p3-native-gate.log`. |
| 495 | The original fifteen lifetime mutations and regressions remain in place. |
| 496 | No actual Keychain, provisioning profile or signing identity was changed. |
| 497 | |