From 462297cd78c1f717466386bae084ac715a3ff9ee Mon Sep 17 00:00:00 2001 From: htafolla Date: Tue, 19 May 2026 14:43:50 -0500 Subject: [PATCH] Codify Test Coverage Expansion pattern --- .strray/inference/prompts/01-researcher.md | 1 - .../Codify-Test-Coverage-Expansion-pattern.md | 10 ++ docs/inference/latest-session.json | 149 +++--------------- .../release-v1.22.66-to-head-2026-05-19.md | 68 ++++++++ src/inference/inference-cycle.ts | 64 +++++++- 5 files changed, 153 insertions(+), 139 deletions(-) create mode 100644 docs/guards/Codify-Test-Coverage-Expansion-pattern.md create mode 100644 docs/reflections/deep/release-v1.22.66-to-head-2026-05-19.md diff --git a/.strray/inference/prompts/01-researcher.md b/.strray/inference/prompts/01-researcher.md index c7705b6c4..fd16efdf2 100644 --- a/.strray/inference/prompts/01-researcher.md +++ b/.strray/inference/prompts/01-researcher.md @@ -173,7 +173,6 @@ Analyze the following data sources to gather insights for inference improvement: - /Users/blaze/dev/stringray/logs/framework/activity-2026-05-11T23-32-16-547Z.log.gz - /Users/blaze/dev/stringray/logs/framework/activity-2026-05-15T14-01-55-740Z.log.gz - /Users/blaze/dev/stringray/logs/framework/activity-report.json -- /Users/blaze/dev/stringray/logs/framework/activity.log - /Users/blaze/dev/stringray/logs/framework/activity.log.orig - /Users/blaze/dev/stringray/logs/framework/framework-activity-2026-03-18T11-30-14-805Z.log.gz - /Users/blaze/dev/stringray/logs/framework/framework-activity-2026-03-18T11-31-42-888Z.log.gz diff --git a/docs/guards/Codify-Test-Coverage-Expansion-pattern.md b/docs/guards/Codify-Test-Coverage-Expansion-pattern.md new file mode 100644 index 000000000..27049c741 --- /dev/null +++ b/docs/guards/Codify-Test-Coverage-Expansion-pattern.md @@ -0,0 +1,10 @@ +# Guard: Codify Test Coverage Expansion pattern + +Test Coverage Expansion detected across 110 sessions (avg confidence: 95%). 7 new test files added. Test-first or test-alongside development — covering new code as it ships. + +## Evidence ++ src/__tests__/e2e/inference-e2e.test.ts ++ src/__tests__/integration/inference-pipeline.test.ts ++ src/__tests__/unit/inference/deploy-verifier.test.ts ++ src/__tests__/unit/inference/inference-accumulator.test.ts ++ src/__tests__/unit/inference/inference-cycle.test.ts \ No newline at end of file diff --git a/docs/inference/latest-session.json b/docs/inference/latest-session.json index 1b666c9ef..34688001a 100644 --- a/docs/inference/latest-session.json +++ b/docs/inference/latest-session.json @@ -1,162 +1,51 @@ { - "sessionId": "session-2026-05-08", - "timestamp": "2026-05-08T00:15:51.647Z", + "sessionId": "session-2026-05-19", + "timestamp": "2026-05-19T19:43:22.696Z", "span": { - "from": "v1.22.46", + "from": "v1.22.66", "to": "HEAD" }, "problems": [ - "Bug: fix: remove unused imports and any type from processor-manager.interfaces.test.ts (processor-test-rules ESLint) (529d3d2)", - "Bug: fix: address all open bugs (#29-32, #34) and prevent noise PRs from inference cycle (c32d711)", - "Bug: fix: remove enforcer references from integration test, add fetch-depth:0 for e2e git tests (deb49f4)", - "Bug: fix: triage and fix all GitHub workflow pipelines (097b48c)", - "Bug: fix: restore package.json, mcp-install.ts, workflows, and govern-reflection.mjs gutted by 84dae31b1 (7417fd6)", - "Bug: fix: add npm audit fix to main CI workflow (84dae31)", - "Bug: fix: run npm audit fix to resolve moderate vulnerabilities (314cc06)", - "Bug: fix: remove duplicate case undefined in mcp-install.ts (lint error) (9b713b9)", - "Bug: fix: make trace-context more robust + fix ESM issues in govern-reflection (e665442)", - "Bug: fix: agent registry cleanup — remove skill-only entries, delete deprecated agents (1cafc3a)", - "Bug: fix: agent export naming + single-architect governance (b5c6100)", - "Bug: fix: complete inference-cycle.ts — all fixes applied. (cef1ecd)", - "Bug: fix: guard inference:run for StringRay internal use only (beefefb)", - "Bug: fix: governance pipeline — force flag, skipDeployVerify default, deploy failure handling (40ae8ae)", - "Bug: fix: increase timeout for processor auto-discovery tests to prevent flaky failures (baae755)", - "Bug: fix: inference processor double-joining absolute path created bogus Users/ dir (a795635)", - "Accumulated dead code: - .opencode/core/activity-logger.d.ts.map", - "Technical debt requiring stability focus" + "Bug: fix: update tests for new resolveFrameworkPaths behavior + deflake inference-e2e (4702109)" ], "approaches": [ - "Extract methods into dedicated files to reduce monolith size", - "Add tests alongside new implementations", - "Delete unused code to reduce maintenance burden", - "Automate version synchronization across config files", - "Structural guard to enforce invariants" + "Declare dependencies explicitly for testability and auto-wiring" ], "wrongTurns": [ - "Approach was reverted — initial direction was wrong", - "Path handling bug: absolute vs relative path confusion", - "Timing issue: test assumptions violated in parallel execution" + "Path handling bug: absolute vs relative path confusion" ], "solutions": [ - "Applied Extract Method pattern (confidence: 95%)", - "Applied Test Coverage Expansion pattern (confidence: 95%)", - "Applied Dead Code Removal pattern (confidence: 90%)", - "Applied Stability Sprint pattern (confidence: 75%)", - "Integration: feat: wire apply phase for real code changes instead of markdown markers (f190318)", - "Integration: feat: add centralized TraceContext + integrate Reflection Governance with ValidatorRegistry (1a79c88)", - "Integration: feat: wire apply phase + researcher double-check for PRs (7bfa4ca)", - "Integration: feat: unify governance — wire WeightedVotingAggregator, expand agents, connect orchestrator (fca44e6)", - "Integration: feat: unify governance — wire WeightedVotingAggregator, expand agents, connect orchestrator (191536d)", - "New tooling: fix: inference processor double-joining absolute path created bogus Users/ dir (a795635)" + "Applied Dependency Injection pattern (confidence: 82%)" ], "reasoningChain": [ { "from": "approach", "to": "solution", - "reasoning": "Extract methods into dedicated files to reduce monolith size → Applied Extract Method pattern (confidence: 95%)" - }, - { - "from": "approach", - "to": "solution", - "reasoning": "Add tests alongside new implementations → Applied Test Coverage Expansion pattern (confidence: 95%)" - }, - { - "from": "approach", - "to": "solution", - "reasoning": "Delete unused code to reduce maintenance burden → Applied Dead Code Removal pattern (confidence: 90%)" - }, - { - "from": "approach", - "to": "solution", - "reasoning": "Automate version synchronization across config files → Applied Stability Sprint pattern (confidence: 75%)" - }, - { - "from": "approach", - "to": "solution", - "reasoning": "Structural guard to enforce invariants → Integration: feat: wire apply phase for real code changes instead of markdown markers (f190318)" - }, - { - "from": "approach", - "to": "wrong_turn", - "reasoning": "Approach was reverted — initial direction was wrong" + "reasoning": "Declare dependencies explicitly for testability and auto-wiring → Applied Dependency Injection pattern (confidence: 82%)" }, { "from": "approach", "to": "wrong_turn", "reasoning": "Path handling bug: absolute vs relative path confusion" - }, - { - "from": "approach", - "to": "wrong_turn", - "reasoning": "Timing issue: test assumptions violated in parallel execution" } ], "patterns": [ { - "name": "Extract Method", - "confidence": 0.95, - "evidence": [ - "1 new files + 4 modified in src/__tests__/integration/", - " + inference-pipeline.test.ts", - " ~ agent-registry-integration.test.ts (-1 lines)", - " ~ codex-enforcement.test.ts (-3 lines)", - " ~ processors.test.ts (-8 lines)", - "1 new files + 3 modified in src/core/", - " + trace-context.ts", - " ~ boot-orchestrator.ts (-1 lines)", - " ~ features-config.ts (-1 lines)", - " ~ framework-logger.ts (-1 lines)", - "1 new files + 13 modified in ./", - " + vitest.config.ts", - " ~ .gitignore (-1 lines)", - " ~ .npmignore (-4 lines)", - " ~ AGENTS-consumer.md (-1 lines)" - ], - "description": "Methods extracted from monolithic modules into dedicated files in the same directory. Classic decomposition pattern: one large file sheds responsibilities into focused modules." - }, - { - "name": "Test Coverage Expansion", - "confidence": 0.95, - "evidence": [ - "+ src/__tests__/e2e/inference-e2e.test.ts", - "+ src/__tests__/integration/inference-pipeline.test.ts", - "+ src/__tests__/unit/inference/deploy-verifier.test.ts", - "+ src/__tests__/unit/inference/inference-accumulator.test.ts", - "+ src/__tests__/unit/inference/inference-cycle.test.ts" - ], - "description": "7 new test files added. Test-first or test-alongside development — covering new code as it ships." - }, - { - "name": "Dead Code Removal", - "confidence": 0.9, - "evidence": [ - "- .opencode/core/activity-logger.d.ts.map", - "- .opencode/core/adaptive-kernel.d.ts.map", - "- .opencode/core/boot-orchestrator.d.ts.map", - "- .opencode/core/boot-phases.d.ts.map", - "- .opencode/core/codex-formatter.d.ts.map", - "... and 1748 more" - ], - "description": "1753 files deleted — unused code eliminated. Reduces maintenance burden, removes misleading signals for new readers." - }, - { - "name": "Stability Sprint", - "confidence": 0.75, + "name": "Dependency Injection", + "confidence": 0.82, "evidence": [ - "1753 files deleted", - "Net 164692 lines removed", - "22 fix-related changes" + "DI container / injection logic" ], - "description": "Focus on removal and fixing over feature addition. Technical debt being paid down — a sign of mature development practice." + "description": "Explicit dependency declarations replacing hardcoded imports. Enables testing with mocks, runtime configuration, and auto-wiring." } ], "metrics": { - "commits": 42, - "filesChanged": 2070, - "insertions": 13145, - "deletions": 177837, - "filesAdded": 56, - "filesDeleted": 1753, - "uniqueDirs": 211 + "commits": 3, + "filesChanged": 10, + "insertions": 437, + "deletions": 10, + "filesAdded": 3, + "filesDeleted": 0, + "uniqueDirs": 6 } } \ No newline at end of file diff --git a/docs/reflections/deep/release-v1.22.66-to-head-2026-05-19.md b/docs/reflections/deep/release-v1.22.66-to-head-2026-05-19.md new file mode 100644 index 000000000..f84c1a521 --- /dev/null +++ b/docs/reflections/deep/release-v1.22.66-to-head-2026-05-19.md @@ -0,0 +1,68 @@ +# Release Reflection: 1.22.66 → HEAD + +**Generated:** 2026-05-19T19:43:22.109Z +**Cadence:** release (since tag v1.22.66) +**Commits examined:** 3 +**Span:** v1.22.66..HEAD + +## Scope + +- **3 commits** with **10 file changes** +- **+426 insertions / -0 deletions** +- **3 files added, 7 modified, 0 deleted** + +## Areas Touched + +- `.opencode/state` (1 files) +- `.strray` (4 files) +- `docs/reflections/deep` (2 files) +- `node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709` (1 files) +- `src/__tests__/e2e` (1 files) +- `src/mcps/config/__tests__` (1 files) + +## Commit Chronicle + +- **docs: add deep journey reflection on Grok CLI MCP stability and publish pipeline fixes** (cba8b87) + 0 files: docs/reflections/deep/grok-mcp-publish-stability-journey-2026-05-19.md + +- **docs: add deep journey reflection on double-dist fix and Dynamo governance pipeline** (c297183) + 1 files: docs/reflections/deep/the-path-to-dynamo-journey-2026-05-19.md + +- **fix: update tests for new resolveFrameworkPaths behavior + deflake inference-e2e** (4702109) + 1 files: .opencode/state/state.json, .strray/codex.json, .strray/config.json, .strray/features.json, .strray/integrations.json +3 more + +## Files Added + +- `.opencode/state/state.json` +- `docs/reflections/deep/grok-mcp-publish-stability-journey-2026-05-19.md` +- `docs/reflections/deep/the-path-to-dynamo-journey-2026-05-19.md` + +## Files Modified + +- `.strray/codex.json` +- `.strray/config.json` +- `.strray/features.json` +- `.strray/integrations.json` +- `node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json` +- `src/__tests__/e2e/inference-e2e.test.ts` +- `src/mcps/config/__tests__/server-config-registry.test.ts` + +## Patterns Observed + +- Bug fixes present — stability improvement + +## Key Decisions + +- Fix: docs: add deep journey reflection on Grok CLI MCP stability and publish pipeline fixes +- Fix: docs: add deep journey reflection on double-dist fix and Dynamo governance pipeline +- Fix: fix: update tests for new resolveFrameworkPaths behavior + deflake inference-e2e + +## Inference Notes + +- Dependency Injection pattern detected [82%]: Explicit dependency declarations replacing hardcoded imports. Enables testing with mocks, runtime configuration, and auto-wiring. (DI container / injection logic) +- Structured inference captured → session-2026-05-19-1779219802696.json +- Registry Pattern: factory/registry changes suggest switch-to-Map refactoring +- Stability sprint: 3/3 commits are fixes — addressing accumulated issues + +--- +*Generated by StorytellingTriggerProcessor — release cadence — 2026-05-19T19:43:22.109Z* \ No newline at end of file diff --git a/src/inference/inference-cycle.ts b/src/inference/inference-cycle.ts index 79d7d92c4..63a19cad1 100644 --- a/src/inference/inference-cycle.ts +++ b/src/inference/inference-cycle.ts @@ -424,8 +424,25 @@ export class InferenceCycle { filesChanged = await this.applyAutomation(p); } + // Critical fix: actually verify the agent made changes before committing + if (filesChanged) { + try { + const status = execSync('git status --porcelain', { cwd: this.projectRoot, encoding: 'utf-8' }).trim(); + if (status.length === 0) { + frameworkLogger.log("inference-cycle", "no-actual-changes-after-agent", "warning", { + proposalId: p.id, + title: p.title, + }); + filesChanged = false; + } + } catch (e) { + frameworkLogger.log("inference-cycle", "change-detection-failed", "warning", { error: String(e) }); + } + } + if (!filesChanged) { - execSync(`git checkout master`, { cwd: this.projectRoot, stdio: "pipe" }); + const defaultBranch = this.getDefaultBranch(); + execSync(`git checkout ${defaultBranch}`, { cwd: this.projectRoot, stdio: "pipe" }); execSync(`git branch -D ${branchName}`, { cwd: this.projectRoot, stdio: "pipe" }); return false; } @@ -441,7 +458,8 @@ export class InferenceCycle { const review = await this.researcherReview(p, prUrl); if (review === "no-go") { frameworkLogger.log("inference-cycle", "researcher-no-go", "warning", { prUrl }); - execSync(`git checkout master`, { cwd: this.projectRoot, stdio: "pipe" }); + const defaultBranch = this.getDefaultBranch(); + execSync(`git checkout ${defaultBranch}`, { cwd: this.projectRoot, stdio: "pipe" }); execSync(`git branch -D ${branchName}`, { cwd: this.projectRoot, stdio: "pipe" }); return false; } else if (review === "modify") { @@ -449,12 +467,14 @@ export class InferenceCycle { } } - execSync(`git checkout master`, { cwd: this.projectRoot, stdio: "pipe" }); + const defaultBranch = this.getDefaultBranch(); + execSync(`git checkout ${defaultBranch}`, { cwd: this.projectRoot, stdio: "pipe" }); return true; } catch (err) { try { - execSync(`git checkout master`, { cwd: this.projectRoot, stdio: "pipe" }); + const db = this.getDefaultBranch(); + execSync(`git checkout ${db}`, { cwd: this.projectRoot, stdio: "pipe" }); execSync(`git branch -D ${branchName}`, { cwd: this.projectRoot, stdio: "pipe" }); } catch { // ignore cleanup errors @@ -489,9 +509,11 @@ export class InferenceCycle { }); try { - let agentName = p.type === "refactor" ? "refactorer" : "code-reviewer"; + // Better agent selection for actual code changes (not review) + let agentName = "refactorer"; + if (p.type === "fix") agentName = "enforcer"; // enforcer often good at targeted fixes - // In pure MCP mode, use real skill server names so the orchestrator dispatches to actual MCP tools + // In pure MCP mode, use real skill servers if (process.env.STRRAY_FORCE_MCP_GOVERNANCE === 'true') { agentName = p.type === "refactor" ? "refactoring-strategies" : "code-review"; } @@ -523,9 +545,10 @@ export class InferenceCycle { ].join("\n"); try { + // Prefer agents that can implement guards const agentName = process.env.STRRAY_FORCE_MCP_GOVERNANCE === 'true' - ? "code-review" - : "code-reviewer"; + ? "enforcer" + : "enforcer"; await this.invokeAgentInternal(agentName, prompt); return true; } catch (err) { @@ -597,6 +620,31 @@ export class InferenceCycle { return [...files]; } + private getDefaultBranch(): string { + try { + const symRef = execSync('git symbolic-ref refs/remotes/origin/HEAD', { + cwd: this.projectRoot, + encoding: 'utf-8', + stdio: 'pipe' + }).trim(); + if (symRef) { + const branch = symRef.replace('refs/remotes/origin/', ''); + if (branch) return branch; + } + } catch {} + + try { + const current = execSync('git branch --show-current', { + cwd: this.projectRoot, + encoding: 'utf-8', + stdio: 'pipe' + }).trim(); + if (['main', 'master', 'develop'].includes(current)) return current; + } catch {} + + return 'main'; + } + private createPR(p: InferenceProposal, branchName: string): string { try { execSync(`git push -u origin ${branchName}`, { cwd: this.projectRoot, stdio: "pipe" });