Skip to content

#274 detect non-convergence when max-cycles exhausted#274

Open
VasilevNStas wants to merge 1 commit into
zerocracy:masterfrom
VasilevNStas:274-convergence-check
Open

#274 detect non-convergence when max-cycles exhausted#274
VasilevNStas wants to merge 1 commit into
zerocracy:masterfrom
VasilevNStas:274-convergence-check

Conversation

@VasilevNStas

Copy link
Copy Markdown
Contributor

The judges CLI exits with code 0 even when --max-cycles is reached without achieving a fixpoint (convergence). The factbase keeps changing on every cycle, but judges reports "Update completed" with exit 0.

The problem

# judges always exits 0, even if max-cycles exhausted:
judges update --max-cycles=3 ...
echo $?  # → 0 (even if factbase never stabilised)

This means baza.rb treats the job as successful when in fact judges may not have finished processing all facts. The result is silently incomplete.

What this PR does

After judges update completes, entry.sh now scans stdout for the fixpoint message "has made no changes":

Condition Before After
Converged exit 0 exit 0
Max-cycles exhausted, not converged exit 0 🚫 exit 75
Judge error exit ≠0 exit ≠0 (preserved)

Exit code 75 (EX_TEMPFAIL) tells baza.rb that the job failed in a potentially transient way — a retry with higher --max-cycles or fixed judge logic may succeed.

Why this works

The judges gem emits:

  • "The update cycle #N has made no changes to the factbase, let's stop"converged
  • "Too many cycles already, as set by --max-cycles=N, breaking"not converged

We grep for the presence of "has made no changes" in the output. If it's missing and exit code is 0, convergence was not reached.

Limitations

This is a workaround. The proper fix belongs in the judges gem — it should exit non-zero when --max-cycles is exhausted without convergence. A follow-up PR to yegor256/judges would be the correct long-term solution.

Checklist

  • bundle exec rubocop — 0 offenses
  • bundle exec rake — all tasks pass
  • HoC ≤ 133

@yegor256 please review

@VasilevNStas VasilevNStas requested a review from yegor256 as a code owner June 29, 2026 16:36
VasilevNStas added a commit to VasilevNStas/swarm-template that referenced this pull request Jun 29, 2026
The judges CLI exits with code 0 even when --max-cycles is reached
without achieving a fixpoint. The factbase keeps changing on every
cycle, but judges reports "Update completed" with exit 0. This means
baza.rb treats the job as successful when in fact judges may not have
finished processing all facts.

After judges update completes, scan its stdout for the fixpoint
message "has made no changes". If this message is absent but the exit
code is 0, it means --max-cycles was exhausted before convergence.
In that case, exit with code 75 (EX_TEMPFAIL) to signal baza.rb that
the job needs investigation or a retry with higher --max-cycles.

This is a workaround — the proper fix belongs in the judges gem,
which should exit non-zero when max-cycles is exhausted without
convergence.
@VasilevNStas VasilevNStas force-pushed the 274-convergence-check branch from 600a4b1 to f4ae766 Compare June 29, 2026 16:42
VasilevNStas added a commit to VasilevNStas/swarm-template that referenced this pull request Jun 29, 2026
The judges CLI exits with code 0 even when --max-cycles is reached
without achieving a fixpoint. The factbase keeps changing on every
cycle, but judges reports "Update completed" with exit 0. This means
baza.rb treats the job as successful when in fact judges may not have
finished processing all facts.

After judges update completes, scan its stdout for the fixpoint
message "has made no changes". If this message is absent but the exit
code is 0, it means --max-cycles was exhausted before convergence.
In that case, exit with code 75 (EX_TEMPFAIL) to signal baza.rb that
the job needs investigation or a retry with higher --max-cycles.

This is a workaround — the proper fix belongs in the judges gem,
which should exit non-zero when max-cycles is exhausted without
convergence.
@VasilevNStas VasilevNStas force-pushed the 274-convergence-check branch from f4ae766 to e0a0bcb Compare June 29, 2026 16:45
@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@yegor256 — this PR is part of a 3-PR series that addresses a critical reliability gap in the baza.rb ↔ entry.sh pipeline.

The problem: When baza.rb pushes a job, entry.sh runs judges update with no time limit, no convergence detection, and no signal handling. If judges hang or fail to converge, the container runs forever and baza.rb's polling of finished? times out after 10 minutes with no diagnostic information — the user sees a silent failure.

The judges CLI exits with code 0 even when --max-cycles is reached
without achieving a fixpoint. The factbase keeps changing on every
cycle, but judges reports "Update completed" with exit 0. This means
baza.rb treats the job as successful when in fact judges may not have
finished processing all facts.

After judges update completes, scan its stdout for the fixpoint
message "has made no changes". If this message is absent but the exit
code is 0, it means --max-cycles was exhausted before convergence.
In that case, exit with code 75 (EX_TEMPFAIL) to signal baza.rb that
the job needs investigation or a retry with higher --max-cycles.

This is a workaround — the proper fix belongs in the judges gem,
which should exit non-zero when max-cycles is exhausted without
convergence.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant