Repository navigation
fork fleet: free/v1 "is this machine free?" contract and examples (D10) - #230
scuttletoby wants to merge 7 commits into
Conversation
f061484 to
e554ddf
Compare
91abd6e to
f877ff9
Compare
One small contract for every tool that asks whether a machine may take more work: no arguments, 3 s, exit 0 free / 75 busy, one JSON object on stdout. fork-kit/common/free_contract.py is the one reader (judge, ask, and a CLI for shell callers); free-fixtures.json holds the cases every reader must agree on. Two examples: memory (pressure, swap) and busy-while-running (named programs). The launcher's fits also asks FREE_COMMAND when launch.conf names one (default none: the memory rule alone). The desk kit installs the reader and the memory example and writes FREE_COMMAND from the machine file's desk.freeCommand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e554ddf to
3a91ca2
Compare
f877ff9 to
f18fbda
Compare
|
Review round 1 at f18fbda (lens230): SAFE WITH NITS. Fix round to follow. Holds: no wall weakened (
|
- ask() runs the file unsafe() judged (the link's target), never the link - NaN and Infinity are not JSON: not available (two fixture cases) - a child that left the group with setsid and still holds stdout is ended; one that also closed stdout is the documented bound - poll() instead of select() (descriptors above 1024) - busy-while-running matches names longer than 15 characters - FREE.md: the bound, links, ACLs, the memory example's pressure caveat Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ontract # Conflicts: # fork-kit/desk/sbin/desk-install
The round-1 fix resolved the link again after the check, so a link repointed between the two still changed what ran. The new test caught it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Fix round 1 (commits 8a312ae and f706ea4; D9's round 1 merged in; head f706ea4). Tests: free_contract 13 OK, machine_file 17 OK, install 28 OK, windows 11 OK (1 skipped, no pwsh), walls-wsl2 15 OK.
Fails before the fix: the new tests run against the round-0 code fail 5 times (repointed link, setsid child, 15-character name, NaN, Infinity). PR body updated (30 cases, the bound, links). Still draft. |
|
Re-check lens 230 r1 at f706ea4: SAFE WITH NITS Earlier findings: 1 link checked vs run FIXED ( New:
def test_a_link_another_user_owns_in_a_sticky_folder_is_not_followed(self):
with tempfile.TemporaryDirectory() as d:
os.chmod(d, 0o1777); link = os.path.join(d, 'free')
os.symlink('/usr/bin/true', link)
real, os.geteuid = os.geteuid, (lambda: 4242)
try: verdict, reason, _ = fc.ask(link)
finally: os.geteuid = real
self.assertNotEqual(reason, 'stdout is not JSON')
Checked and holding: monotonic 3 s limit with the whole group killed on every path, 4096-byte cap, plain env from |
…und 2) - free_contract.resolve() follows freeCommand one part at a time, as the kernel does: every folder on the path as written must belong to root or the caller and not be changeable by others (sticky is fine), and every link on the way must belong to root or the caller. Another user's link in a sticky folder is no longer followed to a root program (what fs.protected_symlinks refuses). Loops stop after 40 links. - ask(): a process group it may not signal no longer makes it wait without a limit; it ends the script itself when it can and waits at most one more second. - Tests: the lens test (another user's link in a sticky folder), folders of the path as written, relative links, chains and loops, and the bounded wait. FREE.md says the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Fix round 2 at 83849bc (D9 round 2 merged in first) Findings of the lens 230 r1 re-check:
State question:
Docs: FREE.md and the PR body say the same. Local run (round 2):
Red-check: the new tests run against round-1 code give 3 failures and 1 error. |
Row D10 of the desktop pool plan: the free/v1 contract, "is this machine free?". It defines one small script contract, one reader, shared cases and two example scripts. The desk pool's
fitscan now use it. Stacked on #229 (D9).Why
Several tools need to ask whether a machine may take more work: a desk pool's
fits, the placementfactsCommand, and laterheavy facts. If each one has its own idea of the answer, CI and agents disagree about the same machine. A desktop owner also needs one simple way to say "not now, a game is running".fork-kit/common/FREE.md: the contract.v,freeandat, andreasonwhen busy. A few optional fact groups may follow.file that was checked is the one run: a link is resolved once and its target is run, never the link.
the way must belong to root or the caller (another user's link in
/tmpis refused, asfs.protected_symlinkswould).
fork-kit/common/free_contract.py: the one reader.judgejudges one answer.askruns a script with a time limit, an output limit and its own process group, which is ended on a timeout,together with any process that left the group (
setsid) and still holds its stdout. A process that left thegroup and also closed stdout is not found: that is the documented bound. A group it may not signal (a set-uid
script) is never waited for without a limit: at most one more second.
NaNandInfinityare not JSON: an answer with one is not available.ask [--need-mb MB] /pathis for shell callers.fork-kit/common/free-fixtures.json: 30 cases every reader, in any language, must agree on.free/memory: busy under memory pressure or with swap nearly full (FREE.md says when pressure can stay low).free/busy-while-running: busy while a named program runs (names longer than 15 characters too). Copy it and putyour programs in it. Windows programs are not visible from WSL (FREE.md).
desk.freeCommand(optional) goes tolaunch.confasFREE_COMMAND.fits MBthen also needs a free answer from it, throughFREE_CHECK, the reader installed beside the launcher.desk-install checkshows what the script answers now./opt/fork-fleet/free-memory).With no
freeCommand, nothing changes:fitsuses its memory rule alone.What happens when this runs again, stops half-way, or meets existing, old or empty state?
freeCommandrewrites nothing (D8's rule).freeCommandreached through a folder others may change, or through another user's link, was run before and is now not available (not free) until the path is fixed;desk-install checkshows why. Facts more than 60 s from now count as not available, so a stale cached answer cannot say free. A newervcounts as not available, never guessed. An oldlaunch.confwithoutFREE_COMMANDkeeps the memory-only rule. Unknown fields are ignored.General vs project
General. The contract, reader and examples name no project, person or machine. The example program names in
busy-while-runningare made up. Which script a desktop uses is that desktop's own machine file setting.Upstream fit
Only the fork-only folders
fork-kit/and.github/scripts/fork-fleet-*change. Nothing in upstream T3 changes.Tests
fork-kit/common/tests/free_contract.test.py(new, in.github/fork-ci-tests.txt):left the group and holds stdout is ended, a name longer than 15 characters, another user's link in a sticky folder not followed, the folders of the path as
written judged, relative links, chains and loops, a script it may not end not waited for without a limit
.github/scripts/fork-fleet.test.py:fitsasks the free script too: free, busy, afreeMbbelow the size asked, not available, the memory rule asked first (the script is not run when memory already says no), a reader others may write refused, and a relativeFREE_COMMANDrefused.fork-kit/desk/tests/install.test.py: a free script reacheslaunch.confand thecheckrow.Local run (round 2):
fork-kit/common/tests/free_contract.test.py: 17 OKfork-kit/common/tests/machine_file.test.py: 17 OKfork-kit/desk/tests/install.test.py: 34 OK.github/scripts/fork-fleet.test.py -k fits: 2 OK.github/scripts/fork-fleet-walls-wsl2.test.py: 15 OKtrue,a 0777 folder of the path as written not judged, no
resolve, a 30 s wait after a refusedkillpg).Since #213 the WSL2 walls pin the launcher's sha256 (
LAUNCHER_SHA256), so this PR's launcher change updates thepin. The change only adds two settings and a step in
fits; how job units are made is unchanged, so the walls'reading of the launcher still holds.
fork-fleet-walls.test.py(41) andfork-fleet-walls-wsl2.test.py(15) passwith it.
FREE.mdandfree-fixtures.jsonare now in the repository's format (oxfmt; the data is unchanged).Red-checks
Each rule was broken in a copy, one at a time, and the named test failed (all 6 red):
test_no_answer_in_time_ends_its_whole_groupfreemust match the exit code -> the shared fixturestest_unsafe_scripts_never_runfreeMbbelow the size counts as busy -> the shared fixturesfitsasks the free script ->test_fits_asks_the_free_script_too🤖 Generated with Claude Code