feat(inbox): walk the drop directory recursively
Door B listed `inbox.iterdir()` and kept only top-level files. A file in a subdirectory was neither ingested nor refused: it appeared in none of the result's buckets, so a nested drop produced a bundle that was silently short of what was dropped and no count said so. That broke the K1b identity for any inbox with folders in it. Operator decision 2026-09-06. - `walk_inbox` is the ONE walk rule, shared with `tools/okf_corpus_run.py`: the denominator N is now counted over exactly the set of files the door ingests, rather than over a second listing that happened to agree. - Sorted on the whole relative path, not the basename, so the order is a function of the tree; that is what keeps rebuild-from-scratch byte-equal to an incremental update. - A concept's `source_file` is the path relative to the inbox root, `/`-separated. The concept NAME still comes from the basename, so two folders holding one basename hit the existing §3 collision refusal instead of one silently claiming the other's concept. - Dot-directories and a bundle directory inside the inbox are skipped with a CODE, in a new `InboxResult.skipped`. Recursion makes the door's own output reachable as its own input; a silent skip would be the same absence-without-a-denominator defect one level down. - `--path-prefix` reduces per component and rejoins with `/`, so the caller driving a nested corpus can carry the relative directory. Reducing the whole string folded the separator into a `-` and flattened `sub/sub2`. `tests/test_inbox_flow.py::test_subdirectories_are_not_walked` asserted the opposite and is superseded in place, with the reason written down. Measured on the K2 corpus (flat, N=43): 39/43 merged, 4 coded, K1b holds. The bundle digest is `1472e98aec8643c5beee540f4c42b5e437bd26e7c61d69a91bcff799f06a6d13` over 1108 files -- byte-identical to a run of the same corpus at190086fWITHOUT this change (`diff -r` exit 0), so recursion costs a flat inbox nothing. It differs from the stored 2026-09-03 artifact by one line in `index.md` (`- [Corpus run history](log.md)`), which95eb271added 15 hours after that bundle was built. Suite 1113 passed, `ruff` clean, `mypy --strict src/ tools/` clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
190086fc3d
commit
aa87eb8818
11 changed files with 489 additions and 39 deletions
|
|
@ -421,14 +421,21 @@ def test_an_empty_inbox_writes_nothing(tmp_path: Path) -> None:
|
|||
assert not bundle.exists() or list(bundle.iterdir()) == []
|
||||
|
||||
|
||||
def test_subdirectories_are_not_walked(tmp_path: Path) -> None:
|
||||
"""Top-level only, like every other inbox in this ecosystem: a nested tree
|
||||
is the operator's structure, not ours to flatten into one namespace.
|
||||
def test_subdirectories_are_walked(tmp_path: Path) -> None:
|
||||
"""Superseded, deliberately, by the operator's decision of 2026-09-06.
|
||||
|
||||
This test used to assert the opposite -- top-level only, "the operator's
|
||||
nested structure is theirs". The rule it pinned was not a boundary, it was
|
||||
a silent loss: a file under a folder appeared in NONE of the result's
|
||||
buckets, so the count said nothing was there rather than that nothing was
|
||||
looked at. The nested structure is still the operator's, and it survives
|
||||
in the recorded `source_file`; it is the disappearance that is gone. The
|
||||
rule's own suite is `tests/test_inbox_recursion.py`.
|
||||
"""
|
||||
drop(tmp_path / "inbox" / "nested", "deep.md", "Body\n")
|
||||
drop(tmp_path / "inbox", "top.md", "Body\n")
|
||||
|
||||
result, bundle = run(tmp_path, StubGuard())
|
||||
|
||||
assert [entry.source_file for entry in result.persisted] == ["top.md"]
|
||||
assert not (bundle / "inbox-deep.md").exists()
|
||||
assert [entry.source_file for entry in result.persisted] == ["nested/deep.md", "top.md"]
|
||||
assert (bundle / "inbox-deep.md").is_file()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue