fix(wiki): enforce frontmatter normalization and governance contract on all write paths - #112
Merged
Merged
Conversation
…on all write paths Issue #110: 8 call sites bypassed write_governed_page, so PR #109's write-time frontmatter normalization only protected the interactive wiki_write tool. Move normalize_frontmatter into wiki_store.write_page itself (the true choke point every caller shares) so no path — governed or direct — can persist a non-canonical frontmatter shape. Deduplicate the now-redundant normalize call in write_governed_page, correct its docstring's false "only function that may call write_page" claim, and add an architecture test enumerating the audited whitelist of direct callers so a new unreviewed bypass fails loudly instead of shipping silently. Also fixes a regression introduced mid-change: routing normalization through write_page's own try/except let UnclosedFrontmatterError (a ValueError subclass) get silently swallowed into an error dict instead of propagating. Co-Authored-By: Claude <noreply@anthropic.com>
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.
Closes #110
(Initialement empilée sur #109 ; rebasée sur main après son merge en squash — diff net d'un seul commit.)
Mécanisme
Analyse des 8 call sites contournants : tous écrivent des pages complètes (jamais de fragments), aucun ne doit légitimement échapper à la normalisation — mais plusieurs contournent la gouvernance délibérément (stubs de redirect, pages générées PRD/findings/référence, réécritures de liens). D'où la séparation :
wiki_store.write_page(mode != "append") — le point d'étranglement partagé. Ferme la classe de corruption pour tout appelant, présent et futur. Import infra→core suivant l'exception documentée préexistante du sous-système wiki (wiki_layout,wiki_sync).write_governed_page; les 8 contournements restent délibérés. Docstring mensongère (« the ONLY function that may call write_page ») corrigée.write_governed_pageavalaitUnclosedFrontmatterError(sous-classe deValueError) dans sonexcept (ValueError, OSError)générique — contrat documenté cassé. Ré-levée explicite ajoutée, attrapée par le test préexistant.tests_py/architecture/test_write_page_call_sites.py— scan regex demcp_server/diffé contre une liste blanche auditée par fichier ; prouvé qu'il échoue sur un bypass injecté artificiellement (puis retiré).Tests
title: title:persistée canonique via 2 des 8 chemins contournants (wiki_adr,wiki_link) ;append_sectioninchangé.Limites connues
Garde-fou par comptage par fichier (pas par ligne) — le modèle de menace principal est un nouveau fichier contournant ; corruption des tests
wiki_adr/wiki_linkinjectée par seed (leur génération réelle ne la produit pas) — prouve la frontière d'enforcement. Dette de taille préexistante (wiki_write.py/wiki_store.pyvs guideline 300 l.) hors scope, sous le cap dur de 500.🤖 Generated with Claude Code