fix(dream-cli): Apple GPU output polish + compose wrapper SIGINT/zero-match#1016
fix(dream-cli): Apple GPU output polish + compose wrapper SIGINT/zero-match#1016yasinBursali wants to merge 3 commits intoLight-Heart-Labs:mainfrom
Conversation
|
Re-marking as draft as a mechanical merge-order safeguard. This branch contains commits Merge order: #999 first, then this PR rebases clean and gets re-marked ready. |
|
Audit follow-up: keep draft / rescope after the split fixes. The focused foundations this overlapped with are now merged (#1006, #1007, #1008, #1023). Please rebase on current |
…date The four commands that shell out to `docker compose` (restart, start, stop, update) previously let the raw per-container-state-transition output pass through with no summary and no visible error banner. A failure like "dream-llama-ready is unhealthy" was one line buried in 40+ lines of state transitions. Introduce `_compose_run_with_summary` that runs compose with `--progress quiet`, captures stdout+stderr to a mktemp log, and either prints a "<verb> — done" success line or a red "<verb> failed:" banner that surfaces up to 20 lines matching error|unhealthy|failed|dependency and points the operator at the preserved full log. Wrap all four callers. For `cmd_update`, keep the existing `if ! …; error` guard on both the pull and up-recreate calls so the actionable rollback hint is preserved on top of the surfaced error context. Use `cmd || rc=\$?` to capture the compose exit code (safe under `set -e` and not reliant on `\$?` after `if…fi`, which is spec'd to 0 on the not-taken branch). The grep | sed | head pipeline is safe under `set -e` without pipefail — this branch does not have pipefail, so no SIGPIPE / no-match exit concerns. Platform impact: - macOS / Linux / Windows (WSL2): identical — no platform branching. `docker compose --progress quiet`, `grep -iE`, `sed`, `head`, `mktemp` are all portable.
…ware header cmd_status_json emitted gpu_cores as a JSON string via --arg. Switch to --argjson with integer-or-null detection: numeric gpu_cores become JSON integers, the literal "?" from system_profiler fallback becomes JSON null. dream gpu status header hardcoded "(0 GPUs)" derived from nvidia-smi. Branch on GPU_BACKEND=apple to show "(1 integrated GPU)" instead. Non-apple paths keep the existing behavior. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… fallback Ctrl-C during a compose operation leaked the mktemp log because there was no INT/TERM trap. Add trap 'rm -f "$_compose_log"' INT TERM after mktemp and restore with trap - INT TERM before each return. The grep | sed | head pipeline exit code is 0 even when grep finds no matches (head exits 0 on empty input), so the || warn fallback never fired. Capture the pipeline output to _surfaced and branch on non-empty to decide between printing matches or emitting the "no error keywords matched" hint. Correct under set -e today, pipefail-safe going forward. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4cd57c9 to
0fc56ca
Compare
|
Pushed audit follow-up — rebased onto current The audit said "rescope after the split fixes (#1006, #1007, #1008, #1023)" and "reduce this branch to the remaining unique Apple GPU output polish / compose-wrapper behavior, with the strict-mode fixes preserved from main rather than duplicated." Rebase outcome: the 5 pre-rebase commits collapsed to 3 clean commits on top of current Final 3 commits:
Strict-mode preservation:
Re-marking ready — the audit ask is addressed and the PR no longer depends on #999/#1001 (one merged, one closed). |
All four fixes live in code introduced by unmerged upstream PRs:
fix/dream-cli-apple-silicon-coverage)_compose_run_with_summaryadded by fix(dream-cli): compose summary wrapper for restart/start/stop/update #1001 (fix/dream-cli-compose-summary-wrapper)Once #999 and #1001 both merge, I'll rebase and the PR diff will reduce to just the delta shown below.
What
Four small polish fixes on top of #999 + #1001:
cmd_status_jsonApple branch was emittinggpu_coresas a string viajq --arg. Switch to--argjsonwith integer-or-null detection: numeric values become JSON integers; the fallback literal"?"becomes JSONnull.dream gpu statusheader hardcoded"(${gpu_count} GPUs)"derived fromnvidia-smi --list-gpus. On Apple Silicon this produced"(0 GPUs)"despite the Apple branch below showing valid GPU info. Branch onGPU_BACKEND=appleto show"(1 integrated GPU)"instead._compose_run_with_summarymktemp'd a compose log but had notrapto clean up on SIGINT/SIGTERM. Ctrl-C during compose ops leaked/tmp/tmp.*files. Addtrap 'rm -f "$_compose_log"' INT TERMafter mktemp andtrap - INT TERMbefore each return.grep | sed | head -20 || warnnever triggered the warn fallback whengrepfound zero matches, becausehead -20exits 0 on empty input (the pipeline exit was 0, not 1). Users saw a blank gap between the error banner and the log path. Capture to_surfacedand branch on non-empty — correct underset -etoday AND pipefail-safe going forward.Our delta (post-deps-rebase view)
One file, two commits:
dream-server/dream-cli: +21/-9 lines across the 4 touched regionsTesting
bash -n dream-server/dream-cli— cleanshellcheck dream-server/dream-cli— zero NEW warnings in the deltagpu_countpath ([[ GPU_BACKEND == "apple" ]]short-circuits before$gpu_countis evaluated)Platform Impact
dream gpu statusheader +dream status-jsongpu_cores field type.Known Considerations
Follow-up fork issue worth filing: the SIGINT trap currently only cleans up the log file without exiting. A cleaner idiom (
trap 'rm -f "$_compose_log"; exit 130' INTorEXITtrap) would avoid a downstream log-path-to-deleted-file edge case. Not a regression vs. current behavior (previously no cleanup at all on INT) so out-of-scope for this PR.