Skip to content

Commit f6777ee

Browse files
fix: always emit edge count as last graph trailer entry (SPEC 8.4)
Zero-edge graph streams dropped the trailing edge count (counts=2,1 vs 2,1,0; labeled omitted edges:0), violating SPEC 8.4/8.4.1. Decoder-ignored trailer; producer output only. Verified by conformance fixtures 008/009.
1 parent de11ecb commit f6777ee

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## v2.4.0 (2026-07-12)
44

5+
### Fixes
6+
7+
- Graph streaming trailer: the edge count is now always the last `counts` entry, even when the stream has no edges (positional `counts=2,1,0`; labeled `counts=…,edges:0`). A zero-edge stream previously dropped it, violating the SPEC §8.4 / §8.4.1 rule that the edge count is always present and last (the invariant that keeps the positional form unambiguous). The graph trailer is decoder-ignored, so this changes producer output only.
8+
59
### Streaming: opt-in labeled trailer counts (SPEC §8.4.1)
610

711
- New `labeled_trailer_counts` keyword on `StreamEncoder`. When set, the `##! summary` graph streaming trailer emits `counts=` in the labeled form `label:count` per group (e.g. `counts=targets:2,related:1,edges:3`) instead of the default positional values-only form (`counts=2,1,3`). Default false is byte-identical to prior output.

src/gcf/stream.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,11 @@ def close(self) -> None:
136136
for g, c in self._group_counts.items():
137137
if g not in group_order and c > 0:
138138
sections.append(f"{g}:{c}")
139-
if self._edge_count > 0:
140-
sections.append(f"edges:{self._edge_count}")
139+
# The edge count is always the last counts entry, even when 0 (SPEC
140+
# 8.4, 8.4.1): it keeps the positional form unambiguous and anchors the
141+
# labeled form (minimal counts=edges:0). Zero-count distance groups are
142+
# omitted, but edges is not.
143+
sections.append(f"edges:{self._edge_count}")
141144

142145
if self._labeled_trailer_counts:
143146
counts_str = ",".join(sections)

0 commit comments

Comments
 (0)