feat(framework): Propagate run source attribution - #7998
Conversation
There was a problem hiding this comment.
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_uifor HTTP,clifor gRPC) and normalization tounknown. - Extend
control_handlers.start_runwith a keyword-onlysourceparameter 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.RunStartSourceduplicates its allowed values in_RUN_START_SOURCES; deriving the set from theLiteralavoids future drift.
Consistency concerns
framework/py/flwr/superlink/extensions.pymodule 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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…to codex/run-source-best-effort * origin/codex/run-source-best-effort: Potential fix for pull request finding
There was a problem hiding this comment.
💡 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".
There was a problem hiding this comment.
💡 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".
Co-authored-by: Heng Pan <pan@flower.ai>
Co-authored-by: Heng Pan <pan@flower.ai>
There was a problem hiding this comment.
💡 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".
Summary
Follow-up to #7970, which introduced the run-started extension hook.
This PR propagates best-effort run-source attribution through the
StartRunentry points:unknown; callers may provide thex-flwr-run-sourceheader with an explicit source.unknown; callers may provide thex-flwr-run-sourcemetadata with an explicit source.automation.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