|
| 1 | +# OKGF Conformance |
| 2 | + |
| 3 | +This document defines what it means for a page or bundle to conform to **OKGF v0.1**, and how to check |
| 4 | +it with the reference validator in [`tools/okgf_validate.py`](tools/okgf_validate.py). The normative rules |
| 5 | +live in [`SPEC.md`](SPEC.md); this file restates them as a checklist and describes the tooling. |
| 6 | + |
| 7 | +## What conformance means |
| 8 | + |
| 9 | +OKGF is a strict superset of [OKF](https://github.com/GoogleCloudPlatform/knowledge-catalog). A conformant |
| 10 | +OKGF artifact is therefore a conformant OKF artifact that additionally respects the governance rules. |
| 11 | + |
| 12 | +### A conformant page |
| 13 | + |
| 14 | +1. Has a `---`-delimited YAML frontmatter block that parses as a YAML mapping. |
| 15 | +2. Declares a non-empty `type` (the only OKF-required field). |
| 16 | +3. For every governance field present, the value is within range: |
| 17 | + - `x-okgf-scope` is one of `personal`, `team`, `org` |
| 18 | + - `x-okgf-review` is one of `draft`, `proposed`, `approved` |
| 19 | + - `x-okgf-tier` is one of `bronze`, `silver`, `gold` |
| 20 | + - `x-okgf-sources` is a list of strings (URIs) |
| 21 | + - `x-okgf-signature` is base64 that decodes to a 64-byte Ed25519 signature |
| 22 | +4. Preserves any unrecognized frontmatter keys (they are never an error). |
| 23 | + |
| 24 | +Governance fields are **optional**. A page that omits all of them is a conformant (ungoverned) OKGF page. |
| 25 | + |
| 26 | +### A conformant bundle |
| 27 | + |
| 28 | +1. Contains a root `index.md` whose frontmatter declares `okf_version`. |
| 29 | +2. `log.md`, `index.md`, `principles.md`, and `schema.md` are reserved and are not validated as content |
| 30 | + pages. |
| 31 | +3. Every other `.md` file is a conformant page (above). |
| 32 | + |
| 33 | +### Signature verification (optional) |
| 34 | + |
| 35 | +`x-okgf-signature` is base64 Ed25519 over the UTF-8 bytes of: |
| 36 | + |
| 37 | +``` |
| 38 | +<type>\n<title>\n<x-okgf-scope>\n<x-okgf-review>\n<body> |
| 39 | +``` |
| 40 | + |
| 41 | +The verifying public key is distributed out of band. A present-but-invalid signature MUST be treated as |
| 42 | +untrusted (the validator reports it as an error when a key is supplied). An unsigned page is valid. When no |
| 43 | +key is supplied, the validator format-checks the signature and reports it as **unverified**, not trusted. |
| 44 | + |
| 45 | +## Checking conformance |
| 46 | + |
| 47 | +The reference validator needs Python 3.9+ and PyYAML. Signature verification additionally needs the |
| 48 | +`cryptography` package and a public key. |
| 49 | + |
| 50 | +```sh |
| 51 | +# Validate pages and/or bundle directories (structure + governance ranges): |
| 52 | +python tools/okgf_validate.py examples/minimal examples/governed |
| 53 | + |
| 54 | +# Also cryptographically verify signatures against an org public key: |
| 55 | +python tools/okgf_validate.py --pubkey examples/governed/ORG_PUBKEY.pem examples/governed |
| 56 | + |
| 57 | +# Treat warnings (e.g. missing recommended OKF fields, unverified signatures) as failures: |
| 58 | +python tools/okgf_validate.py --strict examples/governed |
| 59 | +``` |
| 60 | + |
| 61 | +Exit status is `0` when there are no errors (and, under `--strict`, no warnings), otherwise `1`. A usage or |
| 62 | +environment problem (bad key, missing dependency) exits `2`. |
| 63 | + |
| 64 | +### Errors vs warnings |
| 65 | + |
| 66 | +- **Errors** are conformance violations: missing frontmatter, empty `type`, an out-of-range governance |
| 67 | + value, a malformed or cryptographically invalid signature, or a bundle whose `index.md` is missing or |
| 68 | + does not declare `okf_version`. |
| 69 | +- **Warnings** are advisory: a missing recommended OKF field (`title`, `description`, `timestamp`), an |
| 70 | + `okf_version` the validator does not recognize, or a signature that could not be verified because no key |
| 71 | + was supplied. |
| 72 | + |
| 73 | +## Examples |
| 74 | + |
| 75 | +The [`examples/`](examples/) directory ships two bundles that are held conformant by CI: |
| 76 | + |
| 77 | +- `examples/minimal/` - the smallest valid bundle, OKF baseline with no governance. |
| 78 | +- `examples/governed/` - full governance: scoped/reviewed/tiered pages, provenance, and a real signed `org` |
| 79 | + promotion with its public key (`ORG_PUBKEY.pem`). |
0 commit comments