Skip to content

Frontmatter writer injects empty title/created onto records that lack them (events) #815

Description

@williamthorsen

Description

writeFrontmatter (in @codeassembly/kb) renders title, created, and updated unconditionally, in a fixed order. The Frontmatter model treats them as first-class string fields, and parse-note.ts defaults each to '' when the source omits it. This is assertion-shaped: assertions carry title/created/updated, but event records do not (they use captured-at, have no title, and — until #809 — no updated).

So writing an event back through writeFrontmatter injects title: '' and created: '' into it. Validation then rejects the record, because created is a date field (DATE_FIELDS) and '' is not a valid date:

created: expected YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ, got ""

writeBackNote validates before the atomic write, so the write is refused and the note is left untouched — which means every kb-edit operation on an event fails outright. --add-addressed-by (#785) is the first operation pointed at events, so it is the first to surface that the write path cannot round-trip a non-assertion record.

This is independent of the schema declarations in #809: even with updated/addressed-by declared on the event type, the writer still injects an empty title/created, and the date rule still rejects the empty created.

Context

Acceptance criteria

Must have

  • writeFrontmatter round-trips an event record without injecting title, created, or updated fields the record does not carry.
  • A kb-edit operation (e.g. --add-addressed-by) on an event produces a record that passes schema validation, including the date-format rule (no empty created).
  • Records that legitimately carry title/created/updated (assertions) still round-trip unchanged.
  • New and modified behavior is covered by tests, including round-tripping an event through a write operation.

Metadata

Metadata

Labels

bugSomething isn't workingscope:kb

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions