Upload 16 files
Browse files- src/bucket.py +15 -3
- src/effective_status.py +34 -6
- src/eval_archive.py +2 -2
- src/jobs.py +7 -0
- src/target_space_identity.py +100 -0
- src/version.py +2 -2
- src/view_models.py +12 -2
- src/worker_payload.py +44 -11
src/bucket.py
CHANGED
|
@@ -12,6 +12,7 @@ from huggingface_hub import HfFileSystem, bucket_info, create_bucket, sync_bucke
|
|
| 12 |
|
| 13 |
from .config import bucket_uri_from_source, normalize_bucket_name, settings, user_bucket_source
|
| 14 |
from .effective_status import compute_effective_run_status
|
|
|
|
| 15 |
from .security import redact
|
| 16 |
|
| 17 |
|
|
@@ -1613,6 +1614,8 @@ def summarize_run_bundle(run_id: str, bundle: dict[str, Any], *, bucket_source:
|
|
| 1613 |
"full_inference_success",
|
| 1614 |
"validated_after_space_test",
|
| 1615 |
"validated_after_manual_space_test",
|
|
|
|
|
|
|
| 1616 |
"recovered_by_space_test",
|
| 1617 |
"recovered_by_manual_validation",
|
| 1618 |
"manual_validation_passed",
|
|
@@ -1640,6 +1643,8 @@ def summarize_run_bundle(run_id: str, bundle: dict[str, Any], *, bucket_source:
|
|
| 1640 |
"full_inference_success",
|
| 1641 |
"validated_after_space_test",
|
| 1642 |
"validated_after_manual_space_test",
|
|
|
|
|
|
|
| 1643 |
"recovered_by_space_test",
|
| 1644 |
"recovered_by_manual_validation",
|
| 1645 |
"manual_validation_passed",
|
|
@@ -1658,7 +1663,8 @@ def summarize_run_bundle(run_id: str, bundle: dict[str, Any], *, bucket_source:
|
|
| 1658 |
eval_publish_status = bundle.get("eval_publish_status") or {}
|
| 1659 |
final_status_reconciliation = bundle.get("final_status_reconciliation") or {}
|
| 1660 |
eval_record = bundle.get("eval_record") or {}
|
| 1661 |
-
|
|
|
|
| 1662 |
kind = state.get("kind") or launch.get("kind") or summary_file.get("kind") or "unknown"
|
| 1663 |
is_validation = "validate" in str(kind).lower() or str(run_id).startswith("validate-")
|
| 1664 |
if is_validation:
|
|
@@ -1704,7 +1710,12 @@ def summarize_run_bundle(run_id: str, bundle: dict[str, Any], *, bucket_source:
|
|
| 1704 |
"model_id": state.get("model_id") or launch.get("model_id") or summary_file.get("model_id") or state.get("model") or "",
|
| 1705 |
"pi_model": state.get("pi_model") or launch.get("pi_model") or summary_file.get("pi_model") or (bundle.get("pi_model_resolution") or {}).get("requested_model") or "",
|
| 1706 |
"target_space": target_space,
|
| 1707 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1708 |
"job_id": state.get("job_id") or launch.get("job_id") or summary_file.get("job_id") or "",
|
| 1709 |
"job_url": _job_url_from_sources(bucket_source=bucket_source, summary_file=summary_file, launch=launch, state=state),
|
| 1710 |
"created_at": state.get("created_at") or launch.get("created_at") or summary_file.get("created_at") or "",
|
|
@@ -1784,6 +1795,7 @@ def read_run_bundle(run_id: str, *, bucket_source: str, token: str | None = None
|
|
| 1784 |
"pi_model_resolution": _safe_read_json(f"{paths.root}/pi_model_resolution.json", token=token) or (read_json(paths.state, token=token) or {}).get("pi_model_resolution") or {},
|
| 1785 |
"space_runtime": _safe_read_json(f"{paths.root}/space_runtime.json", token=token),
|
| 1786 |
"runtime_upload_epoch": _safe_read_json(f"{paths.root}/runtime_upload_epoch.json", token=token),
|
|
|
|
| 1787 |
"placeholder_scaffold_detection": _safe_read_json(f"{paths.root}/placeholder_scaffold_detection.json", token=token),
|
| 1788 |
"api_schema": _safe_read_json(f"{paths.root}/tests/api_schema.json", token=token) or _safe_read_json(f"{paths.root}/tests/generation_api_schema.json", token=token),
|
| 1789 |
"validation_payload": _safe_read_json(f"{paths.root}/tests/validation_payload.json", token=token),
|
|
@@ -1954,7 +1966,7 @@ def _build_run_list_item_from_files(run_id: str, *, root: str, bucket_source: st
|
|
| 1954 |
item["effective_status"] = post_build_validation_status.get("effective_status") or item.get("effective_status")
|
| 1955 |
if linked_validations:
|
| 1956 |
rows = linked_validations.get("validations") if isinstance(linked_validations, dict) else []
|
| 1957 |
-
terminal_tokens = {"success", "passed", "succeeded", "full_inference_success", "validated_after_space_test", "validated_after_manual_space_test", "recovered_by_space_test", "recovered_by_manual_validation", "manual_validation_passed", "manual_validated", "partial_validation", "manual_hardware_required", "generated_needs_manual_hardware", "technical_blocker", "technical_blocker_boot_only", "blocked", "completed_with_warnings", "failed", "failure", "error", "auth_refresh_required", "stale", "stopped", "cancelled", "canceled"}
|
| 1958 |
accounted_rows = [row for row in rows if isinstance(row, dict) and str(row.get("status") or row.get("validation_status") or row.get("result_status") or row.get("effective_status") or "").lower() in terminal_tokens] if isinstance(rows, list) else []
|
| 1959 |
item["linked_validations"] = linked_validations
|
| 1960 |
item["linked_validation_count"] = len(accounted_rows)
|
|
|
|
| 12 |
|
| 13 |
from .config import bucket_uri_from_source, normalize_bucket_name, settings, user_bucket_source
|
| 14 |
from .effective_status import compute_effective_run_status
|
| 15 |
+
from .target_space_identity import target_space_identity_overlay
|
| 16 |
from .security import redact
|
| 17 |
|
| 18 |
|
|
|
|
| 1614 |
"full_inference_success",
|
| 1615 |
"validated_after_space_test",
|
| 1616 |
"validated_after_manual_space_test",
|
| 1617 |
+
"success_with_expert_intervention",
|
| 1618 |
+
"expert_intervention_validation_passed",
|
| 1619 |
"recovered_by_space_test",
|
| 1620 |
"recovered_by_manual_validation",
|
| 1621 |
"manual_validation_passed",
|
|
|
|
| 1643 |
"full_inference_success",
|
| 1644 |
"validated_after_space_test",
|
| 1645 |
"validated_after_manual_space_test",
|
| 1646 |
+
"success_with_expert_intervention",
|
| 1647 |
+
"expert_intervention_validation_passed",
|
| 1648 |
"recovered_by_space_test",
|
| 1649 |
"recovered_by_manual_validation",
|
| 1650 |
"manual_validation_passed",
|
|
|
|
| 1663 |
eval_publish_status = bundle.get("eval_publish_status") or {}
|
| 1664 |
final_status_reconciliation = bundle.get("final_status_reconciliation") or {}
|
| 1665 |
eval_record = bundle.get("eval_record") or {}
|
| 1666 |
+
target_overlay = target_space_identity_overlay(bundle)
|
| 1667 |
+
target_space = target_overlay.get("target_space") or state.get("target_space") or launch.get("target_space") or summary_file.get("target_space") or ""
|
| 1668 |
kind = state.get("kind") or launch.get("kind") or summary_file.get("kind") or "unknown"
|
| 1669 |
is_validation = "validate" in str(kind).lower() or str(run_id).startswith("validate-")
|
| 1670 |
if is_validation:
|
|
|
|
| 1710 |
"model_id": state.get("model_id") or launch.get("model_id") or summary_file.get("model_id") or state.get("model") or "",
|
| 1711 |
"pi_model": state.get("pi_model") or launch.get("pi_model") or summary_file.get("pi_model") or (bundle.get("pi_model_resolution") or {}).get("requested_model") or "",
|
| 1712 |
"target_space": target_space,
|
| 1713 |
+
"target_space_id": target_space,
|
| 1714 |
+
"target_space_url": target_overlay.get("target_space_url") or state.get("target_space_url") or launch.get("target_space_url") or summary_file.get("target_space_url") or (f"https://huggingface.co/spaces/{target_space}" if target_space else ""),
|
| 1715 |
+
"target_space_settings_url": target_overlay.get("target_space_settings_url") or (f"https://huggingface.co/spaces/{target_space}/settings" if target_space else ""),
|
| 1716 |
+
"target_space_original": target_overlay.get("target_space_original") or "",
|
| 1717 |
+
"target_space_override_active": bool(target_overlay.get("target_space_override_active")),
|
| 1718 |
+
"target_space_source": target_overlay.get("target_space_source") or "generated_run",
|
| 1719 |
"job_id": state.get("job_id") or launch.get("job_id") or summary_file.get("job_id") or "",
|
| 1720 |
"job_url": _job_url_from_sources(bucket_source=bucket_source, summary_file=summary_file, launch=launch, state=state),
|
| 1721 |
"created_at": state.get("created_at") or launch.get("created_at") or summary_file.get("created_at") or "",
|
|
|
|
| 1795 |
"pi_model_resolution": _safe_read_json(f"{paths.root}/pi_model_resolution.json", token=token) or (read_json(paths.state, token=token) or {}).get("pi_model_resolution") or {},
|
| 1796 |
"space_runtime": _safe_read_json(f"{paths.root}/space_runtime.json", token=token),
|
| 1797 |
"runtime_upload_epoch": _safe_read_json(f"{paths.root}/runtime_upload_epoch.json", token=token),
|
| 1798 |
+
"target_space_override": _safe_read_json(f"{paths.root}/TARGET_SPACE_OVERRIDE.json", token=token),
|
| 1799 |
"placeholder_scaffold_detection": _safe_read_json(f"{paths.root}/placeholder_scaffold_detection.json", token=token),
|
| 1800 |
"api_schema": _safe_read_json(f"{paths.root}/tests/api_schema.json", token=token) or _safe_read_json(f"{paths.root}/tests/generation_api_schema.json", token=token),
|
| 1801 |
"validation_payload": _safe_read_json(f"{paths.root}/tests/validation_payload.json", token=token),
|
|
|
|
| 1966 |
item["effective_status"] = post_build_validation_status.get("effective_status") or item.get("effective_status")
|
| 1967 |
if linked_validations:
|
| 1968 |
rows = linked_validations.get("validations") if isinstance(linked_validations, dict) else []
|
| 1969 |
+
terminal_tokens = {"success", "passed", "succeeded", "full_inference_success", "validated_after_space_test", "validated_after_manual_space_test", "success_with_expert_intervention", "expert_intervention_validation_passed", "recovered_by_space_test", "recovered_by_manual_validation", "manual_validation_passed", "manual_validated", "partial_validation", "manual_hardware_required", "generated_needs_manual_hardware", "technical_blocker", "technical_blocker_boot_only", "blocked", "completed_with_warnings", "failed", "failure", "error", "auth_refresh_required", "stale", "stopped", "cancelled", "canceled"}
|
| 1970 |
accounted_rows = [row for row in rows if isinstance(row, dict) and str(row.get("status") or row.get("validation_status") or row.get("result_status") or row.get("effective_status") or "").lower() in terminal_tokens] if isinstance(rows, list) else []
|
| 1971 |
item["linked_validations"] = linked_validations
|
| 1972 |
item["linked_validation_count"] = len(accounted_rows)
|
src/effective_status.py
CHANGED
|
@@ -2,6 +2,8 @@ from __future__ import annotations
|
|
| 2 |
|
| 3 |
from typing import Any
|
| 4 |
|
|
|
|
|
|
|
| 5 |
|
| 6 |
SUCCESS_VALIDATION_TOKENS = {
|
| 7 |
"success",
|
|
@@ -15,6 +17,8 @@ SUCCESS_VALIDATION_TOKENS = {
|
|
| 15 |
"manual_validated",
|
| 16 |
"recovered_by_manual_validation",
|
| 17 |
"recovered_by_space_test",
|
|
|
|
|
|
|
| 18 |
}
|
| 19 |
|
| 20 |
PARTIAL_BUILD_TOKENS = {
|
|
@@ -54,6 +58,9 @@ def _first_nonempty(*values: Any) -> str:
|
|
| 54 |
|
| 55 |
|
| 56 |
def _target_space_from_bundle(bundle: dict[str, Any]) -> str:
|
|
|
|
|
|
|
|
|
|
| 57 |
summary = bundle.get("summary") or bundle.get("summary_file") or {}
|
| 58 |
state = bundle.get("state") or {}
|
| 59 |
launch = bundle.get("launch") or {}
|
|
@@ -180,6 +187,8 @@ def _successful_post_build_validation(bundle: dict[str, Any]) -> dict[str, Any]:
|
|
| 180 |
|
| 181 |
def _normalize_build_status(value: Any) -> str:
|
| 182 |
status = _lower(value)
|
|
|
|
|
|
|
| 183 |
if status in {"succeeded", "success", "passed", "done", "completed", "repair_success"}:
|
| 184 |
return "full_inference_success"
|
| 185 |
if status in {"repair_validation_failed", "upload_failed", "smoke_still_failed", "repair_failed_same_error", "repair_exhausted", "no_patch_produced_by_pi", "no_relevant_patch_produced_by_pi", "pi_patch_rejected_by_guard"}:
|
|
@@ -235,8 +244,23 @@ def compute_effective_run_status(
|
|
| 235 |
can_promote = bool(post)
|
| 236 |
promotion_reason = ""
|
| 237 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
if can_promote:
|
| 239 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
normalized_build in FAILED_BUILD_TOKENS
|
| 241 |
or "failed" in normalized_build
|
| 242 |
or normalized_build in BLOCKED_BUILD_TOKENS
|
|
@@ -244,14 +268,16 @@ def compute_effective_run_status(
|
|
| 244 |
):
|
| 245 |
display_status = "recovered_by_space_test"
|
| 246 |
legacy_effective_status = "recovered_by_manual_validation"
|
|
|
|
| 247 |
else:
|
| 248 |
display_status = "validated_after_space_test"
|
| 249 |
legacy_effective_status = "validated_after_manual_space_test"
|
| 250 |
-
if can_promote:
|
| 251 |
-
post_build_status = display_status
|
| 252 |
promotion_reason = "linked_space_test_success"
|
|
|
|
| 253 |
|
| 254 |
-
if display_status == "
|
|
|
|
|
|
|
| 255 |
display_label = "Validated after Space Test"
|
| 256 |
elif display_status == "recovered_by_space_test":
|
| 257 |
display_label = "Recovered by Space Test"
|
|
@@ -279,18 +305,20 @@ def compute_effective_run_status(
|
|
| 279 |
display_label = display_status.replace("_", " ").title() if display_status else "Unknown"
|
| 280 |
|
| 281 |
return {
|
| 282 |
-
"schema_version": "effective_run_status.
|
| 283 |
"build_status": normalized_build,
|
| 284 |
"build_verdict": normalized_verdict,
|
| 285 |
"build_verdict_preserved": True,
|
| 286 |
"post_build_status": post_build_status,
|
| 287 |
"post_build_validation": {
|
| 288 |
"status": "success" if can_promote else ("blocked" if post and not can_promote else "none"),
|
| 289 |
-
"source": "linked_space_test" if post else "none",
|
| 290 |
"validation_run_id": post.get("validation_run_id") or post.get("run_id") or "",
|
| 291 |
"target_space": post.get("target_space") or post.get("target_space_id") or "",
|
| 292 |
"api_name": post.get("api_name") or "",
|
| 293 |
"updated_at": post.get("updated_at") or post.get("validated_at") or "",
|
|
|
|
|
|
|
| 294 |
},
|
| 295 |
"display_status": display_status,
|
| 296 |
"display_label": display_label,
|
|
|
|
| 2 |
|
| 3 |
from typing import Any
|
| 4 |
|
| 5 |
+
from .target_space_identity import target_space_identity_overlay
|
| 6 |
+
|
| 7 |
|
| 8 |
SUCCESS_VALIDATION_TOKENS = {
|
| 9 |
"success",
|
|
|
|
| 17 |
"manual_validated",
|
| 18 |
"recovered_by_manual_validation",
|
| 19 |
"recovered_by_space_test",
|
| 20 |
+
"success_with_expert_intervention",
|
| 21 |
+
"expert_intervention_validation_passed",
|
| 22 |
}
|
| 23 |
|
| 24 |
PARTIAL_BUILD_TOKENS = {
|
|
|
|
| 58 |
|
| 59 |
|
| 60 |
def _target_space_from_bundle(bundle: dict[str, Any]) -> str:
|
| 61 |
+
overlay = target_space_identity_overlay(bundle)
|
| 62 |
+
if overlay.get("target_space"):
|
| 63 |
+
return str(overlay.get("target_space") or "")
|
| 64 |
summary = bundle.get("summary") or bundle.get("summary_file") or {}
|
| 65 |
state = bundle.get("state") or {}
|
| 66 |
launch = bundle.get("launch") or {}
|
|
|
|
| 187 |
|
| 188 |
def _normalize_build_status(value: Any) -> str:
|
| 189 |
status = _lower(value)
|
| 190 |
+
if status in {"success_with_expert_intervention", "expert_intervention_validation_passed"}:
|
| 191 |
+
return "success_with_expert_intervention"
|
| 192 |
if status in {"succeeded", "success", "passed", "done", "completed", "repair_success"}:
|
| 193 |
return "full_inference_success"
|
| 194 |
if status in {"repair_validation_failed", "upload_failed", "smoke_still_failed", "repair_failed_same_error", "repair_exhausted", "no_patch_produced_by_pi", "no_relevant_patch_produced_by_pi", "pi_patch_rejected_by_guard"}:
|
|
|
|
| 244 |
can_promote = bool(post)
|
| 245 |
promotion_reason = ""
|
| 246 |
|
| 247 |
+
expert_intervention_required = bool(
|
| 248 |
+
post.get("expert_intervention_required")
|
| 249 |
+
or post.get("accepted_outcome") == "success_with_expert_intervention"
|
| 250 |
+
or post.get("expert_acceptance")
|
| 251 |
+
) if isinstance(post, dict) else False
|
| 252 |
+
|
| 253 |
if can_promote:
|
| 254 |
+
if expert_intervention_required:
|
| 255 |
+
display_status = "success_with_expert_intervention"
|
| 256 |
+
legacy_effective_status = "recovered_by_manual_validation" if (
|
| 257 |
+
normalized_build in FAILED_BUILD_TOKENS
|
| 258 |
+
or "failed" in normalized_build
|
| 259 |
+
or normalized_build in BLOCKED_BUILD_TOKENS
|
| 260 |
+
or "technical_blocker" in normalized_build
|
| 261 |
+
) else "validated_after_manual_space_test"
|
| 262 |
+
promotion_reason = "expert_intervention_acceptance_validation_success"
|
| 263 |
+
elif (
|
| 264 |
normalized_build in FAILED_BUILD_TOKENS
|
| 265 |
or "failed" in normalized_build
|
| 266 |
or normalized_build in BLOCKED_BUILD_TOKENS
|
|
|
|
| 268 |
):
|
| 269 |
display_status = "recovered_by_space_test"
|
| 270 |
legacy_effective_status = "recovered_by_manual_validation"
|
| 271 |
+
promotion_reason = "linked_space_test_success"
|
| 272 |
else:
|
| 273 |
display_status = "validated_after_space_test"
|
| 274 |
legacy_effective_status = "validated_after_manual_space_test"
|
|
|
|
|
|
|
| 275 |
promotion_reason = "linked_space_test_success"
|
| 276 |
+
post_build_status = display_status
|
| 277 |
|
| 278 |
+
if display_status == "success_with_expert_intervention":
|
| 279 |
+
display_label = "Success with expert intervention"
|
| 280 |
+
elif display_status == "validated_after_space_test":
|
| 281 |
display_label = "Validated after Space Test"
|
| 282 |
elif display_status == "recovered_by_space_test":
|
| 283 |
display_label = "Recovered by Space Test"
|
|
|
|
| 305 |
display_label = display_status.replace("_", " ").title() if display_status else "Unknown"
|
| 306 |
|
| 307 |
return {
|
| 308 |
+
"schema_version": "effective_run_status.v198_26_120",
|
| 309 |
"build_status": normalized_build,
|
| 310 |
"build_verdict": normalized_verdict,
|
| 311 |
"build_verdict_preserved": True,
|
| 312 |
"post_build_status": post_build_status,
|
| 313 |
"post_build_validation": {
|
| 314 |
"status": "success" if can_promote else ("blocked" if post and not can_promote else "none"),
|
| 315 |
+
"source": "expert_intervention_acceptance" if (post and expert_intervention_required) else ("linked_space_test" if post else "none"),
|
| 316 |
"validation_run_id": post.get("validation_run_id") or post.get("run_id") or "",
|
| 317 |
"target_space": post.get("target_space") or post.get("target_space_id") or "",
|
| 318 |
"api_name": post.get("api_name") or "",
|
| 319 |
"updated_at": post.get("updated_at") or post.get("validated_at") or "",
|
| 320 |
+
"expert_intervention_required": expert_intervention_required,
|
| 321 |
+
"accepted_outcome": post.get("accepted_outcome") or ("success_with_expert_intervention" if expert_intervention_required else ""),
|
| 322 |
},
|
| 323 |
"display_status": display_status,
|
| 324 |
"display_label": display_label,
|
src/eval_archive.py
CHANGED
|
@@ -9,7 +9,7 @@ from .bucket import RunPaths, read_json, read_text, write_json
|
|
| 9 |
from .eval_config import effective_eval_config
|
| 10 |
from .security import redact
|
| 11 |
|
| 12 |
-
_TERMINAL = {"success", "done", "completed", "failed", "failure", "error", "cancelled", "canceled", "manual", "stale", "partial", "partial_validation", "completed_with_warnings", "success_with_warnings", "validated", "validated_after_manual_space_test", "recovered_by_manual_validation", "validated_after_stale_run", "manual_validation_passed", "full_inference_success", "full_inference_candidate_health_passed", "health_only", "technical_blocker", "technical_blocker_boot_only", "manual_hardware_required"}
|
| 13 |
|
| 14 |
|
| 15 |
def _now() -> str:
|
|
@@ -59,7 +59,7 @@ def _first_successful_linked_validation(payload: dict[str, Any] | None) -> dict[
|
|
| 59 |
if not isinstance(payload, dict):
|
| 60 |
return {}
|
| 61 |
rows = payload.get("validations") if isinstance(payload.get("validations"), list) else []
|
| 62 |
-
success_tokens = {"success", "passed", "full_inference_success", "validated_after_manual_space_test", "recovered_by_manual_validation"}
|
| 63 |
for row in reversed(rows):
|
| 64 |
if isinstance(row, dict) and str(row.get("status") or row.get("effective_status") or "").lower() in success_tokens:
|
| 65 |
return row
|
|
|
|
| 9 |
from .eval_config import effective_eval_config
|
| 10 |
from .security import redact
|
| 11 |
|
| 12 |
+
_TERMINAL = {"success", "done", "completed", "failed", "failure", "error", "cancelled", "canceled", "manual", "stale", "partial", "partial_validation", "completed_with_warnings", "success_with_warnings", "validated", "validated_after_manual_space_test", "success_with_expert_intervention", "expert_intervention_validation_passed", "recovered_by_manual_validation", "validated_after_stale_run", "manual_validation_passed", "full_inference_success", "full_inference_candidate_health_passed", "health_only", "technical_blocker", "technical_blocker_boot_only", "manual_hardware_required"}
|
| 13 |
|
| 14 |
|
| 15 |
def _now() -> str:
|
|
|
|
| 59 |
if not isinstance(payload, dict):
|
| 60 |
return {}
|
| 61 |
rows = payload.get("validations") if isinstance(payload.get("validations"), list) else []
|
| 62 |
+
success_tokens = {"success", "passed", "full_inference_success", "validated_after_manual_space_test", "success_with_expert_intervention", "expert_intervention_validation_passed", "recovered_by_manual_validation"}
|
| 63 |
for row in reversed(rows):
|
| 64 |
if isinstance(row, dict) and str(row.get("status") or row.get("effective_status") or "").lower() in success_tokens:
|
| 65 |
return row
|
src/jobs.py
CHANGED
|
@@ -351,6 +351,8 @@ def launch_validate_existing_space_job(
|
|
| 351 |
effective_status_on_success: str | None = None,
|
| 352 |
parent_replay_source_json: str | None = None,
|
| 353 |
validation_launch_payload_json: str | None = None,
|
|
|
|
|
|
|
| 354 |
run_id: str | None = None,
|
| 355 |
bucket_name: str | None = None,
|
| 356 |
) -> dict[str, Any]:
|
|
@@ -382,6 +384,9 @@ def launch_validate_existing_space_job(
|
|
| 382 |
env["VALIDATION_LINK_MODE"] = "build_run"
|
| 383 |
env["SPACE_TEST_POLICY_MODE"] = (validation_mode or "complete").strip()
|
| 384 |
env["EFFECTIVE_STATUS_ON_SUCCESS"] = (effective_status_on_success or "validated_after_manual_space_test").strip()
|
|
|
|
|
|
|
|
|
|
| 385 |
env["API_NAME"] = (api_name if api_name is not None else "/generate").strip()
|
| 386 |
env["ENDPOINT_DISCOVERY_REQUIRED"] = "true" if not env["API_NAME"] else "false"
|
| 387 |
env["TEST_ARGS_JSON"] = ensure_validation_payload_json_fits_env(test_args_json or '["a cinematic robot cat astronaut, detailed, studio lighting"]', field_name="test_args_json")
|
|
@@ -414,6 +419,8 @@ def launch_validate_existing_space_job(
|
|
| 414 |
"linked_target_space": target,
|
| 415 |
"space_test_policy_mode": env.get("SPACE_TEST_POLICY_MODE"),
|
| 416 |
"effective_status_on_success": env.get("EFFECTIVE_STATUS_ON_SUCCESS"),
|
|
|
|
|
|
|
| 417 |
"api_name": env["API_NAME"] or "<discover>",
|
| 418 |
"endpoint_discovery_required": env.get("ENDPOINT_DISCOVERY_REQUIRED") == "true",
|
| 419 |
"expected_output_type": env["EXPECTED_OUTPUT_TYPE"],
|
|
|
|
| 351 |
effective_status_on_success: str | None = None,
|
| 352 |
parent_replay_source_json: str | None = None,
|
| 353 |
validation_launch_payload_json: str | None = None,
|
| 354 |
+
expert_intervention_required: bool = False,
|
| 355 |
+
expert_intervention_note: str | None = None,
|
| 356 |
run_id: str | None = None,
|
| 357 |
bucket_name: str | None = None,
|
| 358 |
) -> dict[str, Any]:
|
|
|
|
| 384 |
env["VALIDATION_LINK_MODE"] = "build_run"
|
| 385 |
env["SPACE_TEST_POLICY_MODE"] = (validation_mode or "complete").strip()
|
| 386 |
env["EFFECTIVE_STATUS_ON_SUCCESS"] = (effective_status_on_success or "validated_after_manual_space_test").strip()
|
| 387 |
+
env["EXPERT_INTERVENTION_REQUIRED"] = "true" if expert_intervention_required else "false"
|
| 388 |
+
if expert_intervention_note:
|
| 389 |
+
env["EXPERT_INTERVENTION_NOTE"] = ensure_validation_payload_json_fits_env(expert_intervention_note, field_name="expert_intervention_note")
|
| 390 |
env["API_NAME"] = (api_name if api_name is not None else "/generate").strip()
|
| 391 |
env["ENDPOINT_DISCOVERY_REQUIRED"] = "true" if not env["API_NAME"] else "false"
|
| 392 |
env["TEST_ARGS_JSON"] = ensure_validation_payload_json_fits_env(test_args_json or '["a cinematic robot cat astronaut, detailed, studio lighting"]', field_name="test_args_json")
|
|
|
|
| 419 |
"linked_target_space": target,
|
| 420 |
"space_test_policy_mode": env.get("SPACE_TEST_POLICY_MODE"),
|
| 421 |
"effective_status_on_success": env.get("EFFECTIVE_STATUS_ON_SUCCESS"),
|
| 422 |
+
"expert_intervention_required": env.get("EXPERT_INTERVENTION_REQUIRED") == "true",
|
| 423 |
+
"expert_intervention_note_present": bool(env.get("EXPERT_INTERVENTION_NOTE")),
|
| 424 |
"api_name": env["API_NAME"] or "<discover>",
|
| 425 |
"endpoint_discovery_required": env.get("ENDPOINT_DISCOVERY_REQUIRED") == "true",
|
| 426 |
"expected_output_type": env["EXPECTED_OUTPUT_TYPE"],
|
src/target_space_identity.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import re
|
| 4 |
+
from typing import Any
|
| 5 |
+
|
| 6 |
+
TARGET_SPACE_OVERRIDE_FILENAME = "TARGET_SPACE_OVERRIDE.json"
|
| 7 |
+
TARGET_SPACE_OVERRIDE_CLEARED_STATUS = "cleared"
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def normalize_target_space_id(value: Any) -> str:
|
| 11 |
+
text = str(value or "").strip()
|
| 12 |
+
if not text or text == "—":
|
| 13 |
+
return ""
|
| 14 |
+
text = text.replace("https://huggingface.co/spaces/", "").strip("/")
|
| 15 |
+
text = text.split("/settings", 1)[0].strip("/")
|
| 16 |
+
text = text.split("?", 1)[0].split("#", 1)[0].strip("/")
|
| 17 |
+
if ".hf.space" in text and "/" not in text:
|
| 18 |
+
return ""
|
| 19 |
+
return text if re.match(r"^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$", text) else ""
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def _first_nonempty(*values: Any) -> str:
|
| 23 |
+
for value in values:
|
| 24 |
+
text = str(value or "").strip()
|
| 25 |
+
if text:
|
| 26 |
+
return text
|
| 27 |
+
return ""
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def _target_space_from_events(events: list[dict[str, Any]] | None, *, require_success: bool = False) -> str:
|
| 31 |
+
for event in reversed(events or []):
|
| 32 |
+
if not isinstance(event, dict):
|
| 33 |
+
continue
|
| 34 |
+
step = str(event.get("step") or "")
|
| 35 |
+
status = str(event.get("status") or "").lower()
|
| 36 |
+
if step not in {"create_space", "create_space_hardware", "upload_files", "runtime_upload_epoch"}:
|
| 37 |
+
continue
|
| 38 |
+
if require_success and status != "success":
|
| 39 |
+
continue
|
| 40 |
+
data = event.get("data") if isinstance(event.get("data"), dict) else {}
|
| 41 |
+
target = normalize_target_space_id(data.get("target_space") or data.get("target_space_id"))
|
| 42 |
+
if target:
|
| 43 |
+
return target
|
| 44 |
+
return ""
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def target_space_url(target_space_id: Any) -> str:
|
| 48 |
+
target = normalize_target_space_id(target_space_id)
|
| 49 |
+
return f"https://huggingface.co/spaces/{target}" if target else ""
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def active_target_space_override(bundle: dict[str, Any] | None) -> dict[str, Any]:
|
| 53 |
+
override = (bundle or {}).get("target_space_override") or {}
|
| 54 |
+
if not isinstance(override, dict):
|
| 55 |
+
return {}
|
| 56 |
+
if str(override.get("status") or "active").strip().lower() == TARGET_SPACE_OVERRIDE_CLEARED_STATUS:
|
| 57 |
+
return {}
|
| 58 |
+
target = normalize_target_space_id(override.get("target_space_id") or override.get("target_space"))
|
| 59 |
+
if not target:
|
| 60 |
+
return {}
|
| 61 |
+
return {**override, "target_space_id": target, "target_space": target, "target_space_url": target_space_url(target)}
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def original_target_space_from_bundle(bundle: dict[str, Any] | None) -> str:
|
| 65 |
+
bundle = bundle or {}
|
| 66 |
+
summary = bundle.get("summary") or bundle.get("summary_file") or {}
|
| 67 |
+
state = bundle.get("state") or {}
|
| 68 |
+
launch = bundle.get("launch") or {}
|
| 69 |
+
runtime_upload_epoch = bundle.get("runtime_upload_epoch") or {}
|
| 70 |
+
return normalize_target_space_id(_first_nonempty(
|
| 71 |
+
summary.get("target_space"), summary.get("target_space_id"),
|
| 72 |
+
state.get("target_space"), state.get("target_space_id"),
|
| 73 |
+
launch.get("target_space"), launch.get("target_space_id"),
|
| 74 |
+
runtime_upload_epoch.get("target_space_id"), runtime_upload_epoch.get("target_space"),
|
| 75 |
+
_target_space_from_events(bundle.get("events") or []),
|
| 76 |
+
))
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
def effective_target_space_from_bundle(bundle: dict[str, Any] | None) -> str:
|
| 80 |
+
override = active_target_space_override(bundle)
|
| 81 |
+
if override:
|
| 82 |
+
return normalize_target_space_id(override.get("target_space_id"))
|
| 83 |
+
return original_target_space_from_bundle(bundle)
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def target_space_identity_overlay(bundle: dict[str, Any] | None) -> dict[str, Any]:
|
| 87 |
+
original = original_target_space_from_bundle(bundle)
|
| 88 |
+
override = active_target_space_override(bundle)
|
| 89 |
+
effective = normalize_target_space_id(override.get("target_space_id") if override else original)
|
| 90 |
+
return {
|
| 91 |
+
"target_space": effective,
|
| 92 |
+
"target_space_id": effective,
|
| 93 |
+
"target_space_url": target_space_url(effective),
|
| 94 |
+
"target_space_settings_url": f"{target_space_url(effective)}/settings" if effective else "",
|
| 95 |
+
"target_space_original": original,
|
| 96 |
+
"target_space_original_url": target_space_url(original),
|
| 97 |
+
"target_space_override_active": bool(override),
|
| 98 |
+
"target_space_override": override,
|
| 99 |
+
"target_space_source": "manual_override" if override else "generated_run",
|
| 100 |
+
}
|
src/version.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
-
ASF_APP_VERSION = "v198.26.
|
| 4 |
-
ASF_RELEASE_NAME = "Agentic Space Factory v198.26.
|
| 5 |
|
| 6 |
|
| 7 |
def resolve_app_version(value: str | None = None) -> str:
|
|
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
+
ASF_APP_VERSION = "v198.26.121"
|
| 4 |
+
ASF_RELEASE_NAME = "Agentic Space Factory v198.26.121"
|
| 5 |
|
| 6 |
|
| 7 |
def resolve_app_version(value: str | None = None) -> str:
|
src/view_models.py
CHANGED
|
@@ -8,6 +8,7 @@ from .progress import STEP_ALIASES, STEP_LABELS, STEP_ORDER
|
|
| 8 |
from .timeline_model import build_run_timeline_model
|
| 9 |
from .config import settings
|
| 10 |
from .effective_status import compute_effective_run_status
|
|
|
|
| 11 |
|
| 12 |
PRODUCT_STEPS = [{"id": step, "label": STEP_LABELS[step]} for step in STEP_ORDER]
|
| 13 |
|
|
@@ -47,7 +48,7 @@ RUNNING_RAW_STATUSES = {"started", "running", "waiting", "queued", "pending", "s
|
|
| 47 |
AUTH_RAW_STATUSES = {"auth_refresh_required", "oauth_expired", "auth_expired", "repair_validation_inconclusive_auth", "inconclusive_auth_expired"}
|
| 48 |
|
| 49 |
AUTHORITATIVE_TERMINAL_SOURCE_KEYS = ("status", "final_status", "effective_status", "effective_verdict", "display_status", "verdict", "result_status", "validation_status", "post_repair_validation", "failure_type")
|
| 50 |
-
TERMINAL_DISPLAY_STATUSES = SUCCESS_RAW_STATUSES | PARTIAL_RAW_STATUSES | MANUAL_RAW_STATUSES | FAILED_RAW_STATUSES | CANCELLED_RAW_STATUSES | BLOCKED_RAW_STATUSES | AUTH_RAW_STATUSES | {"stale", "stopped", "succeeded", "validated_after_space_test", "validated_after_manual_space_test", "recovered_by_space_test", "recovered_by_manual_validation"}
|
| 51 |
|
| 52 |
STEP_TO_PHASE = {step: step for step in STEP_ORDER} | {alias: canonical for alias, canonical in STEP_ALIASES.items()}
|
| 53 |
|
|
@@ -545,6 +546,9 @@ def _space_target_from_events(events: list[dict[str, Any]] | None, *, require_su
|
|
| 545 |
|
| 546 |
|
| 547 |
def _space_target_from_bundle(bundle: dict[str, Any]) -> str:
|
|
|
|
|
|
|
|
|
|
| 548 |
summary = bundle.get("summary") or {}
|
| 549 |
state = bundle.get("state") or {}
|
| 550 |
launch = bundle.get("launch") or {}
|
|
@@ -564,6 +568,9 @@ def _space_target_from_bundle(bundle: dict[str, Any]) -> str:
|
|
| 564 |
|
| 565 |
|
| 566 |
def _space_target_url_from_bundle(bundle: dict[str, Any], target: str = "") -> str:
|
|
|
|
|
|
|
|
|
|
| 567 |
summary = bundle.get("summary") or {}
|
| 568 |
state = bundle.get("state") or {}
|
| 569 |
launch = bundle.get("launch") or {}
|
|
@@ -622,6 +629,9 @@ def build_space_link_state(bundle: dict[str, Any], *, target: str = "", target_u
|
|
| 622 |
"target_space_known": bool(target),
|
| 623 |
"target_space_url": target_url,
|
| 624 |
"target_space_settings_url": f"{target_url}/settings" if target_url else "",
|
|
|
|
|
|
|
|
|
|
| 625 |
"space_created": bool(space_created),
|
| 626 |
"runtime_uploaded": bool(runtime_uploaded),
|
| 627 |
"space_uploaded": bool(runtime_uploaded),
|
|
@@ -679,7 +689,7 @@ def _latest_successful_linked_validation(bundle: dict[str, Any]) -> dict[str, An
|
|
| 679 |
rows = linked.get("validations") if isinstance(linked, dict) else []
|
| 680 |
if not isinstance(rows, list):
|
| 681 |
return {}
|
| 682 |
-
successful = [row for row in rows if isinstance(row, dict) and _lower(row.get("status") or row.get("effective_status")) in {"success", "passed", "succeeded", "full_inference_success", "validated_after_space_test", "validated_after_manual_space_test"}]
|
| 683 |
if not successful:
|
| 684 |
return {}
|
| 685 |
successful.sort(key=lambda row: str(row.get("validated_at") or row.get("updated_at") or row.get("created_at") or ""), reverse=True)
|
|
|
|
| 8 |
from .timeline_model import build_run_timeline_model
|
| 9 |
from .config import settings
|
| 10 |
from .effective_status import compute_effective_run_status
|
| 11 |
+
from .target_space_identity import target_space_identity_overlay
|
| 12 |
|
| 13 |
PRODUCT_STEPS = [{"id": step, "label": STEP_LABELS[step]} for step in STEP_ORDER]
|
| 14 |
|
|
|
|
| 48 |
AUTH_RAW_STATUSES = {"auth_refresh_required", "oauth_expired", "auth_expired", "repair_validation_inconclusive_auth", "inconclusive_auth_expired"}
|
| 49 |
|
| 50 |
AUTHORITATIVE_TERMINAL_SOURCE_KEYS = ("status", "final_status", "effective_status", "effective_verdict", "display_status", "verdict", "result_status", "validation_status", "post_repair_validation", "failure_type")
|
| 51 |
+
TERMINAL_DISPLAY_STATUSES = SUCCESS_RAW_STATUSES | PARTIAL_RAW_STATUSES | MANUAL_RAW_STATUSES | FAILED_RAW_STATUSES | CANCELLED_RAW_STATUSES | BLOCKED_RAW_STATUSES | AUTH_RAW_STATUSES | {"stale", "stopped", "succeeded", "validated_after_space_test", "validated_after_manual_space_test", "success_with_expert_intervention", "expert_intervention_validation_passed", "recovered_by_space_test", "recovered_by_manual_validation"}
|
| 52 |
|
| 53 |
STEP_TO_PHASE = {step: step for step in STEP_ORDER} | {alias: canonical for alias, canonical in STEP_ALIASES.items()}
|
| 54 |
|
|
|
|
| 546 |
|
| 547 |
|
| 548 |
def _space_target_from_bundle(bundle: dict[str, Any]) -> str:
|
| 549 |
+
overlay = target_space_identity_overlay(bundle)
|
| 550 |
+
if overlay.get("target_space"):
|
| 551 |
+
return _normalize_target_space_id(overlay.get("target_space"))
|
| 552 |
summary = bundle.get("summary") or {}
|
| 553 |
state = bundle.get("state") or {}
|
| 554 |
launch = bundle.get("launch") or {}
|
|
|
|
| 568 |
|
| 569 |
|
| 570 |
def _space_target_url_from_bundle(bundle: dict[str, Any], target: str = "") -> str:
|
| 571 |
+
overlay = target_space_identity_overlay(bundle)
|
| 572 |
+
if overlay.get("target_space_url"):
|
| 573 |
+
return str(overlay.get("target_space_url"))
|
| 574 |
summary = bundle.get("summary") or {}
|
| 575 |
state = bundle.get("state") or {}
|
| 576 |
launch = bundle.get("launch") or {}
|
|
|
|
| 629 |
"target_space_known": bool(target),
|
| 630 |
"target_space_url": target_url,
|
| 631 |
"target_space_settings_url": f"{target_url}/settings" if target_url else "",
|
| 632 |
+
"target_space_original": target_space_identity_overlay(bundle).get("target_space_original") or "",
|
| 633 |
+
"target_space_override_active": bool(target_space_identity_overlay(bundle).get("target_space_override_active")),
|
| 634 |
+
"target_space_source": target_space_identity_overlay(bundle).get("target_space_source") or "generated_run",
|
| 635 |
"space_created": bool(space_created),
|
| 636 |
"runtime_uploaded": bool(runtime_uploaded),
|
| 637 |
"space_uploaded": bool(runtime_uploaded),
|
|
|
|
| 689 |
rows = linked.get("validations") if isinstance(linked, dict) else []
|
| 690 |
if not isinstance(rows, list):
|
| 691 |
return {}
|
| 692 |
+
successful = [row for row in rows if isinstance(row, dict) and _lower(row.get("status") or row.get("effective_status")) in {"success", "passed", "succeeded", "full_inference_success", "validated_after_space_test", "validated_after_manual_space_test", "success_with_expert_intervention", "expert_intervention_validation_passed"}]
|
| 693 |
if not successful:
|
| 694 |
return {}
|
| 695 |
successful.sort(key=lambda row: str(row.get("validated_at") or row.get("updated_at") or row.get("created_at") or ""), reverse=True)
|
src/worker_payload.py
CHANGED
|
@@ -40,8 +40,8 @@ DEFAULT_FALLBACK_SPACE_HARDWARE = "a10g-large"
|
|
| 40 |
DEFAULT_MODEL_ID = "sshleifer/tiny-gpt2"
|
| 41 |
MAX_PI_REPAIR_ATTEMPTS = 3
|
| 42 |
DEFAULT_FACTORY_UPLOAD_RETRY_BUDGET = 1
|
| 43 |
-
APP_VERSION = "v198.26.
|
| 44 |
-
app_version = "v198.26.
|
| 45 |
|
| 46 |
# Internal agent/recovery files may be needed inside the transient Pi
|
| 47 |
# workspace, but they should not be published to the generated Space or shown
|
|
@@ -144,6 +144,10 @@ RUNTIME_PAYLOAD_RELEASE_ARTIFACT_FILENAMES = {
|
|
| 144 |
"SMOKE_PRIMARY_ERROR.json",
|
| 145 |
"MEMORY_DIAGNOSIS_PACKET.json",
|
| 146 |
"RUNTIME_RISK_HINTS.json",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
}
|
| 148 |
|
| 149 |
|
|
@@ -510,7 +514,7 @@ def build_runtime_risk_hints(workspace: Path, run_dir: Path, events_path: Path,
|
|
| 510 |
)
|
| 511 |
|
| 512 |
payload = {
|
| 513 |
-
"schema_version": "runtime_risk_hints.
|
| 514 |
"mode": "advisory_only",
|
| 515 |
"reason": reason,
|
| 516 |
"auto_applied": False,
|
|
@@ -19607,7 +19611,7 @@ def smoke_generate(target_space_id: str, token: str, run_dir: Path, events_path:
|
|
| 19607 |
# write_json(run_dir / "tests" / "payload_source.json", payload_source_record)
|
| 19608 |
# write_json(run_dir / "tests" / "replay_source.json", replay_source)
|
| 19609 |
# write_json(run_dir / "tests" / "validation_preflight.json", validation_preflight)
|
| 19610 |
-
app_version = "v198.26.
|
| 19611 |
engine_version = "unified_gradio_validation_harness_v198_25_3"
|
| 19612 |
parent_build_run_id = os.environ.get("PARENT_BUILD_RUN_ID", "").strip()
|
| 19613 |
validation_mode = os.environ.get("VALIDATION_MODE") or os.environ.get("SPACE_TEST_POLICY_MODE") or "linked"
|
|
@@ -20042,12 +20046,14 @@ def main():
|
|
| 20042 |
output_root = Path(os.environ.get("OUTPUT_ROOT", "/output"))
|
| 20043 |
target_space_id = os.environ["TARGET_SPACE_ID"].strip()
|
| 20044 |
parent_build_run_id = os.environ.get("PARENT_BUILD_RUN_ID", "").strip()
|
|
|
|
|
|
|
| 20045 |
token = os.environ.get("HF_TOKEN")
|
| 20046 |
run_dir = output_root / "runs" / run_id
|
| 20047 |
events_path = run_dir / "events.jsonl"
|
| 20048 |
state_path = run_dir / "state.json"
|
| 20049 |
-
append_event(events_path, "bootstrap", "started", "Existing Space validation worker started", {"target_space_id": target_space_id})
|
| 20050 |
-
write_json(state_path, {"run_id": run_id, "kind": "linked_space_validation", "status": "running", "target_space": target_space_id, "parent_build_run_id": parent_build_run_id, "source_kind": "build_run_prefill", "created_by": username, "updated_at": now()})
|
| 20051 |
if not token:
|
| 20052 |
raise RuntimeError("HF_TOKEN is missing")
|
| 20053 |
ensure_hf_token_context(run_dir, events_path)
|
|
@@ -20073,6 +20079,8 @@ def main():
|
|
| 20073 |
"target_space_url": f"https://huggingface.co/spaces/{target_space_id}",
|
| 20074 |
"live_validation": live,
|
| 20075 |
"generation_smoke": smoke,
|
|
|
|
|
|
|
| 20076 |
"updated_at": now(),
|
| 20077 |
}
|
| 20078 |
final_state["parent_build_run_id"] = parent_build_run_id
|
|
@@ -20088,10 +20096,33 @@ def main():
|
|
| 20088 |
expected_output_type_used = smoke.get("expected_output_type") or os.environ.get("EXPECTED_OUTPUT_TYPE") or "any"
|
| 20089 |
effective_status_on_success = os.environ.get("EFFECTIVE_STATUS_ON_SUCCESS") or "validated_after_space_test"
|
| 20090 |
space_test_policy_mode = os.environ.get("SPACE_TEST_POLICY_MODE") or "complete"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20091 |
manual_status = {
|
| 20092 |
-
"schema_version": "post_build_validation.
|
| 20093 |
"status": "success",
|
| 20094 |
"effective_status": effective_status_on_success,
|
|
|
|
|
|
|
|
|
|
| 20095 |
"legacy_effective_status": "validated_after_manual_space_test",
|
| 20096 |
"space_test_policy_mode": space_test_policy_mode,
|
| 20097 |
"validation_run_id": run_id,
|
|
@@ -20108,6 +20139,8 @@ def main():
|
|
| 20108 |
"validated_at": now(),
|
| 20109 |
"applies_to_target_space": True,
|
| 20110 |
}
|
|
|
|
|
|
|
| 20111 |
write_json(parent_dir / "post_build_validation_status.json", manual_status)
|
| 20112 |
write_json(parent_dir / "manual_validation_status.json", manual_status)
|
| 20113 |
linked_path = parent_dir / "linked_validations.json"
|
|
@@ -20119,9 +20152,9 @@ def main():
|
|
| 20119 |
if not isinstance(validations, list):
|
| 20120 |
validations = []
|
| 20121 |
validations.append(manual_status)
|
| 20122 |
-
linked = {"parent_build_run_id": parent_build_run_id, "effective_status": effective_status_on_success, "validations": validations, "updated_at": now()}
|
| 20123 |
write_json(linked_path, linked)
|
| 20124 |
-
update_runs_index(parent_dir, {"run_id": parent_build_run_id, "manual_validation_passed": True, "post_build_status": effective_status_on_success, "effective_status": effective_status_on_success, "linked_validation_count": len(validations), "linked_validations_count": len(validations), "latency_seconds": manual_status.get("latency_seconds"), "observed_latency_seconds": manual_status.get("observed_latency_seconds"), "recommended_zero_gpu_duration_seconds": manual_status.get("recommended_zero_gpu_duration_seconds"), "recommendation_source": "linked_space_test", "recommendation_hardware": manual_status.get("recommendation_hardware"), "hardware_used_for_validation": manual_status.get("hardware_used_for_validation"), "updated_at": now()})
|
| 20125 |
report = f"""# Agentic Space Factory — Existing Space Validation Report
|
| 20126 |
|
| 20127 |
Status: **full_inference_success**
|
|
@@ -20161,14 +20194,14 @@ Target Space: [`{target_space_id}`](https://huggingface.co/spaces/{target_space_
|
|
| 20161 |
details["status_reason"] = "auth_refresh_required"
|
| 20162 |
details["failure_type"] = "auth_refresh_required"
|
| 20163 |
terminal_status = "auth_refresh_required" if auth_blocked else "failed"
|
| 20164 |
-
failure_state = {"run_id": run_id, "kind": "linked_space_validation", "status": terminal_status, "message": "HF OAuth token expired or will expire too soon; refresh sign-in before continuing" if auth_blocked else str(exc), "target_space": target_space_id, "parent_build_run_id": parent_build_run_id, "source_kind": "build_run_prefill", "details": details, "updated_at": now()}
|
| 20165 |
write_json(state_path, failure_state)
|
| 20166 |
write_final_summary(run_dir, failure_state, {}, {"status": terminal_status, "failure_type": details.get("failure_type", "linked_validation_failed") if isinstance(details, dict) else "linked_validation_failed"}, status=terminal_status, message=str(failure_state.get("message") or details.get("error", "Existing Space validation failed")) if isinstance(details, dict) else "Existing Space validation failed")
|
| 20167 |
append_event(events_path, "failure", "failed", "Existing Space validation failed; terminal state was written before log collection", details)
|
| 20168 |
if parent_build_run_id:
|
| 20169 |
parent_dir = output_root / "runs" / parent_build_run_id
|
| 20170 |
parent_dir.mkdir(parents=True, exist_ok=True)
|
| 20171 |
-
failed_status = {"schema_version": "post_build_validation.
|
| 20172 |
linked_path = parent_dir / "linked_validations.json"
|
| 20173 |
linked = read_json(linked_path, {"parent_build_run_id": parent_build_run_id, "validations": []}) or {"parent_build_run_id": parent_build_run_id, "validations": []}
|
| 20174 |
validations = linked.get("validations") if isinstance(linked, dict) else []
|
|
|
|
| 40 |
DEFAULT_MODEL_ID = "sshleifer/tiny-gpt2"
|
| 41 |
MAX_PI_REPAIR_ATTEMPTS = 3
|
| 42 |
DEFAULT_FACTORY_UPLOAD_RETRY_BUDGET = 1
|
| 43 |
+
APP_VERSION = "v198.26.121"
|
| 44 |
+
app_version = "v198.26.121"
|
| 45 |
|
| 46 |
# Internal agent/recovery files may be needed inside the transient Pi
|
| 47 |
# workspace, but they should not be published to the generated Space or shown
|
|
|
|
| 144 |
"SMOKE_PRIMARY_ERROR.json",
|
| 145 |
"MEMORY_DIAGNOSIS_PACKET.json",
|
| 146 |
"RUNTIME_RISK_HINTS.json",
|
| 147 |
+
"EXPERT_INTERVENTION_ACCEPTANCE.json",
|
| 148 |
+
"EXPERT_ACCEPTANCE_RESULT.json",
|
| 149 |
+
"TARGET_SPACE_OVERRIDE.json",
|
| 150 |
+
"TARGET_SPACE_ID_OVERRIDE.json",
|
| 151 |
}
|
| 152 |
|
| 153 |
|
|
|
|
| 514 |
)
|
| 515 |
|
| 516 |
payload = {
|
| 517 |
+
"schema_version": "runtime_risk_hints.v198_26_121",
|
| 518 |
"mode": "advisory_only",
|
| 519 |
"reason": reason,
|
| 520 |
"auto_applied": False,
|
|
|
|
| 19611 |
# write_json(run_dir / "tests" / "payload_source.json", payload_source_record)
|
| 19612 |
# write_json(run_dir / "tests" / "replay_source.json", replay_source)
|
| 19613 |
# write_json(run_dir / "tests" / "validation_preflight.json", validation_preflight)
|
| 19614 |
+
app_version = "v198.26.121"
|
| 19615 |
engine_version = "unified_gradio_validation_harness_v198_25_3"
|
| 19616 |
parent_build_run_id = os.environ.get("PARENT_BUILD_RUN_ID", "").strip()
|
| 19617 |
validation_mode = os.environ.get("VALIDATION_MODE") or os.environ.get("SPACE_TEST_POLICY_MODE") or "linked"
|
|
|
|
| 20046 |
output_root = Path(os.environ.get("OUTPUT_ROOT", "/output"))
|
| 20047 |
target_space_id = os.environ["TARGET_SPACE_ID"].strip()
|
| 20048 |
parent_build_run_id = os.environ.get("PARENT_BUILD_RUN_ID", "").strip()
|
| 20049 |
+
expert_intervention_required = str(os.environ.get("EXPERT_INTERVENTION_REQUIRED") or "").strip().lower() in {"1", "true", "yes", "on"}
|
| 20050 |
+
expert_intervention_note = (os.environ.get("EXPERT_INTERVENTION_NOTE") or "").strip()
|
| 20051 |
token = os.environ.get("HF_TOKEN")
|
| 20052 |
run_dir = output_root / "runs" / run_id
|
| 20053 |
events_path = run_dir / "events.jsonl"
|
| 20054 |
state_path = run_dir / "state.json"
|
| 20055 |
+
append_event(events_path, "bootstrap", "started", "Existing Space validation worker started", {"target_space_id": target_space_id, "expert_intervention_required": expert_intervention_required})
|
| 20056 |
+
write_json(state_path, {"run_id": run_id, "kind": "linked_space_validation", "status": "running", "target_space": target_space_id, "parent_build_run_id": parent_build_run_id, "source_kind": "build_run_prefill", "expert_intervention_required": expert_intervention_required, "created_by": username, "updated_at": now()})
|
| 20057 |
if not token:
|
| 20058 |
raise RuntimeError("HF_TOKEN is missing")
|
| 20059 |
ensure_hf_token_context(run_dir, events_path)
|
|
|
|
| 20079 |
"target_space_url": f"https://huggingface.co/spaces/{target_space_id}",
|
| 20080 |
"live_validation": live,
|
| 20081 |
"generation_smoke": smoke,
|
| 20082 |
+
"expert_intervention_required": expert_intervention_required,
|
| 20083 |
+
"expert_intervention_note_present": bool(expert_intervention_note),
|
| 20084 |
"updated_at": now(),
|
| 20085 |
}
|
| 20086 |
final_state["parent_build_run_id"] = parent_build_run_id
|
|
|
|
| 20096 |
expected_output_type_used = smoke.get("expected_output_type") or os.environ.get("EXPECTED_OUTPUT_TYPE") or "any"
|
| 20097 |
effective_status_on_success = os.environ.get("EFFECTIVE_STATUS_ON_SUCCESS") or "validated_after_space_test"
|
| 20098 |
space_test_policy_mode = os.environ.get("SPACE_TEST_POLICY_MODE") or "complete"
|
| 20099 |
+
expert_acceptance = None
|
| 20100 |
+
if expert_intervention_required:
|
| 20101 |
+
effective_status_on_success = "success_with_expert_intervention"
|
| 20102 |
+
expert_acceptance = {
|
| 20103 |
+
"schema_version": "expert_intervention_acceptance.v198_26_121",
|
| 20104 |
+
"status": "validated",
|
| 20105 |
+
"accepted_outcome": "success_with_expert_intervention",
|
| 20106 |
+
"expert_intervention_required": True,
|
| 20107 |
+
"expert_intervention_note": expert_intervention_note,
|
| 20108 |
+
"parent_build_run_id": parent_build_run_id,
|
| 20109 |
+
"validation_run_id": run_id,
|
| 20110 |
+
"target_space": target_space_id,
|
| 20111 |
+
"api_name": api_name_used,
|
| 20112 |
+
"expected_output_type": expected_output_type_used,
|
| 20113 |
+
"validation_status": "full_inference_success",
|
| 20114 |
+
"validated_at": now(),
|
| 20115 |
+
"raw_build_status_preserved": True,
|
| 20116 |
+
}
|
| 20117 |
+
write_json(run_dir / "EXPERT_INTERVENTION_ACCEPTANCE.json", expert_acceptance)
|
| 20118 |
+
write_json(parent_dir / "EXPERT_INTERVENTION_ACCEPTANCE.json", expert_acceptance)
|
| 20119 |
manual_status = {
|
| 20120 |
+
"schema_version": "post_build_validation.v198_26_121",
|
| 20121 |
"status": "success",
|
| 20122 |
"effective_status": effective_status_on_success,
|
| 20123 |
+
"expert_intervention_required": expert_intervention_required,
|
| 20124 |
+
"expert_intervention_note_present": bool(expert_intervention_note),
|
| 20125 |
+
"accepted_outcome": "success_with_expert_intervention" if expert_intervention_required else effective_status_on_success,
|
| 20126 |
"legacy_effective_status": "validated_after_manual_space_test",
|
| 20127 |
"space_test_policy_mode": space_test_policy_mode,
|
| 20128 |
"validation_run_id": run_id,
|
|
|
|
| 20139 |
"validated_at": now(),
|
| 20140 |
"applies_to_target_space": True,
|
| 20141 |
}
|
| 20142 |
+
if expert_acceptance:
|
| 20143 |
+
manual_status["expert_acceptance"] = {k: v for k, v in expert_acceptance.items() if k != "expert_intervention_note"}
|
| 20144 |
write_json(parent_dir / "post_build_validation_status.json", manual_status)
|
| 20145 |
write_json(parent_dir / "manual_validation_status.json", manual_status)
|
| 20146 |
linked_path = parent_dir / "linked_validations.json"
|
|
|
|
| 20152 |
if not isinstance(validations, list):
|
| 20153 |
validations = []
|
| 20154 |
validations.append(manual_status)
|
| 20155 |
+
linked = {"parent_build_run_id": parent_build_run_id, "effective_status": effective_status_on_success, "expert_intervention_required": expert_intervention_required, "validations": validations, "updated_at": now()}
|
| 20156 |
write_json(linked_path, linked)
|
| 20157 |
+
update_runs_index(parent_dir, {"run_id": parent_build_run_id, "manual_validation_passed": True, "expert_intervention_required": expert_intervention_required, "expert_acceptance_status": "validated" if expert_intervention_required else "none", "post_build_status": effective_status_on_success, "effective_status": effective_status_on_success, "linked_validation_count": len(validations), "linked_validations_count": len(validations), "latency_seconds": manual_status.get("latency_seconds"), "observed_latency_seconds": manual_status.get("observed_latency_seconds"), "recommended_zero_gpu_duration_seconds": manual_status.get("recommended_zero_gpu_duration_seconds"), "recommendation_source": "expert_intervention_acceptance" if expert_intervention_required else "linked_space_test", "recommendation_hardware": manual_status.get("recommendation_hardware"), "hardware_used_for_validation": manual_status.get("hardware_used_for_validation"), "updated_at": now()})
|
| 20158 |
report = f"""# Agentic Space Factory — Existing Space Validation Report
|
| 20159 |
|
| 20160 |
Status: **full_inference_success**
|
|
|
|
| 20194 |
details["status_reason"] = "auth_refresh_required"
|
| 20195 |
details["failure_type"] = "auth_refresh_required"
|
| 20196 |
terminal_status = "auth_refresh_required" if auth_blocked else "failed"
|
| 20197 |
+
failure_state = {"run_id": run_id, "kind": "linked_space_validation", "status": terminal_status, "message": "HF OAuth token expired or will expire too soon; refresh sign-in before continuing" if auth_blocked else str(exc), "target_space": target_space_id, "parent_build_run_id": parent_build_run_id, "source_kind": "build_run_prefill", "expert_intervention_required": expert_intervention_required, "details": details, "updated_at": now()}
|
| 20198 |
write_json(state_path, failure_state)
|
| 20199 |
write_final_summary(run_dir, failure_state, {}, {"status": terminal_status, "failure_type": details.get("failure_type", "linked_validation_failed") if isinstance(details, dict) else "linked_validation_failed"}, status=terminal_status, message=str(failure_state.get("message") or details.get("error", "Existing Space validation failed")) if isinstance(details, dict) else "Existing Space validation failed")
|
| 20200 |
append_event(events_path, "failure", "failed", "Existing Space validation failed; terminal state was written before log collection", details)
|
| 20201 |
if parent_build_run_id:
|
| 20202 |
parent_dir = output_root / "runs" / parent_build_run_id
|
| 20203 |
parent_dir.mkdir(parents=True, exist_ok=True)
|
| 20204 |
+
failed_status = {"schema_version": "post_build_validation.v198_26_121", "status": terminal_status, "validation_run_id": run_id, "parent_build_run_id": parent_build_run_id, "target_space": target_space_id, "expert_intervention_required": expert_intervention_required, "expert_acceptance_status": "validation_failed" if expert_intervention_required else "none", "details": details, "updated_at": now(), "effective_status": "unchanged"}
|
| 20205 |
linked_path = parent_dir / "linked_validations.json"
|
| 20206 |
linked = read_json(linked_path, {"parent_build_run_id": parent_build_run_id, "validations": []}) or {"parent_build_run_id": parent_build_run_id, "validations": []}
|
| 20207 |
validations = linked.get("validations") if isinstance(linked, dict) else []
|