oficina / equipo Public

hosted slice 2: review fixes, plan cert lines match the CLIs

Task 32 finding 3. The account plan's section 6 and 8.3 now use the
real equipo-hosted-certify flags (-controller-tls-pin, -controller-pub,
-operator-id, -size, -key-id, -cert-keys), read the launch ID from cert
launch's own output (the evidence file holds only signed bytes), and
apply controller/env with ops controller reboot: reload does not
re-read the launch switch. 9.3 and Task 34's text follow.

certify and the image tool each parse and check an invocation before
anything is read or called (parseCommand, parseInvocation), and
TestPlanCertInvocationsParse and TestPlanImgInvocationsParse run every
literal cert and img line of both plans through them (img with the
plan's own wrapper flags), via the plantest helper.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 2ac29b1a7bb4ae1cca2491afed691ed9ae0ad829 parent 639be43
7 files changed, +453 −71
  • cmd/equipo-hosted-certify/main.go +87 −28
  • cmd/equipo-hosted-certify/plan_test.go +72 −0
  • cmd/equipo-hosted-image/main.go +51 −28
  • cmd/equipo-hosted-image/plan_test.go +55 −0
  • docs/superpowers/plans/2026-11-30-hosted-prod-account-plan.md +24 −14
  • docs/superpowers/plans/2026-11-30-hosted-runners-slice-2.md +1 −1
  • internal/hostedops/plantest/plantest.go +163 −0
diff --git a/cmd/equipo-hosted-certify/main.go b/cmd/equipo-hosted-certify/main.go
index bde19e14..3696ba99 100644
--- a/cmd/equipo-hosted-certify/main.go
+++ b/cmd/equipo-hosted-certify/main.go
@@ -111,53 +111,84 @@ func report(w io.Writer, err error) int {
}
func run(ctx context.Context, args []string, stdout, stderr io.Writer, now func() time.Time) int {
+ cmd, err := parseCommand(ctx, args, now)
+ if err != nil {
+ return report(stderr, err)
+ }
+ res, err := cmd()
+ if err != nil {
+ return report(stderr, err)
+ }
+ b, _ := json.Marshal(res)
+ fmt.Fprintf(stdout, "%s\n", b)
+ return 0
+}
+
+// parseCommand parses one invocation and checks its arguments, reading no
+// file and calling nothing (the account plan's invocations are checked
+// this way, Task 32); the command it returns does the rest.
+func parseCommand(ctx context.Context, args []string, now func() time.Time) (func() (any, error), error) {
if len(args) == 0 {
- return report(stderr, usage("a command is required: launch, judge, sign, verify, reload or alert-test"))
+ return nil, usage("a command is required: launch, judge, sign, verify, reload or alert-test")
}
fs := flag.NewFlagSet(args[0], flag.ContinueOnError)
fs.SetOutput(io.Discard)
- var res any
- var err error
switch args[0] {
case "launch":
l := launchFlags(fs)
- if err = parse(fs, args[1:]); err == nil {
- res, err = l.run(ctx, now)
+ if err := parse(fs, args[1:]); err != nil {
+ return nil, err
}
+ if err := l.check(); err != nil {
+ return nil, err
+ }
+ return func() (any, error) { return l.run(ctx, now) }, nil
case "judge":
j := judgeFlags(fs)
out := fs.String("out", "snapshot.json", "where to write the derived snapshot")
- if err = parse(fs, args[1:]); err == nil {
- res, err = judge(j, *out)
+ if err := parse(fs, args[1:]); err != nil {
+ return nil, err
+ }
+ if err := j.check(); err != nil {
+ return nil, err
}
+ return func() (any, error) { return judge(j, *out) }, nil
case "sign":
j := judgeFlags(fs)
key := fs.String("key", "", "the offline signing key: an ed25519 seed in standard base64, readable by its owner alone")
keyID := fs.String("key-id", "", "the signing key's ID in controller/cert-keys.json")
out := fs.String("out", "certificate.json", "where to write the certificate")
- if err = parse(fs, args[1:]); err == nil {
- res, err = sign(j, *key, *keyID, *out, now)
+ if err := parse(fs, args[1:]); err != nil {
+ return nil, err
+ }
+ if err := j.check(); err != nil {
+ return nil, err
}
+ if *key == "" || *keyID == "" {
+ return nil, usage("-key and -key-id are required")
+ }
+ return func() (any, error) { return sign(j, *key, *keyID, *out, now) }, nil
case "verify":
cert := fs.String("cert", "", "the certificate to verify")
keys := fs.String("cert-keys", "", "the certificate key file (controller/cert-keys.json)")
- if err = parse(fs, args[1:]); err == nil {
- res, err = verify(*cert, *keys)
+ if err := parse(fs, args[1:]); err != nil {
+ return nil, err
+ }
+ if *cert == "" || *keys == "" {
+ return nil, usage("-cert and -cert-keys are required")
}
+ return func() (any, error) { return verify(*cert, *keys) }, nil
case "reload", "alert-test":
c := controllerFlags(fs)
- if err = parse(fs, args[1:]); err == nil {
- res, err = admin(ctx, args[0], c)
+ if err := parse(fs, args[1:]); err != nil {
+ return nil, err
}
- default:
- err = usage("unknown command %q", args[0])
- }
- if err != nil {
- return report(stderr, err)
+ if err := c.check(); err != nil {
+ return nil, err
+ }
+ return func() (any, error) { return admin(ctx, args[0], c) }, nil
}
- b, _ := json.Marshal(res)
- fmt.Fprintf(stdout, "%s\n", b)
- return 0
+ return nil, usage("unknown command %q", args[0])
}
func parse(fs *flag.FlagSet, args []string) error {
@@ -182,11 +213,19 @@ func judgeFlags(fs *flag.FlagSet) judgeArgs {
}
}
+// check refuses a judgement missing a required argument.
+func (j judgeArgs) check() error {
+ if *j.evidence == "" || *j.release == "" || *j.controllerPub == "" {
+ return usage("-evidence, -release and -controller-pub are required")
+ }
+ return nil
+}
+
// certified is the whole judgement: the snapshot the evidence certifies,
// derived from the evidence alone.
func (j judgeArgs) certified() (hostedcert.Snapshot, error) {
- if *j.evidence == "" || *j.release == "" || *j.controllerPub == "" {
- return hostedcert.Snapshot{}, usage("-evidence, -release and -controller-pub are required")
+ if err := j.check(); err != nil {
+ return hostedcert.Snapshot{}, err
}
pub, err := readPublic(*j.controllerPub)
if err != nil {
@@ -315,14 +354,22 @@ func controllerFlags(fs *flag.FlagSet) controllerArgs {
}
}
-func (c controllerArgs) client() (*hostedclient.Client, hostedwire.KeyID, error) {
+// check refuses controller flags that are missing or malformed.
+func (c controllerArgs) check() error {
if *c.url == "" || *c.pin == "" || *c.pub == "" || *c.id == "" || *c.key == "" {
- return nil, "", usage("-controller, -controller-tls-pin, -controller-pub, -operator-id and -operator-key are required")
+ return usage("-controller, -controller-tls-pin, -controller-pub, -operator-id and -operator-key are required")
}
- want, err := hex.DecodeString(*c.pin)
- if err != nil || len(want) != sha256.Size {
- return nil, "", usage("-controller-tls-pin must be 64 hex digits")
+ if want, err := hex.DecodeString(*c.pin); err != nil || len(want) != sha256.Size {
+ return usage("-controller-tls-pin must be 64 hex digits")
}
+ return nil
+}
+
+func (c controllerArgs) client() (*hostedclient.Client, hostedwire.KeyID, error) {
+ if err := c.check(); err != nil {
+ return nil, "", err
+ }
+ want, _ := hex.DecodeString(*c.pin)
pub, err := readPublic(*c.pub)
if err != nil {
return nil, "", err
@@ -390,6 +437,18 @@ type launchResult struct {
Evidence string `json:"evidence"`
}
+// check refuses a launch missing a required argument or out of range,
+// its controller flags included.
+func (l launchArgs) check() error {
+ switch {
+ case *l.image == "" || *l.size == "" || *l.ledger == "" || *l.out == "":
+ return usage("-image, -size, -ledger and -out are required")
+ case *l.window <= 0 || *l.timeout <= 0 || *l.timeout > 2*time.Hour || *l.interval <= 0:
+ return usage("-window, -timeout (at most 2h) and -interval must be positive")
+ }
+ return l.controllerArgs.check()
+}
+
func (l launchArgs) run(ctx context.Context, now func() time.Time) (launchResult, error) {
switch {
case *l.image == "" || *l.size == "" || *l.ledger == "" || *l.out == "":
diff --git a/cmd/equipo-hosted-certify/plan_test.go b/cmd/equipo-hosted-certify/plan_test.go
new file mode 100644
index 00000000..3d5cfcd1
--- /dev/null
+++ b/cmd/equipo-hosted-certify/plan_test.go
@@ -0,0 +1,72 @@
+package main
+
+import (
+ "context"
+ "strings"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/hostedops/plantest"
+)
+
+// TestPlanCertInvocationsParse (Task 32, whole-branch review finding 3):
+// every literal cert invocation in the account plan and the slice 2 plan
+// parses and passes its argument checks in this command's own parser; a
+// bare name in prose must at least name a command.
+func TestPlanCertInvocationsParse(t *testing.T) {
+ n := 0
+ for _, name := range plantest.Plans {
+ doc, err := plantest.Read("../..", name)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, inv := range plantest.Invocations(doc, "cert") {
+ _, err := parseCommand(context.Background(), inv.Args, time.Now)
+ if inv.Bare() {
+ if err != nil && strings.Contains(err.Error(), "unknown command") {
+ t.Errorf("%s: `cert %s` (a name in prose) is not a command: %v", name, strings.Join(inv.Args, " "), err)
+ }
+ continue
+ }
+ n++
+ if err != nil {
+ t.Errorf("%s: cert %s: %v\n(from: %s)", name, strings.Join(inv.Args, " "), err, inv.Text)
+ }
+ }
+ }
+ if n < 6 {
+ t.Fatalf("only %d literal cert invocations read; the account plan has at least launch, judge, sign, verify, reload and alert-test", n)
+ }
+}
+
+// TestParseChecksArguments: parsing alone refuses a missing required
+// argument or a malformed pin, before any file is read or call made.
+func TestParseChecksArguments(t *testing.T) {
+ ctl := []string{"-controller", "https://198.51.100.7", "-controller-tls-pin", strings.Repeat("ab", 32), "-controller-pub", "/nonexistent/pub",
+ "-operator-id", "operator", "-operator-key", "/nonexistent/key"}
+ launch := append([]string{"launch", "-image", "sha256:" + strings.Repeat("a", 64), "-size", "large", "-ledger", "/nonexistent", "-out", "/nonexistent/e.json"}, ctl...)
+ judge := []string{"-evidence", "e.json", "-release", "m.json", "-controller-pub", "c.pub"}
+ for name, args := range map[string][]string{
+ "launch": launch,
+ "judge": append([]string{"judge"}, judge...),
+ "sign": append(append([]string{"sign"}, judge...), "-key", "k", "-key-id", "paul-cert-1"),
+ "verify": {"verify", "-cert", "c.json", "-cert-keys", "k.json"},
+ "reload": append([]string{"reload"}, ctl...),
+ "alert-test": append([]string{"alert-test"}, ctl...),
+ } {
+ if _, err := parseCommand(context.Background(), args, time.Now); err != nil {
+ t.Errorf("%s with every argument: %v", name, err)
+ }
+ for i := 1; i < len(args); i += 2 {
+ short := append(append([]string{}, args[:i]...), args[i+2:]...)
+ if _, err := parseCommand(context.Background(), short, time.Now); err == nil || !strings.Contains(err.Error(), "required") {
+ t.Errorf("%s without %s: %v, want a refusal naming it required", name, args[i], err)
+ }
+ }
+ }
+ bad := append([]string{}, launch...)
+ bad[len(bad)-7] = "not-a-pin"
+ if _, err := parseCommand(context.Background(), bad, time.Now); err == nil || !strings.Contains(err.Error(), "64 hex") {
+ t.Errorf("a malformed pin: %v, want refused", err)
+ }
+}
diff --git a/cmd/equipo-hosted-image/main.go b/cmd/equipo-hosted-image/main.go
index be4be128..1c0fba0f 100644
--- a/cmd/equipo-hosted-image/main.go
+++ b/cmd/equipo-hosted-image/main.go
@@ -145,6 +145,36 @@ func waitFlags(fs *flag.FlagSet, def time.Duration) func() hostedimage.Wait {
// run parses args and runs one command. It returns the exit code.
func run(ctx context.Context, args []string, stdout, stderr io.Writer, connect connectFunc) int {
+ inv, err := parseInvocation(ctx, args)
+ if err != nil {
+ return report(stderr, err)
+ }
+ // Every argument is checked before any credential is read.
+ if err := inv.check(); err != nil {
+ return report(stderr, err)
+ }
+ var p hostedimage.Provider
+ if inv.aws {
+ if p, err = connect(ctx, inv.profile, inv.region); err != nil {
+ return report(stderr, err)
+ }
+ }
+ res, err := inv.step(p)
+ return finish(stdout, stderr, res, err)
+}
+
+// invocation is one parsed command: check refuses its arguments, global
+// and its own, reading no file and calling nothing; step runs it, with
+// the provider when aws (the account plan's invocations are checked by
+// parsing and checking alone, Task 32).
+type invocation struct {
+ check func() error
+ step func(hostedimage.Provider) (any, error)
+ aws bool
+ profile, region string
+}
+
+func parseInvocation(ctx context.Context, args []string) (invocation, error) {
top := flag.NewFlagSet("equipo-hosted-image", flag.ContinueOnError)
top.SetOutput(io.Discard)
profile := top.String("profile", "", "the shared-config profile holding static keys (default AWS_PROFILE, then default)")
@@ -154,11 +184,11 @@ func run(ctx context.Context, args []string, stdout, stderr io.Writer, connect c
top.StringVar(&t.Prefix, "prefix", "", "every name the tool touches starts with this")
top.StringVar(&t.Caller, "expect-role", "", "the caller ARN STS must name: the role and session the run bound at its first ops guard (ops guard -print-role)")
if err := top.Parse(args); err != nil {
- return report(stderr, usage("%v", err))
+ return invocation{}, usage("%v", err)
}
rest := top.Args()
if len(rest) == 0 {
- return report(stderr, usage("want a command: build, assemble, publish, list, delete or connector-wait"))
+ return invocation{}, usage("want a command: build, assemble, publish, list, delete or connector-wait")
}
fs := flag.NewFlagSet(rest[0], flag.ContinueOnError)
fs.SetOutput(io.Discard)
@@ -174,20 +204,18 @@ func run(ctx context.Context, args []string, stdout, stderr io.Writer, connect c
gitleaks := fs.String("gitleaks-config", "", "the gitleaks configuration the payload scan uses (default: the nearest .gitleaks.toml above the manifest)")
out := fs.String("out", "", "the zip to write")
if err := parse(fs, rest[1:]); err != nil {
- return report(stderr, err)
+ return invocation{}, err
}
if *bundle != "" {
if *manifest != "" || *inputs != "" || *gitleaks == "" || *out == "" {
- return report(stderr, usage("build -bundle needs -gitleaks-config and -out, and neither -manifest nor -inputs"))
+ return invocation{}, usage("build -bundle needs -gitleaks-config and -out, and neither -manifest nor -inputs")
}
- res, err := buildBundle(*bundle, *gitleaks, *out)
- return finish(stdout, stderr, res, err)
+ return local(func() (any, error) { return buildBundle(*bundle, *gitleaks, *out) }), nil
}
if *manifest == "" || *inputs == "" || *out == "" {
- return report(stderr, usage("build needs -manifest, -inputs and -out (or -bundle)"))
+ return invocation{}, usage("build needs -manifest, -inputs and -out (or -bundle)")
}
- res, err := build(*manifest, *inputs, *gitleaks, *out)
- return finish(stdout, stderr, res, err)
+ return local(func() (any, error) { return build(*manifest, *inputs, *gitleaks, *out) }), nil
case "assemble":
var a assembleArgs
fs.StringVar(&a.manifest, "manifest", "", "the checked-in image manifest (infra/hosted/image/manifest.json)")
@@ -200,14 +228,13 @@ func run(ctx context.Context, args []string, stdout, stderr io.Writer, connect c
fs.StringVar(&a.image, "image", "", "the image zip to write")
fs.StringVar(&a.manifestOut, "manifest-out", "", "where to write a copy of the bundle's manifest")
if err := parse(fs, rest[1:]); err != nil {
- return report(stderr, err)
+ return invocation{}, err
}
if a.manifest == "" || a.pins == "" || a.runnerRelease == "" || a.built == "" || a.gitleaks == "" || a.bundle == "" ||
a.image == "" || a.manifestOut == "" {
- return report(stderr, usage("assemble needs -manifest, -pins, -runner-release, -built, -gitleaks-config, -bundle, -image and -manifest-out"))
+ return invocation{}, usage("assemble needs -manifest, -pins, -runner-release, -built, -gitleaks-config, -bundle, -image and -manifest-out")
}
- res, err := assemble(ctx, a)
- return finish(stdout, stderr, res, err)
+ return local(func() (any, error) { return assemble(ctx, a) }), nil
case "publish":
var r hostedimage.PublishRequest
fs.StringVar(&r.Ledger, "ledger", "", "the run's ledger directory; the intent and records go to journal.tsv there")
@@ -225,14 +252,14 @@ func run(ctx context.Context, args []string, stdout, stderr io.Writer, connect c
fs.Var(tags, "tag", "key=value tag (repeatable)")
wait := waitFlags(fs, 45*time.Minute)
if err := parse(fs, rest[1:]); err != nil {
- return report(stderr, err)
+ return invocation{}, err
}
r.Size, r.Tags, r.Wait = isolatedjob.Size(*size), tags, wait()
check = func() error { return r.Check(t) }
step = func(p hostedimage.Provider) (any, error) { return hostedimage.Publish(ctx, p, t, r) }
case "list":
if err := parse(fs, rest[1:]); err != nil {
- return report(stderr, err)
+ return invocation{}, err
}
step = func(p hostedimage.Provider) (any, error) {
imgs, err := hostedimage.List(ctx, p, t)
@@ -242,7 +269,7 @@ func run(ctx context.Context, args []string, stdout, stderr io.Writer, connect c
arn := fs.String("arn", "", "the image ARN")
wait := waitFlags(fs, 15*time.Minute)
if err := parse(fs, rest[1:]); err != nil {
- return report(stderr, err)
+ return invocation{}, err
}
check = func() error { return hostedimage.CheckDelete(t, *arn, wait()) }
step = func(p hostedimage.Provider) (any, error) { return hostedimage.Delete(ctx, p, t, *arn, wait()) }
@@ -250,23 +277,19 @@ func run(ctx context.Context, args []string, stdout, stderr io.Writer, connect c
arn := fs.String("arn", "", "the network connector ARN")
wait := waitFlags(fs, 20*time.Minute)
if err := parse(fs, rest[1:]); err != nil {
- return report(stderr, err)
+ return invocation{}, err
}
check = func() error { return hostedimage.CheckConnectorWait(t, *arn, wait()) }
step = func(p hostedimage.Provider) (any, error) { return hostedimage.ConnectorWait(ctx, p, t, *arn, wait()) }
default:
- return report(stderr, usage("unknown command %q", rest[0]))
- }
- // Every argument is checked before any credential is read.
- if err := check(); err != nil {
- return report(stderr, err)
- }
- p, err := connect(ctx, *profile, t.Region)
- if err != nil {
- return report(stderr, err)
+ return invocation{}, usage("unknown command %q", rest[0])
}
- res, err := step(p)
- return finish(stdout, stderr, res, err)
+ return invocation{check: check, step: step, aws: true, profile: *profile, region: t.Region}, nil
+}
+
+// local is a command that calls no AWS and reads no credential.
+func local(f func() (any, error)) invocation {
+ return invocation{check: func() error { return nil }, step: func(hostedimage.Provider) (any, error) { return f() }}
}
func parse(fs *flag.FlagSet, args []string) error {
diff --git a/cmd/equipo-hosted-image/plan_test.go b/cmd/equipo-hosted-image/plan_test.go
new file mode 100644
index 00000000..e875e132
--- /dev/null
+++ b/cmd/equipo-hosted-image/plan_test.go
@@ -0,0 +1,55 @@
+package main
+
+import (
+ "context"
+ "slices"
+ "strings"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/hostedops/plantest"
+)
+
+// TestPlanImgInvocationsParse (Task 32, whole-branch review finding 3):
+// every literal img invocation in the account plan and the slice 2 plan,
+// with the flags the plan's img wrapper adds (its -expect-role as ops
+// guard -print-role prints it), parses and passes every argument check in
+// this command's own parser; a bare name in prose must name a command.
+func TestPlanImgInvocationsParse(t *testing.T) {
+ plantest.RunDir = t.TempDir() // publish checks its -ledger directory
+ n := 0
+ for _, name := range plantest.Plans {
+ doc, err := plantest.Read("../..", name)
+ if err != nil {
+ t.Fatal(err)
+ }
+ wrapper := plantest.Wrapper(doc, "img", "equipo-hosted-image")
+ if name == plantest.Plans[0] && (len(wrapper) == 0 || !slices.Contains(wrapper, "-expect-role")) {
+ t.Fatalf("the account plan's img wrapper passes %q; want the global flags with -expect-role", wrapper)
+ }
+ for i, w := range wrapper {
+ if w == `\$r` { // what ops guard -print-role prints for the bound caller
+ wrapper[i] = "arn:aws:sts::149757027610:assumed-role/OrganizationAccountAccessRole/equipo-hosted-bringup"
+ }
+ }
+ for _, inv := range plantest.Invocations(doc, "img") {
+ args := append(slices.Clone(wrapper), inv.Args...)
+ p, err := parseInvocation(context.Background(), args)
+ if inv.Bare() {
+ if err != nil && strings.Contains(err.Error(), "unknown command") {
+ t.Errorf("%s: `img %s` (a name in prose) is not a command: %v", name, strings.Join(inv.Args, " "), err)
+ }
+ continue
+ }
+ n++
+ if err == nil {
+ err = p.check()
+ }
+ if err != nil {
+ t.Errorf("%s: img %s: %v\n(from: %s)", name, strings.Join(args, " "), err, inv.Text)
+ }
+ }
+ }
+ if n < 3 {
+ t.Fatalf("only %d literal img invocations read; the account plan has at least build, publish and delete", n)
+ }
+}
diff --git a/docs/superpowers/plans/2026-11-30-hosted-prod-account-plan.md b/docs/superpowers/plans/2026-11-30-hosted-prod-account-plan.md
index 95495629..a6268b50 100644
--- a/docs/superpowers/plans/2026-11-30-hosted-prod-account-plan.md
+++ b/docs/superpowers/plans/2026-11-30-hosted-prod-account-plan.md
@@ -520,16 +520,23 @@ pinned in the release manifest; the controller publishes `LitestreamLag`, and an
`ops object put` `controller/certification-images.json` (`[{"digest": IMAGE_DIGEST, "image_arn":
<ledger>, "version_arn": <ledger>}]`) and `controller/env` with `EQUIPO_HOSTED_ENABLED=1`; then
-`cert reload --restart --controller https://<controller EIP> --pin <pin> --operator-key
-"$P/keys/operator.key"`; `ops status` must show `enabled 1`. (`reload` makes the controller re-fetch every `controller/` object from the bucket, verify it and
-swap it in; `--restart` restarts the unit instead.) Nothing else can launch: no instance holds the
-instance key until 7.1, and a `checks` launch needs a certificate.
+`ops controller reboot --enabled 1 --max 10m`; `ops status` must show `enabled 1`. The launch switch
+is read only when the controller unit starts (its `ExecStartPre` fetches every `controller/` object,
+`env` included), and `POST /v1/admin/reload` re-fetches only `cert-keys.json`, `certificates.json`,
+`certification-images.json` and `operators.json`. So the restart is a reboot of the controller host:
+`ops controller reboot` reboots the run's one controller host with the frozen keys (refused after a
+fence), and reads `GET /v1/status` through the pin until the rebooted controller answers with launches
+as `--enabled` says, within `--max`, or exits 99. The TLS key stays on the host, so the pin does not
+change. Nothing else can launch: no instance holds the instance key until 7.1, and a `checks` launch
+needs a certificate.
### 6.2 Certification launch (unit, bound 25 min)
-`ops reserve vm 2` (the launch and one retry), then `cert launch -ledger "$P" --controller
-https://<controller EIP> --pin <pin> --operator-key "$P/keys/operator.key" --image "$IMAGE_DIGEST" --wait 20m --out "$P/evidence.json"`, then `ops ledger rec cert-launch
-"$(jq -r .LaunchID "$P/evidence.json")"`. The certification VM's one egress service is
+`ops reserve vm 2` (the launch and one retry), then `cert launch -ledger "$P" -controller https://<controller EIP> -controller-tls-pin <pin> -controller-pub "$P/keys/controller.pub" -operator-id operator -operator-key "$P/keys/operator.key" -image "$IMAGE_DIGEST" -size large -timeout 20m -out "$P/evidence.json" > "$P/cert-launch.json"`, then `ops ledger rec cert-launch
+"$(jq -r .launch_id "$P/cert-launch.json")"`. `cert launch` prints `{"attempt_id", "launch_id",
+"evidence"}`; the evidence file holds only the signed bytes (`evidence` and `sig`, base64), so the
+launch ID is read from the launch's own output. The pin is the ledger's `controller-pin` (5.2); the
+operator's key ID is `operator`, as `ops keys upload` writes it in `controller/operators.json`. The certification VM's one egress service is
`INSTANCE_HOST` (its positive control); its report goes through the proxy bootstrap listener, signed
by its own key. The controller signs the evidence from its launch record and stops the VM with proof.
Then `ops vms settle --image <image ARN> --max 10m`: no live VM of this image, three provider scans
@@ -538,7 +545,7 @@ Then `ops vms settle --image <image ARN> --max 10m`: no live VM of this image, t
### 6.3 Judge (no AWS call; fatal)
`cert judge -evidence "$P/evidence.json" -release "$P/image-manifest.json" -controller-pub
-"$P/keys/controller.pub"` must pass. `$P/image-manifest.json` is the release's published image manifest, checked
+"$P/keys/controller.pub" -out "$P/snapshot.json"` must pass. `$P/image-manifest.json` is the release's published image manifest, checked
in 4.1. Evidence signed by any other key is refused.
### 6.4 Paul signs (HUMAN, bounded 24 h)
@@ -547,9 +554,12 @@ Paul copies `evidence.json` and the release's `image-manifest.json` to his signi
checks the manifest's SHA-256 against the release manifest, and checks that the controller public
key's fingerprint matches the one posted on discussion 46 in 1.2. Then he
runs `cert sign -evidence evidence.json -release image-manifest.json -controller-pub controller.pub
--key <his key>`, which judges again and signs the
-snapshot it derives from the evidence. The agent runs `cert verify -cert certificate.json -pub
-<public key from prod.tfvars>`, `ops object put` `controller/certificates.json`, `cert reload`, and
+-key <his certification key> -key-id paul-cert-1 -out certificate.json`, which judges again and signs the
+snapshot it derives from the evidence; `paul-cert-1` is the key ID 3.5 put in `controller/cert-keys.json`.
+The agent writes `$P/cert-keys.json` as `{"keys": [{"id": "paul-cert-1", "public_key": "<CERT_PUB>"}]}`
+(the object 3.5 uploaded) and runs `cert verify -cert "$P/certificate.json" -cert-keys
+"$P/cert-keys.json"`, `ops object put` `controller/certificates.json`, `cert reload -controller https://<controller EIP> -controller-tls-pin <pin> -controller-pub "$P/keys/controller.pub" -operator-id operator -operator-key "$P/keys/operator.key"` (reload re-fetches
+`certificates.json` from the bucket, verifies it and swaps it in; a failure keeps the old set), and
`ops assert` that `GET /v1/certs` lists it. Within 15 minutes, `ops fact` that the trail holds a data event for the image; 9.1 requires it.
## 7. Instance wiring
@@ -590,7 +600,7 @@ step ends, `ops vms settle --image <image ARN> --max
### 8.3 Alert path
-`cert alert-test --controller https://<controller EIP> --pin <pin> --operator-key "$P/keys/operator.key"`;
+`cert alert-test -controller https://<controller EIP> -controller-tls-pin <pin> -controller-pub "$P/keys/controller.pub" -operator-id operator -operator-key "$P/keys/operator.key"`;
then `ops wait-human alert-received --max 24h --background`, and `ops wait-human alert-received --done`
when Paul confirms the email arrived. 9.1 requires it.
@@ -613,8 +623,8 @@ estimate into `HOSTED-PROD-BRINGUP.md`.
### 9.3 The operator key, and replacing it later
The operator public key lives in `controller/operators.json`. To rotate: mint a new key pair, upload
-a new `operators.json`, and reboot the controller host (`aws ec2 reboot-instances`, which re-runs
-`ExecStartPre`); no existing operator key is needed. This run's private key is deleted in 9.4.
+a new `operators.json`, and reboot the controller host from a reopened run (`ops reopen`, 9.4, then
+`ops controller reboot --enabled 1`, which re-runs `ExecStartPre`); no existing operator key is needed. This run's private key is deleted in 9.4.
### 9.4 Clean up docs-t1
diff --git a/docs/superpowers/plans/2026-11-30-hosted-runners-slice-2.md b/docs/superpowers/plans/2026-11-30-hosted-runners-slice-2.md
index 11671641..f86f8acf 100644
--- a/docs/superpowers/plans/2026-11-30-hosted-runners-slice-2.md
+++ b/docs/superpowers/plans/2026-11-30-hosted-runners-slice-2.md
@@ -617,7 +617,7 @@ The account plan's Astra round 1 showed that live-run machinery adapted by hand
### Task 34: Dev live drill in `kass` (HUMAN GO)
-- [ ] Write `docs/superpowers/plans/2026-MM-DD-hosted-2-dev-live-plan.md` in the shape of Task 17b (safety-only hard stops, FINDING lines, ledger, systemd user units, teardown verified by type and tag): `tofu apply` of `envs/dev/*` in `kass` / `eu-west-1`, image build and publish, a certification launch, **HUMAN:** Paul signs offline, then hosted checks from the staging Equipo instance end to end, the Task 30 drills against real VMs, the egress matrix from inside a real VM, the connector interface cleanup (still unexercised), then `tofu destroy` and verification. Run every AWS step through `equipo-hosted-ops` (Task 33) with `-account 640012953448 -profile kass`, so the production tool is exercised first. The `kass` profile names no `role_arn`, so the drill passes `-role` (its expected caller) to every `ops` call; the first `guard` binds that caller for the run. The dev release must pin `HostAMI` for `eu-west-1` (tfvars refuses a release without one), and the drill installs Litestream with `ops litestream-install` as the account plan's 4.1 does. Record `Task 34 PASSED` in the progress file only if every safety check passed. Astra reviews the plan, three rounds at most.
+- [ ] Write `docs/superpowers/plans/2026-MM-DD-hosted-2-dev-live-plan.md` in the shape of Task 17b (safety-only hard stops, FINDING lines, ledger, systemd user units, teardown verified by type and tag): `tofu apply` of `envs/dev/*` in `kass` / `eu-west-1`, image build and publish, a certification launch, **HUMAN:** Paul signs offline, then hosted checks from the staging Equipo instance end to end, the Task 30 drills against real VMs, the egress matrix from inside a real VM, the connector interface cleanup (still unexercised), then `tofu destroy` and verification. Run every AWS step through `equipo-hosted-ops` (Task 33) with `-account 640012953448 -profile kass`, so the production tool is exercised first. The `kass` profile names no `role_arn`, so the drill passes `-role` (its expected caller) to every `ops` call; the first `guard` binds that caller for the run. The dev release must pin `HostAMI` for `eu-west-1` (tfvars refuses a release without one), and the drill installs Litestream with `ops litestream-install` as the account plan's 4.1 does. Task 32's rules hold there too: `ops inventory` runs before the first intent (its `PRE-RUN` facts), the `img` wrapper passes `-expect-role "$(ops guard -print-role)"`, the `cert` lines take the account plan's section 6 flags, `controller/env` is applied with `ops controller reboot`, and the teardown runs `ops controller terminate` and `ops unfence` immediately before `ops tf services destroy-dev-services`. Add the drill plan to `plantest.Plans`, so `TestPlanCertInvocationsParse`, `TestPlanImgInvocationsParse` and `TestPlanInvocationsParse` parse its invocations. Record `Task 34 PASSED` in the progress file only if every safety check passed. Astra reviews the plan, three rounds at most.
- [ ] **HUMAN:** Paul's one GO. The agent runs it, records spend, tears down.
### Task 35: Production bring-up (HUMAN GO)
diff --git a/internal/hostedops/plantest/plantest.go b/internal/hostedops/plantest/plantest.go
new file mode 100644
index 00000000..10399c4f
--- /dev/null
+++ b/internal/hostedops/plantest/plantest.go
@@ -0,0 +1,163 @@
+// Package plantest reads the hosted plans' literal command invocations, so
+// each tool's tests can run every one through the tool's own parser (slice
+// 2 Task 32). It is used by tests only.
+package plantest
+
+import (
+ "os"
+ "path/filepath"
+ "regexp"
+ "strings"
+)
+
+// Plans are the documents whose invocations are checked: the production
+// account plan, and the slice 2 plan's Task 34 (the dev drill).
+var Plans = []string{"2026-11-30-hosted-prod-account-plan.md", "2026-11-30-hosted-runners-slice-2.md"}
+
+// Read returns the named plan from the repository root above dir.
+func Read(root, name string) (string, error) {
+ b, err := os.ReadFile(filepath.Join(root, "docs", "superpowers", "plans", name))
+ return string(b), err
+}
+
+// Invocation is one literal invocation of a tool: its words after the
+// tool's name, placeholders filled, and the text it came from.
+type Invocation struct {
+ Args []string
+ Text string
+}
+
+// Bare reports whether the invocation is only a command's name (prose
+// naming it, such as "`cert reload`"), with no flag or argument.
+func (i Invocation) Bare() bool { return len(i.Args) <= 1 }
+
+// pin fills a pin placeholder with a well-formed pin.
+var pin = strings.Repeat("ab", 32)
+
+// RunDir stands for the run directory, $P: a test that checks paths sets
+// it to a directory of its own.
+var RunDir = "/p"
+
+// fill gives the plans' shell variables values of the right form: a
+// sha256 image digest, the run's name, the run directory.
+func fill() *strings.Replacer {
+ return strings.NewReplacer(`"$P"`, `"`+RunDir+`"`, "$P/", RunDir+"/", `$IMAGE_DIGEST`, "sha256:"+strings.Repeat("a", 64), `$RUN`, "r1", `$REPO`, RunDir+"/repo")
+}
+
+// typed are the plans' placeholders whose value has a form a parser
+// checks; any other <...> becomes "x".
+var typed = map[string]string{
+ "<pin>": pin,
+ "<controller EIP>": "198.51.100.7",
+ "<image-input bucket>": "equipo-hosted-image-inputs-149757027610",
+ "<image_build role ARN>": "arn:aws:iam::149757027610:role/equipo-hosted-image-build",
+ "<image_build log group>": "/aws/lambda-microvms/equipo-hosted-image-build",
+ "<image ARN>": "arn:aws:lambda:eu-west-1:149757027610:microvm-image:equipo-hosted-prod-r1",
+ "<connector ARN>": "arn:aws:lambda:eu-west-1:149757027610:network-connector:equipo-hosted-prod-r1-egress",
+ "<his certification key>": "/home/paul/equipo-cert/paul-cert-1",
+}
+
+var (
+ subst = regexp.MustCompile(`\$\([^)]*\)`)
+ placeholder = regexp.MustCompile(`<[^>]*>`)
+)
+
+// Fill applies the plans' substitutions to s.
+func Fill(s string) string {
+ s = fill().Replace(s)
+ s = subst.ReplaceAllString(s, "x")
+ return placeholder.ReplaceAllStringFunc(s, func(h string) string {
+ if v, ok := typed[h]; ok {
+ return v
+ }
+ return "x"
+ })
+}
+
+// Invocations are every literal invocation of tool in doc: each inline
+// code span that starts with it (wrapped lines included), and each command
+// of a sh block, backslash-continued lines joined, comments dropped,
+// commands split at ";" and "&&". The tool's own definition ("tool()") and
+// anything after a pipe or a redirection are not part of an invocation.
+func Invocations(doc, tool string) []Invocation {
+ var out []Invocation
+ add := func(text string) {
+ text = strings.TrimSpace(text)
+ for _, cut := range []string{" | ", " > ", " >> ", " 2>"} {
+ if i := strings.Index(text, cut); i >= 0 {
+ text = text[:i]
+ }
+ }
+ w := ShellWords(Fill(strings.ReplaceAll(text, "\n", " ")))
+ if len(w) == 0 || w[0] != tool {
+ return
+ }
+ out = append(out, Invocation{Args: w[1:], Text: text})
+ }
+ for _, m := range regexp.MustCompile("`("+regexp.QuoteMeta(tool)+" [^`]+)`").FindAllStringSubmatch(doc, -1) {
+ add(m[1])
+ }
+ for _, block := range regexp.MustCompile("(?s)```sh\n(.*?)```").FindAllStringSubmatch(doc, -1) {
+ for _, line := range strings.Split(strings.ReplaceAll(block[1], "\\\n", " "), "\n") {
+ line = strings.SplitN(line, "#", 2)[0]
+ for _, part := range regexp.MustCompile(`;|&&`).Split(line, -1) {
+ part = strings.TrimSpace(part)
+ if strings.HasPrefix(part, tool+" ") && !strings.HasPrefix(part, tool+"()") {
+ add(part)
+ }
+ }
+ }
+ }
+ return out
+}
+
+// ShellWords splits s as sh would for the plans' simple quoting.
+func ShellWords(s string) []string {
+ var out []string
+ var cur strings.Builder
+ in, q := false, byte(0)
+ for i := 0; i < len(s); i++ {
+ c := s[i]
+ switch {
+ case q != 0 && c == q:
+ q = 0
+ case q != 0:
+ cur.WriteByte(c)
+ case c == '\'' || c == '"':
+ q, in = c, true
+ case c == ' ' || c == '\t' || c == '\n':
+ if in {
+ out = append(out, cur.String())
+ cur.Reset()
+ in = false
+ }
+ default:
+ cur.WriteByte(c)
+ in = true
+ }
+ }
+ if in {
+ out = append(out, cur.String())
+ }
+ return out
+}
+
+// Wrapper returns the words the plan's run.env wrapper for tool passes
+// before the invocation's own ("tool() ( ... exec BINARY WORDS "\$@" )"),
+// filled; nil when the plan defines no such wrapper.
+func Wrapper(doc, tool, binary string) []string {
+ for _, line := range strings.Split(doc, "\n") {
+ if !strings.HasPrefix(line, tool+"()") {
+ continue
+ }
+ i := strings.Index(line, binary)
+ j := strings.LastIndex(line, `"\$@"`)
+ if i < 0 || j < i {
+ return nil
+ }
+ rest := line[i+len(binary) : j]
+ rest = strings.TrimPrefix(rest, `"`)
+ return ShellWords(Fill(rest))
+ }
+ return nil
+}