From 8a1f2ec5ca79d4163c3c105adc672960737f1ba8 Mon Sep 17 00:00:00 2001 From: hyeokjun32 Date: Mon, 1 Jun 2026 12:59:49 +0900 Subject: [PATCH] test: gate AIGuard max queue raw context --- .../runtime_intelligence_gitlab_artifacts.md | 6 +++ .../edgeenv_runtime_regression_lab_handoff.md | 5 +++ ...uard_runtime_operation_guard_analysis.json | 7 ++++ ...ck_runtime_intelligence_bundle_manifest.py | 25 ++++++++++++ ...st_runtime_intelligence_bundle_manifest.py | 40 +++++++++++++++++++ ...ntime_intelligence_evidence_chain_smoke.py | 6 +++ 6 files changed, 89 insertions(+) diff --git a/docs/ci/runtime_intelligence_gitlab_artifacts.md b/docs/ci/runtime_intelligence_gitlab_artifacts.md index dd5bad6..4dc2053 100644 --- a/docs/ci/runtime_intelligence_gitlab_artifacts.md +++ b/docs/ci/runtime_intelligence_gitlab_artifacts.md @@ -187,6 +187,12 @@ producer-lineage guard-alignment run IDs. This keeps the cross-repo marker check file-based and does not make AIGuard a deployment decision owner. The artifact gate is implemented by `scripts/check_runtime_intelligence_artifact_bundle.py`. It checks the generated Markdown / HTML report for the required Runtime Intelligence rows, including Lab ownership, EdgeEnv comparability, telemetry coverage-gap markers, Runtime replay duration scope with `source=entrypoint_requested_frames` traceability, Orchestrator operation feed context, compact queue/deadline/fallback operation markers with `max_total_queue_depth`, Orchestrator task event rollup, Lab EdgeEnv preservation context, Jetson/device-local preservation identity and detail labels, Orchestrator `operation_risk_summary` navigation context, AIGuard runtime operation anomalies, AIGuard `edgeenv_orchestrator_operation_risk_summary` evidence, AIGuard `edgeenv_orchestrator_task_event_rollup` evidence, remote dispatch starter event summary, `Remote fallback starter evidence`, `edgeenv_orchestrator_producer_lineage`, `runtime_history_seed_run_config_traceability`, `remote_execution_recovered_by_fallback`, and triggered deployment review rules. + +The bundle manifest gate also checks the external AIGuard artifact before the +rendered report stage. In particular, `runtime_queue_overload` must preserve +`orchestrator_candidate_operation_max_total_queue_depth=7` in +`raw_context.edgeenv_regression`, so the Lab `max_total_queue_depth` report row +can be traced back to Orchestrator producer-side operation context. When that report gate passes, its summary now emits a `Validated Duration Traceability` section with `duration_handoff_alignment`, `duration_source: source=entrypoint_requested_frames`, diff --git a/docs/portfolio/edgeenv_runtime_regression_lab_handoff.md b/docs/portfolio/edgeenv_runtime_regression_lab_handoff.md index 5bc6862..7a9dcb2 100644 --- a/docs/portfolio/edgeenv_runtime_regression_lab_handoff.md +++ b/docs/portfolio/edgeenv_runtime_regression_lab_handoff.md @@ -176,6 +176,11 @@ Expected Lab behavior: - When EdgeEnv preservation context is present, Lab renders `Lab EdgeEnv preservation context` with `lab_report_preservation_context_present=True`, `lab_preservation=present`, and `lab_context=present` so the Runtime Intelligence report gate and entrypoint evidence index use the same Lab-owned marker vocabulary. - When an EdgeEnv handoff manifest is provided, the bundle gate requires EdgeEnv-produced file keys, external AIGuard file keys, source repository mapping, artifact roles, producer contracts, and boundary flags to match Lab's Runtime Intelligence bundle contract. - The same manifest gate requires `expected_report_markers` to preserve these exact Lab-owned report markers: `Runtime Intelligence Risk Summary`, `Runtime replay duration scope`, `Orchestrator operation feed context`, `Orchestrator task event rollup`, `Lab EdgeEnv preservation context`, `AIGuard task event rollup evidence`, `AIGuard runtime operation anomalies`, `AIGuard remote dispatch event summary`, `AIGuard remote event summary consistency`, `Remote fallback starter evidence`, `lab=Remote fallback starter evidence; evidence=remote_execution_recovered_by_fallback`, `AIGuard producer-lineage guard alignment`, and `Lab remains the final deployment decision owner.`. +- The external AIGuard artifact gate also requires `runtime_queue_overload` + raw context to preserve + `orchestrator_candidate_operation_max_total_queue_depth=7`, keeping the + rendered Lab `max_total_queue_depth` row traceable to Orchestrator's + producer-side operation context. - The same gate summary emits `expected_report_markers: remote fallback Lab context row declared`, keeping the remote fallback row-value marker visible in file-based CI artifacts without making CI a runtime control plane. - The same handoff gate verifies that the referenced `runtime_telemetry_history` artifact exists and preserves EdgeEnv history schema, telemetry coverage, and Runtime history seed ownership markers. - The same handoff gate verifies that missing telemetry entries remain evidence gaps while preserving Orchestrator producer markers, owner boundary flags, and EdgeEnv mapping hints when Orchestrator context is attached. diff --git a/examples/runtime_intelligence_chain/aiguard_runtime_operation_guard_analysis.json b/examples/runtime_intelligence_chain/aiguard_runtime_operation_guard_analysis.json index 52204c8..79735b0 100644 --- a/examples/runtime_intelligence_chain/aiguard_runtime_operation_guard_analysis.json +++ b/examples/runtime_intelligence_chain/aiguard_runtime_operation_guard_analysis.json @@ -181,6 +181,7 @@ "candidate_throttling_detected": true, "baseline_queue_depth": null, "candidate_queue_depth": 7.0, + "orchestrator_candidate_operation_max_total_queue_depth": 7.0, "evidence_gap_count": 1.0, "evidence_gaps": [], "history_missing_orchestrator_context_count": 1.0, @@ -508,6 +509,7 @@ "candidate_throttling_detected": true, "baseline_queue_depth": null, "candidate_queue_depth": 7.0, + "orchestrator_candidate_operation_max_total_queue_depth": 7.0, "evidence_gap_count": 1.0, "evidence_gaps": [], "history_missing_orchestrator_context_count": 1.0, @@ -1226,6 +1228,7 @@ "candidate_throttling_detected": true, "baseline_queue_depth": null, "candidate_queue_depth": 7.0, + "orchestrator_candidate_operation_max_total_queue_depth": 7.0, "evidence_gap_count": 1.0, "evidence_gaps": [] }, @@ -1544,6 +1547,7 @@ "candidate_throttling_detected": true, "baseline_queue_depth": null, "candidate_queue_depth": 7.0, + "orchestrator_candidate_operation_max_total_queue_depth": 7.0, "evidence_gap_count": 1.0, "evidence_gaps": [], "history_missing_orchestrator_context_count": 1.0, @@ -1844,6 +1848,7 @@ "candidate_throttling_detected": true, "baseline_queue_depth": null, "candidate_queue_depth": 7.0, + "orchestrator_candidate_operation_max_total_queue_depth": 7.0, "evidence_gap_count": 1.0, "evidence_gaps": [], "history_missing_orchestrator_context_count": 1.0, @@ -2272,6 +2277,7 @@ "candidate_throttling_detected": true, "baseline_queue_depth": null, "candidate_queue_depth": 7.0, + "orchestrator_candidate_operation_max_total_queue_depth": 7.0, "evidence_gap_count": 1.0, "evidence_gaps": [], "history_missing_orchestrator_context_count": 1.0, @@ -2574,6 +2580,7 @@ "queue_depth": 7, "operation": { "queue_depth": 7, + "max_total_queue_depth": 7, "deadline_missed_count": 2, "fallback_count": 1 }, diff --git a/scripts/check_runtime_intelligence_bundle_manifest.py b/scripts/check_runtime_intelligence_bundle_manifest.py index 2fd3005..acd53ce 100644 --- a/scripts/check_runtime_intelligence_bundle_manifest.py +++ b/scripts/check_runtime_intelligence_bundle_manifest.py @@ -167,6 +167,7 @@ "aiguard_raw_context: downstream_guard_alignment preserved", "aiguard_raw_context: producer_lineage_guard_alignment preserved", "aiguard_raw_context: missing_telemetry_orchestrator_context preserved", + "aiguard_raw_context: max_total_queue_depth traceability preserved", "aiguard_handoff_alignment: external required evidence types satisfied", "expected_report_markers: Runtime Intelligence report markers declared", "expected_report_markers: remote fallback Lab context row declared", @@ -1653,6 +1654,8 @@ def _validate_guard_analysis(guard_analysis: dict[str, Any], errors: list[str]) _validate_run_config_traceability_evidence(item, index, errors) if item.get("type") == "remote_execution_recovered_by_fallback": _validate_remote_runtime_event_summary_evidence(item, index, errors) + if item.get("type") == "runtime_queue_overload": + _validate_queue_overload_evidence(item, index, errors) def _validate_external_aiguard_evidence_alignment( @@ -2244,6 +2247,28 @@ def _validate_coverage_gap_evidence( _validate_aiguard_missing_orchestrator_context(edgeenv, errors) +def _validate_queue_overload_evidence( + item: dict[str, Any], + index: int, + errors: list[str], +) -> None: + edgeenv = (item.get("raw_context") or {}).get("edgeenv_regression") + _record( + isinstance(edgeenv, dict), + errors, + f"AIGuard evidence[{index}] raw_context.edgeenv_regression must be an object", + ) + if not isinstance(edgeenv, dict): + return + _record( + edgeenv.get("orchestrator_candidate_operation_max_total_queue_depth") + == 7.0, + errors, + "AIGuard queue overload evidence " + "orchestrator_candidate_operation_max_total_queue_depth must be 7.0", + ) + + def _validate_aiguard_history_seed_context( edgeenv_context: dict[str, Any], errors: list[str], diff --git a/tests/test_runtime_intelligence_bundle_manifest.py b/tests/test_runtime_intelligence_bundle_manifest.py index f3d837b..76af873 100644 --- a/tests/test_runtime_intelligence_bundle_manifest.py +++ b/tests/test_runtime_intelligence_bundle_manifest.py @@ -119,6 +119,10 @@ def test_runtime_intelligence_bundle_manifest_gate_cli_passes(tmp_path): ) assert "aiguard_raw_context: downstream_guard_alignment preserved" in summary assert "aiguard_raw_context: producer_lineage_guard_alignment preserved" in summary + assert ( + "aiguard_raw_context: max_total_queue_depth traceability preserved" + in summary + ) assert ( "expected_report_markers: Runtime Intelligence report markers declared" in summary @@ -1081,6 +1085,42 @@ def test_runtime_intelligence_bundle_manifest_gate_fails_for_old_guard_coverage_ assert "history missing field runs must be a list" in summary +def test_runtime_intelligence_bundle_manifest_gate_fails_for_missing_guard_max_queue_context( + tmp_path, +): + manifest = json.loads(MANIFEST.read_text(encoding="utf-8")) + guard_path = ( + REPO_ROOT + / "examples" + / "runtime_intelligence_chain" + / manifest["files"]["aiguard_guard_analysis"] + ) + guard_analysis = json.loads(guard_path.read_text(encoding="utf-8")) + queue_evidence = next( + item + for item in guard_analysis["evidence"] + if item.get("type") == "runtime_queue_overload" + ) + edgeenv_context = queue_evidence["raw_context"]["edgeenv_regression"] + edgeenv_context.pop("orchestrator_candidate_operation_max_total_queue_depth") + + guard_copy = tmp_path / "aiguard_guard_analysis.json" + guard_copy.write_text(json.dumps(guard_analysis), encoding="utf-8") + manifest["files"]["aiguard_guard_analysis"] = str(guard_copy) + manifest_path = tmp_path / "bundle_manifest.json" + manifest_path.write_text(json.dumps(manifest), encoding="utf-8") + summary_path = tmp_path / "bundle_manifest_gate_summary.md" + + result = manifest_gate(manifest=str(manifest_path), summary_out=str(summary_path)) + + assert result == 2 + summary = summary_path.read_text(encoding="utf-8") + assert ( + "AIGuard queue overload evidence " + "orchestrator_candidate_operation_max_total_queue_depth must be 7.0" + ) in summary + + def test_runtime_intelligence_bundle_manifest_gate_fails_for_bad_guard_mapping_hint( tmp_path, ): diff --git a/tests/test_runtime_intelligence_evidence_chain_smoke.py b/tests/test_runtime_intelligence_evidence_chain_smoke.py index 0804f5c..77766aa 100644 --- a/tests/test_runtime_intelligence_evidence_chain_smoke.py +++ b/tests/test_runtime_intelligence_evidence_chain_smoke.py @@ -150,6 +150,12 @@ def test_runtime_intelligence_chain_smoke_ingests_precomputed_guard_artifact(): assert guard_edgeenv_context["orchestrator_candidate_context_telemetry_source"] == ( "inferedge_orchestrator_operation_summary" ) + assert ( + guard_edgeenv_context[ + "orchestrator_candidate_operation_max_total_queue_depth" + ] + == 7.0 + ) assert guard_edgeenv_context["orchestrator_downstream_guard_alignment"][ "producer_lineage_evidence_type" ] == "edgeenv_orchestrator_producer_lineage"