Skip to content

fix: Unity busy detection no longer relies on obsolete lock files#1144

Merged
hatayama merged 5 commits into
v3-betafrom
feature/hatayama/audit-reload-compile-locks
May 17, 2026
Merged

fix: Unity busy detection no longer relies on obsolete lock files#1144
hatayama merged 5 commits into
v3-betafrom
feature/hatayama/audit-reload-compile-locks

Conversation

@hatayama
Copy link
Copy Markdown
Owner

@hatayama hatayama commented May 16, 2026

Summary

  • Unity command readiness now uses the current server state file and readiness probes instead of legacy Temp lock hints.
  • uloop fix now cleans the stale readiness state files that actually affect busy detection.
  • Obsolete Unity architecture docs were removed so outdated guidance is not kept in the package.

User Impact

  • Commands still wait while Unity is compiling, reloading scripts, or recovering.
  • Stale busy recovery is clearer because uloop fix targets the current readiness state source instead of obsolete lock files.
  • Maintainers no longer see deleted lock-file behavior documented as if it were still part of the architecture.

Changes

  • Removed domainreload.lock, compiling.lock, and serverstarting.lock producers, cleanup paths, tests, and startup policy plumbing.
  • Simplified server startup and recovery contracts after removing startup lock release handling.
  • Updated focused tests, compile skill guidance, and checked-in native CLI binaries for the new readiness contract.
  • Deleted ARCHITECTURE_Unity.md, ARCHITECTURE_Unity_ja.md, and stale references to those docs.

Verification

  • scripts/check-go-cli.sh
  • Packages/src/Cli~/dist/darwin-arm64/uloop compile --project-path /Users/a12115/ghq/hatayama/unity-cli-loop
  • Packages/src/Cli~/dist/darwin-arm64/uloop run-tests --project-path /Users/a12115/ghq/hatayama/unity-cli-loop --test-mode EditMode --filter-type regex --filter-value ".*(CompilationLockFileServiceTests|DomainReloadDetectionServiceTests|DomainReloadRecoveryUseCaseTests|UnityCliLoopServerControllerRecoveryTests|UnityCliLoopServerStartupProtectionTests|ServerLifecycleContractTests|UnityCliLoopEditorSettingsRecoveryTests).*"
  • codex-review v3-beta

The CLI now uses server-state.json and readiness probes as the readiness contract, so the legacy Temp lock hints no longer need producers, cleanup paths, or startup lifecycle policy.

- Keep uloop fix focused on stale server readiness state files.
- Remove domain reload, compile, and server startup lock file handling from the Editor side.
- Refresh generated skill copies and native CLI binaries after the contract change.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 16, 2026

📝 Walkthrough

Walkthrough

This PR removes lock-file-based server recovery mechanisms across the codebase and simplifies server initialization by eliminating the ServerInitializationRequest parameter. Changes include updating uloop compile documentation to use --no-wait-for-domain-reload, removing lock-file lifecycle operations from infrastructure services, refactoring server startup/recovery orchestration, and aligning test assertions with state-based recovery instead of file-based detection.

Changes

Lock-File Removal and Startup Flow Simplification

Layer / File(s) Summary
Add toolName metadata to all skill definitions
.agents/skills/*/SKILL.md, .claude/skills/*/SKILL.md
All skill tool definitions uniformly receive toolName identifier fields in frontmatter metadata.
Update compile command documentation with new flag semantics
.agents/skills/uloop-compile/SKILL.md, .claude/skills/uloop-compile/SKILL.md, Packages/src/Editor/FirstPartyTools/Compile/*
Compile command flag documentation changes from --wait-for-domain-reload to --no-wait-for-domain-reload; troubleshooting moves from "stale lock files" to "stale recovery state" guidance.
Remove lock-release policy and initialization request from domain contracts
Packages/src/Editor/Domain/ServerLifecycleContract.cs, Packages/src/Editor/Domain/DomainReloadDetectionService.cs
ServerStartupLockReleasePolicy enum and ServerInitializationRequest struct removed; lock-file query methods removed from IDomainReloadDetectionService interface.
Simplify public service interfaces by removing lock-file operations
Packages/src/Editor/Application/CompilationLockService.cs
ICompilationLockService interface contract reduced to registration only; DeleteLockFile() removed from public surface.
Remove clearServerStartingLockWhenReady parameter from StartServer contract
Packages/src/Editor/Application/UnityCliLoopServerApplicationService.cs
IUnityCliLoopServerInstance.StartServer interface simplified from optional-parameter form to parameterless method.
Remove lock-file implementation from compilation and domain reload services
Packages/src/Editor/Infrastructure/Server/CompilationLockFileService.cs, Packages/src/Editor/Infrastructure/Server/DomainReloadDetectionFileService.cs
Lock-file lifecycle operations eliminated; lock-file path helpers, creation/deletion methods, and related imports removed; state-store-based readiness handling preserved.
Remove ServerInitializationRequest parameter from initialization use case
Packages/src/Editor/Application/UseCases/UnityCliLoopServerInitializationUseCase.cs
ExecuteAsync signature changed to accept only CancellationToken; startup invocation removes request dependency.
Simplify server startup service by removing initialization request
Packages/src/Editor/Application/UnityCliLoopServerStartupService.cs
StartServer method removes ServerInitializationRequest parameter and no longer references request.ClearStartupLockWhenReady.
Remove lock-file cleanup from session recovery
Packages/src/Editor/Application/SessionRecoveryService.cs
Lock-file deletion calls removed from RestoreServerStateIfNeededAsync when currently-running server is detected.
Refactor server controller startup and recovery flow
Packages/src/Editor/Infrastructure/Server/UnityCliLoopServerController.cs
Initialization use case execution simplified to CancellationToken only; server-starting lock token creation/deletion removed from recovery path; TryBindWithWaitAsync removes clearServerStartingLockWhenReady parameter.
Remove clearServerStartingLockWhenReady parameter from bridge server
Packages/src/Editor/Infrastructure/UnityCliLoopBridgeServer.cs
StartServer becomes parameterless; preceding lock-file cleanup (compilation, domain reload, server-starting locks) removed before ServerStarted invocation.
Update CLI fix command to focus on server state file cleanup
Packages/src/Cli~/internal/cli/fix.go, Packages/src/Cli~/internal/cli/fix_test.go
Fix command cleanup delegates only to cleanupServerStateFiles, removing stale lock-file cleanup and fmt import; tests verify lock-hint files ignored and readiness state files are sole cleanup target.
Update architecture diagrams to reflect simplified initialization contract
Packages/docs/ARCHITECTURE_Unity.md, Packages/docs/ARCHITECTURE_Unity_ja.md
Initialization use case ExecuteAsync signature removes ServerInitializationRequest parameter; request-acceptance diagram relationship removed.
Remove lock-file cleanup assertions and helpers from test teardown
Assets/Tests/Editor/CompilationLockFileServiceTests.cs, Assets/Tests/Editor/DomainReloadDetectionServiceTests.cs, Assets/Tests/Editor/DomainReloadRecoveryUseCaseTests.cs
Test cleanup paths remove DeleteLockFile() calls and lock-file presence assertions; tests align with state-based recovery.
Remove startup lock tests from contract and lifecycle test suites
Assets/Tests/Editor/ServerLifecycleContractTests.cs
Startup lock release/preservation test methods removed; entire ServerStartingLockServiceTests fixture removed.
Update test server instance mocks to use parameterless StartServer
Assets/Tests/Editor/UnityCliLoopEditorSettingsRecoveryTests.cs, Assets/Tests/Editor/UnityCliLoopServerControllerStartupLockTests.cs, Assets/Tests/Editor/UnityCliLoopServerStartupProtectionTests.cs
Test mock StartServer() method becomes parameterless; ClearServerStartingLockWhenReady parameter and property removed; test fixture renamed to recovery-focused naming.
Update domain reload rollback test to verify state persistence instead of lock presence
Assets/Tests/Editor/DomainReloadDetectionServiceTests.cs
Rollback test removes lock-file presence assertion; adds assertion that ServerReadinessState.Phase equals "failed" and LastError is non-empty.

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly Related PRs

  • hatayama/unity-cli-loop#1136: Both PRs are part of the readiness/recovery-state refactor, replacing stale lock-file handling with shared persisted server readiness state around CLI fix cleanup and editor-side readiness services.
  • hatayama/unity-cli-loop#1031: Both PRs update the uloop-compile command guidance in skill documentation by changing documented Domain Reload flag usage and updating recovery/troubleshooting wording.
  • hatayama/unity-cli-loop#1079: Both PRs refactor Unity CLI Loop server initialization/lifecycle contracts and method signatures, including ServerLifecycleContract types and UnityCliLoopServerInitializationUseCase/UnityCliLoopServerStartupService startup-request/start-server flow.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.39% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: removing reliance on obsolete lock files for Unity busy detection, which aligns with the primary objective of replacing lock-file-based readiness with state-file-based detection.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 feature/hatayama/audit-reload-compile-locks

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 and usage tips.

Keep the pull request focused on source files and Claude skill copies after the generated .agents snapshots were requested to stay out of the branch diff.
Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

No issues found across 55 files

Re-trigger cubic

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
Packages/src/Cli~/internal/cli/fix_test.go (1)

35-68: ⚡ Quick win

Add coverage for serverStateBackupSuffix cleanup path.

cleanupServerStateFiles also removes the backup state artifact, but this test only asserts three files. Please seed/assert the backup file too so the cleanup contract is fully covered.

Suggested test update
 func TestCleanupStaleRecoveryStateRemovesServerStateFiles(t *testing.T) {
@@
 	if err := os.WriteFile(statePath+serverStateInProgressTempSuffix, []byte(`{"phase":"recovering"}`), 0o644); err != nil {
 		t.Fatalf("failed to seed in-progress temp state file: %v", err)
 	}
+	if err := os.WriteFile(statePath+serverStateBackupSuffix, []byte(`{"phase":"backup"}`), 0o644); err != nil {
+		t.Fatalf("failed to seed backup state file: %v", err)
+	}
@@
-	if cleaned != 3 {
+	if cleaned != 4 {
 		t.Fatalf("cleaned count mismatch: %d", cleaned)
 	}
@@
 	if _, err := os.Stat(statePath + serverStateInProgressTempSuffix); err == nil {
 		t.Fatal("in-progress temporary server state file was not removed")
 	}
+	if _, err := os.Stat(statePath + serverStateBackupSuffix); err == nil {
+		t.Fatal("backup server state file was not removed")
+	}
 }
🤖 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/Cli`~/internal/cli/fix_test.go around lines 35 - 68, The test
TestCleanupStaleRecoveryStateRemovesServerStateFiles seeds three server state
files but omits the backup file that cleanupServerStateFiles should also remove;
update the test to create a backup file at statePath+serverStateBackupSuffix
before calling cleanupStaleRecoveryState, assert the returned cleaned count
increments to 4 (or adjust expectation accordingly), and add an os.Stat check to
ensure the backup file was removed after cleanup; reference
TestCleanupStaleRecoveryStateRemovesServerStateFiles, cleanupStaleRecoveryState,
cleanupServerStateFiles, and serverStateBackupSuffix to locate where to add the
seed and assertion.
🤖 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.

Inline comments:
In `@Packages/docs/ARCHITECTURE_Unity_ja.md`:
- Line 149: 図で契約を ExecuteAsync(CancellationToken):
Task~ServerInitializationResult~ に変更したので、本文(3.6節、該当箇所は約354行付近)に残っている
"request/result" の記述を同一契約に合わせて書き換えてください。具体的には、ExecuteAsync が CancellationToken
を受け取り ServerInitializationResult を返す旨を明記し、旧来の request/result
フローやそれに依存する用語・例を削除または置換して、ServerInitializationResult
の意味(初期化成功/失敗やエラー情報等)と呼び出し側の期待動作を簡潔に記述してください。

In `@Packages/docs/ARCHITECTURE_Unity.md`:
- Line 260: Update the prose that describes the initialization lifecycle so it
matches the new no-request contract: replace any wording that says
UnityCliLoopServerInitializationUseCase orchestrates request/result values with
wording that ExecuteAsync(CancellationToken): Task<ServerInitializationResult>
performs initialization without client request/response semantics. Locate
references to UnityCliLoopServerInitializationUseCase and the lifecycle prose
around the later section (around the current Line ~465) and rephrase to state
that the use case returns a ServerInitializationResult directly from
ExecuteAsync and does not depend on incoming requests or request/result
orchestration.

---

Nitpick comments:
In `@Packages/src/Cli`~/internal/cli/fix_test.go:
- Around line 35-68: The test
TestCleanupStaleRecoveryStateRemovesServerStateFiles seeds three server state
files but omits the backup file that cleanupServerStateFiles should also remove;
update the test to create a backup file at statePath+serverStateBackupSuffix
before calling cleanupStaleRecoveryState, assert the returned cleaned count
increments to 4 (or adjust expectation accordingly), and add an os.Stat check to
ensure the backup file was removed after cleanup; reference
TestCleanupStaleRecoveryStateRemovesServerStateFiles, cleanupStaleRecoveryState,
cleanupServerStateFiles, and serverStateBackupSuffix to locate where to add the
seed and assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d216f06b-fc13-4166-96c0-ff61c132c6f1

📥 Commits

Reviewing files that changed from the base of the PR and between 15d3ad0 and 1142756.

⛔ Files ignored due to path filters (5)
  • Assets/Tests/Editor/ServerStartingLockServiceTests.cs.meta is excluded by none and included by none
  • Packages/src/Cli~/dist/darwin-amd64/uloop is excluded by !**/dist/** and included by none
  • Packages/src/Cli~/dist/darwin-arm64/uloop is excluded by !**/dist/** and included by none
  • Packages/src/Cli~/dist/windows-amd64/uloop.exe is excluded by !**/dist/**, !**/*.exe and included by none
  • Packages/src/Editor/Infrastructure/Server/ServerStartingLockService.cs.meta is excluded by none and included by none
📒 Files selected for processing (50)
  • .agents/skills/uloop-clear-console/SKILL.md
  • .agents/skills/uloop-compile/SKILL.md
  • .agents/skills/uloop-find-game-objects/SKILL.md
  • .agents/skills/uloop-get-hierarchy/SKILL.md
  • .agents/skills/uloop-get-logs/SKILL.md
  • .agents/skills/uloop-record-input/SKILL.md
  • .agents/skills/uloop-replay-input/SKILL.md
  • .agents/skills/uloop-run-tests/SKILL.md
  • .agents/skills/uloop-screenshot/SKILL.md
  • .agents/skills/uloop-simulate-keyboard/SKILL.md
  • .agents/skills/uloop-simulate-mouse-input/SKILL.md
  • .agents/skills/uloop-simulate-mouse-ui/SKILL.md
  • .claude/skills/uloop-clear-console/SKILL.md
  • .claude/skills/uloop-compile/SKILL.md
  • .claude/skills/uloop-find-game-objects/SKILL.md
  • .claude/skills/uloop-get-hierarchy/SKILL.md
  • .claude/skills/uloop-get-logs/SKILL.md
  • .claude/skills/uloop-record-input/SKILL.md
  • .claude/skills/uloop-replay-input/SKILL.md
  • .claude/skills/uloop-run-tests/SKILL.md
  • .claude/skills/uloop-screenshot/SKILL.md
  • .claude/skills/uloop-simulate-keyboard/SKILL.md
  • .claude/skills/uloop-simulate-mouse-input/SKILL.md
  • .claude/skills/uloop-simulate-mouse-ui/SKILL.md
  • Assets/Tests/Editor/CompilationLockFileServiceTests.cs
  • Assets/Tests/Editor/DomainReloadDetectionServiceTests.cs
  • Assets/Tests/Editor/DomainReloadRecoveryUseCaseTests.cs
  • Assets/Tests/Editor/ServerLifecycleContractTests.cs
  • Assets/Tests/Editor/ServerStartingLockServiceTests.cs
  • Assets/Tests/Editor/UnityCliLoopEditorSettingsRecoveryTests.cs
  • Assets/Tests/Editor/UnityCliLoopServerControllerStartupLockTests.cs
  • Assets/Tests/Editor/UnityCliLoopServerStartupProtectionTests.cs
  • Packages/docs/ARCHITECTURE_Unity.md
  • Packages/docs/ARCHITECTURE_Unity_ja.md
  • Packages/src/Cli~/internal/cli/fix.go
  • Packages/src/Cli~/internal/cli/fix_test.go
  • Packages/src/Editor/Application/CompilationLockService.cs
  • Packages/src/Editor/Application/SessionRecoveryService.cs
  • Packages/src/Editor/Application/UnityCliLoopServerApplicationService.cs
  • Packages/src/Editor/Application/UnityCliLoopServerStartupService.cs
  • Packages/src/Editor/Application/UseCases/UnityCliLoopServerInitializationUseCase.cs
  • Packages/src/Editor/Domain/DomainReloadDetectionService.cs
  • Packages/src/Editor/Domain/ServerLifecycleContract.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileResponse.cs
  • Packages/src/Editor/FirstPartyTools/Compile/Skill/SKILL.md
  • Packages/src/Editor/Infrastructure/Server/CompilationLockFileService.cs
  • Packages/src/Editor/Infrastructure/Server/DomainReloadDetectionFileService.cs
  • Packages/src/Editor/Infrastructure/Server/ServerStartingLockService.cs
  • Packages/src/Editor/Infrastructure/Server/UnityCliLoopServerController.cs
  • Packages/src/Editor/Infrastructure/UnityCliLoopBridgeServer.cs
💤 Files with no reviewable changes (7)
  • Packages/src/Editor/Domain/ServerLifecycleContract.cs
  • Assets/Tests/Editor/CompilationLockFileServiceTests.cs
  • Packages/src/Editor/Domain/DomainReloadDetectionService.cs
  • Assets/Tests/Editor/ServerLifecycleContractTests.cs
  • Assets/Tests/Editor/ServerStartingLockServiceTests.cs
  • Packages/src/Editor/Application/SessionRecoveryService.cs
  • Packages/src/Editor/Infrastructure/Server/ServerStartingLockService.cs

Comment thread Packages/docs/ARCHITECTURE_Unity_ja.md Outdated
Comment thread Packages/docs/ARCHITECTURE_Unity.md Outdated
hatayama added 2 commits May 17, 2026 08:27
Keep the pull request focused on the readiness contract change by removing generated .claude skill snapshots from the branch diff.
Drop the unused Unity architecture markdown and its Unity meta file so the pull request no longer carries changes to a document that should not be maintained. Remove stale code-comment references that would otherwise point to the deleted file.
Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

4 issues found across 24 files (changes from recent commits).

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=".claude/skills/uloop-compile/SKILL.md">

<violation number="1">
P2: The documented compile flag was flipped to `--wait-for-domain-reload`, but the CLI/docs still use `--no-wait-for-domain-reload`, so this skill now teaches an option name that may not work.</violation>

<violation number="2">
P1: Troubleshooting was changed back to lock-file cleanup, but `uloop fix` now cleans server readiness state files; this guidance will send users to the wrong root cause.</violation>
</file>

<file name=".agents/skills/uloop-compile/SKILL.md">

<violation number="1">
P2: This troubleshooting instruction is outdated: `uloop fix` now cleans stale recovery/readiness state files (`server-state.json*`), not lock files.</violation>

<violation number="2">
P2: The documented `--wait-for-domain-reload` flag does not match the CLI’s actual option (`--no-wait-for-domain-reload`), so users can be given an unsupported command.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic

Delete the remaining Japanese Unity architecture document and its Unity meta file so the PR no longer retains the removed architecture docs in any language.
@hatayama hatayama changed the title chore: Unity readiness cleanup now uses a single state file fix: Unity busy detection no longer relies on obsolete lock files May 17, 2026
@hatayama hatayama merged commit ba5746f into v3-beta May 17, 2026
8 checks passed
@hatayama hatayama deleted the feature/hatayama/audit-reload-compile-locks branch May 17, 2026 00:09
@github-actions github-actions Bot mentioned this pull request May 16, 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