Skip to content

[APPS][Connections Part 6] Discover action calls in reachable modules#353

Draft
sdkennedy2 wants to merge 1 commit into
sdkennedy2/get-vite-plugin-refactorfrom
sdkennedy2/reachable-module-graph-call-sites
Draft

[APPS][Connections Part 6] Discover action calls in reachable modules#353
sdkennedy2 wants to merge 1 commit into
sdkennedy2/get-vite-plugin-refactorfrom
sdkennedy2/reachable-module-graph-call-sites

Conversation

@sdkennedy2
Copy link
Copy Markdown
Collaborator

@sdkennedy2 sdkennedy2 commented May 10, 2026

Motivation

Backend connection ID extraction previously only scanned the .backend.* entry module. That missed action-catalog calls hidden in local helper modules imported by a backend function, so the generated app manifest could omit required connection allowlists.

This PR now sits on top of build-plugins#357, which contains the behavior-neutral getVitePlugin ownership refactor. This diff is intended to focus on reachable module graph call-site discovery.

Changes

Adds an entry-scoped reachable local module graph pass for backend connection ID extraction. The transform hook now runs connection ID extraction asynchronously and passes a narrow graph context over Vite/Rollup resolution, loading, watch-file registration, and a TypeScript/JSX transform fallback.

The graph pass loads each local module reachable from the backend entry through static imports, named re-exports, and export *, then reuses the existing action-catalog call-site and same-module value resolver for each parsed module. This keeps the current value boundary intact: inline strings, same-module constants, and same-module object reads in reachable helpers work, while imported connection ID values still fail closed for the next PR.

Unsupported local graph shapes continue to fail closed when they could hide action-catalog calls, including unresolved local imports, local require, and local dynamic imports. Package imports, type-only imports/re-exports, virtual/generated files, and files outside the app root are skipped.

QA Instructions

Added tests.

Manual test app from the earlier combined branch:

  • Linked /Users/scott.kennedy/dd/test-action-catalog-app to this local @datadog/vite-plugin.
  • Verified dry production builds collect connection IDs from reachable helper modules with inline, same-module const, same-module object member, and export * re-export action calls.
  • Verified a reachable helper using an imported CONNECTIONS.HTTP value fails closed with imported connectionId object binding CONNECTIONS.
  • Verified staging upload with: NODE_TLS_REJECT_UNAUTHORIZED=0 DD_APPS_UPLOAD_ASSETS=1 dd-auth --domain="dd.datad0g.com" --actions-api -- npm run build
  • Verified dev-server execution through /__dd/executeAction returned {"success":true,"result":{"data":{"ok":true}}} for moduleGraphHttpProbe.

Staging app: https://app.datad0g.com/app-builder/apps/0e17a356-3929-4bf0-8ae9-e67955c6dc55
Uploaded version: 00741f10cdd6718d

Blast Radius

Affects the @dd/apps-plugin backend transform path for .backend.ts / .backend.js files. The change is limited to connection ID manifest analysis and dev/build watch dependencies; backend proxy generation and runtime execution contracts are unchanged.

Risk is primarily false positive fail-closed behavior for unsupported local graph patterns. Dynamic local imports, local require, and unresolved local static imports now intentionally fail when they could hide action-catalog calls.

Documentation

Copy link
Copy Markdown
Collaborator Author

sdkennedy2 commented May 10, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@sdkennedy2 sdkennedy2 changed the title Discover action calls in reachable modules [APPS][WIP] Discover action calls in reachable modules May 10, 2026
@sdkennedy2
Copy link
Copy Markdown
Collaborator Author

@codex review
@cursor review

Copy link
Copy Markdown

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

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: e118c97bcd

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +103 to +104
if (!shouldResolveStaticDependency(dependency.specifier)) {
continue;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve aliased local imports before skipping dependencies

For backend files that import local helpers through a Vite/TS path alias such as @/backend/helpers/http, this guard treats the bare specifier as a package and skips it before calling context.resolve. Vite supports aliases for import/require specifiers (https://vite.dev/config/shared-options/#resolve-alias), so an aliased helper can resolve back under buildRoot; skipping it means any action-catalog calls in that helper are never scanned and the generated manifest silently omits their allowedConnectionIds.

Useful? React with 👍 / 👎.

@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/reachable-module-graph-call-sites branch 2 times, most recently from 89e014a to 6e7a15a Compare May 10, 2026 23:06
@sdkennedy2 sdkennedy2 changed the base branch from sdkennedy2/same-module-connection-id-values to graphite-base/353 May 11, 2026 13:11
@sdkennedy2 sdkennedy2 force-pushed the graphite-base/353 branch from 908d3d4 to d7a3e8c Compare May 11, 2026 15:52
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/reachable-module-graph-call-sites branch from 6e7a15a to 93ee73a Compare May 11, 2026 15:52
@sdkennedy2 sdkennedy2 changed the base branch from graphite-base/353 to sdkennedy2/get-vite-plugin-refactor May 11, 2026 15:52
@sdkennedy2 sdkennedy2 changed the title [APPS][WIP] Discover action calls in reachable modules [APPS][Connections Part 6] Discover action calls in reachable modules May 11, 2026
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/get-vite-plugin-refactor branch from d7a3e8c to cb0c1ca Compare May 11, 2026 16:54
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/reachable-module-graph-call-sites branch 2 times, most recently from 1b1f8fa to 5e9d380 Compare May 11, 2026 17:50
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/get-vite-plugin-refactor branch 2 times, most recently from 5ce434d to 67e2595 Compare May 11, 2026 18:58
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/reachable-module-graph-call-sites branch from 5e9d380 to fc121d3 Compare May 11, 2026 18:58
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/get-vite-plugin-refactor branch from 67e2595 to ad770f4 Compare May 11, 2026 19:04
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/reachable-module-graph-call-sites branch 2 times, most recently from 32a0e6f to 4297d54 Compare May 11, 2026 19:09
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/reachable-module-graph-call-sites branch from 4297d54 to c0eab57 Compare May 11, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant