Skip to content

chore: Collapse the Compile tool's redundant intermediate DTO layer - #1514

Merged
hatayama merged 3 commits into
v3-betafrom
refactor/c2-collapse-compile-dto-layers
Jul 5, 2026
Merged

hatayama merged 3 commits into
v3-betafrom
refactor/c2-collapse-compile-dto-layers

Conversation

@hatayama

@hatayama hatayama commented Jul 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Removes the Compile tool's intermediate DTO layer (IUnityCliLoopCompilationService, UnityCliLoopCompileRequest, UnityCliLoopCompileIssue, UnityCliLoopCompileResult), which only performed field-by-field copies between the wire DTOs and the compile pipeline.

User Impact

  • No user-visible change. The compile tool response and the get-compile-status result JSON stay byte-identical.

Changes

  • The compile pipeline (CompileUseCase, CompilationExecutionService, CompileController, CompileSessionResultService) now uses CompileSchema / CompileResponse / CompileIssue directly.
  • CompileTool no longer needs its ToRequest/ToResponse/ToCompileIssues mapping helpers; it passes the schema through and returns the use case result.
  • UnityCliLoopCompileTypes.cs (the whole intermediate layer) is deleted. Repo-wide grep confirms no remaining references, including non-C# files.

Wire compatibility

  • CompileSessionResultService.StoreCompileResult serializes the stored result into Editor SessionState, and that JSON is returned verbatim to the CLI via get-compile-status. CompileResponse extends an empty base class and declares the same 7 properties in the same order and nullability as the deleted UnityCliLoopCompileResult, and JsonRpcResponseSerializer.Settings uses no contract resolver, so the stored JSON shape is unchanged (asserted by StoreCompileResult_WhenResultIsPersisted_UsesPascalCaseJson).

Verification

  • dist/darwin-arm64/uloop compile → 0 errors, 0 warnings.
  • dist/darwin-arm64/uloop run-tests --filter-type regex --filter-value "Compile.*Tests" → 48 passed, 0 failed, 0 skipped.

Review in cubic

The Compile pipeline used to carry a redundant intermediate DTO layer
(IUnityCliLoopCompilationService, UnityCliLoopCompileRequest,
UnityCliLoopCompileIssue, UnityCliLoopCompileResult) that only performed
field-for-field copies between the wire-facing CompileSchema / CompileResponse
and the internal CompileResult. The intermediate types had no external
consumers and added mapping code without changing behavior.

Route CompileSchema and CompileResponse directly through CompileUseCase,
CompilationExecutionService, CompileController, and CompileSessionResultService,
and delete the intermediate types. The session-state JSON that
StoreCompileResult writes stays byte-identical because CompileResponse has
the same declaration order, nullability, and PascalCase property names as
the old UnityCliLoopCompileResult, and both flow through the same
JsonRpcResponseSerializer settings without a contract resolver rename.
@coderabbitai

coderabbitai Bot commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@hatayama, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 45 seconds

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5c216e1b-6f69-4ca1-a2fd-4c812980b9a7

📥 Commits

Reviewing files that changed from the base of the PR and between f22494b and 3b62a61.

📒 Files selected for processing (2)
  • Packages/src/Editor/FirstPartyTools/Compile/CompileSessionResultService.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileUseCase.cs
📝 Walkthrough

Walkthrough

This PR migrates the compilation feature's request/response types from legacy UnityCliLoopCompileRequest/UnityCliLoopCompileResult/UnityCliLoopCompileIssue to CompileSchema/CompileResponse/CompileIssue across CompilationExecutionService, CompileController, CompileSessionResultService, CompileTool, CompileUseCase, and removes the legacy type definitions file. Tests are updated to match.

Changes

Compile Response Type Migration

Layer / File(s) Summary
Remove legacy type definitions
Packages/src/Editor/FirstPartyTools/Compile/UnityCliLoopCompileTypes.cs
Deletes the file containing IUnityCliLoopCompilationService, UnityCliLoopCompileRequest, UnityCliLoopCompileIssue, and UnityCliLoopCompileResult.
Session result service builds/stores CompileResponse
Packages/src/Editor/FirstPartyTools/Compile/CompileSessionResultService.cs
CreateCompileResult, CreateForceCompileResult, ToIssues, StoreCompileResult, and CompileResultRecordingContext.Create are retyped to construct/persist CompileResponse/CompileIssue[] and accept CompileSchema.
Controller and execution service wiring
Packages/src/Editor/FirstPartyTools/Compile/CompilationExecutionService.cs, Packages/src/Editor/FirstPartyTools/Compile/CompileController.cs
ExecuteCompilationAsync accepts CompileSchema; RecordCompileResultIfNeeded uses CompileResponse.
CompileUseCase retyped end-to-end
Packages/src/Editor/FirstPartyTools/Compile/CompileUseCase.cs
Removes IUnityCliLoopCompilationService implementation; CompileAsync and internal helpers (creation, storage, pending-request marking, logging, correlation id) use CompileSchema/CompileResponse/CompileIssue; removes legacy CreateIssue helper.
CompileTool direct passthrough
Packages/src/Editor/FirstPartyTools/Compile/CompileTool.cs
ExecuteAsync returns useCase.CompileAsync(...) directly, removing request/response conversion helpers.
Test updates for CompileResponse contract
Assets/Tests/Editor/CompileSessionResultServiceTests.cs
Tests use CompileResponse instead of legacy result types; persisted JSON assertions expanded to verify PascalCase field names.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CompileTool
  participant CompileUseCase
  participant CompileController
  participant CompileSessionResultService
  participant SessionState

  CompileTool->>CompileUseCase: CompileAsync(CompileSchema, ct)
  CompileUseCase->>CompileController: ExecuteCompilationAsync(CompileSchema, ct)
  CompileController->>CompileSessionResultService: CreateCompileResult(compilerMessages)
  CompileSessionResultService-->>CompileController: CompileResponse
  CompileController->>CompileSessionResultService: StoreCompileResult(CompileResponse)
  CompileSessionResultService->>SessionState: persist serialized CompileResponse JSON
  CompileController-->>CompileUseCase: compilation completed
  CompileUseCase-->>CompileTool: CompileResponse
Loading

Possibly related PRs

  • hatayama/unity-cli-loop#1237: Both PRs modify compile completion/missing-finish handling in CompileController, overlapping in how compile outcomes are represented and stored.
  • hatayama/unity-cli-loop#1282: Both PRs modify StoreCompileResult in CompileSessionResultService, directly touching the same persistence method.
  • hatayama/unity-cli-loop#1342: Both PRs change forced-compilation "unknown result" shaping and message contract in CompileSessionResultService.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: removing the redundant Compile tool DTO layer.
Description check ✅ Passed The description matches the changeset and accurately summarizes the refactor and its impact.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/c2-collapse-compile-dto-layers

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 8 files

Re-trigger cubic

Use the existing CompileIssue constructor instead of the CreateIssue
helper and object initializers, because the constructor only became
available once the intermediate DTO (which had no constructor) was
replaced by CompileIssue. Extend the PascalCase pinning test to cover
all seven stored properties, since CompileResponse now doubles as the
SessionState payload parsed by the CLI and no dedicated storage DTO
guards that shape anymore.
@hatayama

hatayama commented Jul 5, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
Packages/src/Editor/FirstPartyTools/Compile/CompileUseCase.cs (1)

145-162: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Redundant helper duplicates the CompileResponse constructor.

CreateCompileResult(bool?, int?, int?, CompileIssue[], CompileIssue[], string) has the exact same parameter order/types as the existing CompileResponse(bool?, int?, int?, CompileIssue[], CompileIssue[], string message = null) constructor. This is the same kind of redundant mapping this PR is removing elsewhere (the commit history already dropped the legacy CreateIssue helper for the same reason).

♻️ Proposed cleanup: drop the wrapper, call the constructor directly
-                CompileResponse response = CreateCompileResult(
-                    false,
-                    1,
-                    0,
-                    new[] { new CompileIssue(preparation.ErrorMessage, "", 0) },
-                    Array.Empty<CompileIssue>(),
-                    null);
+                CompileResponse response = new(
+                    false,
+                    1,
+                    0,
+                    new[] { new CompileIssue(preparation.ErrorMessage, "", 0) },
+                    Array.Empty<CompileIssue>());

(apply the same substitution at the two other call sites, lines 96-102 and 120-126)

-        private static CompileResponse CreateCompileResult(
-            bool? success,
-            int? errorCount,
-            int? warningCount,
-            CompileIssue[] errors,
-            CompileIssue[] warnings,
-            string message)
-        {
-            return new CompileResponse
-            {
-                Success = success,
-                ErrorCount = errorCount,
-                WarningCount = warningCount,
-                Errors = errors,
-                Warnings = warnings,
-                Message = message,
-            };
-        }
-
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Packages/src/Editor/FirstPartyTools/Compile/CompileUseCase.cs` around lines
145 - 162, Remove the redundant CreateCompileResult helper in CompileUseCase and
construct CompileResponse directly instead, since it duplicates the
CompileResponse(bool?, int?, int?, CompileIssue[], CompileIssue[], string)
constructor exactly. Update the call sites in CompileUseCase that currently use
CreateCompileResult so they instantiate CompileResponse inline with the same
arguments, matching the cleanup already done for CreateIssue.
Packages/src/Editor/FirstPartyTools/Compile/CompileSessionResultService.cs (1)

20-53: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Same constructor-vs-initializer redundancy as CompileUseCase.CreateCompileResult.

The CompileResponse object initializers here (and in CreateForceCompileResult, lines 101-113) populate the exact same fields the CompileResponse(bool?, int?, int?, CompileIssue[], CompileIssue[], string) constructor already accepts. Not a functional issue, but worth consolidating with the constructor since this file is the canonical place doing that mapping now that the DTO layer is gone.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Packages/src/Editor/FirstPartyTools/Compile/CompileSessionResultService.cs`
around lines 20 - 53, The CompileResponse construction in CreateCompileResult
(and the matching path in CreateForceCompileResult) is duplicating the same
field mapping already covered by the CompileResponse(bool?, int?, int?,
CompileIssue[], CompileIssue[], string) constructor. Replace the object
initializers with the constructor call so CompileSessionResultService becomes
the single canonical mapping point, and keep the existing logic for
indeterminate results, force-recompile handling, and
AddMissingTestFrameworkReferenceHint intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@Packages/src/Editor/FirstPartyTools/Compile/CompileSessionResultService.cs`:
- Around line 20-53: The CompileResponse construction in CreateCompileResult
(and the matching path in CreateForceCompileResult) is duplicating the same
field mapping already covered by the CompileResponse(bool?, int?, int?,
CompileIssue[], CompileIssue[], string) constructor. Replace the object
initializers with the constructor call so CompileSessionResultService becomes
the single canonical mapping point, and keep the existing logic for
indeterminate results, force-recompile handling, and
AddMissingTestFrameworkReferenceHint intact.

In `@Packages/src/Editor/FirstPartyTools/Compile/CompileUseCase.cs`:
- Around line 145-162: Remove the redundant CreateCompileResult helper in
CompileUseCase and construct CompileResponse directly instead, since it
duplicates the CompileResponse(bool?, int?, int?, CompileIssue[],
CompileIssue[], string) constructor exactly. Update the call sites in
CompileUseCase that currently use CreateCompileResult so they instantiate
CompileResponse inline with the same arguments, matching the cleanup already
done for CreateIssue.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f047a388-8f72-4858-a12e-c7d6b5d1334f

📥 Commits

Reviewing files that changed from the base of the PR and between 35d904c and f22494b.

⛔ Files ignored due to path filters (1)
  • Packages/src/Editor/FirstPartyTools/Compile/UnityCliLoopCompileTypes.cs.meta is excluded by none and included by none
📒 Files selected for processing (7)
  • Assets/Tests/Editor/CompileSessionResultServiceTests.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompilationExecutionService.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileController.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileSessionResultService.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileTool.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileUseCase.cs
  • Packages/src/Editor/FirstPartyTools/Compile/UnityCliLoopCompileTypes.cs
💤 Files with no reviewable changes (1)
  • Packages/src/Editor/FirstPartyTools/Compile/UnityCliLoopCompileTypes.cs

CodeRabbit flagged that the CreateCompileResult helper and the
remaining object initializers duplicate the CompileResponse
constructor, mirroring the CreateIssue cleanup already applied.
Named arguments keep the adjacent nullable counts and issue arrays
from being swapped silently.
@hatayama
hatayama merged commit bf0cb79 into v3-beta Jul 5, 2026
10 checks passed
@hatayama
hatayama deleted the refactor/c2-collapse-compile-dto-layers branch July 5, 2026 09:56
RyanXie123 pushed a commit to RyanXie123/unity-cli-loop that referenced this pull request Sep 22, 2026
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