feat(okf): OKF-conformant hubs + freshness provenance#151
Merged
Conversation
Make Surface hubs a superset of an Open Knowledge Format (OKF) concept, so every hub is a conformant OKF document that any OKF consumer can read, while Surface adds the freshness OKF deliberately omits. - Frontmatter carries OKF `type` (defaulted to `concept`, existing hubs byte-unchanged), `title`/`tags`/`timestamp`, and preserves any other key verbatim in `extra` (the OKF preserve-unknown-keys rule). Relaxed `deny_unknown_fields` on the frontmatter only; anchor items stay strict. - `surf verify` records the freshness OKF lacks: a stable per-claim `id` (written once, never regenerated) plus `verified_at`/`verified_commit`, stamped only when the hash changes so a no-op verify stays byte-identical. The "who" is intentionally not stored (git blame has it) — no author emails in tracked files. Additive `id` on the JSON `Divergence`. - `bundles` glob governs an OKF bundle directory tree; reserved files (index.md/log.md) are classified and skipped, never blocking the gate. - `surf lint` warns (never blocks) on typo'd frontmatter keys, missing headlines, and dangling OKF cross-links. - Docs: new docs/guides/okf.md; README/index/configuration/CHANGELOG. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
e9e86af to
0ba6e86
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes Surface hubs a superset of an Open Knowledge Format (OKF) concept, so every hub is a conformant OKF document any OKF consumer can read — while Surface adds the one thing OKF's spec explicitly omits: freshness. The positioning writes itself: Surface = OKF + the freshness OKF leaves out.
Changes Made
surf-core/src/hub.rs): frontmatter is a superset of an OKF concept —type(defaulted toconcept, so existing hubs are byte-unchanged and keep working),title/tags/timestamp, and any other key preserved verbatim in a flattenedextra(OKF's "consumers MUST preserve unknown keys").deny_unknown_fieldsrelaxed on the frontmatter only; anchor items stay strict so per-anchor typos still fail closed.surf-cli/src/verify.rs):surf verifystamps a stable per-claimid(written once, never regenerated) plusverified_at/verified_commit— only when the hash actually changes, so a no-op re-verify stays byte-identical. The who is deliberately not stored (git blame on the hub records it), so no author emails land in tracked files. Additiveidon the--format jsonDivergence(no report-version bump).surf-core/src/config.rs,surf-cli/src/workspace.rs): abundlesglob governs a directory tree (<root>/**/*.md); reserved files (index.md/log.md) are classified and skipped, never blocking the gate.surf lintOKF advisories (surf-cli/src/lint.rs): warns (never blocks) on typo'd frontmatter keys — recovering the fail-closed signal the relaxed schema gave up — on missing headlines, and on dangling OKF cross-links (OKF tolerates broken links).docs/guides/okf.md; OKF conformance statements inREADME.md,docs/index.md,docs/reference/configuration.md, andCHANGELOG.md.Type
Feature
Scope boundary (deliberate)
Only concepts that describe code are fact-checked (Surface hashes an AST span). Anchor-less OKF concepts (a table's business meaning, an RFC) are valid, rendered, and ungoverned — they pass the gate untouched. Non-code-resource verifiers and cross-repo aggregation are left as seams for later, not built here.
Testing
cargo test --all— all suites pass (new tests: extra-key round-trip, anchor-less pass-through, reserved-file no-block, unknown-claim-key still rejected, provenance-on-change-only, byte-identical re-verify, id stable across re-verify, bundle discovery, OKF cross-link lint, edit-distance).cargo clippy --all-targets -- -D warningsclean;cargo fmt --allclean.check_workspace/hub_paths/etc.; prose re-read, updated, and re-verified —surf checkis green.index.mdand an anchor-less concept passescheck; a dangling cross-link warns without blocking.🤖 Generated with Claude Code