public-release phases 1-3: read-only public mode, gunicorn container, demo bootstrap, CI, README
- before_request guard: visitors browse + explore; writes need PHYSCOM_ADMIN_TOKEN login - SameSite=Lax/HttpOnly cookies, persisted secret key, debug off unless FLASK_DEBUG=1 - non-root gunicorn container with healthcheck; physcom demo --if-empty on first start - landing page Top Concepts, write controls hidden from visitors - CI workflow, pyproject metadata, compose Ollama parity, README rewrite - tests/test_web_access.py: access control + GET smoke test of every page Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -12,10 +12,10 @@ PhysCom (Physical Combinatorics) — innovation discovery engine that generates
|
||||
- **Tests (all)**: `python -m pytest tests/ -q` (~130 tests, ~2 min). Run after every change.
|
||||
- **Single test file**: `python -m pytest tests/test_scorer.py -q`
|
||||
- **Single test**: `python -m pytest tests/test_scorer.py::test_score_combination -q`
|
||||
- **Web dev server**: `python -m physcom_web`
|
||||
- **Web dev server**: `python -m physcom_web` (localhost, open access, debug only with `FLASK_DEBUG=1`)
|
||||
- **CLI**: `python -m physcom` (or `physcom` if installed)
|
||||
- **Docker**: `docker compose up web` / `docker compose run cli physcom seed`
|
||||
- **Seed data**: loaded automatically on first DB init (SQLite, `physcom.db` or `$PHYSCOM_DB`)
|
||||
- **Demo data**: `python -m physcom demo` seeds + runs passes 1-3 for every domain (~20s). The Docker image does this on first start (`--if-empty`). DB is `data/physcom.db` or `$PHYSCOM_DB`.
|
||||
|
||||
## Architecture
|
||||
|
||||
@@ -35,7 +35,7 @@ src/physcom/ # Core library (no web dependency)
|
||||
seed/transport_example.py # 11 platforms × 15 actuators × 18 energy storages, 5 domains
|
||||
|
||||
src/physcom_web/ # Flask web UI
|
||||
app.py # App factory, get_repo(), DB path resolution
|
||||
app.py # App factory, get_repo(), DB path, read-only public mode + /login
|
||||
routes/pipeline.py # Background thread pipeline execution, HTMX status/cancel endpoints
|
||||
routes/results.py # Results browse, detail view, human review submission
|
||||
routes/entities.py # Entity CRUD
|
||||
@@ -58,6 +58,7 @@ tests/ # pytest, uses seeded_repo fixture from conftest.py
|
||||
- **`save_combination`** loads existing status/block_reason on dedup (important for resume).
|
||||
- **`ensure_metric`** backfills unit if the row already exists with an empty unit.
|
||||
- **MetricBound** carries `unit` — flows through seed → ensure_metric → metrics table → get_combination_scores → template display.
|
||||
- **Read-only public mode**: `create_app()` locks every non-GET (except `results.explore`) and the admin/pipeline/new pages behind a session login with `PHYSCOM_ADMIN_TOKEN`. Only the dev server (`run()` → `create_app(open_access=True)`) is open, and only while no token is set. Templates use `is_admin()`; `body.readonly` hides every `form[method=post]` via CSS — a new write form needs no template guard, but a new public POST must be added to `PUBLIC_POST_ENDPOINTS`.
|
||||
- **HTMX polling**: `_run_status.html` partial polls every 2s while run is pending/running; stops polling when terminal.
|
||||
|
||||
## Data flow (pipeline passes)
|
||||
|
||||
Reference in New Issue
Block a user