--- id: CUST-WP-0008 type: workplan title: Consistency Checking Engine domain: custodian status: done owner: custodian topic_slug: the-custodian repo_slug: the-custodian created: 2026-03-03 updated: 2026-03-03 state_hub_workstream_id: "78891e58-2889-43d7-9c1a-d7637990dc82" --- # CUST-WP-0008 — Consistency Checking Engine Implements a bidirectional ADR-001 consistency checker between workplan files in registered repos and the state-hub DB. The file is always authoritative; the DB is the cache/index layer. Checks C-01 through C-12 cover: missing workplans/, parse failures, stale references, status/title drift, unlinked workplans, orphan DB workstreams, repo mismatches, task drift, and orphan DB tasks. The `--fix` flag applies auto-fixable issues (C-04, C-05, C-06, C-09, C-10, C-11). --- ## Task T01: Implement consistency_check.py ```task id: CUST-WP-0008-T01 status: done priority: critical assignee: custodian state_hub_task_id: "a18c2389-ee98-40e9-a392-b5ff3deab838" ``` Core engine + CLI at `state-hub/scripts/consistency_check.py`. - Checks C-01 through C-12 - `--repo SLUG` or `--all` mode - `--fix` applies auto-fixable issues - `--json` machine-readable output - Exit codes: 0=ok, 1=fail, 2=warn-only ## Task T02: Add MCP tool check_repo_consistency ```task id: CUST-WP-0008-T02 status: done priority: high assignee: custodian state_hub_task_id: "90b626e5-3f0c-47ba-be32-e57e1132563a" ``` Add `check_repo_consistency(repo_slug, fix=False)` tool to `state-hub/mcp_server/server.py` following the validate_repo_adr pattern. ## Task T03: Add Makefile targets ```task id: CUST-WP-0008-T03 status: done priority: medium assignee: custodian state_hub_task_id: "151ba804-9938-4734-a49c-20bcd7c0b10b" ``` Add `check-consistency`, `fix-consistency`, `check-consistency-all`, `fix-consistency-all` targets to `state-hub/Makefile`. ## Task T04: Run dry-run and apply auto-fixes ```task id: CUST-WP-0008-T04 status: done priority: high assignee: custodian state_hub_task_id: "ad2a697e-6eb4-4ccf-8c76-82984e354571" ``` 1. Run `check-consistency-all` to verify findings match expected issues 2. Run `fix-consistency-all` to apply C-09 repo remaps and C-04 status drift fix 3. Verify `activity-core-foundation` and `activity-core-triggers-ops` repo_id updated 4. Verify railiance-bootstrap `phase-0-operational-baseline` status updated