feat(okf): OKF v0.2 document model — parse, write, provenance, validation with profiles, index files #73

Closed
opened 2026-11-19 07:48:56 +00:00 by crapougnax · 0 comments
Owner

Need

Applications that read and write OKF bundles (curation tools, ingestion pipelines) need the document model of OKF v0.2, not only a backend adapter: parse and write a concept, keep unknown keys, read provenance and trust, check a document against the specification and against the stricter rules of an application, upgrade v0.1 documents, and write index.md files.

@quatrain/okf only ships OKFBackendAdapter today, which serialises entities and knows nothing of sources, generated, verified, trust tiers or index files.

Proposal

A document module in @quatrain/okf, independent of the backend adapter:

  • parseOkfDocument(text) / serializeOkfDocument(document): YAML frontmatter + markdown body; unknown keys preserved in their order; spec keys written first; a bare verified mapping read as a one-element list.
  • Provenance (§5, §7): actor parsing (human:, process:, <producer>/<version>), trustTier(), isStale(), lastChange() (falls back to a legacy timestamp), helpers to stamp generated and add a verification.
  • validateOkfDocument(document, profile?): issues (error / warning) for the producer-side rules of the specification (non-empty type, datetimes with an explicit offset, actor format, sources[].resource, status vocabulary, reserved names); a profile lets an application add required keys, refuse empty values or legacy keys, and plug its own rules.
  • upgradeOkfDocument(document, { by }): v0.1 → v0.2 (timestamp → generated), reporting what it cannot convert (# Citations body list).
  • renderOkfIndex(sections, { okfVersion }): index.md per §8, frontmatter only at the bundle root.

Attested computations (§10) are out of scope.

## Need Applications that read and write OKF bundles (curation tools, ingestion pipelines) need the **document model of OKF v0.2**, not only a backend adapter: parse and write a concept, keep unknown keys, read provenance and trust, check a document against the specification and against the stricter rules of an application, upgrade v0.1 documents, and write `index.md` files. `@quatrain/okf` only ships `OKFBackendAdapter` today, which serialises entities and knows nothing of `sources`, `generated`, `verified`, trust tiers or index files. ## Proposal A document module in `@quatrain/okf`, independent of the backend adapter: - `parseOkfDocument(text)` / `serializeOkfDocument(document)`: YAML frontmatter + markdown body; unknown keys preserved in their order; spec keys written first; a bare `verified` mapping read as a one-element list. - Provenance (§5, §7): actor parsing (`human:`, `process:`, `<producer>/<version>`), `trustTier()`, `isStale()`, `lastChange()` (falls back to a legacy `timestamp`), helpers to stamp `generated` and add a verification. - `validateOkfDocument(document, profile?)`: issues (error / warning) for the producer-side rules of the specification (non-empty `type`, datetimes with an explicit offset, actor format, `sources[].resource`, `status` vocabulary, reserved names); a **profile** lets an application add required keys, refuse empty values or legacy keys, and plug its own rules. - `upgradeOkfDocument(document, { by })`: v0.1 → v0.2 (`timestamp` → `generated`), reporting what it cannot convert (`# Citations` body list). - `renderOkfIndex(sections, { okfVersion })`: `index.md` per §8, frontmatter only at the bundle root. Attested computations (§10) are out of scope.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
quatrain/core#73
No description provided.