feat(tasks): allow rejecting a task from any non-terminal state
An operator could only reject work that was waiting on a human decision, so a task sitting in review (PR open) or running had no way to be refused even when it was clearly dangerous. - expose reject in taskstate.Actions for every non-terminal state (queued, running, waiting_human, parked, pr_open) so both the dashboard and the chat tool surface it; terminal states still only expose archive - make rejectTask transition from the task's actual status to closed_wont_do and interrupt running execution first, so nothing keeps working against a task being closed out - keep the distinct stop (recoverable → parked) semantics; reject is the terminal escape hatch - update the lifecycle contract tests to the new intent
This commit is contained in:
1 parent
8ef6980fe6
commit
96c82cd4e0
6 files changed
+40
-25
No files matched your search
@@ -72,19 +72,24 @@ func Terminal(status string) bool {
|
||||
|
||||
// Actions returns the ordered controls valid for status. Callers receive a
|
||||
// fresh slice so presentation code cannot mutate the lifecycle table.
|
||||
//
|
||||
// Reject is deliberately present in every non-terminal state: an operator can
|
||||
// refuse work no matter where it currently sits, and the refusal always lands
|
||||
// in the terminal Declined state. Terminal states are already resolved, so
|
||||
// they only expose archive.
|
||||
func Actions(status string) []Action {
|
||||
var actions []Action
|
||||
switch status {
|
||||
case Queued:
|
||||
actions = []Action{ActionCancel}
|
||||
actions = []Action{ActionCancel, ActionReject}
|
||||
case Running:
|
||||
actions = []Action{ActionStop}
|
||||
actions = []Action{ActionStop, ActionReject}
|
||||
case WaitingHuman:
|
||||
actions = []Action{ActionApprove, ActionReject}
|
||||
case Parked:
|
||||
actions = []Action{ActionRetry, ActionAbandon}
|
||||
actions = []Action{ActionRetry, ActionAbandon, ActionReject}
|
||||
case PROpen:
|
||||
actions = []Action{ActionOpenPR, ActionOpenIssue}
|
||||
actions = []Action{ActionOpenPR, ActionOpenIssue, ActionReject}
|
||||
case Merged, Rejected, Dead, Declined:
|
||||
actions = []Action{ActionArchive}
|
||||
}
|
||||
@@ -126,9 +131,9 @@ func CheckRetry(status string) error {
|
||||
// CheckDecline reports whether a task in this status can be declined.
|
||||
//
|
||||
// The legacy chat command expresses cancel, stop, reject and abandon as one
|
||||
// operation. It remains available only where the canonical action table
|
||||
// exposes one of those controls; unknown, PR-open and terminal states fail
|
||||
// closed instead of permitting an arbitrary transition.
|
||||
// operation. Because Reject is now offered in every non-terminal state, that
|
||||
// command is available everywhere a task is still live; unknown and terminal
|
||||
// states fail closed instead of permitting an arbitrary transition.
|
||||
func CheckDecline(status string) error {
|
||||
for _, action := range Actions(status) {
|
||||
switch action {
|
||||
|
||||
@@ -15,11 +15,11 @@ func TestActionRules(t *testing.T) {
|
||||
terminal bool
|
||||
actions []Action
|
||||
}{
|
||||
{status: Queued, decline: true, actions: []Action{ActionCancel}},
|
||||
{status: Running, decline: true, actions: []Action{ActionStop}},
|
||||
{status: Queued, decline: true, actions: []Action{ActionCancel, ActionReject}},
|
||||
{status: Running, decline: true, actions: []Action{ActionStop, ActionReject}},
|
||||
{status: WaitingHuman, approve: true, decline: true, actions: []Action{ActionApprove, ActionReject}},
|
||||
{status: PROpen, actions: []Action{ActionOpenPR, ActionOpenIssue}},
|
||||
{status: Parked, retry: true, decline: true, actions: []Action{ActionRetry, ActionAbandon}},
|
||||
{status: PROpen, decline: true, actions: []Action{ActionOpenPR, ActionOpenIssue, ActionReject}},
|
||||
{status: Parked, retry: true, decline: true, actions: []Action{ActionRetry, ActionAbandon, ActionReject}},
|
||||
{status: Merged, terminal: true, actions: []Action{ActionArchive}},
|
||||
{status: Rejected, terminal: true, actions: []Action{ActionArchive}},
|
||||
{status: Dead, terminal: true, actions: []Action{ActionArchive}},
|
||||
|
||||
Reference in new issue
Block a user