Merge frontmatter/parsing: parseFrontmatter with YAML 1.2, TypeBox validation, InvalidInputError
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
---
|
||||
id: frontmatter/parsing
|
||||
name: Implement parseFrontmatter with YAML parsing and TypeBox validation
|
||||
status: pending
|
||||
status: completed
|
||||
depends_on:
|
||||
- frontmatter/splitter
|
||||
- schema/input-schemas
|
||||
@@ -24,17 +24,17 @@ Per [frontmatter.md](../../../docs/architecture/frontmatter.md), the function us
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- [ ] `parseFrontmatter(markdown: string): TaskInput`:
|
||||
- [x] `parseFrontmatter(markdown: string): TaskInput`:
|
||||
- Calls splitter to extract YAML string
|
||||
- Throws `InvalidInputError` if no valid frontmatter found (not `null` return — the caller expects TaskInput)
|
||||
- Calls `yaml.parse(yamlString)` for YAML 1.2 parsing
|
||||
- Runs `Value.Clean(TaskInput, parsed)` to strip unknown properties
|
||||
- Runs `Value.Check(TaskInput, cleaned)` — if fails, runs `Value.Errors()` and throws `InvalidInputError` with structured field/path/message/value details
|
||||
- Returns validated `TaskInput`
|
||||
- [ ] `InvalidInputError` is populated with field-level details from `Value.Errors()` output
|
||||
- [ ] YAML 1.2 used exclusively (the `yaml` package default) — no YAML 1.1 type coercion
|
||||
- [ ] Handles YAML `null` values (e.g., `risk:` with no value) correctly — becomes `null` in the TaskInput (distinction from absent field)
|
||||
- [ ] Unit tests: valid frontmatter, missing required fields, invalid enum values, unknown fields stripped, null categorical values preserved
|
||||
- [x] `InvalidInputError` is populated with field-level details from `Value.Errors()` output
|
||||
- [x] YAML 1.2 used exclusively (the `yaml` package default) — no YAML 1.1 type coercion
|
||||
- [x] Handles YAML `null` values (e.g., `risk:` with no value) correctly — becomes `null` in the TaskInput (distinction from absent field)
|
||||
- [x] Unit tests: valid frontmatter, missing required fields, invalid enum values, unknown fields stripped, null categorical values preserved
|
||||
|
||||
## References
|
||||
|
||||
@@ -44,8 +44,11 @@ Per [frontmatter.md](../../../docs/architecture/frontmatter.md), the function us
|
||||
|
||||
## Notes
|
||||
|
||||
> To be filled by implementation agent
|
||||
All acceptance criteria verified by unit tests and type-checker.
|
||||
|
||||
## Summary
|
||||
|
||||
> To be filled on completion
|
||||
Implemented `parseFrontmatter(markdown: string): TaskInput` with full YAML 1.2 parsing and TypeBox validation pipeline.
|
||||
- Modified: `src/frontmatter/parse.ts` — replaced stub with full implementation (splitter → yaml.parse → Value.Clean → Value.Check → Value.Errors → InvalidInputError)
|
||||
- Modified: `test/frontmatter.test.ts` — added 23 new tests for parseFrontmatter (total 41 tests in file)
|
||||
- Tests: 41 frontmatter tests, all passing; 211 total across all test files, all passing
|
||||
Reference in New Issue
Block a user