Skip to content

3.0 parameter cleanup: -Dispose switch, checked -Level, -PollCallback - #43

Merged
HalRiveria-Bot merged 4 commits into
mainfrom
feature/api-cleanup
Nov 16, 2026
Merged

HalRiveria-Bot merged 4 commits into
mainfrom
feature/api-cleanup

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

Three parameter changes for 3.0, one commit each.

1. Complete-PkProcess -Dispose is a switch (breaking)

It was a [bool], so disposing took -Dispose $true. Now it's just -Dispose. Only -Job binds by position, so the old form is an error ("A positional parameter cannot be found that accepts argument 'True'"). Without that, a plain switch would have quietly handed the leftover $true to -StreamTimeoutMs as 1 ms and cut the output off with no error. Tested on 5.1 and 7.

What scripts must change: Complete-PkProcess -Job $job -Dispose $true becomes Complete-PkProcess -Job $job -Dispose. A -StreamTimeoutMs given by position (Complete-PkProcess $job 5000) must be named: -StreamTimeoutMs 5000.

2. Write-PkMessage -Level is checked (breaking)

It took any string and passed it straight to the message handler. It now takes Info, Warn, Error or Warning. Warning arrives as Warn, and the case is normalized, so a handler only ever sees Info, Warn or Error, from a worker too.

What scripts must change: any other -Level value (Debug, Verbose, say) is now an error. Use one of the four.

3. The dispatcher's -AbortPollCallback is now -PollCallback (not breaking)

It runs on every loop pass, not just during an abort, and the runspace engine already calls the same role -PollCallback. -AbortPollCallback stays as an alias, so existing scripts keep working.

How it was tested

New harness section AK covers:

  • -Dispose $true and a positional -StreamTimeoutMs are errors, and Complete-PkProcess $job -Dispose works.
  • Each -Level comes through as Info/Warn/Error, on the main thread and from a worker, and an unknown level is an error.
  • The dispatcher takes both -PollCallback and -AbortPollCallback.

The harness's own -Dispose $true and -AbortPollCallback calls use the new forms. The new checks failed before their change. The harness passes on Windows PowerShell 5.1 and PowerShell 7 (453 assertions each).

🤖 Generated with Claude Code

HalRiveria and others added 4 commits November 16, 2026 14:47
-Dispose was a [bool], so disposing took -Dispose $true. It's now a switch: write -Dispose. Only -Job binds by position, so the old -Dispose $true is an error ("A positional parameter cannot be found that accepts argument 'True'") instead of quietly handing $true to -StreamTimeoutMs as 1 ms and cutting the output off. The same goes for a -StreamTimeoutMs given by position.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-Level took any string and passed it straight to the message handler. It now takes Info, Warn, Error or Warning; anything else is an error. Warning arrives as Warn, and the case is normalized, so a handler only ever sees Info, Warn or Error, from a worker too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It runs on every loop pass, not just during an abort, and the runspace engine already calls the same role -PollCallback. -AbortPollCallback stays as an alias, so existing scripts keep working.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HalRiveria-Bot
HalRiveria-Bot merged commit b4d23e4 into main Nov 16, 2026
2 checks passed
@HalRiveria-Bot
HalRiveria-Bot deleted the feature/api-cleanup branch November 16, 2026 20:02
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