Skip to content

feat: configure native federation without rebuilding desktop - #2152

Open
nkuhn-vmw wants to merge 1 commit into
block:mainfrom
nkuhn-vmw:codex/runtime-federated-identity
Open

nkuhn-vmw wants to merge 1 commit into
block:mainfrom
nkuhn-vmw:codex/runtime-federated-identity

Conversation

@nkuhn-vmw

@nkuhn-vmw nkuhn-vmw commented Nov 2, 2026 •

Copy link
Copy Markdown

A desktop deployment with its own NIP-FA/NIP-FI authority currently has to compile the authority into Buzz. This change lets a desktop built with an empty sign-in registry load one nonsecret descriptor, federated-identity.json, from its existing federation store at startup. The configuration guide covers installation, permissions, removal, and issuer compatibility.

A nonempty compiled registry takes precedence and Buzz never opens the local file. Standard downloads compile bb-public. Standard and mixed registries retain Builderlab customer routing, saved customer hosts, community-specific sign-in links, and per-server session slots. A local descriptor selects a single authority and cannot enable Builderlab customer discovery, even if it copies the built-in descriptor.

In a build with an empty registry, an absent file leaves federation unconfigured. An invalid or unreadable file stops startup. Unix checks the opened file's type, owner and write mode, refuses a symlink at the final component, and bounds the read. The operator must protect the parent path and ACLs. Windows relies on the user's application-data ACLs. Sessions keep their existing profile and descriptor fingerprint. Installed plugins still need a matching explicit grant.

Trust decision for review. Someone with write access as the user could place a descriptor and change which organization prompts for sign-in after restart. Is enabling that local choice for builds shipped with an empty registry acceptable? The earlier review left this decision to the project owners.

Current validation: 78318db8, rebased onto e933a830. The rebase preserves the current Builderlab routing and sign-in guidance. After the rebase, 171 native federation tests, 10 build-configuration tests, 241 relay tests (2 existing ignores), and 132 renderer tests across federation and Builderlab passed. The only subsequent changes corrected documentation. The import regression fixture and required pre-push checks, including workspace Clippy, passed on the final head. Formatting passed. An arm64 debug bundle built from the final head with pinned dependencies and an empty compiled sign-in registry; its executable checksum matched after transfer to a macOS VM.

Independent review by claude-opus-5-5 found no blocking code defect. Its two documentation findings were corrected: the current Community sign-ins UI location and the issuer contract required for native agent grants.

Live Mac validation passed on this head, November 18. The exact arm64 bundle ran in a macOS VM with an existing Keychain identity and a relay enforcing NIP-FI. Its executable SHA-256 was 1df73a79a34545e1724b631337918662c11537b7d8d5f31d903032982a9ca7c9.

  • Browser sign-in completed; Settings displayed the expected account. A new private channel and signed-in message appeared, with authenticated relay access.
  • A dedicated local agent enrolled through the native token client: grant and assertion endpoints both returned 200. Its grant expired with the original owner session.
  • Organization sign-out returned 204. The UI displayed “Not signed in” and required sign-in to open the community; a protected relay query returned 401. Server records confirmed revocation of the current session and original agent grant, and the owner grant epoch advanced. The local Buzz identity remained in place.
  • Reconnect requested prompt=login, completed exchange/session/assertion with 200 responses and restored the same identity. A new message was accepted; both messages remained visible after switching away and reopening the channel.
  • Updating that same agent's profile after reconnect exercised lazy re-enrollment. Grant and assertion endpoints returned 200 again, the signed profile write was accepted, and the new grant retained the same agent public key while expiring with the new owner session. The original grant remained revoked.

The external test issuer was updated separately for the current native logout, forced-login parameter and grant/assertion contracts. Its 28 Node 24 tests passed, including real PostgreSQL integration with signed proofs, renewal, replay refusal, owner/key/relay boundaries and logout revocation. Deployed source hashes and health matched. These issuer changes are not part of this client PR.

The author manually exercised sign-in renewal in the current VM build and confirmed completion. The subsequent full logout/reconnect/agent-grant cycle was driven through the native UI and corroborated with server receipts. Agent validation covers credential lifecycle and signed profile publication; it does not claim model inference. App-session revocation does not establish identity-provider global logout or forced password/MFA.

buzz-review-completed

The November 9 existing-identity Mac validation previously recorded in this description was on 804133e, not this head. It covered browser sign-in, enforced relay access, organization sign-out and a second sign-in with persisted messages. The previous Mac run and contributor's Windows run also cover earlier heads.

Fresh enterprise signup, a signed distribution, and adding another authority to the standard download remain outside this change. The rebase was clean against e933a830; a later merge-tree check against 7ab40051 was conflict-free, but that combined tree is not the VM-tested artifact. The current application CI run requires maintainer approval and has zero jobs. DCO passed. GitHub reports the PR mergeable, with required checks still blocking merge. The local-authority trust decision above also remains with maintainers.

@corydouthat-sq

Copy link
Copy Markdown

Windows run of the manual acceptance from the description, against a real enforcing NIP-FI deployment (Block's), in case it helps with the "Windows native execution" item.

Environment: Windows 11 Enterprise 10.0.26300, WebView2 156, existing Buzz identity, relay in NIP-FI enforce mode (plain WebSocket upgrade → 401). Builds made with the repo-pinned Rust 1.98.1 / pnpm 11.8.0, pnpm tauri build --ci --no-sign --bundles nsis --config candidate.json -- --locked, without BUZZ_BUILD_FEDERATED_IDENTITY_CONFIG, BUZZ_BUILDERLAB_URL=https://app.builderlab.xyz (same as the published previews). Descriptor placed at %APPDATA%\.xyz.block.buzz.desktop.federated-session\federated-identity.json as documented.

1. The branch as-is needs a rebase. Built from 04df5c0 (base ec8b29ee8), the runtime descriptor loaded and the existing session restored (Settings showed the account and expiry), but every relay socket ended with invalid-assertion and the sidebar showed "Buzz couldn't confirm your organization sign-in for this community". That is the client-side validate_jwt check expiry - minted > 300 that #2171 removed on 2026-11-02; this deployment's adapter now issues longer-lived assertions, so the pre-#2171 code rejects them before the relay sees them. Not a problem with this PR's code, but anyone testing it against a current adapter will hit it.

2. Rebased onto 1a48ed1 (clean, no conflicts), acceptance on Windows:

Step Result
Runtime descriptor in a build with no compiled authority ✅ loaded; Organization sign-in shows the authority
Existing session restored into the same slot (no re-prompt) ✅ same <fingerprint> credential/lock reused, consistent with native_owner_uses_same_session_slot_for_equivalent_sources
Relay connects with assertion ✅ sockets open, relay-backed writes resume
Sign out of organization ✅ session credential removed from Credential Manager; relay connections dropped within ~10 s; protected reads refused
Sign in again through the deployment (browser SSO) ✅ twice
Invalid descriptor (truncated JSON / http:// origin / non-JSON) ✅ startup stops with an error dialog "Cannot load federated identity deployment: " (path only, no contents); no WebView or network started
Restore descriptor ✅ normal startup, at-launch sign-in
Build with compiled authority + invalid local file ✅ ignores the file and connects normally

Observations (not blockers):

  • federated-identity.json survives sign-out alongside <fingerprint>.lock / .record, as documented.
  • While the browser sign-in was still open, Settings briefly showed a red "Sign-in did not finish. Try again." under Organization sign-in; it cleared when the callback completed. Same wording appears in the compiled-authority build, so it's not specific to this change.
  • Windows ACL note in docs/configuration.md reads fine; nothing on this side validates the file's ACL, and a same-user write to %APPDATA% is all it takes, as the description says.

Build note for Windows without admin: corepack enable needs elevation, but a user-level pnpm.cmd wrapping corepack pnpm@11.8.0 %* on PATH is enough for beforeBuildCommand.

@nkuhn-vmw
nkuhn-vmw force-pushed the codex/runtime-federated-identity branch from 04df5c0 to b130944 Compare November 3, 2026 21:42
@nkuhn-vmw

Copy link
Copy Markdown
Author

@corydouthat-sq Thanks for testing this and documenting the Windows results. I verified the lifetime check you identified and rebased onto upstream 92d4c36; the published head is now b130944.

That also brings in the macOS Keychain bundling change. There were two conflicts against this newer base: the configuration docs and the session-store constructor. Both are resolved, preserving upstream's launch guidance and bundled: store::BUNDLED.

Checks on the rebased Mac checkout passed: 113 federation tests, 207 relay tests (2 existing ignored), the native import fixture, formatting, and the mandatory workspace Clippy check. Another 313 existing first-run/sign-in tests passed. Independent Claude Opus 5.5 review found no blockers.

The description now credits your Windows acceptance against the build you tested, separately from our checks on this newer head. We're keeping the PR draft pending packaged Mac/real-Keychain/browser SSO testing, human acceptance and hosted CI. Headless Chromium/WebKit also confirmed the separate first-run limitation: an external community still offers Builderlab signup or an existing key. This rebase doesn't expand into that signup work.

@nkuhn-vmw
nkuhn-vmw marked this pull request as ready for review November 4, 2026 19:53
@nkuhn-vmw
nkuhn-vmw requested a review from a team as a code owner November 4, 2026 19:53

@joahg joahg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Read runtime.rs and the FederatedIdentity::open wiring. Compiled config short-circuits before the file is opened, and the Unix loader opens with O_NOFOLLOW, checks the handle's owner and mode, and bounds the read. The PR itself notes that maintainer agreement on this opt-in local trust model is needed; that decision is outside what I reviewed. Branch currently conflicts with main.

@nkuhn-vmw
nkuhn-vmw force-pushed the codex/runtime-federated-identity branch 2 times, most recently from 523fc46 to 2eba153 Compare November 6, 2026 12:04
@nkuhn-vmw

Copy link
Copy Markdown
Author

Rebased onto current main fd21dba; published head is 2eba153, and the branch is conflict-free again. The multi-server constructor now retains all compiled entries and their session slots. Native federation/relay/import checks, focused renderer checks and the required Clippy hook passed; the description has exact counts and current-source packaged startup evidence.

The important scope change upstream is the built-in bb-public server. Standard builds now ignore the local file, as compiled-policy precedence requires. This PR still helps builds with zero compiled servers; it does not add runtime servers alongside the compiled registry. Could maintainers confirm whether that remaining scope is wanted, or point to the intended mechanism for independently hosted organizations in the official client? I have not broadened the trust boundary to solve that here.

The current CI run requires approval. I also reproduced an unrelated typecheck failure on clean main: the PageNavigation fixture in ChannelsPage.context.test.tsx:248 lacks passThrough. A test-only stub allowed the Mac candidate build and its 9 fixture tests; that overlay is not in this PR. The new candidate's full live SSO round trip is still pending, and the description clearly separates yesterday's successful live test from today's evidence.

@nkuhn-vmw

Copy link
Copy Markdown
Author

The current-head Mac live cycle is now complete on 2eba153, using the same executable SHA-256 32753befbcd1de2257a0d562c7e74e2c013b5b55cf6b61a70bf411490d451327 recorded in the description.

  • Browser sign-in → code exchange/session/assertion → protected write: HTTP 200.
  • Organization sign-out preserved the Buzz public key. A new message showed Retry; relay write and reads returned 401.
  • Reconnect obtained a fresh session/assertion and accepted a new message. It remained visible after switching away and reopening the channel; the rejected message remained Retry.

This used the existing Keychain identity and an enforcing relay in an Apple silicon macOS VM. The validation section retains the packaging limit: this unsigned debug bundle required direct executable launch; Finder launch and signed distribution are not qualified. The zero-compiled-server scope and standard official-download limitation are unchanged. Upstream also fixed the unrelated build fixture in #2783. No additional code was pushed for this test.

@nkuhn-vmw
nkuhn-vmw force-pushed the codex/runtime-federated-identity branch from 2eba153 to 804133e Compare November 9, 2026 15:11
@nkuhn-vmw

Copy link
Copy Markdown
Author

Could a maintainer approve the CI run and weigh in on allowing a local sign-in descriptor when Buzz ships with an empty sign-in registry? Thanks.

Co-authored-by: Codex <codex@openai.com>
Signed-off-by: Nick <ci@kuhn-labs.com>
@nkuhn-vmw
nkuhn-vmw force-pushed the codex/runtime-federated-identity branch from 804133e to 78318db Compare November 18, 2026 22:40
@nkuhn-vmw

Copy link
Copy Markdown
Author

Rebased onto e933a830 and pushed 78318db8, preserving Builderlab customer routing and sign-in guidance. Local federation, relay, renderer, import and required pre-push checks passed; independent claude-opus-5-5 review found no code blockers.

The exact arm64 candidate now passed the existing-identity Mac cycle: sign-in, native sign-out (204; protected relay read 401), reconnect and persisted messages. Native agent enrollment also passed; logout revoked its grant, and a profile update after reconnect obtained a new grant for the same agent key, bounded by the new owner session. The updated description records artifact identity, receipts, human/agent test scope and remaining limits.

The current CI run still requires approval and has zero jobs. The local-authority trust decision remains unchanged; this does not add an authority to a standard download with a compiled registry.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants