Skip to content

Commit fe01f42

Browse files
stream: emit graph trailer distance groups in pure emission order (SPEC 16.1)
Drop the fixed targets,related,extended prefix; iterate the insertion-ordered group-count dict directly, matching gcf-go/rust/swift/kotlin. Byte-identical for contract-conformant ascending input; deterministic for distance_N groups. Pinned by shared fixtures streaming-v2/010-011.
1 parent 8f66aa2 commit fe01f42

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
### Conformance and docs
1717

18+
- Streaming graph trailer now emits `distance_N` group counts in pure group-header emission order (dropping a fixed `targets,related,extended` prefix), matching the other SDKs and deterministic per SPEC 16.1. Byte-identical for contract-conformant (ascending-distance) input; pinned by shared fixtures `streaming-v2/010``011`.
1819
- The conformance runner now executes the `graph-stream-encode` fixtures (streaming-encode parity, previously decode-only): fixture 004 (positional trailer) and 005 (labeled trailer).
1920
- README: corrected the streaming example trailer from the defunct `## _summary … sections=` to the real `##! summary … counts=`; README now leads with the project diagram.
2021
- Added a generic-delta fuzz test (decoder never crashes; string round-trip).

src/gcf/stream.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,13 @@ def close(self) -> None:
126126
with self._lock:
127127
# Build label:count sections, then either emit as-is (labeled form,
128128
# SPEC 8.4.1) or strip to values (default positional form).
129-
sections: list[str] = []
130-
group_order = ["targets", "related", "extended"]
131-
132-
for g in group_order:
133-
c = self._group_counts.get(g, 0)
134-
if c > 0:
135-
sections.append(f"{g}:{c}")
136-
for g, c in self._group_counts.items():
137-
if g not in group_order and c > 0:
138-
sections.append(f"{g}:{c}")
129+
# One entry per non-empty distance group in group-header emission order
130+
# (SPEC 8.4). The dict preserves insertion order, which is the order the
131+
# group headers were emitted, so the trailer is deterministic and matches
132+
# the section order (including distance_N groups) across all SDKs.
133+
sections: list[str] = [
134+
f"{g}:{c}" for g, c in self._group_counts.items() if c > 0
135+
]
139136
# The edge count is always the last counts entry, even when 0 (SPEC
140137
# 8.4, 8.4.1): it keeps the positional form unambiguous and anchors the
141138
# labeled form (minimal counts=edges:0). Zero-count distance groups are

0 commit comments

Comments
 (0)