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

Merged
crapougnax merged 2 commits from feat/73-okf-v02-document into develop 2026-11-19 08:04:20 +00:00
Owner

Closes #73

What

A document module in @quatrain/okf for OKF v0.2, independent of OKFBackendAdapter:

  • parseOkfDocument / serializeOkfDocument: unknown keys kept in their order, spec keys first, a bare verified mapping read as a one-element list, body written as given (reads back unchanged), undefined/null left out.
  • Provenance (§5, §7): parseOkfActor, okfTrustTier, isOkfStale, okfLastChange (legacy timestamp fallback), withOkfGenerated, withOkfVerification (one entry per actor).
  • validateOkfDocument(document, profile?): producer-side rules of the spec (non-empty type, status vocabulary, tags list, actors, datetimes with offset, sources[].resource, unique source ids; timestamp / # Citations as warnings) and a profile for applications: required keys, forbidEmpty, forbidLegacy, own rules.
  • upgradeOkfDocument(document, { by }): v0.1 → v0.2.
  • renderOkfIndex(sections, { okfVersion, preamble }): index.md per §8.

Attested computations (§10) are out of scope.

Tests

  • npx jest packages/okf: 74 passed (16 new); tsc --noEmit clean.
  • Smoke run, not committed, on a real v0.1 bundle of 798 concepts: every document parses and upgrades; writing twice gives the same text and the same keys for 796 of them — the other 2 hold null values, which are left out by design.

🤖 Generated with Claude Code

Closes #73 ## What A document module in `@quatrain/okf` for OKF v0.2, independent of `OKFBackendAdapter`: - `parseOkfDocument` / `serializeOkfDocument`: unknown keys kept in their order, spec keys first, a bare `verified` mapping read as a one-element list, body written as given (reads back unchanged), `undefined`/`null` left out. - Provenance (§5, §7): `parseOkfActor`, `okfTrustTier`, `isOkfStale`, `okfLastChange` (legacy `timestamp` fallback), `withOkfGenerated`, `withOkfVerification` (one entry per actor). - `validateOkfDocument(document, profile?)`: producer-side rules of the spec (non-empty `type`, `status` vocabulary, `tags` list, actors, datetimes with offset, `sources[].resource`, unique source ids; `timestamp` / `# Citations` as warnings) and a **profile** for applications: required keys, `forbidEmpty`, `forbidLegacy`, own rules. - `upgradeOkfDocument(document, { by })`: v0.1 → v0.2. - `renderOkfIndex(sections, { okfVersion, preamble })`: `index.md` per §8. Attested computations (§10) are out of scope. ## Tests - `npx jest packages/okf`: 74 passed (16 new); `tsc --noEmit` clean. - Smoke run, not committed, on a real v0.1 bundle of 798 concepts: every document parses and upgrades; writing twice gives the same text and the same keys for 796 of them — the other 2 hold `null` values, which are left out by design. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(okf): OKF v0.2 document model — parse, write, provenance, validation with profiles, index files
All checks were successful
Quatrain Core CI / Monorepo Build, Tests & Quality Audit (pull_request) Successful in 5m7s
Quatrain Core CI / Monorepo Build, Tests & Quality Audit (push) Successful in 5m12s
Quatrain Core CI / Publish Changed Packages to npm (push) Has been skipped
Quatrain Core CI / Publish Changed Packages to npm (pull_request) Has been skipped
eda2209802
Applications that read and write OKF bundles need the document model of
OKF v0.2, not only the backend adapter. A document module, independent of
the adapter:

- parseOkfDocument / serializeOkfDocument: unknown keys kept in their order,
  spec keys written first, a bare verified mapping read as a list, the body
  written as given so it reads back unchanged;
- provenance: actors, trust tier, staleness, last change with the legacy
  timestamp as fallback, helpers to stamp generated and add a verification;
- validateOkfDocument with profiles: required keys, no empty values, no
  v0.1 keys, and rules of the application;
- upgradeOkfDocument: timestamp to generated, citations list reported;
- renderOkfIndex: index.md per section 8, okf_version at the root only.

Attested computations (section 10) are out of scope.

Closes #73

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge branch 'develop' into feat/73-okf-v02-document
All checks were successful
Quatrain Core CI / Monorepo Build, Tests & Quality Audit (push) Successful in 5m29s
Quatrain Core CI / Publish Changed Packages to npm (push) Has been skipped
Quatrain Core CI / Monorepo Build, Tests & Quality Audit (pull_request) Successful in 7m25s
Quatrain Core CI / Publish Changed Packages to npm (pull_request) Has been skipped
2ab8801f2e
crapougnax merged commit 01c91f8c4a into develop 2026-11-19 08:04:20 +00:00
crapougnax deleted branch feat/73-okf-v02-document 2026-11-19 08:04:20 +00:00
Sign in to join this conversation.
No description provided.