Skip to content

Harness: static checks for the dispatcher's copied blocks, callback guards and empty catches - #59

Merged
HalRiveria-Bot merged 2 commits into
mainfrom
test/static-checks
Nov 17, 2026
Merged

HalRiveria-Bot merged 2 commits into
mainfrom
test/static-checks

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

Three rules in the kit were only enforced by comments and review, so a one-sided edit could slip through with every test still green:

  • The dispatcher's three poll/finalize passes (main loop, graceful wait, final pass) are deliberate copies, as are its force-stop and its finally teardown. "Keep in sync" was only a comment.
  • Every call of a user callback has to go through Invoke-PkCallback or its inlined do { } while ($false) guard plus the loop warning, so a continue/break in the callback can't escape into the kit's loops. A new call site that forgot it was only caught if someone also remembered to add a behavior test for it.
  • Every empty catch { } has to say why it swallows. One didn't: the caller-scope path lookup in Resolve-PkFileSystemPath.

What changed

New harness section AN reads ParallelKit.ps1 and checks:

  1. The three finalize passes match token for token (comments and layout ignored), apart from the two intended differences: the final pass has no time-limit check, and each invariant message names its own pass.
  2. The force-stop and the teardown run the same per-job steps, apart from the teardown skipping -JobAbortCleanup for a job whose -JobFinalize was running.
  3. Every &/. call of a callback (by variable, index or property) has the reset flag, the do { } while ($false) guard and the warning after it; .Invoke() on a callback is refused. The kit's own helpers captured into variables are on an allow-list.
  4. Every empty catch, in PowerShell or in the C# blocks, has a comment on its line or right above it.

Each check also runs on a copy of the kit broken in one spot, so a check that has stopped seeing anything fails too.

The kit itself only gains the missing reason comment on that one catch; no behavior change.

Testing

  • The empty-catch check failed on the old code (line 1242: } catch { }) and passes with the comment added.
  • Full harness passes in fresh processes on Windows PowerShell 5.1 and PowerShell 7 (485 assertions each). Section AN adds well under a second.

🤖 Generated with Claude Code

HalRiveria and others added 2 commits November 17, 2026 15:24
…and empty catches

The dispatcher's three poll/finalize passes and its force-stop/teardown
pair are copies on purpose; a one-sided edit now fails the harness. Every
`& $callback` call must sit in the continue/break guard, and every empty
catch must say why. Each check also runs on a copy broken in one spot.
Gives the one empty catch without a reason (in Resolve-PkFileSystemPath's
caller-scope lookup) its comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also catches callbacks called through an index, a property, a dot-source
or .Invoke(), and empty catches whose body spans blank lines; exempts
$ScriptBlock only in Invoke-PkRun.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HalRiveria-Bot
HalRiveria-Bot merged commit 3d8a422 into main Nov 17, 2026
2 checks passed
@HalRiveria-Bot
HalRiveria-Bot deleted the test/static-checks branch November 17, 2026 20:35
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