feat(okf): wire adapter into public API — import_bundle carries link graph, package exposes okf namespace (TDD, +2)
This commit is contained in:
parent
b80c896fd9
commit
07e0b2153a
3 changed files with 31 additions and 2 deletions
|
|
@ -56,6 +56,7 @@ from .grounding import (
|
|||
no_grounding_check,
|
||||
DEFAULT_GROUNDING_CHECK,
|
||||
)
|
||||
from . import okf
|
||||
|
||||
__version__ = "0.1.0"
|
||||
|
||||
|
|
@ -142,4 +143,6 @@ __all__ = [
|
|||
"SourceGroundingCheck", "no_grounding_check", "DEFAULT_GROUNDING_CHECK",
|
||||
# §6 bookends
|
||||
"prepare_input", "screen_output", "PreparedInput",
|
||||
# OKF adapter (v0.2) — the format-specific layer, as its own namespace
|
||||
"okf",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -315,10 +315,17 @@ class ConceptResult:
|
|||
|
||||
@dataclass(frozen=True)
|
||||
class BundleResult:
|
||||
"""Per-concept results plus the bundle's aggregate (most-severe) disposition."""
|
||||
"""Per-concept results, the aggregate disposition, and the cross-link graph.
|
||||
|
||||
``links`` is the in-import :class:`LinkGraphResult` for the whole bundle
|
||||
(dangling / rejected / resolved edges), so a mode-b import returns both halves
|
||||
of the gate together. Whether a dangling or rejected link should block is the
|
||||
caller's disposition call (design principle 4).
|
||||
"""
|
||||
|
||||
concepts: tuple
|
||||
disposition: Disposition
|
||||
links: "LinkGraphResult"
|
||||
|
||||
def log(self):
|
||||
"""The ``log.md`` body — one line per concept, rejected ones marked."""
|
||||
|
|
@ -347,7 +354,7 @@ def import_bundle(bundle, *, origin=Origin.EXTERNAL, channel=Channel.AUTOMATIC):
|
|||
for path in sorted(bundle)
|
||||
)
|
||||
aggregate = _most_severe(r.disposition for r in results)
|
||||
return BundleResult(results, aggregate)
|
||||
return BundleResult(results, aggregate, link_graph(bundle))
|
||||
|
||||
|
||||
def _validate_concept(path, doc, origin, channel):
|
||||
|
|
|
|||
|
|
@ -444,3 +444,22 @@ def test_link_graph_records_rejected_dangerous_link():
|
|||
bundle = {"a/main.md": "---\ntype: t\n---\n[x](javascript:alert(1))\n"}
|
||||
graph = link_graph(bundle)
|
||||
assert any(from_id == "a/main" for from_id, _target, _reason in graph.rejected)
|
||||
|
||||
|
||||
# --- wiring: import_bundle carries the cross-link graph, and the package
|
||||
# exposes the okf adapter as a first-class namespace ----------------------
|
||||
|
||||
def test_import_bundle_attaches_link_graph():
|
||||
bundle = {
|
||||
"a/main.md": "---\ntype: t\n---\nSee [later](/b/target.md).\n",
|
||||
"a/other.md": "---\ntype: t\n---\nNothing linked here.\n",
|
||||
}
|
||||
result = import_bundle(bundle)
|
||||
assert ("a/main", "b/target") in result.links.dangling
|
||||
|
||||
|
||||
def test_okf_adapter_is_exposed_from_package():
|
||||
import llm_ingestion_guard as guard
|
||||
|
||||
assert "okf" in guard.__all__
|
||||
assert guard.okf.import_bundle is import_bundle
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue