From de3dc1c66f0e82990de6fd3eb2a40cdf053dcc7c Mon Sep 17 00:00:00 2001 From: scuttletoby <123843277+scuttletoby@users.noreply.github.com> Date: Sun, 22 Nov 2026 11:04:12 +0000 Subject: [PATCH 1/3] heavy: count a reservation's work once; machine tier without a user manager; ~/.local checks (#771, #844, #923) - #923: a reservation's owed part is the learned debt of the pieces working in its folder, added to its use, so free counts it once. t3-capacity shows holding without the owed part. - #844: with cgroup v2 and user.slice but no manager of this user's, facts answer at the new machine tier from machine-wide numbers instead of always NOT OK. The answer cache falls back to a private 0700 folder under the temp root when /run/user/ is missing. - #771: heavy and the sweep refuse a ~/.local others can write; HOME is resolved before it is checked; README repair line covers ~/.local; the timeout hygiene check knows more Popen/waitpid forms. Co-Authored-By: Claude Opus 5.5 --- fork-kit/heavy/README.md | 42 +++++--- fork-kit/heavy/bin/heavy | 12 +-- fork-kit/heavy/bin/t3-capacity | 20 +++- fork-kit/heavy/lib/heavy_facts.py | 150 +++++++++++++++++++++-------- fork-kit/heavy/lib/heavy_sweep.py | 34 +++++-- fork-kit/heavy/tests/facts.test.py | 148 +++++++++++++++++++++++++++- fork-kit/heavy/tests/heavy.test.py | 28 +++++- fork-kit/heavy/tests/sweep.test.py | 41 ++++++++ 8 files changed, 398 insertions(+), 77 deletions(-) diff --git a/fork-kit/heavy/README.md b/fork-kit/heavy/README.md index 4d177b59484ab..c07a123c2e562 100644 --- a/fork-kit/heavy/README.md +++ b/fork-kit/heavy/README.md @@ -59,9 +59,10 @@ heavy asks Docker only after a run that labelled a container (`heavy docker-labe `/run/user` is full or a sandbox has a `/run/user` of its own, in `~/.local/state/heavy/labelled/`, which heavy reads too; the home is `$HOME`, else the password database's, and only one this user owns and no one else can write (not `/`), so heavy run as root with a user's `HOME` (`sudo -E heavy ...`) or `HOME=/tmp` uses root's own home -and never makes a root-owned folder in the user's; `~/.local` must be a real folder (not a link) of the user's; -an older heavy run as root with your `HOME` may have left a root-owned `~/.local/state` (heavy then skips it): -`sudo chown -R "$USER:" ~/.local/state` gives it back; +and never makes a root-owned folder in the user's; `~/.local` must be a real folder (not a link, even to a folder +of the user's: kept fail-closed) of the user's that no one else can write; an older heavy run as root with your +`HOME` may have left a root-owned `~/.local` or `~/.local/state` (heavy then skips it): +`sudo chown "$USER:" ~/.local && sudo chown -R "$USER:" ~/.local/state` gives them back; heavy tells `docker-label` which folders it reads in `HEAVY_MARKS`; without either folder heavy asks after every run), so a run with no containers costs no `docker ps`. No Docker, or none this user can reach (a rootless Docker through `docker context use` counts as reachable): nothing to do, nothing said. Docker down: one @@ -543,9 +544,12 @@ after another, up to the group's ceiling), the memory budget, the queue and note - **--kind K:** does the rule admit one piece of K (`agent-writer`, `job-build`, or heavy's own `build`). **--mb MB** alone: do MB fit the free budget at level "ok"; with --kind, the piece declares MB. - **T3 down or not installed:** no agent scopes, still an answer from the kernel. -- **Tiers:** full with cgroup v2 and a systemd user manager. Without them (Basic) agents and other users' work - cannot be counted, so the answer is never free and every `fits` is 0 (a note says why). An other user's folder - that exists but cannot be listed is Basic too. +- **Tiers:** full with cgroup v2 and a systemd user manager. Machine with cgroup v2 and `user.slice` but no user + manager of the caller's (a CI runner's user without lingering or a login session): it has no agents or heavy + jobs of its own, every user's are counted as usual, so it gets the answer a caller with a user manager gets + (`tier: "machine"`, a note, and the reason says "machine-wide numbers"). Without cgroup v2, or without both a user + manager and `user.slice` (Basic), agents and other users' work cannot be counted, so the answer is never free and + every `fits` is 0 (a note says why). An other user's folder that exists but cannot be listed is Basic too. - **Unreadable signals** (PSI, a box with a live piece but without its `memory.pressure`, or with no folder at all) give "elevated", never "ok"; a missing MemAvailable or a container limit that cannot be read gives busy for every kind. A box with no live piece of its own passes no box pressure (as the server's observer). A piece whose @@ -554,9 +558,11 @@ after another, up to the group's ceiling), the memory budget, the queue and note ` [until=YYYY-MM-DD]`. The folder matches itself and what is below it, with or without a trailing `/`, never a sibling sharing its first letters (`/x/app` is not `/x/app-x`); its real path (links resolved) matches too. A reservation holds back its MB less what this user's processes working in that folder - already use; a caller working inside the folder (its real working folder) is not held back by its own - reservation. Ended, broken or unreadable lines hold nothing and give a note. Limit: another user's reservations - are not seen. + already use, and less what this user's agents and heavy jobs with a process working there still owe the rule + (their cost less their demand, `owedMb`): that room is already held as their debt, so it is counted once (one + idle 300 MB agent under a 1536 MB reservation holds 1536 MB in all, not 1536 + 768 - 300). A caller working + inside the folder (its real working folder) is not held back by its own reservation. Ended, broken or unreadable + lines hold nothing and give a note. Limit: another user's reservations are not seen. - **Holds (machine file):** a cgroup outside the user managers, such as a CI runners' slice, is not in the ledger. `heavy.capacity.holds` names such cgroups; one that uses more than `inUseFromMb` (anon + shmem + swap) keeps its budget (its `memory.max`, or `budgetMb` when it has none) less the RAM it uses (anon + shmem: `memory.max` limits @@ -565,14 +571,16 @@ after another, up to the group's ceiling), the memory budget, the queue and note with a note. Its use cannot be read: the whole budget is held, with a note. A reservation file named like a hold (`