Skip to content

feat(framework): Propagate run source attribution - #7998

Merged
tanertopal merged 25 commits into
mainfrom
codex/run-source-best-effort
Aug 26, 2026
Merged

feat(framework): Propagate run source attribution#7998
tanertopal merged 25 commits into
mainfrom
codex/run-source-best-effort

Conversation

@tanertopal

@tanertopal tanertopal commented Aug 25, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to #7970, which introduced the run-started extension hook.

This PR propagates best-effort run-source attribution through the StartRun entry points:

  • HTTP requests default to unknown; callers may provide the x-flwr-run-source header with an explicit source.
  • Direct gRPC requests default to unknown; callers may provide the x-flwr-run-source metadata with an explicit source.
  • Automation continues to use automation.
  • Invalid source values normalize to unknown.

The companion Labs changes are in flwrlabs/labs#780, stacked on #730.

Attribution contract

This value is for analytics only and is never used for authentication or authorization. A user can only affect the analytics label for their own request, so we assume users will not intentionally corrupt their own analytics and keep this deliberately best effort.

Validation

  • Focused Flower pytest suite
  • SuperGrid analytics pytest suite
  • Ruff, Black, and isort checks
  • TypeScript tests and type-check in the companion Labs changes

Copilot AI lite review requested due to automatic review settings August 25, 2026 11:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Propagates best-effort “run source” attribution (analytics-only) through the HTTP and gRPC StartRun entrypoints and forwards it into the run-started extension notification hook, preserving automation for scheduled runs.

Changes:

  • Add HTTP header + gRPC metadata intake for x-flwr-run-source, with defaults (web_ui for HTTP, cli for gRPC) and normalization to unknown.
  • Extend control_handlers.start_run with a keyword-only source parameter and notify extensions after persisting the run.
  • Add focused unit tests covering normalization, propagation, and extension notification behavior.

Critical issues

  • None found.

Simplicity/readability suggestions

  • extensions.RunStartSource duplicates its allowed values in _RUN_START_SOURCES; deriving the set from the Literal avoids future drift.

Consistency concerns

  • framework/py/flwr/superlink/extensions.py module docstring still says “FastAPI extension hooks” even though it now also includes non-FastAPI (gRPC/control) run-start attribution/notification utilities.

Whether the PR should be split

  • No, the changes are cohesive around run-source attribution + notification + tests.

Overall verdict

Low-risk, cohesive change with good targeted test coverage; only minor maintainability/documentation nits.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
framework/py/flwr/superlink/servicer/control/control_servicer.py Extract run-source from gRPC metadata and forward normalized source into handler.
framework/py/flwr/superlink/servicer/control/control_servicer_test.py Add tests for gRPC metadata forwarding + defaulting behavior.
framework/py/flwr/superlink/servicer/control/control_handlers.py Add source param, notify extensions after persisting run, preserve automation source.
framework/py/flwr/superlink/servicer/control/control_handlers_test.py Verify notification is invoked for persisted runs with the expected source.
framework/py/flwr/superlink/routers/control/router.py Accept x-flwr-run-source header and forward normalized source into handler (default web_ui).
framework/py/flwr/superlink/routers/control/router_test.py Add tests for HTTP default source + header override.
framework/py/flwr/superlink/extensions.py Add source normalization, run-start source typing/constants, and extension notification hook.
framework/py/flwr/superlink/extensions_test.py Add tests for normalization and extension notification snapshot/isolation behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread framework/py/flwr/superlink/extensions.py Outdated
Comment thread framework/py/flwr/superlink/extensions.py Outdated
@github-actions github-actions Bot added the Maintainer Used to determine what PRs (mainly) come from Flower maintainers. label Aug 25, 2026
tanertopal and others added 3 commits August 25, 2026 14:41
@tanertopal
tanertopal enabled auto-merge (squash) August 25, 2026 12:50

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 03eee2e623

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread framework/py/flwr/superlink/servicer/control/control_servicer.py Outdated
Comment thread framework/py/flwr/superlink/servicer/control/control_servicer.py Outdated
Comment thread framework/py/flwr/superlink/extensions.py Outdated
Comment thread framework/py/flwr/superlink/routers/control/router.py
Comment thread framework/py/flwr/superlink/servicer/control/control_servicer.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a2e3a518a1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread framework/py/flwr/superlink/servicer/control/control_servicer.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

smoroso
smoroso previously approved these changes Aug 26, 2026
Comment thread framework/py/flwr/superlink/servicer/control/control_servicer.py Outdated
Comment thread framework/py/flwr/superlink/extensions.py Outdated
Comment thread framework/py/flwr/superlink/servicer/control/control_servicer.py
Comment thread framework/py/flwr/superlink/extensions.py Outdated
Comment thread framework/py/flwr/superlink/extensions.py Outdated
Comment thread framework/py/flwr/superlink/dependencies/run_source.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Comment thread framework/e2e/test_control_api.sh
Comment thread framework/py/flwr/superlink/run_source.py Outdated

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

LGTM!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7f635e50a3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread framework/e2e/test_control_api.sh
@tanertopal
tanertopal merged commit cabef3a into main Aug 26, 2026
69 checks passed
@tanertopal
tanertopal deleted the codex/run-source-best-effort branch August 26, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Maintainer Used to determine what PRs (mainly) come from Flower maintainers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants