generated from coulomb/repo-seed
Operator metrics, job inspection, and event views, Recovery, Governance reports, Extension catalog and semantic extension events
This commit is contained in:
@@ -517,6 +517,97 @@ def test_service_runtime_ingestion_directory_reports_partial_failures(tmp_path)
|
||||
assert result["retry_options"]["retryable"] is True
|
||||
|
||||
|
||||
def test_service_runtime_exposes_operator_metrics_recovery_export_governance_and_quality(
|
||||
tmp_path,
|
||||
) -> None:
|
||||
runtime = ServiceRuntime(repository=InMemoryAssetRegistryRepository())
|
||||
context = runtime.operation_context(actor_id="operator", actor_type="service_account", correlation_id="corr-ops")
|
||||
source = tmp_path / "ops-source.txt"
|
||||
source.write_text("Operational export and governance signals should be source grounded.", encoding="utf-8")
|
||||
ingestion = runtime.start_ingestion_job(
|
||||
{
|
||||
"mode": "file",
|
||||
"path": str(source),
|
||||
"asset_id": "asset-ops",
|
||||
"classification": {
|
||||
"asset_type": "document",
|
||||
"sensitivity": "confidential",
|
||||
},
|
||||
},
|
||||
context,
|
||||
)
|
||||
runtime.query_assets({"text": "governance", "include_snippets": True}, context)
|
||||
transform = runtime.execute_transformation(
|
||||
{
|
||||
"operation_id": "structured_view",
|
||||
"source_asset_ids": ["asset-ops"],
|
||||
"output_asset_id": "asset-ops-derived",
|
||||
},
|
||||
context,
|
||||
)
|
||||
|
||||
metrics = runtime.operational_metrics()
|
||||
jobs = runtime.inspect_jobs(correlation_id="corr-ops")
|
||||
events = runtime.operational_events(correlation_id="corr-ops", operation_prefix="asset.")
|
||||
recovery_actions = runtime.recovery_actions()
|
||||
inspected_failure = runtime.execute_recovery_action(
|
||||
"inspect_failure",
|
||||
{"kind": "ingestion", "id": ingestion["job_id"]},
|
||||
context,
|
||||
)
|
||||
export = runtime.create_export_package({"scope": {"asset_ids": ["asset-ops", "asset-ops-derived"]}}, context)
|
||||
validation = runtime.validate_export_package({"package": export}, context)
|
||||
tampered = dict(export)
|
||||
tampered["manifest"] = dict(export["manifest"])
|
||||
tampered["manifest"]["asset_count"] = 999
|
||||
invalid = runtime.validate_export_package({"package": tampered}, context)
|
||||
governance = runtime.governance_report({"scope": {"asset_ids": ["asset-ops"]}}, context)
|
||||
extension_catalog = runtime.extension_catalog()
|
||||
extension_event = runtime.emit_extension_event(
|
||||
{"event_type": "derived_artifact.created", "target": "asset:asset-ops-derived"},
|
||||
context,
|
||||
)
|
||||
signal = runtime.record_quality_signal(
|
||||
{
|
||||
"signal_type": "ai_usage",
|
||||
"target": "workflow:ops",
|
||||
"asset_id": "asset-ops",
|
||||
"agent_id": "agent-ops",
|
||||
"metrics": {"confidence": 0.91},
|
||||
"ai_usage": {"provider": "test", "model": "deterministic", "tokens": 123},
|
||||
"cost": {"estimated": 0.42, "currency": "EUR"},
|
||||
},
|
||||
context,
|
||||
)
|
||||
quality_cost = runtime.quality_cost_signals()
|
||||
smoke = runtime.performance_smoke_report()
|
||||
compliance = runtime.mvp_compliance_report()
|
||||
|
||||
assert metrics["ingestion"]["job_count"] >= 1
|
||||
assert metrics["retrieval"]["query_events"] >= 1
|
||||
assert metrics["transformations"]["completed"] >= 1
|
||||
assert jobs["count"] >= 2
|
||||
assert events["items"][0]["correlation_id"] == "corr-ops"
|
||||
assert any(action["action"] == "retry_ingestion_job" for action in recovery_actions["items"])
|
||||
assert inspected_failure["result"]["job_id"] == ingestion["job_id"]
|
||||
assert export["manifest"]["asset_count"] == 2
|
||||
assert export["manifest"]["export_hash"].startswith("sha256:")
|
||||
assert export["adapter_sections"]["markitect_tool"]["included"] is False
|
||||
assert validation["valid"] is True
|
||||
assert invalid["valid"] is False
|
||||
assert any(issue["code"] == "export.count_mismatch" for issue in invalid["issues"])
|
||||
assert governance["redaction"]["content_included"] is False
|
||||
assert "governance.sensitive_without_review_metadata" in governance["summary"]
|
||||
assert "markitect-tool" in extension_catalog["markitect_boundary"]
|
||||
assert extension_event["event"]["operation"] == "extension.derived_artifact.created"
|
||||
assert signal["event"]["operation"] == "quality.signal.recorded"
|
||||
assert quality_cost["ai_usage"]["tokens"] == 123
|
||||
assert quality_cost["cost"]["estimated_total"] == 0.42
|
||||
assert smoke["smoke_targets"] == ["ingestion", "retrieval", "workflow", "export"]
|
||||
assert compliance["implemented_capabilities"]["exports"] is True
|
||||
assert transform["lineage"]["output_asset_id"] == "asset-ops-derived"
|
||||
|
||||
|
||||
def test_create_app_reports_missing_optional_dependency_when_fastapi_is_absent() -> None:
|
||||
try:
|
||||
import fastapi # noqa: F401
|
||||
@@ -576,6 +667,13 @@ def test_service_health_readiness_version_and_openapi_contracts(client) -> None:
|
||||
assert "/api/v1/agents/operations" in paths
|
||||
assert "/api/v1/context-packages" in paths
|
||||
assert "/api/v1/context-packages/schema" in paths
|
||||
assert "/api/v1/operations/metrics" in paths
|
||||
assert "/api/v1/operations/recovery/actions" in paths
|
||||
assert "/api/v1/exports" in paths
|
||||
assert "/api/v1/governance/report" in paths
|
||||
assert "/api/v1/extensions/catalog" in paths
|
||||
assert "/api/v1/quality/signals" in paths
|
||||
assert "/api/v1/compliance/mvp" in paths
|
||||
|
||||
|
||||
def test_create_app_attaches_runtime_to_application_state(client) -> None:
|
||||
|
||||
Reference in New Issue
Block a user