You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Draft PR #983 adds graph.encoding.graph6.decode.compute by implementing the graph6 format twice:
the producer manually decodes the header, six-bit characters, order, length, padding, column-major upper-triangle bits, edge list, degrees, and digest;
the independent checker repeats essentially the same bitstream parser.
The independent checker may legitimately retain a separate small replay implementation. The producer should not: Jacobian already depends on NetworkX, and NetworkX 3.6.1 exposes a maintained pure-Python graph6 codec through networkx.from_graph6_bytes() / to_graph6_bytes().
This is a concrete example of the anti-pattern tracked broadly in #699: reimplementing a maintained backend operation while increasing the code and review surface that must be independently proven.
Evidence
PR #983 adds approximately the following producer path in src/jacobian/domains/graph_optimization/invariants.py:
NetworkX is already a core graph-domain dependency and provider in Jacobian; this does not add a new backend.
Why the current implementation is riskier
Two parser implementations must remain specification-equivalent
Both copies need the same decisions for:
headers and newline handling;
small versus extended order encodings;
invalid character boundaries;
exact length and unused padding bits;
edge iteration order;
canonical normalization;
malformed sparse6/digraph6 rejection.
Any future format extension or bug fix becomes a coordinated producer/checker edit.
The producer’s advertised scope and parser behavior are entangled
The proposed capability intentionally supports only orders 0..62. That is a product scope decision; it need not be encoded by rejecting graph6’s maintained extended-order parser. The simpler boundary is:
This keeps format correctness and capability resource policy separate.
Reimplementing in both producer and checker does not improve independence
Independent verification requires the checker not to trust the producer’s result or algorithm. It does not require the producer to avoid a maintained parser.
A sound split is:
producer: NetworkX codec, then Jacobian-owned bounded/canonical projection;
checker: separate stdlib bitstream replay (or another independently pinned codec), bound to the exact input/result contract.
That preserves implementation diversity while removing one unnecessary parser.
Proposed implementation
Producer
Use the maintained decoder and a strict canonical round trip:
The round-trip equality preserves stricter requirements not necessarily rejected by the reader alone, including canonical small-order encoding and zero padding.
Decide explicitly whether a trailing newline is accepted/normalized or rejected; follow NetworkX’s documented behavior rather than implementing an accidental third convention.
Checker
Keep the checker’s independent stdlib replay if the project values implementation diversity. Move its duplicated wire-contract validation under #1110’s generated passive checker contract, leaving only the graph6 mathematics/bitstream replay in checker code.
Tests
Differentially test the producer against NetworkX and the independent checker across:
every order 0..62 at boundaries 0, 1, 2, 62;
optional standard header;
random simple graphs and round trips;
all invalid ASCII boundaries;
sparse6 and digraph6 prefixes;
incorrect encoded length;
nonzero padding;
trailing newline policy;
extended-order input rejected by the capability scope even though the codec can parse it;
Summary
Draft PR #983 adds
graph.encoding.graph6.decode.computeby implementing the graph6 format twice:The independent checker may legitimately retain a separate small replay implementation. The producer should not: Jacobian already depends on NetworkX, and NetworkX 3.6.1 exposes a maintained pure-Python graph6 codec through
networkx.from_graph6_bytes()/to_graph6_bytes().This is a concrete example of the anti-pattern tracked broadly in #699: reimplementing a maintained backend operation while increasing the code and review surface that must be independently proven.
Evidence
PR #983 adds approximately the following producer path in
src/jacobian/domains/graph_optimization/invariants.py:src/jacobian_checkers/graph_exact_operations.pythen adds another copy of the same algorithm.NetworkX’s maintained implementation already:
>>graph6<<header;to_graph6_bytes().Official documentation/source:
NetworkX is already a core graph-domain dependency and provider in Jacobian; this does not add a new backend.
Why the current implementation is riskier
Two parser implementations must remain specification-equivalent
Both copies need the same decisions for:
Any future format extension or bug fix becomes a coordinated producer/checker edit.
The producer’s advertised scope and parser behavior are entangled
The proposed capability intentionally supports only orders
0..62. That is a product scope decision; it need not be encoded by rejecting graph6’s maintained extended-order parser. The simpler boundary is:This keeps format correctness and capability resource policy separate.
Reimplementing in both producer and checker does not improve independence
Independent verification requires the checker not to trust the producer’s result or algorithm. It does not require the producer to avoid a maintained parser.
A sound split is:
That preserves implementation diversity while removing one unnecessary parser.
Proposed implementation
Producer
Use the maintained decoder and a strict canonical round trip:
Then construct Jacobian’s typed result from:
sorted(graph.edges());[graph.degree(i) for i in range(len(graph))];The round-trip equality preserves stricter requirements not necessarily rejected by the reader alone, including canonical small-order encoding and zero padding.
Decide explicitly whether a trailing newline is accepted/normalized or rejected; follow NetworkX’s documented behavior rather than implementing an accidental third convention.
Checker
Keep the checker’s independent stdlib replay if the project values implementation diversity. Move its duplicated wire-contract validation under #1110’s generated passive checker contract, leaving only the graph6 mathematics/bitstream replay in checker code.
Tests
Differentially test the producer against NetworkX and the independent checker across:
0..62at boundaries0, 1, 2, 62;Property tests can generate NetworkX graphs, encode them using
to_graph6_bytes, and require the Jacobian producer and independent checker to agree.Acceptance criteria
Non-goals
Related