Openclaw-superpowers memory-integrity-checker

Validates memory summary DAGs for structural integrity — detects orphan nodes, circular references, token inflation, broken lineage, and stale summaries that corrupt the agent's memory.

install
source · Clone the upstream repo
git clone https://github.com/ArchieIndian/openclaw-superpowers
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ArchieIndian/openclaw-superpowers "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/openclaw-native/memory-integrity-checker" ~/.claude/skills/archieindian-openclaw-superpowers-memory-integrity-checker && rm -rf "$T"
OpenClaw · Install into ~/.openclaw/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ArchieIndian/openclaw-superpowers "$T" && mkdir -p ~/.openclaw/skills && cp -r "$T/skills/openclaw-native/memory-integrity-checker" ~/.openclaw/skills/archieindian-openclaw-superpowers-memory-integrity-checker && rm -rf "$T"
manifest: skills/openclaw-native/memory-integrity-checker/SKILL.md
source content

Memory Integrity Checker

What it does

As memory DAGs grow through compaction, they can develop structural problems: orphan nodes with no parent, circular reference loops, summaries that inflated instead of compressing, broken lineage chains, and stale nodes that should have been dissolved. These problems silently corrupt the agent's memory.

Memory Integrity Checker runs 8 structural checks on the DAG, generates a repair plan, and optionally auto-fixes safe issues.

Inspired by lossless-claw's DAG integrity checking system, which detects and repairs corrupted summaries.

When to invoke

  • Automatically Sundays at 3am (cron) — weekly structural audit
  • After a crash or unexpected shutdown — check for corruption
  • When the agent's memory seems inconsistent — diagnose structural issues
  • Before a major compaction or prune operation — ensure clean starting state

Integrity checks (8 total)

CheckWhat it detectsSeverity
ORPHAN_NODENode with no parent and not a rootHIGH
CIRCULAR_REFCircular parent-child loops in the DAGCRITICAL
TOKEN_INFLATIONSummary has more tokens than its combined childrenHIGH
BROKEN_LINEAGEEdge references a node ID that doesn't existCRITICAL
STALE_ACTIVEActive node older than 30 days with no childrenMEDIUM
EMPTY_NODENode with empty or whitespace-only contentHIGH
DUPLICATE_EDGESame parent-child edge appears multiple timesLOW
DEPTH_MISMATCHNode's depth doesn't match its position in the DAGMEDIUM

How to use

python3 integrity.py --check                  # Run all 8 integrity checks
python3 integrity.py --check --fix            # Auto-fix safe issues
python3 integrity.py --check --only ORPHAN_NODE  # Run a specific check
python3 integrity.py --repair-plan            # Generate repair plan without fixing
python3 integrity.py --status                 # Last check summary
python3 integrity.py --format json            # Machine-readable output

Procedure

Step 1 — Run integrity checks

python3 integrity.py --check

Runs all 8 checks and reports findings by severity.

Step 2 — Review repair plan

python3 integrity.py --repair-plan

For each finding, shows what the auto-fix would do:

  • ORPHAN_NODE → reattach to nearest active root or deactivate
  • DUPLICATE_EDGE → remove duplicates
  • EMPTY_NODE → deactivate
  • STALE_ACTIVE → deactivate

Step 3 — Apply safe fixes

python3 integrity.py --check --fix

Auto-fixes LOW and MEDIUM severity issues. HIGH and CRITICAL require manual review.

State

Check results, finding history, and repair actions stored in

~/.openclaw/skill-state/memory-integrity-checker/state.yaml
.

Fields:

last_check_at
,
findings
,
check_history
,
repairs_applied
.

Notes

  • Reads from memory-dag-compactor's state file — does not maintain its own DAG
  • Auto-fix only applies to LOW and MEDIUM severity issues
  • CRITICAL issues (circular refs, broken lineage) require manual intervention
  • Circular reference detection uses DFS with visited-set tracking
  • Token inflation check compares parent tokens vs. sum of children tokens