Add AGENTS.md review guidance: --embed-package on frontend plugins risks breaking singleton API references
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- documentation, frontend, tooling
Research direction
Start with AGENTS.md and the existing “Overlay vs Patch” and “Major Version Bumps in Patches” sections, then review plugins-list.yaml entries for frontend-plugin and backend --embed-package usage. Add the requested guidance on Module Federation singleton identity and review criteria, and validate it against the next three review-agent runs affecting frontend entries.
Written by the indexing model from the issue text.
Description
What happened
In PR #3524, --embed-package flags were added for orchestrator-form-api, orchestrator-form-react, and orchestrator-common to two frontend plugin entries in plugins-list.yaml. The review agent (run 33641873741) approved it by verifying that backend plugins in the same file already use --embed-package, concluding the pattern was safe. A domain expert (davidfestal) later identified the solution as invalid, and the PR was closed without merging.
The root cause: frontend dynamic plugins use Module Federation (Scalprum/Webpack). When --embed-package bundles a web-library that defines a createApiRef singleton (like orchestratorFormApiRef), each frontend plugin gets its own copy of the singleton object. Two copies means two different object references in Backstage's ApiHolder Map — the provider plugin (orchestrator-form-widgets) registers with one ref, the consumer (orchestrator) looks up another, and the API lookup fails silently at runtime. This does not affect backend plugins, which load as separate Node.js modules with no shared singleton registry.
What could go better
The review agent had no guidance distinguishing frontend and backend --embed-package semantics. AGENTS.md documents overlay vs patch mechanics and major version bump risks, but does not explain that frontend plugins share a browser runtime via Module Federation where singleton identity matters, while backend plugins run in isolated Node.js modules where duplication is safe.
Without this guidance, the agent applied pattern-matching logic: "backend plugins in this file already embed packages, so the same pattern is safe for frontend plugins." This is a reasonable heuristic that happens to be wrong for this specific architectural reason. Confidence is high that adding explicit guidance would prevent this class of false positive — the review agent demonstrably follows AGENTS.md constraints when they exist (it correctly applied major-version-bump review criteria in other PRs).
Note: existing issue #3539 covers a related but distinct concern (embed-package libraries not getting standalone metadata entries). This proposal addresses the runtime singleton identity problem, which is a separate failure mode not covered by any open issue.
Proposed change
Add a new section to AGENTS.md under "Working with Workspaces" (near the existing "Overlay vs Patch" and "Major Version Bumps in Patches" sections) titled "Embedding packages in frontend vs backend plugins."
The section should explain:
-
Backend plugins load as separate Node.js modules. Embedding creates isolated copies of dependencies — safe because no shared singleton registry exists across backend modules.
-
Frontend plugins use Module Federation (Scalprum/Webpack). Each plugin runs in the same browser runtime but in a separate Webpack container. Embedding a dependency creates a private copy inside the container.
-
The singleton identity problem: When a web-library defines a
createApiRefsingleton (via Backstage'screateApiRef), two frontend plugins that both embed that library will each get a separate object reference. Backstage'sApiHolderuses a Map keyed by object identity, so the provider's ref and the consumer's ref are different objects — the API lookup returnsundefinedat runtime. -
Review criteria for
--embed-packageon frontend plugins:- When a PR adds
--embed-packagefor a web-library to afrontend-pluginentry inplugins-list.yaml, check whether that library defines anycreateApiRefcalls, React contexts, or other singleton patterns. - If it does, and multiple frontend plugins in the same workspace would embed the same library, flag the change as a potential runtime failure and request human review.
- This does NOT apply to
-commonor-nodesuffixed packages that contain only types, interfaces, and constants (nocreateApiRefor context providers). - Embedding web-libraries in a single frontend plugin (not shared across plugins) is safe.
- When the PR claims to fix a build-pipeline issue (e.g., BODY DRIFT, sync-midstream scrubbing), verify the fix doesn't introduce a runtime regression in the plugin architecture.
- When a PR adds
Validation criteria
The next time a PR proposes adding --embed-package for a web-library to frontend plugin entries in plugins-list.yaml, the review agent should either: (a) flag the singleton identity risk and request human review, or (b) verify the embedded package contains no createApiRef or context provider patterns before approving. Validate against the next 3 review agent runs that touch plugins-list.yaml frontend entries with --embed-package changes.
Generated by retro agent from https://github.com/redhat-developer/rhdh-plugin-export-overlays/pull/3524
- Dominant language
- TypeScript
- Stars
- 9
- Forks
- 72
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 133
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from redhat-developer/rhdh-plugin-export-overlays
-
documentation non-workspace-changes ready-for-triage ready-to-code
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
redhat-developer/rhdh-plugin-export-overlays#3815 · 3 comments ·
-
documentation non-workspace-changes ready-for-triage ready-to-code
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
redhat-developer/rhdh-plugin-export-overlays#3810 · 3 comments ·
-
Add AGENTS.md review guidance: Prettier/ESLint/TypeScript violations in e2e-tests are CI-blocking Opendocumentation ready-for-triage ready-to-code
Difficulty 1/5 Under an hour Newbie friendliness 88/100
redhat-developer/rhdh-plugin-export-overlays#3792 · 3 comments ·
-
e2e-failure ready-to-code
Difficulty 1/5 Under an hour Newbie friendliness 88/100
redhat-developer/rhdh-plugin-export-overlays#3789 · 1 comment ·
-
e2e-failure ready-to-code
Difficulty 1/5 Under an hour Newbie friendliness 88/100
redhat-developer/rhdh-plugin-export-overlays#3788 · 1 comment ·
All issues in redhat-developer/rhdh-plugin-export-overlays
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100