test(control): cross-process control channel tests#120
Conversation
Stop/pause from claudetm-server/MCP/CLI now reach a running orchestrator across process boundaries. request_shutdown only set a process-local threading.Event, invisible to a CLI-launched run in another process, so POST /control/stop returned 200 while work continued. - Add ControlChannel (control.json) with durable atomic writes + tolerant reads (missing/corrupt/unknown-action -> no request) - ControlManager.stop/pause write the durable signal; resume clears it - Orchestrator polls the channel each loop cycle beside is_cancellation_requested(); stop -> "stopped", pause -> "paused" - ShutdownManager observes a bound durable-stop check so in-cycle CI waits (interruptible_sleep) also honour a cross-process stop Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The orchestrator holds one long-lived in-memory TaskState and saves it ~31 times per run. Between saves, another process (REST/MCP/CLI via ControlManager) may stop/pause the run or patch its options — the orchestrator's next save clobbered those back (stopped->working is a valid transition; stale options reverted a PATCH /config). - Add StateManager.save_state_merged: re-reads on-disk state under the same exclusive lock as the write and overlays control-plane fields — options always win (config patch adopted in place), and an external stopped/paused is kept for any incoming status (never resumed except via an explicit resume on the plain save_state path). Keeping the disk status makes the transition a no-op, so a terminal write racing a stop can't trip InvalidStateTransitionError. - Route all orchestrator save_state sites through save_state_merged. - Add CONTROL_AUTHORITATIVE_STATUSES; save_state now returns the state. - Tests: merged-save unit tests + cross-process control integration (stop/pause/config-patch survive a second StateManager's save). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Wait (bounded, env-configurable) for is_session_active() to go false before cleanup_on_success; skip cleanup if a live session persists so a cross-process orchestrator's next save_state can't recreate a half-populated state dir. - Log + report dropped pending mailbox count on cleanup. - Add 5 tests: dropped-count logging, skip-on-active, proceed-on- release, immediate-when-inactive. Co-Authored-By: Claude <noreply@anthropic.com>
- TestControlChannelCrossProcess: verify stop/pause are written to control.json and readable in one poll cycle (orchestrator first read) - test_resume_clears_channel: resume() clears stale stop from channel - Two stop+cleanup race tests using a second StateManager instance to simulate real cross-process scenario (skipped vs proceeds variants) Co-Authored-By: Claude <noreply@anthropic.com>
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 15 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
TestControlChannelCrossProcessclass verifying stop/pause are written tocontrol.jsonimmediately (honored in one cycle)resume()clears the channel so a stale signal doesn't re-halt the fresh runStateManagerinstance to simulate the real cross-process scenario (control process vs. orchestrator process): skip-cleanup when session active, proceed once releasedTest plan
uv run pytest tests/core/test_control.py— 77 passedruff check+ruff format --check— cleanmypy .— 305 files, no issues🤖 Generated with Claude Code