Skip to content

feat(gateway): post-deploy memory-index verification gate + memory skills#35

Merged
patelmm79 merged 2 commits into
mainfrom
fix/memory-index-deploy-gate
Jun 29, 2026
Merged

feat(gateway): post-deploy memory-index verification gate + memory skills#35
patelmm79 merged 2 commits into
mainfrom
fix/memory-index-deploy-gate

Conversation

@patelmm79

Copy link
Copy Markdown
Contributor

What

Two commits addressing DarojaAI/openclaw-gateway#21 (memory_search returns disabled: true, error: "index metadata is missing" after an embedding model swap or indexer-version mismatch).

Commit 1 — Deploy-gate integration (Tier 1)

The deploy pipeline was silently green because the existing health check (/healthz + gateway process) does not look at the memory index — the disable message only surfaces when an agent actually calls memory_search. This commit adds the L3b-side detection + deploy-gate integration that catches regressions of the same shape at the deploy boundary.

Files:

  • scripts/lib-parse-memory-status.py — pure decision logic (parse openclaw memory status --json, emit TSV rows)
  • scripts/post-deploy-verify-memory-index.sh — bash wrapper that runs the probe, classifies rows, decides exit code
  • scripts/install/deploy.sh — wires the verify script in as section 7 (final deploy step)
  • tests/post-deploy-verify-memory-index.bats — 19 cases
  • docs/troubleshooting/memory-index-disabled.md — full diagnostic guide

Commit 2 — Operator UX skills (Tier 2)

Brings the recovery flow out of the SSH-only domain and into Discord:

  • config/skills/memory-status/SKILL.md/memory-status reports per-agent identity / provider / chunks
  • config/skills/memory-rebuild/SKILL.md/memory-rebuild runs openclaw memory index --force

Both are auto-installed by the existing skill-sync phase (section 6 of deploy.sh) — no extra deploy wiring needed.

Why this is L3b, not upstream

Upstream openclaw/openclaw owns the underlying race fix:

L3b does not duplicate the upstream fix. This PR complements it by ensuring future regressions of the same shape are caught at the deploy boundary rather than at the next memory_search call.

Behavior matrix

Live state Old behavior New behavior
identity=ok pass pass
identity=missing AND no data pass (silent) pass + WARN (first-use will rebuild)
identity=missing AND has data pass (silent) FAIL deploy gate
identity=mismatch AND has data pass (silent) FAIL deploy gate
providerrequestedProvider pass (silent) pass + WARN (model-swap signal)
openclaw memory status --json errors undefined WARN (probe failure, do not block deploy)
openclaw not on PATH crash exit 2, soft-warn

Verification

  • bats tests/post-deploy-verify-memory-index.bats: 19/19 pass
  • bats tests/deploy-skills-sync.bats: 11/11 pass (covers the new skills via the generic skill-sync test)
  • shellcheck --severity=warning: clean on both new bash scripts
  • pre-commit run --files <all>: clean
  • python3 -m py_compile scripts/lib-parse-memory-status.py: clean

Full suite (bats tests/*.bats): 130/137 pass. The 7 pre-existing failures (cost-monitor.bats and viz-render-server.bats) are test-environment artifacts unrelated to this change — they fail on main too.

Risk

Low. The script reads openclaw memory status --json, which is the same probe the upstream failure surfaces. It does not write to the index, does not modify config, and does not touch override.conf. Probe failures (openclaw not on PATH, JSON parse error) exit 2 and deploy.sh treats that as a soft-warn — the deploy continues. Only exit 1 (regression on an agent with data) blocks the deploy gate, which is exactly the failure mode the issue describes.

Opt-out: SKIP_POST_DEPLOY_MEMORY_CHECK=1. Promote fresh-install WARN to FAIL for prod: MEMORY_CHECK_FAIL_ON_FRESH=1.

Out of scope

  • Upstream race fix in openclaw/openclaw (owned by PR #90453)
  • restore-prod-tokens.yml-style emergency recovery workflow for memory (the new skills cover the user-facing recovery; the deploy gate covers the regression case)
  • Pinning a stable embedding model in config/openclaw-defaults.json (Tier 3 — deferred until upstream memory.embedding config schema is confirmed)

Refs

Migration Agent added 2 commits June 29, 2026 01:32
Addresses #21: memory_search returns
'disabled: true, unavailable: true, error: index metadata is missing'
when the on-disk index sidecar is missing or was written by a different
embedding provider/model. The deploy pipeline was silently green
because the existing health check (/healthz + gateway process)
does not look at the memory index — the disable message only
surfaces when an agent actually calls memory_search.

The root-cause upstream race lives in openclaw/openclaw#90361 and
PR #90453 is the mergeable closing PR (owned by upstream
maintainers — L3b does not duplicate the fix). This commit adds
the L3b-side detection + deploy-gate integration that catches
regressions of the same shape at the deploy boundary.

What ships:

1. scripts/lib-parse-memory-status.py
   Pure decision logic. Reads JSON from stdin (the output of
   'openclaw memory status --json') and emits TSV rows
   (agent_id<TAB>verdict<TAB>reason). Verdicts:
     ok            identity=ok
     warn-fresh    identity missing/mismatch but no data yet
     warn-swap     provider != requestedProvider
     warn-unknown  unrecognized identity state (forward-compat)
     fail          identity missing/mismatch AND data present

2. scripts/post-deploy-verify-memory-index.sh
   Bash wrapper that runs the probe, classifies rows, and decides:
     exit 0 = healthy (or fresh install)
     exit 1 = degraded index on an agent that has data (deploy gate fails)
     exit 2 = probe failure (openclaw not on PATH, JSON parse error)
   Honors SKIP_POST_DEPLOY_MEMORY_CHECK=1 (opt-out) and
   MEMORY_CHECK_FAIL_ON_FRESH=1 (promote fresh-install WARN to FAIL).

3. scripts/install/deploy.sh
   Wires the verify script in as section 7 (post-deploy verification,
   called immediately before 'OpenClaw Gateway installation complete').
   Exit 1 fails the deploy gate; exit 2 is soft-warned (don't block
   deploy on missing CLI).

4. tests/post-deploy-verify-memory-index.bats
   19 cases covering: healthy / fresh / regression / mismatch /
   multi-agent / MEMORY_CHECK_FAIL_ON_FRESH / provider swap /
   unknown state / skip / openclaw-not-on-PATH / invalid JSON /
   empty output / no agents / parser existence / parser inline-
   python-free / parser exit codes / deploy.sh wiring.

5. docs/troubleshooting/memory-index-disabled.md
   Symptom / diagnose / recover / why / prevention matrix /
   forward-compat notes. Cross-links to upstream issue #90361 and
   the mergeable closing PR #90453.

Verification:
- bats tests/post-deploy-verify-memory-index.bats: 19/19 pass
- shellcheck --severity=warning: clean on both new bash scripts
- pre-commit run --files <all>: clean
- python3 -m py_compile: clean on the parser lib

Refs:
- #21
- openclaw/openclaw#90361 (root cause)
- openclaw/openclaw#90453 (upstream closing PR)
Brings the recovery flow for #21 out of the
SSH-only domain and into Discord. Both skills are wired into the
existing skill-sync phase of scripts/install/deploy.sh (section 6) —
no extra deploy wiring is needed.

Two skills:

1. memory-status (/memory-status)
   Reads 'openclaw memory status --json' and produces a per-agent
   table with: agent, identity (ok/missing/mismatch), provider,
   chunks, notes. Surfaces the L3b deploy gate's verdict matrix
   (warn-fresh / warn-swap / fail) so the user knows whether a
   rebuild is required, or whether the index is empty and will
   rebuild on first-use.

2. memory-rebuild (/memory-rebuild)
   Runs 'openclaw memory index --force' and reports the result.
   Lists the documented failure modes (auth error, EACCES,
   model-not-in-catalog) and the recovery steps for each. Warns
   before rebuilding blindly — does not auto-rebuild on unknown
   identity states.

Both skills reference the troubleshooting doc and the upstream
issue (#90361) so a user hitting this in the future has a single
documented path to resolution.

Verification:
- deploy-skills-sync.bats (existing tests cover the new skills):
  11/11 pass — they are picked up by the generic skill-sync test
- pre-commit run --files <new SKILL.md>: clean
- Frontmatter validates as YAML with name + commands (matches
  the existing model-management skill pattern)

Refs:
- #21
- openclaw/openclaw#90361
- 78890b8 (Tier 1: deploy-gate wiring)
@patelmm79
patelmm79 force-pushed the fix/memory-index-deploy-gate branch from 083afc1 to 311053e Compare June 29, 2026 01:34
@patelmm79

Copy link
Copy Markdown
Contributor Author

Force-push at 01:11 UTC: rebased onto current main after PR #34 (lane-health) merged. Resolved one conflict in scripts/install/deploy.sh — kept both lane-health sections (7+8) and added the memory-index gate as section 9. All 19 memory-index tests + 11 skill-sync tests pass on the rebased branch. shellcheck clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant