fix(update): owed follow-ups reach the Desktop result through the commit-safe hand-offs
While this branch was in review, #132386 landed on main: a committed `hermes update` that still owes work prints one whole "Desktop app build owed:" line and one "Update follow-up '<step>' did not finish:" line per owed step, and both Desktop hand-offs turn those into a manual outcome naming the step (never a plain "Update complete."). This branch rewrites both hand-off scripts, so the rebuild took its versions whole and this commit carries main's behaviour into them, through this branch's own post-commit design: - posix.sh: owed_followup_steps() (unchanged from main: the parser contract test runs it), the build-owed and owed-steps checks on a zero exit, each setting DONE_NOTE (finish() makes it manual) and an add_warning entry so the step also reaches the result's warnings; the Linux relaunch gate now appends to DONE_NOTE instead of replacing an owed-step note. - windows.ps1: the same two checks as Add-Followup -Manual calls before the runtime verify, with main's exact [regex]::Matches expression. Already equivalent here: the mac swap is skipped when the rebuild failed, and finish() relaunches the kept app for a manual note unless the Linux gate says skew/manual. Before: 6 of main's contract tests fail on the rebuilt branch (test_every_owed_followup_reaches_the_desktop_result x4, the truncated build-owed case, the parser contract). After: tests/scripts/desktop_update/ plus test_update_post_commit_followups.py pass, 113 passed, 0 failed.
This commit is contained in:
@@ -120,6 +120,12 @@ log() {
|
||||
else echo "$(date +%Y-%m-%dT%H:%M:%S%z) $1" | tee -a "$LOG" 2>/dev/null; fi
|
||||
}
|
||||
|
||||
owed_followup_steps() { # $OUT -> the distinct owed steps, space-separated, in print order
|
||||
# hermes_cli/update_receipt.record_followup prints each as one whole line.
|
||||
printf '%s\n' "$OUT" | sed -n "s/^.*Update follow-up '\([A-Za-z0-9_]*\)' did not finish: .*$/\1/p" \
|
||||
| awk '!seen[$0]++' | tr '\n' ' ' | sed 's/ *$//'
|
||||
}
|
||||
|
||||
# The marker (contract C1/C2 + the A7 lock): parsing, identity, claim, delegate,
|
||||
# release and the Desktop's helper ops live in marker.sh.
|
||||
MY_PID=$$ MY_CT=""
|
||||
@@ -641,7 +647,7 @@ deliver_outcome() { # the truth-determining half: swap bundles / gate the relaun
|
||||
else
|
||||
linux_gate
|
||||
if [ "$GATE" != "relaunch" ] && [ "$FINAL_CODE" -eq 0 ]; then
|
||||
DONE_NOTE="$GATE_MSG"
|
||||
DONE_NOTE="${DONE_NOTE:+$DONE_NOTE }$GATE_MSG"
|
||||
add_warning "relaunch" "$GATE: $GATE_MSG"
|
||||
fi
|
||||
fi
|
||||
@@ -1220,6 +1226,27 @@ fi
|
||||
trap 'on_signal TERM' TERM
|
||||
|
||||
if [ "$CODE" -eq 0 ]; then FINAL_CODE=0 FINAL_MSG="Update complete." UPDATE_COMMITTED=1
|
||||
# Contract C3: a Desktop build that fails after the code committed is an owed
|
||||
# follow-up (hermes update exits 0 and prints one whole "Desktop app build
|
||||
# owed:" line for it; the follow-up text itself is truncated). The user is on
|
||||
# the new Hermes, but this app was not rebuilt: say so and say how to fix it,
|
||||
# never "finished OK" and never "still on the previous version".
|
||||
if printf '%s\n' "$OUT" | grep -Eq '^[[:space:]]*Desktop app build owed: '; then
|
||||
APP_REBUILD_FAILED=1
|
||||
DONE_NOTE="Hermes was updated, but the Desktop app could not be rebuilt, so it still runs its old build. Run hermes desktop --force-build in a terminal to rebuild it; the update log has the build error."
|
||||
add_warning "build" "the Desktop app build is owed by the committed update"
|
||||
fi
|
||||
# Every other owed follow-up (a gateway still on the old code, a Windows
|
||||
# resume, a lost completion, channel adoption, maintenance...) prints one
|
||||
# whole "Update follow-up '<step>' did not finish:" line. None of them may
|
||||
# end as a plain "Update complete." (review regression 1).
|
||||
OWED_STEPS="$(owed_followup_steps)"
|
||||
if [ -n "$OWED_STEPS" ]; then
|
||||
case " $OWED_STEPS " in *" gateway_restart "*) OWED_HINT=" Run hermes gateway restart to move the messaging gateway onto the new code now." ;; *) OWED_HINT="" ;; esac
|
||||
if [ -n "$DONE_NOTE" ]; then DONE_NOTE="$DONE_NOTE Follow-up steps still owed: $OWED_STEPS.$OWED_HINT"
|
||||
else DONE_NOTE="Hermes was updated, but some follow-up steps did not finish ($OWED_STEPS). The next launch or hermes update retries them; the update log has the details.$OWED_HINT"; fi
|
||||
add_warning "followup" "owed by the committed update: $OWED_STEPS"
|
||||
fi
|
||||
elif [ "$CODE" -ne 2 ] && update_committed_after_exit; then
|
||||
# Past the commit point: installed, with an owed follow-up (contract C3).
|
||||
FINAL_CODE=0 FINAL_MSG="Update complete." UPDATE_COMMITTED=1
|
||||
|
||||
@@ -1667,6 +1667,23 @@ try {
|
||||
}
|
||||
}
|
||||
|
||||
# Contract C3: a Desktop build that failed after the code committed is an owed follow-up
|
||||
# (exit 0); the CLI prints one whole "Desktop app build owed:" line for it. The user is on
|
||||
# the new Hermes but this app was not rebuilt: a manual outcome, never plain success.
|
||||
if (-not $desktopBuildFailed -and $res.Output -match '(?m)^\s*Desktop app build owed: ') {
|
||||
Add-Followup "build: the Desktop app build is owed by the committed update" "the Desktop app could not be rebuilt, so it still runs its old build. Run 'hermes desktop --force-build' in a terminal to rebuild it; the update log has the build error." -Manual
|
||||
}
|
||||
|
||||
# Every other owed follow-up of the committed update (a gateway still on the old code, a
|
||||
# Windows resume, a lost completion...) prints one whole "Update follow-up '<step>' did not
|
||||
# finish:" line (hermes_cli/update_receipt.record_followup): never a plain success either.
|
||||
$owedSteps = @([regex]::Matches(($res.Output -join "`n"), "Update follow-up '([A-Za-z0-9_]+)' did not finish: ") |
|
||||
ForEach-Object { $_.Groups[1].Value } | Select-Object -Unique)
|
||||
if ($owedSteps.Count -gt 0) {
|
||||
$owedHint = if ($owedSteps -contains 'gateway_restart') { " Run 'hermes gateway restart' to move the messaging gateway onto the new code now." } else { '' }
|
||||
Add-Followup ("followup: owed by the committed update: " + ($owedSteps -join ', ')) ("some follow-up steps did not finish (" + ($owedSteps -join ', ') + "). The next launch or 'hermes update' retries them; the update log has the details." + $owedHint) -Manual
|
||||
}
|
||||
|
||||
# A zero-exit update is not proof that the runtime survived the update.
|
||||
if (-not $desktopBuildFailed) {
|
||||
$verifyFailure = $null
|
||||
|
||||
Reference in New Issue
Block a user