Repository navigation
Implement IROH v2 Cloudflare backend and clients #12326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
15e7456
Implement IROH v2 Cloudflare backend and clients
azooz2003-bit 8b3650b
Configure v2 origins in development builds
azooz2003-bit 4137fa2
Fix Worker fetch redirect policy and failure telemetry
azooz2003-bit 17f8230
Record staging v2 interaction smoke evidence
azooz2003-bit 520b09b
Pin corrected v2 smoke evidence to current source
azooz2003-bit 79caa32
Add blocked v2 interaction evidence
azooz2003-bit efc6e1d
Record native relay handshake acceptance blocker
azooz2003-bit f773efe
relay: preserve deployed JWT admission contract
azooz2003-bit 5f4d8fb
fix: use team relay set for v2 peer dialing
azooz2003-bit 6d179e8
fix: publish home relay for v2 peer dialing
azooz2003-bit 1cb0ee3
fix: track v2 relay hints without blocking accept
azooz2003-bit 833f94d
test: define isolated IROH dashboard ticket authority
azooz2003-bit 3277199
feat: add v2 dashboard and backend observability
azooz2003-bit 37748ed
iroh v2: ignore stale relay preferences after rollout
azooz2003-bit 3c66630
iroh v2: use existing production database
azooz2003-bit 682ac77
iroh v2: point ownership at existing production database
azooz2003-bit 0b24cdf
iroh v2: support PlanetScale shared database workflow
azooz2003-bit 5faae88
relay: restore shipped key for legacy client compatibility
azooz2003-bit 1ef420d
docs: record relay compatibility recovery
azooz2003-bit 51863e3
Merge main into Iroh v2 and retain runtime ownership fixes
azooz2003-bit b5f96b1
Use authorized Cloudflare origin for IROH v2
azooz2003-bit a1f2e8d
Allow dashboard connections to authorized v2 origin
azooz2003-bit 9356631
Wait for IROH socket responses in runtime tests
azooz2003-bit 30e8e83
Link the app directly to its IrohLib dependency
azooz2003-bit 2daad4d
test: exercise ownership reservations through the shared database pool
azooz2003-bit 9c8bbb7
fix: apply ownership timeouts inside pooled database transactions
azooz2003-bit a3241c6
Test delayed first RPC on admitted Iroh session
azooz2003-bit 3177225
Restore ownership test location
azooz2003-bit 8b9dfa4
Move ownership test to live database suite
azooz2003-bit 57eef4b
Exercise legacy timeout beside idle admitted Iroh peer
azooz2003-bit 5dc1bb6
Keep admitted Iroh peers alive before their first RPC
azooz2003-bit 401bf24
docs: record shared PlanetScale cutover and current verification evid…
azooz2003-bit 23b04ec
Avoid NSWindow keyWindow collision in drag test fixture
azooz2003-bit 04d5449
test: exercise v2 credential renewals during short dogfood runs
azooz2003-bit 1077e42
Fix hover test screen-coordinate conversion
azooz2003-bit fc9c9f7
Merge origin/main into Iroh v2 generation
azooz2003-bit 2146581
Fix throwing geometry assertion in test
azooz2003-bit ce1cb2c
Test directory changes arriving while a snapshot is saved
azooz2003-bit b3df7c9
Fix IROH v2 review findings
azooz2003-bit 93728af
Fix iOS IROH v2 projection and stream lifecycle
azooz2003-bit fabaf59
test: cover v2 authority and relay rotation lifecycle gaps
azooz2003-bit a9568de
fix: fence v2 host readiness and credential rotation authority
azooz2003-bit d16f214
Preserve empty directory clearing in discovery projection
azooz2003-bit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| name: IROH v2 | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - workers/iroh-v2/** | ||
| - Packages/Shared/CmuxIrxTransport/** | ||
| - .github/workflows/iroh-v2.yml | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - workers/iroh-v2/** | ||
| - Packages/Shared/CmuxIrxTransport/** | ||
| - .github/workflows/iroh-v2.yml | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| backend: | ||
| runs-on: ${{ vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }} | ||
| timeout-minutes: 15 | ||
| defaults: | ||
| run: | ||
| working-directory: workers/iroh-v2 | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 | ||
| with: | ||
| bun-version: "1.3.14" | ||
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | ||
| with: | ||
| node-version: "22" | ||
| - run: bun install --frozen-lockfile | ||
| - name: Contracts, architecture, generated bindings and unit tests | ||
| run: bun run check | ||
| - name: Real Cloudflare runtime and SQLite tests | ||
| run: bun run test:runtime | ||
| - name: Validate staging and production bundles | ||
| run: | | ||
| bunx wrangler deploy --env staging --dry-run --outdir dist/staging | ||
| bunx wrangler deploy --env production --dry-run --outdir dist/production |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
Packages/Shared/CMUXMobileCore/Sources/CMUXMobileCore/CmxIrohLocalSocketAddress.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import Foundation | ||
|
|
||
| /// An explicitly entered local IROH address and UDP port. Never publish this value to a server. | ||
| public struct CmxIrohLocalSocketAddress: Equatable, Sendable { | ||
| public let address: CmxIrohCustomPrivateAddress | ||
| public let port: UInt16 | ||
| public var value: String { address.socketAddress(port: port) } | ||
|
|
||
| /// Accepts IPv4:port or [IPv6]:port; a port is required and DNS names are rejected. | ||
| public init(_ raw: String) throws { | ||
| let value = raw.trimmingCharacters(in: .whitespacesAndNewlines) | ||
| let host: String | ||
| let portText: String | ||
| if value.hasPrefix("["), let end = value.firstIndex(of: "]") { | ||
| host = String(value[value.index(after: value.startIndex)..<end]) | ||
| let suffix = value[value.index(after: end)...] | ||
| guard suffix.hasPrefix(":") else { throw CmxIrohCustomPrivateAddressError.invalidAddress } | ||
| portText = String(suffix.dropFirst()) | ||
| } else { | ||
| let parts = value.split(separator: ":", omittingEmptySubsequences: false) | ||
| guard parts.count == 2 else { throw CmxIrohCustomPrivateAddressError.invalidAddress } | ||
| host = String(parts[0]); portText = String(parts[1]) | ||
| } | ||
| guard !portText.isEmpty, portText.allSatisfy({ $0.isASCII && $0.isNumber }), | ||
| let port = UInt16(portText), port > 0 else { throw CmxIrohCustomPrivateAddressError.invalidAddress } | ||
| address = try CmxIrohCustomPrivateAddress(host) | ||
| self.port = port | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
...ages/Shared/CMUXMobileCore/Tests/CMUXMobileCoreTests/CmxIrohLocalSocketAddressTests.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import Testing | ||
| @testable import CMUXMobileCore | ||
|
|
||
| struct CmxIrohLocalSocketAddressTests { | ||
| @Test func requiresExplicitPortAndCanonicalizesBothFamilies() throws { | ||
| #expect(try CmxIrohLocalSocketAddress(" 192.168.1.5:58470 ").value == "192.168.1.5:58470") | ||
| #expect(try CmxIrohLocalSocketAddress("[fd00:0:0::5]:443").value == "[fd00::5]:443") | ||
| } | ||
| @Test(arguments: ["192.168.1.5", "fd00::5", "[fd00::5]", "192.168.1.5:0", "192.168.1.5:65536", | ||
| "mac.local:443", "127.0.0.1:443", "[fe80::1%en0]:443", "192.168.1.5:+443", "[fd00::5]:443:5"]) | ||
| func refusesIncompleteOrNonNumericRoutes(_ value: String) { | ||
| #expect(throws: CmxIrohCustomPrivateAddressError.self) { try CmxIrohLocalSocketAddress(value) } | ||
| } | ||
| } |
52 changes: 52 additions & 0 deletions
52
...ared/CmuxAuthRuntime/Sources/CmuxAuthRuntime/Coordinator/AuthCoordinator+TeamScopes.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import Foundation | ||
|
|
||
| public extension AuthCoordinator { | ||
| /// Current account and selected team, without accessing either credential. | ||
| var authenticatedTeamScope: AuthenticatedTeamScope? { | ||
| guard let session = publishedAuthenticatedSessionIdentity, | ||
| let teamID = resolvedTeamID, | ||
| !teamID.isEmpty else { return nil } | ||
| return AuthenticatedTeamScope( | ||
| session: session, | ||
| teamID: teamID, | ||
| generation: authenticatedTeamScopeGeneration | ||
| ) | ||
| } | ||
|
|
||
| /// Emits current scope immediately, then account, sign-out and team changes. | ||
| /// | ||
| /// Consumers fence callbacks against ``isAuthenticatedTeamScopeCurrent(_:)`` | ||
| /// before installing results; stream consumption itself is asynchronous. | ||
| func authenticatedTeamScopes() -> AsyncStream<AuthenticatedTeamScope?> { | ||
| publishAuthenticatedTeamScope() | ||
| let id = UUID() | ||
| return AsyncStream(bufferingPolicy: .bufferingNewest(1)) { continuation in | ||
| authenticatedTeamScopeContinuations[id] = continuation | ||
| continuation.yield(authenticatedTeamScope) | ||
| continuation.onTermination = { @Sendable [weak self] _ in | ||
| Task { @MainActor [weak self] in | ||
| self?.authenticatedTeamScopeContinuations[id] = nil | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Returns false synchronously when a captured account or team is replaced. | ||
| func isAuthenticatedTeamScopeCurrent(_ scope: AuthenticatedTeamScope) -> Bool { | ||
| authenticatedTeamScope == scope | ||
| } | ||
| } | ||
|
|
||
| extension AuthCoordinator { | ||
| func publishAuthenticatedTeamScope() { | ||
| let next = authenticatedTeamScope | ||
| let previous = lastPublishedAuthenticatedTeamScope | ||
| guard next?.session != previous?.session || next?.teamID != previous?.teamID else { return } | ||
| authenticatedTeamScopeGeneration &+= 1 | ||
| let scope = authenticatedTeamScope | ||
| lastPublishedAuthenticatedTeamScope = scope | ||
| for continuation in authenticatedTeamScopeContinuations.values { | ||
| continuation.yield(scope) | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...s/Shared/CmuxAuthRuntime/Sources/CmuxAuthRuntime/Coordinator/AuthenticatedTeamScope.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import Foundation | ||
|
|
||
| /// Credential-free account and team authority for cancelling scoped work. | ||
| public struct AuthenticatedTeamScope: Sendable, Equatable, | ||
| CustomStringConvertible, CustomDebugStringConvertible { | ||
| /// Auth session identity, including its account generation. | ||
| public let session: AuthenticatedSessionIdentity | ||
| /// The selected, resolved Stack team. | ||
| public let teamID: String | ||
| /// Advances on every account/team transition, including A to B to A. | ||
| public let generation: UInt64 | ||
|
|
||
| /// Creates a captured account/team scope without copying credentials. | ||
| public init(session: AuthenticatedSessionIdentity, teamID: String, generation: UInt64) { | ||
| self.session = session | ||
| self.teamID = teamID | ||
| self.generation = generation | ||
| } | ||
|
|
||
| /// Logs contain the generation, with account and team identifiers redacted. | ||
| public var description: String { | ||
| "AuthenticatedTeamScope(generation: \(generation), accountID: <redacted>, teamID: <redacted>)" | ||
| } | ||
|
|
||
| public var debugDescription: String { description } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Fence
authenticatedTeamScopeto the currentsessionGeneration.During account-changing revalidation,
applySignedInUserpublishes the new session beforerefreshTeamscompletes. If the refresh fails,resolvedTeamIDcan reuse the prior persisted selection becauseavailableTeamsis empty.authenticatedTeamScopethen exposes the new account with an unconfirmed prior-account team, andisAuthenticatedTeamScopeCurrentaccepts it. Clear or generation-fence team membership before publishing the session, record the generation of successful team refreshes, and returnnilunless that generation matches the currentsessionGeneration. KeepselectedTeamIDas a preference and apply it only after membership is authoritative.🤖 Prompt for AI Agents