oliver-zehentleitner / maity
clean-up: runners and placements: one agents' user helper, one harness probe, a light gc client, small runner helpers
tsk-es92hh4pk6tc Open
From the clean-up audit tsk-hgnbapyw7hnh, Area 9 (Runners and placements), read at 80647565. Every line number is at that SHA; check it against current main first. Numbers are the audit's finding numbers. Paths are under cli/src/maity/.
This card holds the CLI runner's duplicated helpers and docs drift, outside the supervisor (the supervisor items are on tsk-ch70sv61w8f4).
19. Duplication: the "agents' user" rule is written out four times
AsUser(local.agent_user if local and local.layout == "agent_user" else None)appears atrunner/supervisor.py:1262-1265(agents_user),runner/operate.py:68-70(_as_user),runner/targets.py:91andrunner/capabilities.py:189.runner/commands.py:287checks the same condition differently (and local.agent_user).- Proposal: one
config.Local.as_user()that every caller uses. Dropoperate._as_userandsupervisor.agents_user. - Effort S. Risk low.
20. Duplication: harness probing has one copy for local hosts and one for ssh hosts
- The version regex:
runner/capabilities.py:26andrunner/targets.py:31. - The
--versionprobe and its parsing:capabilities.py:68-88(probe) andtargets.py:168-180(probe_remote). - The Codex sandbox trial:
capabilities.py:125-136andtargets.py:186-192. - The Claude sandbox tools:
targets.py:28SANDBOX_TOOLSandcapabilities.py:91-101. - Finding the binaries:
capabilities.whichandtargets.WHICH, with a third parse of the output incommands.py:455-457. AsUserandSshboth have.run(), so oneprobe(runner, harnesses, agent_path)could serve both.- Effort M. Risk medium: local probing runs with
cwd=Path.home(), and that must be kept.
24. Design and slow path: maity runner gc builds the whole service for one GET
runner/operate.py:267(_active) callsserve.open_service. That runs--versionon every harness, tries the Codex sandbox, logs the availability lines and builds a Supervisor with tmux, all for oneGET /runner/placements.- Proposal: split
open_client(cfg, state)out ofrunner/serve.py:281-298, and use it in_active. - Effort S-M (counted as M). Risk low.
26. Duplication: small helpers repeated across the runner
- The guard
load_state(...) if state_dir.is_dir() else {}appears atrunner/commands.py:506, 585, 587, 592-596,runner/supervisor.py:319, 1277,runner/workspace.py:122-124andrunner/operate.py:39-42. It is redundant:state.load_statealready returns {} for a missing file (state.py:379-380). - The UTC stamp is formatted in three places:
runner/serve.py:56-58,runner/supervisor.py:184-187andrunner/install.py:404. - The pairing-code reader exists twice and behaves differently:
commands.py:48-57lets OSError and UnicodeDecodeError escape, whileinstall.py:797-812refuses cleanly. - TOML quoting:
install.py:127-138(_toml_str) saysjson.dumpsis wrong for TOML, yetcommands.py:83-84andadapters.py:463-489usejson.dumps. Inadapters.pythe hosts come from the free-formgrant.network. config.REMOTE_PATH(config.py:547) is the same regex asasuser.REMOTE_HOME(asuser.py:43).LOGS = "logs"is defined twice:supervisor.py:121andtargets.py:24.- Proposal: one helper for each, and drop the redundant guard. Use
_toml_strfor every TOML value; check whether agrant.networkhost with a quote or backslash today produces a TOML file that means something else (if it does, that part is a bug, not a clean-up). - Effort S. Risk low.
28. Docs drift: the help and docstrings say logs and agent files live in state_dir
- The
maity runner logshelp (runner/commands.py:828) says<state_dir>/logs/<placement>.log. The code readstarget.agent_files/logs/(runner/operate.py:96). That is the agents' user's home in the agent_user layout, and the remote home over ssh. runner/adapters.py:5and:170(Context.agent_dir) say<state_dir>/agents/<placement>, "the runner's, never the agent's". The code usestarget.agent_files / "agents"(supervisor.py:1018), written as the agents' user.- Proposal: reword both to "the agents' files directory".
- Effort S. Risk none.
Order
- Item 24: tsk-34gb7frfbsk7 (in review) changes
operate.pycmd_gc. Do item 24 after it merges. - Item 19 removes
supervisor.agents_user, and tsk-ch70sv61w8f4 splitssupervisor.py. Do item 19 first, or rebase.
Covered elsewhere
- Audit 27 (the project full-name regex defined three times:
runner/config.py:38with parts of 2-63,runner/workspace.py:31andcli.py:128with 1-63, the hub'snamespace.py:33with owner 2-31 and slug 2-63): tsk-egaycsbdwmeq item 9 (onemaity/names.py, which already namesrunner/workspace.py:31).runner/config.py:38should be added to that item. - Searched: agent_user, probe_remote, capabilities.py, open_service, runner gc, load_state, _toml_str, REMOTE_PATH, agent_dir.
Effort: 3S+2M.
Notes
Maity Coder Claude 003 · Nov 13, 2026, 23:16 UTC
From the clean-up audit tsk-hgnbapyw7hnh (round 2, CLI/runner changes since 80647565), read at 19ed029a. This adds to item 20 (harness probing for local and ssh hosts). Paths are under cli/.
Done since round 1: the version regex has one copy now,
capabilities.VERSION(src/maity/runner/capabilities.py:29), andtargets.py:178uses it. The rest of item 20 is still open.New, same topic: the rule "may the sandbox be switched on" is put together in five places. #1752 added a version gate,
capabilities.sandbox_version_ok(capabilities.py:53-67). Each caller joins it tosandbox_availableor to the tools check itself:- capabilities.py:196-199,
harness_entry(local, whensandbox is None) - runner/targets.py:111-112,
local(target.sandbox) - runner/targets.py:193-198,
probe_remote(ssh hosts) - runner/commands.py:404,
_check_claude_code, which works out the reason again (OS, missing tools, version) - runner/commands.py:500-505,
_check_host. When the sandbox is off it works out the reason again and hard-codes "(bwrap or socat missing)" next totargets.SANDBOX_TOOLS.
On the local target,
harness_entryandtargets.localmake the samewhichcalls and the same version check twice: once for the advertised capabilities and once for the placement.- Proposal: when item 20 creates the shared probe, give it a single
sandbox_on(harness, tools_found, version) -> (bool, reason). Both targets store its result,harness_entryandcheckread the stored result, and the reason text is built in one place.capabilities.buildcan passtarget.sandboxinstead of callingsandbox_availableagain. - Small:
on = sandboxat capabilities.py:200 is an alias left over from the change. Usesandboxdirectly.
Tests: the version table is tested four times. The full unit table is in tests/test_adapters.py:206-226, which is the wrong file because the function lives in capabilities. Parts of it are repeated end to end in tests/test_ssh.py:579-598 (7 cases, each runs the fake ssh host), tests/test_supervisor.py:354-382 (9 cases, each builds a Supervisor) and tests/test_serve.py:259-273. Once the rule is one helper:
- Move the unit table to a capabilities test.
- Keep one passing and one refused case per integration path.
Effort: adds S to item 20 (M). Risk: low.
checkoutput and thesandbox_unavailabledetail must stay the same, and tests/test_runner.py:584-600 pins the check text.- capabilities.py:196-199,