OR-1 dataflow CPU sketch

fix: address code review feedback for Phase 3

- Issue I1: Remove unused imports (Union, Port, NameRef, PipelineStage, OpcodeCategory) from dfgraph/graph_json.py
- Issue M1: Simplify redundant single-iteration loop in graph_to_json (lines 146-149)
- Issue M2: Remove unused import RegionKind from tests/test_dfgraph_json.py
- Issue M3: Replace conditional guard with proper assertion in test_error_structure

Orual 0d3b8d23 f0d21b33

+12 -14
+8 -9
dfgraph/graph_json.py
··· 6 6 7 7 from __future__ import annotations 8 8 9 - from typing import Any, Union 9 + from typing import Any 10 10 11 - from cm_inst import Addr, Port 11 + from cm_inst import Addr 12 12 from asm.ir import ( 13 13 IRGraph, IRNode, IREdge, IRRegion, RegionKind, 14 - SourceLoc, NameRef, ResolvedDest, 14 + SourceLoc, ResolvedDest, 15 15 collect_all_nodes_and_edges, 16 16 ) 17 17 from asm.errors import AssemblyError 18 18 from asm.opcodes import OP_TO_MNEMONIC 19 - from dfgraph.pipeline import PipelineResult, PipelineStage 20 - from dfgraph.categories import categorise, CATEGORY_COLOURS, OpcodeCategory 19 + from dfgraph.pipeline import PipelineResult 20 + from dfgraph.categories import categorise, CATEGORY_COLOURS 21 21 22 22 23 23 def _serialise_loc(loc: SourceLoc) -> dict[str, Any]: ··· 143 143 ] 144 144 145 145 regions_json = [] 146 - for subgraph_regions in [graph.regions]: 147 - for region in subgraph_regions: 148 - if region.kind == RegionKind.FUNCTION: 149 - regions_json.append(_serialise_region(region)) 146 + for region in graph.regions: 147 + if region.kind == RegionKind.FUNCTION: 148 + regions_json.append(_serialise_region(region)) 150 149 151 150 errors_json = [_serialise_error(e) for e in result.errors] 152 151
+4 -5
tests/test_dfgraph_json.py
··· 10 10 11 11 from dfgraph.graph_json import graph_to_json 12 12 from dfgraph.pipeline import run_progressive, PipelineStage 13 - from asm.ir import RegionKind 14 13 15 14 16 15 class TestFullyAllocatedGraph: ··· 284 283 result = run_progressive(source) 285 284 json_out = graph_to_json(result) 286 285 287 - if len(json_out["errors"]) > 0: 288 - error = json_out["errors"][0] 289 - required_fields = {"line", "column", "category", "message", "suggestions"} 290 - assert set(error.keys()) >= required_fields 286 + assert len(json_out["errors"]) > 0, "Expected errors for undefined reference" 287 + error = json_out["errors"][0] 288 + required_fields = {"line", "column", "category", "message", "suggestions"} 289 + assert set(error.keys()) >= required_fields 291 290 292 291 def test_metadata_structure(self): 293 292 """Metadata has all required fields."""