MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / NodeIR

Class NodeIR

verifier/AgentVerifier/WorkflowToLean.py:84–134  ·  view source on GitHub ↗

A workflow node.

Source from the content-addressed store, hash-verified

82
83@dataclass
84class NodeIR:
85 """A workflow node."""
86 id: int
87 name: str
88 step_type: str # one of the 13 Lean StepType names
89 reads: list[TypedVar]
90 writes: list[TypedVar]
91 instruction: Optional[str] = None
92 submodule_ref: Optional[SubmoduleRef] = None
93
94 @property
95 def exec_type(self) -> str:
96 # Mirror AgentVerifier/YamlStepType.lean::StepType.execType
97 deterministic = {
98 "forEachLoop", "whileLoop", "conditional", "switchBranch",
99 "setVariable", "incrementVariable", "returnValue", "input",
100 "parallel", "gather",
101 }
102 composition = {"call"}
103 if self.step_type in deterministic:
104 return "deterministic"
105 if self.step_type in composition:
106 return "composition"
107 return "unstructured"
108
109 @property
110 def is_llm_node(self) -> bool:
111 """True iff the node's behaviour depends on an LLM call."""
112 return self.exec_type != "deterministic"
113
114 def to_dict(self) -> dict:
115 d: dict = {
116 "id": self.id, "name": self.name, "step_type": self.step_type,
117 "reads": [r.to_dict() for r in self.reads],
118 "writes": [w.to_dict() for w in self.writes],
119 }
120 if self.instruction is not None:
121 d["instruction"] = self.instruction
122 if self.submodule_ref is not None:
123 d["submodule_ref"] = self.submodule_ref.to_dict()
124 return d
125
126 @staticmethod
127 def from_dict(d: dict) -> "NodeIR":
128 return NodeIR(
129 id=d["id"], name=d["name"], step_type=d["step_type"],
130 reads=[TypedVar.from_dict(r) for r in d["reads"]],
131 writes=[TypedVar.from_dict(w) for w in d["writes"]],
132 instruction=d.get("instruction"),
133 submodule_ref=SubmoduleRef.from_dict(d["submodule_ref"]) if d.get("submodule_ref") else None,
134 )
135
136
137# ---------- EdgeIR ----------

Callers 3

from_dictMethod · 0.85
parse_body_stepsFunction · 0.85
parse_task_jsonFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected