orthonym.assembly.name_tree_builder#

Note

Internal API. Names and behaviour may change between releases.

a phase (SCORE-01/02) — pure fragments_to_tree deriver.

The single genuinely-new artifact of Plan 165-01. A side-effect-free transform List[NameFragment] -> NameTreeNode that mirrors the _assemble_fragments classification loop (handlers/_handler_shared.py:779-787) and parent unsaturation-locant unpacking (:877-880), producing the structured Name-Tree IR consumed by SCORE-02 / a phase per-substring scoring.

DUAL-CARRY: every derived node ALSO carries fragment_legacy — the

pre-assembled final name string — so name_tree_to_string round-trips byte-identically . A single synthetic NameFragment CANNOT reproduce a multi-fragment concatenation (the parent path appends "ane" via _build_hydrocarbon_name), so the byte-identical carrier is the final string itself, returned verbatim by the name_tree_to_string str short-circuit (RESEARCH lines 459-462: “a dedicated short-circuit that stores the final string”). The structured fields and the string view both derive from the SAME fragment list, so they cannot disagree.

Purity (-15 /): NO mutation of fragments, its elements, or module globals. NameFragment instances are read, never rewritten.

orthonym.assembly.name_tree_builder.fragments_to_tree(fragments, *, class_id='', section_cite=None, is_mononuclear_parent=False)#

Derive a structured NameTreeNode from a List[NameFragment] (pure).

Mirrors _assemble_fragments term-for-term: - classification loop (_handler_shared.py:779-787) - parent locants is a (double_bond_locants, triple_bond_locants)

tuple, unpacked into unsaturation_locants (:877-880)

  • prefixes alphabetized via _alphabetize_prefixes (same alpha_sort_key as the legacy sort at :854); locants canonicalized via _normalize_locants.