Skip to content

Latest commit

Β 

History

History
69 lines (55 loc) Β· 3.62 KB

File metadata and controls

69 lines (55 loc) Β· 3.62 KB

miru

Multimodal reasoning tracer β€” extract, visualize, and explain what vision-language models attend to. Attention maps, reasoning traces, visualization overlays, and a dataset recorder for training data collection.

v1.11.0 β€” 767 tests passing (9 skipped without MIRU_TEST_REAL_BACKENDS=1).

Stack

Python 3.10+ Β· FastAPI Β· Pydantic v2 Β· transformers (CLIP, optional) Β· Pillow Β· NumPy Β· uvicorn

Commands

python -m pytest tests/ -x                           # full test suite (mock backends)
MIRU_TEST_REAL_BACKENDS=1 python -m pytest tests/    # include real VLM backend tests
uvicorn miru.main:app --reload                        # dev server on :8000
python -m miru                                        # CLI entry point

Critical Constraints

  • No unwrap() β€” raise with a clear message or log + re-raise
  • No silent failures β€” logging.warning when a fallback path swallows an error
  • transformers / torch are optional β€” all code paths must work in mock-only mode
  • CLIPBackend must lazy-load weights on first infer() call β€” never at import time
  • Visualization fallback: pure-zlib PNG encoder when Pillow is absent β€” never fail silently
  • Real-backend tests are always gated behind MIRU_TEST_REAL_BACKENDS=1 β€” CI runs offline
  • Attention maps must always be float32 with values in [0, 1] β€” assert at AttentionExtractor output
  • Version bumps touch pyproject.toml + miru/__init__.py

Module Map

Module Role
miru/api/routes.py FastAPI app: GET /health, POST /analyze
miru/models/base.py VLMBackend abstract interface
miru/models/mock.py Deterministic MockVLMBackend (stable-hash Gaussian attention)
miru/models/clip.py CLIPBackend β€” HuggingFace CLIP via transformers (optional)
miru/models/qwen3vl.py Qwen3VLBackend β€” generative Qwen3-VL with cross-modal attention (optional)
miru/models/registry.py register(), get(), available(), register_defaults()
miru/attention/extractor.py Min-max norm, block-average resize, top-k hotspot detection
miru/reasoning/tracer.py Structured reasoning trace with decay confidence
miru/visualization/overlay.py Attention heatmap overlay on input image
miru/recorder.py Dataset recorder for training data collection
miru/fidelity.py Deletion-test fidelity scorecard (does masking salient pixels drop confidence?)
miru/synergy.py Modality-level visionΓ—language Shapley-interaction probe (F_syn)
miru/alerts.py SQLite rule store + webhook delivery for /explain anomalies
api/main.py Deployable FastAPI surface: /explain, /explain/batch, /annotate, etc.
miru/cli/ CLI entry points

Planning Docs

  • PLAN.md β€” current phase state and version history
  • CHANGELOG.md β€” all notable changes

Konjo Quality Framework

Three walls against AI slop β€” all enforced by CI.

Wall 1 β€” Pre-commit (bash .konjo/scripts/install-hooks.sh to activate): ruff lint, ruff format, bare-except scan, DRY check, TODO scan. Blocks the commit.

Wall 2 β€” CI gate (.github/workflows/konjo-gate.yml): Coverage β‰₯ 80% Β· mutation survival ≀ 10% Β· complexity ≀ 15 Β· file ≀ 500L Β· zero DRY violations. Blocks the merge.

Wall 3 β€” Adversarial review (local only β€” disabled in CI): git diff HEAD~1 | python3 .konjo/scripts/konjo_review.py Claude Opus adversarial critic answers 10 mandatory quality questions.

See KONJO_QUALITY_FRAMEWORK.md for the full specification.

Skills

See .claude/skills/ β€” auto-loaded when relevant. Run /konjo to boot a full session (Brief + Discovery + Plan).