yuqi1129 commented on code in PR #14990:
URL: https://github.com/apache/gravitino/pull/14990#discussion_r4594869602


##########
.github/scripts/fork-ci-status.cjs:
##########
@@ -60,29 +60,66 @@ const MISSING_WORKFLOW = 'Your fork has no Fork CI 
workflow, so pushes to this b
   'Merge or rebase the branch onto the latest base branch, which adds 
.github/workflows/fork-ci.yml, ' +
   'make sure Actions are enabled in your fork, and push again.';
 const requiredAction = note => ({ status: 'completed', conclusion: 
'action_required',
-  title: 'Fork CI needs attention', note });
+  title: NEEDS_ATTENTION, note });
+
+function incompleteAttempt(run, jobs) {
+  if (jobs.some(job => job.run_attempt > run.run_attempt)) {
+    return requiredAction('The jobs API reports a newer attempt than the run 
listing. ' +
+      'Waiting for consistent results; the publisher will automatically check 
again.');
+  }
+  // A completed rerun must expose at least one job from that attempt. 
Otherwise all
+  // retained successes (and auxiliary cancellations) could belong to the 
previous run.
+  if (run.status === 'completed' && run.run_attempt > 1 &&
+      !jobs.some(job => job.run_attempt === run.run_attempt)) {

Review Comment:
   Fixed in 93e2cf55f0. An arbitrary current job is no longer sufficient. A 
matching successful gate cannot cover newer prerequisite/suite jobs, and 
overriding an unsuccessful aggregate after a rerun requires the gate from that 
current attempt. Incomplete evidence stays retryable.
   
   Added fork/trusted × changed/unchanged × aggregate × current-job-visibility 
coverage, plus scheduled tests for eligibility-only snapshots followed by 
either downstream cancellation or successful recovery. A watcher-only rerun 
with an unsuccessful aggregate and an older gate intentionally remains 
non-green until Required CI is rerun; that conservative boundary is documented. 
Successful watcher-only reruns remain supported.
   
   The new sandbox validation uses real current eligibility over captured 
previous successful jobs, verifies error/retry without duplicate statuses, then 
reveals the actual current gate/downstream jobs and recovers.



##########
.github/scripts/fork-ci-status.cjs:
##########
@@ -60,29 +60,66 @@ const MISSING_WORKFLOW = 'Your fork has no Fork CI 
workflow, so pushes to this b
   'Merge or rebase the branch onto the latest base branch, which adds 
.github/workflows/fork-ci.yml, ' +
   'make sure Actions are enabled in your fork, and push again.';
 const requiredAction = note => ({ status: 'completed', conclusion: 
'action_required',
-  title: 'Fork CI needs attention', note });
+  title: NEEDS_ATTENTION, note });
+
+function incompleteAttempt(run, jobs) {
+  if (jobs.some(job => job.run_attempt > run.run_attempt)) {
+    return requiredAction('The jobs API reports a newer attempt than the run 
listing. ' +
+      'Waiting for consistent results; the publisher will automatically check 
again.');
+  }
+  // A completed rerun must expose at least one job from that attempt. 
Otherwise all
+  // retained successes (and auxiliary cancellations) could belong to the 
previous run.
+  if (run.status === 'completed' && run.run_attempt > 1 &&
+      !jobs.some(job => job.run_attempt === run.run_attempt)) {
+    return requiredAction('The jobs API has not reported the completed current 
attempt yet. ' +
+      'Waiting for consistent results; the publisher will automatically check 
again.');
+  }
+}
 
 function evaluateExecution(pr, run, jobs, baseSha) {
+  const incomplete = incompleteAttempt(run, jobs);
+  if (incomplete) return incomplete;
   const required = jobs.find(job => job.name === requiredName(pr, baseSha));
   if (run.status !== 'completed') {
     // A workflow can remain queued while some of its matrix jobs already have 
runners.
     const running = run.status === 'in_progress' || jobs.some(job => 
job.status === 'in_progress');
     return { status: running ? 'in_progress' : 'queued',
       title: running ? 'Fork CI is running' : 'Fork CI is queued, waiting for 
a runner' };
   }
-  const failed = jobs.filter(job => job.name !== FAIL_FAST && ['failure', 
'timed_out'].includes(job.conclusion))
+  // A nonmatching summary is obsolete only when it is provably from an older 
attempt.
+  // A newer (possibly unexpanded) summary must not reuse an earlier exact 
success.
+  const otherSummary = job => job.name.startsWith('Required CI / ') && job !== 
required;
+  const obsoleteSummary = job => otherSummary(job) && required &&
+    Number.isInteger(job.run_attempt) && job.run_attempt > 0 &&
+    Number.isInteger(required.run_attempt) && required.run_attempt > 
job.run_attempt;
+  if (jobs.some(job => otherSummary(job) && !obsoleteSummary(job))) {
+    return requiredAction('A Required CI record from the same, newer or 
unknown attempt does not match ' +
+      'this head and base. Rerun Required CI for the current context before 
publishing success.');
+  }
+  const isAuxiliary = job => job.name === FAIL_FAST || obsoleteSummary(job);
+  const currentJobs = jobs.filter(job => !isAuxiliary(job));
+  const failed = currentJobs.filter(job => ['failure', 
'timed_out'].includes(job.conclusion))
     .map(job => job.name);
-  // A run that failed only because of the watcher is judged by its suites 
below.
-  const watcherOnly = run.conclusion === 'failure' && !failed.length &&
-    jobs.some(job => job.name === FAIL_FAST && ['failure', 
'timed_out'].includes(job.conclusion));
-  if (run.conclusion !== 'success' && !watcherOnly) {
-    // Fork CI cancels its own run on the first failed job, so report that 
job, not the cancellation.
-    if (failed.length) return { status: 'completed', conclusion: 'failure',
-      title: `Failed: ${failed[0]}${failed.length > 1 ? ` (+${failed.length - 
1} more)` : ''}`.slice(0, 200) };
+  // Partial reruns can retain a cancelled watcher or an obsolete Required CI 
job, keeping
+  // the whole run cancelled after its suites recover. Ignore only those 
auxiliary results,
+  // then verify the exact Required CI and all required suites below. Any 
other unfinished
+  // or unsuccessful job still blocks.
+  const auxiliaryOnly = ['failure', 'timed_out', 
'cancelled'].includes(run.conclusion) &&
+    jobs.some(job => isAuxiliary(job) && ['failure', 'timed_out', 
'cancelled'].includes(job.conclusion)) &&
+    currentJobs.every(job => ['success', 'skipped'].includes(job.conclusion));
+  // Run and job metadata are separate API snapshots. Even a successful 
aggregate must
+  // not hide a failed prerequisite or suite observed in the jobs response.
+  if (failed.length) return { status: 'completed', conclusion: 'failure',

Review Comment:
   Fixed in 93e2cf55f0. Previous-attempt unsuccessful jobs are now classified 
as retryable attention rather than settled failure. Current failures remain 
visible. The same handling covers old timeout/cancellation/unfinished records 
and current unfinished results.
   
   Scheduled-publisher regressions expose the old result first, then the 
replacement success without changing run ID/attempt, for successful/cancelled 
aggregates and changed/unchanged definitions. They assert additional jobs reads 
while incomplete, recovery, and restoration of the settled-success probe. 
Sandbox fault injection also hides the live replacement backend behind its 
captured attempt-1 failure and verifies automatic recovery.



##########
.github/scripts/fork-ci-status.cjs:
##########
@@ -60,29 +60,66 @@ const MISSING_WORKFLOW = 'Your fork has no Fork CI 
workflow, so pushes to this b
   'Merge or rebase the branch onto the latest base branch, which adds 
.github/workflows/fork-ci.yml, ' +
   'make sure Actions are enabled in your fork, and push again.';
 const requiredAction = note => ({ status: 'completed', conclusion: 
'action_required',
-  title: 'Fork CI needs attention', note });
+  title: NEEDS_ATTENTION, note });
+
+function incompleteAttempt(run, jobs) {
+  if (jobs.some(job => job.run_attempt > run.run_attempt)) {
+    return requiredAction('The jobs API reports a newer attempt than the run 
listing. ' +
+      'Waiting for consistent results; the publisher will automatically check 
again.');
+  }
+  // A completed rerun must expose at least one job from that attempt. 
Otherwise all
+  // retained successes (and auxiliary cancellations) could belong to the 
previous run.
+  if (run.status === 'completed' && run.run_attempt > 1 &&
+      !jobs.some(job => job.run_attempt === run.run_attempt)) {
+    return requiredAction('The jobs API has not reported the completed current 
attempt yet. ' +
+      'Waiting for consistent results; the publisher will automatically check 
again.');
+  }
+}
 
 function evaluateExecution(pr, run, jobs, baseSha) {
+  const incomplete = incompleteAttempt(run, jobs);
+  if (incomplete) return incomplete;
   const required = jobs.find(job => job.name === requiredName(pr, baseSha));
   if (run.status !== 'completed') {
     // A workflow can remain queued while some of its matrix jobs already have 
runners.
     const running = run.status === 'in_progress' || jobs.some(job => 
job.status === 'in_progress');
     return { status: running ? 'in_progress' : 'queued',
       title: running ? 'Fork CI is running' : 'Fork CI is queued, waiting for 
a runner' };
   }
-  const failed = jobs.filter(job => job.name !== FAIL_FAST && ['failure', 
'timed_out'].includes(job.conclusion))
+  // A nonmatching summary is obsolete only when it is provably from an older 
attempt.
+  // A newer (possibly unexpanded) summary must not reuse an earlier exact 
success.
+  const otherSummary = job => job.name.startsWith('Required CI / ') && job !== 
required;
+  const obsoleteSummary = job => otherSummary(job) && required &&
+    Number.isInteger(job.run_attempt) && job.run_attempt > 0 &&
+    Number.isInteger(required.run_attempt) && required.run_attempt > 
job.run_attempt;
+  if (jobs.some(job => otherSummary(job) && !obsoleteSummary(job))) {
+    return requiredAction('A Required CI record from the same, newer or 
unknown attempt does not match ' +
+      'this head and base. Rerun Required CI for the current context before 
publishing success.');
+  }
+  const isAuxiliary = job => job.name === FAIL_FAST || obsoleteSummary(job);
+  const currentJobs = jobs.filter(job => !isAuxiliary(job));
+  const failed = currentJobs.filter(job => ['failure', 
'timed_out'].includes(job.conclusion))
     .map(job => job.name);
-  // A run that failed only because of the watcher is judged by its suites 
below.
-  const watcherOnly = run.conclusion === 'failure' && !failed.length &&
-    jobs.some(job => job.name === FAIL_FAST && ['failure', 
'timed_out'].includes(job.conclusion));
-  if (run.conclusion !== 'success' && !watcherOnly) {
-    // Fork CI cancels its own run on the first failed job, so report that 
job, not the cancellation.
-    if (failed.length) return { status: 'completed', conclusion: 'failure',
-      title: `Failed: ${failed[0]}${failed.length > 1 ? ` (+${failed.length - 
1} more)` : ''}`.slice(0, 200) };
+  // Partial reruns can retain a cancelled watcher or an obsolete Required CI 
job, keeping
+  // the whole run cancelled after its suites recover. Ignore only those 
auxiliary results,
+  // then verify the exact Required CI and all required suites below. Any 
other unfinished
+  // or unsuccessful job still blocks.
+  const auxiliaryOnly = ['failure', 'timed_out', 
'cancelled'].includes(run.conclusion) &&
+    jobs.some(job => isAuxiliary(job) && ['failure', 'timed_out', 
'cancelled'].includes(job.conclusion)) &&
+    currentJobs.every(job => ['success', 'skipped'].includes(job.conclusion));
+  // Run and job metadata are separate API snapshots. Even a successful 
aggregate must
+  // not hide a failed prerequisite or suite observed in the jobs response.
+  if (failed.length) return { status: 'completed', conclusion: 'failure',
+    title: `Failed: ${failed[0]}${failed.length > 1 ? ` (+${failed.length - 1} 
more)` : ''}`.slice(0, 200) };

Review Comment:
   Fixed in 93e2cf55f0. The trust overlay now depends on the evaluated 
execution outcome (`needsSuiteChecks`), not raw aggregate success. It preserves 
current prerequisite failures and incomplete results, including their 
diagnostic notes.
   
   Added changed-definition fork/trusted regressions for failure, timeout, 
cancellation and unfinished prerequisite results. Restoring the previous 
aggregate-based overwrite makes the new regression fail. The sandbox checks 
also combine changed definitions with a current prerequisite failure and 
unfinished evidence, then verify that only recovered execution requests trusted 
verification.
   
   Final validation: 124 Fork CI tests passed; all scripts 156 passed / 18 
unrelated yq-dependent skips. The final full diff received fresh-context 
review. Live sandbox outcomes and deliberate fault-injection boundaries are 
documented in the updated PR description.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to