fix(agentic): reject invalid workspace clean filters
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
b1b51c04f9
commit
85ef4a6dd4
2 changed files with 18 additions and 2 deletions
|
|
@ -45,6 +45,10 @@ func (s *PrepSubsystem) cmdWorkspaceClean(options core.Options) core.Result {
|
|||
if filter == "" {
|
||||
filter = "all"
|
||||
}
|
||||
if !workspaceCleanFilterValid(filter) {
|
||||
core.Print(nil, "usage: core-agent workspace clean [all|completed|failed|blocked]")
|
||||
return core.Result{Value: core.E("agentic.cmdWorkspaceClean", core.Concat("unknown filter: ", filter), nil), OK: false}
|
||||
}
|
||||
|
||||
statusFiles := WorkspaceStatusPaths()
|
||||
var toRemove []string
|
||||
|
|
@ -93,6 +97,15 @@ func (s *PrepSubsystem) cmdWorkspaceClean(options core.Options) core.Result {
|
|||
return core.Result{OK: true}
|
||||
}
|
||||
|
||||
func workspaceCleanFilterValid(filter string) bool {
|
||||
switch filter {
|
||||
case "all", "completed", "failed", "blocked":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// input := DispatchInput{Repo: "go-io", Task: "Fix the failing tests", Issue: 12}
|
||||
func (s *PrepSubsystem) cmdWorkspaceDispatch(options core.Options) core.Result {
|
||||
input := workspaceDispatchInputFromOptions(options)
|
||||
|
|
|
|||
|
|
@ -83,9 +83,12 @@ func TestCommandsworkspace_CmdWorkspaceClean_Bad_UnknownFilterLeavesEverything(t
|
|||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
// Filter "unknown" matches no switch case — nothing gets removed
|
||||
// Unknown filters now fail explicitly so agent callers can correct typos.
|
||||
r := s.cmdWorkspaceClean(core.NewOptions(core.Option{Key: "_arg", Value: "unknown"}))
|
||||
assert.True(t, r.OK)
|
||||
assert.False(t, r.OK)
|
||||
err, ok := r.Value.(error)
|
||||
assert.True(t, ok)
|
||||
assert.Contains(t, err.Error(), "unknown filter: unknown")
|
||||
|
||||
// All workspaces should still exist
|
||||
for _, name := range []string{"ws-done", "ws-fail", "ws-run"} {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue