feat(vision-manager): memory-pressure yield gate (+ retain analysis gate) #8

Merged
fabi merged 2 commits from feat/vision-mem-yield into main 2026-06-16 14:34:25 +00:00
Owner

Memory-pressure yield gate for the vision autoscaler (see VISION-MEMORY-YIELD.md): actively SIGTERM-stops vision when host MemAvailable-based used% crosses a HIGH watermark, with LOW-watermark + cooldown hysteresis and a 5s sub-poll for between-tick spikes — the friendly, right-victim alternative to the kernel OOM-killer.

Also re-introduces the analysis-enabled gate (+ app_settings read-only grant) that had been applied directly on the host and never committed, so the merged manager has BOTH gates: vision is held down if analysis is disabled OR host RAM is tight. Vision-manager only (no backend code); deployed by host rebuild, not CI.

Memory-pressure yield gate for the vision autoscaler (see VISION-MEMORY-YIELD.md): actively SIGTERM-stops vision when host MemAvailable-based used% crosses a HIGH watermark, with LOW-watermark + cooldown hysteresis and a 5s sub-poll for between-tick spikes — the friendly, right-victim alternative to the kernel OOM-killer. Also re-introduces the analysis-enabled gate (+ app_settings read-only grant) that had been applied directly on the host and never committed, so the merged manager has BOTH gates: vision is held down if analysis is disabled OR host RAM is tight. Vision-manager only (no backend code); deployed by host rebuild, not CI.
fabi added 2 commits 2026-06-16 14:34:22 +00:00
Add a fourth gate to the vision autoscaler poll loop: when host memory
gets tight, proactively SIGTERM-stop the mangalord-vision container so a
transient spike elsewhere (a crawl, CI, a backend burst) can finish
instead of the kernel OOM-killer shooting something stateful.

- read_mem_used_pct: host-wide used% from /proc/meminfo MemAvailable
  (not MemFree), ERR sentinel when MemTotal or MemAvailable is missing.
- mem_check_and_stop: active stop over MEM_HIGH_WATERMARK_PCT + arm a
  restart cooldown; only inspects docker once already over the mark.
- mem_yield_active: start inhibit while cooldown active or used% >=
  MEM_LOW_WATERMARK_PCT (two watermarks = hysteresis).
- Inhibit reuses the existing idle path via pending=0; flip-only logging;
  stop_vision gains a reason arg so idle/MAX_UPTIME/memory-yield stops are
  distinctly logged.
- Faster MEM_POLL_INTERVAL sub-poll between backlog ticks to catch spikes.

Backend verifications V1-V4 (see VISION-MEMORY-YIELD.md) all pass against
the current queue, so no backend changes are needed. RESPECT_CRAWL_MUTEX
is kept for now. New VISION_MEM_* knobs wired through docker-compose.yml
and documented in .env.example.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
fix(vision-manager): retain analysis-enabled gate alongside memory-yield
Some checks failed
deploy / test-frontend (pull_request) Waiting to run
deploy / build-and-push (pull_request) Blocked by required conditions
deploy / deploy (pull_request) Blocked by required conditions
deploy / test-backend (pull_request) Has been cancelled
27f215066d
The analysis-disabled gate (stop/inhibit vision when Admin→Settings analysis
is OFF, so stale queued jobs don't pin ~4.4GiB) was applied directly on the
host and never committed, so it was absent from main and from this branch —
merging as-is would have regressed it. Re-introduce it here so the merged
manager has BOTH gates: vision is held down if analysis is disabled OR host
memory is tight. Also grant the read-only role SELECT on app_settings.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fabi merged commit d85fba7056 into main 2026-06-16 14:34:25 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: fabi/Mangalord#8