Skip to content

test(cli): pin the client list --plain namespace= contract the installer greps (#141)#242

Merged
aptracebloc merged 1 commit into
developfrom
test/141-client-list-contract
Jul 13, 2026
Merged

test(cli): pin the client list --plain namespace= contract the installer greps (#141)#242
aptracebloc merged 1 commit into
developfrom
test/141-client-list-contract

Conversation

@LukasWodka

@LukasWodka LukasWodka commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

What

Closes #141. Pins the fragile contract the installer's #303 pre-flight depends on: it shells tracebloc client list --plain and greps the output for namespace=<ns> — and client list is now a Hidden command, so nothing guaranteed the output format still holds.

internal/cli/client_list_contract_test.go drives the real command the way the installer does (client list --plain through the root command) over the existing fake backend and asserts:

  • client list is still Hidden and still dispatches / exits 0 while Hidden (Hidden only removes it from help);
  • the output carries the literal namespace=<ns> field, and the installer's exact regex namespace=<ns>([[:space:]]|$) matches;
  • boundary: an absent namespace and a strict prefix (acme-prod-0) do not match — pinning the whitespace/EOL anchor.

Mutation-proven: renaming namespace=/location= in client.go fails the test. Test-only; make ci green (internal/cli 74.1%). Pairs with a client-repo test of the consumer half (_account_owns_namespace) — see that PR.

Closes #141.

🤖 Generated with Claude Code


Note

Low Risk
Test-only addition with no production code changes; low risk aside from future CI breakage if list output format changes without updating the installer.

Overview
Adds internal/cli/client_list_contract_test.go to lock the cross-repo contract used by the tracebloc installer’s #303 pre-flight (provision.shtracebloc client list --plain + grep on namespace=<ns>).

The test runs client list --plain through NewRootCmdExecute (not the handler directly) against the existing withClientBackend fake API. It checks that client list stays Hidden yet still exits 0, that plain output includes namespace=<ns> and a stable namespace=… location=… fragment, that the installer’s regex namespace=<ns>([[:space:]]|$) matches, and that absent namespaces and strict prefixes do not match.

Test-only — no runtime behavior changes.

Reviewed by Cursor Bugbot for commit f860d6d. Bugbot is set up for automated code reviews on this repo. Configure here.

`client list` is Hidden (RFC-0001 §7.10), but the client installer's #303
one-client-per-machine pre-flight still shells out to it:
`scripts/lib/provision.sh` `_account_owns_namespace` runs
`tracebloc client list --plain` and greps the output for
`namespace=<ns>([[:space:]]|$)` to refuse a cross-account re-provision.

Hidden ≠ disabled, so the command still runs — but nothing pinned that
`--plain` stays a valid flag or that the output keeps emitting the
`namespace=<ns>` field in a form the installer's grep matches. If either
drifts, the grep silently fails and #303 stops firing in the field with
no error.

Add a cli-side guard that drives the REAL root (`NewRootCmd` → Execute,
as the installer invokes it, not `runClientList` directly) and asserts:
  - `client list --plain` still dispatches + exits 0 while Hidden;
  - the output contains the literal `namespace=<ns>   location=<loc>`
    field (canary for any format drift);
  - the installer's exact regex matches the live output (the real break
    condition), and is prefix-anchored (no false-accept on a strict
    prefix or an absent namespace).

Mutation-verified: renaming the `namespace=`/`location=` fields fails
this test. A format change now breaks CI here instead of silently
disabling the installer's #303 refusal.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@LukasWodka
LukasWodka requested a review from aptracebloc July 12, 2026 14:49
@aptracebloc
aptracebloc merged commit 67b09d6 into develop Jul 13, 2026
20 checks passed
@aptracebloc
aptracebloc deleted the test/141-client-list-contract branch July 13, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants