Skip to content

refactor(forges): bind account-scoped adapter operations via getAccountAdapter - #3266

Merged
afonsojramos merged 4 commits into
mainfrom
refactor/account-scoped-forge-adapter
Sep 6, 2026
Merged

refactor(forges): bind account-scoped adapter operations via getAccountAdapter#3266
afonsojramos merged 4 commits into
mainfrom
refactor/account-scoped-forge-adapter

Conversation

@afonsojramos

@afonsojramosafonsojramos commented Sep 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Split the forge adapter contract. ForgeAdapter keeps the forge-wide members (login flows, token validation, display helpers), and a new ForgeAccountAdapter carries the account-scoped operations with no account parameter.
  • Adapters implement those operations under accountOps, still taking the account explicitly; the shape is derived from ForgeAccountAdapter by a mapped WithAccount type so the two cannot drift. getAccountAdapter(account) in the registry binds them, so call sites read getAccountAdapter(account).listNotifications() instead of getAdapter(account).listNotifications(account).
  • Migrates all 18 call sites, re-points test spies at adapter.accountOps.*, and adds registry tests for the binding (argument forwarding, nested capability bundles, optional bundles, call-time member lookup).

Follows up on the double-passing pattern raised in #3255 (comment).

Notes

  • No behaviour change: URLs, capability checks and notification flows are untouched. The full unit suite, typecheck, lint and format pass.
  • A bound view closes over the account object it was created from, and the store replaces accounts on token rotation, so views should be created at the call site rather than stored. This is documented on ForgeAccountAdapter.
  • followUrl<T> stays generic on the bound side; on the implementation side the type parameter erases to unknown, matching the trust boundary that existed before.

@github-actionsgithub-actionsBot added the refactor Refactoring of existing feature label Sep 3, 2026
@afonsojramos

afonsojramos commented Sep 3, 2026

Copy link
Copy Markdown
MemberAuthor

What do you think of these ergonomics @setchy? I'm a bit on the fence with the naming. Chained, forAccount makes sense, but it isolation it is awful. getAccountAdapter is much cleaner, but it does use a lot more characters.

@afonsojramosafonsojramos changed the title refactor(forges): bind account-scoped adapter operations via forAccountrefactor(forges): bind account-scoped adapter operations via getAccountAdapterSep 3, 2026
@setchy

Copy link
Copy Markdown
Member

What do you think of these ergonomics @setchy? I'm a bit on the fence with the naming. Chained, forAccount makes sense, but it isolation it is awful. getAccountAdapter is much cleaner, but it does use a lot more characters.

let me soak on this PR for a moment 🧽

Replace recursive runtime binding and mapped signatures with explicit typed
operations, preserving the generic followUrl contract. Cover same-forge
account isolation and bound Gitea requests, failures, and response types.
@afonsojramos

Copy link
Copy Markdown
MemberAuthor

@setchy just replaced the recursive binder and mapped types with explicit typed bindings. The account-bound API now stays the same, and followUrl preserves its generic contract throughout.

@sonarqubecloud

Copy link
Copy Markdown

@setchysetchy 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.

Let's give it a go.

@afonsojramos
afonsojramos merged commit 525386e into mainSep 6, 2026
19 checks passed
@afonsojramos
afonsojramos deleted the refactor/account-scoped-forge-adapter branch September 6, 2026 14:02
@github-actionsgithub-actionsBot added this to the Release 7.x.x milestone Sep 6, 2026
@github-actionsgithub-actionsBot mentioned this pull request Sep 5, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactorRefactoring of existing feature

Development

Successfully merging this pull request may close these issues.

2 participants

@afonsojramos@setchy