How victormerk/planpilot-service works
Purpose and entry points
This is a containerized Python HTTP service for IPEXCO that exposes stateful PlanPilot planning sessions over /api. The process entry point is run.py; request handlers live in app/rest/sessions.py and app/rest/auth.py. Docker deployment is defined by Dockerfile.
HTTP boundary and authentication
The REST layer provides health/readiness/capabilities plus session operations. Authorization is enforced for protected routes using a bearer API key, while health and readiness remain unauthenticated. API inputs are converted into service-level session contracts at app/rest/sessions.py and app/service/session_contract.py; this is the boundary between untrusted HTTP data and planning execution.
Session lifecycle and capacity control
A session represents a prepared PDDL task plus a live FASB process whose selected facets persist until explicit stop or TTL expiry. app/service/session_registry.py owns active-session tracking, expiration, and admission limits. app/service/planpilot_service.py orchestrates session creation, facet queries/selections, and shutdown. This in-process registry is the primary state store and makes session continuity instance-local.
Planning pipeline
Session preparation accepts PDDL domain/problem material, parses or hashes it, and invokes Fast Downward to produce the planning representation required by PlanPilot. app/service/fastdownward_service.py encapsulates the subprocess boundary and timeout handling; app/utils/parsing.py and app/utils/hashing.py support validation/identity. The vendored Fast Downward driver performs translation and search: lib/downward/fast-downward.py, lib/downward/src/translate/translate.py, and lib/downward/src/search/planner.cc.
PlanPilot/FASB execution
The PlanPilot adapter starts and communicates with the bundled Linux x86_64 FASB executable, maintaining an interactive solver process per session. Core upstream assets are lib/planpilot/planpilot.py, lib/planpilot/bin/fasb, and lib/planpilot/scripts/facet-reason.fasb. PlanPilot includes ASP encodings for sequential horizons and facets in lib/planpilot/encodings/. This is a process and platform boundary: production images must be Linux amd64 or emulate it.
Persistence model
Persistence is isolated behind app/persistence/db.py and app/persistence/models.py. Its role is distinct from the active registry: durable records, if used, should not be assumed to contain live solver state. Session-facing orchestration should preserve this separation so database failures or restarts do not leave orphaned subprocesses.
Runtime and operational limits
The service runs in Docker and depends on Python plus vendored Python, C++, and native solver components. Configuration is environment-driven for API access, horizon, active-session cap, session TTL, and Fast Downward/FASB/query timeouts. CI builds through .github/workflows/build.yml. External network services are not indicated; the material external dependencies are local subprocesses and bundled planner binaries.
Main entry points: planpilot_service.py PlanPilot orchestration · planpilot.py PlanPilot adapter · sessions.py Session API · fast-downward.py Fast Downward driver
Components 20
HTTP API
- Bearer API key auth · Protects session routes while health and readiness remain public.
app/rest/auth.py - Session API · Exposes session lifecycle, facet, health, readiness, and capability endpoints.
app/rest/sessions.py
Session Service
- Session contracts · Converts untrusted HTTP payloads into service-level requests.
app/service/session_contract.py - PlanPilot orchestration · Coordinates preparation, facets, selections, and shutdown.
app/service/planpilot_service.py - Active session registry · Owns live solver sessions, TTL expiry, and admission limits; state is instance-local.
app/service/session_registry.py - Durable persistence · Durable records are separate from live solver state.
app/persistence/db.py - Persistence models
app/persistence/models.py
Planning Pipeline
- PDDL parsing
app/utils/parsing.py - Task identity hashing
app/utils/hashing.py - Fast Downward adapter · Invokes planning with timeout handling.
app/service/fastdownward_service.py - Fast Downward driver
lib/downward/fast-downward.py - PDDL translation
lib/downward/src/translate/translate.py - Planner search
lib/downward/src/search/planner.cc
PlanPilot / FASB
- PlanPilot adapter · Maintains one FASB process and selected facets per session.
lib/planpilot/planpilot.py - FASB executable · Bundled Linux x86_64 interactive solver.
lib/planpilot/bin/fasb - Facet reasoning program
lib/planpilot/scripts/facet-reason.fasb - ASP encodings · Sequential-horizon and facet encodings.
Runtime & Delivery
- Process entry point
run.py - Docker image · Requires Linux amd64 FASB support or emulation.
Dockerfile - Build CI
.github/workflows/build.yml
Connections 20
- Docker image → Process entry point: runs
- Build CI → Docker image: builds
- Process entry point → Session API: serves
- Session API → Bearer API key auth: authorizes protected routes
- Session API → Session contracts: converts requests
- Session contracts → PlanPilot orchestration: session commands
- PlanPilot orchestration → Active session registry: creates and manages live sessions
- PlanPilot orchestration → Durable persistence: optionally records durable data
- Durable persistence → Persistence models: uses
- PlanPilot orchestration → PDDL parsing: validates PDDL
- PlanPilot orchestration → Task identity hashing: derives task identity
- PlanPilot orchestration → Fast Downward adapter: prepares planning representation
- Fast Downward adapter → Fast Downward driver: subprocess invocation
- Fast Downward driver → PDDL translation: translates
- Fast Downward driver → Planner search: searches
- PlanPilot orchestration → PlanPilot adapter: starts and queries solver
- Active session registry → PlanPilot adapter: retains live session process
- PlanPilot adapter → FASB executable: interactive subprocess
- PlanPilot adapter → Facet reasoning program: loads
- PlanPilot adapter → ASP encodings: uses