Skip to content

feat: stop newly started reviews gracefully on Ctrl-C - #90

Open
am-saksham wants to merge 1 commit into
prooflinedev:mainfrom
am-saksham-proofline-lab:feat/graceful-ctrl-c-stop
Open

am-saksham wants to merge 1 commit into
prooflinedev:mainfrom
am-saksham-proofline-lab:feat/graceful-ctrl-c-stop

Conversation

@am-saksham

Copy link
Copy Markdown

Summary

Adds graceful Ctrl-C (SIGINT) handling to CLI commands that poll a running review (review, findings --wait, scan, rerun, ci review, and Git hooks).

Previously, interrupting a waiting review terminated the process immediately without printing the review link or stopping the remote job—leaving newly started reviews running and consuming credits on the server.

Changes

  • Explicit interrupt ownership policy (OnInterrupt) in src/lib.rs:
    • OnInterrupt::Stop — used only for newly created (!existing) local-patch, pushed-commit, named-file, and Git-hook reviews. Cancels polling immediately and sends a single bounded POST /reviews/{id}/stop (5s timeout, never retried). Pressing Ctrl-C a second time aborts immediately and prints the manual proofline stop <id> command and review URL.
    • OnInterrupt::Detach — used for reused (existing: true) reviews, pull-request reviews, findings --wait, scan, rerun, and ci review. Detaches without calling /stop and prints the console URL plus proofline findings --review <id> --wait.
  • Exit code & stream hygiene (src/lib.rs, src/main.rs):
    • Adds Verdict::Interrupted, mapped to exit code 130 (128 + SIGINT).
    • Writes all interrupt notices to stderr, keeping stdout clean for --json callers.
  • Git hooks (src/hooks.rs):
    • Interrupting a pre-commit or pre-push hook stops a newly requested hook review and exits 130 immediately rather than continuing to remaining refs or letting mode = warn proceed.
  • Signal support (Cargo.toml):
    • Enables Tokio's signal feature.

Verification

  • Unit tests (src/lib.rs): deterministic read_review_until tests with injected interrupt futures covering:
    • interrupt_with_stop_sends_one_stop_request_and_returns_interrupted
    • interrupt_with_detach_never_calls_stop
    • interrupt_with_stop_refusal_does_not_retry_and_returns_interrupted
    • second_interrupt_aborts_hung_stop_immediately
  • Integration tests (tests/interrupt.rs): real Unix SIGINT subprocess tests against an axum loopback server covering:
    • sigint_stops_newly_requested_local_review_and_exits_130
    • sigint_detaches_reused_local_review_without_stopping_and_exits_130
  • Ran cargo fmt --check, cargo clippy --all-targets, and cargo test.

This branch has not been deployed

No deployments
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