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, matching fbaac6d) 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:
Kjell Tore Guttormsen 2026-09-08 03:21:36 +02:00
commit 5a0c8794af
5 changed files with 111 additions and 9 deletions

View file

@ -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 ------------------------------------------------