Skip to content

index: preserve root index.md okf_version on regeneration - #25

Open
3a3 wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
3a3:index-preserve-okf-version
Open

3a3 wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
3a3:index-preserve-okf-version

Conversation

@3a3

@3a3 3a3 commented Sep 13, 2026 •

Copy link
Copy Markdown

regenerate_indexes() rewrites every index.md from scratch and never reads the existing file, so an okf_version declared in the bundle-root index.md — the only place SPEC.md §8/§12 allow it — is dropped on every enrich run (runner.py calls it at the end of enrich_all).

This change reads the existing bundle-root index.md before rewriting it and re-emits its okf_version key ahead of the regenerated listing. Only that key is carried, and only at the bundle root; every other index.md stays frontmatter-free, as §8 requires.

Reproduced on a copy of bundles/acme_retail at ad30107 with okf_version: "0.2" added to the root index.md: before this change the key is gone after one run; after it, it survives.

Notes:

  • yaml.safe_dump renders the value as okf_version: '0.2' (single quotes); that is the same YAML string as the spec's "0.2".
  • The listing itself is still regenerated from frontmatter, so hand-written index text is still replaced. That behaviour is unchanged here.
  • Test: tests/test_index.py::test_regenerate_preserves_root_okf_version. Full suite: 40 passed.

Related to #26 (gap 1 there is the behaviour this fixes).

regenerate_indexes() never read the existing index.md and wrote the
listing without frontmatter, so an okf_version declared per SPEC.md §8/§12
was dropped on every enrich run. Carry the key forward at the bundle root
only; other index files stay frontmatter-free.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant