Repository navigation
kb init: check rule claims and evidence at a pinned upstream SHA, and adapter lifecycle flips - #242
Merged
Merged
Conversation
…lifecycle flips kb init (design v3 §9.1, §9.3) writes a knowledge base against one pinned upstream baseline and edits one file outside knowledge/: the adapter manifest. Neither was checkable with existing code: facts.attest observes the upstream head, and the knowledge L1 whitelist only covers knowledge/. - knowledge_service/pinned_claims.py: PinnedObserver implements facts.Observer over a local clone with head() fixed to the pin, plus is_ancestor(). check_rules() extracts claims exactly as the service does (facts.claims_in) and requires cited PRs to be merged into the pin's history. Evidence/evidence_for/check_evidence bind a line range at the pin to a content hash. - kb_service/lifecycle_flip.py: check_lifecycle_flip() compares parsed manifests with only the allowed key paths removed; check_flip_to_shadow() also requires enabled: true in shadow mode. The service and publisher paths (facts.attest/recheck, Observer) are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 014cfba90c
ℹ️ 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".
…tory git merge-base --is-ancestor exits 1 both for "not an ancestor" and when the history walk hits an unreadable commit (it then only prints "error: Could not read" on stderr). PinnedObserver.is_ancestor treated every non-zero exit as "no", so a corrupt mirror made check_rules report a PR merged before the pin as merged after it. Now 0 is yes, 1 with a silent stderr is no, an unknown commit is still no, and anything else raises FactsError so the caller retries. A corrupt candidate commit is told apart from an absent one with cat-file --batch-check: both print "missing", but only corruption writes an unpack error to stderr. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PinnedObserver.pull passed the injected lookup's exceptions straight through: a missing gh binary raised FileNotFoundError and a network failure ConnectionError, both bypassing callers' FactsError retry handling. pull now re-raises FactsError unchanged, wraps anything else in FactsError, and rejects a non-object answer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part 3/9 of kb init (design v3, sol-approved): the two deterministic checks
kb initneeds that existing code can't provide.knowledge_service/pinned_claims.py(design §9.1):facts.attestobserves the upstream head, but init writes a whole KB against one pinned baseline.PinnedObserverimplementsfacts.Observerover a local clone withhead()fixed to the pin, plusis_ancestor().ls-tree: a missing entry means absent, while an unreadable object or tree raisesFactsError. Directories are paths but have no file text.check_rules()uses the service's ownfacts.claims_in/observe, and also requires each cited PR's merge commit to be in the pin's history.Evidence/evidence_for/check_evidencebind a 1-based line range at the pin to a SHA-256 that ignores line-ending style.kb_service/lifecycle_flip.py(design §9.3): the one non-knowledge/file init edits is the adapter manifest, which the knowledge L1 whitelist never sees.check_lifecycle_flip()compares the parsed manifests with only the allowed key paths removed.1≠true≠1.0), un-shares YAML aliases so an allowed removal can't hide a change made through an alias, and rejects recursive aliases.check_flip_to_shadow()also requiresenabled: truein shadow mode.The service and publisher paths are unchanged:
facts.attest/recheckand theObserverprotocol.Tests
test/test_kb_pinned_claims.pyruns against temp git repos: claims before and after the pin, missing symbols, PRs merged after the pin or never merged, evidence range and hash, CRLF vs LF, directories, unreadable blob and tree objects, and an invalid pin.test/test_kb_lifecycle_flip.pycovers comments kept, the default mode, refused edits, type strictness, aliases, recursive aliases, and invalid YAML.--strict, and the knowledge linters, all green. The commit gate approved it.🤖 Generated with Claude Code