Skip to content

feat(knowledge): report note conformance on the doc-integrity pass (KnowledgeLint is invoked by nothing) - #1686

Open
elhoim wants to merge 2 commits into
danielmiessler:mainfrom
elhoim:feat/knowledge-conformance-check
Open

feat(knowledge): report note conformance on the doc-integrity pass (KnowledgeLint is invoked by nothing)#1686
elhoim wants to merge 2 commits into
danielmiessler:mainfrom
elhoim:feat/knowledge-conformance-check

Conversation

@elhoim

@elhoim elhoim commented Jul 28, 2026

Copy link
Copy Markdown

Stacks on #1685. That PR keeps _schema.md honest against KnowledgeSchema.ts, so the doc can no longer drift from the code. Nothing checks whether the notes conform to either.

The gap this closes

KnowledgeLint.ts exists and works. It is invoked by nothing in the tree — every reference to it is prose, telling a human to run it. So note-level conformance is only ever measured when someone remembers to type the command.

That is how an archive reached 0.9% conformance without a single warning:

  1. A bulk import wrote 1,744 notes bypassing MemorySystem.renderInitialNote.
  2. Later writers read a neighbouring note and copied its frontmatter, spreading the legacy dialect.
  3. Nothing ever compared the notes to the schema, so none of it surfaced.

#1685 makes step 3's documentation half impossible. This makes the data half visible.

The change

A read-only handler alongside the regen, in the pass that already runs.

  • Calls validate() / parseNote() from KnowledgeSchema directly rather than shelling out to the CLI — one pass, no subprocess.
  • Reports conformance percentage, per-directory breakdown, and the top violation classes.
  • Names the repair command (MigrateKnowledge.ts) in the warning, so the next step is obvious.
  • Emits doc.integrity.knowledge_conformance to STATE/events.jsonl for Pulse.
  • Reports only. Never edits, never blocks. Non-conformance is a soft warning, matching MemoryDirIntegrity's contract.

Verified

On a 1,801-note archive:

[KnowledgeConformance] === Check complete (451ms, 100.0% conformant) ===

And with one note deliberately downgraded to convention: kb-v2:

[KnowledgeConformance] 1/1801 notes off-schema (99.9% conformant). Repair: bun LIFEOS/TOOLS/MigrateKnowledge.ts
[KnowledgeConformance]   1× convention — not kb-v3 (dialect not migrated)

Positive and negative both exercised. 451ms over 1,801 notes, so it is not a meaningful cost on the Stop path.

elhoim added 2 commits July 28, 2026 07:15
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.
RebuildKnowledgeSchema (danielmiessler#1685) keeps _schema.md honest against
KnowledgeSchema.ts, so the DOC can no longer drift from the CODE. Nothing
checks whether the NOTES conform to either.

That gap is how an archive reached 0.9% conformance without a single
warning: a bulk import wrote 1,744 notes off-schema, later writers copied
their frontmatter and spread the dialect, and KnowledgeLint — the one tool
that could have said so — is invoked by nothing in the tree. It only ever
runs when a human remembers to type it.

Add a read-only conformance check alongside the regen. It calls validate()
from KnowledgeSchema directly rather than shelling out, reports a
percentage plus the top violation classes, names the repair command
(MigrateKnowledge.ts), and emits a typed event for Pulse.

Reports only. Never edits, never blocks — non-conformance is a soft
warning, matching MemoryDirIntegrity's contract.

Verified on a 1,801-note archive: reports 100.0% clean, and a deliberately
downgraded note is caught as '1x convention — not kb-v3'.

Stacks on danielmiessler#1685.
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