@@ -578,6 +578,7 @@ def _optimize_dependency(
578578 attempted_versions : list [str ] = []
579579 attempts : list [DependencyAttempt ] = []
580580
581+ # Establish a validated baseline before searching for lower acceptable bounds.
581582 baseline_version = dependency .lower_version
582583 attempted_versions .append (str (baseline_version ))
583584 print (f"[cyan]{ package_label } :: { dependency .name } :: baseline current_lower [{ baseline_version } ] [/cyan]" )
@@ -637,6 +638,7 @@ def _optimize_dependency(
637638 skipped_reason = "No lower candidate bounds found within allowed boundary." ,
638639 )
639640
641+ # Probe older bounds with a binary-search-style loop: keep successful tighter lowers, revert failures.
640642 low = 0
641643 high = len (candidates ) - 1
642644 while low <= high :
@@ -710,6 +712,7 @@ def _process_package(
710712 skipped = ["No check/test task combination found." ],
711713 )
712714
715+ # Build the per-package optimization target set from eligible bounded dependency specifications.
713716 targets , skipped = _collect_targets (pyproject_file , dependency_filters = dependency_filters )
714717 if not targets :
715718 return PackageOutcome (
@@ -758,6 +761,7 @@ def _process_package(
758761 if candidate .exists ():
759762 temp_internal_editables .append (candidate )
760763
764+ # Execute lower-bound trials per dependency and accumulate final replacement strings for persistence.
761765 dependency_results : list [DependencyOutcome ] = []
762766 replacements : dict [str , str ] = {}
763767 package_label = f"{ plan .project_path } ({ plan .package_name } )"
@@ -893,6 +897,7 @@ def main() -> None:
893897 dependency_filters = {name .lower () for name in args .dependencies } if args .dependencies else None
894898 output_json_path = (workspace_root / args .output_json ).resolve ()
895899
900+ # Phase 1: prepare shared workspace metadata and collect package execution plans.
896901 package_map = _build_workspace_package_map (workspace_root )
897902 internal_graph = _build_internal_graph (workspace_root , package_map )
898903 lock_versions = _load_lock_versions (workspace_root )
@@ -927,6 +932,7 @@ def main() -> None:
927932 print ("[yellow]No packages matched the selection.[/yellow]" )
928933 return
929934
935+ # Phase 2: initialize incremental report state before running package validations in parallel.
930936 report : dict = {
931937 "started_at" : _utc_now (),
932938 "workspace_root" : str (workspace_root ),
@@ -978,6 +984,7 @@ def main() -> None:
978984 if outcome .changed and not args .dry_run :
979985 _apply_package_replacements (plan .pyproject_path , outcome .replacements )
980986
987+ # Phase 3: aggregate outcomes, persist incremental JSON snapshots, and emit per-package progress.
981988 report ["packages" ].append (_to_json (outcome ))
982989 report ["summary" ]["packages_changed" ] = sum (1 for value in package_outcomes if value .changed )
983990 report ["summary" ]["dependencies_changed" ] = sum (
0 commit comments