Repository navigation
Conversation
The hard-coded --max-cycles=3 stopped dependency chains that need more than three update cycles, contradicting the README promise that judges run until no new facts appear. Drop the flag so judges converge on their own default cap.
macoladik
left a comment
There was a problem hiding this comment.
Drops --max-cycles=3 from entry.sh and adds a stub-based test. The change replaces a bounded failure with an unbounded run, and the new test never runs judges, so it cannot detect either regression.
| self=$(dirname "$(readlink -f "$0")") | ||
|
|
||
| judges update --summary --max-cycles=3 --no-log \ | ||
| judges update --summary --no-log \ |
There was a problem hiding this comment.
Removing the flag leaves judges update without any ceiling. In the gem, the cycle loop ends only when a cycle makes zero changes to the factbase, on --max-cycles, or on --lifetime; neither of the last two is passed here. Scenario: a judge that inserts a fact with a fresh when or _id on every cycle (a (absent ...) guard forgotten) keeps delta non-zero, so the process never returns and the swarm container runs until the platform kills it. The old --max-cycles=3 was the only stop. Fix: keep a bound, just a larger one, e.g. --max-cycles=10.
|
|
||
| judges update --summary --max-cycles=3 --no-log \ | ||
| judges update --summary --no-log \ | ||
| --option "id=${id}" --lib "${self}/lib" "${self}/judges" "${home}/base.fb" |
There was a problem hiding this comment.
Nothing here bounds a single cycle either. judges update supports --lifetime, and without it one judge blocked on a network call (Octokit without a timeout, a hanging git clone) holds the job forever regardless of the cycle cap. Fix: add --lifetime=3600 to this argument list.
| File.write(ENV.fetch('JUDGES_ARGS_FILE'), ARGV.join("\n")) | ||
| RUBY | ||
|
|
||
| # Models a chain A→B→C→D→E plus the confirming cycle, so it needs five cycles. |
There was a problem hiding this comment.
The comment promises a modelled chain A->B->C->D->E plus the confirming cycle, but the stub models no chain at all - it parses one integer and aborts below 5. A reader will believe the convergence path is covered when only a string comparison is. Fix: either drop the comment or make the stub behave like a converging chain (count invocations, exit non-zero while the count is under 5).
| #!/usr/bin/env ruby | ||
| File.write(ENV.fetch('JUDGES_ARGS_FILE'), ARGV.join("\n")) | ||
| args = ARGV.dup | ||
| cap = 8 |
There was a problem hiding this comment.
cap = 8 invents a default that judges does not have: with no --max-cycles the gem's loop is unbounded (opts['max-cycles'].nil? in Judges::Update#loop_them). Because of this fake default the test passes when entry.sh passes no cap at all - which is exactly what this PR does - so it cannot tell "raised the cap" from "removed the cap", and it documents a contract the gem does not implement. Fix: model reality (cap = Float::INFINITY) and assert on the recorded argv instead.
| cap = args.shift.to_i | ||
| end | ||
| end | ||
| abort("chain needs 5 cycles, got #{cap}") if cap < 5 |
There was a problem hiding this comment.
The assertion is one-sided: it rejects 0..4 and accepts everything above, so --max-cycles=999999 passes, and so does no flag at all. That means the test stays green for the regression it exists for (an unbounded run) and for any cap so large it is meaningless. Fix: read the args file and require an explicit bound, e.g. assert_match(/--max-cycles=(\d+)/, passed.join(' ')) plus assert_operator(cap, :>=, 5).
| # Models a chain A→B→C→D→E plus the confirming cycle, so it needs five cycles. | ||
| CHAIN_STUB = <<~'RUBY' | ||
| #!/usr/bin/env ruby | ||
| File.write(ENV.fetch('JUDGES_ARGS_FILE'), ARGV.join("\n")) |
There was a problem hiding this comment.
This write is dead in the only test that uses the stub: test_allows_chain_longer_than_three_cycles calls run_entry and throws the returned lines away, so JUDGES_ARGS_FILE is written and never read. Consequence: entry.sh could invoke the stub with a wrong --lib, a wrong base.fb, or no --summary, and the test would still pass. Fix: assert on the returned argv in that test, or drop the write from this stub.
| Dir.mktmpdir do |dir| | ||
| home = File.join(dir, 'home') | ||
| FileUtils.mkdir_p(home) | ||
| run_entry(judges_stub(dir, CHAIN_STUB), home, File.join(dir, 'args.txt')) |
There was a problem hiding this comment.
The result of run_entry is discarded, so the test proves only that the exit status is zero. Any change that keeps the stub happy but breaks the real invocation - losing --summary, --no-log, --option id=job-42, or the --lib path - stays green. Fix: passed = run_entry(...) and assert the argv, as test_forwards_job_id_to_judges_options does two methods below.
| assert_equal(File.expand_path('../judges', __dir__), passed[passed.index('--lib') + 2]) | ||
| end | ||
|
|
||
| def test_allows_chain_longer_than_three_cycles |
There was a problem hiding this comment.
The name says the chain may run longer than three cycles, but the real judges is never executed - run_entry puts the stub first on PATH. So the gem's own behaviour (whatever its default cap is, and whether --max-cycles was actually the blocker) is untested; a version of judges that still stops at 3 cycles for another reason would keep this green. judges is already a dependency (Gemfile:9), so an integration test with a 5-step chain of judges fixtures would prove the fix; the stub only proves the flag string.
| FileUtils.mkdir_p(bin) | ||
| stub = File.join(bin, 'judges') | ||
| File.write(stub, JUDGES_STUB) | ||
| File.write(stub, source) |
There was a problem hiding this comment.
The new source parameter is written verbatim, and CHAIN_STUB duplicates JUDGES_STUB's shebang and write line instead of extending it. When JUDGES_STUB grows (for example a check on the factbase argument), CHAIN_STUB silently keeps the old behaviour and the test passes for the wrong reason. Fix: build the chain stub from the plain one, e.g. CHAIN_STUB = "#{JUDGES_STUB}\n<cycle check>", and add one assertion on the recorded argv so the two stubs cannot drift unnoticed.
| Dir.mktmpdir do |dir| | ||
| home = File.join(dir, 'home') | ||
| FileUtils.mkdir_p(home) | ||
| run_entry(judges_stub(dir, CHAIN_STUB), home, File.join(dir, 'args.txt')) |
There was a problem hiding this comment.
This invokes CHAIN_STUB, which only records argv and rejects caps below five; it never executes a judge or produces any facts. For example, replacing the old cap with --max-cycles=5 would pass even for a chain needing six cycles, leaving its output incomplete. Add an integration fixture that runs the real judges update through the entry point with a dependency chain requiring more than three cycles, asserts the final facts, and fails with the original --max-cycles=3.
entry.sh capped every update at three cycles, so a dependency chain that needs a fourth cycle stopped before the fixed point the README promises.
Removed the flag so
judges updateruns its own convergence loop (default cap 8); job-id, lib, and factbase forwarding are unchanged. A new fixture intest_entrymodels a five-cycle A→B→C→D→E chain and fails if the entry point caps below it.Closes #297