|
13 | 13 | cached_goal_run_index_is_current, |
14 | 14 | load_status_projection_cache, |
15 | 15 | resolve_status_projection_cache_runtime_root, |
| 16 | + status_projection_cache_metadata, |
16 | 17 | write_status_projection_cache, |
17 | 18 | ) |
18 | 19 | from ..control_plane.scheduler.execution_context import ( |
@@ -362,21 +363,49 @@ def prepare_quota_command_context( |
362 | 363 | available_capabilities=args.available_capabilities, |
363 | 364 | agent_lane_id=args.agent_id, |
364 | 365 | include_presentation_projections=False, |
| 366 | + # A scheduler ACK/failure return writes cadence, not settlement |
| 367 | + # facts. One damaged audit row must not fail the whole status read |
| 368 | + # before the tolerant native fence can answer it. |
| 369 | + tolerate_malformed_settlement_history=( |
| 370 | + command in QUOTA_SCHEDULER_FOLLOWUP_COMMANDS |
| 371 | + ), |
365 | 372 | ) |
366 | 373 | preview = command == "should-run" and getattr(args, "dry_run", False) |
367 | 374 | if not preview and bool(getattr(args, "write_projection_cache", False)): |
368 | | - cache_metadata = write_status_projection_cache( |
369 | | - registry_path=registry_path, |
370 | | - runtime_root=runtime_root, |
371 | | - limit=status_limit, |
372 | | - include_task_graph=False, |
373 | | - goal_id=status_goal_id, |
374 | | - payload=status_payload, |
375 | | - max_age_seconds=projection_cache_ttl_seconds, |
376 | | - available_capabilities=args.available_capabilities, |
377 | | - agent_lane_id=args.agent_id, |
378 | | - include_presentation_projections=False, |
379 | | - ) |
| 375 | + if command in QUOTA_SCHEDULER_FOLLOWUP_COMMANDS: |
| 376 | + # The follow-up collector tolerates malformed history so a |
| 377 | + # valid scheduler return can still be recorded. That partial |
| 378 | + # view must never become the cache consumed by strict status |
| 379 | + # readers under the same key. |
| 380 | + cache_metadata = status_projection_cache_metadata( |
| 381 | + registry_path=registry_path, |
| 382 | + runtime_root=runtime_root, |
| 383 | + limit=status_limit, |
| 384 | + include_task_graph=False, |
| 385 | + goal_id=status_goal_id, |
| 386 | + max_age_seconds=projection_cache_ttl_seconds, |
| 387 | + available_capabilities=args.available_capabilities, |
| 388 | + agent_lane_id=args.agent_id, |
| 389 | + include_presentation_projections=False, |
| 390 | + ) |
| 391 | + cache_metadata.update({ |
| 392 | + "hit": False, |
| 393 | + "written": False, |
| 394 | + "skipped_reason": "tolerant_scheduler_followup_view", |
| 395 | + }) |
| 396 | + else: |
| 397 | + cache_metadata = write_status_projection_cache( |
| 398 | + registry_path=registry_path, |
| 399 | + runtime_root=runtime_root, |
| 400 | + limit=status_limit, |
| 401 | + include_task_graph=False, |
| 402 | + goal_id=status_goal_id, |
| 403 | + payload=status_payload, |
| 404 | + max_age_seconds=projection_cache_ttl_seconds, |
| 405 | + available_capabilities=args.available_capabilities, |
| 406 | + agent_lane_id=args.agent_id, |
| 407 | + include_presentation_projections=False, |
| 408 | + ) |
380 | 409 | elif isinstance(status_payload.get("projection_cache"), dict): |
381 | 410 | cache_metadata = dict(status_payload["projection_cache"]) |
382 | 411 |
|
|
0 commit comments