Repository navigation
#302: forward job ID as job_id option to judges - #310
Conversation
macoladik
left a comment
There was a problem hiding this comment.
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.
|
|
||
| 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}" \ |
There was a problem hiding this comment.
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)).
| 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" |
There was a problem hiding this comment.
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.
| 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" |
There was a problem hiding this comment.
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.
| @@ -40,7 +40,7 @@ def test_forwards_job_id_to_judges_options | |||
|
|
|||
| assert_includes(passed, 'update') | |||
There was a problem hiding this comment.
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)).
| @@ -40,7 +40,7 @@ def test_forwards_job_id_to_judges_options | |||
|
|
|||
| assert_includes(passed, 'update') | |||
| assert_includes(passed, '--option') | |||
There was a problem hiding this comment.
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')).
| 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=/)) |
There was a problem hiding this comment.
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.
| 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=/)) |
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
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.
| 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" |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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 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 policyAn 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. |
|
@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. |
entry.sh forwarded the job id as
id, sooptions.job_idstayed 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