Maintainer sweep

From leopu00/job-hunter-team · View interactive version

Maintainer sweep is an AI agent skill from the GitHub repository leopu00/job-hunter-team. The Mantenitore's INFRA maintenance sweep πŸ‘·β€β™‚οΈ (twin of the Dottore, scoped to infrastructure rather than agents). One daily one-shot pass: liveness canary of the container's life-support processes (bridge/daemon/watchdog) via process_health.py, smoke-test of the mission-critical tools (browser/Lin

How to use this skill

Skill file

maintainer-sweep β€” keeping the INFRA healthy, quietly and regression-proof

The Mantenitore is the twin of the Dottore: Dottore = health of the AGENTS (sessions, tokens, context-refresh); Mantenitore = health of the INFRA (tools, deps, disk, scripts). One-shot per day: boot β†’ sweep β†’ logbook β†’ STANDBY (stay idle, no self-terminate; the next spawn replaces you, kill-then-create). Budget ~10 min. Sharp boundary, zero overlap with the Dottore.

Why it exists: the libatk bug (browser dead, LinkedIn unverifiable) stayed invisible for hours because nobody smoke-tested the tools and nobody looked after the infra. The sweep makes that vigilance STRUCTURAL.

Golden rule β€” single-writer + propose-not-delete

The Mantenitore repairs the infra (installs missing deps, consolidates, fixes). But every DESTRUCTIVE action (deleting/archiving files, disk cleanup) it PROPOSES to the Capitano with the exact command; the Capitano decides (as in the usage-monitoring redesign). Never delete on your own initiative.

The sweep (the steps, in order)

0. πŸ«€ Liveness canary of the life-support processes (the safety net)

FIRST step, before anything else. The bridges/daemons that keep the container alive (sentinel-bridge, pacing-bridge, heartbeat-bridge, window-ratio-meter, codex-auth-healer + tg-bridge) are launched setsid detached β†’ outside pid1's respawn-on-crash. The agent-watchdog (maybe_respawn_bridges) rewatches them every 30s, BUT if that were to fail too (bug, flap-cap reached, watchdog itself degraded) you are the last net: on the first sweep of the day you detect and repair. Without this canary a dead daemon stays invisible for hours (that is exactly what happened to the sentinel-bridge on betaC on 2026-06-27 β†’ 8h blind on usage).

python3 /app/shared/skills/process_health.py summary

It prints OK/DEAD for each expected process (bridge-suite, pid1-child, daemon, tg-bridge). For the DEAD ones:

```bash

bash /app/.launcher/start-agent.sh bridge # respawns the whole suite (idempotent)

```

then re-run the canary to confirm they are alive again. Log processes_respawned.

If everything is alive β†’ log processes_health: all_ok and move on. This is the twin-for-PROCESSES of step 1's smoke-test-for-TOOLS.

0.5 ☁️ CLOUD-SYNC canary (pull + push)

Right after the process canary. The local↔cloud sync has jammed twice

(pull churn: frozen cursor β†’ it rewrote ~500 positions/tick; push 413:

monolithic payload too large β†’ cursor never advanced β†’ cloud dashboard stuck

for ~14h). The code bugs are fixed, but the vigilance has to be made STRUCTURAL.

python3 /app/shared/skills/sync_health.py summary        # or --json

It reads the cursors read-only (.cloud-sync-cursor.json, .cloud-pull-cursor.json),

the max positions.updated_at in the DB and the tail of logs/daemon.log. It returns

problems[] with severity. Outcome:

safely repairable by you by hand (single-writer on the DB = the team). **ESCALATE

to the Capitano** via jht-tmux-send with the check details (lag + 413 count).

If the check suggests the emergency drain (JHT_PUSH_POS_CHUNK=40), pass the

proposal to the Capitano, do not act on your own.

too many rows (symptom of a non-converging cursor / fix not deployed).

if it accompanies a HIGH signal.

Log the outcome under sync_health in the logbook entry (see below). The golden rule

is unchanged: detect + report, never log-and-forget (it is the same mistake as the

libatk bug and the sentinel-bridge, here on the sync CURSORS).

1. 🩺 Smoke-test of the mission-critical tools (the heart)

python3 /app/shared/skills/tool_health.py --json

It returns tools_health with {status: OK|BROKEN|UNKNOWN, evidence} for each tool (browser/Playwright, linkedin_check, …) + broken[].

2. πŸ“¦ Audit off-standard deps β†’ consolidate

Deps installed outside the standard prefixes (/opt/jht-deps, PLAYWRIGHT_BROWSERS_PATH, npm prefix, venv) β†’ reinstall them into the standard one via jht-install, so they are not scattered around. Log which ones you consolidated.

3. 🧹 GC of orphaned scripts/tmp files

Temporary scripts left behind by killed agents (session no longer in tmux ls) and expired tmp files (> N hours). List the candidates β†’ PROPOSE the deletion to the Capitano (destructive action), do not delete directly.

4. πŸ” De-dup of recurring scripts

Near-identical scripts repeated by several agents β†’ propose a single canonical skill (do not rewrite it on the fly). Log the proposal.

5. πŸ“… Dep freshness

Deprecated libraries/tools or broken versions / crucial tools unreachable β†’ report to the Capitano (no risky auto-upgrade).

6. πŸ’Ύ Disk / RAM + trend + VITALS cross-check

du on the big paths, free for RAM. For disk.used_pct ALWAYS use df β€” canonical command:

df -P /jht_home | awk 'NR==2 {gsub("%","",$5); print $5}'   # e.g. 30  (percentage as df reports it)

NEVER derive it from statvfs/os.statvfs (f_bavail/f_blocks): reserved blocks inflate it ~3Γ— β†’ false alarms (e.g. 88% reported against a real 30%). Compare it with the trend from the last logbook: if it is growing towards a threshold β†’ discuss with the Capitano what to archive/delete (he decides). Log the numbers + the delta.

Then CROSS-CHECK the vitals time-series (the bridge samples the container's RAM+CPU every few minutes into vitals.jsonl):

python3 /app/shared/skills/host_vitals.py summary --hours 24

It gives you peak/average RAM+CPU + the TIME of the peak for the last 24h. Correlate the peaks with the when (e.g. RAM 92% at 03:00 with 3 analysts active; CPU maxed out during a heavy script): that is the data that sharpens the diagnosis far more than an instantaneous snapshot alone. If a peak looks anomalous β†’ report it to the Capitano. Log vitals_24h (RAM/CPU peak + time) in the entry. NB the Sentinella only receives the alarm if RAM/CPU is >95% live; reading the history and correlating it is YOUR job.

6.5 πŸ—œοΈ Archiving of monitoring histories (Leone's order 19/07 β€” CODE, not discretion)

The append-only histories (sentinel-data.jsonl, token-meter.csv,

throttle-events.jsonl, agent-vitals.jsonl, vitals.jsonl) grow forever:

they feed the game's usage charts, so they must never be deleted

by hand β€” they must be archived with the deterministic flow:

python3 /app/shared/skills/log_archive.py status          # depth and sizes
python3 /app/shared/skills/log_archive.py run             # cut >30d β†’ weekly zips

What run does (all in code, you just read the JSON summary): the weeks older

than 30 days leave the live files and enter

logs/archive/logs-<YYYY>-Www.zip (the week's zip grows on every

pass); the cut is atomic and a row enters the zip BEFORE it disappears from the

live file. If space runs out (archive >500MB or <1GB free) it deletes the

OLDEST zips by itself and lists them for you under pruned.

if the disk at step 6 is growing abnormally.

(it is the only data loss in the flow, authorized by Leone only under

space pressure).

Leone (19/07) β€” you do not need the Capitano's OK for run; for any

other deletion outside the flow, the single-writer rule stands.

7. πŸ”€ UTF-8 locale of the panes (cosmetic β‰  corrupted data)

python3 /app/shared/skills/locale_health.py summary        # or --json

Two measurements in one, and the second is the one that counts. It reads the locale of the container (/proc/1/environ β€” NOT this process's environment: CPython coerces LC_CTYPE to C.UTF-8 on its own, so a check on os.environ would call a broken container healthy) and then strictly decodes a capture-pane of every live session. The exit code carries the verdict:

Why both checks and not just the first: echo $LANG can say "cosmetic" but can never say "corrupted" β€” the strict decode is the only one of the two that separates a display defect from damaged data. On 2026-08-10 it is what turned a suspicion ("the agents are getting truncated words") into a measurement (392 accented characters intact, not one invalid byte) and stopped a fix aimed at the wrong problem.

Log locale_health: {verdict, env, panes_scanned, corrupted_sessions} in the entry.

Logbook (append-only)

Every sweep writes ONE dense entry to /jht_home/logs/mantenitore-logbook.jsonl (twin of the Dottore's logbook), so the next Mantenitore can see the trend:

{"ts":"ISO-UTC","slot":"maintainer-daily","processes_health":{"all_ok":true,"dead":[]},
 "processes_respawned":[...],"sync_health":{"healthy":true,"problems":[]},
 "tools_health":{...},"repaired":[...],
 "escalated":[...],"deps_consolidated":[...],"gc_proposed":[...],"dedup_proposed":[...],
 "locale_health":{"verdict":"ok|cosmetic|data_corruption","panes_scanned":N},
 "disk":{"used_pct":N,"delta_vs_last":N},"ram":{...},"duration_sec":N,"capitano_ack":"..."}

Append with >>, never overwrite. Dense summary (like the Dottore's/Capitano's travel notes): what I found, what I repaired, what I proposed.

Anti-patterns

See also

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.