Skip to content

feat(skills): add moon-agent skill for driving Moon from an AI agent - #749

Merged
TinDang97 merged 1 commit into
mainfrom
feat/moon-agent-skill
Aug 27, 2026
Merged

feat(skills): add moon-agent skill for driving Moon from an AI agent#749
TinDang97 merged 1 commit into
mainfrom
feat/moon-agent-skill

Conversation

@TinDang97

Copy link
Copy Markdown
Collaborator

What

Adds .claude/skills/moon-agent/ — a skill that teaches an AI agent to operate a Moon
instance and use it as an agent data plane, plus scripts/smoke.py that exercises every
documented flow.

Why

Moon already covers what an agent usually needs three services for: scratch state (KV+TTL),
semantic recall (FT.* vector), relations (Cypher graph), full-text, and events (pub/sub).
Nothing in the repo told an agent how to drive it. The SDK README has a quick start, but not
the failure modes — and several of them fail silently rather than loudly.

Everything here was executed before it was written

The constraints below were found by running the flows against a live moon 0.8.7, not
inferred from signatures. First harness run: 26 of 29 passed; the three failures became
documentation.

Constraint Symptom if you get it wrong
vector FILTER needs --shards 1 FILTER not supported in multi-shard mode yet
text schema is (name, type, opts) tuples, not a dict ValueError: too many values to unpack
vector fields need encode_vector() indexes but never matches — silent
COSINE score is a distance, ascending "best" hit looks like the worst one
cache key must fall under the index PREFIX cache_hit permanently False, no error

Found a bug on the way: moon#748

Probing the semantic-cache path surfaced that cache_hit is inverted for COSINE /
INNER_PRODUCT (cache_search.rs:179 treats a cosine distance as a similarity). A
near-identical query misses; an unrelated query hits. L2 is correct. Filed as #748 with a
threshold sweep and the reason CI is blind to it — the unit tests assert the predicate in
isolation against the same wrong assumption.

The skill routes around it (use L2, or apply your own cut-off on score) rather than
pretending the path works.

The smoke test is not a gate that cannot fail

scripts/smoke.py was verified in both directions:

  • against plain redis-serverexit 1, 11 failures including is moon (not redis)
  • against Moon → exit 0, 22 passed at --shards 1, 21 + 1 skip at --shards 2
    (FILTER correctly skipped, not failed)

It also doubles as a regression detector for #748: reports the inversion as a SKIP with a
diagnostic today, flips to PASS once the predicate is fixed.

Notes

  • Skill only — no src/ changes, so no runtime risk. Needs skip-changelog.
  • Verified on moon 0.8.7 / moondb 0.1.1 / redis-py 8.1.0, macOS arm64.

Moon covers what an agent normally needs three services for: scratch state
(KV + TTL), semantic recall (FT.* vector search), relations (Cypher graph),
full-text, and events (pub/sub). Nothing in the repo told an agent how to use
any of it — the SDK README shows a quick start, but not the failure modes, and
several of them are silent rather than loud.

The skill has two modes. OPERATE covers bringing an instance up (always pass an
explicit --dir; an empty one means CWD and reloads stale indexes), choosing
--shards, health-checking that the listener is actually Moon and not a stray
redis-server, and shutting down with a bounded wait plus a kill -9 fallback.
USE covers the five SDK namespaces with the constraints that are not guessable
from the signatures.

Every flow was executed against a live moon 0.8.7 before being written down,
which is how the constraints were found rather than assumed:

  - vector FILTER expressions work only at --shards 1; a multi-shard instance
    answers "FILTER not supported in multi-shard mode yet"
  - the text index schema is a sequence of (name, type, opts) tuples, not a
    dict — a dict raises "too many values to unpack"
  - COSINE scores are DISTANCES, ascending, and an exact self-match scores
    near-zero rather than zero because of quantization
  - vector fields must be wrapped in encode_vector(); a plain list silently
    fails to index
  - semantic-cache entries are only visible to FT.CACHESEARCH when the key
    falls under the index PREFIX — outside it, cache_hit is permanently false
    and nothing is raised

Probing the cache path also surfaced moon#748: cache_hit is inverted for
COSINE and INNER_PRODUCT indexes, so a near-identical query misses and an
unrelated query hits. The skill routes around it (use L2, or apply your own
cut-off on the score) until it is fixed.

scripts/smoke.py exercises all of it and doubles as a regression detector: it
reports the #748 inversion as a SKIP with a diagnostic today and flips to PASS
once the predicate is corrected. Verified to exit 1 against a plain
redis-server and 0 against Moon, so it is not a gate that cannot fail.

author: Tin Dang
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 47 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 839a15f6-caae-4c2b-9211-7fd55dafc654

📥 Commits

Reviewing files that changed from the base of the PR and between 0173ab1 and bac2ff9.

📒 Files selected for processing (2)
  • .claude/skills/moon-agent/SKILL.md
  • .claude/skills/moon-agent/scripts/smoke.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@TinDang97 TinDang97 added the skip-changelog Skip the CHANGELOG.md update gate for this PR label Aug 27, 2026
@TinDang97
TinDang97 merged commit 7e4e3e5 into main Aug 27, 2026
24 checks passed
@TinDang97
TinDang97 deleted the feat/moon-agent-skill branch August 27, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Skip the CHANGELOG.md update gate for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant