Remove resource pools, leases and wait queues

Drop the resource allocation feature end to end: store tables and migration, runner scheduling and cleanup, protocol types and commands, CLI commands, TUI screens, tests and docs. Existing databases open cleanly and definitions carrying a retired resources block still validate.
This commit is contained in:
2026-10-19 22:27:27 +01:00
parent a676b30ff0
commit 72aecd8b1f
45 changed files with 282 additions and 3954 deletions
+3 -146
View File
@@ -7,7 +7,6 @@ import (
"flag"
"fmt"
"io"
"net/url"
"os"
"os/exec"
"path/filepath"
@@ -47,9 +46,7 @@ type options struct {
keepSet bool
all bool
json, source, noOpen, yes, allow, createOnly, force, wait bool
version, expected, limit, recoverySequence, retryVisit int
recoveryRun int64
recoveryStage, resource, poolFile string
version, expected, limit, retryVisit int
timeout, waitTimeout time.Duration
stageModels stageModelFlags
}
@@ -186,18 +183,6 @@ func (a App) flags(command string) (*flag.FlagSet, *options) {
case "decide":
f.StringVar(&o.option, "option", "", "Option key to choose among the waiting stage's edges (required)")
f.StringVar(&o.feedback, "feedback", "", "Optional free-text feedback recorded with the decision")
case "resource-inspect":
f.StringVar(&o.resource, "resource", "", "Exclusive resource key")
case "resource-reconcile":
f.StringVar(&o.evidence, "evidence", "", "Bounded positive cleanup/restoration evidence (required)")
f.StringVar(&o.actor, "actor", "operator", "Bounded operator identity")
f.BoolVar(&o.allow, "no-mutating-action", false, "Evidence explicitly records that no mutating action occurred")
f.BoolVar(&o.yes, "yes", false, "Confirm reconciliation without prompting")
case "resource-pool-inspect":
f.StringVar(&o.resource, "pool", "", "Resource pool name")
case "resource-pool-configure":
f.StringVar(&o.poolFile, "file", "", "JSON pool declaration, or - for stdin")
f.BoolVar(&o.yes, "yes", false, "Confirm this mutation without prompting")
case "debug":
f.StringVar(&o.harness, "harness", "", "Debugging harness: configured opencode/pi, or nvim")
f.BoolVar(&o.yes, "yes", false, "Approve opening a debugging session without prompting")
@@ -484,13 +469,6 @@ func (a App) Run(ctx context.Context, args []string) error {
requestTimeout = 30 * time.Second
}
connectURL := o.url
if command == "resource-inspect" || command == "resource-reconcile" || command == "resource-pool-inspect" || command == "resource-pool-configure" {
var transportErr error
connectURL, transportErr = operatorTransportURL(o.url)
if transportErr != nil {
return transportErr
}
}
dialCtx, cancel := context.WithTimeout(ctx, requestTimeout)
c, err := client.Open(dialCtx, connectURL)
cancel()
@@ -803,7 +781,7 @@ func (a App) Run(ctx context.Context, args []string) error {
}
case "runs":
for _, run := range r.Runs {
fmt.Fprintf(a.Out, "%d\t%s\t%s\tv%d\t%s\n", run.ID, run.Label(), run.Name, run.Version, run.StatusLabel())
fmt.Fprintf(a.Out, "%d\t%s\t%s\tv%d\t%s\n", run.ID, run.Label(), run.Name, run.Version, run.Status)
}
case "ping":
fmt.Fprintln(a.Out, "Connected ·", r.Time)
@@ -926,117 +904,6 @@ func (a App) Run(ctx context.Context, args []string) error {
}
}
return fmt.Errorf("template %q not found", key)
case "resource-inspect":
if len(pos) > 1 {
return fmt.Errorf("resource-inspect takes one resource key")
}
if o.resource == "" && len(pos) == 1 {
o.resource = pos[0]
}
if strings.TrimSpace(o.resource) == "" {
return fmt.Errorf("resource-inspect requires a resource key")
}
r, err := call(protocol.Message{Type: protocol.InspectResource, Resource: o.resource})
if err != nil {
return err
}
if r.ResourceInspection == nil {
return fmt.Errorf("server did not return resource inspection")
}
return a.output(r.ResourceInspection)
case "resource-reconcile":
if len(pos) != 4 {
return fmt.Errorf("resource-reconcile requires resource, run-id, stage and sequence")
}
runID, err := strconv.ParseInt(pos[1], 10, 64)
if err != nil || runID <= 0 {
return fmt.Errorf("run ID must be positive")
}
sequence, err := strconv.Atoi(pos[3])
if err != nil || sequence <= 0 {
return fmt.Errorf("sequence must be positive")
}
if strings.TrimSpace(o.evidence) == "" {
return fmt.Errorf("--evidence is required")
}
if err := a.confirmAction(fmt.Sprintf("Reconcile quarantined resource %s for run #%d?", pos[0], runID), o.yes); err != nil {
return err
}
r, err := call(protocol.Message{Type: protocol.ReconcileResource, Resource: pos[0], ResourceRecovery: &protocol.ResourceRecoveryRequest{Resource: pos[0], RunID: runID, Stage: pos[2], Sequence: sequence, Actor: o.actor, Evidence: &protocol.ResourceRecoveryEvidence{CleanupConfirmed: true, NoMutatingAction: o.allow, Summary: o.evidence}}})
if err != nil {
return err
}
if o.json {
return a.output(r)
}
_, err = fmt.Fprintf(a.Out, "Reconciled resource %s for run #%d\n", pos[0], runID)
return err
case "resource-pool-inspect":
if len(pos) > 1 {
return fmt.Errorf("resource-pool-inspect takes one pool name")
}
if o.resource == "" && len(pos) == 1 {
o.resource = pos[0]
}
if strings.TrimSpace(o.resource) == "" {
return fmt.Errorf("resource-pool-inspect requires a pool name")
}
r, err := call(protocol.Message{Type: protocol.InspectResourcePool, Resource: o.resource})
if err != nil {
return err
}
if r.ResourcePool == nil {
return fmt.Errorf("server did not return resource pool")
}
return a.output(r.ResourcePool)
case "resource-pool-configure":
if len(pos) > 1 {
return fmt.Errorf("resource-pool-configure takes one JSON file")
}
file := o.poolFile
if file == "" && len(pos) == 1 {
file = pos[0]
}
if file == "" {
return fmt.Errorf("resource-pool-configure requires a JSON file")
}
var data []byte
if file == "-" {
input := a.In
if input == nil {
input = os.Stdin
}
data, err = io.ReadAll(io.LimitReader(input, 256*1024+1))
} else {
var input *os.File
input, err = os.Open(file)
if err == nil {
data, err = io.ReadAll(io.LimitReader(input, 256*1024+1))
_ = input.Close()
}
}
if err != nil {
return err
}
if len(data) > 256*1024 {
return fmt.Errorf("resource pool input exceeds 262144 bytes")
}
var pool protocol.ResourcePool
if err := json.Unmarshal(data, &pool); err != nil {
return fmt.Errorf("invalid resource pool JSON: %w", err)
}
if err := a.confirmAction(fmt.Sprintf("Configure resource pool %s?", pool.Name), o.yes); err != nil {
return err
}
r, err := call(protocol.Message{Type: protocol.ConfigureResourcePool, ResourcePool: &pool})
if err != nil {
return err
}
if o.json {
return a.output(r)
}
_, err = fmt.Fprintf(a.Out, "Configured resource pool %s\n", pool.Name)
return err
case "inspect", "cancel", "retry":
value, err := one()
if err != nil {
@@ -1217,16 +1084,6 @@ func (a App) Run(ctx context.Context, args []string) error {
return nil
}
func operatorTransportURL(raw string) (string, error) {
u, err := url.Parse(raw)
if err != nil || u.Scheme == "" || u.Host == "" {
return "", fmt.Errorf("invalid configured pipeline URL")
}
u.Path = "/operator-connect"
u.RawPath = ""
return u.String(), nil
}
func (a App) output(value any) error {
encoder := json.NewEncoder(a.Out)
encoder.SetIndent("", " ")
@@ -1672,7 +1529,7 @@ func (e *waitLimitError) Runs() string {
// waitLine is the one-line terminal report `pipelines wait` prints: the run id,
// its status and outcome, its stage and how long it took.
func waitLine(d *protocol.RunDetail) string {
line := fmt.Sprintf("run %d · %s", d.ID, d.StatusLabel())
line := fmt.Sprintf("run %d · %s", d.ID, d.Status)
if outcome := strings.TrimSpace(d.Outcome); outcome != "" {
line += " (" + outcome + ")"
}