Session log 2026-04-30: PS5→PS7 hardening, expected-value contracts, and the agentic-workflow vision #175

Closed
opened 2026-04-30 14:54:55 -07:00 by romaine-life-app[bot] · 0 comments
romaine-life-app[bot] commented 2026-04-30 14:54:55 -07:00 (Migrated from github.com)

Documentation of a long, productive session. Filed and closed immediately as the canonical "what happened" record. The work split into three arcs: hardening the existing issue-agent against PS5→PS7 + StrictMode failure modes, raising the verification contract from "evidence existed" to "evidence matched expected", and capturing a meta-architecture rewrite vision for glimmung as the canonical agentic-workflow surface.

Arc 1 — Recovery and PS5→PS7 hardening

Started by recovering a dead claude.ai session transcript via authenticated API + a minted GitHub App installation token (no real credential exposure required; demonstrated end-to-end). The transcript pointed at an in-flight 6-item PowerShell hardening plan against the issue-agent scripts. We finished it.

Code landed:

  • spirelens@35d3cda (PR #167) — Fix PS5→PS7 .PSObject.Properties bug class + Set-StrictMode -Version 2.0 + flip $ErrorActionPreference to Stop in summarize-issue-agent.ps1. Closed the latent class of bugs where iterating $x.PSObject.Properties over [ordered]@{}/[hashtable] returns reflection properties in PS7 instead of dict entries.
  • spirelens@82882f7 — Wrapped Where-Object pipeline outputs in @(...) so .Count is safe under StrictMode when the filter rejects all elements.
  • spirelens@4cb3d25 — Restored Get-ExitCodeText (its caller landed in #139 but the function definition was never committed; ErrorActionPreference=Continue swallowed the missing-function error for 3 days; the StrictMode flip exposed it). Made the workflow's terminal pass-gate surface scenario_setup: abort reasons when verification was skipped, instead of an empty verification_reason.
  • spirelens@292a33a → reverted in d58bcb2 — Tried return ,@(...) in ConvertTo-Array to preserve array shape against PS function-return-unwrap; reverted because it broke the pipe form (ConvertTo-Array $x | Where-Object {...} delivered the whole inner array as a single $_). The current solution: plain return @(...) plus @(...) wrap at assignment-then-.Count call sites.

Arc 2 — Encounter-default fix and bridge rename completion

Diagnosed and fixed the FUZZY_WURM_CRAWLER_WEAK encounter that the MCP server published as a system default but the live STS2 catalog no longer recognized.

  • spire-lens-mcp@f4164db (PR #7) — Drop the hardcoded encounter default from BuildValidationCapabilities; replace with guidance text directing callers to use list_encounters. Also fix the bundled-save fallback path so _known_save_encounter_ids returns real ids on a fresh runner.
  • spirelens@2e54619 (PR #166) — Test-plan prompt now treats next_normal_encounter as optional (default null); only specify when the relic/card behavior under test depends on which encounter is fought.
  • spire-lens-mcp@6bc6034 (PR #1) — Manifest id rename SpireLensMcp → SpireLensMcpBridge, log strings updated.
  • spire-lens-mcp@7546b18 (PR #9) — Completed the bridge rename: csproj, sln, build.ps1 paths, README, docs. Build now produces out/SpireLensMcpBridge/SpireLensMcpBridge.dll so the consumer-side basename matches the manifest id.
  • spirelens@3e2d71a (PR #168) — Omnibus thoroughness pass: deploy paths follow rename + stale-file cleanup; per-id scenario_id_validation prompt tightening; StrictMode 2.0→3.0 ratchet (verified empirically — V3 only adds out-of-bounds array indexing on PS 7.4, which we confirmed all existing patterns pass); Pester tests for the JSONL parsers (43 tests, AST-extracts function definitions from production scripts so they stay in lockstep); .github/workflows/ps-quality.yml running PSScriptAnalyzer (Error severity gate) + Pester on PRs touching .github/scripts/**.

Arc 3 — Expected-value contracts on screenshot evidence

The verification contract was previously: "screenshot exists, target_visible, text_visible, observed_text non-empty." That accepted the agent's misread of vigor gained: 88 as vigor gained: 8 because the contract didn't compare observed against an expected literal.

  • spirelens@f8115de (PR #171) — Verification phase now produces a plain-English ## Test Process section in issue-agent-verification.md for every step of the validation plan (what was done, what it was supposed to prove with expected values, what was actually observed). Required even on pass — its purpose is to support reviewer comparison after a PR exists.
  • spirelens@e00f5ff (PR #172) — Schema: required_evidence items with text_visible_required:true must declare a literal expected_text field. Test-plan prompt forbids loose phrasings ("non-zero", "≥ N", "at minimum N") and requires the value to be derived from scenario_setup × validation_plan (one-combat-start of Akabeko ⇒ vigor gained: 8). Wrapper compares observed_text against expected_text with a word-boundary-aware regex (so vigor gained: 8 does NOT match vigor gained: 88 as a prefix substring) and aborts with claimed_result_not_observed on mismatch. Verification prompt requires copying literal screenshot characters into observed_text, not paraphrased; abort with target_evidence_missing if illegible. 9 new Pester tests cover the digit-prefix failure mode + start/end/middle anchoring.
  • spirelens@d58bcb2 (PR #169) — Reverted the ConvertTo-Array comma-operator regression that PR #168 introduced (broke pipe forms). 53/53 Pester now passing.

Arc 4 — End-to-end validation against issue #142

Re-triggered the issue-agent on issue #142 (Akabeko relic stats) at every milestone; the run history is itself a story.

Run Commit Outcome What it proved
25153953835 35d3cda abort: .Count post-test_plan First end-to-end run with new scripts; surfaced that more .Count patterns needed @() wrap
25154511916 82882f7 abort: verification_reason= (empty) Surfaced the terminal-gate masking bug; materialize_only died on FUZZY_WURM
25170444144 4cb3d25 abort: .Count post-verification Verification passed and produced evidence (vigor gained: 80 per agent's own claim, actually 88 in the screenshot); next surface area for .Count exposed
25171327395 292a33a abort: scenario_id_validation contract Comma-operator regression broke the pipe form
25173504069 292a33a abort: scenario_id_validation, BASH Confirmed regression independent of run
25174359513 d58bcb2 PASS end-to-end First issue-agent run to produce a real PR (PR #170); SpireLens stat tooltip showed vigor gained: 88 (silently accepted because contract was loose)
25178505492 e00f5ff abort: claimed_result_not_observed New expected_text contract caught the silent misread; agent honestly wrote observed_text="vigor gained: 88", wrapper aborted
25182719661 e00f5ff abort: claimed_result_not_observed Reproducible. Agent proposed alternate diagnosis (cross-session persistence) which evidence ruled out — value stayed at 88 across runs, would have grown if accumulator were persisting

Net: PR #170 has a real implementation bug (Akabeko postfix fires more than once per combat → 88 instead of 8). The new contract correctly aborts on it. The bug itself is unfixed pending a follow-up.

Architecture and design captures

Filed for future work, not implemented in this session:

  • spirelens#173 — PR-comment-driven agent revisions — Design for /agent revise <feedback> slash-command on PRs. ~2 days MVP / ~8 days full feature. Includes triage phase, delta-mode planning, per-PR serialization, budget caps, threaded reactions.
  • spirelens#174 — Verification-failure self-correction loop — Design for the agent self-correcting when its own verification fails (the more foundational of the two; without it, every fixable failure escalates to a human). ~2 days MVP / ~7 days full. Today's retryable: true field already partitions failures correctly; what's missing is the loop control + prior-attempt-aware prompts.
  • glimmung#15 — Architecture proposal: Glimmung as orchestrator, GH Actions as executor — First sketch of moving orchestration out of GH Actions yaml and into glimmung as real code. Phased migration plan.
  • glimmung#17 — META: Glimmung as the canonical agentic-workflow system — The umbrella. 9 workstreams (orchestration core, result surface UI, storage, GH integration, auth, observability, annotation/replay, multi-project extensibility, ops), 7-sprint sequencing path that ships value at every boundary, operating principles, explicit non-goals, risk register. Includes an addendum: GitHub is not source of truth — issues become a shallow-copy intake that gets closed when glimmung consumes them; all routing/state/UI lives in glimmung.

The thread connecting #173, #174, and glimmung#17: every loop-control feature we want (self-correction, comment-revise, cost ceilings, per-issue state) is fighting yaml inside GitHub Actions and natural in a real orchestrator. Long-term, the orchestration logic moves to glimmung.

Diagnostic issues closed

Operational artifacts produced

  • 53/53 Pester tests across Helpers.psm1, Phases.Tests.ps1, Summarize.Tests.ps1, EvidenceGuard.Tests.ps1. All pass on pwsh 7.4.
  • .github/workflows/ps-quality.yml running PSScriptAnalyzer (Error gate) + Pester on PRs touching scripts.
  • Empirical proof of Set-StrictMode -Version 2.0 vs 3.0 differences on PS 7.4 (V3 only adds OOB array indexing — captured in commit message + StrictMode comment).
  • Empirical proof of return ,$x vs return @($x) semantics through assign vs pipe. Captured in ConvertTo-Array comments + test fixtures so the next person doesn't repeat the regression.

Unfinished work

  • Akabeko 11×-fire bug in PR #170. Diagnosed: RecordAkabekoVigorGained is invoked multiple times per combat-start because the Harmony patch is hooking Akabeko.BeforeSideTurnStart and the original method is called more than once during combat-init sequencing (or via base-class inheritance — exact root cause needs game-source inspection). Suggested fix: agg.VigorGained = Math.Max(agg.VigorGained, amount) instead of +=, making the per-combat aggregate idempotent under N postfix fires. Not landed.
  • TODO child issues for glimmung#17 workstreams W2 / W3 / W6 / W7 / W9. Listed in the meta but not yet broken out into per-workstream issues.
  • spire-lens-mcp C# namespace cleanup (SpireLens.Mcp namespace name still references the old fork identity). Documented as out-of-scope on glimmung#15.

Closing this issue

This is a session log, not a tracking issue — closing immediately. The unfinished work above lives in its own follow-up issues; this is just the historical record.

Documentation of a long, productive session. Filed and closed immediately as the canonical "what happened" record. The work split into three arcs: hardening the existing issue-agent against PS5→PS7 + StrictMode failure modes, raising the verification contract from "evidence existed" to "evidence matched expected", and capturing a meta-architecture rewrite vision for glimmung as the canonical agentic-workflow surface. ## Arc 1 — Recovery and PS5→PS7 hardening Started by recovering a dead claude.ai session transcript via authenticated API + a minted GitHub App installation token (no real credential exposure required; demonstrated end-to-end). The transcript pointed at an in-flight 6-item PowerShell hardening plan against the issue-agent scripts. We finished it. Code landed: - **[spirelens@35d3cda](https://github.com/nelsong6/spirelens/commit/35d3cda)** ([PR #167](https://github.com/nelsong6/spirelens/pull/167)) — Fix PS5→PS7 `.PSObject.Properties` bug class + `Set-StrictMode -Version 2.0` + flip `$ErrorActionPreference` to `Stop` in `summarize-issue-agent.ps1`. Closed the latent class of bugs where iterating `$x.PSObject.Properties` over `[ordered]@{}`/`[hashtable]` returns reflection properties in PS7 instead of dict entries. - **[spirelens@82882f7](https://github.com/nelsong6/spirelens/commit/82882f7)** — Wrapped Where-Object pipeline outputs in `@(...)` so `.Count` is safe under StrictMode when the filter rejects all elements. - **[spirelens@4cb3d25](https://github.com/nelsong6/spirelens/commit/4cb3d25)** — Restored `Get-ExitCodeText` (its caller landed in #139 but the function definition was never committed; ErrorActionPreference=Continue swallowed the missing-function error for 3 days; the StrictMode flip exposed it). Made the workflow's terminal pass-gate surface `scenario_setup:` abort reasons when verification was skipped, instead of an empty `verification_reason`. - **[spirelens@292a33a → reverted in d58bcb2](https://github.com/nelsong6/spirelens/commit/d58bcb2)** — Tried `return ,@(...)` in `ConvertTo-Array` to preserve array shape against PS function-return-unwrap; reverted because it broke the pipe form (`ConvertTo-Array $x | Where-Object {...}` delivered the whole inner array as a single `$_`). The current solution: plain `return @(...)` plus `@(...)` wrap at assignment-then-`.Count` call sites. ## Arc 2 — Encounter-default fix and bridge rename completion Diagnosed and fixed the `FUZZY_WURM_CRAWLER_WEAK` encounter that the MCP server published as a system default but the live STS2 catalog no longer recognized. - **[spire-lens-mcp@f4164db](https://github.com/nelsong6/spire-lens-mcp/commit/f4164db)** ([PR #7](https://github.com/nelsong6/spire-lens-mcp/pull/7)) — Drop the hardcoded encounter default from `BuildValidationCapabilities`; replace with guidance text directing callers to use `list_encounters`. Also fix the bundled-save fallback path so `_known_save_encounter_ids` returns real ids on a fresh runner. - **[spirelens@2e54619](https://github.com/nelsong6/spirelens/commit/2e54619)** ([PR #166](https://github.com/nelsong6/spirelens/pull/166)) — Test-plan prompt now treats `next_normal_encounter` as optional (default null); only specify when the relic/card behavior under test depends on which encounter is fought. - **[spire-lens-mcp@6bc6034](https://github.com/nelsong6/spire-lens-mcp/commit/6bc6034)** ([PR #1](https://github.com/nelsong6/spire-lens-mcp/pull/1)) — Manifest id rename `SpireLensMcp → SpireLensMcpBridge`, log strings updated. - **[spire-lens-mcp@7546b18](https://github.com/nelsong6/spire-lens-mcp/commit/7546b18)** ([PR #9](https://github.com/nelsong6/spire-lens-mcp/pull/9)) — Completed the bridge rename: csproj, sln, build.ps1 paths, README, docs. Build now produces `out/SpireLensMcpBridge/SpireLensMcpBridge.dll` so the consumer-side basename matches the manifest id. - **[spirelens@3e2d71a](https://github.com/nelsong6/spirelens/commit/3e2d71a)** ([PR #168](https://github.com/nelsong6/spirelens/pull/168)) — Omnibus thoroughness pass: deploy paths follow rename + stale-file cleanup; per-id `scenario_id_validation` prompt tightening; StrictMode 2.0→3.0 ratchet (verified empirically — V3 only adds out-of-bounds array indexing on PS 7.4, which we confirmed all existing patterns pass); Pester tests for the JSONL parsers (43 tests, AST-extracts function definitions from production scripts so they stay in lockstep); `.github/workflows/ps-quality.yml` running PSScriptAnalyzer (Error severity gate) + Pester on PRs touching `.github/scripts/**`. ## Arc 3 — Expected-value contracts on screenshot evidence The verification contract was previously: "screenshot exists, target_visible, text_visible, observed_text non-empty." That accepted the agent's misread of `vigor gained: 88` as `vigor gained: 8` because the contract didn't compare observed against an expected literal. - **[spirelens@f8115de](https://github.com/nelsong6/spirelens/commit/f8115de)** ([PR #171](https://github.com/nelsong6/spirelens/pull/171)) — Verification phase now produces a plain-English `## Test Process` section in `issue-agent-verification.md` for every step of the validation plan (what was done, what it was supposed to prove with expected values, what was actually observed). Required even on pass — its purpose is to support reviewer comparison after a PR exists. - **[spirelens@e00f5ff](https://github.com/nelsong6/spirelens/commit/e00f5ff)** ([PR #172](https://github.com/nelsong6/spirelens/pull/172)) — Schema: `required_evidence` items with `text_visible_required:true` must declare a literal `expected_text` field. Test-plan prompt forbids loose phrasings ("non-zero", "≥ N", "at minimum N") and requires the value to be derived from `scenario_setup × validation_plan` (one-combat-start of Akabeko ⇒ `vigor gained: 8`). Wrapper compares `observed_text` against `expected_text` with a word-boundary-aware regex (so `vigor gained: 8` does NOT match `vigor gained: 88` as a prefix substring) and aborts with `claimed_result_not_observed` on mismatch. Verification prompt requires copying *literal screenshot characters* into `observed_text`, not paraphrased; abort with `target_evidence_missing` if illegible. 9 new Pester tests cover the digit-prefix failure mode + start/end/middle anchoring. - **[spirelens@d58bcb2](https://github.com/nelsong6/spirelens/commit/d58bcb2)** ([PR #169](https://github.com/nelsong6/spirelens/pull/169)) — Reverted the `ConvertTo-Array` comma-operator regression that PR #168 introduced (broke pipe forms). 53/53 Pester now passing. ## Arc 4 — End-to-end validation against issue #142 Re-triggered the issue-agent on issue #142 (Akabeko relic stats) at every milestone; the run history is itself a story. | Run | Commit | Outcome | What it proved | |---|---|---|---| | 25153953835 | 35d3cda | abort: `.Count` post-test_plan | First end-to-end run with new scripts; surfaced that more `.Count` patterns needed `@()` wrap | | 25154511916 | 82882f7 | abort: `verification_reason=` (empty) | Surfaced the terminal-gate masking bug; `materialize_only` died on FUZZY_WURM | | 25170444144 | 4cb3d25 | abort: `.Count` post-verification | Verification passed and produced evidence (`vigor gained: 80` per agent's own claim, actually 88 in the screenshot); next surface area for `.Count` exposed | | 25171327395 | 292a33a | abort: scenario_id_validation contract | Comma-operator regression broke the pipe form | | 25173504069 | 292a33a | abort: scenario_id_validation, BASH | Confirmed regression independent of run | | 25174359513 | d58bcb2 | **PASS** end-to-end | First issue-agent run to produce a real PR ([PR #170](https://github.com/nelsong6/spirelens/pull/170)); SpireLens stat tooltip showed `vigor gained: 88` (silently accepted because contract was loose) | | 25178505492 | e00f5ff | abort: `claimed_result_not_observed` | New `expected_text` contract caught the silent misread; agent honestly wrote `observed_text="vigor gained: 88"`, wrapper aborted | | 25182719661 | e00f5ff | abort: `claimed_result_not_observed` | Reproducible. Agent proposed alternate diagnosis (cross-session persistence) which evidence ruled out — value stayed at 88 across runs, would have grown if accumulator were persisting | Net: PR #170 has a real implementation bug (Akabeko postfix fires more than once per combat → 88 instead of 8). The new contract correctly aborts on it. The bug itself is unfixed pending a follow-up. ## Architecture and design captures Filed for future work, not implemented in this session: - **[spirelens#173 — PR-comment-driven agent revisions](https://github.com/nelsong6/spirelens/issues/173)** — Design for `/agent revise <feedback>` slash-command on PRs. ~2 days MVP / ~8 days full feature. Includes triage phase, delta-mode planning, per-PR serialization, budget caps, threaded reactions. - **[spirelens#174 — Verification-failure self-correction loop](https://github.com/nelsong6/spirelens/issues/174)** — Design for the agent self-correcting when its own verification fails (the more foundational of the two; without it, every fixable failure escalates to a human). ~2 days MVP / ~7 days full. Today's `retryable: true` field already partitions failures correctly; what's missing is the loop control + prior-attempt-aware prompts. - **[glimmung#15 — Architecture proposal: Glimmung as orchestrator, GH Actions as executor](https://github.com/nelsong6/glimmung/issues/15)** — First sketch of moving orchestration out of GH Actions yaml and into glimmung as real code. Phased migration plan. - **[glimmung#17 — META: Glimmung as the canonical agentic-workflow system](https://github.com/nelsong6/glimmung/issues/17)** — The umbrella. 9 workstreams (orchestration core, result surface UI, storage, GH integration, auth, observability, annotation/replay, multi-project extensibility, ops), 7-sprint sequencing path that ships value at every boundary, operating principles, explicit non-goals, risk register. Includes an addendum: GitHub is *not* source of truth — issues become a shallow-copy intake that gets closed when glimmung consumes them; all routing/state/UI lives in glimmung. The thread connecting #173, #174, and glimmung#17: every loop-control feature we want (self-correction, comment-revise, cost ceilings, per-issue state) is fighting yaml inside GitHub Actions and natural in a real orchestrator. Long-term, the orchestration logic moves to glimmung. ## Diagnostic issues closed - **[spire-lens-mcp#8](https://github.com/nelsong6/spire-lens-mcp/issues/8)** — closed; resolved by [PR #7](https://github.com/nelsong6/spire-lens-mcp/pull/7) (FUZZY_WURM hardcoded default). ## Operational artifacts produced - 53/53 Pester tests across `Helpers.psm1`, `Phases.Tests.ps1`, `Summarize.Tests.ps1`, `EvidenceGuard.Tests.ps1`. All pass on pwsh 7.4. - `.github/workflows/ps-quality.yml` running PSScriptAnalyzer (Error gate) + Pester on PRs touching scripts. - Empirical proof of `Set-StrictMode -Version 2.0 vs 3.0` differences on PS 7.4 (V3 only adds OOB array indexing — captured in commit message + StrictMode comment). - Empirical proof of `return ,$x` vs `return @($x)` semantics through assign vs pipe. Captured in `ConvertTo-Array` comments + test fixtures so the next person doesn't repeat the regression. ## Unfinished work - **Akabeko 11×-fire bug in [PR #170](https://github.com/nelsong6/spirelens/pull/170).** Diagnosed: `RecordAkabekoVigorGained` is invoked multiple times per combat-start because the Harmony patch is hooking `Akabeko.BeforeSideTurnStart` and the original method is called more than once during combat-init sequencing (or via base-class inheritance — exact root cause needs game-source inspection). Suggested fix: `agg.VigorGained = Math.Max(agg.VigorGained, amount)` instead of `+=`, making the per-combat aggregate idempotent under N postfix fires. Not landed. - **TODO child issues for glimmung#17 workstreams W2 / W3 / W6 / W7 / W9.** Listed in the meta but not yet broken out into per-workstream issues. - **`spire-lens-mcp` C# namespace cleanup** (`SpireLens.Mcp` namespace name still references the old fork identity). Documented as out-of-scope on glimmung#15. ## Closing this issue This is a session log, not a tracking issue — closing immediately. The unfinished work above lives in its own follow-up issues; this is just the historical record.
Sign in to join this conversation.
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#175
No description provided.