Skip to content

chore: simplify dynamic code missing-return recovery - #1652

Merged
hatayama merged 1 commit into
v3-betafrom
refactor/hatayama/extract-dynamic-code-retry-policy
Jul 9, 2026
Merged

chore: simplify dynamic code missing-return recovery#1652
hatayama merged 1 commit into
v3-betafrom
refactor/hatayama/extract-dynamic-code-retry-policy

Conversation

@hatayama

@hatayama hatayama commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Refs: Refactor round 3 ToDo R3-4

Summary

  • Preserve missing-return recovery while moving retry decisions and transformations into one policy.
  • Add direct coverage for compiler signals, source-shape eligibility, code rewriting, delegate short-circuiting, and log ordering.

User Impact

  • Optional-return recovery behavior remains unchanged.
  • The use case is now a focused 229-line orchestrator with retry policy owned separately.

Changes

  • Extract a stateless missing-return retry policy.
  • Inject a non-async retry delegate that keeps request creation and runtime execution in the use case.
  • Track the new async policy and its ConfigureAwait behavior with source guards.

Verification

  • Baseline dynamic-code tests: 27 passed.
  • Red: 10 expected missing-policy compile errors.
  • Unity compile: 0 errors, 0 warnings.
  • New retry policy tests: 10 passed.
  • StaticFacadeStateGuardTests: 20 passed.
  • Head dynamic-code tests: 37 passed.
  • Normalized move diff: pure logic bodies preserved; 12 residual lines are the approved delegate-boundary adaptation for the old signature, call site, request construction, and execution call.
  • IPC protocol version unchanged.

Review in cubic

Move missing-return detection, retry code shaping, and log merging into a stateless policy. Inject a non-async retry delegate so request construction and runtime execution remain owned by the use case.
@coderabbitai

coderabbitai Bot commented Jul 9, 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: eb256040-69b6-4e42-bb23-e5db5328d3cc

📥 Commits

Reviewing files that changed from the base of the PR and between fc97dff and 4bc91fe.

⛔ Files ignored due to path filters (2)
  • Assets/Tests/Editor/DynamicCodeToolTests/DynamicCodeMissingReturnRetryPolicyTests.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCodeMissingReturnRetryPolicy.cs.meta is excluded by none and included by none
📒 Files selected for processing (4)
  • Assets/Tests/Editor/DynamicCodeToolTests/DynamicCodeMissingReturnRetryPolicyTests.cs
  • Assets/Tests/Editor/StaticFacadeStateGuardTests.cs
  • Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCodeMissingReturnRetryPolicy.cs
  • Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/ExecuteDynamicCodeUseCase.cs

📝 Walkthrough

Walkthrough

The missing-return retry logic previously embedded inside ExecuteDynamicCodeUseCase is extracted into a new DynamicCodeMissingReturnRetryPolicy class, which handles detection, eligibility checking, code appending, and log merging. The use case now delegates to this policy. New unit tests cover the policy, and static guard tests are updated for the new file.

Changes

Missing-return retry policy extraction

Layer / File(s) Summary
DynamicCodeMissingReturnRetryPolicy implementation
Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCodeMissingReturnRetryPolicy.cs
New internal class with RetryMissingReturnIfNeeded, LooksLikeMissingReturn, CanRetryMissingReturn, AppendReturnIfMissing, MergeLogs, and CloneLogs implementing missing-return detection and retry orchestration.
ExecuteDynamicCodeUseCase wiring
Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/ExecuteDynamicCodeUseCase.cs
ExecuteAsync now delegates to DynamicCodeMissingReturnRetryPolicy.RetryMissingReturnIfNeeded, removing the former in-class retry implementation.
Unit tests for retry policy
Assets/Tests/Editor/DynamicCodeToolTests/DynamicCodeMissingReturnRetryPolicyTests.cs
New test fixture validating missing-return detection, retry eligibility, code appending, log merging, and success/failure retry paths.
Static guard test updates
Assets/Tests/Editor/StaticFacadeStateGuardTests.cs
Guard allowlist extended with new source paths, and ConfigureAwait(false) assertion redirected to check DynamicCodeMissingReturnRetryPolicy.cs.

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

Sequence Diagram(s)

sequenceDiagram
  participant ExecuteDynamicCodeUseCase
  participant DynamicCodeMissingReturnRetryPolicy
  participant RetryDelegate

  ExecuteDynamicCodeUseCase->>DynamicCodeMissingReturnRetryPolicy: RetryMissingReturnIfNeeded(result, originalCode)
  DynamicCodeMissingReturnRetryPolicy->>DynamicCodeMissingReturnRetryPolicy: LooksLikeMissingReturn / CanRetryMissingReturn
  alt eligible for retry
    DynamicCodeMissingReturnRetryPolicy->>DynamicCodeMissingReturnRetryPolicy: AppendReturnIfMissing(originalCode)
    DynamicCodeMissingReturnRetryPolicy->>RetryDelegate: executeRetryAsync(retryCode)
    RetryDelegate-->>DynamicCodeMissingReturnRetryPolicy: retryResult
    DynamicCodeMissingReturnRetryPolicy->>DynamicCodeMissingReturnRetryPolicy: MergeLogs(originalLogs, retryLogs)
  end
  DynamicCodeMissingReturnRetryPolicy-->>ExecuteDynamicCodeUseCase: final ExecutionResult
Loading

Possibly related PRs

  • hatayama/unity-cli-loop#901: Both PRs implement the same missing-return retry workflow (CS0161/CS0127 detection, appending `return null;`, and merging logs) for `ExecuteDynamicCodeUseCase`, with this PR extracting that logic into `DynamicCodeMissingReturnRetryPolicy`.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the refactor to simplify dynamic code missing-return recovery.
Description check ✅ Passed The description is directly related to the refactor and tests added in this changeset.
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 refactor/hatayama/extract-dynamic-code-retry-policy

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.

@hatayama
hatayama merged commit a04855d into v3-beta Jul 9, 2026
10 checks passed
@hatayama
hatayama deleted the refactor/hatayama/extract-dynamic-code-retry-policy branch July 9, 2026 04:12
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