On main: stage5_r2_predirty
This commit is contained in:
@@ -111,7 +111,9 @@ def test_mdx_section_default_construction_preserves_4_positional_callers():
|
||||
|
||||
|
||||
def test_align_passthrough_when_v4_key_exact_match():
|
||||
# Section already aligned to V4 key — aligner keeps it untouched.
|
||||
# Section already aligned to V4 key (no H3 sub-sections, no override
|
||||
# target): aligner keeps it untouched. Parent-level V4 evidence
|
||||
# flows via exact-match lookup.
|
||||
sections = [_section("04-1", 1, "1. Top", "body")]
|
||||
v4 = {"mdx_sections": {"04-1": {"judgments_full32": []}}}
|
||||
out = align_sections_to_v4_granularity(sections, v4)
|
||||
@@ -119,6 +121,63 @@ def test_align_passthrough_when_v4_key_exact_match():
|
||||
assert out[0].section_id == "04-1"
|
||||
|
||||
|
||||
def test_align_parent_v4_exact_keeps_section_when_no_override_targets_sub():
|
||||
# Backward-compat axis: when V4 carries the parent exact key and no
|
||||
# drag/drop override targets a sub-id of this section, the aligner
|
||||
# MUST keep the parent (preserves V4 evidence at parent granularity).
|
||||
raw = "### 2.1 First\nbody1\n### 2.2 Second\nbody2\n"
|
||||
sections = [_section("03-2", 2, "2. Parent", raw)]
|
||||
v4 = {"mdx_sections": {"03-2": {"judgments_full32": []}}}
|
||||
out = align_sections_to_v4_granularity(sections, v4)
|
||||
assert [s.section_id for s in out] == ["03-2"]
|
||||
|
||||
|
||||
def test_align_force_drills_when_override_targets_sub_id_with_parent_in_v4():
|
||||
# Stage 5 R2 blocker-fix regression: when V4 has the parent exact key
|
||||
# AND an override targets a sub-id of that section, the aligner MUST
|
||||
# drill regardless of V4 parent presence. This makes drag/drop
|
||||
# addressing deterministic across all V4 yaml shapes.
|
||||
raw = "### 2.1 First\nbody1\n### 2.2 Second\nbody2\n"
|
||||
sections = [_section("04-2", 2, "2. Parent", raw)]
|
||||
v4 = {
|
||||
"mdx_sections": {
|
||||
"04-2": {"judgments_full32": []}, # parent V4 entry present
|
||||
"04-2.1": {"judgments_full32": []}, # plus decimal sub entries
|
||||
"04-2.2": {"judgments_full32": []},
|
||||
}
|
||||
}
|
||||
out = align_sections_to_v4_granularity(
|
||||
sections, v4, override_target_section_ids=["04-2-sub-1"]
|
||||
)
|
||||
# Force-drill: parent id MUST be replaced by canonical sub-ids.
|
||||
assert [s.section_id for s in out] == ["04-2-sub-1", "04-2-sub-2"]
|
||||
# Decimal aliases preserved (N-R5: decimal heading_number).
|
||||
assert out[0].v4_alias_keys == ["04-2.1"]
|
||||
assert out[1].v4_alias_keys == ["04-2.2"]
|
||||
|
||||
|
||||
def test_align_top_level_override_target_does_not_force_drill_other_sections():
|
||||
# Top-level override target ("primary=03-1") has no derive_parent_id,
|
||||
# so it MUST NOT force-drill any section. Only "X-sub-N" targets
|
||||
# trigger force-drill on parent X.
|
||||
raw = "### 2.1 First\nbody1\n"
|
||||
sections = [
|
||||
_section("03-1", 1, "1. Top", "body"),
|
||||
_section("03-2", 2, "2. Parent", raw),
|
||||
]
|
||||
v4 = {
|
||||
"mdx_sections": {
|
||||
"03-1": {"judgments_full32": []},
|
||||
"03-2": {"judgments_full32": []},
|
||||
}
|
||||
}
|
||||
out = align_sections_to_v4_granularity(
|
||||
sections, v4, override_target_section_ids=["03-1"]
|
||||
)
|
||||
# No sub-id target -> both sections kept at parent granularity.
|
||||
assert [s.section_id for s in out] == ["03-1", "03-2"]
|
||||
|
||||
|
||||
def test_align_drill_emits_canonical_ordinal_id_with_decimal_alias():
|
||||
# Decimal H3 headings -> canonical ordinal id + decimal alias (legacy V4 key).
|
||||
raw = "### 2.1 First\nbody1\n### 2.2 Second\nbody2\n"
|
||||
|
||||
Reference in New Issue
Block a user