Last updated: 2026-11-18
App Attest shadow collection records stable machine identities, fleet adoption, submitted proofs and receipts alongside legacy verification. Shadow alone changes no routing, rewards or trust. The separately enabled provider authorization path uses qualified evidence for serving and rewards; App Attest is the only verification path. DeviceCheck's separate two-bit API remains deferred.
Current backend behavior is owned by the platform's default branch: App Attest and serving authorization. Immutable backend links below preserve revision-specific source evidence, not current policy. Backend inventory, archive, receipt and dashboard implementation remain external; local worker and endpoint-resumption behavior is described below.
Clients advertise register.app_attest_protocol = 3, and the coordinator serves only protocol 3. It was introduced in 0.9.4 together with the callback-timer fix and first shipped in 0.9.5 (0.9.4 was never released); protocol 2 shipped only in 0.9.3 and protocol 1 was never released. A registration announcing protocol 1 or 2 receives no frames and is observed as rollout / provider_upgrade_required, so stragglers stay visible. Older providers announce no protocol and receive no unknown frames. A coordinator predating version 3 may ignore the new capability while continuing legacy serving. The registration capability is preserved by both Swift encoders, including encodeRegisterPreservingRawAttestation.
The shadow session uses the registry's validated endpoint key, never the original registration field. It requires a canonical 44-character base64 encoding of 32 bytes, rejecting missing/invalid keys and encodings padded with CR/LF before enrollment. Machine inventory remains independent of that readiness check. Code: coordinator/appattest/service/session.go.
Frames use type = "app_attest_shadow" and nested payload. Every request has a random session and expected environment, and carries protocol_version 3 and an opaque authenticated-account scope.
| Direction | Action | Behavior |
|---|---|---|
| Coordinator → app | prepare |
Check OS, bundle, signed entitlements, Apple API, and Keychain; load or generate the account-scoped credential. |
| App → coordinator | ready |
Report support/error and key ID. This is not cryptographic proof. |
| Coordinator → app | attest |
Persist the enrollment transaction before sending the challenge for an unknown key. |
| App → coordinator | attestation |
Return complete base64 CBOR and locally derived status. A cached unacknowledged proof also includes its original enrollment_session. |
| Coordinator → app | assert |
Sent only after durable enrollment acceptance. The challenge is encrypted to the actual registered X25519 endpoint. This is the implicit enrollment acknowledgement. |
| App → coordinator | assertion |
Decrypt using the app's own key, sign the transcript, and return the complete assertion and status. |
Code: coordinator/protocol/app_attest_shadow.go, coordinator/protocol/app_attest_status.go, and provider-swift/Sources/ProviderAppAttest/ShadowProtocol.swift.
Error replies may include optional apple_error diagnostics with domain, signed 32-bit code, and an optional paired underlying_domain / underlying_code. Domains are the closed buckets devicecheck, osstatus, url, cocoa, and other. The coordinator validates the bounds before admission, retains valid details in the evidence context and error event, and never uses them as proof or metric-tag cardinality. Native descriptions, arbitrary domains and NSError.userInfo are excluded. Older peers may omit or ignore this additive field. Code: coordinator/protocol/app_attest_error.go (AppAttestAppleError.Valid), provider-swift/Sources/ProviderAppAttest/AppAttestAppleError.swift.
Failed ready replies may also carry a closed availability_reason: os_below_27, not_app_bundle, signing_info_unavailable, opt_in_missing, environment_entitlement_invalid, environment_mismatch, or is_supported_false. A synthetic apple_error with no native NSError may carry apple_error_source as callback_without_nserror or proof_oversize. These fields are client-reported diagnostics only, not part of the signed transcript or authorization policy. The coordinator rejects unknown values before storage and retains valid values in private evidence and failure events. No bundle path, entitlement value, native description or NSError.userInfo crosses the wire. Code: coordinator/protocol/app_attest_client_diagnostic.go (ValidClientDiagnostics), provider-swift/Sources/ProviderAppAttest/AppleAppAttestService.swift (checkAvailability), and AppAttestCallbacks.swift (failure).
Provider ready replies, successful or failed, may carry three optional runtime diagnostics: launch_session (gui, background, or unknown), boot_time (Unix seconds from kern.boottime), and operation_stalled_seconds (1–86400, only with result busy). They are not part of the signed transcript. Admission strips any invalid, out-of-range or misplaced value (including boot_time before 2020 or more than one day ahead of the coordinator clock); a stripped value never drops the frame, counts as a refused input, or fences a lease. Valid values appear in the shadow observation event and in every evidence context archived later in the same attempt. Code: coordinator/protocol/app_attest_runtime_diagnostic.go (SanitizeRuntimeDiagnostics, RuntimeDiagnosticFields) and coordinator/appattest/service/session.go (offer).
The transcript encodes UTF-8 fields preceded by four-byte big-endian byte lengths, then SHA-256 the result: domain darkbloom.app-attest.shadow.v3, action, session, environment, key ID, plaintext challenge, the app-owned X25519 public key, account scope, OS version, OS build, app version, chip and binary hash, then machine model, physical RAM in GiB, total/performance/efficiency CPU cores and GPU cores as canonical decimal strings, followed by the app’s existing attestation public key (AppAttestShadowHashV3, coordinator/protocol/app_attest_hardware.go). Go and Swift tests pin the same vector. The coordinator compares these signed app measurements against the registration.
The app derives status locally. The server never supplies a replacement endpoint key or arbitrary status to sign. Assertion-bound status is authenticated app reporting; it is not an independent Apple certification of the OS version, chip, or binary hash. The prospective policy requires the current Apple launch category and a type-2 CodeDirectory measurement, an active catalog match and separately qualified binary/code-hash pair. The signed 20-byte form must uniquely bind to the same durable qualified artifact's full 32-byte hash; the full 32-byte wire form matches directly. Missing assertion metadata never falls back to enrollment metadata or an app-reported version.
Optional deep diagnostics explain failures that the closed error labels cannot: whether the provider runs outside a GUI session or under changed boot security, whether a key died across a reboot or a process restart, whether accepted APNs pushes reached the Mac and were answered, and what the native error chain underneath a DeviceCheck failure was. Every member is a closed enum, bounded integer, boolean or short version string; none is part of the signed transcript or any authorization, rotation or backoff decision. Admission (SanitizeRuntimeDiagnostics) strips each member independently: an out-of-range, unknown, mistyped (wrong JSON type) or misplaced value is removed and never drops the frame, counts as a refused input or fences a lease. A nested object whose members are all stripped is removed. Valid values appear in the shadow observation event (stored and emitted like the other event fields, see Dashboard and telemetry evidence) and in the evidence context of the same exchange; ready members are carried through the attempt into later attestation/assertion events and evidence contexts. They never become metric tags or public API fields. Older coordinators ignore these fields; older providers never send them. Code: coordinator/protocol/app_attest_deep_diagnostic.go, coordinator/internal/appattest/diagnostics/lifecycle.go.
Provider-side computation is summarised in the Source column; a member is omitted whenever the provider cannot compute it. key_history is sent only when App Attest availability passed (availability failures never read Keychain) and describes the account key for this ready.
Local daemon history is refreshed after every attestation/assertion exchange, not only prepare. Its local-only keyHistoryObservedAt anchors relative key ages; doctor and explicit reports advance known ages to display time without changing when the other fields were observed. Older snapshots use observedAt as the age anchor. This does not add history to proof wire replies: automatic key_history remains a ready snapshot.
| Field | Type and bounds | Sent on | Source (provider) | Answers |
|---|---|---|---|---|
process_started_at |
int64 Unix seconds, 2020-01-01 to coordinator now + 1 day | ready |
Kernel start time of this process (proc_pidinfo pbi_start_tvsec); an in-place exec (a self-update of a provider that launchd does not run) keeps it |
With boot_time, whether a key died across a reboot or a process restart. |
previous_exit |
clean, unclean, unknown |
ready |
Local marker provider-run.json beside daemon-state.json (0600): written running once the serve process holds the single-instance lock, clean after the drain (SIGTERM, CLI stop/restart, schedule end) or right before an update/stall-restart relaunch. Next start: running → unclean (crash, SIGKILL/jetsam, power loss, reboot without drain), clean → clean, missing/unreadable → unknown. A run is identified by the kernel's microsecond start time, so a replacement started within the same second is a new run, while an in-place exec keeps its earlier answer |
Whether a clean shutdown preceded a key failure. |
start_reason |
launchd, watchdog, update, stall_restart, manual, unknown |
ready |
First match wins; "recent" is a timestamp from 120 s before process start up to classification time (so evidence written after start, e.g. across an in-place exec, counts): stall_restart (recent App Attest restart marker, written by the stall restart and by the is_supported_false restart, or a recorded relaunch of either), watchdog (recent watchdog last_restart_at), update (version differs within the exact same kernel process identity, or recent recorded update relaunch), manual (recent CLI lifecycle stop, or not started by launchd), launchd (XPC_SERVICE_NAME is the provider LaunchAgent label: login/boot/kickstart) |
Why this process started. |
console_user_active |
bool | ready |
SCDynamicStoreCopyConsoleUser returns a user other than loginwindow/root/_mbsetupuser (doctor's console-session rule); false when nobody is logged in or the store is unavailable. The name is never sent |
With launch_session = background: a user is logged in but the provider runs outside that session. |
sip_enabled |
bool | ready |
SIP is at Apple's default configuration: the kernel's csr_get_active_config value is 0 (SIPConfigurationReader); when that cannot be read, csrutil status (SIPStatusChecker) reports SIP fully enabled. false = any CSR_ALLOW_* bit set (a custom configuration, or disabled); omitted only when neither reading is available. Probed once per process. From 0.10.15 (with the blob's SIPEnabled): a Mac with only authenticated root off reads false, where earlier versions said true, so compare versions with care |
Whether boot-security changes line up with isSupported == false. |
authenticated_root |
bool | ready |
checkAuthenticatedRootEnabled (csrutil authenticated-root status, then diskutil info / Sealed); true only on a positive result; omitted when neither command ran. Once per process |
As above, for the sealed system volume. |
preflight.opt_in_entitlement |
bool | ready |
Running code's signing entitlements (SecCodeCopySigningInformation, as checkAvailability) grant com.apple.developer.devicecheck.app-attest-opt-in = CDhash (string or array) |
Signing/entitlement problems behind isSupported == false or invalidKey. |
preflight.environment_entitlement |
production, development, absent, invalid |
ready |
com.apple.developer.devicecheck.appattest-environment; missing → absent, other value/type → invalid. Both entitlement members are omitted when signing info is unavailable |
As above. |
preflight.profile_present |
bool | ready |
<bundle>/Contents/embedded.provisionprofile exists and is readable |
Missing provisioning profile. |
preflight.profile_expired |
bool | ready |
Profile ExpirationDate (decoded locally with the Security CMS decoder) < now; omitted without a decodable profile |
Expired provisioning profile. |
preflight.bundle_path_class |
user_install, applications, other |
ready |
Running bundle path with symlinks resolved: under ~/.darkbloom → user_install; /Applications or ~/Applications → applications; else other. Never the path |
Whether an unusual install location correlates with failures. |
key_history.generations_last_24h |
int 0–100 | ready |
generateKey attempts in the trailing 24 h, recorded when the hourly budget is consumed (before the Apple call). Rolling list of the last 125 attempts shared across account scopes per coordinator + environment; covers the saturated hourly budget across 24 h, with the wire count capped at 100 |
Repeated fresh-key churn (e.g. every new key failing with invalidKey). |
key_history.last_generation_age_seconds |
int 0–315360000 (10 years) | ready |
now − latest generation attempt | As above. |
key_history.last_success_age_seconds |
int 0–315360000 | ready |
now − last successful attestKey or generateAssertion with the current key |
How long the key has been failing. |
key_history.consecutive_assertion_failures |
int 0–1000 | ready |
generateAssertion calls on the current key that failed inside the Apple call (error, callback without NSError, or deadline) since its last success; reset on success and for a new key; capped at 1000. 0 for keys generated by this build; omitted for keys from older providers until their first counted failure or success |
How persistently assertions fail. Timeouts and serverUnavailable count too; the rotation rule and doctor's dead-key verdict use the error class instead. |
key_history.key_age_seconds |
int 0–315360000 | ready |
now − the pre-generateKey creation marker |
Age of the current key. |
key_history.created_boot_matches |
bool | ready |
kern.boottime recorded at key creation equals the current one (±60 s for clock steps) |
Whether the key survived a reboot. |
key_history.created_app_version |
≤ 32 chars matching ^[0-9A-Za-z.+-]+$ |
ready |
Provider version (status.app_version) when the key was generated |
Which release created keys that later die. No key ID is ever sent. |
push_history.device_token_present |
bool | ready |
The APNs bridge holds a device token when ready is built; never the token |
Whether a push could be addressed at all. |
push_history.pushes_received_last_24h |
int 0–1000 | ready |
APNs pushes delivered to the app delegate in the trailing 24 h, recorded on arrival before parsing. Rolling 2,048-timestamp file apns-push-history.json beside daemon-state.json (0600; no tokens, nonces or payloads), covering earlier connections and processes and more than a day at the 75-second alert cadence plus token-rotation resets; wire count saturates at 1,000 |
Compare unsaturated counts with code_attest.push sent_ok for the same machine and snapshot window; a count of 1,000 means at least 1,000 arrivals, and a missing/older history file cannot establish a delivery gap. |
push_history.last_push_received_age_seconds |
int 0–315360000 | ready |
now − latest receipt; omitted without a timestamp or when it is in the future | When a push last arrived. |
push_history.last_reply_sent_age_seconds |
int 0–315360000 | ready |
now − last code_attestation_response sent for an APNs-delivered challenge (recorded only after a successful WebSocket transport write; this is not a coordinator acknowledgement, and WebSocket resume-challenge replies are not counted); omitted as above |
A push received after the last reply: it arrived but was not answered; compare with code_attest.push_reply. |
native_error_chain |
array of at most 4 {domain, code}; domain ∈ devicecheck, osstatus, url, cocoa, cryptotokenkit, aks, other; code signed 32-bit |
failed attestation/assertion with result apple_error or apple_invalid_key |
Entry 0 is the top-level DeviceCheck callback NSError, then NSUnderlyingErrorKey recursively; an entry whose userInfo has an AKSError number is followed by an extra aks entry. Domains: DCErrorDomain → devicecheck, NSOSStatusErrorDomain → osstatus, NSURLErrorDomain → url, NSCocoaErrorDomain → cocoa, CryptoTokenKit → cryptotokenkit, else other. A code outside int32 that fits in 32 bits is sent as its signed bit pattern; otherwise that entry is dropped. No descriptions or userInfo |
What sits under a DeviceCheck code 0/3, e.g. CryptoTokenKit −3 over AKS 0xe007c013. The coordinator strips the whole chain if any entry is invalid. |
The coordinator derives two optional booleans before each proof archive by comparing the current provider timestamps with provider timestamps in the newest verified assertion's context. It never compares them with the coordinator's clock, UpdatedAt, or key-insertion time. rebooted_since_last_success detects a boot-time difference greater than 60 seconds in either direction; process_restarted_since_last_success detects a different process-start timestamp. The read projects only these timestamps from the latest AppAttestDiagnosticLookback (100) evidence rows for that key and has a 100 ms budget under separate, single-query nonblocking admission before acquiring a proof storage permit. A busy diagnostic lane skips the lookup. A missing/invalid member, absent verified baseline in that window, unsupported store capability or failed read omits the corresponding flag; a newer verified legacy assertion never falls back to older context. Subsequent verified assertions advance the baseline without another prepare. Static provider/coordinator clock skew cannot create a transition, but a Mac wall-clock adjustment larger than the boot tolerance can resemble a reboot; these remain untrusted diagnostics. Code: coordinator/internal/appattest/diagnostics/lifecycle.go (Derive); coordinator/store/app_attest_archive.go (AppAttestDiagnosticStore).
The verifier revision is mac-shadow-v7. Production macOS 27 attestations and
assertions can contain a complete CDhash extension map while the ED flag is
clear. coordinator/internal/appattest/proof/authenticator.go (authData) accepts only the
fully decoded Developer ID category 6, type-2 32-byte or 20-byte SHA-256
CodeDirectory measurement on an unflagged assertion. The 20-byte form is a
truncated CandidateCDHash, not a full digest or independent build approval.
Verifier.Assertion in
coordinator/appattest/verify.go verifies the signature over all the
authenticator bytes first, then validates App ID and the increasing counter.
Enrollment separately verifies Apple's certificate chain, exact Mac ACL and
nonce. Missing or malformed measurements, duplicate/trailing CBOR and arbitrary
unflagged tails remain rejected. This compatibility rule does not itself grant
serving.
The Apple-callback restart policy below describes the default in-process provider path. The internal, default-off supervised worker candidate instead terminates and reaps its owned child before replacement, preserving the parent's memory-only endpoint key and existing credential budgets. It does not fall back to parent Apple calls or restart inference for a worker stall. The recorded native passes separate worker components, the loaded-engine callback scenario and Stage C resumption. They apply only to the tested signed artifacts, not later rebuilds or the remaining physical OS/update/reboot and fleet-rollout matrix. Implementation and transport tests alone are not Apple qualification. The separate endpoint-resumption protocol can avoid a new Apple call on same-process reconnect only with its platform counterpart. It does not extend the original assertion or proof deadlines. Backend policy changes and their canonical docs remain in sibling darkbloom-platform.
Backend scheduling entries below retain the cited revision's evidence. Current assertion cadence, recovery budgets and receipt policy are defined by platform controls, not the older ten-minute cadence or receipt-required basic grant below. The provider-local Apple callback, retry, key-budget and socket fences remain separate.
| Boundary | Behavior |
|---|---|
| Initial spread | Random 0–29 seconds after inventory is ready. |
| Shadow processing | One worker and two queued replies per connection; four verification operations and four shared session storage permits globally, including rejection and cleanup paths. |
| Protocol | 48 KiB frame, 32 KiB decoded proof; bounded CBOR and status fields. |
| Response/storage | 90-second response deadline for every stage (recovery.ResponseTimeout, coordinator/internal/appattest/recovery/exchange_timing.go), including attestation; two-second handling budget, with a separate two-second budget for deferred archive completion. Standalone events and enrollment writes each have a two-second storage timeout. |
| Assertions | Every ten minutes after success; a fresh encrypted challenge after reconnect or recovery. A definite Apple serverUnavailable assertion failure gets one same-key, same-client-hash retry after two seconds inside the current exchange, well within its 90-second deadline. Unknown, invalid-key and timed-out outcomes are not locally retried. A failed exchange immediately supersedes the last prospective verdict. |
| Session recovery | Generic or server-unavailable Apple API failures retry after one minute, then five minutes, then at most the normal ten-minute assertion interval. Other transient coordinator/storage failures retain the one-minute, five-minute, then hourly backoff. Every attempt gets a new session/nonce and reloads durable acceptance/counters. Successful assertions reset backoff. An Apple API error is an unknown prospective verdict and grants no permission; verified crypto/policy rejections remain terminal, and cancellation stops retries. Persistent generic errors still need native domain/code diagnostics from a signed upgraded client. Dead-key rotation and the invalid-key enrollment backoff replace this delay in their specific cases. Code: coordinator/internal/appattest/recovery/recovery_policy.go (ExchangeRetryDelay), coordinator/internal/appattest/recovery/driver.go (Driver.Run); session wiring in coordinator/appattest/service/retry.go (run). |
| First-risk-receipt wait | A valid first assertion with no verified risk receipt yet, including an initial renewal_required receipt, stays unknown. Without an existing authorization record, a fresh assertion retries after one minute, five minutes, then at the normal ten-minute cadence while Apple's receipt renewal runs independently. Only complete fresh evidence can authorize serving. Code: coordinator/appattest/service/authorization_identity.go and retry.go. |
| Apple callbacks | 25-second waiter deadline. The actual uncancellable Apple operation retains admission until its callback arrives; retries receive busy in the meantime. A token fences duplicate late callbacks from unlocking a newer operation. A pre-cancelled call does not acquire admission. The gate records when it was acquired: once held longer than AppleOperationStall.threshold (15 min), ready replies return busy with operation_stalled_seconds, and the provider restarts itself through the background-update path (update lease, drain, waitForSafeDisconnect, ProcessLifecycle.restartAfterUpdate) only when no inference is in flight or loading and no update or lifecycle drain is running, at most once per AppAttestStallRestartPolicy.minimumInterval (6 h, persisted in app-attest-stall-restart.json beside the daemon state file before the restart is issued). An attempt that drains but cannot restart reopens serving and waits before draining again in the same process: AppAttestStallRestartPolicy.drainRetryDelay (15 min) when accepted work or the coordinator's drain acknowledgement did not finish in time, and a full minimumInterval when the marker cannot be written, since no restart may be issued without it. After the drain, and after its last suspension point, it checks again (AppAttestStallRestartPolicy.afterDrain): if Apple's callback released the gate, or a CLI stop, OS termination or scheduled shutdown took over the drain, it releases the update lease without restarting, and a lifecycle-owned drain stays closed. Code: AppleOperationGate.swift, AppleAppAttestService.swift, AppleOperationStall.swift and AppAttestStallRestart.swift in provider-swift/Sources/ProviderAppAttest/; provider-swift/Sources/ProviderCore/ProviderLoop+AppAttestStall.swift. |
isSupported false after verification |
Before a ready answers is_supported_false, the provider re-registers its running bundle with macOS LaunchServices (LSRegisterURL) and asks Apple again: a self-update swaps Darkbloom.app in place, and DeviceCheck reports unsupported while LaunchServices still describes the previous bundle. Each AppleAppAttestService does this at most once (AppleAppAttestService.isSupportedRefreshingRegistration, provider-swift/Sources/ProviderAppAttest/AppAttestSupport.swift). A provider without an availability schedule keeps one service per process; a scheduled provider makes a new one for each availability window, so it can re-register once per window (ProviderLoop.handleAppAttestShadow in provider-swift/Sources/ProviderCore/ProviderLoop+AppAttestShadow.swift; Start.runScheduled in provider-swift/Sources/darkbloom/Start/StartCommand+Modes.swift). The updater also registers the new bundle right after the swap (SelfUpdater.commitStagedBundle). When a ready still answers is_supported_false (macOS 27 or later), the provider restarts once through launchd if all of these hold: the coordinator granted this Mac an App Attest authorization within AppAttestStallRestartPolicy.verifiedWithin (7 days) and after the last automatic App Attest restart (the time is kept in app-attest-verified.json beside the daemon state file, rewritten at most once per hour), so one unsupported episode gets one restart; the embedded provisioning profile has not expired; this is not a cluster member; and launchd runs this provider (ProcessLifecycle.RelaunchRoute: launchd's record of the loaded provider job names this exact process, which an in-place exec keeps). The live DCAppAttestService.isSupported must stay false for AppAttestStallRestartPolicy.unsupportedThreshold (5 min) and again after the drain. The restart uses the stall restart's monitor, idle checks, drain, app-attest-stall-restart.json limit (one automatic App Attest restart per 6 h, for both causes) and start_reason stall_restart. It never uses an in-place exec. A version that never wrote app-attest-verified.json leaves it missing after an update. At serve start, before the provider writes its own daemon state, it then seeds the file once from the previous daemon-state.json, with evidence from the last 7 days: the last successful Apple attestation or assertion of a stored key that Apple attested, or (only after an unclean exit) the time of an App Attest grant. So the seeded time can be an Apple success, not a coordinator grant. A previous provider that was itself answering is_supported_false published no key, so nothing is seeded and that Mac does not restart until the coordinator grants App Attest again (DaemonState.appAttestVerifiedAt, AppAttestVerifiedMarker.seedFromPreviousRun in provider-swift/Sources/ProviderCore/Service/AppAttestVerifiedSeed.swift). Code: AppAttestStallRestart.swift in provider-swift/Sources/ProviderAppAttest/; provider-swift/Sources/ProviderCore/ProviderLoop+AppAttestStall.swift. |
| Coordinator-driven rotation (client side) | An attest for a key this client already attested, with no cached proof, clears the key ID and replies key_unregistered without calling Apple. The next prepare generates a replacement within the per-key one-hour cooldown and the shared five-per-hour generation budget. Released 0.9.8 and 0.9.9 clients behave the same way. Code: provider-swift/Sources/ProviderAppAttest/AppAttestShadowClient.swift; pinned by provider-swift/Tests/ProviderAppAttestTests/StalledOperationAndRotationTests.swift. |
| Attestation retries | At most three attempts, 2/8-second waits, only for service unavailable. ShadowEnrollmentAttempt persists the original key/hash, status, session and timestamp across later coordinator retries and reconnects (the provider serves protocol 3 only; an attempt recorded under an earlier protocol is retired), as Apple requires. Successful recovery uses the original stored server transaction; a subsequent serving assertion always signs fresh status/challenge/endpoint. Expired or malformed retry state retires under existing generation limits. |
| Failed one-time enrollment | Non-service-unavailable Apple failures, including the 25-second callback deadline, retire the enrollment key identifier under the existing generation limits. The app persists attestationStartedAt before calling Apple. Apple attests a key once, so cancelling the exchange (a connection end or a planned stop) does not cancel the call: it runs in its own task, and the exchange still waits for Apple's answer and records it as an uncancelled exchange would. A proof is cached with its original enrollment session and status for the next attest; a cancelled exchange starts no further Apple call. An exchange that arrives meanwhile waits for that answer, at most AppAttestShadowClient.outstandingAttestationWaitSeconds (30 s), instead of answering busy; planned stops wait the same bound (Cancellation row). An attempt the process did not outlive (crash, SIGKILL, power loss, or a stop past that bound) leaves the marker without a proof, and the next prepare retires that key. Cached successful proofs remain recoverable. Generic assertion failures do not make the client rotate an accepted key on its own; an explicit invalid-key response can retire it, and the coordinator can request dead-key rotation. Code: provider-swift/Sources/ProviderAppAttest/EnrollmentKeyLifecycle.swift and AppAttestShadowClient.swift (attestToCompletion, waitForOutstandingAttestation). |
| Key generation | In the normal single-provider process, a persisted shared five-generations-per-coordinator/environment-per-hour budget across account scopes is checked and saved before the empty-key pre-call marker and every Apple call. A budget storage failure therefore creates no new one-hour marker or Apple key. Only a completed native Apple callback reporting an error with no usable key ID permits a new attempt after a persisted one-minute cooldown; Apple may still have created an inaccessible key internally, so the shared budget bounds normal-process attempts. Busy admission, operation timeout, cancellation, issued/retired keys and a crash before an error response retain the one-hour cooldown. Separate processes that bypass the provider instance lock do not have an atomic cross-process Keychain budget. Code: provider-swift/Sources/ProviderAppAttest/EnrollmentKeyLifecycle.swift (mayGenerateKey, mayRetryKeyGeneration) and AppAttestShadowClient.swift (respond). |
| Lost enrollment response | Keychain temporarily retains proof and original status; retry uses a server-persisted, same-owner transaction up to 24 hours old. Only a stored protocol-3 transaction resumes; one recorded without a version or under protocol 2 is refused as enrollment_protocol, which is not retried, and the client starts a fresh protocol-3 enrollment (coordinator/internal/appattest/transcript/binding.go, Prepare). The server measures the 24-hour limit from its original challenge, before the client caches the completed proof. A matching but expired transaction returns enrollment_expired and uses bounded exchange retries so a later prepare can expire the local cache and replace the key; binding mismatches remain terminal. Expired pending proof is replaced under the generation budget. |
| Acknowledgement | An assertion request follows durable enrollment acceptance; the successful local assertion clears the cached enrollment proof. |
| Cancellation | ProviderLoop generation invalidation cancels the exchange; AppAttestShadowReply additionally checks the originating NWConnection, registration, session, protocol and matching reply action immediately before writing. An old reply capability cannot send through the stable router to a new socket (provider-swift/Sources/ProviderCore/Coordinator/AppAttestShadowReply.swift, sendAppAttestShadow). A cancelled exchange's attestation still completes and is persisted, but its reply is never sent: the cached proof reaches the coordinator only as the reply to a later attest for that key. Planned stops (SIGTERM or SIGINT, darkbloom stop, the cluster service stopping a part, an update restart) cancel the exchange, then wait at most outstandingAttestationWaitSeconds for that answer before shutting down or restarting (ProviderLoop.stopAppAttestWorkerAndWait and stopAppAttestWorkerForUpdateAndWait in provider-swift/Sources/ProviderCore/ProviderLoop+AppAttestShadow.swift). |
Code: AppAttestShadowClient.swift, CallbackDeadline.swift, AppleAppAttestService.swift, and coordinator/internal/appattest/transcript/binding.go (Prepare). Keychain items remain nonsynchronizing and device-local; private App Attest keys remain with Apple's service.
A Secure Enclave key can die when a new provider process starts (reboot, power loss, macOS update): every later assertion then fails with DeviceCheck code 0, or a bare apple_error from 0.9.8 clients. The coordinator retires such a key through the released client's existing behavior, with no new message type: it sends attest for the already-attested key, the client clears it and replies key_unregistered, and the next prepare generates a replacement under the client's own persisted generation budget.
| Step | Rule | Code |
|---|---|---|
| Evidence | Count archived assertion evidence for this key with outcome apple_error whose context has no apple_error, or domain devicecheck with code 0 or 2, received since the key's last verified assertion (app_attest_shadow_keys.updated_at, which is the insert time until a counter advances). The context's coordinator-expected key_id must match; apple_error_source=proof_oversize, apple_unavailable, busy, timeouts and unsupported never count |
coordinator/store/app_attest_rotation.go (CountAppAttestRotationFailures) |
| Decision | On a ready for a known, owner-matched key (every session is protocol 3): at least recovery.RotationFailureThreshold = 2 failures, account in the rotation cohort, and at most one rotation in the trailing hour and four in the trailing 24 hours per machine (canonical connection machine, else the key's machine, else account:<id>). Rotations recorded for machines later merged into that machine count toward its limits. Then record the rotation and send attest instead of assert |
coordinator/internal/appattest/recovery/rotation.go (Rotation.Request, permitted, RotationLimits); session wiring in coordinator/appattest/service/key_rotation.go (maybeRequestKeyRotation) |
| Record | app_attest_key_rotations holds one row per retired key: machine scope, account, request time, failure count and reason. PostgreSQL admission first holds inventory barrier 9952701 shared (machine merges hold it exclusively), resolves the current canonical scope, then locks that scope's rotation budget. It holds both locks through window checks and insertion; memory uses its store mutex over the same steps. Stale pre-merge scope IDs therefore cannot obtain a separate budget, even during a concurrent merge. Existing rows retain their original scope, so window counts walk darkbloom_machines.merged_into (index darkbloom_machines_merged_into) to include merged history. A repeat request for a recorded key re-sends attest for that key without a new row |
coordinator/store/app_attest_rotation.go (AdmitAppAttestKeyRotation); postgres_app_attest_rotation.go |
| Scheduling | When an eligible assertion failure reaches the threshold while rotation is permitted, or the client answers a newly recorded rotation with key_unregistered in the same session, the next attempt starts after a random 15–45 seconds (RotationRetryDelay) with a fresh session ID. Rate-limited, excluded and repeat requests keep the normal bounded backoff |
coordinator/internal/appattest/recovery/driver.go (Driver.Run); coordinator/internal/appattest/recovery/rotation.go (Rotation.RetryDue, RotationRetryDelay) |
| Observation | Stage rotation with outcome requested, rate_limited, cohort_excluded, configuration_error or storage_error; metric app_attest.key_rotation tagged outcome: |
key_rotation.go (observeKeyRotation) |
Rotation retires a dead key; it never revokes it, fences serving or changes legacy trust. A rate-limited or excluded key keeps today's assert behavior. The replacement key is unknown, so it must pass the complete attestation path (chain, nonce, Mac ACL, CDhash, receipt, build qualification) and a fresh assertion before any grant. That grant binds the same canonical machine through the normal identity checks. A retired key is only ever asked to attest again, which it cannot satisfy, so it cannot regain authorization through rotation. Revoking the replacement still fences the connection.
Some Macs reject the first attestKey call for every freshly generated key with apple_invalid_key. Each retry makes the client generate another key and raises Apple's per-device risk metric. When an attestation reply fails with apple_invalid_key and the machine has at least recovery.EnrollmentInvalidKeyThreshold = 3 such archived failures in the trailing recovery.EnrollmentInvalidKeyWindow = 24 * time.Hour (the current one included), the next attempt waits recovery.EnrollmentInvalidKeyBackoff = 6 * time.Hour instead of the normal one-minute, five-minute, one-hour backoff. The machine is the connection's canonical machine; without one, the count covers the account's sessions. Failures come from app_attest_evidence rows (action attestation, outcome apple_invalid_key) joined to darkbloom_machine_sessions by session_id, capped at AppAttestRotationCountCap = 100. A verified attestation does not reset the window. Storage errors keep the normal backoff. The event is stage recovery, outcome enrollment_backoff. A reconnect, coordinator restart or release starts a new session, which re-derives a running backoff from the same archive before its first exchange: when the latest such failure had at least three in the 24 hours up to it and is less than six hours old, the session first waits until six hours after it (never longer than six hours, whatever the replica clocks), observed as stage recovery, outcome enrollment_backoff_resumed. That check waits up to 10 seconds for a session storage permit; a storage error starts normally. Both record app_attest.enrollment_backoff, tagged phase:failure or phase:session_start. Code: coordinator/internal/appattest/recovery/enrollment_timing.go (constants); coordinator/internal/appattest/recovery/enrollment.go (Enrollment.Due, Enrollment.Remaining); coordinator/appattest/service/enrollment_backoff.go (session wiring); coordinator/store/postgres/app_attest_rotation.go (AppAttestEnrollmentInvalidKeyFailureTimes).
This section describes the immutable implementation cited below, not current serving policy. In particular, its receipt-required eligibility and receipt-bound expiry must not be applied to basic serving today. Current basic serving and stricter reward decisions are separate; consult platform authorization.
coordinator/appattest/authorization.go (EvaluateAuthorization) is the pure
eligibility evaluator used for observations and the independently enabled
App Attest serving path. It has no APNs inputs
and does not mutate registry state itself. coordinator/appattest/service/policy.go
records the versioned result after each durably accepted assertion;
coordinator/appattest/service/authorization_identity.go applies eligible evidence
through the authorizer when serving is enabled. Failed exchanges supersede the
prospective observation; current dispatch still checks its bounded authorization.
| Condition | Missing evidence | Negative evidence |
|---|---|---|
| Account, machine, credential, connection, endpoint, app and environment binding | unknown |
ineligible on a binding mismatch |
| Complete admitted evidence for this connection | unknown when the current proof was refused or its archive write failed |
A later, separately challenged and completely archived proof can recover; the earlier gap remains in the audit |
| Protocol 3 existing verification key matches the verified registration key | unknown if unavailable/unbound |
ineligible on substitution; keeps existing model/runtime signatures linked to the verified app |
| Protocol 3 static hardware claims match registration | unknown if absent/unbound |
ineligible for a model, chip, RAM or CPU/GPU mismatch |
| Verified credential, endpoint custody and current assertion | unknown; assertions expire after AssertionFreshness = 15 * time.Minute |
Existing crypto verifier rejects invalid signatures/replay |
| Current Apple launch category and exact code measurement | unknown for absent metadata, unsupported algorithm, missing qualified mapping or an ambiguous 20-byte prefix; no enrollment fallback |
ineligible for non-Developer-ID launch, a definite code-hash mismatch, or a present bundle-version mismatch. A missing bundle version is allowed only with the required matching code measurement. |
| Active release catalog plus qualified immutable build | unknown when unavailable/unqualified |
ineligible for a known catalog mismatch |
| Credential revocation | unknown when storage is unavailable |
ineligible when revoked |
| Verified unexpired receipt, risk metric and configured renewal | unknown |
Renewal overdue by 24 hours remains unknown, not a zero risk metric |
eligible receives an expiry bounded by assertion freshness, receipt expiration
and renewal freshness. It is a prospective observation, not a portable cached
lease. The separately enabled serving path reevaluates current connection,
revocation and release policy at dispatch. Raw risk counts are evidence, not an invented fraud
threshold or physical-device identifier. app_attest_key_revocations and
RevokeAppAttestKey persist account-scoped, idempotent revocations without
changing legacy trust. The rollout runbook
lists qualification and retirement gates.
A controlled physical macOS 27 test of the same probe with SDK 26.5 and SDK 27.0 found that only the SDK 27 build returned the launch category and code measurement. With CDhash opt-in, its assertions carried apple_cd_hash_type_01 as one byte (2) and apple_cd_hash_hash_01 as the full 32-byte SHA-256 CodeDirectory digest. That digest exactly matched codesign -d --verbose=4 CandidateCDHashFull sha256, not the SHA-256 of the entire signed executable. A later Apple-signed proof carried the 20-byte truncation. Apple TN3126 distinguishes CandidateCDHash sha256 from CandidateCDHashFull sha256. No bundle-version extension was present. These are observed wire semantics requiring qualification on the final artifact and supported OS builds, not a promise of an undocumented future format.
coordinator/internal/appattest/proof/code_measurement.go parses the bounded signed fields and exposes only type-2 20- or 32-byte SHA-256 candidates for matching. A 20-byte candidate qualifies only when it uniquely prefixes one full 32-byte hash across all durable qualifications, including revoked rows, and that exact row is approved, unrevoked, active in the release catalog and matches the reported binary/version. It cannot use environment bootstrap. The signed-prefix match and active-catalog qualification are separate checks: a catalog outage or ambiguous prefix withholds App Attest permission as unknown, without falsely treating the signed code as tampered or hard-denying independent APNs trust. coordinator/internal/appattest/qualification/measurement.go requires an explicit qualified mapping for the reported binary hash; the independently loaded release catalog also pins that binary hash and version. The policy never accepts a code hash supplied in ordinary client status as Apple's measurement. Unknown algorithms remain recorded but cannot qualify. Assertions and enrollment observations retain attested_code_directory_type and attested_code_directory_hash; only the current assertion feeds prospective authorization. Parsed measurements are also committed atomically into the proof decision details. Verified OS/build status is recorded even when readiness storage fails or the key is revoked; only identity alias attachment depends on a known non-revoked credential. SDK 26 builds remain safe shadow clients and stay unknown for replacement readiness.
The optional boot-security probes use SecurityCommandRunner.bounded with a one-second deadline per command (at most three commands). Timeouts omit the affected fields. APNsBridge.trackDeviceToken keeps persisted token presence synchronized with callbacks even after the startup waiter expires.
The existing CLI, app identity, user LaunchAgent, APNs grants, and deployment floor remain intact. scripts/prepare-app-attest-entitlements.py adds only profile-authorized CDhash opt-in and any explicitly granted environment entitlement. An old profile keeps legacy signing. The real adapter requires the full signed app in the supported user context and checks actual API availability.
The initial physical report records macOS 27 acceptance and its limits. The version 2 validation records earlier integration evidence; 0.9.4 recovery qualification records the current candidate and its limits. Final notarization, install/update and APNs regressions across the supported OS fleet, security-transition negatives, and production rollout remain separate release gates.
The 0.9.3 disconnect investigation
records the optimized callback-timer crash and production pause. App Attest
deadlines and retry delays use the non-generic nanoseconds sleep workaround.
The packaged runtime-smoke command exercises callback completion and deadline
expiry without calling Apple; the release workflow requires its
app-attest-callback-runtime-smoke: ok marker before publishing.
Run isolated Swift transcript, account-isolation, response-loss and deadline tests. Real Apple evidence and exact signed-artifact/native qualification remain separate from public fixtures. Backend receipt, inventory, archive and admin tests belong to the private platform; no Go/Rust/database build is required here.