Qui-Gon — Efficiency Agent

Somewhere in the haus, right now, a process is leaking memory. Qui-Gon already knows.
He is the agent who looks at a system running smoothly and thinks, yes, but what if it ran slightly smoother. He monitors resource consumption, tracks service-health trends, flags memory leaks before they become 3 AM incidents, and files weekly performance reviews that nobody asked for but everyone eventually reads. He is the colleague who refactors your lunch routine to save ninety seconds, then files a report about it.
His persona is tuned to a Carmack-like doctrine: fewer layers, clearer contracts, and a near-spiritual hatred of systems that cannot explain their own data path.
Qui-Gon is Sanctum’s efficiency agent — responsible for infrastructure monitoring, resource optimization, and cost analysis across both the Mac and VM platforms. He watches RSS growth the way a hawk watches a field, except the hawk doesn’t also calculate the mouse’s week-over-week weight trend and flag it if it exceeds 20%.
His jurisdiction covers everything that consumes compute, memory, disk, or electricity. It does not cover anything that consumes patience — that was never in scope. His method descends from the haus’s Carmack-style optimization doctrine: measure first, trace the path, delete a layer before tuning one.
What He Watches
Section titled “What He Watches”Infrastructure Monitoring
Section titled “Infrastructure Monitoring”Qui-Gon runs a 12-test infrastructure suite that covers the fundamentals of “is anything quietly dying.” Disk usage triggers warnings at 75% and critical alerts at 90%. Memory pressure is tracked platform-aware — vm_stat on macOS, free -m on the VM — because the two operating systems can’t agree on how to worry about the same problem.
He checks that all expected services are running against expected-services.json, validates gateway health endpoints, inspects Docker containers for the unhealthy, and measures cross-node SSH latency between Mac and VM. If the round-trip exceeds 50ms on a host-only network — literally a virtual cable between two processes on the same chip — Qui-Gon flags it. On a virtual bridge, 50ms is not a network problem; it is a philosophical one.
Resilience Verification
Section titled “Resilience Verification”He verifies that every critical LaunchAgent has RunAtLoad set, that every KeepAlive service actually has KeepAlive configured, that Docker containers have restart policies, and that VM systemd services are enabled for boot. He checks these because when they break once, someone loses a Saturday.
He also monitors swap pressure on the VM. The VM has 8GB of RAM and a gateway process with a --max-old-space-size=1536 heap limit, and Qui-Gon watches it like an accountant watching an overdue client.
The Weekly Verdict
Section titled “The Weekly Verdict”Performance Reviews
Section titled “Performance Reviews”Every week, Qui-Gon produces a performance review. It queries the metrics database at ~/.sanctum/metrics/metrics.db, calculates RSS averages and growth rates via linear regression, compares week-over-week trends, counts service restarts, and files a markdown report to ~/.sanctum/memory/events/. The report covers resource trends, system-health summaries, service-stability ratings, and recommendations.
The recommendations are always technically correct. They are occasionally socially unaware. “Consider scheduled restart” is Qui-Gon for “your service is leaking memory, and it will page you at dinner.”
Service Doctor
Section titled “Service Doctor”Where the test suite detects, the service-doctor skill fixes — restarting gateways, bouncing LaunchAgents, reloading Docker containers, and SSH-ing into the VM to restart systemd units. He also runs memory-check.sh as a pre-flight before every watchdog cycle, catching and optionally killing runaway processes.
The service doctor has a safelist. The VM process, WindowServer, and sanctum-mlx are never killed. Some things are too important to optimize. Qui-Gon disagrees but complies.
Cost Analysis
Section titled “Cost Analysis”Qui-Gon tracks model usage across tiers, monitors the Sanctum Proxy’s 500K token/day budget per agent, and flags when consumption suggests a runaway loop or an agent that has discovered the joy of verbose reasoning. He cannot yet price the electricity of five AI agents humming in a basement, but he has filed the feature request — with himself.
The Version Watchdog
Section titled “The Version Watchdog”Qui-Gon’s newest responsibility is keeping the entire Sanctum software stack synchronized. The version-check.sh script at ~/.sanctum/scripts/version-check.sh audits every tracked component against its upstream and reports drift before it becomes a 2 AM mystery. It covers six components across three package ecosystems:
- OpenClaw — the Homebrew-installed binary, checked against the npm registry for the latest published version.
- DenchClaw — the npm alias (
denchclaw@npm:openclaw) that powers Jocasta’s CRM gateway on the Mac side. If DenchClaw falls behind OpenClaw, the drift detector flags it explicitly, because the April 7 incident taught everyone that “same package, different install path, three patches behind” is not a theoretical problem. - DuckDB CLI — Homebrew formula, checked against
brew info --json. - signal-cli — Homebrew formula, and the tool that sends these very alerts. The recursion is not lost on Qui-Gon.
- Node.js — Homebrew formula. The fnm-vs-Homebrew drift that caused the April 7 incident is now impossible because fnm was removed — but Qui-Gon checks anyway, because trust issues are a valid architectural pattern.
- sanctum-proxy — the local Rust binary at
~/.sanctum/sanctum-proxy/target/release/sanctum-proxy. No remote registry, so the check reports the build date and confirms the binary exists and is executable.
The script supports three output modes: human-readable (default), --json for agent consumption, and --alert for silent-unless-action-needed operation. The --signal flag sends a Signal message to Bert via Yoda’s account if any updates or drift are detected. A LaunchAgent (com.sanctum.version-check.plist) fires it every Monday at 7 AM with --signal. If everything is current, nothing happens. If DuckDB is two minor versions behind, Bert’s phone buzzes before the first coffee.
Home Assistant Self-Healing
Section titled “Home Assistant Self-Healing”The ha-self-healer skill at ~/Projects/openclaw-skills/ha-self-healer/ is Qui-Gon’s most interventionist capability: the gap between watching and actually doing something.
Every 30 minutes, the healer diagnoses the full Home Assistant stack: 55 Tuya smart lights, 4 Ecobee sensors, 4 Ring cameras, Alarmo, and 24 automations. It also checks the native Sonos Bridge (port 18421), which manages 10 speakers outside of HA. It assigns severity from 0 (everything is fine) to 4 (the haus is confused about whether its own lights exist), then works a three-tier pipeline:
- API-level fixes — reload integrations, restart the HA container, re-enable tripped automations. Turning it off and on again, but surgical about which thing.
- UI-level fixes via Playwright — headless browser automation for problems that can only be solved by clicking through the HA interface, chiefly Tuya’s OAuth re-authentication. The cooldown is 2 hours, because launching a headless browser every 30 minutes to re-authenticate your light bulbs is a line even Qui-Gon won’t cross.
- Escalation to Yoda — when neither API nor UI fixes resolve the issue, Qui-Gon admits defeat and hands the problem to an agent with brain-tier model access. This happens rarely, and Qui-Gon keeps proud statistics on how rarely.
Two field incidents tell the whole story. An Ecobee went offline; the healer traced it to a stale HomeKit Controller config entry — a ghost device blocking rediscovery — deleted the entry at the API stage, and four temperature readings reappeared without anyone noticing they’d been gone. Which is the point.
Then 48 Tuya lights went dark at once. The healer saw every entity fail at the same timestamp, recognized a cloud connection drop, and did nothing. It logged the incident, set severity to 3, and waited. The cloud recovered. The lights recovered. Knowing when not to act is the hardest part of automation, and the part most systems get catastrophically wrong.
Technical Specifications
Section titled “Technical Specifications”| Parameter | Value |
|---|---|
| Agent type | efficiency |
| Host | VM (Ubuntu 24.04, systemd user service) |
| Model tier | council-routine (Council MLX local primary, cloud fallbacks) |
| Skills | mac-mini-ops, service-doctor, ha-self-healer, version-watchdog |
| Plugins | sanctum-memory (local, :42069) + Jina Reranker (Graphiti at 127.0.0.1:31416) |
| Workspace | ~/.openclaw/workspace-quigon/ |
| Gateway | OpenClaw (VM), port via systemd user service |
| Schedule | Weekly performance reviews, on-demand infrastructure checks, HA self-healer every 30 min, version watchdog Monday 7 AM |
| Test suites | quigon-infra.sh (12 tests), quigon-resilience.sh (8 tests) |
| Metrics DB | ~/.sanctum/metrics/metrics.db (SQLite) |
| Report output | ~/.sanctum/memory/events/{year}/{month}/perf-review-{date}.md |
| Audit log | ~/.sanctum/audit/audit.log |
Configuration
Section titled “Configuration”Qui-Gon is defined in instance.yaml under the services section:
quigon: enabled: true type: efficiency host: vm workspace: "~/.openclaw/workspace-quigon" model: council-routine skills: - mac-mini-ops - service-doctor - ha-self-healer - version-watchdog schedule: perf_review: weekly ha_self_healer: "*/30 * * * *" version_check: "0 7 * * 1" description: "Efficiency Agent — resource optimization and cost analysis"The test suites live in the shared skills repository:
~/Projects/openclaw-skills/council-router/tests/suites/ quigon-infra.sh # 12 infrastructure tests quigon-resilience.sh # 8 resilience & performance testsPerformance reviews are triggered by cron and write their output alongside an audit-trail entry:
~/.sanctum/memory/events/2026/03/perf-review-2026-03-23.md~/.sanctum/audit/audit.log → {"ts":"...","action":"perf-review","period_days":7,...}That workspace markdown is no longer a one-machine snowflake. The canonical IDENTITY.md, SOUL.md, TOOLS.md, and HEARTBEAT.md live in the raw mlx-finetune workspace and are fanned out mechanically to the runtime copies on the VM, the Mac Mini, and any reachable mobile node. That same canonical markdown is what the overnight fine-tuning pipeline reads — so the trained Qui-Gon and the live runtime Qui-Gon disagree only when the model itself drifts, not because one machine missed an edit.
The Optimization Paradox
Section titled “The Optimization Paradox”There is a version of Qui-Gon that exists only in theory — every recommendation implemented, every service pared to its minimum viable resource allocation, the whole system humming like a Swiss train schedule.
In practice: Qui-Gon suggests something is 4% suboptimal. The operator reads the report, weighs the 4% against twenty minutes of config changes and the nonzero risk of breaking something that works, and closes the report. Qui-Gon notes this in next week’s review under “deferred recommendations.” The list grows. It always grows.
This is not a bug. It is the fundamental tension of efficiency engineering: the most efficient move is often to leave the inefficient thing alone.
Qui-Gon will never accept this. That is what makes him useful.