work parallel: register and monitor the spawned session fleet in sessions.json - #120
Open
CSalcedoDataBI wants to merge 1 commit into
Open
work parallel: register and monitor the spawned session fleet in sessions.json#120CSalcedoDataBI wants to merge 1 commit into
CSalcedoDataBI wants to merge 1 commit into
Conversation
…ad sessions (#101) Two defects in the parallel-session monitor: 1. MODE 2 listing assigned the live session list to $sessions at SCRIPT scope. PowerShell variable names are case-insensitive, so it aliased the [switch]$Sessions parameter and threw 'Cannot convert Object[] to SwitchParameter' on EVERY listing (even with an empty registry). The 'Sesiones activas' fleet display therefore never rendered. Rename to $liveSessions (and the same name inside Show-SessionFleet for hygiene). 2. Read-SessionRegistry pruned dead entries with $alive | ConvertTo-Json -AsArray | Set-Content — but an empty pipe emits nothing, so when ALL sessions were dead the file was never rewritten and the stale entries survived. Extract ConvertTo-SessionRegistryJson, which returns an explicit '[]' for the empty case; use it in both writers. Add Pester coverage: ConvertTo-SessionRegistryJson (empty/single/multi) and a source guard that MODE 2 uses $liveSessions, not the colliding name. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses Issue #101 by making the parallel-session registry (.agentic-bi-ops/sessions.json) reliably serialize as a JSON array (including the empty case) and by avoiding a PowerShell variable/parameter name collision that can break MODE 2 session listing.
Changes:
- Added
ConvertTo-SessionRegistryJsonto ensure session registry writes always produce a JSON array string, including emitting[]when empty. - Updated session registry prune/write paths to use the new serializer helper.
- Added Pester tests covering empty/single/multi session serialization and preventing
$sessionsfrom colliding with[switch]$Sessions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| plugins/agentic-bi-ops/scripts/Board-Work.ps1 | Adds a dedicated JSON serializer for the session registry and updates registry write sites; renames MODE 2/monitor listing variable to avoid the $Sessions switch collision. |
| plugins/agentic-bi-ops/tests/Board-Work.Tests.ps1 | Adds regression tests for sessions.json serialization and for preventing $sessions assignment that aliases the [switch]$Sessions script parameter. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
179
to
182
| $alive = @($entries | Where-Object { $_.sessionPid -and (Get-Process -Id $_.sessionPid -ErrorAction SilentlyContinue) }) | ||
| if ($alive.Count -ne $entries.Count) { | ||
| # Pipe (not -InputObject) or a passed array gets double-wrapped by -AsArray | ||
| $alive | ConvertTo-Json -Depth 4 -AsArray | Set-Content $p | ||
| Set-Content -Path $p -Value (ConvertTo-SessionRegistryJson $alive) | ||
| } |
Comment on lines
216
to
220
| host = $env:COMPUTERNAME | ||
| started = (Get-Date -Format "yyyy-MM-dd HH:mm") | ||
| } | ||
| $entries | ConvertTo-Json -Depth 4 -AsArray | Set-Content $p | ||
| Set-Content -Path $p -Value (ConvertTo-SessionRegistryJson $entries) | ||
| } |
Comment on lines
+628
to
+630
| # $liveSessions (not $sessions): even here inside a function the name would | ||
| # shadow the [switch]$Sessions param and invites the issue-#101 footgun. | ||
| $liveSessions = @(Read-SessionRegistry) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #101