7575INFRA_RETRIES = 1
7676#: A state write that fails with one of these waits for room instead of ending the run.
7777STORAGE_FULL = frozenset ({errno .EDQUOT , errno .ENOSPC })
78- #: How many stale checks run again, in the contract's order, beside running work each
79- #: time the target changes; the rest wait for the graph to run out of work.
80- RECHECKS_WHILE_BUSY = 4
8178#: Agent slots a campaign's turns may take at once while the onboarding has work open.
8279CAMPAIGN_SLOTS_BESIDE_ONBOARDING = 2
8380#: How long a task thread waiting on its soft dependencies sleeps between looks,
@@ -271,8 +268,6 @@ def __init__(
271268 ) -> None :
272269 self .s = services
273270 self .contract = contract
274- #: The full benchmarks, which run again at milestones only (:meth:`_settle`).
275- self ._accuracy_keys = {c .key for c in contract .checks if c .gate .startswith ("accuracy[" )}
276271 #: State writes a full filesystem refused, by what they write: each is tried
277272 #: again as the loop goes round, and nothing new starts until all have landed.
278273 self ._unwritten : dict [str , Callable [[], None ]] = {}
@@ -309,7 +304,7 @@ def __init__(
309304 #: How many worker runs one task gets (``graph.apply_revision``).
310305 self .max_attempts = max (1 , max_attempts )
311306 self .max_parallel = max_parallel
312- #: Checks running at once, across every task and the re-checks of an idle run .
307+ #: Checks running at once, across every task and the final round .
313308 self .max_parallel_checks = max (1 , max_parallel_checks )
314309 #: How long the loop waits between looks while ready work waits for devices.
315310 self .poll_s = poll_s
@@ -383,11 +378,6 @@ def __init__(
383378 #: The delivery files that last kept a holding contract from full support, per
384379 #: marker, as the planner heard them.
385380 self ._files_said : tuple [str , tuple [str , ...]] | None = None
386- #: The target's marker and the landing the last re-checks beside running work
387- #: were chosen on.
388- self ._rechecked_at : tuple [str , str ] | None = None
389- #: Delivery-tier checks rehearsed in this process.
390- self ._rehearsed : set [str ] = set ()
391381 #: The task threads in flight, by task id, as the loop drives them.
392382 self ._running : dict [str , Future ] = {}
393383 #: The campaign whose end the loop had not recorded when :meth:`run` returned the
@@ -415,12 +405,9 @@ def __init__(
415405 self ._foreground_demand = 0
416406 #: When each ready task was first seen ready, for the order they start in.
417407 self ._ready_since : dict [str , float ] = {}
418- #: Re-checks of an idle run in flight: what the planner is told if one fails, and the checks.
408+ #: The final round's checks in flight (:meth:`_settle`): what the planner is told if
409+ #: one fails, and the checks.
419410 self ._settling : tuple [str , list [tuple [str , Future ]]] | None = None
420- #: The task whose change landed on the target last, in this process, and the
421- #: target's marker just after it.
422- self ._landed : graph_mod .Task | None = None
423- self ._landed_marker = ""
424411 self ._check_pool : ThreadPoolExecutor | None = None
425412 #: Checks passing on the target when progress was last measured.
426413 self ._passed_seen = len (self ._evaluated ()[1 ].passed )
@@ -597,7 +584,7 @@ def _run_task(self, task: graph_mod.Task) -> tuple[str, list[str]]:
597584 return decision , self ._run_checks (k for k in task .satisfies if k not in delivery )
598585 except ChecksRaised as exc :
599586 # The work stands and has landed; only these checks' outcome is unknown.
600- # They are missing on the target, so they run again as re-checks .
587+ # They are missing on the target, so the final round runs them again .
601588 self ._inconclusive [task .id ] = str (exc )
602589 return decision , exc .failed
603590 finally :
@@ -650,10 +637,6 @@ def mark_integrated(self, task_id: str, attempt: int) -> None:
650637 """``task_id``'s commits are on the target: the tasks that soft-depend on it may go on."""
651638 with self ._ended :
652639 self ._integrated [task_id ] = attempt
653- task = self .graph .by_id ().get (task_id )
654- if task is not None :
655- # What landed last: stale checks run again beside the work once per landing.
656- self ._landed , self ._landed_marker = task , self .s .marker ()
657640 self ._ended .notify_all ()
658641
659642 def _evaluated (self ) -> tuple [str , contract_mod .Evaluation ]:
@@ -838,84 +821,40 @@ def _foreground(self, running: Mapping[str, Future]) -> list[str]:
838821 kinds = {t .id : t .kind for t in self .graph .tasks }
839822 return [task_id for task_id in running if kinds .get (task_id ) not in BACKGROUND_KINDS ]
840823
841- def _settle (self , busy : bool = False ) -> None :
842- """Keep the target verified as it changes; then, with no required task open, the delivery tier.
843-
844- ``busy``, with foreground work running: each time a change lands, the
845- first :data:`RECHECKS_WHILE_BUSY` stale checks in the contract's order
846- run again beside it, and the delivery tier of a member whose other
847- checks all hold is rehearsed once (:meth:`_rehearsal`). Otherwise every
848- stale check runs again; and once every other required check holds and
849- no required task is open but a campaign, the delivery tier runs on the
850- target as it is. Both run on the check pool; :meth:`_settled` reads the
851- verdicts once they are all in, and tells the planner what failed.
852-
853- A stale accuracy check runs again at a milestone only: once no required
854- task is open, or for the bring-up before it was named. Until then the
855- cheaper checks of each landing (the boots) stand watch.
824+ def _settle (self ) -> None :
825+ """Re-certify the final tree: once no required task is open, each claimed check stale on it.
826+
827+ While required work is open nothing runs here: a task's claimed checks
828+ run as it lands (:meth:`_run_task`), and the planner adds a ``check``
829+ task for whatever a change may have broken. Once no required task is
830+ open but a campaign (it changes nothing a check measures), every
831+ required check a done task claims and with no verdict on the target as
832+ it is runs again; then, once every other required check holds, the
833+ delivery tier runs on the target as it is. A check that failed on this
834+ very target stays failed until the target changes; running it again
835+ would measure the same thing. The checks run on the check pool;
836+ :meth:`_settled` reads the verdicts once they are all in, and tells the
837+ planner what failed.
856838 """
839+ if self ._required_open (campaign = False ):
840+ return
857841 claimed = {k for t in self .graph .tasks if t .status == "done" for k in t .satisfies }
858842 delivery = self ._delivery_keys ()
859- marker , evaluation = self ._evaluated ()
860- stale = [c .key for c in evaluation .missing if c .key in claimed and c .key not in delivery ]
861- if self ._required_open (campaign = False ):
862- bringup = (
863- {c .key for c in contract_mod .bringup_checks (self .contract )}
864- if contract_mod .bringup_milestone (self .workspace ) is None
865- else set ()
866- )
867- stale = [k for k in stale if k not in self ._accuracy_keys or k in bringup ]
868- if busy or (not stale and self ._required_open (campaign = False )):
869- keys : list [str ] = []
870- # Once per landing the loop knows made the target what it is.
871- landed = (marker , self ._landed .id if self ._landed is not None else "" )
872- known = self ._landed is not None and self ._landed_marker == marker
873- if stale and known and landed != self ._rechecked_at :
874- self ._rechecked_at = landed
875- keys = stale [:RECHECKS_WHILE_BUSY ]
876- keys += self ._rehearsal (evaluation )
877- what = "checks run beside the work in flight failed on the current target: "
878- else :
879- what , keys = (
880- "checks that held before failed on the current target: " ,
881- stale ,
882- )
883- if not stale :
884- # A check that already failed on this very target stays failed until
885- # the target changes; running it again would measure the same thing.
886- missing = {c .key for c in evaluation .missing }
887- failed_here = {c .key for c , _ in evaluation .failed }
888- if not missing or not (missing | failed_here ) <= delivery :
889- return
890- what , keys = "delivery checks failed: " , sorted (missing )
891- submitted = self ._submit_checks (self ._check_pool , keys ) if keys else []
843+ _ , evaluation = self ._evaluated ()
844+ missing = {c .key for c in evaluation .missing }
845+ what , keys = (
846+ "checks re-run on the final tree failed: " ,
847+ [c .key for c in evaluation .missing if c .key in claimed and c .key not in delivery ],
848+ )
849+ if not keys :
850+ failed_here = {c .key for c , _ in evaluation .failed }
851+ if not missing or not (missing | failed_here ) <= delivery :
852+ return
853+ what , keys = "delivery checks failed: " , sorted (missing )
854+ submitted = self ._submit_checks (self ._check_pool , keys )
892855 if submitted :
893856 self ._settling = (what , submitted )
894857
895- def _rehearsal (self , evaluation : contract_mod .Evaluation ) -> list [str ]:
896- """Delivery-tier checks to rehearse now, each once: those whose member is otherwise green.
897-
898- A member whose every other required check passed on the target as it
899- is gets its delivery-tier checks run once, ahead of the final tree,
900- as advisory: a failure reaches the planner, and the final tree runs
901- them again whatever they found.
902- """
903- passed = {c .key for c in evaluation .passed }
904- required = self .contract .required ()
905- due = []
906- for check in self .contract .by_tier (contract_mod .TIER_DELIVERY ):
907- if check .key in self ._rehearsed or check .key in passed :
908- continue
909- before = [
910- c
911- for c in required
912- if c .member == check .member and c .tier != contract_mod .TIER_DELIVERY
913- ]
914- if before and all (c .key in passed for c in before ):
915- self ._rehearsed .add (check .key )
916- due .append (check .key )
917- return due
918-
919858 def _settled (self ) -> None :
920859 what , submitted = self ._settling
921860 self ._settling = None
@@ -924,7 +863,7 @@ def _settled(self) -> None:
924863 except ChecksRaised as exc :
925864 # No verdict was recorded for these: they are still due and run again.
926865 failed = exc .failed
927- self .s .log (f"[settle] re- checks raised, to run again: { exc } " )
866+ self .s .log (f"[settle] final-round checks raised, to run again: { exc } " )
928867 if failed :
929868 self ._note (what + ", " .join (failed ), urgent = True )
930869 self ._save_events ()
@@ -1226,7 +1165,6 @@ def _finish(self, task: graph_mod.Task, decision: str, failed: list[str]) -> Non
12261165 task .status = "failed" if failed else "done"
12271166 if task .kind in INTEGRATED_KINDS :
12281167 # Integrated before its checks ran, whatever they found.
1229- self ._landed , self ._landed_marker = task , self .s .marker ()
12301168 self ._landings [task .id ] = (time .time (), task .attempts )
12311169 unknown = self ._inconclusive .pop (task .id , "" )
12321170 self ._note (
@@ -1235,7 +1173,8 @@ def _finish(self, task: graph_mod.Task, decision: str, failed: list[str]) -> Non
12351173 else f"task { task .id } ({ task .kind } ) { decision } ; "
12361174 + (f"checks failed: { ', ' .join (failed )} " if failed else "its checks passed" )
12371175 + (
1238- f"; some checks could not run ({ unknown } ): they run again as re-checks"
1176+ f"; some checks could not run ({ unknown } ): a `check` task runs them, "
1177+ "or the final round does"
12391178 if unknown
12401179 else ""
12411180 ),
@@ -1409,10 +1348,10 @@ def _start_check_task(self, task: graph_mod.Task) -> Future:
14091348 No agent turn runs and no task slot is taken: its checks wait for
14101349 devices on the check pool as every check does.
14111350 The future holds what a worker's thread returns, :data:`CHECKED` and
1412- the keys that failed, once every check is in. Its delivery-tier checks
1413- wait for the delivery tier, as any task's do. A regression check runs
1414- the package tests instead (``Services.regression``), and what failed is
1415- named the same way.
1351+ the keys that failed, once every check is in. A delivery-tier check it
1352+ names runs now too: the planner may rehearse delivery before the final
1353+ round. A regression check runs the package tests instead
1354+ (``Services.regression``), and what failed is named the same way.
14161355 """
14171356 if task .regression :
14181357 outcome = Future ()
@@ -1429,10 +1368,7 @@ def tests_in(done: Future) -> None:
14291368
14301369 ran .add_done_callback (tests_in )
14311370 return outcome
1432- delivery = self ._delivery_keys ()
1433- submitted = self ._submit_checks (
1434- self ._check_pool , [k for k in task .satisfies if k not in delivery ]
1435- )
1371+ submitted = self ._submit_checks (self ._check_pool , task .satisfies )
14361372 outcome : Future = Future ()
14371373 if not submitted :
14381374 outcome .set_result ((CHECKED , []))
@@ -1906,11 +1842,9 @@ def _drive(self, tasks: ThreadPoolExecutor, planner: ThreadPoolExecutor) -> str:
19061842 ]
19071843 )
19081844 )
1909- # The target is kept verified as it changes: beside foreground work the
1910- # riskiest stale checks and the delivery rehearsals, and once only a
1911- # campaign runs (it changes nothing a check measures) the rest.
1845+ # Once no required task is open, the final tree is re-certified.
19121846 if self ._settling is None :
1913- self ._settle (busy = bool ( self . _foreground ( running )) )
1847+ self ._settle ()
19141848 # Nothing in flight but a campaign is nothing in flight: the onboarding
19151849 # decides, delivers and escalates without waiting for one, which goes on
19161850 # past it as the tune stage (:attr:`campaign`).
@@ -2007,11 +1941,11 @@ def _wait(self, running: dict[str, Future], timeout: float | None) -> None:
20071941 wait ([* in_flight , self ._stop ], timeout = timeout , return_when = FIRST_COMPLETED )
20081942
20091943 def _in_flight (self , running : dict [str , Future ]) -> list [Future ]:
2010- """The tasks, re- checks and planner turn in flight, as futures to wait on.
1944+ """The tasks, the final round's checks and planner turn in flight, as futures to wait on.
20111945
20121946 A task or planner turn that ended since the loop looked
2013- ends the wait at once, and is recorded. A batch of re- checks is read
2014- once all of it is in, so until then only its members still out are
1947+ ends the wait at once, and is recorded. The final round's checks are
1948+ read once all of them are in, so until then only those still out are
20151949 waited on: one already in would end every wait at once.
20161950 """
20171951 in_flight = list (running .values ())
0 commit comments