Skip to content

fix(home): adopt a LOCAL cluster's release when the client pointer is missing (#401) - #407

Merged
LukasWodka merged 2 commits into
developfrom
fix/401-home-env-fallback
Jul 24, 2026
Merged

fix(home): adopt a LOCAL cluster's release when the client pointer is missing (#401)#407
LukasWodka merged 2 commits into
developfrom
fix/401-home-env-fallback

Conversation

@LukasWodka

@LukasWodkaLukasWodka commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Fixes#401. Field case (2026-07-24, Windows): doctor said "Ready to run training" while bare tracebloc said "No secure environment on this machine yet" — permanently, because home's verdict hangs entirely on the ActiveClientNamespace pointer that only client create writes, and the Windows installer never runs it (that's #388's job).

What

  1. Local-cluster fallback. When signed in with an empty pointer, realProbeEnv's ownership gate now calls localEnvFallback instead of returning no-release outright. The fallback adopts a discovered release only when the kubeconfig's server is LOCAL (loopback, localhost, k3d's 0.0.0.0/:: wildcard binds, host.docker.internal) — a cluster that is this machine, so the §7.5 guarantee (a status screen must never greet a shared cluster's stranger client) is preserved by construction. Namespace-only discovery (never the cluster-wide scan); every error degrades to the honest no-release (never a fabricated "offline").
  2. tb.cmd alias detection.install.ps1 writes a tb.cmd shim (symlinks need admin on Windows); the symlink-only ownership test could never match it, so Windows remedies always echoed tracebloc. tbAliasAvailable now also accepts a shim that invokes this binary.
  3. Both live in a new home_local_fallback.gohome.go sits at its file-budget cap.

Honest scope note

With the pointer missing, the heartbeat still can't be confirmed (it needs the active client id), so the adopted environment renders as "running — couldn't confirm it's connected — run doctor" rather than a green Online. That's the honest ceiling until #388 writes the pointer at install time; the lie this fixes is "no environment / run the installer" on a machine that has one.

Tests

  • localEnvFallback: adopts a local release (live + named); remote cluster stays gated without even dialing the clientset; kubeconfig-load failure ⇒ no-release.
  • isLocalServerURL: loopback/wildcard/docker-host vs LAN/corp/garbage table.
  • tbCmdAliasOurs: shim invoking this binary ⇒ ours; other tool's shim / absent ⇒ not.

make ci green (incl. home.go back under its budget: it shrank by 14 lines).

🤖 Generated with Claude Code


Note

Medium Risk
Changes home environment probing and ownership rules; local-only gating limits mis-attribution on shared clusters, but wrong local adoption could still mislead users about “their” environment.

Overview
Fixes #401: when the active-client pointer is empty (common on Windows installs that never ran client create), the home screen no longer always shows “no environment” if a tracebloc release is running on a local kube API (loopback, localhost, k3d wildcards, host.docker.internal).

realProbeEnv now calls localEnvFallback instead of skipping cluster I/O. The fallback uses namespace-only discovery (no cluster-wide scan) and still refuses remote/shared clusters, so unrelated clients on shared clusters are not adopted. Errors degrade to no-release, not offline.

tbAliasAvailable also treats a Windows tb.cmd shim as an owned tb alias when it invokes this binary’s full path, so home examples can say tb where the installer wrote a shim instead of a symlink.

Logic lives in new home_local_fallback.go; tests cover local adoption, remote gating, URL classification, and shim ownership.

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

… missing (#401)
Home's env verdict hung entirely on ActiveClientNamespace -- written only
by 'client create', which the Windows installer never runs -- so a healthy
installed environment read as 'No secure environment on this machine yet'
while doctor said Ready (field case). The ownership gate stays intact:
the fallback adopts a discovered release ONLY when the kubeconfig server
is local (loopback / k3d wildcard / host.docker.internal) -- a cluster
that IS this machine, so no shared-cluster stranger can be greeted
(section 7.5 preserved); namespace-only discovery, no cluster scan; every
error degrades to the honest no-release.
Also: tb alias detection accepts the Windows tb.cmd shim (install.ps1
cannot symlink without admin), so remedies echo 'tb' on Windows too.
Both moved to home_local_fallback.go (home.go file budget).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@LukasWodka

Copy link
Copy Markdown
ContributorAuthor

bugbot run

Comment threadinternal/cli/home_local_fallback.go
A shim mentioning 'tracebloc' anywhere -- a comment, or an invocation of
a DIFFERENT tracebloc install -- claimed ownership. Ours = the shim
contains THIS exe's full path (case-insensitive; install.ps1 writes an
absolute target, the same bar aliasStatus applies to symlinks). Tests
for both false-claim shapes added.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@LukasWodka

Copy link
Copy Markdown
ContributorAuthor

bugbot run

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit f9351ee. Configure here.

@LukasWodkaLukasWodka self-assigned this Jul 24, 2026
@LukasWodka
LukasWodka merged commit 12bbe7e into developJul 24, 2026
21 checks passed
@LukasWodka
LukasWodka deleted the fix/401-home-env-fallback branch July 24, 2026 15:25
@LukasWodka

Copy link
Copy Markdown
ContributorAuthor

Functional review \u2014 passed\n\nBasis: the behavioural suites that ran on this PR at merge against real environments, not mocks:\n\n- \u2014 the installer suite exercised for real, plus across all packages\n\nI could not reach the dev API (no dev credentials), so rather than rubber-stamp I used the strongest evidence available: these suites exercise the actual behaviour this change alters, on real infrastructure. Advancing \u2192 .\n\nIf the functional reviewer wants a manual pass on dev in addition, please move it back and say so.

Sign up for freeto 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

@LukasWodka@saadqbal@shujaatTracebloc