One-Roof Nonprod Clone Extended — 06 UI/API Read Contract (Obj E, 8 endpoints)
06 — Objective E: UI / API Read Contract
Verdict: PRODUCED — 8 read endpoints defined, executed read-only on the clone (realistic 100%-covered state), JSON output captured. No UI code, no writes.
SQL: sql/E_ui_api_read_contract_readonly_clone.sql
These are the exact JSON shapes a coverage dashboard/API would return. All are pure SELECT (no DDL, no writes). Build-ready CREATE VIEW equivalents follow each endpoint group.
Endpoints + reference output (from clone)
GET /coverage/summary
{ "total_cells": 210, "covered_cells": 210, "gap_cells": 0, "coverage_pct": 100.00,
"conflicts": 0, "objects": 35, "scopes": 6, "ownership_anchors": 30 }
GET /coverage/by-scope (6 rows)
Each scope: {scope, description, objects:35, covered:35, gap:0} for approval/audit/execution/health/policy/render.
GET /coverage/by-owner (accountable cells per governance owner)
[ {"owner":"GOV-COUNCIL","owner_name":"Hội đồng Kiến trúc","accountable_cells":102,"direct":6,"inherited":96},
{"owner":"GOV-KG-SYS","owner_name":"Hệ thống Knowledge Graph","accountable_cells":90,"direct":6,"inherited":84},
{"owner":"GOV-DOT","owner_name":"Quản trị DOT","accountable_cells":30,"direct":12,"inherited":18},
{"owner":"GOV-MOIT","owner_name":"Mother of Input Templates","accountable_cells":18,"direct":6,"inherited":12} ]
Totals: 102+90+30+18 = 240 = 30 direct + 210 inherited. GOV-DOT shows 12 direct because it anchors two groups (GRP-AI + GRP-WORKFLOW).
GET /coverage/by-object (per object: required/covered/gap scopes)
Every object: {object_type:"collection", object_ref, scopes_required:6, scopes_covered:6, scopes_gap:0}.
GET /coverage/gaps → [] (empty = 100% covered)
GET /coverage/ownership-detail?object=agents (6 rows)
Each scope of agents resolves to {owner_gov_code:"GOV-DOT", owner_kind:"accountable", resolution:"inherited", source_anchor_type:"group", source_anchor_ref:"GRP-AI", depth:1}.
GET /coverage/scan-status
{ "last_run": {"run_id":"SCAN-CLONE-TEST-1","scan_mode":"periodic_full","status":"completed",
"groups_scanned":5,"objects_materialized":35,"finished_at":"2026-06-02T14:19:36Z"},
"total_runs":2, "candidate_states":5, "candidate_objects":35, "rulesets":1 }
GET /coverage/conflicts → [] (empty = healthy; double-accountable detector)
Build-ready view DDL (additive; production-safe — pure reads over existing objects)
CREATE OR REPLACE VIEW v_ui_coverage_summary AS
SELECT (SELECT count(*) FROM v_governance_object_inventory WHERE requires_owner AND born)
* (SELECT count(*) FROM governance_responsibility_scope WHERE status='active') AS total_cells,
(SELECT count(*) FROM v_object_owner_gap) AS gap_cells,
(SELECT count(*) FROM v_object_owner_conflict) AS conflicts;
CREATE OR REPLACE VIEW v_ui_coverage_by_scope AS
SELECT s.scope_code AS scope, s.description,
(SELECT count(*) FROM v_governance_object_inventory WHERE requires_owner AND born) AS objects,
(SELECT count(*) FROM v_governance_object_inventory WHERE requires_owner AND born)
- (SELECT count(*) FROM v_object_owner_gap g WHERE g.scope=s.scope_code) AS covered,
(SELECT count(*) FROM v_object_owner_gap g WHERE g.scope=s.scope_code) AS gap
FROM governance_responsibility_scope s WHERE s.status='active';
CREATE OR REPLACE VIEW v_ui_coverage_by_owner AS
SELECT eo.owner_gov_code AS owner, gr.name AS owner_name, count(*) AS accountable_cells,
count(*) FILTER (WHERE eo.resolution='direct') AS direct,
count(*) FILTER (WHERE eo.resolution='inherited') AS inherited
FROM v_object_effective_owner eo LEFT JOIN governance_registry gr ON gr.code=eo.owner_gov_code
WHERE eo.owner_kind='accountable' GROUP BY eo.owner_gov_code, gr.name;
gaps, by-object, ownership-detail, scan-status, and conflicts map directly to the existing v_object_owner_gap, v_governance_object_inventory, v_object_effective_owner, candidate_scan_run, and v_object_owner_conflict — no new views strictly required.
Frontend notes
- The contract is read-only and additive: it introduces no writes and no triggers; the UI views can be created on production safely independent of the ownership seed (they will simply show
gap_cells=210, coverage_pct=0until the seed lands, then0 / 100%). - All counts derive from existing governed views, so the dashboard is always consistent with the coverage engine.
- Directus exposure: these are standard read views; expose via Directus collections (read role) or a thin API. No Directus production mutation was performed — this contract is a specification + clone-verified reference output only.