feat(consistency): implement ADR-001 consistency checking engine (CUST-WP-0008)

Adds state-hub/scripts/consistency_check.py with C-01 through C-12 checks:
bidirectional file↔DB validation, --fix for auto-fixable issues, --all for all
repos, --json output, exit codes 0/1/2.

MCP tool: check_repo_consistency(repo_slug, fix=False)
Makefile: check-consistency, fix-consistency, check-consistency-all, fix-consistency-all

Auto-fixes applied across all repos:
- C-09: activity-core-foundation + activity-core-triggers-ops repo_id → activity-core
- C-04: railiance phase-0-operational-baseline status → completed
- C-05: railiance phase-0 title synced from file
- C-10/C-11: task status drifts resolved; state_hub_task_id injected into
  CUST-WP-0006 and CUST-WP-0007 task blocks

Remaining orphans reported for human review: repo-integration-activity-core,
infospace-s3-closeout, testdrive-jsui-publication, staged-promotion-lifecycle,
three-phoenix-ha-cluster, current-env-safety-net.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-03 08:16:00 +01:00
parent 8ab6e6c9c5
commit 44c19c422f
6 changed files with 1043 additions and 0 deletions

View File

@@ -40,6 +40,7 @@ id: T01
status: done
priority: high
assignee: custodian
state_hub_task_id: "b771f327-128e-4923-a7ad-2080b4e49eb9"
```
**Deliverable:** `wiki/GEMS-StateHub-TypeRegistry.md`
@@ -71,6 +72,7 @@ id: T02
status: done
priority: high
assignee: custodian
state_hub_task_id: "2be639ea-a19e-4c80-bcde-c3da06ec5a49"
```
**Identified inconsistencies:**
@@ -130,6 +132,7 @@ id: T03
status: done
priority: critical
assignee: custodian
state_hub_task_id: "da639706-3b14-42b8-92de-b9de84dbb2be"
```
Six decisions were escalated (see state-hub records):
@@ -151,6 +154,7 @@ id: T04
status: done
priority: high
assignee: custodian
state_hub_task_id: "96dd379a-02b4-4629-8db7-3bef15b9639d"
```
**Deliverable:** `wiki/GEMS-StateHub-SWOT.md`
@@ -178,6 +182,7 @@ status: blocked
priority: high
assignee: custodian
blocking_reason: "Blocked on decisions DEC-GEMS-001 through DEC-GEMS-006"
state_hub_task_id: "032649fb-2d21-44b7-9735-346405168d8e"
```
Once the six decisions are resolved, produce `workplans/CUST-WP-0007-gems-migration.md`

View File

@@ -37,6 +37,7 @@ id: T01
status: done
priority: critical
assignee: custodian
state_hub_task_id: "1c21c419-30f8-4208-9a55-c2fd83d5005a"
```
Operations:
@@ -56,6 +57,7 @@ id: T02
status: done
priority: critical
assignee: custodian
state_hub_task_id: "fe4f5673-6053-404a-8930-4bc0c7d29fd9"
```
Replace `domain: Mapped[str]` with `domain_id: Mapped[uuid.UUID]` FK +
@@ -68,6 +70,7 @@ id: T03
status: done
priority: high
assignee: custodian
state_hub_task_id: "c1ccf2ae-6241-4281-a443-12953796c1ee"
```
Add `repo_id: Mapped[uuid.UUID | None]` nullable FK to `managed_repos`.
@@ -79,6 +82,7 @@ id: T04
status: done
priority: high
assignee: custodian
state_hub_task_id: "4997aa59-39c0-46d6-8c63-f13fffd8d6ea"
```
- Filter by `domain_id` FK instead of domain string
@@ -91,6 +95,7 @@ id: T05
status: done
priority: high
assignee: custodian
state_hub_task_id: "50fdb7ee-91c3-4a2b-be27-e171c144aec6"
```
`register_extension_point` and `register_technical_debt` still accept
@@ -103,6 +108,7 @@ id: T06
status: done
priority: medium
assignee: custodian
state_hub_task_id: "4b19bb95-7200-4fa4-a240-afe14012bafa"
```
`extensions.md` and `techdept.md` load domain list from `/domains/` API and
@@ -125,6 +131,7 @@ id: T07
status: done
priority: critical
assignee: custodian
state_hub_task_id: "b34b6bb0-3968-464f-b340-389c4758821e"
```
Operations:
@@ -141,6 +148,7 @@ id: T08
status: done
priority: critical
assignee: custodian
state_hub_task_id: "6f1fcf2c-824b-4e3e-884f-5e48b5dea51d"
```
Add `repo_id: Mapped[uuid.UUID | None]` nullable FK to `managed_repos`.
@@ -153,6 +161,7 @@ id: T09
status: done
priority: high
assignee: custodian
state_hub_task_id: "58a23afa-601a-40a5-b658-2603dc006d13"
```
- `create_workstream` MCP tool: add optional `repo_id` / `repo_slug` param
@@ -166,6 +175,7 @@ id: T10
status: done
priority: high
assignee: custodian
state_hub_task_id: "b0bf1338-b097-4130-ab18-95b4980cf551"
```
Add `repo_slug` field to ADR-001 workplan frontmatter spec. Update existing
@@ -178,6 +188,7 @@ id: T11
status: done
priority: high
assignee: custodian
state_hub_task_id: "2a49ad8e-8d6d-4082-8833-a79d9ace0b34"
```
`dependencies.md` currently resolves domain via `topicMap[w.topic_id]?.domain_slug`.
@@ -199,6 +210,7 @@ id: T12
status: done
priority: critical
assignee: custodian
state_hub_task_id: "1ab3b919-64f7-432a-b173-7b66b042955f"
```
Operations:
@@ -216,6 +228,7 @@ id: T13
status: done
priority: critical
assignee: custodian
state_hub_task_id: "015462de-2095-48ff-8b2e-3f53e41dfe32"
```
New model `api/models/sbom_snapshot.py` with FK to managed_repos.
@@ -227,6 +240,7 @@ id: T14
status: done
priority: critical
assignee: custodian
state_hub_task_id: "f0f1a2d0-f0a3-45a4-ad10-b86f32849a84"
```
Add `snapshot_id` FK to `sbom_snapshots`. Update `repo` relationship to go
@@ -239,6 +253,7 @@ id: T15
status: done
priority: high
assignee: custodian
state_hub_task_id: "2a90b3f7-4938-4235-8ab6-1f9ad9cb06a7"
```
- Ingest creates/finds a snapshot record, then creates entries under it
@@ -252,6 +267,7 @@ id: T16
status: done
priority: high
assignee: custodian
state_hub_task_id: "081ef72e-e19c-4938-b6de-c0c17b98d99a"
```
`ingest_sbom_tool` returns `snapshot_id` in result. New MCP resource:
@@ -264,6 +280,7 @@ id: T17
status: done
priority: medium
assignee: custodian
state_hub_task_id: "5626cd89-ff77-4f45-90e6-2059673e4247"
```
`sbom.md` "By Repo" section adds a snapshot history row showing ingest dates

View File

@@ -0,0 +1,85 @@
---
id: CUST-WP-0008
type: workplan
title: Consistency Checking Engine
domain: custodian
status: active
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