80 lines
2.9 KiB
Python
80 lines
2.9 KiB
Python
"""Manufacturing Proof Certificate schema: decision lineage, simulation proof, process, machine, risk."""
|
|
|
|
from enum import Enum
|
|
from typing import Any
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class MPCId(BaseModel):
|
|
"""Immutable MPC identifier: content-addressed or versioned."""
|
|
|
|
value: str = Field(..., description="Unique MPC id (e.g. hash or versioned id)")
|
|
version: int = Field(default=1, description="Certificate version")
|
|
|
|
def __str__(self) -> str:
|
|
return f"{self.value}@v{self.version}"
|
|
|
|
|
|
class DecisionLineageEntry(BaseModel):
|
|
"""Single entry in decision lineage."""
|
|
|
|
node_id: str = Field(..., description="DLT or decision node id")
|
|
family: str = Field(..., description="DLT family: INT, GEO, PHY, PROC, MACH")
|
|
evidence_ref: str | None = Field(default=None, description="Reference to evidence artifact")
|
|
outcome: str = Field(..., description="Outcome: pass, fail_closed, etc.")
|
|
|
|
|
|
class SimulationProof(BaseModel):
|
|
"""Binding simulation proof reference."""
|
|
|
|
proof_id: str = Field(..., description="Proof artifact id")
|
|
governing_equations: str | None = Field(default=None)
|
|
boundary_conditions_ref: str | None = Field(default=None)
|
|
safety_factor: float | None = Field(default=None)
|
|
failure_modes_covered: list[str] = Field(default_factory=list)
|
|
|
|
|
|
class ProcessJustification(BaseModel):
|
|
"""Process eligibility justification."""
|
|
|
|
process_type: str = Field(..., description="additive, subtractive, hybrid")
|
|
eligible: bool = Field(...)
|
|
checks_ref: str | None = Field(default=None)
|
|
tool_access: bool | None = None
|
|
thermal_distortion: bool | None = None
|
|
overhangs: bool | None = None
|
|
datum_survivability: bool | None = None
|
|
|
|
|
|
class MachineDeclaration(BaseModel):
|
|
"""Machine binding declaration."""
|
|
|
|
machine_id: str = Field(..., description="Bound machine id")
|
|
profile_ref: str | None = Field(default=None)
|
|
limits_ref: str | None = Field(default=None)
|
|
deviation_model_ref: str | None = Field(default=None)
|
|
|
|
|
|
class RiskRegisterEntry(BaseModel):
|
|
"""Single risk register entry."""
|
|
|
|
risk_id: str = Field(...)
|
|
description: str = Field(...)
|
|
severity: str = Field(..., description="e.g. low, medium, high")
|
|
mitigation_ref: str | None = Field(default=None)
|
|
|
|
|
|
class ManufacturingProofCertificate(BaseModel):
|
|
"""Manufacturing Proof Certificate: immutable, versioned; required for manufacturing execution."""
|
|
|
|
mpc_id: MPCId = Field(..., description="Certificate identifier")
|
|
decision_lineage: list[DecisionLineageEntry] = Field(default_factory=list)
|
|
simulation_proof: SimulationProof | None = Field(default=None)
|
|
process_justification: ProcessJustification | None = Field(default=None)
|
|
machine_declaration: MachineDeclaration | None = Field(default=None)
|
|
risk_register: list[RiskRegisterEntry] = Field(default_factory=list)
|
|
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
|
|
model_config = {"frozen": True}
|