Found reviewing PR #379, and the root cause of the corruption that PR had to fix.
apply_to_community dumps blocks with width=4096, so each key is one line. The --emit-yaml path dumps at the default width (~100), so long scalars — gtdb_lineage, mapping_source — wrap onto continuation lines indented deeper than the block keys.
13 records in kb/communities/ carry such a wrapped block today, pasted in from --emit-yaml output.
That inconsistency is what made #378 hard: any line-level editor has to handle both shapes, and the first version matched exactly six spaces and orphaned the continuations into duplicate keys. --refresh now normalises them (the swept diff is net −30 lines, all unwrapping), but the two paths still disagree, so a fresh --emit-yaml paste reintroduces the shape.
Fix: dump at the same width in both paths — width=4096 in _block's --emit-yaml rendering — so a pasted block is byte-identical to an applied one.
Secondary, worth considering with it: --refresh without --apply is silently a no-op, and --refresh with --ncbi-id/--name is silently ignored. Argparse enforces neither.
Found reviewing PR #379, and the root cause of the corruption that PR had to fix.
apply_to_communitydumps blocks withwidth=4096, so each key is one line. The--emit-yamlpath dumps at the default width (~100), so long scalars —gtdb_lineage,mapping_source— wrap onto continuation lines indented deeper than the block keys.13 records in
kb/communities/carry such a wrapped block today, pasted in from--emit-yamloutput.That inconsistency is what made #378 hard: any line-level editor has to handle both shapes, and the first version matched exactly six spaces and orphaned the continuations into duplicate keys.
--refreshnow normalises them (the swept diff is net −30 lines, all unwrapping), but the two paths still disagree, so a fresh--emit-yamlpaste reintroduces the shape.Fix: dump at the same width in both paths —
width=4096in_block's--emit-yamlrendering — so a pasted block is byte-identical to an applied one.Secondary, worth considering with it:
--refreshwithout--applyis silently a no-op, and--refreshwith--ncbi-id/--nameis silently ignored. Argparse enforces neither.