Skip to content

Commit 64742c5

Browse files
mayurpiseclaude
andcommitted
feat(okf): add OKF v0.1 conformance checker; fix index.md to spec
Validated the OKF work against the authoritative spec (github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md §9). This surfaced a real bug: index.md is a RESERVED file and must contain no frontmatter (§6) — except the bundle-root index.md may declare only okf_version (§11). The emitters were writing concept-style `type: Repository` frontmatter into index.md, which is non-conformant. Fixed. - add scripts/tools/okf-check.sh — faithful §9 validator: every non-reserved .md has parseable frontmatter (§9.1) with non-empty `type` (§9.2); reserved index.md/log.md follow §6/§7 (no frontmatter except root okf_version; ISO-8601 log date headings). --quiet for summary-only. tests/test-tools-okf-check.sh. - fix okf-emit.sh + okf-bundle.sh index.md: reserved-file conformant (no frontmatter / root okf_version only; §6 bullet body). Remove okf-bundle --check (okf-check.sh is the single source of truth). - add `type:` to track concept templates (spec/plan/hld/lld/discovery/rca) and inline tracks.md (TrackIndex) so a freshly-init'd draft/ is fully conformant. - wire `okf-check.sh --dir draft` (advisory) into /draft:init and /draft:index. - update affected tests (emit/bundle/snapshot) for the conformant index.md format; each now asserts the emitted bundle passes okf-check. regenerate integrations. No browser required — conformance is purely structural; the OKF visualizer is optional eyeballing only. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 222bcb4 commit 64742c5

19 files changed

Lines changed: 316 additions & 115 deletions

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ TEST_SCRIPTS = \
3232
./tests/test-tools-graph-snapshot.sh \
3333
./tests/test-tools-okf-emit.sh \
3434
./tests/test-tools-okf-bundle.sh \
35+
./tests/test-tools-okf-check.sh \
3536
./tests/test-tools-graph-impact.sh \
3637
./tests/test-tools-graph-callers.sh \
3738
./tests/test-tools-validate-frontmatter.sh \

core/templates/discovery.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
type: Discovery
23
project: "{PROJECT_NAME}"
34
module: "root"
45
track_id: "{TRACK_ID}"

core/templates/hld.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
type: HLD
23
project: "{PROJECT_NAME}"
34
module: "root"
45
track_id: "{TRACK_ID}"

core/templates/lld.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
type: LLD
23
project: "{PROJECT_NAME}"
34
module: "root"
45
track_id: "{TRACK_ID}"

core/templates/plan.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
type: Plan
23
project: "{PROJECT_NAME}"
34
module: "root"
45
track_id: "{TRACK_ID}"

core/templates/rca.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
type: RCA
23
project: "{PROJECT_NAME}"
34
track_id: "{TRACK_ID}"
45
jira_ticket: "{JIRA_KEY}"

core/templates/spec.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
type: Spec
23
project: "{PROJECT_NAME}"
34
module: "root"
45
track_id: "{TRACK_ID}"

integrations/agents/AGENTS.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,6 +1709,7 @@ Create `draft/tracks.md` with metadata header:
17091709

17101710
```markdown
17111711
---
1712+
type: TrackIndex
17121713
project: "{PROJECT_NAME}"
17131714
module: "root"
17141715
generated_by: "draft:init"
@@ -1759,14 +1760,17 @@ to (re)generate the Open Knowledge Format root index so the whole `draft/` tree
17591760
a portable, vendor-neutral OKF bundle. This is the default — no flag required.
17601761

17611762
```bash
1762-
scripts/tools/okf-bundle.sh --dir draft # writes draft/index.md (type: Repository)
1763-
scripts/tools/okf-bundle.sh --dir draft --check # verifies every concept declares type:
1763+
scripts/tools/okf-bundle.sh --dir draft # writes the bundle-root draft/index.md
1764+
scripts/tools/okf-check.sh --dir draft # OKF v0.1 conformance (advisory, non-fatal)
17641765
```
17651766

17661767
`okf-bundle.sh` links every concept file present (`.ai-profile.md`, `.ai-context.md`,
17671768
`architecture.md`, `product.md`, `tech-stack.md`, `workflow.md`, `guardrails.md`), the
1768-
tracks, and the graph sub-bundle (`graph/okf/`). Concept `type:` frontmatter comes
1769-
from the templates; `--check` is a conformance gate, not a hard failure of init.
1769+
tracks, and the graph sub-bundle (`graph/okf/`). Concept `type:` frontmatter comes from
1770+
the templates; `okf-check.sh` validates §9 conformance (frontmatter + `type` on every
1771+
concept; reserved `index.md`/`log.md` structure). It is advisory — report the result,
1772+
do not fail init. Note: operational reports later written into `draft/` (e.g.
1773+
`deep-review-report.md`) are not OKF concepts and will be flagged.
17701774

17711775
**Finalize run memory:** Update `draft/.state/run-memory.json`:
17721776
- `status`: `"completed"`
@@ -3972,8 +3976,8 @@ Format root index so the root `draft/` tree is a portable OKF bundle. This is th
39723976
default; the index links `service-index.md` and every other concept present.
39733977

39743978
```bash
3975-
scripts/tools/okf-bundle.sh --dir draft # writes draft/index.md (type: Repository)
3976-
scripts/tools/okf-bundle.sh --dir draft --check # conformance gate (non-fatal)
3979+
scripts/tools/okf-bundle.sh --dir draft # writes the bundle-root draft/index.md
3980+
scripts/tools/okf-check.sh --dir draft # OKF v0.1 conformance (advisory, non-fatal)
39773981
```
39783982

39793983
## Step 9: Completion Report
@@ -20724,6 +20728,7 @@ If task exceeds 5 iterations:
2072420728
<core-file path="core/templates/spec.md">
2072520729

2072620730
---
20731+
type: Spec
2072720732
project: "{PROJECT_NAME}"
2072820733
module: "root"
2072920734
track_id: "{TRACK_ID}"
@@ -20898,6 +20903,7 @@ approvers:
2089820903
<core-file path="core/templates/plan.md">
2089920904

2090020905
---
20906+
type: Plan
2090120907
project: "{PROJECT_NAME}"
2090220908
module: "root"
2090320909
track_id: "{TRACK_ID}"
@@ -21756,6 +21762,7 @@ Org-wide conventions:
2175621762
<core-file path="core/templates/rca.md">
2175721763

2175821764
---
21765+
type: RCA
2175921766
project: "{PROJECT_NAME}"
2176021767
track_id: "{TRACK_ID}"
2176121768
jira_ticket: "{JIRA_KEY}"
@@ -21930,6 +21937,7 @@ git-ignored at the track level. No HTML or PDF templates ship here.
2193021937
<core-file path="core/templates/discovery.md">
2193121938

2193221939
---
21940+
type: Discovery
2193321941
project: "{PROJECT_NAME}"
2193421942
module: "root"
2193521943
track_id: "{TRACK_ID}"
@@ -22018,6 +22026,7 @@ without line numbers are exempt from drift checks (they document
2201822026
<core-file path="core/templates/hld.md">
2201922027

2202022028
---
22029+
type: HLD
2202122030
project: "{PROJECT_NAME}"
2202222031
module: "root"
2202322032
track_id: "{TRACK_ID}"
@@ -22354,6 +22363,7 @@ Result stored in `metadata.json:pre_deploy_status`
2235422363
<core-file path="core/templates/lld.md">
2235522364

2235622365
---
22366+
type: LLD
2235722367
project: "{PROJECT_NAME}"
2235822368
module: "root"
2235922369
track_id: "{TRACK_ID}"

integrations/copilot/.github/copilot-instructions.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,6 +1709,7 @@ Create `draft/tracks.md` with metadata header:
17091709

17101710
```markdown
17111711
---
1712+
type: TrackIndex
17121713
project: "{PROJECT_NAME}"
17131714
module: "root"
17141715
generated_by: "draft:init"
@@ -1759,14 +1760,17 @@ to (re)generate the Open Knowledge Format root index so the whole `draft/` tree
17591760
a portable, vendor-neutral OKF bundle. This is the default — no flag required.
17601761

17611762
```bash
1762-
scripts/tools/okf-bundle.sh --dir draft # writes draft/index.md (type: Repository)
1763-
scripts/tools/okf-bundle.sh --dir draft --check # verifies every concept declares type:
1763+
scripts/tools/okf-bundle.sh --dir draft # writes the bundle-root draft/index.md
1764+
scripts/tools/okf-check.sh --dir draft # OKF v0.1 conformance (advisory, non-fatal)
17641765
```
17651766

17661767
`okf-bundle.sh` links every concept file present (`.ai-profile.md`, `.ai-context.md`,
17671768
`architecture.md`, `product.md`, `tech-stack.md`, `workflow.md`, `guardrails.md`), the
1768-
tracks, and the graph sub-bundle (`graph/okf/`). Concept `type:` frontmatter comes
1769-
from the templates; `--check` is a conformance gate, not a hard failure of init.
1769+
tracks, and the graph sub-bundle (`graph/okf/`). Concept `type:` frontmatter comes from
1770+
the templates; `okf-check.sh` validates §9 conformance (frontmatter + `type` on every
1771+
concept; reserved `index.md`/`log.md` structure). It is advisory — report the result,
1772+
do not fail init. Note: operational reports later written into `draft/` (e.g.
1773+
`deep-review-report.md`) are not OKF concepts and will be flagged.
17701774

17711775
**Finalize run memory:** Update `draft/.state/run-memory.json`:
17721776
- `status`: `"completed"`
@@ -3972,8 +3976,8 @@ Format root index so the root `draft/` tree is a portable OKF bundle. This is th
39723976
default; the index links `service-index.md` and every other concept present.
39733977

39743978
```bash
3975-
scripts/tools/okf-bundle.sh --dir draft # writes draft/index.md (type: Repository)
3976-
scripts/tools/okf-bundle.sh --dir draft --check # conformance gate (non-fatal)
3979+
scripts/tools/okf-bundle.sh --dir draft # writes the bundle-root draft/index.md
3980+
scripts/tools/okf-check.sh --dir draft # OKF v0.1 conformance (advisory, non-fatal)
39773981
```
39783982

39793983
## Step 9: Completion Report
@@ -20724,6 +20728,7 @@ If task exceeds 5 iterations:
2072420728
<core-file path="core/templates/spec.md">
2072520729

2072620730
---
20731+
type: Spec
2072720732
project: "{PROJECT_NAME}"
2072820733
module: "root"
2072920734
track_id: "{TRACK_ID}"
@@ -20898,6 +20903,7 @@ approvers:
2089820903
<core-file path="core/templates/plan.md">
2089920904

2090020905
---
20906+
type: Plan
2090120907
project: "{PROJECT_NAME}"
2090220908
module: "root"
2090320909
track_id: "{TRACK_ID}"
@@ -21756,6 +21762,7 @@ Org-wide conventions:
2175621762
<core-file path="core/templates/rca.md">
2175721763

2175821764
---
21765+
type: RCA
2175921766
project: "{PROJECT_NAME}"
2176021767
track_id: "{TRACK_ID}"
2176121768
jira_ticket: "{JIRA_KEY}"
@@ -21930,6 +21937,7 @@ git-ignored at the track level. No HTML or PDF templates ship here.
2193021937
<core-file path="core/templates/discovery.md">
2193121938

2193221939
---
21940+
type: Discovery
2193321941
project: "{PROJECT_NAME}"
2193421942
module: "root"
2193521943
track_id: "{TRACK_ID}"
@@ -22018,6 +22026,7 @@ without line numbers are exempt from drift checks (they document
2201822026
<core-file path="core/templates/hld.md">
2201922027

2202022028
---
22029+
type: HLD
2202122030
project: "{PROJECT_NAME}"
2202222031
module: "root"
2202322032
track_id: "{TRACK_ID}"
@@ -22354,6 +22363,7 @@ Result stored in `metadata.json:pre_deploy_status`
2235422363
<core-file path="core/templates/lld.md">
2235522364

2235622365
---
22366+
type: LLD
2235722367
project: "{PROJECT_NAME}"
2235822368
module: "root"
2235922369
track_id: "{TRACK_ID}"

scripts/lib.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ TOOLS=(
160160
"graph-snapshot.sh"
161161
"okf-emit.sh"
162162
"okf-bundle.sh"
163+
"okf-check.sh"
163164
"graph-impact.sh"
164165
"graph-callers.sh"
165166
"validate-frontmatter.sh"

0 commit comments

Comments
 (0)