Skip to content

chore: Keep Infrastructure editor sources under 500 lines#1785

Merged
hatayama merged 2 commits into
feature/god-class-split-integrationfrom
feat/split-infrastructure-scan-detector
Jul 14, 2026
Merged

chore: Keep Infrastructure editor sources under 500 lines#1785
hatayama merged 2 commits into
feature/god-class-split-integrationfrom
feat/split-infrastructure-scan-detector

Conversation

@hatayama

@hatayama hatayama commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Keep two Infrastructure editor sources under the 500-line complexity budget without changing CLI detection or third-party migration scan behavior.
  • Add characterization coverage for assembly-usage scan-state aggregation before the Extract Class work.

User Impact

  • No end-user behavior change. This is maintainability-only so future edits stay reviewable under the line-count gate.

Changes

  • Characterization tests for ThirdPartyToolMigrationAssemblyUsageScanState (committed before production restructuring).
  • Extract Class: reference-requirement recording → ThirdPartyToolMigrationAssemblyUsageReferenceRequirementRecorder.
  • Extract Class: login-shell CLI probe command/parsing → CliShellInstallationProbe (existing detector tests retargeted to the probe).
  • Resulting file sizes: ScanState 341 / Detector 263 / Recorder 258 / Probe 268 (all < 500).

Verification

  • dist/darwin-arm64/uloop compile → 0 errors / 0 warnings
  • uloop run-tests EditMode filter ThirdPartyToolMigrationAssemblyUsageScanState|CliInstallationDetector → 30 passed
  • dotnet test tests/UnityCliLoop.CodeComplexity.Tests → 12 passed

Discipline note (from PR-4 Fable review)

  • Test commit contains characterization only; production Extract Class is a separate refactor commit.

Made with Cursor

Review in cubic

hatayama and others added 2 commits July 14, 2026 19:42
…ehavior

Add characterization coverage before Extract Class so scan-state transitions and reference aggregation stay observable without restructuring production code in the same commit.

Co-authored-by: Cursor <cursoragent@cursor.com>
Extract Class: move asmdef reference-requirement recording out of
ThirdPartyToolMigrationAssemblyUsageScanState and move login-shell CLI
probe command/parsing out of CliInstallationDetector. No behavior change;
characterization and existing CliInstallationDetector tests stay green.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change extracts CLI shell probing from CliInstallationDetector, adds focused scan-state reference recording for third-party tool migration, and introduces tests covering both behaviors.

Changes

CLI shell probing

Layer / File(s) Summary
Shell probe implementation
Packages/src/Editor/Infrastructure/CLI/CliShellInstallationProbe.cs
Adds shell-specific command construction, marker-based output parsing, contract/version handling, argument quoting, and path-setup usability checks.
Detector integration and coverage
Packages/src/Editor/Infrastructure/CLI/CliInstallationDetector.cs, Assets/Tests/Editor/CliInstallationDetectorTests.cs
Routes detector operations and tests through CliShellInstallationProbe, removing the previous local parsing constants and implementations.

Migration reference recording

Layer / File(s) Summary
Reference requirement recorder
Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationAssemblyUsageReferenceRequirementRecorder.cs
Adds assembly-scoped recording for tool-contract, registrar, domain, screenshot, and editor-window migration reference requirements.
Scan-state delegation
Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationAssemblyUsageScanState.cs
Delegates reference-requirement evaluation to the new recorder and removes the former helper methods.
Scan-state behavior coverage
Assets/Tests/Editor/ThirdPartyToolMigrationAssemblyUsageScanStateTests.cs
Adds tests for source facts, aliases, namespace scopes, target scans, reference requirements, registrar bridging, and empty usage snapshots.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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
Title check ✅ Passed The title clearly summarizes the main change: keeping Infrastructure editor sources under the 500-line limit.
Description check ✅ Passed The description is directly related to the refactor, tests, and size-budget goal described in the changeset.
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 feat/split-infrastructure-scan-detector

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.

Actionable comments posted: 1

🤖 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/src/Editor/Infrastructure/CLI/CliShellInstallationProbe.cs`:
- Around line 221-233: The dispatcher detection logic in
CliShellInstallationProbe must validate the JSON DispatcherContractVersion
against CliConstants.REQUIRED_DISPATCHER_CONTRACT_VERSION before returning a
valid CliInstallationDetection, rejecting missing or mismatched contract
generations and removing the semver-only compatibility comment. Update the
mocked JSON payload around
Assets/Tests/Editor/CliInstallationDetectorTests.cs:213 to include the required
contract version field; no other test behavior should change.
🪄 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: 507f81a3-6a02-4d84-812a-52547cc10c3a

📥 Commits

Reviewing files that changed from the base of the PR and between 03b532d and 6e54152.

⛔ Files ignored due to path filters (3)
  • Assets/Tests/Editor/ThirdPartyToolMigrationAssemblyUsageScanStateTests.cs.meta is excluded by none and included by none
  • Packages/src/Editor/Infrastructure/CLI/CliShellInstallationProbe.cs.meta is excluded by none and included by none
  • Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationAssemblyUsageReferenceRequirementRecorder.cs.meta is excluded by none and included by none
📒 Files selected for processing (6)
  • Assets/Tests/Editor/CliInstallationDetectorTests.cs
  • Assets/Tests/Editor/ThirdPartyToolMigrationAssemblyUsageScanStateTests.cs
  • Packages/src/Editor/Infrastructure/CLI/CliInstallationDetector.cs
  • Packages/src/Editor/Infrastructure/CLI/CliShellInstallationProbe.cs
  • Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationAssemblyUsageReferenceRequirementRecorder.cs
  • Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationAssemblyUsageScanState.cs

Comment on lines +221 to +233
// Why: dispatcher compatibility is enforced by the pin's minimumDispatcherVersion (semver floor),
// so identifying the dispatcher only needs its release version.
string dispatcherVersion = parsed[VERSION_JSON_DISPATCHER_VERSION_PROPERTY]?.ToString();
if (string.IsNullOrEmpty(dispatcherVersion))
{
return new CliInstallationDetection(null, executablePath);
}

return new CliInstallationDetection(
dispatcherVersion,
executablePath,
true);
}

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Enforce exact dispatcher contract generation compatibility.

The implementation explicitly bypasses exact dispatcher contract matching, relying only on minimumDispatcherVersion. Based on learnings, the setup/compatibility parsing logic must first validate an exact match to CliConstants.REQUIRED_DISPATCHER_CONTRACT_VERSION and reject mismatched dispatcher contract generations before reporting setup compatibility.

  • Packages/src/Editor/Infrastructure/CLI/CliShellInstallationProbe.cs#L221-L233: Enforce an exact match against CliConstants.REQUIRED_DISPATCHER_CONTRACT_VERSION (e.g., checking "DispatcherContractVersion" in the JSON) before returning a valid dispatcher detection, and remove the comment suggesting semver alone is sufficient.
  • Assets/Tests/Editor/CliInstallationDetectorTests.cs#L213-L213: Update the test's mocked JSON payload (around line 200) to include the required contract version field so the test continues to pass once the exact contract match check is enforced.
📍 Affects 2 files
  • Packages/src/Editor/Infrastructure/CLI/CliShellInstallationProbe.cs#L221-L233 (this comment)
  • Assets/Tests/Editor/CliInstallationDetectorTests.cs#L213-L213
🤖 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/CLI/CliShellInstallationProbe.cs` around
lines 221 - 233, The dispatcher detection logic in CliShellInstallationProbe
must validate the JSON DispatcherContractVersion against
CliConstants.REQUIRED_DISPATCHER_CONTRACT_VERSION before returning a valid
CliInstallationDetection, rejecting missing or mismatched contract generations
and removing the semver-only compatibility comment. Update the mocked JSON
payload around Assets/Tests/Editor/CliInstallationDetectorTests.cs:213 to
include the required contract version field; no other test behavior should
change.

Source: Learnings

@hatayama
hatayama merged commit 0c43b33 into feature/god-class-split-integration Jul 14, 2026
2 checks passed
@hatayama
hatayama deleted the feat/split-infrastructure-scan-detector branch July 14, 2026 10:51
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