Skip to content

fix(installer): memory truth — machine RAM vs Docker's budget, advice clamped (bash half of #417) - #445

Open
LukasWodka wants to merge 2 commits into
developfrom
fix/417-memory-truth-bash
Open

fix(installer): memory truth — machine RAM vs Docker's budget, advice clamped (bash half of #417)#445
LukasWodka wants to merge 2 commits into
developfrom
fix/417-memory-truth-bash

Conversation

@LukasWodka

@LukasWodka LukasWodka commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Bash half of #417 (Windows half: #444) — same three bugs, same design:

  1. Flip-flop: _pf_total_mem_kb preferred docker info MemTotal — the code's own test even called it "the Mac trap" — so a Mac reported 16 GB (host) cold and 6 GB (Docker VM) warm.
  2. Unachievable advice: remediation used the raw PF_REC_MEM_GB=16 regardless of the machine.
  3. Diverging copy: the preflight warning and the post-Docker _pf_recheck_runtime_mem warning disagreed, and both could fire in one run.

Change

  • _pf_memory gates on the machine (native Linux: daemon sees all host RAM → hard-fail gate unchanged; the 64 MiB grace and the Linux MemAvailable check are preserved) and prints Memory: N GB (machine); a second Docker's memory budget: N GB line appears only when a runtime is up with a meaningfully smaller budget (the VM case) — never as a duplicate on native Linux.
  • _pf_mem_targets clamps budget advice to host − 2 GB (floor 4); macOS hint covers both Docker Desktop and colima. Hardware statements stay unclamped.
  • _pf_runtime_mem_status is the single shared copy (preflight + recheck) with a PF_RUNTIME_MEM_WARNED latch.
  • _pf_hw_summary_line now reports host RAM (it had the same flip-flop in miniature).
  • The _pf_total_mem_kb selector and its trap-codifying tests are deleted; 6 new tests cover the clamp matrix, the two-line output, the Linux no-duplicate case, the latch, and the summary line.
  • manifest.sha256 regenerated.

Labels, clamp math, and latch semantics mirror #444 exactly — a ready-made row for the #435 facts spec.

Stacked on #441 (both touch preflight.sh); merge #441 first. Same local-macOS test-flake note as #442 applies (3 pre-existing, ubuntu CI is the arbiter).

Type

Bug fix

Test plan

preflight.bats fully green including 6 new tests; full bats suite green except the 3 documented pre-existing local-macOS failures; bash -n + shellcheck --severity=error clean; copy catalog unchanged; gen-manifest.sh --check clean.

🤖 Generated with Claude Code


Note

Low Risk
Installer preflight messaging and test-only changes; Linux hard-fail gates and existing grace/MemAvailable behavior are preserved.

Overview
Fixes installer preflight memory reporting and advice (#417): host RAM vs Docker’s cgroup/VM budget are no longer conflated, and remediation no longer tells users to allocate more RAM than the machine has.

_pf_memory gates on machine RAM (Memory: N GB (machine)), with a second Docker's memory budget line only when Docker is up and its budget is meaningfully smaller (macOS/colima/WSL). Native Linux no longer duplicates the same number. The old _pf_total_mem_kb selector (runtime-over-host “Mac trap”) is removed.

_pf_mem_targets clamps warn/rec Docker budget advice to host − 2 GB, floored at PF_MIN_MEM_GB so hints never say “give Docker 4 GB” when the client needs 5 GB (#445). _pf_runtime_mem_status is the single shared warning/hint path for preflight and _pf_recheck_runtime_mem, with PF_RUNTIME_MEM_WARNED preventing double warnings; Linux hints avoid Docker Desktop (#445).

_pf_hw_summary_line uses host RAM so the collapsed hardware line doesn’t flip to the VM budget. Bats stubs switch to _pf_host_mem_kb; old selector tests are dropped and six memory truth tests are added. manifest.sha256 updated for preflight.sh.

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

@LukasWodka
LukasWodka requested a review from saadqbal as a code owner July 27, 2026 14:44
@LukasWodka LukasWodka self-assigned this Jul 27, 2026
@LukasWodka

Copy link
Copy Markdown
Contributor Author

bugbot run

Comment thread scripts/lib/preflight.sh
@LukasWodka

Copy link
Copy Markdown
Contributor Author

Converted to draft to disable the merge button while the base is a feature branch (the #438-#440 mis-merge trap). Plan: once #441 merges to develop, rebase this onto develop, retarget, regen manifest.sha256, re-run bats, flip ready.

… lines; advice clamped (#417, bash half)

The single 'Memory:' line preferred docker info MemTotal over host RAM
(_pf_total_mem_kb, 'the Mac trap'), so the same Mac reported 16 GB
(host) on a cold run and 6 GB (Docker VM) on a warm re-run — and the
remediation could recommend raising the VM past what the machine has.

- _pf_memory gates on the MACHINE (on native Linux the daemon sees all
  host RAM, so the hard-fail gate is unchanged) and prints 'Memory:
  N GB (machine)'; when a runtime is up with a meaningfully smaller
  budget (macOS Docker Desktop / colima) it prints a second line,
  'Docker's memory budget: N GB', with advice clamped to host - 2 GB
  via the new _pf_mem_targets (floor 4). Hardware statements stay
  unclamped — they describe the machine, not a setting.
- _pf_runtime_mem_status is the ONE copy for the budget line, shared
  with _pf_recheck_runtime_mem (the copies used to diverge), and a
  PF_RUNTIME_MEM_WARNED latch stops one run warning twice.
- _pf_hw_summary_line now summarizes host RAM, not the VM budget —
  the same flip-flop in miniature.
- The runtime-preferring _pf_total_mem_kb selector is deleted, along
  with the tests that codified the trap.

Bash half of #417 (Windows half: the fix/417-memory-truth-ps branch);
labels, clamp math, and latch semantics mirror the PowerShell side.

Closes #417

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@LukasWodka
LukasWodka force-pushed the fix/417-memory-truth-bash branch from 35a5930 to 22426ed Compare July 27, 2026 15:35
@LukasWodka
LukasWodka changed the base branch from fix/432-nfs-guard-order to develop July 27, 2026 15:35
@LukasWodka

Copy link
Copy Markdown
Contributor Author

Rebased onto develop as a single clean commit (#441's content is already in via its squash). Manifest regenerated; preflight+common bats green locally (modulo the known macOS-only flake). bugbot run

Comment thread scripts/lib/preflight.sh
Comment thread scripts/lib/preflight.sh
…p hint on Linux (Bugbot #445)

1. _pf_mem_targets floored budget advice at 4 GB while the status line
   says the client needs PF_MIN_MEM_GB (5) — on 5-6 GB machines the
   operator was told 'below the 5 GB the client needs' and 'Give Docker
   4 GB' in the same breath. The floor is now PF_MIN_MEM_GB.

2. The non-Darwin remediation said 'Docker Desktop -> Settings' — a
   dead end on headless/engine-only Linux, where a low budget is the
   machine's RAM or a VM/cgroup limit. Linux now gets that guidance.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@LukasWodka

Copy link
Copy Markdown
Contributor Author

bugbot run

1 similar comment
@LukasWodka

Copy link
Copy Markdown
Contributor Author

bugbot run

LukasWodka added a commit that referenced this pull request Jul 27, 2026
…gbot #444)

Get-PfMemTargets used Max(4, host-2): on <=6 GB hosts it paired 'below
the 5 GB the client needs' with 'give Docker 4 GB' (advice that can
never clear the warning), and on <=4 GB hosts the floor exceeded the
machine. The floor is now PF_MIN_MEM_GB (5, env-overridable) — the
exact twin of the bash fix on #445.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@cursor cursor Bot 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 581f804. Configure here.

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.

1 participant