Skip to content

Conversation

@darvld
Copy link
Member

@darvld darvld commented Jun 25, 2025

Ready for review Powered by Pull Request Badge

Summary

This PR refactors the tooling module, moving part of it to a new builder package, which now contains all code related to Elide's build tools. The goal is to keep in tooling only the public APIs that third-party integrations expect when interfacing with Elide, for example, to provide IDE support, which will be prototyped in an upcoming Pull Request.

Note

The module name changes are up for discussion; a rationale is provided below for the current choice.

Motivation

Certain features of Elide's tooling, such as lockfiles and project manifests, can be very useful for developing integrations with IDEs and other tools; however, they are currently mixed in with the code that configures and builds user projects. Since integrations are unlikely to call said code directly (they would use the Elide binary instead), it would be convenient for them to have access to only the APIs and models necessary to understand an Elide project, while ensuring that their behavior is consistent with the Elide distributions being used.

Notable changes

  • The tooling module now only contains code related to Elide Lockfile management, abstract tool APIs (basic interfaces that are specialized and implemented in the CLI), and part of the project manifest code.
  • The new builder module was added to contain all logic related to resolving, configuring, and building Elide projects, based on the API definitions from tooling.
  • Some interfaces and types previously hosted in engine have been moved to tooling, specifically, those formerly in the elide.tool package (now in elide.tooling, for naming consistency).
  • The EnvVar sealed interface hierarchy, which is used across several modules, and was previously nested within the env plugin in the graalvm module, has been moved to base; this allows it to be used by all modules freely without becoming coupled to most of the runtime transitively. Since the concept of resolvable environment variables is generic enough, the change has no significant semantic implications.
  • Other minor changes to package names to improve consistency of the naming schemes (e.g. elide.tool -> elide.tooling outside of the cli module).

darvld added 4 commits June 24, 2025 22:05
Signed-off-by: Dario Valdespino <dvaldespino00@gmail.com>
Signed-off-by: Dario Valdespino <dvaldespino00@gmail.com>
Signed-off-by: Dario Valdespino <dvaldespino00@gmail.com>
Signed-off-by: Dario Valdespino <dvaldespino00@gmail.com>
@darvld darvld self-assigned this Jun 25, 2025
@darvld darvld requested a review from sgammon as a code owner June 25, 2025 02:52
@darvld darvld added enhancement New feature or request tools Issues and PRs related to tooling labels Jun 25, 2025
@darvld darvld changed the title Feat/tooling api refactor: split tooling api from builder code Jun 25, 2025
@claude

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Jun 25, 2025

Codecov Report

Attention: Patch coverage is 1.58730% with 310 lines in your changes missing coverage. Please review.

Project coverage is 40.54%. Comparing base (4e26cf3) to head (121256e).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
...n/kotlin/elide/tooling/jvm/JvmBuildConfigurator.kt 0.00% 125 Missing ⚠️
...n/kotlin/elide/tooling/project/SourceSetFactory.kt 0.00% 59 Missing ⚠️
...ng/gvm/nativeImage/NativeImageBuildConfigurator.kt 0.00% 29 Missing ⚠️
...tooling/src/main/kotlin/elide/tooling/MultiPath.kt 15.15% 28 Missing ⚠️
...e/tooling/project/manifest/ElidePackageManifest.kt 0.00% 18 Missing ⚠️
...src/main/kotlin/elide/tooling/project/SourceSet.kt 0.00% 16 Missing ⚠️
...ilder/src/main/kotlin/elide/tooling/cli/Statics.kt 0.00% 8 Missing ⚠️
...kotlin/elide/tooling/project/ProjectEnvironment.kt 0.00% 7 Missing ⚠️
.../tooling/project/manifest/GradleCatalogManifest.kt 0.00% 6 Missing and 1 partial ⚠️
...tlin/elide/tooling/project/DefaultProjectLoader.kt 0.00% 5 Missing ⚠️
... and 5 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1500      +/-   ##
==========================================
- Coverage   41.99%   40.54%   -1.45%     
==========================================
  Files         680      698      +18     
  Lines       31366    32361     +995     
  Branches     4386     4517     +131     
==========================================
- Hits        13172    13121      -51     
- Misses      16627    17713    +1086     
+ Partials     1567     1527      -40     
Flag Coverage Δ
jvm 40.54% <1.58%> (-1.45%) ⬇️
lib 40.54% <1.58%> (-1.45%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...gvm/nativeImage/ElideNativeBuildConfiguration.java 0.00% <ø> (ø)
...ide/tooling/gvm/nativeImage/NativeImageResult.java 0.00% <ø> (ø)
...c/main/kotlin/elide/tooling/builder/BuildDriver.kt 0.00% <ø> (ø)
...rc/main/kotlin/elide/tooling/builder/TestDriver.kt 0.00% <ø> (ø)
.../kotlin/elide/tooling/config/BuildConfiguration.kt 0.00% <ø> (ø)
...n/kotlin/elide/tooling/config/BuildConfigurator.kt 0.00% <ø> (ø)
.../kotlin/elide/tooling/config/BuildConfigurators.kt 0.00% <ø> (ø)
...lide/tooling/config/CompositeBuildConfiguration.kt 0.00% <ø> (ø)
...elide/tooling/config/CompositeTestConfiguration.kt 0.00% <ø> (ø)
...n/kotlin/elide/tooling/config/TestConfiguration.kt 0.00% <ø> (ø)
... and 90 more

... and 13 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2d6857c...121256e. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines 145 to 141
@JvmRecord @Serializable public data class CatalogBundle internal constructor (
@JvmRecord @Serializable public data class CatalogBundle(
Copy link
Member

Choose a reason for hiding this comment

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

these all change often enough that it would be good to preserve internal if we can, otherwise the api pins will change constantly on this, and any coupling will break

maybe that's unavoidable anyway but effectively we've got two API surfaces here: pkl and the kotlin objects. if we could keep one of those internal and only couple to the public API surface in pkl, it would be ideal; thoughts? otoh we don't have codegen for this yet and adding @JvmStatic entrypoints would be a lot of code.

Copy link
Member Author

Choose a reason for hiding this comment

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

I moved the codec implementations to the tooling module (which I probably should have done before), so now there's no need for those constructors to be exposed.

darvld added 2 commits June 28, 2025 14:03
Signed-off-by: Dario Valdespino <dvaldespino00@gmail.com>
Signed-off-by: Dario Valdespino <dvaldespino00@gmail.com>
@claude
Copy link

claude bot commented Jun 28, 2025

Claude finished @darvld's task —— View job


PR Review: Tooling API Refactoring

Reviewing this large refactoring that splits the tooling module into separate concerns.

Todo List:

  • Read repository guidelines and setup
  • Review module structure and build configuration
  • Check architectural separation between tooling/builder
  • Verify moved code integrity and imports
  • Assess naming consistency and conventions
  • Look for potential circular dependencies
  • Check for any breaking changes or security concerns
  • Provide comprehensive review feedback

Analysis Results

Architectural Design

The refactoring achieves its stated goals well:

  • Clear separation: tooling now contains only public APIs (lockfiles, manifests, tool interfaces), perfect for IDE integrations
  • Build logic isolation: builder module properly encapsulates all build-related functionality
  • Dependency reduction: Moving EnvVar to base eliminates coupling to runtime modules

Module Structure & Dependencies

  • Builder module: Well-configured with proper dependencies on tooling, exec, engine, and GraalVM modules
  • Tooling module: Streamlined to focus on core APIs with dependencies on base and core
  • Service loading: Build configurators properly registered in META-INF/services

Code Migration Quality

  • Import updates: CLI modules correctly updated to use new builder package locations
  • EnvVar refactoring: Successfully moved to base with proper import updates (verified in graalvm module)
  • Package naming: Consistent use of elide.tooling vs elide.tool across modules

Implementation Details

  • Service configuration: All build/test configurators properly listed in service files
  • Static utilities: Statics.kt properly moved to builder with correct imports
  • Project loading: Clean abstraction with DefaultProjectLoader and extension functions

Issues Found

🚨 Critical Issue

Service registration mismatch in packages/builder/src/main/resources/META-INF/services/elide.tooling.config.BuildConfigurator:

  • References elide.tooling.js.JsBuildConfigurator
  • But this class is in the cli module at packages/cli/src/main/kotlin/elide/tooling/js/JsBuildConfigurator.kt
  • Service loader won't find this class at runtime when using the builder module standalone

🔧 Minor Issues

  1. API documentation: Consider adding KDoc to the new module separation to help future contributors understand the split
  2. Version compatibility: Ensure any existing integrations that depend on the old structure have migration guidance

Recommendations

💡 Suggestions

  1. Fix service registration: Either move JsBuildConfigurator to builder module or remove it from the service file
  2. Module naming: The current choice of builder vs tooling is good, but consider documenting the rationale in module README files
  3. API surface: Consider the review comment about keeping manifest constructors internal to reduce API coupling

Security & Performance

  • No security concerns: No secrets, credentials, or sensitive data handling changes
  • Performance impact: Minimal - primarily organizational changes with no algorithm modifications
  • Dependency management: Proper separation should improve build times by reducing transitive dependencies

Conclusion

This is a well-executed refactoring that successfully achieves its architectural goals. The separation of concerns is clean, imports are properly updated, and the module structure will serve IDE integrations well while keeping build complexity isolated.

Recommendation: ✅ Approve with fix - Address the service registration issue, then this refactoring improves the codebase architecture without introducing risks.


darvld added 5 commits June 28, 2025 14:31
Signed-off-by: Dario Valdespino <dvaldespino00@gmail.com>
Signed-off-by: Dario Valdespino <dvaldespino00@gmail.com>
Signed-off-by: Dario Valdespino <dvaldespino00@gmail.com>
Signed-off-by: Dario Valdespino <dvaldespino00@gmail.com>
Signed-off-by: Dario Valdespino <dvaldespino00@gmail.com>
@claude
Copy link

claude bot commented Jun 28, 2025

Claude finished @darvld's task —— View job


PR Review: Tooling API Refactoring

Reviewing this large refactoring that splits the tooling module into separate concerns.

Todo List:

  • Read repository guidelines and setup
  • Review module structure and build configuration
  • Check architectural separation between tooling/builder
  • Verify moved code integrity and imports
  • Assess naming consistency and conventions
  • Look for potential circular dependencies
  • Check for any breaking changes or security concerns
  • Provide comprehensive review feedback

Analysis Results

Architectural Design

The refactoring achieves its stated goals excellently:

  • Clear separation: tooling now contains only public APIs (lockfiles, manifests, tool interfaces), perfect for IDE integrations
  • Build logic isolation: builder module properly encapsulates all build-related functionality
  • Dependency reduction: Moving EnvVar to base eliminates coupling to runtime modules

Module Structure & Dependencies

  • Builder module: Well-configured with proper dependencies on tooling, exec, engine, and GraalVM modules
  • Tooling module: Streamlined to focus on core APIs with dependencies on base and core
  • Service loading: Build configurators properly registered in META-INF/services

Code Migration Quality

  • Import updates: CLI modules correctly updated to use new builder package locations (packages/cli/src/main/kotlin/elide/tool/cli/cmd/tool/kotlinc/KotlinCompilerAdapter.kt:30-43)
  • EnvVar refactoring: Successfully moved to base with proper import updates and formatting
  • Package naming: Consistent use of elide.tooling vs elide.tool across modules

Implementation Details

  • Service configuration: All build/test configurators properly listed in service files
  • Static utilities: Statics.kt properly moved to builder with correct imports
  • Project loading: Clean abstraction with DefaultProjectLoader (builder) and ElideProjectLoader interface (tooling)
  • API surface: Manifest constructors made internal to reduce API coupling (packages/tooling/src/main/kotlin/elide/tooling/project/manifest/GradleCatalogManifest.kt:46)

Testing Infrastructure

  • Proper test separation: Each module has appropriate test coverage
  • Shared test utilities: Common factories like RepositorySystemFactory duplicated where needed for module independence

Security & Performance

  • No security concerns: No secrets, credentials, or sensitive data handling changes
  • Performance impact: Minimal - primarily organizational changes with no algorithm modifications
  • Dependency management: Proper separation should improve build times by reducing transitive dependencies

Test Coverage

The 1.59% patch coverage is expected and acceptable for this type of refactoring:

  • Most changes are moved code rather than new logic
  • The goal is architectural improvement, not feature additions
  • Test infrastructure properly maintained in both modules

Conclusion

This is a well-executed refactoring that successfully achieves its architectural goals. The separation of concerns is clean, imports are properly updated, and the module structure will serve IDE integrations well while keeping build complexity isolated.

Recommendation: ✅ Approve - This refactoring significantly improves the codebase architecture without introducing risks.


@sgammon sgammon merged commit 3cd6f6c into main Jun 28, 2025
22 checks passed
@elidebot elidebot mentioned this pull request Jul 19, 2025
29 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request tools Issues and PRs related to tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants