Skip to content

Add traceAPIDependency debug utility for inspecting transitive API de… - #348

Merged
vladik7244 merged 1 commit into
masterfrom
trace-api-dependency
Apr 26, 2026
Merged

vladik7244 merged 1 commit into
masterfrom
trace-api-dependency

Conversation

@vladik7244

Copy link
Copy Markdown
Contributor

…pendencies

Exposes two new helpers on globalThis.repluggableAppDebug.utils:

  • traceAPIDependency(entryPoint, api): returns a DependencyTree showing every route through which the entry point transitively depends on the API, built in-place during DFS (no flat paths intermediate).
  • visualizeDependencyTree(tree): renders the tree as an ASCII diagram, with shared prefixes collapsed.

@vladik7244
vladik7244 force-pushed the trace-api-dependency branch from e1c9382 to 7349567 Compare April 22, 2026 17:34
…pendencies

Exposes two new helpers on globalThis.repluggableAppDebug.utils:
- traceAPIDependency(entryPoint, api): returns a DependencyTree showing
  every route through which the entry point transitively depends on the
  API, built in-place during DFS (no flat paths intermediate).
- visualizeDependencyTree(tree): renders the tree as an ASCII diagram,
  with shared prefixes collapsed.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vladik7244
vladik7244 force-pushed the trace-api-dependency branch from 7349567 to f06fdc1 Compare April 22, 2026 18:43

@itsh01 itsh01 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good. See 2 minor comments

entryPoints = [...addedShells.values()].map(x => x.entryPoint)
) => getAPIOrEntryPointsDependencies(apisOrEntryPointsNames, entryPoints),
traceAPIDependency: (entryPointName: string, apiName: string): DependencyTree | null =>
traceAPIDependency(entryPointName, apiName, [...getUnreadyEntryPoints(), ...[...addedShells.values()].map(x => x.entryPoint)]),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why not reuse getAllEntryPoints?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It throws "not implemented" error in runtime

Comment on lines +32 to +36
getAPIOrEntryPointsDependencies(
apisOrEntryPointsNames: string[],
entryPoints?: EntryPoint[]
): { entryPoints: EntryPoint[]; apis: AnySlotKey[] }
traceAPIDependency(entryPointName: string, apiName: string): DependencyTree | null

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These public signatures are inconsistent with the rest of the API and also with themselves.

Did you expose (getAPIOrEntryPointsDependencies) in public signature on purpose (+ isn't it weird that someone would need to provide an entrypoints array for the debug tool, or is there a use-case you know of)?

Why do you need entryPointName instead of deriving it by searching the declarer of the API?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I just added types. The implementation itself is already there, and it accepts a list of entryPoints. Not sure if there are real use cases for that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

EntryPointName is the starting point.
The goal is to visualize subtree of dependencies starting from this entry point to the specific API.

Use case: we have one entry point that we don't want to be dependant on the DocumentServicesAPI, because this entry point should be executed as early as possible (to show welcome screen). So adding documentServices even transitively will make it appear much later.

So this utility should make it easy to understand if provided entry point is dependant on the provided api, and if yes - visualise why exactly

@vladik7244
vladik7244 merged commit 0b581bb into master Apr 26, 2026
2 checks passed
@vladik7244
vladik7244 deleted the trace-api-dependency branch April 26, 2026 11:03
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.

2 participants