Skip to content

I0812 — Validate the graph, and let doctor and watch ask the same validator

Implement `knowledge validate` detecting duplicate node ids, dangling explicit references, source paths that no longer exist, hash mismatches, edges with a missing end, edges without provenance and a stale generated index, each with a severity and a reproduce command, and declare the rule in the doctrine registry so doctor and watch dispatch the same validator rather than reimplementing it.

BLOCKED wave 6 · p1 · implementation profile · runs alone

Part of M003 — A session is a durable envelope, and knowledge is compiled from what is already canonical.

Blocked. This issue cannot start until I0811 is done. The status is derived from that, not declared.

Objective

Implement `knowledge validate` detecting duplicate node ids, dangling explicit references, source paths that no longer exist, hash mismatches, edges with a missing end, edges without provenance and a stale generated index, each with a severity and a reproduce command, and declare the rule in the doctrine registry so doctor and watch dispatch the same validator rather than reimplementing it.

Why

Validation logic that exists twice diverges, and the second copy is the one that stops being run. The registry is the mechanism that makes doctor, watch and the command itself provably the same rule.

Current state

Doctrines are declared with a validator, the commands that enforce it and its test; doctor proves each link of that chain from the source rather than from the declaration.

Desired state

knowledge_integrity is declared and dispatched from doctor and watch. Findings distinguish a broken Majordomus-owned reference, which is a failure, from a broken link to a deliberately external resource, which is not. Doctor also answers whether the index can be built at all in this checkout.

Scope

  • lib/knowledge.sh
  • share/doctrines.yaml
  • lib/doctor.sh
  • lib/watch.sh
  • test/cases/70_knowledge_validate.sh

Out of scope

  • Repairing anything automatically
  • Failing on a link to a resource outside the repository

Dependencies

What waits on this

Acceptance criteria

  • Every listed condition is detected by a case that introduces exactly that fault
  • The doctrine appears in doctrine list, doctor proves it reaches both commands, and its test is named
  • Severity distinguishes an owned reference from an external one, and the rule for which is which is stated
  • A stale index is drift under watch and a failure under the command, and neither rebuilds it
  • doctor reports whether the index is buildable here without leaving one behind

Validation

  • bash test/run.sh 70_knowledge_validate
  • bin/majordomus doctor
  • bin/majordomus watch

Evidence required

  • validation_detects
  • doctrines_wired

Evidence

None recorded. Every token above needs a command or an artifact behind it before this issue can be completed; narrative is refused.

Risk

A validator that runs a full extraction inside doctor makes doctor slow enough to be skipped, and a check nobody runs is the failure this project measures. It has to compare hashes rather than rebuild.

Timeline

started
verified
completed

Those three fields, the evidence above and the state of the dependencies are all the status is made of. There is no status field to disagree with them.

Canonical record: .ai/repo/project/issues/I0812.yaml. Read it back with majordomus plan show I0812.