Skip to content

chore: Avoid duplicate compile result persistence - #1548

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

hatayama merged 4 commits into
v3-betafrom
codex/c4-8-compile-result-session-recorder

Conversation

@hatayama

@hatayama hatayama commented Jul 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Keep delayed compile polling results on the controller timing path while removing the second execution-result write from the use case.
  • Add pins for the current indeterminate response shape and byte-stable compile-result JSON before the behavior change.

User Impact

  • No compile response JSON shape change is intended in this PR.
  • Delayed compile polling continues to receive the result before domain reload while avoiding duplicate SessionState writes for normal execution results.

Changes

  • Add a compile result session recorder as the single shaping and persistence seam.
  • Route controller execution completions and controller early execution failures through the recorder.
  • Keep the use case responsible only for pre-controller failures, then return execution responses without storing them again.
  • Add regression tests for non-force indeterminate response shape, byte-stable normal-result JSON, and recorder persistence.

Verification

  • dist/darwin-arm64/uloop compile --project-path "<PROJECT_ROOT>"
  • dist/darwin-arm64/uloop run-tests --project-path "<PROJECT_ROOT>" --test-mode EditMode --filter-type regex --filter-value "(CompileResponseFactoryTests|CompileSessionResultStoreTests|CompileResultSessionRecorderTests|CompileStatusBridgeCommandTests|CompileLifecycleWatchdogTests)"

Review in cubic

hatayama added 3 commits July 6, 2026 17:38
Capture the current non-force indeterminate response shape and prove duplicate normal-result persistence writes byte-identical JSON before removing the duplicate storage path.
Route compile result shaping and persistence through a single recorder so execution results are stored from the controller timing path and the use case no longer writes the same stored result a second time.
Rename the byte-stability test so it describes the post-change invariant instead of the removed duplicate writer shape.
@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: efb36c64-f833-43be-ae84-4ee8418964aa

📥 Commits

Reviewing files that changed from the base of the PR and between 6f1173d and 9947c8a.

⛔ Files ignored due to path filters (3)
  • Assets/Tests/Editor/CompileResultSessionRecorderTests.cs.meta is excluded by none and included by none
  • Assets/Tests/Editor/CompileUseCaseTests.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Compile/CompileResultSessionRecorder.cs.meta is excluded by none and included by none
📒 Files selected for processing (9)
  • Assets/Tests/Editor/CompileResponseFactoryTests.cs
  • Assets/Tests/Editor/CompileResultSessionRecorderTests.cs
  • Assets/Tests/Editor/CompileSessionResultStoreTests.cs
  • Assets/Tests/Editor/CompileUseCaseTests.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileController.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileResultRecordingContext.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileResultSessionRecorder.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileSessionResultStore.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileUseCase.cs

📝 Walkthrough

Walkthrough

This PR centralizes compile result persistence into a new CompileResultSessionRecorder helper used by both CompileController and CompileUseCase. It adds a CanRecord eligibility check, extracts a StampProjectRoot helper, introduces a swappable compilation execution delegate for testing, and adds corresponding unit tests.

Changes

Compile result session recording refactor

Layer / File(s) Summary
Recorder helper and supporting utilities
Packages/src/Editor/FirstPartyTools/Compile/CompileResultSessionRecorder.cs, CompileResultRecordingContext.cs, CompileSessionResultStore.cs
New CompileResultSessionRecorder creates and stores CompileResponse from CompileResult; adds CanRecord eligibility check and extracts StampProjectRoot helper.
Controller early-exit recording
Packages/src/Editor/FirstPartyTools/Compile/CompileController.cs
TryCompileAsync now records failure results via RecordCompileResultIfNeeded before returning; that method delegates to CompileResultSessionRecorder.RecordCompileResult.
Use case execution delegate and persistence
Packages/src/Editor/FirstPartyTools/Compile/CompileUseCase.cs
Adds swappable _executeCompilationAsync delegate with testing seam; replaces StoreResponseIfNeeded with StorePreControllerResponseIfNeeded, StampProjectRootForDelayedResponseIfNeeded, and LogMissingRecordableRequestIfNeeded gated by CanRecord.
Unit tests
Assets/Tests/Editor/CompileResponseFactoryTests.cs, CompileResultSessionRecorderTests.cs, CompileSessionResultStoreTests.cs, CompileUseCaseTests.cs
Adds tests covering indeterminate response handling, recorder persistence and pending-request clearing, byte-identical JSON storage, and single-store guarantee via a counting repository wrapper.

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

Sequence Diagram(s)

sequenceDiagram
  participant CompileController
  participant CompileUseCase
  participant CompileResultSessionRecorder
  participant CompileResponseFactory
  participant CompileSessionResultStore

  CompileController->>CompileController: TryCompileAsync detects validation/scene-change failure
  CompileController->>CompileResultSessionRecorder: RecordCompileResult(result, requestId, forceRecompile)
  CompileResultSessionRecorder->>CompileResponseFactory: CreateResponse(result)
  CompileResultSessionRecorder->>CompileSessionResultStore: StoreCompileResult(response)
  CompileSessionResultStore-->>CompileResultSessionRecorder: stored
  CompileResultSessionRecorder-->>CompileController: CompileResponse

  CompileUseCase->>CompileUseCase: CompileAsync invokes _executeCompilationAsync
  CompileUseCase->>CompileResultSessionRecorder: RecordCompileResponse(response) via StorePreControllerResponseIfNeeded
  CompileResultSessionRecorder->>CompileSessionResultStore: StoreCompileResult(response)
Loading

Possibly related PRs

  • hatayama/unity-cli-loop#1514: Both PRs modify RecordCompileResultIfNeeded in CompileController.cs, coordinating on how compile results are persisted.
  • hatayama/unity-cli-loop#1532: Part of the same compile-result persistence refactor, introducing the ICompileResultSessionRepository abstraction used by the recorder.

Poem

A rabbit hops through session state,
Recording results, early or late,
CanRecord checks before we store,
StampProjectRoot marks the floor,
Tests confirm each byte's the same—
Compile results, tracked by name.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: preventing duplicate compile result persistence.
Description check ✅ Passed The description matches the code changes and regression tests around compile result persistence and recording.
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-result-session-recorder

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

@hatayama
hatayama merged commit 300cc5d into v3-beta Jul 6, 2026
10 checks passed
@hatayama
hatayama deleted the codex/c4-8-compile-result-session-recorder branch July 6, 2026 09:15
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