fix(agent99): terminalize unscoped cold-start recovery

This commit is contained in:
Your Name
2026-07-22 14:17:58 +08:00
parent 3a6f8badb7
commit 9fce2cd00f
8 changed files with 466 additions and 64 deletions

View File

@@ -404,9 +404,27 @@ def resolve_typed_alert_target(
executor="Agent99",
verifier="cold_start_independent_scorecard_verifier",
risk_class="high",
controlled_apply_allowed=False,
execution_role="single_writer_control_plane_recovery_executor",
)
route["route_id"] = "agent99_recover_after_owner_review"
route.update(
{
"source_namespace": legacy_recovery["source_namespace"],
"normalized_execution_namespace": legacy_recovery[
"normalized_execution_namespace"
],
"kubernetes_namespace_applicable": False,
"inventory_scope_status": "exact_inventory_scope_unresolved",
"no_write_terminal_required": True,
"no_write_terminal_reason": "exact_inventory_scope_missing",
"check_route": legacy_recovery["check_route"],
"controlled_apply_route": legacy_recovery[
"controlled_apply_route"
],
"rollback_route": legacy_recovery["rollback_route"],
}
)
return route
if compact_alert in {
@@ -962,10 +980,17 @@ def resolve_controlled_alert_target(
"schema_version": "controlled_alert_target_route_v1",
"target_kind": "control_plane_recovery",
"target_resource": target_resource or "cold-start-gate",
"canonical_asset_id": "control-plane:cold-start-gate",
"source_namespace": namespace or None,
"normalized_execution_namespace": "host_recovery",
"kubernetes_namespace_applicable": False,
"executor": "Agent99",
"verifier": "cold_start_independent_scorecard_verifier",
"allowed_inventory_hosts": [],
"controlled_apply_allowed": False,
"inventory_scope_status": "exact_inventory_scope_unresolved",
"no_write_terminal_required": True,
"no_write_terminal_reason": "exact_inventory_scope_missing",
"route_id": "agent99_recover_after_owner_review",
"check_route": "agent99-mode Status controlledApply=false",
"controlled_apply_route": "agent99-mode Recover controlledApply=true",
@@ -1020,10 +1045,16 @@ def build_controlled_recovery_promotion_contract(
},
{
"field": "controlled_apply_route",
"status": "ready",
"status": "blocked",
"source": "domain_target_normalizer",
"value": route["controlled_apply_route"],
},
{
"field": "no_write_terminal_receipt",
"status": "pending",
"source": "alert_operation_log",
"value": "required_before_no_write_terminal_is_durable",
},
{
"field": "dispatch_receipt",
"status": "pending",
@@ -1089,12 +1120,12 @@ def build_controlled_recovery_promotion_contract(
"fields": fields,
"runtime_execution_authorized": False,
"runtime_write_allowed": False,
"controlled_playbook_queue": True,
"controlled_playbook_queue": False,
"owner_review_required": False,
"owner_review_gate": "auto_waived_for_low_medium_high",
"needs_human": False,
"completion_status": "partial",
"completion_blocker": "dispatch_verifier_and_learning_receipts_missing",
"completion_status": "no_write_terminal_pending_durable_receipt",
"completion_blocker": "exact_inventory_scope_missing",
"forbidden_operations": [
"kubectl_for_host_control_plane_target",
"generic_ansible_keyword_fallback",
@@ -1107,12 +1138,16 @@ def build_controlled_recovery_promotion_contract(
"controlled_automation_closure": {
"schema_version": "controlled_recovery_closure_contract_v1",
"trace_id_required": True,
"status": "pending_source_check_dispatch_verify_writeback",
"status": "no_write_terminal_pending_durable_receipt",
"stages": [
{"stage": "sensor", "status": "pending", "writes_runtime_state": False},
{"stage": "normalize", "status": "passed", "writes_runtime_state": False},
{"stage": "check", "status": "pending", "writes_runtime_state": False},
{"stage": "controlled_apply", "status": "pending", "writes_runtime_state": False},
{
"stage": "controlled_apply",
"status": "blocked_exact_inventory_scope_missing",
"writes_runtime_state": False,
},
{"stage": "verify", "status": "pending", "writes_runtime_state": False},
{"stage": "learn_writeback", "status": "pending", "writes_runtime_state": False},
],
@@ -1128,7 +1163,7 @@ def build_controlled_recovery_promotion_contract(
"asset_type": "PlayBook",
"asset_id": "agent99:Recover",
"owner": "Agent99",
"status": "dispatch_receipt_pending",
"status": "blocked_exact_inventory_scope_missing",
},
{
"asset_type": "Verifier",
@@ -1162,19 +1197,34 @@ def build_controlled_recovery_handoff(
)
if contract is None:
return None
no_write_required = bool(
contract.get("target_route", {}).get("no_write_terminal_required") is True
)
return {
"schema_version": "ai_decision_controlled_executor_handoff_v1",
"status": "agent99_dispatch_receipt_readback_pending",
"status": (
"cold_start_no_write_terminal_pending_receipt"
if no_write_required
else "agent99_dispatch_receipt_readback_pending"
),
"queued": False,
"side_effect_performed": False,
"single_writer_executor": "Agent99",
"route_id": contract["route_id"],
"active_blockers": [
"agent99_dispatch_receipt_readback_pending",
"post_apply_verifier_missing",
"km_playbook_writeback_missing",
],
"safe_next_action": "read_agent99_dispatch_then_run_independent_cold_start_verifier",
"active_blockers": (
["exact_inventory_scope_missing"]
if no_write_required
else [
"agent99_dispatch_receipt_readback_pending",
"post_apply_verifier_missing",
"km_playbook_writeback_missing",
]
),
"safe_next_action": (
"persist_no_write_terminal_without_claim_or_transport"
if no_write_required
else "read_agent99_dispatch_then_run_independent_cold_start_verifier"
),
"repair_candidate_promotion_contract": contract,
"runtime_execution_authorized": False,
"runtime_write_allowed": False,