Repository navigation
Fix compare validation safety followups - #462
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR adds configurable validation timeouts for native-agent "implement" compare runs, enforces prerelease-only README doc links to target ChangesValidation Timeout and Release Hygiene Enhancements
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
.github/scripts/verify-release-hygiene.mjs (2)
13-16: 💤 Low valueConsider adding a comment explaining "next-only" paths.
The
NEXT_ONLY_README_PATHSallowlist would benefit from a brief comment explaining what makes these paths "next-only" (e.g., documentation that only exists or is only accurate on thenextbranch for prereleases).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/scripts/verify-release-hygiene.mjs around lines 13 - 16, Add a brief comment above the NEXT_ONLY_README_PATHS Set explaining that these are readme files that exist or are only accurate on the "next" branch (used for prerelease builds), why they are allowlisted (to avoid hygiene failures when running verify-release-hygiene on non-main branches), and give one-sentence examples (e.g., docs that reference upcoming features or enterprise offers only present on next). Reference the symbol NEXT_ONLY_README_PATHS and place the comment immediately above its declaration.
57-61: ⚡ Quick winImprove error message to show invalid links.
When the assertion fails, developers would benefit from seeing which specific links are invalid and what branch they're pointing to instead of just knowing that "next-only README doc links must target blob/next."
🔍 Proposed enhancement
- assert.deepEqual( - invalidTargets, - [], - 'next-only README doc links must target blob/next for prereleases', - ) + assert.deepEqual( + invalidTargets, + [], + `next-only README doc links must target blob/next for prereleases. Invalid links: ${invalidTargets.join(', ')}`, + )🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/scripts/verify-release-hygiene.mjs around lines 57 - 61, The assertion on invalidTargets using assert.deepEqual currently provides only a static message; update the failure output to include the actual invalidTargets details so devs can see which links and branches are wrong. Change the assertion around invalidTargets (the assert.deepEqual call) to include the invalidTargets data in the error string (e.g., serialize invalidTargets with JSON.stringify or util.inspect) or replace the assert with a conditional throw that constructs a message containing the descriptive text plus the serialized invalidTargets for easier debugging.tests/unit/release-hygiene.test.ts (1)
136-149: 💤 Low valueConsider adding explicit positive test case.
The test validates that incorrect next-only links are rejected, but there's no explicit test showing that a prerelease with correct
blob/nextlinks for next-only docs passes validation. While the test at line 88-100 implicitly covers this by running verification on the actual codebase, an explicit positive test case would make the coverage more obvious.📝 Example test case
it('accepts next-only README doc links that target next for prereleases', () => { withReleaseReadmeFixture( '0.27.7-next.0', [ '[release notes](https://github.com/mohanagy/madar/blob/next/CHANGELOG.md#0277-next0---2026-05-29)', '[enterprise offer](https://github.com/mohanagy/madar/blob/next/docs/team-enterprise-offer.md)', '[telemetry](https://github.com/mohanagy/madar/blob/next/docs/telemetry.md)', '', ].join('\n'), (runVerify) => { expect(runVerify).not.toThrow() }, ) })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/release-hygiene.test.ts` around lines 136 - 149, Add an explicit positive test that verifies prerelease READMEs with next-only links pointing to blob/next pass validation: create a new it(...) using withReleaseReadmeFixture with a prerelease version like '0.27.7-next.0', provide README lines where next-only doc links use 'https://.../blob/next/...' (e.g. CHANGELOG and docs paths), and assert expect(runVerify).not.toThrow(); this mirrors the failing test but ensures correct next-targeted links in the withReleaseReadmeFixture/runVerify flow are accepted.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/infrastructure/compare.ts`:
- Around line 3007-3016: runImplementationValidationCommands currently awaits
runShellCommand with an AbortController but can hang if the child
process/descendants don't close promptly; change it to enforce a hard bound like
runNativeAgentArmWithTimeout by wrapping the await in a bounded Promise.race (or
move the logic into runShellCommand) that races the runShellCommand promise
against a timeout promise that resolves/rejects after timeoutMs + optional
grace, calls controller.abort(), and ensures proper cleanup (clearTimeout, kill
child if needed) so the validation path always resolves when timeoutMs elapses;
reference runImplementationValidationCommands, runShellCommand,
runNativeAgentArmWithTimeout, timeoutMs, controller/AbortController and
timeoutHandle when locating where to add the bounded race and cleanup.
In `@src/shared/shell.ts`:
- Around line 2-5: The win32 branch of shellEscape is already using
PowerShell-style single-quote escaping but the code and/or tests imply cmd.exe;
update the implementation and surrounding comment in the shellEscape function so
it explicitly documents and preserves PowerShell-style escaping for Windows
(keep the platform === 'win32' branch that returns the value with doubled single
quotes), and ensure call sites that spawn commands on Windows (which use
powershell.exe -NoProfile -Command with spawn(..., { shell: false })) are
documented to require this PowerShell escaping; reference the shellEscape
function and the platform === 'win32' branch when making the change.
---
Nitpick comments:
In @.github/scripts/verify-release-hygiene.mjs:
- Around line 13-16: Add a brief comment above the NEXT_ONLY_README_PATHS Set
explaining that these are readme files that exist or are only accurate on the
"next" branch (used for prerelease builds), why they are allowlisted (to avoid
hygiene failures when running verify-release-hygiene on non-main branches), and
give one-sentence examples (e.g., docs that reference upcoming features or
enterprise offers only present on next). Reference the symbol
NEXT_ONLY_README_PATHS and place the comment immediately above its declaration.
- Around line 57-61: The assertion on invalidTargets using assert.deepEqual
currently provides only a static message; update the failure output to include
the actual invalidTargets details so devs can see which links and branches are
wrong. Change the assertion around invalidTargets (the assert.deepEqual call) to
include the invalidTargets data in the error string (e.g., serialize
invalidTargets with JSON.stringify or util.inspect) or replace the assert with a
conditional throw that constructs a message containing the descriptive text plus
the serialized invalidTargets for easier debugging.
In `@tests/unit/release-hygiene.test.ts`:
- Around line 136-149: Add an explicit positive test that verifies prerelease
READMEs with next-only links pointing to blob/next pass validation: create a new
it(...) using withReleaseReadmeFixture with a prerelease version like
'0.27.7-next.0', provide README lines where next-only doc links use
'https://.../blob/next/...' (e.g. CHANGELOG and docs paths), and assert
expect(runVerify).not.toThrow(); this mirrors the failing test but ensures
correct next-targeted links in the withReleaseReadmeFixture/runVerify flow are
accepted.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: cee63cd9-0f0c-4dda-a4d9-4ac231a387b2
📒 Files selected for processing (11)
.github/scripts/verify-release-hygiene.mjsREADME.mdsrc/cli/main.tssrc/cli/parser.tssrc/infrastructure/compare.tssrc/runtime/implementation-pack.tssrc/shared/shell.tstests/unit/cli.test.tstests/unit/compare-native-agent.test.tstests/unit/implementation-pack.test.tstests/unit/release-hygiene.test.ts
| const controller = new AbortController() | ||
| const timeoutHandle = setTimeout(() => { | ||
| controller.abort() | ||
| }, timeoutMs) | ||
| let execution: { exitCode: number; stdout: string; stderr: string } | ||
| try { | ||
| execution = await runShellCommand(command, { cwd: workspaceRoot, signal: controller.signal }) | ||
| } finally { | ||
| clearTimeout(timeoutHandle) | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Show the validation timeout path and the already-bounded native-agent arm timeout path side by side.
sed -n '2948,3038p' src/infrastructure/compare.ts
printf '\n---\n'
sed -n '3499,3567p' src/infrastructure/compare.tsRepository: mohanagy/madar
Length of output: 5080
Make the validation timeout truly bounded in runImplementationValidationCommands.
runImplementationValidationCommands aborts after timeoutMs, but it still awaits runShellCommand(...). In runShellCommand, the abort handler only does child.kill() and the promise resolves only on child.on('close'), so if the shell/descendants don’t close pipes promptly, the await can hang past --validation-timeout. Wrap runShellCommand with the same kind of bounded Promise.race/grace approach used by runNativeAgentArmWithTimeout (or move the bound into runShellCommand) so the validation path resolves/times out even if the process doesn’t settle quickly.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/infrastructure/compare.ts` around lines 3007 - 3016,
runImplementationValidationCommands currently awaits runShellCommand with an
AbortController but can hang if the child process/descendants don't close
promptly; change it to enforce a hard bound like runNativeAgentArmWithTimeout by
wrapping the await in a bounded Promise.race (or move the logic into
runShellCommand) that races the runShellCommand promise against a timeout
promise that resolves/rejects after timeoutMs + optional grace, calls
controller.abort(), and ensures proper cleanup (clearTimeout, kill child if
needed) so the validation path always resolves when timeoutMs elapses; reference
runImplementationValidationCommands, runShellCommand,
runNativeAgentArmWithTimeout, timeoutMs, controller/AbortController and
timeoutHandle when locating where to add the bounded race and cleanup.
| if (platform === 'win32') { | ||
| return `'${value.replaceAll("'", "''")}'` | ||
| } | ||
| return `'${value.replaceAll("'", `'\"'\"'`)}'` |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Locate all usages of shell escaping helpers
rg -n --type=ts -C3 '\bshellEscape(IfNeeded)?\b' src
# 2) Locate process execution callsites
rg -n --type=ts -C4 '\b(exec|execFile|spawn)\s*\(' src
# 3) Confirm whether shell mode is enabled and which shell is configured
rg -n --type=ts -C4 'shell\s*:' srcRepository: mohanagy/madar
Length of output: 11834
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find any cmd.exe usage
rg -n --type=ts 'cmd\.exe' src
# Show how shellEscape is consumed (compare + implementation-pack)
rg -n --type=ts 'shellEscapeIfNeeded|shellEscape\(' src/infrastructure/compare.ts src/runtime/implementation-pack.ts src/infrastructure/review-compare.ts src/shared/shell.ts
# Inspect the Windows execution branches near the earlier spawn callsites
sed -n '220,280p' src/infrastructure/review-compare.ts
sed -n '360,460p' src/infrastructure/compare.ts
sed -n '2890,2990p' src/infrastructure/compare.ts
sed -n '1310,1375p' src/runtime/implementation-pack.tsRepository: mohanagy/madar
Length of output: 40
🏁 Script executed:
#!/bin/bash
set -euo pipefail
ls -la src/infrastructure src/runtime src/shared || true
ls -la src/infrastructure | head
# Find any cmd.exe usage
rg -n --type=ts 'cmd\.exe' src || true
# Show how shellEscape is consumed
rg -n --type=ts 'shellEscapeIfNeeded|shellEscape\(' \
src/infrastructure/compare.ts src/runtime/implementation-pack.ts src/infrastructure/review-compare.ts src/shared/shell.ts || true
# Print relevant Windows execution branches (bounded reads)
if [ -f src/infrastructure/review-compare.ts ]; then
nl -ba src/infrastructure/review-compare.ts | sed -n '200,280p'
fi
if [ -f src/infrastructure/compare.ts ]; then
nl -ba src/infrastructure/compare.ts | sed -n '280,460p'
nl -ba src/infrastructure/compare.ts | sed -n '2890,3020p'
fi
if [ -f src/runtime/implementation-pack.ts ]; then
nl -ba src/runtime/implementation-pack.ts | sed -n '1290,1385p'
fiRepository: mohanagy/madar
Length of output: 7223
Fix Windows quoting concern in shellEscape: it’s PowerShell, not cmd.exe.
The win32 branch in src/shared/shell.ts returns PowerShell-style single-quoted strings ('...' with doubled '), and the call sites on Windows execute commands via powershell.exe -NoProfile -Command ... with spawn(..., { shell: false }) (not cmd.exe). So single-quote escaping here is appropriate for the actual execution shell.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/shared/shell.ts` around lines 2 - 5, The win32 branch of shellEscape is
already using PowerShell-style single-quote escaping but the code and/or tests
imply cmd.exe; update the implementation and surrounding comment in the
shellEscape function so it explicitly documents and preserves PowerShell-style
escaping for Windows (keep the platform === 'win32' branch that returns the
value with doubled single quotes), and ensure call sites that spawn commands on
Windows (which use powershell.exe -NoProfile -Command with spawn(..., { shell:
false })) are documented to require this PowerShell escaping; reference the
shellEscape function and the platform === 'win32' branch when making the change.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary\n- disclose native-agent implement validation work in compare warnings and add a dedicated validation timeout\n- bound post-run validation commands and harden targeted test-path command construction\n- fix prerelease README next-only links and extend release hygiene coverage\n\n## Testing\n- npm run release:verify\n- npm run typecheck\n- npm run build\n- CI=1 npm run test:run
Summary by CodeRabbit
New Features
--validation-timeoutCLI option for compare (default 120s); warnings surface timeout info when relevantBug Fixes
-are properly escaped/prefixed to avoid misinterpretationDocumentation
Tests