feat(okf): add okf_validate; harden YAML parser for block lists + folded scalars

Verified conformant against Google reference bundles (crypto_bitcoin, ga4, stackoverflow).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-16 19:38:31 +09:00
parent 9762ee97ab
commit 7b239dda8f
4 changed files with 223 additions and 4 deletions

View File

@@ -24,6 +24,21 @@ class TestFrontmatter(unittest.TestCase):
def test_empty_list(self):
self.assertEqual(parse_yaml_subset("tags: []")["tags"], [])
def test_block_list(self):
raw = "type: BigQuery Dataset\ntags:\n- cryptocurrency\n- bitcoin\n- public data\ntimestamp: '2026-05-28T22:44:47+00:00'"
meta = parse_yaml_subset(raw)
self.assertEqual(meta["tags"], ["cryptocurrency", "bitcoin", "public data"])
self.assertEqual(meta["timestamp"], "2026-05-28T22:44:47+00:00")
def test_folded_multiline_scalar(self):
raw = "description: This dataset contains a complete history of the Bitcoin\n blockchain and updates every 10 minutes.\ntype: BigQuery Dataset"
meta = parse_yaml_subset(raw)
self.assertEqual(
meta["description"],
"This dataset contains a complete history of the Bitcoin blockchain and updates every 10 minutes.",
)
self.assertEqual(meta["type"], "BigQuery Dataset")
def test_no_frontmatter(self):
meta, body = parse_frontmatter("# Just markdown\n")
self.assertIsNone(meta)