Files
archie/internal/tools/classification.go
T
sam c265b07ec7 refactor(workflow): stop assuming a human decides
An approval, ask or park can be resolved by an operator, a rule, a
classifier or automatically, so the vocabulary stops naming a person:

- step type human.approve -> workflow.approve
- park class needs_human -> needs_decision (ParkNeedsDecision)
- event kinds human_* -> operator_*
- alert kind task.needs_human -> task.needs_decision
- status grouping "needs you" -> "needs attention"

0061 rewrites the stored values, including the approval step type in the
workflow-definitions resource and each task's pinned definition, with the
digest recomputed so resumed tasks still match.
2026-10-25 17:31:16 +11:00

63 lines
1.8 KiB
Go

package tools
import "strings"
// ToolClassification is a bitmask that describes a tool's behavioral
// characteristics for dispatch gating, guardrail decisions, and per-result
// limit enforcement.
type ToolClassification int
const (
// ClassIdempotent marks a read-only tool. Idempotent tools can be
// safely retried and run in parallel with other calls.
ClassIdempotent ToolClassification = 1 << iota
// ClassMutating marks a tool that modifies external state (writes files,
// creates resources, sends messages, etc.). A mutating call with a path
// argument runs in order with other calls on that path; any other
// mutating call runs alone.
ClassMutating
// RequiresApproval marks a tool that needs operator approval before each call.
RequiresApproval
)
// IsIdempotent reports whether the classification includes the idempotent
// flag. A zero-value classification reports false.
func (c ToolClassification) IsIdempotent() bool {
return c&ClassIdempotent != 0
}
// IsMutating reports whether the classification includes the mutating flag.
// A zero-value classification reports false.
func (c ToolClassification) IsMutating() bool {
return c&ClassMutating != 0
}
// IsApprovalRequired reports whether the classification includes the
// RequiresApproval flag. A zero-value classification reports false.
func (c ToolClassification) IsApprovalRequired() bool {
return c&RequiresApproval != 0
}
// String returns a human-readable representation of the classification.
func (c ToolClassification) String() string {
if c == 0 {
return "default"
}
var parts []string
if c.IsIdempotent() {
parts = append(parts, "idempotent")
}
if c.IsMutating() {
parts = append(parts, "mutating")
}
if c.IsApprovalRequired() {
parts = append(parts, "requires_approval")
}
if len(parts) == 0 {
return "unknown"
}
return strings.Join(parts, "|")
}