Skip to content

[APPS][Connections Part 9] Trace imported connection ID values#365

Draft
sdkennedy2 wants to merge 1 commit into
graphite-base/365from
sdkennedy2/imported-connection-id-value-tracing-graph
Draft

[APPS][Connections Part 9] Trace imported connection ID values#365
sdkennedy2 wants to merge 1 commit into
graphite-base/365from
sdkennedy2/imported-connection-id-value-tracing-graph

Conversation

@sdkennedy2
Copy link
Copy Markdown
Collaborator

@sdkennedy2 sdkennedy2 commented May 13, 2026

Motivation

The backend connection ID stack can already find action-catalog calls in reachable backend helper modules, but it still fails closed when the connectionId value is imported from another local module. Real apps commonly keep connection IDs in shared connections or ids modules, so the manifest analysis needs to trace those imported static values without changing graph collection or reachability traversal.

Changes

This PR adds graph-aware import/export value tracing on top of the existing reachable module graph extraction. Module graph records now preserve enough resolved static import information for value tracing to map AST import/export source literals back to collected module records.

The connection ID resolver keeps the same same-module behavior by default, but graph extraction now passes an optional imported-value resolver. That resolver follows named imports, local export aliases, aliased re-exports, import/export relays, and unambiguous export * chains back to static exported constants or object roots. Imported object roots reuse the existing static object member resolver, so patterns like this are handled demand-first from an action-catalog call site:

import { CONNECTIONS } from './connections';

request({ connectionId: CONNECTIONS.HTTP.PROD, inputs: {} });

The implementation keeps the analysis conservative. Missing exports, mutable or reassigned exports, default and namespace imports, ambiguous star exports, import/export cycles, and unsupported object shapes still fail closed instead of silently producing an incomplete allowlist.

QA Instructions

Validated the apps plugin with typecheck, focused lint, focused AST/module graph tests, and the full apps plugin unit slice:

yarn workspace @dd/apps-plugin typecheck
yarn eslint packages/plugins/apps/src/backend/ast-parsing/connection-id-imports.ts packages/plugins/apps/src/backend/ast-parsing/connection-id-values.ts packages/plugins/apps/src/backend/ast-parsing/extract-connection-ids.ts packages/plugins/apps/src/backend/ast-parsing/extract-connection-ids-from-module-graph.ts packages/plugins/apps/src/backend/ast-parsing/module-graph.ts packages/plugins/apps/src/backend/ast-parsing/extract-connection-ids-from-module-graph.test.ts packages/plugins/apps/src/backend/ast-parsing/walk-module-graph.test.ts packages/plugins/apps/src/vite/backend-module-graph-collector.ts packages/plugins/apps/src/vite/backend-module-graph-collector.test.ts --quiet
yarn workspace @dd/tests test:unit packages/plugins/apps/src

Blast Radius

This affects High Code Apps backend connection ID manifest analysis for backend builds and dev backend execution. It only changes static analysis for app-local backend modules collected through the backend module graph; unsupported shapes continue to fail closed.

Documentation

@sdkennedy2 sdkennedy2 changed the title Trace imported backend connection ID values [APPS][Connections Part 9] Trace imported connection ID values May 13, 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: 98a8c40d8f

ℹ️ 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 +77 to +79
return sources.map((source, index) => {
const resolvedId = staticDependencies[index] ?? resolvedBySource.get(source) ?? source;
resolvedBySource.set(source, resolvedId);
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 Preserve dependency alignment when sources repeat

When a module imports/re-exports the same source more than once before another source, this index-based pairing shifts every later resolution because Rollup exposes importedIds/importedIdResolutions once per unique source. For example import './a'; import './a'; import { HTTP_ID } from './ids'; produces dependencies [a, ids], but this maps the second ./a to ids and leaves ./ids unresolved as the literal string, so imported connection IDs from ./ids fail as outside the collected graph. Reuse the cached resolution for a source before consuming the next dependency index, or build the mapping directly from Rollup's source order.

Useful? React with 👍 / 👎.

@sdkennedy2 sdkennedy2 marked this pull request as draft May 13, 2026 20:25
@sdkennedy2 sdkennedy2 changed the base branch from sdkennedy2/refactor-connection-id-extraction-modules to graphite-base/365 May 13, 2026 20:33
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