Skip to content

chore: Compile result session state uses a dedicated repository - #1532

Merged
hatayama merged 2 commits into
v3-betafrom
codex/c4-5d-compile-result-session-repository
Jul 6, 2026
Merged

hatayama merged 2 commits into
v3-betafrom
codex/c4-5d-compile-result-session-repository

Conversation

@hatayama

@hatayama hatayama commented Jul 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Split compile-result session persistence out of the broad editor SessionState port.
  • Keep existing compile-result behavior unchanged while preparing the remaining PendingCompile and SessionFlags splits.

User Impact

  • No user-facing behavior change is intended.
  • Compile result recovery after Domain Reload keeps the same keyed storage, legacy migration, malformed tick cleanup, and expiry behavior.

Changes

  • Added a domain-owned compile-result session repository port and a Unity SessionState-backed infrastructure implementation.
  • Removed the compile-result raw KV methods from the broad editor session-state port.
  • Kept UnityCliLoopEditorSessionStateService as a transitional delegate for this series; service delegation is transitional and will be removed in the final PR of this series.
  • Updated session-state tests and onion guard coverage for the new repository port.

Verification

  • dist/darwin-arm64/uloop compile --project-path "/Users/a12115/ghq/hatayama/unity-cli-loop2" (0 errors, 0 warnings)
  • dist/darwin-arm64/uloop run-tests --project-path "/Users/a12115/ghq/hatayama/unity-cli-loop2" --test-mode EditMode --filter-type regex --filter-value "(UnityCliLoopEditorSessionStateRepositoryTests|CompileStatusBridgeCommandTests|CompileSessionResultServiceTests|OnionAssemblyDependencyTests|StaticFacadeStateGuardTests)" (127 passed)

Review in cubic

Move compile-result SessionState storage behind a dedicated domain repository port and infrastructure implementation. Keep UnityCliLoopEditorSessionStateService as a transitional delegate for this series while removing the raw compile-result KV methods from the broad session-state port.
@coderabbitai

coderabbitai Bot commented Jul 6, 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: 12 minutes

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: 63a085dd-e294-47de-829d-a0ad06a5feda

📥 Commits

Reviewing files that changed from the base of the PR and between 4c1a25d and 4255db9.

📒 Files selected for processing (1)
  • Packages/src/Editor/Infrastructure/Settings/UnityCliLoopCompileResultSessionRepository.cs
📝 Walkthrough

Walkthrough

This PR extracts compile-result session persistence into a new ICompileResultSessionRepository interface and its UnityCliLoopCompileResultSessionRepository implementation. UnityCliLoopEditorSessionStateRepository and UnityCliLoopEditorSessionStateService no longer handle compile-result storage directly, delegating to the new repository instead. Composition root wiring and tests are updated accordingly.

Changes

Compile-result repository extraction

Layer / File(s) Summary
Repository interface and implementation
Packages/src/Editor/Domain/ICompileResultSessionRepository.cs, Packages/src/Editor/Infrastructure/Settings/UnityCliLoopCompileResultSessionRepository.cs
New ICompileResultSessionRepository interface defines store/get/clear/expire methods; UnityCliLoopCompileResultSessionRepository implements it via SessionState, including per-request storage, bulk retrieval, legacy data migration, and parsing/formatting helpers.
Service and legacy repository cleanup
Packages/src/Editor/Domain/UnityCliLoopEditorSessionStateService.cs, Packages/src/Editor/Infrastructure/Settings/UnityCliLoopEditorSessionStateRepository.cs
UnityCliLoopEditorSessionStateService gains an ICompileResultSessionRepository dependency and delegates compile-result methods to it; IUnityCliLoopEditorSessionStatePort and UnityCliLoopEditorSessionStateRepository have compile-result APIs and keys removed.
Composition root wiring
Packages/src/Editor/CompositionRoot/UnityCliLoopApplicationRegistration.cs
Register() creates a UnityCliLoopCompileResultSessionRepository and passes it into the UnityCliLoopEditorSessionStateService constructor.
Test updates and assembly boundary check
Assets/Tests/Editor/UnityCliLoopEditorSessionStateTestFactory.cs, Assets/Tests/Editor/UnityCliLoopEditorSessionStateRepositoryTests.cs, Assets/Tests/Editor/OnionAssemblyDependencyTests.cs
Test factory and tests construct services with both repositories and seed compile-result data via the new repository's static setters; a new test verifies ICompileResultSessionRepository compiles under the domain assembly.

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

Sequence Diagram(s)

sequenceDiagram
  participant Registration as UnityCliLoopApplicationRegistration
  participant Service as UnityCliLoopEditorSessionStateService
  participant CompileRepo as UnityCliLoopCompileResultSessionRepository
  participant Session as SessionState

  Registration->>CompileRepo: new UnityCliLoopCompileResultSessionRepository()
  Registration->>Service: new UnityCliLoopEditorSessionStateService(sessionStateRepository, compileRepo)
  Service->>CompileRepo: StoreCompileResult(requestId, forceRecompile, resultJson, completedAtUtc)
  CompileRepo->>Session: write per-request keys + index
  Service->>CompileRepo: GetStoredCompileResult()
  CompileRepo->>Session: read index and per-request keys
  CompileRepo-->>Service: UnityCliLoopStoredCompileResult
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: moving compile-result session state to a dedicated repository.
Description check ✅ Passed The description is directly related to the changeset and accurately describes the repository split and test updates.
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 codex/c4-5d-compile-result-session-repository

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/Infrastructure/Settings/UnityCliLoopCompileResultSessionRepository.cs (1)

332-425: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Duplicate index/ticks-parsing logic vs. UnityCliLoopEditorSessionStateService.

ParseUtcTicks, ParseRequestIdIndex, FormatRequestIdIndex, AddRequestIdToIndex, and RemoveRequestIdFromIndex here are identical to the private static helpers still in UnityCliLoopEditorSessionStateService.cs (used for pending-compile indexing). The split introduced this duplication; extracting a small shared utility (e.g. a RequestIdIndexCodec in Domain, referenced by both Domain and Infrastructure) would avoid future divergence between the two copies.

🤖 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/Infrastructure/Settings/UnityCliLoopCompileResultSessionRepository.cs`
around lines 332 - 425, The helper methods for ticks/request-id index parsing
are duplicated between this repository class and
UnityCliLoopEditorSessionStateService, so move the shared logic into one
reusable utility and have both call it. Extract ParseUtcTicks,
ParseRequestIdIndex, FormatRequestIdIndex, AddRequestIdToIndex, and
RemoveRequestIdFromIndex into a common helper such as RequestIdIndexCodec (or
equivalent shared service), then update
UnityCliLoopCompileResultSessionRepository to use that shared implementation
instead of maintaining a second copy.
🤖 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/Infrastructure/Settings/UnityCliLoopCompileResultSessionRepository.cs`:
- Around line 332-425: The helper methods for ticks/request-id index parsing are
duplicated between this repository class and
UnityCliLoopEditorSessionStateService, so move the shared logic into one
reusable utility and have both call it. Extract ParseUtcTicks,
ParseRequestIdIndex, FormatRequestIdIndex, AddRequestIdToIndex, and
RemoveRequestIdFromIndex into a common helper such as RequestIdIndexCodec (or
equivalent shared service), then update
UnityCliLoopCompileResultSessionRepository to use that shared implementation
instead of maintaining a second copy.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f8d40ac3-d70e-4e85-aa71-a239094a3f7c

📥 Commits

Reviewing files that changed from the base of the PR and between 87e603f and 4c1a25d.

⛔ Files ignored due to path filters (2)
  • Packages/src/Editor/Domain/ICompileResultSessionRepository.cs.meta is excluded by none and included by none
  • Packages/src/Editor/Infrastructure/Settings/UnityCliLoopCompileResultSessionRepository.cs.meta is excluded by none and included by none
📒 Files selected for processing (8)
  • Assets/Tests/Editor/OnionAssemblyDependencyTests.cs
  • Assets/Tests/Editor/UnityCliLoopEditorSessionStateRepositoryTests.cs
  • Assets/Tests/Editor/UnityCliLoopEditorSessionStateTestFactory.cs
  • Packages/src/Editor/CompositionRoot/UnityCliLoopApplicationRegistration.cs
  • Packages/src/Editor/Domain/ICompileResultSessionRepository.cs
  • Packages/src/Editor/Domain/UnityCliLoopEditorSessionStateService.cs
  • Packages/src/Editor/Infrastructure/Settings/UnityCliLoopCompileResultSessionRepository.cs
  • Packages/src/Editor/Infrastructure/Settings/UnityCliLoopEditorSessionStateRepository.cs

@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 across 10 files

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/Infrastructure/Settings/UnityCliLoopCompileResultSessionRepository.cs">

<violation number="1" location="Packages/src/Editor/Infrastructure/Settings/UnityCliLoopCompileResultSessionRepository.cs:58">
P2: Compile status reads for unknown request IDs now mutate SessionState, because `GetCompileResult` clears storage on miss. This can create unnecessary persistent key churn from polling inputs; returning `None()` directly on miss avoids side effects.</violation>
</file>

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

Re-trigger cubic

return legacyResult;
}

ClearCompileResultForRequestId(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: Compile status reads for unknown request IDs now mutate SessionState, because GetCompileResult clears storage on miss. This can create unnecessary persistent key churn from polling inputs; returning None() directly on miss avoids side effects.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Packages/src/Editor/Infrastructure/Settings/UnityCliLoopCompileResultSessionRepository.cs, line 58:

<comment>Compile status reads for unknown request IDs now mutate SessionState, because `GetCompileResult` clears storage on miss. This can create unnecessary persistent key churn from polling inputs; returning `None()` directly on miss avoids side effects.</comment>

<file context>
@@ -0,0 +1,452 @@
+                    return legacyResult;
+                }
+
+                ClearCompileResultForRequestId(requestId);
+                return UnityCliLoopStoredCompileResult.None();
+            }
</file context>

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This clear-on-miss behavior is not introduced by this PR — it is a verbatim move of the pre-existing implementation. On the base branch, UnityCliLoopEditorSessionStateService.GetCompileResult (origin/v3-beta, lines 391-423) performs the identical ClearCompileResultForRequestId(requestId) on the same two miss paths (missing json and malformed ticks). That cleanup is the deliberate self-heal mechanism for partial or corrupt entries and their index bookkeeping. This PR is a behavior-preserving extraction of compile-result persistence into a dedicated repository; changing the miss semantics here would violate the PR's no-behavior-change scope. If the read-mutates-on-miss pattern should be revisited, that belongs in a separate behavior-change PR, not this mechanical split.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The parent comment was wrong for this PR: the miss cleanup already existed in UnityCliLoopEditorSessionStateService.GetCompileResult, and this change just moved that behavior into UnityCliLoopCompileResultSessionRepository while keeping the no-behavior-change scope intact. If the read-mutate-on-miss semantics should change, that needs a separate behavior-change PR.

Route legacy compile-result migration through StoreCompileResult so the migration path stays aligned with normal aggregate persistence, and clear legacy keys through the same wrappers used elsewhere.
@hatayama
hatayama merged commit 1ac55d6 into v3-beta Jul 6, 2026
10 checks passed
@hatayama
hatayama deleted the codex/c4-5d-compile-result-session-repository branch July 6, 2026 01:24
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