From 1433f151f624ea539a38bab2425eefed969972ec Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 1 Jul 2026 23:55:57 +0800 Subject: [PATCH] fix(api): surface gitops runtime readback current --- .../services/delivery_closure_workbench.py | 34 ++++++++++++++++ .../test_delivery_closure_workbench_api.py | 39 +++++++++++++++++++ apps/web/src/lib/api-client.ts | 19 +++++++++ 3 files changed, 92 insertions(+) diff --git a/apps/api/src/services/delivery_closure_workbench.py b/apps/api/src/services/delivery_closure_workbench.py index dd98054c..71891963 100644 --- a/apps/api/src/services/delivery_closure_workbench.py +++ b/apps/api/src/services/delivery_closure_workbench.py @@ -157,6 +157,22 @@ def build_delivery_closure_workbench( ) production_deploy_readback = _dict(production_deploy.get("readback")) production_deploy_rollups = _dict(production_deploy.get("rollups")) + production_deploy_runtime_matches_gitops_desired = ( + production_deploy_readback.get("runtime_build_matches_gitops_desired_image_tag") + is True + ) + production_deploy_runtime_readback_status = str( + production_deploy_readback.get("runtime_build_readback_status") or "" + ) + production_deploy_runtime_committed_drift_accepted = ( + production_deploy_runtime_readback_status + == "matches_gitops_desired_image_tag_with_committed_deploy_readback_drift" + ) + production_deploy_runtime_readback_current = ( + production_deploy_runtime_matches_gitops_desired + and production_deploy_readback.get("desired_main_api_image_tag_readback_status") + == "ok" + ) gitea_status = _dict(gitea.get("program_status")) gitea_rollups = _dict(gitea.get("rollups")) gitea_runner_request_readback = _dict( @@ -310,6 +326,15 @@ def build_delivery_closure_workbench( production_deploy_readback.get("runtime_build_readback_status") or "" ), + "runtime_build_matches_gitops_desired_image_tag": ( + production_deploy_runtime_matches_gitops_desired + ), + "runtime_build_deploy_readback_current": ( + production_deploy_runtime_readback_current + ), + "runtime_build_committed_readback_drift_accepted": ( + production_deploy_runtime_committed_drift_accepted + ), "runtime_build_matches_committed_source_control_readback": ( production_deploy_readback.get( "runtime_build_matches_committed_source_control_readback" @@ -1849,6 +1874,15 @@ def build_delivery_closure_workbench( "production_deploy_runtime_build_readback_status": str( production_deploy_readback.get("runtime_build_readback_status") or "" ), + "production_deploy_runtime_build_matches_gitops_desired_image_tag": ( + production_deploy_runtime_matches_gitops_desired + ), + "production_deploy_runtime_build_deploy_readback_current": ( + production_deploy_runtime_readback_current + ), + "production_deploy_runtime_build_committed_readback_drift_accepted": ( + production_deploy_runtime_committed_drift_accepted + ), "production_deploy_runtime_build_matches_committed_source_control_readback": ( production_deploy_readback.get( "runtime_build_matches_committed_source_control_readback" diff --git a/apps/api/tests/test_delivery_closure_workbench_api.py b/apps/api/tests/test_delivery_closure_workbench_api.py index 4c0db75f..ae1b3889 100644 --- a/apps/api/tests/test_delivery_closure_workbench_api.py +++ b/apps/api/tests/test_delivery_closure_workbench_api.py @@ -49,6 +49,45 @@ def test_delivery_closure_workbench_endpoint_returns_product_summary(): _assert_delivery_workbench_shape(data) +def test_delivery_closure_workbench_surfaces_gitops_runtime_readback_current( + monkeypatch, +): + build_sha = "0123456789abcdef0123456789abcdef01234567" + monkeypatch.setenv("AWOOOI_BUILD_COMMIT_SHA", build_sha) + monkeypatch.setenv("AWOOOI_DESIRED_API_IMAGE_TAG", build_sha) + + payload = load_delivery_closure_workbench() + summary = payload["summary"] + production_lane = { + lane["id"]: lane for lane in payload["lanes"] + }["production_deploy"] + metric = production_lane["metric"] + + assert summary["production_deploy_image_tag_matches_main"] is True + assert ( + summary[ + "production_deploy_runtime_build_matches_gitops_desired_image_tag" + ] + is True + ) + assert ( + summary["production_deploy_runtime_build_deploy_readback_current"] + is True + ) + assert ( + summary[ + "production_deploy_runtime_build_committed_readback_drift_accepted" + ] + is True + ) + assert ( + metric["runtime_build_matches_gitops_desired_image_tag"] + is True + ) + assert metric["runtime_build_deploy_readback_current"] is True + assert metric["runtime_build_committed_readback_drift_accepted"] is True + + def test_delivery_closure_workbench_uses_gitea_private_inventory_lane(): payload = load_delivery_closure_workbench() diff --git a/apps/web/src/lib/api-client.ts b/apps/web/src/lib/api-client.ts index 76896665..e37fb685 100644 --- a/apps/web/src/lib/api-client.ts +++ b/apps/web/src/lib/api-client.ts @@ -2775,6 +2775,16 @@ export interface DeliveryClosureWorkbenchSnapshot { production_deploy_status: string production_deploy_source_control_main_ready: boolean production_deploy_image_tag_matches_main: boolean + production_deploy_runtime_build_commit_sha: string + production_deploy_runtime_build_commit_short_sha: string + production_deploy_runtime_build_readback_status: string + production_deploy_runtime_build_matches_gitops_desired_image_tag: boolean + production_deploy_runtime_build_deploy_readback_current: boolean + production_deploy_runtime_build_committed_readback_drift_accepted: boolean + production_deploy_runtime_build_matches_committed_source_control_readback: boolean + production_deploy_runtime_build_matches_committed_production_image_tag: boolean + production_deploy_desired_main_api_image_tag_short_sha: string + production_deploy_desired_main_api_image_tag_readback_status: string production_deploy_governance_fields_present: boolean production_deploy_authorized_dispatch_channel_ready: boolean production_deploy_manual_run_button_visible: boolean @@ -2873,6 +2883,15 @@ export interface DeliveryClosureWorkbenchSnapshot { observed_source_control_main_short_sha: string production_image_tag_short_sha: string production_image_tag_matches_main: boolean + runtime_build_commit_short_sha: string + runtime_build_readback_status: string + runtime_build_matches_gitops_desired_image_tag: boolean + runtime_build_deploy_readback_current: boolean + runtime_build_committed_readback_drift_accepted: boolean + runtime_build_matches_committed_source_control_readback: boolean + runtime_build_matches_committed_production_image_tag: boolean + desired_main_api_image_tag_short_sha: string + desired_main_api_image_tag_readback_status: string current_main_cd_run_visible: boolean authorized_dispatch_channel_ready: boolean manual_run_button_visible: boolean