feat(solver): Phase 3d — .kc SolveContext packing on commit #158

Open
opened 2026-02-20 02:02:23 +00:00 by forbes · 0 comments
Owner

Phase 3d: .kc Context Packing

Pack SolveContext into .kc archives on commit so that solver runners can extract constraint graphs without needing a full FreeCAD installation.

See docs/SOLVER.md — Phase 3d

Files to modify

  • mods/silo/freecad/silo_origin.py — Hook into commit to pack solver context

.kc archive layout

silo/solver/context.json    # Pre-extracted SolveContext
silo/solver/result.json     # Last solve result (if any)

Client-side packing

# In the Assembly workbench commit hook:
ctx = assembly_object.build_solve_context()
kc_archive.write("silo/solver/context.json", ctx.to_json())

Runner-side extraction

import zipfile, json

with zipfile.ZipFile("assembly.kc") as zf:
    ctx_json = json.loads(zf.read("silo/solver/context.json"))

Context

When a solver job is triggered by revision_created (e.g. the assembly-validate job definition), the runner needs a SolveContext to work with. Two extraction paths exist:

  1. Pre-packed in .kc (this phase) — lightweight, no FreeCAD on runner
  2. Headless Create extraction — full fidelity, requires Create installation

Path 1 is preferred for most deployments. Path 2 is a fallback for geometry-dependent operations.

Dependencies

  • Phase 3a (JSON serialization) — build_solve_context() must produce JSON
  • This work is in the Kindred Create / silo-mod repos
## Phase 3d: .kc Context Packing Pack `SolveContext` into `.kc` archives on commit so that solver runners can extract constraint graphs without needing a full FreeCAD installation. See [docs/SOLVER.md — Phase 3d](../docs/SOLVER.md#phase-3d-kc-context-packing) ### Files to modify - `mods/silo/freecad/silo_origin.py` — Hook into commit to pack solver context ### .kc archive layout ``` silo/solver/context.json # Pre-extracted SolveContext silo/solver/result.json # Last solve result (if any) ``` ### Client-side packing ```python # In the Assembly workbench commit hook: ctx = assembly_object.build_solve_context() kc_archive.write("silo/solver/context.json", ctx.to_json()) ``` ### Runner-side extraction ```python import zipfile, json with zipfile.ZipFile("assembly.kc") as zf: ctx_json = json.loads(zf.read("silo/solver/context.json")) ``` ### Context When a solver job is triggered by `revision_created` (e.g. the `assembly-validate` job definition), the runner needs a `SolveContext` to work with. Two extraction paths exist: 1. **Pre-packed in .kc** (this phase) — lightweight, no FreeCAD on runner 2. **Headless Create extraction** — full fidelity, requires Create installation Path 1 is preferred for most deployments. Path 2 is a fallback for geometry-dependent operations. ### Dependencies - Phase 3a (JSON serialization) — `build_solve_context()` must produce JSON - This work is in the Kindred Create / silo-mod repos
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/silo#158