How to Run & Reproduce
This guide covers local setup, solver execution, native and WebAssembly builds, coordinator server operation, and dashboard generation.
1. Environment Setup
Install Python 3.10+, Node.js 20+, and the Rust toolchain (cargo and rustup), then install the package in editable mode so shape_packing and src.shape_packing resolve to your working tree:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
pip install -e . --no-deps
2. Rebuild Native & WebAssembly Solvers
The Rust crate in packer_rs/ produces three targets: the PyO3 Python extension, the standalone shape-packing-worker binary, and the browser WASM module used by /contribute. Whenever you edit packer_rs/src/solver.rs, rebuild the targets you use.
Browser WASM Solver (wasm-pack)
Install the wasm32 target and wasm-pack once:
rustup target add wasm32-unknown-unknown
cargo install wasm-pack
Compile the WASM bundle into site/public/wasm:
wasm-pack build packer_rs --target web --out-dir ../site/public/wasm --no-default-features --features wasm
Passing --no-default-features --features wasm is required. The default feature enables python (pyo3), which does not target wasm32, while packer_rs/Cargo.toml restricts native-only crates (clap, ureq, ctrlc) to non-WASM targets.
Python Extension (maturin) & Standalone Worker
# Rebuild the in-process Python solver extension
maturin develop --release --manifest-path packer_rs/Cargo.toml
# Build the standalone Rust distributed worker binary
cargo build --release --bin shape-packing-worker --no-default-features --manifest-path packer_rs/Cargo.toml
3. Run Local Search & Verification
Run the Python auto-research loop or verify a single solution JSON against exact SAT and container bounds checks:
python scripts/autoresearch/run_autoresearch_loop.py --max-seconds 300 --attempts 10000
python scripts/verify_solution.py results/10_3_in_3/20260726_164732/solution.json
python scripts/compare_results.py
Canonical problem IDs use the {N}_{INNER}_in_{CONTAINER} convention (for example 25_4_in_3, 2_DOMINO_in_6, 1_CIRCLE_in_SEMICIRCLE, 1_RHOMBUS_in_4).
4. Run & Inspect the Coordinator Server
Start the FastAPI coordinator:
uvicorn src.shape_packing.server.app:app --host 0.0.0.0 --port 8000
On startup, create_app migrates any legacy IDs in shape_packing.db and runs sync_problem_catalog() to seed all data/packingVerification/*.json benchmarks and canonical quadrilateral Frontier problems (tier='frontier'). Set SHAPE_PACKING_AUTO_SEED=0 if you want to skip startup seeding.
Check enabled problems and active tiers through the HTTP API:
# Cluster totals and tier breakdown (benchmark vs frontier)
curl http://localhost:8000/api/v1/stats
# List Frontier problems or filter by shape
curl "http://localhost:8000/api/v1/problems?tier=frontier&limit=50"
curl "http://localhost:8000/api/v1/problems?inner=CIRCLE&container=SEMICIRCLE"
# Register a worker to receive a Bearer token, then lease a Frontier work unit
curl -X POST http://localhost:8000/api/v1/workers/register \
-H "Content-Type: application/json" \
-d '{"username":"test_worker","client_type":"native"}'
curl -H "Authorization: Bearer <worker_secret>" \
"http://localhost:8000/api/v1/work?worker_id=<worker_id>&tier=frontier"
Running the Standalone Worker (shape-packing-worker)
Pre-built binaries from GitHub Releases (or compiled via cargo build --release --bin shape-packing-worker) store credentials and settings in ~/.shape_packing_worker.json:
# First-run interactive setup wizard
./shape-packing-worker
# Run with 8 cores solving one independent problem per thread (like the browser worker)
./shape-packing-worker --cores 8 --thread-mode per-thread
Available ~/.shape_packing_worker.json fields:
server_url(string): Coordinator URL (defaulthttps://shape-packing-ggd4d5e8c2ctggam.eastus-01.azurewebsites.net)username(string): Public leaderboard handleworker_id/worker_secret(string): Assigned automatically on registrationcores(integer): CPU threads to allocatethread_mode("per_problem"or"per_thread"):"per_problem"(default) puts all cores on one problem;"per_thread"leases one problem per threadthread_credentials(object): Per-thread Bearer secrets generated inper_threadmode- Desktop GUI options (used by
src.shape_packing.client.gui):autostart,start_minimized,minimize_on_close,schedule_enabled,schedule_start,schedule_end
5. Refresh Benchmarks, Queue & Astro Dashboard
# Optional: re-fetch Packomania circle benchmarks (7/9/10-gons, semicircle, quadrant, octagon)
python scripts/import_packomania.py
# Regenerate data/priority_queue.json from data/packingVerification/*.json
python -m src.shape_packing.ranker
# Rebuild site/src/data/site_data.json and family spec slugs
python scripts/parse_erich_friedman.py
python scripts/build_site_data.py
python scripts/build_family_slugs.py
# Run dev server or build static dist/
cd site
npm install
npm run dev
npm run build
Open http://localhost:4321 during npm run dev.
6. Run Test Suites
# Rust solver and worker tests
cargo test --manifest-path packer_rs/Cargo.toml
# Site unit and quality audit tests
npm test --prefix site
# Python tests (geometry, catalog, ranker, DB, scheduler, import hygiene)
python -m pytest tests/test_catalog.py tests/test_problems.py tests/test_geometry.py tests/test_solution_tools.py tests/test_ranker.py tests/test_package_imports.py tests/test_server_database.py tests/test_server_scheduler.py -p no:cacheprovider -q