Skip to content

PowerShell hygiene burndown: kill git -C, sanitize $Comment, backport retry-with-backoff #530

Description

@PolyphonyRequiem

Context

Three PowerShell hygiene issues surfaced by Liszt (PowerShell) during the 2026-05-28 fan-out, all in or adjacent to the production launcher and worktree manager:

  1. git -C in production launcherscripts/Invoke-PolyphonySdlc.ps1:833 is the last surviving git -C in production code. On Windows, git -C with paths containing spaces produces unreliable results and can silently misdetect the platform (falling back to 'ado' without warning, or embedding a multi-line error string into $remoteUrl). Fix: Push-Location/Pop-Location wrapper.

  2. $Comment injection surfacescripts/Invoke-PolyphonySdlc.ps1:357,424-456 embeds $Comment verbatim into a PowerShell here-string that is passed to pwsh -Command. If $Comment contains newlines or backticks (reachable via conductor workflow inputs to the reset path), the child window opens with a syntax error and the exit sidecar records "exit_code": null with no diagnostic. Fix: sanitize $Comment at parameter-bind time (reject or strip [\r\n + backtick]).

  3. Missing retry-with-backoff in worktree teardown.conductor/registry/scripts/worktree-manager.ps1:254-272 deletes git worktrees without the retry-with-backoff pattern that was backported to src/Polyphony/Journal/Reset/Deleters/GitWorktreeDeleter.cs:37-64. Worktree deletion on Windows is prone to transient file-lock failures; without retry, the script fails hard. Fix: backport the C# retry pattern to the PS script.

Parent epic: #522 (Squad short-term wins, 2026-05-28 fan-out)


Acceptance criteria

  • scripts/Invoke-PolyphonySdlc.ps1:833: git -C $mainWorktree remote get-url origin replaced with Push-Location $mainWorktree; try { git remote get-url origin } finally { Pop-Location } pattern
  • scripts/Invoke-PolyphonySdlc.ps1:357,424-456: $Comment validated/sanitized against newlines and backtick injection before heredoc embedding
  • .conductor/registry/scripts/worktree-manager.ps1:254-272: retry-with-backoff loop backported from GitWorktreeDeleter.cs:37-64 for worktree deletion

Owner

  • Primary: Liszt (PowerShell — production launcher + worktree-manager)
  • Secondary: Reich (worktree teardown retry — owns git/worktree seam)

Estimated effort

4–6 hours


File anchors

  • scripts/Invoke-PolyphonySdlc.ps1 (lines 833, 357, 424-456)
  • .conductor/registry/scripts/worktree-manager.ps1 (lines 254-272)
  • src/Polyphony/Journal/Reset/Deleters/GitWorktreeDeleter.cs (lines 37-64 — retry source of truth)

In-situ clause

Apply DU patterns and hygiene fixes opportunistically where natural in your scope. Don't make these the primary focus.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions