Skip to content

Read the answer, not a stray value, from -GroupReleaseCheck, -GroupProvider and -NextJobProvider - #62

Merged
HalRiveria-Bot merged 2 commits into
mainfrom
fix/callback-return-values
Nov 17, 2026
Merged

HalRiveria-Bot merged 2 commits into
mainfrom
fix/callback-return-values

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

A value a callback lets out before its answer (an ArrayList.Add index is the usual one) reaches the kit together with the answer, as one array. Three callbacks read the wrong thing from that array:

  • -GroupReleaseCheck released a held group early. $log.Add($g); return $false arrived as @(0, $false), which [bool] reads as true. It now takes the last value, as -JobPollCompleted already does.
  • -GroupProvider could make a run that never ends. $log.Add('asked'); return $null arrived as @(0, $null), which isn't $null, so the dispatcher took it as one more group and asked again, forever. Output that ends in $null is now the end of the groups, with a warning.
  • -NextJobProvider took the wrong value from mixed output. It kept the last hashtable and ignored a final $null: a hashtable let out before return $null ran as a job and the run didn't end, and of two hashtables the first was dropped silently. Now the last value decides: $null ends the run, otherwise the last hashtable is the job, and anything else is ignored with a warning.

The README and help now state each callback's contract: one group or $null from -GroupProvider (return ,@('a', 'b', 'c') for a list as one group), one job or $null from -NextJobProvider, and only the last value counting for -GroupReleaseCheck. The README's claim that callback output "can't corrupt the dispatcher's result by accident" is replaced by what actually happens to stray output.

One consequence: a list given as one group can't end in $null, wrapped or not. return ,@('a', $null) reaches the dispatcher exactly as $list.Add(...); return $null does, so it's read as the end, with a warning. The README says so.

Testing

  • New harness section AT: a -GroupReleaseCheck that leaks a value, a -GroupProvider that leaks one before return $null, a wrapped list group, and -NextJobProvider outputting two jobs, and a job then $null. The four bug tests failed on the old code (group released after 1 check of 3; the provider ran away and was cut off after 10 calls; no warnings, and the leaked job ran) and pass now.
  • Full harness passes in fresh processes on Windows PowerShell 5.1 and PowerShell 7 (510 assertions each).

🤖 Generated with Claude Code

HalRiveria and others added 2 commits November 17, 2026 16:44
…ovider and -NextJobProvider

A value a callback lets out before its answer (an ArrayList.Add index)
arrives together with it:

- -GroupReleaseCheck: `$log.Add($g); return $false` read as true and
  released a held group early. Only the last value counts now, as with
  -JobPollCompleted.
- -GroupProvider: `$log.Add(...); return $null` arrived as @(index, $null),
  was taken as one more group, and the dispatcher asked again forever.
  Output ending in $null is now the end, with a warning.
- -NextJobProvider: took the last hashtable and ignored a final $null, so
  a hashtable leaked before `return $null` ran as a job, and of two
  hashtables the first was dropped silently. The last value decides now,
  and anything else is warned about.

README and help state each callback's return contract.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HalRiveria-Bot
HalRiveria-Bot merged commit 4e75b62 into main Nov 17, 2026
2 checks passed
@HalRiveria-Bot
HalRiveria-Bot deleted the fix/callback-return-values branch November 17, 2026 21:56
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.

2 participants