Repository navigation
heavy-install: link t3-capacity to the kit's copy; self-check warns on another (#919) - #922
Conversation
…n another (#919) heavy-install now also links /usr/local/bin/t3-capacity to current/bin/t3-capacity, so the command has one source: the release in use. A plain old file there (a host's own copy) is kept in /usr/local/libexec/heavy/replaced-capacity/ (not replaced/: an older installer's uninstall restores the newest file of replaced/ as heavy) and stays in place until its link replaces it in one rename; uninstall puts it back. A link elsewhere or a folder there is refused before anything is written. heavy --self-check warns when the t3-capacity found on PATH is not this kit's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-replace-t3-capacity A host's installer may write its own t3-capacity to /usr/local/bin and its scripts may read or compare that file, so the installer now leaves such a plain file alone (with a note, and no installed.tsv row for it) unless it is run with --replace-t3-capacity. With nothing there, or the kit's link, it links as before; once linked, later runs keep the link without the option. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
lens: code · reviewer: lens agent (Opus) · read at: 975cdef blocker: none |
…tall deletes - The kept copy moves to /usr/local/libexec/heavy-kept/: every released uninstall (ci/v6 to ci/v22) deletes /usr/local/libexec/heavy and /etc/heavy whole, so a copy kept inside them was lost. This release's uninstall puts it back (also after an older uninstall left the t3-capacity link broken) and then removes the folder. - A link at /usr/local/bin/t3-capacity that the kit did not make is left alone with a note when --replace-t3-capacity is not given (refused with it, as before). - The closing install line repeats that the host still uses its own t3-capacity. - Tests: an older release's install and uninstall (ci/v22, from git) over this state; the same deletes without git; a foreign link; the closing-line warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
lens: code r2 · reviewer: lens agent (Opus) · read at: ca97789 |
…checkout CI's clone has no ci/v22 tag, so the test skips there; fork-ci refuses an undeclared skip (round-2 code lens on #922). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Round-2 review handled:
This was the second lens round, so the PR merges once CI is green. 🤖 Generated with Claude Code |
…SKIP Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What and why
t3-capacitynow has one source: the heavy kit's ownbin/t3-capacity(fork part of #919, steps 1 and 3).heavy-installlinks/usr/local/bin/t3-capacitytocurrent/bin/t3-capacity, the same way it linksheavyandheavy-install. Installing a newer kit now changes whatt3-capacitydoes too, so the two copies can no longer drift apart.--replace-t3-capacity), as the issue's plan says ("unless told"). Without the option, the installer leaves the file alone, prints a note, repeats aWARNINGin its closinginstalled releaseline, and writes noinstalled.tsvrow for it. A link there that the kit did not make is treated the same way without the option (left alone, noted, no row). It is opt-in because a host's installer and CI may read or compare that exact file (see the consumer list below). Replacing it without being asked would break them. Once the link is in place, later runs keep it without the option./usr/local/libexec/heavy-kept/t3-capacity.<sha256[:16]>, stored by hash.uninstallputs it back and then removes that folder. It is kept outside/usr/local/libexec/heavyand/etc/heavy, because every released installer's uninstall (ci/v6 to ci/v22) deletes those two folders whole; and it is not inreplaced/, because those installers restore the newest file ofreplaced/as/usr/local/bin/heavy.--replace-t3-capacity, at3-capacitythat is a link to somewhere else (remove it by hand: there is no file to keep); with or without the option, a folder there.heavy --self-checkwarns when thet3-capacityfound on PATH is not this kit's: either it is missing, or a different copy comes first on PATH (for example a user's own wrapper). The warning does not change the exit code.The release needs no new file:
bin/t3-capacitywas already in the release's source files. The #920 release test passes unchanged (ok release holds what the heavy kit's installer reads).Why the kit's reading differs from an old copy
There are three things a caller can reach today, and they measure different things:
heavy facts):available=is the box's available memory less the hold of the reservation files (~/.config/t3-capacity/reserve.d).reserved=is the room that admitted work may still grow into: each running T3 agent counted as a writer (768 MB start cost minus what it uses now), machine-file holds, plus that same reservation hold again. So the hold is inside both numbers: do not computeavailable − reserved, that subtracts the hold twice.free=is the kit's own answer and is right. The answer is OK only whenfreecovers the request and the level isok.reserved=is only the growth room of other busy budgets (the heavy slice, fork runners, the CI-light slice),0MBwhen they are idle. Instead it checks box memory pressure (PSI), a soft cap, and load above 1.5× the core count.reservations: …(available below is after these), lowersavailable=by their hold, and then runs the plain copy. It still does not count agents.Readings on one machine, each row pair at the same moment, with one 1536 MB reservation holding all 1536 MB. The kit is this branch's
bin/t3-capacityrun from the source folder (A to C: from a test-prefix install), next to the plain copy run directly, and in E also the wrapper:What the readings show:
available=is about 1.5 GB below the plain copy's in every run (1538, 1543, 1515, 1536, 1499 MB): that is the reservation hold, not a different source. Against the wrapper, which also takes the hold off, it is the same within the time between the two reads (E: 4358 vs 4343 MB).reserved=less the hold: about 6 GB). The wrapper was not read at that moment. In A, B, C and E both said NOT OK, for different reasons.Kit line from D:
Plain copy line from D (first line shortened):
Does any number get worse for agents? Yes, it gets stricter (run D): with many agents running, the kit holds back their unused room, so a request the old copy allowed can be refused. In return, the kit does not refuse on load alone, and it does not read the old copy's box pressure or soft-cap checks,
T3_CAPACITY_BOX, or the CI-light slice. The first line also loses the old copy's extra fields (java=,agent-sessions=,heavy-slice=,fork-slice=,box…=). The answer staysexit 0 = OK/exit 1 = NOT OK. A separate double count inside the kit (an agent working under a reserved folder is held both as an agent and by the reservation) is #923, not this PR.Consumer part of #919 (step 2, not in this PR)
What a consumer whose installer writes its own
/usr/local/bin/t3-capacitymust change in its own repo:t3-capacityto/usr/local/bin. Instead, runheavy-install --replace-t3-capacityonce, which keeps the old file in/usr/local/libexec/heavy-kept/and links the kit's, or check that/usr/local/bin/t3-capacityresolves into/usr/local/libexec/heavy/current/. Nevercp,installormvonto the path:cpwrites through the link into the release folder;install/mvof a renamed copy puts a plain copy back.LIGHT=slice line) must read that fact elsewhere, for example from the kit's config or the machine file, because the kit's script has no such line.T3_CAPACITY_BOX, or rely on the CI-light box or load checks, lose those checks. Move the holds into the machine file'sheavy.capacity.holds, or keep a separate check in the consumer.heavy factsor the kit's fields./usr/local/bin) are not affected.State answers
current, so nothing changes. A test snapshots the whole prefix before and after a second run, with and without the option, and with a foreign link left alone.test_every_stop_half_way_then_run_again, with an old t3-capacity and the option). The old command keeps working until the links step, when it is swapped in one rename (a temp link renamed over the path). After the rerun there is exactly one kept copy and the link. Another test makes the t3-capacity swap itself fail: the old command still runs, and the next run finishes the job.WARNINGin the closing line;heavy-kept/and linked;installed.tsvrow;uninstallputs the newest kept copy back only if the path is empty, then removesheavy-kept/(it stays, with a note, if something else is at the path);currentback to a release from before this PR leaves the link pointing at that release'sbin/t3-capacity, which exists in every release;/usr/local/libexec/heavyand/etc/heavywhole, so the kept copy lives outside both and survives. That uninstall does not know the t3-capacity link and leaves it broken (gates then fail with 127); running this release'ssbin/heavy-install uninstallfrom its source folder removes the broken link and puts the copy back (README, Rollback). Tested with ci/v22's own installer, taken from git: install with this branch and the option, ci/v22's install and uninstall on the same prefix, then this uninstall restores the original bytes.Tests
First round, without the change (main's kit plus that round's test file):
Ran 22 tests ... FAILED (failures=16, errors=1). Every new test failed, and so did every step of the stop-half-way test. The 15 tests that already existed passed.Fix round 1 (review comment on 975cdef), each new check run against 975cdef with this round's test file:
test_older_installers_install_and_uninstall_keep_the_hosts_t3_capacity, runs ci/v22's ownheavy-installfromgit archive; it skips with a message in a checkout without the tag, such as CI's shallow clone): at 975cdef (folder name only aliased) it fails withFileNotFoundError: .../usr/local/libexec/heavy/replaced-capacityright after ci/v22's uninstall, i.e. the copy was deleted. Now it passes, and this release's uninstall puts the original bytes back.test_kept_t3_capacity_is_outside_every_folder_an_uninstall_deletes, runs everywhere, CI too): at 975cdefAssertionError: True is not false : /usr/local/libexec/heavy(the kept folder is inside it).test_foreign_t3_capacity_link_is_left_alone_without_the_option): at 975cdef1 != 0 : ... /usr/local/bin/t3-capacity exists and is not the kit's link.test_old_plain_t3_capacity_is_left_alone_without_the_option): at 975cdef"WARNING: /usr/local/bin/t3-capacity is still the host's own, not the kit's (--replace-t3-capacity switches it)" not found in 'heavy-install: installed release aaaa…: slice heavy.slice, grace 30s'.Tests in
fork-kit/heavy/tests/install.test.pyfor this PR:heavy-kept/At the new head, all through
heavy:install.test.py25 OK (the ci/v22 test ran, not skipped)heavy.test.py68 OK (55 skipped on this machine, as before).github/scripts/fork-ci-release.test.py: all passed, 86 okfork-seam-check.cjs --config-ref origin/main origin/main HEAD): exit 0vp fmt --check fork-kit/heavy/README.md: cleanGeneral vs project
t3-capacity, keeps any old copy outside the folders any uninstall deletes, replaces a host's own copy only when told, and the self-check warns when a different copy is on PATH. Nothing here names a project, path or machine. The kit's install folder, the option and the backup folder are the same for every user.Part of #919. This PR is the fork part (steps 1 and 3). Step 2, the consumer part, is the list above.
🤖 Generated with Claude Code