feat(knowledge): regenerate _schema.md on the doc-integrity pass (generator is currently dead code) - #1685
Open
elhoim wants to merge 1 commit into
Open
Conversation
GenerateKnowledgeSchemaDoc.ts is currently dead code — nothing invokes it. Two consequences: _schema.md does not exist on a fresh install, and where it does exist it drifts from KnowledgeSchema.ts, which is the declared source of truth. That drift is not theoretical. On the archive this was found on, _schema.md declared kb-v3 while describing 0.9% of the notes it governed, and the gap went unnoticed because nothing regenerated the doc. Wire the generator into DocIntegrity so the doc is rebuilt from the schema on every integrity pass. Fire-and-forget, non-fatal on failure, and run as a subprocess rather than imported because the generator executes main() on import.
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.
GenerateKnowledgeSchemaDoc.tsis dead code — nothing in the tree invokes it. Two consequences follow:_schema.mddoes not exist on a fresh install. The schema doc the archive is supposed to be governed by simply isn't there.KnowledgeSchema.ts, which the doc itself names as the single source of truth.This is not theoretical
On the archive this was found on,
_schema.mddeclaredkb-v3canonical while describing 0.9% of the notes it governed — 17 of 1,801. The gap went unnoticed for as long as it did precisely because nothing regenerated the doc, so there was no moment at which the declaration and the reality were compared.The same class of drift bit again during the repair: a change to the validation rule in
validate()would not have appeared in the generated doc, because the generator reads thePER_TYPE_REQUIREDdata table. Caught only because the doc was regenerated by hand and read.The change
Wire the generator into
DocIntegrity, which already runs a cross-reference pass, so_schema.mdis rebuilt fromKnowledgeSchema.tsevery time integrity is checked.GenerateKnowledgeSchemaDoc.tsexecutesmain()at import time, so importing it would run the generator as a side effect of loading the handler.Net effect: the schema doc exists on every install, and cannot silently disagree with the code that defines it.
Companion to #1684, which fixes a rule in the same schema. That PR changes behaviour in
validate(); this one guarantees the generated doc reflects such changes.