Skip to content

fix: deny rather than silently auto-approve on daemon shutdown#483

Merged
tomasz-tomczyk merged 1 commit intomainfrom
fix/silent-auto-approve-on-daemon-shutdown
May 7, 2026
Merged

fix: deny rather than silently auto-approve on daemon shutdown#483
tomasz-tomczyk merged 1 commit intomainfrom
fix/silent-auto-approve-on-daemon-shutdown

Conversation

@tomasz-tomczyk
Copy link
Copy Markdown
Owner

Summary

  • handleReviewCycle ignored server-shutdown SSE events, so the handler kept blocking through graceful shutdown until the HTTP server force-closed the connection.
  • runReviewClientRaw then mapped every error path to (true, "") — silently approving the plan-hook PermissionRequest whenever the daemon died (graceful shutdown, crash, or crit stop).

Fix

  • Server: emits 503 with {status:"shutdown", approved:false, prompt} when the shutdown event fires (Content-Type set before WriteHeader so writeJSON doesn't drop it).
  • Client: never auto-approves on errors. Returns approved=false with an explanatory prompt for unreachable / malformed-body / unexpected-status / 503-shutdown cases, so the hook denies (with reason) instead of silently allowing.

Review

  • Code review: passed (go-expert + intent audit, both clean after fixups)
  • Parity audit: N/A (backend only)

Test plan

  • New regression tests TestRunReviewClientRaw_DaemonShutdownDeniesNotApproves:
    • 503 + structured shutdown payload → asserts approved=false, non-empty prompt
    • hijacked connection drop mid-request → asserts approved=false, non-empty prompt
  • Existing TestRunReviewClientRaw_* (readiness / no-delay) still green
  • go test ./..., gofmt, golangci-lint all clean

🤖 Generated with Claude Code

handleReviewCycle ignored server-shutdown SSE events, so the handler kept
blocking through graceful shutdown until the HTTP server force-closed the
connection. Client-side, runReviewClientRaw mapped every error path to
(true, "") — silently approving the plan-hook PermissionRequest whenever
the daemon died.

Now: server emits a 503 + {status:"shutdown", approved:false} payload when
the shutdown event fires, and the client returns approved=false with an
explanatory prompt for unreachable / malformed / unexpected-status cases
so the hook denies (with reason) instead of silently allowing.

Adds regression tests covering both the structured shutdown response and
a hard connection drop mid-request.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tomasz-tomczyk tomasz-tomczyk merged commit 2515c6d into main May 7, 2026
7 of 8 checks passed
@tomasz-tomczyk tomasz-tomczyk deleted the fix/silent-auto-approve-on-daemon-shutdown branch May 7, 2026 12:07
@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 5.26316% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.22%. Comparing base (3e31cd4) to head (c52e2c2).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
main.go 10.00% 7 Missing and 2 partials ⚠️
server.go 0.00% 9 Missing ⚠️

❌ Your patch status has failed because the patch coverage (5.26%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #483      +/-   ##
==========================================
- Coverage   69.27%   69.22%   -0.06%     
==========================================
  Files          43       43              
  Lines       10817    10829      +12     
==========================================
+ Hits         7494     7496       +2     
- Misses       2755     2765      +10     
  Partials      568      568              
Flag Coverage Δ
e2e 32.12% <0.00%> (-0.07%) ⬇️
unit 67.07% <5.26%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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