oficina / equipo Public

hostedops: safe-stop S.1 passes --console and --no-prompt to carlos

S.1 runs carlos under env -i with stdin null but passed neither flag the
plan and staging-thin.py use. The argv now names the console (the
ledger's instance-console note, or console.carloku.com) and never
prompts; a console that is not an https origin is refused. Mutations
C1-C4 recorded.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev ce57dd8e57e18c1445865865bac6b0fe888f3fe2 parent 9b9036d
4 files changed, +96 −2
  • docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md +22 −0
  • internal/hostedops/drill_test.go +52 −0
  • internal/hostedops/fix1_test.go +1 −1
  • internal/hostedops/stop.go +21 −1
diff --git a/docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md b/docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md
index 631fa161..f231d2e2 100644
--- a/docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md
+++ b/docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md
@@ -3424,3 +3424,25 @@ Mutation checks, each restored and green again:
- **S2** the wait no longer doubles. Same test: FAIL `drill_test.go:153: the waits did not grow: [10:00:00 10:00:05 10:00:10 10:00:15]`.
- **S3** the bound ten times longer. Same test: FAIL `drill_test.go:173: a persistent failure: 33 scans over 29m15s, want several within 3m0s`.
- **S4** the retry FINDING dropped. Same test: FAIL `drill_test.go:163: 0 retry findings, want 3`.
+
+### Fix 7: safe-stop's S.1 passes the console and --no-prompt (Fable 34, section 0)
+
+S.1 ran `carlos env unset --app A --account B EQUIPO_HOSTED_RUNNERS` under `env -i` with stdin null,
+without the `--console` and `--no-prompt` the plan's 8.1 and `scripts/staging-thin.py` pass. The argv
+is now built by `carlosUnsetArgv`: `env unset --app A --account B --console C --no-prompt
+EQUIPO_HOSTED_RUNNERS`, C being the ledger's `instance-console` note or `DefaultConsole`
+(`https://console.carloku.com`, the console the dev plan and staging-thin.py name). A note that is
+not an https origin is refused before carlos runs (S.1 fails, safe-stop ends 99). No plan text
+changes: the dev plan's console is the default.
+
+Red: `go test ./internal/hostedops -run 'TestSafeStopCarlosArgv|TestSafeStopInstanceFlagUnresolved' -count=1`: FAIL
+`drill_test.go:224: the plans' console: carlos argv ["env" "unset" "--app" "equipo-staging" "--account" "bds" "EQUIPO_HOSTED_RUNNERS"], want [... "--console" "https://console.carloku.com" "--no-prompt" ...]`,
+the same for the noted console, `drill_test.go:216: a console flag: safe-stop = 0, carlos ran true`, and
+`fix1_test.go:483` (its expectation now names both flags). Green: the whole package, ok.
+
+Mutation checks, each restored and green again:
+- **C1** `--console C` dropped from the argv. `-run TestSafeStopCarlosArgv`: FAIL `drill_test.go:224: the plans' console: carlos argv [... "--no-prompt" "EQUIPO_HOSTED_RUNNERS"]`.
+- **C2** `--no-prompt` dropped. Same test: FAIL `drill_test.go:224: ... "--console" "https://console.carloku.com" "EQUIPO_HOSTED_RUNNERS"]`.
+- **C3** the origin refusal skipped (`_ = u` in place of the return). Same test: FAIL `drill_test.go:216: a console flag: safe-stop = 0, carlos ran true`.
+ (A first try, `false && err != nil || ...`, left the other clauses refusing and passed; it was not a real mutation and is not counted.)
+- **C4** the note ignored (always the default). Same test: FAIL `drill_test.go:224: a noted console: carlos argv [... "https://console.carloku.com" ...]`.
diff --git a/internal/hostedops/drill_test.go b/internal/hostedops/drill_test.go
index 64204c51..1db011a8 100644
--- a/internal/hostedops/drill_test.go
+++ b/internal/hostedops/drill_test.go
@@ -2,6 +2,9 @@ package hostedops
import (
"errors"
+ "os"
+ "path/filepath"
+ "slices"
"strings"
"testing"
"time"
@@ -173,3 +176,52 @@ func TestEstimateRetriesTheScan(t *testing.T) {
t.Fatalf("a persistent failure: %d scans over %s, want several within %s", len(at), r.clock.Now().Sub(start), EstimateScanMax)
}
}
+
+// carlosStub is a carlos that records its argv, one argument a line, and
+// answers 0.
+func carlosStub(t *testing.T, r *rig) string {
+ t.Helper()
+ carlos := filepath.Join(t.TempDir(), "carlos")
+ if err := os.WriteFile(carlos, []byte("#!/bin/sh\nprintf '%s\\n' \"$@\" > \"$0.args\"\n"), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ r.deps.Carlos = carlos
+ return carlos + ".args"
+}
+
+// TestSafeStopCarlosArgv (Fable 34, section 0): S.1 runs carlos under
+// env -i with stdin null, so it passes the console and --no-prompt as the
+// plan and scripts/staging-thin.py do: the console the ledger notes
+// (instance-console), or the one every plan names. A console note that is
+// not an https origin is refused before carlos runs.
+func TestSafeStopCarlosArgv(t *testing.T) {
+ for name, c := range map[string]struct {
+ console string // the instance-console note, "" none
+ want []string
+ }{
+ "the plans' console": {"", []string{"env", "unset", "--app", "equipo-staging", "--account", "bds", "--console", "https://console.carloku.com", "--no-prompt", "EQUIPO_HOSTED_RUNNERS"}},
+ "a noted console": {"https://console.example.test", []string{"env", "unset", "--app", "equipo-staging", "--account", "bds", "--console", "https://console.example.test", "--no-prompt", "EQUIPO_HOSTED_RUNNERS"}},
+ "a console flag": {"--help", nil},
+ } {
+ lines := []string{ctlVM, "NOTE instance-app equipo-staging", "NOTE instance-account bds"}
+ if c.console != "" {
+ lines = append(lines, "NOTE instance-console "+c.console)
+ }
+ r := newRig(t, lines...)
+ args := carlosStub(t, r)
+ code := r.ops("safe-stop")
+ b, err := os.ReadFile(args)
+ if c.want == nil {
+ if code != ExitStop || err == nil || r.has("INSTANCE-FLAG", "") {
+ t.Errorf("%s: safe-stop = %d, carlos ran %t (%s)", name, code, err == nil, b)
+ }
+ continue
+ }
+ if code != 0 || err != nil {
+ t.Fatalf("%s: safe-stop = %d, %v:\n%s", name, code, err, r.out.String())
+ }
+ if got := strings.Split(strings.TrimSuffix(string(b), "\n"), "\n"); !slices.Equal(got, c.want) {
+ t.Errorf("%s: carlos argv %q, want %q", name, got, c.want)
+ }
+ }
+}
diff --git a/internal/hostedops/fix1_test.go b/internal/hostedops/fix1_test.go
index bac8b952..b083a4cb 100644
--- a/internal/hostedops/fix1_test.go
+++ b/internal/hostedops/fix1_test.go
@@ -479,7 +479,7 @@ func TestSafeStopInstanceFlagUnresolved(t *testing.T) {
os.WriteFile(carlos, []byte("#!/bin/sh\necho \"$@\" > \"$0.args\"\n"), 0o755)
r.deps.Carlos = carlos
r.want(0, "safe-stop")
- if b, _ := os.ReadFile(carlos + ".args"); !strings.Contains(string(b), "env unset --app equipo --account acme EQUIPO_HOSTED_RUNNERS") {
+ if b, _ := os.ReadFile(carlos + ".args"); !strings.Contains(string(b), "env unset --app equipo --account acme --console https://console.carloku.com --no-prompt EQUIPO_HOSTED_RUNNERS") {
t.Fatalf("carlos was not asked to unset the flag: %q", b)
}
}
diff --git a/internal/hostedops/stop.go b/internal/hostedops/stop.go
index 86897765..ea46417d 100644
--- a/internal/hostedops/stop.go
+++ b/internal/hostedops/stop.go
@@ -5,6 +5,7 @@ import (
"errors"
"flag"
"io"
+ "net/url"
"os"
"os/exec"
"slices"
@@ -297,12 +298,31 @@ func (o *Ops) unsetInstanceFlag() error {
_ = o.jw("UNRESOLVED", "S.1: a controller exists and the ledger has no instance-app and instance-account notes; the instance flag's state is unknown")
return stopf("S.1: cannot prove EQUIPO_HOSTED_RUNNERS is off: record ledger note instance-app and instance-account (7.1) and run safe-stop again")
}
+ console := l.Notes["instance-console"]
+ if console == "" {
+ console = DefaultConsole
+ }
+ if u, err := url.Parse(console); err != nil || u.Scheme != "https" || u.Host == "" || u.User != nil || strings.TrimSuffix(u.Path, "/") != "" || u.RawQuery != "" || u.Fragment != "" {
+ return failf("S.1: the instance-console note %q is not an https origin", console)
+ }
ctx, cancel := context.WithTimeout(o.ctx, 2*time.Minute)
defer cancel()
- cmd := exec.CommandContext(ctx, o.Carlos, "env", "unset", "--app", app, "--account", acct, "EQUIPO_HOSTED_RUNNERS")
+ cmd := exec.CommandContext(ctx, o.Carlos, carlosUnsetArgv(app, acct, console)...)
cmd.Stdout, cmd.Stderr = o.Stdout, o.Stderr
if err := cmd.Run(); err != nil {
return failf("carlos env unset EQUIPO_HOSTED_RUNNERS: %v", err)
}
return o.jw("INSTANCE-FLAG", "unset EQUIPO_HOSTED_RUNNERS on %s/%s", acct, app)
}
+
+// DefaultConsole is the CARLOS console S.1 names when the ledger notes
+// none (instance-console): the one the plans and scripts/staging-thin.py
+// name.
+const DefaultConsole = "https://console.carloku.com"
+
+// carlosUnsetArgv is S.1's carlos argv. The unit runs it under env -i with
+// stdin null, so it names the console and never prompts, as the plan's
+// 8.1 and scripts/staging-thin.py do (Fable 34, section 0).
+func carlosUnsetArgv(app, account, console string) []string {
+ return []string{"env", "unset", "--app", app, "--account", account, "--console", console, "--no-prompt", "EQUIPO_HOSTED_RUNNERS"}
+}