Skip to content

Fix backend defects, gate CI on lint/tests, tidy packaging + docs - #41

Merged
duckyquang merged 1 commit into
mainfrom
chore/release-backend-ci
Jul 16, 2026
Merged

Fix backend defects, gate CI on lint/tests, tidy packaging + docs#41
duckyquang merged 1 commit into
mainfrom
chore/release-backend-ci

Conversation

@duckyquang

Copy link
Copy Markdown
Owner

Release-prep pass on the backend: fix real defects, make lint gate CI, tidy packaging and docs. Minimal diffs, no logic refactors.

Code fixes

  • web/app.py (BLOCKER, F821 → HTTP 500): the legacy /classic/sessions/{id} and /classic/.../hypotheses/{hid} routes call hyp_repo.list_for_session(...) / hyp_repo.fetch(...) but the repo was never imported — every hit NameError'd (500). app.py:create_app is the Docker CMD / co-scientist serve entrypoint. Added from ..storage.repos import hypotheses as hyp_repo; dropped the unused datetime imports.
  • web/react_api.py (RUF006): the live-spawn path did asyncio.create_task(_bg()) without keeping a reference, so the event loop's weak ref let a running session be garbage-collected mid-flight. Anchored it in a module-level set() with add_done_callback(discard). Run logic unchanged.
  • agents/generation.py, agents/reflection.py: the dead defensive branches now raise a neutral ValueError("unsupported ...") instead of NotImplementedError("... lands in a later milestone"), so they read as guards rather than unfinished work.

Lint — ruff check . now zero errors (was 23)

F401 / F841 / I001 / UP037 / B905 / RUF001 across web/spa.py, webapp/*, scripts/build_bench_report.py. zip(strict=) chosen per call site: False where slice-pairing ([::2]/[1::2]) intentionally drops a leftover, True where the row width always matches the column list. RUF001 ambiguous /× in bench-report strings replaced with ASCII.

CI hardening

  • test.yml: added a ruff check . step so lint gates.
  • deploy-pages.yml: the build job (which deploy already needs) now installs deps + runs ruff check . + pytest before building, so a red suite blocks the Pages deploy.

Packaging (pyproject.toml)

version1.0.0 (matches frontend/package.json), added [project.urls] and classifiers, author set to Quang Bui.

Docs

git mv docs/superpowers → docs/design (no code references to update).

Verification

  • ruff check . → All checks passed
  • pytest co_scientist/tests/unit -q → 283 passed
  • create_app() imports without NameError; both /classic/... routes render 200 against a seeded session + hypothesis (B1 proven end-to-end)
  • All workflow YAML parses; pyproject.toml parses with version 1.0.0

🤖 Generated with Claude Code

Backend correctness:
- web/app.py: import hypotheses repo as hyp_repo — the legacy
  /classic/sessions/{id} and .../hypotheses/{hid} routes referenced an
  unimported name (F821) and 500'd with NameError. Drop unused datetime imports.
- web/react_api.py: anchor the background session task in a module-level set
  with a done-callback (RUF006) so a live run can't be GC'd mid-flight.
- agents/generation.py, agents/reflection.py: raise ValueError("unsupported ...")
  instead of NotImplementedError on the dead defensive branches so they read as
  guards, not unfinished work.

Lint: ruff check . is now zero errors (was 23) — F401/F841/I001/UP037/B905/RUF001
across web/spa.py, webapp/*, scripts/build_bench_report.py. zip strict= chosen
per call site (False where slice pairing drops a leftover, True where row width
matches the column list).

CI: test.yml runs `ruff check .`; deploy-pages.yml installs deps + runs ruff +
pytest in the build job (which deploy needs) so a red suite blocks Pages deploy.

Packaging: pyproject version 1.0.0 (matches frontend), [project.urls],
classifiers, author Quang Bui.

Docs: git mv docs/superpowers -> docs/design (no code references).

Co-Authored-By: Claude Fable 5 <[email protected]>
@duckyquang
duckyquang merged commit dcefda8 into main Jul 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant