Knowledge schema: enforce every declared select enum, not just type - #2042
Open
hjbrandt wants to merge 1 commit into
Open
Knowledge schema: enforce every declared select enum, not just type#2042hjbrandt wants to merge 1 commit into
hjbrandt wants to merge 1 commit into
Conversation
`validate()` checked CANONICAL_TYPES by hand and never read the `values` list declared on the other select fields. `source_kind`, `status` and `quality_inferred` could therefore hold any string and still lint clean: a note carrying `source_kind: external` passed a 100%-conformant run in my archive, which is how I found this. Walk ENVELOPE instead and check every select that declares `values`, so adding a new controlled vocabulary to the envelope is enforced by construction rather than needing a matching hand-written branch. Three regression tests added (danielmiessler#7); they fail on the current code and pass on this one. Full smoke suite: 32 passed, 0 failed. Lint over a 334-note archive goes 333/334 -> 334/334, catching exactly the one off-vocabulary note. Two smaller things in the same area: - `_schema.md` now says when `book` and `blog` apply, next to the existing bookmark rule. `type` and `source_kind` both contain the value `blog`, and nothing said which axis a blog post belongs on. (It is `type: idea` + `source_kind: blog`; `type: blog` is the archived post itself.) - The shipped Cortex skill still listed four note types in five places. There are six. No migrations, no vocabulary changes, no behaviour change for conformant notes.
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.
The bug
validate()inKnowledgeSchema.tschecksCANONICAL_TYPESby hand and never reads thevalueslist declared on the other select fields. Sosource_kind,statusandquality_inferredcan hold any string and still lint clean.I found it because a note in my archive carries
source_kind: external— not inSOURCE_KINDS— and passed a 100%-conformant run.The fix
Walk
ENVELOPEand check every select that declaresvalues. Adding a new controlled vocabulary to the envelope is then enforced by construction, instead of needing a matching hand-written branch that nobody remembers to write.Three regression tests added (
#7). They fail on currentmainand pass here.Evidence
KnowledgeLintover a 334-note archive: 333/334 → 334/334 envelope-conformant, catching exactly the one off-vocabulary note and nothing else. No false positives across 334 real notes.Two smaller things in the same area
_schema.mdnow says whenbookandblogapply, next to the existing bookmark rule.typeandsource_kindboth contain the valueblogand nothing stated which axis a blog post belongs on. It istype: idea+source_kind: blog;type: blogis the archived post itself. Both lines are descriptive of how the types are already used, not a new policy.BooksandBlogswere missing.Scope
No migrations, no vocabulary changes, no behaviour change for conformant notes. A non-conformant note starts reporting the violation it always had.
Related: #1986.