ADR 0097: hyper_sssp in Python and on the command line, and the container’s incidence edits from Python#
Status: Technical parts accepted under delegation (2026-11-11; GOVERNANCE.md, “Delegation of technical ADRs”). The names are the author’s: HD12 (
dyng.hyper_sssp,dyng hyper_sssp compute|update, the C++ names the Python ones mirror), HD14 (no openmp backend; every example, tutorial and Python test passes explicit resources) and HD10 (the.dgbflag), decided by the author on 2026-10-28 (GOVERNANCE.md, approvals log, the rows of 2026-10-28); the names the decided list does not spell out are listed in ADR 0096 for the author’s acknowledgement. It carries out M11b criteria 6 and 7 and the Python half of the container’s 0.4 additions (ADR 0087 kept them refused until now). It changes no approved rule.Decided: the author acknowledged on 2026-11-11 (GOVERNANCE.md, approvals log, the row “M11’s public names beyond HD12’s list”) the names that ADR 0096 lists for acknowledgement, and confirmed on 2026-11-18 (the row “AD15 and HD17: the stability of 0.4’s surfaces”; ADR 0110 part A) that
dyng.hyper_sssp,dyng hyper_ssspand the incidence edits andslack_csrstorage ofdyng.Hypergrapharestablefrom 0.4.0; the acknowledgement above is closed.Date: 2026-11-11
Deciders: the AI assistant, on the author’s behalf for the technical parts (M11b, step public-python-cli-docs-freeze); the names: S M Shovan (2026-10-28, HD10, HD12, HD14)
Builds on: ADR 0011 (the Python layer: holders, locks, arrays), ADR 0023 (the uniform contract), ADR 0025 (the command line), ADR 0031 (device arrays and plugins), ADR 0046 (the hypergraph’s Python layer), ADR 0059 (the precedent: triad_count’s Python module and command line), ADRs 0085, 0087 and 0090 (the incidence edits, their files, hyper_sssp’s API).
Context#
The C++ library has had slack_csr storage, incidence edits and hyper_sssp since M11a; the
Python layer refused them (NotSupportedError: HypergraphProperties with "slack_csr", a
batch with an edit read from a file, a .dgb file with the flag incidence_edits) and the
command line had no hyper_sssp. HD14 adds a constraint the earlier modules did not have: the
CPU wheel’s default resources are OpenMP’s (python/dyng/resources.py), where hyper_sssp does not
run in 0.4.
Decision#
1. dyng.hyper_sssp (python/dyng/hyper_sssp.py, python/bindings/hyper_sssp.cpp)#
compute(hypergraph, source, *, options=None, resources=None, **kwargs)andupdate(hypergraph, batch, result, *, resources=None), asdyng.sssp’s (the source an argument of compute; option fields as keywords; the resources default to the hypergraph’s).Options(a dataclass of the C++ fields and defaults:work_budget1.0,max_iterations4096,on_budget"recompute",cuda_engine"automatic",validate_inputsTrue),BudgetActionandFallbackReason(StrEnums: a member is also its name, asdyng.triad_count.Pattern),INFINITE_DISTANCE(2^61 - 1, sssp’s).Stats(a frozen dataclass: the inherited fields,batchadyng.HyperApplySummary,line_graph_insertions,line_graph_deletions,invalidated,relaxations,fallback_reasonaFallbackReason).Result:hyperedge_distancesandhyperedge_parentsare read-only zero-copydyng.Arrays of the result’s state (device memory on cuda; stale after the next update), as sssp’sdistancesandparents;vertex_distances()is a method (computed on request, a hostdyng.Array),distance_to(v)an int;source,options,set_options(),graph_version,space,clone(resources);copy/deepcopyareclone(), and pickling raises with a hint.The hypergraph behind
distance_to()andvertex_distances(). The C++ result reads the rows of the hypergraph it matches through a weak reference, and the two accessors fill caches of the result (ADR 0096 finding 5). The Python result keeps aweakrefto itsdyng.Hypergraph(re-pointed after every successful update, as the C++ link is) and the binding holds the result’s lock exclusively and the hypergraph’s shared during the two calls, so a concurrentHypergraph.apply()or a second accessor call in another thread cannot race with them. A hypergraph that is gone gives the C++stale_result_error(“no longer exists”), as in C++.Errors are mapped as for sssp (ADR 0011’s table); an unweighted hypergraph raises
NotSupportedErrorin Python (the C++ static_assert’s case); openmp resources raise the C++not_supported_error, whose message names the sequential and cuda backends and the fixdyng.Resources("sequential")(HD14). The host store serves both host backends, so a hypergraph built with OpenMP resources runs hyper_sssp withresources=dyng.Resources("sequential").dyng.update(hypergraph, batch, *results)takes hyper_sssp results, several at once (several sources) and next to triad_count results (refused by triad_count’s requirement underslack_csr, HD9:NotSupportedError, nothing changed). A hyper_sssp result passed with adyng.Graphraises theTypeErrorofDYNG_HYPER_SSSP_CONTAINER_MESSAGE.dyng.testing.hyper_sssp_reference(hypergraph, source)andcheck_hyper_sssp_tree(hypergraph, result)bind the C++ oracle in its public mode (a source vertex), on host copies of the rows by id and the weights.
2. The container from Python#
HypergraphProperties(storage="slack_csr", line_graph="slack_csr")(and"automatic") work; the C++ property checks give the matrix’s errors (NotSupportedErrorfor escher +slack_csrandslack_csr+sorted_merge,InvalidArgumentErrorwithoutstore_v2h).HyperedgeBatch(delete_incidences=(h, v), insert_incidences=(h, v))(0.3’s keywords) apply onslack_csrstorage; the batch gains the propertiesdelete_incidences,insert_incidences(two arrays each; empty without edits) andnum_incidence_edits;emptyandreprcount the edits.HyperApplySummary’sinserted_incidences,deleted_incidencesandskipped_ops(0.3’s fields) now count them.dyng.io: the.dgtreader returns the edits, the.dgbreader reads files with the flagincidence_edits(BatchFileHeader.incidence_edits),write_binary_batchessets the flag when a batch has an edit (so a file without edits is 0.3’s, byte for byte) and the.dgtwriter writes-i/+i. The native batch tuple of the readers and the generator gains the four edit arrays.dyng.generators.random_hyperedge_batchtakes the seven incidence mixes (HD12’s enumerators), typed by their ownLiteral,dyng.generators.IncidenceBatchMixName: appending them to 0.3’sHyperedgeBatchMixNamechanges the alias’s value, which griffe reports as a breaking change of the Python API, while a new alias next to it is an addition only.dyng.testing:HypergraphModel.apply()takes the edits withapply()’s skip rules, andstrategies.hyperedge_batches(model, max_incidence_edits=k)draws them (Hypothesis: the update chain with edits equals compute and the oracle, both id orders).
3. dyng hyper_sssp compute|update (python/dyng/cli/_algorithms.py)#
The option flags are the fields of
dyng.hyper_sssp.Optionsone to one (--work-budget X,--max-iterations N,--on-budget recompute|error,--cuda-engine,--validate-inputs/--no-validate-inputs), generated as for every algorithm (ADR 0025).Input:
--input/--hypergraph(a.hgfile) withdyng triad_count’s read flags; the properties default toslack_csrstorage and line graph; the read is weighted (; w) unless--random-weights MIN,MAX,SEEDor--read-options hsosp(MOSP_ESCHER’s loader with its seeded weights) draws the weights; a file without weights fails with a message naming those flags.--source S(default 0).update:--batches FILE ...(.dgtor.dgb, incidence edits included; a.dgbfile’s expected ids checked, as for triad_count).Output:
--out DIRwithhyperedge_distances.txtandhyperedge_parents.txt(sssp’s file formats, one line per hyperedge id,INFand -1 for none) and, with--vertex-distances,vertex_distances.txt; report lines on standard output (--quiet);update_seconds=on standard error, and with--compare-recomputerecompute_seconds=andmatch=yes|no.The default backend is
sequential(hyper_sssp has no OpenMP backend in 0.4;--backend openmpfails with exit status 1 and the library’s message). Exit statuses 0 / 1 / 2 as for every command.add_hyper_sssplives incli/_algorithms.pyand joins the existingfrom ._algorithms importline ofcli/__init__.py, its registration call afteradd_triad_count(the fixed positions of the reconciliation, so M10’slabel_propagationCLI never touches the same line).
4. Explicit resources (HD14)#
The example examples/python/hyper_sssp.py, the tutorial, the doc snippets and every Python test
of hyper_sssp pass dyng.Resources("sequential") (or cuda) explicitly; the CLI chooses sequential
itself; the plugin smoke test (ci/plugin_smoke.py) runs hyper_sssp on the CPU path’s sequential
backend and on cuda with both engines.
Consequences#
The Python layer has no 0.4 refusal left for hypergraphs; the 0.3 refusal tests are updated where
slack_csrnow accepts (escher storage still refuses edits).dyng.hyper_ssspanddyng hyper_ssspare frozen with the C++ header (ADR 0096): a renamed parameter or changed default fails griffe’s check.The weak reference makes the vertex accessors safe across threads at the cost of the two exclusive locks; the hyperedge arrays need no lock beyond the result’s shared one.