fix(build,consume): stamp every segmented concept, exclude a linked log.md from concept navigation
Two producer-side defects from the S7 acid test (ordre 20260907T234741Z-9578626297-from-.claude), both reproduced on K2 before and after. F1: `okf build --ingested-at` alone stamped only 11/629 concepts -- the unsegmented ones, which read the call's value directly. The 618 segmented concepts read `segment.ingested_at`, the plan's `proposed_at`, independently defaulted to `DEFAULT_STAMP`. `proposed_at` now falls back to `ingested_at` when omitted; neither flag passed still yields `DEFAULT_STAMP` for both. F2: the consumption pre-pass's index walk counted a root-linked `log.md` (`corpus.link_log_in_root_index`, `95eb271`) as a concept, inflating a 629-concept K2 rebuild to 630 and letting the log rank and cut like real content. The link stays -- the contract is silent on `log.md` and `95eb271` already named it a LOCAL choice -- but the walk now treats `LOG_NAME` like the index itself: reachable, never a concept. K2 rebuilt twice from the same corpus and diffed against the delivered `K2-bundle-20260903`: FOR (stashed fix, matchingfbaac6d) reproduces po's numbers exactly -- 619/1108 files differ, 618 ingested_at-only, ref `sha256-tree:4ffd750c...`. ETTER (fix applied) leaves exactly 1 line differing (the deliberate log link, predating this fix) -- 0 files stamped 1970, 629/629 stamped 2026-09-03, ref `sha256-tree:f14872a0...`. The delivered bundle's ref is unchanged before and after (`sha256-tree:9a4e5561...a968b5`), since it carries no log link and the new branch never fires. Conservation identity holds both times: merged + coded rejections = 43 = N, 39/0/4. 1258 -> 1260 tests. mypy --strict clean on 28 files. ruff clean. Both goldens byte-unchanged. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
35b8c9e805
commit
5a0c8794af
5 changed files with 111 additions and 9 deletions
|
|
@ -372,6 +372,30 @@ def test_the_default_stamp_is_named_once(tmp_path: Path) -> None:
|
|||
assert cli.DEFAULT_STAMP[:10] in (bundle / "log.md").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_ingested_at_alone_stamps_every_concept_the_same(tmp_path: Path) -> None:
|
||||
"""`--ingested-at` without `--proposed-at` must stamp every concept alike.
|
||||
|
||||
Measured on K2 (S7 acid test, F1): passing only `--ingested-at` stamped 11
|
||||
of 629 concepts -- the unsegmented whole-document concepts, which read the
|
||||
call's `ingested_at` directly. The 618 segmented concepts read
|
||||
`segment.ingested_at`, which is the PLAN's `proposed_at`, independently
|
||||
defaulted to `DEFAULT_STAMP` when the caller never set it. A caller naming
|
||||
one clock is naming "when this ran", not asking for two different clocks.
|
||||
"""
|
||||
inbox = inbox_with_subdirectories(tmp_path)
|
||||
bundle = tmp_path / "bundle"
|
||||
assert build(inbox, bundle, "--ingested-at", INGESTED_AT) == 0
|
||||
concepts = {
|
||||
name: body
|
||||
for name, body in tree(bundle).items()
|
||||
if name.endswith(".md") and not name.endswith("index.md") and name != "log.md"
|
||||
}
|
||||
assert concepts, "the fixture must produce concepts for this control to mean anything"
|
||||
for name, body in concepts.items():
|
||||
assert f"ingested_at: {INGESTED_AT}".encode() in body, name
|
||||
assert cli.DEFAULT_STAMP.encode() not in body, name
|
||||
|
||||
|
||||
# --- the one implementation ------------------------------------------------
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -112,6 +112,37 @@ def _copy_bundle(source: Path, target: Path) -> None:
|
|||
destination.write_bytes(path.read_bytes())
|
||||
|
||||
|
||||
def test_the_index_walk_excludes_a_linked_log_from_concept_navigation(tmp_path: Path) -> None:
|
||||
"""A linked `log.md` is bundle metadata, not a concept -- measured on K2 (S7 F2).
|
||||
|
||||
`link_log_in_root_index` (`corpus.py`) links a run's own log from the root
|
||||
index so a reader entering at `index.md` can reach it (`95eb271`). That link
|
||||
makes the log reachable by the same walk this instrument uses to enumerate
|
||||
concepts, and a walk that does not distinguish "linked" from "concept"
|
||||
counts it as a 630th concept on a 629-concept bundle -- exactly what the S7
|
||||
acid test measured, with the log then ranked and cut like real content.
|
||||
"""
|
||||
from llm_ingestion_okf.corpus import LOG_NAME, link_log_in_root_index
|
||||
from llm_ingestion_okf.profiles import SEGMENTED_OKF_V0_2
|
||||
|
||||
copy = tmp_path / "bundle"
|
||||
_copy_bundle(GOLDEN, copy)
|
||||
(copy / LOG_NAME).write_text("# Corpus run history\n\nN = 3\n", encoding="utf-8")
|
||||
link_log_in_root_index(copy, SEGMENTED_OKF_V0_2)
|
||||
index = (copy / "index.md").read_text(encoding="utf-8")
|
||||
assert "](log.md)" in index, (
|
||||
"the fixture must actually link the log for this control to mean anything"
|
||||
)
|
||||
|
||||
found = okf_consume.enumerate_concepts(copy)
|
||||
assert found == (
|
||||
"krav/1-1/foerste-krav",
|
||||
"krav/1-2/andre-krav",
|
||||
"veiledning",
|
||||
)
|
||||
assert not any(concept.endswith("log") for concept in found)
|
||||
|
||||
|
||||
def test_the_ref_covers_the_indexes_too_since_the_walk_reads_them(tmp_path: Path) -> None:
|
||||
# The docstring claims every byte that can reach a payload is inside the
|
||||
# ref. An index byte can: it decides which concepts are reachable at all.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue