feat(ingest/repository-documents): import OKF bundles by the OKF 0.3 rules
Brings the GitHub and GitLab documents OKF import (repository_documents) up to OKF 0.3. It reads input leniently: OKF 0.2 bundles keep importing, and the stricter 0.3 rules for stale_after and verified apply to every bundle, whatever its version.
Changes, by OKF 0.3 rule
- Date-only timestamps (§5, §13.2).
stale_after,generated.atandverified[].ataccept2026-06-30, read as the start of that day in UTC. A date-time with no offset is still invalid. Date-times are now checked against RFC 3339 before parsing, so other ISO 8601 forms (20260630T100000Z, week dates,T10Z) are rejected, and every supported Python version gives the same result. - An unreadable
stale_aftermust never count as fresh (§5.5, §11.2). New optionalokfProperties.staleAfterInvalid: boolean, searchable asokfStaleAfterInvalidand exposed in GraphQL asOkfProperties.staleAfterInvalid: Boolean!(false when unset).staleAfterstays null.- Why a flag and not the raw string: the raw value is already stored once, in
raw(and GraphQLfrontmatter), so storing it again would duplicate it. Consumers need a yes/no "treat as stale" signal that search can filter on, and a boolean gives that. A sentinel date would put a fake date in theokfStaleAfterrange queries.
- Why a flag and not the raw string: the raw value is already stored once, in
verifiedevents need bothbyandat(§5.2). An event missing either one, or with an unreadableat, is dropped with an "Incomplete OKF verification event" warning (okf_incomplete_verified_events). It stays inraw.generatedwithoutatis still kept.okf_versionis optional (§2, §8.1). Anyindex.mdwith frontmatter defines a bundle. An unversionedindex.mdinside an existing bundle is a folder listing, not a nested bundle, so a bundle where every folderindex.mdhas frontmatter keeps its concept IDs. A versionedindex.mdstill starts a nested bundle, as before.okf_bundle_rootsworks as before.- Unquoted
okf_version: 0.3. It is kept as written ("0.3", and0.10stays"0.10") rather than dropped. A boolean still warns. - Empty values count as absent (§11.2). null,
""and[]produce no warnings for any typed key, reference key or list entry,typeincluded. - Dot-paths are not part of a bundle (§3.2). Files and folders whose names start with
.below a bundle root (e.g..github/) are not imported (okf_dot_paths_excluded). Anindex.mdin such a dot-folder does not start a nested bundle, even withokf_version. Files outside bundles are unchanged, and a configured root may itself be a dot-folder. x-extension keys (§4.1).x-datahub-owners,x-datahub-glossary_termsandx-datahub-idare aliases of the unprefixed keys. The unprefixed keys are still accepted, and the prefix is never required. If a file sets both forms, the unprefixed key wins, because it is the documented, always-accepted form. The run warns ("Conflicting OKF alias keys",okf_conflicting_alias_keys). Attribution keeps the logical key (owners), so switching between the two forms does not churn associations.- Bundle metadata (§8.1, §13.3). The bundle-root
index.md'stitle,descriptionandlicenseare stored onOkfBundle(and GraphQLOkfBundle), so every concept carries its bundle's name, scope and license. Documents have no description field, so this is where a bundle's description is kept. Values are trimmed (the same rule #21884 uses for the bundletitle), empty values are absent, and a non-string value warns. Explicitokf_bundle_rootsread theirindex.mdmetadata too. - Docs.
github-documents_post.mdnow describes OKF 0.3 and links the spec's new home.docs/how/breaking-changes.mddescribes the behaviour changes.
MAPPING_VERSION goes from 6 to 7, so the next run re-maps existing concepts once and they pick up the new typed values.
Model
OkfPropertiesgains an optionalstaleAfterInvalidfield with@SearchableBOOLEAN.OkfBundlegains optionaltitle,descriptionandlicense. They are not searchable.okfPropertiesgoes fromschemaVersion2 to 3 so consumers can tell which aspects carry the 0.3 fields.bump_schema_versions.pywould treat these additive optional fields as needing no bump, so this one is deliberate.SearchTemplateGoldenTestand the V3 search field tests pass unchanged: no new field is queried by default.
Why this lives in repository_documents
The OKF reading code is shared by github-documents and gitlab-documents, and no other source reads OKF. Nothing here belongs in the framework.
Coordination
- Touches
source.pynext to #21146 (lifecycle stage on import). The only change there is a small block after bundle discovery, so a conflict would be trivial. - Overlap with #21884 (hierarchy).
- #21884 names a bundle's top document from the root
index.mdtitle, using the same rule asOkfBundle.titlehere (a non-empty string, trimmed). The two stay consistent, and #21884 can readbundle.titleonce both land. - Both PRs handle dot-paths. #21884 makes
enclosing_bundlereturn None for a dot-path, which turns such a file into a plain document. This PR leavesenclosing_bundleunchanged and drops dot-paths from the import inokf_bundles.is_excluded_from_bundle, which relies onenclosing_bundlestill returning the bundle. Whichever PR merges second has to reconcile this: keep a single check, and keepis_excluded_from_bundleworking on the raw enclosing root.
- #21884 names a bundle's top document from the root
- Version-aware path resolution (§6.2, §12.1) is out of scope; this PR does not touch path code.
Tests
-
Unit tests for each rule:
test_okf_metadata.py(date-only,staleAfterInvalid, incompleteverified, empty values),test_okf_mapping.py(aliases and precedence),test_okf_bundles.py(unversioned bundles, nested folder indexes, numericokf_version, dot-paths),test_okf_frontmatter.py(emptytype). On master's source, 30 of these fail. -
Golden: the integration test now runs on two bundles. The existing OKF 0.2 fixture is kept; its golden changes only
mappingVersionand the source hashes. A new OKF 0.3 fixture (fixtures_okf_0_3/) covers an unquotedokf_version, date-only values, an unreadablestale_after, an incompleteverifiedevent,x-datahub-keys, empty values and a.github/folder. Its fixture dir is added to.prettierignorelike the existing one. -
DocumentMapperTestcoversstaleAfterInvalidin GraphQL. -
PR title follows the Contributing Guideline
-
Tests added/updated
-
Docs updated
-
Breaking changes documented in
docs/how/breaking-changes.md
🤖 Opened with cclaude on behalf of @shirshanka