🎁 Get the FREE AI Skills Starter Guide β€” Subscribe β†’
BytesAgainBytesAgain
πŸ¦€ ClawHub

memory-guardian-agnet

by @5rbdmak7f-alt

Agent workspace memory lifecycle management via 10 MCP tools + batch maintenance. Manages MEMORY.md, memory/ directory, meta.json, quality gate, Bayesian dec...

Versionv1.0.0
Downloads512
Stars⭐ 1
TERMINAL
clawhub install memory-guardian-agent

πŸ“– About This Skill


name: memory-guardian description: > Agent workspace memory lifecycle management via 10 MCP tools + batch maintenance. Manages MEMORY.md, memory/ directory, meta.json, quality gate, Bayesian decay, case lifecycle, and compaction. Use when: (1) Installing or configuring memory-guardian, (2) Running scheduled or on-demand memory maintenance, (3) Diagnosing memory bloat, quality anomalies, or case invalidation, (4) Writing, querying, or archiving memories, (5) Reviewing or retiring judgment cases, (6) Checking quality gate state or L3 confirmations. Triggers on: memory_status, memory_decay, memory_ingest, memory_compact, quality_check, case_query, case_review, run_batch, memory_sync, meta.json, MEMORY.md, memory-guardian.

memory-guardian

Workspace memory lifecycle system. Dual-layer Bayesian decay + four-state quality gate + case lifecycle + compaction.

Design Principles

1. Check status before any write β€” memory_status first 2. Dry-run before apply β€” preview destructive operations 3. Default behavior > toggles β€” workspace defaults from MG_WORKSPACE 4. Write ordering > content correctness β€” sequence matters 5. Observable but not brittle β€” signal degradation β†’ WARNING, not crash 6. Single source of truth β€” all defaults in mg_schema/meta_defaults.py

MCP Tools (10)

workspace defaults from MG_WORKSPACE env var; only non-default params listed.

Query

  • memory_status() β€” System overview (memory count / gate state / case summary / references integrity)
  • memory_query(type="active", min_score=0.3) β€” Search memories (keyword/memory_type filter)
  • Write

  • memory_ingest(content="...", importance="auto", tags=[]) β€” Create new memory
  • memory_decay(lambda=0.01, dry_run=false) β€” Run five-track Bayesian decay
  • Audit

  • quality_check(layer="all") β€” Quality gate (retire_rate / similar_case_signal / stale_cases)
  • case_query(filter="frozen") β€” Query cases (active/frozen/retired/stale/ignored)
  • case_review(case_id, action="retire", origin_type="agent_initiated") β€” Case operations (active/frozen/retired/unfreeze/ignore)
  • Batch

  • run_batch(skip_compact=true, dry_run=false, timeout=300) β€” Full maintenance (includes sync + signal merge)
  • memory_sync(dry_run=true) β€” Sync file changes β†’ meta.json (auto-run in run_batch)
  • memory_compact(dry_run=true, aggressive=false) β€” Compact MEMORY.md
  • Workflows

    New Installation

    1. memory_status β†’ confirm references.complete: true 2. If false, create missing files per the missing list, re-verify 3. Create cron task (see signal-loop.md for cron template) 4. Manually trigger once to verify

    Daily Maintenance (cron)

    run_batch(skip_compact=true) runs automatically. Includes:

  • memory_sync (incremental file scan)
  • Signal merge (access_log + cron inference)
  • Decay + quality gate check
  • Compact triggers only when MEMORY.md > 15KB
  • Diagnostics

    D1: Memory bloat β†’ memory_compact(dry_run=true) β†’ apply if needed β†’ see compaction.md

    D2: Quality anomaly β†’ quality_check(layer="all") β†’ see error_recovery.md

    D3: Case invalidation β†’ case_query(filter="stale") β†’ case_review(action="retire"|"active"|"unfreeze") β†’ see case-management.md

    Signal Loop (v0.4.6)

    Dual-layer access signals feed the decay engine:

  • Layer 1 (weight 1.0): access_log.jsonl β€” agent appends after memory_get
  • Layer 2 (weight 0.5): cron keyword inference from daily notes
  • Health check auto-degrades to Layer 2 if access_log stale > 24h
  • Agent must append to access_log.jsonl after each memory_get call. See signal-loop.md for integration code.

    References

    Load on demand per scenario:

  • signal-loop.md β€” Signal loop setup, AGENTS.md integration code, cron template, config fields
  • triggers.md β€” Trigger/anti-trigger rules
  • parameters.md β€” Decay params, Ξ² scar, PID gains, TTL
  • compaction.md β€” D1 diagnosis and compaction strategy
  • error_recovery.md β€” D2 diagnosis, anomaly states, self-healing
  • case-management.md β€” D3 diagnosis, case audit, L3 review
  • advanced-tools.md β€” Quiet degradation, topic lock, PID adaptive
  • CLI Fallback

    When MCP unavailable, CLI path relative to skill dir:

    python3 scripts/memory_guardian.py  [--workspace ]
    
    Commands: status, ingest, bootstrap, snapshot, run, violations, migrate