Skip to content

feat(resources): 3-layer view (machine / environment / training) + guided change - #361

Closed
LukasWodka wants to merge 5 commits into
developfrom
fix/resources-redesign
Closed

feat(resources): 3-layer view (machine / environment / training) + guided change#361
LukasWodka wants to merge 5 commits into
developfrom
fix/resources-redesign

Conversation

@LukasWodka

@LukasWodkaLukasWodka commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Fixes#360 · epic backend#1142. Supersedes #359 (the 2-line step) — stacked on it; merge #359 first, or close it and merge this. Concept settled with Lukas over the preceding thread.

What tb resources looks like now (verified on a live k3d cluster)

 Your machine has: 14 CPU · 36 GiB
Your secure environment has: 12 CPU · 23.3 GiB
to give it more, open Docker Desktop → Resources
Each training run may use up to: 2 CPU · 8 GiB
Change how much each training run gets? [y/N] ← on a terminal → guided wizard

Off a terminal: no prompt, a scriptable pointer (tb resources set --cores N --memory NGi) instead.

Three layers

  1. Your machine — the physical host (resources.DetectHost: runtime.NumCPU + OS-specific memory — x/sys on darwin, /proc/meminfo on linux, 0 elsewhere so it degrades to CPU-only). Shown only on a local install (cluster API is loopback); on a remote cluster it's dropped and the environment line reads "(across N nodes)" with a node-pool pointer.
  2. Your secure environment — what the cluster can schedule, with a per-OS/remote pointer to where its size is actually changed (Docker Desktop / node pool / cgroups). Never a dead-end y/N — the CLI can't resize Docker or a node pool.
  3. Each training run — the one dial the CLI owns (cluster-wide per-run ceiling), changed inline via the existing wizard.

Also

  • No banner — the user typed resources.
  • Order CPU · GPU · GiB (compute pair, then memory).
  • Wizard reworded — the cryptic (1–11) [2]How much CPU should each training run get? (now 2 · max 11).
  • resources set stays as the scriptable door.

Cross-compiles on linux/windows/darwin (host-mem build tags); cli + resources + ui tests green (incl. new local-path + host-detection tests).


Note

Low Risk
Changes are CLI presentation, host detection, and interactive flow only; cluster mutation still goes through the existing helm-based resources set path with prior safeguards.

Overview
tracebloc resources is reworked into a three-layer readout: Your machine (physical host via new DetectHost / OS-specific memory probes, only when the API server is local), Your secure environment (schedulable cluster capacity with multi-node suffix and hints for Docker Desktop / node pools), and Each training run may use up to (cluster-wide ceiling). The top banner is removed; output uses new Printer.Stat rows and CPU · GPU · GiB ordering via Machine.Line / perRunSize.

After the show view, interactive terminals get an inline “Change how much each training run gets?” prompt that jumps into the existing resources set wizard; non-TTY runs print a resources set --cores/--memory hint instead.

The set wizard CPU/memory prompts are reworded to show current vs max bounds. Help text and tests are updated for the new labels, local-vs-remote machine line, and isLocalServer detection (loopback + Docker Desktop hosts).

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

LukasWodkaand others added 3 commits July 20, 2026 17:22
… per-run
tb resources used the labels "This machine" (capacity) and "tracebloc uses"
(per training run), which confused: "This machine" is actually the summed
capacity of the environment's Ready nodes (misleading on a remote/multi-node
cluster), and "tracebloc uses" reads like total usage when it's the per-RUN
ceiling. Reframe as two plain aligned lines:
Your secure environment is equipped with: 12 CPU · 23.3 GiB
A training run is allocated up to: 2 CPU · 8 GiB
Do you want to change the allocation? Run `tb resources set` (guided ...).
- New ui.Printer.Stat: aligned label/value for full-sentence labels (Field's
14-col key is too narrow here).
- The trailing hint now resolves the launcher like the home screen
(invokedName + tbAliasAvailable) so it reads `tb ...` on a real install and
`tracebloc ...` otherwise — fixing the tb/tracebloc inconsistency Lukas spotted.
- Value strips the leading "up to " (the label carries it now).
Part of epic tracebloc/backend#1142 / cli#355 (copy consistency).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Bugbot: the Stat value called trainingLine then stripped its 'up to ' prefix —
a round-trip that duplicated perRunSize (resources_set.go), which already
returns the clean 'CPU · mem' ceiling. Use perRunSize directly and delete
trainingLine (its only caller was this stripped one).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ided change
Redesign `tb resources` per the concept settled with Lukas (cli#360):
Your machine has: 14 CPU · 36 GiB
Your secure environment has: 12 CPU · 23.3 GiB
to give it more, open Docker Desktop -> Resources
Each training run may use up to: 2 CPU · 8 GiB
Change how much each training run gets? [y/N] (terminal)
To change: tb resources set --cores N --memory NGi (non-terminal)
- No banner: the user typed `resources`; don't echo tool/rule/"resources" back.
- Three layers. "Your machine" = the physical host (new: resources.DetectHost,
runtime.NumCPU + OS-specific memory via x/sys on darwin, /proc on linux, 0
elsewhere so it degrades to CPU-only). Shown only on a LOCAL install (cluster
API is loopback); dropped on a remote cluster, where the environment line adds
"(across N nodes)" and points at the node pool.
- The environment line carries a per-OS/remote pointer to where its size is
actually changed (Docker Desktop / node pool / cgroups) — never a dead-end
prompt, because the CLI can't resize Docker or a node pool.
- The one dial the CLI owns (the cluster-wide per-run ceiling) is offered inline
on a terminal (-> the existing guided wizard via runResourcesSet), or as a
scriptable pointer off a terminal. `resources set` stays the non-interactive
door.
- Ordering CPU · GPU · GiB (compute pair first, memory last).
- Wizard prompts reworded from the cryptic "(1-11) [2]" to "How much CPU should
each training run get? (now 2 · max 11)".
Verified: real `tb resources` on a live k3d cluster renders the three layers
exactly; cross-compiles on linux/windows/darwin (host-mem build tags); cli +
resources + ui tests green.
Fixes#360. Part of epic tracebloc/backend#1142. Supersedes #359
(the 2-line step) — stacked on it; merge #359 first or close it.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@LukasWodkaLukasWodka self-assigned this Jul 20, 2026
@LukasWodka
LukasWodka requested a review from saadqbalJuly 20, 2026 16:44
@LukasWodka

Copy link
Copy Markdown
ContributorAuthor

@BugBot run

Comment threadinternal/cli/resources.go
Comment threadinternal/cli/resources.go Outdated
Comment threadinternal/cli/resources.go
Comment threadinternal/cli/resources.go Outdated
Comment threadinternal/cli/resources.go
- hostmem_linux.go: check the deferred f.Close() (errcheck Lint gate).
- runResourcesShow: distinguish a prompt cancel (Ctrl-C = exit 0) from a real
Confirm error (now surfaced, not swallowed).
- Count only Ready nodes for the "(across N nodes)" suffix (new
resources.ReadyNodes), matching the set MachineCapacity sums.
- A node-list failure now says "couldn't read its capacity" (it can be RBAC on
a reachable cluster), not "can't reach it".
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@LukasWodka

Copy link
Copy Markdown
ContributorAuthor

@BugBot run

Comment threadinternal/cli/resources.go
Comment threadinternal/cli/resources.go
…without node list
Bugbot: (1) the 'Your machine' line was gated on the node list succeeding, but
DetectHost needs no cluster API — so a reachable local install with an RBAC
node-list failure wrongly hid the host layer. Show it whenever the cluster is
local. (2) Local detection was loopback-only, so Docker Desktop clusters
(kubernetes.docker.internal, NOT loopback) got the remote 'resize your node
pool' text and no machine line. isLoopbackServer -> isLocalServer now also
matches kubernetes.docker.internal / host.docker.internal.
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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3da8004. Configure here.

// Ctrl-C / abort at the prompt is a choice, not a failure (exit 0);
// a genuine prompt error must surface, not be swallowed.
if errors.Is(cerr, errInteractiveCancelled) {
return nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ctrl-C shows no cancel message

Medium Severity

The new inline confirm after resources treats Ctrl-C as a clean exit but prints nothing. Other prompting commands print a visible “Cancelled — nothing was changed.” note at every interrupt site, so users cannot tell whether the flow aborted or succeeded silently.

Fix in CursorFix in Web

Triggered by learned rule: errInteractiveCancelled must produce visible feedback at every prompt site

Reviewed by Cursor Bugbot for commit 3da8004. Configure here.

@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 3da8004. Configure here.

@LukasWodka

Copy link
Copy Markdown
ContributorAuthor

Superseded by #359.

#359 ships the two-line tb resources view (secure-environment total + per-run
training ceiling, with a pointer to resources set) — the agreed spec. It is
clean (all CI green, Bugbot ✔). This 3-layer redesign re-introduced the "Your
machine" line, added an inline "Change how much each training run gets?" prompt
that wasn't in scope, and carried the only live Bugbot finding in the set.
Closing in favor of #359 per Lukas.

The branch fix/resources-redesign is kept, not deleted: its host-detection
work (internal/resources/host.go + the per-OS memory probes) reads the
machine's true capacity and can be grafted into #359 later if we want the
environment line to reflect actual host size rather than allocatable.

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.

1 participant

@LukasWodka