From 12538c8791fc76b1d4c1c3ccef49bf5f56f4461b Mon Sep 17 00:00:00 2001 From: htafolla Date: Tue, 19 May 2026 15:04:49 -0500 Subject: [PATCH] Codify Test Coverage Expansion pattern --- .strray/state/state.json | 17 ++++++++++ .../Codify-Test-Coverage-Expansion-pattern.md | 10 ++++++ src/inference/inference-cycle.ts | 34 ++++++++++++++++--- 3 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 .strray/state/state.json create mode 100644 docs/guards/Codify-Test-Coverage-Expansion-pattern.md diff --git a/.strray/state/state.json b/.strray/state/state.json new file mode 100644 index 000000000..ec0e52f9d --- /dev/null +++ b/.strray/state/state.json @@ -0,0 +1,17 @@ +{ + "votingHistory": [], + "metrics": { + "totalVotes": 0, + "successfulVotes": 0, + "failedVotes": 0, + "averageConfidence": 0, + "strategyUsage": { + "majority_vote": 0, + "consensus": 0, + "expert_priority": 0 + }, + "agentParticipation": {}, + "averageVoterTurnout": 0 + }, + "exportedAt": "2026-05-19T19:43:23.601Z" +} \ No newline at end of file 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/src/inference/inference-cycle.ts b/src/inference/inference-cycle.ts index 79d7d92c4..97efac825 100644 --- a/src/inference/inference-cycle.ts +++ b/src/inference/inference-cycle.ts @@ -425,7 +425,8 @@ export class InferenceCycle { } 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 +442,7 @@ 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" }); + execSync(`git checkout ${this.getDefaultBranch()}`, { cwd: this.projectRoot, stdio: "pipe" }); execSync(`git branch -D ${branchName}`, { cwd: this.projectRoot, stdio: "pipe" }); return false; } else if (review === "modify") { @@ -449,12 +450,12 @@ export class InferenceCycle { } } - execSync(`git checkout master`, { cwd: this.projectRoot, stdio: "pipe" }); + execSync(`git checkout ${this.getDefaultBranch()}`, { cwd: this.projectRoot, stdio: "pipe" }); return true; } catch (err) { try { - execSync(`git checkout master`, { cwd: this.projectRoot, stdio: "pipe" }); + execSync(`git checkout ${this.getDefaultBranch()}`, { cwd: this.projectRoot, stdio: "pipe" }); execSync(`git branch -D ${branchName}`, { cwd: this.projectRoot, stdio: "pipe" }); } catch { // ignore cleanup errors @@ -597,6 +598,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" });