From 388b37e471f088ecf5d587a96dd0e1fe9a95e859 Mon Sep 17 00:00:00 2001 From: Robert Helewka Date: Sun, 26 Apr 2026 06:35:11 -0400 Subject: [PATCH] fix(search): require library match and preserve raw scores for RRF Replace OPTIONAL MATCH with MATCH for Library-Collection-Item paths to ensure results are properly scoped to libraries, and remove per-query score normalization since RRF fuses results by rank rather than score magnitude. --- docs/Red Panda Standards_Django_V1-00.md | 306 ----------------------- mnemosyne/library/services/search.py | 93 ++++--- mnemosyne/library/tests/test_search.py | 16 +- 3 files changed, 55 insertions(+), 360 deletions(-) delete mode 100644 docs/Red Panda Standards_Django_V1-00.md diff --git a/docs/Red Panda Standards_Django_V1-00.md b/docs/Red Panda Standards_Django_V1-00.md deleted file mode 100644 index d65ac4b..0000000 --- a/docs/Red Panda Standards_Django_V1-00.md +++ /dev/null @@ -1,306 +0,0 @@ -## 🐾 Red Panda Approvalβ„’ - -This project follows Red Panda Approval standards β€” our gold standard for Django application quality. Code must be elegant, reliable, and maintainable to earn the approval of our adorable red panda judges. - -### The 5 Sacred Django Criteria -1. **Fresh Migration Test** β€” Clean migrations from empty database -2. **Elegant Simplicity** β€” No unnecessary complexity -3. **Observable & Debuggable** β€” Proper logging and error handling -4. **Consistent Patterns** β€” Follow Django conventions -5. **Actually Works** β€” Passes all checks and serves real user needs - -## Environment Standards -- Virtual environment: ~/env/PROJECT/bin/activate -- Use pyproject.toml for project configuration (no setup.py, no requirements.txt) -- Python version: specified in pyproject.toml -- Dependencies: floor-pinned with ceiling (e.g. `Django>=5.2,<6.0`) - -### Dependency Pinning - -```toml -# Correct β€” floor pin with ceiling -dependencies = [ - "Django>=5.2,<6.0", - "djangorestframework>=3.14,<4.0", - "cryptography>=41.0,<45.0", -] - -# Wrong β€” exact pins in library packages -dependencies = [ - "Django==5.2.7", # too strict, breaks downstream -] -``` - -Exact pins (`==`) are only appropriate in application-level lock files, not in reusable library packages. - -## Directory Structure -myproject/ # Git repository root -β”œβ”€β”€ .gitignore -β”œβ”€β”€ README.md -β”œβ”€β”€ pyproject.toml # Project configuration (moved to repo root) -β”œβ”€β”€ docker-compose.yml -β”œβ”€β”€ .env # Docker Compose environment (DATABASE_URL=postgres://...) -β”œβ”€β”€ .env.example -β”‚ -β”œβ”€β”€ project/ # Django project root (manage.py lives here) -β”‚ β”œβ”€β”€ manage.py -β”‚ β”œβ”€β”€ Dockerfile -β”‚ β”œβ”€β”€ .env # Local development environment (DATABASE_URL=sqlite:///...) -β”‚ β”œβ”€β”€ .env.example -β”‚ β”‚ -β”‚ β”œβ”€β”€ config/ # Django configuration module -β”‚ β”‚ β”œβ”€β”€ __init__.py -β”‚ β”‚ β”œβ”€β”€ settings.py -β”‚ β”‚ β”œβ”€β”€ urls.py -β”‚ β”‚ β”œβ”€β”€ wsgi.py -β”‚ β”‚ └── asgi.py -β”‚ β”‚ -β”‚ β”œβ”€β”€ accounts/ # Django app -β”‚ β”‚ β”œβ”€β”€ __init__.py -β”‚ β”‚ β”œβ”€β”€ models.py -β”‚ β”‚ β”œβ”€β”€ views.py -β”‚ β”‚ └── urls.py -β”‚ β”‚ -β”‚ β”œβ”€β”€ blog/ # Django app -β”‚ β”‚ β”œβ”€β”€ __init__.py -β”‚ β”‚ β”œβ”€β”€ models.py -β”‚ β”‚ β”œβ”€β”€ views.py -β”‚ β”‚ └── urls.py -β”‚ β”‚ -β”‚ β”œβ”€β”€ static/ -β”‚ β”‚ β”œβ”€β”€ css/ -β”‚ β”‚ └── js/ -β”‚ β”‚ -β”‚ └── templates/ -β”‚ └── base.html -β”‚ -β”œβ”€β”€ web/ # Nginx configuration -β”‚ └── nginx.conf -β”‚ -β”œβ”€β”€ db/ # PostgreSQL configuration -β”‚ └── postgresql.conf -β”‚ -└── docs/ # Project documentation - └── index.md - -## Settings Structure -- Use a single settings.py file -- Use django-environ or python-dotenv for environment variables -- Never commit .env files to version control -- Provide .env.example with all required variables documented -- Create .gitignore file -- Create a .dockerignore file - -## Code Organization -- Imports: PEP 8 ordering (stdlib, third-party, local) -- Type hints on function parameters -- CSS: External .css files only (no inline styles, no embedded `