fix(knowledge): point diff_policy.py at knowledge/ instead of the missing vault/ - #249
Merged
Conversation
…sing vault/ VAULT_DIR was parents[1] / "vault" = knowledge/vault, which does not exist, so the policy gate failed on every run. It now defaults to the script's parent directory (knowledge/) and the script is runnable from any cwd. Also aligns the gate with sync_knowledge_index.py, which landed in #245: - require the same seven front matter keys (was a loose 'starts with ---' check) - skip README.md, which is structure rather than content - add --index to detect a stale staged index (missing notes, changed body_hash) - report the note count on success
| VAULT_DIR = Path(__file__).resolve().parents[1] | ||
|
|
||
| _FRONTMATTER_RE = re.compile(r"^---\s*\n(.*?)\n---\s*\n?", re.DOTALL) | ||
| _HEADING_RE = re.compile(r"^#{1,6}\s+.+$", re.MULTILINE) |
|
|
||
| _FRONTMATTER_RE = re.compile(r"^---\s*\n(.*?)\n---\s*\n?", re.DOTALL) | ||
| _HEADING_RE = re.compile(r"^#{1,6}\s+.+$", re.MULTILINE) | ||
| _FENCE_RE = re.compile(r"```[\s\S]*?```") |
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.
🔧 Fix / Correction
What was broken
knowledge/scripts/diff_policy.py— the CI policy gate that is supposed to block anunsafe index push — could not work as written:
parents[1]is alreadyknowledge/, so this resolved toknowledge/vault/, whichdoes not exist. Every run failed with:
The notes have always lived directly in
knowledge/. There is novault/subfolder.What this changes
1. The path. The vault now defaults to the script's parent directory
(
knowledge/), and the script works from any working directory — verified by runningit from
/tmp.2. The gate is aligned with
sync_knowledge_index.py(merged in #245):text.startswith("---")onlytitle,description,tags,doc_kind,status,owner,last_reviewed.mdREADME.md— it is structure, not content (the indexer skips it too)--index <json>detects a stale staged index: missing notes, changedbody_hash, or anote_countthat no longer matches the vault[policy] OK — 7 note(s) index-safe.The docstring's second promise ("a staged index is consistent with the vault
content") was previously unimplemented;
--indexnow delivers it.Verification
Ran against the live
knowledge/onmain, plus 11 cases:knowledge/as-isOK — 7 note(s) index-safe.exit 0/tmp(not repo root)missing front matter--changed <note>.md--changed <non-md file>--changed <missing>.mdmissing:--vault <nonexistent>vault directory not found--indexfresh index--indexafter body editstale body_hash--indexmissing a notenote not in index--indexmalformed JSONindex unreadableThe indexed JSON used for the
--indexcases was produced by the mergedsync_knowledge_index.py([index] 7 note(s), 176 record(s)), so the two agree.Type
Scope
Checklist
Note
This script is not yet called by any workflow (the only reference is a mention in
ZYNTROAI-SCAFFOLD.md), so nothing regresses here — this makes the gate correct forwhen it is wired in. A follow-up can add it to the knowledge CI job alongside
sync_knowledge_index.py.