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:
95
README.md
95
README.md
@@ -1,72 +1,68 @@
|
||||
# Applied Combinatorics
|
||||
# Physical Combinatorics
|
||||
### Innovation via Attribute Mixing
|
||||
|
||||
This is an experimental repo which uses lists of physical attributes and recombines them to form new objects. These objects are then reviewed for comprehensibility and viability.
|
||||
[](https://git.asimonson.com/andrew/physicalCombinatorics/actions)
|
||||
|
||||
Example:
|
||||
An experiment that takes lists of real physical attributes, recombines them into every possible object, and then sorts vaguely reasonable concepts from nonsense.
|
||||
|
||||
Let's identify some methods of getting from here to there:
|
||||
Let's identify some ways of getting from here to there:
|
||||
|
||||
- Car
|
||||
- Airplane
|
||||
- Train
|
||||
- Bicycle
|
||||
- Walking with your legs
|
||||
- Wheelchair
|
||||
- Scooter
|
||||
- Spaceship
|
||||
- Teleportation or beaming technology
|
||||
|
||||
To build object 'car' you must select a power source. Power sources include:
|
||||
To build a car you must choose what pushes it and what it runs on:
|
||||
|
||||
- Gas/Internal Combustion Engine
|
||||
- Lithium Ion Batteries
|
||||
- Hydrogen Combustion Engine
|
||||
- Human pedalling
|
||||
- Modular Nuclear Reactor
|
||||
- Coal/steam locomotion
|
||||
- the Sun via Solar Sail
|
||||
- Cannonfire Recoil
|
||||
- Pushed by a friend
|
||||
- Gas engine, electric motor, human pedalling, a solar sail, cannonfire recoil...
|
||||
- Gasoline, lithium ion batteries, hydrogen, coal, sunlight, gunpowder...
|
||||
|
||||
Putting together lists 1 and 2 we can create 81 mostly novel forms of transportation, such as trains powered by solar sails or walking powered by tiny cannon recoil. Obviously some of these concepts are not as viable as others. While being pushed by a friend might work for those in a wheelchair, it is too slow for those in a car. Speed is therefore a target metric. Let's list some target metrics:
|
||||
Multiply those lists together and you get thousands of mostly novel forms of transportation: trains driven by solar sails, walking powered by tiny cannon recoil. Obviously some are more viable than others. Being pushed by a friend might work for a wheelchair, but it's far too slow for a car. So each concept is measured against target metrics (power density, cost, speed, range, cargo), weighted by what matters in a given **domain** (urban commuting cares about cost and speed; interplanetary travel cares about range).
|
||||
|
||||
- Speed
|
||||
- Cost efficiency
|
||||
- Availability
|
||||
- Safety
|
||||
- Range (by fuel)
|
||||
- Range (by platform degredation or maintenance)
|
||||
The shortlist may include concepts that sound bizarre but are technically plausible. Bicycles, motorcycles and e-bikes all had their turn. Why not hydrogen-bikes?
|
||||
|
||||
Using these metrics this experiment intends to sift vaguely reasonable concepts from nonsense. Its shortlist may include concepts that sound bizarre but may be technically plausible. Bicycles, motorcycles, and e-bikes all had their turn. Why not hydrogen-bikes?
|
||||
The seed data is 11 platforms × 15 actuators × 18 energy storages = **2,970 combinations**, scored across 5 domains.
|
||||
|
||||
## How it works
|
||||
|
||||
Every combination goes through five passes:
|
||||
|
||||
1. **Constraints.** Each entity declares only its own physical envelope: what it `requires`, `provides` and `excludes`, plus numeric floors and ceilings on shared quantities like mass and footprint. The resolver cross-checks those generically across every pair. A nuclear reactor is blocked from a bicycle because its mass floor collides with the bicycle's mass ceiling, not because anyone wrote "nuclear + bicycle = no". Most of the combinatorial explosion dies here. ([why](LOGIC%20DOCS/002-guardrails-via-intrinsic-properties.md))
|
||||
2. **Physics estimation.** A deterministic engine sizes each surviving combination from its entities' declared properties. It optimizes the platform/actuator/storage mass split, solves for drag-limited speed, and derives power density, range, cost and cargo. Domains can also define their own metrics as formulas.
|
||||
3. **Scoring.** Raw values are log-normalized against each domain's bounds and combined with a weighted geometric mean. The geometric mean is deliberately harsh: one near-zero metric sinks the whole concept, which filters out things that are technically possible but pointless.
|
||||
4. **LLM review (optional).** Top combinations get a plausibility verdict and a LOW/MEDIUM/HIGH rating from Gemini or a local Ollama model.
|
||||
5. **Human review.** Annotate or approve results in the web UI.
|
||||
|
||||
Design reasoning lives in [`LOGIC DOCS/`](LOGIC%20DOCS/).
|
||||
|
||||
## Setup
|
||||
|
||||
### Docker (recommended)
|
||||
|
||||
```bash
|
||||
cp .env.example .env # set PHYSCOM_ADMIN_TOKEN to be able to edit
|
||||
docker compose up web
|
||||
```
|
||||
|
||||
Then open [http://localhost:5000](http://localhost:5000).
|
||||
Open [http://localhost:5000](http://localhost:5000). On first start with an empty volume, the container seeds the transport example and scores every domain (about 20 seconds). Visitors are read-only; log in at `/login` with `PHYSCOM_ADMIN_TOKEN` to edit entities, run the pipeline or use the admin page.
|
||||
|
||||
Seed the database with the transport example:
|
||||
CLI inside the container:
|
||||
|
||||
```bash
|
||||
docker compose run cli seed transport
|
||||
docker compose run --rm cli results urban_commuting --top 10
|
||||
```
|
||||
|
||||
### Local development
|
||||
|
||||
```bash
|
||||
pip install -e ".[dev,web]"
|
||||
python -m physcom init
|
||||
python -m physcom seed transport
|
||||
python -m physcom_web
|
||||
python -m physcom demo # seed + run passes 1-3 for every domain
|
||||
python -m physcom_web # localhost-only dev server, no login needed
|
||||
```
|
||||
|
||||
Then open [http://localhost:5000](http://localhost:5000).
|
||||
Then open [http://localhost:5000](http://localhost:5000). Set `FLASK_DEBUG=1` for the Werkzeug debugger (never on a reachable host).
|
||||
|
||||
Run tests:
|
||||
|
||||
@@ -74,9 +70,9 @@ Run tests:
|
||||
python -m pytest tests/ -q
|
||||
```
|
||||
|
||||
### LLM integration (optional)
|
||||
### LLM review (optional)
|
||||
|
||||
Pass 2 (physics estimation) is always the deterministic estimator — no LLM.
|
||||
Pass 2 (physics estimation) is always the deterministic estimator, with no LLM involved.
|
||||
An LLM is only used for the optional pass 4 plausibility review.
|
||||
|
||||
Gemini:
|
||||
@@ -98,15 +94,32 @@ export LLM_PROVIDER=ollama
|
||||
physcom run urban_commuting --passes 1,2,3,4
|
||||
```
|
||||
|
||||
Copy `.env.example` to `.env` and fill in your key for persistent configuration.
|
||||
Copy `.env.example` to `.env` to keep these settings.
|
||||
|
||||
---
|
||||
## Deploying publicly
|
||||
|
||||
a few notes: the thin atmosphere and the sun are obvious dependencies to the solar sail power source. Dependencies would include things such as scale of force (nuclear reactor vs pedalling obviously has an important force differential) and geographic requirements (walking requires ground and gravity). The project should include on every entity a list of dependencies. The viability tester will need to pull in all of these dependencies to ensure they do not contradict.
|
||||
The container is built to sit behind a TLS-terminating reverse proxy (Caddy, nginx, or a platform like Fly.io or Railway):
|
||||
|
||||
Additionally, metrics are expected to be extremely close to full points or none at all. The speed of a person pushing a car is effectively zero in its domain whereas a rocket powered car would easily reach the limits of speed in the domain. The resulting multiplication between metrics to get the viability score will be heavily logarithmic. This is expected and is intended to be a filter to eliminate technically plausible but completely pointless in practice concepts.
|
||||
Metric weights are therefore dependent on domain, which will also need to be defined.
|
||||
- It serves with gunicorn (one worker, eight threads), runs as a non-root user and has a healthcheck.
|
||||
- Anonymous visitors can browse every result and use the mass-allocation explorer, and nothing else. Every write needs a login with `PHYSCOM_ADMIN_TOKEN`. If the token is unset, nobody can write.
|
||||
- Set `PHYSCOM_SECURE_COOKIES=1` once it's served over HTTPS.
|
||||
- Mount a persistent volume at `/app/data`. SQLite plus a single writer is plenty for a read-mostly demo.
|
||||
- To publish LLM reviews without exposing an API key: run pass 4 locally against Ollama, export from `/admin` (or `physcom snapshot export`), and import that snapshot on the server.
|
||||
|
||||
First pass viability is physics such as force output, possibly generalized by LLM, last passes can include LLM and human review of social factors.
|
||||
Minimal Caddy example:
|
||||
|
||||
Attributes themselves are real (quality proven) and are thusly not garbage in the 'garbage in garbage out' risk - that risk is measured in how much nonsense the dimensional explosion generates that makes it past heuristic filters.
|
||||
```
|
||||
physcom.example.com {
|
||||
reverse_proxy localhost:5000
|
||||
}
|
||||
```
|
||||
|
||||
## Project layout
|
||||
|
||||
```
|
||||
src/physcom/ core engine: models, SQLite repository, constraint resolver,
|
||||
physics estimator, scorer, pipeline, LLM providers, CLI
|
||||
src/physcom_web/ Flask + HTMX web UI
|
||||
tests/ pytest suite
|
||||
LOGIC DOCS/ design decisions and the reasoning behind them
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user