fix(gate,propose): okf build runs a real guard; a code fence declares no structure
Two defects reported from outside by claude-code-llm-wiki (order 20260915T202332Z-228694739), both reproduced against this tree before anything moved. F1 -- the packaged CLI never ran the guard. corpus.measure wired an unconditional approve-everything stub into process_inbox and 0 of 90 add_argument calls named a gate, so the one path most people use screened nothing while pyproject.toml made the guard a mandatory runtime dependency and the README recommended a composition the command line could not reach. --gate takes guard-trusted-source (default), guard-user-upload or none. corpus.resolve_gate is the one name->callable map, with the guard imported lazily so importing the package still does not pull it in; an unknown name RAISES rather than falling back, because a fallback reproduces the defect with an extra step. The gate's NAME goes into the section 9 log.md -- a stub is only dangerous when nothing downstream can see it -- and --gate none renders NOTHING WAS SCREENED. The default was chosen on a measurement: over the 453 concept bodies of the pinned reference bundle, PRESET_TRUSTED_SOURCE persists 453 of 453 and PRESET_USER_UPLOAD holds 1, costing that concept's whole source document. Neither tier waves anything through -- an invisible carrier and a CRITICAL finding fail secure at both. Door B's library default is UNCHANGED at PRESET_USER_UPLOAD: an inbox drop is an untrusted upload, an operator pointing this command at their own folder is not. The second tier ships as guard_adapter.inbox_gate_trusted_source, the three-line adapter that module's docstring already described, never a preset parameter. process_inbox(segmentations=..., gate=inbox_gate) now has a test. Before this, `grep -rl inbox_gate tests/` gave 1 file with 0 occurrences of `segment` -- the recommended composition was untested, which is how the defect survived. F2 -- a fenced code block declared structure. `# Use the opus[1m] alias` inside a ```bash fence became a level-1 ATX heading: the document was refused entirely where the line carried [ or ] (5 of 191 pages of the reporter's corpus), and the concept TITLE came from somebody's shell session on 62 of 191 (32.5 %). The fix is in the proposer and never in Door B's title rule -- that rule is right, and a heading that was never a heading is what has to stop being proposed. propose.fenced_lines is computed once per text and no rule reads a fenced line, including Arm D's outline RUN, which selects from the whole line list. Backtick and tilde fences, three leading spaces, a closing fence at least as long as its opener, and no backtick in a backtick fence's info string -- that last one keeps a line holding only `okf build` from silencing a document. MEASURED ON THE BYTES, and this is the number that decides: the 43-document reference corpus built atb6da09c(from git archive, never the editable tree) and rebuilt at the shipped defaults differ in log.md alone, by the one added bullet. 865 concept files on both sides, every concept byte-identical. Found by that control and NOT caused by this work: the pinned artifact K2-bundle-default-20260912 was written 2026-09-09, two days beforeed0418fchanged title: quoting, so it differs from what HEAD produces on 42 concept files. test_default_bundle_pin stays green because it pins the count and the hit@8 ranks, not the bytes. Re-pinning is the operator's call. Suite 1896 passed / 1 skipped (+27 from 1869). ruff, ruff format and mypy --strict clean. No version bump, no tag, no push. Report: docs/2026-09-15-f1-f2-gaten-og-kodefencen.md Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
b6da09cc97
commit
332961a19c
11 changed files with 1194 additions and 10 deletions
23
README.md
23
README.md
|
|
@ -889,6 +889,29 @@ No security functionality is reimplemented here.
|
|||
and (at Door C) a concept the gate returned no verdict for. What it cannot
|
||||
do is check that your adapter is a real guard: a permissive stub approves
|
||||
everything, and the flow will believe it.
|
||||
- **`okf build` runs a real guard by default, and names it in the bundle.**
|
||||
`--gate` takes `guard-trusted-source` (the default), `guard-user-upload` or
|
||||
`none`, and the name is written into the bundle's `log.md` either way, so a
|
||||
consumer holding a bundle can tell a screened one from an unscreened one
|
||||
without asking. `okf project` has no such flag and takes the default.
|
||||
|
||||
That paragraph is new, and the sentence above it was true of our own command
|
||||
until 2026-09-15: `okf build` injected a permissive stub and no argument
|
||||
anywhere in the package named a gate, so the only path most people use
|
||||
screened nothing while the guard sat in `pyproject.toml` as a mandatory
|
||||
runtime dependency. It was reported from outside, reproduced here, and the
|
||||
cost of each tier was measured before the default was chosen — over the 453
|
||||
concept bodies of the pinned reference bundle, `guard-trusted-source` returns
|
||||
the persist disposition on 453 of 453 and `guard-user-upload` holds 1 of
|
||||
them. Neither waves anything through: an invisible carrier and a CRITICAL
|
||||
finding fail secure at both.
|
||||
|
||||
<!-- cli-default-gate: guard-trusted-source -->
|
||||
|
||||
- **`--gate none` is still reachable, by name.** The corpus harness reproduces
|
||||
published numbers with it, and a caller measuring segmentation alone has a
|
||||
legitimate reason to take the gate out of the picture. What changed is that
|
||||
asking for it is an act, and the log says `NOTHING WAS SCREENED`.
|
||||
|
||||
`llm_ingestion_okf.guard_adapter` is the adapter over the real guard, and the
|
||||
only module here that imports it — importing the package itself does not:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue