oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

Oficina ID native adoption

Branch: native/oficina-id. Implements step 5 of the approved spec.

What a person sees

  • First Oficina app: the kit's Welcome, passkey or email/code, then the team.
  • One readable Oficina ID and one Equipo team: straight in, with no sign-in form or team address. Several identities use the kit's identity chooser.
  • Several Equipo teams: the kit's Team step. The account menu can change teams.
  • No Equipo teams: the kit's zero-teams help. Other apps' teams are filtered out.
  • Other ways to sign in: the existing address, code and browser approval. Saved pairings still open. This route suspends automatic Oficina ID sign-in; Sign in with Oficina ID returns to it.
  • Sign out: the kit forgets the shared identity and its app sessions; Equipo forgets and best-effort revokes that identity's device credentials, detaches push registration, unregisters remote notifications, clears the badge and ends Live Activities. Use another goes through the kit's confirmation and the same cleanup. Signing out elsewhere also clears Equipo's native account.
  • An outage during renewal keeps the conversation and pending writes, with a retry notice when the kit reports the failure. Foreground and stream retries recover when Home returns.

The existing server contract still requires an Oficina ID linked to an active Equipo member. A directory entry alone grants no access; the kit shows the server's refusal.

Implementation

RastrilloApple was initially pinned to Docs' 1e36aac95ed252848722926efc8ba8f9dc803216. The current pin is a18c32b3584ab5cadb8327f8f52a6186721f58dd; see the kit update below. The kit selects an identity/team and mints its session. Equipo posts the session cookie, same-origin header, a fresh Curve25519 signing public key and device label to the native device endpoint. It persists the returned bearer and key in DeviceAccounts, as pairing does. Engine requests remain device bearers.

Optional account metadata binds a saved device to its identity, team and the hash of its source session. Existing account JSON still decodes. Renewal updates the current EquipoSession without discarding its conversation or pending writes. The kit renews on foreground and a 24-hour clock; an updated session registers a replacement device and retires the previous device best effort. HTTP 401/403 and rejected event streams re-mint and retry once, retaining the original request body, revision and idempotency key. A definite permission refusal remains a 403 after the retry. Re-mints are coalesced and limited to once a minute. Late answers after leaving cannot restore an account.

Both entitlement files retain the old default Keychain group first, 9U4A84C4WK.works.oficina.equipo, followed by the shared identity group. They add the platform's App Group and webcredentials association and retain push entitlements. The new signing check verifies the old default group.

Mac packaging already delegates to the kit's bundler, which at the pinned revision supports both --provisioning-profile and --entitlements, embeds the profile before signing and strips restricted grants from ad hoc development builds. The wrapper now documents these options; the gate exercises profile embedding and ad hoc behavior with dummy bytes and mocked signing. The existing configuration retains the private profile path. No profile is copied into this repository and verification does not read it or invoke a signing identity.

Verification

Tests use FakeOficinaIDService, in-memory identity/device stores and ScriptedTransport. No test uses a real identity or Keychain. The initial suite failed on the absent adoption; additional failing tests exposed native-device rejection, cold-launch orphan cleanup, recovery after a Home outage and starting the conversation when sign-in completes in an already active scene. A final regression test distinguishes definite permission refusals from renewal outages.

The native gate is native/scripts/check-native.sh: signing contract, API fixtures, strings, web parity, reference scan, Swift tests, Mac build and an unsigned iOS Simulator build. The initial gate passed 114 Swift tests, including 20 Oficina ID adoption tests. All 28 deliberate mutations below failed their selected check; each change was restored before the final gate. Two initially surviving mutations led to stronger assertions for local credential removal and absence of fallback Home requests.

Live loopback check:

CGO_ENABLED=0 go test ./internal/plan3test -run '^TestPersonAPINativeLiveExchange$' -count=1

Passed. The existing test runs fake Home and the production Equipo router on loopback listeners, exchanges an assertion, registers a device, checks the session/device expiry match and reads the engine snapshot with the bearer. The Swift integration suite tests the app side separately with the kit fake; this was not a signed app or passkey UI smoke test.

Copy reviewed by Luna

Five new English strings; existing Equipo strings are unchanged:

| Key | Text | | --- | --- | | oficina.sign_in | Sign in with Oficina ID | | oficina.connecting | Connecting to your team | | oficina.device_failed | Could not connect to this team. | | oficina.retry | Connect again | | oficina.current_team | Current team |

The onboarding, Other ways to sign in, Use another Oficina ID, identity/team rows, replacement confirmation and identity-labelled Sign out reuse the kit's copy. Both existing string catalogs are generated from the English source; string and web-parity checks pass. Luna reviewed all five strings; her three edits are applied exactly. Her brief and result are copied below.

Controller follow-up

Review the branch. The five strings have Luna's delegated approval. Signed-device/shared-Keychain and Developer ID launch checks remain with the controller: this task does not change profiles, identities, App Store Connect or Keychains. Nothing is merged, deployed or uploaded.

Deliberate mutations

Each Swift mutation ran swift test --package-path native/apple --filter with its protecting test, observing an assertion failure (not a compiler failure). The signing mutations ran python3 native/scripts/check-oficina-id.py. Kit mutations used a temporary module copy because SwiftPM's checkout is read-only.

| Guard broken | Protecting check | | --- | --- | | Same-origin header | firstAppShowsWelcomeThenKeepsDeviceAndFreshKey | | Cookie restricted to device registration | onlyDeviceRegistrationMaySendTheSessionCookie | | Submitted public key matches fresh stored key | firstAppShowsWelcomeThenKeepsDeviceAndFreshKey | | Device persisted before adoption | firstAppShowsWelcomeThenKeepsDeviceAndFreshKey | | Directory filtered for Equipo | oneIdentityGoesStraightInAndSeveralTeamsOrNoneUseKit | | Credential bound to its source session | renewsAfter24HoursWithoutReplacingConversationSession | | Late device response refused after sign-out | lateRegistrationCannotRestoreSignedOutDevice | | Orphaned credential removed on cold launch | nativeCredentialWhoseIdentityWasRemovedCannotSurviveRelaunch | | Old paired account restored | oldSavedPairingStillLoadsWithoutOficinaID | | Re-mint rate limited | repeatedRejectionsAreRateLimitedAndKeepConversation | | Device endpoint refusal re-mints | deviceEndpointRejectionRemintsTheKitSession | | Engine 403 re-mints | rejectionsRemintOnceAndRetryWithTheNewBearer | | Retry uses replacement bearer | rejectionsRemintOnceAndRetryWithTheNewBearer | | Clock waits 24 hours | dailyTimerRenewsWhileAppStaysOpen | | Equipo device revoked | signOutStopsPushesAndRevokesThisDevice | | Notifications unregistered and badge cleared | signOutStopsPushesAndRevokesThisDevice | | Kit identity signs out | signOutStopsPushesAndRevokesThisDevice | | Unavailable team retried on foreground | foregroundRecoversAfterARejectedSessionMetAnOutage | | Shared sign-out leaves fallback pairing alone | sharedIdentityRemovalLeavesAnActiveFallbackPairingAlone | | Local device removed on sign-out | signOutStopsPushesAndRevokesThisDevice | | Fallback suppresses automatic Home requests | pairingFallbackSuspendsStraightInAndReturnResumesIt | | Old default Keychain group retained | Signing check | | Mac profile embedded | Signing check with dummy profile and mocked signing | | Ad hoc build strips restricted grants | Signing check with dummy profile and mocked signing | | Foreground sign-in starts conversation | signingInWhileAlreadyForegroundStartsTheConversation | | Push registrar detached on sign-out | signOutStopsPushesAndRevokesThisDevice | | Definite permission refusal remains a 403 | aDefinite403StaysARefusalAfterRemint | | Event-stream authentication re-mints | rejectedEventStreamRemintsAndPreservesCursor |

Independent review fixes

Astra requested changes at 7f4e1006: a snapshot released after sign-out could save the departed account's bearer and private key while updating its team name; a failed re-mint could leave the kit unavailable with no error string and hence no recovery notice.

The three new regression tests first failed with six assertions. The snapshot was held until after sign-out, then released: the old session became ready and saved its credential again. A held renewal plus a queued session update also restored metadata. The unavailable test reproduced an engine 401 followed by Home offline, with both error strings nil and no notice.

Departing sessions now become permanently invalid before they are released. Snapshot completion, direct metadata application and renewal all respect that invalidation. Sign-out, replacement, pairing fallback and session expiry use the same invalidation. Native device registration retains its existing epoch/state check before persistence, tested with a renewal response released after sign-out. Pairing sign-out forgets its credential before network cleanup, so a late revocation cannot remove a newly saved credential at the same origin. Push cleanup remains in place.

The mounted conversation explicitly shows the kit's unavailable title when the kit is unavailable, even without error strings. Its Connect again button retries the kit and refreshes the conversation. Recovery removes the notice.

Regression commands:

swift test --package-path native/apple --filter 'OficinaIDTests/(lateSnapshot|lateRenewal|unavailableRenewal)'
swift test --package-path native/apple --filter OficinaIDTests

First command before fixes: three tests failed, six assertions. The mutation checks remove one guard at a time and run its selected test, requiring an assertion failure rather than a compiler error; every mutation is restored.

| Guard broken | Regression test | | --- | --- | | Invalidate departing session | lateSnapshotCannotRestoreSignedOutDevice | | Ignore late snapshot completion | lateSnapshotCannotRestoreSignedOutDevice | | Ignore direct metadata on invalid session | lateRenewalCannotRestoreSignedOutDevice | | Refuse renewal of invalid session | lateRenewalCannotRestoreSignedOutDevice | | Reject native device response from departed epoch | lateRenewalCannotRestoreSignedOutDevice | | Show unavailable notice without an error | unavailableRenewalShowsRecoveryWithoutAnErrorString | | Invalidate when switching to pairing | departingSessionCannotPersistAfterItsReplacement | | Invalidate when replacing team | departingSessionCannotPersistAfterItsReplacement | | Forget paired credential before revocation awaits | latePairingRevocationCannotRemoveANewCredential |

The review gate passed native/scripts/check-native.sh: 119 Swift tests in 14 suites (25 Oficina ID tests), Mac build, unsigned iOS Simulator build, 7 fixtures, 169 strings, 23 parity entries and a clean reference scan. All nine review mutations above failed their intended assertion and were restored. The loopback native exchange test also passed again. Logs are under the ignored native/build/logs directory: review-red.log, review-mutations, review-native-gate.log and review-loopback.log.

Luna's brief and verdict

The controller supplied this review from gpt-5.6-luna, with Paul's instruction to apply the verdicts as approved copy. Source: the controller's luna-oid brief and result, copied verbatim below. All three changes are applied in strings.json and both generated catalogs. None has a web parity mapping.

Brief

Copy review brief: Equipo's apps sign in with Oficina ID (native, 2026-11-20)

Paul delegates copy review for this work to you. You are the copy editor. Your edits will be applied as approved copy.

Context

Equipo is Oficina's team app, on iPhone and Mac. It now signs in with Oficina ID, the one account behind every Oficina app. It uses a shared sign-in kit whose own screens (Welcome, "Sign in with a passkey", email and code, choosing a team, "Other ways to sign in…", "Sign out", "Try again") are reviewed already and are not yours to change. The strings below are Equipo's own and appear next to the kit's. With an Oficina ID already on the device, the app goes straight in. The person never types anything. "Other ways to sign in…" opens the older pairing (type the team's address, approve a code in the browser).

The strings (ids are fixed, text is yours to change)

  • oficina.sign_in: a button at the bottom of the pairing screen, which takes the person back to signing in with Oficina ID. Draft: Sign in with Oficina ID
  • oficina.connecting: the label of a spinner, shown after Oficina ID has signed the person in while the app gets its own access to the chosen team (normally a second or less). Draft: Signing in to your team
  • oficina.device_failed: an error shown on that same screen when the app could not get access to the team (network or server failure). Below it are a retry button, "Other ways to sign in…" and "Sign out". Draft: Could not sign in to this team. Try again.
  • oficina.retry: the retry button under that error. Draft: Try again. The kit already has a "Try again" string of its own.
  • oficina.current_team: the accessibility label (VoiceOver) of a checkmark next to the team the app is using, in the account menu's list of teams. Draft: Current team

House rules (Paul's, all binding)

  • No em dashes, ever. No exclamation marks.
  • Plain words. No jargon a reader would not know. Short. Sentence case.
  • Say what happened and what to do.
  • Use the product names exactly: Oficina ID, Equipo.
  • Do not change the facts. If something looks wrong, flag it.

Output

  1. A table of every string: id | current | new (or "unchanged") | why.
  2. A list of flagged rows: id | problem.
  3. One line of counts: changed, flagged, left alone.

Verdict

| id | current | new | why | |---|---|---|---| | oficina.sign_in | Sign in with Oficina ID | unchanged | Clear and accurate. | | oficina.connecting | Signing in to your team | Connecting to your team | Oficina ID has already signed the person in. | | 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. | | oficina.retry | Try again | Connect again | Avoids repeating the sign-in kit's “Try again” label. | | oficina.current_team | Current team | unchanged | Clear accessibility label. |

Flagged rows:

| id | problem | |---|---| | oficina.connecting | “Signing in” suggests the person is signing in again. | | oficina.device_failed | “Sign in” describes the wrong failure, and the sentence duplicates the retry button. | | oficina.retry | Duplicates the sign-in kit's “Try again” label. |

Changed: 3. Flagged: 3. Left alone: 2.

Shared sign-in lifetime review

Astra's re-review of f90cf412 found two further crossings of the sign-in boundary: cancelled pairing could persist a late exchange or /me answer, and a departed card-answer retry could borrow the bearer of a later sign-in to the same identity and team.

Before implementation, the new reproductions failed with 19 assertions across two tests (the pairing test has four cases: exchange or /me, each with and without signing out after switching to Oficina ID). The persistence source check also failed because there was no common guarded commit boundary.

SignInLifetime now represents authority for one sign-in. SignInLifetimes is shared through DeviceAccounts by pairing, Oficina ID and the app model. Beginning another sign-in ends the previous token. Pairing captures its token synchronously when Start is tapped, before scheduling its task. An approved pairing hands that same token to the conversation. Native renewal retains its token; identity/team/origin changes, cancellation, replacement and sign-out end it. A token cannot be reactivated.

Every Equipo-owned write of a device, private key, account index or sign-in route goes through DeviceAccounts.commit. The raw store is private. Commit requires the captured token to be both active and the current token. Its check and writes are synchronous on MainActor. Removal also matches the saved private key, so cleanup cannot remove another sign-in's saved account at the same origin. The pinned kit continues to own its shared identity store and its own epoch checks; Equipo does not write that store directly.

Bound async flows:

  • Pairing start, challenge retries, exchange polling, credential persistence, authenticated /me, and metadata persistence.
  • Native startup/restore, selection callbacks, Home renewal, rejection recovery, native device registration and credential installation.
  • Snapshot/task/Needs you refresh, metadata persistence, stream setup and consumption, reconnects and queued refreshes.
  • Message and thread sends, waiting-message delivery, card answers, Set aside and Undo retries, and turn cancellation.
  • Retained clients and credential providers. Both the transport and its provider capture the original token; matching the same identity/team after another sign-in cannot authorize them.
  • Session renewal/adoption, foreground continuation and push attachment. Push registration passes also retain the lifetime alongside their existing generation check. A queued old attachment cannot replace the new session.

A scene's daily clock is an app-level scheduler: each renewal it starts captures the then-current token, while an already running renewal retains its original token. Old registration/renewal tasks cannot clear a newer task's coalescing slot because those slots have distinct task IDs.

Late pairing exchanges and native device mints are decoded so their abandoned credentials can be revoked best effort. Revocation is the sole network cleanup allowed after a lifetime ends: DeviceRevocation uses only the abandoned credential, never a current credential provider, and never persists anything. Cancelling after a pairing credential arrived also schedules revocation at once.

Additional regressions cover cancellation without a replacement sign-in, ended/foreign persistence tokens, late transport responses and later requests, both write retry loops stopping without a sleep, a retained provider refusing a later sign-in's bearer, late push attachment, and abandoned native revocation. check-sign-in-lifetime.py is part of the native gate. It rejects raw store or Keychain writes outside the approved boundary and rejects an unguarded commit.

Mutation commands use swift test --package-path native/apple --filter with the listed regression, or python3 native/scripts/check-sign-in-lifetime.py. Each mutation must produce an assertion failure, not a compiler error, and is restored before the gate:

| Mutation | Regression | | --- | --- | | Pairing cancellation leaves token active | cancellingPairingAloneEndsItsLifetime | | New lifetime leaves previous token active | endedTransportRefusesLateResponsesAndNewRequests | | Commit skips lifetime validation | endedOrForeignLifetimesCannotPersistAnything | | Provider ignores captured lifetime | departedWriteCannotRetryWithALaterSignInsBearer | | Answer/visibility retries ignore ended lifetime | endedWriteLoopsDoNotWaitOrRetry | | Abandoned pairing is not revoked | cancelledPairingCannotOverwriteNativeSignIn | | Abandoned native device is not revoked | lateRenewalCannotRestoreSignedOutDevice | | Push attach accepts an ended lifetime | lateAttachCannotReplaceTheNextSignIn | | Transport ignores lifetime | endedTransportRefusesLateResponsesAndNewRequests | | Source has unguarded commit | check-sign-in-lifetime.py | | Source adds raw secret-store write | check-sign-in-lifetime.py | | Source adds another writer inside DeviceAccounts | check-sign-in-lifetime.py | | Native sign-out leaves onboarding token active | signOutBeforeRegistrationEndsThePendingLifetime | | App sign-out leaves onboarding token active | signOutBeforeRegistrationEndsThePendingLifetime | | Session removal ends the gate before forgetting | signingOutAfterTheSessionEndsStillForgetsItsCredential |

The early sign-out regression first failed at both entry points, then passed. Cancellation-alone also tests signing out while pairing is pending, ensuring its staged key is removed before the token ends. All fifteen deliberate mutations failed their assertions and were restored. Evidence is in the ignored native/build/logs/lifetime-* logs, including the two mutation result files.

No user-facing strings changed in this review. Luna's approved copy above is unchanged. Signed-device and shared-Keychain launch checks remain with the controller; this work does not touch actual profiles, identities or Keychains.

The final audit also reproduced sign-out after session removal: ending the token before forgetting could correctly reject the later cleanup write. Session removal, account switching and pairing fallback now forget through the still-valid token, then end it. Terminal engine authentication failure likewise removes its saved credential before invalidation. No stale-token exception was added to commit.

Final lifetime gate: native/scripts/check-native.sh passed with 128 tests in 15 Swift suites, both native builds, the lifetime persistence scan, 7 fixtures, 169 strings, 23 parity entries and a clean reference scan. The loopback native exchange test passed again. The existing push sign-out regression also passes: notification cleanup still runs when sessionEnded is called with no session, while a nested coordinator callback is handled only once.

Shared kit stale-grant fix

Both Package.swift and Package.resolved now pin rastrillo/native main at a18c32b3584ab5cadb8327f8f52a6186721f58dd, as supplied by the controller. The kit binds grant-ended handling to its epoch and the grant and stamps identity items with their grant ID, protecting a newer sign-in from a stale refreshTeams response. No shared-kit source was changed in this worktree.

Equipo has no custom OficinaSecureStore conformances or wrappers. Its sign-in tests use the kit's OficinaMemoryStore directly; the pinned implementation supports tagged and referenced conditional writes. No adapter changes are needed. The existing Equipo lifetime regressions remain in place; no additional Equipo regression or guard was introduced in this dependency-only update. No user-facing strings changed.

Validation: native/scripts/check-native.sh passed at this pin: 128 Swift tests in 15 suites, Mac build, unsigned iOS Simulator build, lifetime persistence scan, old-default-Keychain-group and profile-embedding checks, 7 fixtures, 169 strings, 23 parity entries and the reference scan (2527 files, 2846 matches, 0 failures). Evidence: native/build/logs/kit-pin-native-gate.log.

Fable final-review follow-up

The first two P3 findings are fixed. Leaving Oficina sign-in now removes every saved DeviceAccount with an oficinaIdentity and best-effort revokes each bearer, even before the bridge synchronizes or the kit loads an identity. Pairing-made accounts remain saved. The bridge observes the kit identity during onboarding, so confirmed Use another also performs this cleanup from Continue as and unavailable. Cleanup tasks retain earlier revocations when a second leave has nothing left to remove. All persistence still uses the lifetime-guarded commit.

The app distinguishes the kit leaving from the server ending a session. A local sign-out or confirmed identity replacement clears endedTeam. A server-ended session retains the existing team notice when pairing opens. Push cleanup and lifetime invalidation still run in both cases. No strings changed.

Tests were added before the fixes. Running swift test --package-path native/apple --filter 'leavingBeforeBridgeSynchronizes|onlyServerSessionEnd|permissionRefusalDuringHomeOutage' failed with 28 assertions: all eight combinations of Continue as/unavailable and app sign-out/bridge sign-out/replacement/pairing, the three deliberate-leave notice cases, and the lost kit session. The tests also retain a pairing-made account and require revocation of both native accounts, including another identity. A further three-case regression covers leaving before any identity has loaded. Evidence: native/build/logs/fable-p3-red.log, fable-p3-green.log and fable-p3-boundaries.log in the same log directory.

Remaining kit limitation: 403 during Home outage

The third P3 is reproduced but cannot be safely fixed through the current kit API. At the pinned revision, OficinaIDModel.sessionRejected deletes the stored session before calling open. open can fall back during an outage only to the stored session it reads, which has already been deleted. renewIfNeeded retains sessions on outage but refuses to mint until the stored session is 24 hours old. choose/retry reuse a fresh session, so they cannot force a re-mint for a possibly stale 403. Equipo must not manufacture kit timestamps or restore session records outside the kit's grant/epoch guards.

No kit source, pin or 403 behavior was changed. The needed kit change is an API for forced renewal that preserves a still-usable session until a replacement is available, or until authoritative evidence says the session/grant has ended. The controller must arrange that shared-kit change before this third finding can be closed.

permissionRefusalDuringHomeOutageKeepsTheKitSession remains an executable reproduction using FakeOficinaIDService and ScriptedTransport. Only its missing stored-session assertion is marked with Swift Testing's withKnownIssue; it reports one known issue and fails on unexpected success when the kit is fixed. The surrounding assertions still require the actual 403 and the mounted conversation. This is documented outstanding work, not a fixed or mutation-checked guard. The initial unmarked assertion failure is recorded in the red log.

Eight deliberate mutations were caught by assertion failures, then restored:

| Mutation | Regression | | --- | --- | | Remove only the tracked identity's accounts | leavingBeforeBridgeSynchronizesForgetsEveryNativeAccount | | Stop observing identity before synchronization | leavingBeforeBridgeSynchronizesForgetsEveryNativeAccount | | Gate bridge sign-out on a loaded identity | leavingBeforeIdentityLoadsForgetsTheSavedBearer | | Gate pairing fallback cleanup on a loaded identity | leavingBeforeIdentityLoadsForgetsTheSavedBearer | | Route app sign-out away from the bridge before identity loads | leavingBeforeIdentityLoadsForgetsTheSavedBearer | | Skip saved native bearer revocation | leavingBeforeBridgeSynchronizesForgetsEveryNativeAccount | | Report kit leave as server-ended | onlyServerSessionEndShowsTheEndedTeamNotice | | Clear the notice for a real server-ended session | onlyServerSessionEndShowsTheEndedTeamNotice |

Each mutation ran swift test --package-path native/apple --filter with the listed regression. All eight returned an assertion failure, not a build failure. Evidence: native/build/logs/fable-p3-mutations/results.json and its sibling logs.

Final native gate: native/scripts/check-native.sh passed with 132 tests in 15 suites and the one explicitly recorded kit issue described above. The Mac and unsigned iOS Simulator builds, lifetime persistence scan, old default Keychain group and profile checks, 7 fixtures, 169 strings, 23 parity entries and reference scan all passed. Evidence: native/build/logs/fable-p3-native-gate.log. The original fifteen lifetime mutations and regressions remain in place. No actual Keychain, provisioning profile or signing identity was changed.