Skip to content

Refuse to activate knowledge in a format this Copilot does not read - #224

Merged
tzhouam merged 1 commit into
mainfrom
kb/knowledge-format-version
Sep 28, 2026
Merged

tzhouam merged 1 commit into
mainfrom
kb/knowledge-format-version

Conversation

@tzhouam

@tzhouam tzhouam commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Knowledge-service redesign follow-up (§8.5): activation refuses a knowledge/API version mismatch. Knowledge now releases independently of the code, so a tree written for a newer format must not be served by a Copilot that can't read it.

  • Declaration: the tree declares its format in knowledge/_format.yaml (format_version: 2: lifecycle footers, typed ops, _routes.yaml, _tombstones.yaml).
    • This is separate from the SDK's KNOWLEDGE_API_VERSION, which versions the curation API and is pinned by the review bot's release checks.
    • The value must be exactly an integer; 2.9, "2", true and .inf count as undeclared, never coerced.
  • Manifest: MANIFEST.json records knowledge_format.
  • Activation: verify_snapshot refuses an undeclared or unsupported format and leaves active unchanged.

Note: the top-level _format.yaml is outside the auto-merge whitelist, so the kb-gate precheck on this PR fails. That is the intended human-gated path; the check isn't required yet.

Commit hook approved; full suite and SPEC freshness pass locally (rebased on #223).

🤖 Generated with Claude Code

The design requires activation to refuse a knowledge/API version mismatch:
knowledge is released independently of the code now, so a tree written for a
newer format must not be served by a Copilot that cannot read it.

- The knowledge tree declares its format in knowledge/_format.yaml
  (format_version: 2, i.e. rule lifecycle footers, typed operations,
  _routes.yaml and _tombstones.yaml). The file sits outside the auto-merge
  whitelist, so changing it takes a person. The SDK's KNOWLEDGE_API_VERSION
  is a separate thing: it versions the curation API that the review bot's
  release checks pin.
- knowledge_view.knowledge_format reads the declaration, which must be exactly
  an integer: 2.9, "2", true or .inf are treated as malformed (undeclared),
  never coerced. build_manifest records it in MANIFEST.json.
- activate.verify_snapshot refuses a snapshot whose format is undeclared or
  not in SUPPORTED_FORMATS, leaving active untouched. Snapshots carry
  _format.yaml alongside the top-level pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T18:27:41.769580Z 90d30a0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 90d30a0596

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +103 to +104
declared = knowledge_format(view.root)
if declared not in SUPPORTED_FORMATS:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Enforce the format in every snapshot reader

When the knowledge scheduler and review service are upgraded independently, a newer scheduler can activate format 3 while an older, long-running review worker still resolves the shared $KB_STATE_DIR/active link. That worker calls KnowledgeView.current()/_load_snapshot() directly and never executes this verify_snapshot() check; _load_snapshot() currently accepts the format-3 manifest, so the old worker serves knowledge it cannot interpret. The same bypass occurs when an unsupported snapshot is supplied directly via KNOWLEDGE_ROOT. Validate knowledge_format against SUPPORTED_FORMATS in the snapshot-loading path as well, so every consumer fails closed rather than only the process performing activation.

Useful? React with 👍 / 👎.

@tzhouam
tzhouam merged commit d98a39b into main Sep 28, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant