test(consume): the reading without the door's link line is the default
K3-23 measured the whole decomposition and landed on one recommendation:
the cost is the PATH, not the link. 39 of 39 newcomers that won a question
token from the door's `Enclosing section:` line won it through the
bundle-absolute path and 0 of 39 through the link's title, and every token
the path ever contributed is a segment of the document's own directory --
the saturation `shared_id_prefix` took OUT of the id signal, back in through
the body.
Ten cases, each red for its own reason on `7faa380`, and each one measuring
BEHAVIOUR rather than a signature: the three entry points are called with no
parameter at all and what came back is read.
- `searchable_text`, `concept_scores` and `build_payload` with no parameter
read a body without the door's line (3 cases).
- The declared default IS the behaviour: the constant is imported from the
module that owns it, INSIDE the test so the red falls on the rule and not
on collection, and then spent on a payload comparison.
- Y = Z in miniature: the flagged bundle read by default delivers the same
list, the same ORDER and the same `spent` as the unflagged build.
- `link_in_signal=True` is still reachable and still does the old thing --
both halves, because either alone would pass on a no-op.
- The two known-negatives restated against the DEFAULT path: a human line
opening with the same two words, and the door's exact form anywhere but
last, keep every byte.
- Rank, never form: the two readings differ in the delivered set while every
concept delivered by both carries identical excerpt bytes.
Two stay green on both sides on purpose. The known-positive -- a bundle where
no body ends in the door's form is byte-identical under both readings -- is
section 4A's exposure gate in miniature and would go red only if the stripper
became eager. The characterisation of what the line does today is HEAD's
behaviour and keeps stating it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
7faa380666
commit
3816ed505c
1 changed files with 218 additions and 5 deletions
|
|
@ -11,8 +11,9 @@ the id signal (`shared_id_prefix`).
|
|||
|
||||
This file gives `consume` the instrument that separates the two readings on ONE
|
||||
bundle: the line stays in the file and stays in the excerpt a reader gets, and
|
||||
`link_in_signal=False` keeps it out of the SIGNAL alone. It is not a flag and
|
||||
not a default; K3-23's measurement decides whether it becomes either.
|
||||
`link_in_signal=False` keeps it out of the SIGNAL alone. K3-23 measured with it
|
||||
and recommended it; since K3-25 it is the DEFAULT reading, and `True` is the
|
||||
reading a caller now has to ask for.
|
||||
|
||||
The recognition is the DOOR's, not a regex over prose: `inbox.ENCLOSING_SECTION`
|
||||
plus the link's own shape, in the one place the door writes it -- last in the
|
||||
|
|
@ -190,11 +191,223 @@ def test_the_excerpt_still_carries_the_line_the_reader_needs(tmp_path: Path) ->
|
|||
assert any(DOOR_LINE in text for text in texts)
|
||||
|
||||
|
||||
def test_the_default_payload_is_byte_identical_to_the_instrument_off(tmp_path: Path) -> None:
|
||||
"""The instrument ships OFF: no default moves until K3-23's numbers say so."""
|
||||
def test_the_default_payload_is_the_reading_without_the_line(tmp_path: Path) -> None:
|
||||
"""K3-23 shipped the instrument OFF; K3-25 made it the default.
|
||||
|
||||
The assertion is the same shape and the other side of it: a payload built
|
||||
with no parameter is the one built with `link_in_signal=False`, and the
|
||||
reading K3-23 defaulted to is now the one a caller names.
|
||||
"""
|
||||
root = _bundle(tmp_path / "bundle")
|
||||
implicit = okf_consume.serialise(okf_consume.build_payload(root, question=QUESTION))
|
||||
explicit = okf_consume.serialise(
|
||||
okf_consume.build_payload(root, question=QUESTION, link_in_signal=True)
|
||||
okf_consume.build_payload(root, question=QUESTION, link_in_signal=False)
|
||||
)
|
||||
assert implicit == explicit
|
||||
|
||||
|
||||
# --- K3-25: the reading WITHOUT the line becomes the default ------------------
|
||||
#
|
||||
# K3-23 measured the whole decomposition and landed on one recommendation: the
|
||||
# cost is the PATH, not the link. 39 of 39 newcomers that won a question token
|
||||
# from the door's line won it through the bundle-absolute path and 0 of 39
|
||||
# through the link's title, and every token the path ever contributed is a
|
||||
# segment of the document's own directory -- exactly the saturation
|
||||
# `shared_id_prefix` (round 20) took OUT of the id signal, back in through the
|
||||
# body. Under that reading the flagged bundle delivers what the unflagged one
|
||||
# delivers, on 16 of 16 rows.
|
||||
#
|
||||
# These cases pin the RULE, never the implementation: every one of them calls
|
||||
# the entry points WITHOUT the parameter and reads what came back. None of them
|
||||
# asks a signature what its default is, because a default is a behaviour and a
|
||||
# signature is a spelling of it.
|
||||
#
|
||||
# The two known-negatives above are now on the DEFAULT path rather than behind
|
||||
# a parameter, which is why they are restated here against it.
|
||||
|
||||
|
||||
def _default_texts(root: Path) -> dict[str, str]:
|
||||
"""`searchable_text` with NO parameter, keyed by concept id."""
|
||||
concepts = [
|
||||
okf_consume.read_concept(
|
||||
root / f"{concept_id}.md", bundle_root=root, root_bundle_id="link-fixture"
|
||||
)
|
||||
for concept_id in okf_consume.enumerate_concepts(root)
|
||||
]
|
||||
return dict(zip([c.concept_id for c in concepts], okf_consume.searchable_text(concepts)))
|
||||
|
||||
|
||||
def _unflagged(root: Path) -> Path:
|
||||
"""The same three concepts as `_bundle`, built as the door leaves them
|
||||
WITHOUT `--shell-parent`: the shell's body is its heading alone.
|
||||
|
||||
This is Z. `_bundle` is the flagged build, and reading it with the default
|
||||
is Y. K3-23's Y = Z control is the one row that makes rank-versus-budget a
|
||||
measurement rather than an assumption, so it is restated here in miniature,
|
||||
deterministic, and without a corpus.
|
||||
"""
|
||||
_bundle(root)
|
||||
(root / "r761" / "skall.md").write_text(
|
||||
_FRONTMATTER.format(title="33.212 Boltetype B", digest="1" * 64)
|
||||
+ "## 33.212 Boltetype B\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
return root
|
||||
|
||||
|
||||
def _delivered(payload: dict[str, object]) -> list[str]:
|
||||
return [str(excerpt["concept_id"]) for excerpt in payload["excerpts"]] # type: ignore[index,union-attr]
|
||||
|
||||
|
||||
def _spent(payload: dict[str, object]) -> int:
|
||||
return int(payload["budget"]["spent"]) # type: ignore[index,call-overload]
|
||||
|
||||
|
||||
def test_the_default_reading_takes_the_doors_line_out_of_the_signal(tmp_path: Path) -> None:
|
||||
"""`searchable_text` called with NO parameter: the door's line is gone."""
|
||||
root = _bundle(tmp_path / "bundle")
|
||||
texts = _default_texts(root)
|
||||
assert DOOR_LINE not in texts["r761/skall"]
|
||||
|
||||
|
||||
def test_the_default_reading_scores_the_shell_at_zero(tmp_path: Path) -> None:
|
||||
"""`concept_scores` called with NO parameter: the shell's only hit was the
|
||||
line, so its own lexical overlap is 0 and the cut withholds it as a guess."""
|
||||
root = _bundle(tmp_path / "bundle")
|
||||
concepts = [
|
||||
okf_consume.read_concept(
|
||||
root / f"{concept_id}.md", bundle_root=root, root_bundle_id="link-fixture"
|
||||
)
|
||||
for concept_id in okf_consume.enumerate_concepts(root)
|
||||
]
|
||||
ranked = okf_consume.concept_scores(
|
||||
concepts, QUESTION, okf_consume.document_scores(root, QUESTION)
|
||||
)
|
||||
scored = {concept.concept_id: lexical for concept, _, lexical in ranked}
|
||||
assert scored["r761/skall"] == 0
|
||||
|
||||
|
||||
def test_the_default_payload_reads_the_body_without_the_line(tmp_path: Path) -> None:
|
||||
"""`build_payload` called with NO parameter equals the explicit `False`."""
|
||||
root = _bundle(tmp_path / "bundle")
|
||||
implicit = okf_consume.serialise(okf_consume.build_payload(root, question=QUESTION))
|
||||
explicit = okf_consume.serialise(
|
||||
okf_consume.build_payload(root, question=QUESTION, link_in_signal=False)
|
||||
)
|
||||
assert implicit == explicit
|
||||
|
||||
|
||||
def test_the_named_default_is_the_one_the_entry_points_read(tmp_path: Path) -> None:
|
||||
"""The constant this module declares IS the behaviour, not a label beside it.
|
||||
|
||||
Imported from the module that OWNS it -- inside the test, so the red falls
|
||||
on the rule and not on collection -- and then spent: a payload built with
|
||||
the constant's value must be the payload built with no parameter at all.
|
||||
"""
|
||||
from llm_ingestion_okf.consume import DEFAULT_LINK_IN_SIGNAL
|
||||
|
||||
assert DEFAULT_LINK_IN_SIGNAL is False
|
||||
root = _bundle(tmp_path / "bundle")
|
||||
implicit = okf_consume.serialise(okf_consume.build_payload(root, question=QUESTION))
|
||||
named = okf_consume.serialise(
|
||||
okf_consume.build_payload(root, question=QUESTION, link_in_signal=DEFAULT_LINK_IN_SIGNAL)
|
||||
)
|
||||
assert implicit == named
|
||||
|
||||
|
||||
def test_the_old_reading_is_still_reachable_and_still_does_the_old_thing(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
"""The default moves; the possibility does not disappear.
|
||||
|
||||
A caller asking for today's reading explicitly gets today's reading -- the
|
||||
shell still scores on the line, and the payload is a DIFFERENT one from the
|
||||
default's. Both halves, because either alone would pass on a no-op.
|
||||
"""
|
||||
root = _bundle(tmp_path / "bundle")
|
||||
assert _lexical(root, link_in_signal=True)["r761/skall"] == 1
|
||||
default = okf_consume.serialise(okf_consume.build_payload(root, question=QUESTION))
|
||||
old = okf_consume.serialise(
|
||||
okf_consume.build_payload(root, question=QUESTION, link_in_signal=True)
|
||||
)
|
||||
assert default != old
|
||||
|
||||
|
||||
def test_the_flagged_bundle_read_by_default_delivers_what_the_unflagged_one_does(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
"""Y = Z, in miniature: same list, same ORDER, same `spent`.
|
||||
|
||||
The flagged build read with the default (Y) against the unflagged build read
|
||||
with the default (Z). `spent` can be equal here for one reason and it is the
|
||||
same reason it was equal on R761: under this reading the shell has no
|
||||
lexical hit at all, so it is never delivered, and every concept that IS
|
||||
delivered holds bytes the door never touched.
|
||||
"""
|
||||
flagged = okf_consume.build_payload(_bundle(tmp_path / "flagged"), question=QUESTION)
|
||||
unflagged = okf_consume.build_payload(_unflagged(tmp_path / "unflagged"), question=QUESTION)
|
||||
assert _delivered(flagged) == _delivered(unflagged)
|
||||
assert _spent(flagged) == _spent(unflagged)
|
||||
|
||||
|
||||
def test_a_human_line_with_the_same_two_words_survives_the_default_reading(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
"""Known-negative 1, restated against the default path."""
|
||||
root = _bundle(tmp_path / "bundle")
|
||||
texts = _default_texts(root)
|
||||
assert DOOR_LINE not in texts["r761/skall"]
|
||||
assert "Enclosing section: se kapittelet om sikringsbolter." in texts["r761/menneske"]
|
||||
|
||||
|
||||
def test_the_doors_form_anywhere_but_last_survives_the_default_reading(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
"""Known-negative 2, restated against the default path."""
|
||||
root = _bundle(tmp_path / "bundle")
|
||||
texts = _default_texts(root)
|
||||
assert DOOR_LINE not in texts["r761/skall"]
|
||||
assert DOOR_LINE in texts["r761/midt"]
|
||||
assert "Denne teksten staar under lenka." in texts["r761/midt"]
|
||||
|
||||
|
||||
def test_the_two_readings_differ_in_rank_and_never_in_an_excerpts_bytes(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
"""The line stays in the EXCERPT under both readings.
|
||||
|
||||
This is the whole difference between a ranking change and a form change,
|
||||
and it is why the two SKILL.md passages describing the line in the excerpt
|
||||
need no edit: a concept delivered by both readings carries identical bytes,
|
||||
and only the delivered set and its order can move.
|
||||
"""
|
||||
root = _bundle(tmp_path / "bundle")
|
||||
default = okf_consume.build_payload(root, question=QUESTION)
|
||||
old = okf_consume.build_payload(root, question=QUESTION, link_in_signal=True)
|
||||
assert _delivered(default) != _delivered(old)
|
||||
by_id_old = {
|
||||
str(e["concept_id"]): str(e["text"]) # type: ignore[index]
|
||||
for e in old["excerpts"] # type: ignore[union-attr]
|
||||
}
|
||||
for excerpt in default["excerpts"]: # type: ignore[union-attr]
|
||||
concept_id = str(excerpt["concept_id"]) # type: ignore[index]
|
||||
if concept_id in by_id_old:
|
||||
assert str(excerpt["text"]) == by_id_old[concept_id] # type: ignore[index]
|
||||
|
||||
|
||||
def test_a_bundle_carrying_no_link_is_byte_identical_under_both_readings(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
"""Section 4A's exposure gate, in miniature and in the suite.
|
||||
|
||||
KNOWN-POSITIVE: on a bundle where NO body ends in the door's form -- which
|
||||
is every bundle anyone ships today, 0 of 5 -- moving the default moves not
|
||||
one byte. It is the test that would go red if `body_without_link_line` ever
|
||||
became eager.
|
||||
"""
|
||||
root = _unflagged(tmp_path / "bundle")
|
||||
default = okf_consume.serialise(okf_consume.build_payload(root, question=QUESTION))
|
||||
old = okf_consume.serialise(
|
||||
okf_consume.build_payload(root, question=QUESTION, link_in_signal=True)
|
||||
)
|
||||
assert default == old
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue