Skip to content

kb init: validate the adapter's knowledge_lifecycle.init block - #239

Merged
tzhouam merged 1 commit into
mainfrom
kb/init-adapter-schema
Sep 30, 2026
Merged

tzhouam merged 1 commit into
mainfrom
kb/init-adapter-schema

Conversation

@tzhouam

@tzhouam tzhouam commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Part 1/9 of kb init (design v3, sol-approved): the adapter's knowledge_lifecycle.init block.

Summary

  • kb_service/config.py: init is a new, strictly validated sub-mapping of knowledge_lifecycle. It's parsed into a frozen InitConfig on RepoLifecycle.init (None when absent).
    • seeds: knowledge-relative paths under general/ or repos/<other repo>/. Self-seeds, absolute paths, empty/./.. segments and duplicates are refused.
    • doc_globs: defaults to README*, docs/**/*.md (the same set build_doc_corpus reads), CONTRIBUTING.md and AGENTS.md.
    • source_roots: defaults to the manifest's ut_coverage.source_roots.
    • Also exclude, module_depth, min_module_loc, pr_window {count, max_age_days}, coverage_target, budget_usd and judge_call_usd. Each is range-checked, non-finite numbers are refused, and unknown keys are refused.
  • validate_seeds(init, knowledge_root) -> list[str]: run-time check that each seed exists in the knowledge tree and stays inside it.
  • No adapter manifest is changed, and there are no repo literals in src/.
  • SPEC kb_service.md is updated.

Test evidence

  • test/test_kb_init_config.py: defaults, a full parse, the ut_coverage fallback, 32 rejection cases (including .nan/.inf), and validate_seeds for missing paths and symlink escape.
  • Local mirror of CI (the full pytest suite, doc links/citations, SPEC freshness --strict, knowledge linters): rc=0.
  • Commit gate (gpt-6-astra-high): approved on iteration 2. Iteration 1 found that non-finite budgets were accepted; that's fixed.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 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-30T09:08:51.114633Z 5160b38 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: 5160b3844d

ℹ️ 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 +202 to +203
target = (root / seed).resolve()
if not target.is_relative_to(root):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject symlink aliases that resolve into the initialized repo

When a valid-looking seed such as general/alias is a symlink to knowledge_root/repos/<repo>, _seed_problem approves the textual path and this runtime check approves the resolved target merely because it remains under the knowledge root. This bypasses the documented self-seed prohibition and can feed the repository's own existing knowledge back into initialization; runtime validation should also reject resolved paths under the repository being initialized, or reject such symlink aliases.

Useful? React with 👍 / 👎.

kb init (design kb-init v3 §3) reads its per-repository settings from a new,
strictly validated `init` sub-mapping of `knowledge_lifecycle`. Parsing
produces an `InitConfig` on `RepoLifecycle.init` (None when absent):

- seeds: knowledge-relative paths under general/ or repos/<other repo>/;
  a seed naming the repository being initialised, an absolute path, empty,
  `.` or `..` segments, or duplicates are refused at parse time
- doc_globs default to README* + docs/**/*.md (what build_doc_corpus reads)
  plus CONTRIBUTING.md and AGENTS.md
- source_roots default to the manifest's ut_coverage.source_roots
- exclude, module_depth (>=1, 2), min_module_loc (>=0, 300),
  pr_window {count, max_age_days} (>0, 200/180), coverage_target ((0,1],
  0.85), budget_usd (>0, 30), judge_call_usd (>=0, 0.50); non-finite numbers (.nan, .inf) are refused

`validate_seeds(init, knowledge_root)` is the run-time check that every seed
exists in the knowledge tree and does not resolve outside it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tzhouam
tzhouam force-pushed the kb/init-adapter-schema branch from e90c31b to f325875 Compare September 30, 2026 14:51
@tzhouam
tzhouam merged commit 8cb9045 into main Sep 30, 2026
2 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