build-small-hackathon/microfactory-lab
2
1"""Pydantic domain types for the Chief Engineer.2 3Adapted from microfactory-lab `core/src/types.ts` — stripped of routing,4economic, energy, and tick concepts (over-scope per pattern-review.md §7).5Only what the compounding-knowledge loop needs.6"""7 8from __future__ import annotations9 10from pydantic import BaseModel, Field11 12MATERIALS = ["PLA", "PETG", "ABS", "TPU"]13# geometry_type doubles as a retrieval key (pattern-review.md §3/§9)14GEOMETRY_TYPES = ["overhang", "bridge", "stringing", "adhesion", "vase"]15OUTCOMES = ["success", "failed_sag", "failed_stringing"]16# where the part sits on the heated bed — drives edge-cooling warp + adhesion risk17BED_POSITIONS = ["center", "edge", "corner"]18 19 20class Job(BaseModel):21 geometry_type: str22 material: str23 description: str = ""24 mesh_path: str | None = None25 bed_position: str = "center" # center|edge|corner — affects warp/adhesion26 27 28class Environment(BaseModel):29 temp: float = Field(description="Ambient temperature °C")30 humidity: float = Field(description="Ambient humidity %")31 printer: str = "Creality Ender 3 V2" # simulated machine (220×220×250 bed)32 33 34class PrintSettings(BaseModel):35 nozzle_temp: float36 bed_temp: float37 retraction_mm: float38 fan_pct: float39 first_layer_fan_pct: float40 layer_height: float = 0.2 # mm — drives virtual-print preview cross-sections41 42 43class RiskRegion(BaseModel):44 location: str # human description, e.g. "underside of the overhang"45 risk: str # "sag" | "stringing" | "adhesion" | "warping" | ...46 why: str # one-line rationale47 anchor_hint: str | None = None # optional geometry hint for the 3D annotation48 49 50class Advice(BaseModel):51 """The Chief Engineer's structured proposal (the LLM's output)."""52 53 reasoning: str # the EVALUATION of precedent — the load-bearing text54 settings: PrintSettings55 risks: list[RiskRegion] = []56 57 58class LessonEntry(BaseModel):59 """Append-only ledger record. Schema is locked (02-ARCHITECTURE.md)."""60 61 job_id: str62 material: str63 geometry_type: str64 env_temp: float65 env_humidity: float66 outcome: str67 lesson: str68 source: str = "earned" # "seed" | "earned"69 timestamp: str70 