Skip to content

[APPS][Connections Part 12] Use static definitions for imported connection IDs#375

Draft
sdkennedy2 wants to merge 2 commits into
graphite-base/375from
sdkennedy2/connection-id-definition-resolution
Draft

[APPS][Connections Part 12] Use static definitions for imported connection IDs#375
sdkennedy2 wants to merge 2 commits into
graphite-base/375from
sdkennedy2/connection-id-definition-resolution

Conversation

@sdkennedy2
Copy link
Copy Markdown
Collaborator

@sdkennedy2 sdkennedy2 commented May 16, 2026

Motivation

This is the next PR in the backend connection ID analysis stack. The previous PR adds a domain-neutral static definition resolver that can follow identifier references through named imports, export aliases, re-exports, and star exports. Connection ID extraction can now reuse that resolver instead of maintaining its own import/export traversal.

Changes

Wires module-graph connection ID extraction into the static definition resolver. extractConnectionIds(...) now requires ParsedModuleRecord and module-map context so connection-id-values.ts can resolve the actual connectionId identifier, or the root identifier of a member expression, through resolveStaticDefinitionForIdentifier(...) and evaluate the returned const binding in the module where that definition lives.

Supported cases:

  • Imported string constants
  • Imported static template literals without interpolation
  • Imported const-to-const chains across module contexts
  • Imported object roots such as CONNECTIONS.HTTP
  • Imported nested object member paths such as CONNECTIONS.HTTP.PROD
  • Local export aliases
  • Named re-export aliases
  • Local import/export relays
  • Unambiguous star exports
  • Existing same-module inline, const, and object connection IDs

Unsupported cases continue to fail closed with connection ID errors:

  • Missing exports
  • Ambiguous star exports
  • Import/export cycles
  • Default imports
  • Namespace imports
  • Mutable bindings
  • Reassigned bindings
  • Unsupported top-level declarations and binding patterns
  • Dynamic object shapes already rejected by the object resolver

This removes the older optional same-module binding-map path from connection ID value resolution. Same-module identifiers now use the same static definition resolver as imported identifiers.

QA Instructions

No manual QA needed. This is an internal AST-analysis change covered by unit tests and does not change manifest wiring outside the backend connection ID extractor.

Blast Radius

This affects High Code Apps backend connection ID extraction in @dd/apps-plugin when analyzing reachable app-local backend modules. It expands supported static import/re-export shapes while preserving fail-closed behavior for unsupported module graph and value shapes.

Documentation

Copy link
Copy Markdown
Collaborator Author

sdkennedy2 commented May 16, 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 Use static definitions for connection IDs [APPS][Connections Part 12] Use static definitions for imported connection IDs May 16, 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: 2090651bdb

ℹ️ 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 +572 to +577
if (context.moduleGraph) {
const definition = resolveStaticDefinitionForIdentifier(
context.moduleGraph.modules,
context.moduleGraph.moduleId,
node,
);
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 Reject imported object bindings mutated through aliases

When an imported object root is resolved here, a definition module can still change the runtime value through a local alias, e.g. export const CONNECTIONS = { HTTP: 'conn-a' }; const ALIAS = CONNECTIONS; ALIAS.HTTP = 'conn-b';. I checked the mutation tracking in module-graph.ts, and member assignments only mark the assigned root variable (ALIAS) unsupported, not the original CONNECTIONS binding, so this path now records conn-a instead of failing closed or seeing the runtime value. Previously imported object roots were rejected, so this is a new false allowlist for that alias-mutation shape.

Useful? React with 👍 / 👎.

@sdkennedy2 sdkennedy2 changed the base branch from sdkennedy2/static-definition-resolution to graphite-base/375 May 16, 2026 18:13
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