Skip to content

[cli] fix: require clean service-stop result - #269

Merged
Wangmerlyn merged 1 commit into
mainfrom
codex/service-stop-message-validation
Jul 1, 2026
Merged

[cli] fix: require clean service-stop result#269
Wangmerlyn merged 1 commit into
mainfrom
codex/service-stop-message-validation

Conversation

@Wangmerlyn

@Wangmerlyn Wangmerlyn commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • block non-force service-stop from signaling the daemon when stop_keep returns a non-empty message
  • add regression coverage for a message-only stop result that previously allowed daemon shutdown
  • document the clean stop_keep requirement in AGENTS.md and the CLI reference

Verification

  • PYTHONPATH=src pytest tests/test_cli_service_commands.py::test_service_stop_rejects_stop_keep_message_before_stopping_daemon -q (RED before fix: failed because exit_code was 0)
  • PYTHONPATH=src pytest tests/test_cli_service_commands.py::test_service_stop_rejects_stop_keep_message_before_stopping_daemon -q
  • PYTHONPATH=src pytest tests/test_cli_service_commands.py -k service_stop -q
  • PYTHONPATH=src pytest tests/test_cli_service_commands.py -q
  • mkdocs build --strict
  • PYTHONPATH=src pytest tests -q
  • pre-commit run --all-files --show-diff-on-failure

Summary by CodeRabbit

  • Bug Fixes

    • Improved keep-gpu service-stop validation so malformed stop responses are treated as incomplete when they include a message, preventing shutdown from continuing with bad input.
    • The command now surfaces the returned message, exits with an error, and shows the --force hint when applicable.
  • Tests

    • Added coverage for rejecting stop responses that contain a message before any daemon shutdown action occurs.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Wangmerlyn, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9de6cc9e-7ee0-45cd-b3a1-f5ee543329e2

📥 Commits

Reviewing files that changed from the base of the PR and between 1c55f49 and e70ed25.

📒 Files selected for processing (4)
  • AGENTS.md
  • docs/reference/cli.md
  • src/keep_gpu/cli.py
  • tests/test_cli_service_commands.py
📝 Walkthrough

Walkthrough

Adds a check for a non-empty message field in stop_keep results to the _require_clean_stop_keep_for_service_stop validation in the CLI, blocking service-stop when present, with an accompanying test. Also reflows unrelated documentation text in AGENTS.md and cli.md.

Changes

stop_keep Message Validation

Layer / File(s) Summary
Validation logic and test
src/keep_gpu/cli.py, tests/test_cli_service_commands.py
_require_clean_stop_keep_for_service_stop now treats a non-empty message field as an incomplete indicator, blocking service-stop; a new test verifies exit code 1, message output, --force hint, and that the daemon stop function is not called.
Documentation reflow
AGENTS.md, docs/reference/cli.md
Text describing service-stop behavior is rewrapped for line length, with no change in meaning.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI as keep-gpu CLI
  participant Validator as _require_clean_stop_keep_for_service_stop
  participant Daemon

  User->>CLI: keep-gpu service-stop
  CLI->>Validator: check stop_keep result
  alt message field non-empty
    Validator->>Validator: append message to incomplete list
    Validator-->>CLI: raise error
    CLI-->>User: exit code 1, message + --force hint
    CLI--xDaemon: stop_process not called
  else no message
    Validator-->>CLI: validation passes
    CLI->>Daemon: stop_process
  end
Loading

Possibly related PRs

  • Wangmerlyn/KeepGPU#66: Introduced the service-stop workflow whose _require_clean_stop_keep_for_service_stop validation this PR extends.
  • Wangmerlyn/KeepGPU#131: Also extends stop_keep payload validation to treat a non-empty message as invalid and adds corresponding tests ensuring no daemon stop side-effect.
  • Wangmerlyn/KeepGPU#168: Similarly tightens pre-stop stop_keep validation and extends tests confirming the daemon stop routine isn't called on failure.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main CLI change: service-stop now requires a clean stop_keep result before stopping the daemon.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/service-stop-message-validation

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.

@Wangmerlyn
Wangmerlyn force-pushed the codex/service-stop-message-validation branch from 1c55f49 to e70ed25 Compare July 1, 2026 23:06
@Wangmerlyn
Wangmerlyn merged commit e8629f3 into main Jul 1, 2026
6 checks passed
@Wangmerlyn
Wangmerlyn deleted the codex/service-stop-message-validation branch July 1, 2026 23:10
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