refactor: deepen process termination intent#2210
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR refactors process termination from signal-based to intent-based semantics. It introduces TerminationIntent carrying mode and signal, adds intent-based TerminateProcessGroup APIs (Unix/Windows), defines an executor Stopper interface, updates executors to implement Stop(intent), and propagates intent-driven stop requests through Node, Runner, and Agent with timeout-based escalation. ChangesProcess Termination Intent Refactoring
Sequence Diagram(s)sequenceDiagram
participant Agent
participant Runner as Runner.Stop
participant Node as Node.Stop
participant Executor as Executor.Stop
participant Terminator as TerminateProcessGroup
Agent->>Agent: stopChildren(sig, allowOverride)
Note over Agent: intent = TerminationFromSignal(sig)
Agent->>Runner: Stop(intent, maxCleanUpTime)
loop Graceful phase
Runner->>Node: Stop(intent, allowOverride)
activate Node
Note over Node: Apply SignalOnStop override
Node->>Executor: Stop(intent)
Executor->>Terminator: TerminateProcessGroup(cmd, intent)
deactivate Node
Note over Agent: Poll, retry every N ms
end
alt Timeout
Agent->>Runner: Stop(ForceTermination())
Runner->>Node: Stop(ForceTermination(), allowOverride)
Node->>Executor: Stop(ForceTermination())
Executor->>Terminator: TerminateProcessGroup(cmd, ForceTermination())
else Success
Note over Agent: Done channel signals completion
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@internal/cmn/cmdutil/termination.go`:
- Around line 41-46: GracefulTermination currently returns
Mode=TerminationModeGraceful even for force-class signals (e.g., os.Kill), which
violates the "force signal => force mode" invariant enforced by
TerminationFromSignal and WithSignal; update GracefulTermination(sig os.Signal)
so it normalizes force signals by detecting the same force-class signals those
functions use and returning TerminationIntent{Mode: TerminationModeForce,
Signal: sig} when sig is a force signal, otherwise return the existing graceful
intent—follow the same detection logic used in TerminationFromSignal/WithSignal
so behavior is consistent across these helpers.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 41880d11-443f-4f54-a176-0cf92645c625
📒 Files selected for processing (16)
internal/agent/bash.gointernal/cmn/cmdutil/cmd_unix.gointernal/cmn/cmdutil/cmd_windows.gointernal/cmn/cmdutil/parent_exit_watcher_unix.gointernal/cmn/cmdutil/parent_exit_watcher_windows.gointernal/cmn/cmdutil/termination.gointernal/cmn/cmdutil/termination_test.gointernal/runtime/agent/agent.gointernal/runtime/builtin/command/command.gointernal/runtime/builtin/harness/harness.gointernal/runtime/executor/dag_runner.gointernal/runtime/executor/executor.gointernal/runtime/node.gointernal/runtime/node_test.gointernal/runtime/runner.gointernal/service/frontend/terminal/process_windows.go
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary
Refactor process termination around lifecycle intent so runtime code requests graceful or forceful stops without assuming Unix signal semantics.
Changes
cmdutil.TerminationIntentModule with graceful and force modes plus compatibility wrappers for legacy signal-based callers.signal_on_stopoverride behavior.Related Issues
N/A
Checklist
Testing
go test ./internal/cmn/cmdutil ./internal/runtime/... ./internal/engine ./internal/agent ./internal/service/frontend/terminal -count=1GOOS=windows GOARCH=amd64 go test -c -o /tmp/dagu-cmdutil.test.exe ./internal/cmn/cmdutilGOOS=windows GOARCH=amd64 go test -c -o /tmp/dagu-runtime.test.exe ./internal/runtimeGOOS=windows GOARCH=amd64 go test -c -o /tmp/dagu-command.test.exe ./internal/runtime/builtin/commandGOOS=windows GOARCH=amd64 go test -c -o /tmp/dagu-runtime-agent.test.exe ./internal/runtime/agentGOOS=windows GOARCH=amd64 go test -c -o /tmp/dagu-agent.test.exe ./internal/agentGOOS=windows GOARCH=amd64 go test -c -o /tmp/dagu-terminal.test.exe ./internal/service/frontend/terminalSummary by CodeRabbit
Refactor
Tests