dev server uses admin login too: localhost shows the public view

Drop open_access; run() prints a one-off PHYSCOM_ADMIN_TOKEN when none is set.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-09-25 17:27:55 -05:00
parent 8171fc023e
commit af401d6bc2
6 changed files with 25 additions and 26 deletions

View File

@@ -12,7 +12,7 @@ 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` (localhost, open access, debug only with `FLASK_DEBUG=1`)
- **Web dev server**: `python -m physcom_web` (localhost, public read-only view; log in at `/login` with `PHYSCOM_ADMIN_TOKEN` or the one-off token it prints; 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`
- **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`.
@@ -58,7 +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`.
- **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`. The dev server uses the same rules (it prints a one-off token if none 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)