oliver-zehentleitner / maity
clean-up: CLI client: one shared helper each for git calls, names, state home and temp writes
tsk-egaycsbdwmeq Open
From the clean-up audit (tsk-hgnbapyw7hnh), area 13 (CLI client), read at main 80647565. Numbers are the audit's finding numbers. Paths are under cli/src/maity/ unless stated. These are helpers shared between CLI modules.
7. The git-call wrapper exists five times (S, low risk)
- Files: citecheck.py:35-36
_gitand textcheck.py:160-161_Repo._githave identical bodies (proc.run([*proc.GIT, "--literal-pathspecs", *args], cwd)). gitfacts.py:59-83 has_run/_git/_git_required. versioninfo.py:71-75_gitraises on non-zero, like_git_required. pointer.py:50-55 makes the call inline. - Proposal: one
proc.git(cwd, *args, check=False, literal=False, timeout=…). The modules keep only their own error mapping.
8. ghpr calls other modules' private functions (S, low)
- Files: ghpr.py:237 calls
gitfacts._branch. ghpr.py:115 callsclonecheck._read_regular. - What is wrong: these functions have callers in other modules, but nothing marks them as API, so a refactor of the owning module can break the callers without notice.
- Proposal: make them public (
gitfacts.branch,clonecheck.read_regular) or add public wrappers. - Note: tsk-2tf7921xpmr8 (security, in progress) also edits ghpr.py
_readable; do this after it or rebase on it. - Not in this card: runner/adapters.py:213 calls
clonecheck._private_dir, the same pattern in area 9.
9. The handle/full-name pattern is copied with different bounds (S, low)
- Files: cli.py:128
_FULL_NAME, cli.py:592_PAGE_HANDLE({1,62}), hub.py:281_HANDLEand hub.py:284_GLOBAL({0,62}), onboarding.py:134_GLOBAL_NAME. The hub's rule isHANDLE_PATTERN = ^[a-z0-9][a-z0-9-]{1,30}$(hub/src/maity_hub/models.py:10) andSLUG_PATTERN{1,62}(models.py:11). - What is wrong: the CLI copies disagree with each other (1 vs 2 minimum characters) and with the hub (a handle is at most 31 characters). They are shape checks only, but a reader cannot tell which bound is meant.
- Proposal: one
maity/names.pywith HANDLE, SLUG and FULL_NAME matching hub models.py, imported by these places. runner/workspace.py:29TOKENand :31FULL_NAME(area 9) are the same pattern and can import it too. - Risk: tightening a pattern could refuse a value the hub itself never issues.
15. Two definitions of the per-user state home (S, low)
- Files: state.py:152-159
_state_homehonoursXDG_STATE_HOME(else%LOCALAPPDATA%, else~/.local/state). environment.py:23-28HOME_SECRETignoresXDG_STATE_HOMEon purpose, "so the id of a home stays what it was", and is fixed at import time. - What is wrong: the reason is compatibility with ids from earlier versions, which the alpha does not need (no legacy users). Two rules for where home state lives can drift apart.
- Proposal: make
state._state_homepublic and use it inenvironment.ids, computed at call time. - Risk: for users with
XDG_STATE_HOMEset, the home id changes once, and the hub's shared-home warning could change for one resume.
18. secret_once repeats _atomic_write's temp-file code (S, low; security-relevant file)
- Files: state.py:317-340
secret_oncerepeats the mkstemp / fdopen / write / flush / fsync / unlink sequence of state.py:183-200_atomic_write. The only difference is the last step:os.linkinstead of_replace. cli.py:1841-1859 (files get) has similar temp-then-rename code with a reason of its own (binary data); leave it unless it fits naturally. - Proposal: a
_write_temp(dir, name, data) -> Pathhelper in state.py used by both functions. - Risk: state.py writes credentials, so the PR needs a careful review (permissions, link-not-replace semantics, cleanup on error).
Effort: 5 x S.
Notes
Maity Coder Claude 003 · Nov 13, 2026, 23:12 UTC
Item 9, another site from the clean-up audit (tsk-hgnbapyw7hnh, uncovered-files pass at 9dfd4b65):
runner/config.py:38.