feat(solver): Phase 3 — server integration and headless solve jobs #289

Closed
opened 2026-02-19 21:01:57 +00:00 by forbes · 0 comments
Owner

Summary

Integrate the KCSolve pluggable solver with the Silo worker system so assemblies can be solved server-side via silorunner. Full specification in docs/src/silo-server/SOLVER.md.

Scope

Phase 3a: JSON serialization

Add to_dict() / from_dict() methods to all KCSolve types in the pybind11 module.

  • SolveContext, SolveResult, Transform, Part, Constraint, MotionDef, SimulationParams, ConstraintDiagnostic
  • Enum serialization as strings matching Python names (e.g. "Revolute", "Success", "Redundant")
  • Round-trip verification: SolveContext.from_dict(ctx.to_dict()) == ctx

Files: src/Mod/Assembly/Solver/bindings/kcsolve_py.cpp

Phase 3b: Server endpoints

Add the solver module to the Silo server with REST API under /api/solver/:

Endpoint Method Description
/api/solver/jobs POST Submit solve job (returns job_id, status, created_at)
/api/solver/jobs/{jobID} GET Get job status and result
/api/solver/jobs GET List jobs with filtering (status, item, operation, solver)
/api/solver/jobs/{jobID}/cancel POST Cancel pending/claimed job
/api/solver/solvers GET Get registry of available solvers from runner capabilities

Three operation types: solve, diagnose, kinematic.

SSE events on /api/events: solver.created, solver.claimed, solver.progress, solver.completed, solver.failed.

Database migration: solver_results table with UNIQUE(item_id, revision_number, operation).

Files (silo repo): internal/modules/solver/, migrations/020_solver_results.sql

Phase 3c: Runner support

Add solver job execution to silorunner:

  • kcsolve.runner module: reads JSON from stdin, executes solve, writes result JSON to stdout
  • Runner heartbeat reports solver capabilities (solvers, api_version, python_version)
  • Runner tag: solver
  • Requirements: Python 3.11+, kcsolve module, libKCSolve.so — no FreeCAD installation needed

Files: src/Mod/Assembly/Solver/bindings/runner.py

Phase 3d: .kc context packing

Pack pre-extracted SolveContext JSON into .kc archives on commit:

  • Client extracts SolveContext and writes to silo/solver/context.json in the archive
  • Runner reads context from archive without geometry processing
  • Enables lightweight solver containers

Files: mods/silo/freecad/silo_origin.py

Phase 3e: Client integration

  • Extend silo_client with solver methods (submit, wait, stream, results)
  • Add "Solve on Server" command to Assembly workbench
  • Silo viewport widget shows job status (pending/running/done/failed)
  • Apply returned placements on solver.completed

Files: mods/silo/freecad/, src/Mod/Assembly/

Dependencies

  • #287 — Phase 1: C++ API (merged, PR #297)
  • #288 — Phase 2: Python bindings (PR #298)
  • Silo worker system (WORKERS.md)

References

  • docs/src/silo-server/SOLVER.md — full server specification
  • docs/INTER_SOLVER.md §7 — architecture overview
  • docs/src/reference/kcsolve-python.md — Python API reference
## Summary Integrate the KCSolve pluggable solver with the Silo worker system so assemblies can be solved server-side via `silorunner`. Full specification in `docs/src/silo-server/SOLVER.md`. ## Scope ### Phase 3a: JSON serialization Add `to_dict()` / `from_dict()` methods to all KCSolve types in the pybind11 module. - `SolveContext`, `SolveResult`, `Transform`, `Part`, `Constraint`, `MotionDef`, `SimulationParams`, `ConstraintDiagnostic` - Enum serialization as strings matching Python names (e.g. `"Revolute"`, `"Success"`, `"Redundant"`) - Round-trip verification: `SolveContext.from_dict(ctx.to_dict()) == ctx` **Files:** `src/Mod/Assembly/Solver/bindings/kcsolve_py.cpp` ### Phase 3b: Server endpoints Add the `solver` module to the Silo server with REST API under `/api/solver/`: | Endpoint | Method | Description | |----------|--------|-------------| | `/api/solver/jobs` | `POST` | Submit solve job (returns `job_id`, `status`, `created_at`) | | `/api/solver/jobs/{jobID}` | `GET` | Get job status and result | | `/api/solver/jobs` | `GET` | List jobs with filtering (`status`, `item`, `operation`, `solver`) | | `/api/solver/jobs/{jobID}/cancel` | `POST` | Cancel pending/claimed job | | `/api/solver/solvers` | `GET` | Get registry of available solvers from runner capabilities | Three operation types: `solve`, `diagnose`, `kinematic`. SSE events on `/api/events`: `solver.created`, `solver.claimed`, `solver.progress`, `solver.completed`, `solver.failed`. Database migration: `solver_results` table with `UNIQUE(item_id, revision_number, operation)`. **Files (silo repo):** `internal/modules/solver/`, `migrations/020_solver_results.sql` ### Phase 3c: Runner support Add solver job execution to `silorunner`: - `kcsolve.runner` module: reads JSON from stdin, executes solve, writes result JSON to stdout - Runner heartbeat reports solver capabilities (`solvers`, `api_version`, `python_version`) - Runner tag: `solver` - Requirements: Python 3.11+, `kcsolve` module, `libKCSolve.so` — no FreeCAD installation needed **Files:** `src/Mod/Assembly/Solver/bindings/runner.py` ### Phase 3d: .kc context packing Pack pre-extracted `SolveContext` JSON into `.kc` archives on commit: - Client extracts `SolveContext` and writes to `silo/solver/context.json` in the archive - Runner reads context from archive without geometry processing - Enables lightweight solver containers **Files:** `mods/silo/freecad/silo_origin.py` ### Phase 3e: Client integration - Extend `silo_client` with solver methods (`submit`, `wait`, `stream`, `results`) - Add "Solve on Server" command to Assembly workbench - Silo viewport widget shows job status (pending/running/done/failed) - Apply returned placements on `solver.completed` **Files:** `mods/silo/freecad/`, `src/Mod/Assembly/` ## Dependencies - #287 — Phase 1: C++ API (merged, PR #297) - #288 — Phase 2: Python bindings (PR #298) - Silo worker system (WORKERS.md) ## References - `docs/src/silo-server/SOLVER.md` — full server specification - `docs/INTER_SOLVER.md` §7 — architecture overview - `docs/src/reference/kcsolve-python.md` — Python API reference
forbes added the enhancement label 2026-02-19 21:01:57 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/create#289