Skip to content

fix: Compile reload diagnostics are now saved to VibeLog files - #1281

Closed
hatayama wants to merge 2 commits into
v3-betafrom
feature/hatayama/fix-issue-1280
Closed

hatayama wants to merge 2 commits into
v3-betafrom
feature/hatayama/fix-issue-1280

Conversation

@hatayama

@hatayama hatayama commented Jun 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • When uloop compile waits through a Unity script reload, both CLI-side and Unity-side details are written to external VibeLog files under .uloop/outputs/VibeLogs/.
  • Debug-enabled Unity projects now enable CLI VibeLog output automatically, so consumer runs keep those diagnostic files without setting ULOOP_DEBUG in the shell.

User Impact

  • You do not need to run an extra compile step; this applies to the normal uloop compile flow.
  • If Unity reloads scripts while uloop compile is waiting for the result, the request ID, polling state, reload recovery, and stored result state remain available in VibeLog files for diagnosis.
  • Diagnostic logging now avoids unbounded per-write scanning and status-cache growth during long-lived Unity sessions.

Changes

  • Resolve CLI debug logging from both the shell environment and the Unity project debug define.
  • Add structured compile request, polling, reload, and result-store diagnostics on the CLI and Unity sides.
  • Serialize Unity VibeLog appends, validate only the appended JSONL tail, and bound compile status duplicate-suppression state.

Verification

  • scripts/check-go-cli.sh
  • cli/dist/darwin-arm64/uloop compile --project-path "$(git rev-parse --show-toplevel)"
  • cli/dist/darwin-arm64/uloop run-tests --project-path "$(git rev-parse --show-toplevel)" --test-mode EditMode --filter-type regex --filter-value "io\\.github\\.hatayama\\.UnityCliLoop\\.Tests\\.Editor\\.(CompileStatusBridgeCommandTests|CompileSessionResultServiceTests|VibeLoggerTests)\\."
  • codex-review v3-beta

Closes #1280

hatayama added 2 commits June 3, 2026 21:51
Enable CLI VibeLog from the target Unity project's debug define so consumer runs keep CLI-side evidence without a shell override.

Add structured compile request, send, polling, status, and result-store diagnostics so timeouts and duplicate Unity stores can be diagnosed after the fact.

Harden Unity VibeLog JSONL appends with serialized writes, retrying, and integrity diagnostics.
Limit compile status duplicate-suppression state and avoid full-file VibeLog integrity scans so debug diagnostics do not grow unbounded in long-lived Unity sessions.
@coderabbitai

coderabbitai Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR implements comprehensive structured logging across the compile request lifecycle and status polling to enable post-mortem diagnostics of compile wait issues. Changes span VibeLog persistence integrity (JSONL append validation), CLI debug mode resolution from Unity project settings, compile request/result/status logging on the Unity side, and extensive compile wait polling diagnostics on the CLI side.

Changes

Enhanced Compile Diagnostics and CLI VibeLog Debug Detection

Layer / File(s) Summary
VibeLog JSONL Append Integrity
Packages/src/Editor/ToolContracts/VibeLogger.cs, Assets/Tests/Editor/VibeLoggerTests.cs
Refactored log persistence to validate only the appended byte region for malformed JSON, detect write interleaving, and emit diagnostic logs on failures; added retry logic for file-sharing violations and session-scoped interleaving warnings to prevent repeated duplicate alerts.
CLI Debug Mode Resolution from Project Settings
cli/internal/cli/cli_vibe.go, cli/internal/cli/cli_vibe_test.go
Enables CLI VibeLog activation via shell environment variable (ULOOP_DEBUG) or Unity project's scripting define; added project identity hashing and YAML-style ProjectSettings.asset parsing with indentation-aware section detection.
Compile Request Reception and Registration Logging
Packages/src/Editor/FirstPartyTools/Compile/CompileController.cs, Packages/src/Editor/FirstPartyTools/Compile/CompileUseCase.cs, Packages/src/Editor/FirstPartyTools/Compile/CompileSessionResultService.cs, Assets/Tests/Editor/CompileSessionResultServiceTests.cs
Tracks compile start timestamp and logs finish callback with elapsed time; logs request received (including editor state) and pending-request registration for status polling; extends store-complete logging to include duplicate detection and sequence indicators.
Compile Status Query Logging and Deduplication
Packages/src/Editor/Infrastructure/Api/CompileStatusBridgeCommand.cs, Assets/Tests/Editor/CompileStatusBridgeCommandTests.cs
Adds optional ULOOP_DEBUG debug logging to compile status queries with per-RequestId signature caching to suppress repeated identical responses; manages cache capacity and clears signatures when responses become ready.
Compile Status Polling with Comprehensive Logging
cli/internal/cli/compile_wait.go, cli/internal/cli/compile_wait_test.go, cli/internal/cli/run.go
Refactors polling loop to track state (attempt count, last status/error, dedup signature); logs start/observed/complete/timeout/cancel/bridge-recovery phases with elapsed time and request correlation; deduplicates repeated status observations and includes poll attempt count and last-status context in terminal logs.
Server Lifecycle and Domain Reload Correlation
Packages/src/Editor/Infrastructure/Server/DomainReloadDetectionFileService.cs, Packages/src/Editor/Infrastructure/Server/UnityCliLoopServerController.cs
Adds server generation counter for bind lifecycle tracking; refactors domain-reload start/complete and server binding logs via helper methods to include pending compile request id, endpoint, and generation for request correlation during bridge recovery.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • hatayama/unity-cli-loop#1027: Fixes compile waits to also wait for bridge readiness using the startup lock; related to compile-wait polling refactoring in this PR.
  • hatayama/unity-cli-loop#1225: Modifies compile completion logging in CompileController.cs (HandleCompileFinished); overlaps with completion callback logging added in this PR.
  • hatayama/unity-cli-loop#1248: Refactors compile-status-polling and request-id keyed storage in CompileSessionResultService and CompileStatusBridgeCommand; this PR extends those components with diagnostic logging.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.44% 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 The PR successfully implements all major objectives from issue #1280: CLI debug logging from project defines [cli_vibe.go], structured compile diagnostics [CompileController, CompileUseCase, compile_wait.go], JSONL integrity improvements [VibeLogger.cs], bounded duplicate suppression [CompileStatusBridgeCommand.cs], and comprehensive test coverage.
Out of Scope Changes check ✅ Passed All changes align with the stated objectives of improving compile wait diagnostics and CLI VibeLog debug detection; no unrelated modifications were introduced.
Title check ✅ Passed The title directly reflects the main change: adding compile reload diagnostics to VibeLog files. It accurately summarizes the primary objective of the pull request.
Description check ✅ Passed The description clearly relates to the changeset, detailing how VibeLog files now capture compile diagnostics, CLI debug logging resolution, and the user impact of these changes.

✏️ 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/fix-issue-1280

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.

@hatayama hatayama changed the title fix: Compile waits now leave actionable diagnostics after Unity reloads fix: Compile reload diagnostics are now saved to VibeLog files Jun 3, 2026

@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 (2)
cli/internal/cli/compile_wait.go (1)

412-426: ⚡ Quick win

Consider clarifying the bridge recovery log context.

Both old_endpoint and new_endpoint are set to options.connection.Endpoint.Address, which means they will always have identical values. If the endpoint address doesn't actually change during bridge recovery (only the connection is re-established), consider either:

  • Renaming the fields to clarify this (e.g., endpoint instead of old_endpoint/new_endpoint)
  • Removing one of the duplicate fields
  • Or documenting that the endpoint remains the same but the connection was recovered

The current field names suggest they should differ, which could mislead during diagnostics.

🤖 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 `@cli/internal/cli/compile_wait.go` around lines 412 - 426, In
logCompileBridgeRecoveryObserved, old_endpoint and new_endpoint are both set to
options.connection.Endpoint.Address which is misleading; update the log to
either use a single field (e.g., "endpoint") or rename/remove one of the
duplicate fields and set it to options.connection.Endpoint.Address, or add a
clarifying context entry that the endpoint remained unchanged while the
connection was re-established; adjust the cliVibeLogEntry Context map inside
logCompileBridgeRecoveryObserved accordingly (referencing
old_endpoint/new_endpoint and options.connection.Endpoint.Address).
Packages/src/Editor/Infrastructure/Api/CompileStatusBridgeCommand.cs (1)

210-222: 💤 Low value

Consider more gradual cache eviction.

The cache clearing strategy at Line 218 drops all 256 entries when the limit is reached. This could cause previously-deduplicated status observations to be logged again if the same request is polled after the cache clears. While the current approach achieves the bounded-state objective, a more gradual eviction (e.g., removing the oldest 25% of entries) would reduce diagnostic noise during high-request-volume scenarios.

However, given that this is debug-only logging and most compile-wait scenarios poll a single request ID until completion (at which point Line 204 removes the entry), the simple clear-all strategy is acceptable.

🤖 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/Api/CompileStatusBridgeCommand.cs` around
lines 210 - 222, StoreLoggedStatusSignature currently clears the entire
LastLoggedStatusByRequestId when Count >= MaxLoggedStatusSignatureCacheEntries
causing abrupt eviction and potential re-logging; change this to a gradual
eviction strategy: when the cache is full remove the oldest ~25% of entries
instead of clearing all. Implement this by tracking insertion order (e.g.,
maintain an ordered collection or queue alongside LastLoggedStatusByRequestId)
and, inside StoreLoggedStatusSignature, pop and remove the oldest N =
MaxLoggedStatusSignatureCacheEntries/4 keys from LastLoggedStatusByRequestId
before adding the new signature; keep the existing Debug.Assert checks and
continue to set LastLoggedStatusByRequestId[requestId] = signature afterwards.
🤖 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 `@cli/internal/cli/compile_wait.go`:
- Around line 412-426: In logCompileBridgeRecoveryObserved, old_endpoint and
new_endpoint are both set to options.connection.Endpoint.Address which is
misleading; update the log to either use a single field (e.g., "endpoint") or
rename/remove one of the duplicate fields and set it to
options.connection.Endpoint.Address, or add a clarifying context entry that the
endpoint remained unchanged while the connection was re-established; adjust the
cliVibeLogEntry Context map inside logCompileBridgeRecoveryObserved accordingly
(referencing old_endpoint/new_endpoint and options.connection.Endpoint.Address).

In `@Packages/src/Editor/Infrastructure/Api/CompileStatusBridgeCommand.cs`:
- Around line 210-222: StoreLoggedStatusSignature currently clears the entire
LastLoggedStatusByRequestId when Count >= MaxLoggedStatusSignatureCacheEntries
causing abrupt eviction and potential re-logging; change this to a gradual
eviction strategy: when the cache is full remove the oldest ~25% of entries
instead of clearing all. Implement this by tracking insertion order (e.g.,
maintain an ordered collection or queue alongside LastLoggedStatusByRequestId)
and, inside StoreLoggedStatusSignature, pop and remove the oldest N =
MaxLoggedStatusSignatureCacheEntries/4 keys from LastLoggedStatusByRequestId
before adding the new signature; keep the existing Debug.Assert checks and
continue to set LastLoggedStatusByRequestId[requestId] = signature afterwards.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e241893d-5e18-492f-aaed-e38811ff5a88

📥 Commits

Reviewing files that changed from the base of the PR and between b0608f3 and 701e7aa.

⛔ Files ignored due to path filters (1)
  • Assets/Tests/Editor/VibeLoggerTests.cs.meta is excluded by none and included by none
📒 Files selected for processing (15)
  • Assets/Tests/Editor/CompileSessionResultServiceTests.cs
  • Assets/Tests/Editor/CompileStatusBridgeCommandTests.cs
  • Assets/Tests/Editor/VibeLoggerTests.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileController.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileSessionResultService.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileUseCase.cs
  • Packages/src/Editor/Infrastructure/Api/CompileStatusBridgeCommand.cs
  • Packages/src/Editor/Infrastructure/Server/DomainReloadDetectionFileService.cs
  • Packages/src/Editor/Infrastructure/Server/UnityCliLoopServerController.cs
  • Packages/src/Editor/ToolContracts/VibeLogger.cs
  • cli/internal/cli/cli_vibe.go
  • cli/internal/cli/cli_vibe_test.go
  • cli/internal/cli/compile_wait.go
  • cli/internal/cli/compile_wait_test.go
  • cli/internal/cli/run.go

@hatayama

hatayama commented Jun 3, 2026

Copy link
Copy Markdown
Owner Author

Closing this PR to redo the work on a fresh branch. The ProjectSettings.asset-based CLI debug detection will be removed, and CLI VibeLog enablement will stay controlled by the ULOOP_DEBUG environment variable.

@hatayama hatayama closed this Jun 3, 2026
@hatayama
hatayama deleted the feature/hatayama/fix-issue-1280 branch July 10, 2026 12:20
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