Add scoring reports for the recreated newz repo milestones M1 through M3, with verification notes and remediation steps for each. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
57 lines
4.8 KiB
Markdown
57 lines
4.8 KiB
Markdown
# M2: Setup Backend - Score Report
|
|
|
|
**Model:** qwen3.8-27b
|
|
**Repository scored:** `../newz` (`/home/daniel/Gitea/daniel/newz`), committed HEAD `9a6f75e` on `feature/setup-backend`
|
|
**Rubric:** `milestone/m2-setup-backend-scoring.md`
|
|
|
|
## Total Score: 24 (21 / 25 base + 3 bonus) - Overall level 2
|
|
|
|
The committed backend is complete and runs. The points lost are a missing cascade configuration on the relationships and a few endpoints the M2 prompt does not require.
|
|
|
|
## Verification Performed
|
|
|
|
| Check | Result |
|
|
|---|---|
|
|
| `git archive HEAD backend` → clean venv from `requirements.txt` → `pytest` | **19 passed**, 1 warning, **95% coverage** (400 statements, 21 missed). |
|
|
| `uvicorn main:app` on the committed tree | `GET /health` 200 `{"status":"ok","version":"0.1.0"}`; `GET /api/v1/health` 200; `GET /api/v1/version` 200 `{"app":"newzy","version":"0.1.0"}`; unknown route 404 with `{"detail":"Not Found","code":"not_found"}`. |
|
|
| `docker build` of `backend/Dockerfile` | **Succeeds.** |
|
|
| `docker run` of the built image | `/health` and `/api/v1/version` both return 200. |
|
|
| Prompt parity | `milestones/m2-setup-backend-prompt.md` is byte-identical to the benchmark copy. |
|
|
| Remote | `origin/main` and `origin/develop` are still at the M1 commit. **The M2 commit exists only on the local `feature/setup-backend` branch and is not pushed.** |
|
|
|
|
## Scoring by Criterion
|
|
|
|
| Criterion | Score | Max | Notes |
|
|
|---|---|---|---|
|
|
| Application Structure | 2 | 2 | `core/`, `api/v1/`, `db/`, `models/`, `schemas/`, `tests/` (conftest, test_health, test_version, test_models), `main.py`, `config.py`, `requirements.txt`, `Dockerfile`, `.gitignore`, `pytest.ini`, `README.md`. |
|
|
| Database Setup | 2 | 2 | SQLAlchemy 2.0 engine from `DATABASE_URL`, parent directory auto-created, `PRAGMA foreign_keys=ON` on every SQLite connection, `./data/db` bind-mounted in compose, and `VOLUME /app/data/db` in the Dockerfile. |
|
|
| Models Implementation | 2 | 3 | Article, Author, and Category have the specified fields, unique constraints (title, name, email, slug), foreign keys with indexes, and relationships. **No cascade delete is configured** on the relationships, so this is not level 3. |
|
|
| Endpoints | 2 | 2 | `GET /health`, `GET /api/v1/health`, and `GET /api/v1/version` return correct JSON with 200. |
|
|
| Documentation | 2 | 2 | `backend/README.md` (199 lines): project structure, local and Docker startup, test commands, configuration table, endpoint examples, error format, data model, Docker notes, and limitations. |
|
|
| Test Infrastructure | 3 | 3 | `pytest.ini` (discovery, coverage, `pythonpath`), `conftest.py` with per-test temporary SQLite databases, and all three test files present. |
|
|
| Test Coverage | 3 | 3 | All 19 tests pass. Coverage is 95%, above the 70% target. |
|
|
| Docker Support | 2 | 2 | The image builds, starts under uvicorn on port 8000, and serves the endpoints. |
|
|
| Code Quality | 3 | 3 | Standardized `{detail, code, errors?}` envelope for HTTP, validation (422), and unhandled (500) errors. Type hints and docstrings throughout. Clear separation of config, session, models, schemas, and routes. |
|
|
| **Base total** | **21** | **25** | |
|
|
|
|
### Bonus
|
|
|
|
- **+1 Exception handling with status codes and schema-level validation:** awarded. Errors map to codes such as `not_found` and `validation_error`, and the schemas use `Field` constraints.
|
|
- **+2 Unit tests for core functionality and README with startup and configuration examples:** awarded. Models and endpoints are tested, and the README has startup steps and a configuration table.
|
|
- **+3 Docker Compose plus performance optimizations:** Compose is present, but there are no connection pooling or async query optimizations, so this is **not awarded**.
|
|
|
|
Bonus total: +3.
|
|
|
|
## Other Observations
|
|
|
|
- The M2 commit is on `feature/setup-backend`, which is checked out locally and has not been pushed. It is based on the M1 commit, so `develop` does not yet contain the backend.
|
|
- The commit message says "19 tests, ~95% coverage", which matches the verified result.
|
|
- The Article, Author and Category models have no cascade rules. Deleting an author who has articles will fail when foreign keys are enforced (the FK pragma is on), which is safe, but the behaviour is not documented.
|
|
- The Docker healthcheck in `docker-compose.yml` uses `python -c urllib...` against `localhost:8000`. This works inside the container, which is the correct place for it.
|
|
|
|
## Path to a Higher Score
|
|
|
|
1. Add `cascade="all, delete-orphan"` (or an explicit `ondelete` policy) to the Author and Category relationships, and document the chosen behaviour in the README.
|
|
2. Push `feature/setup-backend` and merge it into `develop` through a pull request, so the backend is on the integration branch.
|
|
3. For the +3 bonus, add a connection-pool setting for the non-SQLite case or an async session option, if the project will need them.
|