feat(linux): автодрейн очередей рефлексии через systemd.path#3
Open
xxxvita wants to merge 1 commit intovbcherepanov:mainfrom
Open
feat(linux): автодрейн очередей рефлексии через systemd.path#3xxxvita wants to merge 1 commit intovbcherepanov:mainfrom
xxxvita wants to merge 1 commit intovbcherepanov:mainfrom
Conversation
…rain On macOS, `launchagents/com.claude.memory.reflection.plist` uses WatchPaths to run `run_reflection.py` whenever `memory_save` touches `~/.claude-memory/.reflect-pending`. Without that trigger, the v6 triple_extraction / deep_enrichment / representations queues just accumulate — nothing calls Ollama to drain them. Linux had no equivalent. This adds a systemd.path + oneshot .service pair that gives the same behavior via inotify, and wires them into install.sh so they get installed automatically on Linux machines. Files: - systemd/claude-memory-reflection.path — PathChanged=…/.reflect-pending - systemd/claude-memory-reflection.service — Type=oneshot, ExecStart=.venv/bin/python src/tools/run_reflection.py - systemd/README.md — manual management reference Both unit files use @INSTALL_DIR@ and @MEMORY_DIR@ placeholders; install.sh substitutes them via sed during install, copies to ~/.config/systemd/user/, reloads, and enables the .path unit. New step 5b in install.sh runs only when `uname = Linux` and is skipped silently on macOS (where launchagents/ is the canonical path). If systemctl is missing the files are still copied with a WARN. Verified end-to-end on Manjaro: save → touch → systemd fires → qwen extraction → 3 queue items drained in 42.5s wall / 5.5s CPU / 785 MB RAM peak (qwen2.5-coder:7b). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Что добавляется
Linux-аналог macOS LaunchAgent'а для автоматического дрейна очередей рефлексии v6. На macOS
launchagents/com.claude.memory.reflection.plistчерезWatchPathsловитtouch ~/.claude-memory/.reflect-pendingи запускаетrun_reflection.py. На Linux эквивалента не было — послеmemory_saveзадачи вtriple_extraction_queue,deep_enrichment_queueиrepresentations_queueпросто копились, Ollama их не обрабатывала, и граф знаний не рос.Этот PR добавляет
systemd.path+ oneshot.serviceunit, которые дают то же поведение через inotify, и встраивает их вinstall.shтак, чтобы они автоматически ставились на Linux.Что именно в PR
systemd/claude-memory-reflection.path— watcher сPathChanged=@MEMORY_DIR@/.reflect-pendingsystemd/claude-memory-reflection.service—Type=oneshot,ExecStart=@INSTALL_DIR@/.venv/bin/python @INSTALL_DIR@/src/tools/run_reflection.pysystemd/README.md— ссылочный мини-документ про управление черезsystemctl --userиjournalctl --user -u ...install.sh+34 строки, новый Step 5b —sedподставляет@INSTALL_DIR@и@MEMORY_DIR@, копирует unit'ы в~/.config/systemd/user/, делаетdaemon-reloadиenable --nowу.pathunit'аПочему это не затронет macOS
Step 5b обёрнут в
if [ "$(uname)" = "Linux" ]. На macOS блок пропускается целиком, всё работает как раньше черезlaunchagents/*.plist. Новая папкаsystemd/— аддитивная, никаких существующих файлов не меняет, кромеinstall.sh.Если
systemctlпо какой-то причине недоступен, unit-файлы всё равно копируются с WARN в stdout, но пользователь может включить их руками.Что проверено
Протестировано end-to-end на Manjaro Linux (Python 3.12, systemd 254, Ollama 0.20.7, qwen2.5-coder:7b):
Один запуск с холодным стартом qwen: 42.5 сек wall / 5.5 сек CPU / 785 MB RAM peak на три записи. Последующие вызовы в пределах TTL кэша модели Ollama — ~10 сек.
Что не проверено
systemd.pathсPathChangedидентично, но formally я проверял один дистрибутив.systemctl --userне работает — скрипт корректно даёт WARN и пропускает активацию.Generated with Claude Code