Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# CLAUDE.md

<!-- Add your custom instructions below. Repowise will never modify anything outside the REPOWISE markers. -->
<!-- Examples: coding style rules, test commands, workflow preferences, constraints -->

<!-- REPOWISE:START — Do not edit below this line. Auto-generated by Repowise. -->
## IMPORTANT: Codebase Intelligence Instructions for mcp-ariel-memory

> This repository is indexed by [Repowise](https://repowise.dev).
> Use the MCP tools below for orientation, discovery, and enriched context
> (documentation, ownership, history, decisions). **Always verify against
> actual source files before making changes** — the index may be stale.

Last indexed: 2026-07-15 (commit 9a92a0f)
### Entry Points
- `__main__.py`
- `mcp_server/server.py`
### Tech Stack
**Languages:** Python
**Frameworks:** Pydantic

**Infra:** Docker, Docker Compose### Architectural Layers
| Layer | Files | Purpose |
|-------|-------|---------|
| Application | 66 | |
| Service | 5 | |
| Config | 19 | |
| Utility | 21 | |
| Docs & Tooling | 43 | |
| Test | 55 | |

### Guided Tour (12 steps)
1. `README.md`
2. `server.py`
3. `__main__.py`
4. `index.js`
5. `connection.py`
6. `config.py`
... and 6 more steps
### Hotspots (High Churn)
| File | Churn | 90d Commits | Owner |
|------|-------|-------------|-------|
| `rag/engine.py` | 99.2th %ile | 32 | Ariel Memory |
| `tests/test_mcp/test_tools_e2e.py` | 98.5th %ile | 9 | Ariel Memory |
| `tests/test_hypothesis.py` | 97.7th %ile | 7 | Ariel Memory |
| `mcp_server/tools_layer.py` | 96.9th %ile | 20 | Ariel Memory |
| `shared/saga.py` | 96.2th %ile | 19 | Ariel Memory |

## Code health
Three signals: **defect risk** (the overall score), **maintainability** (smells that hurt readability/change-cost without predicting bugs), and **performance** (static performance RISK: I/O-in-loop / N+1 shapes that waste work, high-precision/low-recall). Maintainability and performance are co-equal views, never blended into the defect headline. See `docs/CODE_HEALTH.md`.

Defect risk, Hotspot health: 4.74/10 (stable) ·
Average: 7.11/10 ·
Worst: 1.0/10 (`shared/saga.py`)
Maintainability, Average: 8.71/10
Performance risk, Average: 9.82/10

### Critical biomarkers
- `tests/test_integration.py` — churn risk — impact −2.4
- `features/rate_limiting.py` — untested hotspot — impact −2.0
- `features/audit_trail.py` — untested hotspot — impact −2.0
- `graph/epistemic.py` — untested hotspot — impact −2.0
- `graph/temporal.py` — untested hotspot — impact −2.0

### Repowise MCP Tools

This repo has the Repowise MCP server configured. The tools below answer questions `grep`/`Read` cannot. Every response carries an `_meta` envelope with `index_age_days`, `indexed_commit`, and a `stale_warning` only when the index has actually diverged from HEAD — silence means the index is current.

**When to call which tool:**

| Tool | What only this tool answers |
|------|------------------------------|
| `get_answer(question)` | Synthesised answer with citations and a content-grounded `confidence`. First call for "how does X work" / "where is Y" / "why is Z". Value questions may return `grounding: "extracted"` — the verbatim source line, no synthesis involved. On low confidence returns `best_guesses` with one-line justifications. |
| `get_context(targets=[...])` | Triage card for files/modules/symbols — title, summary, signatures, `hotspot` bit, `decision_records` titles, `symbol_id`s. File targets auto-upgrade to a `verified` skeleton (every signature, ~37% of a full Read). `include=["callers"]` works on file targets too (import + call rollup). |
| `get_symbol(...)` | Source bytes with live-verified bounds. Three forms: `"path.py::Name"` (indexed symbol), `"path.py:140-180"` (live range read, ≤200 lines), `"repowise#<hex>"` (omission ref). Index misses return `fallback_lines` from a live grep instead of a dead end. |
| `search_codebase(query, mode?, kind?, symbol_kind?)` | Hybrid code search. `mode="auto"` (default) routes by query shape: an identifier → indexed symbol hits (`symbol_id`/`file`/line bounds — pipe into `get_symbol`), a path → file pages (pipe into `get_context`), prose → wiki-semantic search, mixed → hybrid (symbols first). Force a branch with `mode=symbol\|path\|concept\|hybrid`. Concept hits carry `search_method` (`embedding` vs `bm25` fallback); decision records rank below file pages unless the query is why-shaped. |
| `get_why(query, targets?)` | Architectural decision archaeology — *why* the code is shaped this way. Call before refactors or pattern divergences. Falls back to git archaeology when no ADRs exist for a file. |
| `get_risk(targets, changed_files?)` | What history says about touching these files: churn, owners, blast radius. Pass `changed_files` for PR mode → returns a `directive` (`will_break`, `missing_cochanges`, `missing_tests`). |
| `get_health(targets?, include?)` | Code-health scores + biomarker findings (defect / maintainability / performance pillars). Self-check before a PR — read the same signals the merge-gate judges your change on. Default is lean; opt in with `include`: `["accuracy"]` (does the score rank the buggy files first — precision@K + `lift`), `["signals"]` (per-file prior-defects / churn / owners / degree, targeted mode), `["churn_complexity"]` (volatile-and-complex danger-zone files), `["biomarkers"]` (all findings), and a dimension name `["performance"]` / `["defect"]` / `["maintainability"]` to filter findings to one pillar. |
| `get_dead_code(...)` | Tiered unreachable / unused-export / zombie-package findings. Run before a cleanup sprint, not before a targeted fix. |
| `get_overview(repo?)` | Architecture map + `tool_guide` recipes. One-time orientation; skip on subsequent calls in the same session. |

**Trust protocol — when a response replaces reading the source:**
- `verified: true` on any response means the served content was checked against the live working tree. **Never follow a verified response with a Read of the same lines** — you would be paying twice for identical bytes.
- `get_answer` with `confidence: "high"` or `grounding: "extracted"` is content-grounded (asserted values were verified against retrieved source; ≥1 citation is source-backed). Cite it directly. `quotes` entries `{path, lines, quote}` are verbatim live source — quote them instead of re-reading.
- Reading code: `get_context` skeleton first (~37% of a full Read), then `get_symbol` for bodies, `"path.py:a-b"` range reads for anything between symbols. Raw `Read` is for files the index marks `mostly_full` or cannot serve.
- The **only** re-read triggers: `bounds: "approximate"`, `_meta.stale_warning`, `search_method: "bm25"`, or `confidence: "low"`/`retrieval_quality: "weak"`.
- Disallowed rationalizations for extra reads: "just to be safe", "to double-check the tool", "to see the full context" (use the skeleton / a range read), "the file might have changed" (that is what `verified` already checked).

**Composition tips:**
- `get_answer` → if `confidence` is `medium`/`low`, follow `best_guesses[0].file` or `fallback_targets[0]` into `get_context`, then `get_symbol` for bytes.
- `get_context` returns `decision_records` titles → `get_why(targets=[...])` for the rationale; `hotspot: true` → `get_risk` before editing.
- PR review → `get_risk(targets=[...], changed_files=[...])`; read the `directive` block first.
- A `tombstone` error means the file was deleted/renamed since indexing — follow `successor_paths`.

### Output Distillation

- Prefer `repowise distill <cmd>` for noisy commands — test runs, builds, `git status`/`log`/`diff`, searches, file listings. It runs the command unchanged (exit code preserved) and prints a compact, errors-first rendering; every error line survives.
- Output may contain a marker like `[repowise#a1b2c3d4e5f6: 230 lines omitted (~6.1k tokens); restore: repowise expand a1b2c3d4e5f6]`. The omitted content is fully preserved — run `repowise expand <ref>` to retrieve it, or `repowise expand <ref> -q <regex>` for just the matching lines.
- Never re-run a command to see omitted output; expand the marker instead.
- For structure-level questions about a large indexed file ("what's in here", "which function handles X"), `get_context(["path"], include=["skeleton"])` returns the file with bodies elided — every signature plus the bodies of the most central symbols — at a fraction of the cost of a full Read.

### Codebase Conventions
**Commands:**
- Test: `pytest`
- Lint: `ruff check .`
- Typecheck: `mypy .`

<!-- REPOWISE:END -->
6 changes: 6 additions & 0 deletions .pytest_cache/v/cache/lastfailed
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"tests/test_hypothesis.py::test_chaos_db_locked_graceful": true,
"tests/test_importance_scheduler.py::test_scheduler_rescores_big_delta": true,
"tests/test_importance_scheduler.py::test_scheduler_skips_small_delta": true,
"tests/test_importance_scheduler.py::test_scheduler_retrieval_signal_boosts": true
}
Comment on lines +1 to +6

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Generated pytest cache tracked

This adds local pytest failure and collection state to version control; subsequent test runs rewrite these generated files, creating unrelated repository churn. Remove both .pytest_cache/v/cache/lastfailed and .pytest_cache/v/cache/nodeids from the change and keep the cache ignored.

Prompt To Fix With AI
This is a comment left during a code review.
Path: .pytest_cache/v/cache/lastfailed
Line: 1-6

Comment:
**Generated pytest cache tracked**

This adds local pytest failure and collection state to version control; subsequent test runs rewrite these generated files, creating unrelated repository churn. Remove both `.pytest_cache/v/cache/lastfailed` and `.pytest_cache/v/cache/nodeids` from the change and keep the cache ignored.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Codex

Loading
Loading