Skip to content

#302: forward job ID as job_id option to judges - #310

Merged
yegor256 merged 2 commits into
zerocracy:masterfrom
macoladik:issue-302
Nov 26, 2026
Merged

yegor256 merged 2 commits into
zerocracy:masterfrom
macoladik:issue-302

Conversation

@macoladik

@macoladik macoladik commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

entry.sh forwarded the job id as id, so options.job_id stayed nil and created facts carried no _job.
The old test ran entry.sh without an id, so the wrong option name passed.
The test now asserts job_id=<id> reaches judges, that spaces and $(id) survive as one argument, and that empty/missing home/id exit non-zero without invoking judges.
bundle exec rake test: reverting the option fails test/test_entry.rb, with it green (6 tests).

Closes #302

@macoladik macoladik left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forwarding the job id as an option is fine in principle, but the test only pins the spelling of argv, nothing in the template consumes the new option, and the assertions miss the mutants that would break judges at runtime. Nine comments below.

Comment thread entry.sh

judges update --summary --max-cycles=3 --no-log \
--option "id=${id}" --lib "${self}/lib" "${self}/judges" "${home}/base.fb"
--option "id=${id}" --option "job_id=${id}" \

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing binds job_id to the --option flag: passed.grep(/\A(?:job_)?id=/) matches the value wherever it appears in argv. Change this line to --option "id=${id}" job_id=${id} \ and all four assertions still pass (--option is still present once, the value still matches, base.fb is still last), but judges update then receives job_id=job-42 as a third factbase path and every swarm run fails with a missing-file error. Fix: assert the pairing, e.g. assert_equal(%w[--option id=job-42 --option job_id=job-42], passed.slice(passed.index('--option'), 4)).

Comment thread entry.sh
judges update --summary --max-cycles=3 --no-log \
--option "id=${id}" --lib "${self}/lib" "${self}/judges" "${home}/base.fb"
--option "id=${id}" --option "job_id=${id}" \
--lib "${self}/lib" "${self}/judges" "${home}/base.fb"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

job_id has no consumer in this repository: no judge under judges/, nothing in lib/, no YAML fixture and no line of README.md mentions it, so the new option is only verified as an argv string. A user who copies this template gets a judge that never reads it. Fix: read job_id in judges/say-hello/say-hello.rb (or add a YAML test that asserts the option reaches a judge) and list it in the README.

Comment thread entry.sh
judges update --summary --max-cycles=3 --no-log \
--option "id=${id}" --lib "${self}/lib" "${self}/judges" "${home}/base.fb"
--option "id=${id}" --option "job_id=${id}" \
--lib "${self}/lib" "${self}/judges" "${home}/base.fb"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id and job_id are hard-wired to the same value with nothing saying why: a judge cannot distinguish the swarm id from the job id, and the day they must differ this line is the only place to change, with no test that would notice. Fix: add one comment line stating they are intentionally identical today, or forward only one of the two.

Comment thread test/test_entry.rb
@@ -40,7 +40,7 @@ def test_forwards_job_id_to_judges_options

assert_includes(passed, 'update')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update flags on the command line this PR edits are never asserted: deleting --max-cycles=3 (or --summary, --no-log) leaves this test green, and the swarm then runs judges without a cycle cap. Fix: assert the full head, e.g. assert_equal(%w[update --summary --max-cycles=3 --no-log], passed.first(4)).

Comment thread test/test_entry.rb
@@ -40,7 +40,7 @@ def test_forwards_job_id_to_judges_options

assert_includes(passed, 'update')
assert_includes(passed, '--option')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One --option satisfies this assertion, so a missing flag for the new job_id pair is not detected here. Fix: assert_equal(2, passed.count('--option')).

Comment thread test/test_entry.rb
assert_includes(passed, 'update')
assert_includes(passed, '--option')
assert_includes(passed, 'id=job-42')
assert_equal(%w[id=job-42 job_id=job-42], passed.grep(/\A(?:job_)?id=/))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expected literal is the same id the test passes in (job-42 at line 62), so --option "job_id=job-42" - a hard-coded value instead of "${id}" - keeps this green; the test cannot see the interpolation. Fix: use a distinctive id constant (e.g. job-7f3c9a1) both in run_entry and in the expectation.

Comment thread test/test_entry.rb
assert_includes(passed, 'update')
assert_includes(passed, '--option')
assert_includes(passed, 'id=job-42')
assert_equal(%w[id=job-42 job_id=job-42], passed.grep(/\A(?:job_)?id=/))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comparison is over-constrained on form and under-constrained on meaning: %w[...] pins the order, so a later alphabetical reorder of the two flags (identical behaviour) turns CI red, while the --option that gives the pair meaning is only checked by the loose assert_includes above. Fix: compare passed.grep(/\A(?:job_)?id=/).sort and add the paired assertion.

Comment thread test/test_entry.rb
assert_includes(passed, '--option')
assert_includes(passed, 'id=job-42')
assert_equal(%w[id=job-42 job_id=job-42], passed.grep(/\A(?:job_)?id=/))
assert_equal("#{home}/base.fb", passed.last)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passed.last is the only guard on the positional part of argv, so a stray argument inserted before the factbase path (e.g. a bad merge that also passes a bare job_id=job-42 next to the --lib pair) keeps all four assertions green while judges treats it as a second fb file and dies. Fix: assert the whole argv, or at least passed.length.

Comment thread entry.sh
judges update --summary --max-cycles=3 --no-log \
--option "id=${id}" --lib "${self}/lib" "${self}/judges" "${home}/base.fb"
--option "id=${id}" --option "job_id=${id}" \
--lib "${self}/lib" "${self}/judges" "${home}/base.fb"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change only reaches swarms created from now on: entry.sh is copied into every existing swarm repository, and README.md has no upgrade note, so a swarm that hit the reported bug keeps failing after this merge until someone re-copies the script. Fix: add a short note to the README saying which file to re-copy (or bump the version the template declares).

@yegor256 yegor256 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forwarding job_id alongside id supplies the option FBE consumes while preserving compatibility with custom judges. The regression tests cover forwarding, shell metacharacters, paths with spaces, and invalid arguments.

@yegor256
yegor256 merged commit 7f53d4a into zerocracy:master Nov 26, 2026
7 checks passed
@0crat

0crat commented Nov 26, 2026

Copy link
Copy Markdown

@yegor256 Thanks for the review! You've earned +18 points. Calculation inputs: 71 hits-of-code; 9 review comments; self-review: no. Your running score is +6169; don't forget to check your Zerocracy account too).

Reward policy

An author of every code review receives a bonus. Here is how it's calculated: First, assume that hoc is the total number of hits-of-code in the contribution. Then, assume that comments is the total number of comments made by all reviewers. Then, assume that self is 1 if the review was made for their own code contribution, otherwise zero, and award 18 points. Then, deduct 12 points if they reviewed their own contribution. Then, add 0.015 points for each hit-of-code, but not more than 16 points. Then, deduct 5 points if there were less than 9 comments made during review. Then, deduct 8 points if there were absolutely no comments made during review. Then, add 0.375 points for each comment during the review, but not more than 8 points. Then, deduct 4 points if there were less than 24 hits-of-code. Then, make sure the reward is not larger than 24 points and not smaller than 4 points.

@0crat

0crat commented Nov 26, 2026

Copy link
Copy Markdown

@macoladik Nice work on this one! You racked up +24 points — started with the base 24, picked up +5 for your 71 hits-of-code (0.075 pts per hoc, nice and steady, well under the 133 mark so no deductions there), then trimmed -5 since we cap bonuses at 24. Solid contribution, no penalties this time. Keep this pace up and keep the code coming! Your running score is now +882 — go check your Zerocracy account for the full picture.

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.

entry.sh forwards the job ID as id instead of the job_id consumed by FBE

3 participants