Skip to content

fn: move Future/Promise from actor package#10727

Open
Abdulkbk wants to merge 4 commits into
lightningnetwork:masterfrom
Abdulkbk:move-to-fn
Open

fn: move Future/Promise from actor package#10727
Abdulkbk wants to merge 4 commits into
lightningnetwork:masterfrom
Abdulkbk:move-to-fn

Conversation

@Abdulkbk
Copy link
Copy Markdown
Contributor

Closes #10724.

Change Description

Future[T], Promise[T], and NewPromise[T] currently live in the actor package but do not depend on actor-specific functionality.
This PR moves them to the fn package where they belong as general-purpose async primitives.

Testing

cd fn && go test ./...

# Run the actor unit tests to verify nothing regressed:
cd actor && go test ./...

# Verify the root module builds cleanly against the local fn:
go build ./...

📝 Please see our Contribution Guidelines for further guidance.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request improves the codebase architecture by relocating generic asynchronous primitives from the actor-specific package to a more appropriate, shared utility package. This change promotes better code reuse and separation of concerns by ensuring that these primitives are not coupled to actor-specific functionality.

Highlights

  • Refactoring: Moved the Future and Promise types from the actor package to the fn package to treat them as general-purpose asynchronous primitives.
  • Dependency Management: Updated go.mod files to reflect the relocation, including adding pgregory.net/rapid to the fn package for testing.
  • Documentation: Updated the release notes to document the architectural change.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions Bot added the severity-medium Focused review required label Apr 10, 2026
@Abdulkbk Abdulkbk changed the title Move to fn fn: move Future/Promise from actor package Apr 10, 2026
@github-actions
Copy link
Copy Markdown

🟡 PR Severity: MEDIUM

Automated classification | 9 files | 125 lines changed

🟡 Medium (8 files)
  • actor/actor.go - actor package (uncategorized Go file → medium)
  • actor/go.mod - actor package module file
  • actor/interface.go - actor package (uncategorized Go file → medium)
  • actor/router.go - actor package (uncategorized Go file → medium)
  • fn/future.go - fn/* explicitly listed as medium
  • fn/go.mod - fn package module file
  • fn/go.sum - fn package module checksum
  • go.mod - root module file (uncategorized → medium)
🟢 Low (1 file)
  • docs/release-notes/release-notes-0.21.0.md - release notes / docs

Analysis

This PR modifies fn/future.go (renamed/updated) and the actor package, along with associated module files. Neither fn/* nor actor/* fall into the critical or high severity categories — fn/* is explicitly listed as MEDIUM, and actor/* is an uncategorized Go package (also MEDIUM). The release notes addition is LOW. With only 9 non-test files changed and ~125 non-test lines, no severity bump criteria are triggered. The highest applicable severity is MEDIUM.


To override, add a severity-override-{critical,high,medium,low} label.
<!-- pr-severity-bot -->

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request migrates the Future and Promise types from the actor package to the fn package to serve as general-purpose async primitives, updating all internal references and module dependencies. Review feedback recommends renaming interface parameters to avoid shadowing the fn package name and reclassifying the change as a breaking change in the release notes for better visibility.

Comment thread fn/future.go
// returned. If the passed context is cancelled while waiting for the
// original future to complete, the new future will complete with the
// context's error.
ThenApply(ctx context.Context, fn func(T) T) Future[T]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The parameter name fn shadows the package name fn. This can lead to confusion and compilation errors if the package needs to be referenced within an implementation of this interface. It is better to use a more descriptive name like fApply, which is already used in the implementation.

Suggested change
ThenApply(ctx context.Context, fn func(T) T) Future[T]
ThenApply(ctx context.Context, fApply func(T) T) Future[T]

Comment thread fn/future.go
// future is ready. If the passed context is cancelled before the future
// completes, the callback function will be invoked with the context's
// error.
OnComplete(ctx context.Context, fn func(Result[T]))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The parameter name fn shadows the package name fn. Using a name like cFunc (as seen in the implementation) would avoid this shadowing and improve clarity.

Suggested change
OnComplete(ctx context.Context, fn func(Result[T]))
OnComplete(ctx context.Context, cFunc func(Result[T]))

Comment on lines +374 to +376
* [`Future` and `Promise` types have been moved](https://github.com/lightningnetwork/lnd/pull/10727)
from the `actor` package into the `fn` package, where they better belong as
general-purpose async primitives.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Moving the Future and Promise types from the actor package to the fn package is a breaking change for any external consumers of these packages. This entry should be moved from the 'Code Health' section to the 'Breaking Changes' section (starting around line 195) to ensure it is properly noticed by developers.

@saubyk saubyk added this to lnd v0.22 Apr 10, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in lnd v0.22 Apr 10, 2026
@saubyk saubyk added this to the v0.22.0 milestone Apr 10, 2026
@Abdulkbk Abdulkbk force-pushed the move-to-fn branch 2 times, most recently from 643f23e to bbc0f12 Compare April 13, 2026 10:25
@lightninglabs-deploy
Copy link
Copy Markdown
Collaborator

@Abdulkbk, remember to re-request review from reviewers when ready

Abdulkbk added 4 commits May 25, 2026 17:06
Moves the Future[T] and Promise[T] interfaces along with their
concrete implementations and NewPromise[T] constructor from the
actor package into fn, where they belong as general-purpose
async computation primitives.
Internal callers are updated to use fn.NewPromise directly.
Temporary replace directive to build against the local fn/v2 until the
Future/Promise changes are published as a new release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

severity-medium Focused review required

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

fn: move Future/Promise from actor to fn package

3 participants