Skip to content

[APPS][Connections Part 6] Collect backend action calls during backend builds#353

Draft
sdkennedy2 wants to merge 4 commits into
masterfrom
sdkennedy2/reachable-module-graph-call-sites
Draft

[APPS][Connections Part 6] Collect backend action calls during backend builds#353
sdkennedy2 wants to merge 4 commits into
masterfrom
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 sits on top of build-plugins#357, which contains the behavior-neutral getVitePlugin ownership refactor. This diff focuses on reachable helper-module action-catalog discovery.

Changes

Moves reachable action-catalog discovery out of the frontend .backend.* transform and into the dedicated backend build path. The frontend transform now stays narrow: it discovers backend exports, registers backend functions with placeholder allowlists, and generates proxy modules.

Adds a backend-build collector plugin that observes parsed modules during the backend vite.build used for production upload and dev execution. The collector records parsed module records keyed by normalized module ID, then computes the backend entry's conservative file-level allowlist from the collected backend module graph.

This avoids duplicating Rollup/Vite resolution and loading in the frontend transform. Production backend builds now return enriched BackendFunction[] before manifest upload, and dev execution enriches the selected backend function before sending allowedConnectionIds to Datadog.

The value boundary remains unchanged: 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 local dynamic imports, non-literal dynamic imports, local require, and uncollected local static imports.

QA Instructions

Automated verification run locally:

  • yarn workspace @dd/apps-plugin typecheck
  • yarn workspace @dd/tests test:unit packages/plugins/apps/src/backend/ast-parsing/module-graph-connection-ids.test.ts packages/plugins/apps/src/vite/dev-server.test.ts packages/plugins/apps/src/index.test.ts packages/plugins/apps/src/vite/index.test.ts --runInBand
  • yarn eslint packages/plugins/apps/src/backend/ast-parsing/module-graph-connection-ids.ts packages/plugins/apps/src/backend/ast-parsing/module-graph-connection-ids.test.ts packages/plugins/apps/src/vite/backend-connection-id-collector.ts packages/plugins/apps/src/vite/build-config.ts packages/plugins/apps/src/vite/build-backend-functions.ts packages/plugins/apps/src/vite/dev-server.ts packages/plugins/apps/src/vite/dev-server.test.ts packages/plugins/apps/src/vite/index.ts packages/plugins/apps/src/index.test.ts --quiet

Manual staging/test-app verification still needs to be rerun after this backend-build collector rewrite.

Blast Radius

Affects @dd/apps-plugin backend function build/upload and dev execution paths for .backend.ts / .backend.js files. Backend proxy generation and runtime execution contracts are unchanged.

Risk is primarily fail-closed behavior for unsupported local graph patterns or collector visibility edge cases in the backend build. The implementation intentionally keeps analysis scoped to modules observed by the backend build instead of scanning the full project.

Documentation

Copy link
Copy Markdown
Collaborator Author

sdkennedy2 commented May 10, 2026

@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 3 times, most recently from 4297d54 to c0eab57 Compare May 11, 2026 22:22
@sdkennedy2 sdkennedy2 changed the title [APPS][Connections Part 6] Discover action calls in reachable modules [APPS][Connections Part 6] Collect backend action calls during backend builds May 12, 2026
Base automatically changed from sdkennedy2/get-vite-plugin-refactor to master May 12, 2026 18:21
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/reachable-module-graph-call-sites branch from 0e3d954 to b941937 Compare May 12, 2026 18:42
@datadog-official
Copy link
Copy Markdown

Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 2 Tests failed

Bundling Bundler: esbuild Should not throw on easy project. from ../tools/src/rollupConfig.test.ts   View in Datadog   (Fix with Cursor)
The blob could not be read
Bundling Bundler: esbuild Should not throw on hard project. from ../tools/src/rollupConfig.test.ts   View in Datadog   (Fix with Cursor)
The blob could not be read

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: b941937 | Docs | Datadog PR Page | Give us feedback!

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