vouch icon indicating copy to clipboard operation
vouch copied to clipboard

cascade option for propose_delete: page-cited claims are undeletable

Open plind-junior opened this issue 4 months ago • 0 comments

what you're trying to do

removing an approved claim from the console usually fails with cannot delete claim <id>: referenced by page '<page>'. the block is correct — referenced_by() in src/vouch/proposals.py:1113 refuses a delete while anything still points at the target — but in a compiled kb it means most claims are permanently undeletable. this kb has 1638 claims across 107 pages, and pages cite claims in bulk, so a large fraction of claims are page-referenced and there is no supported way to remove them.

two cases are worse than "just referenced":

  • supersede pairs are mutually locked. if b supersedes a, then a is blocked (b lists it in supersedes) and b is blocked (a's superseded_by points at b). no delete ordering escapes it, so neither end of a supersede chain can ever be removed. same for contradicts.
  • the relation check is kind-blind. proposals.py:1131-1136 compares the claim id against bare relation endpoints, which carry no kind tag, so a relation about a same-slug entity or page blocks an unrelated claim. the existing comment defers this to the spec's slug-collision caveat, but it shows up here as an unexplainable refusal.

what you've tried

  • kb.propose_delete on the claim — refused at propose time, and again at approve time (proposals.py:1211).
  • kb.supersede — the right move when there is a replacement claim, but it does not help when the claim is simply wrong noise that should not exist. it also creates a new permanently-undeletable pair.
  • hand-editing the page's claims: list to drop the reference first — works, but it is exactly the "parallel data path that bypasses proposals.approve()" the north star forbids.

suggested shape

keep the gate. make the referrers part of the proposal, so the reviewer sees and approves the whole cascade as one unit.

  • kb.propose_delete(target_kind, target_id, cascade=false) — new optional flag, default off (today's behaviour is unchanged).
  • with cascade=true, propose_delete walks referenced_by() and records the required referrer edits in the payload alongside the existing snapshot, e.g. cascade: [{kind: "page", id: "...", unlink_claims: ["..."]}, {kind: "relation", id: "...", action: "delete"}]. pages and claims get their pointer removed (unlink); relations, being edges with no inbound refs of their own, get deleted.
  • _approve_delete applies the cascade first, re-deriving it at approve time the way refs are re-checked today, then deletes the target. a reviewer-visible diff of every referrer touched, one decision, one audit event chain.
  • cli mirror: vouch propose-delete <kind> <id> --cascade, and the refusal message should name the flag so the dead end is discoverable.
  • console: DeleteArtifactButton shows the referrer list in the confirm step and offers "delete with cascade" when the plain delete is refused.

fixing the kind-blind relation match is a smaller separate change — compare endpoints only when the endpoint's kind resolves to the target's kind — and could land first.

compatibility considerations

additive. cascade defaults to false, so every existing caller and every existing kb behaves exactly as it does now. it touches the kb.* surface (a new optional parameter on an existing method plus a new payload field on decided delete proposals), so it likely wants a vep. no storage migration: the payload is already free-form, and unlinking is a normal put_page / put_claim write.

the four registration sites still apply even though no new method is added — the parameter has to appear in server.py, jsonl_server.py, and cli.py in step, and test_capabilities will not catch a missing cli flag.

alternatives

  • an unlink proposal kind — kb.propose_unlink(page, claim) as its own reviewable write, then delete the claim separately. more granular and more auditable, but it turns a one-claim cleanup into n+1 review rounds.
  • soft delete / status: retired — hide the claim from search and context without removing the file, leaving referrers intact. cheapest to build and never breaks a reference, but it does not answer "get this out of my kb" and the storage keeps growing.
  • allow deleting a page-cited claim and let the page dangle — the console already renders a broken reference for a missing claim, so it would not crash. rejected: silently corrupting pages is worse than the refusal.

plind-junior avatar Jul 30 '26 02:07 plind-junior