Skip to content

fix(bench): repair benchmark workflow broken by TypeScript migration#612

Merged
carlos-alm merged 4 commits intomainfrom
fix/benchmark-ts-migration
Mar 26, 2026
Merged

fix(bench): repair benchmark workflow broken by TypeScript migration#612
carlos-alm merged 4 commits intomainfrom
fix/benchmark-ts-migration

Conversation

@carlos-alm
Copy link
Contributor

Summary

The v3.4.0 benchmark workflow (run #23576682993) failed across all 4 jobs after the TypeScript migration (PR #580). Three issues:

  • node src/cli.js build . — the embedding benchmark's graph-build step hardcoded the old .js path. Fixed to use --strip-types + ts-resolve-loader with src/cli.ts
  • srcImport() resolved .js paths that only exist as .ts — the helper now checks for .ts on disk first, falling back to .js for backwards compatibility
  • 2>/dev/null on benchmark commands — silenced all errors, making the failures invisible. Removed so CI logs show actual errors
  • Stale HuggingFace cache key — referenced src/embeddings/** (pre-migration path), updated to src/domain/search/**

Test plan

  • Merge to main, then trigger benchmark workflow via workflow_dispatch with version: dev to verify all 4 jobs pass
  • Alternatively, re-run the v3.4.0 benchmark after merge by dispatching with version: 3.4.0

The TS migration renamed src/cli.js → src/cli.ts and all src/ files
from .js to .ts, but the benchmark workflow and srcImport helper were
not updated:

- embedding-benchmark "Build graph" step referenced `node src/cli.js`
  which no longer exists — now uses strip-types + ts-resolve-loader
- srcImport() constructed file:// URLs with .js extensions pointing at
  files that only exist as .ts — now checks for .ts on disk first
- HuggingFace cache key referenced stale `src/embeddings/**` path,
  updated to `src/domain/search/**`
- Removed `2>/dev/null` from benchmark runner commands so failures
  produce visible error output in CI logs
@claude
Copy link

claude bot commented Mar 26, 2026

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


PR Review Complete ✅

Reviewing this TypeScript migration fix for the benchmark workflow.

Todo List:

  • Read and analyze changed files
  • Phase 1: Root cause analysis
  • Phase 2: Configuration change detection
  • Phase 3: Test integrity check
  • Phase 4: Code quality review
  • Phase 5: Backlog compliance assessment
  • Provide final rating and recommendation

Root Cause Analysis

Problem Being Solved: Post-TypeScript migration, the v3.4.0 benchmark workflow failed because:

  1. Hardcoded .js CLI path: src/cli.js no longer exists, now src/cli.ts
  2. Import resolution mismatch: Dynamic imports still used .js extensions but actual files are .ts
  3. Error masking: 2>/dev/null redirects hid the actual TypeScript execution failures
  4. Stale cache key: Referenced old src/embeddings/** instead of new src/domain/search/**

Why This Approach: ✅ Justified. The fixes directly address the root causes without introducing workarounds or masking symptoms.

Risk Assessment: ✅ Low Risk. These are targeted fixes that restore broken functionality without introducing new behaviors.

Backlog Compliance

  • Zero-dep: ✅ — No new runtime dependencies added
  • Foundation-aligned: ✅ — Maintains local-first principles, no cloud dependencies
  • Problem-fit: 3 — Infrastructure fix enabling performance monitoring, indirectly supports AI workflow optimization
  • Breaking: No — Pure bugfix, no API or behavior changes
  • Tier: 1 (zero-dep ✓ + foundation-aligned ✓)

Critical Concerns

None. This is a clean, targeted fix for post-migration breakage.

Technical Assessment

Excellent execution:

Smart path resolution (scripts/lib/bench-config.ts:183-202):

  • Intelligent .ts-first, .js-fallback logic handles transition period gracefully
  • Proper pathToFileURL() usage for cross-platform compatibility
  • Clear documentation explaining the TypeScript migration context

Workflow fixes (.github/workflows/benchmark.yml):

  • Line 234: Cache key updated from src/embeddings/**src/domain/search/**
  • Line 241: CLI execution updated from src/cli.jssrc/cli.ts with proper TypeScript loader
  • Error visibility: Removed 2>/dev/null redirects so CI shows actual failures

Quality highlights:

  • ✅ No configuration rules relaxed or thresholds lowered
  • ✅ No test integrity compromised
  • ✅ Addresses root causes, not symptoms
  • ✅ Maintains backward compatibility in npm mode

Minor optimization note: srcImport() does runtime filesystem checks on every call, adding I/O overhead. However, this only affects benchmark scripts (not production), so the impact is negligible.

Final Recommendation

  • Rating: ⭐⭐⭐⭐☆ (4/5)
  • Action: APPROVE
  • Reasoning: High-quality fix that directly addresses TypeScript migration breakage. Clean implementation with proper fallbacks, good documentation, and no compromises to quality gates. The approach is exactly what's needed: targeted repairs without introducing technical debt.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 26, 2026

Greptile Summary

This PR repairs the benchmark CI workflow that was broken by the TypeScript migration in PR #580, fixing four distinct issues across the workflow YAML and the shared benchmark config helper.\n\nChanges made:\n\n- 2>/dev/null removal — All four benchmark run: steps were silently swallowing stderr, making failures invisible in CI logs. The redirects are removed so actual errors surface.\n- src/cli.jssrc/cli.ts — The embedding benchmark's "Build graph" step hardcoded the pre-migration .js entry point. It now computes STRIP_FLAG (matching the pattern used in every other job step) and invokes src/cli.ts via ts-resolve-loader.\n- HuggingFace cache path — The hashFiles glob src/embeddings/** was a stale pre-migration path; updated to src/domain/search/** which is confirmed present in the repo.\n- srcImport .ts probe — When dynamic-importing a .js-suffixed path, the helper now checks for a .ts variant on disk first and uses it if found, falling back to .js for npm-published layouts. fs is already imported at the top of the file. TypeScript parameter/return types were also added (follow-up from the prior review thread).\n\nAll fixes are minimal, targeted, and consistent with the existing patterns in the workflow.

Confidence Score: 5/5

Safe to merge — all four fixes are correct, targeted, and consistent with existing workflow patterns.

Every changed line addresses a concrete, confirmed breakage from the failed v3.4.0 benchmark run. The src/domain/search/** glob is verified to resolve real files in the repo, ts-resolve-loader.js exists, fs is already imported for the new existsSync call, and the STRIP_FLAG computation in the new Build graph step is identical to the pattern used elsewhere. No logic regressions or new risks introduced. Prior review concern about missing TypeScript types is addressed.

No files require special attention.

Important Files Changed

Filename Overview
.github/workflows/benchmark.yml Removes 4× 2>/dev/null suppressors, fixes the embedding job's graph-build step to invoke src/cli.ts with strip-types, and updates the HuggingFace cache key to the post-migration path.
scripts/lib/bench-config.ts Adds TypeScript parameter/return types to srcImport and extends it to probe for a .ts variant on disk before falling back to the .js path, enabling dynamic imports to resolve the migrated source files.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[workflow_dispatch] --> B{source = npm?}
    B -- yes --> C[Wait for package on npm registry]
    B -- no --> D[Use local checkout]
    C --> E[Cache HuggingFace models hashFiles src/domain/search/**]
    D --> E
    E --> F[Build graph node --strip-types ts-resolve-loader src/cli.ts build .]
    F --> G[Run embedding benchmark stderr now visible in CI]
    G --> H[Upload result artifact]

    subgraph srcImport resolution
        P[srcImport srcDir foo.js] --> Q{foo.ts exists on disk?}
        Q -- yes --> R[return file URL for foo.ts]
        Q -- no --> S[return file URL for foo.js]
    end
Loading

Reviews (3): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile

Comment on lines 195 to 202
export function srcImport(srcDir, file) {
return pathToFileURL(path.join(srcDir, file)).href;
const full = path.join(srcDir, file);
if (file.endsWith('.js')) {
const tsVariant = full.replace(/\.js$/, '.ts');
if (fs.existsSync(tsVariant)) return pathToFileURL(tsVariant).href;
}
return pathToFileURL(full).href;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

P2 Missing TypeScript parameter types

srcImport is in a .ts file but its parameters are untyped. The JSDoc annotations provide documentation but don't give the compiler any enforcement. Consider adding explicit types:

Suggested change
export function srcImport(srcDir, file) {
return pathToFileURL(path.join(srcDir, file)).href;
const full = path.join(srcDir, file);
if (file.endsWith('.js')) {
const tsVariant = full.replace(/\.js$/, '.ts');
if (fs.existsSync(tsVariant)) return pathToFileURL(tsVariant).href;
}
return pathToFileURL(full).href;
}
export function srcImport(srcDir: string, file: string): string {
const full = path.join(srcDir, file);
if (file.endsWith('.js')) {
const tsVariant = full.replace(/\.js$/, '.ts');
if (fs.existsSync(tsVariant)) return pathToFileURL(tsVariant).href;
}
return pathToFileURL(full).href;
}

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed — added explicit TypeScript parameter types (srcDir: string, file: string) and return type (: string) to srcImport.

@carlos-alm
Copy link
Contributor Author

CI failure analysis: The test failure in tests/engines/ast-parity.test.ts:216 ("JS: native calls match legacy calls field count" — expected 3 >= 4) is a pre-existing native engine parity bug, not caused by this PR. This PR only modifies scripts/lib/bench-config.ts and .github/workflows/benchmark.yml. The same test passed on PRs #606 and #607 but may have become sensitive to the native addon version shipped with v3.4.0. This needs a separate fix in the native engine (crates/codegraph-core/).

1 similar comment
@carlos-alm
Copy link
Contributor Author

CI failure analysis: The test failure in tests/engines/ast-parity.test.ts:216 ("JS: native calls match legacy calls field count" — expected 3 >= 4) is a pre-existing native engine parity bug, not caused by this PR. This PR only modifies scripts/lib/bench-config.ts and .github/workflows/benchmark.yml. The same test passed on PRs #606 and #607 but may have become sensitive to the native addon version shipped with v3.4.0. This needs a separate fix in the native engine (crates/codegraph-core/).

@carlos-alm
Copy link
Contributor Author

@greptileai

…ation

Impact: 1 functions changed, 2 affected
@carlos-alm
Copy link
Contributor Author

Merged main into the branch to pick up the native engine fix from #618 (fix(native): recurse into await_expression children in walk_ast_nodes). The ast-parity.test.ts test now passes — the CI failure was caused by the branch being behind main, not by this PR's changes.

@greptileai

@carlos-alm carlos-alm merged commit c711c88 into main Mar 26, 2026
12 checks passed
@carlos-alm carlos-alm deleted the fix/benchmark-ts-migration branch March 26, 2026 06:49
@github-actions github-actions bot locked and limited conversation to collaborators Mar 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant