Skip to content

Commit c46e729

Browse files
conformance: run graph-stream-encode fixture (streaming parity)
Implement the graph-stream-encode operation in the conformance runner so the shared streaming-encode fixture runs here instead of being skipped as an unknown operation. Drives StreamEncoder and compares exact bytes; output matches the shared expected string byte-for-byte (no divergence). Enforces streaming-header parity (profile=graph) with the other SDKs.
1 parent d389abf commit c46e729

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

tests/test_conformance_v2.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,5 +198,40 @@ def _set(s):
198198
f"turn {i + 1} wire mismatch:\n got: {wire!r}\n exp: {e['wire']!r}"
199199
)
200200

201+
elif op == "graph-stream-encode":
202+
import io
203+
204+
from gcf.stream import StreamEncoder
205+
from gcf.types import Edge, Symbol
206+
207+
inp = data["input"]
208+
buf = io.StringIO()
209+
enc = StreamEncoder(
210+
buf,
211+
inp.get("tool", ""),
212+
token_budget=inp.get("tokenBudget", 0),
213+
tokens_used=inp.get("tokensUsed", 0),
214+
pack_root=inp.get("packRoot", ""),
215+
)
216+
for s in inp.get("symbols", []):
217+
enc.write_symbol(
218+
Symbol(
219+
qualified_name=s["qualifiedName"],
220+
kind=s["kind"],
221+
score=s["score"],
222+
provenance=s["provenance"],
223+
distance=s.get("distance", 0),
224+
)
225+
)
226+
for e in inp.get("edges", []):
227+
enc.write_edge(
228+
Edge(source=e["source"], target=e["target"], edge_type=e["edgeType"])
229+
)
230+
enc.close()
231+
got = buf.getvalue()
232+
assert got == data["expected"], (
233+
f"stream encode mismatch:\n got: {got!r}\n exp: {data['expected']!r}"
234+
)
235+
201236
else:
202237
pytest.skip(f"unknown operation: {op}")

0 commit comments

Comments
 (0)