fix(cli): diagnose before advising — a wrong active-client pointer has a way back (cli#515) - #519
Conversation
…indly
The §7.3 binding-miss error is RFC-0001's sentence with the remedy deleted:
it names --namespace but never says WHICH namespace, and nothing else in the
CLI will tell you. On a laptop with a healthy local install that left no
supported way back.
explain now diagnoses before advising. A binding-applied noParentReleaseError
carries the clientset and server URL of the cluster that actually missed, and
explain spends one naming-only cluster.FindClientNamespaces — the same read
discoverRelease already spends purely to write a better message — then branches
on isLocalServerURL:
one client + local server URL name it, offer `client create` (a re-run on a
cluster that already hosts a client adopts it,
so the repoint mints nothing)
client(s) on a remote cluster name the namespaces, offer ONLY --namespace;
never `client create` there, because the client
we found may be a colleague's (§7.5)
none, scan clean today's text plus "No tracebloc client is
running on this cluster either", which is when
the installer is the right advice
could not look today's text, byte for byte
The last branch is the point of the three-valued clientSurvey: a nil probe or a
failed scan is an absence of evidence, and printing it as "nothing is running
here" would tell a user with a working client the opposite of the truth.
allowScan() is untouched and still false for an applied binding: this changes
what the CLI says, never what it targets. TestActiveClientBinding_AllowScan and
TestDiscoverRelease_NoScanWhenExplicit pass unmodified, and
TestExplain_BindingMiss_NamesTheLocalClientWithoutRetargeting pins both halves
at once — the namespace appears in the message and nowhere else.
The probe travels on the error rather than through explain's signature so a
caller cannot hand it a clientset for a different cluster than the one that
missed; six of the seven call sites never held one anyway (resolveClusterTarget
builds it internally and returns nil on the error path).
Refs cli#515
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
#401 taught the home screen that an EMPTY active-client pointer says nothing about what runs on this machine. The wrong-pointer case was never covered, and it is the worse one: doctor binds the stale pointer, probes only that namespace, never scans, and prints "No secure environment on this machine yet" with the installer command underneath — over a perfectly healthy install. home has the same hole from the other side: its local-env fallback sat behind `if !binding.applied`, so a non-empty pointer skipped the #401 fix entirely. Both now route the miss through the same fallback: home the ErrNoParentRelease branch returns localEnvFallback(ctx) instead of a bare localNoRelease. Every failure inside the fallback degrades to localNoRelease, so this branch's old return value is still its floor. doctor on a ReachNoEnv result that a BINDING (not the user) aimed, re-probe the namespace the kubeconfig itself selects, via localEnvNamespace. The ownership gate is what makes this safe, and it is unchanged: both adopt only when isLocalServerURL says the kubeconfig's server is this machine — a cluster that is this machine by definition, so whatever runs there is this machine's environment. On a remote or shared cluster the honest no-environment answer stands, and a colleague's client is never greeted as yours (§7.5). No scan is spent either: the installer points the kubeconfig context at the client's namespace (client/scripts/lib/install-client-helm.sh runs `kubectl config set-context --current --namespace <ns>`), so reading the context is enough to find a healthy install that the pointer missed. doctor keeps the original results unless the re-probe actually finds an environment, so a genuinely bare machine still gets the installer advice and the --diagnose bundle still describes the namespace the user is configured for. An explicit --namespace is never second-guessed — no binding, no re-probe. Refs cli#515 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…achine"
Two things the diagnose-before-advising fix needs in order to reach anyone.
`client create` is visible. It was Hidden because a human running it standalone
on a cluster with no client mints one the installer never deploys — an orphaned
phantom (backend#970). That risk is real and unchanged, but hiding the command
was never what prevented it. The two guards that do are untouched, and now have
tests naming them:
• on a TTY, the review + "Provision this client?" confirm. A re-run on a
cluster that already hosts a client never reaches it — adoption happens
first — so the repoint stays prompt-free and mints nothing.
• off a TTY, a hard refusal without --yes/--credential-file, so a pipe or CI
can never mint silently.
What hiding did cost is #515: the one command that repoints a machine was
unlisted, so the error telling a user to repoint pointed at nothing they could
find. Its Short/Long now describe what it does for a user (adopt/repoint) rather
than the installer's use of it. `client list` stays hidden.
`client list` marks residency, not just selection. It labelled the active
pointer "(active — this machine)" without ever checking where that client runs —
so in exactly the state this ticket is about, the listing sat there confirming a
client provably not on this machine. Selection (the local pointer) and residency
(does it run on the cluster the kubeconfig reaches, keyed on the §7.2 cluster
anchor) are now two separate facts, and a mismatch names the repoint.
An unreadable anchor is a third state, not a "no": with no kubeconfig or an
unreachable API server, no row claims to be here and none is denied — the marker
degrades to bare "(active)". The installer's #303 pre-flight is unaffected; the
markers sit in the row label and the greppable `namespace=<ns>` field is
untouched (client_list_contract_test.go still passes).
Refs cli#515
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…hidden
The golden diff is the whole user-visible change, reviewed line by line:
08-client.golden `create` now appears under Available Commands, with its
new Short and the Long that explains adoption.
zz-all-strings.golden the five §7.3 branches and the `client list` mismatch
hint.
Each branch of repointMessage is one format literal rather than a `+`-joined
string, because the catalog's AST harvest only sees literal arguments — the
message it replaced was invisible there for exactly that reason, and half a
sentence in the completeness backstop is worse than none.
cli-navigation.md carried two statements this change makes false: it drew
`client create` as a hidden node, and its exit-4 remedy line said "run the
installer (or --namespace)", which is now only one of three answers.
Refs cli#515
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
v0.10.8 is already released and this PR changes published files under `internal/*`, so version-bump-gate (a required check) asks for the bump here rather than leaving it to fail the next prod hop on somebody else (backend#1561). The release train reads VERSION and cuts the tag from it. Patch, matching this repo's dominant pattern for user-facing copy and surface changes — say so on the PR if 0.11.0 is wanted for the `client create` unhide. Refs cli#515 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`%w` is the house convention (~325 sites), which makes a bare errors.New here read as an oversight. It is the same deliberate replacement the fmt.Errorf it replaced did: the §7.3 guidance is meant to BE the message, not to trail the raw "no release in namespace X". Wrapping would also make the result re-match errors.As(*noParentReleaseError) and so re-explainable. Recorded in place so a reviewer doesn't have to re-derive it. Refs cli#515 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Two notes for review, both about judgement calls rather than the code: VERSION → 0.10.9.
On the added scan's cost in |
Both Bugbot findings on this PR were right, and both are the same mistake: a two-valued answer where the honest answer has three values. HIGH — "stale pointer still blocks after fallback". Re-probing found the healthy environment and then said nothing about the pointer that missed. So doctor printed "Everything looks good — you're ready to run training" and exited 0 while `data`/`resources`/`seal` all still bind the stale namespace and exit 4; before this PR that state at least exited 3. doctor now names the stale pointer and the repoint, and exits 2 — the code it already uses for every actionable finding. A problem WAS found; it just isn't in the cluster. The home half was worse, and was newly introduced here: local liveness came from the fallback's client while the heartbeat is still looked up by the STALE client's id, so a colleague's machine being online could render this one green. envProbe carries pointerStale, and resolveHomeModel refuses both directions off it — a stale heartbeat can no longer green the screen, nor harden into "backend reports not online" for a client it isn't about. It drops to "running, couldn't confirm", which is exactly true. MEDIUM — "empty cluster ID marked absent". `client list` compared anchors as a boolean, so a client whose OWN anchor is empty — legacy / not-yet-backfilled, which api.ProvisionedClient documents — was reported as "NOT on the cluster your kubeconfig reaches", with the repoint hint, possibly while running on this very machine. Exactly the collapse this PR's cluster-anchor handling was careful to avoid, missed one level down. Residency is now a three-valued residencyOf(): either anchor missing is resUnknown, and unknown claims nothing either way. realProbeEnv moved to home_local_fallback.go: home.go went 13 lines over its file budget, and the probe is now mostly a decision about WHICH fallback to take, so it reads better beside them than beside the renderer. Six mutations, each with its anchor asserted and each reddening an assertion rather than the compiler: collapse the empty client anchor; let doctor green a stale pointer; drop doctor's stale-pointer note; stop marking the fallback's result stale; let a stale pointer render Online; let another client's not-online harden into a verdict. TestDoctor_HealthyPointer_StillGreen is the control — without it, "never says Everything looks good" would pass vacuously. Refs cli#515 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Bugbot round 1 — 2 findings, both real, both fixed in 63364ffReplies are on the threads; the short version, because both were the same mistake at two levels:
High. Finding the environment was only half the job:
Medium. Deliberately not done: repointing automatically. Writing Also in this commit: Six more mutations, same discipline as the table above — anchor asserted, build+vet required to still pass so the compiler can't stand in for an assertion, then RED:
|
Rendering the previous commit showed the fix was half done: the closing verdict
was honest, but the line above it still read
✔ Connected to tracebloc
✔ Ready to run training
⚠ Your active client points at namespace "stale-ns" …
— a green tick and, directly beneath it, a warning saying the opposite. That is
the same unearned success the finding was about, moved up the screen.
`Ready to run training` is false whenever the pointer is stale, however green
the cluster checks are, because every data command binds the pointer. So the
readiness healthLine is replaced rather than accompanied, and it carries the
remedy, so the finding and the fix read as one thing:
✔ Connected to tracebloc
✖ Not ready — your active client points at namespace "stale-ns", which
isn't on this cluster, so data commands will keep failing until you
repoint.
Point this machine at the environment above: tracebloc client create
(this cluster already runs a client, so it adopts it — no new credential)
Phrased "Not ready — …" to match the three readiness failures already in the
catalog. `--diagnose` records the replaced line, which is what triage needs.
Exit stays 2 via the pointerStale branch, which skips the "email support" nudge
a doctorVerdict fail would add — we just gave a precise one-command fix.
Three more mutations: disable the replacement (green tick returns) → red;
drop the remedy → red; stop naming the stale namespace → red. The
already-added TestDoctor_HealthyPointer_StillGreen now also asserts the green
tick IS present when nothing is stale, so "no green tick" can't pass by the
line disappearing entirely.
Refs cli#515
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Bugbot round 2, two Mediums, and the same class a third time: a sentence asserting something the code never established. `client list` set the mismatch hint from the ACTIVE row alone, so with the pointer elsewhere and nothing confirmed on this cluster it still said "point this machine at the client that IS there: … client create". There may be no client there — and on a cluster with none, `client create` falls through to the MINT path and produces the orphaned phantom backend#970 exists to prevent. So this PR's own advice could manufacture the bug the command was hidden for. The repoint is now offered only when some row is resHere — that is what earns the phrase "the client that IS there". Otherwise the mismatch is still reported, without a target: "no client here is confirmed. Check your kubeconfig context, then run: … doctor". Deliberately covers BOTH remaining cases, because they are equally unnameable — no client here at all, and clients that might be here but carry no anchor to prove it (resUnknown). The home screen had the label version of the same thing: with a stale pointer, `env.name` was still overridden by the remembered handle, so the client the pointer names was printed as the environment running here — a client that is by construction NOT what the fallback found, and a name contradicting doctor's for the identical state. The override is now skipped when the pointer is stale, so the screen falls through to the probe's own name for the release that is actually running. Three mutations: let the repoint hint fire without anyHere → red; source anyHere from the active row instead of residency → red; restore the unconditional remembered-name override → red. Both fixes carry a control assertion in the same test (the repoint IS offered when a row is here; the remembered name IS still preferred when the pointer is fresh), so neither can pass by the behaviour disappearing altogether. N10's first attempt left `anyHere` unused and reddened the compiler; rewritten to keep it used and re-run. Refs cli#515 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Bugbot round 2 — 2 more Mediums, both valid, both fixed in 60c6d54Round 1's two threads were auto-resolved by Bugbot on the fix. These two are the same class a third time: a sentence asserting something the code never established.
Home labelled the environment with the stale client's handle — blocking the Online state while leaving the label wrong fixed only half of it. The remembered-name override is now skipped when Three more mutations (N10b, N11, N12), each with a control assertion in the same test so neither fix can pass by the behaviour vanishing:
Controls: Running total: 27 mutations. Every one had its anchor asserted to have applied and was required to redden an assertion — six attempts that reddened the compiler or
|
version-bump-gate: v0.10.8 is already released and this PR changes a published path (internal/*), so the train would otherwise cut the next tag from a stale file. 0.10.9 is the same pending version cli#518, #519 and #520 bump to — they all ship under it together, and the identical change merges without conflict. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 60c6d54. Configure here.
Bugbot round 3, High, and correct. The re-probe adopted on
`reachStateOf(retry) != doctor.ReachNoEnv`, and ReachState has four members:
ReachUnreachable and ReachError also satisfy that. Both mean "we could not
tell". So a stale pointer plus RBAC on the context namespace, or a transient
read failure, would have:
• named an unconfirmed namespace as `Secure environment "…"`,
• set pointerStale and printed "this cluster already runs a client, so it
adopts it — no new credential",
• and sent the user to `client create` on a cluster that may host nothing,
where it does not adopt but MINTS — the backend#970 phantom.
Which is the exact absence-as-presence collapse surveyCluster's `looked` and
residencyOf's resUnknown exist to prevent, made twice more in the same PR.
Adoption now requires a positive confirmation, via reachConfirmedOK(). It is
deliberately NOT `reachStateOf(results) == ReachOK`: reachStateOf defaults to
ReachOK when the check is ABSENT, which is the right lenient default on the main
path and precisely the wrong one here, where the whole question is whether an
unproven namespace may be believed. Absent, unreachable and errored all answer
"could not tell", and none may authorize naming an environment or advising a
repoint.
The test derives its input domain from doctor.ReachState's declared surface —
every non-OK member, plus the absent case — rather than picking the states that
came to mind: mutation coverage cannot see a vocabulary gap, so a future member
has to be added to the enum's own list to escape it.
Three mutations: restore `!= ReachNoEnv` → three subtests red; make an absent
check count as confirmed → red; let ReachError confirm → red.
Refs cli#515
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Bugbot round 3 — 1 High, valid, fixed in c37086a
ReachOK ReachUnreachable ReachNoEnv ReachError
That is the third instance of one mistake on this PR ( Fixed with The new test derives its input domain from the enum's declared surface (every non-OK member, plus absent) rather than the states that came to mind — per the house rule that mutation coverage can't see a vocabulary gap, which is precisely what this finding was.
Control: Running total: 30 mutations, each anchor-asserted and each required to redden an assertion rather than the compiler or |
Org standard: "A finding that recurs across PRs becomes a rule: add it to
.cursor/BUGBOT.md". This one recurred three times inside a SINGLE PR — a failed
scan read as "nothing is here", an empty legacy cluster_id read as "runs
elsewhere", and `!= ReachNoEnv` read as "an environment is here" — each found by
Bugbot only after the previous was fixed. Three instances of one root cause is
past the threshold.
BUGBOT.md already had the neighbouring rule, but scoped to the value a function
RETURNS ("prefer a three-valued return"). Every instance here got the return
type right and then collapsed it at the `if` that consumed it, so the existing
bullet didn't catch any of them. The new bullet is about the branch, and names
the two concrete shapes rather than restating the principle:
• a negated comparison against ONE member of a multi-valued enum, which
silently absorbs every member added later — with the corollary that the
test's input domain must come from the enum's declared surface, since
mutation coverage cannot see a vocabulary gap;
• a lenient "not found" default reused where the question is "may I believe
this?" — reachStateOf returning ReachOK for an ABSENT check is right for a
verdict roll-up and wrong for authorising a claim, which is why
reachConfirmedOK exists beside it.
It closes with the customer-visible cost, per this file's own Tone section: each
instance ended in advice to run `client create` on a cluster nothing was
confirmed on, where it mints instead of adopting — the guidance manufacturing
the orphaned phantom backend#970 is about.
Refs cli#515
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Also added the recurring finding to The file already carried the neighbouring rule, but scoped to the value a function returns ("prefer a three-valued return"). All three instances here got the return type right and then collapsed it at the |
version-bump-gate fails any PR touching a published path while the current VERSION names a released tag, and its publish glob is `internal/*` — which matches internal/cli/copy_catalog_test.go even though a _test.go file ships nothing. 0.10.9 is being cut regardless (cli#518, #519, #520 and #521 all bump to it), so this change genuinely rides under that version; the identical one-line edit merges without conflict. Preferred over the skip-version-gate override: the label is for a false positive nobody should have to reason about later, and the honest statement here is that this is part of 0.10.9. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
saqlainsyed007
left a comment
There was a problem hiding this comment.
Approve — correctness review, focused on the three changes in #519.
What this does
Turns a wrong active-client pointer from a dead end into a recoverable state, without changing what any command targets:
explaindiagnoses before advising — a naming-onlysurveyClusterfeedsrepointMessage, branched on what's actually on the reached cluster (local single →client createadopt; remote/multi →--namespaceonly; empty → installer; couldn't-look → the byte-for-byte pre-#515 sentence).allowScan()staysfalse, so this changes the message, never the target.doctor/homeextend #401's local fallback to a wrong (not just empty) pointer, gated onisLocalServerURL+binding.appliedand adopted only on a positivereachConfirmedOK.client createis unhidden (with its mint guards intact and now tested);client listsplits selection from residency via a three-valuedresidencyOf.
Correctness verification
- All 5 Bugbot findings (3 rounds) are fixed in the head and I re-checked each against the current diff:
reachConfirmedOKrequires== ReachOK(not!= ReachNoEnv, which would sweep inReachUnreachable/ReachError);residencyOfkeeps an empty clientcluster_idatresUnknown; theclient listrepoint hint requiresanyHereso it can't push a mint;homeblocks the Online state, the stale display label, andconfirmedNotOnline; and doctor's closing verdict fix (43a4b07) is present. - The absence-vs-presence discipline is consistent across all three sites (
clientSurvey.looked,residency,reachConfirmedOK) — no lenient default leaks into a claim-authorising branch. FindClientNamespacessorts, so the multi-namespace message and the--namespace <first>suggestion are deterministic.localEnvFallbackonly ever returnslocalNoRelease/localLive/localDegraded, sopointerStale = ep.local != localNoReleasecorrectly excludes the no-release case.- doctor's re-probe reuses the original clientset against the kubeconfig's own namespace; since
localEnvNamespacereloads the same Path/Context, itsisLocalServerURLgate applies to the same cluster the probe hits — the ownership guarantee holds. - The
--namespace/--contextexplicit-override paths stay un-re-probed (binding not applied), and the remote/shared gate is exercised on bothdoctorandhome.
Non-blocking observations
- Test coverage is unusually strong — the mutation table plus per-branch text pins are exactly what this class of message-vs-target bug needs.
- CI is fully green (Test, Lint, golangci-lint, govulncheck, all builds, Bugbot).
No correctness issues found on my pass. Nice work on the three-valued discipline and the fail-closed survey.
…e window (#517) (#521) * fix(auth): a transient poll failure retries; the expiry copy names the window cli#517. The device-poll loop's `default:` branch was terminal, so anything that was not one of the four RFC 8628 sentinels ended the sign-in — a DNS blip, a backend restart, a proxy 502. Inside a ten-minute human-paced window that is a long exposure, and under the installer it threw away a run that had already built a cluster. The default is inverted: unknown failures retry, and every terminal state is now enumerated in classifyPollError — the four sentinels, a 426 version floor, a cancelled context, and any *APIError that is not 5xx / 408 / 429. So a server's refusal still stops on the first poll; only failures that never reached a verdict are ridden out. Retries are bounded by maxPollFailures consecutive failures (reset by any answer), so an unreachable backend reports itself instead of burning the code's window and then blaming the user. Also from #517: • the expiry message names the window ("sign-in codes are valid for 10 minutes"), derived from the server's expires_in rather than hardcoded — without it a ten-minute timeout reads as an instant failure; • "Run `tracebloc login` to start a new one" is suppressed when TRACEBLOC_INSTALLER is set. That advice is right for a hand-typed login and wrong under the installer, which prints its own next step; the two used to contradict each other on screen. • a Ctrl-C landing mid-request now exits quietly, like one landing between polls, instead of reporting the operator's interrupt as a sign-in failure. Every message stays a literal argument of errors.New / fmt.Errorf so the copy catalog's AST harvest can still see it; TestCopyCatalogSeesTheSignInStrings pins that, because composing copy inside a helper drops it from the catalog silently. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore(release): VERSION 0.10.8 -> 0.10.9 version-bump-gate: v0.10.8 is already released and this PR changes a published path (internal/*), so the train would otherwise cut the next tag from a stale file. 0.10.9 is the same pending version cli#518, #519 and #520 bump to — they all ship under it together, and the identical change merges without conflict. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
…104 invisible) (#522) * fix(test): the copy catalog skipped every message written as a join harvestMessages type-asserted arguments straight to *ast.BasicLit, so a message split across source lines — fmt.Errorf("unknown backend environment %q — valid values are … "+ "set CLIENT_ENV or pass --env", env) — is an *ast.BinaryExpr and was skipped ENTIRELY. Not the second half: the whole message. This file's own header calls the golden "the completeness backstop", and it passed forever while a whole syntactic class of copy was invisible to it. 104 previously-unseen messages, 0 removed. They are not marginal — they are the long validation errors that tell a user how to fix their data: the BOM in an Excel "CSV UTF-8" export, non-UTF-8 CSVs, masks that don't match the image resolution, labels.csv rows referencing absent images, symlinks in the dataset tree. The copy most worth guarding against drift was the copy the guard could not see. literalString folds ADD chains of literals (and parenthesised ones), refusing any join with a non-literal operand. That refusal is the load-bearing half: emitting the literal fragments of a part-computed message would put a sentence in the catalog that no user ever sees, and mark it inventoried while the real text drifts. Absent is honest; half is not. Proven in BOTH directions on the same mutation — breaking the reported message in auth.go: with the fix TestCopyCatalog FAILS without the fix TestCopyCatalog passes <- the guard could not see it TestLiteralString pins the fold with inputs written down independently of the matcher, so a typo in one cannot plant itself in the other; reverting the fold reddens 5 of its cases. TestHarvestMessages_SeesConcatenatedCopy pins the reported defect itself. Found while doing cli#517 (#521), where new copy composed inside a helper vanished from the catalog the same way; that PR worked around it by keeping every sentence a direct literal argument. This is the underlying scanner gap. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore(version): 0.10.8 -> 0.10.9 version-bump-gate fails any PR touching a published path while the current VERSION names a released tag, and its publish glob is `internal/*` — which matches internal/cli/copy_catalog_test.go even though a _test.go file ships nothing. 0.10.9 is being cut regardless (cli#518, #519, #520 and #521 all bump to it), so this change genuinely rides under that version; the identical one-line edit merges without conflict. Preferred over the skip-version-gate override: the label is for a false positive nobody should have to reason about later, and the honest statement here is that this is part of 0.10.9. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>

Closes #515.
Summary
A wrong active-client pointer had no supported recovery, and the two commands a
stuck user reaches for next told them to reinstall over a healthy environment.
Three changes, in the order the issue lays them out.
1. Diagnose before advising (
clustertarget.go)The shipped §7.3 sentence is RFC-0001's with the third clause deleted: it names
--namespacebut never says which namespace, and nothing else in the CLI willtell you.
explainnow spends one naming-onlycluster.FindClientNamespaces—the same read
discoverReleasealready spends purely to write a better message —and branches on the existing
isLocalServerURLpredicate.What the user sees, in each branch:
One client + local server URL:
Client(s) on a remote/shared cluster —
--namespaceonly, neverclient create:(several →
in namespaces: alpha, beta.+Target one just this once: --namespace alpha. More than one client is the--namespacebranch even on a local cluster — "point this machine at it" has no unambiguous "it".)None found, scan clean:
Could not look — no probe, or the cluster-wide list failed (RBAC, timeout,
unreachable API) — the pre-#515 sentence, byte for byte. That fourth branch is
the point of the three-valued
clientSurvey: an absence of evidence must neverprint as evidence of absence, or we'd tell a user with a working client the
opposite of the truth.
allowScan()is untouched and stillfalsefor an applied binding. Thischanges what the CLI says, never what it targets.
TestActiveClientBinding_AllowScanandTestDiscoverRelease_NoScanWhenExplicitpass unmodified, and a new test pins both halves at once — the discovered
namespace appears in the message and nowhere else.
2. Extend #401's local fallback to
binding.appliedmisses (doctor.go,home.go)ErrNoParentReleasebranch returnslocalEnvFallback(ctx)instead of a bare
localNoRelease. Every failure inside the fallback degradesto
localNoRelease, so this branch's old return value is still its floor.ReachNoEnvresult that a binding (not the user) aimed,re-probe the namespace the kubeconfig itself selects, via a new
localEnvNamespace.The ownership gate is unchanged and is what makes this safe: both adopt only when
isLocalServerURLsays the server is this machine. On a remote/shared cluster thehonest no-environment answer stands (§7.5).
No scan is spent, and it still finds the install — the installer points the
kubeconfig context at the client's namespace
(
client/scripts/lib/install-client-helm.sh:657,kubectl config set-context --current --namespace <ns>), so reading the context is enough. doctor keeps theoriginal results unless the re-probe actually finds something, so a bare machine
still gets the installer advice and
--diagnosestill describes the namespace theuser is configured for.
3. Unhide
client create;client listmarks the local cluster (client.go)Hidden: truewas set because a standalone run on a cluster with no client mintsa phantom (backend#970). That risk is real and unchanged — but hiding was never
what prevented it. The two guards that do are untouched, and now have tests
naming them: the TTY review + confirm, and the off-TTY refusal without
--yes/--credential-file. The repoint itself never reaches the prompt (adoptionhappens first), so it stays prompt-free and mints nothing.
client liststays hidden.client listlabelled the active pointer(active — this machine)without everchecking where that client runs. Selection and residency are now separate facts,
keyed on the §7.2 cluster anchor, and a mismatch names the repoint. An unreadable
anchor is a third state: no row claims to be here and none is denied — the marker
degrades to bare
(active). The installer's #303 pre-flight is unaffected (markerslive in the row label; the greppable
namespace=<ns>field is untouched, andclient_list_contract_test.gostill passes).Not in scope
The two RFC-0001 §7.5 mitigations that were never implemented (drop the pointer on
account switch; cheap re-validation per command) would have prevented this state
rather than explained it, and the upstream cause — orphaned client records from
cluster recreation — is tracked separately. This PR makes the state recoverable.
One correction to the issue's design
The issue says all seven
explaincall sites already hold a clientset and serverURL. Six do not:
resolveClusterTargetbuilds the clientset internally and returnsnilon its error path. So the probe travels onnoParentReleaseError(attachedat both construction sites, which do hold both) rather than through
explain'ssignature — which also makes it impossible for a caller to hand
explainaclientset for a different cluster than the one that missed.
Test plan
make checkandmake check-allgreen;go test ./...green. Golden filesregenerated and the diff reviewed line by line (only
create's help entry and thenew strings).
Mutation evidence — 15 mutations, each with the anchor asserted to have applied,
each reddening an assertion:
surveyClusteralways returns "didn't look"TestExplain_BindingMiss_…looked: trueTestSurveyCluster_FailsClosed/scan_forbiddenclient createbranch…/remote_cluster_never_suggests_client_createTestDoctor_WrongPointerOnLocalCluster_…,…LocalClusterWithNothing…--namespaceTestDoctor_ExplicitNamespaceMiss_IsNotReprobedlocalEnvNamespacedrops the local-cluster gateTestLocalEnvNamespace/remote_server_is_refused,TestDoctor_WrongPointerOnRemoteCluster_StaysGatedlocalNoReleasereturnTestRealProbeEnv_WrongPointerOnLocalCluster_FallsBacklocalEnvFallbackadopts a remote clusterTestRealProbeEnv_WrongPointerOnRemoteCluster_StaysGatedclient createback toHidden: trueTestClientSubcommandVisibilityTestClientCreate_UnhiddenStillRefusesSilentMintTestClientListMarker,TestClientList_UnreadableAnchorClaimsNoLocationclient listmarks the active row regardless of residency (today's bug)TestClientList_MarksTheClientOnThisCluster…/clean_scan_finding_nothing_points_at_the_installer…/one_client_on_a_local_cluster_offers_the_repoint…/several_clients_name_them_all_and_offer_only_--namespaceControl: mutating
allowScan()to returntruefor an applied binding reddensTestActiveClientBinding_AllowScan/active-client_binding_appliedand the newno-retarget test — the rule this PR must not have changed is still guarded.
Three earlier attempts (M5, M10, M13, M14 first pass) reddened the compiler
(unused variable / unused import) or
go vet's Printf check rather than anassertion. Those prove nothing about coverage, so they were rewritten to keep every
identifier used and the verb count intact and re-run; the table lists only the
valid runs.
🤖 Generated with Claude Code
Note
Medium Risk
Touches exit-4 messaging, doctor exit 2 verdicts, and user-visible
client create; behavior is heavily tested but wrong survey/re-probe logic could still mis-advise repoint vs mint on edge cases (RBAC, legacy emptycluster_id).Overview
Fixes cli#515: when the local active-client pointer names a namespace that isn’t on the cluster the kubeconfig reaches, users previously got generic “runs elsewhere” / reinstall advice with no supported way to repoint. This PR makes that state recoverable without changing what commands target (
allowScan()stays false on binding misses).§7.3 errors now diagnose before advising (
clustertarget.go): on active-client binding misses,explainruns a bounded naming-only scan (surveyCluster/repointMessage) and branches on what’s actually on the reached cluster—local single client → visibleclient create(adopt); remote/shared →--namespaceonly; empty cluster → installer; scan failed → pre-#515 message unchanged. AclusterProberides onnoParentReleaseErrorso the scan uses the same cluster that missed.client createis user-visible again with unchanged mint guards (TTY confirm / non-interactive--yesor--credential-file).client listseparates selection vs residency via three-valuedresidencyOf(unknown anchor ≠ “elsewhere”) and only suggestsclient createwhen a client is confirmed on this cluster.Doctor and home extend the #401 local-only fallback to wrong pointers: re-probe the kubeconfig’s namespace on loopback via
localEnvNamespace, adopt only onreachConfirmedOK(not!= ReachNoEnv). Stale pointer → exit 2, “Not ready” line, andclient createremedy—not green “ready to train.” Home’srealProbeEnvuses the same fallback on pointer miss and ignores heartbeat whenpointerStale.Docs/navigation, golden strings, VERSION 0.10.9, and BUGBOT.md guidance on “couldn’t confirm” treated as confirmed are updated; broad test coverage pins message branches and phantom-mint prevention.
Reviewed by Cursor Bugbot for commit aaa00f2. Bugbot is set up for automated code reviews on this repo. Configure here.