feat: expose institutional architecture and runtime state
This commit is contained in:
@@ -11,6 +11,14 @@ from govoplan_core.core.modules import (
|
||||
RoleTemplate,
|
||||
)
|
||||
from govoplan_core.core.registry import PlatformRegistry
|
||||
from govoplan_core.core.provider_governance import (
|
||||
ExternalProviderDeclaration,
|
||||
ModuleArchitectureDeclaration,
|
||||
ModuleArchitectureDocumentation,
|
||||
ModuleMaturityEvidence,
|
||||
ProviderBehaviorDeclaration,
|
||||
ProviderObjectDeclaration,
|
||||
)
|
||||
|
||||
from govoplan_ops.backend.api.v1.routes import _governance_inventory
|
||||
|
||||
@@ -60,9 +68,70 @@ class GovernanceInventoryTests(unittest.TestCase):
|
||||
),
|
||||
),
|
||||
migration_spec=MigrationSpec(module_id="example"),
|
||||
architecture=ModuleArchitectureDeclaration(
|
||||
layer="governance_accountability",
|
||||
kind="governance",
|
||||
maturity="vertical_slice",
|
||||
evidence=(
|
||||
ModuleMaturityEvidence(
|
||||
kind="test",
|
||||
reference="tests/test_governance_inventory.py",
|
||||
summary="Exercises the governance projection.",
|
||||
),
|
||||
ModuleMaturityEvidence(
|
||||
kind="documentation",
|
||||
reference="example.reference",
|
||||
summary="Documents the example provider.",
|
||||
),
|
||||
),
|
||||
known_limits=("The example has no runtime implementation.",),
|
||||
supported_authority_modes=("external_mirror",),
|
||||
owned_concepts=("example projections",),
|
||||
documentation=ModuleArchitectureDocumentation(
|
||||
operations=("example.reference",),
|
||||
),
|
||||
),
|
||||
external_providers=(
|
||||
ExternalProviderDeclaration(
|
||||
id="example.read",
|
||||
module_id="example",
|
||||
label="Example reader",
|
||||
maturity="read",
|
||||
operations=("read", "search"),
|
||||
objects=(
|
||||
ProviderObjectDeclaration(
|
||||
object_type="example.record",
|
||||
field_groups=("identity", "summary"),
|
||||
authority_modes=("external_mirror",),
|
||||
default_authority_mode="external_mirror",
|
||||
),
|
||||
),
|
||||
behavior=ProviderBehaviorDeclaration(
|
||||
freshness="Request-time read with a five-minute cache.",
|
||||
health="Reported through example.health.",
|
||||
max_read_items=100,
|
||||
outage="Reads fail closed and retain the last inspected snapshot.",
|
||||
classifications=("internal",),
|
||||
purposes=("operations",),
|
||||
retention="No provider-owned payload is retained.",
|
||||
),
|
||||
documentation_topic_ids=("example.reference",),
|
||||
),
|
||||
),
|
||||
))
|
||||
|
||||
payload = _governance_inventory(registry)
|
||||
payload = _governance_inventory(
|
||||
registry,
|
||||
external_provider_states={
|
||||
"example.read": {
|
||||
"configured": True,
|
||||
"active": True,
|
||||
"health": "warning",
|
||||
"freshness": "stale",
|
||||
"recovery": "attention",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEqual(payload["summary"]["module_count"], 1)
|
||||
self.assertEqual(payload["summary"]["permission_count"], 1)
|
||||
@@ -71,6 +140,21 @@ class GovernanceInventoryTests(unittest.TestCase):
|
||||
self.assertEqual(payload["summary"]["policy_count"], 1)
|
||||
self.assertEqual(payload["summary"]["documented_module_count"], 1)
|
||||
self.assertEqual(payload["summary"]["migration_module_count"], 1)
|
||||
self.assertEqual(payload["summary"]["architecture_declared_module_count"], 1)
|
||||
self.assertEqual(payload["summary"]["external_provider_count"], 1)
|
||||
self.assertEqual(
|
||||
payload["summary"]["configured_external_provider_count"],
|
||||
1,
|
||||
)
|
||||
self.assertEqual(payload["summary"]["provider_attention_count"], 1)
|
||||
self.assertEqual(payload["modules"][0]["architecture"]["maturity"], "vertical_slice")
|
||||
self.assertEqual(payload["modules"][0]["external_providers"][0]["id"], "example.read")
|
||||
self.assertEqual(
|
||||
payload["modules"][0]["external_providers"][0]["runtime_state"][
|
||||
"freshness"
|
||||
],
|
||||
"stale",
|
||||
)
|
||||
self.assertEqual(payload["modules"][0]["module_id"], "example")
|
||||
self.assertNotIn("capability_factories", payload["modules"][0])
|
||||
self.assertFalse(any(
|
||||
|
||||
@@ -63,3 +63,22 @@ def test_module_operational_check_failure_is_isolated() -> None:
|
||||
assert result["state"] == "error"
|
||||
assert "secret detail" not in result["detail"]
|
||||
|
||||
|
||||
def test_shared_runtime_cluster_missing_replicas_blocks_readiness() -> None:
|
||||
check = routes._runtime_cluster_check(
|
||||
{
|
||||
"available": True,
|
||||
"state_profile": "shared",
|
||||
"nodes": [
|
||||
{"role": "api", "state": "active", "stale": False},
|
||||
{"role": "worker", "state": "active", "stale": True},
|
||||
],
|
||||
"expected": {"api": 2, "worker": 1},
|
||||
"active": {"api": 1, "worker": 0},
|
||||
"recovery": {"requires_attention": 1},
|
||||
}
|
||||
)
|
||||
|
||||
assert check["state"] == "error"
|
||||
assert check["readiness_critical"] is True
|
||||
assert check["metrics"]["recovery_required"] == 1
|
||||
|
||||
Reference in New Issue
Block a user