{"record":{"id":"e3a5da29d8c5ff0b","repo":"stablyai/orca","slug":"direct-pairing-upgrade-was-not-authoritatively-com","errorCode":null,"errorMessage":"direct pairing upgrade was not authoritatively committed","messagePattern":"direct pairing upgrade was not authoritatively committed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mobile/src/transport/mobile-relay-direct-upgrade.ts","lineNumber":103,"sourceCode":"  }\n  const installed = DeviceCredentialInstalledSchema.parse(requireSuccess(provisionResponse))\n  assertDirectInstall(journal, installed)\n  const reconciled = await getEndpoints(args.client, journal.reqId)\n  if (reconciled === 'method-not-found') {\n    throw new Error('relay endpoint reconciliation became unavailable')\n  }\n  assertCommitted(reconciled, installed)\n  return publishCommitted(args.host, journal, reconciled, dependencies)\n}\n\nasync function publishCommitted(\n  host: HostProfile,\n  journal: MobileRelayDirectUpgradeJournal,\n  endpoints: PairingGetEndpointsResult,\n  dependencies: Dependencies\n): Promise<MobileRelayDirectUpgradeResult> {\n  if (endpoints.installStatus?.state !== 'committed' || !endpoints.relay) {\n    throw new Error('direct pairing upgrade was not authoritatively committed')\n  }\n  const installed = endpoints.installStatus.result\n  assertDirectInstall(journal, installed)\n  const bundle = MobileRelayCredentialBundleSchema.parse({\n    v: 1,\n    hostId: host.id,\n    deviceToken: host.deviceToken,\n    current: {\n      token: journal.pendingResumeToken,\n      hash: journal.pendingResumeTokenHash,\n      version: installed.currentVersion,\n      expiresAt: installed.resumeExpiresAt\n    }\n  })\n  // Why: the overlay must never advertise relay without its matching credential.\n  await dependencies.writeBundle(bundle)\n  let updatedHost: HostProfile\n  try {","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/mobile/src/transport/mobile-relay-direct-upgrade.ts#L85-L121","documentation":"Thrown by `publishCommitted` in the direct-upgrade path when `endpoints.installStatus?.state !== 'committed'` or `endpoints.relay` is missing. This is the final authoritative check before writing the credential bundle and publishing the relay host — it guarantees the bundle and host profile are never advertised without a matching committed install.","triggerScenarios":"`assertCommitted` passed but `publishCommitted` was called with a different endpoints object whose state regressed; the committed install lost its `relay` field between calls; a code path that reaches `publishCommitted` without the committed invariant.","commonSituations":"Refactor that reorders the committed check and publish; server-side state regression between reconciliation and publish; race that mutates the endpoints object.","solutions":["Re-fetch endpoints and retry publish once if the state regressed.","Never call `publishCommitted` except from the committed branch of `upgradeDirectMobileRelay`.","If persistent, treat as server inconsistency and abort the upgrade (preserve the journal)."],"exampleFix":"// before\nreturn publishCommitted(host, journal, endpoints, dependencies) // throws\n\n// after\nif (endpoints.installStatus?.state !== 'committed' || !endpoints.relay) {\n  endpoints = await getEndpoints(client, journal.reqId) // re-check\n}\nreturn publishCommitted(host, journal, endpoints, dependencies)","handlingStrategy":"validation","validationCode":"function isCommittedWithRelay(e: PairingGetEndpointsResult): boolean {\n  return e.installStatus?.state === 'committed' && !!e.relay\n}\nif (!isCommittedWithRelay(endpoints)) { endpoints = await getEndpoints(client, journal.reqId) }","typeGuard":"function isPublishable(e: PairingGetEndpointsResult): boolean { return e.installStatus?.state === 'committed' && !!e.relay }","tryCatchPattern":"try { return await upgradeDirectMobileRelay({ client, host }) } catch (e) { if (e.message === 'direct pairing upgrade was not authoritatively committed') { /* preserve journal, abort */ abortUpgradePreserveJournal(hostId); throw e } throw e }","preventionTips":["Never call publishCommitted from a non-committed branch.","Re-fetch endpoints if state may have regressed before publish.","Keep the journal intact on abort so upgrade can resume."],"tags":["relay","upgrade","consistency","credentials"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}