Repository navigation
[duplicate-code] refactor: share repeated harness output pattern matchers - #75757
Conversation
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Specification Reviewer completed successfully! PR Specification ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Design Decision Gate 🏗️Outcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
There was a problem hiding this comment.
Reviewed the changed harness matcher refactor and its export path. The shared helper is correctly re-exported through harness_retry_guard.cjs, regexes are non-global, and the replacements preserve behavior. No actionable correctness, performance, or maintainability issues found in the changed lines. Specialist pass completed; its unverified-export and test-coverage concerns were discarded after checking the existing export and scope.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~2 AIC · ⊞ 1.6K
Comment /review to run again
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified in the supplied evidence, and the refactor preserves the existing provider-specific patterns and exported predicates.
No open issues 🎉
What changed in this PR
This pull request removes duplicated output-pattern predicate wrappers from the Claude, Codex, and Copilot harnesses by centralizing matcher construction while preserving existing classification behavior.
Changes:
- Added and exported
createOutputPatternMatcher. - Replaced six duplicated predicate implementations across the three harnesses.
- Preserved provider-specific regular expressions and exported predicate names.
- No workflow lock files were changed.
| File | Description |
|---|---|
actions/setup/js/harness_error_patterns.cjs |
Defines and exports the shared output-pattern matcher factory. |
actions/setup/js/copilot_harness.cjs |
Uses the shared matcher for connection-refused detection. |
actions/setup/js/codex_harness.cjs |
Uses the shared matcher for rate-limit and invalid-model detection. |
actions/setup/js/claude_harness.cjs |
Uses the shared matcher for rate-limit, connection-refused, and invalid-model detection. |
Review effort: Lite (auto)
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /codebase-design and /tdd. Approving: the refactor preserves every classification rule, and the one note left is low severity.
📋 Key Themes & Highlights
Verified
- ✅ Each pattern constant is declared before its
createOutputPatternMatcher(...)call, so theconstis not used before initialization. All call sites are inside function bodies. - ✅
harness_retry_guard.cjsspreads...errorPatterns, so the re-export reaches all three harnesses. - ✅
node --checkpasses on all changed files. Plain-Node smoke loads of the three harnesses return the expected classifications. - ✅ No test mocks these modules, and no test relies on the old wrapper function
.name. - ✅ The invalid-model pattern is non-global, so the stateful
lastIndexhazard does not apply to any current caller.
Notes
- [/codebase-design] Low: the helper is stateful for
/gand/ypatterns. See the inline comment onharness_error_patterns.cjs. Optional guard or JSDoc note. - [/tdd] No direct unit test covers
createOutputPatternMatcher. A one-case test inharness_retry_guard.test.cjswould lock the contract in, though the harness suites already exercise each predicate indirectly. - The
.nameof the returned matcher is now empty. Nothing in the repo reads it, so this is safe. - I could not run the vitest suites:
npm cifails here withDEPTH_ZERO_SELF_SIGNED_CERT, the same blocker the PR notes. CI should run them; the approval assumes they pass.
@copilot please address the low-severity inline note if you agree with it.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~4 AIC · ⌖ ~2 AIC · ⊞ 5.4K
Comment /matt to run again
| * @returns {(output: string) => boolean} | ||
| */ | ||
| function createOutputPatternMatcher(pattern) { | ||
| return output => pattern.test(output); |
There was a problem hiding this comment.
[/codebase-design] Low severity: pattern.test is stateful for /g and /y regexes, because lastIndex carries across calls. A future global pattern passed here would alternate between true and false. The old per-function wrappers had the same property, so this is not a regression, and all three current patterns are non-global (MODEL_NOT_SUPPORTED_PATTERN only has the i flag).
💡 Optional guard
function createOutputPatternMatcher(pattern) {
return output => {
pattern.lastIndex = 0;
return pattern.test(output);
};
}Alternatively, add a JSDoc line stating the pattern must be non-global.
@copilot please address this.
|
Copilot assignment requested for the following outstanding work:
Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI. Sous-chef requested-head: 93b9fde
|
Co-authored-by: gh-aw-bot <[email protected]>
…ss-output-matchers-567820cd9e96f148 Co-authored-by: gh-aw-bot <[email protected]>
|
🎉 This pull request is included in a new release. Release: |
🔍 Duplicate Code Detected: Harness output-pattern predicates
Analysis of recent Go and CommonJS commits using Serena semantic analysis.
Summary
Recent harness changes left the same three-line regex-predicate wrapper duplicated across the Claude, Codex, and Copilot runtimes. The duplicate pattern appeared six times across three harness files, exceeding the requested threshold and creating parallel maintenance points for shared classification behavior.
Duplication Details
Pattern:
return PATTERN.test(output)wrappersactions/setup/js/claude_harness.cjs:isRateLimitError,isConnectionRefusedError, andisInvalidModelErroractions/setup/js/codex_harness.cjs:isRateLimitErrorandisInvalidModelErroractions/setup/js/copilot_harness.cjs:isConnectionRefusedErrorPATTERN.test(output), for 18 duplicated wrapper-body lines in total. The provider-specific regular expressions remain intentionally distinct.Impact Analysis
Implemented Refactoring
createOutputPatternMatchertoactions/setup/js/harness_error_patterns.cjs.harness_retry_guard.cjs, preserving the existing harness import boundary.Validation
node --checkpassed for all four changed CommonJS files.git diff --checkpassed.make fmt-cjsandmake lint-cjscould not run to completion because the workspace has no local Prettier binary andnpxwas blocked byDEPTH_ZERO_SELF_SIGNED_CERTwhile requestingregistry.npmjs.org.claude_harness.test.cjs,codex_harness.test.cjs, andcopilot_harness.test.cjscould not start becausevitestis not installed in the workspace. No Vitest results are being claimed.Analysis Metadata
119c1ef(documentation-only),dd9fca5(harness deduplication),dc2578f(runtime/Go fixes),1f4083e(MCP validation), andb5d8d79(run artifact processor split)..go/.cjsfiles from the recent commits, with primary focus onpkg/and the three harness runtimes.References
dd9fca59249a92276cfa006ce728d70605bcc576— Deduplicate JavaScript harness prompt and permission handlingb5d8d79195f2849420262cef75a43fb1c8cc0984— Split run artifact processor into focused files