feat(cli,consume): the first span, and the fusion that punished fine-graining
Round 6 left two things behind: a measured coverage hole with the repair built
but not the number to move it, and a retrieval regression that kept two
spreadsheet rules off the default. Both are measured; four defaults move.
THE HOLE IS BIGGER THAN THE RULE BUILT FOR IT. Measured over the 39-document
corpus, the pre-move default left 207 435 characters -- 11.92 % -- in no
segment: 163 804 above the first entry, 26 041 between entries, 17 590 after
the last. `--first-span-from-zero` closes the first part entirely, 79 % of the
whole, leaving 43 631 (2.51 %) over 8 of 32 documents. It adds no boundary and
the K2 concept count is identical with and without it (425 = 425); hit@8 holds
[1,1,1,1,1,-] under both tie-breaks and the 12-position reference does not move
one cell.
THE RANKER WAS PUNISHING FINE-GRAINING FOR BEING FINE-GRAINED. Round 6 held
`--sheet-section-rows --keep-table-heading` back because on a bundle built with
them row 1 fell rank 1 -> 2, and ruled out the document prior because its rank
over 39 DOCUMENTS was 1 on both bundles. RRF reads a rank over CONCEPTS:
splitting the gold document 1 -> 12 puts its own twelve concepts in that
signal's whole top tie group, so the one leading the body signal takes position
11, contributing 1/71 where the undivided concept contributed 1/61. A signal
that scored them all EQUALLY still emitted twelve ranks, ordered by concept_id,
and the fusion read alphabetical order as a measurement.
AND THE REPAIR WAS ALREADY IN THE TREE, OFF FOR A COST THAT HAD BEEN REMOVED.
`--tie-shared-rank` shipped off 2026-09-08 because hit@8 fell 5 of 6 to 4 of 6.
Swept over 2 prior exponents x 3 bundles x 6 rows: that fall exists only at
DOCUMENT_PRIOR_EXPONENT 1.0. Round 6 moved the exponent to 0.5 for an unrelated
reason and correctly reported it moved no hit@8 row -- nobody measured the
pair. A flag's "off by measurement" is a measurement of a CONFIGURATION, not a
property of the flag.
Shipped, each with an explicit opt-out and both directions measured rather than
asserted: --no-first-span-from-zero --no-sheet-section-rows
--no-keep-table-heading reproduces the previous bundle byte for byte (diff -rq,
0 differences), and the no-flag build equals the explicit-flag build.
--no-tie-shared-rank reproduces the previous excerpt order -- the one change
here that alters a payload with no bundle changing.
K2 default: 436 concepts / 832 files, digest 8dff8a8e6c15d2f7..., hit@8 5 of 6
ranks [1,1,1,1,1,-]. The pin now holds its own known-negative on those bytes:
read with --no-tie-shared-rank the same bundle gives [2,1,1,1,1,-], so the
green assertion names its cause. Consumer cost is a re-run: 425/810 -> 436/832
on the reference corpus, 15/30 -> 26/52 on a five-document folder.
pptx and md measured end to end for the first time, on two hand-built
documents: md recovers 3 of 4 declared headings, pptx segments per slide only
where the converter recognised a title placeholder. A converter attribute leaks
into titles ({#slide-N}, {#sheet-1}) on 2 of 810 K2 files and 1 of 30 on a
five-document folder -- not fixed, because a filename is reduced from its title
and the fix renames concept ids a consumer has cited.
Suite 1486 (1478 before), ruff and mypy --strict clean over 21 files.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
38104b7df5
commit
a364ef4c7d
11 changed files with 768 additions and 99 deletions
|
|
@ -638,10 +638,13 @@ def test_sheet_section_rows_reaches_the_proposer_from_the_build_command(tmp_path
|
|||
|
||||
|
||||
def test_the_build_default_leaves_a_sheet_as_one_concept(tmp_path: Path) -> None:
|
||||
"""The control the test above rests on: same inbox, no flag, one concept.
|
||||
"""The control the test above rests on: same inbox, D3 OFF, one concept.
|
||||
|
||||
Without it, a change that turned D3 on by default would leave the assertion
|
||||
above green while cutting every table a consumer has ever ingested.
|
||||
D3 became the default on 2026-09-10, so the control now names the opt-out
|
||||
rather than saying nothing. It is still a control and still load-bearing:
|
||||
it is what makes the assertion above a statement about D3 rather than a
|
||||
statement about this fixture, and it is the test that goes red if
|
||||
`--no-sheet-section-rows` ever stops reproducing the pre-2026-09-10 cut.
|
||||
"""
|
||||
inbox = inbox_for_sheet_sections(tmp_path)
|
||||
plans = tmp_path / "plans-sheet-plain"
|
||||
|
|
@ -653,6 +656,8 @@ def test_the_build_default_leaves_a_sheet_as_one_concept(tmp_path: Path) -> None
|
|||
str(plans),
|
||||
"--proposed-at",
|
||||
PROPOSED_AT,
|
||||
"--no-sheet-section-rows",
|
||||
"--no-keep-table-heading",
|
||||
)
|
||||
== 0
|
||||
)
|
||||
|
|
|
|||
|
|
@ -6,14 +6,17 @@ measured on a bundle nobody produces is a number that cannot regress, so the
|
|||
guarantee it looks like was never held by anything.
|
||||
|
||||
This file pins the CURRENT default: `--outline-run 3 --table-grid --unit-fold
|
||||
--drop-wrapped-outline --outline-gate`, the configuration round 6 moved the
|
||||
default to on 2026-09-09 after measuring hit@8 on exactly this bundle.
|
||||
--drop-wrapped-outline --outline-gate --first-span-from-zero
|
||||
--sheet-section-rows --keep-table-heading`, plus the reading side's
|
||||
`tie_shared_rank`. Round 6 moved the first five on 2026-09-09 and round 7 moved
|
||||
the last four on 2026-09-10, each after measuring hit@8 on exactly the bundle
|
||||
its own default produces.
|
||||
|
||||
The gold set is LOCAL-ONLY and stays that way: no question and no
|
||||
`gold_document` is reproduced here, and a row is named by its INDEX, the way
|
||||
`docs/2026-09-07-okf-konsumskill-maaling.md` already names them.
|
||||
|
||||
The bundle itself is a build artefact, not a fixture: it is 810 files of a
|
||||
The bundle itself is a build artefact, not a fixture: it is 832 files of a
|
||||
consumer's corpus and this repository is public. Absent, these tests SKIP with
|
||||
the command that rebuilds it -- "not measured", never zero.
|
||||
"""
|
||||
|
|
@ -34,10 +37,10 @@ import okf_consume_measure # noqa: E402
|
|||
|
||||
#: Built by:
|
||||
#: okf build <corpus>/K2/trinn1 \
|
||||
#: --bundle ~/corpora/okf-telling-20260829/K2-bundle-default-20260909 \
|
||||
#: --bundle ~/corpora/okf-telling-20260829/K2-bundle-default-20260910 \
|
||||
#: --bundle-id k2-trinn1-20260903 --okf-version 0.2
|
||||
#: with no arm flag at all -- the package default, which is the point.
|
||||
DEFAULT_BUNDLE = Path.home() / "corpora" / "okf-telling-20260829" / "K2-bundle-default-20260909"
|
||||
DEFAULT_BUNDLE = Path.home() / "corpora" / "okf-telling-20260829" / "K2-bundle-default-20260910"
|
||||
GOLD_SET = PROJECT_ROOT / ".claude/projects/2026-09-07-okf-consume-prepass/hit-at-k-questions.json"
|
||||
|
||||
requires_default_bundle = pytest.mark.skipif(
|
||||
|
|
@ -49,8 +52,11 @@ requires_default_bundle = pytest.mark.skipif(
|
|||
),
|
||||
)
|
||||
|
||||
#: Measured 2026-09-09 on the bundle above.
|
||||
EXPECTED_CONCEPTS = 425
|
||||
#: Measured 2026-09-10 on the bundle above. The count moved 425 -> 436 with
|
||||
#: `--sheet-section-rows --keep-table-heading`; `--first-span-from-zero` moved
|
||||
#: it by NOTHING, which is the point of that rule -- it adds no boundary and
|
||||
#: only moves one span's start.
|
||||
EXPECTED_CONCEPTS = 436
|
||||
EXPECTED_HITS = 5
|
||||
#: Rank per question INDEX, `None` for the row that misses on every bundle and
|
||||
#: every configuration measured so far. The identity is the index; the question
|
||||
|
|
@ -70,6 +76,10 @@ def test_hit_at_eight_holds_rank_one_on_every_row_it_held() -> None:
|
|||
Not the hit COUNT alone: the count survived a configuration that lost a
|
||||
row from rank 1 to rank 2, which is exactly how the previous round's
|
||||
regression hid. The rank per row is the pin.
|
||||
|
||||
On THIS bundle that is not a hypothetical -- see the test below, which
|
||||
reproduces the fall on these exact bytes by turning the reading-side
|
||||
default off.
|
||||
"""
|
||||
questions = json.loads(GOLD_SET.read_text(encoding="utf-8"))["questions"]
|
||||
assert len(questions) == len(EXPECTED_RANKS), "the gold set changed shape"
|
||||
|
|
@ -87,3 +97,31 @@ def test_hit_at_eight_holds_rank_one_on_every_row_it_held() -> None:
|
|||
def test_the_bundle_declares_the_identity_the_reader_needs() -> None:
|
||||
"""Whatever else moves, the bundle stays one the reading direction opens."""
|
||||
assert okf_consume.root_bundle_id_of(DEFAULT_BUNDLE) == "k2-trinn1-20260903"
|
||||
|
||||
|
||||
@requires_default_bundle
|
||||
def test_the_reading_default_is_what_holds_row_one_on_these_bytes() -> None:
|
||||
"""The known-negative, on the shipped bundle rather than a fixture.
|
||||
|
||||
Round 7 moved `--sheet-section-rows --keep-table-heading` into the build
|
||||
default, which splits row 1's gold document from 1 concept into 12. Round 6
|
||||
measured that exact split costing row 1 its rank, and held the two rules
|
||||
back for it. What removed the cost is `consume.DEFAULT_TIE_SHARED_RANK`,
|
||||
and this test is the proof that it is still what removes it: turn it off
|
||||
on these bytes and the fall comes back.
|
||||
|
||||
Without this, `EXPECTED_RANKS` above would be a green assertion with no
|
||||
stated cause, and a later change to the fusion could take the cause away
|
||||
while the pin stayed green on some other accident.
|
||||
"""
|
||||
questions = json.loads(GOLD_SET.read_text(encoding="utf-8"))["questions"]
|
||||
ranks = []
|
||||
for entry in questions:
|
||||
payload = okf_consume.build_payload(
|
||||
DEFAULT_BUNDLE, question=entry["question"], tie_shared_rank=False
|
||||
)
|
||||
excerpts = payload["excerpts"]
|
||||
assert isinstance(excerpts, list)
|
||||
ranks.append(okf_consume_measure.hit_rank(excerpts, entry["gold_document"]))
|
||||
assert ranks[0] == 2, "the known-negative stopped being negative"
|
||||
assert tuple(ranks[1:]) == EXPECTED_RANKS[1:]
|
||||
|
|
|
|||
|
|
@ -68,5 +68,10 @@ def test_the_rule_adds_and_removes_no_boundary() -> None:
|
|||
assert [c.start for c in plain][1:] == [c.start for c in moved][1:]
|
||||
|
||||
|
||||
def test_it_is_off_by_default_in_the_build_command() -> None:
|
||||
assert cli.DEFAULT_FIRST_SPAN_FROM_ZERO is False
|
||||
def test_it_is_on_by_default_in_the_build_command() -> None:
|
||||
"""Moved 2026-09-10, once the hit@8 number round 6 lacked was measured.
|
||||
|
||||
The opt-out is asserted in `tests/test_round7_defaults.py`; here the point
|
||||
is only that the rule below is what a caller gets without saying anything.
|
||||
"""
|
||||
assert cli.DEFAULT_FIRST_SPAN_FROM_ZERO is True
|
||||
|
|
|
|||
|
|
@ -522,10 +522,19 @@ def test_reversing_the_input_order_does_not_change_the_output_order() -> None:
|
|||
|
||||
|
||||
def test_a_concept_in_a_high_scoring_document_outranks_an_equally_lexical_one() -> None:
|
||||
# `tie_shared_rank=False` for the same reason `lookup=False` appears
|
||||
# elsewhere in this file: the claim is about the DOCUMENT PRIOR, and the
|
||||
# default tie-break (shared since 2026-09-10) puts this fixture's two
|
||||
# concepts in the same prior tie group, which makes the assertion true
|
||||
# in both directions and so measures nothing. Isolate the stage under test.
|
||||
concepts = _fixture_concepts()
|
||||
question = "Hvordan skal prisene fylles ut?"
|
||||
lifted = okf_consume.concept_scores(concepts, question, {"krav": 10.0, "dyp": 0.0})
|
||||
dropped = okf_consume.concept_scores(concepts, question, {"krav": 0.0, "dyp": 10.0})
|
||||
lifted = okf_consume.concept_scores(
|
||||
concepts, question, {"krav": 10.0, "dyp": 0.0}, tie_shared_rank=False
|
||||
)
|
||||
dropped = okf_consume.concept_scores(
|
||||
concepts, question, {"krav": 0.0, "dyp": 10.0}, tie_shared_rank=False
|
||||
)
|
||||
krav_first = [c.concept_id for c, _, _ in lifted].index("krav/pristabell")
|
||||
krav_later = [c.concept_id for c, _, _ in dropped].index("krav/pristabell")
|
||||
assert krav_first < krav_later
|
||||
|
|
@ -1771,7 +1780,9 @@ def test_counting_leaves_the_identifier_worth_no_more_than_the_common_word() ->
|
|||
# The claim here is about the FUSION, so the fusion is what is read.
|
||||
for identifier_in_body in (False, True):
|
||||
concepts = _rarity_corpus(identifier_in_body=identifier_in_body)
|
||||
ranked = okf_consume.concept_scores(concepts, RARITY_QUESTION, {}, lookup=False)
|
||||
ranked = okf_consume.concept_scores(
|
||||
concepts, RARITY_QUESTION, {}, lookup=False, tie_shared_rank=False
|
||||
)
|
||||
assert _rank_of(ranked, RARITY_GOLD) == 18
|
||||
lexical = {concept.concept_id: value for concept, _, value in ranked}
|
||||
assert lexical["krav/c-00"] == 6
|
||||
|
|
@ -1786,7 +1797,9 @@ def test_weighting_a_hit_by_its_rarity_lifts_the_identifier_into_the_cut() -> No
|
|||
weights = okf_consume.rarity_weights(
|
||||
okf_consume.normalise(RARITY_QUESTION), okf_consume.searchable_text(concepts)
|
||||
)
|
||||
ranked = okf_consume.concept_scores(concepts, RARITY_QUESTION, {}, weights=weights)
|
||||
ranked = okf_consume.concept_scores(
|
||||
concepts, RARITY_QUESTION, {}, weights=weights, tie_shared_rank=False
|
||||
)
|
||||
assert _rank_of(ranked, RARITY_GOLD) <= 8
|
||||
|
||||
|
||||
|
|
@ -1817,9 +1830,28 @@ def test_a_rarity_weight_cannot_move_a_signal_the_gold_already_leads() -> None:
|
|||
assert _signal_rank(concepts, RARITY_QUESTION, RARITY_GOLD, None) == 1
|
||||
assert _signal_rank(concepts, RARITY_QUESTION, RARITY_GOLD, weights) == 1
|
||||
ranked = okf_consume.concept_scores(
|
||||
concepts, RARITY_QUESTION, {}, weights=weights, lookup=False
|
||||
concepts, RARITY_QUESTION, {}, weights=weights, lookup=False, tie_shared_rank=False
|
||||
)
|
||||
assert _rank_of(ranked, RARITY_GOLD) == 18
|
||||
# AND the falsification under the 2026-09-10 tie-break, measured rather
|
||||
# than assumed -- with the COST it carries on this fixture written down.
|
||||
# The claim survives and is stronger (30 -> 30 with and without the
|
||||
# weight), but the gold's absolute rank is WORSE than the 18 above: the id
|
||||
# order that had put it at 18 was luck inside a tie group, and shared ranks
|
||||
# take that luck away in both directions. This fixture is the adverse
|
||||
# shape for the rule -- one signal separates, two do not, and the one that
|
||||
# separates is the one the gold loses. It is recorded here because it is
|
||||
# the honest limit of the end-to-end measurement that moved the default:
|
||||
# ranks held at 1 on every row of three real bundles, and a synthetic
|
||||
# corpus of 30 near-identical concepts is not one of them.
|
||||
under_default = okf_consume.concept_scores(
|
||||
concepts, RARITY_QUESTION, {}, weights=weights, lookup=False
|
||||
)
|
||||
unweighted_under_default = okf_consume.concept_scores(
|
||||
concepts, RARITY_QUESTION, {}, lookup=False
|
||||
)
|
||||
assert _rank_of(under_default, RARITY_GOLD) == 30
|
||||
assert _rank_of(unweighted_under_default, RARITY_GOLD) == 30
|
||||
|
||||
|
||||
def test_the_weight_leaves_the_lexical_count_a_count_so_the_cut_is_untouched() -> None:
|
||||
|
|
@ -1836,7 +1868,9 @@ def test_the_weight_leaves_the_lexical_count_a_count_so_the_cut_is_untouched() -
|
|||
}
|
||||
weighted = {
|
||||
c.concept_id: v
|
||||
for c, _, v in okf_consume.concept_scores(concepts, RARITY_QUESTION, {}, weights=weights)
|
||||
for c, _, v in okf_consume.concept_scores(
|
||||
concepts, RARITY_QUESTION, {}, weights=weights, tie_shared_rank=False
|
||||
)
|
||||
}
|
||||
assert plain == weighted
|
||||
|
||||
|
|
@ -1989,14 +2023,29 @@ def test_the_weight_reaches_the_title_signal_and_reorders_it() -> None:
|
|||
assert _signal_rank(concepts, question, "krav/t-29", weights) == 1
|
||||
# `lookup=False`: the gold's title bears the identifier, so the lookup
|
||||
# partition answers this question at rank one. The fusion is the claim.
|
||||
plain = okf_consume.concept_scores(concepts, question, {}, lookup=False)
|
||||
weighted = okf_consume.concept_scores(concepts, question, {}, weights=weights, lookup=False)
|
||||
plain = okf_consume.concept_scores(concepts, question, {}, lookup=False, tie_shared_rank=False)
|
||||
weighted = okf_consume.concept_scores(
|
||||
concepts, question, {}, weights=weights, lookup=False, tie_shared_rank=False
|
||||
)
|
||||
# Fused: 30 -> 18. The title signal is reordered from last to first and the
|
||||
# fused rank moves by twelve, not to one -- the other two signals still
|
||||
# cannot see the identifier. That gap IS the finding of this session, and
|
||||
# the numbers are here so a change to either half shows up as a diff.
|
||||
assert _rank_of(plain, "krav/t-29") == 30
|
||||
assert _rank_of(weighted, "krav/t-29") == 18
|
||||
# AND WHAT THE 2026-09-10 TIE-BREAK DID TO THAT GAP, measured rather than
|
||||
# left implicit. This fixture is the shape shared ranks were built for:
|
||||
# every body is identical and the prior is empty, so both of the signals
|
||||
# that "cannot see the identifier" separate NOTHING, and under shared ranks
|
||||
# they stop ordering by id and contribute one constant each. The title
|
||||
# signal is then alone in deciding and the gold goes to rank 1 -- the gap
|
||||
# this test named does not survive the fusion change, and a reader of
|
||||
# `docs/2026-09-08-sjeldenhetsvekt.md` needs to know the figure there was
|
||||
# measured under the older tie-break.
|
||||
under_default = okf_consume.concept_scores(
|
||||
concepts, question, {}, weights=weights, lookup=False
|
||||
)
|
||||
assert _rank_of(under_default, "krav/t-29") == 1
|
||||
|
||||
|
||||
# --- Step 14: exact identifier matching and the lookup signal (O2c) -----------
|
||||
|
|
|
|||
84
tests/test_round7_defaults.py
Normal file
84
tests/test_round7_defaults.py
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
"""What round 7 moved to the default, and the opt-out that reproduces the old bytes.
|
||||
|
||||
Three moves, each with its own acceptance measurement in
|
||||
`docs/2026-09-10-k3-runde7-forste-spenn-og-rangeringen.md`:
|
||||
|
||||
* `--first-span-from-zero`, because 32 of the 32 corpus documents with a plan
|
||||
left their opening text in NO segment -- 9.18 % of the corpus.
|
||||
* `--sheet-section-rows --keep-table-heading`, which were held back in round 6
|
||||
by a retrieval regression the third move removes.
|
||||
* `tie_shared_rank` on the reading side, which is what removed it.
|
||||
|
||||
Every move keeps an explicit opt-out: a default a caller cannot turn off is
|
||||
not a default, and a consumer needing the previous bytes needs a way to say so.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from llm_ingestion_okf import cli, consume
|
||||
|
||||
|
||||
def test_the_build_defaults_carry_the_three_rules_round_seven_moved() -> None:
|
||||
assert cli.DEFAULT_FIRST_SPAN_FROM_ZERO is True
|
||||
assert cli.DEFAULT_SHEET_SECTION_ROWS is True
|
||||
assert cli.DEFAULT_KEEP_TABLE_HEADING is True
|
||||
|
||||
|
||||
def test_the_reading_side_shares_a_rank_a_signal_did_not_earn_by_default() -> None:
|
||||
"""`tie_shared_rank` is what let the two build rules above ship.
|
||||
|
||||
Measured on the D1+D3 bundle: the gold document splits from 1 concept into
|
||||
12, its own 12 concepts occupy the document-prior signal's whole top tie
|
||||
group, and the concept leading the body signal lands at prior position 11
|
||||
instead of 1. Row 1 falls from fused rank 1 to 2. Shared ranks put it back.
|
||||
"""
|
||||
assert consume.DEFAULT_TIE_SHARED_RANK is True
|
||||
|
||||
|
||||
def test_every_moved_default_has_an_opt_out_that_the_parser_accepts() -> None:
|
||||
args = cli.parse_args(
|
||||
[
|
||||
"build",
|
||||
"src",
|
||||
"--bundle",
|
||||
"out",
|
||||
"--bundle-id",
|
||||
"x",
|
||||
"--no-first-span-from-zero",
|
||||
"--no-sheet-section-rows",
|
||||
"--no-keep-table-heading",
|
||||
]
|
||||
)
|
||||
assert args.first_span_from_zero is False
|
||||
assert args.sheet_section_rows is False
|
||||
assert args.keep_table_heading is False
|
||||
|
||||
|
||||
def test_the_build_defaults_reach_the_parser_without_a_flag() -> None:
|
||||
args = cli.parse_args(["build", "src", "--bundle", "out", "--bundle-id", "x"])
|
||||
assert args.first_span_from_zero is True
|
||||
assert args.sheet_section_rows is True
|
||||
assert args.keep_table_heading is True
|
||||
|
||||
|
||||
def test_the_consume_parser_offers_an_opt_out_for_the_shared_rank() -> None:
|
||||
assert consume.parse_args(["b", "--question", "q"]).tie_shared_rank is True
|
||||
assert (
|
||||
consume.parse_args(["b", "--question", "q", "--no-tie-shared-rank"]).tie_shared_rank
|
||||
is False
|
||||
)
|
||||
|
||||
|
||||
def test_build_payload_defaults_to_the_shared_rank(tmp_path: Path) -> None:
|
||||
"""The default reaches the API, not only the CLI.
|
||||
|
||||
`okf skill` emits `okf consume`, but `tests/test_default_bundle_pin.py` and
|
||||
every measurement harness call `build_payload` directly. A default living
|
||||
in `argparse` alone would make the two disagree.
|
||||
"""
|
||||
import inspect
|
||||
|
||||
signature = inspect.signature(consume.build_payload)
|
||||
assert signature.parameters["tie_shared_rank"].default is True
|
||||
|
|
@ -137,31 +137,54 @@ def test_shared_rank_lifts_the_concept_the_measuring_signals_lead(tmp_path: Path
|
|||
assert _gold_rank(root, tie_shared_rank=True) == 1
|
||||
|
||||
|
||||
def test_the_payload_is_byte_identical_with_the_flag_off(tmp_path: Path) -> None:
|
||||
def test_the_payload_is_byte_identical_with_the_flag_on(tmp_path: Path) -> None:
|
||||
"""The rule became the default 2026-09-10; saying so explicitly changes nothing.
|
||||
|
||||
The assertion is unchanged in kind -- the implicit and the explicit value
|
||||
must produce the same bytes -- only the value it names moved.
|
||||
"""
|
||||
root = _tie_bundle(tmp_path / "bundle")
|
||||
without = okf_consume.serialise(okf_consume.build_payload(root, question=QUESTION))
|
||||
explicit_off = okf_consume.serialise(
|
||||
okf_consume.build_payload(root, question=QUESTION, tie_shared_rank=False)
|
||||
explicit_on = okf_consume.serialise(
|
||||
okf_consume.build_payload(root, question=QUESTION, tie_shared_rank=True)
|
||||
)
|
||||
assert without == explicit_off
|
||||
assert without == explicit_on
|
||||
|
||||
|
||||
def test_the_opt_out_reproduces_the_order_the_default_used_to_give(tmp_path: Path) -> None:
|
||||
"""The other half: a consumer needing the pre-2026-09-10 order can have it.
|
||||
|
||||
Load-bearing rather than symmetric. `--no-tie-shared-rank` is the only
|
||||
thing standing between a consumer pinned to the old excerpt order and a
|
||||
silent reordering, so the opt-out needs a test that goes red if it stops
|
||||
being a real alternative -- which it would be if it produced the same
|
||||
bytes as the default on the very fixture built to separate them.
|
||||
"""
|
||||
root = _tie_bundle(tmp_path / "bundle")
|
||||
default = okf_consume.serialise(okf_consume.build_payload(root, question=QUESTION, k=3))
|
||||
opted_out = okf_consume.serialise(
|
||||
okf_consume.build_payload(root, question=QUESTION, k=3, tie_shared_rank=False)
|
||||
)
|
||||
assert default != opted_out
|
||||
|
||||
|
||||
def test_the_flag_changes_the_payload_it_is_meant_to_change(tmp_path: Path) -> None:
|
||||
root = _tie_bundle(tmp_path / "bundle")
|
||||
off = okf_consume.build_payload(root, question=QUESTION, k=3)
|
||||
on = okf_consume.build_payload(root, question=QUESTION, k=3, tie_shared_rank=True)
|
||||
off = okf_consume.build_payload(root, question=QUESTION, k=3, tie_shared_rank=False)
|
||||
on = okf_consume.build_payload(root, question=QUESTION, k=3)
|
||||
delivered_off = [excerpt["concept_id"] for excerpt in off["excerpts"]] # type: ignore[index]
|
||||
delivered_on = [excerpt["concept_id"] for excerpt in on["excerpts"]] # type: ignore[index]
|
||||
assert not any(str(cid).endswith("zz-gull") for cid in delivered_off)
|
||||
assert str(delivered_on[0]).endswith("zz-gull")
|
||||
|
||||
|
||||
def test_the_cli_exposes_the_flag_and_defaults_it_off(tmp_path: Path) -> None:
|
||||
def test_the_cli_exposes_the_flag_and_defaults_it_on(tmp_path: Path) -> None:
|
||||
root = _tie_bundle(tmp_path / "bundle")
|
||||
parsed = okf_consume.parse_args([str(root), "--question", QUESTION])
|
||||
assert parsed.tie_shared_rank is False
|
||||
parsed_on = okf_consume.parse_args([str(root), "--question", QUESTION, "--tie-shared-rank"])
|
||||
assert parsed_on.tie_shared_rank is True
|
||||
# The other flag this session added, asserted here so "both default off"
|
||||
# is one measurement rather than two files' worth of trust.
|
||||
assert parsed.tie_shared_rank is True
|
||||
parsed_off = okf_consume.parse_args([str(root), "--question", QUESTION, "--no-tie-shared-rank"])
|
||||
assert parsed_off.tie_shared_rank is False
|
||||
# `--withheld-titles` did NOT move with it, asserted here so the two are
|
||||
# one measurement rather than two files' worth of trust: it is off for a
|
||||
# reason of BYTES, which nothing this round touched.
|
||||
assert parsed.withheld_titles is False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue