carlos / platform Public

cli: main dispatches from the command tree

commands.go builds the root (commandRoot, sync.Once); main() walks it
with clireg.Dispatch. Top-level commands with subcommands stay one raw
leaf on today's dispatcher. noHintVerbs becomes NoUpdateHint on the
path; cgroup.Shims replaces the shim switch; parity/cli.tsv projects the
tree and replaces docsite's main.go scanner.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev e7c1c945ee4adeb74eac421373b62c1d7b9ef9ac parent e132264
16 files changed, +709 −385
  • Makefile +3 −1
  • canary_test.go +17 −20
  • cli_projection_test.go +57 −0
  • commands.go +289 −0
  • commands_test.go +111 −0
  • internal/cgroup/shim.go +10 −5
  • internal/cgroup/shim_test.go +12 −0
  • internal/docsite/cli_test.go +26 −17
  • internal/docsite/clinames.go +63 −0
  • internal/docsite/cliscan.go +0 −92
  • internal/docsite/fences_test.go +2 −2
  • internal/parity/repo_test.go +9 −9
  • main.go +9 −213
  • parity/cli.tsv +78 −0
  • update.go +11 −14
  • update_test.go +12 −12

Intent

Attributed to this commit: 5.74 g CO₂e (668,708 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on cli-registry-words, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/Makefile b/Makefile
index 6b353802d..8abc7c913 100644
--- a/Makefile
+++ b/Makefile
@@ -38,9 +38,11 @@ fmt:
console-mockup-kit:
CONSOLE_MOCKUP_KIT_DIR="$(CURDIR)/docs/console-mockup-kit" go test ./internal/console/ -run '^TestConsoleMockupKit$$' -count=1
-# Regenerates docs/parity.md from parity/parity.tsv and parity/packages.tsv.
+# Regenerates parity/cli.tsv from the command tree (TestCLIProjection), then
+# docs/parity.md from parity/parity.tsv and parity/packages.tsv.
# It writes nothing while the table breaks a rule (internal/parity).
parity-doc:
+ go test -run '^TestCLIProjection$$' -update .
go run ./internal/parity/cmd/parity-doc
# The root-read census as an approval (#369, AGENTS.md "The census"):
diff --git a/canary_test.go b/canary_test.go
index 51f8823e7..d6db9b45b 100644
--- a/canary_test.go
+++ b/canary_test.go
@@ -1,11 +1,11 @@
package main
import (
- "os"
"strings"
"testing"
"time"
+ "github.com/carlosframework/platform/internal/clireg"
"github.com/carlosframework/platform/internal/controlname"
"github.com/carlosframework/platform/internal/provision"
"github.com/carlosframework/platform/internal/release"
@@ -278,34 +278,31 @@ func TestCanaryNameOfChannel(t *testing.T) {
}
}
-// The whole point of the change: main.go's canary case dispatches instead of
-// exiting "not implemented". internal/docsite's TopLevelCommands scan already
-// insists the verb has a doc heading, but it cannot tell a real dispatch from
-// a stub — and a stub with a heading is exactly the state that made a session
-// conclude the platform could not canary at all.
+// The whole point of the change: canary dispatches instead of exiting "not
+// implemented". internal/docsite insists the verb has a doc heading, but it
+// cannot tell a real dispatch from a stub, and a stub with a heading is
+// exactly the state that made a session conclude the platform could not
+// canary at all. The tree holds canary as something that runs.
func TestCanaryIsDispatchedNotStubbed(t *testing.T) {
- src, err := os.ReadFile("main.go")
- if err != nil {
- t.Fatalf("read main.go: %v", err)
- }
- _, after, ok := strings.Cut(string(src), "case \"canary\":")
- if !ok {
- t.Fatal("main.go no longer dispatches on \"canary\"")
+ var canary *clireg.Node
+ for _, c := range commandRoot().Children {
+ if c.Name == "canary" {
+ canary = c
+ }
}
- body, _, _ := strings.Cut(after, "case \"")
- if !strings.Contains(body, "runCanary(args)") {
- t.Errorf("the canary case does not call runCanary: %q", body)
+ if canary == nil {
+ t.Fatal("the command tree has no canary")
}
- if strings.Contains(body, "not implemented") {
- t.Error("the canary case still exits \"not implemented\"")
+ if canary.Run == nil && canary.DefaultLeaf == nil && canary.Default == "" {
+ t.Error("canary is in the tree but nothing runs for it")
}
}
// canary is a member verb now, not a reserved word, so it takes the
// once-a-day update hint like deploy and ship do.
func TestCanaryTakesTheUpdateHint(t *testing.T) {
- if noHintVerbs["canary"] {
- t.Error("canary is still in noHintVerbs — it was listed there while it was a stub")
+ if pathSkipsHint(pathFor("canary")) {
+ t.Error("carlos canary's path skips the update hint: it was kept out while it was a stub")
}
}
diff --git a/cli_projection_test.go b/cli_projection_test.go
new file mode 100644
index 000000000..3a975899e
--- /dev/null
+++ b/cli_projection_test.go
@@ -0,0 +1,57 @@
+package main
+
+import (
+ "bytes"
+ "flag"
+ "os"
+ "sort"
+ "strings"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/clireg"
+)
+
+// updateProjection rewrites parity/cli.tsv: make parity-doc passes it.
+var updateProjection = flag.Bool("update", false, "rewrite parity/cli.tsv from the command tree")
+
+const projectionFile = "parity/cli.tsv"
+
+// renderCLIProjection is parity/cli.tsv (spec D1): one line per runnable
+// command, internal ones included, sorted by ID. internal/parity and
+// internal/docsite read it; neither can import package main.
+func renderCLIProjection(root *clireg.Node) []byte {
+ var lines []string
+ for _, e := range clireg.Runnable(root) {
+ // effect, scope, tool, flags and enums come with the argument
+ // model (later steps); until then each is "-".
+ lines = append(lines, strings.Join([]string{e.ID, string(e.Node.Audience), "-", "-", "-", "-", "-"}, "\t"))
+ }
+ sort.Strings(lines)
+ var b bytes.Buffer
+ b.WriteString("# Every command the carlos binary runs, from its command tree (commands.go).\n")
+ b.WriteString("# Generated: make parity-doc. Do not edit by hand.\n")
+ b.WriteString("id\taudience\teffect\tscope\ttool\tflags\tenums\n")
+ for _, l := range lines {
+ b.WriteString(l + "\n")
+ }
+ return b.Bytes()
+}
+
+// TestCLIProjection fails when parity/cli.tsv is not what the tree
+// projects; -update rewrites it.
+func TestCLIProjection(t *testing.T) {
+ want := renderCLIProjection(commandRoot())
+ if *updateProjection {
+ if err := os.WriteFile(projectionFile, want, 0o644); err != nil {
+ t.Fatal(err)
+ }
+ return
+ }
+ got, err := os.ReadFile(projectionFile)
+ if err != nil {
+ t.Fatalf("%v: run make parity-doc", err)
+ }
+ if !bytes.Equal(got, want) {
+ t.Errorf("%s is stale: run make parity-doc", projectionFile)
+ }
+}
diff --git a/commands.go b/commands.go
new file mode 100644
index 000000000..fbe3ca4c8
--- /dev/null
+++ b/commands.go
@@ -0,0 +1,289 @@
+package main
+
+import (
+ "context"
+ "fmt"
+ "log"
+ "os"
+ "sort"
+ "sync"
+
+ "github.com/carlosframework/platform/internal/cgroup"
+ "github.com/carlosframework/platform/internal/clireg"
+ "github.com/carlosframework/platform/internal/democlaim"
+ "github.com/carlosframework/platform/internal/edge"
+ "github.com/carlosframework/platform/internal/host"
+ "github.com/carlosframework/platform/internal/instanceexec"
+ "github.com/carlosframework/platform/internal/version"
+ "github.com/carlosframework/platform/internal/vet"
+)
+
+// The command tree: every word the carlos binary dispatches on is a node
+// (spec docs/superpowers/specs/2026-11-09-cli-registry-design.md, A).
+// main() walks it with clireg.Dispatch. It is built on first use, never at
+// init: commandRoot is first called after rootaws.ScrubEnvironment (A8).
+var (
+ commandRootOnce sync.Once
+ commandRootNode *clireg.Node
+)
+
+func commandRoot() *clireg.Node {
+ commandRootOnce.Do(func() { commandRootNode = buildCommandRoot() })
+ return commandRootNode
+}
+
+// subVerbSkipsHint is set by the channels and releases leaves when they ran
+// one of their sub-verbs (channels resign|digests, releases
+// retention|authorize), which returned from main() before the update hint
+// when main dispatched them inline. main skips the hint when it is set.
+// When those sub-verbs become nodes with NoUpdateHint, this goes.
+var subVerbSkipsHint bool
+
+// raw is a leaf that hands its arguments, unparsed, to a handler that
+// takes them: the shape of every leaf in this step.
+func raw(name string, aud clireg.Audience, f func([]string)) *clireg.Node {
+ return &clireg.Node{Name: name, Audience: aud, Run: clireg.RawArgs(f)}
+}
+
+// noHint marks n as one of the words the update hint stays out of: box,
+// daemon and plumbing verbs, and verbs whose output is parsed.
+func noHint(n *clireg.Node) *clireg.Node {
+ n.NoUpdateHint = true
+ return n
+}
+
+// skipBare keeps the golden corpus from running n bare: it starts a daemon
+// or touches the box.
+func skipBare(n *clireg.Node, reason string) *clireg.Node {
+ n.Golden.SkipBare = reason
+ return n
+}
+
+// plumbing is an internal __ word: never typed, no corpus cases.
+func plumbing(name string, f func([]string)) *clireg.Node {
+ n := raw(name, clireg.Internal, f)
+ n.Golden.Skip = "plumbing"
+ return n
+}
+
+func buildCommandRoot() *clireg.Node {
+ const (
+ cust = clireg.Customer
+ op = clireg.Operator
+ box = clireg.BoxLocal
+ )
+ const daemon = "starts a daemon or touches the box"
+
+ children := []*clireg.Node{
+ // The plumbing words main.go checked before its switch.
+ noHint(plumbing("__demo-snapshot", runDemoSnapshot)),
+ // The drain verbs' agent call, run as the agent's user
+ // (internal/host/hadrain_call.go): plumbing, never typed.
+ plumbing("__drain-call", runDrainCallTop),
+ noHint(plumbing("__registry-child", runRegistryChildTop)),
+ // carlos ship --check's health probe, run inside the web container
+ // (ship_check_probe.go): plumbing, not a command anyone types.
+ plumbing("__rootfs-check-probe", func(args []string) { os.Exit(runRootfsCheckProbe(args)) }),
+ // And the container that makes the check's data volume its user's.
+ plumbing("__rootfs-check-prepare", func(args []string) { os.Exit(runRootfsCheckPrepare(args)) }),
+ }
+ children = append(children, shimNodes()...)
+ children = append(children,
+ // Asking for help is not an error: it prints on stdout and exits 0,
+ // so `carlos help | less` works. A bare `carlos` still fails
+ // (stderr, 2).
+ noHint(&clireg.Node{
+ Name: "help",
+ Aliases: []string{"-h", "--help"},
+ Audience: cust,
+ Run: func(*clireg.Invocation) error { usage(os.Stdout); return nil },
+ }),
+ versionCommand(),
+ noHint(skipBare(raw("edge", box, edge.Run), daemon)),
+ raw("devbox", cust, runDevbox),
+ noHint(raw("add", box, runAdd)),
+ noHint(raw("remove", box, runRemove)),
+ noHint(raw("route", box, runRoute)),
+ raw("instances", cust, runInstances),
+ raw("sidecars", cust, runSidecars),
+ raw("routes", cust, runRoutes),
+ raw("domains", cust, runDomains),
+ raw("features", cust, runFeatures),
+ raw("assets", cust, runAssets),
+ raw("gate", cust, runGate),
+ raw("ratelimit", cust, runRatelimit),
+ raw("ship", cust, runShip),
+ raw("promote", cust, runPromote),
+ raw("deploy", cust, runDeploy),
+ raw("restart", cust, runRestart),
+ raw("db", cust, runDB),
+ raw("run", cust, runRun),
+ raw("console", cust, runConsole),
+ raw("steering", cust, runSteering),
+ raw("schedule", cust, runSchedule),
+ raw("economics", op, runEconomics),
+ raw("store", cust, runStore),
+ raw("relay", cust, runRelay),
+ raw("email", cust, runEmail),
+ raw("logs", cust, runLogs),
+ raw("errors", cust, runErrors),
+ raw("availability", cust, runAvailability),
+ raw("geo", cust, runGeo),
+ raw("explain", cust, runExplain),
+ raw("analytics", cust, runAnalytics),
+ raw("protection", cust, runProtection),
+ &clireg.Node{
+ Name: "channels",
+ Audience: cust,
+ Run: func(inv *clireg.Invocation) error {
+ subVerbSkipsHint = runChannelsTop(inv.Raw)
+ return nil
+ },
+ },
+ raw("pipeline", cust, runPipeline),
+ raw("skills", cust, runSkills),
+ &clireg.Node{
+ Name: "releases",
+ Audience: cust,
+ Run: func(inv *clireg.Invocation) error {
+ subVerbSkipsHint = runReleasesTop(inv.Raw)
+ return nil
+ },
+ },
+ raw("rollback", cust, runRollback),
+ raw("ledger", cust, RunLedger),
+ raw("auth", cust, RunAuth),
+ raw("config", cust, RunConfig),
+ raw("accounts", cust, RunAccounts),
+ raw("billing", op, runBilling),
+ raw("apps", cust, RunApps),
+ raw("fleets", cust, RunFleets),
+ raw("services", cust, RunServices),
+ raw("env", cust, RunEnv),
+ raw("secrets", cust, RunSecrets),
+ noHint(raw("release-keygen", box, runKeygen)),
+ raw("proof", box, runProof),
+ noHint(raw("ops", op, runOps)),
+ noHint(raw("system", op, runSystem)),
+ raw("move", cust, runMove),
+ noHint(raw("status", op, RunStatus)),
+ noHint(skipBare(raw("agent", box, host.RunAgent), daemon)),
+ noHint(skipBare(raw("bootstrap", box, host.RunBootstrap), daemon)),
+ noHint(skipBare(raw("adopt", box, host.RunAdopt), daemon)),
+ skipBare(raw("instance-control", box, host.RunInstanceControl), daemon),
+ skipBare(raw("instance-exec", box, instanceexec.RunExec), daemon),
+ skipBare(raw("instance-exit", box, instanceexec.RunExit), daemon),
+ skipBare(raw("instance-stop", box, instanceexec.RunStop), daemon),
+ skipBare(raw("instance-probe", box, instanceexec.RunProbe), daemon),
+ noHint(raw("vet", cust, vet.Run)),
+ noHint(raw("update", cust, runUpdate)),
+ raw("canary", cust, runCanary),
+ )
+ return &clireg.Node{
+ Children: children,
+ Fallback: func(args, consumed []string) {
+ usage(os.Stderr)
+ os.Exit(2)
+ },
+ }
+}
+
+// shimNodes declares cgroup's early words from cgroup.Shims itself, so the
+// tree cannot miss one. RunShimIfRequested serves them and exits before
+// main reaches the tree.
+func shimNodes() []*clireg.Node {
+ names := make([]string, 0, len(cgroup.Shims))
+ for name := range cgroup.Shims {
+ names = append(names, name)
+ }
+ sort.Strings(names)
+ var out []*clireg.Node
+ for _, name := range names {
+ out = append(out, &clireg.Node{
+ Name: name,
+ Audience: clireg.Internal,
+ Golden: clireg.Golden{Skip: "the cgroup shim, dispatched before main"},
+ Run: func(*clireg.Invocation) error {
+ panic("clireg: " + name + " is dispatched by cgroup before main")
+ },
+ })
+ }
+ return out
+}
+
+// versionCommand: `carlos version` on its own is the build id and nothing
+// else, unchanged, because every install script and support request in
+// existence types it. `carlos version target ...` is the only string that
+// dispatches anywhere new (release versioning spec, 2026-08-08): a sub-verb
+// rather than a top-level `carlos target`, because what it sets IS the
+// app's version, and it reads that way at the terminal. Any other word or
+// flag after `version` still prints the build id.
+func versionCommand() *clireg.Node {
+ return noHint(&clireg.Node{
+ Name: "version",
+ Audience: clireg.Customer,
+ Children: []*clireg.Node{raw("target", clireg.Customer, runVersionTarget)},
+ DefaultLeaf: &clireg.Node{
+ Audience: clireg.Customer,
+ Run: func(*clireg.Invocation) error {
+ fmt.Printf("carlos %s\n", version.Build)
+ return nil
+ },
+ },
+ DefaultOn: clireg.OnAbsent | clireg.OnFlag | clireg.OnWord,
+ })
+}
+
+func runDemoSnapshot(args []string) {
+ if len(args) != 0 {
+ log.Fatal(democlaim.ErrSnapshot)
+ }
+ if err := democlaim.RunSnapshotWorker(context.Background()); err != nil {
+ log.Fatal(err)
+ }
+}
+
+func runDrainCallTop(args []string) {
+ os.Exit(host.RunDrainCall(args, os.Stdout))
+}
+
+func runRegistryChildTop(args []string) {
+ if err := host.RunRegistryChild(args); err != nil {
+ log.Fatal(err)
+ }
+}
+
+// runChannelsTop is `carlos channels`, moved from main's switch unchanged.
+// Two sub-verbs, resign and digests (#253); bare `carlos channels` still
+// lists, the `carlos releases retention` precedent. It reports whether a
+// sub-verb ran: those skipped the update hint (subVerbSkipsHint).
+func runChannelsTop(args []string) (subVerb bool) {
+ if len(args) > 0 && args[0] == "resign" {
+ runChannelsResign(args[1:])
+ return true
+ }
+ if len(args) > 0 && args[0] == "digests" {
+ runChannelsDigests(args[1:])
+ return true
+ }
+ runChannels(args)
+ return false
+}
+
+// runReleasesTop is `carlos releases`, moved from main's switch unchanged.
+// Two sub-verbs, `retention` and `authorize`: the `carlos version target`
+// judgment call: flags-only verbs stay flat until a word genuinely names a
+// different action, and a policy write or a signature is not a listing. It
+// reports whether a sub-verb ran, as runChannelsTop does.
+func runReleasesTop(args []string) (subVerb bool) {
+ if len(args) > 0 && args[0] == "retention" {
+ runReleasesRetention(args[1:])
+ return true
+ }
+ if len(args) > 0 && args[0] == "authorize" {
+ runReleasesAuthorize(args[1:])
+ return true
+ }
+ runReleases(args)
+ return false
+}
diff --git a/commands_test.go b/commands_test.go
new file mode 100644
index 000000000..f261515bc
--- /dev/null
+++ b/commands_test.go
@@ -0,0 +1,111 @@
+package main
+
+import (
+ "sort"
+ "strings"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/clireg"
+)
+
+// TestCommandTreeIsValid is spec A8: Validate runs here, never at init
+// or dispatch.
+func TestCommandTreeIsValid(t *testing.T) {
+ for _, err := range clireg.Validate(commandRoot()) {
+ t.Error(err)
+ }
+}
+
+// TestTopLevelWordsUnchanged pins the words main dispatched on before the
+// tree (the switch's cases, the five __ words checked before it, and the
+// cgroup shim's two words), written out so a word cannot appear or vanish
+// without this list changing too.
+func TestTopLevelWordsUnchanged(t *testing.T) {
+ want := []string{
+ // The __ plumbing words main.go checked before its switch.
+ "__demo-snapshot", "__drain-call", "__registry-child",
+ "__rootfs-check-probe", "__rootfs-check-prepare",
+ // cgroup.RunShimIfRequested's words.
+ "__cgexec", "__cgprobe",
+ // The switch.
+ "help", "-h", "--help", "version", "edge", "devbox", "add", "remove",
+ "route", "instances", "sidecars", "routes", "domains", "features",
+ "assets", "gate", "ratelimit", "ship", "promote", "deploy", "restart",
+ "db", "run", "console", "steering", "schedule", "economics", "store",
+ "relay", "email", "logs", "errors", "availability", "geo", "explain",
+ "analytics", "protection", "channels", "pipeline", "skills",
+ "releases", "rollback", "ledger", "auth", "config", "accounts",
+ "billing", "apps", "fleets", "services", "env", "secrets",
+ "release-keygen", "proof", "ops", "system", "move", "status", "agent",
+ "bootstrap", "adopt", "instance-control", "instance-exec",
+ "instance-exit", "instance-stop", "instance-probe", "vet", "update",
+ "canary",
+ }
+ var got []string
+ for _, c := range commandRoot().Children {
+ got = append(got, c.Name)
+ got = append(got, c.Aliases...)
+ }
+ sort.Strings(want)
+ sort.Strings(got)
+ if strings.Join(got, "\n") != strings.Join(want, "\n") {
+ t.Errorf("top-level words changed\n got: %v\nwant: %v", got, want)
+ }
+}
+
+// inertTree copies n with every Run and Fallback replaced by one that does
+// nothing, so a test can ask Dispatch which path a command line takes
+// without running it.
+func inertTree(n *clireg.Node) *clireg.Node {
+ if n == nil {
+ return nil
+ }
+ c := *n
+ if c.Run != nil {
+ c.Run = func(*clireg.Invocation) error { return nil }
+ }
+ if c.Fallback != nil {
+ c.Fallback = func(args, consumed []string) {}
+ }
+ c.Children = nil
+ for _, ch := range n.Children {
+ c.Children = append(c.Children, inertTree(ch))
+ }
+ c.DefaultLeaf = inertTree(n.DefaultLeaf)
+ return &c
+}
+
+// pathFor is the path Dispatch takes for args, nothing run.
+func pathFor(args ...string) []*clireg.Node {
+ return clireg.Dispatch(inertTree(commandRoot()), args)
+}
+
+func pathSkipsHint(path []*clireg.Node) bool {
+ for _, n := range path {
+ if n.NoUpdateHint {
+ return true
+ }
+ }
+ return false
+}
+
+// TestUpdateHintSkippedPerPath is spec A7: the words in the old
+// noHintVerbs map, and the __ words that returned from main before the
+// hint, carry NoUpdateHint on their path; member verbs do not.
+func TestUpdateHintSkippedPerPath(t *testing.T) {
+ for _, line := range [][]string{
+ {"edge"}, {"agent"}, {"adopt"}, {"bootstrap"}, {"add"}, {"remove"},
+ {"route"}, {"ops"}, {"status"}, {"vet"}, {"release-keygen"},
+ {"version"}, {"version", "target"}, {"help"}, {"-h"}, {"--help"},
+ {"update"}, {"system"}, {"__demo-snapshot"}, {"__registry-child"},
+ } {
+ if !pathSkipsHint(pathFor(line...)) {
+ t.Errorf("carlos %s: path has no NoUpdateHint node", strings.Join(line, " "))
+ }
+ }
+ for _, line := range [][]string{{"ship"}, {"apps", "list"}, {"canary"}, {"channels"}, {"releases"}} {
+ if pathSkipsHint(pathFor(line...)) {
+ t.Errorf("carlos %s: path skips the update hint", strings.Join(line, " "))
+ }
+ }
+}
diff --git a/internal/cgroup/shim.go b/internal/cgroup/shim.go
index 1bf9d2f30..77b6b2ab9 100644
--- a/internal/cgroup/shim.go
+++ b/internal/cgroup/shim.go
@@ -24,6 +24,14 @@ const ShimVerb = "__cgexec"
// arm-time placement check (VerifyPlacement) execs through the shim.
const ProbeVerb = "__cgprobe"
+// Shims are the words RunShimIfRequested dispatches on, each to the code
+// that serves it and returns the exit code. Package main declares its
+// early words from this map's keys, so the two cannot drift apart.
+var Shims = map[string]func([]string) int{
+ ShimVerb: runShim,
+ ProbeVerb: func([]string) int { return runProbe() },
+}
+
var shimHooked atomic.Bool
// shimForcedForTest makes shimAvailable answer true while
@@ -41,11 +49,8 @@ func RunShimIfRequested() {
if len(os.Args) < 2 {
return
}
- switch os.Args[1] {
- case ShimVerb:
- os.Exit(runShim(os.Args[2:]))
- case ProbeVerb:
- os.Exit(runProbe())
+ if run, ok := Shims[os.Args[1]]; ok {
+ os.Exit(run(os.Args[2:]))
}
}
diff --git a/internal/cgroup/shim_test.go b/internal/cgroup/shim_test.go
index 1fe34b243..7026bcc43 100644
--- a/internal/cgroup/shim_test.go
+++ b/internal/cgroup/shim_test.go
@@ -93,3 +93,15 @@ func TestShimSpecRefusesBadSigIgnAndTheOldEncoding(t *testing.T) {
}
}
}
+
+// TestShimsMapIsTheSwitch: RunShimIfRequested dispatches from Shims, and
+// Shims holds exactly the two early words (spec A9).
+func TestShimsMapIsTheSwitch(t *testing.T) {
+ if len(Shims) != 2 || Shims[ShimVerb] == nil || Shims[ProbeVerb] == nil {
+ keys := make([]string, 0, len(Shims))
+ for k := range Shims {
+ keys = append(keys, k)
+ }
+ t.Errorf("Shims keys = %v, want exactly [%s %s]", keys, ShimVerb, ProbeVerb)
+ }
+}
diff --git a/internal/docsite/cli_test.go b/internal/docsite/cli_test.go
index 3a5b7a393..94728e099 100644
--- a/internal/docsite/cli_test.go
+++ b/internal/docsite/cli_test.go
@@ -1,32 +1,41 @@
package docsite
-import "testing"
+import (
+ "strings"
+ "testing"
+)
-// mainFile is the CLI's dispatch, relative to this package.
-const mainFile = "../../main.go"
+// cliFile is the projection of the CLI's command tree, relative to this
+// package (package main's TestCLIProjection writes it).
+const cliFile = "../../parity/cli.tsv"
// cliPage is the page that must document all of it.
const cliPage = "cli"
-// TestTopLevelCommandsReadsTheDispatch checks the scanner before the
-// gate that depends on it. A scanner that silently returns nothing
-// turns the gate below into a test that always passes.
-func TestTopLevelCommandsReadsTheDispatch(t *testing.T) {
- cmds, err := TopLevelCommands(mainFile)
+// TestTopLevelNamesReadsTheProjection checks the reader before the gate
+// that depends on it. A reader that silently returns nothing turns the
+// gate below into a test that always passes.
+func TestTopLevelNamesReadsTheProjection(t *testing.T) {
+ cmds, err := TopLevelNames(cliFile)
if err != nil {
- t.Fatalf("scan: %v", err)
+ t.Fatalf("read: %v", err)
}
if len(cmds) < 20 {
- t.Fatalf("found %d commands (%v) — the scanner is broken, not the docs", len(cmds), cmds)
+ t.Fatalf("found %d commands (%v) — the reader is broken, not the docs", len(cmds), cmds)
}
for _, want := range []string{"ship", "promote", "deploy", "domains", "logs", "fleets"} {
if !contains(cmds, want) {
- t.Errorf("scanner missed the %q command", want)
+ t.Errorf("reader missed the %q command", want)
}
}
for _, unwanted := range []string{"-h", "--help", ""} {
if contains(cmds, unwanted) {
- t.Errorf("scanner kept %q, which is not a command", unwanted)
+ t.Errorf("reader kept %q, which is not a command", unwanted)
+ }
+ }
+ for _, c := range cmds {
+ if strings.HasPrefix(c, "__") {
+ t.Errorf("reader kept the internal word %q", c)
}
}
}
@@ -40,10 +49,10 @@ func contains(xs []string, s string) bool {
return false
}
-// TestCLICommandsAreDocumented is the gate. It reads the dispatch
-// switch rather than the usage text on purpose: usage text is prose
+// TestCLICommandsAreDocumented is the gate. It reads the command tree's
+// projection rather than the usage text on purpose: usage text is prose
// someone can forget to update, so gating against it would only prove
-// the docs match a second copy of the docs. The switch is the CLI.
+// the docs match a second copy of the docs. The tree is the CLI.
//
// It asks for a HEADING, not a substring of the body, and that is not
// a stylistic preference. A substring check is defeated by prefixes:
@@ -64,9 +73,9 @@ func TestCLICommandsAreDocumented(t *testing.T) {
if !ok {
t.Fatalf("no %s page — every command has to be documented somewhere", cliPage)
}
- cmds, err := TopLevelCommands(mainFile)
+ cmds, err := TopLevelNames(cliFile)
if err != nil {
- t.Fatalf("scan: %v", err)
+ t.Fatalf("read: %v", err)
}
for _, cmd := range cmds {
if !hasAnchor(page, Anchor("carlos "+cmd)) {
diff --git a/internal/docsite/clinames.go b/internal/docsite/clinames.go
new file mode 100644
index 000000000..92214972c
--- /dev/null
+++ b/internal/docsite/clinames.go
@@ -0,0 +1,63 @@
+package docsite
+
+import (
+ "bufio"
+ "fmt"
+ "os"
+ "sort"
+ "strings"
+)
+
+// TopLevelNames returns the top-level commands a reader can type: the
+// first word of every command in parity/cli.tsv whose audience is not
+// internal, deduplicated and sorted.
+//
+// The file is the projection of the binary's command tree (written by
+// package main's TestCLIProjection), not the usage text: the tree is the
+// CLI and the usage text is prose about it. A gate against the prose would
+// prove only that the docs agree with a second copy of the docs, which is
+// exactly the drift worth catching. A branch such as `apps` has no line of
+// its own, only its descendants, hence the first word.
+func TopLevelNames(path string) ([]string, error) {
+ f, err := os.Open(path)
+ if err != nil {
+ return nil, err
+ }
+ defer f.Close()
+ seen := map[string]bool{}
+ var out []string
+ sc := bufio.NewScanner(f)
+ n := 0
+ header := false
+ for sc.Scan() {
+ n++
+ line := sc.Text()
+ if line == "" || strings.HasPrefix(line, "#") {
+ continue
+ }
+ cols := strings.Split(line, "\t")
+ if !header {
+ if cols[0] != "id" {
+ return nil, fmt.Errorf("%s:%d: want the header line first", path, n)
+ }
+ header = true
+ continue
+ }
+ if len(cols) < 2 || cols[0] == "" {
+ return nil, fmt.Errorf("%s:%d: want an id and an audience", path, n)
+ }
+ if cols[1] == "internal" {
+ continue
+ }
+ word, _, _ := strings.Cut(cols[0], " ")
+ if !seen[word] {
+ seen[word] = true
+ out = append(out, word)
+ }
+ }
+ if err := sc.Err(); err != nil {
+ return nil, err
+ }
+ sort.Strings(out)
+ return out, nil
+}
diff --git a/internal/docsite/cliscan.go b/internal/docsite/cliscan.go
deleted file mode 100644
index 56fe105e5..000000000
--- a/internal/docsite/cliscan.go
+++ /dev/null
@@ -1,92 +0,0 @@
-package docsite
-
-import (
- "go/ast"
- "go/parser"
- "go/token"
- "sort"
- "strconv"
-)
-
-// TopLevelCommands returns every subcommand main.go dispatches on.
-//
-// It reads the switch statement rather than the usage text because the
-// switch is the CLI and the usage text is prose about it. A gate
-// against the prose would prove only that the docs agree with a second
-// copy of the docs, which is exactly the drift worth catching.
-//
-// Flags are deliberately not scanned. rastrillo's equivalent gate does
-// scan them, but its CLI is one small package; CARLOS declares flags
-// across the whole root package and the list would run to hundreds,
-// most of them things no reader ever types.
-func TopLevelCommands(mainFile string) ([]string, error) {
- fset := token.NewFileSet()
- file, err := parser.ParseFile(fset, mainFile, nil, parser.SkipObjectResolution)
- if err != nil {
- return nil, err
- }
-
- seen := map[string]bool{}
- var out []string
- ast.Inspect(file, func(n ast.Node) bool {
- sw, ok := n.(*ast.SwitchStmt)
- if !ok {
- return true
- }
- // Only the dispatch switch — the one on `cmd`. main.go has a
- // single string switch today, but a second one added later
- // would feed non-commands into the gate, and the obvious way
- // to make that gate pass again is to document things that are
- // not commands.
- tag, ok := sw.Tag.(*ast.Ident)
- if !ok || tag.Name != "cmd" {
- return true
- }
- for _, stmt := range sw.Body.List {
- clause, ok := stmt.(*ast.CaseClause)
- if !ok {
- continue
- }
- for _, expr := range clause.List {
- s, ok := stringLit(expr)
- if !ok || !isCommandWord(s) {
- continue
- }
- if !seen[s] {
- seen[s] = true
- out = append(out, s)
- }
- }
- }
- return true
- })
- sort.Strings(out)
- return out, nil
-}
-
-// isCommandWord filters case arms down to real commands: flag aliases
-// like "-h" are documented as part of the command they belong to, and a
-// case arm is only a command if it looks like one.
-func isCommandWord(s string) bool {
- if s == "" {
- return false
- }
- for _, r := range s {
- if (r < 'a' || r > 'z') && r != '-' {
- return false
- }
- }
- return s[0] != '-'
-}
-
-func stringLit(e ast.Expr) (string, bool) {
- lit, ok := e.(*ast.BasicLit)
- if !ok || lit.Kind != token.STRING {
- return "", false
- }
- s, err := strconv.Unquote(lit.Value)
- if err != nil {
- return "", false
- }
- return s, true
-}
diff --git a/internal/docsite/fences_test.go b/internal/docsite/fences_test.go
index 3795c5119..1e6f0722f 100644
--- a/internal/docsite/fences_test.go
+++ b/internal/docsite/fences_test.go
@@ -72,9 +72,9 @@ func TestFencedCarlosCommandsAreReal(t *testing.T) {
if err != nil {
t.Fatalf("load: %v", err)
}
- cmds, err := TopLevelCommands(mainFile)
+ cmds, err := TopLevelNames(cliFile)
if err != nil {
- t.Fatalf("scan: %v", err)
+ t.Fatalf("read: %v", err)
}
real := map[string]bool{}
for _, c := range cmds {
diff --git a/internal/parity/repo_test.go b/internal/parity/repo_test.go
index 20065fecb..998244f4d 100644
--- a/internal/parity/repo_test.go
+++ b/internal/parity/repo_test.go
@@ -16,7 +16,7 @@ const (
repoTable = "../../parity/parity.tsv"
repoPackages = "../../parity/packages.tsv"
repoPage = "../../docs/parity.md"
- repoMain = "../../main.go"
+ repoCLI = "../../parity/cli.tsv" // the command tree's projection
)
func loadRepo(t *testing.T) ([]Row, []Package) {
@@ -50,18 +50,18 @@ func TestParityTableIsValid(t *testing.T) {
}
}
-// TestParityCLITopLevel is spec C5: every command main.go dispatches
-// starts some row's CLI member, and every CLI member starts with a command
-// main.go dispatches, except the __ plumbing words dispatched before the
-// switch, which Check holds to shape only.
+// TestParityCLITopLevel is spec C5: every top-level command the binary
+// dispatches (the first words of parity/cli.tsv, internal ones aside)
+// starts some row's CLI member, and every CLI member starts with one of
+// them, except the __ plumbing words, which Check holds to shape only.
func TestParityCLITopLevel(t *testing.T) {
rows, _ := loadRepo(t)
- words, err := docsite.TopLevelCommands(repoMain)
+ words, err := docsite.TopLevelNames(repoCLI)
if err != nil {
t.Fatal(err)
}
if len(words) == 0 {
- t.Fatal("docsite.TopLevelCommands found no commands in main.go")
+ t.Fatal("docsite.TopLevelNames found no commands in parity/cli.tsv")
}
dispatched := map[string]bool{}
for _, w := range words {
@@ -76,13 +76,13 @@ func TestParityCLITopLevel(t *testing.T) {
continue
}
if !dispatched[w] {
- t.Errorf("parity/parity.tsv:%d: row %s: `%s` is not a command main.go dispatches", r.Line, r.ID, w)
+ t.Errorf("parity/parity.tsv:%d: row %s: `%s` is not a command the binary dispatches (parity/cli.tsv)", r.Line, r.ID, w)
}
}
}
for _, w := range words {
if !first[w] {
- t.Errorf("main.go dispatches `%s` but no row's CLI member starts with it: add a row", w)
+ t.Errorf("the binary dispatches `%s` but no row's CLI member starts with it: add a row", w)
}
}
}
diff --git a/main.go b/main.go
index d0c16156b..0578db420 100644
--- a/main.go
+++ b/main.go
@@ -3,7 +3,6 @@
package main
import (
- "context"
"fmt"
"io"
"log"
@@ -12,14 +11,9 @@ import (
"strings"
"github.com/carlosframework/platform/internal/cgroup"
- "github.com/carlosframework/platform/internal/democlaim"
- "github.com/carlosframework/platform/internal/edge"
+ "github.com/carlosframework/platform/internal/clireg"
"github.com/carlosframework/platform/internal/execsandbox"
- "github.com/carlosframework/platform/internal/host"
- "github.com/carlosframework/platform/internal/instanceexec"
"github.com/carlosframework/platform/internal/rootaws"
- "github.com/carlosframework/platform/internal/version"
- "github.com/carlosframework/platform/internal/vet"
)
func main() {
@@ -38,213 +32,15 @@ func main() {
usage(os.Stderr)
os.Exit(2)
}
- cmd, args := os.Args[1], os.Args[2:]
- if cmd == "__demo-snapshot" {
- if len(args) != 0 {
- log.Fatal(democlaim.ErrSnapshot)
- }
- if err := democlaim.RunSnapshotWorker(context.Background()); err != nil {
- log.Fatal(err)
- }
- return
- }
- // The drain verbs' agent call, run as the agent's user
- // (internal/host/hadrain_call.go): plumbing, never typed.
- if cmd == "__drain-call" {
- os.Exit(host.RunDrainCall(args, os.Stdout))
- }
- if cmd == "__registry-child" {
- if err := host.RunRegistryChild(args); err != nil {
- log.Fatal(err)
- }
- return
- }
- // carlos ship --check's health probe, run inside the web container
- // (ship_check_probe.go): plumbing, not a command anyone types.
- if cmd == "__rootfs-check-probe" {
- os.Exit(runRootfsCheckProbe(args))
- }
- // And the container that makes the check's data volume its user's.
- if cmd == "__rootfs-check-prepare" {
- os.Exit(runRootfsCheckPrepare(args))
- }
- switch cmd {
- // Asking for help is not an error: it prints on stdout and exits 0, so
- // `carlos help | less` works. A bare `carlos` still fails (stderr, 2).
- case "help", "-h", "--help":
- usage(os.Stdout)
- case "version":
- // `carlos version` on its own is the build id and nothing else —
- // unchanged, because every install script and support request in
- // existence types it. `carlos version target ...` is the only string
- // that dispatches anywhere new (release versioning spec, 2026-08-08):
- // a sub-verb rather than a top-level `carlos target`, because what it
- // sets IS the app's version, and it reads that way at the terminal.
- if len(args) > 0 && args[0] == "target" {
- runVersionTarget(args[1:])
- } else {
- fmt.Printf("carlos %s\n", version.Build)
- }
- case "edge":
- edge.Run(args)
- case "devbox":
- runDevbox(args)
- case "add":
- runAdd(args)
- case "remove":
- runRemove(args)
- case "route":
- runRoute(args)
- case "instances":
- runInstances(args)
- case "sidecars":
- runSidecars(args)
- case "routes":
- runRoutes(args)
- case "domains":
- runDomains(args)
- case "features":
- runFeatures(args)
- case "assets":
- runAssets(args)
- case "gate":
- runGate(args)
- case "ratelimit":
- runRatelimit(args)
- case "ship":
- runShip(args)
- case "promote":
- runPromote(args)
- case "deploy":
- runDeploy(args)
- case "restart":
- runRestart(args)
- case "db":
- runDB(args)
- case "run":
- runRun(args)
- case "console":
- runConsole(args)
- case "steering":
- runSteering(args)
- case "schedule":
- runSchedule(args)
- case "economics":
- runEconomics(args)
- case "store":
- runStore(args)
- case "relay":
- runRelay(args)
- case "email":
- runEmail(args)
- case "logs":
- runLogs(args)
- case "errors":
- runErrors(args)
- case "availability":
- runAvailability(args)
- case "geo":
- runGeo(args)
- case "explain":
- runExplain(args)
- case "analytics":
- runAnalytics(args)
- case "protection":
- runProtection(args)
- case "channels":
- // Two sub-verbs, resign and digests (#253); bare `carlos channels`
- // still lists, the `carlos releases retention` precedent.
- if len(args) > 0 && args[0] == "resign" {
- runChannelsResign(args[1:])
- return
- }
- if len(args) > 0 && args[0] == "digests" {
- runChannelsDigests(args[1:])
- return
- }
- runChannels(args)
- case "pipeline":
- runPipeline(args)
- case "skills":
- runSkills(args)
- case "releases":
- // Two sub-verbs, `retention` and `authorize` — the `carlos version
- // target` judgment call: flags-only verbs stay flat until a word
- // genuinely names a different action, and a policy write or a
- // signature is not a listing.
- if len(args) > 0 && args[0] == "retention" {
- runReleasesRetention(args[1:])
- return
- }
- if len(args) > 0 && args[0] == "authorize" {
- runReleasesAuthorize(args[1:])
- return
- }
- runReleases(args)
- case "rollback":
- runRollback(args)
- case "ledger":
- RunLedger(args)
- case "auth":
- RunAuth(args)
- case "config":
- RunConfig(args)
- case "accounts":
- RunAccounts(args)
- case "billing":
- runBilling(args)
- case "apps":
- RunApps(args)
- case "fleets":
- RunFleets(args)
- case "services":
- RunServices(args)
- case "env":
- RunEnv(args)
- case "secrets":
- RunSecrets(args)
- case "release-keygen":
- runKeygen(args)
- case "proof":
- runProof(args)
- case "ops":
- runOps(args)
- case "system":
- runSystem(args)
- case "move":
- runMove(args)
- case "status":
- RunStatus(args)
- case "agent":
- host.RunAgent(args)
- case "bootstrap":
- host.RunBootstrap(args)
- case "adopt":
- host.RunAdopt(args)
- case "instance-control":
- host.RunInstanceControl(args)
- case "instance-exec":
- instanceexec.RunExec(args)
- case "instance-exit":
- instanceexec.RunExit(args)
- case "instance-stop":
- instanceexec.RunStop(args)
- case "instance-probe":
- instanceexec.RunProbe(args)
- case "vet":
- vet.Run(args)
- case "update":
- runUpdate(args)
- case "canary":
- runCanary(args)
- default:
- usage(os.Stderr)
- os.Exit(2)
- }
+ path := clireg.Dispatch(commandRoot(), os.Args[1:])
// After a verb that ran to success: the once-a-day newer-release hint
- // (#161). Verbs that fail never reach here — log.Fatal exits — so a
- // broken command is never followed by an upsell.
- maybeUpdateHint(cmd)
+ // (#161). Verbs that fail never reach here (log.Fatal exits), so a
+ // broken command is never followed by an upsell. Paths through a
+ // NoUpdateHint node skip it (maybeUpdateHint), and so, until they become
+ // nodes, do the channels and releases sub-verbs.
+ if !subVerbSkipsHint {
+ maybeUpdateHint(path)
+ }
}
// usage prints the top-level command list, grouped by the role you are in
diff --git a/parity/cli.tsv b/parity/cli.tsv
new file mode 100644
index 000000000..1de2b85ef
--- /dev/null
+++ b/parity/cli.tsv
@@ -0,0 +1,78 @@
+# Every command the carlos binary runs, from its command tree (commands.go).
+# Generated: make parity-doc. Do not edit by hand.
+id audience effect scope tool flags enums
+__cgexec internal - - - - -
+__cgprobe internal - - - - -
+__demo-snapshot internal - - - - -
+__drain-call internal - - - - -
+__registry-child internal - - - - -
+__rootfs-check-prepare internal - - - - -
+__rootfs-check-probe internal - - - - -
+accounts customer - - - - -
+add box-local - - - - -
+adopt box-local - - - - -
+agent box-local - - - - -
+analytics customer - - - - -
+apps customer - - - - -
+assets customer - - - - -
+auth customer - - - - -
+availability customer - - - - -
+billing operator - - - - -
+bootstrap box-local - - - - -
+canary customer - - - - -
+channels customer - - - - -
+config customer - - - - -
+console customer - - - - -
+db customer - - - - -
+deploy customer - - - - -
+devbox customer - - - - -
+domains customer - - - - -
+economics operator - - - - -
+edge box-local - - - - -
+email customer - - - - -
+env customer - - - - -
+errors customer - - - - -
+explain customer - - - - -
+features customer - - - - -
+fleets customer - - - - -
+gate customer - - - - -
+geo customer - - - - -
+help customer - - - - -
+instance-control box-local - - - - -
+instance-exec box-local - - - - -
+instance-exit box-local - - - - -
+instance-probe box-local - - - - -
+instance-stop box-local - - - - -
+instances customer - - - - -
+ledger customer - - - - -
+logs customer - - - - -
+move customer - - - - -
+ops operator - - - - -
+pipeline customer - - - - -
+promote customer - - - - -
+proof box-local - - - - -
+protection customer - - - - -
+ratelimit customer - - - - -
+relay customer - - - - -
+release-keygen box-local - - - - -
+releases customer - - - - -
+remove box-local - - - - -
+restart customer - - - - -
+rollback customer - - - - -
+route box-local - - - - -
+routes customer - - - - -
+run customer - - - - -
+schedule customer - - - - -
+secrets customer - - - - -
+services customer - - - - -
+ship customer - - - - -
+sidecars customer - - - - -
+skills customer - - - - -
+status operator - - - - -
+steering customer - - - - -
+store customer - - - - -
+system operator - - - - -
+update customer - - - - -
+version customer - - - - -
+version target customer - - - - -
+vet customer - - - - -
diff --git a/update.go b/update.go
index e13ccf31c..2ce1a20fe 100644
--- a/update.go
+++ b/update.go
@@ -22,6 +22,7 @@ import (
"strings"
"time"
+ "github.com/carlosframework/platform/internal/clireg"
"github.com/carlosframework/platform/internal/publicrelease"
"github.com/carlosframework/platform/internal/release"
"github.com/carlosframework/platform/internal/version"
@@ -67,17 +68,6 @@ func newerVersion(latest, current string) bool {
return lok && cok && l.Compare(c) > 0
}
-// noHintVerbs are the box/daemon/plumbing verbs the update hint stays out
-// of — either they run where updates are the platform's job, or their
-// output is parsed (version: the tap formula's test asserts on it).
-var noHintVerbs = map[string]bool{
- "edge": true, "agent": true, "adopt": true, "bootstrap": true,
- "add": true, "remove": true, "route": true, "ops": true,
- "status": true, "vet": true, "release-keygen": true,
- "version": true, "help": true, "-h": true, "--help": true,
- "update": true, "system": true,
-}
-
type updateCache struct {
CheckedAt time.Time `json:"checked_at"`
Latest string `json:"latest"`
@@ -112,9 +102,16 @@ func fetchLatest(timeout time.Duration) (string, error) {
// the hint share the cache window), and only where a hint can possibly be
// wanted: a human at a terminal, running a release build, off-box, not
// opted out. Every failure is silence; this must never make a working
-// command look broken.
-func maybeUpdateHint(cmd string) {
- if noHintVerbs[cmd] || !interactiveTerminal() || !releaseBuild(version.Build) {
+// command look broken. ran is the path clireg.Dispatch took: a node on it with
+// NoUpdateHint (box, daemon and plumbing verbs, or output that is parsed:
+// the tap formula's test asserts on `carlos version`) keeps the hint out.
+func maybeUpdateHint(ran []*clireg.Node) {
+ for _, n := range ran {
+ if n.NoUpdateHint {
+ return
+ }
+ }
+ if !interactiveTerminal() || !releaseBuild(version.Build) {
return
}
if os.Getenv("CARLOS_DEPLOYMENT_BUCKET") != "" || os.Getenv("CARLOS_DEPLOYMENT_DIR") != "" {
diff --git a/update_test.go b/update_test.go
index 3c0815aaf..ff3a89959 100644
--- a/update_test.go
+++ b/update_test.go
@@ -80,13 +80,13 @@ func TestUpdateHintShowsOncePerDay(t *testing.T) {
useVersion(t, "v0.7.0")
hits := latestServer(t, "v0.8.0")
- maybeUpdateHint("ship")
+ maybeUpdateHint(pathFor("ship"))
if !strings.Contains(out.String(), "carlos v0.8.0 is available (you have v0.7.0) — run: carlos update") {
t.Fatalf("no hint:\n%s", out.String())
}
// Within the cache window: no second fetch, no second hint.
out.Reset()
- maybeUpdateHint("ship")
+ maybeUpdateHint(pathFor("ship"))
if *hits != 1 || out.String() != "" {
t.Fatalf("second run: hits=%d out=%q, want cached silence", *hits, out.String())
}
@@ -96,7 +96,7 @@ func TestUpdateHintShowsOncePerDay(t *testing.T) {
if err := os.WriteFile(path, []byte(stale), 0o600); err != nil {
t.Fatal(err)
}
- maybeUpdateHint("ship")
+ maybeUpdateHint(pathFor("ship"))
if *hits != 2 {
t.Fatalf("hits after stale cache = %d, want 2", *hits)
}
@@ -112,27 +112,27 @@ func TestUpdateHintGates(t *testing.T) {
// Each gate must keep the network untouched, not merely the output.
t.Setenv("CARLOS_DEPLOYMENT_BUCKET", "some-box-bucket")
- maybeUpdateHint("ship")
+ maybeUpdateHint(pathFor("ship"))
t.Setenv("CARLOS_DEPLOYMENT_BUCKET", "")
t.Setenv("CARLOS_NO_UPDATE_CHECK", "1")
- maybeUpdateHint("ship")
+ maybeUpdateHint(pathFor("ship"))
t.Setenv("CARLOS_NO_UPDATE_CHECK", "")
writeConfig(t, ".", `{"update_check": "off"}`)
- maybeUpdateHint("ship")
+ maybeUpdateHint(pathFor("ship"))
os.RemoveAll(".carlos")
- maybeUpdateHint("edge") // box verb
- maybeUpdateHint("version") // parsed output
- maybeUpdateHint("update") // the verb itself
+ maybeUpdateHint(pathFor("edge")) // box verb
+ maybeUpdateHint(pathFor("version")) // parsed output
+ maybeUpdateHint(pathFor("update")) // the verb itself
forceTerminal(t, false)
- maybeUpdateHint("ship")
+ maybeUpdateHint(pathFor("ship"))
forceTerminal(t, true)
useVersion(t, "dev")
- maybeUpdateHint("ship")
+ maybeUpdateHint(pathFor("ship"))
if *hits != 0 || out.String() != "" {
t.Fatalf("gated runs: hits=%d out=%q, want zero of both", *hits, out.String())
@@ -147,7 +147,7 @@ func TestUpdateHintUpToDateIsSilent(t *testing.T) {
useVersion(t, "v0.8.0")
hits := latestServer(t, "v0.8.0")
- maybeUpdateHint("ship")
+ maybeUpdateHint(pathFor("ship"))
if *hits != 1 || out.String() != "" {
t.Fatalf("up to date: hits=%d out=%q, want one silent check", *hits, out.String())
}