MCPcopy Create free account
hub / github.com/RightNow-AI/autokernel / cmd_next

Function cmd_next

orchestrate.py:414–457  ·  view source on GitHub ↗

Determine which kernel to optimize next and print the decision.

(state: dict)

Source from the content-addressed store, hash-verified

412
413
414def cmd_next(state: dict) -> None:
415 """Determine which kernel to optimize next and print the decision."""
416 kernels = state["kernels"]
417 idx = state.get("current_kernel_idx", 0)
418
419 # All done?
420 all_done = all(k["status"] in (STATUS_DONE, STATUS_SKIPPED) for k in kernels)
421 if all_done:
422 print("All kernels optimized. Run verify.py for end-to-end check.")
423 return
424
425 current = kernels[idx] if idx < len(kernels) else None
426 if current is None or current["status"] in (STATUS_DONE, STATUS_SKIPPED):
427 # Current is already finished; find next pending
428 next_idx = _find_next_pending(kernels, -1)
429 if next_idx is None:
430 print("All kernels optimized. Run verify.py for end-to-end check.")
431 return
432 _transition_to(state, next_idx)
433 save_state(state)
434 _print_next_decision(state, kernels[next_idx], "Previous kernel already finished")
435 return
436
437 # Evaluate move-on criteria for the current kernel
438 should_move, reason = _should_move_on(current)
439 if should_move:
440 current["status"] = STATUS_DONE
441 next_idx = _find_next_pending(kernels, idx)
442 if next_idx is None:
443 print(f"Kernel {Path(current['file']).name} done ({reason}).")
444 print("All kernels optimized. Run verify.py for end-to-end check.")
445 save_state(state)
446 return
447 _transition_to(state, next_idx)
448 save_state(state)
449 _print_next_decision(state, kernels[next_idx], reason)
450 else:
451 # Continue current
452 kname = Path(current["file"]).name
453 print(f"DECISION: Continue optimizing {kname}")
454 print(f" Reason: {reason}")
455 print(f" Rank {current['rank']} | {current['op_type']} | "
456 f"{current['experiments_run']} experiments | "
457 f"speedup {current['speedup'] or 'N/A'}")
458
459
460def _transition_to(state: dict, next_idx: int) -> None:

Callers 1

mainFunction · 0.85

Calls 5

_find_next_pendingFunction · 0.85
_transition_toFunction · 0.85
save_stateFunction · 0.85
_print_next_decisionFunction · 0.85
_should_move_onFunction · 0.85

Tested by

no test coverage detected