Skip to content

chore: Split compile response persistence responsibilities#1546

Merged
hatayama merged 3 commits into
v3-betafrom
codex/c4-8-compile-session-result-split
Jul 6, 2026
Merged

chore: Split compile response persistence responsibilities#1546
hatayama merged 3 commits into
v3-betafrom
codex/c4-8-compile-session-result-split

Conversation

@hatayama

@hatayama hatayama commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Keeps compile behavior unchanged while separating response shaping from delayed status persistence.
  • Preserves delayed compile-result storage and the PascalCase JSON payload used by status polling.

User Impact

  • No user-facing behavior change. Compile responses and get-compile-status polling payloads stay the same.

Changes

  • Replaced CompileSessionResultService with CompileResponseFactory and CompileSessionResultStore.
  • Moved CompileResultRecordingContext into its own file outside the response factory.
  • Renamed the response factory method to CreateResponse to avoid colliding with CompileResultFactory.CreateCompileResult.
  • Split tests into response factory and store-focused fixtures while keeping assertions unchanged.

Verification

  • dist/darwin-arm64/uloop compile --project-path "<PROJECT_ROOT>" -> 0 errors / 0 warnings
  • dist/darwin-arm64/uloop run-tests --project-path "<PROJECT_ROOT>" --test-mode EditMode --filter-type regex --filter-value "CompileLifecycleWatchdogTests|CompileResponseFactoryTests|CompileSessionResultStoreTests|CompileStatusBridgeCommandTests|ExternalSceneChangeResolverTests" -> 38/38 passed

Review in cubic

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 33290356-cba4-4439-9aa4-7a6c42f399fc

📥 Commits

Reviewing files that changed from the base of the PR and between 1714e12 and fa97842.

📒 Files selected for processing (1)
  • Packages/src/Editor/FirstPartyTools/Compile/CompileResultRecordingContext.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • Packages/src/Editor/FirstPartyTools/Compile/CompileResultRecordingContext.cs

📝 Walkthrough

Walkthrough

CompileSessionResultService is removed and its logic is split into CompileResponseFactory, CompileSessionResultStore, and CompileResultRecordingContext. CompileController and CompileUseCase now use the new types, and tests were renamed and expanded for the new split.

Changes

Compile result service split

Layer / File(s) Summary
CompileResponseFactory: response mapping logic
Packages/src/Editor/FirstPartyTools/Compile/CompileResponseFactory.cs, Packages/src/Editor/FirstPartyTools/Compile/CompileResultFactory.cs
New static factory converts CompileResult into CompileResponse, handling force-recompile, indeterminate results, issue conversion, and missing test-framework hint logic; the result factory doc comment now references it.
CompileSessionResultStore and CompileResultRecordingContext
Packages/src/Editor/FirstPartyTools/Compile/CompileResultRecordingContext.cs, Packages/src/Editor/FirstPartyTools/Compile/CompileSessionResultStore.cs
New struct determines whether compile results should be recorded, and new store persists a CompileResponse to session state with validation, clearing of matching pending requests, and structured logging.
Call site updates in compile flow
Packages/src/Editor/FirstPartyTools/Compile/CompileController.cs, Packages/src/Editor/FirstPartyTools/Compile/CompileUseCase.cs
Compile response creation now uses CompileResponseFactory.CreateResponse, and persistence now uses CompileSessionResultStore.StoreCompileResult instead of the removed service methods.
Test suite updates for renamed/split components
Assets/Tests/Editor/CompileResponseFactoryTests.cs, Assets/Tests/Editor/CompileSessionResultStoreTests.cs
The response factory test fixture and method names were updated, and a new store test verifies PascalCase JSON persistence for stored compile results.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main refactor: splitting compile response persistence responsibilities.
Description check ✅ Passed The description matches the code changes and objectives, covering the factory/store split and unchanged behavior.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/c4-8-compile-session-result-split

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.

@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 (1)
Packages/src/Editor/FirstPartyTools/Compile/CompileResponseFactory.cs (1)

29-38: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Missing test coverage for the non-force-recompile indeterminate branch.

This branch (triggered e.g. from HandleCompileStoppedWithoutFinishEvent results with IsIndeterminate=true and forceRecompile=false) isn't exercised by any test in CompileResponseFactoryTests.cs. The only indeterminate-flagged test case (CreateResponse_WhenForceCompileIsUnknown_ExplainsNullDetails) actually short-circuits into CreateForceCompileResult since forceRecompile: true, never reaching this code path.

✅ Suggested additional test
[Test]
public void CreateResponse_WhenNonForceCompileIsIndeterminate_ExplainsNullDetails()
{
    CompileResult result = new CompileResult(
        success: null,
        errorCount: 0,
        warningCount: 0,
        completedAt: DateTime.Now,
        messages: Array.Empty<CompilerMessage>(),
        errors: Array.Empty<CompilerMessage>(),
        warnings: Array.Empty<CompilerMessage>(),
        isIndeterminate: true,
        message: null);

    CompileResponse response =
        CompileResponseFactory.CreateResponse(result, forceRecompile: false);

    Assert.That(response.Errors, Is.Null);
    Assert.That(response.Warnings, Is.Null);
    Assert.That(response.Message,
        Is.EqualTo("Compilation status is unknown. Use get-logs to inspect the compiler output."));
}
🤖 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/CompileResponseFactory.cs` around
lines 29 - 38, Add test coverage for the `CompileResponseFactory.CreateResponse`
indeterminate path when `forceRecompile` is false, since the existing
`CreateResponse_WhenForceCompileIsUnknown_ExplainsNullDetails` test only
exercises `CreateForceCompileResult`. Add a new test in
`CompileResponseFactoryTests` that builds a `CompileResult` with
`IsIndeterminate = true` and `forceRecompile: false`, then verifies the returned
`CompileResponse` has null `Errors` and `Warnings` and the fallback status
message. Use the existing `CompileResponseFactory.CreateResponse` and
`CompileResult` symbols to target the non-force-recompile branch directly.
🤖 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/CompileResponseFactory.cs`:
- Around line 29-38: Add test coverage for the
`CompileResponseFactory.CreateResponse` indeterminate path when `forceRecompile`
is false, since the existing
`CreateResponse_WhenForceCompileIsUnknown_ExplainsNullDetails` test only
exercises `CreateForceCompileResult`. Add a new test in
`CompileResponseFactoryTests` that builds a `CompileResult` with
`IsIndeterminate = true` and `forceRecompile: false`, then verifies the returned
`CompileResponse` has null `Errors` and `Warnings` and the fallback status
message. Use the existing `CompileResponseFactory.CreateResponse` and
`CompileResult` symbols to target the non-force-recompile branch directly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1fdef517-1f93-43f7-a17d-c8a95733d24e

📥 Commits

Reviewing files that changed from the base of the PR and between a48aaba and 1714e12.

⛔ Files ignored due to path filters (5)
  • Assets/Tests/Editor/CompileResponseFactoryTests.cs.meta is excluded by none and included by none
  • Assets/Tests/Editor/CompileSessionResultStoreTests.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Compile/CompileResponseFactory.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Compile/CompileResultRecordingContext.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Compile/CompileSessionResultStore.cs.meta is excluded by none and included by none
📒 Files selected for processing (9)
  • Assets/Tests/Editor/CompileResponseFactoryTests.cs
  • Assets/Tests/Editor/CompileSessionResultStoreTests.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileController.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileResponseFactory.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileResultFactory.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileResultRecordingContext.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileSessionResultService.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileSessionResultStore.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileUseCase.cs
💤 Files with no reviewable changes (1)
  • Packages/src/Editor/FirstPartyTools/Compile/CompileSessionResultService.cs

@hatayama

hatayama commented Jul 6, 2026

Copy link
Copy Markdown
Owner Author

Deferring the CodeRabbit indeterminate-response coverage nitpick to the planned follow-up PR. The suggestion is valid coverage, but this PR is intentionally move-only with test reference swaps/assertions preserved. The follow-up that pins indeterminate and validation response shapes before unifying them will include the IsIndeterminate=true and forceRecompile=false CreateResponse shape.

@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.

1 issue found and verified against the latest diff

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="Packages/src/Editor/FirstPartyTools/Compile/CompileResultRecordingContext.cs">

<violation number="1" location="Packages/src/Editor/FirstPartyTools/Compile/CompileResultRecordingContext.cs:30">
P2: Direct callers of CompilationExecutionService.ExecuteCompilationAsync can persist compile status with an unsafe RequestId, bypassing the safety contract CompileUseCase applies before storage. Consider keeping CompileResultRecordingContext.Create aligned with CompileRequestIdRules.IsSafe so malformed IDs do not corrupt the SessionState request index or scoped keys.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

{
Debug.Assert(request != null, "request must not be null");

if (!request.WaitForDomainReload || string.IsNullOrWhiteSpace(request.RequestId))

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: Direct callers of CompilationExecutionService.ExecuteCompilationAsync can persist compile status with an unsafe RequestId, bypassing the safety contract CompileUseCase applies before storage. Consider keeping CompileResultRecordingContext.Create aligned with CompileRequestIdRules.IsSafe so malformed IDs do not corrupt the SessionState request index or scoped keys.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Packages/src/Editor/FirstPartyTools/Compile/CompileResultRecordingContext.cs, line 30:

<comment>Direct callers of CompilationExecutionService.ExecuteCompilationAsync can persist compile status with an unsafe RequestId, bypassing the safety contract CompileUseCase applies before storage. Consider keeping CompileResultRecordingContext.Create aligned with CompileRequestIdRules.IsSafe so malformed IDs do not corrupt the SessionState request index or scoped keys.</comment>

<file context>
@@ -0,0 +1,41 @@
+        {
+            Debug.Assert(request != null, "request must not be null");
+
+            if (!request.WaitForDomainReload || string.IsNullOrWhiteSpace(request.RequestId))
+            {
+                return Disabled();
</file context>

@hatayama
hatayama merged commit d6c0ea6 into v3-beta Jul 6, 2026
10 checks passed
@hatayama
hatayama deleted the codex/c4-8-compile-session-result-split branch July 6, 2026 08:16
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