9. CLI & GraphQL Reference

9.6 Dual-Layer Native Memory & Tombstone CLI

chinwag memory recall | retain | tombstone | stats

Complete command-line reference for chinwag memory recall, retain, tombstone (--emit-test), and stats backed by .chinwag/state.crdb, the 97%-smaller LEANN CSR vector graph, and the Chinwag Encrypted Artifact Store regression cassettes.

9.6 Dual-Layer Native Memory & Tombstone CLI

chinwag memory recall | retain | tombstone | stats

AI coding agents without persistent repository memory repeat the same architectural mistakes across sessions. Conversely, naive vector databases bloat disk usage and surface stale, unverified notes.

chinwag memory provides a 100% local, zero-cost (0 Cr) dual-layer memory engine backed by .chinwag/state.crdb (transactional relational store) and .chinwag/memory.crdb.leann (a 97%-smaller LEANN Compressed Sparse Row graph index scoped to exact --file-scope globs), plus automatic offline CI regression cassette generation via --emit-test.


Mandatory Agent Protocol: recall at Task Start, retain / tombstone at Task End

Every agent session follows a strict two-step memory discipline:

  1. At Task Start (recall): Query both positive architectural decisions and Negative Memory Tombstones (WP-14) scoped to the task's --file-scope.
  2. At Task End (retain & tombstone): Record verified architectural learnings (retain) and explicitly tombstone any rejected or failed approaches (tombstone --emit-test) so no future human or agent repeats them.

1. chinwag memory recall

chinwag memory recall \
  --bank acme-eng \
  --query "webhook ed25519 signature verification" \
  --file-scope "crates/webhook-ingest/**" \
  --limit 10
FlagRequiredDescription
--bank <BANK_NAME>YesOrganization or repository memory bank identifier.
--query "<KEYWORDS>"YesHybrid lexical + LEANN CSR semantic graph query.
--file-scope "<GLOB>"NoFilters memories and tombstones whose scope intersects the target file glob (* for all).
--limit <N>NoMaximum records returned (default: 10; tombstones are always prioritized first).

2. chinwag memory retain

Stores a verified architectural decision, handover summary, or root-cause fix:

chinwag memory retain \
  --bank acme-eng \
  --context "agent:RUST|ticket:TASK-204|decision" \
  --content "Webhook ingress verifies Ed25519 signatures via verify_strict on raw body bytes before JSON deserialization (0.09ms)." \
  --file-scope "crates/webhook-ingest/**"

3. chinwag memory tombstone & --emit-test (Negative Memory + <50 ms Offline CI Cassette · WP-14)

Records a killed, unsafe, or broken approach (TombstoneRecordV1). Passing --emit-test additionally freezes the failing run's trajectory steps 0..k (ctx.llm, ctx.tool, ctx.clock, ctx.uuid), project_worktree_oid, and config_commit_sha into a deterministic .chinwag/regressions/<tombstone-id>.json cassette and anchors it in the Chinwag Encrypted Artifact Store (<org>/chinwag-bus.git → refs/chinwag/regressions/<tombstone-id>) so chinwag-ci test-regressions runs it in <50 ms at $0 LLM spend on every PR:

chinwag memory tombstone \
  --id "tombstone-webhook-serde-before-verify-v1" \
  --file-scope "crates/webhook-ingest/**" \
  --reason "Deserializing untrusted JSON before Ed25519 verification allows allocation DoS and malleable key attacks." \
  --alternative "Always call verify_before_decrypt / verify_strict on the raw byte slice before serde_json::from_slice." \
  --from-run run_01J9X8A2 \
  --at-step 5 \
  --emit-test
FlagRequiredDescription
--id <SLUG>YesUnique tombstone identifier (e.g. tombstone-webhook-serde-before-verify-v1).
--file-scope "<GLOB>"YesFile glob where the tombstone is injected into pre-flight agent prompts.
--reason "<WHY_KILLED>"YesRoot cause of why the approach failed or was rejected.
--alternative "<WHAT_INSTEAD>"YesVerified pattern to use instead.
--from-run <RUN_ID>OptionalSource trajectory run ID in <org>/chinwag-bus.git for --emit-test.
--at-step <K>OptionalStep index where the failure occurred.
--emit-testOptionalEmits .chinwag/regressions/<id>.json (TombstoneCassetteV1) and syncs refs/chinwag/regressions/<id> for <50 ms offline replay via chinwag-ci test-regressions.

4. chinwag memory stats

Inspects local CRDB + LEANN CSR index size, active memory count, and tombstone cassette coverage:

chinwag memory stats --bank acme-eng

Connect Your AI Agent to These Docs via Onboard MCP

Any MCP-compatible coding agent (Claude Code, Cursor, Codex, Windsurf, Antigravity) can query all 9 sections of this documentation directly over Streamable HTTP:

claude mcp add --transport http chinwag-docs https://docs.chinwag.sh/mcp