docs(reports): add qwen3.5-9b milestone scores M1-M6
Add scoring reports for the newz repo milestones M1 through M6, with verification notes and remediation steps for each. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4c82e4f54c
commit
5168b13044
6 files changed
+439
No files matched your search
@@ -0,0 +1,30 @@
|
||||
# M1: Setup Git Project - Score Report
|
||||
|
||||
**Repository scored:** `../newz` (`/home/daniel/Gitea/daniel/newz`)
|
||||
**Rubric:** `milestone/m1-setup-git-project-scoring.md`
|
||||
**Model:** qwen3.5-9b
|
||||
|
||||
## Total Score: 6 / 9 (Overall level 1 - partial)
|
||||
|
||||
| Criterion | Score | Max | Notes |
|
||||
|---|---|---|---|
|
||||
| Repository Setup | 0 | 2 | Repository is named `newz` locally and `newz-qwen-9b` on origin, not `newzy`. Has `.gitignore` and an initial commit. |
|
||||
| Branch Strategy | 1 | 2 | `main` and `develop` both exist and are documented. `develop` is stale: it sits at the initial commit (`0967f70`), 5 commits behind `main` (`3e7ff19`), and lacks the `docs/` directory. |
|
||||
| Documentation Files | 3 | 3 | `.gitignore`, `README.md` (114 lines), `CONTRIBUTING.md` (168 lines), `LICENSE` (MIT), and `docs/` (BUILDING, MERGE-CONFLICTS, PUSH-CONFIG; 528 lines total) all present on `main`. |
|
||||
| Git Best Practices | 2 | 2 | Conventional commit types explained with two examples (CONTRIBUTING and BUILDING). Merge and rebase procedures documented. |
|
||||
|
||||
## Why Level 1 Rather Than Level 2
|
||||
|
||||
Level 2 requires a `newzy` repository with `main` and `develop` branches. The repository name is wrong, and `develop` was not created from `main` as step 9 of the M1 prompt requires.
|
||||
|
||||
## Other Observations
|
||||
|
||||
- The README clone URL is `github.com/daniel/newzy.git`, but the origin remote is a Gitea URL.
|
||||
- `npm run build`, `npm test` and `npm run lint` only echo placeholder text. They exit successfully but verify nothing.
|
||||
- The pre-push hook exists only as a local `.git/hooks/pre-push` and is not versioned, though `docs/PUSH-CONFIG.md` documents it.
|
||||
- The repository's git identity is `Newzy Developer <dev@newzy.dev>`.
|
||||
|
||||
## Remediation to Reach Level 2
|
||||
|
||||
1. Rename the repository and remote to `newzy`.
|
||||
2. Reset `develop` to `main` (or merge `main` into `develop`) and push.
|
||||
@@ -0,0 +1,64 @@
|
||||
# M2: Setup Backend - Score Report
|
||||
|
||||
**Repository scored:** `../newz` (`/home/daniel/Gitea/daniel/newz`), `backend/` working tree
|
||||
**Rubric:** `milestone/m2-setup-backend-scoring.md`
|
||||
**Model:** qwen3.5-9b
|
||||
|
||||
## Total Score: 17 / 25 base (+3 bonus, 20 with bonus)
|
||||
|
||||
**As delivered, the score is 0.** `backend/config.py` defines both `model_config` and `class Config`, which Pydantic v2 rejects with `PydanticUserError: "Config" and "model_config" cannot be used together`. The application cannot be imported, so every test errors at collection. The rubric states that a score of 0 applies when "application won't run". The scores below assume that one line is fixed.
|
||||
|
||||
## Scoring by Criterion
|
||||
|
||||
| Criterion | Score | Max | Notes |
|
||||
|---|---|---|---|
|
||||
| Application Structure | 2 | 2 | All expected folders and files present: `api/v1`, `core`, `db`, `models`, `schemas`, `tests`, `main.py`, `config.py`, `requirements.txt`, `Dockerfile`, `.gitignore`, `pytest.ini`, `README.md`. |
|
||||
| Database Setup | 2 | 2 | SQLAlchemy engine and session configured for SQLite via `DATABASE_URL`. Volume mapping in `docker-compose.yml`. |
|
||||
| Models Implementation | 2 | 2 | Article, Author and Category have the specified fields, foreign keys and relationships. No cascade deletes or extra indexes, so not 3. |
|
||||
| Endpoints | 2 | 2 | `GET /health` and `GET /api/v1/version` return correct JSON. `/api/v1/health` is not implemented, though a test expects it. |
|
||||
| Documentation | 2 | 2 | `backend/README.md` (200 lines) covers endpoints with examples, startup, configuration table and schema. It overstates some things: CORS is configured but no middleware is added, and it says foreign keys are enforced, which SQLite does not do by default. |
|
||||
| Test Infrastructure | 3 | 3 | `pytest.ini`, `conftest.py`, and all three test files present. `pytest` and `pytest-asyncio` are in `requirements.txt`. |
|
||||
| Test Coverage | 1 | 3 | 8 of 16 tests fail (see below). Coverage is 68%, which is above 50% but below the 70% target. |
|
||||
| Docker Support | 1 | 2 | `Dockerfile` present and reasonable, but not built here. Once the config bug is fixed, the container should start. Also `backend/.gitignore` lists `Dockerfile`, so git ignores it and it would not be committed. |
|
||||
| Code Quality | 2 | 3 | Type hints, docstrings, and separated models, schemas and session. Exception handlers exist for `ValidationError` and generic `Exception`. But `RequestValidationError` is not handled, so 422 responses use FastAPI's default format rather than the "standardized" format the README describes. |
|
||||
| **Base total** | **17** | **25** | |
|
||||
|
||||
### Bonus
|
||||
|
||||
| Bonus | Awarded | Reason |
|
||||
|---|---|---|
|
||||
| +1 Schema-level input validation | Yes | Pydantic `Field` constraints on all schemas. |
|
||||
| +2 README with startup instructions and config examples | Yes | Local and Docker startup, environment variable table. |
|
||||
| +3 Docker Compose setup | Not counted | `docker-compose.yml` exists, but the rubric's +3 also lists performance optimizations, which are absent. |
|
||||
|
||||
Bonus total: +3.
|
||||
|
||||
## Test Results
|
||||
|
||||
Run in a temporary copy with the `config.py` fix and `httpx` added. Results: **8 failed, 8 passed**, 68% coverage.
|
||||
|
||||
Failures:
|
||||
- `test_health.py::test_api_v1_health_exists`: `/api/v1/health` is not implemented.
|
||||
- `test_models.py::test_author_unique_constraints` and `test_category_unique_constraints`: the duplicate-insert checks are fragile, and the assertion logic is wrong.
|
||||
- `test_models.py::test_article_creation` and `test_article_default_published`: SQLAlchemy errors when committing against the test database.
|
||||
- `test_models.py::test_tables_exist`: the test database has no tables, so the fixture does not create them.
|
||||
- `test_models.py::test_foreign_keys_exist`: `NameError`, `db_engine` is not in scope.
|
||||
- `test_version.py::test_version_format`: asserts the version starts with `v`, but the endpoint returns `0.1.0`. The test and the README disagree.
|
||||
|
||||
## Other Issues Found
|
||||
|
||||
1. **`config.py` import failure.** Remove the `class Config` block, which duplicates `model_config`. This blocks the whole application.
|
||||
2. **`requirements.txt` is missing `httpx`.** Starlette's `TestClient` requires it, so the test suite cannot collect without it.
|
||||
3. **`backend/.gitignore` ignores `Dockerfile`.** Remove that line so the Dockerfile is committed.
|
||||
4. **Git state.** `backend/` and `docker-compose.yml` are untracked. The `m2` commit on `main` contains only the prompt file.
|
||||
5. **Version format.** `APP_VERSION` is `0.1.0`, but the test and the prompt's example expect `v0.1.0`. Pick one and align the test and the README.
|
||||
6. **`Dockerfile` copies the whole `backend/` folder**, including `tests/` and any local `.env`. Consider a `.dockerignore`.
|
||||
|
||||
## Path to a Higher Score
|
||||
|
||||
1. Fix `config.py`, add `httpx` to `requirements.txt`, and remove `Dockerfile` from `backend/.gitignore`.
|
||||
2. Make the `test_models.py` tests create tables and use proper `IntegrityError` assertions, and fix the `db_engine` reference.
|
||||
3. Align the version format between code, tests and README.
|
||||
4. Add `/api/v1/health`, or remove its test and README reference.
|
||||
5. Add a `RequestValidationError` handler that returns the standardized error format.
|
||||
6. Build and run the Docker image to confirm it works.
|
||||
@@ -0,0 +1,77 @@
|
||||
# M3: Setup Frontend - Score Report
|
||||
|
||||
**Repository scored:** `../newz` (`/home/daniel/Gitea/daniel/newz`), `frontend/` working tree
|
||||
**Rubric:** `milestone/m3-setup-frontend-scoring.md`
|
||||
**Model:** qwen3.5-9b
|
||||
|
||||
## Total Score: 24 / 49 (Overall level 1 - partial)
|
||||
|
||||
The level-2 requirement that the project "builds successfully" is not met. `npm run build` fails at the `tsc` step, so the build script does not pass.
|
||||
|
||||
## Verification Performed
|
||||
|
||||
Run in a temporary copy of `frontend/` (node 26.11.1, `node_modules` copied from the working tree):
|
||||
|
||||
| Check | Result |
|
||||
|---|---|
|
||||
| `npm run build` (`tsc && vite build`) | **Fails.** `tsc` reports 4 `TS6133` errors: unused `render`, `ArticleCard` and `Header` imports in `src/tests/*.test.tsx`. |
|
||||
| `npx vite build` (alone) | Succeeds. Output in `dist/`. |
|
||||
| `npx vitest run` | 2 of 2 test files pass, but each test is `expect(1).toBe(1)`. |
|
||||
| `npm run lint` | **Fails.** ESLint cannot find `eslint-plugin-react`, which `.eslintrc.cjs` requires. Lint does not run. |
|
||||
| `npx playwright test --list` | **0 tests found.** `playwright.config.ts` sets `testDir: './e2e'`, but the specs live in `playwright/e2e/`. |
|
||||
| Playwright browsers | Not installed (`~/.cache/ms-playwright` missing). E2E tests were not run. |
|
||||
| `docker build` | Not run. The Dockerfile has an invalid line, described below. |
|
||||
|
||||
## Scoring by Criterion
|
||||
|
||||
| Criterion | Score | Max | Notes |
|
||||
|---|---|---|---|
|
||||
| Project Setup | 2 | 2 | All required folders present: `public/`, `src/`, `assets/`, `components/`, `pages/`, `types/`, `api/`, `tests/`. |
|
||||
| TypeScript & Dependencies | 3 | 5 | Interfaces for Article, Author, Category, and `ApiResponse<T>` exist. `react-router-dom ^6.20.0` and `lucide-react` are installed. The components do not use the shared types from `src/types/`; `ArticleCard` and `Home` define their own inline types. The build fails with TypeScript errors, so the level-4 requirement is not met. |
|
||||
| UI Components | 4 | 5 | `Header`, `Layout`, `ArticleCard`, `AuthorAvatar`, `CategoryBadge` all exist and render. The `Search` icon from the acceptance criteria is missing. Header links are icon-only with no accessible name, so role-based queries like `getByRole('link', { name: /home/i })` cannot match. |
|
||||
| React Router Configuration | 5 | 5 | `BrowserRouter` in `App.tsx`, routes for `/`, `/articles`, `/categories`, pages imported from `src/pages/`, and `<Link>` used for navigation. |
|
||||
| Page Components | 3 | 3 | `Home`, `ArticlePage`, `CategoriesPage` exist under `pages/` and are mapped in `App.tsx`. |
|
||||
| API Integration | 2 | 2 | `src/api/client.ts` has a base URL, a fetch wrapper with error handling, and typed endpoint functions. Nothing in the app calls it yet. |
|
||||
| Unit Testing | 1 | 4 | Vitest is configured and both test files run. Neither test checks anything (`expect(1).toBe(1)`), and the comments say routing context is tested via E2E, which never runs. |
|
||||
| E2E Testing | 1 | 6 | Playwright is installed and two spec files exist, but `testDir` is wrong, so zero tests are discovered. Browsers are not installed. |
|
||||
| Docker Configuration | 1 | 3 | Multi-stage Dockerfile (Node build, Nginx serve) and a root `docker-compose.yml` with a frontend service on port `3000:80` and `depends_on: backend`. But the Dockerfile contains `COPY package-lock.json* . 2>/dev/null \|\| true`, which is not valid Dockerfile syntax, so the build should fail. The compose file also mounts `./data` onto `/usr/share/nginx/html`, which hides the built files. |
|
||||
| Code Quality | 0 | 2 | ESLint does not run, so the "linting passes" requirement is not met. |
|
||||
| Documentation | 2 | 3 | `frontend/README.md` (253 lines) covers setup, scripts, Lucide icons, routing, Docker, and known limitations. It has no per-component prop documentation, so it does not reach level 3. |
|
||||
| **Total** | **24** | **49** | |
|
||||
|
||||
### Bonus
|
||||
|
||||
None awarded.
|
||||
|
||||
- **+1 ESLint:** not awarded, because the ESLint config is not runnable.
|
||||
- **+2 TypeScript strict mode with react-router types:** not awarded. `strict: true` is set, but the build fails under `tsc`.
|
||||
- **+3 Compose orchestrating both services, SPA fallback, and E2E routing tests:** partially met. The compose file orchestrates both services and `nginx.conf` has `try_files ... /index.html`. The E2E routing tests do not run.
|
||||
|
||||
### Critical Requirements Checklist (from rubric)
|
||||
|
||||
- [x] `lucide-react` installed
|
||||
- [x] `react-router-dom` installed
|
||||
- [x] `BrowserRouter` configured in `App.tsx`
|
||||
- [x] `<Link>` used for navigation
|
||||
|
||||
## Other Issues Found
|
||||
|
||||
1. **`npm run build` fails** because unused imports in `src/tests/*.test.tsx` trip `noUnusedLocals`.
|
||||
2. **ESLint cannot run.** `eslint-plugin-react` is required by `.eslintrc.cjs` but is not in `devDependencies`.
|
||||
3. **Playwright discovers no tests.** `playwright.config.ts` says `testDir: './e2e'`; the specs are in `playwright/e2e/`.
|
||||
4. **Invalid Dockerfile line.** `COPY package-lock.json* . 2>/dev/null || true` is not valid Docker syntax. Use `COPY package.json package-lock.json* ./`.
|
||||
5. **Compose volume shadows the build output.** `./data:/usr/share/nginx/html` in the root `docker-compose.yml` replaces the built `dist` with the host `data/` folder. Remove that volume.
|
||||
6. **Tailwind is not set up.** `globals.css` uses `@tailwind` directives, but `tailwindcss` is not installed, and there is no `tailwind.config` or PostCSS config. The directives pass through unprocessed.
|
||||
7. **Favicon and logo references.** `public/index.html` links `/vite.svg`, which does not exist. `src/assets/logo.svg` is not used.
|
||||
8. **Test placeholders.** The unit tests assert nothing and do not exercise the components.
|
||||
9. **Git state.** `frontend/`, root `docker-compose.yml`, and `milestones/m3-setup-frontend-prompt.md` are untracked. `backend/` and the M1 files are also uncommitted.
|
||||
|
||||
## Path to a Higher Score
|
||||
|
||||
1. Remove the unused imports in the test files so `npm run build` passes.
|
||||
2. Add `eslint-plugin-react` to `devDependencies`, and make the lint script pass.
|
||||
3. Fix `playwright.config.ts` `testDir` to `./playwright/e2e`, install browsers with `npx playwright install`, and run the E2E suite.
|
||||
4. Replace the placeholder unit tests with real tests for Header (icons and links) and ArticleCard, wrapped in `MemoryRouter`.
|
||||
5. Fix the Dockerfile `COPY` line, remove the `./data` volume from the root compose file, and run `docker compose build frontend`.
|
||||
6. Add the `Search` icon, use the shared types from `src/types/` in components, and give icon-only links an `aria-label`.
|
||||
7. Add `tailwindcss`, `postcss` and `autoprefixer` with config files, or remove the `@tailwind` directives.
|
||||
@@ -0,0 +1,71 @@
|
||||
# M4: Setup Developer Environment - Score Report
|
||||
|
||||
**Repository scored:** `../newz` (`/home/daniel/Gitea/daniel/newz`), working tree
|
||||
**Rubric:** `milestone/m4-setup-developer-environment-scoring.md`
|
||||
**Model:** qwen3.5-9b
|
||||
|
||||
## Total Score: 13 / 29 base (+1 bonus, 14 with bonus) - Overall level 1 (partial)
|
||||
|
||||
The level-2 requirement that the implementation "builds successfully" is not met. `docker compose config` rejects the root `docker-compose.yml`, so the stack cannot be brought up as written.
|
||||
|
||||
## Verification Performed
|
||||
|
||||
| Check | Result |
|
||||
|---|---|
|
||||
| `docker compose config -q` (root) | **Fails.** `service "backend" depends on undefined service "backend-db": invalid compose project`. A warning also says the `version` key is obsolete. |
|
||||
| `make -n dev test clean restart` | Expands correctly. The Makefile is syntactically valid. |
|
||||
| `make test` contents | Runs `npm run test` from the **repo root**, where `package.json` has only an `echo` placeholder. It does not run the frontend tests in `frontend/`. Also `cd backend && pytest`. No E2E step. |
|
||||
| Tracked-file check | `backend/Dockerfile`, `backend/.dockerignore`, `frontend/.dockerignore`, and `.env.example` are **not tracked** by git. |
|
||||
| Ignore-rule check | Root `.gitignore` line 57 (`.dockerignore`) matches `backend/.dockerignore` and `frontend/.dockerignore`. Root `**/.env*` matches `.env.example`. `backend/.gitignore` line 14 (`Dockerfile`) matches `backend/Dockerfile`. A fresh clone would lack all of these. |
|
||||
| Backend CORS | `BACKEND_CORS_ORIGINS` and `FRONTEND_API_URL` are not read anywhere in `backend/`. `config.py` defines `CORS_ORIGINS` but `main.py` adds no CORS middleware. |
|
||||
| `docker build` | Not run. |
|
||||
|
||||
## Scoring by Criterion
|
||||
|
||||
| Criterion | Score | Max | Notes |
|
||||
|---|---|---|---|
|
||||
| docker-compose Configuration | 1 | 4 | Both services are defined with the right build contexts, ports 3000 and 8000, a bridge network, a bind-mounted `./data/db` volume, and `restart: unless-stopped`. But the file fails validation: the backend depends on an undefined `backend-db` service, and the frontend waits on `service_healthy` from a backend that has no healthcheck. |
|
||||
| Environment Configuration | 2 | 3 | `.env` and `.env.example` both list the required variables with defaults. `.env.example` is not tracked by git, and it has no per-variable descriptions. The README has the variable table. |
|
||||
| Development Commands | 3 | 4 | `dev`, `stop`, `restart`, `backend-start`, `frontend-start`, `build`, `logs`, `clean`, and shell targets are all present. `test` does not run the frontend tests (it hits the root placeholder) and has no E2E step. `clean` removes volumes and images. |
|
||||
| Security & Best Practices | 2 | 3 | `.env`, `*.local`, and `data/` are excluded from git. The `data/.gitignore` pattern is correct. But `.env.example` and both `.dockerignore` files are excluded by the same rules, so they are not committed. |
|
||||
| Documentation | 3 | 3 | Root `README.md` covers prerequisites, quick start, service table, port mappings, network, volume, environment variables, Makefile commands, and a troubleshooting section. One troubleshooting command is wrong: `curl http://frontend:3000/health` targets nginx on port 80 and a `/health` route that the backend serves, not the frontend. |
|
||||
| Service Communication | 1 | 2 | Services share a bridge network. But inter-service communication was not verified. Backend CORS is unimplemented, and the nginx `/api` proxy is the only path between the frontend and backend. |
|
||||
| Build Optimization | 1 | 3 | The backend image uses `python:3.11-slim` and `pip --no-cache-dir`. The frontend Dockerfile is multi-stage with nginx. But the frontend Dockerfile still contains the invalid `COPY package-lock.json* . 2>/dev/null || true` line, so the build should fail (not verified with `docker build`). The backend Dockerfile is unchanged from M2 and copies the whole directory including tests. Neither `.dockerignore` is committed. |
|
||||
| **Base total** | **13** | **29** | |
|
||||
|
||||
### Bonus
|
||||
|
||||
- **+1 Logs command and restart policies:** awarded. The Makefile has `logs`, and both services set `restart: unless-stopped`.
|
||||
- **+2 README Docker troubleshooting and `.dockerignore`:** not awarded. The README troubleshooting section exists, but the `.dockerignore` files are not committed.
|
||||
- **+3 Full test automation and clean removes images:** not awarded. `make test` does not run the frontend tests, and the E2E suite is not included.
|
||||
|
||||
Bonus total: +1.
|
||||
|
||||
### Critical Requirements Checklist (from rubric)
|
||||
|
||||
- [x] `docker-compose.yml` defines both backend and frontend services
|
||||
- [x] Ports 3000 and 8000 configured
|
||||
- [x] Docker network defined
|
||||
- [x] `.env.example` and `.env` present (but `.env.example` is not tracked)
|
||||
|
||||
## Other Issues Found
|
||||
|
||||
1. **Compose file fails validation.** Remove the `backend-db` dependency, or define that service. Also add a healthcheck to the backend if the frontend should wait on `service_healthy`. Drop the obsolete `version:` key.
|
||||
2. **`.env.example` is git-ignored.** Root `.gitignore` line 10 (`**/.env*`) matches it. Add `!.env.example`.
|
||||
3. **`.dockerignore` files are git-ignored.** Root `.gitignore` line 57 (`.dockerignore`) matches both files. Remove that line, or scope it to the root.
|
||||
4. **`backend/Dockerfile` is git-ignored.** `backend/.gitignore` line 14 lists `Dockerfile`. A fresh clone cannot build the backend image.
|
||||
5. **Frontend Dockerfile is broken.** Remove the `COPY package-lock.json* . 2>/dev/null || true` line and use `COPY package.json package-lock.json* ./`. The stage uses `node:18-alpine`, but the M4 prompt suggests `node:20-alpine`.
|
||||
6. **`make test` is incomplete.** It runs the root placeholder `npm test`, not `frontend/`'s Vitest suite, and does not run Playwright. Change it to `cd frontend && npm test`, and add the E2E step once the suite is discoverable.
|
||||
7. **Unused environment variables.** `BACKEND_CORS_ORIGINS` and `FRONTEND_API_URL` are not read by the backend or frontend. Wire them up or drop them from `.env`.
|
||||
8. **`make clean` deletes the data `.gitignore`.** `rm -rf data/` removes `data/.gitignore` along with the database. Remove only `data/db`.
|
||||
9. **Backend Dockerfile is not optimized.** It copies the whole directory including `tests/` and `pytest.ini`. Copy only the runtime code.
|
||||
10. **Root `README.md` is partly out of date.** It says the database is at `/data/db/newzy.db` in the volume section, and the troubleshooting `curl` targets the wrong service.
|
||||
|
||||
## Path to a Higher Score
|
||||
|
||||
1. Fix the compose file so `docker compose config` passes.
|
||||
2. Fix the `.gitignore` rules so `.env.example`, both `.dockerignore` files, and `backend/Dockerfile` are committed.
|
||||
3. Fix the frontend Dockerfile `COPY` line and run `docker compose build`.
|
||||
4. Make `make test` run the real frontend and backend tests.
|
||||
5. Add a backend healthcheck and verify frontend-to-backend calls through the nginx proxy.
|
||||
6. Change `make clean` to remove only `data/db` so it leaves `data/.gitignore` in place.
|
||||
@@ -0,0 +1,99 @@
|
||||
# M5: Setup Authentication - Score Report
|
||||
|
||||
**Repository scored:** `../newz` (`/home/daniel/Gitea/daniel/newz`), working tree (auth work is uncommitted)
|
||||
**Rubric:** `milestone/m5-setup-authentication-scoring.md`
|
||||
**Model:** qwen3.5-9b
|
||||
|
||||
## Total Score: 31 / 46 (30 base, +1 bonus), assuming the blockers below are fixed
|
||||
|
||||
**As delivered, the score is 0.** The backend does not start. This matches the rubric's rule that 0 applies when "application won't run". The blockers are listed in the next section. The score above is what the code earns once they are fixed.
|
||||
|
||||
## Blockers Found
|
||||
|
||||
| # | Problem | Where | Evidence |
|
||||
|---|---|---|---|
|
||||
| 1 | `config.py` mixes `model_config` with `class Config` | `backend/config.py` | Carried over from M2. Pydantic v2 raises `PydanticUserError` on import. |
|
||||
| 2 | Circular import between models and database | `backend/app/database.py` imports `Base` from `.models`; `backend/app/models.py` imports `Base` from `.database` | `ImportError: cannot import name 'Base' from partially initialized module 'app.models'` |
|
||||
| 3 | `jwt` (PyJWT) is imported, but `requirements.txt` lists `python-jose` only | `backend/app/auth.py` line 14; `backend/requirements.txt` | `ModuleNotFoundError: No module named 'jwt'` on a clean install |
|
||||
| 4 | Placeholder routes use SQLAlchemy classes as `response_model` | `backend/main.py` `/api/articles`, `/api/authors`, `/api/categories` | `FastAPIError: Invalid args for response field` on import |
|
||||
| 5 | `httpx` is missing (needed by Starlette's `TestClient`) | `backend/requirements.txt` | `RuntimeError: ... requires the httpx2 package` |
|
||||
|
||||
Blocker 2 also means `Base` used by `app.models` is not the `Base` that `lifespan` calls `create_all` on, so the `users` table would never be created at startup.
|
||||
|
||||
## Verification Performed
|
||||
|
||||
Run in temporary copies. The temp copy was patched step by step so later failures could be seen. Patches were only applied outside the repo.
|
||||
|
||||
| Step | Result |
|
||||
|---|---|
|
||||
| Clean install of `requirements.txt`, then `import app.models` | Fails on `import jwt`. |
|
||||
| Add PyJWT, fix `config.py` | Fails on the circular import. |
|
||||
| Point `database.py` at `db.session.Base`, add httpx | `main` imports, but the placeholder routes fail (blocker 4). |
|
||||
| Remove the three placeholder `response_model`s | `main` imports. Suite: 8 failed, 9 passed, 9 errors. |
|
||||
| `test_auth.py` | All tests that use the `auth_client` fixture error. Two causes: the temp copy had no `./data/db` directory (`unable to open database file`), and `test_auth.py` never imports `app`, so the fixture would raise `NameError` once the database error was resolved. `test_jwt_token_structure` does not use the fixture. |
|
||||
| Frontend `npm run build` | Fails at `tsc`: 4 `TS6133` errors in `src/tests/*.test.tsx` (unchanged from M3). |
|
||||
| Frontend `npx vite build` | Succeeds. |
|
||||
| Frontend `npx vitest run` | 2 of 2 pass. The tests are still `expect(1).toBe(1)` placeholders. |
|
||||
|
||||
## Scoring by Criterion
|
||||
|
||||
| Criterion | Score | Max | Notes |
|
||||
|---|---|---|---|
|
||||
| Backend User Model | 2 | 3 | Fields are correct: `id`, `username` (String(60), unique, indexed), `password_hash` (String(128)), `created_at`. The model is not usable because of blocker 2, and the `users` table is not registered on the app's `Base`. |
|
||||
| Password Hashing | 3 | 4 | `hash_password` uses PBKDF2-HMAC-SHA256 with 120,000 iterations and a `secrets.token_hex(16)` salt. The stored format is `salt$digest`. `verify_password` uses `secrets.compare_digest`. The hashing test does not run (see above). |
|
||||
| JWT Token System | 4 | 5 | `create_token` sets `sub`, `iat` and `exp` (7 days), signs with HS256, and reads `HN_SECRET_KEY` with a clearly marked dev default. `get_current_user` decodes and checks the user. Deduction: `jwt` is not in requirements (blocker 3). |
|
||||
| Backend Auth Endpoints | 3 | 5 | `POST /api/auth/register` returns 201 with `{token, username}`. `POST /api/auth/login` checks the hash and returns 401 on failure. Deductions: `get_current_user` returns `user.model_dump(...)`, which SQLAlchemy models do not have, so `/api/auth/me` returns 500 for a valid token. Also `logout` requires a token, so an anonymous logout returns 401 (the test expects 204). The duplicate-username check returns 409, while the QA notes say 400. The username regex in `RegisterIn` returns 422 before the 400 check runs. |
|
||||
| Frontend Authentication Context | 3 | 5 | `AuthProvider` provides `username`, `ready`, `login`, `register` and `logout`. `useAuth` is exported. On load it calls `api.me` with the stored token and clears the token on failure. Deduction: `Login.tsx` and `Register.tsx` call `api.login` and `api.register` directly, not the context. They never store the token or set `username`, so after a successful login the app stays on the login screen. |
|
||||
| Token Storage & Management | 2 | 3 | `TOKEN_KEY = 'AUTH_TOKEN'` is used consistently. Logout removes it. Restoration clears invalid tokens. The login and register pages do not store the token (see above). |
|
||||
| API Client Auth Methods | 4 | 4 | `login`, `register`, `logout` and `me` are implemented. `me` sends the Bearer header. Non-OK responses throw. `logout` removes the token even if the request fails. The `TokenResponse` and `MeResponse` types are duplicated in `client.ts` instead of imported from `types/auth.ts`. |
|
||||
| Frontend Auth Pages | 4 | 6 | `Login.tsx` and `Register.tsx` have labelled fields, client-side validation (username pattern, 8-character password, matching passwords), a loading state with a spinner, and error messages. `SignOut.tsx` clears the token and redirects, but **no route points to it** in `App.tsx`. No success feedback is shown. |
|
||||
| Security Implementation | 3 | 4 | PBKDF2 at 120,000 iterations, HS256, `HN_SECRET_KEY` from the environment, and no plaintext passwords. Deduction: no CORS middleware, and `CORS_ORIGINS` in `config.py` is not used. |
|
||||
| Git Configuration | 2 | 2 | `backend/.gitignore` excludes `*.db`, `*.sqlite`, `data/` and `.env`. `data/.gitignore` lists the required patterns. |
|
||||
| **Base total** | **30** | **46** | |
|
||||
|
||||
### Bonus
|
||||
|
||||
- **+1 Input validation and password strength:** awarded. The username regex is `^[a-zA-Z0-9_]{3,20}$` and passwords need at least 8 characters, enforced on both server and client.
|
||||
- **+2 Error messages do not leak and rate-limit placeholders:** not awarded. Login errors are generic, but there are no rate-limit placeholder comments.
|
||||
- **+3 Complete error handling and protected-route redirect:** not awarded. The redirect is implemented, but error handling is incomplete (`/me` returns 500, and the login flow dead-ends).
|
||||
|
||||
Bonus total: +1.
|
||||
|
||||
### Critical Requirements Checklist (from rubric)
|
||||
|
||||
**Must have for score above 1:**
|
||||
- [x] Passwords never stored as plaintext
|
||||
- [x] PBKDF2 with at least 120,000 iterations (SHA256)
|
||||
- [x] JWT uses HS256 (no `none`)
|
||||
- [x] `HN_SECRET_KEY` used for signing
|
||||
- [x] Token `exp` is 7 days after `iat`
|
||||
|
||||
**Must have for score above 3:**
|
||||
- [x] Context provides login, register, logout (defined in `auth.tsx`)
|
||||
- [ ] Login and register pages use the context, so `AUTH_TOKEN` is stored on login
|
||||
- [x] Session check on load calls `/api/auth/me`
|
||||
- [ ] `401` on invalid tokens works end to end: `/api/auth/me` returns 500 for a valid token, and that path is not tested
|
||||
|
||||
Two of the checks marked above 3 fail, so the score-above-3 requirements are not met.
|
||||
|
||||
## Other Issues Found
|
||||
|
||||
1. **Two model layers.** `backend/models/` (SQLAlchemy `Base` from `db/session.py`) and `backend/app/models.py` (a separate `Base`) both exist. `Article`, `Author` and `Category` are defined in `models/`, and `User` in `app/`. Pick one.
|
||||
2. **`data/.gitignore` was overwritten.** M4 specified "ignore everything except `keep_files.txt`". M5 replaced it with a pattern list, which removes the M4 rule. The file also has a malformed last line (`# OS specific files.DS_Store`).
|
||||
3. **`docker-compose.yml` still references `backend-db`.** This is an M4 blocker that remains. The backend also has no healthcheck, but the frontend waits on `service_healthy`.
|
||||
4. **`M5_AUTH_IMPLEMENTATION.md` overstates the work.** It marks items complete and states that the security checks are satisfied, but the backend does not start and the login page does not complete the flow. Treat it as a plan, not as a test record.
|
||||
5. **`SignOut.tsx` is unreachable.** Add a `/signout` route, or wire the sign-out button to it.
|
||||
6. **Frontend build still fails** on the unused test imports (M3 item).
|
||||
|
||||
## Path to a Higher Score
|
||||
|
||||
1. Remove `class Config` from `config.py`.
|
||||
2. Break the cycle: have `app/database.py` import `Base` from `db/session.py`, and `app/models.py` use that same `Base`.
|
||||
3. Add `PyJWT` to `requirements.txt` and remove `python-jose`, or switch the code to `jose`.
|
||||
4. Remove the `response_model=list[...]` of SQLAlchemy classes on the placeholder routes, or use Pydantic schemas.
|
||||
5. Add `httpx` to `requirements.txt`.
|
||||
6. Fix `get_current_user` to return the user object, or a dict built from its fields (`{"username": user.username}`), not `model_dump`.
|
||||
7. Make `Login.tsx` and `Register.tsx` call `useAuth().login` and `useAuth().register`.
|
||||
8. Add `from main import app` to `test_auth.py`, and make the tests create `./data/db` before running.
|
||||
9. Route `SignOut.tsx`, and make `logout` accept anonymous calls (return 204 without a token).
|
||||
10. Fix the frontend `tsc` errors so `npm run build` passes.
|
||||
@@ -0,0 +1,98 @@
|
||||
# M6: Setup Admin Area - Score Report
|
||||
|
||||
**Repository scored:** `../newz` (`/home/daniel/Gitea/daniel/newz`), working tree (M6 work is uncommitted)
|
||||
**Rubric:** `milestone/m6-setup-admin-area-scoring.md`
|
||||
**Model:** qwen3.5-9b
|
||||
|
||||
## Total Score: 24 / 51 (23 base, +1 bonus) - Overall level 0
|
||||
|
||||
Overall level 0 applies because the rubric's level-0 conditions are met: the Lexical editor is not integrated (the packages are installed but never imported), and the backend does not start. The numeric score assumes the import blockers are fixed. Most of the admin UI is placeholder or stubbed, so the numeric score is limited by that as well.
|
||||
|
||||
## Blockers Found
|
||||
|
||||
| # | Problem | Where | Evidence |
|
||||
|---|---|---|---|
|
||||
| 1 | `HTTPAuthorizationCredentials` is imported from `fastapi` | `backend/main.py` line 10 | `ImportError: cannot import name 'HTTPAuthorizationCredentials' from 'fastapi'` (confirmed in a temp copy). It lives in `fastapi.security`. |
|
||||
| 2 | `Boolean` used but not imported | `backend/app/models.py` line 7 and line 21 | The import line is `from sqlalchemy import DateTime, ForeignKey, Integer, String, Text`. This raises `NameError` on import. Not reached in the temp run because blocker 1 fires first. |
|
||||
| 3 | `config.py` still has `class Config` alongside `model_config` | `backend/config.py` line 29 | Carried over from M2. Pydantic v2 rejects this. |
|
||||
| 4 | Admin dependency returns `user.model_dump(...)` on a SQLAlchemy object | `backend/app/auth.py` `get_current_admin` | SQLAlchemy models have no `model_dump`. Admins get 500 on every admin route, and the `current_user["id"]` lookup in create also depends on this dict. |
|
||||
| 5 | `Article` model has no `url` or `points` columns | `backend/models/article.py` | `ArticleAdminIn`/`ArticleAdminOut` and every admin endpoint use `url` and `points`. Search on `Article.url` and creating an article with `url=` would fail at runtime. |
|
||||
|
||||
Earlier blockers from M2 and M5 are still unresolved: the missing `httpx` in `requirements.txt`, the placeholder `response_model=list[Article]` routes, and the `jwt` / `python-jose` mismatch.
|
||||
|
||||
## Verification Performed
|
||||
|
||||
| Check | Result |
|
||||
|---|---|
|
||||
| `import main` in a clean venv (`requirements.txt` + PyJWT + httpx) | Fails on blocker 1. |
|
||||
| `npm run build` (frontend) | Fails at `tsc` with the same 4 `TS6133` errors in `src/tests/*.test.tsx` (unchanged since M3). |
|
||||
| `npx vite build` | Succeeds. |
|
||||
| `npx vitest run` | 2 of 2 pass. Both are still `expect(1).toBe(1)` placeholders. |
|
||||
| `npm run lint` | Fails. ESLint cannot find `eslint-plugin-react` (unchanged since M3). |
|
||||
| Admin tests | None exist. `backend/tests/` has no admin test file, and `frontend/src/tests/` has no admin test. |
|
||||
|
||||
## Scoring by Criterion
|
||||
|
||||
| Criterion | Score | Max | Notes |
|
||||
|---|---|---|---|
|
||||
| Database Schema | 1 | 3 | `is_admin = Mapped[bool] = mapped_column(Boolean, default=False, index=True)` is the right definition, but `Boolean` is not imported (blocker 2). There is no migration for existing databases. `seed_admin.py` creates or upgrades an admin user, which covers the seed requirement. |
|
||||
| Backend Admin Protection | 2 | 4 | `get_current_admin` validates the JWT and checks `is_admin`, returns 403 with "Admin access required", and every admin route depends on it. Deductions: the success path returns `model_dump` (blocker 4), so admins also get 500. No security headers or rate-limit placeholder. |
|
||||
| Admin List Endpoint | 2 | 4 | `GET /api/admin/items` returns `items`, `total`, `page`, `page_size` and `total_pages`, so pagination works in principle. Search uses `ilike` on title and url, which meets the requirement in code but fails at runtime (blocker 5). Sort ignores `sort_order` for `created_at`: the code always sorts newest first, so ascending date order is not possible. |
|
||||
| Create Endpoint | 2 | 3 | `POST /api/admin/items` is admin-only, validates the URL scheme, and enforces `points >= 0` and `title` length. The `Article(...)` constructor passes `url=` and `points=`, which the model does not have (blocker 5). Author defaults to `1` if the id is not on the dict, which is not a valid author lookup. |
|
||||
| Update Endpoint | 2 | 3 | `PUT /api/admin/items/{id}` is admin-only and maps title, url, content and points. No optimistic UI. The frontend does show an error message on failure. |
|
||||
| Delete Endpoint | 2 | 3 | `DELETE` is admin-only and sets `published = False` (soft delete, which the rubric lists as optional). It does not remove the record, so the hard-delete part of level 3 is not met. The delete endpoint is not reachable from the UI (see Delete Confirmation). |
|
||||
| Frontend Layout | 3 | 4 | `AdminLayout` renders the sidebar only when `isAdmin` is true and shows an "Access Denied" message otherwise. The sidebar is 250px, with a mobile toggle, an overlay, and a "Back to Site" link. Non-admins are redirected to `/` by the catch-all route. Deduction: `App.tsx`, `AdminDashboard.tsx` and `EditItemPage.tsx` each wrap their content in `<AdminLayout>`, so admin pages render two nested sidebars. |
|
||||
| List View Components | 1 | 6 | `AdminDashboard.tsx` has a search box and a sort dropdown, but no list. It shows a placeholder: "Admin dashboard will be populated with items when API is ready." There is no pagination, no page-size selector, no edit or delete buttons, and no empty state. `adminApi.listItems` returns a hard-coded empty result without calling the API. |
|
||||
| Edit View Components | 2 | 4 | `EditItemPage.tsx` has title, url, a content editor, points, and a Save button that calls `createItem` or `updateItem`. It shows a loading state ("Saving...") and a success message. Deductions: pre-fill is broken because `adminApi.getItem` is a stub that returns an empty object, so edit mode shows a blank form. Cancel navigates away and does not revert. The edit route `/admin/items/:id/edit` is not linked from anywhere. |
|
||||
| Delete Confirmation | 4 | 5 | `DeleteConfirmation.tsx` has an `AlertCircle` warning icon, a title with the item name, the text "This action cannot be undone", Cancel and "Yes, Delete" buttons, and an overlay that calls `onCancel` on click. Deductions: ESC does not close it, and the component is **never imported or rendered**, so the delete flow cannot be reached from the dashboard. |
|
||||
| Lexical Editor | 1 | 5 | `@lexical/react` and `lexical` are in `package.json`, but nothing in `src/` imports them. `LexicalEditor.tsx` is a plain `<textarea>` with a React-controlled value. The toolbar buttons (bold, italic, underline, headings, lists, link) have `onClick={() => {}}` and do nothing. Content is saved as plain text. |
|
||||
| Frontend API Client | 1 | 4 | `adminApi` lives in `api/client.ts` rather than the specified `adminApi.ts`. Create, update and delete use `authenticatedClient`, so the Bearer header is sent and non-OK responses throw. `listItems` and `getItem` are stubs that return fake data without making a request. Sort parameters are not part of `listItems`. |
|
||||
| **Base total** | **23** | **51** | |
|
||||
|
||||
### Bonus
|
||||
|
||||
- **+1 Soft delete (`published = False`):** awarded.
|
||||
- **+1 Audit logging, +2 loading skeleton / empty-state / pagination metadata, +3 responsive and keyboard shortcuts:** not awarded. Mobile sidebar behaviour exists, but there are no keyboard shortcuts, no skeleton, and no empty-state view. The backend does return `total_pages`, but the frontend never shows pagination.
|
||||
|
||||
Bonus total: +1.
|
||||
|
||||
### Critical Requirements Checklist (from rubric)
|
||||
|
||||
**Must have for score above 2:**
|
||||
- [x] `is_admin` field exists in the database model (blocked by the missing `Boolean` import)
|
||||
- [x] Backend validates both the JWT and the `is_admin` flag
|
||||
- [x] Non-admin users receive 403 Forbidden
|
||||
- [x] Error message is "Admin access required"
|
||||
|
||||
**Must have for score above 4:**
|
||||
- [x] All admin CRUD endpoints are protected server-side
|
||||
- [x] Search is filtered on the backend (title OR url), in code
|
||||
- [ ] Sort parameters change the query (`created_at` ignores `sort_order`, and the frontend never sends sort parameters)
|
||||
|
||||
**Must have for score above 6:**
|
||||
- [ ] Delete requires an explicit confirmation dialog in the UI (the component exists but is not used)
|
||||
- [ ] Warning message explains consequences (present in the component, not reachable)
|
||||
- [ ] Cancel button available and functional (present in the component, not reachable)
|
||||
|
||||
## Other Issues Found
|
||||
|
||||
1. **Admin UI is mostly placeholder.** The dashboard does not list items. Stubs in `adminApi.listItems` and `adminApi.getItem` return fake data, so the UI looks like it works but never talks to the backend.
|
||||
2. **Lexical packages installed but unused.** `@lexical/react` and `lexical` are in `package.json` and not imported. The M6 spec requires a working Lexical editor with formatting.
|
||||
3. **No route from the site to the admin area.** `Header.tsx` has no admin link, and the dashboard has no edit or delete actions that lead to the edit page or the confirmation modal.
|
||||
4. **Nested `AdminLayout`.** Wrapping the same layout in both the route and the page doubles the sidebar.
|
||||
5. **`seed_admin.py` prints the admin password to stdout**, and its "Connecting to database" message uses a fallback URL (`sqlite:///data/db/newzy.db`) that does not match the engine it actually uses (from `db/session.py`). The message is misleading, but the seeding itself goes through the app engine.
|
||||
6. **Frontend and backend admin routes do not match the spec's file layout.** `adminApi.ts` is inside `client.ts`, and `AdminModal.tsx` is absent (optional).
|
||||
7. **Docs overstate the work.** `docs/admin-area.md` (242 lines) describes features that are placeholders or not wired up.
|
||||
8. **Unresolved earlier blockers.** `config.py` `class Config` (M2), missing `httpx` (M2/M5), placeholder `response_model=list[Article]` routes (M5), and the `jwt`/`python-jose` mismatch (M5). Also `docker-compose.yml` still references undefined `backend-db` (M4).
|
||||
|
||||
## Path to a Higher Score
|
||||
|
||||
1. Fix the import blockers: import `HTTPAuthorizationCredentials` from `fastapi.security`, import `Boolean` in `app/models.py`, remove `class Config` from `config.py`, and add `httpx` and `PyJWT` to `requirements.txt`.
|
||||
2. Add `url` (String, nullable) and `points` (Integer, default 0) columns to the `Article` model, and add a small migration or a note to recreate the table.
|
||||
3. Return the user object (or a dict built from its fields) from `get_current_admin` instead of `model_dump`.
|
||||
4. Make `sort_order` apply to `created_at` as well, and pass `sort_by`/`sort_order` from the frontend.
|
||||
5. Implement `listItems` and `getItem` with real `fetch` calls, and wire the dashboard to render a table with pagination, page size, and a debounced search.
|
||||
6. Render `DeleteConfirmation` from the dashboard row actions, with ESC and outside-click dismissal.
|
||||
7. Replace the textarea with a real Lexical editor (`LexicalComposer`, `RichTextPlugin`, `ContentEditable`) and wire the toolbar to Lexical commands.
|
||||
8. Remove the `AdminLayout` wrappers from the pages, keeping only the route-level wrapper.
|
||||
9. Add admin tests: 403 for non-admins, pagination, search, sort, and the create/update/delete flows.
|
||||
Reference in new issue
Block a user