carlos / platform Public

cli: carlos domains check --country

Sends the optional country the console's check door uses to price a
domain before an account has a billing currency. Validated client-side
(two ASCII letters). Not on buy: the purchase prices by the contact.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Squashed from domains-check-country into main.
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 16941087ab182578fa6db21f3894fe03a595ffb8 parent e44476a
7 files changed, +115 −9
  • approved_domains_buy_copy_test.go +5 −2
  • docs/superpowers/notes/census-proposal-domains-check-country.md +11 −0
  • domains_buy_cli.go +17 −4
  • domains_buy_cli_test.go +69 −1
  • domains_buy_copy.go +9 −2
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-domains-check-country.tsv +3 −0

CI failed — run details

diff --git a/approved_domains_buy_copy_test.go b/approved_domains_buy_copy_test.go
index 7905454a7..bb2bc0518 100644
--- a/approved_domains_buy_copy_test.go
+++ b/approved_domains_buy_copy_test.go
@@ -66,8 +66,11 @@ func TestApprovedDomainsBuyCopy(t *testing.T) {
{"door.hostUnavailable", "internal/console/apidomains.go", "hostname unavailable"},
{"door.customDomain", "internal/console/plancaps_copy.go", "custom domains need a paid plan. on this plan the app keeps its platform address"},
{"door.planCheckFailed", "internal/console/plancaps_copy.go", "could not check this account's plan. Try again"},
- {"cli.help", "domains_buy_copy.go", " check <name> [flags]\n check availability and the price for one year\n buy <name> --app <a> [--contact-file contact.json] [--yes] [--no-wait] [flags]\n buy a domain and wait for it to serve the app\n\n"},
- {"cli.checkUsage", "domains_buy_copy.go", "usage: carlos domains check <name> [--account <a>] [--account-id <id>] [--console <origin>]\n"},
+ // approved by delegation (reviewer, 2026-11-03)
+ {"cli.countryFlag", "domains_buy_copy.go", "country for the price check when no billing currency is set (two letters)"},
+ {"cli.countryInvalid", "domains_buy_copy.go", "--country must be two letters a-z"},
+ {"cli.help", "domains_buy_copy.go", " check <name> [--country <cc>] [flags]\n check availability and the price for one year\n buy <name> --app <a> [--contact-file contact.json] [--yes] [--no-wait] [flags]\n buy a domain and wait for it to serve the app\n\n"},
+ {"cli.checkUsage", "domains_buy_copy.go", "usage: carlos domains check <name> [--country <cc>] [--account <a>] [--account-id <id>] [--console <origin>]\n"},
{"cli.buyUsage", "domains_buy_copy.go", "usage: carlos domains buy <name> --app <a> [--contact-file contact.json] [--yes] [--no-wait] [--account <a>] [--account-id <id>] [--console <origin>]\n"},
{"cli.appFlag", "domains_buy_copy.go", "app the domain will serve"},
{"cli.accountFlag", "domains_buy_copy.go", "account (sqid or name)"},
diff --git a/docs/superpowers/notes/census-proposal-domains-check-country.md b/docs/superpowers/notes/census-proposal-domains-check-country.md
new file mode 100644
index 000000000..f4befa72e
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-domains-check-country.md
@@ -0,0 +1,11 @@
+# Census approval: domains-check-country
+
+Ruling `census-ruling-domains-check-country`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+Envelopes re-pinned: `.`.
+
+Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
+
+Seal: `b0fc198c53bb0dacba33a54c3d8bf8fe5ac07d94b76a31b8a69e9411115ecd85` → `b0fc198c53bb0dacba33a54c3d8bf8fe5ac07d94b76a31b8a69e9411115ecd85`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-domains-check-country.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/domains_buy_cli.go b/domains_buy_cli.go
index 1b899a0f0..94d9c61c8 100644
--- a/domains_buy_cli.go
+++ b/domains_buy_cli.go
@@ -33,13 +33,15 @@ func runDomainBuyVerb(args []string, buy bool) {
acctRaw := fs.String("account", "", domainsBuyCopy["accountFlag"])
acctID := fs.String("account-id", "", domainsBuyCopy["accountIDFlag"])
console := consoleOption(fs, domainsBuyCopy["consoleFlag"])
- var app, contactFile string
+ var app, contactFile, country string
var yes, noWait bool
if buy {
fs.StringVar(&app, "app", "", domainsBuyCopy["appFlag"])
fs.StringVar(&contactFile, "contact-file", "", domainsBuyCopy["contactFileFlag"])
fs.BoolVar(&yes, "yes", false, domainsBuyCopy["yesFlag"])
fs.BoolVar(&noWait, "no-wait", false, domainsBuyCopy["noWaitFlag"])
+ } else {
+ fs.StringVar(&country, "country", "", domainsBuyCopy["countryFlag"])
}
fs.Usage = flagUsage(fs, usage)
pos, err := parseInterspersed(fs, args)
@@ -49,6 +51,17 @@ func runDomainBuyVerb(args []string, buy bool) {
if len(pos) != 1 || strings.TrimSpace(pos[0]) == "" || (buy && strings.TrimSpace(app) == "") {
log.Fatal(usage)
}
+ fs.Visit(func(f *flag.Flag) {
+ if f.Name == "country" {
+ if len(country) != 2 {
+ log.Fatal(domainsBuyCopy["countryInvalid"])
+ }
+ country = strings.ToUpper(country)
+ if len(country) != 2 || country[0] < 'A' || country[0] > 'Z' || country[1] < 'A' || country[1] > 'Z' {
+ log.Fatal(domainsBuyCopy["countryInvalid"])
+ }
+ }
+ })
sess := requireAPISession(verb, *console)
printUsing(stdout, sess)
acct := resolvedAccount(sess, acctRaw, acctID)
@@ -60,7 +73,7 @@ func runDomainBuyVerb(args []string, buy bool) {
now: time.Now, wait: waitDomainBuy,
})
} else {
- err = domainsCheck(ctx, sess, acct, strings.TrimSpace(pos[0]), stdout)
+ err = domainsCheck(ctx, sess, acct, strings.TrimSpace(pos[0]), country, stdout)
}
if err != nil {
log.Fatal(err)
@@ -75,8 +88,8 @@ func printDomainQuote(out io.Writer, q domainQuoteResp) {
fmt.Fprintf(out, domainsBuyCopy["quote"], q.Domain, availability, plans.FormatMinor(q.Currency, q.Price), strings.ToUpper(q.Currency))
}
-func domainsCheck(ctx context.Context, s *apiSession, acct apiAcct, name string, out io.Writer) error {
- q, err := s.postDomainCheck(ctx, acct, name, "")
+func domainsCheck(ctx context.Context, s *apiSession, acct apiAcct, name, country string, out io.Writer) error {
+ q, err := s.postDomainCheck(ctx, acct, name, country)
if err != nil {
return err
}
diff --git a/domains_buy_cli_test.go b/domains_buy_cli_test.go
index bd3ea55e2..ea044ecd8 100644
--- a/domains_buy_cli_test.go
+++ b/domains_buy_cli_test.go
@@ -14,6 +14,7 @@ import (
"path/filepath"
"reflect"
"strings"
+ "sync/atomic"
"testing"
"time"
)
@@ -54,7 +55,7 @@ func buyTestOptions(out *bytes.Buffer) domainBuyOptions {
func TestDomainsCheckPrintsPrice(t *testing.T) {
ts := buyTestServer(t, nil, nil)
var out bytes.Buffer
- if err := domainsCheck(context.Background(), newTestSession(ts.URL), apiAcct{Seg: "bab"}, "shop.com", &out); err != nil {
+ if err := domainsCheck(context.Background(), newTestSession(ts.URL), apiAcct{Seg: "bab"}, "shop.com", "", &out); err != nil {
t.Fatal(err)
}
for _, want := range []string{"shop.com", "available", "12.99", "EUR"} {
@@ -397,6 +398,73 @@ func TestDomainsCheckCommand(t *testing.T) {
}
}
+func runCheckTestCommand(t *testing.T, base string, args ...string) (string, error) {
+ t.Helper()
+ scratch := t.TempDir()
+ creds := filepath.Join(scratch, "credentials")
+ writeTestCredential(t, creds, base)
+ argv := append([]string{"domains", "check", "shop.com", "--account", "bab", "--console", base}, args...)
+ cmd := exec.Command(buildCarlos(t), argv...)
+ cmd.Dir = scratch
+ cmd.Env = carlosTestEnv(t, "CARLOS_CREDENTIALS="+creds, "CARLOS_DEPLOYMENT_BUCKET=", "CARLOS_DEPLOYMENT_DIR=", "CARLOS_CONFIG=")
+ out, err := cmd.CombinedOutput()
+ return string(out), err
+}
+
+func TestDomainsCheckCountryFlag(t *testing.T) {
+ for _, country := range []string{"IE", "ie", "iE"} {
+ t.Run(country, func(t *testing.T) {
+ var checks atomic.Int32
+ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ checks.Add(1)
+ var in struct{ Name, Country string }
+ if err := json.NewDecoder(r.Body).Decode(&in); err != nil {
+ t.Error(err)
+ }
+ if r.Method != "POST" || r.URL.Path != buyTestPath+"/check" || in.Name != "shop.com" || in.Country != "IE" {
+ t.Errorf("unexpected request: %s %s %+v", r.Method, r.URL.Path, in)
+ }
+ fmt.Fprint(w, `{"domain":"shop.com","available":true,"price":1299,"currency":"eur"}`)
+ }))
+ defer ts.Close()
+ out, err := runCheckTestCommand(t, ts.URL, "--country", country)
+ if err != nil || checks.Load() != 1 || !strings.Contains(out, "EUR") {
+ t.Fatalf("checks=%d err=%v output=%s", checks.Load(), err, out)
+ }
+ })
+ }
+}
+
+func TestDomainsCountryFlagInvalidBeforeRequest(t *testing.T) {
+ for _, country := range []string{"", "I", "IRL", "I1", "1E", "I-", " IE", "IE ", "É", "ıe"} {
+ t.Run(country, func(t *testing.T) {
+ var requests atomic.Int32
+ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ requests.Add(1)
+ http.Error(w, "unexpected request", http.StatusInternalServerError)
+ }))
+ defer ts.Close()
+ out, err := runCheckTestCommand(t, ts.URL, "--country", country)
+ if err == nil || requests.Load() != 0 || !strings.Contains(out, "--country must be two letters a-z") {
+ t.Fatalf("requests=%d err=%v output=%s", requests.Load(), err, out)
+ }
+ })
+ }
+}
+
+func TestDomainsBuyRejectsCountryFlagBeforeRequest(t *testing.T) {
+ var requests atomic.Int32
+ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ requests.Add(1)
+ http.Error(w, "unexpected request", http.StatusInternalServerError)
+ }))
+ defer ts.Close()
+ out, err := runBuyTestCommand(t, ts.URL, "--country", "IE")
+ if err == nil || requests.Load() != 0 || !strings.Contains(out, "flag provided but not defined") {
+ t.Fatalf("requests=%d err=%v output=%s", requests.Load(), err, out)
+ }
+}
+
type domainBuyRoundTrip func(*http.Request) (*http.Response, error)
func (f domainBuyRoundTrip) RoundTrip(r *http.Request) (*http.Response, error) { return f(r) }
diff --git a/domains_buy_copy.go b/domains_buy_copy.go
index a1b310ddd..8d928368e 100644
--- a/domains_buy_copy.go
+++ b/domains_buy_copy.go
@@ -3,12 +3,19 @@ package main
// Approved by delegation (Luna), 2026-11-02:
// docs/superpowers/specs/LUNA-COPY-RESULT-DOMAINS-1.md, plus controller rulings
// on four flags. Apply later edits through a copy pass.
-const domainsBuyHelp = " check <name> [flags]\n check availability and the price for one year\n buy <name> --app <a> [--contact-file contact.json] [--yes] [--no-wait] [flags]\n buy a domain and wait for it to serve the app\n\n"
+// approved by delegation (reviewer, 2026-11-03)
+const domainsBuyHelp = " check <name> [--country <cc>] [flags]\n check availability and the price for one year\n buy <name> --app <a> [--contact-file contact.json] [--yes] [--no-wait] [flags]\n buy a domain and wait for it to serve the app\n\n"
-const domainsCheckUsage = "usage: carlos domains check <name> [--account <a>] [--account-id <id>] [--console <origin>]\n"
+// approved by delegation (reviewer, 2026-11-03)
+const domainsCheckUsage = "usage: carlos domains check <name> [--country <cc>] [--account <a>] [--account-id <id>] [--console <origin>]\n"
+
+// approved by delegation (reviewer, 2026-11-03)
const domainsBuyUsage = "usage: carlos domains buy <name> --app <a> [--contact-file contact.json] [--yes] [--no-wait] [--account <a>] [--account-id <id>] [--console <origin>]\n"
var domainsBuyCopy = map[string]string{
+ // approved by delegation (reviewer, 2026-11-03)
+ "countryFlag": "country for the price check when no billing currency is set (two letters)",
+ "countryInvalid": "--country must be two letters a-z",
// Approved by delegation (reviewer), 2026-11-03.
"confirmChanged": "buy this domain at the new price? [y/N] ",
// Draft for the Luna pass: domain registration Plan 2, slice 1.
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 2e49aa73e..408b05739 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -71,3 +71,4 @@ plan14-root-reads-design-pdf-service.tsv 09ad1d7267b9598c64e89ec0faa7b18839c785c
plan14-root-reads-region-ha-placement-survivor.tsv 09ad1d7267b9598c64e89ec0faa7b18839c785c5c63905b398afe681cf9777c6
plan14-root-reads-domains-buy-nosub.tsv 09ad1d7267b9598c64e89ec0faa7b18839c785c5c63905b398afe681cf9777c6
plan14-root-reads-wake-storm-cap.tsv b0fc198c53bb0dacba33a54c3d8bf8fe5ac07d94b76a31b8a69e9411115ecd85
+plan14-root-reads-domains-check-country.tsv b0fc198c53bb0dacba33a54c3d8bf8fe5ac07d94b76a31b8a69e9411115ecd85
diff --git a/internal/provision/testdata/plan14-root-reads-domains-check-country.tsv b/internal/provision/testdata/plan14-root-reads-domains-check-country.tsv
new file mode 100644
index 000000000..2c1fc5210
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-domains-check-country.tsv
@@ -0,0 +1,3 @@
+# Census overlay domains-check-country, written by census-propose (#369). census-ruling-domains-check-country, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-domains-check-country.md.
+# 0 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@coverage . a60ca048c2e1fd41a4569a2e8419b1ab62c4d0687a7b0e8b7336ae05db85fcba