Thoroughness pass: deploy rename, prompt tightening, StrictMode 3, Pester + ps-quality CI #168

Merged
romaine-life-app[bot] merged 1 commit from fix/spirelens-omnibus-thoroughness into main 2026-04-30 08:13:24 -07:00
romaine-life-app[bot] commented 2026-04-30 08:13:03 -07:00 (Migrated from github.com)

Closes out the original 6-item PS5→PS7 hardening plan plus the follow-on items uncovered during the issue-agent debug arc on #142.

1. Deploy paths follow the bridge rename

prepare-issue-agent-job.ps1 now reads from out/SpireLensMcpBridge/SpireLensMcpBridge.dll and copies as mods/SpireLensMcpBridge.{dll,json}, matching the manifest id after spire-lens-mcp#1 + spire-lens-mcp#9. The mod loader pairs <id>.dll ↔ <id>.json by basename, so basename must match the manifest id. Added explicit stale-file cleanup for mods/SpireLensMcp.{dll,json} left over on existing runners (the previous $staleMcpFolder cleanup only matched a folder the deploy never created).

2. Test-plan LLM prompt — per-id scenario_id_validation contract

Run 25171327395 failed at run-issue-agent-phases.ps1:776:

scenario_id_validation.cards is missing validated entry for scenario_setup.deck value 'ANGER'.

The LLM declared ANGER in scenario_setup.deck but didn't include a matching entry in scenario_id_validation.cards. The prior prompt said "every id must be validated through MCP catalog tools" — interpreted by the LLM as "do the lookup," not "include the artifact row." Tightened to: (a) scenario_id_validation.cards MUST contain one entry per id in deck/add_cards/remove_cards, same for relics; (b) walk every id and confirm coverage before writing the JSON.

3. Set-StrictMode -Version 2.0 → 3.0 in all 6 scripts

Empirically verified on PS 7.4 that V2 already catches missing PSCustomObject/hashtable/OrderedDict properties + uninitialized variables; V3 only adds out-of-bounds array indexing. Audited every array-indexing pattern; both spots ($args[$i+1] in a Count-1 bounded loop, $match[0] guarded by Count -eq 0 early-return) are safe. No Get-PropertyValue-funnel refactor was actually required — V2 was already enforcing that surface.

4. Pester tests for the JSONL parsers

.github/scripts/tests/{Phases,Summarize}.Tests.ps1 — 42 tests covering:

Function Why it's tested
ConvertTo-Array The function-return-unwrap fix (commit 292a33a) — array-shape preservation across null/single/many input
Get/Set-PropertyValue The PS5→PS7 IDictionary branch (commit 35d3cda) — works for both [ordered]@{} and PSCustomObject
Format-FailureCategories The line-154 [ordered]@{} iteration bug
Get-ClaudeToolCallSummary / Get-ClaudeCostSummary Real fixtures including phase attribution and permission_denials accounting
Get-ExitCodeText The function I restored in 4cb3d25
Get-NestedPropertyValue, Read-JsonOrNull, Format-Usd, Get-TextBlob, Test-TextMentions* Pure helpers, edge-case coverage

Tests don't dot-source the parent scripts (they have script-level main flows that need GH Actions context). Helpers.psm1::Import-ScriptFunctions AST-extracts the function bodies from the live source so tests stay in lockstep — no copied helpers to drift.

5. ps-quality.yml — PSScriptAnalyzer + Pester on PRs

Triggers on PRs touching .github/scripts/** or this workflow. Fails on Error-severity ScriptAnalyzer findings (currently 0 in the script tree) and on any failing Pester test. Pester output uploads as a JUnitXml artifact for downstream consumption.

The 81 existing Warning-severity findings are intentionally tolerated until the surface is tuned — they're mostly PSAvoidUsingWriteHost (the scripts use Write-Host for GH Actions log groups) and naming-preference rules like PSUseSingularNouns. Workflow comment notes the eventual ratchet.

Out of scope / explicitly deferred

  • C# namespace SpireLens.Mcp rename — wider refactor, separate concern from the bridge surface naming. Documented in spire-lens-mcp#9.
  • Tightening ScriptAnalyzer warning floor — needs case-by-case decisions (Write-Host is genuinely correct for GH Actions logs; some PSAvoidUsingEmptyCatchBlock swallows are intentional per-line JSONL parse tolerance).
Closes out the original 6-item PS5→PS7 hardening plan plus the follow-on items uncovered during the issue-agent debug arc on #142. ## 1. Deploy paths follow the bridge rename `prepare-issue-agent-job.ps1` now reads from `out/SpireLensMcpBridge/SpireLensMcpBridge.dll` and copies as `mods/SpireLensMcpBridge.{dll,json}`, matching the manifest id after [spire-lens-mcp#1](https://github.com/nelsong6/spire-lens-mcp/pull/1) + [spire-lens-mcp#9](https://github.com/nelsong6/spire-lens-mcp/pull/9). The mod loader pairs `<id>.dll` ↔ `<id>.json` by basename, so basename must match the manifest id. Added explicit stale-file cleanup for `mods/SpireLensMcp.{dll,json}` left over on existing runners (the previous `$staleMcpFolder` cleanup only matched a folder the deploy never created). ## 2. Test-plan LLM prompt — per-id `scenario_id_validation` contract Run [25171327395](https://github.com/nelsong6/spirelens/actions/runs/25171327395) failed at `run-issue-agent-phases.ps1:776`: ``` scenario_id_validation.cards is missing validated entry for scenario_setup.deck value 'ANGER'. ``` The LLM declared `ANGER` in `scenario_setup.deck` but didn't include a matching entry in `scenario_id_validation.cards`. The prior prompt said "every id must be validated through MCP catalog tools" — interpreted by the LLM as "do the lookup," not "include the artifact row." Tightened to: (a) `scenario_id_validation.cards` MUST contain one entry per id in `deck`/`add_cards`/`remove_cards`, same for relics; (b) walk every id and confirm coverage before writing the JSON. ## 3. `Set-StrictMode -Version 2.0 → 3.0` in all 6 scripts Empirically verified on PS 7.4 that V2 already catches missing PSCustomObject/hashtable/OrderedDict properties + uninitialized variables; V3 only adds out-of-bounds array indexing. Audited every array-indexing pattern; both spots (`$args[$i+1]` in a `Count-1` bounded loop, `$match[0]` guarded by `Count -eq 0` early-return) are safe. No `Get-PropertyValue`-funnel refactor was actually required — V2 was already enforcing that surface. ## 4. Pester tests for the JSONL parsers `.github/scripts/tests/{Phases,Summarize}.Tests.ps1` — 42 tests covering: | Function | Why it's tested | |---|---| | `ConvertTo-Array` | The function-return-unwrap fix (commit `292a33a`) — array-shape preservation across null/single/many input | | `Get/Set-PropertyValue` | The PS5→PS7 IDictionary branch (commit `35d3cda`) — works for both `[ordered]@{}` and PSCustomObject | | `Format-FailureCategories` | The line-154 `[ordered]@{}` iteration bug | | `Get-ClaudeToolCallSummary` / `Get-ClaudeCostSummary` | Real fixtures including phase attribution and `permission_denials` accounting | | `Get-ExitCodeText` | The function I restored in `4cb3d25` | | `Get-NestedPropertyValue`, `Read-JsonOrNull`, `Format-Usd`, `Get-TextBlob`, `Test-TextMentions*` | Pure helpers, edge-case coverage | Tests don't dot-source the parent scripts (they have script-level main flows that need GH Actions context). `Helpers.psm1::Import-ScriptFunctions` AST-extracts the function bodies from the live source so tests stay in lockstep — no copied helpers to drift. ## 5. `ps-quality.yml` — PSScriptAnalyzer + Pester on PRs Triggers on PRs touching `.github/scripts/**` or this workflow. Fails on Error-severity ScriptAnalyzer findings (currently 0 in the script tree) and on any failing Pester test. Pester output uploads as a JUnitXml artifact for downstream consumption. The 81 existing Warning-severity findings are intentionally tolerated until the surface is tuned — they're mostly `PSAvoidUsingWriteHost` (the scripts use Write-Host for GH Actions log groups) and naming-preference rules like `PSUseSingularNouns`. Workflow comment notes the eventual ratchet. ## Out of scope / explicitly deferred - C# namespace `SpireLens.Mcp` rename — wider refactor, separate concern from the bridge surface naming. Documented in [spire-lens-mcp#9](https://github.com/nelsong6/spire-lens-mcp/pull/9). - Tightening ScriptAnalyzer warning floor — needs case-by-case decisions (Write-Host is genuinely correct for GH Actions logs; some `PSAvoidUsingEmptyCatchBlock` swallows are intentional per-line JSONL parse tolerance).
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
romaine-life/spirelens!168
No description provided.