Skip to content

Reject unknown arguments everywhere; accept each engine's limit names on all - #35

Merged
HalRiveria-Bot merged 1 commit into
mainfrom
fix/api-cleanups
Nov 3, 2026
Merged

HalRiveria-Bot merged 1 commit into
mainfrom
fix/api-cleanups

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

What was wrong

  • Seven public functions (Initialize-ParallelKit, Set-PkMessageHandler, Request-PkAbort, Test-PkAbortSignal, Test-PkCancelRequested, Get-PkAbortTriggerLabel, Reset-PkAbortState) weren't advanced functions, so a wrong or extra argument was silently ignored. Initialize-ParallelKit -MaxParallel 300 left the thread pool unsized, and Reset-PkAbortState -WhatIf reset anyway.
  • Invoke-PkProcessBatch -MaxConcurrent 0 failed with an error naming Invoke-PkProcessDispatch.
  • The process engines say -MaxConcurrent / -AbortTimeoutSeconds and the runspace engine says -MaxParallel / -DrainTimeoutSeconds for the same things, so using one engine's name on the other was an error.
  • -CheckWorkerSafety was a switch defaulting to $true, which lint tools flag.

What changed

  • [CmdletBinding()] on those seven, so unknown arguments are an error. Every public function is now advanced, and the harness checks that.
  • The batch validates -MaxConcurrent itself.
  • Aliases both ways: -MaxParallel and -DrainTimeoutSeconds on the batch and dispatcher, -MaxConcurrent and -AbortTimeoutSeconds on Invoke-PkRunspaceJobs. Get-Help doesn't show aliases, so the help text and README name them.
  • -CheckWorkerSafety is a plain switch. Not passing it still means on; a bare -CheckWorkerSafety and -CheckWorkerSafety:$false behave as before, and a splatted CheckWorkerSafety = $false is tested too.

Behavior to note

  • Scripts that passed extra or misspelled arguments to those seven functions now get an error.
  • On Invoke-PkRunspaceJobs, the abbreviation -Abort used to mean -AbortWaitMessage. It now also matches the -AbortTimeoutSeconds alias, so it fails with "parameter name 'Abort' is ambiguous" before anything starts. Spell out -AbortWaitMessage.

Testing

Harness passes on Windows PowerShell 5.1 and PowerShell 7 (378 assertions, none skipped). 8 of the new assertions failed before the change.

🤖 Generated with Claude Code

… on all

Seven public functions weren't advanced functions, so a wrong or extra
argument was silently ignored: Initialize-ParallelKit -MaxParallel 300 left
the thread pool unsized, and Reset-PkAbortState -WhatIf reset anyway. They now
have [CmdletBinding()].

The batch checks -MaxConcurrent itself, so its error names the batch rather
than Invoke-PkProcessDispatch.

The process engines take -MaxParallel and -DrainTimeoutSeconds, and the
runspace engine takes -MaxConcurrent and -AbortTimeoutSeconds, as aliases.
Get-Help doesn't show aliases, so the help text and README name them. On
Invoke-PkRunspaceJobs, -Abort no longer abbreviates -AbortWaitMessage, since
it now also matches the -AbortTimeoutSeconds alias.

-CheckWorkerSafety is a plain switch: not passing it means on, as before, and
a bare -CheckWorkerSafety or -CheckWorkerSafety:$false behaves as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HalRiveria-Bot
HalRiveria-Bot merged commit e6a0574 into main Nov 3, 2026
2 checks passed
@HalRiveria-Bot
HalRiveria-Bot deleted the fix/api-cleanups branch November 3, 2026 02:46
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