agents-database maintenance wrapper fix

On branch feat/memory-promotion-automation-clean, automatic maintenance was broken because scripts/run-maintenance-daemon.sh launched python3 without repo PYTHONPATH and without preferring .venv, causing ModuleNotFoundError for shared_agent_memory.cli from a repo checkout. Fixed wrapper, restored executable bit, added versioned systemd user service file, and added subprocess coverage for the wrapper path.

Summary: On branch feat/memory-promotion-automation-clean, automatic maintenance was broken because scripts/run-maintenance-daemon.sh launched python3 without repo PYTHONPATH and without p…


**Evaluating risk and paths**

I’m considering the residual risk regarding the systemd template path, which is still pointing to /home/sebas/agents-database, and I’m wondering if it needs to match the install-time path. However, the new test asserts that this path is acceptable, so maybe that's okay. I need to finalize and concisely include the root cause, the files that were changed, the validation run, and the residual risk involved.

Done.

Root cause:
- `scripts/run-maintenance-daemon.sh` was broken.
- It launched `python3 -m shared_agent_memory.cli` without repo `PYTHONPATH`.
- From a normal repo checkout, that crashed with `ModuleNotFoundError: No module named 'shared_agent_memory'`.
- Result: background consolidation/promotion daemon never started, so automatic maintenance depended only on opportunistic in-process hooks.

Intended flow found:
- `MemoryService` seeds `maintenance_jobs`.
- Due jobs run via `MemoryEngine.run_due_maintenance()`.
- Trigger paths:
  - long-lived daemon: `maintenance-daemon`
  - startup catch-up: `MemoryService.__init__`
  - write-time catch-up: `_run_opportunistic_maintenance()`
- Consolidation/promotion logic lives in `MemoryService.consolidate_candidates()`.

Concrete failure reproduced:
- Command:
  - `bash scripts/run-maintenance-daemon.sh --help`
- Before fix:
  - `/usr/bin/python3: Error while finding module specification for 'shared_agent_memory.cli' (ModuleNotFoundError: No module named 'shared_agent_memory')`

Fixes made:
- `scripts/run-maintenance-daemon.sh`
  - export `PYTHONPATH=$REPO_ROOT/src`
  - prefer `./.venv/bin/python`
  - pass through extra CLI args like `--once` / `--job-id`
  - restored executable bit
- `systemd/user/agents-database-maintenance.service`
  - added missing versioned maintenance service file
- `tests/test_memory_service.py`
  - added subprocess test for wrapper end-to-end from repo checkout
  - added presence check for versioned systemd service file

Files changed:
- `scripts/run-maintenance-daemon.sh`
- `systemd/user/agents-database-maintenance.service`
- `tests/test_memory_service.py`

Validation run:
- Tests:
  - `.venv/bin/python -m pytest -q tests/test_memory_service.py`
  - result: `20 passed`
- Wrapper daemon smoke test:
  - `DB_PATH=/tmp/agents-db-maint-test.sqlite3 INTERVAL_SECONDS=1 JITTER_SECONDS=0 bash scripts/run-maintenance-daemon.sh --once --job-id job_consolidation_daily_10`
  - result: maintenance job completed successfully with JSON output
- End-to-end auto-promotion check:
  - temp DB, due job set, created high-confidence inbox memory
  - result: `{'memory_status': 'active', 'job_last_status': 'completed', 'run_count': 1}`

Residual risk:
- The versioned systemd service still hardcodes `/home/sebas/agents-database`, same style as existing HTTP service. Fine if installed there; if this checkout is run directly from `/mnt/rpi/agents-database`, install path must match or be adjusted at install time.
- I did not touch the dirty `data/shared-agent-memory.sqlite3` DB.