Skip to content

#29 : Add fixture validation for benchmark workspaces (fail-fast) #30

Open
defender-777 wants to merge 4 commits into
edouardmisset:mainfrom
defender-777:feature/fix-validation
Open

#29 : Add fixture validation for benchmark workspaces (fail-fast) #30
defender-777 wants to merge 4 commits into
edouardmisset:mainfrom
defender-777:feature/fix-validation

Conversation

@defender-777
Copy link
Copy Markdown

@defender-777 defender-777 commented May 4, 2026

This PR introduces fail-fast validation for benchmark fixtures to ensure that all workspaces provide the required fixtures.ts implementation before benchmark execution begins.

The validation prevents silent gaps in benchmark coverage by enforcing consistency across all workspaces.


Changes

1. Fixture Validation System

  • Scans all workspaces at deno task bench startup

  • Verifies existence of fixtures.ts in each workspace

  • Dynamically imports and validates required interface:

    • small()
    • medium()
    • large()
  • Supports both named exports and default export object patterns

2. Fail-Fast Execution

  • Benchmark execution is halted if any workspace is missing fixtures
  • Clear and structured error messages are displayed
  • Exit code is set to non-zero on failure

3. Error Reporting Improvements

  • Lists all affected workspaces
  • Displays expected file paths
  • Specifies missing components (file or functions)
  • Provides clear guidance on required structure

4. Cross-Platform Path Handling Fix

  • Replaced URL.pathname with fromFileUrl() to ensure correct filesystem path resolution
  • Fixed Windows-specific issue causing invalid paths (\C:\...)
  • Ensures compatibility across Windows, Linux, and macOS environments

5. CLI Feedback Enhancements

  • Displays total number of workspaces being validated
  • Improved output formatting for readability and clarity

Example Output

Validating 7 workspace fixtures...

Fixture validation failed!

Found 6 workspaces with missing or invalid fixtures:

Workspace: date
Path: C:\Users\GAGAN\utils\date\fixtures.ts
Missing: fixtures.ts file
Screenshot 2026-05-05 002159_edited ---

Motivation

Previously, benchmark execution could proceed even when some workspaces lacked fixtures, leading to incomplete or misleading benchmark results.

This change enforces consistency and ensures that all workspaces participate in benchmarking, improving reliability and developer confidence.


Scope

Included:

  • Fixture validation logic
  • Cross-platform path fix
  • CLI improvements

Excluded:

  • Automatic fixture generation
  • Benchmark execution logic changes

Testing

  • Verified on Windows environment
  • Confirmed correct detection of missing fixtures
  • Confirmed proper error messaging and fail-fast behavior
  • Validation passes when all workspaces implement required fixtures

Impact

  • No breaking changes to existing functionality
  • Improves reliability of benchmark system
  • Adds strict validation layer before execution

Notes

A screenshot of validation output has been included to demonstrate expected behavior during failure scenarios.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added benchmark infrastructure with fixture validation support
    • New bench command available for running performance benchmarks
  • Chores

    • Implemented internal validation system to ensure benchmark fixtures meet required specifications
    • Added benchmark fixture datasets across supported modules

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Warning

Rate limit exceeded

@defender-777 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 43 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c7134488-71fa-47a7-9081-16f71d4b4743

📥 Commits

Reviewing files that changed from the base of the PR and between 45969a2 and 6ebc21b.

📒 Files selected for processing (3)
  • _internal-tools/bench.ts
  • _internal-tools/validate-fixtures.ts
  • array/fixtures.ts
📝 Walkthrough

Walkthrough

This PR establishes a benchmark fixture validation system for workspaces. It introduces type definitions for fixture factories, implements validation logic that checks each workspace for properly structured fixtures.ts files, and provides a Deno entrypoint that validates all fixtures before benchmark execution. The first workspace fixture (array) is implemented as a reference.

Changes

Benchmark Fixture Validation System

Layer / File(s) Summary
Type Definitions & Configuration
_internal-tools/fixture-types.ts, _internal-tools/deno-config.ts
FixtureFactory interface defines required small(), medium(), large() methods; ROOT_DIRECTORY computation updated to use dirname(fromFileUrl(...)) for correct path resolution.
Fixture Validation Logic
_internal-tools/validate-fixtures.ts
Validates all workspaces by dynamically importing each fixtures.ts, verifying file existence and required exports; aggregates errors and exposes validateAllFixtures() and validateFixturesOrThrow().
Bench Entrypoint
_internal-tools/bench.ts
Async entry point that loads workspace configs, validates fixtures with fail-fast error handling, and logs results; only executes when run directly via import.meta.main.
Concrete Fixtures & Task
array/fixtures.ts, deno.json
First workspace fixture implementation generating arrays of sizes 10, 1000, and 100000; new bench task defined in deno.json with read and network permissions.

Sequence Diagram

sequenceDiagram
    participant User as User
    participant BenchCLI as bench.ts
    participant Config as deno-config
    participant Validator as validate-fixtures
    participant FS as File System
    participant Module as fixtures.ts

    User->>BenchCLI: deno run --allow-read bench.ts
    BenchCLI->>Config: getAllWorkspaceConfigs()
    Config-->>BenchCLI: [workspace configs]
    BenchCLI->>Validator: validateFixturesOrThrow()
    Validator->>Config: ROOT_DIRECTORY
    Config-->>Validator: root path
    loop For each workspace
        Validator->>FS: Check fixtures.ts exists
        FS-->>Validator: file exists?
        Validator->>Module: Dynamic import fixtures.ts
        Module-->>Validator: module or default export
        Validator->>Validator: Verify small, medium, large are functions
    end
    alt All valid
        Validator-->>BenchCLI: Validation success
        BenchCLI-->>User: "All fixtures valid" + benchmark placeholder
    else Validation failed
        Validator-->>BenchCLI: Throw formatted error
        BenchCLI-->>User: Error details + exit(1)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • Issue #29: Directly implements the requested fixture scanning and validation system with clear fail-fast error reporting.
  • Issue #23: Implements the requested FixtureFactory interface and provides the first concrete workspace fixture module.

Poem

🐰 A warren of arrays now has fixtures to measure,
Bench validation confirms each workspace's treasure,
Three sizes—small, medium, large—ready to race,
The system validates before benchmark's pace! 🏃‍♂️

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding fixture validation for benchmark workspaces with fail-fast behavior, which aligns with all file additions and modifications shown in the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 43 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 4, 2026

Not up to standards ⛔

🔴 Issues 1 critical · 1 high

Alerts:

⚠ 2 issues (≤ 1 issue of at least minor severity)

Results:
2 new issues

Category Results
Security 1 critical
1 high

View in Codacy

🟢 Metrics 20 complexity · 0 duplication

Metric Results
Complexity 20
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
array/fixtures.ts (1)

1-25: ⚡ Quick win

Optional: add compile-time FixtureFactory compliance check

There's no type-level binding between this module and the FixtureFactory interface; if new required functions are added to the interface, this file will only fail at runtime (deno task bench) rather than at deno task typecheck. A module-level satisfies assertion catches drift earlier:

✨ Proposed refactor
+import type { FixtureFactory } from '../_internal-tools/fixture-types.ts'
+
+// Compile-time check: ensures this module fully implements FixtureFactory
+const _: FixtureFactory = { small, medium, large }
+void _
+
 export function small(): number[] {
🤖 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 `@array/fixtures.ts` around lines 1 - 25, Add a compile-time check that this
module implements the FixtureFactory interface: import the FixtureFactory type
(type-only) and create a single exported object that bundles the small, medium,
and large functions (e.g. const fixtures = { small, medium, large }) and assert
it satisfies FixtureFactory (using a TypeScript "satisfies" assertion or
explicit typed export). This ensures the module-level symbol (fixtures or the
default export) is checked against FixtureFactory at typecheck time and will
catch missing or renamed functions like small, medium, or large during type
checking.
🤖 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 `@_internal-tools/bench.ts`:
- Around line 8-12: Move the call to getAllWorkspaceConfigs() into the try block
inside main() so any errors thrown by readDenoConfig/getAllWorkspaceConfigs()
are caught by the existing catch handler; specifically, in function main()
remove the top-level await of getAllWorkspaceConfigs() and call it after
entering the try (so the console.log and subsequent logic remain inside the
try), ensuring the catch block handles failures and triggers the existing
console.error + Deno.exit(1) path.
- Around line 10-24: Replace the bare console.* calls in the try/catch block
with globalThis.console.* so they comply with the no-console lint rule;
specifically update the console.log calls that reference workspaces (the
"Validating ...", "All workspace fixtures are valid!", "Benchmark execution
would start here..." and the runner placeholder lines) and the console.error in
the catch that prints errors thrown by validateFixturesOrThrow to use
globalThis.console.log / globalThis.console.error respectively.

---

Nitpick comments:
In `@array/fixtures.ts`:
- Around line 1-25: Add a compile-time check that this module implements the
FixtureFactory interface: import the FixtureFactory type (type-only) and create
a single exported object that bundles the small, medium, and large functions
(e.g. const fixtures = { small, medium, large }) and assert it satisfies
FixtureFactory (using a TypeScript "satisfies" assertion or explicit typed
export). This ensures the module-level symbol (fixtures or the default export)
is checked against FixtureFactory at typecheck time and will catch missing or
renamed functions like small, medium, or large during type checking.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8a1f4fc5-3a74-4f87-8db5-87b8cfae6ae3

📥 Commits

Reviewing files that changed from the base of the PR and between 1ee773b and 45969a2.

📒 Files selected for processing (6)
  • _internal-tools/bench.ts
  • _internal-tools/deno-config.ts
  • _internal-tools/fixture-types.ts
  • _internal-tools/validate-fixtures.ts
  • array/fixtures.ts
  • deno.json

Comment thread _internal-tools/bench.ts
Comment thread _internal-tools/bench.ts Outdated
- restrict dynamic import to file:// URLs
- move async operations inside try block
- comply with no-console lint rule
- improve variable naming and formatting
@defender-777
Copy link
Copy Markdown
Author

Addressed final review feedback:

  • Updated dynamic import to use validated URL.href (cross-platform safe)
  • Removed unnecessary suppression for error propagation
  • Kept minimal changes while improving clarity and safety

Dynamic import suppression is intentional, as the path is restricted to validated local file URLs and does not involve user input.

@defender-777
Copy link
Copy Markdown
Author

Addressed all Codacy and CodeRabbit findings.

  • Dynamic import is restricted to validated file:// URLs and constructed from internal workspace configuration
  • No user-controlled input is involved
  • Error propagation is intentional and handled in bench.ts

The remaining Codacy warnings appear to be false positives due to static analysis limitations on dynamic imports and cross-function error handling.

Happy to adjust further if needed.

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