Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion okf/src/reference_agent/bundle/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Callable

from reference_agent.bundle.document import OKFDocument
from reference_agent.bundle.paths import RESERVED_FILENAMES
from reference_agent.bundle.synthesizer import synthesize_description

_INDEX_FILE = "index.md"
Expand Down Expand Up @@ -68,7 +69,7 @@ def regenerate_indexes(
entries: list[tuple[str, str, str, str]] = []

for child in sorted(directory.iterdir()):
if child.name == _INDEX_FILE:
if child.name in RESERVED_FILENAMES:
continue
if child.is_file() and child.suffix == ".md":
doc = _load_doc(child)
Expand Down
2 changes: 2 additions & 0 deletions okf/src/reference_agent/bundle/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import re
from pathlib import Path

RESERVED_FILENAMES = frozenset({"index.md", "log.md"})

_SEGMENT_RE = re.compile(r"[A-Za-z0-9_][A-Za-z0-9_.\-]*")


Expand Down
4 changes: 2 additions & 2 deletions okf/src/reference_agent/viewer/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from typing import Any

from reference_agent.bundle.document import OKFDocument, OKFDocumentError
from reference_agent.bundle.paths import RESERVED_FILENAMES

_INDEX_NAME = "index.md"
_LINK_RE = re.compile(r"\]\(([^)\s]+\.md)(?:#[A-Za-z0-9_\-]*)?\)")
_TYPE_PALETTE = {
"BigQuery Dataset": "#8b5cf6",
Expand Down Expand Up @@ -69,7 +69,7 @@ def _extract_links(body: str, doc_dir: Path, bundle_root: Path) -> list[str]:
def _walk_concepts(bundle_root: Path) -> list[Concept]:
concepts: list[Concept] = []
for md_path in sorted(bundle_root.rglob("*.md")):
if md_path.name == _INDEX_NAME:
if md_path.name in RESERVED_FILENAMES:
continue
rel = md_path.relative_to(bundle_root).with_suffix("")
concept_id = "/".join(rel.parts)
Expand Down
17 changes: 17 additions & 0 deletions okf/tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,20 @@ def counting_synth(rel: str, children, *, model: str) -> str:
root_index = (root / "index.md").read_text(encoding="utf-8")
assert "(datasets/index.md) - The only dataset in this bundle." in root_index
assert call_count == 0


def test_regenerate_excludes_reserved_log_md(tmp_path: Path):
root = tmp_path / "bundle"
_write_doc(
root / "tables" / "users.md",
"BigQuery Table",
"users",
"Per-user dimension.",
)
(root / "tables" / "log.md").write_text("Added users.\n", encoding="utf-8")

regenerate_indexes(root, model="stub", synthesize=_stub_synth)

tables_index = (root / "tables" / "index.md").read_text(encoding="utf-8")
assert "[users](users.md)" in tables_index
assert "log.md" not in tables_index
16 changes: 16 additions & 0 deletions okf/tests/test_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,22 @@ def test_index_md_is_not_a_concept(tmp_path: Path):
}


def test_log_md_is_not_a_concept(tmp_path: Path):
bundle = tmp_path / "bundle"
_make_bundle(bundle)
_write(bundle / "tables" / "log.md", "Added users on 2026-05-28.\n")
out = tmp_path / "viz.html"
generate_visualization(bundle, out)
data = _extract_bundle_data(out.read_text(encoding="utf-8"))
ids = {n["data"]["id"] for n in data["nodes"]}
assert ids == {
"datasets/my_dataset",
"tables/users",
"tables/events",
"references/metrics/dau",
}


def test_cross_links_become_edges(tmp_path: Path):
bundle = tmp_path / "bundle"
_make_bundle(bundle)
Expand Down