Skip to content

fix(bench): add timeout and remove redundant stdio option#199

Merged
carlos-alm merged 12 commits intomainfrom
fix/bench-version-minor
Mar 2, 2026
Merged

fix(bench): add timeout and remove redundant stdio option#199
carlos-alm merged 12 commits intomainfrom
fix/bench-version-minor

Conversation

@carlos-alm
Copy link
Contributor

Summary

  • Add 10s timeout to GIT_OPTS in bench-version.js to prevent execFileSync from hanging indefinitely on git operations
  • Remove redundant stdio: ['pipe', 'pipe', 'pipe'] (already the default for execFileSync)

Test plan

  • Verify benchmark workflow still resolves version correctly
  • Confirm git commands respect the 10s timeout

github-actions bot and others added 11 commits February 28, 2026 01:39
The branch-compare command was registered in cli.js and its exports
added to index.js, but the implementation file src/branch-compare.js
was never created. This caused two issues:

1. `codegraph branch-compare` crashed with ERR_MODULE_NOT_FOUND
2. `import('@optave/codegraph')` crashed entirely because index.js
   has a top-level re-export from the missing file, making the
   programmatic API completely unusable

Remove the dead references until an implementation exists.

Closes #166
The branch-compare command was registered in cli.js and index.js but
src/branch-compare.js was never committed — it was lost as untracked
files in the fix/complexity-sql-sanitize worktree. Recovered the full
implementation (568 lines) and integration test (192 lines, 7 tests)
from git object 22c8185.

This restores the cli.js command and index.js exports that were removed
in 746aa65, now that the implementation file exists. Updated the dogfood
report to reflect the recovery (no bugs found, rating 8.5/10).

Closes #166

Impact: 13 functions changed, 4 affected
Dev builds always produced 2.4.1-dev.<sha> because PATCH was hardcoded
to +1 from package.json. Now uses git rev-list to count commits since
the release tag, giving monotonically increasing versions like 2.4.5,
2.4.15, etc.

Benchmark scripts now use getBenchmarkVersion() (via git describe) to
detect dev vs release state, preventing dev runs from overwriting
release benchmark data in historical reports.

Impact: 2 functions changed, 6 affected
The bench-config.js local mode returned 'dev' as the version string.
Now uses getBenchmarkVersion() to derive a proper semver from git state,
so all 4 benchmark scripts that use bench-config get dev-aware versions.

Impact: 1 functions changed, 4 affected
Both now use git describe --tags --match "v*" to find the nearest
release tag and count commits from it. Previously publish.yml
constructed the tag from package.json (v${CURRENT}) while
bench-version.js used git describe, which would diverge if
package.json was bumped but not yet tagged.

Impact: 1 functions changed, 0 affected
When no git tags exist, bench-version.js now produces PATCH+1 (e.g.
"2.5.1-dev") matching publish.yml's fallback, instead of the bare
"2.5.0-dev" which diverged.

Impact: 1 functions changed, 0 affected
Refactor getBenchmarkVersion to use --abbrev=0 + git rev-list (same
as publish.yml) instead of parsing full git describe output. Both
now use identical steps: find tag, count commits, get short SHA.

Impact: 1 functions changed, 0 affected
…om/optave/codegraph into fix/benchmark-all-reports

# Conflicts:
#	.github/workflows/publish.yml

Impact: 3 functions changed, 7 affected
Merges PR #173 (commit-count versioning for dev builds) and fixes a bug
where embedding, query, and incremental benchmark reports were never
persisted. The "Check for changes" step used `git diff` which only
detects modifications to tracked files — newly created report files
(untracked) were invisible, so the PR was never created. Now also checks
for untracked files via `git ls-files --others`.
Add 10s timeout to GIT_OPTS to prevent execFileSync from hanging
on git operations. Remove redundant stdio config (already the default).
@claude
Copy link

claude bot commented Mar 1, 2026

Claude finished @carlos-alm's task —— View job


Reviewing PR: fix(bench): add timeout and remove redundant stdio option

Todo List

  • Read and analyze the changed file (scripts/bench-version.js)
  • Apply Phase 1: Root Cause Analysis
  • Apply Phase 2: Configuration Change Detection
  • Apply Phase 3: Test Integrity Review
  • Apply Phase 4: Code Quality Assessment
  • Provide final assessment and rating

Phase 1: Root Cause Analysis ✅

Problem Being Solved:
The getBenchmarkVersion() function makes multiple execFileSync calls to git commands without a timeout, which could cause benchmark scripts to hang indefinitely if git operations become unresponsive.

Why This Approach:

  • Legitimate fix: Adding timeout: 10_000 (10s) prevents indefinite hangs
  • Consistent with codebase: Other execFileSync calls use similar timeouts (10s standard, 120s for npm, 600s for long ops)
  • Redundant code removal: stdio: ['pipe', 'pipe', 'pipe'] is indeed the default for execFileSync

Phase 2: Configuration Change Detection ✅

Assessment: ✅ NO HIGH-RISK CHANGES

  • No linting rules disabled or relaxed
  • No test configuration changes
  • No build/module resolution modifications
  • No TypeScript strict mode changes
  • biome.json is scoped to src/ and tests/ only; scripts/ changes don't affect linting scope

Phase 3: Test Integrity Review ✅

Assessment: ✅ NO TEST INTEGRITY CONCERNS

  • No test files modified
  • No assertions removed or weakened
  • No getBenchmarkVersion tests found (function has built-in fallback behavior)
  • Change doesn't affect test behavior - it's a defensive timeout addition

Phase 4: Code Quality Assessment ✅

Strengths:

  • Timeout value appropriate: 10s matches other git operations in the codebase (src/config.js:100)
  • Graceful degradation: Existing try/catch blocks handle timeout failures properly (lines 45-47, 56-58)
  • Consistent patterns: Follows established patterns for execFileSync usage in the codebase
  • Minimal surface area: Single-line change reduces risk
  • Documentation alignment: Change aligns with defensive programming practices mentioned in CLAUDE.md

Technical Correctness:

  • timeout: 10_000 is valid execFileSync option
  • ✅ Removing redundant stdio config is technically correct
  • ✅ No breaking changes to function signature or return values

Final Assessment

Root Cause Analysis

Problem Being Solved: Preventing indefinite hangs in benchmark scripts when git operations become unresponsive
Why This Approach: Adds defensive timeout with fallback behavior already in place, removes redundant configuration
Risk Assessment: LOW RISK - defensive change with graceful degradation

Critical Concerns

None identified. This is a straightforward defensive fix that follows established patterns in the codebase.

Final Recommendation

  • Rating: ⭐⭐⭐⭐☆ (4/5)
  • Action: APPROVE
  • Reasoning: Clean, defensive fix that prevents hangs without introducing risk. Follows codebase patterns, handles failures gracefully, and addresses a legitimate operational concern. Only missing the 5th star due to lack of test coverage, but the built-in fallback behavior makes this acceptable.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 1, 2026

Greptile Summary

Added 10-second timeout to git operations in bench-version.js to prevent indefinite hangs, and removed redundant stdio option that was already the default for execFileSync.

  • Timeout applies to all three git operations (describe, rev-list, rev-parse) and is handled gracefully by existing try-catch blocks
  • No behavioral changes other than improved resilience against hanging git commands

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are defensive improvements with no functional side effects. The timeout prevents potential hangs while existing error handling ensures graceful degradation, and removing the redundant stdio option has no impact since it was already the default.
  • No files require special attention

Important Files Changed

Filename Overview
scripts/bench-version.js Added 10s timeout to prevent hanging git operations, removed redundant stdio default

Last reviewed commit: e5a75f4

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

Base automatically changed from fix/benchmark-all-reports to main March 1, 2026 23:57
@claude
Copy link

claude bot commented Mar 2, 2026

Claude finished @carlos-alm's task —— View job


Reviewing PR: fix(bench): add timeout and remove redundant stdio option

Todo List

  • Read and analyze the changed file (scripts/bench-version.js)
  • Apply Phase 1: Root Cause Analysis
  • Apply Phase 2: Configuration Change Detection
  • Apply Phase 3: Test Integrity Review
  • Apply Phase 4: Code Quality Assessment
  • Provide final assessment and rating

Phase 1: Root Cause Analysis ✅

Problem Being Solved:
The getBenchmarkVersion() function makes multiple execFileSync calls to git commands without a timeout, which could cause benchmark scripts to hang indefinitely if git operations become unresponsive.

Why This Approach:

  • Legitimate fix: Adding timeout: 10_000 (10s) prevents indefinite hangs
  • Consistent with codebase: Other execFileSync calls use similar timeouts (10s standard, 120s for npm, 600s for long ops)
  • Redundant code removal: stdio: ['pipe', 'pipe', 'pipe'] is indeed the default for execFileSync

Phase 2: Configuration Change Detection ✅

Assessment: ✅ NO HIGH-RISK CHANGES

  • No linting rules disabled or relaxed
  • No test configuration changes
  • No build/module resolution modifications
  • No TypeScript strict mode changes
  • biome.json is scoped to src/ and tests/ only; scripts/ changes don't affect linting scope

Phase 3: Test Integrity Review ✅

Assessment: ✅ NO TEST INTEGRITY CONCERNS

  • No test files modified
  • No assertions removed or weakened
  • No getBenchmarkVersion tests found (function has built-in fallback behavior)
  • Change doesn't affect test behavior - it's a defensive timeout addition

Phase 4: Code Quality Assessment ✅

Strengths:

  • Timeout value appropriate: 10s matches other git operations in the codebase (src/config.js:100)
  • Graceful degradation: Existing try/catch blocks handle timeout failures properly (lines 45-47, 56-58)
  • Consistent patterns: Follows established patterns for execFileSync usage in the codebase
  • Minimal surface area: Single-line change reduces risk
  • Documentation alignment: Change aligns with defensive programming practices mentioned in CLAUDE.md

Technical Correctness:

  • timeout: 10_000 is valid execFileSync option
  • ✅ Removing redundant stdio config is technically correct
  • ✅ No breaking changes to function signature or return values

Final Assessment

Root Cause Analysis

Problem Being Solved: Preventing indefinite hangs in benchmark scripts when git operations become unresponsive
Why This Approach: Adds defensive timeout with fallback behavior already in place, removes redundant configuration
Risk Assessment: LOW RISK - defensive change with graceful degradation

Critical Concerns

None identified. This is a straightforward defensive fix that follows established patterns in the codebase.

Final Recommendation

  • Rating: ⭐⭐⭐⭐☆ (4/5)
  • Action: APPROVE
  • Reasoning: Clean, defensive fix that prevents hangs without introducing risk. Follows codebase patterns, handles failures gracefully, and addresses a legitimate operational concern. Only missing the 5th star due to lack of test coverage, but the built-in fallback behavior makes this acceptable.

@carlos-alm carlos-alm merged commit 978b590 into main Mar 2, 2026
15 checks passed
@carlos-alm carlos-alm deleted the fix/bench-version-minor branch March 2, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant